diff options
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/dbus_minimal_p.h | 7 | ||||
-rw-r--r-- | src/dbus/qdbus_symbols.cpp | 8 | ||||
-rw-r--r-- | src/dbus/qdbus_symbols_p.h | 57 | ||||
-rw-r--r-- | src/dbus/qdbusmessage.cpp | 44 | ||||
-rw-r--r-- | src/dbus/qdbusmessage.h | 3 | ||||
-rw-r--r-- | src/dbus/qdbusmessage_p.h | 1 | ||||
-rw-r--r-- | src/dbus/qdbusmetaobject.cpp | 2 | ||||
-rw-r--r-- | src/dbus/qt_attribution.json | 3 |
8 files changed, 116 insertions, 9 deletions
diff --git a/src/dbus/dbus_minimal_p.h b/src/dbus/dbus_minimal_p.h index b52b0153e4..869c02b59d 100644 --- a/src/dbus/dbus_minimal_p.h +++ b/src/dbus/dbus_minimal_p.h @@ -218,7 +218,7 @@ struct DBusMessageIter int dummy10; /**< Don't use this */ int dummy11; /**< Don't use this */ int pad1; /**< Don't use this */ - int pad2; /**< Don't use this */ + void *pad2; /**< Don't use this */ /* Was int; changed to void* at 1.10.8 */ void *pad3; /**< Don't use this */ }; @@ -251,6 +251,7 @@ struct DBusMessageIter #define DBUS_TYPE_SIGNATURE_AS_STRING "g" #define DBUS_TYPE_UNIX_FD ((int) 'h') #define DBUS_TYPE_UNIX_FD_AS_STRING "h" + #define DBUS_TYPE_ARRAY ((int) 'a') #define DBUS_TYPE_ARRAY_AS_STRING "a" #define DBUS_TYPE_VARIANT ((int) 'v') @@ -270,14 +271,14 @@ struct DBusMessageIter #define DBUS_DICT_ENTRY_END_CHAR ((int) '}') #define DBUS_DICT_ENTRY_END_CHAR_AS_STRING "}" +#define DBUS_MAXIMUM_NAME_LENGTH 255 + #define DBUS_MESSAGE_TYPE_INVALID 0 #define DBUS_MESSAGE_TYPE_METHOD_CALL 1 #define DBUS_MESSAGE_TYPE_METHOD_RETURN 2 #define DBUS_MESSAGE_TYPE_ERROR 3 #define DBUS_MESSAGE_TYPE_SIGNAL 4 -#define DBUS_MAXIMUM_NAME_LENGTH 255 - #define DBUS_INTROSPECT_1_0_XML_NAMESPACE "http://www.freedesktop.org/standards/dbus" #define DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" #define DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index 1e93a46c0c..f22696639d 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -79,10 +79,8 @@ bool qdbus_loadLibDBus() #endif static bool triedToLoadLibrary = false; -#ifndef QT_NO_THREAD static QBasicMutex mutex; QMutexLocker locker(&mutex); -#endif QLibrary *&lib = qdbus_libdbus; if (triedToLoadLibrary) @@ -126,14 +124,16 @@ bool qdbus_loadLibDBus() #endif } -#if QT_CONFIG(library) void (*qdbus_resolve_conditionally(const char *name))() { +#if QT_CONFIG(library) if (qdbus_loadLibDBus()) return qdbus_libdbus->resolve(name); +#else + Q_UNUSED(name); +#endif return 0; } -#endif void (*qdbus_resolve_me(const char *name))() { diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h index 9eaebe6d7e..7cce0d71aa 100644 --- a/src/dbus/qdbus_symbols_p.h +++ b/src/dbus/qdbus_symbols_p.h @@ -161,6 +161,19 @@ template <> struct TraceReturn<void> { typedef void Type; }; funcret DEBUGRET(ret) ptr argcall; \ } +# define DEFINEFUNC_CONDITIONALLY(ret, func, args, argcall, funcret, failret) \ + typedef ret (* _q_PTR_##func) args; \ + static inline ret q_##func args \ + { \ + static _q_PTR_##func ptr; \ + DEBUGCALL(#func, argcall); \ + if (!ptr) \ + ptr = (_q_PTR_##func) qdbus_resolve_conditionally(#func); \ + if (!ptr) \ + failret; \ + funcret DEBUGRET(ret) ptr argcall; \ + } + #else // defined QT_LINKED_LIBDBUS inline bool qdbus_loadLibDBus() { return true; } @@ -300,6 +313,26 @@ DEFINEFUNC(const char* , dbus_message_get_signature, (DBusMessage *message), (message), return) DEFINEFUNC(int , dbus_message_get_type, (DBusMessage *message), (message), return) + +#if !defined QT_LINKED_LIBDBUS + +DEFINEFUNC_CONDITIONALLY(dbus_bool_t , dbus_message_get_allow_interactive_authorization, (DBusMessage *message), + (message), return, return false) + +#else // defined QT_LINKED_LIBDBUS + +static inline dbus_bool_t q_dbus_message_get_allow_interactive_authorization(DBusMessage *message) +{ +#ifdef DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION + return dbus_message_get_allow_interactive_authorization(message); +#else + Q_UNUSED(message); + return false; +#endif +} + +#endif // defined QT_LINKED_LIBDBUS + DEFINEFUNC(dbus_bool_t , dbus_message_iter_append_basic, (DBusMessageIter *iter, int type, const void *value), @@ -378,9 +411,33 @@ DEFINEFUNC(dbus_bool_t , dbus_message_set_sender, (DBusMessage *message, DEFINEFUNC(void , dbus_message_unref, (DBusMessage *message), (message), ) +#if !defined QT_LINKED_LIBDBUS + +DEFINEFUNC_CONDITIONALLY(void, dbus_message_set_allow_interactive_authorization, + (DBusMessage *message, dbus_bool_t allow), (message, allow), return, return) + + +#else // defined QT_LINKED_LIBDBUS + +static inline void q_dbus_message_set_allow_interactive_authorization(DBusMessage *message, dbus_bool_t allow) +{ +#ifdef DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION + dbus_message_set_allow_interactive_authorization(message, allow); +#else + Q_UNUSED(message); + Q_UNUSED(allow); +#endif +} + +#endif // defined QT_LINKED_LIBDBUS + /* dbus-misc.h */ DEFINEFUNC(char* , dbus_get_local_machine_id , (void), (), return) +DEFINEFUNC(void , dbus_get_version , (int *major_version, int *minor_version, int *micro_version) + , (major_version, minor_version, micro_version) + , return) + /* dbus-pending-call.h */ DEFINEFUNC(dbus_bool_t , dbus_pending_call_set_notify, (DBusPendingCall *pending, diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index ef827e82b0..3e8f2eaf3f 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -70,7 +70,8 @@ static inline const char *data(const QByteArray &arr) QDBusMessagePrivate::QDBusMessagePrivate() : msg(0), reply(0), localReply(0), ref(1), type(QDBusMessage::InvalidMessage), delayedReply(false), localMessage(false), - parametersValidated(false), autoStartService(true) + parametersValidated(false), autoStartService(true), + interactiveAuthorizationAllowed(false) { } @@ -138,6 +139,8 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), d_ptr->path.toUtf8(), data(d_ptr->interface.toUtf8()), d_ptr->name.toUtf8()); q_dbus_message_set_auto_start( msg, d_ptr->autoStartService ); + q_dbus_message_set_allow_interactive_authorization(msg, d_ptr->interactiveAuthorizationAllowed); + break; case QDBusMessage::ReplyMessage: msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); @@ -242,6 +245,7 @@ QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg, QDBusConnec QString::fromUtf8(q_dbus_message_get_member(dmsg)); message.d_ptr->service = QString::fromUtf8(q_dbus_message_get_sender(dmsg)); message.d_ptr->signature = QString::fromUtf8(q_dbus_message_get_signature(dmsg)); + message.d_ptr->interactiveAuthorizationAllowed = q_dbus_message_get_allow_interactive_authorization(dmsg); message.d_ptr->msg = q_dbus_message_ref(dmsg); QDBusDemarshaller demarshaller(capabilities); @@ -725,6 +729,44 @@ bool QDBusMessage::autoStartService() const } /*! + Sets the interactive authorization flag to \a enable. + This flag only makes sense for method call messages, where it + tells the D-Bus server that the caller of the method is prepared + to wait for interactive authorization to take place (for instance + via Polkit) before the actual method is processed. + + By default this flag is false and the other end is expected to + make any authorization decisions non-interactively and promptly. + + The \c org.freedesktop.DBus.Error.InteractiveAuthorizationRequired + error indicates that authorization failed, but could have succeeded + if this flag had been set. + + \sa isInteractiveAuthorizationAllowed() + + \since 5.12 +*/ +void QDBusMessage::setInteractiveAuthorizationAllowed(bool enable) +{ + d_ptr->interactiveAuthorizationAllowed = enable; +} + +/*! + Returns the interactive authorization allowed flag, as set by + setInteractiveAuthorizationAllowed(). By default this flag + is false and the other end is expected to make any authorization + decisions non-interactively and promptly. + + \sa setInteractiveAuthorizationAllowed() + + \since 5.12 +*/ +bool QDBusMessage::isInteractiveAuthorizationAllowed() const +{ + return d_ptr->interactiveAuthorizationAllowed; +} + +/*! 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. diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h index 9f4a98b855..23e04045d8 100644 --- a/src/dbus/qdbusmessage.h +++ b/src/dbus/qdbusmessage.h @@ -119,6 +119,9 @@ public: void setAutoStartService(bool enable); bool autoStartService() const; + void setInteractiveAuthorizationAllowed(bool enable); + bool isInteractiveAuthorizationAllowed() const; + void setArguments(const QList<QVariant> &arguments); QList<QVariant> arguments() const; diff --git a/src/dbus/qdbusmessage_p.h b/src/dbus/qdbusmessage_p.h index 4b84b3f0cc..f921c33832 100644 --- a/src/dbus/qdbusmessage_p.h +++ b/src/dbus/qdbusmessage_p.h @@ -87,6 +87,7 @@ public: uint localMessage : 1; mutable uint parametersValidated : 1; uint autoStartService : 1; + uint interactiveAuthorizationAllowed : 1; static void setParametersValidated(QDBusMessage &msg, bool enable) { msg.d_ptr->parametersValidated = enable; } diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index f64e30b49b..c4296f5c55 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -412,7 +412,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) - methods.count(); // ditto QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data()); - Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QtDBus meta-object generator should generate the same version as moc"); + Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 8, "QtDBus meta-object generator should generate the same version as moc"); header->revision = QMetaObjectPrivate::OutputRevision; header->className = 0; header->classInfoCount = 0; diff --git a/src/dbus/qt_attribution.json b/src/dbus/qt_attribution.json index 52636ba89b..69d946ba5c 100644 --- a/src/dbus/qt_attribution.json +++ b/src/dbus/qt_attribution.json @@ -6,9 +6,12 @@ "Description": "D-Bus is a message bus system, a simple way for applications to talk to one another.", "Homepage": "https://www.freedesktop.org/wiki/Software/dbus/", + "Version": "Minimal supported is 1.2, compatible up to ...", + "Version": "1.12", "LicenseId": "AFL-2.1 OR GPL-2.0-or-later", "License": "Academic Free License v2.1, or GNU General Public License v2.0 or later", "LicenseFile": "LIBDBUS-1-LICENSE.txt", + "Files": "Fragments from various upstream files, see comments in ...", "Files": "dbus_minimal_p.h", "Copyright": "Copyright (C) 2002, 2003 CodeFactory AB Copyright (C) 2004, 2005 Red Hat, Inc." |