From 07a94078b2555852355b10f56c28da55d4fe74dc Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 23 Jul 2010 20:01:49 -0700 Subject: [PATCH] Update RegisterCounter method parameters --- doc/manager-api.txt | 20 +++++++++++++++----- src/manager.c | 11 +++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/doc/manager-api.txt b/doc/manager-api.txt index 40dac01..20ceb70 100644 --- a/doc/manager-api.txt +++ b/doc/manager-api.txt @@ -129,14 +129,24 @@ Methods dict GetProperties() Possible Errors: [service].Error.InvalidArguments - void RegisterCounter(object path, uint32 interval) + void RegisterCounter(object path, uint32 accuracy, uint32 period) Register a new counter for user notifications. - If the interval is zero then no timer for updates - will be started. Only kernel events can then - trigger updates. Otherwise the kernel will be - polled every n seconds for an update. + The accuracy is specified in kilo-bytes and defines + a threshold for counter updates. Together with the + period value it defines how often user space needs + to be updated. The period value is in seconds. + + This interface is not meant for time tracking. If + the time needs to be tracked down to the second, it + is better to have a real timer running inside the + application than using this interface. + + Also getting notified for every kilo-byte is a bad + choice (even if the interface supports it). Something + like 10 kilo-byte units or better 1 mega-byte seems + to be a lot more reasonable and better for the user. Possible Errors: [service].Error.InvalidArguments diff --git a/src/manager.c b/src/manager.c index 514cd1e..54c5c3e 100644 --- a/src/manager.c +++ b/src/manager.c @@ -572,7 +572,7 @@ static DBusMessage *register_counter(DBusConnection *conn, DBusMessage *msg, void *data) { const char *sender, *path; - unsigned int interval; + unsigned int accuracy, period; int err; DBG("conn %p", conn); @@ -580,10 +580,13 @@ static DBusMessage *register_counter(DBusConnection *conn, sender = dbus_message_get_sender(msg); dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, - DBUS_TYPE_UINT32, &interval, + DBUS_TYPE_UINT32, &accuracy, + DBUS_TYPE_UINT32, &period, DBUS_TYPE_INVALID); - err = __connman_counter_register(sender, path, interval); + /* FIXME: add handling of accuracy parameter */ + + err = __connman_counter_register(sender, path, period); if (err < 0) return __connman_error_failed(msg, -err); @@ -670,7 +673,7 @@ static GDBusMethodTable manager_methods[] = { G_DBUS_METHOD_FLAG_ASYNC }, { "RegisterAgent", "o", "", register_agent }, { "UnregisterAgent", "o", "", unregister_agent }, - { "RegisterCounter", "ou", "", register_counter }, + { "RegisterCounter", "ouu", "", register_counter }, { "UnregisterCounter", "o", "", unregister_counter }, { "RequestSession", "s", "o", request_session }, { "ReleaseSession", "s", "", release_session }, -- 2.7.4