本文整理汇总了C++中QDBusInterface::callWithArgumentList方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusInterface::callWithArgumentList方法的具体用法?C++ QDBusInterface::callWithArgumentList怎么用?C++ QDBusInterface::callWithArgumentList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusInterface
的用法示例。
在下文中一共展示了QDBusInterface::callWithArgumentList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dbusaction
ActionReply Helper::dbusaction(const QVariantMap& args)
{
ActionReply reply;
QDBusMessage dbusreply;
// Get arguments to method call
QString service = args["service"].toString();
QString path = args["path"].toString();
QString interface = args["interface"].toString();
QString method = args["method"].toString();
QList<QVariant> argsForCall = args["argsForCall"].toList();
QDBusConnection systembus = QDBusConnection::systemBus();
QDBusInterface *iface = new QDBusInterface (service,
path,
interface,
systembus,
this);
if (iface->isValid())
dbusreply = iface->callWithArgumentList(QDBus::AutoDetect, method, argsForCall);
delete iface;
// Error handling
if (method != "Reexecute")
{
if (dbusreply.type() == QDBusMessage::ErrorMessage)
{
reply.setErrorCode(ActionReply::DBusError);
reply.setErrorDescription(dbusreply.errorMessage());
}
}
// Reload systemd daemon to update the enabled/disabled status
if (method == "EnableUnitFiles" || method == "DisableUnitFiles" || method == "MaskUnitFiles" || method == "UnmaskUnitFiles")
{
// systemd does not update properties when these methods are called so we
// need to reload the systemd daemon.
iface = new QDBusInterface ("org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
systembus,
this);
dbusreply = iface->call(QDBus::AutoDetect, "Reload");
delete iface;
}
// return a reply
return reply;
}
示例2: unregisterAgent
bool QBluetoothPasskeyAgent_Private::unregisterAgent(const QString &localAdapter,
const QString &addr)
{
QString bluezAdapter = "/org/bluez";
if (!localAdapter.isNull()) {
bluezAdapter.append("/");
bluezAdapter.append(localAdapter);
}
QDBusInterface *iface = new QDBusInterface("org.bluez",
bluezAdapter,
"org.bluez.Security",
QDBusConnection::systemBus());
if (!iface->isValid())
return false;
QString bluezMethod;
QVariantList args;
QString path = m_name;
path.prepend('/');
args << path;
if (addr.isNull()) {
bluezMethod = "UnregisterDefaultPasskeyAgent";
}
else {
bluezMethod = "UnregisterPasskeyAgent";
args << addr;
}
QDBusReply<void> reply = iface->callWithArgumentList(QDBus::Block,
bluezMethod, args);
if (!reply.isValid()) {
handleError(reply.error());
return false;
}
return true;
}
示例3: data
//.........这里部分代码省略.........
QString toolTipText;
toolTipText.append("<FONT COLOR=white>");
toolTipText.append("<b>" + selUnit + "</b><hr>");
// Create a DBus interface
QDBusConnection bus("");
if (!userBus.isEmpty())
bus = QDBusConnection::connectToBus(userBus, "org.freedesktop.systemd1");
else
bus = QDBusConnection::systemBus();
QDBusInterface *iface;
// Use the DBus interface to get unit properties
if (!selUnitPath.isEmpty())
{
// Unit has a valid path
iface = new QDBusInterface ("org.freedesktop.systemd1",
selUnitPath,
"org.freedesktop.systemd1.Unit",
bus);
if (iface->isValid())
{
// Unit has a valid unit DBus object
toolTipText.append(i18n("<b>Description: </b>"));
toolTipText.append(iface->property("Description").toString());
toolTipText.append(i18n("<br><b>Unit file: </b>"));
toolTipText.append(iface->property("FragmentPath").toString());
toolTipText.append(i18n("<br><b>Unit file state: </b>"));
toolTipText.append(iface->property("UnitFileState").toString());
qulonglong ActiveEnterTimestamp = iface->property("ActiveEnterTimestamp").toULongLong();
toolTipText.append(i18n("<br><b>Activated: </b>"));
if (ActiveEnterTimestamp == 0)
toolTipText.append("n/a");
else
{
QDateTime timeActivated;
timeActivated.setMSecsSinceEpoch(ActiveEnterTimestamp/1000);
toolTipText.append(timeActivated.toString());
}
qulonglong InactiveEnterTimestamp = iface->property("InactiveEnterTimestamp").toULongLong();
toolTipText.append(i18n("<br><b>Deactivated: </b>"));
if (InactiveEnterTimestamp == 0)
toolTipText.append("n/a");
else
{
QDateTime timeDeactivated;
timeDeactivated.setMSecsSinceEpoch(InactiveEnterTimestamp/1000);
toolTipText.append(timeDeactivated.toString());
}
}
delete iface;
}
else
{
// Unit does not have a valid unit DBus object
// Retrieve UnitFileState from Manager object
iface = new QDBusInterface ("org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
bus);
QList<QVariant> args;
args << selUnit;
toolTipText.append(i18n("<b>Unit file: </b>"));
if (!selUnitFile.isEmpty())
toolTipText.append(selUnitFile);
toolTipText.append(i18n("<br><b>Unit file state: </b>"));
if (!selUnitFile.isEmpty())
toolTipText.append(iface->callWithArgumentList(QDBus::AutoDetect, "GetUnitFileState", args).arguments().at(0).toString());
delete iface;
}
// Journal entries for units
toolTipText.append(i18n("<hr><b>Last log entries:</b>"));
QStringList log = getLastJrnlEntries(selUnit);
if (log.isEmpty())
toolTipText.append(i18n("<br><i>No log entries found for this unit.</i>"));
else
{
for(int i = log.count()-1; i >= 0; --i)
{
if (!log.at(i).isEmpty())
toolTipText.append(QString("<br>" + log.at(i)));
}
}
toolTipText.append("</FONT");
return toolTipText;
}
return QVariant();
}