本文整理汇总了C++中QDBusError::name方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusError::name方法的具体用法?C++ QDBusError::name怎么用?C++ QDBusError::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusError
的用法示例。
在下文中一共展示了QDBusError::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retrieveNotificationId
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();
}
}
示例2: launch
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();
}
示例3: init
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;
}
示例4: notifyKeyboardListenerError
void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& /*message*/)
{
qWarning() << QStringLiteral("QSpiApplication::keyEventError ") << error.name() << error.message();
while (!keyEvents.isEmpty()) {
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
QCoreApplication::postEvent(event.first, event.second);
}
}
示例5: notifyKeyboardListenerError
void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& /*message*/)
{
qWarning() << "QSpiApplication::keyEventError " << error.name() << error.message();
while (!keyEvents.isEmpty()) {
QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue();
if (event.first)
QCoreApplication::postEvent(event.first.data(), event.second);
}
}
示例6: 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;
}
示例7: handleError
void QBluetoothPasskeyAgent_Private::handleError(const QDBusError &error)
{
m_error = QBluetoothPasskeyAgent::UnknownError;
int i = 0;
while (bluez_errors[i].name) {
if (error.name() == bluez_errors[i].name) {
m_error = bluez_errors[i].error;
break;
}
i++;
}
}
示例8: save
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();
}
示例9: one
ConnectionManager::SocketConnectionStatus
ConnectionManager::setupSocketConnection()
{
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QLatin1String one("1");
if (environment.value(QLatin1String("SSO_USE_PEER_BUS"), one) != one) {
return SocketConnectionUnavailable;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QString runtimeDir =
QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
#else
QString runtimeDir = environment.value(QLatin1String("XDG_RUNTIME_DIR"));
#endif
if (runtimeDir.isEmpty()) return SocketConnectionUnavailable;
QString socketFileName =
QString::fromLatin1("unix:path=%1/" SIGNOND_SOCKET_FILENAME).arg(runtimeDir);
static int count = 0;
QDBusConnection connection =
QDBusConnection::connectToPeer(socketFileName,
QString(QLatin1String("libsignon-qt%1")).arg(count++));
if (!connection.isConnected()) {
QDBusError error = connection.lastError();
QString name = error.name();
BLAME() << "p2p error:" << error << error.type();
if (name == QLatin1String("org.freedesktop.DBus.Error.FileNotFound") &&
m_serviceStatus != ServiceActivated) {
return SocketConnectionNoService;
} else {
return SocketConnectionUnavailable;
}
}
m_connection = connection;
m_connection.connect(QString(),
QLatin1String("/org/freedesktop/DBus/Local"),
QLatin1String("org.freedesktop.DBus.Local"),
QLatin1String("Disconnected"),
this, SLOT(onDisconnected()));
return SocketConnectionOk;
}
示例10: getProperty
void getProperty(const QString &service, const QString &path, const QString &interfaceAndName)
{
QString property;
QString interface;
if (!splitInterfaceAndName(interfaceAndName, "Property", interface, property))
exit(1);
QDBusInterfacePtr iface(*connection, service, path, interface);
QVariant reply = iface->property(property.toLatin1());
if (reply.isNull()) {
QDBusError error = iface->lastError();
fprintf(stderr, "Could not get property '%s' on interface '%s': %s (%s)\n",
qPrintable(property), qPrintable(interface), qPrintable(error.name()),
qPrintable(error.message()));
exit(1);
}
printf("%s\n", qPrintable(reply.toString()));
}
示例11: notifyDBus
bool Notifications::notifyDBus(const QString &text) {
Q_ASSERT(m_interface);
if (!m_interface->isValid()) return false;
QString member = "Notify";
QVariantList params;
params << qApp->applicationName() << static_cast<unsigned int>(0);
params << "/home/h/Projects/qmpdclient/qmpdclient/icons/qmpdclient22.png";
params << qApp->applicationName() << text;
params << QStringList() << QMap<QString, QVariant>() << Config::instance()->notificationsTimeout()*1000;
QDBusMessage reply = m_interface->callWithArgumentList(QDBus::Block, member, params);
if (reply.type() == QDBusMessage::ErrorMessage) {
QDBusError err = reply;
qWarning("Error: %s\n%s", qPrintable(err.name()), qPrintable(err.message()));
return false;
} else if (reply.type() != QDBusMessage::ReplyMessage) {
qWarning("Invalid reply type %d", int(reply.type()));
return false;
}
return true;
}
示例12:
/*!
* This slot is called when an error is occured during the dbus communication.
* The error message is printed as a warning message.
*/
void
gprsBusinessLogic::DBusMessagingFailure (
QDBusError error)
{
SYS_WARNING ("%s: %s", SYS_STR (error.name()), SYS_STR (error.message()));
}
示例13:
QDebug operator<<(QDebug dbg, const QDBusError &msg)
{
dbg.nospace() << "QDBusError(" << msg.name() << ", " << msg.message() << ')';
return dbg.space();
}
示例14: saver
QDebug operator<<(QDebug dbg, const QDBusError &msg)
{
QDebugStateSaver saver(dbg);
dbg.nospace() << "QDBusError(" << msg.name() << ", " << msg.message() << ')';
return dbg;
}
示例15: placeCall
void placeCall(const QString &service, const QString &path, const QString &interface,
const QString &member, int argc, const char *const *argv)
{
QDBusInterfacePtr iface(*connection, service, path, interface);
if (!iface->isValid()) {
QDBusError err(iface->lastError());
fprintf(stderr, "Interface '%s' not available in object %s at %s:\n%s (%s)\n",
qPrintable(interface), qPrintable(path), qPrintable(service),
qPrintable(err.name()), qPrintable(err.message()));
exit(1);
}
const QMetaObject *mo = iface->metaObject();
QByteArray match = member.toLatin1();
match += '(';
int midx = -1;
for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
QMetaMethod mm = mo->method(i);
QByteArray signature = mm.signature();
if (signature.startsWith(match)) {
midx = i;
break;
}
}
if (midx == -1) {
fprintf(stderr, "Cannot find '%s.%s' in object %s at %s\n",
qPrintable(interface), qPrintable(member), qPrintable(path),
qPrintable(service));
exit(1);
}
QMetaMethod mm = mo->method(midx);
QList<QByteArray> types = mm.parameterTypes();
QVariantList params;
for (int i = 0; argc && i < types.count(); ++i) {
int id = QVariant::nameToType(types.at(i));
if ((id == QVariant::UserType || id == QVariant::Map) && types.at(i) != "QVariant") {
fprintf(stderr, "Sorry, can't pass arg of type %s yet\n",
types.at(i).constData());
exit(1);
}
if (id == QVariant::UserType)
id = QMetaType::type(types.at(i));
Q_ASSERT(id);
QVariant p;
if ((id == QVariant::List || id == QVariant::StringList) && QLatin1String("(") == argv[0])
p = readList(argc, argv);
else
p = QString::fromLocal8Bit(argv[0]);
if (id < int(QVariant::UserType)) {
// avoid calling it for QVariant
p.convert( QVariant::Type(id) );
if (p.type() == QVariant::Invalid) {
fprintf(stderr, "Could not convert '%s' to type '%s'.\n",
argv[0], types.at(i).constData());
exit(1);
}
} else if (types.at(i) == "QVariant") {
QVariant tmp(id, p.constData());
p = tmp;
}
params += p;
--argc;
++argv;
}
if (params.count() != types.count()) {
fprintf(stderr, "Invalid number of parameters\n");
exit(1);
}
QDBusMessage reply = iface->callWithArgs(member, params, QDBusInterface::NoUseEventLoop);
if (reply.type() == QDBusMessage::ErrorMessage) {
QDBusError err = reply;
printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message()));
exit(2);
} else if (reply.type() != QDBusMessage::ReplyMessage) {
fprintf(stderr, "Invalid reply type %d\n", int(reply.type()));
exit(1);
}
foreach (QVariant v, reply) {
if (v.userType() == QVariant::StringList) {
foreach (QString s, v.toStringList())
printf("%s\n", qPrintable(s));
} else {
if (v.userType() == qMetaTypeId<QVariant>())
v = qvariant_cast<QVariant>(v);
printf("%s\n", qPrintable(v.toString()));
}
}
exit(0);
}