diff options
Diffstat (limited to 'fakepropertyadaptor.cpp')
-rw-r--r-- | fakepropertyadaptor.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fakepropertyadaptor.cpp b/fakepropertyadaptor.cpp new file mode 100644 index 0000000..0a65c31 --- /dev/null +++ b/fakepropertyadaptor.cpp @@ -0,0 +1,36 @@ +#include <QtCore/QRegExp> +#include <QtCore/QDebug> +#include <QtDBus/QDBusMessage> + +#include "fakepropertyadaptor.h" + +FakePropertyAdaptor::FakePropertyAdaptor(FakeProperty* property) : + QDBusAbstractAdaptor(property), _property(property) +{ +} + +QString FakePropertyAdaptor::objectPath() const +{ + if (_property->key().startsWith("/")) + return QString(_property->key()); + + return QString("/org/maemo/contextkit/") + + QString(_property->key()).replace(".", "/").replace(QRegExp("[^A-Za-z0-9_/]"), "_"); +} + +void FakePropertyAdaptor::Subscribe(const QDBusMessage& msg, QVariantList& values, quint64& timestamp) +{ + qDebug() << "subscribe from " << msg.service(); + Get(values, timestamp); +} + +void FakePropertyAdaptor::Unsubscribe(const QDBusMessage& msg) +{ + qDebug() << "unsubscribe from " << msg.service(); +} + +void FakePropertyAdaptor::Get(QVariantList& values, quint64& timestamp) +{ + values << _property->value(); + timestamp = -1LL; +} |