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. Receiving system D-Bus signals and responding to them

Receiving system D-Bus signals and responding to them

Scheduled Pinned Locked Moved Unsolved General and Desktop
dbusqdbus
1 Posts 1 Posters 426 Views
  • 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.
  • swirlS Offline
    swirlS Offline
    swirl
    wrote on last edited by
    #1

    I already asked this last month but nobody answered plus I've got some new stuff.

    Basically, I need to respond to the org.freedesktop.login1.Manager.PrepareForSleep signal, closing out the application and deallocating all memory in order to prevent users from accessing sensitive data if the computer is hibernated and writes the contents of RAM to disk.

    Here are the two things I've tried:

    class Test : public QDBusAbstractAdaptor
    {
        Q_OBJECT
        Q_CLASSINFO("D-Bus Interface", "org.freedesktop.login1.Manager")
    public:
        Test(QObject *obj) : QDBusAbstractAdaptor(obj)
        { }
    signals:
        void PrepareForSleep();
    };
    
    int main() {
        // ...
        QObject obj;
        Test *test = new Test(&obj);
        QObject::connect(pong, &Test::PrepareForSleep, test, [] {
            qDebug() << "Preparing for sleep";
        });
        
        QDBusConnection::sessionBus().registerObject("/", &obj);
    } 
    

    Which simply did nothing, and:

    QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep")
    

    Which also did nothing. I'm pretty sure the latter not working is because it's using incorrect arguments, but I haven't found any documentation for like, what I should even make the arguments to match the PrepareForSleep signal.

    In general I just can't figure anything out from any of the documentation and examples. All of them seem to deal with either custom signals/slots, and just listing the names from org.freedesktop.DBus, nothing else.

    the

    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