当前位置: 首页>>代码示例>>C++>>正文


C++ QDBusInterface::callWithArgumentList方法代码示例

本文整理汇总了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;
}
开发者ID:rthomsen,项目名称:kcmsystemd,代码行数:48,代码来源:helper.cpp

示例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;
}
开发者ID:Artox,项目名称:qtmoko,代码行数:43,代码来源:qbluetoothpasskeyagent.cpp

示例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();
}
开发者ID:cmacq2,项目名称:systemd-kcm,代码行数:101,代码来源:unitmodel.cpp


注:本文中的QDBusInterface::callWithArgumentList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。