Results 1 to 5 of 5

Thread: qdbus connect return always FALSE

  1. #1

    Default qdbus connect return always FALSE

    hi to all, this is my first post, i'm developing an program in qt4 and i want to attach it to the dbus daemon...

    i have using this method:

    Qt Code:
    1. halconnection = new QDBusInterface(HAL_SERVICE,HAL_PATH,HAL_INTERFACE,QDBusConnection::systemBus());
    2. //check if the connection is valid
    3. //sorround this with an try cath interface for emit the error and exit
    4. if(halconnection->isValid())
    5. {
    6. Logger::instance()->threadLogDebug(QString(__FUNCTION__),QString("%1").arg(__LINE__),"Dbus interface correctly created");
    7. } else
    8. Logger::instance()->threadLogDebug(QString(__FUNCTION__),QString("%1").arg(__LINE__),"Dbus interface problem");
    9.  
    10. QDBusReply<QStringList> allDevicesReply = halconnection->call("GetAllDevices");
    11. allDevicesReply.isValid() ? Logger::instance()->threadLogDebug(QString(__FUNCTION__),QString("%1").arg(__LINE__),"All devices were recieved") :
    12. Logger::instance()->threadLogDebug(QString(__FUNCTION__),QString("%1").arg(__LINE__),"Cannot receive all devices");
    To copy to clipboard, switch view to plain text mode 

    where :

    // Hal constants
    #define HAL_SERVICE "org.freedesktop.Hal"
    #define HAL_PATH "/org/freedesktop/Hal/Manager"
    #define HAL_INTERFACE "org.freedesktop.Hal.Manager"
    #define HAL_DEVICE_INTERFACE "org.freedesktop.Hal.Device"

    this all works graeat but i have problem at this point:
    Qt Code:
    1. ...
    2. qDebug() << "connection to hal DeviceAdded: "<<halconnection->connection().connect(HAL_SERVICE,HAL_PATH,HAL_INTERFACE,
    3. "DeviceAdded",this,SLOT(addNewDevice(const QString&)));
    4. qDebug() << "connection to hal DeviceRemoved: "<< halconnection->connection().connect(HAL_SERVICE,HAL_PATH,HAL_INTERFACE,
    5. "DeviceRemoved",this,SLOT(removedDevice(const QString&)));
    6. qDebug() << "connection to hal is connected: " << halconnection->connection().isConnected();
    7. qDebug() << "connection to hal is valid: " << halconnection->isValid();
    To copy to clipboard, switch view to plain text mode 

    this is the output:

    Qt Code:
    1. connection to hal DeviceAdded: false
    2. connection to hal DeviceRemoved: false
    3. connection to hal is connected: true
    4. connection to hal is valid: true
    To copy to clipboard, switch view to plain text mode 

    so i can't connect to the dbus and when a new device is attached my program is never advised by dbus...
    the class is called hub and have as super type QThread...
    can any help me??

    ps. all code compile well... but the problem is at runtime
    Last edited by ciberkids; 16th September 2009 at 16:55. Reason: subscription for email :)

  2. #2
    Join Date
    Aug 2009
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face Re: qdbus connect return always FALSE

    Use:
    Qt Code:
    1. connect(QString(), QString(), HAL_INTERFACE, "DeviceAdded", this, SLOT(addNewDevice(QString)));
    To copy to clipboard, switch view to plain text mode 

    instead of

    Qt Code:
    1. connect(HAL_SERVICE,HAL_PATH,HAL_INTERFACE, "DeviceAdded",this,SLOT(addNewDevice(const QString&)));
    To copy to clipboard, switch view to plain text mode 

    and so on.

  3. #3

    Default Re: qdbus connect return always FALSE

    i have used this:
    Qt Code:
    1. qDebug() << "connection to hal DeviceAdded: "<<halconnection->connection().connect(QString(),QString(),HAL_INTERFACE,
    2. "DeviceAdded",this,SLOT(addNewDevice( QString)));
    To copy to clipboard, switch view to plain text mode 

    but the output is the same

    Qt Code:
    1. connection to hal DeviceAdded: false
    2. connection to hal DeviceRemoved: false
    3. connection to hal is connected: true
    4. connection to hal is valid: true
    To copy to clipboard, switch view to plain text mode 
    Last edited by ciberkids; 16th September 2009 at 17:43. Reason: wrong paste

  4. #4

    Default Re: qdbus connect return always FALSE

    i have just re-read my last post.. i have wring pasted the code... i'm sorry..

    the code is:
    Qt Code:
    1. qDebug() << "connection to hal DeviceAdded: "<< halconnection->connection().connect(QString(HAL_SERVICE),
    2. QString(HAL_PATH), QString(HAL_INTERFACE),
    3. QString("DeviceAdded"), this, SLOT(addNewDevice(const QString)));
    To copy to clipboard, switch view to plain text mode 

    but the problem are the same... is doesn't conect to the dbus signal and return false..

    any can explain me where i'm wrong??

  5. #5

    Unhappy Re: qdbus connect return always FALSE

    i also tryed this:

    Qt Code:
    1. qDebug() << "connection to hal DeviceAdded: "<< halconnection->connection().connect(QString(), QString(), HAL_INTERFACE,
    2. "DeviceAdded", this, SLOT(addNewDevice(QString)));
    To copy to clipboard, switch view to plain text mode 

    where the define od device added in .h file is:
    Qt Code:
    1. private slots:
    2. void addNewDevice(QString deviceUdi);
    To copy to clipboard, switch view to plain text mode 

    following the API REFERENCE:

    bool QDBusConnection::connect ( const QString & service, const QString & path, const QString & interface, const QString & name, QObject * receiver, const char * slot )

    Connects the signal specified by the service, path, interface and name parameters to the slot slot in object receiver. The arguments service and path can be empty, denoting a connection to any signal of the (interface, name) pair, from any remote application.

    Returns true if the connection was successful.

    but the output is always the same:
    Qt Code:
    1. connection to hal DeviceAdded: false
    2. connection to hal is connected: true
    3. connection to hal is valid: true
    To copy to clipboard, switch view to plain text mode 



    i have really need of help, i have tried out all combination of arguments with the same result...

    i have controlled with:
    Qt Code:
    1. [matteo@devel Build]$ qdbus --system org.freedesktop.Hal /org/freedesktop/Hal/Manager
    2. method QString org.freedesktop.DBus.Introspectable.Introspect()
    3. method void org.freedesktop.Hal.Manager.AcquireGlobalInterfaceLock(QString interface_name, bool exclusive)
    4. method void org.freedesktop.Hal.Manager.CommitToGdl(QString temporary_udi, QString global_udi)
    5. signal void org.freedesktop.Hal.Manager.DeviceAdded(QString udi) <---------
    6. method bool org.freedesktop.Hal.Manager.DeviceExists(QString udi)
    7. signal void org.freedesktop.Hal.Manager.DeviceRemoved(QString udi)
    8. method QStringList org.freedesktop.Hal.Manager.FindDeviceByCapability(QString capability)
    9. method QStringList org.freedesktop.Hal.Manager.FindDeviceStringMatch(QString key, QString value)
    10. method QStringList org.freedesktop.Hal.Manager.GetAllDevices()
    11. signal void org.freedesktop.Hal.Manager.GlobalInterfaceLockAcquired(QString interface_name, QString lock_holder, int num_locks)
    12. signal void org.freedesktop.Hal.Manager.GlobalInterfaceLockReleased(QString interface_name, QString lock_holder, int num_locks)
    13. signal void org.freedesktop.Hal.Manager.NewCapability(QString udi, QString cap_name)
    14. method QString org.freedesktop.Hal.Manager.NewDevice()
    15. method void org.freedesktop.Hal.Manager.ReleaseGlobalInterfaceLock(QString interface_name)
    16. method void org.freedesktop.Hal.Manager.Remove(QString udi)
    17. method void org.freedesktop.Hal.Manager.SingletonAddonIsReady(QString command_line)
    To copy to clipboard, switch view to plain text mode 
    where i can see the signal...
    i doesn't know where i can search/try for this...

Similar Threads

  1. connect returning false
    By thru in forum Newbie
    Replies: 3
    Last Post: 28th April 2009, 19:58
  2. error with QList with a class
    By john_god in forum Newbie
    Replies: 7
    Last Post: 12th January 2009, 21:48
  3. QTableView performances
    By miraks in forum Qt Programming
    Replies: 18
    Last Post: 1st December 2008, 10:25
  4. Problem with connect()
    By mrnor3 in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 14:05
  5. connect returns false
    By krivenok in forum Qt Programming
    Replies: 6
    Last Post: 21st February 2006, 20:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.