diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-10-18 23:27:35 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-19 18:29:09 (GMT) |
commit | 4b7b6f20248e43337103fc2c52f9fc40c5ca83af (patch) | |
tree | 0c47457093cbd5f2fbb8809d6fdbdb3e290d9385 | |
parent | eadfdbbf0c2f20dbd2df7832df64f4a1ef67acb7 (diff) | |
download | Qt-4b7b6f20248e43337103fc2c52f9fc40c5ca83af.zip Qt-4b7b6f20248e43337103fc2c52f9fc40c5ca83af.tar.gz Qt-4b7b6f20248e43337103fc2c52f9fc40c5ca83af.tar.bz2 |
Make QtDBus work again with D-Bus 1.0 and 1.1
The dbus_get_version function was introduced in 1.2, so we'd need to
detect pre-1.2 by the absence of the function. But if we're going to
detect the presence or absence of any function, we might as well do it
on dbus_connection_can_send_type, which is the function we wanted anyway.
Change-Id: I6e17a3a8f1382c6a489490084f6e3f61aa5a1947
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from qtbase/0510fc149e0c6b955ee9b93917e72ee378369197)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/dbus/qdbus_symbols_p.h | 12 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 19 |
2 files changed, 9 insertions, 22 deletions
diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h index 6112812..75874b6 100644 --- a/src/dbus/qdbus_symbols_p.h +++ b/src/dbus/qdbus_symbols_p.h @@ -297,10 +297,6 @@ DEFINEFUNC(void , dbus_message_unref, (DBusMessage *message), (message), ) /* dbus-misc.h */ -DEFINEFUNC(void , dbus_get_version , (int *major_version_p, - int *minor_version_p, - int *micro_version_p), - (major_version_p, minor_version_p, micro_version_p), ) DEFINEFUNC(char* , dbus_get_local_machine_id , (void), (), return) @@ -363,14 +359,6 @@ DEFINEFUNC(void , dbus_server_unref, (DBusServer *server), /* dbus-thread.h */ DEFINEFUNC(dbus_bool_t , dbus_threads_init_default, (), (), return) - -/* D-Bus 1.4 symbols */ -#if !defined(QT_LINKED_LIBDBUS) || (DBUS_VERSION >= 0x010400) -DEFINEFUNC(dbus_bool_t , dbus_connection_can_send_type , (DBusConnection *connection, - int type), - (connection, type), return) -#endif - QT_END_NAMESPACE #endif // QT_NO_DBUS diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index d29e20f..71647e7 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1680,24 +1680,23 @@ void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnection *connection) { QDBusConnection::ConnectionCapabilities result = 0; + typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int); + static can_send_type_t can_send_type = 0; -#if defined(QT_LINKED_LIBDBUS) && DBUS_VERSION < 0x010400 - // no capabilities are possible +#if defined(QT_LINKED_LIBDBUS) +# if DBUS_VERSION-0 >= 0x010400 + can_send_type = dbus_connection_can_send_type; +# endif #else -# if !defined(QT_LINKED_LIBDBUS) // run-time check if the next functions are available - int major, minor, micro; - q_dbus_get_version(&major, &minor, µ); - if (major == 1 && minor < 4) - return result; -# endif + can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); +#endif #ifndef DBUS_TYPE_UNIX_FD # define DBUS_TYPE_UNIX_FD int('h') #endif - if (q_dbus_connection_can_send_type(connection, DBUS_TYPE_UNIX_FD)) + if (can_send_type && can_send_type(connection, DBUS_TYPE_UNIX_FD)) result |= QDBusConnection::UnixFileDescriptorPassing; -#endif return result; } |