QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent) : QWidget(parent), c(connection), objectPathRegExp(QLatin1String("\\[ObjectPath: (.*)\\]")) { services = new QTreeWidget; services->setRootIsDecorated(false); services->setHeaderLabels(QStringList(QLatin1String("Services"))); tree = new QTreeView; tree->setContextMenuPolicy(Qt::CustomContextMenu); connect(tree, SIGNAL(activated(QModelIndex)), this, SLOT(activate(QModelIndex))); refreshAction = new QAction(tr("&Refresh"), tree); refreshAction->setData(42); // increase the amount of 42 used as magic number by one refreshAction->setShortcut(QKeySequence::Refresh); connect(refreshAction, SIGNAL(triggered()), this, SLOT(refreshChildren())); QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, tree); connect(refreshShortcut, SIGNAL(activated()), this, SLOT(refreshChildren())); QVBoxLayout *topLayout = new QVBoxLayout(this); log = new QTextBrowser; connect(log, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(services, 1); layout->addWidget(tree, 2); topLayout->addLayout(layout); topLayout->addWidget(log); connect(services, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(serviceChanged(QTreeWidgetItem*))); connect(tree, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); if (c.isConnected()) { logMessage(QLatin1String("Connected to D-Bus.")); QDBusConnectionInterface *iface = c.interface(); connect(iface, SIGNAL(serviceRegistered(QString)), this, SLOT(serviceRegistered(QString))); connect(iface, SIGNAL(serviceUnregistered(QString)), this, SLOT(serviceUnregistered(QString))); connect(iface, SIGNAL(serviceOwnerChanged(QString,QString,QString)), this, SLOT(serviceOwnerChanged(QString,QString,QString))); } else { logError(QLatin1String("Cannot connect to D-Bus: ") + c.lastError().message()); } objectPathRegExp.setMinimal(true); }
NetworkManager::NetworkManager(QObject* parent) : QObject(parent), m_manager(NULL), m_getPropertiesWatcher(NULL), m_getTechnologiesWatcher(NULL), m_getServicesWatcher(NULL), m_defaultRoute(NULL), watcher(NULL), m_available(false) { registerCommonDataTypes(); watcher = new QDBusServiceWatcher("net.connman",QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectToConnman(QString))); connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(connmanUnregistered(QString))); m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman"); if(m_available) connectToConnman(); }
KPasswdServerLoop::KPasswdServerLoop() : m_seqNr(-1) { QDBusServiceWatcher *watcher = new QDBusServiceWatcher("org.kde.kded", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(kdedServiceUnregistered())); }
NetworkManager::NetworkManager(QObject* parent) : QObject(parent), m_manager(NULL), m_defaultRoute(NULL), m_invalidDefaultRoute(new NetworkService("/", QVariantMap(), this)), watcher(NULL), m_available(false), m_servicesEnabled(true), m_technologiesEnabled(true) { registerCommonDataTypes(); watcher = new QDBusServiceWatcher("net.connman",QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectToConnman(QString))); connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(connmanUnregistered(QString))); m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman"); if (m_available) connectToConnman(); else qDebug() << "connman not AVAILABLE"; }
SensorfwSensorBase::SensorfwSensorBase(QSensor *sensor) : QSensorBackend(sensor), m_sensorInterface(0), m_bufferSize(-1), m_prevOutputRange(0), m_efficientBufferSize(1), m_maxBufferSize(1), m_available(0), running(0) { watcher = new QDBusServiceWatcher("com.nokia.SensorService",QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectToSensord(QString))); connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(sensordUnregistered(QString))); m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("com.nokia.SensorService"); if (m_available) connectToSensord(); }
void JobViewServer::startServer() { QDBusConnection bus = QDBusConnection::sessionBus(); bus.unregisterService("org.kde.kuiserver"); bus.unregisterService("org.kde.JobViewServer"); bus.unregisterObject("/JobViewServer"); if (bus.registerService("org.kde.kuiserver") && bus.registerService("org.kde.JobViewServer") && bus.registerObject("/JobViewServer", this)) { connected = true; } else { connected = false; QDBusServiceWatcher* watcher = new QDBusServiceWatcher("org.kde.kuiserver", bus, QDBusServiceWatcher::WatchForUnregistration, this); QDBusServiceWatcher* watcher2 = new QDBusServiceWatcher("org.kde.JobViewServer", bus, QDBusServiceWatcher::WatchForUnregistration, this); QObject::connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(startServer())); QObject::connect(watcher, SIGNAL(serviceUnregistered(QString)), watcher, SLOT(deleteLater())); QObject::connect(watcher2, SIGNAL(serviceUnregistered(QString)), this, SLOT(startServer())); QObject::connect(watcher2, SIGNAL(serviceUnregistered(QString)), watcher2, SLOT(deleteLater())); } updateStatusIndicators(); }
/*! \internal */ QDBusConnectionInterface::QDBusConnectionInterface(const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(QLatin1String(DBUS_SERVICE_DBUS), QLatin1String(DBUS_PATH_DBUS), DBUS_INTERFACE_DBUS, connection, parent) { connect(this, SIGNAL(NameAcquired(QString)), this, SIGNAL(serviceRegistered(QString))); connect(this, SIGNAL(NameLost(QString)), this, SIGNAL(serviceUnregistered(QString))); connect(this, SIGNAL(NameOwnerChanged(QString,QString,QString)), this, SIGNAL(serviceOwnerChanged(QString,QString,QString))); }
UPower::UPower() : m_interfaceProps(0), m_interface(0) { m_watcher = new QDBusServiceWatcher; m_watcher->addWatchedService("org.freedesktop.UPower"); m_watcher->setConnection(QDBusConnection::systemBus()); m_watcher->setWatchMode( QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration ); connect(m_watcher, SIGNAL(serviceUnregistered(QString)), this, SIGNAL(upowerUnavailable())); connect(m_watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectInterfaces())); connect(this, SIGNAL(upowerAvailable()), this, SLOT(probeDevices())); connectInterfaces(); }
/*! \internal */ void QDBusConnectionInterface::disconnectNotify(const char *signalName) { // translate the signal names to what we really want // this avoids setting hooks for signals that don't exist on the bus if (qstrcmp(signalName, SIGNAL(serviceRegistered(QString))) == 0) QDBusAbstractInterface::disconnectNotify(SIGNAL(NameAcquired(QString))); else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0) QDBusAbstractInterface::disconnectNotify(SIGNAL(NameLost(QString))); else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) QDBusAbstractInterface::disconnectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString))); }
DBusWinIdProvider::DBusWinIdProvider(QWidget *referenceWindow) : QObject(referenceWindow), d(new Private(this, referenceWindow)) { Q_ASSERT(referenceWindow != nullptr); QDBusServiceWatcher *watcher = new QDBusServiceWatcher(QStringLiteral("org.freedesktop.akonaditray"), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(tryRegister())); QMetaObject::invokeMethod(this, "tryRegister", Qt::QueuedConnection); }
ConnectionAgentPlugin::ConnectionAgentPlugin(QObject *parent): QObject(parent), connManagerInterface(0) { connectiondWatcher = new QDBusServiceWatcher(CONND_SERVICE,QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(connectiondWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectToConnectiond(QString))); connect(connectiondWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(connectiondUnregistered(QString))); connectToConnectiond(); }
MixerEngine::MixerEngine(QObject *parent, const QVariantList &args) : Plasma::DataEngine(parent, args) , m_kmix(0) { Q_UNUSED(args) interface = QDBusConnection::sessionBus().interface(); watcher = new QDBusServiceWatcher( this ); watcher->addWatchedService( KMIX_DBUS_SERVICE ); watcher->setConnection( QDBusConnection::sessionBus() ); watcher->setWatchMode( QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration ); connect( watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(slotServiceRegistered(QString)) ); connect( watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(slotServiceUnregistered(QString)) ); init(); }
void ServiceRegistry::unregisterService(const std::string& name) { Poco::ScopedLockWithUnlock<FastMutex> lock(_mutex); ServiceMap::iterator it = _services.find(name); if (it != _services.end()) { ServiceEvent unregisteredEvent(it->second, ServiceEvent::EV_SERVICE_UNREGISTERED); _services.erase(it); lock.unlock(); serviceUnregistered(this, unregisteredEvent); _logger.information(std::string("Service unregistered: ") + name); } else throw Poco::NotFoundException(name); }
AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(QString service, QString path, QString interface, QObject *parent) : QObject(parent) , m_service(service) , m_path(path) , m_interface(interface) , m_watcher(new QDBusServiceWatcher(service, QDBusConnection::sessionBus())) , m_dbusInterface(0) { connect(m_watcher, SIGNAL(serviceRegistered(QString)), SLOT(createInterface())); connect(m_watcher, SIGNAL(serviceUnregistered(QString)), SLOT(destroyInterface())); // Connect to the service if it's up already QDBusConnectionInterface* sessionBus = QDBusConnection::sessionBus().interface(); QDBusReply<bool> reply = sessionBus->isServiceRegistered(m_service); if (reply.isValid() && reply.value()) { createInterface(); } }
/*! \internal */ void QDBusConnectionInterface::connectNotify(const char *signalName) { // translate the signal names to what we really want // this avoids setting hooks for signals that don't exist on the bus if (qstrcmp(signalName, SIGNAL(serviceRegistered(QString))) == 0) QDBusAbstractInterface::connectNotify(SIGNAL(NameAcquired(QString))); else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0) QDBusAbstractInterface::connectNotify(SIGNAL(NameLost(QString))); else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) { static bool warningPrinted = false; if (!warningPrinted) { qWarning("Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)"); warningPrinted = true; } QDBusAbstractInterface::connectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString))); } }
ClientImpl::ClientImpl(Client *interface, QObject *parent) : QObject(parent) , mInterface(interface) , mServiceWatcher(new QDBusServiceWatcher("org.razorqt.global_key_shortcuts", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this)) , mDaemonPresent(false) { connect(mServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(daemonDisappeared(QString))); connect(mServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(daemonAppeared(QString))); mProxy = new org::razorqt::global_key_shortcuts::native("org.razorqt.global_key_shortcuts", "/native", QDBusConnection::sessionBus(), this); mDaemonPresent = mProxy->isValid(); connect(this, SIGNAL(emitShortcutGrabbed(QString)), mInterface, SIGNAL(shortcutGrabbed(QString))); connect(this, SIGNAL(emitGrabShortcutFailed()), mInterface, SIGNAL(grabShortcutFailed())); connect(this, SIGNAL(emitGrabShortcutCancelled()), mInterface, SIGNAL(grabShortcutCancelled())); connect(this, SIGNAL(emitGrabShortcutTimedout()), mInterface, SIGNAL(grabShortcutTimedout())); connect(this, SIGNAL(emitDaemonDisappeared()), mInterface, SIGNAL(daemonDisappeared())); connect(this, SIGNAL(emitDaemonAppeared()), mInterface, SIGNAL(daemonAppeared())); connect(this, SIGNAL(emitDaemonPresenceChanged(bool)), mInterface, SIGNAL(daemonPresenceChanged(bool))); }
void SpeechClient::setupSpeechSystem() { if ( KStandardDirs::findExe( "kttsd" ).isEmpty() ) { kDebug() <<"KTTSD not installed, disable support"; d->isTextSpeechInstalled = false; } else { if ( QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kttsd") ) { d->isTextSpeechInstalled = true; } else { QString error; if (KToolInvocation::startServiceByDesktopName("kttsd", QString(), &error) != 0) { kDebug() <<"Starting KTTSD failed with message" << error; d->isTextSpeechInstalled = false; } else { d->isTextSpeechInstalled = true; } } if (d->isTextSpeechInstalled) { if ( !m_kspeech ) { m_kspeech = new org::kde::KSpeech("org.kde.kttsd", "/KSpeech", QDBusConnection::sessionBus()); m_kspeech->setParent(this); m_kspeech->setApplicationName("Akregator Speech Text"); connect(m_kspeech, SIGNAL(jobStateChanged(QString,int,int)), this, SLOT(textRemoved(QString,int,int))); connect( QDBusConnection::sessionBus().interface(), SIGNAL(serviceUnregistered(QString)), this, SLOT(slotServiceUnregistered(QString)) ); connect( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), this, SLOT(slotServiceOwnerChanged(QString,QString,QString)) ); } } }
Actions::Actions(QObject *parent) : QObject(parent) , mServiceWatcher(new QDBusServiceWatcher(QLatin1String("org.lxqt.global_key_shortcuts"), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this)) , mMultipleActionsBehaviour(MULTIPLE_ACTIONS_BEHAVIOUR_FIRST) { connect(mServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(on_daemonDisappeared(QString))); connect(mServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(on_daemonAppeared(QString))); mDaemonProxy = new org::lxqt::global_key_shortcuts::daemon(QLatin1String("org.lxqt.global_key_shortcuts"), QStringLiteral("/daemon"), QDBusConnection::sessionBus(), this); connect(mDaemonProxy, SIGNAL(actionAdded(qulonglong)), this, SLOT(on_actionAdded(qulonglong))); connect(mDaemonProxy, SIGNAL(actionEnabled(qulonglong, bool)), this, SLOT(on_actionEnabled(qulonglong, bool))); connect(mDaemonProxy, SIGNAL(clientActionSenderChanged(qulonglong, QString)), this, SLOT(on_clientActionSenderChanged(qulonglong, QString))); connect(mDaemonProxy, SIGNAL(actionModified(qulonglong)), this, SLOT(on_actionModified(qulonglong))); connect(mDaemonProxy, SIGNAL(actionRemoved(qulonglong)), this, SLOT(on_actionRemoved(qulonglong))); connect(mDaemonProxy, SIGNAL(actionShortcutChanged(qulonglong)), this, SLOT(on_actionShortcutChanged(qulonglong))); connect(mDaemonProxy, SIGNAL(actionsSwapped(qulonglong, qulonglong)), this, SLOT(on_actionsSwapped(qulonglong, qulonglong))); connect(mDaemonProxy, SIGNAL(multipleActionsBehaviourChanged(uint)), this, SLOT(on_multipleActionsBehaviourChanged(uint))); QTimer::singleShot(0, this, SLOT(delayedInit())); }
void ActivityEngine::init() { if (qApp->applicationName() == "plasma-netbook") { //hack for the netbook //FIXME can I read a setting or something instead? } else { m_activityController = new KActivities::Controller(this); m_currentActivity = m_activityController->currentActivity(); QStringList activities = m_activityController->listActivities(); //setData("allActivities", activities); foreach (const QString &id, activities) { insertActivity(id); } connect(m_activityController, SIGNAL(activityAdded(QString)), this, SLOT(activityAdded(QString))); connect(m_activityController, SIGNAL(activityRemoved(QString)), this, SLOT(activityRemoved(QString))); connect(m_activityController, SIGNAL(currentActivityChanged(QString)), this, SLOT(currentActivityChanged(QString))); //some convenience sources for times when checking every activity source would suck //it starts with _ so that it can easily be filtered out of sources() //maybe I should just make it not included in sources() instead? m_runningActivities = m_activityController->listActivities(KActivities::Info::Running); setData("Status", "Current", m_currentActivity); setData("Status", "Running", m_runningActivities); m_watcher = new QDBusServiceWatcher( ACTIVITYMANAGER_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(m_watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(enableRanking())); connect(m_watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(disableRanking())); if (QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITYMANAGER_SERVICE)) { enableRanking(); } }
DBusInterface::DBusInterface(QObject *parent) : QObject(parent) , m_serviceName(QStringLiteral("org.kde.KWin")) { (void) new KWinAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject(QStringLiteral("/KWin"), this); const QByteArray dBusSuffix = qgetenv("KWIN_DBUS_SERVICE_SUFFIX"); if (!dBusSuffix.isNull()) { m_serviceName = m_serviceName + QLatin1Char('.') + dBusSuffix; } if (!dbus.registerService(m_serviceName)) { QDBusServiceWatcher *dog = new QDBusServiceWatcher(m_serviceName, dbus, QDBusServiceWatcher::WatchForUnregistration, this); connect (dog, SIGNAL(serviceUnregistered(QString)), SLOT(becomeKWinService(QString))); } else { announceService(); } dbus.connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"), Workspace::self(), SLOT(slotReloadConfig())); }
DashClient::DashClient(QObject* parent) : QObject(parent) , m_dashDbusIface(0) , m_active(false) , m_alwaysFullScreen(false) { /* Check if the shell is already up and running by asking the bus instead of trying to create an instance of the interface. Creating an instance would cause D-Bus to activate the shell and we don’t want this to happen, the shell should be started on demand only. */ QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface(); QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(SHELL_DBUS_SERVICE); if (reply.isValid() && reply.value()) { connectToDash(); } QDBusServiceWatcher* watcher = new QDBusServiceWatcher(SHELL_DBUS_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash())); connect(watcher, SIGNAL(serviceUnregistered(QString)), SLOT(onDashDisconnect())); }
IdlenessWatcher::IdlenessWatcher(QObject* parent): Watcher(parent), mPSettings(), mErrorNotification(tr("LxQt Idleness watcher failed to start")), mDBusWatcher(this), mInhibitorCookie(0), mIsLocked(false) { qDebug() << "Starting idlenesswatcher"; mConn = X11Helper::connection(); xcb_prefetch_extension_data(mConn, &xcb_screensaver_id); xcb_prefetch_extension_data(mConn, &xcb_dpms_id); xcb_screensaver_query_version_cookie_t verCookie = xcb_screensaver_query_version_unchecked(mConn, XCB_SCREENSAVER_MAJOR_VERSION, XCB_SCREENSAVER_MINOR_VERSION); xcb_dpms_get_version_cookie_t dpmsVerCookie = xcb_dpms_get_version_unchecked(mConn, XCB_DPMS_MAJOR_VERSION, XCB_DPMS_MINOR_VERSION); // Note that XCB is asynchronous, so we want to make requests ASAP and get the responses as late as possible. mScreen = screenOfDisplay(mConn, 0); mErrorNotification.setUrgencyHint(LxQt::Notification::UrgencyCritical); mErrorNotification.setIcon("object-unlocked"); mErrorNotification.setTimeout(0); new ScreenSaverAdaptor(this); QDBusConnection sessionBus = QDBusConnection::sessionBus(); if (!sessionBus.registerService("org.freedesktop.ScreenSaver") || !sessionBus.registerObject("/ScreenSaver", this)) { mErrorNotification.setBody(tr("D-Bus interface org.freedesktop.ScreenSaver is already registered")); mErrorNotification.update(); qWarning() << "ERROR: D-Bus interface org.freedesktop.ScreenSaver is already registered"; } mDBusWatcher.setConnection(QDBusConnection::sessionBus()); mDBusWatcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration); connect(&mTimer, SIGNAL(timeout()), SLOT(idleTimeout())); connect(&mPSettings, SIGNAL(settingsChanged()), SLOT(restartTimer())); connect(&mDBusWatcher, SIGNAL(serviceUnregistered(QString)), SLOT(serviceUnregistered(QString))); connect(&mLockProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(screenUnlocked(int,QProcess::ExitStatus))); connect(&mErrorNotification, SIGNAL(actionActivated(int)), SLOT(notificationAction(int))); // Get XCB responses ... const xcb_query_extension_reply_t* extReply = xcb_get_extension_data(mConn, &xcb_screensaver_id); const xcb_query_extension_reply_t* dpmsExtReply = xcb_get_extension_data(mConn, &xcb_dpms_id); xcb_screensaver_query_version_reply_t* verReply = xcb_screensaver_query_version_reply(mConn, verCookie, NULL); xcb_dpms_get_version_reply_t* dpmsVerReply = xcb_dpms_get_version_reply(mConn, dpmsVerCookie, NULL); if (mScreen && extReply && extReply->present && dpmsExtReply && dpmsExtReply->present && verReply && dpmsVerReply && verReply->server_major_version == XCB_SCREENSAVER_MAJOR_VERSION && verReply->server_minor_version >= XCB_SCREENSAVER_MINOR_VERSION //&& dpmsVerReply->server_major_version == XCB_DPMS_MAJOR_VERSION //&& dpmsVerReply->server_minor_version >= XCB_DPMS_MINOR_VERSION ) { free(verReply); free(dpmsVerReply); } else { mErrorNotification.setBody(tr("The X11 Screensaver extension is not usable")); mErrorNotification.update(); if (verReply) free(verReply); qCritical() << "ERROR: Can't use the X11 Screensaver Extension!"; } mErrorNotification.setActions(QStringList(tr("Configure..."))); qDebug() << "LxQt Screenlocker started."; qDebug() << "timeout:" << getMaxIdleTimeoutMs() << "ms, lock command:" << mLockCommand; restartTimer(); }
OkularTTS::OkularTTS( QObject *parent ) : QObject( parent ), d( new Private( this ) ) { connect( &d->watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(slotServiceUnregistered(QString)) ); }
QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent) : QWidget(parent), c(connection), objectPathRegExp(QLatin1String("\\[ObjectPath: (.*)\\]")) { servicesModel = new QStringListModel(this); servicesFilterModel = new QSortFilterProxyModel(this); servicesFilterModel->setSourceModel(servicesModel); servicesFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); serviceFilterLine = new QLineEdit(this); serviceFilterLine->setPlaceholderText(tr("Search...")); servicesView = new QListView(this); servicesView->setModel(servicesFilterModel); connect(serviceFilterLine, SIGNAL(textChanged(QString)), servicesFilterModel, SLOT(setFilterFixedString(QString))); tree = new QTreeView; tree->setContextMenuPolicy(Qt::CustomContextMenu); connect(tree, SIGNAL(activated(QModelIndex)), this, SLOT(activate(QModelIndex))); refreshAction = new QAction(tr("&Refresh"), tree); refreshAction->setData(42); // increase the amount of 42 used as magic number by one refreshAction->setShortcut(QKeySequence::Refresh); connect(refreshAction, SIGNAL(triggered()), this, SLOT(refreshChildren())); QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, tree); connect(refreshShortcut, SIGNAL(activated()), this, SLOT(refreshChildren())); QVBoxLayout *layout = new QVBoxLayout(this); QSplitter *topSplitter = new QSplitter(Qt::Vertical, this); layout->addWidget(topSplitter); log = new QTextBrowser; connect(log, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); QSplitter *splitter = new QSplitter(topSplitter); splitter->addWidget(servicesView); QWidget *servicesWidget = new QWidget; QVBoxLayout *servicesLayout = new QVBoxLayout(servicesWidget); servicesLayout->addWidget(serviceFilterLine); servicesLayout->addWidget(servicesView); splitter->addWidget(servicesWidget); splitter->addWidget(tree); topSplitter->addWidget(splitter); topSplitter->addWidget(log); connect(servicesView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(serviceChanged(QModelIndex))); connect(tree, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); if (c.isConnected()) { logMessage(QLatin1String("Connected to D-Bus.")); QDBusConnectionInterface *iface = c.interface(); connect(iface, SIGNAL(serviceRegistered(QString)), this, SLOT(serviceRegistered(QString))); connect(iface, SIGNAL(serviceUnregistered(QString)), this, SLOT(serviceUnregistered(QString))); connect(iface, SIGNAL(serviceOwnerChanged(QString,QString,QString)), this, SLOT(serviceOwnerChanged(QString,QString,QString))); } else { logError(QLatin1String("Cannot connect to D-Bus: ") + c.lastError().message()); } objectPathRegExp.setMinimal(true); }
MDeclarativeStatusBar::MDeclarativeStatusBar(QDeclarativeItem *parent) : QDeclarativeItem(parent), updatesEnabled(true), mousePressed(false), feedbackDelay(false), swipeGesture(false), sharedPixmapHandle(0), pixmapDamage(0), mOrientation(MDeclarativeScreen::Portrait), #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) updateSharedTexture(false), #endif feedbackPlayer(new FeedbackPlayer(this)) { setFlag(QGraphicsItem::ItemHasNoContents, false); setAcceptedMouseButtons(Qt::LeftButton); // higher than TitleBar setZValue(1010); setImplicitHeight(STATUSBAR_HEIGHT); if (!filterRegistered) { #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ::oldEventFilter = QCoreApplication::instance()->setEventFilter(x11EventFilter); #else qApp->installNativeEventFilter(this); #endif #ifdef HAVE_XDAMAGE MDeclarativeScreen* screen = MDeclarativeScreen::instance(); XDamageQueryExtension(screen->display(), &xDamageEventBase, &xDamageErrorBase); #endif filterRegistered = true; } #ifdef HAVE_DBUS if (QDBusConnection::sessionBus().interface()->isServiceRegistered(PIXMAP_PROVIDER_DBUS_SERVICE)) isPixmapProviderOnline = true; else #endif isPixmapProviderOnline = false; #ifdef HAVE_DBUS dbusWatcher = new QDBusServiceWatcher( PIXMAP_PROVIDER_DBUS_SERVICE , QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration, this ); connect(dbusWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(handlePixmapProviderOnline())); connect(dbusWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(handlePixmapProviderOffline())); #endif querySharedPixmapFromProvider(); // XDamage event should come only when application is in foreground #if defined USE_ABSTRACTION QmlWindowState * windowState = QmlWindowState::instance(); #else MWindowState * windowState = MWindowState::instance(); #endif connect(windowState, SIGNAL(activeChanged()), this, SLOT(updateXdamageEventSubscription())); connect(this, SIGNAL(visibleChanged()), this, SLOT(updateXdamageEventSubscription())); if (!feedbackPlayer->init("qt-components")) { delete feedbackPlayer; feedbackPlayer = 0; } }