Active Topics

 


Reply
Thread Tools
Posts: 113 | Thanked: 67 times | Joined on Jun 2012 @ Yunfu city,Guangdong province,China
#81
how can i launch app with dbus?
__________________
I am sorry for my poor English....
Using N900 in China.
BBS moderator in bbs.dospy.com 's n900 plate.
http://bbs.dospy.com/forum-315-1.html
 
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#82
[edit]Thanks to coderus, at least the solution for my problem (not for setting properties, though) is available a few posts down.[/edit]

Can anyone help me with how to set DBus Properties from QML?
Calling methods works, for example stuff like this:
Code:
    DBusInterface {
        id:dbif
        service: 'org.mpris.MediaPlayer2.jolla-mediaplayer'
        path: '/org/mpris/MediaPlayer2'
        iface: 'org.mpris.MediaPlayer2.Player'
    }
// […]
    dbif.call('Pause', undefined)
But when I tried to adapt the Bluetooth snippet from earlier in this thread, I failed miserably.
One of my ~1000 attempts:

Code:
    DBusInterface {
        id:dbifcon
        bus: DBus.SystemBus
        service: 'net.connman'
        path: '/net/connman/technology/bluetooth'
        iface: 'net.connman.Technology'
    }
// […] 
    dbifcon.setProperty('Powered', false)
I also tried using combinations of different ifaces (org.freedesktop.DBus.Properties) and setProperty, even tried dbifcon.call('setProperty', ['Powered', false]), which from my understanding isn't even supposed to work that way.

But it still won't do a thing. Am I missing something obvious?

The docs of nemo-qml-plugin-dbus only have a big "TODO" where setting Properties are supposed to be explained…
Thanks in advance…

Last edited by velox; 2015-11-11 at 21:09. Reason: solved. thanks!
 

The Following User Says Thank You to velox For This Useful Post:
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#83
^^

It looks like the setting of properties is disabled by default: https://git.merproject.org/mer-core/...rface.cpp#L147

Try this:

Code:
propertiesEnabled: true
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 

The Following User Says Thank You to marxian For This Useful Post:
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#84
Originally Posted by marxian View Post
Try this:

Code:
propertiesEnabled: true
That's interesting, thank you so much!
Sadly, propertiesEnabled does not seem to be exported to the QML layer (or however you'd call that if you knew what you're doing, which I am obviously not).

So there might be no QML-only way to do this?
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#85
It turns out that property introspection was only recently added in this commit: https://git.merproject.org/mer-core/...c7924af7538c2b

So, I suppose you can either drop the code into your project, or wait for the update.
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 

The Following User Says Thank You to marxian For This Useful Post:
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#86
Sounds like a Plan and should not be that hard to do... Thanks again, your input was extremely helpful for me.
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,700 times | Joined on Nov 2011 @ Ängelholm, Sweden
#87
btw, net.connman /net/connman/technology/bluetooth NOT using DBus Properties, SetProperty is it's own method, so setProperty over DBusInterface wont work. Use typedCall.
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following 2 Users Say Thank You to coderus For This Useful Post:
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#88
Originally Posted by coderus View Post
btw, net.connman /net/connman/technology/bluetooth NOT using DBus Properties, SetProperty is it's own method, so setProperty over DBusInterface wont work. Use typedCall.
I love you. In a non-sexual, nerdy way.

[…awkward pause…]

Anyway, if anyone is a beginner like me and wants to enable or disable Bluetooth via QML, feel free to copy and paste this working example:
Code:
    DBusInterface {
        id:dbif
        bus: DBus.SystemBus
        service: 'net.connman'
        path: '/net/connman/technology/bluetooth'
        iface: 'net.connman.Technology'
        function enable(){
            var valueVariant = true; 
            dbif.typedCall('SetProperty', [
                {'type':'s', 'value': 'Powered'}, 
                {'type':'v', 'value': valueVariant}
            ]);
        }

        function disable(){
            var valueVariant = false;
            dbif.typedCall('SetProperty', [
                {'type':'s', 'value': 'Powered'}, 
                {'type':'v', 'value': valueVariant}
            ]);
        }
    }
Note: I found the extra var statement to be necessary – from what I understand, writing true/false directly seems to be cast as Boolean, not as Variant.
 

The Following 3 Users Say Thank You to velox For This Useful Post:
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, España
#89
Originally Posted by velox View Post
I love you. In a non-sexual, nerdy way.

[…awkward pause…]

Anyway, if anyone is a beginner like me and wants to enable or disable Bluetooth via QML, feel free to copy and paste this working example:
Code:
    DBusInterface {
        id:dbif
        bus: DBus.SystemBus
        service: 'net.connman'
        path: '/net/connman/technology/bluetooth'
        iface: 'net.connman.Technology'
        function enable(){
            var valueVariant = true; 
            dbif.typedCall('SetProperty', [
                {'type':'s', 'value': 'Powered'}, 
                {'type':'v', 'value': valueVariant}
            ]);
        }

        function disable(){
            var valueVariant = false;
            dbif.typedCall('SetProperty', [
                {'type':'s', 'value': 'Powered'}, 
                {'type':'v', 'value': valueVariant}
            ]);
        }
    }
Note: I found the extra var statement to be necessary – from what I understand, writing true/false directly seems to be cast as Boolean, not as Variant.
Yep, I'm a beginner and I'd like to know how to do this, rather, I would like to know where to put this information?, is it being added to an existing file?, I have read the comments but don't fully understand...help!
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,700 times | Joined on Nov 2011 @ Ängelholm, Sweden
#90
star t from helloworld examples of qml please, then you would understand what qml is and how it works.
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following User Says Thank You to coderus For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 02:54.