void QmlIODevice::setDevice(QIODevice *io) { if(m_device != io) { //! 如果 m_device 被删除了怎么办? if(m_device != Q_NULLPTR) { disconnect(m_device, 0, this, 0); } m_device = io; if(m_device != Q_NULLPTR) { connect( m_device,SIGNAL(aboutToClose()), this, SIGNAL(aboutToClose()) ); connect( m_device, SIGNAL(bytesWritten(qint64)), this, SIGNAL(bytesWritten(qint64)) ); connect( m_device, SIGNAL(readChannelFinished()), this, SIGNAL(readChannelFinished()) ); connect( m_device, SIGNAL(readyRead()), this, SIGNAL(readyRead()) ); } emit deviceChanged(); emit hasDeviceChanged(this->hasDevice()); } }
void QUDisksInterface::connectNotify(const char *signal) { if (QLatin1String(signal) == SIGNAL(deviceChanged(QDBusObjectPath))) { if (!connection().connect(QLatin1String(UDISKS_SERVICE), UDISKS_PATH, UDISKS_SERVICE, "DeviceChanged", this, SIGNAL(deviceChanged(QDBusObjectPath)))) { qDebug() << "This is messed up"<<connection().lastError().message(); } } }
void DeviceSignalMapManager::mapDevice(Solid::StorageAccess *storageaccess, const QString &udi) { StorageAccessSignalMapper *map=0; if (!signalmap.contains(Solid::DeviceInterface::StorageAccess)) { map = new StorageAccessSignalMapper(this); signalmap[Solid::DeviceInterface::StorageAccess] = map; connect(map, SIGNAL(deviceChanged(QString,QString,QVariant)), user, SLOT(deviceChanged(QString,QString,QVariant))); } else { map = (StorageAccessSignalMapper*)signalmap[Solid::DeviceInterface::StorageAccess]; } connect(storageaccess, &Solid::StorageAccess::accessibilityChanged, map, &StorageAccessSignalMapper::accessibilityChanged); map->setMapping(storageaccess, udi); }
Device::Device(const QString &p, QObject *parent) : QObject(parent) , m_path(p) , m_type(Device::Undefined) { #ifndef NO_DBUS m_deviceInterface = new UDisksDeviceInterface("org.freedesktop.UDisks", m_path, QDBusConnection::systemBus(), this); if (!m_deviceInterface->isValid()) { m_valid = false; return; } m_valid = true; m_isPartition = m_deviceInterface->DeviceIsPartition(); m_mountPoint = m_deviceInterface->DeviceMountPath(); m_label = m_deviceInterface->IdLabel(); m_uuid = m_deviceInterface->IdUuid(); m_type = Device::UsbDrive; connect(m_deviceInterface, SIGNAL(Changed()), this, SLOT(deviceChanged())); #else // no implementation yet, so not valid m_valid = false; m_isPartition = false; #endif emit changed(); }
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))); }
QPulseAudioDeviceChooser::QPulseAudioDeviceChooser ( QPulseAudioThread * qpulseAudioThread, QWidget * parent = 0, Qt::WindowFlags f ) : QDialog ( parent, f ), _qpulseAudioDeviceModel ( qpulseAudioThread->devices(), qpulseAudioThread->sourcePosition(), this), _qpulseAudioThread ( qpulseAudioThread ) { setupUi ( this ); readSettings(); this->devicesListView->setModel ( &_qpulseAudioDeviceModel ); QHBoxLayout * hboxLayout = new QHBoxLayout(); hboxLayout->addWidget(this->layoutWidget); this->setLayout(hboxLayout); connect ( tryFirstPlayBackMonitorCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateDevicesListViewLock(int))); // Using the display index is fine as as we are getting the text associated with it // and passing the raw string to pulse audio. connect ( devicesListView, SIGNAL ( doubleClicked ( const QModelIndex& ) ), _qpulseAudioThread, SLOT ( connectDevice ( const QModelIndex& ) ) ); connect ( _qpulseAudioThread, SIGNAL ( deviceChanged()), &_qpulseAudioDeviceModel, SLOT (updateItemHighlights())); }
void DeviceSignalMapManager::mapDevice(Solid::Battery *battery, const QString &udi) { BatterySignalMapper *map=0; if (!signalmap.contains(Solid::DeviceInterface::Battery)) { map = new BatterySignalMapper(this); signalmap[Solid::DeviceInterface::Battery] = map; connect(map, SIGNAL(deviceChanged(QString,QString,QVariant)), user, SLOT(deviceChanged(QString,QString,QVariant))); } else { map = (BatterySignalMapper*)signalmap[Solid::DeviceInterface::Battery]; } connect(battery, &Solid::Battery::chargePercentChanged, map, &BatterySignalMapper::chargePercentChanged); connect(battery, &Solid::Battery::chargeStateChanged, map, &BatterySignalMapper::chargeStateChanged); connect(battery, &Solid::Battery::presentStateChanged, map, &BatterySignalMapper::presentStateChanged); map->setMapping(battery, udi); }
void CameraModeControl::setDevice(const QString &device) { if(device != m_device) { m_device = device; if(m_camera) { QMediaObject *mediaObject = m_camera ? qobject_cast<QMediaObject *>(m_camera->property("mediaObject").value<QObject*>()) : nullptr; if(mediaObject) { QVideoDeviceSelectorControl *videoDevice = mediaObject->service()->requestControl<QVideoDeviceSelectorControl*>(); if(videoDevice) { const int value = ("primary" == device) ? 0 : 1; if(videoDevice->selectedDevice() != value) { videoDevice->setSelectedDevice(value); } } } } emit deviceChanged(m_device); } }
bool Camera::reset(const QVariant& deviceId, const CameraMode& mode) { if (mode == Camera::UnknownMode) { qmlInfo(this) << "Cannot set mode to unknown"; return false; } QVariant oldId = m_id; Camera::CameraMode oldMode = m_mode; if (setDeviceId(deviceId) && setMode(mode)) { if (oldId != m_id) { emit deviceIdChanged(); resetCapabilities(); emit deviceChanged(); emit sensorOrientationAngleChanged(); } if (oldMode != m_mode) { emit modeChanged(); } return true; } return false; }
void QIODeviceInput::setDevice(QIODevice *dev) { DPTR_D(QIODeviceInput); if (d.dev == dev) return; d.dev = dev; emit deviceChanged(); }
void NetworkDevice::onStateChanged(uint newState, uint oldState, uint reason) { Q_UNUSED(oldState); qCDebug(dcNetworkManager()) << m_interface << "--> State changed:" << deviceStateToString(NetworkDeviceState(newState)) << ":" << deviceStateReasonToString(NetworkDeviceStateReason(reason)); if (m_deviceState != NetworkDeviceState(newState)) { m_deviceState = NetworkDeviceState(newState); emit deviceChanged(); } }
void LEDControl::setDevice(QString name) { qDebug() << "Storing device name " << name; m_device = name; emit deviceChanged(m_device); // store the new device name in settings applicationSettings->setValue("device",m_device); }
void UDiskProvider::dbusDeviceChanged(const QDBusObjectPath &path) { UDiskMountDevice *device = getDevice(path); if (!device) return; if (device->update()) emit deviceChanged(device); }
void OSCQueryDevice::slot_createDevice() { const auto& cur_settings = settings(); const auto& stgs = cur_settings.deviceSpecificSettings.value<OSCQuerySpecificSettings>(); try { std::unique_ptr<ossia::net::protocol_base> ossia_settings = std::make_unique<ossia::oscquery::oscquery_mirror_protocol>( stgs.host.toStdString()); auto& p = static_cast<ossia::oscquery::oscquery_mirror_protocol&>( *ossia_settings); m_mirror = &p; if (stgs.rate) { ossia_settings = std::make_unique<ossia::net::rate_limiting_protocol>( std::chrono::milliseconds{*stgs.rate}, std::move(ossia_settings)); } // run the commands in the Qt event loop // FIXME they should be disabled upon manual disconnection m_dev = std::make_unique<ossia::net::generic_device>( std::move(ossia_settings), settings().name.toStdString()); deviceChanged(nullptr, m_dev.get()); p.set_command_callback([=] { sig_command(); }); p.set_disconnect_callback([=] { sig_disconnect(); }); p.set_fail_callback([=] { sig_disconnect(); }); setLogging_impl(Device::get_cur_logging(isLogging())); enableCallbacks(); m_connected = true; } catch (std::exception& e) { qDebug() << "Could not connect: " << e.what(); m_connected = false; if (!m_dev) m_mirror = nullptr; } catch (...) { // TODO save the reason of the non-connection. m_connected = false; if (!m_dev) m_mirror = nullptr; } connectionChanged(m_connected); }
void QPulseAudioThread::connectDevice ( const QModelIndex & index ) { if (index.isValid()) reconnect(s_sourceList.begin() + index.row()); else reconnect(s_sourceList.end()); emit(deviceChanged()); }
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(); }
bool StorageMx508::startSharingOverUSB() { qDebug() << Q_FUNC_INFO; //Block sleep m_powerLock->activate(); Storage::startSharingOverUSB(); system("rmmod g_zero"); system("rmmod g_file_storage"); sharedDevices.clear(); QString command = QString("modprobe g_file_storage stall=0 file=" + publicPartition->getDevice()); sharedDevices << publicPartition->getDevice(); for (QMap<QString, StorageDevice*>::iterator it = _devices.begin(); it != _devices.end(); ++it) { StorageDevice *dev = it.value(); if (dev->getType() == StorageDevice::REMOVABLE && dev->isInserted() && removablePartition) { command += "," + removablePartition->getDevice(); sharedDevices << removablePartition->getDevice(); } } command += " removable=1"; system(command.toAscii().data()); //TODO: Netronix think we need wait 0.5 seconds here.... ¿? // Added waiting loop to avoid white screen when going to sleep QEventLoop waitingLoop; QTimer::singleShot(500, &waitingLoop, SLOT(quit())); waitingLoop.exec(); if (removablePartition && removablePartition->isMounted()) if(removablePartition->umount()) emit partitionUmounted(removablePartition); if (publicPartition->isMounted()) if(publicPartition->umount()) emit partitionUmounted(publicPartition); connect(this, SIGNAL(deviceChanged(QString)), this, SLOT(deviceUnshared(QString))); // FIXME: We should check for errors return true; }
bool KALPhonon::setDevice( const Phonon::AudioOutputDevice& device ) { // get the part of the device name that is common to Phonon and OpenAL QString phononDevice = device.name().remove( d->parentheses ); QStringList alDeviceList = KALEngine::deviceList().filter( phononDevice ); if( alDeviceList.isEmpty() ) { qWarning() << "Could not find any OpenAL device that matches current Phonon device"; return false; } d->alDevice = alDeviceList.first(); emit( deviceChanged( d->alDevice ) ); return true; }
void NetworkManager::reloadDevices() { const QJsonDocument doc = QJsonDocument::fromJson(m_networkInter->devices().toUtf8()); Q_ASSERT(doc.isObject()); const QJsonObject obj = doc.object(); NetworkDevice::NetworkTypes types = NetworkDevice::None; QSet<NetworkDevice> deviceSet; for (auto infoList(obj.constBegin()); infoList != obj.constEnd(); ++infoList) { Q_ASSERT(infoList.value().isArray()); const NetworkDevice::NetworkType deviceType = NetworkDevice::deviceType(infoList.key()); const auto list = infoList.value().toArray(); if (list.isEmpty()) continue; types |= deviceType; for (auto device : list) deviceSet.insert(NetworkDevice(deviceType, device.toObject())); } const QSet<NetworkDevice> removedDeviceList = m_deviceSet - deviceSet; for (auto dev : removedDeviceList) emit deviceRemoved(dev); for (auto dev : deviceSet) { if (m_deviceSet.contains(dev)) emit deviceChanged(dev); else emit deviceAdded(dev); } m_deviceSet = std::move(deviceSet); if (m_types == types) return; m_types = types; emit deviceTypesChanged(m_types); // qDebug() << "device type: " << m_types; }
void ColordEngine::init() { // Creates a ColorD interface, it must be created with new // otherwise the object will be deleted when this block ends QDBusInterface *interface; interface = new QDBusInterface(QLatin1String("org.freedesktop.ColorManager"), QLatin1String("/org/freedesktop/ColorManager"), QLatin1String("org.freedesktop.ColorManager"), QDBusConnection::systemBus(), this); // listen to colord for device events connect(interface, SIGNAL(DeviceAdded(QDBusObjectPath)), this, SLOT(deviceAdded(QDBusObjectPath))); connect(interface, SIGNAL(DeviceRemoved(QDBusObjectPath)), this, SLOT(deviceRemoved(QDBusObjectPath))); connect(interface, SIGNAL(DeviceChanged(QDBusObjectPath)), this, SLOT(deviceChanged(QDBusObjectPath))); // listen to colord for profile events connect(interface, SIGNAL(ProfileAdded(QDBusObjectPath)), this, SLOT(profileAdded(QDBusObjectPath))); connect(interface, SIGNAL(ProfileRemoved(QDBusObjectPath)), this, SLOT(profileRemoved(QDBusObjectPath))); connect(interface, SIGNAL(ProfileChanged(QDBusObjectPath)), this, SLOT(profileChanged(QDBusObjectPath))); // Ask for profiles QDBusMessage msg; msg = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ColorManager"), QLatin1String("/org/freedesktop/ColorManager"), QLatin1String("org.freedesktop.ColorManager"), QLatin1String("GetProfiles")); QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(gotProfiles(QDBusMessage))); // Ask for devices QDBusMessage message; message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ColorManager"), QLatin1String("/org/freedesktop/ColorManager"), QLatin1String("org.freedesktop.ColorManager"), QLatin1String("GetDevices")); QDBusConnection::systemBus().callWithCallback(message, this, SLOT(gotDevices(QDBusMessage))); }
bool QtPicBootloaderDriver::readDevice(const bool rethrow) { const bullycpp::PicDevice* optionalDevice = nullptr; // Our ISerialPort implementation may throw its TimeoutException try { optionalDevice = driver.readDevice(); } catch(SerialPort::TimeoutException&) { emit programmingStatusChanged(IProgressCallback::Status::Error, 0); if(rethrow) throw; } if(optionalDevice) { emit deviceChanged(QString::fromStdString(optionalDevice->name)); // Serial console wants us to throw the error so it can display it. return true; } else return false; }
AudioTest::AudioTest(QWidget *parent, Qt::WFlags f) : AudioDevicesBase(parent, f) { mode = QAudio::AudioOutput; connect(testButton, SIGNAL(clicked()), SLOT(test())); connect(modeBox, SIGNAL(activated(int)), SLOT(modeChanged(int))); connect(deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int))); connect(frequencyBox, SIGNAL(activated(int)), SLOT(freqChanged(int))); connect(channelsBox, SIGNAL(activated(int)), SLOT(channelChanged(int))); connect(codecsBox, SIGNAL(activated(int)), SLOT(codecChanged(int))); connect(sampleSizesBox, SIGNAL(activated(int)), SLOT(sampleSizeChanged(int))); connect(sampleTypesBox, SIGNAL(activated(int)), SLOT(sampleTypeChanged(int))); connect(endianBox, SIGNAL(activated(int)), SLOT(endianChanged(int))); modeBox->setCurrentIndex(0); modeChanged(0); deviceBox->setCurrentIndex(0); deviceChanged(0); }
void UdevNotifier::eventReady(int socket) { struct udev_device * dev; while (nullptr != (dev = udev_monitor_receive_device(d->monitor))) { QString const action = udev_device_get_action(dev); QString const device = udev_device_get_devpath(dev); if (QStringLiteral("add") == action) emit deviceAdded(std::move(device)); else if (QStringLiteral("remove") == action) emit deviceRemoved(std::move(device)); else if (QStringLiteral("change") == action) emit deviceChanged(std::move(device)); else if (QStringLiteral("online") == action) emit deviceOnline(std::move(device)); else if (QStringLiteral("offline") == action) emit deviceOffline(std::move(device)); udev_device_unref(dev); } }
/*----------------------------------------------------------------------------*/ bool Analyzer::selectDevice( int num ) { if (!mDeviceList) // nothing to select from return false; PRINT_DEBUG ("Old device: " << mActiveDevice); delete mActiveDevice; // it is always replaced mActiveDevice = (*mDeviceList)[num]; PRINT_DEBUG ("Selecting device: " << mActiveDevice << num); if (!mActiveDevice) { error("Selecting device failed"); return false; } connect( mActiveDevice, SIGNAL(packetArrived(IDevice*, QByteArray)), this, SLOT(addPacket(IDevice*, QByteArray)), Qt::DirectConnection ); emit deviceChanged( mActiveDevice ); return true; }
void AttributesEditor::connectSlots() { // General connect(_generalColorButton, SIGNAL(clicked()), this, SLOT(changeColor())); connect(_boxStartValue, SIGNAL(valueChanged(double)), this, SLOT(startChanged())); connect(_boxLengthValue, SIGNAL(valueChanged(double)), this, SLOT(lengthChanged())); connect(_boxName, SIGNAL(returnPressed()), this, SLOT(nameChanged())); connect(_networkTree, SIGNAL(startMessageValueChanged(QTreeWidgetItem *)), this, SLOT(startMessageChanged(QTreeWidgetItem *))); connect(_networkTree, SIGNAL(endMessageValueChanged(QTreeWidgetItem *)), this, SLOT(endMessageChanged(QTreeWidgetItem *))); connect(_snapshotAssignStart, SIGNAL(clicked()), this, SLOT(snapshotStartAssignment())); connect(_snapshotAssignEnd, SIGNAL(clicked()), this, SLOT(snapshotEndAssignment())); connect(_networkTree, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(addToExpandedItemsList(QTreeWidgetItem*))); connect(_networkTree, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(removeFromExpandedItemsList(QTreeWidgetItem*))); connect(_networkTree, SIGNAL(curveActivationChanged(QTreeWidgetItem*, bool)), this, SLOT(curveActivationChanged(QTreeWidgetItem*, bool))); connect(_networkTree, SIGNAL(curveRedundancyChanged(QTreeWidgetItem*, bool)), this, SLOT(curveRedundancyChanged(QTreeWidgetItem*, bool))); connect(_networkTree, SIGNAL(curveSampleRateChanged(QTreeWidgetItem*, int)), this, SLOT(curveSampleRateChanged(QTreeWidgetItem*, int))); connect(_networkTree, SIGNAL(messageChanged(QTreeWidgetItem*, QString)), this, SLOT(deployMessageChanged(QTreeWidgetItem*, QString))); connect(_networkTree, SIGNAL(deviceChanged(QString, QString)), this, SLOT(deployDeviceChanged(QString, QString))); }
void DeviceMuxer::setDevice(QIODevice* dev) { if (dev == _device) return; // Disconnect signals from old device if (_device) { disconnect(_device, SIGNAL(readyRead()), this, SLOT(handleReadyRead())); // disconnect(_device, SIGNAL(readChannelFinished()), // this, SIGNAL(readChannelFinished())); } QIODevice* oldDev = _device; _device = dev; // Connect signals to new device if (_device) { connect(_device, SIGNAL(readyRead()), this, SLOT(handleReadyRead()), Qt::QueuedConnection); } emit deviceChanged(oldDev, _device); }
void UdevNotifier::eventReady(int /*socket*/) { struct udev_device * dev; while (nullptr != (dev = udev_monitor_receive_device(d->monitor))) { const char *action = udev_device_get_action(dev); QString const device = QString::fromUtf8(udev_device_get_devnode(dev)); if (action && !device.isEmpty()) { if (qstrcmp(action, "add") == 0) emit deviceAdded(std::move(device)); else if (qstrcmp(action, "remove") == 0) emit deviceRemoved(std::move(device)); else if (qstrcmp(action, "change") == 0) emit deviceChanged(std::move(device)); else if (qstrcmp(action, "online") == 0) emit deviceOnline(std::move(device)); else if (qstrcmp(action, "offline") == 0) emit deviceOffline(std::move(device)); } udev_device_unref(dev); } }
VolumeButton::VolumeButton(RazorPanel *panel, QWidget* parent): QToolButton(parent), m_panel(panel), m_popupHideTimerDuration(1000), m_showOnClick(true), m_muteOnMiddleClick(true) { // initial icon for button. It will be replaced after devices scan. // In the worst case - no soundcard/pulse - is found it remains // in the button but at least the button is not blank ("invisible") handleStockIconChanged("dialog-error"); m_volumePopup = new VolumePopup(); connect(this, SIGNAL(clicked()), this, SLOT(toggleVolumeSlider())); connect(m_panel, SIGNAL(positionChanged()), this, SLOT(hideVolumeSlider())); connect(&m_popupHideTimer, SIGNAL(timeout()), this, SLOT(handlePopupHideTimeout())); connect(m_volumePopup, SIGNAL(mouseEntered()), this, SLOT(popupHideTimerStop())); connect(m_volumePopup, SIGNAL(mouseLeft()), this, SLOT(popupHideTimerStart())); connect(m_volumePopup, SIGNAL(deviceChanged()), this, SLOT(handleDeviceChanged())); connect(m_volumePopup, SIGNAL(launchMixer()), this, SLOT(handleMixerLaunch())); connect(m_volumePopup, SIGNAL(stockIconChanged(QString)), this, SLOT(handleStockIconChanged(QString))); }
/** * Process any relevant changes in the attached USB devices. * * Except for the first call, this is always running on the service thread. */ void USBProxyService::processChanges(void) { LogFlowThisFunc(("\n")); /* * Get the sorted list of USB devices. */ PUSBDEVICE pDevices = getDevices(); pDevices = sortDevices(pDevices); // get a list of all running machines while we're outside the lock // (getOpenedMachines requests higher priority locks) SessionMachinesList llOpenedMachines; mHost->parent()->getOpenedMachines(llOpenedMachines); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* * Compare previous list with the new list of devices * and merge in any changes while notifying Host. */ HostUSBDeviceList::iterator it = this->mDevices.begin(); while ( it != mDevices.end() || pDevices) { ComObjPtr<HostUSBDevice> pHostDevice; if (it != mDevices.end()) pHostDevice = *it; /* * Assert that the object is still alive (we still reference it in * the collection and we're the only one who calls uninit() on it. */ AutoCaller devCaller(pHostDevice.isNull() ? NULL : pHostDevice); AssertComRC(devCaller.rc()); /* * Lock the device object since we will read/write its * properties. All Host callbacks also imply the object is locked. */ AutoWriteLock devLock(pHostDevice.isNull() ? NULL : pHostDevice COMMA_LOCKVAL_SRC_POS); /* * Compare. */ int iDiff; if (pHostDevice.isNull()) iDiff = 1; else { if (!pDevices) iDiff = -1; else iDiff = pHostDevice->compare(pDevices); } if (!iDiff) { /* * The device still there, update the state and move on. The PUSBDEVICE * structure is eaten by updateDeviceState / HostUSBDevice::updateState(). */ PUSBDEVICE pCur = pDevices; pDevices = pDevices->pNext; pCur->pPrev = pCur->pNext = NULL; bool fRunFilters = false; SessionMachine *pIgnoreMachine = NULL; devLock.release(); alock.release(); if (updateDeviceState(pHostDevice, pCur, &fRunFilters, &pIgnoreMachine)) deviceChanged(pHostDevice, (fRunFilters ? &llOpenedMachines : NULL), pIgnoreMachine); alock.acquire(); it++; } else { if (iDiff > 0) { /* * Head of pDevices was attached. */ PUSBDEVICE pNew = pDevices; pDevices = pDevices->pNext; pNew->pPrev = pNew->pNext = NULL; ComObjPtr<HostUSBDevice> NewObj; NewObj.createObject(); NewObj->init(pNew, this); Log(("USBProxyService::processChanges: attached %p {%s} %s / %p:{.idVendor=%#06x, .idProduct=%#06x, .pszProduct=\"%s\", .pszManufacturer=\"%s\"}\n", (HostUSBDevice *)NewObj, NewObj->getName().c_str(), NewObj->getStateName(), pNew, pNew->idVendor, pNew->idProduct, pNew->pszProduct, pNew->pszManufacturer)); mDevices.insert(it, NewObj); devLock.release(); alock.release(); deviceAdded(NewObj, llOpenedMachines, pNew); alock.acquire(); } else { /* * Check if the device was actually detached or logically detached * as the result of a re-enumeration. */ if (!pHostDevice->wasActuallyDetached()) it++; else { it = mDevices.erase(it); devLock.release(); alock.release(); deviceRemoved(pHostDevice); Log(("USBProxyService::processChanges: detached %p {%s}\n", (HostUSBDevice *)pHostDevice, pHostDevice->getName().c_str())); /* from now on, the object is no more valid, * uninitialize to avoid abuse */ devCaller.release(); pHostDevice->uninit(); alock.acquire(); } } } } /* while */ LogFlowThisFunc(("returns void\n")); }
// system-config-printer --setup-printer='file:/tmp/printout' --devid='MFG:Ricoh;MDL:Aficio SP C820DN' PageDestinations::PageDestinations(const QVariantHash &args, QWidget *parent) : GenericPage(parent), ui(new Ui::PageDestinations), m_chooseLpd(new ChooseLpd(this)), m_chooseSamba(new ChooseSamba(this)), m_chooseSerial(new ChooseSerial(this)), m_chooseSocket(new ChooseSocket(this)), m_chooseUri(new ChooseUri(this)), m_chooseLabel(new QLabel(this)) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); ui->stackedWidget->addWidget(m_chooseLpd); connect(m_chooseLpd, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool))); ui->stackedWidget->addWidget(m_chooseSamba); connect(m_chooseSamba, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool))); ui->stackedWidget->addWidget(m_chooseSerial); connect(m_chooseSerial, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool))); ui->stackedWidget->addWidget(m_chooseSocket); connect(m_chooseSocket, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool))); ui->stackedWidget->addWidget(m_chooseUri); connect(m_chooseUri, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool))); m_chooseLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->stackedWidget->addWidget(m_chooseLabel); // Hide the message widget ui->messageWidget->setMessageType(KMessageWidget::Error); ui->messageWidget->hide(); // setup default options setWindowTitle(i18nc("@title:window", "Select a Printer to Add")); m_model = new DevicesModel(this); ui->devicesTV->setModel(m_model); ui->devicesTV->setItemDelegate(new NoSelectionRectDelegate(this)); connect(ui->devicesTV->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(deviceChanged())); connect(m_model, SIGNAL(errorMessage(QString)), ui->messageWidget, SLOT(setText(QString))); connect(m_model, SIGNAL(errorMessage(QString)), ui->messageWidget, SLOT(animatedShow())); // Expand when a parent is added connect(m_model, SIGNAL(parentAdded(QModelIndex)), ui->devicesTV, SLOT(expand(QModelIndex))); // Update the view when the device URI combo box changed connect(ui->connectionsCB, SIGNAL(currentIndexChanged(int)), this, SLOT(deviceUriChanged())); ui->connectionsGB->setVisible(false); // Setup the busy cursor working(); connect(m_model, SIGNAL(loaded()), this, SLOT(notWorking())); if (!args.isEmpty()) { // set our args setValues(args); } }