本文整理汇总了C++中QDBusMessage::interface方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusMessage::interface方法的具体用法?C++ QDBusMessage::interface怎么用?C++ QDBusMessage::interface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusMessage
的用法示例。
在下文中一共展示了QDBusMessage::interface方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: asyncCall
QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int) const
{
qDBusConnectionAsyncCallService = message.service();
qDBusConnectionAsyncCallPath = message.path();
qDBusConnectionAsyncCallInterface = message.interface();
qDBusConnectionAsyncCallMember = message.member();
qDBusConnectionAsyncCallArguments = message.arguments();
return QDBusPendingCall::fromCompletedCall(QDBusMessage());
}
示例2: handleMessage
bool DeclarativeDBusAdaptor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection)
{
QVariant variants[10];
QGenericArgument arguments[10];
const QMetaObject * const meta = metaObject();
const QVariantList dbusArguments = message.arguments();
QString member = message.member();
QString interface = message.interface();
// Don't try to handle introspect call. It will be handled
// internally for QDBusVirtualObject derived classes.
if (interface == QLatin1String("org.freedesktop.DBus.Introspectable")) {
return false;
} else if (interface == QLatin1String("org.freedesktop.DBus.Properties")) {
if (member == QLatin1String("Get")) {
interface = dbusArguments.value(0).toString();
member = dbusArguments.value(1).toString();
const QMetaObject * const meta = metaObject();
if (!member.isEmpty() && member.at(0).isUpper())
member = "rc" + member;
for (int propertyIndex = meta->propertyOffset();
propertyIndex < meta->propertyCount();
++propertyIndex) {
QMetaProperty property = meta->property(propertyIndex);
if (QLatin1String(property.name()) != member)
continue;
QVariant value = property.read(this);
if (value.userType() == qMetaTypeId<QJSValue>())
value = value.value<QJSValue>().toVariant();
if (value.userType() == QVariant::List) {
QVariantList variantList = value.toList();
if (variantList.count() > 0) {
QDBusArgument list;
list.beginArray(variantList.first().userType());
foreach (const QVariant &listValue, variantList) {
list << listValue;
}
list.endArray();
value = QVariant::fromValue(list);
}
}
QDBusMessage reply = message.createReply(QVariantList() << value);
connection.call(reply, QDBus::NoBlock);
return true;
}
示例3: dumpMessage
void QDBusViewer::dumpMessage(const QDBusMessage &message)
{
QList<QVariant> args = message.arguments();
QString out = QLatin1String("Received ");
switch (message.type()) {
case QDBusMessage::SignalMessage:
out += QLatin1String("signal ");
break;
case QDBusMessage::ErrorMessage:
out += QLatin1String("error message ");
break;
case QDBusMessage::ReplyMessage:
out += QLatin1String("reply ");
break;
default:
out += QLatin1String("message ");
break;
}
out += QLatin1String("from ");
out += message.service();
if (!message.path().isEmpty())
out += QLatin1String(", path ") + message.path();
if (!message.interface().isEmpty())
out += QLatin1String(", interface <i>") + message.interface() + QLatin1String("</i>");
if (!message.member().isEmpty())
out += QLatin1String(", member ") + message.member();
out += QLatin1String("<br>");
if (args.isEmpty()) {
out += QLatin1String(" (no arguments)");
} else {
out += QLatin1String(" Arguments: ");
foreach (QVariant arg, args) {
QString str = Qt::escape(QDBusUtil::argumentToString(arg));
// turn object paths into clickable links
str.replace(objectPathRegExp, QLatin1String("[ObjectPath: <a href=\"qdbus://bus\\1\">\\1</a>]"));
out += str;
out += QLatin1String(", ");
}
out.chop(2);
}
示例4: debugVariantList
QDebug operator<<(QDebug dbg, const QDBusMessage &msg)
{
dbg.nospace() << "QDBusMessage(type=" << msg.type()
<< ", service=" << msg.service();
if (msg.type() == QDBusMessage::MethodCallMessage ||
msg.type() == QDBusMessage::SignalMessage)
dbg.nospace() << ", path=" << msg.path()
<< ", interface=" << msg.interface()
<< ", member=" << msg.member();
if (msg.type() == QDBusMessage::ErrorMessage)
dbg.nospace() << ", error name=" << msg.errorName()
<< ", error message=" << msg.errorMessage();
dbg.nospace() << ", signature=" << msg.signature()
<< ", contents=(";
debugVariantList(dbg, msg.arguments());
dbg.nospace() << ") )";
return dbg.space();
}
示例5: messageToScriptValue
static QScriptValue messageToScriptValue(QScriptEngine *engine, const QDBusMessage &message)
{
QScriptValue v = engine->newVariant(QVariant::fromValue(message));
v.setProperty(QLatin1String("service"), QScriptValue(engine, message.service()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("path"), QScriptValue(engine, message.path()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("interface"), QScriptValue(engine, message.interface()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("member"), QScriptValue(engine, message.member()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("type"), QScriptValue(engine, message.type()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("signature"), QScriptValue(engine, message.signature()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("isReplyRequired"), QScriptValue(engine, message.isReplyRequired()), QScriptValue::ReadOnly);
v.setProperty(QLatin1String("delayedReply"), QScriptValue(engine, message.isDelayedReply()));
QScriptValue argValue = engine->newArray();
const QList<QVariant> args = message.arguments();
for (int i = 0; i < args.count(); ++i)
argValue.setProperty(QScriptValue(engine, i).toString(),
engine->newVariant(args.at(i)));
v.setProperty(QLatin1String("arguments"), argValue);
return v;
}
示例6: handleMessage
bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnection& connection)
{
/* Check to make sure we're getting properties on our interface */
if (message.type() != QDBusMessage::MessageType::MethodCallMessage) {
return false;
}
/* Break down the path to just the app id */
bool validpath = true;
QString pathtemp = message.path();
if (!pathtemp.startsWith(QLatin1String("/com/canonical/Unity/Launcher/"))) {
validpath = false;
}
pathtemp.remove(QStringLiteral("/com/canonical/Unity/Launcher/"));
if (pathtemp.indexOf('/') >= 0) {
validpath = false;
}
/* Find ourselves an appid */
QString appid = decodeAppId(pathtemp);
// First handle methods of the Launcher interface
if (message.interface() == QLatin1String("com.canonical.Unity.Launcher")) {
if (message.member() == QLatin1String("Refresh")) {
QDBusMessage reply = message.createReply();
Q_EMIT refreshCalled();
return connection.send(reply);
}
} else if (message.interface() == QLatin1String("com.canonical.Unity.Launcher.Item")) {
// Handle methods of the Launcher-Item interface
if (message.member() == QLatin1String("Alert") && validpath) {
QDBusMessage reply = message.createReply();
Q_EMIT alertCalled(appid);
return connection.send(reply);
}
}
// Now handle dynamic properties (for launcher emblems)
if (message.interface() != QLatin1String("org.freedesktop.DBus.Properties")) {
return false;
}
if (message.member() == QLatin1String("Get") && (message.arguments().count() != 2 || message.arguments()[0].toString() != QLatin1String("com.canonical.Unity.Launcher.Item"))) {
return false;
}
if (message.member() == QLatin1String("Set") && (message.arguments().count() != 3 || message.arguments()[0].toString() != QLatin1String("com.canonical.Unity.Launcher.Item"))) {
return false;
}
if (!validpath) {
return false;
}
int index = m_launcherModel->findApplication(appid);
LauncherItem *item = static_cast<LauncherItem*>(m_launcherModel->get(index));
QVariantList retval;
if (message.member() == QLatin1String("Get")) {
QString cachedString = message.arguments()[1].toString();
if (!item) {
return false;
}
if (cachedString == QLatin1String("count")) {
retval.append(QVariant::fromValue(QDBusVariant(item->count())));
} else if (cachedString == QLatin1String("countVisible")) {
retval.append(QVariant::fromValue(QDBusVariant(item->countVisible())));
} else if (cachedString == QLatin1String("progress")) {
retval.append(QVariant::fromValue(QDBusVariant(item->progress())));
}
} else if (message.member() == QLatin1String("Set")) {
QString cachedString = message.arguments()[1].toString();
if (cachedString == QLatin1String("count")) {
int newCount = message.arguments()[2].value<QDBusVariant>().variant().toInt();
if (!item || newCount != item->count()) {
Q_EMIT countChanged(appid, newCount);
notifyPropertyChanged(QStringLiteral("com.canonical.Unity.Launcher.Item"), encodeAppId(appid), QStringLiteral("count"), QVariant(newCount));
}
} else if (cachedString == QLatin1String("countVisible")) {
bool newVisible = message.arguments()[2].value<QDBusVariant>().variant().toBool();
if (!item || newVisible != item->countVisible()) {
Q_EMIT countVisibleChanged(appid, newVisible);
notifyPropertyChanged(QStringLiteral("com.canonical.Unity.Launcher.Item"), encodeAppId(appid), QStringLiteral("countVisible"), newVisible);
}
} else if (cachedString == QLatin1String("progress")) {
int newProgress = message.arguments()[2].value<QDBusVariant>().variant().toInt();
if (!item || newProgress != item->progress()) {
Q_EMIT progressChanged(appid, newProgress);
notifyPropertyChanged(QStringLiteral("com.canonical.Unity.Launcher.Item"), encodeAppId(appid), QStringLiteral("progress"), QVariant(newProgress));
}
}
} else if (message.member() == QLatin1String("GetAll")) {
if (item) {
QVariantMap all;
all.insert(QStringLiteral("count"), item->count());
all.insert(QStringLiteral("countVisible"), item->countVisible());
all.insert(QStringLiteral("progress"), item->progress());
retval.append(all);
}
} else {
//.........这里部分代码省略.........
示例7: handleMethodCall
// QT3 DBus message handler:
bool LapsusDaemon::handleMethodCall(const QDBusMessage& message)
{
if (message.interface() != LAPSUS_INTERFACE) return false;
if (message.type() != QDBusMessage::MethodCallMessage) return false;
if (message.member() == "listFeatures"
|| message.member() == "listSwitches"
|| message.member() == "listDisplayTypes"
|| message.member() == "getMaxBacklight"
|| message.member() == "getBacklight")
{
if (message.count() != 0)
{
return returnDBusError("org.freedesktop.DBus.Error"
".InvalidSignature", "Expected no arguments",
message);
}
QDBusMessage reply = QDBusMessage::methodReply(message);
if (message.member() == "listFeatures")
{
reply << QDBusData::fromList(listFeatures());
}
else if (message.member() == "listSwitches")
{
reply << QDBusData::fromList(listSwitches());
}
else if (message.member() == "listDisplayTypes")
{
reply << QDBusData::fromList(listDisplayTypes());
}
else if (message.member() == "getMaxBacklight")
{
reply << QDBusData::fromUInt32(getMaxBacklight());
}
else if (message.member() == "getBacklight")
{
reply << QDBusData::fromUInt32(getBacklight());
}
else
{
// Should not happen...
// TODO - some kind of error? to syslog? using dbus?
reply << QDBusData::fromUInt32(0);
}
myConnection->send(reply);
return true;
}
else if (message.member() == "getSwitch"
|| message.member() == "getDisplay")
{
if (message.count() != 1 || message[0].type() != QDBusData::String)
{
return returnDBusError("org.freedesktop.DBus.Error"
".InvalidSignature",
"Expected one string argument",
message);
}
QDBusMessage reply = QDBusMessage::methodReply(message);
if (message.member() == "getSwitch")
{
reply << QDBusData::fromBool(
getSwitch(message[0].toString()));
}
else if (message.member() == "getDisplay")
{
reply << QDBusData::fromBool(
getDisplay(message[0].toString()));
}
else
{
// Should not happen...
// TODO - some kind of error? to syslog? using dbus?
reply << QDBusData::fromBool(false);
}
myConnection->send(reply);
return true;
}
else if (message.member() == "setSwitch"
|| message.member() == "setDisplay")
{
if (message.count() != 2
|| message[0].type() != QDBusData::String
|| message[1].type() != QDBusData::Bool)
{
return returnDBusError("org.freedesktop.DBus.Error"
".InvalidSignature",
"Expected two arguments: string and bool",
message);
}
//.........这里部分代码省略.........
示例8: handleMethodCall
bool LauncherService::handleMethodCall(const QDBusMessage& message)
{
if (message.interface() != interface) return false;
bool ret;
QDBusError error;
if (message.member() == "LaunchFile")
{
switch (message.count())
{
case 1:
if (message[0].type() == QVariant::String)
ret = launch(message[0].toString(), error);
else
return false;
break;
case 2:
if (message[0].type() == QVariant::String &&
message[1].type() == QVariant::String)
{
ret = launch(message[0].toString(), message[1].toString(), error);
}
else
return false;
break;
default:
return false;
}
}
else if (message.member() == "LaunchURL")
{
switch (message.count())
{
case 1:
if (message[0].type() == QVariant::String)
ret = launch(QUrl(message[0].toString()), error);
else
return false;
break;
case 2:
if (message[0].type() == QVariant::String &&
message[1].type() == QVariant::String)
{
ret = launch(QUrl(message[0].toString()), message[1].toString(), error);
}
else
return false;
break;
default:
return false;
}
}
else
return false;
sendReply(message, ret, error);
return true;
}