Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do you find the available methods that are offered by dbus services?
Forum Updated to NodeBB v4.3 + New Features

How do you find the available methods that are offered by dbus services?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • supermassiveblackholeS Offline
    supermassiveblackholeS Offline
    supermassiveblackhole
    wrote on last edited by
    #1

    I'm new to Qt and dbus, and I've learned a lot. I've successfully created a program that displays the registered service names in a QPlainTextEdit's plainText property. Now, for the next step of trying to see which methods and other information (properties?) are available from the services, I'm confused. I've looked at numerous doc pages, but I cannot figure out how to do it. I can't find an example that demonstrates how to query for available public methods or properties offered by services over dbus. The bus I'm referring to is the session bus.

    If anyone can provide a small example, I would greatly appreciate it. Thanks

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi, welcome to the forum.

      Every self-respecting DBus service implements org.freedesktop.DBus.Introspectable.Introspect at /org/freedesktop/DBus. You can just call that method (without any arguments) and the service will answer with a list of its public interfaces.

      1 Reply Last reply
      2
      • supermassiveblackholeS Offline
        supermassiveblackholeS Offline
        supermassiveblackhole
        wrote on last edited by supermassiveblackhole
        #3

        Thanks for the welcome.

        This might seem overly trivial, but I've spent several hours now just trying to figure out how to call a method :)

        I'm trying to model my code here after the example here: https://techbase.kde.org/Development/Tutorials/D-Bus/Accessing_Interfaces#Calling_a_D-Bus_Method and what you suggested.

            QDBusConnection bus = QDBusConnection::sessionBus();
            QDBusMessage msg = QDBusMessage::createMethodCall("org.gnome.SessionManager",
                                                                "/org/freedesktop/DBus",
                                                                "",
                                                                "Introspect");
            QDBusMessage reply = bus.call(msg);
            qDebug() << reply;
        

        However, I get

        QDBusMessage(type=MethodReturn, service=":1.0", signature="s", contents=("<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
        "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
        <node>
        </node>
        ") )
        

        in the Application Output window. Although I don't know what to expect, the scant output information leads me to believe I'm doing something wrong.

        You mentioned that I didn't need to provide any arguments, but then how would the proper service know who I'm talking to? In the example on the site I linked to, they are using three arguments out of the four. Am I doing this right? :P

        1 Reply Last reply
        0
        • supermassiveblackholeS Offline
          supermassiveblackholeS Offline
          supermassiveblackhole
          wrote on last edited by
          #4

          Alright, I figured it out. I was missing the interface in the third argument.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved