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:
//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");
halconnection = new QDBusInterface(HAL_SERVICE,HAL_PATH,HAL_INTERFACE,QDBusConnection::systemBus());
//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");
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:
...
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();
...
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();
To copy to clipboard, switch view to plain text mode
this is the output:
connection to hal DeviceAdded: false
connection to hal DeviceRemoved: false
connection to hal is connected: true
connection to hal is valid: true
connection to hal DeviceAdded: false
connection to hal DeviceRemoved: false
connection to hal is connected: true
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
Bookmarks