⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdbusmessage.cpp

📁 QT 开发环境里面一个很重要的文件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    Q_ASSERT(d_ptr->msg || d_ptr->localMessage);    return reply;}/*!   \fn QDBusMessage QDBusMessage::createReply(const QVariant &argument) const    Constructs a new DBus message representing a reply, with the    given \a argument.*//*!    \fn QDBusMessage QDBusMessage::createErrorReply(const QDBusError &error) const    Constructs a new DBus message representing an error reply message,    from the given \a error object.*//*!    Constructs an empty, invalid QDBusMessage object.    \sa createError(), createMethodCall(), createSignal()*/QDBusMessage::QDBusMessage(){    d_ptr = new QDBusMessagePrivate;}/*!    Constructs a copy of the object given by \a other.    Note: QDBusMessage objects are shared. Modifications made to the    copy will affect the original one as well. See setDelayedReply()    for more information.*/QDBusMessage::QDBusMessage(const QDBusMessage &other){    d_ptr = other.d_ptr;    d_ptr->ref.ref();}/*!    Disposes of the object and frees any resources that were being held.*/QDBusMessage::~QDBusMessage(){    if (!d_ptr->ref.deref())        delete d_ptr;}/*!    Copies the contents of the object given by \a other.    Note: QDBusMessage objects are shared. Modifications made to the    copy will affect the original one as well. See setDelayedReply()    for more information.*/QDBusMessage &QDBusMessage::operator=(const QDBusMessage &other){    qAtomicAssign(d_ptr, other.d_ptr);    return *this;}/*!    Returns the name of the service or the bus address of the remote method call.*/QString QDBusMessage::service() const{    return d_ptr->service;}/*!    Returns the path of the object that this message is being sent to (in the case of a    method call) or being received from (for a signal).*/QString QDBusMessage::path() const{    return d_ptr->path;}/*!    Returns the interface of the method being called (in the case of a method call) or of    the signal being received from.*/QString QDBusMessage::interface() const{    return d_ptr->interface;}/*!    Returns the name of the signal that was emitted or the name of the method that was called.*/QString QDBusMessage::member() const{    if (d_ptr->type != ErrorMessage)        return d_ptr->name;    return QString();}/*!    Returns the name of the error that was received.*/QString QDBusMessage::errorName() const{    if (d_ptr->type == ErrorMessage)        return d_ptr->name;    return QString();}/*!    Returns the signature of the signal that was received or for the output arguments    of a method call.*/QString QDBusMessage::signature() const{    return d_ptr->signature;}/*!    Returns the flag that indicates if this message should see a reply    or not. This is only meaningful for \l {MethodCallMessage}{method    call messages}: any other kind of message cannot have replies and    this function will always return false for them.*/bool QDBusMessage::isReplyRequired() const{    if (!d_ptr->msg)        return false;    return dbus_message_get_no_reply(d_ptr->msg);}/*!    Sets whether the message will be replied later (if \a enable is    true) or if an automatic reply should be generated by QtDBus    (if \a enable is false).    In D-BUS, all method calls must generate a reply to the caller, unless the    caller explicitly indicates otherwise (see isReplyRequired()). QtDBus    automatically generates such replies for any slots being called, but it    also allows slots to indicate whether they will take responsibility    of sending the reply at a later time, after the function has finished    processing.    \sa {Delayed Replies}*/void QDBusMessage::setDelayedReply(bool enable) const{    d_ptr->delayedReply = enable;}/*!    Returns the delayed reply flag, as set by setDelayedReply(). By default, this    flag is false, which means QtDBus will generate automatic replies    when necessary.*/bool QDBusMessage::isDelayedReply() const{    return d_ptr->delayedReply;}/*!    Sets the arguments that are going to be sent over D-BUS to \a arguments. Those    will be the arguments to a method call or the parameters in the signal.    \sa arguments()*/void QDBusMessage::setArguments(const QList<QVariant> &arguments){    d_ptr->arguments = arguments;}/*!    Returns the list of arguments that are going to be sent or were received from    D-BUS.*/QList<QVariant> QDBusMessage::arguments() const{    return d_ptr->arguments;}/*!    Appends the argument \a arg to the list of arguments to be sent over D-BUS in    a method call or signal emission.*/QDBusMessage &QDBusMessage::operator<<(const QVariant &arg){    d_ptr->arguments.append(arg);    return *this;}/*!    Returns the message type.*/QDBusMessage::MessageType QDBusMessage::type() const{    switch (d_ptr->type) {    case DBUS_MESSAGE_TYPE_METHOD_CALL:        return MethodCallMessage;    case DBUS_MESSAGE_TYPE_METHOD_RETURN:        return ReplyMessage;    case DBUS_MESSAGE_TYPE_ERROR:        return ErrorMessage;    case DBUS_MESSAGE_TYPE_SIGNAL:        return SignalMessage;    default:        break;    }    return InvalidMessage;}/*!    Sends the message without waiting for a reply. This is suitable    for errors, signals, and return values as well as calls whose    return values are not necessary.    Returns true if the message was queued successfully;    otherwise returns false.    \sa QDBusConnection::send()*/#ifndef QT_NO_DEBUG_STREAMQDebug operator<<(QDebug dbg, QDBusMessage::MessageType t){    switch (t)    {    case QDBusMessage::MethodCallMessage:        return dbg << "MethodCall";    case QDBusMessage::ReplyMessage:        return dbg << "MethodReturn";    case QDBusMessage::SignalMessage:        return dbg << "Signal";    case QDBusMessage::ErrorMessage:        return dbg << "Error";    default:        return dbg << "Invalid";    }}static void debugVariantList(QDebug dbg, const QVariantList &list);static void debugVariantMap(QDebug dbg, const QVariantMap &map);static void debugVariant(QDebug dbg, const QVariant &v){    if (v.userType() == qMetaTypeId<QDBusArgument>()) {        dbg.nospace() << "argument of type "                      << qvariant_cast<QDBusArgument>(v).currentSignature();        return;    }    dbg.nospace() << v.typeName() << "(";    switch (v.userType())    {    case QVariant::Bool:        dbg.nospace() << v.toBool();        break;    case QMetaType::UChar:        dbg.nospace() << qvariant_cast<uchar>(v);        break;    case QMetaType::Short:        dbg.nospace() << qvariant_cast<short>(v);        break;    case QMetaType::UShort:        dbg.nospace() << qvariant_cast<ushort>(v);        break;    case QVariant::Int:        dbg.nospace() << v.toInt();        break;    case QVariant::UInt:        dbg.nospace() << v.toUInt();        break;    case QVariant::LongLong:        dbg.nospace() << v.toLongLong();        break;    case QVariant::ULongLong:        dbg.nospace() << v.toULongLong();        break;    case QVariant::Double:        dbg.nospace() << v.toDouble();        break;    case QVariant::String:        dbg.nospace() << v.toString();        break;    case QVariant::ByteArray:        dbg.nospace() << v.toByteArray();        break;    case QVariant::StringList:        dbg.nospace() << v.toStringList();        break;    case QVariant::List:        debugVariantList(dbg, v.toList());        break;    case QVariant::Map:        debugVariantMap(dbg, v.toMap());        break;    default: {        int id = v.userType();        if (id == qMetaTypeId<QDBusVariant>())            debugVariant(dbg, qvariant_cast<QDBusVariant>(v).variant());        else if (id == qMetaTypeId<QDBusObjectPath>())            dbg.nospace() << qvariant_cast<QDBusObjectPath>(v).path();        else if (id == qMetaTypeId<QDBusSignature>())            dbg.nospace() << qvariant_cast<QDBusSignature>(v).signature();        else            dbg.nospace() << "unknown";    }    }    dbg.nospace() << ")";}static void debugVariantList(QDebug dbg, const QVariantList &list){    bool first = true;    QVariantList::ConstIterator it = list.constBegin();    QVariantList::ConstIterator end = list.constEnd();    for ( ; it != end; ++it) {        if (!first)            dbg.nospace() << ", ";        debugVariant(dbg, *it);        first = false;    }}static void debugVariantMap(QDebug dbg, const QVariantMap &map){    QVariantMap::ConstIterator it = map.constBegin();    QVariantMap::ConstIterator end = map.constEnd();    for ( ; it != end; ++it) {        dbg << "(" << it.key() << ", ";        debugVariant(dbg, it.value());        dbg.nospace() << ") ";    }}QDebug operator<<(QDebug dbg, const QDBusMessage &msg){    dbg.nospace() << "QDBusMessage(type=" << msg.type()                  << ", service=" << msg.service()                  << ", path=" << msg.path()                  << ", interface=" << msg.interface()                  << ", member=" << msg.member()                  << ", signature=" << msg.signature()                  << ", contents=(";    debugVariantList(dbg, msg.arguments());    dbg.nospace() << ") )";    return dbg.space();}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -