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


C++ QDBusError::isValid方法代码示例

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


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

示例1: 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;
}
开发者ID:mleduque,项目名称:kwin-tiling,代码行数:28,代码来源:khotkeys.cpp

示例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();
}
开发者ID:BackupTheBerlios,项目名称:qds-svn,代码行数:30,代码来源:dbuslauncherimpl.cpp

示例3: 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;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:main.cpp

示例4: setUseNtp

bool TimeDateCtl::setUseNtp(bool value, QString& errorMessage)
{
    mIface->call("SetNTP", value, true);
    QDBusError err = mIface->lastError();
    if(err.isValid())
    {
        errorMessage = err.message();
        return false;
    }
    return true;
}
开发者ID:pmattern,项目名称:lxqt-admin,代码行数:11,代码来源:timedatectl.cpp

示例5: setTimeZone

bool TimeDateCtl::setTimeZone(QString timeZone, QString& errorMessage)
{
    mIface->call("SetTimezone", timeZone, true);
    QDBusError err = mIface->lastError();
    if(err.isValid())
    {
        errorMessage = err.message();
        return false;
    }
    return true;
}
开发者ID:pmattern,项目名称:lxqt-admin,代码行数:11,代码来源:timedatectl.cpp

示例6: valueWriter

QString KWinWaylandTouchpad::valueWriter(const Prop<T> &prop)
{
    if (!prop.changed()) {
        return QString();
    }
    m_iface->setProperty(prop.dbus, prop.val);
    QDBusError error = m_iface->lastError();
    if (error.isValid()) {
        qCCritical(KCM_TOUCHPAD) << error.message();
        return error.message();
    }
    return QString();
}
开发者ID:Zren,项目名称:plasma-desktop,代码行数:13,代码来源:kwinwaylandtouchpad.cpp

示例7: setDateTime

bool TimeDateCtl::setDateTime(QDateTime dateTime, QString& errorMessage)
{
    // the timedatectl dbus service accepts "usec" input.
    // Qt can only get "msec"  => convert to usec here.
    mIface->call("SetTime", dateTime.toMSecsSinceEpoch() * 1000, false, true);
    QDBusError err = mIface->lastError();
    if(err.isValid())
    {
        errorMessage = err.message();
        return false;
    }
    return true;
}
开发者ID:pmattern,项目名称:lxqt-admin,代码行数:13,代码来源:timedatectl.cpp

示例8: stopService

bool ServiceControl::stopService()
{
    QDBusError reply;
    systemd->call("StopUnit", ROCKPOOLD_SYSTEMD_UNIT, "replace");
    systemd->call("DisableUnitFiles", QStringList() << ROCKPOOLD_SYSTEMD_UNIT, false);
    if (reply.isValid()) {
        qWarning() << reply.message();
        return false;
    } else {
        systemd->call("Reload");
        return true;
    }
}
开发者ID:0312birdzhang,项目名称:rockpool,代码行数:13,代码来源:servicecontrol.cpp

示例9: 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();
    }
开发者ID:mgottschlag,项目名称:kwin-tiling,代码行数:51,代码来源:kcm_hotkeys.cpp

示例10: sendReply

void LauncherService::sendReply(const QDBusMessage& message, bool ret, const QDBusError& error)
{
    QDBusMessage reply;

    if (error.isValid())
    {
        reply = QDBusMessage::methodError(message, error);
    }
    else
    {
        reply = QDBusMessage::methodReply(message);
        reply.append(QVariant(ret, ret));
    }

    m_connection.send(reply);
}
开发者ID:BackupTheBerlios,项目名称:qds-svn,代码行数:16,代码来源:launcherservice.cpp

示例11: methodError

QDBusMessage QDBusMessage::methodError(const QDBusMessage &other, const QDBusError& error)
{
    Q_ASSERT(other.d->msg);

    QDBusMessage message;
    if (!error.isValid())
    {
        qWarning("QDBusMessage: error passed to methodError() is not valid!");
        return message;
    }

    message.d->type = DBUS_MESSAGE_TYPE_ERROR;
    message.d->reply = dbus_message_ref(other.d->msg);
    message.d->error = error;

    return message;
}
开发者ID:IIracotII,项目名称:policykit-kde,代码行数:17,代码来源:qdbusmessage.cpp

示例12: qDBusReplyFill

/*!
    \internal
    Fills in the QDBusReply data \a error and \a data from the reply message \a reply.
*/
void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data)
{
    error = reply;

    if (error.isValid()) {
        data = QVariant();      // clear it
        return;
    }

    if (reply.arguments().count() >= 1 && reply.arguments().at(0).userType() == data.userType()) {
        data = reply.arguments().at(0);
        return;
    }

    const char *expectedSignature = 0;
    QByteArray receivedSignature;

    if (reply.arguments().count() >= 1 &&
        reply.arguments().at(0).userType() == QDBusMetaTypeId::argument) {
        // compare signatures instead
        QDBusArgument arg = qvariant_cast<QDBusArgument>(reply.arguments().at(0));
        expectedSignature = QDBusMetaType::typeToSignature(data.userType());
        receivedSignature = arg.currentSignature().toLatin1();
        if (receivedSignature == expectedSignature) {
            // matched. Demarshall it
            QDBusMetaType::demarshall(arg, data.userType(), data.data());
            return;
        }
    }

    // error
    QString errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
                                     "expected \"%2\" (%3)");
    if (receivedSignature.isEmpty())
        receivedSignature = "no signature";
    error = QDBusError(QDBusError::InvalidSignature,
                      errorMsg.arg(QLatin1String(receivedSignature),
                                   QLatin1String(expectedSignature),
                                   QLatin1String(data.typeName())));
    data = QVariant();      // clear it
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:45,代码来源:qdbusreply.cpp

示例13:

// Extract a reply from an error.
QPyDBusReply::QPyDBusReply(const QDBusError &error)
{
    _q_value = 0;
    _q_is_valid = !error.isValid();
    _q_error = error;
}
开发者ID:ContaTP,项目名称:pyqt5,代码行数:7,代码来源:qpydbusreply.cpp

示例14: values

QT_BEGIN_NAMESPACE

/*!
    \class QDBusReply
    \inmodule QtDBus
    \since 4.2

    \brief The QDBusReply class stores the reply for a method call to a remote object.

    A QDBusReply object is a subset of the QDBusMessage object that represents a method call's
    reply. It contains only the first output argument or the error code and is used by
    QDBusInterface-derived classes to allow returning the error code as the function's return
    argument.

    It can be used in the following manner:
    \snippet doc/src/snippets/code/src_qdbus_qdbusreply.cpp 0

    If the remote method call cannot fail, you can skip the error checking:
    \snippet doc/src/snippets/code/src_qdbus_qdbusreply.cpp 1

    However, if it does fail under those conditions, the value returned by QDBusReply::value() is
    a default-constructed value. It may be indistinguishable from a valid return value.

    QDBusReply objects are used for remote calls that have no output
    arguments or return values (i.e., they have a "void" return
    type). Use the isValid() function to test if the reply succeeded.

    \sa QDBusMessage, QDBusInterface
*/

/*!
    \fn QDBusReply::QDBusReply(const QDBusMessage &reply)
    Automatically construct a QDBusReply object from the reply message \a reply, extracting the
    first return value from it if it is a success reply.
*/

/*!
    \fn QDBusReply::QDBusReply(const QDBusPendingReply<T> &reply)
    Constructs a QDBusReply object from the pending reply message, \a reply.
*/

/*!
    \fn QDBusReply::QDBusReply(const QDBusPendingCall &pcall)
    Automatically construct a QDBusReply object from the asynchronous
    pending call \a pcall. If the call isn't finished yet, QDBusReply
    will call QDBusPendingCall::waitForFinished(), which is a blocking
    operation.

    If the return types patch, QDBusReply will extract the first
    return argument from the reply.
*/

/*!
    \fn QDBusReply::QDBusReply(const QDBusError &error)
    Constructs an error reply from the D-Bus error code given by \a error.
*/

/*!
    \fn QDBusReply::operator=(const QDBusReply &other)
    Makes this object be a copy of the object \a other.
*/

/*!
    \fn QDBusReply::operator=(const QDBusError &error)
    Sets this object to contain the error code given by \a error. You
    can later access it with error().
*/

/*!
    \fn QDBusReply::operator=(const QDBusMessage &message)

    Makes this object contain the reply specified by message \a
    message. If \a message is an error message, this function will
    copy the error code and message into this object

    If \a message is a standard reply message and contains at least
    one parameter, it will be copied into this object, as long as it
    is of the correct type. If it's not of the same type as this
    QDBusError object, this function will instead set an error code
    indicating a type mismatch.
*/

/*!
    \fn QDBusReply::operator=(const QDBusPendingCall &pcall)

    Makes this object contain the reply specified by the pending
    asynchronous call \a pcall. If the call is not finished yet, this
    function will call QDBusPendingCall::waitForFinished() to block
    until the reply arrives.

    If \a pcall finishes with an error message, this function will
    copy the error code and message into this object

    If \a pcall finished with a standard reply message and contains at
    least one parameter, it will be copied into this object, as long
    as it is of the correct type. If it's not of the same type as this
    QDBusError object, this function will instead set an error code
    indicating a type mismatch.
*/

//.........这里部分代码省略.........
开发者ID:fluxer,项目名称:katie,代码行数:101,代码来源:qdbusreply.cpp

示例15: musicControl

void WatchCommands::musicControl(WatchConnector::MusicControl operation)
{
    logger()->debug() << "Operation:" << operation;

    QString mpris = parent()->property("mpris").toString();
    if (mpris.isEmpty()) {
        logger()->debug() << "No mpris interface active";
        return;
    }

    QString method;

    switch(operation) {
    case WatchConnector::musicPLAY_PAUSE:
        method = "PlayPause";
        break;
    case WatchConnector::musicPAUSE:
        method = "Pause";
        break;
    case WatchConnector::musicPLAY:
        method = "Play";
        break;
    case WatchConnector::musicNEXT:
        method = "Next";
        break;
    case WatchConnector::musicPREVIOUS:
        method = "Previous";
        break;
    case WatchConnector::musicVOLUME_UP:
    case WatchConnector::musicVOLUME_DOWN: {
            QDBusReply<QDBusVariant> VolumeReply = QDBusConnection::sessionBus().call(
                        QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Get")
                        << "org.mpris.MediaPlayer2.Player" << "Volume");
            if (VolumeReply.isValid()) {
                double volume = VolumeReply.value().variant().toDouble();
                if (operation == WatchConnector::musicVOLUME_UP) {
                    volume += 0.1;
                }
                else {
                    volume -= 0.1;
                }
                logger()->debug() << "Setting volume" << volume;
                QDBusError err = QDBusConnection::sessionBus().call(
                            QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Set")
                            << "org.mpris.MediaPlayer2.Player" << "Volume" << QVariant::fromValue(QDBusVariant(volume)));
                if (err.isValid()) {
                    logger()->error() << err.message();
                }
            }
            else {
                logger()->error() << VolumeReply.error().message();
            }
        }
        return;
    case WatchConnector::musicGET_NOW_PLAYING:
        onMprisMetadataChanged(parent()->property("mprisMetadata").toMap());
        return;

    case WatchConnector::musicSEND_NOW_PLAYING:
        logger()->warn() << "Operation" << operation << "not supported";
        return;
    }

    if (method.isEmpty()) {
        logger()->error() << "Requested unsupported operation" << operation;
        return;
    }

    logger()->debug() << operation << "->" << method;

    QDBusError err = QDBusConnection::sessionBus().call(
                QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", method));
    if (err.isValid()) {
        logger()->error() << err.message();
    }
}
开发者ID:awlx,项目名称:pebble,代码行数:76,代码来源:watchcommands.cpp


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