Make sure we don't call dbus_connection_can_send_type on too old libdbus
This function was introduced alongside the support for Unix file descriptors, so it's a good indicator of whether Unix FDs are supported. Ever since dbus_minimal_p.h, however, DBUS_TYPE_UNIX_FD may be defined even if the system libs don't support it. In order to fix this issue, I had to fix what was apparently a merge conflict resolution mistake and remove the #ifdef around the test. Doing the latter is a good idea due to moc being unable to find <dbus/dbus.h>. This was tested with both linked and dynamically-loaded libdbus-1. Task-number: QTBUG-46199 Change-Id: I66a35ce5f88941f29aa6ffff13dfb4b5438613a3 Reviewed-by: Jani Vähäkangas <jani.vahakangas@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
This commit is contained in:
parent
75af24a2d1
commit
bd1f5b268a
@ -183,9 +183,6 @@ DEFINEFUNC(dbus_bool_t , dbus_connection_add_filter, (DBusConnection
|
|||||||
void *user_data,
|
void *user_data,
|
||||||
DBusFreeFunction free_data_function),
|
DBusFreeFunction free_data_function),
|
||||||
(connection, function, user_data, free_data_function), return)
|
(connection, function, user_data, free_data_function), return)
|
||||||
DEFINEFUNC(dbus_bool_t , dbus_connection_can_send_type, (DBusConnection *connection,
|
|
||||||
int type),
|
|
||||||
(connection, type), return)
|
|
||||||
DEFINEFUNC(void , dbus_connection_close, (DBusConnection *connection),
|
DEFINEFUNC(void , dbus_connection_close, (DBusConnection *connection),
|
||||||
(connection), return)
|
(connection), return)
|
||||||
DEFINEFUNC(DBusDispatchStatus , dbus_connection_dispatch, (DBusConnection *connection),
|
DEFINEFUNC(DBusDispatchStatus , dbus_connection_dispatch, (DBusConnection *connection),
|
||||||
|
@ -39,10 +39,7 @@
|
|||||||
|
|
||||||
#include <QtDBus/private/qdbusutil_p.h>
|
#include <QtDBus/private/qdbusutil_p.h>
|
||||||
#include <QtDBus/private/qdbusconnection_p.h>
|
#include <QtDBus/private/qdbusconnection_p.h>
|
||||||
|
#include <QtDBus/private/qdbus_symbols_p.h>
|
||||||
#define QT_LINKED_LIBDBUS
|
|
||||||
#include <QtDBus/private/qdbusutil_p.h>
|
|
||||||
#include <QtDBus/private/qdbusconnection_p.h>
|
|
||||||
|
|
||||||
static const char serviceName[] = "org.qtproject.autotests.qpong";
|
static const char serviceName[] = "org.qtproject.autotests.qpong";
|
||||||
static const char objectPath[] = "/org/qtproject/qpong";
|
static const char objectPath[] = "/org/qtproject/qpong";
|
||||||
@ -85,10 +82,8 @@ private slots:
|
|||||||
void sendCallErrors_data();
|
void sendCallErrors_data();
|
||||||
void sendCallErrors();
|
void sendCallErrors();
|
||||||
|
|
||||||
#ifdef DBUS_TYPE_UNIX_FD
|
|
||||||
void receiveUnknownType_data();
|
void receiveUnknownType_data();
|
||||||
void receiveUnknownType();
|
void receiveUnknownType();
|
||||||
#endif
|
|
||||||
|
|
||||||
void demarshallPrimitives_data();
|
void demarshallPrimitives_data();
|
||||||
void demarshallPrimitives();
|
void demarshallPrimitives();
|
||||||
@ -1017,7 +1012,6 @@ void tst_QDBusMarshall::sendCallErrors()
|
|||||||
QCOMPARE(reply.errorMessage(), errorMsg);
|
QCOMPARE(reply.errorMessage(), errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBUS_TYPE_UNIX_FD
|
|
||||||
// If DBUS_TYPE_UNIX_FD is not defined, it means the current system's D-Bus library is too old for this test
|
// If DBUS_TYPE_UNIX_FD is not defined, it means the current system's D-Bus library is too old for this test
|
||||||
void tst_QDBusMarshall::receiveUnknownType_data()
|
void tst_QDBusMarshall::receiveUnknownType_data()
|
||||||
{
|
{
|
||||||
@ -1075,6 +1069,27 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// mostly the same as qdbusintegrator.cpp:connectionCapabilies
|
||||||
|
static bool canSendUnixFd(DBusConnection *connection)
|
||||||
|
{
|
||||||
|
typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int);
|
||||||
|
static can_send_type_t can_send_type = 0;
|
||||||
|
|
||||||
|
#if defined(QT_LINKED_LIBDBUS)
|
||||||
|
# if DBUS_VERSION-0 >= 0x010400
|
||||||
|
can_send_type = dbus_connection_can_send_type;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
// run-time check if the next functions are available
|
||||||
|
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
|
||||||
|
return can_send_type && can_send_type(connection, DBUS_TYPE_UNIX_FD);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QDBusMarshall::receiveUnknownType()
|
void tst_QDBusMarshall::receiveUnknownType()
|
||||||
{
|
{
|
||||||
QDBusConnection con = QDBusConnection::sessionBus();
|
QDBusConnection con = QDBusConnection::sessionBus();
|
||||||
@ -1088,7 +1103,8 @@ void tst_QDBusMarshall::receiveUnknownType()
|
|||||||
QVERIFY2(rawcon.data(), error.name);
|
QVERIFY2(rawcon.data(), error.name);
|
||||||
|
|
||||||
// check if this bus supports passing file descriptors
|
// check if this bus supports passing file descriptors
|
||||||
if (!q_dbus_connection_can_send_type(rawcon.data(), DBUS_TYPE_UNIX_FD))
|
|
||||||
|
if (!canSendUnixFd(rawcon.data()))
|
||||||
QSKIP("Your session bus does not allow sending Unix file descriptors");
|
QSKIP("Your session bus does not allow sending Unix file descriptors");
|
||||||
|
|
||||||
// make sure this QDBusConnection won't handle Unix file descriptors
|
// make sure this QDBusConnection won't handle Unix file descriptors
|
||||||
@ -1184,7 +1200,6 @@ void tst_QDBusMarshall::receiveUnknownType()
|
|||||||
QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId);
|
QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void tst_QDBusMarshall::demarshallPrimitives_data()
|
void tst_QDBusMarshall::demarshallPrimitives_data()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user