Send error code to viewer 22/149322/2
authorJunghoon Park <jh9216.park@samsung.com>
Tue, 12 Sep 2017 05:05:29 +0000 (14:05 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Wed, 13 Sep 2017 02:37:10 +0000 (11:37 +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>
src/widget_app.c

index 22d6920..d930a63 100755 (executable)
@@ -232,13 +232,14 @@ 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 *viewer_endpoint = _widget_app_get_viewer_endpoint();
+       char err_str[256];
 
        b = bundle_create();
        if (!b) {
@@ -246,6 +247,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));
@@ -343,7 +349,7 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd
        _D("%s is resumed", id);
        if (send_update) {
                ret = __send_update_status(handle->classid, wc->id,
-                       WIDGET_INSTANCE_EVENT_RESUME, NULL);
+                       WIDGET_INSTANCE_EVENT_RESUME, 0, NULL);
                if (!fg_signal) {
                        _D("Send fg signal to resourceD");
                        aul_send_app_status_change_signal(getpid(),
@@ -387,7 +393,7 @@ static int __instance_pause(widget_class_h handle, const char *id, int send_upda
        _D("%s is paused", id);
        if (send_update) {
                ret = __send_update_status(handle->classid, wc->id,
-                       WIDGET_INSTANCE_EVENT_PAUSE, NULL);
+                       WIDGET_INSTANCE_EVENT_PAUSE, 0, NULL);
                wc = __find_context_by_state(WC_RUNNING);
                if (!wc && fg_signal) {
                        _D("Send bg signal to resourceD");
@@ -420,7 +426,7 @@ static int __instance_resize(widget_class_h handle, const char *id, int w, int h
 
        _D("%s is resized to %dx%d", id, w, h);
        ret = __send_update_status(handle->classid, wc->id,
-               WIDGET_INSTANCE_EVENT_SIZE_CHANGED, NULL);
+               WIDGET_INSTANCE_EVENT_SIZE_CHANGED, 0, NULL);
 
        return ret;
 }
@@ -462,7 +468,7 @@ static int __instance_update_all(widget_class_h handle, int force, const char *c
 
                        handle->ops.update(wc, b, force, handle->user_data);
                        ret = __send_update_status(handle->classid, wc->id,
-                               WIDGET_INSTANCE_EVENT_UPDATE, NULL);
+                               WIDGET_INSTANCE_EVENT_UPDATE, 0, NULL);
                        _D("updated:%s", wc->id);
                }
        }
@@ -497,7 +503,7 @@ static int __instance_update(widget_class_h handle, const char *id, int force, c
        if (handle->ops.update) {
                handle->ops.update(wc, b, force, handle->user_data);
                ret = __send_update_status(handle->classid, wc->id,
-                       WIDGET_INSTANCE_EVENT_UPDATE, NULL);
+                       WIDGET_INSTANCE_EVENT_UPDATE, 0, NULL);
                _D("updated:%s", id);
        }
 
@@ -539,7 +545,7 @@ static int __instance_create(widget_class_h handle, const char *id,
        if (ret < 0) {
                _W("Create callback resturns error(%d)", ret);
                send_ret = __send_update_status(handle->classid, wc->id,
-                               WIDGET_INSTANCE_EVENT_CREATE_ABORTED, NULL);
+                               WIDGET_INSTANCE_EVENT_CREATE_ABORTED, ret, NULL);
                if (send_ret < 0)
                        _E("Fail to send abort status (%d)", send_ret);
 
@@ -554,7 +560,7 @@ static int __instance_create(widget_class_h handle, const char *id,
                        widget_app_exit();
        } else {
                ret = __send_update_status(handle->classid, wc->id,
-                       WIDGET_INSTANCE_EVENT_CREATE, NULL);
+                       WIDGET_INSTANCE_EVENT_CREATE, 0, NULL);
 
                if (content == NULL)
                        content = "NULL";
@@ -604,13 +610,13 @@ static int __instance_destroy(widget_class_h handle, const char *id,
        } else {
                is_permanent = false;
                ret = __send_update_status(handle->classid, id,
-                               WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
+                               WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, 0, content_info);
        }
 
        if (content_info)
                bundle_free(content_info);
 
-       ret = __send_update_status(handle->classid, id, event, NULL);
+       ret = __send_update_status(handle->classid, id, event, 0, NULL);
 
        _widget_app_remove_context(wc);
 
@@ -1687,7 +1693,7 @@ EXPORT_API int widget_app_context_set_content_info(widget_context_h context,
                return widget_app_error(WIDGET_ERROR_FAULT, __FUNCTION__, NULL);
 
        ret = __send_update_status(class_id, context->id,
-                       WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
+                       WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, 0, content_info);
 
        if (context->content)
                free(context->content);