[Widget-viewer-evas] return the default value when title is NULL 45/64045/2 accepted/tizen/common/20160330.120703 accepted/tizen/ivi/20160330.101912 accepted/tizen/mobile/20160330.101738 accepted/tizen/tv/20160330.101808 accepted/tizen/wearable/20160330.101833 submit/tizen/20160330.085048
authormoon87.park <moon87.park@samsung.com>
Tue, 29 Mar 2016 13:35:51 +0000 (22:35 +0900)
committermoon87.park <moon87.park@samsung.com>
Wed, 30 Mar 2016 06:35:15 +0000 (15:35 +0900)
Change-Id: I49243543fe1b6920556db0fc5a03698d3fca1807

widget_viewer_evas/src/widget_viewer_evas.c

index 47ff328..22d9f11 100644 (file)
@@ -572,69 +572,67 @@ EAPI int widget_viewer_evas_resume_widget(Evas_Object *widget)
        return WIDGET_ERROR_NONE;
 }
 
-static int foreach_cb(widget_instance_h handle, void *data)
+EAPI const char *widget_viewer_evas_get_content_info(Evas_Object *widget)
 {
-       struct widget_info *info = data;
+       struct widget_info *info;
+       widget_instance_h handle = NULL;
        bundle_raw *content_info = NULL;
        int content_len = 0;
        bundle *b = NULL;
-       char *id = NULL;
 
-       if (!handle) {
-               return 0;
-       }
 
-       if (widget_instance_get_id(handle, &id) < 0) {
-               return 0;
+       if (!is_widget_feature_enabled()) {
+               return NULL;
        }
 
-       if (!id && !info->instance_id) {
-               return 0;
+       if (!s_info.initialized) {
+               ErrPrint("widget viewer evas is not initialized\n");
+               return NULL;
        }
 
-       if (strcmp(id, info->instance_id)) {
-               free(id);
-               return 0;
+       if (!widget) {
+               ErrPrint("widget object is invalid\n");
+               return NULL;
        }
 
-       if (widget_instance_get_content(handle, &b) < 0 || b == NULL) {
-               return 0;
+       info = evas_object_data_get(widget, WIDGET_INFO_TAG);
+       if (!info) {
+               ErrPrint("widget(%p) don't have the info\n", widget);
+               return NULL;
        }
 
-       if (bundle_encode(b, &content_info, &content_len) < 0) {
-               return 0;
+       if (!info->widget_id && !info->instance_id) {
+               ErrPrint("widget id(%s) or instance id(%s) is invalid data\n", info->widget_id, info->instance_id);
+               return NULL;
        }
 
-       free(info->content_info);
-       info->content_info = (char *)content_info;
-       return 0;
-}
+       handle = widget_instance_get_instance(info->widget_id, info->instance_id);
 
-EAPI const char *widget_viewer_evas_get_content_info(Evas_Object *widget)
-{
-       struct widget_info *info;
-
-       if (!is_widget_feature_enabled()) {
+       if (!handle) {
+               ErrPrint("instance handle of widget(%s) is invalid data\n", info->instance_id);
                return NULL;
        }
 
-       if (!s_info.initialized) {
-               ErrPrint("widget viewer evas is not initialized\n");
+       if (widget_instance_get_content(handle, &b) < 0) {
+               ErrPrint("Failed to get content of widget(%s)\n", info->instance_id);
                return NULL;
        }
 
-       if (!widget) {
-               ErrPrint("widget object is invalid\n");
+       if (b == NULL) {
+               ErrPrint("content of widget(%s) is invalid data\n", info->instance_id);
                return NULL;
        }
 
-       info = evas_object_data_get(widget, WIDGET_INFO_TAG);
-       if (!info) {
-               ErrPrint("widget(%p) don't have the info\n", widget);
+       if (bundle_encode(b, &content_info, &content_len) < 0) {
+               ErrPrint("Failed to encode (%s)\n", info->instance_id);
                return NULL;
        }
 
-       widget_instance_foreach(info->widget_id, foreach_cb, info);
+       if (info->content_info) {
+               free(info->content_info);
+       }
+       info->content_info = (char *)content_info;
+
 
        return info->content_info;
 }
@@ -665,7 +663,15 @@ EAPI const char *widget_viewer_evas_get_title_string(Evas_Object *widget)
        }
 
        title = pepper_efl_object_title_get(pepper_obj);
-       DbgPrint("%s : title is [%s]\n", __func__, title);
+       if (!title) {
+               struct widget_info *info;
+               info = evas_object_data_get(widget, WIDGET_INFO_TAG);
+               if (!info) {
+                       ErrPrint("widget(%p) don't have the info\n", widget);
+                       return NULL;
+               }
+               title = info->widget_id;
+       }
 
        return title;
 }