Make more of QDBus bootstrapping-ready.
The DBus metatype system and marshaller is required for determining the dbus-signature of built-in Qt types, for example QPoint. Change-Id: I8860ab3b88827aeb8063dfb79c4a9b28c0a20c0f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
43a176804f
commit
e640c3bcfe
|
|
@ -52,6 +52,7 @@ void (*qdbus_resolve_me(const char *name))();
|
|||
|
||||
#if !defined QT_LINKED_LIBDBUS
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
static QLibrary *qdbus_libdbus = 0;
|
||||
|
||||
void qdbus_unloadLibDBus()
|
||||
|
|
@ -59,9 +60,11 @@ void qdbus_unloadLibDBus()
|
|||
delete qdbus_libdbus;
|
||||
qdbus_libdbus = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool qdbus_loadLibDBus()
|
||||
{
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
// this is to simulate a library load failure for our autotest suite.
|
||||
if (!qgetenv("QT_SIMULATE_DBUS_LIBFAIL").isEmpty())
|
||||
|
|
@ -93,17 +96,23 @@ bool qdbus_loadLibDBus()
|
|||
delete lib;
|
||||
lib = 0;
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
void (*qdbus_resolve_conditionally(const char *name))()
|
||||
{
|
||||
if (qdbus_loadLibDBus())
|
||||
return qdbus_libdbus->resolve(name);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void (*qdbus_resolve_me(const char *name))()
|
||||
{
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
if (!qdbus_loadLibDBus())
|
||||
qFatal("Cannot find libdbus-1 in your system to resolve symbol '%s'.", name);
|
||||
|
||||
|
|
@ -112,9 +121,15 @@ void (*qdbus_resolve_me(const char *name))()
|
|||
qFatal("Cannot resolve '%s' in your libdbus-1.", name);
|
||||
|
||||
return ptr;
|
||||
#else
|
||||
Q_UNUSED(name);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus)
|
||||
#endif
|
||||
|
||||
#endif // QT_LINKED_LIBDBUS
|
||||
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@
|
|||
#include <qvector.h>
|
||||
|
||||
#include "qdbusmetatype_p.h"
|
||||
#include "qdbusargument_p.h"
|
||||
#include "qdbusutil_p.h"
|
||||
#include "qdbusunixfiledescriptor.h"
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#include "qdbusmessage.h"
|
||||
#include "qdbusunixfiledescriptor.h"
|
||||
#include "qdbusutil_p.h"
|
||||
#include "qdbusargument_p.h"
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DBUS
|
||||
|
|
@ -75,20 +75,6 @@ Q_DECLARE_METATYPE(QList<double>)
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef QT_BOOTSTRAPPED
|
||||
int QDBusMetaTypeId::message = QMetaType::User + 1;
|
||||
int QDBusMetaTypeId::argument = QMetaType::User + 2;
|
||||
int QDBusMetaTypeId::variant = QMetaType::User + 3;
|
||||
int QDBusMetaTypeId::objectpath = QMetaType::User + 4;
|
||||
int QDBusMetaTypeId::signature = QMetaType::User + 5;
|
||||
int QDBusMetaTypeId::error = QMetaType::User + 6;
|
||||
int QDBusMetaTypeId::unixfd = QMetaType::User + 7;
|
||||
|
||||
void QDBusMetaTypeId::init()
|
||||
{
|
||||
|
||||
}
|
||||
#else
|
||||
class QDBusCustomTypeInfo
|
||||
{
|
||||
public:
|
||||
|
|
@ -127,13 +113,15 @@ void QDBusMetaTypeId::init()
|
|||
// reentrancy is not a problem since everything else is locked on their own
|
||||
// set the guard variable at the end
|
||||
if (!initialized) {
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
// register our types with QtCore
|
||||
message = qRegisterMetaType<QDBusMessage>("QDBusMessage");
|
||||
error = qRegisterMetaType<QDBusError>("QDBusError");
|
||||
#endif
|
||||
argument = qRegisterMetaType<QDBusArgument>("QDBusArgument");
|
||||
variant = qRegisterMetaType<QDBusVariant>("QDBusVariant");
|
||||
objectpath = qRegisterMetaType<QDBusObjectPath>("QDBusObjectPath");
|
||||
signature = qRegisterMetaType<QDBusSignature>("QDBusSignature");
|
||||
error = qRegisterMetaType<QDBusError>("QDBusError");
|
||||
unixfd = qRegisterMetaType<QDBusUnixFileDescriptor>("QDBusUnixFileDescriptor");
|
||||
|
||||
#ifndef QDBUS_NO_SPECIALTYPES
|
||||
|
|
@ -166,6 +154,11 @@ void QDBusMetaTypeId::init()
|
|||
qDBusRegisterMetaType<QList<QDBusUnixFileDescriptor> >();
|
||||
#endif
|
||||
|
||||
#if QT_BOOTSTRAPPED
|
||||
const int lastId = qDBusRegisterMetaType<QList<QDBusUnixFileDescriptor> >();
|
||||
message = lastId + 1;
|
||||
error = lastId + 2;
|
||||
#endif
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -306,12 +299,16 @@ bool QDBusMetaType::demarshall(const QDBusArgument &arg, int id, void *data)
|
|||
} else
|
||||
df = info.demarshall;
|
||||
}
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
QDBusArgument copy = arg;
|
||||
df(copy, data);
|
||||
#else
|
||||
Q_UNUSED(arg);
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(df);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\fn QDBusMetaType::signatureToType(const char *signature)
|
||||
|
|
@ -464,7 +461,6 @@ const char *QDBusMetaType::typeToSignature(int type)
|
|||
else if (type == QDBusMetaTypeId::unixfd)
|
||||
return DBUS_TYPE_UNIX_FD_AS_STRING;
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
// try the database
|
||||
QVector<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
{
|
||||
|
|
@ -494,9 +490,6 @@ const char *QDBusMetaType::typeToSignature(int type)
|
|||
info->signature = signature;
|
||||
}
|
||||
return info->signature;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -132,7 +132,6 @@ bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name)
|
|||
// sig must be the normalised signature for the method
|
||||
int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes)
|
||||
{
|
||||
QDBusMetaTypeId::init();
|
||||
return qDBusParametersForMethod(mm.parameterTypes(), metaTypes);
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +139,7 @@ int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes)
|
|||
|
||||
int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<int>& metaTypes)
|
||||
{
|
||||
QDBusMetaTypeId::init();
|
||||
metaTypes.clear();
|
||||
|
||||
metaTypes.append(0); // return type
|
||||
|
|
|
|||
Loading…
Reference in New Issue