Simplify the update event sending API
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 29 Oct 2014 04:59:38 +0000 (13:59 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 29 Oct 2014 04:59:38 +0000 (13:59 +0900)
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ieff436f9dd80c35ccaa7e02374a8f7d07c61708b

src/dynamicbox.c

index 70d98c2..f4a7c8c 100644 (file)
@@ -93,15 +93,11 @@ static struct info {
 
     union _updated {
        struct _slave {
-           int (*dbox)(const char *pkgname, const char *id, int idx, int x, int y, int w, int h);
-           int (*gbar)(const char *pkgname, const char *id, int idx, const char *descfile, int x, int y, int w, int h);
+           int (*send)(const char *pkgname, const char *id, int idx, int x, int y, int w, int h, int gbar, const char *descfile);
        } slave;
 
        struct _app {
-           int (*dbox)(const char *id, int x, int y, int w, int h);
-           int (*gbar)(const char *id, int x, int y, int w, int h);
-           int (*dbox_extra)(const char *id, int idx, int x, int y, int w, int h);
-           int (*gbar_extra)(const char *id, int idx, int x, int y, int w, int h);
+           int (*send)(const char *id, int idx, int x, int y, int w, int h, int gbar);
        } app;
     } updated;
 } s_info = {
@@ -114,13 +110,7 @@ static struct info {
 
 #define FUNC_PREFIX                               "dynamicbox_"
 #define FUNC_DYNAMICBOX_SEND_UPDATED              FUNC_PREFIX "send_updated"
-#define FUNC_DYNAMICBOX_SEND_DESC_UPDATED         FUNC_PREFIX "send_desc_updated"
-
-#define FUNC_DYNAMICBOX_PROVIDER_APP_DBOX_UPDATED FUNC_PREFIX "provider_app_dbox_updated"
-#define FUNC_DYNAMICBOX_PROVIDER_APP_GBAR_UPDATED FUNC_PREFIX "provider_app_gbar_updated"
-#define FUNC_DYNAMICBOX_PROVIDER_APP_DBOX_EXTRA_UPDATED FUNC_PREFIX "provider_app_dbox_extra_updated"
-#define FUNC_DYNAMICBOX_PROVIDER_APP_GBAR_EXTRA_UPDATED FUNC_PREFIX "provider_app_gbar_extra_updated"
-
+#define FUNC_DYNAMICBOX_PROVIDER_APP_UPDATED      FUNC_PREFIX "provider_app_updated"
 #define FUNC_DYNAMICBOX_FIND_PKGNAME              FUNC_PREFIX "find_pkgname"
 #define FUNC_DYNAMICBOX_REQUEST_UPDATE_BY_ID      FUNC_PREFIX "request_update_by_id"
 #define FUNC_DYNAMICBOX_TRIGGER_UPDATE_MONITOR    FUNC_PREFIX "trigger_update_monitor"
@@ -129,26 +119,20 @@ static struct info {
 static inline void load_update_function(void)
 {
     /* Must to be checked the slave function first. */
-    s_info.updated.slave.dbox = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_SEND_UPDATED);
-    s_info.updated.slave.gbar = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_SEND_DESC_UPDATED);
-    if (s_info.updated.slave.dbox && s_info.updated.slave.gbar) {
+    s_info.updated.slave.send = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_SEND_UPDATED);
+    if (s_info.updated.slave.send) {
        s_info.type = LOAD_TYPE_SLAVE;
        DbgPrint("Slave detected\n");
     } else {
-       s_info.updated.app.dbox = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_PROVIDER_APP_DBOX_UPDATED);
-       s_info.updated.app.gbar = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_PROVIDER_APP_GBAR_UPDATED);
-       s_info.updated.app.dbox_extra = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_PROVIDER_APP_DBOX_EXTRA_UPDATED);
-       s_info.updated.app.gbar_extra = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_PROVIDER_APP_GBAR_EXTRA_UPDATED);
-       if (s_info.updated.app.dbox && s_info.updated.app.gbar
-          && s_info.updated.app.dbox_extra && s_info.updated.app.gbar_extra)
-        {
+       s_info.updated.app.send = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_PROVIDER_APP_UPDATED);
+       if (s_info.updated.app.send) {
            s_info.type = LOAD_TYPE_APP;
            DbgPrint("App detected\n");
        }
     }
 }
 
-static int send_dbox_updated(const char *pkgname, const char *id, int idx, int x, int y, int w, int h)
+static int send_updated(const char *pkgname, const char *id, int idx, int x, int y, int w, int h, int gbar, const char *descfile)
 {
     int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
 
@@ -157,13 +141,9 @@ static int send_dbox_updated(const char *pkgname, const char *id, int idx, int x
     }
 
     if (s_info.type == LOAD_TYPE_APP) {
-       if (idx == DBOX_PRIMARY_BUFFER) {
-           ret = s_info.updated.app.dbox(id, x, y, w, h);
-       } else {
-           ret = s_info.updated.app.dbox_extra(id, idx, x, y, w, h);
-       }
+       ret = s_info.updated.app.send(id, idx, x, y, w, h, gbar);
     } else if (s_info.type == LOAD_TYPE_SLAVE) {
-       ret = s_info.updated.slave.dbox(pkgname, id, idx, x, y, w, h);
+       ret = s_info.updated.slave.send(pkgname, id, idx, x, y, w, h, gbar, descfile);
     } else {
        dynamicbox_damage_region_t region = {
            .x = x,
@@ -171,36 +151,7 @@ static int send_dbox_updated(const char *pkgname, const char *id, int idx, int x
            .w = w,
            .h = h,
        };
-       ret = dynamicbox_provider_send_updated(pkgname, id, &region);
-    }
-
-    return ret;
-}
-
-static int send_gbar_updated(const char *pkgname, const char *id, int idx, const char *descfile, int x, int y, int w, int h)
-{
-    int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
-
-    if (s_info.type == LOAD_TYPE_UNKNOWN) {
-       load_update_function();
-    }
-
-    if (s_info.type == LOAD_TYPE_APP) {
-       if (idx == DBOX_PRIMARY_BUFFER) {
-           ret = s_info.updated.app.gbar(id, x, y, w, h);
-       } else {
-           ret = s_info.updated.app.gbar_extra(id, idx, x, y, w, h);
-       }
-    } else if (s_info.type == LOAD_TYPE_SLAVE) {
-       ret = s_info.updated.slave.gbar(pkgname, id, idx, descfile, x, y, w, h);
-    } else {
-       dynamicbox_damage_region_t region = {
-           .x = x,
-           .y = y,
-           .w = w,
-           .h = h,
-       };
-       ret = dynamicbox_provider_send_desc_updated(pkgname, id, descfile, &region);
+       ret = dynamicbox_provider_send_updated(pkgname, id, idx, &region, gbar, descfile);
     }
 
     return ret;
@@ -926,11 +877,11 @@ PUBLIC int dynamicbox_sync_buffer(dynamicbox_buffer_h handle)
      */
 
     if (user_data->is_gbar == 1) {
-       if (send_gbar_updated(pkgname, id, DBOX_PRIMARY_BUFFER, NULL, 0, 0, w, h) < 0) {
+       if (send_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL) < 0) {
            ErrPrint("Failed to send GBAR updated (%s)\n", id);
        }
     } else {
-       if (send_dbox_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h) < 0) {
+       if (send_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL) < 0) {
            ErrPrint("Failed to send updated (%s)\n", id);
        }
     }
@@ -969,14 +920,8 @@ PUBLIC int dynamicbox_send_updated_by_idx(dynamicbox_buffer_h handle, int idx)
        ErrPrint("Failed to get size (%s)\n", id);
     }
 
-    if (user_data->is_gbar == 1) {
-        if (send_gbar_updated(pkgname, id, idx, NULL, 0, 0, w, h) < 0) {
-           ErrPrint("Failed to send GBAR updated (%s) %d\n", id, idx);
-       }
-    } else {
-       if (send_dbox_updated(pkgname, id, idx, 0, 0, w, h) < 0) {
-           ErrPrint("Failed to send updated (%s) %d\n", id, idx);
-       }
+    if (send_updated(pkgname, id, idx, 0, 0, w, h, user_data->is_gbar, NULL) < 0) {
+       ErrPrint("Failed to send GBAR updated (%s) %d\n", id, idx);
     }
 }
 
@@ -1123,14 +1068,8 @@ PUBLIC int dynamicbox_buffer_post_render(dynamicbox_buffer_h handle)
      * to make more efficient updates
      */
 
-    if (user_data->is_gbar == 1) {
-       if (send_gbar_updated(pkgname, id, DBOX_PRIMARY_BUFFER, NULL, 0, 0, w, h) < 0) {
-           ErrPrint("Failed to send GBAR updated (%s)\n", id);
-       }
-    } else {
-       if (send_dbox_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h) < 0) {
-           ErrPrint("Failed to send updated (%s)\n", id);
-       }
+    if (send_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL) < 0) {
+       ErrPrint("Failed to send GBAR updated (%s)\n", id);
     }
 
     return DBOX_STATUS_ERROR_NONE;