+2006-04-23 Thiago Macieira <thiago.macieira@trolltech.com
+
+ * qt/qdbusreply.h: Add default constructor and operator=
+ (r532625)
+ * qt/qdbustypehelper_p.h: Use a clean namespace: no foreach()
+ in public headers (r532952)
+ * qt/qdbusabstractinterface.cpp:
+ * qt/qdbusabstractinterface_p.h: Add the AutoDetect mode and
+ make it the default (r532951)
+
2006-04-19 John (J5) Palmieri <johnp@redhat.com>
* dbus/dbus-connection.c: Fix asserts
sig = method.mid(pos + 1);
}
+ if (mode == AutoDetect) {
+ // determine if this a sync or async call
+ mode = UseEventLoop;
+ const QMetaObject *mo = metaObject();
+ QByteArray match = method.toLatin1() + '(';
+
+ for (int i = staticMetaObject.methodCount(); i < mo->methodCount(); ++i) {
+ QMetaMethod mm = mo->method(i);
+ if (QByteArray(mm.signature()).startsWith(match)) {
+ // found a method with the same name as what we're looking for
+ // hopefully, nobody is overloading asynchronous and synchronous methods with
+ // the same name
+
+ QList<QByteArray> tags = QByteArray(mm.tag()).split(' ');
+ if (tags.contains("async") || tags.contains("Q_ASYNC"))
+ mode = NoWaitForReply;
+
+ break;
+ }
+ }
+ }
+
QDBusMessage msg = QDBusMessage::methodCall(service(), path(), interface(), m);
msg.setSignature(sig);
msg.QList<QVariant>::operator=(args);
enum CallMode {
NoWaitForReply,
UseEventLoop,
- NoUseEventLoop
+ NoUseEventLoop,
+ AutoDetect
};
public:
QDBusError lastError() const;
QDBusMessage callWithArgs(const QString &method, const QList<QVariant> &args = QList<QVariant>(),
- CallMode mode = UseEventLoop);
+ CallMode mode = AutoDetect);
bool callWithArgs(const QString &method, QObject *receiver, const char *slot,
const QList<QVariant> &args = QList<QVariant>());
typedef T Type;
public:
inline QDBusReply(const QDBusMessage &reply)
- : m_error(reply), m_data(Type())
+ : m_data(Type())
{
+ *this = reply;
+ }
+ inline QDBusReply& operator=(const QDBusMessage& reply)
+ {
+ m_error = reply;
if (isSuccess())
m_data = QDBusTypeHelper<Type>::fromVariant(reply.at(0));
+ else
+ m_data = Type();
+ return *this;
}
- inline QDBusReply(const QDBusError &error)
+
+ inline QDBusReply(const QDBusError &error = QDBusError())
: m_error(error), m_data(Type())
{
- }
+ }
+ inline QDBusReply& operator=(const QDBusError& error)
+ {
+ m_error = error;
+ m_data = Type();
+ return *this;
+ }
+
+ inline QDBusReply& operator=(const QDBusReply& other)
+ {
+ m_error = other.m_error;
+ m_data = other.m_data;
+ return *this;
+ }
inline bool isError() const { return m_error.isValid(); }
inline bool isSuccess() const { return !m_error.isValid(); }
static inline QVariantList toVariantList(const List &list)
{
QVariantList tmp;
- foreach (const Type &t, list)
+ Q_FOREACH (const Type &t, list)
tmp.append(toVariant(t));
return tmp;
}
static inline List fromVariantList(const QVariantList &list)
{
List tmp;
- foreach (const QVariant &v, list)
+ Q_FOREACH (const QVariant &v, list)
tmp.append(fromVariant(v));
return tmp;
}