Sailfish OS
  • Info
  • User Experience
  • Cases
  • Community
  • Developers
  • Contact
  • Get Sailfish OS
Select Page
  • Info
  • User Experience
  • Cases
  • Community
  • Developers
  • Contact
  • Get Sailfish OS

Nemo QML Plugin D-Bus

API Documentation
  • API Documentation
  • Libsailfishapp
  • Sailfish Silica
    • Documentation
    • Icon Reference
  • Sailfish Components
    • Sailfish Accounts
    • Sailfish Bluetooth
    • Sailfish Contacts
    • Sailfish Crypto
    • Sailfish Gallery
    • Sailfish Media
    • Sailfish Pickers
    • Sailfish Secrets
    • Sailfish Share
    • Sailfish Telephony
    • Sailfish Webview
    • Amber Web Authorization
    • Amber MPRIS
  • Nemo QML Plugins
    • Configuration
    • Contacts
    • D-Bus
    • Keepalive
    • Notifications
    • Thumbnailer
  • Sailfish Middleware
    • MDM Framework
    • MDM Policy Framework
    • User Manager Daemon
  • API Documentation
  • Libsailfishapp
  • Sailfish Silica
    • Documentation
    • Icon Reference
  • Sailfish Components
    • Sailfish Accounts
    • Sailfish Bluetooth
    • Sailfish Contacts
    • Sailfish Crypto
    • Sailfish Gallery
    • Sailfish Media
    • Sailfish Pickers
    • Sailfish Secrets
    • Sailfish Share
    • Sailfish Telephony
    • Sailfish Webview
    • Amber Web Authorization
    • Amber MPRIS
  • Nemo QML Plugins
    • Configuration
    • Contacts
    • D-Bus
    • Keepalive
    • Notifications
    • Thumbnailer
  • Sailfish Middleware
    • MDM Framework
    • MDM Policy Framework
    • User Manager Daemon

Contents

  • Calling a function on a session bus object
  • Calling a function and getting its return value
  • Listening to signals on a D-Bus object

Examples

There are a number of examples which demonstrate how to use various aspects of the API.

Calling a function on a session bus object

This code snippet talks to the profile daemon and sets the current profile to silent:

 import QtQuick 2.0
 import Nemo.DBus 2.0

 Item {
     DBusInterface {
         id: profiled

         service: 'com.nokia.profiled'
         iface: 'com.nokia.profiled'
         path: '/com/nokia/profiled'
     }

     Component.onCompleted: {
         // Call the "set_profile" method here
         profiled.call('set_profile', ['silent']);
     }
 }

Calling a function and getting its return value

Because function calls are asynchronous, we need to provide a callback to be called when the function result is available:

 import QtQuick 2.0
 import Nemo.DBus 2.0

 Item {
     DBusInterface {
         id: profiled

         service: 'com.nokia.profiled'
         iface: 'com.nokia.profiled'
         path: '/com/nokia/profiled'
     }

     Component.onCompleted: {
         // Call the "get_profile" method without arguments, and
         // when it returns, call the passed-in callback method
         profiled.typedCall('get_profile', [], function (result) {
             // This will be called when the result is available
             console.log('Got profile: ' + result);
         });
     }
 }

Listening to signals on a D-Bus object

 import QtQuick 2.0
 import Nemo.DBus 2.0

 Item {
     DBusInterface {
         id: profiled

         service: 'com.nokia.profiled'
         iface: 'com.nokia.profiled'
         path: '/com/nokia/profiled'

         signalsEnabled: true

         function profile_changed(changed, active, profile, values) {
             if (changed && active)
                 console.log("Profile changed to:", profile)
         }
     }
 }
  • Legal
  • Contact Us
  • Jollyboys Ltd © 2024

  • Facebook
  • Twitter
  • Mastodon
  • YouTube
  • LinkedIn