本文整理汇总了C++中QDBusError类的典型用法代码示例。如果您正苦于以下问题:C++ QDBusError类的具体用法?C++ QDBusError怎么用?C++ QDBusError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDBusError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: launch
bool DBusLauncherImpl::launch(const QUrl& url, const QString& mimeType, QWidget* window)
{
if (!url.isValid()) return false;
if (url.isLocalFile()) return launch(url.path(), mimeType, window);
if (mimeType.isEmpty()) return launch(url, window);
QDBusError error;
QValueList<QVariant> params;
params.append(url.toString());
params.append(mimeType);
QDBusMessage reply = m_proxy->sendWithReply("LaunchURL", params, &error);
if (error.isValid())
{
qWarning("Error while launching through D-Bus:\nerror '%s'\nmessage '%s'",
error.name().local8Bit().data(), error.message().local8Bit().data());
return false;
}
if (reply.count() != 1 || reply[0].type() != QVariant::Bool)
{
qWarning("Unexpected launcher reply");
return false;
}
return reply[0].toBool();
}
示例2: Q_D
/*!
Cached a list of user accounts.
Async unblocking API.
*/
void AccountsManager::listCachedUsersAsync()
{
Q_D(AccountsManager);
QDBusPendingCall call = d->interface->ListCachedUsers();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) {
QDBusPendingReply< QList<QDBusObjectPath> > reply = *w;
w->deleteLater();
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't list cached users: %s",
error.errorString(error.type()).toUtf8().constData());
} else {
UserAccountList userList;
QList<QDBusObjectPath> value = reply.argumentAt<0>();
userList.reserve(value.size());
for (int i = 0; i < value.size(); i++) {
const QString path = value.at(i).path();
UserAccount *account = d->usersCache.value(path, Q_NULLPTR);
if (!account) {
account = new UserAccount(path, d->interface->connection());
d->usersCache[path] = account;
}
userList.append(account);
}
Q_EMIT listCachedUsersFinished(userList);
}
});
}
示例3: listCachedUsers
/*!
Caches a user account, so that it shows up in listCachedUsers() output.
The user name may be a remote user, but the system must be able to lookup
the user name and resolve the user information.
A userCached() signal with a UserAccount pointer will be emitted as soon
as the user account has been cached by AccountsService.
\param userName The user name for the user.
*/
void AccountsManager::cacheUser(const QString &userName)
{
Q_D(AccountsManager);
QDBusPendingCall call = d->interface->CacheUser(userName);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) {
QDBusPendingReply<QDBusObjectPath> reply = *w;
w->deleteLater();
if (reply.isError()) {
QDBusError error = reply.error();
qWarning("Couldn't cache user %s: %s",
userName.toUtf8().constData(),
error.errorString(error.type()).toUtf8().constData());
} else {
QDBusObjectPath path = reply.argumentAt<0>();
if (path.path().isEmpty())
return;
UserAccount *account = d->usersCache.value(path.path(), Q_NULLPTR);
if (!account) {
account = new UserAccount(path.path(), d->interface->connection());
d->usersCache[path.path()] = account;
}
Q_EMIT userCached(account);
}
});
}
示例4: OrgKdeKhotkeysInterface
bool KHotKeys::init()
{
khotkeys_inited = true;
// Check if khotkeys is running
QDBusConnection bus = QDBusConnection::sessionBus();
khotkeysInterface = new OrgKdeKhotkeysInterface(
"org.kde.kded",
"/modules/khotkeys",
bus,
NULL);
QDBusError err;
if(!khotkeysInterface->isValid())
{
err = khotkeysInterface->lastError();
if (err.isValid())
{
kError() << err.name() << ":" << err.message();
}
KMessageBox::error(
NULL,
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
}
khotkeys_present = khotkeysInterface->isValid();
return true;
}
示例5: sendDBusNotify
void CReporterNotificationPrivate::retrieveNotificationId()
{
if (callWatcher == 0)
return;
callWatcher->waitForFinished();
QDBusPendingReply<quint32> reply = *callWatcher;
callWatcher->deleteLater();
callWatcher = 0;
if (reply.isValid()) {
id = reply.argumentAt<0>();
if (id == 0) {
// Notification didn't exist, create a new one.
sendDBusNotify();
retrieveNotificationId();
return;
}
qDebug() << __PRETTY_FUNCTION__
<< "Create notification with id: " << id;
} else if (reply.isError()) {
QDBusError error = reply.error();
qDebug() << __PRETTY_FUNCTION__ << "Failed to create notification: "
<< error.name() << " - " << error.message();
}
}
示例6: fileInfo
bool DBusLauncherImpl::launch(const QString& fileName, const QString& mimeType,
QWidget* window)
{
QFileInfo fileInfo(fileName);
if (!fileInfo.exists() || !fileInfo.isReadable()) return false;
if (mimeType.isEmpty()) return launch(fileName, window);
QDBusError error;
QValueList<QVariant> params;
params.append(fileInfo.absFilePath());
params.append(mimeType);
QDBusMessage reply = m_proxy->sendWithReply("LaunchFile", params, &error);
if (error.isValid())
{
qWarning("Error while launching through D-Bus:\nerror '%s'\nmessage '%s'",
error.name().local8Bit().data(), error.message().local8Bit().data());
return false;
}
if (reply.count() != 1 || reply[0].type() != QVariant::Bool)
{
qWarning("Unexpected launcher reply");
return false;
}
return reply[0].toBool();
}
示例7: notifyKeyboardListenerError
void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& /*message*/)
{
qWarning() << "QSpiApplication::keyEventError " << error.name() << error.message();
while (!keyEvents.isEmpty()) {
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
QApplication::postEvent(event.first, event.second);
}
}
示例8: qDBusErrorToScriptValue
QScriptValue qDBusErrorToScriptValue(QScriptEngine *engine, const QDBusError &error)
{
QScriptValue v = engine->newObject();
v.setProperty(QLatin1String("type"), QScriptValue(engine, error.type()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("name"), QScriptValue(engine, error.name()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("message"), QScriptValue(engine, error.message()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("isValid"), QScriptValue(engine, error.isValid()), QScriptValue::ReadOnly);
return v;
}
示例9: setTimeZone
bool TimeDateCtl::setTimeZone(QString timeZone, QString& errorMessage)
{
mIface->call("SetTimezone", timeZone, true);
QDBusError err = mIface->lastError();
if(err.isValid())
{
errorMessage = err.message();
return false;
}
return true;
}
示例10: setUseNtp
bool TimeDateCtl::setUseNtp(bool value, QString& errorMessage)
{
mIface->call("SetNTP", value, true);
QDBusError err = mIface->lastError();
if(err.isValid())
{
errorMessage = err.message();
return false;
}
return true;
}
示例11: stopService
bool ServiceControl::stopService()
{
QDBusError reply;
systemd->call("StopUnit", ROCKPOOLD_SYSTEMD_UNIT, "replace");
systemd->call("DisableUnitFiles", QStringList() << ROCKPOOLD_SYSTEMD_UNIT, false);
if (reply.isValid()) {
qWarning() << reply.message();
return false;
} else {
systemd->call("Reload");
return true;
}
}
示例12: QString
QString KWinWaylandTouchpad::valueWriter(const Prop<T> &prop)
{
if (!prop.changed()) {
return QString();
}
m_iface->setProperty(prop.dbus, prop.val);
QDBusError error = m_iface->lastError();
if (error.isValid()) {
qCCritical(KCM_TOUCHPAD) << error.message();
return error.message();
}
return QString();
}
示例13: setDateTime
bool TimeDateCtl::setDateTime(QDateTime dateTime, QString& errorMessage)
{
// the timedatectl dbus service accepts "usec" input.
// Qt can only get "msec" => convert to usec here.
mIface->call("SetTime", dateTime.toMSecsSinceEpoch() * 1000, false, true);
QDBusError err = mIface->lastError();
if(err.isValid())
{
errorMessage = err.message();
return false;
}
return true;
}
示例14: applyCurrentItem
void KCMHotkeysPrivate::save()
{
if (current)
applyCurrentItem();
// Write the settings
model->save();
if (!KHotKeys::Daemon::isRunning())
{
if (!KHotKeys::Daemon::start())
{
// On startup the demon does the updating stuff, therefore reload
// the actions.
model->load();
}
else
{
KMessageBox::error(
q,
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
}
return;
}
// Inform kdedkhotkeys demon to reload settings
QDBusConnection bus = QDBusConnection::sessionBus();
QPointer<OrgKdeKhotkeysInterface> iface = new OrgKdeKhotkeysInterface(
"org.kde.kded",
"/modules/khotkeys",
bus,
q);
QDBusError err;
if(!iface->isValid())
{
err = iface->lastError();
if (err.isValid())
{
kError() << err.name() << ":" << err.message();
}
KMessageBox::error(
q,
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
return;
}
// Reread the configuration. We have no possibility to check if it worked.
iface->reread_configuration();
}
示例15: local
void WritePasswordJobPrivate::kwalletOpenFinished( QDBusPendingCallWatcher* watcher ) {
watcher->deleteLater();
QDBusPendingReply<int> reply = *watcher;
std::auto_ptr<QSettings> local( !q->settings() ? new QSettings( q->service() ) : 0 );
QSettings* actual = q->settings() ? q->settings() : local.get();
if ( reply.isError() ) {
if ( q->insecureFallback() ) {
if ( mode == Delete ) {
actual->remove( key );
actual->sync();
q->emitFinished();
return;
}
actual->setValue( QString( "%1/type" ).arg( key ), (int)mode );
if ( mode == Text )
actual->setValue( QString( "%1/data" ).arg( key ), textData.toUtf8() );
else if ( mode == Binary )
actual->setValue( QString( "%1/data" ).arg( key ), binaryData );
actual->sync();
q->emitFinished();
} else {
const QDBusError err = reply.error();
q->emitFinishedWithError( OtherError, tr("Could not open wallet: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) );
}
return;
}
if ( actual->contains( key ) )
{
// If we had previously written to QSettings, but we now have a kwallet available, migrate and delete old insecure data
actual->remove( key );
actual->sync();
}
const int handle = reply.value();
if ( handle < 0 ) {
q->emitFinishedWithError( AccessDenied, tr("Access to keychain denied") );
return;
}
QDBusPendingReply<int> nextReply;
if ( !textData.isEmpty() )
nextReply = iface->writePassword( handle, q->service(), key, textData, q->service() );
else if ( !binaryData.isEmpty() )
nextReply = iface->writeEntry( handle, q->service(), key, binaryData, q->service() );
else
nextReply = iface->removeEntry( handle, q->service(), key, q->service() );
QDBusPendingCallWatcher* nextWatcher = new QDBusPendingCallWatcher( nextReply, this );
connect( nextWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletWriteFinished(QDBusPendingCallWatcher*)) );
}