aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Luc Lamadon <jean-luc.lamadon@nokia.com>2009-10-29 14:32:33 +0200
committerJean-Luc Lamadon <jean-luc.lamadon@nokia.com>2009-10-29 14:32:33 +0200
commit50886e6de8b6eff3d96c079d3578c194ef8c0ad0 (patch)
tree16e5baabbcda0bed8a61c673a51105b46db29a60
parent8a3378f07e019dc2757747814422ee6361765d12 (diff)
parentb62756c04d2662dd1913cccd2c0dd1b7c28f2f46 (diff)
Merge branch 'protocol_chge_provider' of git@gitorious.org:maemo-af/contextkit into protocol_chge_provider
-rw-r--r--libcontextprovider/src/Makefile.am2
-rw-r--r--libcontextprovider/src/propertyadaptor.cpp15
-rw-r--r--libcontextprovider/src/propertyadaptor.h2
-rw-r--r--libcontextprovider/src/propertyprivate.cpp5
-rw-r--r--libcontextprovider/src/queuedinvoker.cpp77
-rw-r--r--libcontextprovider/src/queuedinvoker.h55
6 files changed, 14 insertions, 142 deletions
diff --git a/libcontextprovider/src/Makefile.am b/libcontextprovider/src/Makefile.am
index eac30d7e..2d1ed62a 100644
--- a/libcontextprovider/src/Makefile.am
+++ b/libcontextprovider/src/Makefile.am
@@ -9,8 +9,6 @@ libcontextprovider_la_SOURCES = loggingfeatures.h \
propertyprivate.cpp \
group.h \
group.cpp \
- queuedinvoker.h \
- queuedinvoker.cpp \
contextc.h \
contextc.cpp \
listeners.h \
diff --git a/libcontextprovider/src/propertyadaptor.cpp b/libcontextprovider/src/propertyadaptor.cpp
index 65ddc577..d7dde658 100644
--- a/libcontextprovider/src/propertyadaptor.cpp
+++ b/libcontextprovider/src/propertyadaptor.cpp
@@ -44,9 +44,12 @@ namespace ContextProvider {
PropertyAdaptor::PropertyAdaptor(PropertyPrivate* propertyPrivate, QDBusConnection *conn)
: QDBusAbstractAdaptor(propertyPrivate), propertyPrivate(propertyPrivate), connection(conn)
{
+ // Start listening to the NameOwnerChanged D-Bus signal, to know
+ // when our client has exited.
sconnect((QObject*) connection->interface(),
SIGNAL(serviceOwnerChanged(const QString&, const QString&, const QString&)),
- this, SLOT(OnServiceOwnerChanged(const QString &, const QString&, const QString&)));
+ this, SLOT(onServiceOwnerChanged(const QString &, const QString&, const QString&)));
+
sconnect(propertyPrivate, SIGNAL(valueChanged(const QVariantList&, const quint64&)),
this, SIGNAL(ValueChanged(const QVariantList&, const quint64&)));
@@ -54,7 +57,7 @@ PropertyAdaptor::PropertyAdaptor(PropertyPrivate* propertyPrivate, QDBusConnecti
// same bus we're on: that means if the same property is provided
// both on session and on system bus, overhearing won't work.
connection->connect("", objectPath(), DBUS_INTERFACE, "ValueChanged",
- this, SLOT(onValueChanged(QVariantList, quint64)));
+ this, SLOT(onValueChanged(QVariantList, quint64)));
}
/// Implementation of the D-Bus method Subscribe
@@ -96,9 +99,11 @@ void PropertyAdaptor::Unsubscribe(const QDBusMessage &msg)
}
}
else {
- contextWarning() << "Client" << client << "unsubscribed from property" << propertyPrivate->key << "without subscribing";
+ contextWarning() << "Client" << client << "unsubscribed from property" <<
+ propertyPrivate->key << "without subscribing";
QDBusMessage error = msg.createErrorReply("org.maemo.contextkit.Error.IllegalUnsubscribe",
- "Unsubscribing from a non-subscribed property " + propertyPrivate->key);
+ "Unsubscribing from a non-subscribed property "
+ + propertyPrivate->key);
connection->send(error);
}
}
@@ -123,7 +128,7 @@ void PropertyAdaptor::onValueChanged(QVariantList values, quint64 timestamp)
/// Called when a NameOwnerChanged signal is broadcast on D-Bus. If
/// one of our clients has disappeared from D-Bus, update the client
/// list.
-void PropertyAdaptor::OnServiceOwnerChanged(const QString &name, const QString &oldName, const QString &newName)
+void PropertyAdaptor::onServiceOwnerChanged(const QString &name, const QString &oldName, const QString &newName)
{
if (newName == "") {
diff --git a/libcontextprovider/src/propertyadaptor.h b/libcontextprovider/src/propertyadaptor.h
index eca9a76b..60d741ab 100644
--- a/libcontextprovider/src/propertyadaptor.h
+++ b/libcontextprovider/src/propertyadaptor.h
@@ -53,7 +53,7 @@ signals:
void ValueChanged(const QVariantList &values, const quint64& timestamp);
private slots:
- void OnServiceOwnerChanged(const QString&, const QString&, const QString&);
+ void onServiceOwnerChanged(const QString&, const QString&, const QString&);
void onValueChanged(QVariantList values, quint64 timestamp);
private:
diff --git a/libcontextprovider/src/propertyprivate.cpp b/libcontextprovider/src/propertyprivate.cpp
index 48e3ca19..4b23e823 100644
--- a/libcontextprovider/src/propertyprivate.cpp
+++ b/libcontextprovider/src/propertyprivate.cpp
@@ -25,7 +25,6 @@
#include "sconnect.h"
#include "loggingfeatures.h"
#include <time.h>
-#include <math.h>
namespace ContextProvider {
@@ -156,6 +155,8 @@ void PropertyPrivate::updateOverheardValue(const QVariantList& v, const quint64&
}
}
+#define NSECS_IN_SEC 1000000000ULL
+
/// Compute a unique time stamp for our value. The time stamp is based
/// on monotonic clock and its value is: seconds * 10e9 + nanoseconds.
quint64 PropertyPrivate::currentTimestamp()
@@ -163,7 +164,7 @@ quint64 PropertyPrivate::currentTimestamp()
struct timespec time;
clock_gettime(CLOCK_MONOTONIC, &time);
quint64 toReturn = time.tv_nsec;
- toReturn += ((quint64)pow(10,9) * time.tv_sec);
+ toReturn += (NSECS_IN_SEC * time.tv_sec);
return toReturn;
}
diff --git a/libcontextprovider/src/queuedinvoker.cpp b/libcontextprovider/src/queuedinvoker.cpp
deleted file mode 100644
index 8a7b09e6..00000000
--- a/libcontextprovider/src/queuedinvoker.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Nokia Corporation.
- *
- * Contact: Marius Vollmer <marius.vollmer@nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#include "queuedinvoker.h"
-
-#include <QMetaObject>
-#include <QThread>
-#include <QDebug>
-#include <QMutexLocker>
-
-namespace ContextProvider {
-
-/*! \class QueuedInvoker
- \brief A class that can invoke its own methods in a delayed way.
-
- Via the method QueuedInvoker::queueOnce, the given method is set
- to be invoked when the event loop of the object is entered. Each
- method is queued at most once. QueuedInvoker sends a signal to
- itself, and when the signal is processed, the method is invoked.
-
- QueuedInvoker is normally used by subclassing it.
-
-*/
-
-QueuedInvoker::QueuedInvoker(QObject* parent)
- : QObject(parent)
-{
- connect(this, SIGNAL(queuedCall(const char *)),
- this, SLOT(onQueuedCall(const char *)),
- Qt::QueuedConnection);
-}
-
-//! Slot which is executed when the event loop of this object
-//! runs. Calls all the methods in the queue.
-void QueuedInvoker::onQueuedCall(const char *method)
-{
- QMutexLocker locker(&callQueueLock);
- callQueue.remove(method);
- locker.unlock();
- if (!QMetaObject::invokeMethod(this, method, Qt::DirectConnection)) {
- qFatal(" *****************\n"
- "Erroneous usage of queueOnce(%s)\n"
- " *****************\n", method);
- }
-}
-
-//! Sets the method \a method to be invoked when the event loop of
-//! this object runs next time. If the method was already in the
-//! queue, it won't be inserted again.
-void QueuedInvoker::queueOnce(const char *method)
-{
- QMutexLocker locker(&callQueueLock);
- if (!callQueue.contains(method)) {
- emit queuedCall(method);
- callQueue.insert(method);
- }
-}
-
-} // namespace ContextProvider
diff --git a/libcontextprovider/src/queuedinvoker.h b/libcontextprovider/src/queuedinvoker.h
deleted file mode 100644
index 8f1e8896..00000000
--- a/libcontextprovider/src/queuedinvoker.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Nokia Corporation.
- *
- * Contact: Marius Vollmer <marius.vollmer@nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#ifndef QUEUEDINVOKER_H
-#define QUEUEDINVOKER_H
-
-#include <QObject>
-#include <QMutex>
-#include <QSet>
-#include <QString>
-
-namespace ContextProvider {
-
-class QueuedInvoker : public QObject
-{
- Q_OBJECT
-
-public:
- QueuedInvoker(QObject* parent = 0);
-
-private slots:
- void onQueuedCall(const char *method);
-
-signals:
- void queuedCall(const char *method);
-
-protected:
- void queueOnce(const char *method);
-
-private:
- QMutex callQueueLock; ///< Protects the callQueue
- QSet<QString> callQueue; ///< Methods to be invoked
-};
-
-} // namespace ContextProvider
-
-#endif