I'm beginner to Qt.I thought to use QDbusConnection API to get information about device connected. I used following code
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtDBus/QDBusConnection>
#define HAL_SERV "org.freedesktop.Hal"
#define HAL_MGR_INT "org.freedesktop.Hal.Manager"
#define HAL_DEV_INT "org.freedesktop.Hal.Device"
#define HAL_MGR_PATH "/org/freedesktop/Hal/Manager"
#define HAL_DEVS_PATH "/org/freedesktop/Hal/devices"
class Hal : public QObject
{
Q_OBJECT
public:
Hal() :
QObject(),
cnx( QDBusConnection::connectToBus( QDBusConnection::SystemBus, "system" ) )
{
cnx.connect(
HAL_SERV, HAL_MGR_PATH, HAL_MGR_INT, "DeviceAdded",
this, SLOT(added(QString)) );
cnx.connect(
HAL_SERV, HAL_MGR_PATH, HAL_MGR_INT, "DeviceRemoved",
this, SLOT(removed(QString)) );
}
private slots:
void added( QString dev )
{
qDebug() << __FUNCTION__ << dev;
}
void removed( QString dev )
{
qDebug() << __FUNCTION__ << dev;
}
private:
QDBusConnection cnx;
};
int main( int ac, char * * av )
{
QApplication app( ac, av );
Hal hal;
return( app.exec() );
}
#include "main.moc"
I build the project successfully,If I run I'm not observing any output. and Debugger showing warning like below : GDB: Failed to set controlling terminal: Inappropriate ioctl for device\n"
What is the problem ,can anyone explain me in detail. how to run the application?should I need to any arguments?
Regards, Sujatha