Box can update their content even if it is in pause state 86/12586/1
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 19 Nov 2013 09:24:08 +0000 (18:24 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 19 Nov 2013 09:24:08 +0000 (18:24 +0900)
Change-Id: Id65168ff9f1de6b5d9a2b05cc7a58f6873c59716

packaging/org.tizen.data-provider-slave.spec
src/lb.c
src/update_monitor.c

index e123c3e..75f1218 100644 (file)
@@ -2,7 +2,7 @@
 
 Name: org.tizen.data-provider-slave
 Summary: Plugin type livebox service provider
-Version: 0.12.20
+Version: 0.12.21
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index 0a5c960..5c021d5 100644 (file)
--- a/src/lb.c
+++ b/src/lb.c
@@ -72,9 +72,11 @@ struct item {
 
 static struct info {
        Eina_List *item_list;
+       Eina_List *force_update_list;
        Eina_List *update_list;
        Eina_List *pending_list;
        Eina_List *hidden_list;
+       Ecore_Timer *force_update_timer;
        Ecore_Timer *pending_timer;
        Eina_List *pd_open_pending_list;
        Ecore_Timer *pd_open_pending_timer;
@@ -84,9 +86,11 @@ static struct info {
        int pending_timer_freezed;
 } s_info  = {
        .item_list = NULL,
+       .force_update_list = NULL,
        .update_list = NULL,
        .pending_list = NULL,
        .hidden_list = NULL,
+       .force_update_timer = NULL,
        .pending_timer = NULL,
        .pd_open_pending_list = NULL,
        .pd_open_pending_timer = NULL,
@@ -97,6 +101,7 @@ static struct info {
 };
 
 static Eina_Bool updator_cb(void *data);
+static inline void update_monitor_del(const char *id, struct item *item);
 
 static void pending_timer_freeze(void)
 {
@@ -177,6 +182,61 @@ cleanout:
        return ECORE_CALLBACK_CANCEL;
 }
 
+static Eina_Bool force_update_cb(void *data)
+{
+       struct item *item;
+
+       item = eina_list_nth(s_info.force_update_list, 0);
+       if (!item) {
+               goto cleanout;
+       }
+
+       if (eina_list_data_find(s_info.update_list, item) || pd_is_opened(item->inst->item->pkgname) < 0) {
+               return ECORE_CALLBACK_RENEW;
+       }
+
+       s_info.force_update_list = eina_list_remove(s_info.force_update_list, item);
+       if (updator_cb(item) == ECORE_CALLBACK_CANCEL) {
+       }
+
+       if (s_info.force_update_list) {
+               return ECORE_CALLBACK_RENEW;
+       }
+
+cleanout:
+       s_info.force_update_timer = NULL;
+       return ECORE_CALLBACK_CANCEL;
+}
+
+static inline __attribute__((always_inline)) int activate_force_update_consumer(void)
+{
+       if (s_info.force_update_timer) {
+               return LB_STATUS_SUCCESS;
+       }
+
+       s_info.force_update_timer = ecore_timer_add(0.000001f, force_update_cb, NULL);
+       if (!s_info.force_update_timer) {
+               ErrPrint("Failed to add a new force update timer\n");
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       DbgPrint("Force update timer is registered\n");
+
+       return LB_STATUS_SUCCESS;
+}
+
+static inline void deactivate_force_update_consumer(void)
+{
+       if (!s_info.force_update_timer) {
+               return;
+       }
+
+       ecore_timer_del(s_info.force_update_timer);
+       s_info.force_update_timer = NULL;
+
+       DbgPrint("Force update timer is deleted\n");
+}
+
 static Eina_Bool pended_cmd_consumer_cb(void *data)
 {
        struct item *item;
@@ -212,7 +272,7 @@ cleanout:
 static inline __attribute__((always_inline)) int activate_pending_consumer(void)
 {
        if (s_info.pending_timer) {
-               return 0;
+               return LB_STATUS_SUCCESS;
        }
 
        s_info.pending_timer = ecore_timer_add(0.000001f, pended_cmd_consumer_cb, NULL);
@@ -229,7 +289,7 @@ static inline __attribute__((always_inline)) int activate_pending_consumer(void)
                ecore_timer_freeze(s_info.pending_timer);
        }
 
-       return 0;
+       return LB_STATUS_SUCCESS;
 }
 
 static inline void deactivate_pending_consumer(void)
@@ -375,6 +435,59 @@ static int append_pending_list(struct item *item)
        return 0;
 }
 
+static int append_force_update_list(struct item *item)
+{
+       if (item->deleteme) {
+               DbgPrint("Item will be deleted, ignore force update request: %s\n", item->inst->id);
+               return LB_STATUS_ERROR_BUSY;
+       }
+
+       if (!IS_LB_SHOWN(item)) {
+               if (eina_list_data_find(s_info.hidden_list, item) == item) {
+                       DbgPrint("Already in hidden list - %s\n", item->inst->id);
+                       return LB_STATUS_ERROR_EXIST;
+               }
+
+               s_info.hidden_list = eina_list_append(s_info.hidden_list, item);
+
+               DbgPrint("forced item is moved to hidden_list - %s\n", item->inst->id);
+               return LB_STATUS_SUCCESS;
+       }
+
+       if (eina_list_data_find(s_info.force_update_list, item)) {
+               DbgPrint("Already in force update list\n");
+               return LB_STATUS_SUCCESS;
+       }
+
+       if (activate_force_update_consumer() < 0) {
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       s_info.force_update_list = eina_list_append(s_info.force_update_list, item);
+       return LB_STATUS_SUCCESS;
+}
+
+static inline int clear_from_force_update_list(struct item *item)
+{
+       Eina_List *l;
+       struct item *tmp;
+
+       EINA_LIST_FOREACH(s_info.force_update_list, l, tmp) {
+               if (tmp != item) {
+                       continue;
+               }
+
+               s_info.force_update_list = eina_list_remove_list(s_info.force_update_list, l);
+               if (!s_info.force_update_list) {
+                       deactivate_force_update_consumer();
+               }
+
+               return LB_STATUS_SUCCESS;
+       }
+
+       return LB_STATUS_ERROR_NOT_EXIST;
+}
+
 static inline void migrate_to_pending_list_from_hidden_list(struct item *item)
 {
        if (!eina_list_data_find(s_info.hidden_list, item)) {
@@ -530,6 +643,25 @@ static inline Eina_List *find_item(struct instance *inst)
        return NULL;
 }
 
+static int desc_updated_cb(const char *filename, void *data, int over)
+{
+       struct item *item;
+
+       if (over) {
+               WarnPrint("Event Q overflow\n");
+       }
+
+       item = data;
+
+       DbgPrint("DESC %s is updated\n", filename);
+       if (item->is_pd_show) {
+               provider_send_desc_updated(item->inst->item->pkgname, item->inst->id, filename);
+       } else {
+               ErrPrint("But PD is not opened, Ignore this update (%s)\n", item->inst->id);
+       }
+       return EXIT_SUCCESS;
+}
+
 static inline int output_handler(struct item *item)
 {
        int invalid = 0;
@@ -559,6 +691,7 @@ static inline int output_handler(struct item *item)
                s_info.update_list = eina_list_remove(s_info.update_list, item);
 
                if (item->deleteme) {
+                       update_monitor_del(item->inst->id, item);
                        provider_send_deleted(item->inst->item->pkgname, item->inst->id);
                        (void)so_destroy(item->inst);
                        free(item);
@@ -569,25 +702,6 @@ static inline int output_handler(struct item *item)
        return EXIT_SUCCESS;
 }
 
-static int desc_updated_cb(const char *filename, void *data, int over)
-{
-       struct item *item;
-
-       if (over) {
-               WarnPrint("Event Q overflow\n");
-       }
-
-       item = data;
-
-       DbgPrint("DESC %s is updated\n", filename);
-       if (item->is_pd_show) {
-               provider_send_desc_updated(item->inst->item->pkgname, item->inst->id, filename);
-       } else {
-               ErrPrint("But PD is not opened, Ignore this update (%s)\n", item->inst->id);
-       }
-       return EXIT_SUCCESS;
-}
-
 static int file_updated_cb(const char *filename, void *data, int over)
 {
        struct item *item;
@@ -774,6 +888,11 @@ static Eina_Bool updator_cb(void *data)
                (void)append_pending_list(item);
        }
 
+       if (ret & FORCE_TO_SCHEDULE) {
+               DbgPrint("%s Return NEED_TO_FORCE_SCHEDULE\n", item->inst->item->pkgname);
+               (void)append_force_update_list(item);
+       }
+
        if (ret & OUTPUT_UPDATED) {
                /*!
                 * \NOTE 
@@ -1102,6 +1221,11 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info
                (void)append_pending_list(item);
        }
 
+       if (create_ret & FORCE_TO_SCHEDULE) {
+               DbgPrint("%s Returns NEED_TO_FORCE_UPDATE\n", pkgname);
+               (void)append_force_update_list(item);
+       }
+
        if (create_ret & OUTPUT_UPDATED) {
                update_monitor_cnt(item);
                /*!
@@ -1189,6 +1313,7 @@ HAPI int lb_destroy(const char *pkgname, const char *id)
        s_info.hidden_list = eina_list_remove(s_info.hidden_list, item);
        clear_from_pd_open_pending_list(item);
        clear_from_pending_list(item);
+       clear_from_force_update_list(item);
 
        if (item->timer) {
                ecore_timer_del(item->timer);
@@ -1239,6 +1364,11 @@ HAPI int lb_resize(const char *pkgname, const char *id, int w, int h)
                (void)append_pending_list(item);
        }
 
+       if (ret & FORCE_TO_SCHEDULE) {
+               DbgPrint("%s Return NEED_TO_FORCE_SCHEDULE\n", pkgname);
+               (void)append_force_update_list(item);
+       }
+
        if (ret & OUTPUT_UPDATED) {
                update_monitor_cnt(item);
        }
@@ -1338,6 +1468,11 @@ HAPI int lb_clicked(const char *pkgname, const char *id, const char *event, doub
                (void)append_pending_list(item);
        }
 
+       if (ret & FORCE_TO_SCHEDULE) {
+               DbgPrint("%s Return NEED_TO_FORCE_SCHEDULE\n", pkgname);
+               (void)append_force_update_list(item);
+       }
+
        if (ret & OUTPUT_UPDATED) {
                update_monitor_cnt(item);
        }
@@ -1407,6 +1542,11 @@ HAPI int lb_script_event(const char *pkgname, const char *id, const char *emissi
                (void)append_pending_list(item);
        }
 
+       if (ret & FORCE_TO_SCHEDULE) {
+               DbgPrint("%s Return NEED_TO_FORCE_SCHEDULE\n", pkgname);
+               (void)append_force_update_list(item);
+       }
+
        if (ret & OUTPUT_UPDATED) {
                update_monitor_cnt(item);
        }
@@ -1476,6 +1616,11 @@ HAPI int lb_change_group(const char *pkgname, const char *id, const char *cluste
                (void)append_pending_list(item);
        }
 
+       if (ret & FORCE_TO_SCHEDULE) {
+               DbgPrint("%s Return NEED_TO_FORCE_SCHEDULE\n", pkgname);
+               (void)append_force_update_list(item);
+       }
+
        if (ret & OUTPUT_UPDATED) {
                update_monitor_cnt(item);
        }
@@ -1496,6 +1641,11 @@ static int lb_sys_event(struct instance *inst, struct item *item, int event)
                (void)append_pending_list(item);
        }
 
+       if (ret & FORCE_TO_SCHEDULE) {
+               DbgPrint("%s Return NEED_TO_FORCE_SCHEDULE\n", item->inst->item->pkgname);
+               (void)append_force_update_list(item);
+       }
+
        if (ret & OUTPUT_UPDATED) {
                update_monitor_cnt(item);
        }
index 9162e3d..4027d22 100644 (file)
@@ -218,9 +218,12 @@ HAPI int update_monitor_trigger_update_cb(const char *filename, int over)
 
        EINA_LIST_FOREACH_SAFE(s_info.update_list, l, n, item) {
                if (!strcmp(filename, item->filename) && item->cb(filename, item->data, over) == EXIT_FAILURE) {
-                       s_info.update_list = eina_list_remove_list(s_info.update_list, l);
-                       free(item->filename);
-                       free(item);
+                       /* Item can be deleted from the callback, so need to check existence */
+                       if (eina_list_data_find(s_info.update_list, item)) {
+                               s_info.update_list = eina_list_remove_list(s_info.update_list, l);
+                               free(item->filename);
+                               free(item);
+                       }
                        cnt++;
                }
        }
@@ -237,9 +240,12 @@ HAPI int update_monitor_trigger_delete_cb(const char *filename, int over)
 
        EINA_LIST_FOREACH_SAFE(s_info.delete_list, l, n, item) {
                if (!strcmp(filename, item->filename) && item->cb(filename, item->data, over) == EXIT_FAILURE) {
-                       s_info.delete_list = eina_list_remove_list(s_info.delete_list, l);
-                       free(item->filename);
-                       free(item);
+                       /* Item can be deleted from the callback, so need to check existence. */
+                       if (eina_list_data_find(s_info.delete_list, item)) {
+                               s_info.delete_list = eina_list_remove_list(s_info.delete_list, l);
+                               free(item->filename);
+                               free(item);
+                       }
                        cnt++;
                }
        }