Implement widget operation for 'period' 72/139672/1
authorJunghoon Park <jh9216.park@samsung.com>
Thu, 20 Jul 2017 05:23:36 +0000 (14:23 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 20 Jul 2017 05:23:36 +0000 (14:23 +0900)
- 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 <jh9216.park@samsung.com>
src/widget_app.c

index 5cc0e22..527cfa8 100755 (executable)
@@ -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;