summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TelepathyQt/constants.h6
-rw-r--r--TelepathyQt/debug-receiver.cpp153
-rw-r--r--TelepathyQt/debug-receiver.h14
3 files changed, 71 insertions, 102 deletions
diff --git a/TelepathyQt/constants.h b/TelepathyQt/constants.h
index c7cbe3c1..2059b9ba 100644
--- a/TelepathyQt/constants.h
+++ b/TelepathyQt/constants.h
@@ -107,6 +107,12 @@
(QLatin1String("/org/freedesktop/Telepathy/Account"))
/**
+ * The object path of the Debug object of various services.
+ */
+#define TP_QT_DEBUG_OBJECT_PATH \
+ (QLatin1String("/org/freedesktop/Telepathy/debug"))
+
+/**
* @}
*/
diff --git a/TelepathyQt/debug-receiver.cpp b/TelepathyQt/debug-receiver.cpp
index a4fbf4b2..5966770c 100644
--- a/TelepathyQt/debug-receiver.cpp
+++ b/TelepathyQt/debug-receiver.cpp
@@ -1,7 +1,7 @@
/**
* This file is part of TelepathyQt
*
- * @copyright Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+ * @copyright Copyright (C) 2011-2012 Collabora Ltd. <http://www.collabora.co.uk/>
* @license LGPL 2.1
*
* This library is free software; you can redistribute it and/or
@@ -24,10 +24,13 @@
#include "TelepathyQt/_gen/cli-debug-receiver-body.hpp"
#include "TelepathyQt/_gen/cli-debug-receiver.moc.hpp"
-#include <TelepathyQt/debug-internal.h>
-#include <TelepathyQt/ReadinessHelper>
-#include <TelepathyQt/PendingVariantMap>
+#include "TelepathyQt/debug-internal.h"
+
+#include <TelepathyQt/Constants>
#include <TelepathyQt/PendingDebugMessageList>
+#include <TelepathyQt/PendingFailure>
+#include <TelepathyQt/PendingVariantMap>
+#include <TelepathyQt/ReadinessHelper>
namespace Tp
{
@@ -37,22 +40,14 @@ struct TP_QT_NO_EXPORT DebugReceiver::Private
Private(DebugReceiver *parent);
static void introspectCore(Private *self);
- static void introspectMonitor(Private *self);
DebugReceiver *parent;
Client::DebugInterface *baseInterface;
- ReadinessHelper *readinessHelper;
-
- bool newDebugMessageEnabled;
- bool enabledByUs;
};
DebugReceiver::Private::Private(DebugReceiver *parent)
: parent(parent),
- baseInterface(new Client::DebugInterface(parent)),
- readinessHelper(parent->readinessHelper()),
- newDebugMessageEnabled(false),
- enabledByUs(false)
+ baseInterface(new Client::DebugInterface(parent))
{
ReadinessHelper::Introspectables introspectables;
@@ -64,81 +59,29 @@ DebugReceiver::Private::Private(DebugReceiver *parent)
this);
introspectables[DebugReceiver::FeatureCore] = introspectableCore;
- ReadinessHelper::Introspectable introspectableMonitor(
- QSet<uint>() << 0, // makesSenseForStatuses
- Features() << DebugReceiver::FeatureCore, // dependsOnFeatures (core)
- QStringList(), // dependsOnInterfaces
- (ReadinessHelper::IntrospectFunc) &DebugReceiver::Private::introspectMonitor,
- this);
- introspectables[DebugReceiver::FeatureMonitor] = introspectableMonitor;
-
- readinessHelper->addIntrospectables(introspectables);
+ parent->readinessHelper()->addIntrospectables(introspectables);
}
void DebugReceiver::Private::introspectCore(DebugReceiver::Private *self)
{
- //this is done mostly to verify that the object exists...
+ //this is done only to verify that the object exists...
PendingVariantMap *op = self->baseInterface->requestAllProperties();
self->parent->connect(op,
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onRequestAllPropertiesFinished(Tp::PendingOperation*)));
}
-void DebugReceiver::onRequestAllPropertiesFinished(Tp::PendingOperation *op)
-{
- if (op->isError()) {
- mPriv->readinessHelper->setIntrospectCompleted(
- FeatureCore, false, op->errorName(), op->errorMessage());
- } else {
- PendingVariantMap *pvm = qobject_cast<PendingVariantMap*>(op);
- mPriv->newDebugMessageEnabled = pvm->result()[QLatin1String("Enabled")].toBool();
- mPriv->readinessHelper->setIntrospectCompleted(FeatureCore, true);
- }
-}
-
-
-void DebugReceiver::Private::introspectMonitor(DebugReceiver::Private *self)
-{
- if (!self->newDebugMessageEnabled) {
- PendingOperation *op = self->baseInterface->setPropertyEnabled(true);
- self->parent->connect(op,
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onSetPropertyEnabledFinished(Tp::PendingOperation*)));
- } else {
- self->parent->connect(self->baseInterface,
- SIGNAL(NewDebugMessage(double,QString,uint,QString)),
- SLOT(onNewDebugMessage(double,QString,uint,QString)));
-
- self->readinessHelper->setIntrospectCompleted(FeatureMonitor, true);
- }
-}
-
-void DebugReceiver::onSetPropertyEnabledFinished(Tp::PendingOperation *op)
-{
- if (op->isError()) {
- mPriv->readinessHelper->setIntrospectCompleted(
- FeatureMonitor, false, op->errorName(), op->errorMessage());
- } else {
- debug() << "DebugReceiver: Enabled emission of NewDebugMessage";
- mPriv->newDebugMessageEnabled = true;
- mPriv->enabledByUs = true;
- Private::introspectMonitor(mPriv);
- }
-}
-
-void DebugReceiver::onNewDebugMessage(double time, const QString &domain,
- uint level, const QString &message)
-{
- DebugMessage msg;
- msg.timestamp = time;
- msg.domain = domain;
- msg.level = level;
- msg.message = message;
-
- Q_EMIT newDebugMessage(msg);
-}
-
+/**
+ * \class DebugReceiver
+ * \ingroup clientsideproxies
+ * \headerfile TelepathyQt/debug-receiver.h <TelepathyQt/DebugReceiver>
+ *
+ * \brief The DebugReceiver class provides a D-Bus proxy for a Telepathy
+ * Debug object.
+ *
+ * A Debug object provides debugging messages from services.
+ */
/**
* Feature representing the core that needs to become ready to make the DebugReceiver
@@ -152,32 +95,19 @@ void DebugReceiver::onNewDebugMessage(double time, const QString &domain,
*/
const Feature DebugReceiver::FeatureCore = Feature(QLatin1String(DebugReceiver::staticMetaObject.className()), 0, true);
-const Feature DebugReceiver::FeatureMonitor = Feature(QLatin1String(DebugReceiver::staticMetaObject.className()), 1);
-
-
DebugReceiverPtr DebugReceiver::create(const QString &busName, const QDBusConnection &bus)
{
- return DebugReceiverPtr(new DebugReceiver(bus, busName,
- QLatin1String("/org/freedesktop/Telepathy/debug"),
- DebugReceiver::FeatureCore));
+ return DebugReceiverPtr(new DebugReceiver(bus, busName));
}
-DebugReceiver::DebugReceiver(const QDBusConnection &bus,
- const QString &busName,
- const QString &objectPath,
- const Feature &featureCore)
- : StatefulDBusProxy(bus, busName, objectPath, featureCore),
+DebugReceiver::DebugReceiver(const QDBusConnection &bus, const QString &busName)
+ : StatefulDBusProxy(bus, busName, TP_QT_DEBUG_OBJECT_PATH, DebugReceiver::FeatureCore),
mPriv(new Private(this))
{
}
DebugReceiver::~DebugReceiver()
{
-//TODO somehow we have to deal with this shitty spec....
-// if (isValid() && mPriv->enabledByUs) {
-// debug() << "DebugReceiver: Disabling emission of NewDebugMessage";
-// (void) mPriv->baseInterface->setPropertyEnabled(false);
-// }
delete mPriv;
}
@@ -188,4 +118,41 @@ PendingDebugMessageList *DebugReceiver::fetchMessages() const
DebugReceiverPtr(const_cast<DebugReceiver*>(this)));
}
+PendingOperation *DebugReceiver::setMonitoringEnabled(bool enabled)
+{
+ if (!isReady()) {
+ warning() << "DebugReceiver::setMonitoringEnabled called without DebugReceiver being ready";
+ return new PendingFailure(TP_QT_ERROR_NOT_AVAILABLE,
+ QLatin1String("FeatureCore is not ready"), DebugReceiverPtr(this));
+ }
+
+ return mPriv->baseInterface->setPropertyEnabled(enabled);
}
+
+void DebugReceiver::onRequestAllPropertiesFinished(Tp::PendingOperation *op)
+{
+ if (op->isError()) {
+ readinessHelper()->setIntrospectCompleted(
+ FeatureCore, false, op->errorName(), op->errorMessage());
+ } else {
+ connect(mPriv->baseInterface,
+ SIGNAL(NewDebugMessage(double,QString,uint,QString)),
+ SLOT(onNewDebugMessage(double,QString,uint,QString)));
+
+ readinessHelper()->setIntrospectCompleted(FeatureCore, true);
+ }
+}
+
+void DebugReceiver::onNewDebugMessage(double time, const QString &domain,
+ uint level, const QString &message)
+{
+ DebugMessage msg;
+ msg.timestamp = time;
+ msg.domain = domain;
+ msg.level = level;
+ msg.message = message;
+
+ emit newDebugMessage(msg);
+}
+
+} // Tp
diff --git a/TelepathyQt/debug-receiver.h b/TelepathyQt/debug-receiver.h
index c597176c..56dbaef8 100644
--- a/TelepathyQt/debug-receiver.h
+++ b/TelepathyQt/debug-receiver.h
@@ -1,7 +1,7 @@
/**
* This file is part of TelepathyQt
*
- * @copyright Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+ * @copyright Copyright (C) 2011-2012 Collabora Ltd. <http://www.collabora.co.uk/>
* @license LGPL 2.1
*
* This library is free software; you can redistribute it and/or
@@ -40,38 +40,34 @@ class TP_QT_EXPORT DebugReceiver : public StatefulDBusProxy
{
Q_OBJECT
Q_DISABLE_COPY(DebugReceiver)
+
public:
static const Feature FeatureCore;
- static const Feature FeatureMonitor;
static DebugReceiverPtr create(const QString &busName,
const QDBusConnection &bus = QDBusConnection::sessionBus());
virtual ~DebugReceiver();
PendingDebugMessageList *fetchMessages() const;
+ PendingOperation *setMonitoringEnabled(bool enabled);
Q_SIGNALS:
void newDebugMessage(const Tp::DebugMessage & message);
protected:
- DebugReceiver(const QDBusConnection &bus,
- const QString &busName,
- const QString &objectPath,
- const Feature &featureCore);
+ DebugReceiver(const QDBusConnection &bus, const QString &busName);
private Q_SLOTS:
TP_QT_NO_EXPORT void onRequestAllPropertiesFinished(Tp::PendingOperation *op);
- TP_QT_NO_EXPORT void onSetPropertyEnabledFinished(Tp::PendingOperation *op);
TP_QT_NO_EXPORT void onNewDebugMessage(double time, const QString &domain,
uint level, const QString &message);
private:
struct Private;
friend struct Private;
-
Private *mPriv;
};
-}
+} // Tp
#endif