Send error code to viewer 72/150872/2 devel/tizen
authorJunghoon Park <jh9216.park@samsung.com>
Tue, 12 Sep 2017 05:05:29 +0000 (14:05 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Thu, 21 Sep 2017 08:50:08 +0000 (17:50 +0900)
- In case of sending WIDGET_INSTANCE_EVENT_CREATE_ABORTED, the error
  code should be sent to viewer
- Require:
  https://review.tizen.org/gerrit/#/c/149321/

Change-Id: I2ad991dda2e4e10d78a774f75a42fefa90bc99d2
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/base/widget_base.c

index 92c8123..e43635d 100644 (file)
@@ -239,12 +239,13 @@ static int __send_lifecycle_event(const char *class_id, const char *instance_id,
 }
 
 static int __send_update_status(const char *class_id, const char *instance_id,
-       int status, bundle *extra)
+       int status, int err, bundle *extra)
 {
        bundle *b;
        int lifecycle = -1;
        bundle_raw *raw = NULL;
        int len;
+       char err_str[256];
 
        b = bundle_create();
        if (!b) {
@@ -252,6 +253,11 @@ static int __send_update_status(const char *class_id, const char *instance_id,
                return -1; /* LCOV_EXCL_LINE */
        }
 
+       if (err < 0) {
+               snprintf(err_str, sizeof(err_str), "%d", err);
+               bundle_add_str(b, AUL_K_WIDGET_ERROR_CODE, err_str);
+       }
+
        bundle_add_str(b, AUL_K_WIDGET_ID, class_id);
        bundle_add_str(b, AUL_K_WIDGET_INSTANCE_ID, instance_id);
        bundle_add_byte(b, AUL_K_WIDGET_STATUS, &status, sizeof(int));
@@ -385,7 +391,7 @@ static void __control_resize(const char *class_id, const char *id, bundle *b)
 
        LOGD("%s is resized to %dx%d", id, w, h);
        __send_update_status(class_id, id,
-               WIDGET_INSTANCE_EVENT_SIZE_CHANGED, NULL);
+               WIDGET_INSTANCE_EVENT_SIZE_CHANGED, 0, NULL);
 }
 
 static void __call_update_cb(const char *class_id, const char *id, int force,
@@ -430,7 +436,7 @@ static void __call_update_cb(const char *class_id, const char *id, int force,
                cls->ops.update(instance_h, content, force, class_data);
 
        __send_update_status(class_id, id,
-               WIDGET_INSTANCE_EVENT_UPDATE, NULL);
+               WIDGET_INSTANCE_EVENT_UPDATE, 0, NULL);
        LOGD("updated:%s", id);
 
        if (content)
@@ -964,7 +970,7 @@ EXPORT_API int widget_base_context_set_content_info(
                return WIDGET_BASE_ERROR_FAULT;
 
        ret = __send_update_status(class_id, id,
-                       WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
+                       WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, 0, content_info);
 
        if (data->content)
                free(data->content);
@@ -1367,14 +1373,14 @@ static void __multiwindow_instance_create(
        if (ret < 0) {
                LOGW("Create callback returns error(%d)", ret);
                ret = __send_update_status(class_id, id,
-                               WIDGET_INSTANCE_EVENT_CREATE_ABORTED, NULL);
+                               WIDGET_INSTANCE_EVENT_CREATE_ABORTED, ret, NULL);
                if (ret < 0)
                        LOGE("Fail to send abort status (%d) ", ret);
                __instance_drop(instance_h);
        } else {
                LOGD("%s is created", id);
                ret = __send_update_status(class_id, id,
-                       WIDGET_INSTANCE_EVENT_CREATE, NULL);
+                       WIDGET_INSTANCE_EVENT_CREATE, 0, NULL);
                if (ret < 0)
                        LOGE("Fail to send create status (%d) ", ret);
 
@@ -1432,7 +1438,7 @@ static void __multiwindow_instance_resume(
 
        LOGD("%s is resumed", id);
        __send_update_status(class_id, id,
-               WIDGET_INSTANCE_EVENT_RESUME, NULL);
+               WIDGET_INSTANCE_EVENT_RESUME, 0, NULL);
 
        if (!__fg_signal) {
                LOGD("Send fg signal to resourceD");
@@ -1467,7 +1473,7 @@ static void __multiwindow_instance_pause(
 
        LOGD("%s is paused", id);
        __send_update_status(class_id, id,
-               WIDGET_INSTANCE_EVENT_PAUSE, NULL);
+               WIDGET_INSTANCE_EVENT_PAUSE, 0, NULL);
 
        if (__fg_signal) {
                LOGD("Send bg signal to resourceD");
@@ -1528,7 +1534,7 @@ static void __multiwindow_instance_terminate(
        } else {
                __is_permanent = false;
                __send_update_status(class_id, id,
-                               WIDGET_INSTANCE_EVENT_EXTRA_UPDATED,
+                               WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, 0,
                                content_info);
        }
 
@@ -1538,7 +1544,7 @@ static void __multiwindow_instance_terminate(
        if (data->periodic_timer)
                g_source_remove(data->periodic_timer);
 
-       __send_update_status(class_id, id, event, NULL);
+       __send_update_status(class_id, id, event, 0, NULL);
        appcore_multiwindow_base_class_on_terminate(instance_h);
 }