Fix widget_service_get_content_of_widget_instance() 25/81325/7 accepted/tizen/common/20161013.155703 accepted/tizen/ivi/20161013.000921 accepted/tizen/mobile/20161013.000845 accepted/tizen/tv/20161013.000857 accepted/tizen/wearable/20161013.000907 submit/tizen/20161012.155021
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 12 Oct 2016 10:32:09 +0000 (19:32 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Wed, 12 Oct 2016 15:43:09 +0000 (08:43 -0700)
- supports content info of outside processes

Change-Id: I158894842029af77b29a3e2f38a9b88c66b9bcf9
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/widget_service.c
tool/widget_test.c

index 48ec538..2f48eae 100644 (file)
@@ -1756,8 +1756,8 @@ EAPI int widget_service_get_size_type(int width, int height,
 
 EAPI int widget_service_get_content_of_widget_instance(const char *widget_id, const char *widget_instance_id, bundle **b)
 {
-       widget_instance_h instance;
        char *raw = NULL;
+       int ret;
 
        if (!_is_widget_feature_enabled()) {
                _E("not supported");
@@ -1769,15 +1769,27 @@ EAPI int widget_service_get_content_of_widget_instance(const char *widget_id, co
                return WIDGET_ERROR_INVALID_PARAMETER;
        }
 
-       instance = widget_instance_get_instance(widget_id, widget_instance_id);
+       ret = aul_widget_instance_get_content(widget_id, widget_instance_id, &raw);
+       if (raw) {
+               *b = bundle_decode((const bundle_raw *)raw, strlen(raw));
+               return WIDGET_ERROR_NONE;
+       }
 
-       if (instance) {
-               widget_instance_get_content(instance, &raw);
-               if (raw) {
-                       *b = bundle_decode((const bundle_raw *)raw, strlen(raw));
-                       widget_instance_unref(instance);
-                       return WIDGET_ERROR_NONE;
-               }
+       switch (ret) {
+       case AUL_R_EINVAL:
+               ret = WIDGET_ERROR_INVALID_PARAMETER;
+               break;
+       case AUL_R_ECOMM:
+               ret = WIDGET_ERROR_IO_ERROR;
+               break;
+       case AUL_R_ENOAPP:
+               ret = WIDGET_ERROR_NOT_EXIST;
+               break;
+       case AUL_R_EILLACC:
+               ret = WIDGET_ERROR_PERMISSION_DENIED;
+               break;
+       default:
+               ret = WIDGET_ERROR_FAULT;
        }
 
        return WIDGET_ERROR_INVALID_PARAMETER;
index f91a0ad..d1db6a0 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <widget_service.h>
 #include <string.h>
+#include <aul.h>
 
 typedef int (*test_fn)(int argc, char **argv);
 
@@ -42,9 +43,24 @@ int get_widget_list(int argc, char **argv)
        return 0;
 }
 
+int get_content(int argc, char **argv)
+{
+       bundle *b;
+       int ret;
+       char *content_info = NULL;
+
+       ret = widget_service_get_content_of_widget_instance(argv[2], argv[3], &b);
+       if (b)
+               bundle_get_str(b, AUL_K_WIDGET_CONTENT_INFO, &content_info);
+
+       printf("ret:%d %s\n", ret, content_info);
+       return 0;
+}
+
 test_func_t test_func[] = {
        {"get_pkg_id", get_pkg_id, "<widget_id>"},
-       {"get_widget_list", get_widget_list, ""}
+       {"get_widget_list", get_widget_list, ""},
+       {"get_content", get_content, ""},
 };
 
 static void print_usage(char *pname)