本文整理汇总了C++中QDBusPendingCallWatcher类的典型用法代码示例。如果您正苦于以下问题:C++ QDBusPendingCallWatcher类的具体用法?C++ QDBusPendingCallWatcher怎么用?C++ QDBusPendingCallWatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDBusPendingCallWatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qCWarning
void Handler::activateConnection(const QString& connection, const QString& device, const QString& specificObject)
{
NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection);
if (!con) {
qCWarning(NM) << "Not possible to activate this connection";
return;
}
if (con->settings()->connectionType() == NetworkManager::ConnectionSettings::Vpn) {
NetworkManager::VpnSetting::Ptr vpnSetting = con->settings()->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
if (vpnSetting) {
// qCDebug(NM) << "Checking VPN" << con->name() << "type:" << vpnSetting->serviceType();
#if 0
// get the list of supported VPN service types
const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin",
QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(vpnSetting->serviceType()));
if (services.isEmpty()) {
qCWarning(NM) << "VPN" << vpnSetting->serviceType() << "not found, skipping";
KNotification *notification = new KNotification("MissingVpnPlugin", KNotification::CloseOnTimeout, this);
notification->setComponentName("networkmanagement");
notification->setTitle(con->name());
notification->setText(i18n("Missing VPN plugin"));
notification->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(KIconLoader::SizeHuge));
notification->sendEvent();
return;
}
#endif
}
}
#if WITH_MODEMMANAGER_SUPPORT
if (con->settings()->connectionType() == NetworkManager::ConnectionSettings::Gsm) {
NetworkManager::ModemDevice::Ptr nmModemDevice = NetworkManager::findNetworkInterface(device).objectCast<NetworkManager::ModemDevice>();
if (nmModemDevice) {
ModemManager::ModemDevice::Ptr mmModemDevice = ModemManager::findModemDevice(nmModemDevice->udi());
if (mmModemDevice) {
ModemManager::Modem::Ptr modem = mmModemDevice->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
NetworkManager::GsmSetting::Ptr gsmSetting = con->settings()->setting(NetworkManager::Setting::Gsm).staticCast<NetworkManager::GsmSetting>();
if (gsmSetting && gsmSetting->pinFlags() == NetworkManager::Setting::NotSaved &&
modem && modem->unlockRequired() > MM_MODEM_LOCK_NONE) {
QDBusInterface managerIface("org.kde.plasmanetworkmanagement", "/org/kde/plasmanetworkmanagement", "org.kde.plasmanetworkmanagement", QDBusConnection::sessionBus(), this);
managerIface.call("unlockModem", mmModemDevice->uni());
connect(modem.data(), &ModemManager::Modem::unlockRequiredChanged, this, &Handler::unlockRequiredChanged);
m_tmpConnectionPath = connection;
m_tmpDevicePath = device;
m_tmpSpecificPath = specificObject;
return;
}
}
}
}
#endif
QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::activateConnection(connection, device, specificObject);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
watcher->setProperty("action", Handler::ActivateConnection);
watcher->setProperty("connection", con->name());
connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished);
}
示例2: QStringLiteral
void Mpris::checkConnection()
{
if (m_valid) {
QDBusConnection::sessionBus().disconnect(m_service, mprisPath, dbusPropertiesInterface,
QStringLiteral("PropertiesChanged"),
this, SLOT(propertiesChanged(QString, QMap<QString, QVariant>, QStringList)));
}
DBusInterface iface(dbusService, QStringLiteral("/"), dbusService);
if (!iface.isValid()) {
return;
}
QDBusPendingCall call = iface.asyncCall(QStringLiteral("ListNames"));
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call);
watcher->connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
QDBusPendingReply<QStringList> reply = *watcher;
if (reply.isError()) {
qDebug("Failed to get the list of DBus services.");
} else {
QStringList services = reply.value();
checkServices(services);
}
});
}
示例3: qCDebug
bool QFlatpakServices::openUrl(const QUrl &url)
{
qCDebug(QFlatpakPlatformServices) << "Open url: " << url;
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
QLatin1String("/org/freedesktop/portal/desktop"),
QLatin1String("org.freedesktop.portal.OpenURI"),
QLatin1String("OpenURI"));
// TODO get parent window id??
QString parentWindowId = QLatin1String("x11:")/* + QString::number(parent->winId())*/;
QVariantMap options; // TODO: handle "writable" option
message << parentWindowId << url.toDisplayString() << options;
QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
watcher->waitForFinished(); // TODO sorry for a blocking call, but we cannot do it asynchronous here
QDBusPendingReply<QDBusObjectPath> reply = *watcher;
if (reply.isError()) {
qCDebug(QFlatpakPlatformServices) << "Couldn't get reply";
return false;
}
return true;
}
示例4: QDBusPendingCallWatcher
void Handler::addConnection(const NMVariantMapMap& map)
{
QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::addConnection(map);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
watcher->setProperty("action", AddConnection);
watcher->setProperty("connection", map.value("connection").value("id"));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished);
}
示例5: Q_D
void NetworkManager::Connection::secrets(const QString &setting)
{
Q_D(Connection);
QString id = uuid();
QDBusPendingReply<NMVariantMapMap> reply = d->iface.GetSecrets(setting);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
watcher->setProperty("libNetworkManagerQt_id", id);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onSecretsArrived(QDBusPendingCallWatcher*)));
}
示例6: QDBusPendingCallWatcher
void DBusAsyncResponse::setPendingCall(QVariant variant)
{
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
{
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call);
watcher->setProperty("pengingCallVariant", variant);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onCallFinished(QDBusPendingCallWatcher*)));
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), watcher, SLOT(deleteLater()));
connect(&m_timeout, SIGNAL(timeout()), watcher, SLOT(deleteLater()));
m_timeout.start();
};
示例7: QDBusPendingCallWatcher
void DBusAsyncResponse::setPendingCall(QVariant variant)
{
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
{
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call);
watcher->setProperty("pengingCallVariant", variant);
connect(watcher, &QDBusPendingCallWatcher::finished, this, &DBusAsyncResponse::onCallFinished);
connect(watcher, &QDBusPendingCallWatcher::finished, watcher, &QObject::deleteLater);
connect(&m_timeout, &QTimer::timeout, watcher, &QObject::deleteLater);
m_timeout.start();
}
}
示例8: QDBusPendingCallWatcher
void AccountsWorker::randomUserIcon(User *user)
{
QDBusPendingCall call = m_accountsInter->RandUserIcon();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, [=] {
if (!call.isError()) {
QDBusReply<QString> reply = call.reply();
user->setCurrentAvatar(reply.value());
}
watcher->deleteLater();
});
}
示例9: kwinCallDBus
QScriptValue kwinCallDBus(QScriptContext *context, QScriptEngine *engine)
{
KWin::AbstractScript *script = qobject_cast<KWin::AbstractScript*>(context->callee().data().toQObject());
if (!script) {
context->throwError(QScriptContext::UnknownError, QStringLiteral("Internal Error: script not registered"));
return engine->undefinedValue();
}
if (context->argumentCount() < 4) {
context->throwError(QScriptContext::SyntaxError,
i18nc("Error in KWin Script",
"Invalid number of arguments. At least service, path, interface and method need to be provided"));
return engine->undefinedValue();
}
if (!KWin::validateArgumentType<QString, QString, QString, QString>(context)) {
context->throwError(QScriptContext::SyntaxError,
i18nc("Error in KWin Script",
"Invalid type. Service, path, interface and method need to be string values"));
return engine->undefinedValue();
}
const QString service = context->argument(0).toString();
const QString path = context->argument(1).toString();
const QString interface = context->argument(2).toString();
const QString method = context->argument(3).toString();
int argumentsCount = context->argumentCount();
if (context->argument(argumentsCount-1).isFunction()) {
--argumentsCount;
}
QDBusMessage msg = QDBusMessage::createMethodCall(service, path, interface, method);
QVariantList arguments;
for (int i=4; i<argumentsCount; ++i) {
if (context->argument(i).isArray()) {
QStringList stringArray = engine->fromScriptValue<QStringList>(context->argument(i));
arguments << qVariantFromValue(stringArray);
} else {
arguments << context->argument(i).toVariant();
}
}
if (!arguments.isEmpty()) {
msg.setArguments(arguments);
}
if (argumentsCount == context->argumentCount()) {
// no callback, just fire and forget
QDBusConnection::sessionBus().asyncCall(msg);
} else {
// with a callback
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(msg), script);
watcher->setProperty("callback", script->registerCallback(context->argument(context->argumentCount()-1)));
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), script, SLOT(slotPendingDBusCall(QDBusPendingCallWatcher*)));
}
return engine->undefinedValue();
}
示例10: QDBusPendingCallWatcher
PendingSeats* SeatTracker::listSeats()
{
PendingSeats *ps = new PendingSeats;
auto pendingReply = m_managerIface->ListSeats();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply);
connect(watcher, &QDBusPendingCallWatcher::finished, ps, [=]() {
QDBusPendingReply<NamedSeatPathList> reply = *watcher;
watcher->deleteLater();
QList<PendingSeat*> seatsToLoad;
foreach(const NamedSeatPath &seat, reply.value()) {
seatsToLoad << Seat::seatFromPath(seat.path);
}
ps->setPendingItems(seatsToLoad);
});
示例11: QDBusPendingCallWatcher
PendingSessions* SessionTracker::listSessions()
{
PendingSessions *ps = new PendingSessions;
auto pendingReply = m_managerIface->ListSessions();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply);
connect(watcher, &QDBusPendingCallWatcher::finished, ps, [=]() {
QDBusPendingReply<SessionInfoList> reply = *watcher;
watcher->deleteLater();
QList<PendingSession*> sessionsToLoad;
foreach(const SessionInfo &sessionInfo, reply.value()) {
sessionsToLoad << Session::sessionFromPath(sessionInfo.sessionPath);
}
ps->setPendingItems(sessionsToLoad);
});
示例12: Q_ASSERT
void AccountsWorker::setNopasswdLogin(User *user, const bool nopasswdLogin)
{
AccountsUser *userInter = m_userInters[user];
Q_ASSERT(userInter);
Q_EMIT requestFrameAutoHide(false);
QDBusPendingCall call = userInter->EnableNoPasswdLogin(nopasswdLogin);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] {
if (call.isError()) {
Q_EMIT user->nopasswdLoginChanged(user->nopasswdLogin());
}
Q_EMIT requestFrameAutoHide(true);
watcher->deleteLater();
});
}
示例13: iface
void Mpris::checkServices(const QStringList &services)
{
DBusInterface iface(dbusService, QStringLiteral("/"), dbusService);
foreach (QString service, services) {
QDBusPendingCall call = iface.asyncCall(QStringLiteral("GetConnectionUnixProcessID"), service);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call);
watcher->connect(watcher, &QDBusPendingCallWatcher::finished, [this, service](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
QDBusPendingReply<quint32> reply = *watcher;
if (reply.isError()) {
qDebug("Unable to get the pid of service %s.", qPrintable(service));
} else {
quint32 p = reply.value();
if (p == m_pid) {
checkService(service);
}
}
});
}
示例14: m_lineid
CallProxy::CallProxy(const QString &callPath)
: org::ofono::VoiceCall(OFONO_SERVICE,
callPath,
QDBusConnection::systemBus()),
m_lineid(QString()),
m_state(QString()),
m_startTime(QDateTime()),
m_reason(QString()),
m_connected(false),
m_multiparty(false)
{
TRACE;
if (!org::ofono::VoiceCall::isValid()) {
qCritical() << QString("Failed to connect to %1 for call %2:\n\t%3")
.arg(staticInterfaceName())
.arg(callPath)
.arg(lastError().message());
} else {
QDBusPendingReply<QVariantMap> reply;
QDBusPendingCallWatcher *watcher;
reply = GetProperties();
watcher = new QDBusPendingCallWatcher(reply);
// Force this to be sync to ensure we have initial properties
watcher->waitForFinished();
getPropertiesFinished(watcher);
if (isValid()) {
connect(this,
SIGNAL(PropertyChanged(const QString&,const QDBusVariant&)),
SLOT(propertyChanged(const QString&,const QDBusVariant&)));
connect(this, SIGNAL(DisconnectReason(const QString&)),
SLOT(disconnectReason(const QString&)));
} else {
qCritical() << QString("Invalid CallProxy instance: state == %1")
.arg(m_state);
}
}
示例15: QStringLiteral
SnorePlugin::Freedesktop::Freedesktop()
{
m_interface = new org::freedesktop::Notifications(QStringLiteral("org.freedesktop.Notifications"),
QStringLiteral("/org/freedesktop/Notifications"),
QDBusConnection::sessionBus(), this);
QDBusPendingReply<QStringList> reply = m_interface->GetCapabilities();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, [reply, watcher, this]() {
m_supportsRichtext = reply.value().contains(QStringLiteral("body-markup"));
watcher->deleteLater();
});
connect(this, &Freedesktop::enabledChanged, [this](bool enabled) {
if (enabled) {
connect(m_interface, &org::freedesktop::Notifications::ActionInvoked, this, &Freedesktop::slotActionInvoked);
connect(m_interface, &org::freedesktop::Notifications::NotificationClosed, this , &Freedesktop::slotNotificationClosed);
} else {
disconnect(m_interface, &org::freedesktop::Notifications::ActionInvoked, this, &Freedesktop::slotActionInvoked);
disconnect(m_interface, &org::freedesktop::Notifications::NotificationClosed, this , &Freedesktop::slotNotificationClosed);
}
});
}