Using relative path for icon, image path 22/202322/6
authorhyunho <hhstark.kang@samsung.com>
Wed, 27 Mar 2019 05:57:45 +0000 (14:57 +0900)
committerhyunho <hhstark.kang@samsung.com>
Wed, 27 Mar 2019 07:00:03 +0000 (16:00 +0900)
Change-Id: I55ddb7244f8ed1ca4c7ea563485740a34ff93929
Signed-off-by: hyunho <hhstark.kang@samsung.com>
watchface-common/watchface-common-internal.h
watchface-common/watchface-util.cc
watchface-common/watchface-util.h
watchface-complication-provider/complication-provider.cc
watchface-complication-provider/include/watchface-complication-provider.h
watchface-complication-provider/watchface-complication-provider.cc
watchface-complication/complication.cc
watchface-complication/db-manager.cc
watchface-complication/include/watchface-complication-internal.h
watchface-complication/watchface-complication.cc

index f84a94b..c7e358d 100644 (file)
 
 #define EXPORT_API __attribute__((visibility("default")))
 
+#define SETUP_EDITOR_APPID_KEY "__SETUP_EDITOR_APPID_KEY__"
+#define SETUP_EDITABLE_ID_KEY "__SETUP_EDITABLE_ID_KEY__"
+#define SETUP_CONTEXT_DATA_KEY "__SETUP_CONTEXT_DATA_KEY__"
+#define SHORT_TEXT_KEY "__SHORT_TEXT_KEY__"
+#define LONG_TEXT_KEY "__LONG_TEXT_KEY__"
+#define ICON_KEY "__ICON_KEY__"
+#define TITLE_KEY "__TITLE_KEY__"
+#define TIME_KEY "__TIME_KEY__"
+#define RANGE_CUR_KEY "__CUR_KEY__"
+#define RANGE_MAX_KEY "__MAX_KEY__"
+#define RANGE_MIN_KEY "__MIN_KEY__"
+#define IMAGE_KEY "__IMAGE_KEY__"
+#define DATA_TYPE_KEY "__DATA_TYPE_KEY__"
+#define EXTRA_DATA_KEY "__EXTRA_DATA_KEY__"
+#define SCREEN_READER_TEXT_KEY "__SCREEN_READER_TEXT_KEY__"
+#define TOUCH_LAUNCH_CONTEXT_KEY "__TOUCH_LAUNCH_CONTEXT_KEY__"
+#define TOUCH_LAUNCH_PROVIDER_ID_KEY "__TOUCH_LAUNCH_PROVIDER_ID_KEY__"
+#define TOUCH_LAUNCH_TYPE_KEY "__TOUCH_LAUNCH_TYPE_KEY__"
+#define TOUCH_LAUNCH_EVENT_KEY "__TOUCH_LAUNCH_EVENT_KEY__"
+#define TOUCH_LAUNCH_DATA_KEY "__TOUCH_LAUNCH_DATA_KEY__"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 1dd44a5..225a5ef 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "watchface-common/watchface-util.h"
 #include "watchface-common/include/watchface-common.h"
+#include "watchface-common/watchface-common-internal.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -370,5 +371,49 @@ out:
     return appid;
   }
 
+  std::string GetAppPath(const char* appid, char* path) {
+    char* root_path;
+    aul_get_app_shared_resource_path_by_appid(appid, &root_path);
+    std::string app_path =
+        "" + std::string(root_path) + "../../" + std::string(path);
+    free(root_path);
+    LOGI("%s", app_path.c_str());
+    return app_path;
+  }
+
+  int ConvertPathToAppPath(const char* appid, bundle* data) {
+    char* path;
+    char* dup_path;
+    int ret = bundle_get_str(data, ICON_KEY, &path);
+    if (ret == BUNDLE_ERROR_NONE) {
+      dup_path = strdup(path);
+      bundle_del(data, ICON_KEY);
+      ret = bundle_add_str(
+          data, ICON_KEY,
+          util::GetAppPath(appid, dup_path).c_str());
+      free(dup_path);
+      if (ret != BUNDLE_ERROR_NONE) {
+        LOGE("fail to add app path");
+        return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+      }
+    }
+
+    ret = bundle_get_str(data, IMAGE_KEY, &path);
+    if (ret == BUNDLE_ERROR_NONE) {
+      dup_path = strdup(path);
+      bundle_del(data, IMAGE_KEY);
+      ret = bundle_add_str(
+          data, IMAGE_KEY,
+          util::GetAppPath(appid, path).c_str());
+      free(dup_path);
+      if (ret != BUNDLE_ERROR_NONE) {
+        LOGE("fail to add app path");
+        return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+      }
+    }
+
+    return WATCHFACE_COMPLICATION_ERROR_NONE;
+  }
+
 }  // namespace util
 }  // namespace watchface_complication
index 66fee5d..a24a258 100644 (file)
@@ -18,6 +18,8 @@
 #define WATCHFACE_COMMON_WATCHFACE_UTIL_H_
 
 #include <gio/gio.h>
+#include <bundle.h>
+
 #include <string>
 #include "watchface-common/include/watchface-common.h"
 
@@ -67,6 +69,8 @@ namespace util {
   EXPORT_API std::string GetAppId();
   EXPORT_API std::string GetCmdStr(CmdType type);
   EXPORT_API bool CheckCertificate(const std::string& provider_app_id);
+  EXPORT_API std::string GetAppPath(const char* appid, char* path);
+  EXPORT_API int ConvertPathToAppPath(const char* appid, bundle* data);
 }  // namespace util
 }  // namespace watchface_complication
 
index f45f5de..4fc3b29 100644 (file)
@@ -20,6 +20,7 @@
 #include <list>
 
 #include "watchface-common/watchface-util.h"
+#include "watchface-common/watchface-common-internal.h"
 #include "watchface-complication-provider/complication-provider.h"
 #include "watchface-complication-provider/complication-provider-implementation.h"
 #include "watchface-complication-provider/include/watchface-complication-provider.h"
@@ -301,7 +302,7 @@ void ComplicationProvider::Impl::OnSignal(GDBusConnection* connection,
       delete shared_data;
       return;
     }
-
+    util::ConvertPathToAppPath(util::GetAppId().c_str(), shared_data->GetRaw());
     ret = gdbus_.get()->EmitSignal(
           IGDBus::Complication,
           std::string(sender_app_id),
index 1a7417f..f488a3e 100644 (file)
@@ -409,6 +409,7 @@ int watchface_complication_provider_data_set_timestamp(bundle *shared_data,
  * @brief Sets image path data for shared data.
  * @since_tizen 5.0
  * @remarks @a image_path can be added only for #WATCHFACE_COMPLICATION_TYPE_IMAGE type shared data.
+ * @remarks @a image_path should be relative path like shared/res/image.png.
  * @param[in] shared_data The data which will be shared with watch application
  * @param[in] image_path The image path data
  * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
@@ -470,6 +471,7 @@ int watchface_complication_provider_data_set_ranged_value(bundle *shared_data,
  * @since_tizen 5.0
  * @remarks @a icon_path can be added only for #WATCHFACE_COMPLICATION_TYPE_SHORT_TEXT,
  *          #WATCHFACE_COMPLICATION_TYPE_LONG_TEXT, #WATCHFACE_COMPLICATION_TYPE_TIME, #WATCHFACE_COMPLICATION_TYPE_ICON type shared data.
+ * @remarks @a icon_path should be relative path like shared/res/icon.png.
  * @param[in] shared_data The data which will be shared with watch application
  * @param[in] icon_path The icon path data
  * @return #WATCHFACE_COMPLICATION_ERROR_NONE on success,
index a3968f6..3e92dd5 100644 (file)
@@ -29,6 +29,7 @@
 #include <list>
 
 #include "watchface-common/watchface-util.h"
+#include "watchface-common/watchface-common-internal.h"
 #include "watchface-complication-provider/complication-provider.h"
 #include "watchface-complication-provider/include/watchface-complication-provider.h"
 #include "watchface-complication/db-manager.h"
index 9bdebe0..5a4bcf5 100644 (file)
@@ -25,6 +25,7 @@
 #include "watchface-complication/complication.h"
 #include "watchface-complication/complication-implementation.h"
 #include "watchface-common/watchface-util.h"
+#include "watchface-common/watchface-common-internal.h"
 #include "watchface-complication/include/watchface-complication-internal.h"
 
 #ifdef LOG_TAG
index d01a88a..66e833f 100644 (file)
@@ -22,6 +22,7 @@
 #include <pkgmgr_installer_info.h>
 #include <vconf.h>
 
+#include "watchface-complication/include/watchface-complication-internal.h"
 #include "watchface-complication/db-manager.h"
 #include "watchface-common/watchface-util.h"
 
@@ -124,10 +125,10 @@ std::unique_ptr<Bundle> DBManager::GetDefaultData(const char* provider_id,
       goto out;
     }
     default_data = std::unique_ptr<Bundle>(new Bundle(std::string(raw_data)));
+    util::ConvertPathToAppPath(provider_app_id.c_str(), default_data->GetRaw());
   }
 
 out:
-
   sqlite3_finalize(stmt);
   CloseDB(db);
 
index c8e5e03..10a04b6 100644 (file)
 
 #include <watchface-common.h>
 
-#define SETUP_EDITOR_APPID_KEY "__SETUP_EDITOR_APPID_KEY__"
-#define SETUP_EDITABLE_ID_KEY "__SETUP_EDITABLE_ID_KEY__"
-#define SETUP_CONTEXT_DATA_KEY "__SETUP_CONTEXT_DATA_KEY__"
-#define SHORT_TEXT_KEY "__SHORT_TEXT_KEY__"
-#define LONG_TEXT_KEY "__LONG_TEXT_KEY__"
-#define ICON_KEY "__ICON_KEY__"
-#define TITLE_KEY "__TITLE_KEY__"
-#define TIME_KEY "__TIME_KEY__"
-#define RANGE_CUR_KEY "__CUR_KEY__"
-#define RANGE_MAX_KEY "__MAX_KEY__"
-#define RANGE_MIN_KEY "__MIN_KEY__"
-#define IMAGE_KEY "__IMAGE_KEY__"
-#define DATA_TYPE_KEY "__DATA_TYPE_KEY__"
-#define EXTRA_DATA_KEY "__EXTRA_DATA_KEY__"
-#define SCREEN_READER_TEXT_KEY "__SCREEN_READER_TEXT_KEY__"
-#define TOUCH_LAUNCH_CONTEXT_KEY "__TOUCH_LAUNCH_CONTEXT_KEY__"
-#define TOUCH_LAUNCH_PROVIDER_ID_KEY "__TOUCH_LAUNCH_PROVIDER_ID_KEY__"
-#define TOUCH_LAUNCH_TYPE_KEY "__TOUCH_LAUNCH_TYPE_KEY__"
-#define TOUCH_LAUNCH_EVENT_KEY "__TOUCH_LAUNCH_EVENT_KEY__"
-#define TOUCH_LAUNCH_DATA_KEY "__TOUCH_LAUNCH_DATA_KEY__"
-
 namespace watchface_complication {
 
 typedef enum {
index eea49cf..c892ea6 100644 (file)
@@ -30,6 +30,7 @@
 #include "watchface-complication/complication.h"
 #include "watchface-complication/shared-handle.h"
 #include "watchface-common/watchface-util.h"
+#include "watchface-common/watchface-common-internal.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG