aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarja Hassinen <ext-marja.2.hassinen@nokia.com>2009-10-29 14:08:16 +0200
committerMarja Hassinen <ext-marja.2.hassinen@nokia.com>2009-10-29 14:08:16 +0200
commit9b655f793a5df435b328b3eb6d1edc4bf828ad05 (patch)
treebbd99f2f2fe1e06c86ce5375a41b347c03633010
parentf742093e36ebacc2ec8f8134f8bea0438e1e1943 (diff)
libcontextprovider, protocol change: Small changes based on review:
1) don't use pow, 2) consistent slot naming 3) comments and intendation
-rw-r--r--libcontextprovider/src/propertyadaptor.cpp15
-rw-r--r--libcontextprovider/src/propertyadaptor.h2
-rw-r--r--libcontextprovider/src/propertyprivate.cpp5
3 files changed, 14 insertions, 8 deletions
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;
}