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


C++ QDBusObjectPath::path方法代码示例

本文整理汇总了C++中QDBusObjectPath::path方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusObjectPath::path方法的具体用法?C++ QDBusObjectPath::path怎么用?C++ QDBusObjectPath::path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDBusObjectPath的用法示例。


在下文中一共展示了QDBusObjectPath::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qWarning

/*!
    Finds a user by \a userName.
    Sync blocking API.

    \param userName The user name to look up.
    \return the corresponding UserAccount object.
*/
UserAccount *AccountsManager::findUserByName(const QString &userName)
{
    Q_D(AccountsManager);

    QDBusPendingReply<QDBusObjectPath> reply = d->interface->FindUserByName(userName);
    reply.waitForFinished();

    if (reply.isError()) {
        QDBusError error = reply.error();
        qWarning("Couldn't find user by user name %s: %s",
                 userName.toUtf8().constData(),
                 error.errorString(error.type()).toUtf8().constData());
        return 0;
    }

    QDBusObjectPath path = reply.argumentAt<0>();
    if (path.path().isEmpty())
        return Q_NULLPTR;

    UserAccount *account = d->usersCache.value(path.path(), Q_NULLPTR);
    if (!account) {
        account = new UserAccount(path.path(), d->interface->connection());
        d->usersCache[path.path()] = account;
    }
    return account;
}
开发者ID:AOSC-Dev,项目名称:qtaccountsservice,代码行数:33,代码来源:accountsmanager.cpp

示例2: interfaceError

QList<QVariantMap> TrackListInterfaceTest::testGetTracksMetadata(const QList<QDBusObjectPath>& trackIds)
{
    QDBusReply<QList<QVariantMap> > reply = iface->call("GetTracksMetadata");
    if (!reply.isValid()) {
        emit interfaceError(Method, "GetTracksMetadata", "Call to GetTracksMetadata failed with error " + reply.error().message());
    } else {
        QList<QVariantMap> metadataList = reply.value();
        QMap<QDBusObjectPath,QVariantMap> metadataMap;
        int i = 0;
        Q_FOREACH (const QVariantMap& metadata, metadataList) {
            if (metadata.isEmpty()) {
                emit interfaceWarning(Method, "GetTracksMetadata",
                        "Got an empty entry at position " + QString::number(i));
            } else if (!metadata.contains("mpris:trackid")) {
                emit interfaceError(Method, "GetTracksMetadata",
                        "No mpris:trackid entry at position " + QString::number(i));
            } else if (metadata.value("mpris:trackid").userType() != qMetaTypeId<QDBusObjectPath>()) {
                emit interfaceError(Method, "GetTracksMetadata",
                        "mpris:trackid entry was not sent as a D-Bus object path (D-Bus type 'o') at position " + QString::number(i));
            } else {
                QDBusObjectPath trackid = metadata.value("mpris:trackid").value<QDBusObjectPath>();
                if (trackid.path().isEmpty()) {
                    emit interfaceError(Method, "GetTracksMetadata",
                            "mpris:trackid entry is an empty path at position " + QString::number(i));
                } else if (!trackIds.contains(trackid)) {
                    emit interfaceWarning(Method, "GetTracksMetadata",
                            "Entry " + trackid.path() + " was not requested at position " + QString::number(i));
                } else {
                    metadataMap.put(trackid, metadata);
                }
            }
            ++i;
        }
    }
}
开发者ID:andyhelp,项目名称:pkg-mpristester,代码行数:35,代码来源:tracklistinterfacetest.cpp

示例3: userCached

/*!
    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);
        }
    });
}
开发者ID:AOSC-Dev,项目名称:qtaccountsservice,代码行数:38,代码来源:accountsmanager.cpp

示例4: sessionStarted

void QBluetoothTransferReplyBluez::sessionStarted(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QDBusObjectPath, QVariantMap> reply = *watcher;
    if (reply.isError()) {
        qCWarning(QT_BT_BLUEZ) << "Failed to start obex session:"
                               << reply.error().name() << reply.reply().errorMessage();

        m_errorStr = QBluetoothTransferReply::tr("Push session cannot be started");
        m_error = QBluetoothTransferReply::SessionError;
        m_finished = true;
        m_running = false;

        cleanupSession();

        emit QBluetoothTransferReply::error(m_error);
        emit finished(this);

        watcher->deleteLater();
        return;
    }

    const QDBusObjectPath path = reply.argumentAt<0>();
    const QVariantMap map = reply.argumentAt<1>();
    m_transfer_path = path.path();

    //watch the transfer
    OrgFreedesktopDBusPropertiesInterface *properties = new OrgFreedesktopDBusPropertiesInterface(
                            QStringLiteral("org.bluez.obex"), path.path(),
                            QDBusConnection::sessionBus(), this);
    connect(properties, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
            SLOT(sessionChanged(QString,QVariantMap,QStringList)));

    watcher->deleteLater();
}
开发者ID:vitiruiz,项目名称:dbus,代码行数:34,代码来源:qbluetoothtransferreply_bluez.cpp

示例5: _q_userDeleted

void AccountsManagerPrivate::_q_userDeleted(const QDBusObjectPath &path)
{
    Q_Q(AccountsManager);

    UserAccount *account = usersCache.value(path.path(), Q_NULLPTR);
    usersCache.remove(path.path());
    Q_EMIT q->userDeleted(account->userId());
    account->deleteLater();
}
开发者ID:AOSC-Dev,项目名称:qtaccountsservice,代码行数:9,代码来源:accountsmanager.cpp

示例6: InterfacesRemoved

void QtBluezDiscoveryManager::InterfacesRemoved(const QDBusObjectPath &object_path,
                                                const QStringList &interfaces)
{
    if (!d->references.contains(object_path.path())
            || !interfaces.contains(QStringLiteral("org.bluez.Adapter1")))
        return;

    removeAdapterFromMonitoring(object_path.path());
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:9,代码来源:bluez5_helper.cpp

示例7: interfacesRemoved

void NeardHelper::interfacesRemoved(const QDBusObjectPath &path, const QStringList &list)
{
    if (list.contains(QStringLiteral("org.neard.Record"))) {
        qCDebug(QT_NFC_NEARD) << "record removed" << path.path();
        emit recordRemoved(path);
    } else if (list.contains(QStringLiteral("org.neard.Tag"))) {
        qCDebug(QT_NFC_NEARD) << "tag removed" << path.path();
        emit tagRemoved(path);
    }
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:10,代码来源:neard_helper.cpp

示例8: RazorMountDevice

UDiskMountDevice::UDiskMountDevice(const QDBusObjectPath &path):
    RazorMountDevice(),
    mUdiskPath(path.path())
{
    mDbus = new QDBusInterface("org.freedesktop.UDisks",
                               path.path(),
                               "org.freedesktop.UDisks.Device",
                               QDBusConnection::systemBus(),
                               this);
    update();
}
开发者ID:PeterJespersen,项目名称:razor-qt,代码行数:11,代码来源:rzmountproviders.cpp

示例9: deviceRemoved

/*
 * DBus UDisk RemoveDevice handler
 */
void MediaMonitorUnix::deviceRemoved( QDBusObjectPath o)
{
    LOG(VB_MEDIA, LOG_INFO, LOC + "deviceRemoved " + o.path());
#if 0 // This fails because the DeviceFile has just been deleted
    QString dev = DeviceProperty(o, "DeviceFile");
    if (!dev.isEmpty())
        RemoveDevice(dev);
#else
    QString dev = QFileInfo(o.path()).baseName();
    dev.prepend("/dev/");
    RemoveDevice(dev);
#endif
}
开发者ID:mojie126,项目名称:mythtv,代码行数:16,代码来源:mediamonitor-unix.cpp

示例10: _q_userAdded

void AccountsManagerPrivate::_q_userAdded(const QDBusObjectPath &path)
{
    Q_Q(AccountsManager);

    if (usersCache.contains(path.path())) {
        Q_EMIT q->userAdded(usersCache[path.path()]);
        return;
    }

    UserAccount *account = new UserAccount(path.path(), interface->connection());
    usersCache[path.path()] = account;
    Q_EMIT q->userAdded(account);
}
开发者ID:AOSC-Dev,项目名称:qtaccountsservice,代码行数:13,代码来源:accountsmanager.cpp

示例11: dropEvent

void MainItem::dropEvent(QDropEvent *event)
{
    updateIcon(false);

    if (event->source())
        return;

    if (event->mimeData()->formats().indexOf("RequestDock") != -1){    //from desktop or launcher
        QJsonObject dataObj = QJsonDocument::fromJson(event->mimeData()->data("RequestDock")).object();
        if (!dataObj.isEmpty()){
            QString appKey = dataObj.value("appKey").toString();
            QString appName = dataObj.value("appName").toString();
            if (appKey.isEmpty())
                return;
            event->ignore();

            ConfirmUninstallDialog *dialog = new ConfirmUninstallDialog;
            //TODO: need real icon name
            dialog->setIcon(getThemeIconPath(appKey));
            QString message = tr("Are you sure to uninstall %1?").arg(appName);
            dialog->setMessage(message);
            connect(dialog, &ConfirmUninstallDialog::buttonClicked, [=](int key){
                dialog->deleteLater();
                if (key == 1){
                    qWarning() << "Uninstall application:" << appKey << appName;
                    m_launcher->RequestUninstall(appKey, true);
                }
            });
            dialog->exec();
        }
    }
    else//File or Dirctory
    {
        QStringList files;
        foreach (QUrl fileUrl, event->mimeData()->urls())
            files << fileUrl.path();

        QDBusPendingReply<QString, QDBusObjectPath, QString> tmpReply = m_dfo->NewTrashJob(files, false, "", "", "");
        QDBusObjectPath op = tmpReply.argumentAt(1).value<QDBusObjectPath>();
        DBusTrashJob * dtj = new DBusTrashJob(op.path(), this);
        connect(dtj, &DBusTrashJob::Done, dtj, &DBusTrashJob::deleteLater);
        connect(dtj, &DBusTrashJob::Done, [=](){
            updateIcon(false);
        });

        if (dtj->isValid())
            dtj->Execute();

        qWarning()<< op.path() << "Move files to trash: "<< files;
    }
}
开发者ID:tsuibin,项目名称:dde-dock,代码行数:51,代码来源:mainitem.cpp

示例12: RequestBrowser

void AgentAdaptor::RequestBrowser(const QDBusObjectPath &service_path, const QString &url)
{
    if (lastBrowserRequestService != service_path.path())
        browserRequestTimer.invalidate();

    if (!browserRequestTimer.isValid()) {
        lastBrowserRequestService = service_path.path();
        browserRequestTimer.start();
        m_userAgent->requestBrowser(service_path.path(), url);
    }
    if (browserRequestTimer.hasExpired(5 * 60 * 1000)) {
        browserRequestTimer.invalidate();
    }
}
开发者ID:TurpoUrpo,项目名称:libconnman-qt,代码行数:14,代码来源:useragent.cpp

示例13: findObject

QModelIndex QDBusModel::findObject(const QDBusObjectPath &objectPath)
{
    QStringList path = objectPath.path().split(QLatin1Char('/'), QString::SkipEmptyParts);

    QDBusItem *item = root;
    int childIdx = -1;
    while (item && !path.isEmpty()) {
        const QString branch = path.takeFirst() + QLatin1Char('/');
        childIdx = -1;

        // do a linear search over all the children
        for (int i = 0; i < item->children.count(); ++i) {
            QDBusItem *child = item->children.at(i);
            if (child->type == PathItem && child->name == branch) {
                item = child;
                childIdx = i;

                // prefetch the found branch
                if (!item->isPrefetched)
                    addPath(item);
                break;
            }
        }

        // branch not found - bail out
        if (childIdx == -1)
            return QModelIndex();
    }

    // found the right item
    if (childIdx != -1 && item && path.isEmpty())
        return createIndex(childIdx, 0, item);

    return QModelIndex();
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:35,代码来源:qdbusmodel.cpp

示例14: FindUniqueIdByPath

QString DeviceKitLister::FindUniqueIdByPath(const QDBusObjectPath &path) const {
  foreach (const DeviceData& data, device_data_) {
    if (data.dbus_path == path.path())
      return data.unique_id();
  }
  return QString();
}
开发者ID:schalkpd,项目名称:clementine-subsonic,代码行数:7,代码来源:devicekitlister.cpp

示例15:

void
MainWindow::deviceRemoved(QDBusMessage message)
{
    int index;
    QString devicePath;
#ifdef USEHAL
    devicePath = message.arguments().at(0).toString();
    if (devicePath.startsWith("/org/freedesktop/Hal/devices/storage_serial"))
#else
    QDBusObjectPath path = message.arguments().at(0).value<QDBusObjectPath>();
    devicePath = path.path();
    if (devicePath.startsWith("/org/freedesktop/UDisks/devices/"))
#endif
    {
        QLinkedList<DeviceItem *> list = pPlatform->getDeviceList();
        QLinkedList<DeviceItem *>::iterator i;
        for (i = list.begin(); i != list.end(); ++i)
        {
            if ((*i)->getUDI() == devicePath)
            {
                if (removeMenuItem((*i)->getDisplayString()) != -1)
                {
                    pPlatform->removeDeviceFromList(devicePath);
                    break;
                }
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:kiwi,代码行数:29,代码来源:MainWindow.cpp


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