From 0e8dd553a4a9784c3fb1fa29d2dbba7ac04f15d7 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Fri, 7 Oct 2016 14:48:25 +0900 Subject: [PATCH] Dynamic interval table for multi handle Change-Id: Icdb7986f50e9f835f3c93a115cb20eb347698d11 Signed-off-by: kj7.sung --- client/include/lbs_dbus_client.h | 4 ++-- client/src/lbs_dbus_client.c | 14 +++++++++----- packaging/liblbs-dbus.changes | 6 ++++++ packaging/liblbs-dbus.spec | 2 +- server/include/lbs_dbus_server.h | 2 +- server/src/lbs_dbus_server.c | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/client/include/lbs_dbus_client.h b/client/include/lbs_dbus_client.h index e3f9788..1522d5e 100644 --- a/client/include/lbs_dbus_client.h +++ b/client/include/lbs_dbus_client.h @@ -65,12 +65,12 @@ int lbs_client_create(lbs_client_method_e method, lbs_client_dbus_h *lbs_client) int lbs_client_destroy(lbs_client_dbus_h lbs_client); int lbs_client_start(lbs_client_dbus_h lbs_client, unsigned int interval, lbs_client_callback_e callback_type, lbs_client_cb callback, void *user_data); -int lbs_client_stop(lbs_client_dbus_h lbs_client); +int lbs_client_stop(lbs_client_dbus_h lbs_client, unsigned int interval); int lbs_client_batch_start(lbs_client_dbus_h lbs_client, lbs_client_callback_e callback_type, lbs_client_cb callback, unsigned int batch_interval, unsigned int batch_period, void *user_data); int lbs_client_batch_stop(lbs_client_dbus_h lbs_client); int lbs_client_get_nmea(lbs_client_dbus_h lbs_client, int *timestamp, char **nmea); -int lbs_client_set_position_update_interval(lbs_client_dbus_h lbs_client, unsigned int interval); +int lbs_client_set_position_update_interval(lbs_client_dbus_h lbs_client, unsigned int interval, unsigned int prev_interval); /* Tizen 3.0 */ int lbs_client_set_mock_location_async(lbs_client_dbus_h lbs_client, diff --git a/client/src/lbs_dbus_client.c b/client/src/lbs_dbus_client.c index 266c4a1..c7b6a88 100755 --- a/client/src/lbs_dbus_client.c +++ b/client/src/lbs_dbus_client.c @@ -41,6 +41,7 @@ typedef struct _lbs_client_dbus_s { int batch_evt_id; int nmea_evt_id; int privacy_evt_id; + unsigned int interval; lbs_client_cb user_cb; lbs_client_cb batch_cb; void *user_data; @@ -209,7 +210,7 @@ static void __privacy_setting_changed(GDBusConnection *conn, const gchar *name, g_free(pkg_id); g_free(privacy_id); - if (lbs_client_stop(handle) != LBS_CLIENT_ERROR_NONE) + if (lbs_client_stop(handle, handle->interval) != LBS_CLIENT_ERROR_NONE) LBS_CLIENT_LOGE("lbs_client_stop is fail"); if (handle->user_cb) @@ -419,7 +420,7 @@ lbs_client_batch_start(lbs_client_dbus_h lbs_client, lbs_client_callback_e callb } EXPORT_API int -lbs_client_set_position_update_interval(lbs_client_dbus_h lbs_client, unsigned int interval) +lbs_client_set_position_update_interval(lbs_client_dbus_h lbs_client, unsigned int interval, unsigned int prev_interval) { LBS_CLIENT_LOGD("lbs_client_set_position_update_interval"); lbs_client_dbus_s *handle = (lbs_client_dbus_s *)lbs_client; @@ -439,10 +440,11 @@ lbs_client_set_position_update_interval(lbs_client_dbus_h lbs_client, unsigned i LBS_CLIENT_LOGD("LBS signal subscribe Object Path [%s]", signal_path); g_free(signal_path); - LBS_CLIENT_LOGD("SET option INTERVAL_UPDATE:[%u], method:[%d]", interval, method); + LBS_CLIENT_LOGD("SET option INTERVAL_UPDATE:[%u -> %u], method:[%d]", prev_interval, interval, method); builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); g_variant_builder_add(builder, "{sv}", "CMD", g_variant_new_string("SET:OPT")); g_variant_builder_add(builder, "{sv}", "INTERVAL_UPDATE", g_variant_new_uint32(interval)); + g_variant_builder_add(builder, "{sv}", "PREV_INTERVAL", g_variant_new_uint32(prev_interval)); g_variant_builder_add(builder, "{sv}", "METHOD", g_variant_new_int32(handle->method)); param = g_variant_ref_sink(g_variant_new("(@a{sv})", g_variant_builder_end(builder))); method = g_variant_ref_sink(g_variant_new("(i)", handle->method)); @@ -705,14 +707,15 @@ lbs_client_start(lbs_client_dbus_h lbs_client, unsigned int interval, lbs_client lbs_client_privacy_signal_subcribe(handle); handle->is_started = TRUE; + handle->interval = interval; return LBS_CLIENT_ERROR_NONE; } EXPORT_API int -lbs_client_stop(lbs_client_dbus_h lbs_client) +lbs_client_stop(lbs_client_dbus_h lbs_client, unsigned int interval) { - LBS_CLIENT_LOGD("lbs_client_stop"); + LBS_CLIENT_LOGD("lbs_client_stop [interval: %d]", interval); lbs_client_dbus_s *handle = (lbs_client_dbus_s *)lbs_client; g_return_val_if_fail(handle, LBS_CLIENT_ERROR_PARAMETER); @@ -734,6 +737,7 @@ lbs_client_stop(lbs_client_dbus_h lbs_client) LBS_CLIENT_LOGD("METHOD: %d", handle->method); g_variant_builder_add(builder, "{sv}", "METHOD", g_variant_new_int32(handle->method)); + g_variant_builder_add(builder, "{sv}", "INTERVAL", g_variant_new_uint32(interval)); if (__lbs_get_appid(&app_id)) { LBS_CLIENT_LOGD("[%s] Request STOP", app_id); diff --git a/packaging/liblbs-dbus.changes b/packaging/liblbs-dbus.changes index a3adb86..f348853 100644 --- a/packaging/liblbs-dbus.changes +++ b/packaging/liblbs-dbus.changes @@ -1,3 +1,9 @@ +[Version] lbs-dbus_1.0.2 +[Date] 31 Oct 2016 +[Changes] Dynamic interval table for multi handle +[Developer] Kyoungjun Sung +================================================================================ + [Version] lbs-dbus_1.0.1 [Date] 16 Aug 2016 [Changes] Fix mock location diff --git a/packaging/liblbs-dbus.spec b/packaging/liblbs-dbus.spec index cfbb0fc..67b1eb6 100644 --- a/packaging/liblbs-dbus.spec +++ b/packaging/liblbs-dbus.spec @@ -1,6 +1,6 @@ Name: liblbs-dbus Summary: DBus interface for Location Based Service -Version: 1.0.1 +Version: 1.0.2 Release: 1 Group: Location/Libraries License: Apache-2.0 diff --git a/server/include/lbs_dbus_server.h b/server/include/lbs_dbus_server.h index c16d14f..e8bb001 100644 --- a/server/include/lbs_dbus_server.h +++ b/server/include/lbs_dbus_server.h @@ -34,7 +34,7 @@ typedef enum { LBS_SERVER_INTERVAL_REMOVE, LBS_SERVER_INTERVAL_UPDATE, } lbs_server_interval_manipulation_type; -typedef gboolean(*LbsDbusUpdateIntervalCB)(lbs_server_interval_manipulation_type type, const gchar *client, int method, guint interval, gpointer userdata); +typedef gboolean(*LbsDbusUpdateIntervalCB)(lbs_server_interval_manipulation_type type, const gchar *client, int method, guint interval, guint prev_interval, gpointer userdata); typedef void (*LbsDbusRequestChangeIntervalCB)(int method, gpointer userdata); typedef void (*LbsDbusGetNmeaCB)(int *timestamp, gchar **nmea_data, gpointer userdata); diff --git a/server/src/lbs_dbus_server.c b/server/src/lbs_dbus_server.c index c4416f8..ba7e943 100644 --- a/server/src/lbs_dbus_server.c +++ b/server/src/lbs_dbus_server.c @@ -536,7 +536,7 @@ lbs_remove_client_by_force(const char *client, void *data) if (ctx->update_interval_cb) { gboolean is_needed_change_interval = FALSE; for (index = 0; index < LBS_SERVER_METHOD_SIZE ; index++) { - is_needed_change_interval = ctx->update_interval_cb(LBS_SERVER_INTERVAL_REMOVE, client, index, 0, ctx->userdata); + is_needed_change_interval = ctx->update_interval_cb(LBS_SERVER_INTERVAL_REMOVE, client, index, 0, 0, ctx->userdata); if (is_needed_change_interval) { is_needed_change_interval = FALSE; if (ctx->request_change_interval_cb) -- 2.7.4