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:
Code:
//check if the connection is valid
//sorround this with an try cath interface for emit the error and exit
if(halconnection->isValid())
{
Logger
::instance()->threadLogDebug
(QString(__FUNCTION__
),
QString("%1").
arg(__LINE__
),
"Dbus interface correctly created");
} else
Logger
::instance()->threadLogDebug
(QString(__FUNCTION__
),
QString("%1").
arg(__LINE__
),
"Dbus interface problem");
QDBusReply<QStringList> allDevicesReply = halconnection->call("GetAllDevices");
allDevicesReply.
isValid() ? Logger
::instance()->threadLogDebug
(QString(__FUNCTION__
),
QString("%1").
arg(__LINE__
),
"All devices were recieved") : Logger
::instance()->threadLogDebug
(QString(__FUNCTION__
),
QString("%1").
arg(__LINE__
),
"Cannot receive all devices");
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:
Code:
...
qDebug() << "connection to hal DeviceAdded: "<<halconnection->connection().connect(HAL_SERVICE,HAL_PATH,HAL_INTERFACE,
"DeviceAdded",this,SLOT(addNewDevice(const QString&)));
qDebug() << "connection to hal DeviceRemoved: "<< halconnection->connection().connect(HAL_SERVICE,HAL_PATH,HAL_INTERFACE,
"DeviceRemoved",this,SLOT(removedDevice(const QString&)));
qDebug() << "connection to hal is connected: " << halconnection->connection().isConnected();
qDebug() << "connection to hal is valid: " << halconnection->isValid();
this is the output:
Code:
connection to hal DeviceAdded: false
connection to hal DeviceRemoved: false
connection to hal is connected: true
connection to hal is valid: true
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 :(
Re: qdbus connect return always FALSE
Use:
instead of
Code:
connect(HAL_SERVICE,HAL_PATH,HAL_INTERFACE, "DeviceAdded",this,SLOT(addNewDevice(const QString&)));
and so on.
Re: qdbus connect return always FALSE
i have used this:
Code:
qDebug
() <<
"connection to hal DeviceAdded: "<<halconnection
->connection
().
connect(QString(),
QString(),HAL_INTERFACE,
"DeviceAdded",
this,
SLOT(addNewDevice
( QString)));
but the output is the same:(
Code:
connection to hal DeviceAdded: false
connection to hal DeviceRemoved: false
connection to hal is connected: true
connection to hal is valid: true
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:
Code:
qDebug
() <<
"connection to hal DeviceAdded: "<< halconnection
->connection
().
connect(QString(HAL_SERVICE
),
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??
Re: qdbus connect return always FALSE
i also tryed this:
Code:
qDebug
() <<
"connection to hal DeviceAdded: "<< halconnection
->connection
().
connect(QString(),
QString(), HAL_INTERFACE,
"DeviceAdded",
this,
SLOT(addNewDevice
(QString)));
where the define od device added in .h file is:
Code:
private slots:
void addNewDevice
(QString deviceUdi
);
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:
Code:
connection to hal DeviceAdded: false
connection to hal is connected: true
connection to hal is valid: true
i have really need of help, i have tried out all combination of arguments with the same result...
i have controlled with:
Code:
[matteo@devel Build]$ qdbus --system org.freedesktop.Hal /org/freedesktop/Hal/Manager
method
QString org.
freedesktop.
DBus.
Introspectable.
Introspect()method
void org.
freedesktop.
Hal.
Manager.
AcquireGlobalInterfaceLock(QString interface_name,
bool exclusive
)method
void org.
freedesktop.
Hal.
Manager.
CommitToGdl(QString temporary_udi,
QString global_udi
)signal void org.
freedesktop.
Hal.
Manager.
DeviceAdded(QString udi
) <
--------- method
bool org.
freedesktop.
Hal.
Manager.
DeviceExists(QString udi
)signal void org.
freedesktop.
Hal.
Manager.
DeviceRemoved(QString udi
) method
QStringList org.
freedesktop.
Hal.
Manager.
GetAllDevices()signal void org.
freedesktop.
Hal.
Manager.
GlobalInterfaceLockAcquired(QString interface_name,
QString lock_holder,
int num_locks
) signal void org.
freedesktop.
Hal.
Manager.
GlobalInterfaceLockReleased(QString interface_name,
QString lock_holder,
int num_locks
) signal void org.
freedesktop.
Hal.
Manager.
NewCapability(QString udi,
QString cap_name
) method
QString org.
freedesktop.
Hal.
Manager.
NewDevice()method
void org.
freedesktop.
Hal.
Manager.
ReleaseGlobalInterfaceLock(QString interface_name
)method
void org.
freedesktop.
Hal.
Manager.
Remove(QString udi
)method
void org.
freedesktop.
Hal.
Manager.
SingletonAddonIsReady(QString command_line
)
where i can see the signal...
i doesn't know where i can search/try for this... :confused: