From def6e470cc48abce1f37937ddc77be77dffb4999 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Thu, 20 Jul 2017 14:23:36 +0900 Subject: [PATCH] Implement widget operation for 'period' - This patch is associated with widget_service_change_period() - This operation is responsible for changing current update-period Change-Id: I32abe9b865941040d223d467984dac8e72e9d748 Signed-off-by: Junghoon Park --- src/widget_app.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/widget_app.c b/src/widget_app.c index 5cc0e22..527cfa8 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -598,6 +598,31 @@ static int __instance_destroy(widget_class_h handle, const char *id, return ret; } +static int __instance_change_period(const char *id, double period) +{ + widget_context_s *wc = __find_context_by_id(id); + + if (!wc) { + _E("could not find widget obj: %s", id); + return -1; + } + + if (wc->periodic_timer) { + _D("Remove timer!"); + g_source_remove(wc->periodic_timer); + wc->periodic_timer = 0; + } + + wc->period = period; + if (wc->period > 0) { + _D("Restart timer!"); + wc->periodic_timer = g_timeout_add_seconds(wc->period, + __timeout_cb, wc); + } + + return 0; +} + static widget_class_h __find_class_handler(const char *class_id, widget_class_h handle) { @@ -710,6 +735,8 @@ static void __control(bundle *b) __instance_pause(handle, id, UPDATE_ALL); } else if (strcmp(operation, "terminate") == 0) { __instance_destroy(handle, id, WIDGET_APP_DESTROY_TYPE_TEMPORARY, UPDATE_ALL); + } else if (strcmp(operation, "period") == 0) { + __instance_change_period(id, update_period); } return; -- 2.7.4