Add an API to check the supported boxsize.
authorleerang song <leerang.song@samsung.com>
Tue, 30 Apr 2013 01:32:58 +0000 (10:32 +0900)
committerleerang song <leerang.song@samsung.com>
Mon, 20 May 2013 12:29:34 +0000 (21:29 +0900)
[Issue#] N/A
[Problem] Config.xml use the not supported boxsize
[Cause] N/A
[Solution] Add supported boxsize check ApI
[SCMRequest] N/A

Change-Id: I7a2adc9535f3fe3d3543ab9e556f7d65edaf7fb1

src/API/web_provider_plugin_info.cpp [changed mode: 0644->0755]
src/API/web_provider_plugin_info.h [changed mode: 0644->0755]
src/Plugin/AppBoxPlugin/app.json

old mode 100644 (file)
new mode 100755 (executable)
index 2f776a0..1f9b71b
@@ -52,10 +52,12 @@ static const std::string jsonMemberType("type");
 static const std::string jsonMemberPath("path");
 static const std::string jsonMemberBoxId("service_boxid");
 static const std::string jsonMemberBoxScrollable("box_scrollable");
+static const std::string jsonMemberBoxSize("supported_size");
 
 static const std::string jsonValueBoolTrue("true");
 static const std::string jsonValueBoolFalse("false");
 static const std::string jsonFileExtension(".json");
+static const std::string mendatoryBoxSize("1x1");
 
 web_provider_plugin_info** web_provider_plugin_get_installed_list(int* count)
 {
@@ -201,7 +203,11 @@ static web_provider_plugin_info* get_parsed_json_data(std::string& configPath)
         static_cast<const char*>(
             json_object_get_string_member(object, jsonMemberPath.c_str()));
 
-    if (!type || !path) {
+    JsonArray* size =
+        json_object_get_array_member(object, jsonMemberBoxSize.c_str());
+    int sizeCount = static_cast<int>(json_array_get_length(size));
+
+    if (!type || !path || !sizeCount) {
         LogD("mandatory members don't exist");
         g_error_free(error);
         g_object_unref(parser);
@@ -215,6 +221,13 @@ static web_provider_plugin_info* get_parsed_json_data(std::string& configPath)
 
     info->type = strdup(type);
     info->path = strdup(path);
+    info->box_size = static_cast<char**>(malloc(sizeof(char*) * sizeCount));
+
+    for (int i = 0; i < sizeCount; i++) {
+        info->box_size[i] =
+            strdup(static_cast<const char*>(json_array_get_string_element(size, i)));
+    }
+    info->box_size_count = sizeCount;
 
     gboolean hasBoxId = json_object_has_member(object, jsonMemberBoxId.c_str());
     if (hasBoxId == TRUE) {
@@ -250,7 +263,7 @@ static web_provider_plugin_info* get_parsed_json_data(std::string& configPath)
     g_error_free(error);
     g_object_unref(parser);
 
-    return info; 
+    return info;
 }
 
 bool web_provider_plugin_release_info(web_provider_plugin_info* info)
@@ -265,7 +278,60 @@ bool web_provider_plugin_release_info(web_provider_plugin_info* info)
     delete info->type;
     delete info->path;
     delete info->service_boxid;
+    for(int i = 0; i < info->box_size_count; i++) {
+        delete[] info->box_size[i];
+    }
     delete info;
 
     return true;
 }
+
+int web_provider_plugin_check_supported_size(
+    const char* plugin_type, char** size, int sizeCount)
+{
+    bool mendatoryChk = false;
+
+    // read plugin directory and store plugin config path
+    std::string configPath;
+    configPath = installedPluginDirPath;
+    configPath += plugin_type;
+    configPath += jsonFileExtension;
+
+    // get the json datas
+    web_provider_plugin_info* jsonData = get_parsed_json_data(configPath);
+    if (!jsonData) {
+        LogD("failed to get the json file");
+        return false;
+    }
+
+    // compare the parsed config data with the parsed json data
+    for (int configCnt = 0; configCnt < sizeCount; configCnt++) {
+        bool supportedSizeChk = false;
+
+        for (int jsonCnt = 0; jsonCnt < jsonData->box_size_count; jsonCnt++) {
+
+            // check mendatory size
+            if (!strcmp(mendatoryBoxSize.c_str(), size[configCnt])) {
+                mendatoryChk = true;
+            }
+
+            // check supported size
+            if (!strcmp(jsonData->box_size[jsonCnt], size[configCnt])) {
+                supportedSizeChk = true;
+                break;
+            }
+        }
+
+        if (!supportedSizeChk) {
+            LogD("Not supported size: %s", size[configCnt]);
+            return false;
+        }
+    }
+
+    if (!mendatoryChk) {
+        LogD("Mandatory members don't exist ");
+        return false;
+    }
+
+    return true;
+}
old mode 100644 (file)
new mode 100755 (executable)
index a00e2d4..28ed01b
@@ -30,7 +30,9 @@ struct _web_provider_plugin_info {
     const char* type;
     const char* path;
     const char* service_boxid;
+    char** box_size;
     int box_scrollable;
+    int box_size_count;
 };
 typedef _web_provider_plugin_info web_provider_plugin_info;
 
@@ -40,7 +42,7 @@ EXPORT_API void web_provider_plugin_release_installed_list(
                 web_provider_plugin_info** info_list, 
                 int count);
 EXPORT_API int web_provider_plugin_get_box_scrollable(const char* plugin_type);
-
+EXPORT_API int web_provider_plugin_check_supported_size(const char* plugin_type, char** size, int sizeCount);
 #ifdef __cplusplus
 }
 #endif
index cd946f5..6388702 100644 (file)
@@ -1,4 +1,5 @@
 {
      "type" : "app",
-     "path" : "/usr/lib/web-provider/libweb-provider-plugin-app.so"
+     "path" : "/usr/lib/web-provider/libweb-provider-plugin-app.so",
+     "supported_size" : ["1x1","2x1","2x2"]
 }