DevicesModel::DevicesModel(QObject *parent) : QAbstractListModel(parent) , m_dbusInterface(new DaemonDbusInterface(this)) , m_displayFilter(StatusFilterFlag::NoFilter) { //new ModelTest(this, this); connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(rowsChanged())); connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(rowsChanged())); connect(m_dbusInterface, SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString))); connect(m_dbusInterface, SIGNAL(deviceVisibilityChanged(QString,bool)), this, SLOT(deviceUpdated(QString,bool))); connect(m_dbusInterface, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString))); QDBusServiceWatcher* watcher = new QDBusServiceWatcher(DaemonDbusInterface::activatedService(), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this); connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &DevicesModel::refreshDeviceList); connect(watcher, &QDBusServiceWatcher::serviceUnregistered, this, &DevicesModel::clearDevices); //refresh the view, acquireDiscoveryMode if necessary setDisplayFilter(NoFilter); }
void InputDaemon::addInputDevice(int index) { SDL_Joystick *joystick = SDL_JoystickOpen(index); if (joystick) { SDL_JoystickID tempJoystickID = SDL_JoystickInstanceID(joystick); if (!joysticks->contains(tempJoystickID)) { QSettings *settings = new QSettings(PadderCommon::configFilePath, QSettings::IniFormat); settings->beginGroup("Mappings"); QString temp; SDL_JoystickGUID tempGUID = SDL_JoystickGetGUID(joystick); char guidString[65] = {'0'}; SDL_JoystickGetGUIDString(tempGUID, guidString, sizeof(guidString)); temp = QString(guidString); bool disableGameController = settings->value(QString("%1Disable").arg(temp), false).toBool(); if (SDL_IsGameController(index) && !disableGameController) { SDL_GameController *controller = SDL_GameControllerOpen(index); if (controller) { SDL_Joystick *sdlStick = SDL_GameControllerGetJoystick(controller); SDL_JoystickID tempJoystickID = SDL_JoystickInstanceID(sdlStick); if (!joysticks->contains(tempJoystickID)) { GameController *damncontroller = new GameController(controller, index, this); joysticks->insert(tempJoystickID, damncontroller); trackcontrollers.insert(tempJoystickID, damncontroller); // Force close of settings file. settings->endGroup(); delete settings; settings = 0; emit deviceAdded(damncontroller); } } } else { Joystick *curJoystick = new Joystick(joystick, index, this); joysticks->insert(tempJoystickID, curJoystick); trackjoysticks.insert(tempJoystickID, curJoystick); // Force close of settings file. settings->endGroup(); delete settings; settings = 0; emit deviceAdded(curJoystick); } } } }
void SolidDeviceEngine::listenForNewDevices() { if (m_notifier) { return; } //detect when new devices are added m_notifier = Solid::DeviceNotifier::instance(); connect(m_notifier, SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString))); connect(m_notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString))); }
ConnectionUsageMonitor::ConnectionUsageMonitor(ConnectionList * connectionList, ActivatableList * activatableList, QObject * parent) : QObject(parent), d_ptr(new ConnectionUsageMonitorPrivate) { Q_D(ConnectionUsageMonitor); d->connectionList = connectionList; d->activatableList = activatableList; QObject::connect(NetworkManager::notifier(), SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString))); NetworkManager::Device::List allInterfaces = NetworkManager::networkInterfaces(); foreach (const NetworkManager::Device::Ptr &interface, allInterfaces) { deviceAdded(interface->uni()); }
NetworkManager::NetworkManager(QIODevice *serial, QObject *parent) : QObject(parent), serial(serial) { QObject::connect(this, SIGNAL(deviceAdded(node_id,MacAddress)), this, SLOT(onDeviceAdded(node_id,MacAddress))); QObject::connect(this, SIGNAL(deviceRemoved(node_id)), this, SLOT(onDeviceRemoved(node_id))); }
bool QNetworkManagerInterface::setConnections() { if (!isValid()) return false; QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), QLatin1String(NM_DBUS_INTERFACE), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap<QString,QVariant>))); bool allOk = false; if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), QLatin1String(NM_DBUS_INTERFACE), QLatin1String("DeviceAdded"), this,SIGNAL(deviceAdded(QDBusObjectPath)))) { allOk = true; } if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), QLatin1String(NM_DBUS_INTERFACE), QLatin1String("DeviceRemoved"), this,SIGNAL(deviceRemoved(QDBusObjectPath)))) { allOk = true; } return allOk; }
MessagesModel::MessagesModel(BusConnection* busconnection) : QAbstractListModel(0), busconnection(busconnection) { // an object for translating int codes to readable messages trLiriMessages = new trLiriClass(); // important: busconnection != 0 Q_ASSERT(busconnection); connect(busconnection, SIGNAL( devicemanagerStateChanged(int) ), SLOT( devicemanagerStateChanged(int) )); connect(busconnection, SIGNAL( executionengineStateChanged(int) ), SLOT( executionengineStateChanged(int) )); connect(busconnection, SIGNAL( deviceAdded(const QString &) ), SLOT( deviceAdded(const QString &) )); connect(busconnection, SIGNAL( deviceRemoved(const QString &) ), SLOT( deviceRemoved(const QString &) )); connect(busconnection, SIGNAL( executed(const QString &, int, const QString &) ), SLOT( executed(const QString &, int, const QString &) )); connect(busconnection, SIGNAL( modeChanged(const QString &, const QString &, const QString &) ), SLOT( modeChanged(const QString &, const QString &, const QString &) )); connect(busconnection, SIGNAL( targetChanged(int, const QString &) ), SLOT( targetChanged(int, const QString &) )); connect(busconnection, SIGNAL( deviceAddedExecution(const QString &) ), SLOT( deviceAddedExecution(const QString &) )); connect(busconnection, SIGNAL( deviceRemovedExecution(const QString &) ), SLOT( deviceRemovedExecution(const QString &) )); connect(busconnection, SIGNAL( profilesLoaded(const QString &) ), SLOT( profilesLoaded(const QString &) )); // inital device adding QStringList receivers = busconnection->receivers(); foreach(QString rid, receivers) deviceAdded(rid); foreach(QString rid, receivers) deviceAddedExecution(rid); }
void DevicesModel::deviceUpdated(const QString& id, bool isVisible) { Q_UNUSED(isVisible); int row = rowForDevice(id); if (row < 0) { // FIXME: when m_dbusInterface is not valid refreshDeviceList() does // nothing and we can miss some devices. // Someone can reproduce this problem by restarting kdeconnectd while // kdeconnect's plasmoid is still running. // Another reason for this branch is that we removed the device previously // because of the filter settings. qCDebug(KDECONNECT_INTERFACES) << "Adding missing or previously removed device" << id; deviceAdded(id); } else { DeviceDbusInterface *dev = getDevice(row); if (! passesFilter(dev)) { beginRemoveRows(QModelIndex(), row, row); delete m_deviceList.takeAt(row); endRemoveRows(); qCDebug(KDECONNECT_INTERFACES) << "Removed changed device " << id; } else { const QModelIndex idx = index(row); Q_EMIT dataChanged(idx, idx); } } }
HotplugWatcher_GUI::HotplugWatcher_GUI(QWidget *parent) : QWidget(parent) { QVBoxLayout *vbl = new QVBoxLayout(this); setLayout(vbl); state = new QLabel(this); button = new QPushButton(tr("Start"), this); detail_button = new QToolButton(this); detail_button->setText(tr("Detail")); detail_button->setCheckable(true); detail_button->setChecked(true); msg_view = new QTextBrowser(this); msg_view->setLineWrapMode(QTextEdit::NoWrap); QHBoxLayout *hbl = new QHBoxLayout(this); hbl->addWidget(button); hbl->addWidget(detail_button); vbl->addWidget(state); vbl->addLayout(hbl); vbl->addWidget(msg_view); tray = new QSystemTrayIcon(this); tray->show(); watcher = new QDeviceWatcher; watcher->appendEventReceiver(this); connect(watcher, SIGNAL(deviceAdded(QString)), this, SLOT(slotDeviceAdded(QString)), Qt::DirectConnection); connect(watcher, SIGNAL(deviceChanged(QString)), this, SLOT(slotDeviceChanged(QString)), Qt::DirectConnection); connect(watcher, SIGNAL(deviceRemoved(QString)), this, SLOT(slotDeviceRemoved(QString)), Qt::DirectConnection); connect(button, SIGNAL(clicked()), SLOT(toggleWatch())); connect(detail_button, SIGNAL(toggled(bool)), SLOT(showDetail(bool))); }
bool UPower::connectInterfaces() { if(m_interface==0 || !m_interface->isValid()) { m_interface = new QDBusInterface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", QDBusConnection::systemBus()); if(!m_interface->isValid()) { m_interface->deleteLater(); m_interface = 0; if (m_interfaceProps) m_interfaceProps->deleteLater(); m_interfaceProps = 0; return false; } connect(m_interface, SIGNAL(DeviceAdded(QString)), this, SLOT(deviceAdded(QString))); connect(m_interface, SIGNAL(DeviceRemoved(QString)), this, SIGNAL(batteryDisconnected(QString))); connect(m_interface, SIGNAL(Changed()), this, SLOT(changed())); } if(m_interfaceProps==0 || !m_interfaceProps->isValid()) { m_interfaceProps = new QDBusInterface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); if(!m_interfaceProps->isValid()) { if (m_interface) m_interface->deleteLater(); m_interface = 0; m_interfaceProps->deleteLater(); m_interfaceProps = 0; return false; } } emit upowerAvailable(); return true; }
DriveSelection::DriveSelection(BackupPlan *pBackupPlan, QWidget *parent) : QListView(parent), mBackupPlan(pBackupPlan), mSelectedAndAccessible(false), mSyncedBackupType(false) { KConfigDialogManager::changedMap()->insert(QStringLiteral("DriveSelection"), SIGNAL(selectedDriveChanged(QString))); mDrivesModel = new QStandardItemModel(this); setModel(mDrivesModel); setItemDelegate(new DriveSelectionDelegate(this)); setSelectionMode(QAbstractItemView::SingleSelection); setWordWrap(true); if(!mBackupPlan->mExternalUUID.isEmpty()) { QStandardItem *lItem = new QStandardItem(); lItem->setEditable(false); lItem->setData(QString(), DriveSelection::UDI); lItem->setData(mBackupPlan->mExternalUUID, DriveSelection::UUID); lItem->setData(0, DriveSelection::UsedSpace); lItem->setData(mBackupPlan->mExternalPartitionNumber, DriveSelection::PartitionNumber); lItem->setData(mBackupPlan->mExternalPartitionsOnDrive, DriveSelection::PartitionsOnDrive); lItem->setData(mBackupPlan->mExternalDeviceDescription, DriveSelection::DeviceDescription); lItem->setData(mBackupPlan->mExternalVolumeCapacity, DriveSelection::TotalSpace); lItem->setData(mBackupPlan->mExternalVolumeLabel, DriveSelection::Label); mDrivesModel->appendRow(lItem); } QList<Solid::Device> lDeviceList = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive); foreach (const Solid::Device &lDevice, lDeviceList) { deviceAdded(lDevice.udi()); }
void SolidHwTest::testManagerSignals() { fakeManager->unplug("/org/kde/solid/fakehw/acpi_CPU0"); // Heh, we missed a processor in this system ;-) // We're going to add this device, and check that the signal has been // properly emitted by the manager QSignalSpy added(Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString))); fakeManager->plug("/org/kde/solid/fakehw/acpi_CPU0"); QCOMPARE(added.count(), 1); QCOMPARE(added.at(0).at(0).toString(), QString("/org/kde/solid/fakehw/acpi_CPU0")); // Moreover we check that the device is really available Solid::Device cpu("/org/kde/solid/fakehw/acpi_CPU0"); QVERIFY(cpu.isValid()); // Finally we remove the device and spy the corresponding signal again QSignalSpy removed(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString))); fakeManager->unplug("/org/kde/solid/fakehw/acpi_CPU0"); QCOMPARE(added.count(), 1); QCOMPARE(added.at(0).at(0).toString(), QString("/org/kde/solid/fakehw/acpi_CPU0")); // The Device object should become automatically invalid QVERIFY(!cpu.isValid()); // Restore original state fakeManager->plug("/org/kde/solid/fakehw/acpi_CPU0"); }
QTM_BEGIN_NAMESPACE QNmWifiEngine::QNmWifiEngine(QObject *parent) : QNetworkSessionEngine(parent) { iface = new QNetworkManagerInterface(this); if(!iface->isValid()) { return; } iface->setConnections(); connect(iface,SIGNAL(deviceAdded(QDBusObjectPath)), this,SLOT(addDevice(QDBusObjectPath))); // connect(iface,SIGNAL(deviceRemoved(QDBusObjectPath)), // this,SLOT(removeDevice(QDBusObjectPath))); connect(iface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)), this, SLOT(slotActivationFinished(QDBusPendingCallWatcher*))); foreach (const QDBusObjectPath &path, iface->getDevices()) addDevice(path); QStringList connectionServices; connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS; connectionServices << NM_DBUS_SERVICE_USER_SETTINGS; QNetworkManagerSettings *settingsiface; foreach (const QString &service, connectionServices) { settingsiface = new QNetworkManagerSettings(service, this); settingsiface->setConnections(); connect(settingsiface,SIGNAL(newConnection(QDBusObjectPath)), this,(SLOT(newConnection(QDBusObjectPath)))); }
bool Joystick::handleSDLEvent(const SDL_Event *event) { switch (event->type) { case SDL_CONTROLLERDEVICEADDED: case SDL_JOYDEVICEADDED: if (!device_attached) return deviceAdded(event); break; case SDL_CONTROLLERDEVICEREMOVED: case SDL_JOYDEVICEREMOVED: if (device_attached) return deviceRemoved(event); break; case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP: controllerButtonChanged(event); break; case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: // joyButtonChanged(event); break; case SDL_CONTROLLERAXISMOTION: controllerAxisChanged(event); break; case SDL_JOYAXISMOTION: case SDL_JOYHATMOTION: break; } return false; }
UDisks2Plugin::UDisks2Plugin(QObject *parent) : QObject(parent) { qDBusRegisterMetaType<QVariantMapMap>(); qDBusRegisterMetaType<QByteArrayList>(); m_manager = new UDisks2Manager(this); m_actions = new QActionGroup(this); connect(m_manager,SIGNAL(deviceAdded(QDBusObjectPath)), SLOT(addDevice(QDBusObjectPath))); connect(m_manager,SIGNAL(deviceRemoved(QDBusObjectPath)), SLOT(removeDevice(QDBusObjectPath))); connect(m_actions,SIGNAL(triggered (QAction *)), SLOT(processAction(QAction *))); //load settings QSettings settings(Qmmp::configFile(), QSettings::IniFormat); settings.beginGroup("UDisks2"); m_detectCDA = settings.value("cda", true).toBool(); m_detectRemovable = settings.value("removable", true).toBool(); m_addTracks = false; //do not load tracks on startup m_addFiles = false; //find existing devices QList<QDBusObjectPath> devs = m_manager->findAllDevices(); foreach(QDBusObjectPath o, devs) addDevice(o); //load remaining settings m_addTracks = settings.value("add_tracks", false).toBool(); m_removeTracks = settings.value("remove_tracks", false).toBool(); m_addFiles = settings.value("add_files", false).toBool(); m_removeFiles = settings.value("remove_files", false).toBool(); settings.endGroup(); }
void MIDIOut::addDevice(MIDIDevice* device) { Q_ASSERT(device != NULL); m_devices.append(device); emit deviceAdded(device); }
void ColordEngine::gotDevices(const QDBusMessage &message) { if (message.type() == QDBusMessage::ReplyMessage && message.arguments().size() == 1) { QDBusArgument argument = message.arguments().first().value<QDBusArgument>(); ObjectPathList paths = qdbus_cast<ObjectPathList>(argument); foreach (const QDBusObjectPath &path, paths) { deviceAdded(path); }
void HID::addDevice(HIDDevice* device) { Q_ASSERT(device != NULL); m_devices.append(device); emit deviceAdded(device); emit configurationChanged(); }
NetworkInterfaceMonitor::NetworkInterfaceMonitor(ConnectionList * connectionList, ActivatableList * activatableList, QObject * parent) :QObject(parent), d_ptr(new NetworkInterfaceMonitorPrivate) { Q_D(NetworkInterfaceMonitor); d->connectionList = connectionList; d->activatableList = activatableList; d->dialog.clear(); QObject::connect(NetworkManager::notifier(), SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString))); QObject::connect(NetworkManager::notifier(), SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString))); foreach (const NetworkManager::Device::Ptr &iface, NetworkManager::networkInterfaces()) { deviceAdded(iface->uni()); }
void ServerCore::processNewDevice(QVariantMap& dataMap) { bool isSelfBroadcast = dataMap.contains(JSON_KEY_COMMAND) && dataMap[JSON_KEY_COMMAND] == CMD_QUERY && (!dataMap.contains(JSON_KEY_UID) || !dataMap.contains(JSON_KEY_DISPLAYNAME) || !dataMap.contains(JSON_KEY_IP)); if (isSelfBroadcast) { return; } QString deviceUID = dataMap[JSON_KEY_UID].toString(); QString deviceName = dataMap[JSON_KEY_DISPLAYNAME].toString(); QString deviceIP = dataMap[JSON_KEY_IP].toString(); QString deviceType = dataMap[JSON_KEY_TYPE].toString(); DeviceInfo devInfo(deviceUID, deviceName, deviceIP, deviceType); DeviceManagerModule()->AddDevice(deviceUID, devInfo); QVariantMap paramMap; paramMap.insert(JSON_KEY_SEQ, 1234); QTcpSocket *socket = new QTcpSocket(this); QObject::connect(socket, &QTcpSocket::readyRead, [=] { QByteArray byteArray = socket->readAll(); parseSupportCmds(deviceUID, byteArray); Q_EMIT deviceAdded(deviceUID); socket->disconnectFromHost(); }); QObject::connect(socket, static_cast<void(QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error), [=](QAbstractSocket::SocketError socketError) { qDebug() << "Socket Error" << socketError; }); QObject::connect(socket, &QTcpSocket::disconnected, [=] { socket->deleteLater(); }); socket->connectToHost(deviceIP, PORT_SERVER_BROADCAST, QIODevice::ReadWrite); socket->waitForConnected(); QString jsonCmd = JsonGenerator::GenerateJsonCommand(TCP_COMMAND_TYPE::QUERY_DEVICE_SUPPORT_CMDS, paramMap); socket->write(jsonCmd.toLatin1()); socket->flush(); socket->waitForBytesWritten(); socket->waitForReadyRead(); }
MountPointManager::MountPointManager( QObject *parent, SqlStorage *storage ) : QObject( parent ) , m_storage( storage ) , m_ready( false ) { DEBUG_BLOCK setObjectName( "MountPointManager" ); if ( !Amarok::config( "Collection" ).readEntry( "DynamicCollection", true ) ) { debug() << "Dynamic Collection deactivated in amarokrc, not loading plugins, not connecting signals"; m_ready = true; handleMusicLocation(); return; } connect( MediaDeviceCache::instance(), SIGNAL(deviceAdded(QString)), SLOT(deviceAdded(QString)) ); connect( MediaDeviceCache::instance(), SIGNAL(deviceRemoved(QString)), SLOT(deviceRemoved(QString)) ); createDeviceFactories(); }
Solid::DeviceManagerPrivate::DeviceManagerPrivate() : m_nullDevice(new DevicePrivate(QString())) { loadBackends(); QList<QObject*> backends = managerBackends(); foreach (QObject *backend, backends) { connect(backend, SIGNAL(deviceAdded(QString)), this, SLOT(_k_deviceAdded(QString))); connect(backend, SIGNAL(deviceRemoved(QString)), this, SLOT(_k_deviceRemoved(QString))); }
DevicesModel::DevicesModel(QObject *parent) : QAbstractListModel(parent) , m_dbusInterface(new DaemonDbusInterface(this)) , m_displayFilter(DevicesModel::StatusUnknown) { //new ModelTest(this, this); connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SIGNAL(rowsChanged())); connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SIGNAL(rowsChanged())); connect(m_dbusInterface, SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString))); connect(m_dbusInterface, SIGNAL(deviceVisibilityChanged(QString,bool)), this, SLOT(deviceStatusChanged(QString))); connect(m_dbusInterface, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString))); refreshDeviceList(); }
void UPower::probeDevices() { if (!m_interface) return; QDBusArgument argument = m_interface->call( "EnumerateDevices" ).arguments().at(0).value<QDBusArgument>(); if( m_interface->lastError().type() == QDBusError::NoError ) { argument.beginArray(); while( !argument.atEnd() ) { QDBusObjectPath dbusPath; argument >> dbusPath; deviceAdded(dbusPath.path()); } }
void UDiskProvider::dbusDeviceAdded(const QDBusObjectPath &path) { UDiskMountDevice *device = new UDiskMountDevice(path); if (device->isUsable()) { addDevice(device); emit deviceAdded(device); } else { delete device; } }
void AtemDeviceManager::initialize() { QList<AtemDeviceModel> models = DatabaseManager::getInstance().getAtemDevice(); foreach (const AtemDeviceModel& model, models) { QSharedPointer<AtemDevice> device(new AtemDevice(model.getAddress())); this->deviceModels.insert(model.getName(), model); this->devices.insert(model.getName(), device); emit deviceAdded(*device); device->connectDevice(); }
HotplugWatcherThread::HotplugWatcherThread(QObject *parent) : QThread(parent) { qDebug("当前线程id:%#x, %s", (unsigned int)QThread::currentThreadId(), __PRETTY_FUNCTION__); this->start(); this->moveToThread(this); //Let bool event(QEvent *e) be in another thread watcher = new QDeviceWatcher; watcher->moveToThread(this); watcher->appendEventReceiver(this); connect(watcher, SIGNAL(deviceAdded(QString)), this, SLOT(slot_DeviceAdded(QString))); connect(watcher, SIGNAL(deviceChanged(QString)), this, SLOT(slot_DeviceChanged(QString))); connect(watcher, SIGNAL(deviceRemoved(QString)), this, SLOT(slot_DeviceRemoved(QString))); watcher->start(); }
void Popup::addItem(Solid::Device device) { MenuDiskItem *item = new MenuDiskItem(device, this); connect(item, &MenuDiskItem::invalid, this, &Popup::onDeviceRemoved); item->setVisible(true); layout()->addWidget(item); mDisplayCount++; if (mDisplayCount != 0) mPlaceholder->hide(); if (isVisible()) realign(); emit deviceAdded(device); }
void SymbianDeviceManager::update(bool emitSignals) { static int n = 0; typedef SymbianDeviceList::iterator SymbianDeviceListIterator; if (debug) qDebug(">SerialDeviceLister::update(#%d, signals=%d)\n%s", n++, int(emitSignals), qPrintable(toString())); d->m_initialized = true; // Get ordered new list SymbianDeviceList newDevices = serialPorts() + blueToothDevices(); if (newDevices.size() > 1) qStableSort(newDevices.begin(), newDevices.end()); if (d->m_devices == newDevices) { // Happy, nothing changed. if (debug) qDebug("<SerialDeviceLister::update: unchanged\n"); return; } // Merge the lists and emit the respective added/removed signals, assuming // no one can plug a different device on the same port at the speed of lightning if (!d->m_devices.isEmpty()) { // Find deleted devices for (SymbianDeviceListIterator oldIt = d->m_devices.begin(); oldIt != d->m_devices.end(); ) { if (newDevices.contains(*oldIt)) { ++oldIt; } else { SymbianDevice toBeDeleted = *oldIt; toBeDeleted.forcedClose(); oldIt = d->m_devices.erase(oldIt); if (emitSignals) emit deviceRemoved(toBeDeleted); } } } if (!newDevices.isEmpty()) { // Find new devices and insert in order foreach(const SymbianDevice &newDevice, newDevices) { if (!d->m_devices.contains(newDevice)) { d->m_devices.append(newDevice); if (emitSignals) emit deviceAdded(newDevice); } } if (d->m_devices.size() > 1) qStableSort(d->m_devices.begin(), d->m_devices.end()); }
/** * Updates the current list of active devices */ void DeviceManager::updateDeviceList() { //fetch list of current devices GstElement *audioSink= createAudioSink(); QList<QByteArray> list; if (audioSink) { if (!PulseSupport::getInstance()->isActive()) { // If we're using pulse, the PulseSupport class takes care of things for us. list = GstHelper::extractProperties(audioSink, "device"); list.prepend("default"); } for (int i = 0 ; i < list.size() ; ++i) { QByteArray gstId = list.at(i); if (deviceId(gstId) == -1) { // This is a new device, add it m_audioDeviceList.append(AudioDevice(this, gstId)); emit deviceAdded(deviceId(gstId)); m_backend->logMessage(QString("Found new audio device %0").arg(QString::fromUtf8(gstId)), Backend::Debug, this); } } if (list.size() < m_audioDeviceList.size()) { //a device was removed for (int i = m_audioDeviceList.size() -1 ; i >= 0 ; --i) { QByteArray currId = m_audioDeviceList[i].gstId; bool found = false; for (int k = list.size() -1 ; k >= 0 ; --k) { if (currId == list[k]) { found = true; break; } } if (!found) { m_backend->logMessage(QString("Audio device lost %0").arg(QString::fromUtf8(currId)), Backend::Debug, this); emit deviceRemoved(deviceId(currId)); m_audioDeviceList.removeAt(i); } } } } gst_element_set_state (audioSink, GST_STATE_NULL); gst_object_unref (audioSink); }