[Telepathy-commits] [telepathy-qt4/master] Implement a protected method that can be called to invalidate the StatefulDBusProxy.
George Goldberg
george.goldberg at collabora.co.uk
Thu Jan 15 05:38:26 PST 2009
---
TelepathyQt4/Client/dbus-proxy.cpp | 28 ++++++++++++++++++++++++++++
TelepathyQt4/Client/dbus-proxy.h | 5 ++++-
2 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/TelepathyQt4/Client/dbus-proxy.cpp b/TelepathyQt4/Client/dbus-proxy.cpp
index 3f21300..db7e234 100644
--- a/TelepathyQt4/Client/dbus-proxy.cpp
+++ b/TelepathyQt4/Client/dbus-proxy.cpp
@@ -25,6 +25,8 @@
#include "TelepathyQt4/debug-internal.h"
+#include <QtCore/QTimer>
+
namespace Telepathy
{
namespace Client
@@ -121,5 +123,31 @@ QString StatefulDBusProxy::invalidationMessage() const
return mPriv->invalidationMessage;
}
+void StatefulDBusProxy::invalidate(const QString& reason, const QString& message)
+{
+ // FIXME: Which of these should be warnings instead?
+ Q_ASSERT(isValid());
+ Q_ASSERT(mPriv->invalidationReason.isEmpty());
+ Q_ASSERT(mPriv->invalidationMessage.isEmpty());
+ Q_ASSERT(!reason.isEmpty());
+ // FIXME: can message be empty?
+
+ mPriv->invalidationReason = reason;
+ mPriv->invalidationMessage = message;
+
+ Q_ASSERT(!isValid());
+
+ // Defer emitting the invalidated signal until we next
+ // return to the mainloop.
+ QTimer::singleShot(0, this, SLOT(emitInvalidated()));
+}
+
+void StatefulDBusProxy::emitInvalidated()
+{
+ Q_ASSERT(!isValid());
+ Q_ASSERT(!mPriv->invalidationReason.isEmpty());
+ emit invalidated(this, mPriv->invalidationReason, mPriv->invalidationMessage);
+}
+
}
}
diff --git a/TelepathyQt4/Client/dbus-proxy.h b/TelepathyQt4/Client/dbus-proxy.h
index 09cb909..eaa7aa2 100644
--- a/TelepathyQt4/Client/dbus-proxy.h
+++ b/TelepathyQt4/Client/dbus-proxy.h
@@ -187,9 +187,12 @@ Q_SIGNALS:
* of ASCII, prefixed with a reversed domain name)
* \param errorMessage A debugging message associated with the error
*/
- void invalidated(DBusProxy* proxy, QString errorName,
+ void invalidated(StatefulDBusProxy* proxy, QString errorName,
QString errorMessage);
+private Q_SLOTS:
+ void emitInvalidated();
+
private:
struct Private;
friend struct Private;
--
1.5.6.5
More information about the Telepathy-commits
mailing list