dbus/qt qdbusabstractinterface.cpp, 1.1, 1.2 qdbusabstractinterface.h, 1.1, 1.2 qdbustypehelper_p.h, 1.1, 1.2 qdbusreply.h, 1.2, 1.3

Thiago J. Macieira thiago at kemper.freedesktop.org
Sun Apr 23 08:17:30 PDT 2006


Update of /cvs/dbus/dbus/qt
In directory kemper:/tmp/cvs-serv17738/qt

Modified Files:
	qdbusabstractinterface.cpp qdbusabstractinterface.h 
	qdbustypehelper_p.h qdbusreply.h 
Log Message:
	* 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)


Index: qdbusabstractinterface.cpp
===================================================================
RCS file: /cvs/dbus/dbus/qt/qdbusabstractinterface.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- qdbusabstractinterface.cpp	28 Mar 2006 18:56:08 -0000	1.1
+++ qdbusabstractinterface.cpp	23 Apr 2006 15:17:28 -0000	1.2
@@ -146,6 +146,28 @@
         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);

Index: qdbusabstractinterface.h
===================================================================
RCS file: /cvs/dbus/dbus/qt/qdbusabstractinterface.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- qdbusabstractinterface.h	28 Mar 2006 18:56:08 -0000	1.1
+++ qdbusabstractinterface.h	23 Apr 2006 15:17:28 -0000	1.2
@@ -45,7 +45,8 @@
     enum CallMode {
         NoWaitForReply,
         UseEventLoop,
-        NoUseEventLoop
+        NoUseEventLoop,
+        AutoDetect
     };
 
 public:
@@ -60,7 +61,7 @@
     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>());
 

Index: qdbustypehelper_p.h
===================================================================
RCS file: /cvs/dbus/dbus/qt/qdbustypehelper_p.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- qdbustypehelper_p.h	28 Mar 2006 18:56:08 -0000	1.1
+++ qdbustypehelper_p.h	23 Apr 2006 15:17:28 -0000	1.2
@@ -122,7 +122,7 @@
     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;
     }
@@ -135,7 +135,7 @@
     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;
     }

Index: qdbusreply.h
===================================================================
RCS file: /cvs/dbus/dbus/qt/qdbusreply.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- qdbusreply.h	28 Mar 2006 18:56:08 -0000	1.2
+++ qdbusreply.h	23 Apr 2006 15:17:28 -0000	1.3
@@ -39,15 +39,37 @@
     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(); }



More information about the dbus-commit mailing list