Add widget app restart logic
[platform/core/appfw/appcore-widget.git] / src / widget_app.c
index 2018931..f90e7ec 100755 (executable)
@@ -62,14 +62,6 @@ enum {
        UPDATE_ALL = 1,
 };
 
-struct _widget_class {
-       void *user_data;
-       widget_instance_lifecycle_callback_s ops;
-       char *classid;
-       struct _widget_class *next;
-       struct _widget_class *prev;
-};
-
 struct app_event_handler {
        app_event_type_e type;
        app_event_cb cb;
@@ -81,19 +73,7 @@ struct app_event_info {
        void *value;
 };
 
-struct _widget_context {
-       char *id;
-       struct _widget_class *provider;
-       int state;
-       void *tag;
-       Evas_Object *win;
-       int win_id;
-       char *content;
-       widget_instance_lifecycle_callback_s ops;
-};
-
 typedef struct _widget_class widget_class_s;
-typedef struct _widget_context widget_context_s;
 
 #define WIDGET_APP_EVENT_MAX 5
 static GList *handler_list[WIDGET_APP_EVENT_MAX] = {NULL, };
@@ -103,8 +83,6 @@ static widget_app_lifecycle_callback_s *app_ops;
 static void *app_user_data;
 static char *appid;
 static widget_class_h class_provider;
-static GList *contexts;
-static char *viewer_endpoint;
 static int exit_called;
 
 static void _widget_core_set_appcore_event_cb(void);
@@ -138,8 +116,8 @@ static inline bool _is_widget_feature_enabled(void)
        ret = system_info_get_platform_bool(
                        "http://tizen.org/feature/shell.appwidget", &feature);
        if (ret != SYSTEM_INFO_ERROR_NONE) {
-               _E("failed to get system info");
-               return false;
+               _E("failed to get system info"); /* LCOV_EXCL_LINE */
+               return false; /* LCOV_EXCL_LINE */
        }
 
        retrieved = true;
@@ -156,8 +134,13 @@ static gint __comp_by_id(gconstpointer a, gconstpointer b)
 
 static widget_context_s *__find_context_by_id(const char *id)
 {
-       GList *ret = g_list_find_custom(contexts, id, __comp_by_id);
+       GList *ret;
+       GList *contexts = _widget_app_get_contexts();
 
+       if (id == NULL)
+               return NULL;
+
+       ret = g_list_find_custom(contexts, id, __comp_by_id);
        if (ret == NULL)
                return NULL;
 
@@ -174,6 +157,7 @@ static gint __comp_by_win(gconstpointer a, gconstpointer b)
 
 static widget_context_s *__find_context_by_win(int win)
 {
+       GList *contexts = _widget_app_get_contexts();
        GList *ret = g_list_find_custom(contexts, GINT_TO_POINTER(win), __comp_by_win);
 
        if (ret == NULL)
@@ -189,18 +173,18 @@ static int __send_lifecycle_event(const char *class_id, const char *instance_id,
        int ret;
 
        if (b == NULL) {
-               _E("out of memory");
-               return -1;
+               _E("out of memory"); /* LCOV_EXCL_LINE */
+               return -1; /* LCOV_EXCL_LINE */
        }
 
-       bundle_add_str(b, WIDGET_K_ID, class_id);
-       bundle_add_str(b, WIDGET_K_INSTANCE, instance_id);
-       bundle_add_byte(b, WIDGET_K_STATUS, &status, sizeof(int));
+       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));
 
        _D("send lifecycle %s(%d)", instance_id, status);
        ret = aul_app_com_send("widget.status", b);
        if (ret < 0)
-               _E("send lifecycle error:%d", ret);
+               _E("send lifecycle error:%d", ret); /* LCOV_EXCL_LINE */
 
        bundle_free(b);
 
@@ -214,20 +198,22 @@ static int __send_update_status(const char *class_id, const char *instance_id,
        int lifecycle = -1;
        bundle_raw *raw = NULL;
        int len;
+       char *viewer_endpoint = _widget_app_get_viewer_endpoint();
 
        b = bundle_create();
        if (!b) {
-               _E("out of memory");
-               return -1;
+               _E("out of memory"); /* LCOV_EXCL_LINE */
+               return -1; /* LCOV_EXCL_LINE */
        }
 
-       bundle_add_str(b, WIDGET_K_ID, class_id);
-       bundle_add_str(b, WIDGET_K_INSTANCE, instance_id);
-       bundle_add_byte(b, WIDGET_K_STATUS, &status, sizeof(int));
+       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));
 
        if (extra) {
                bundle_encode(extra, &raw, &len);
                bundle_add_str(b, WIDGET_K_CONTENT_INFO, (const char *)raw);
+               aul_widget_instance_add(class_id, instance_id);
        }
 
        _D("send update %s(%d) to %s", instance_id, status, viewer_endpoint);
@@ -264,18 +250,18 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd
        int ret;
 
        if (!wc) {
-               _E("context not found: %s", id);
-               return -1;
+               _E("context not found: %s", id); /* LCOV_EXCL_LINE */
+               return -1; /* LCOV_EXCL_LINE */
        }
 
        if (wc->state == WC_RUNNING) {
-               _D("%s is already in running state", id);
-               return 0;
+               _D("%s is already in running state", id); /* LCOV_EXCL_LINE */
+               return 0; /* LCOV_EXCL_LINE */
        }
 
        if (wc->state == WC_TERMINATED) {
-               _D("%s is in terminated state", id);
-               return 0;
+               _D("%s is in terminated state", id); /* LCOV_EXCL_LINE */
+               return 0; /* LCOV_EXCL_LINE */
        }
 
        if (handle->ops.resume)
@@ -299,18 +285,18 @@ static int __instance_pause(widget_class_h handle, const char *id, int send_upda
        int ret;
 
        if (!wc) {
-               _E("context not found: %s", id);
-               return -1;
+               _E("context not found: %s", id); /* LCOV_EXCL_LINE */
+               return -1; /* LCOV_EXCL_LINE */
        }
 
        if (wc->state == WC_PAUSED) {
-               _D("%s is already in paused state", id);
-               return 0;
+               _D("%s is already in paused state", id); /* LCOV_EXCL_LINE */
+               return 0; /* LCOV_EXCL_LINE */
        }
 
        if (wc->state == WC_TERMINATED) {
-               _D("%s is in terminated state", id);
-               return 0;
+               _D("%s is in terminated state", id); /* LCOV_EXCL_LINE */
+               return 0; /* LCOV_EXCL_LINE */
        }
 
        if (handle->ops.pause)
@@ -334,8 +320,8 @@ static int __instance_resize(widget_class_h handle, const char *id, int w, int h
        int ret;
 
        if (!wc) {
-               _E("context not found: %s", id);
-               return -1;
+               _E("context not found: %s", id); /* LCOV_EXCL_LINE */
+               return -1; /* LCOV_EXCL_LINE */
        }
 
        if (handle->ops.resize)
@@ -348,6 +334,36 @@ static int __instance_resize(widget_class_h handle, const char *id, int w, int h
        return ret;
 }
 
+/* LCOV_EXCL_START */
+static int __instance_update_all(widget_class_h handle, int force, const char *content)
+{
+       widget_context_s *wc;
+       int ret = 0;
+       bundle *b = NULL;
+       GList *context = _widget_app_get_contexts();
+
+       if (content)
+               b = bundle_decode((const bundle_raw *)content, strlen(content));
+
+       if (handle->ops.update) {
+               while (context) {
+                       wc = (widget_context_s *)context->data;
+                       handle->ops.update(wc, b, force, handle->user_data);
+                       ret = __send_update_status(handle->classid, wc->id,
+                               WIDGET_INSTANCE_EVENT_UPDATE, NULL);
+                       _D("updated:%s", wc->id);
+                       context = context->next;
+               }
+       }
+
+       if (b)
+               bundle_free(b);
+
+       return ret;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
 static int __instance_update(widget_class_h handle, const char *id, int force, const char *content)
 {
        widget_context_s *wc = __find_context_by_id(id);
@@ -373,6 +389,7 @@ static int __instance_update(widget_class_h handle, const char *id, int force, c
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 static int __instance_create(widget_class_h handle, const char *id, const char *content, int w, int h)
 {
@@ -380,7 +397,7 @@ static int __instance_create(widget_class_h handle, const char *id, const char *
        int ret = 0;
        bundle *content_info = NULL;
 
-       wc = (widget_context_s *)malloc(sizeof(widget_context_s));
+       wc = (widget_context_s *)calloc(1, sizeof(widget_context_s));
        if (!wc)
                return WIDGET_ERROR_OUT_OF_MEMORY;
 
@@ -395,12 +412,21 @@ static int __instance_create(widget_class_h handle, const char *id, const char *
                content_info = bundle_decode((const bundle_raw *)content, strlen(content));
        }
 
-       contexts = g_list_append(contexts, wc);
+       _widget_app_add_context(wc);
 
-       handle->ops.create(wc, content_info, w, h, handle->user_data);
-       ret = __send_update_status(handle->classid, wc->id,
+       ret = handle->ops.create(wc, content_info, w, h, handle->user_data);
+       if (ret < 0) {
+               /* TODO send abort */
+       } else {
+               ret = __send_update_status(handle->classid, wc->id,
                        WIDGET_INSTANCE_EVENT_CREATE, NULL);
 
+               if (content == NULL)
+                       content = "NULL";
+
+               aul_widget_instance_add(handle->classid, id);
+       }
+
        if (content_info)
                bundle_free(content_info);
 
@@ -415,9 +441,10 @@ static int __instance_destroy(widget_class_h handle, const char *id,
        int event = WIDGET_INSTANCE_EVENT_TERMINATE;
        bundle *content_info;
 
+
        if (!wc) {
-               _E("could not find widget obj: %s", id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               _E("could not find widget obj: %s", id); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_LINE */
        }
 
        wc->state = WC_TERMINATED;
@@ -436,12 +463,14 @@ static int __instance_destroy(widget_class_h handle, const char *id,
                                WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
        }
 
+       aul_widget_instance_del(handle->classid, id);
+
        if (content_info)
                bundle_free(content_info);
 
        ret = __send_update_status(handle->classid, id, event, NULL);
 
-       contexts = g_list_remove(contexts, wc);
+       _widget_app_remove_context(wc);
 
        if (wc->id)
                free(wc->id);
@@ -451,7 +480,7 @@ static int __instance_destroy(widget_class_h handle, const char *id,
 
        free(wc);
 
-       if (contexts == NULL && !exit_called) /* all instance destroyed */
+       if (_widget_app_get_contexts() == NULL && !exit_called) /* all instance destroyed */
                widget_app_exit();
 
        return ret;
@@ -475,6 +504,7 @@ static widget_class_h __find_class_handler(const char *class_id,
        return NULL;
 }
 
+/* LCOV_EXCL_START */
 static void __resize_window(char *id, int w, int h)
 {
        widget_context_s *wc = __find_context_by_id(id);
@@ -489,6 +519,7 @@ static void __resize_window(char *id, int w, int h)
        else
                _E("unable to find window of %d", wc->id);
 }
+/* LCOV_EXCL_STOP */
 
 static void __control(bundle *b)
 {
@@ -510,12 +541,12 @@ static void __control(bundle *b)
        if (class_id == NULL)
                class_id = appid;
 
-       bundle_get_str(b, WIDGET_K_INSTANCE, &id);
+       bundle_get_str(b, AUL_K_WIDGET_INSTANCE_ID, &id);
        bundle_get_str(b, WIDGET_K_OPERATION, &operation);
 
        handle = __find_class_handler(class_id, class_provider);
        if (!handle) {
-               _E("no handle provided: %s", class_id);
+               _E("no handle provided: %s", class_id); /* LCOV_EXCL_LINE */
                goto error;
        }
 
@@ -545,7 +576,11 @@ static void __control(bundle *b)
        } else if (strcmp(operation, "resize") == 0) {
                __resize_window(id, w, h);
        } else if (strcmp(operation, "update") == 0) {
-               __instance_update(handle, id, force, content);
+               if (id)
+                       __instance_update(handle, id, force, content);
+               else
+                       __instance_update_all(handle, force, content);
+
        } else if (strcmp(operation, "destroy") == 0) {
                __instance_destroy(handle, id, WIDGET_APP_DESTROY_TYPE_PERMANENT, UPDATE_ALL);
        } else if (strcmp(operation, "resume") == 0) {
@@ -564,6 +599,7 @@ error:
 
 static void __pause_all(int send_update)
 {
+       GList *contexts = _widget_app_get_contexts();
        GList *iter = g_list_first(contexts);
 
        while (iter != NULL) {
@@ -582,8 +618,10 @@ static void __pause_all(int send_update)
        }
 }
 
+/* LCOV_EXCL_START */
 static void __resume_all(int send_update)
 {
+       GList *contexts = _widget_app_get_contexts();
        GList *iter = g_list_first(contexts);
 
        while (iter != NULL) {
@@ -600,9 +638,11 @@ static void __resume_all(int send_update)
                iter = g_list_next(iter);
        }
 }
+/* LCOV_EXCL_STOP */
 
 static void __destroy_all(int reason, int send_update)
 {
+       GList *contexts = _widget_app_get_contexts();
        GList *iter = g_list_first(contexts);
 
        __pause_all(send_update);
@@ -630,7 +670,7 @@ static Eina_Bool __show_cb(void *data, int type, void *event)
        if (cxt)
                __instance_resume(cxt->provider, cxt->id, UPDATE_ALL);
        else
-               LOGE("unknown window error: %d", ev->win);
+               LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */
 
        return ECORE_CALLBACK_RENEW;
 }
@@ -646,7 +686,7 @@ static Eina_Bool __hide_cb(void *data, int type, void *event)
        if (cxt)
                __instance_pause(cxt->provider, cxt->id, UPDATE_ALL);
        else
-               LOGE("unknown window error: %d", ev->win);
+               LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */
 
        return ECORE_CALLBACK_RENEW;
 }
@@ -674,11 +714,13 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event)
        return ECORE_CALLBACK_RENEW;
 }
 
+/* LCOV_EXCL_START */
 static Eina_Bool __lower_cb(void *data, int type, void *event)
 {
        LOGD("lower");
        return ECORE_CALLBACK_RENEW;
 }
+/* LCOV_EXCL_STOP */
 
 static Eina_Bool __configure_cb(void *data, int type, void *event)
 {
@@ -688,8 +730,8 @@ static Eina_Bool __configure_cb(void *data, int type, void *event)
        LOGD("configure: %d %d", ev->w, ev->h);
 
        if (!cxt) {
-               LOGE("unknown window error: %d", ev->win);
-               return ECORE_CALLBACK_RENEW;
+               LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */
+               return ECORE_CALLBACK_RENEW; /* LCOV_EXCL_LINE */
        }
 
        if (cxt->state == WC_PAUSED || cxt->state == WC_RUNNING)
@@ -746,15 +788,15 @@ static char *__get_domain_name(char *appid)
        char *name_token;
 
        if (appid == NULL) {
-               _E("appid is NULL");
-               return NULL;
+               _E("appid is NULL"); /* LCOV_EXCL_LINE */
+               return NULL; /* LCOV_EXCL_LINE */
        }
 
        name_token = strrchr(appid, '.');
 
        if (name_token == NULL) {
-               _E("appid is invalid");
-               return appid;
+               _E("appid is invalid"); /* LCOV_EXCL_LINE */
+               return appid; /* LCOV_EXCL_LINE */
        }
 
        name_token++;
@@ -762,6 +804,7 @@ static char *__get_domain_name(char *appid)
        return name_token;
 }
 
+/* LCOV_EXCL_START */
 static void __on_poweroff(keynode_t *key, void *data)
 {
        int val;
@@ -780,6 +823,7 @@ static void __on_poweroff(keynode_t *key, void *data)
                break;
        }
 }
+/* LCOV_EXCL_STOP */
 
 extern int _set_i18n(const char *name);
 
@@ -790,6 +834,7 @@ static int __before_loop(int argc, char **argv)
        char *wayland_display = NULL;
        char *xdg_runtime_dir = NULL;
        char *name;
+       char *viewer_endpoint;
 
 #if !(GLIB_CHECK_VERSION(2, 36, 0))
        g_type_init();
@@ -802,7 +847,7 @@ static int __before_loop(int argc, char **argv)
                bundle_get_str(kb, WIDGET_K_ENDPOINT, &viewer_endpoint);
                if (viewer_endpoint) {
                        _E("viewer endpoint :%s", viewer_endpoint);
-                       viewer_endpoint = strdup(viewer_endpoint);
+                       _widget_app_set_viewer_endpoint(viewer_endpoint);
                } else {
                        _E("endpoint is missing");
                }
@@ -820,23 +865,27 @@ static int __before_loop(int argc, char **argv)
                bundle_free(kb);
                kb = NULL;
        } else {
-               _E("failed to get launch argv");
+               _E("failed to get launch argv"); /* LCOV_EXCL_LINE */
        }
 
        elm_init(argc, argv);
 
        r = aul_launch_init(__aul_handler, NULL);
        if (r < 0) {
+               /* LCOV_EXCL_START */
                return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
                                __FUNCTION__,
                                "Fail to call the aul_launch_init");
+               /* LCOV_EXCL_STOP */
        }
 
        r = aul_launch_argv_handler(argc, argv);
        if (r < 0) {
+               /* LCOV_EXCL_START */
                return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
                                __FUNCTION__,
                                "Fail to call the aul_launch_argv_handler");
+               /* LCOV_EXCL_STOP */
        }
 
        r = app_get_id(&appid);
@@ -846,17 +895,21 @@ static int __before_loop(int argc, char **argv)
        name = __get_domain_name(appid);
 
        if (name == NULL) {
+               /* LCOV_EXCL_START */
                return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
                                __FUNCTION__,
                                "Fail to call __get_domain_name");
+               /* LCOV_EXCL_STOP */
        }
 
        r = _set_i18n(name);
 
        if (r < 0) {
+               /* LCOV_EXCL_START */
                return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
                                __FUNCTION__,
                                "Fail to call _set_i18n");
+               /* LCOV_EXCL_STOP */
        }
 
        __add_climsg();
@@ -885,9 +938,7 @@ static void __after_loop()
        if (app_ops->terminate)
                app_ops->terminate(app_user_data);
 
-       if (viewer_endpoint)
-               free(viewer_endpoint);
-
+       _widget_app_free_viewer_endpoint();
        _widget_core_unset_appcore_event_cb();
        __free_handler_list();
        elm_shutdown();
@@ -1049,8 +1100,8 @@ EXPORT_API int widget_app_main(int argc, char **argv,
        int r;
 
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (argc <= 0 || argv == NULL || callback == NULL)
@@ -1079,8 +1130,8 @@ EXPORT_API int widget_app_main(int argc, char **argv,
 EXPORT_API int widget_app_exit(void)
 {
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (exit_called)
@@ -1093,6 +1144,7 @@ EXPORT_API int widget_app_exit(void)
        return WIDGET_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START */
 static gboolean __finish_event_cb(gpointer user_data)
 {
        if (user_data == NULL)
@@ -1115,12 +1167,13 @@ static gboolean __finish_event_cb(gpointer user_data)
 
        return FALSE;
 }
+/* LCOV_EXCL_STOP */
 
 EXPORT_API int widget_app_terminate_context(widget_context_h context)
 {
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (context == NULL)
@@ -1133,12 +1186,13 @@ EXPORT_API int widget_app_terminate_context(widget_context_h context)
 
 EXPORT_API int widget_app_foreach_context(widget_context_cb cb, void *data)
 {
+       GList *contexts = _widget_app_get_contexts();
        GList *list;
        widget_context_s *wc;
 
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (!cb)
@@ -1197,7 +1251,7 @@ EXPORT_API int widget_app_add_event_handler(app_event_handler_h *event_handler,
 
        handler = calloc(1, sizeof(struct app_event_handler));
        if (!handler)
-               return widget_app_error(WIDGET_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+               return widget_app_error(WIDGET_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); /* LCOV_EXCL_LINE */
 
        if (g_list_length(handler_list[event_type]) == 0)
                __register_event(event_type);
@@ -1246,9 +1300,9 @@ EXPORT_API int widget_app_remove_event_handler(app_event_handler_h
 EXPORT_API const char *widget_app_get_id(widget_context_h context)
 {
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               set_last_result(WIDGET_ERROR_NOT_SUPPORTED);
-               return NULL;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               set_last_result(WIDGET_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
+               return NULL; /* LCOV_EXCL_LINE */
        }
 
        if (!context) {
@@ -1268,8 +1322,8 @@ EXPORT_API int widget_app_get_elm_win(widget_context_h context,
        Ecore_Wl_Window *wl_win;
 
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (context == NULL || win == NULL)
@@ -1278,15 +1332,15 @@ EXPORT_API int widget_app_get_elm_win(widget_context_h context,
 
        ret_win = elm_win_add(NULL, cxt->id, ELM_WIN_BASIC);
        if (ret_win == NULL) {
-               _E("failed to create window");
-               return WIDGET_ERROR_FAULT;
+               _E("failed to create window"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_FAULT; /* LCOV_EXCL_LINE */
        }
 
        wl_win = elm_win_wl_window_get(ret_win);
        if (wl_win == NULL) {
-               _E("failed to get wayland window");
-               evas_object_del(ret_win);
-               return WIDGET_ERROR_FAULT;
+               _E("failed to get wayland window"); /* LCOV_EXCL_LINE */
+               evas_object_del(ret_win); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_FAULT; /* LCOV_EXCL_LINE */
        }
 
        ecore_wl_window_class_name_set(wl_win, cxt->id);
@@ -1306,8 +1360,8 @@ widget_class_h _widget_class_create(widget_class_s *prev, const char *class_id,
        widget_class_s *wc;
 
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               set_last_result(WIDGET_ERROR_NOT_SUPPORTED);
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               set_last_result(WIDGET_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
                return NULL;
        }
 
@@ -1316,11 +1370,11 @@ widget_class_h _widget_class_create(widget_class_s *prev, const char *class_id,
                return NULL;
        }
 
-       wc = (widget_class_s *)malloc(sizeof(widget_class_s));
+       wc = (widget_class_s *)calloc(1, sizeof(widget_class_s));
        if (wc == NULL) {
-               _E("failed to malloc : %s", __FUNCTION__);
-               set_last_result(WIDGET_ERROR_OUT_OF_MEMORY);
-               return NULL;
+               _E("failed to calloc : %s", __FUNCTION__); /* LCOV_EXCL_LINE */
+               set_last_result(WIDGET_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
+               return NULL; /* LCOV_EXCL_LINE */
        }
 
        wc->classid = strdup(class_id);
@@ -1354,8 +1408,8 @@ EXPORT_API widget_class_h widget_app_class_create(
 EXPORT_API int widget_app_context_set_tag(widget_context_h context, void *tag)
 {
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (context == NULL)
@@ -1370,8 +1424,8 @@ EXPORT_API int widget_app_context_set_tag(widget_context_h context, void *tag)
 EXPORT_API int widget_app_context_get_tag(widget_context_h context, void **tag)
 {
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (context == NULL || tag == NULL)
@@ -1392,8 +1446,8 @@ EXPORT_API int widget_app_context_set_content_info(widget_context_h context,
        int len;
 
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (context == NULL || content_info == NULL)
@@ -1405,7 +1459,6 @@ EXPORT_API int widget_app_context_set_content_info(widget_context_h context,
                                __FUNCTION__, NULL);
 
        class_id = context->provider->classid;
-
        if (class_id == NULL)
                return widget_app_error(WIDGET_ERROR_FAULT, __FUNCTION__, NULL);
 
@@ -1422,10 +1475,12 @@ EXPORT_API int widget_app_context_set_content_info(widget_context_h context,
                context->content = NULL;
 
        if (ret < 0) {
+               /* LCOV_EXCL_START */
                _E("failed to send content info: %s of %s (%d)", context->id,
                                class_id, ret);
                return widget_app_error(WIDGET_ERROR_IO_ERROR, __FUNCTION__,
                                NULL);
+               /* LCOV_EXCL_STOP */
        }
 
        return WIDGET_ERROR_NONE;
@@ -1435,8 +1490,8 @@ EXPORT_API int widget_app_context_set_title(widget_context_h context,
                const char *title)
 {
        if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               return WIDGET_ERROR_NOT_SUPPORTED;
+               _E("not supported"); /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NOT_SUPPORTED; /* LCOV_EXCL_LINE */
        }
 
        if (!context || !title)
@@ -1447,4 +1502,3 @@ EXPORT_API int widget_app_context_set_title(widget_context_h context,
 
        return WIDGET_ERROR_NONE;
 }
-