DeviceListDBusAdaptor::DeviceListDBusAdaptor( DeviceList* parent ) : QDBusAbstractAdaptor( parent ) { connect( parent, SIGNAL(devicesAdded(DeviceTypeMap)), SIGNAL(devicesAdded(DeviceTypeMap)) ); connect( parent, SIGNAL(devicesRemoved(DeviceTypeMap)), SIGNAL(devicesRemoved(DeviceTypeMap)) ); // TODO: best place to do this? qDBusRegisterMetaType<DeviceTypeMap>(); qDBusRegisterMetaType<Cagibi::Device>(); }
void UpnpNetworkBuilder::startBrowse() { qDBusRegisterMetaType<DeviceTypeMap>(); qDBusRegisterMetaType<Cagibi::Device>(); QDBusConnection dbusConnection = QDBusConnection::systemBus(); const QString serviceName = QLatin1String( cagibiServiceName ); const QString deviceListObjectPath = QLatin1String( cagibiDeviceListObjectPath ); const QString deviceListInterface = QLatin1String( cagibiDeviceListInterface ); // install service watcher QDBusServiceWatcher* cagibiServiceWatcher = new QDBusServiceWatcher( serviceName, dbusConnection, QDBusServiceWatcher::WatchForOwnerChange, this ); connect( cagibiServiceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), SLOT(onCagibiServiceOwnerChanged(QString,QString,QString)) ); // create devicelist proxy mCagibiDeviceListDBusProxy = new QDBusInterface( serviceName, deviceListObjectPath, deviceListInterface, dbusConnection, this ); connect( mCagibiDeviceListDBusProxy, SIGNAL(devicesAdded(DeviceTypeMap)), SLOT(onDevicesAdded(DeviceTypeMap)) ); connect( mCagibiDeviceListDBusProxy, SIGNAL(devicesRemoved(DeviceTypeMap)), SLOT(onDevicesRemoved(DeviceTypeMap)) ); // query current devicelist queryCurrentDevices(); emit initDone(); }