From ceaa10aea74977f098bcaf492d4da4926be794e9 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 2 Mar 2016 15:17:35 +0900 Subject: [PATCH] Remove hard coded path Change-Id: I15e7efb5293f4acf7627dab8525dc7e10ab24007 Signed-off-by: Hyunho Kang --- lib/include/shortcut_manager.h | 9 ++++- sample.xml | 62 -------------------------------- test/icon.c | 11 ++++-- test_db_builder.sh | 80 ------------------------------------------ 4 files changed, 17 insertions(+), 145 deletions(-) delete mode 100755 sample.xml delete mode 100755 test_db_builder.sh diff --git a/lib/include/shortcut_manager.h b/lib/include/shortcut_manager.h index a74bb68..388afb7 100755 --- a/lib/include/shortcut_manager.h +++ b/lib/include/shortcut_manager.h @@ -214,6 +214,9 @@ extern int shortcut_add_to_home(const char *name, shortcut_type type, const char * * #include * #include + * #include + * + * #define TIZEN_PATH_MAX 1024 * * static int result_cb(int ret, int pid, void *data) * { @@ -226,9 +229,13 @@ extern int shortcut_add_to_home(const char *name, shortcut_type type, const char * * static int app_create(void *data) * { + * char *image_root = NULL; + * char image_path[TIZEN_PATH_MAX] = {0, }; + * storage_get_directory(STORAGE_TYPE_INTERNAL, STORAGE_DIRECTORY_IMAGES, &image_root); + * snprintf(image_path, TIZEN_PATH_MAX, "%s/alter_icon.png", image_root); * shortcut_add_to_home_widget("alter_name", * WIDGET_SIZE_1x1, "org.tizen.testwidget", - * "/opt/media/Pictures/alter_icon.png", -1.0f, 0, result_cb, NULL); + * image_path, -1.0f, 0, result_cb, NULL); * return 0; * } * diff --git a/sample.xml b/sample.xml deleted file mode 100755 index 0e471a0..0000000 --- a/sample.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - /opt/usr/apps/org.tizen.myapp/res/icon/myapp_shortcut01.png - - - - - - - - - - - - - - - - - - - /opt/usr/apps/org.tizen.myapp/res/icon/gadget_shortcut01.png - - - - - - - - - - - - - - - - - - - /opt/usr/apps/org.tizen.myapp/res/icon/mayapp_shortcut02.png - - - - - - - - - - - - - - - - - - - diff --git a/test/icon.c b/test/icon.c index 724153d..fc904c3 100755 --- a/test/icon.c +++ b/test/icon.c @@ -17,6 +17,11 @@ #include #include +#include + +#define PATH_FMT_RO_ICONS_ROOT tzplatform_getenv(TZ_SYS_RO_ICONS) +#define PATH_FMT_USER_SHARE_ROOT tzplatform_getenv(TZ_USER_SHARE) +#define TIZEN_PATH_MAX 1024 static int result_cb(struct shortcut_icon *handle, int ret, void *data) { @@ -31,6 +36,7 @@ static Eina_Bool test_main(void *data) int ret; char filename[256]; int type; + char path[TIZEN_PATH_MAX] = {0, }; idx++; @@ -41,14 +47,15 @@ static Eina_Bool test_main(void *data) } printf("Test: %d\n", idx); - ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, "/usr/share/icons/default/small/org.tizen.music-player.png", NULL, NULL); + snprintf(path, TIZEN_PATH_MAX, "%s/default/small/org.tizen.music-player.png", PATH_FMT_RO_ICONS_ROOT); + ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, path, NULL, NULL); printf("NAME set_info: %d\n", ret); snprintf(filename, sizeof(filename), "App Name %d", idx); ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, DEFAULT_NAME_PART, filename, NULL, NULL); printf("TEXT set_info: %d\n", ret); - snprintf(filename, sizeof(filename), "/opt/usr/share/live_magazine/always/out%d.png", idx); + snprintf(filename, sizeof(filename), "%s/live_magazine/always/out%d.png", PATH_FMT_USER_SHARE_ROOT, idx); switch (idx % 7) { case 0: type = DYNAMICBOX_TYPE_1x1; break; diff --git a/test_db_builder.sh b/test_db_builder.sh deleted file mode 100755 index 2719bc7..0000000 --- a/test_db_builder.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -#/* -# * Copyright (c) 2011 - 2015 Samsung Electronics Co., Ltd. All rights reserved. -# * -# * Licensed under the Apache License, Version 2.0 (the "License"); -# * you may not use this file except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# * -#*/ - -DBFILE="/usr/dbspace/.shortcut_service.db" - -APPID=( -"org.tizen.facebook" -"org.tizen.facebook" -"org.tizen.facebook" -"org.tizen.facebook" -"org.tizen.facebook" -) - -ICON=( -"" -"" -"" -"" -"" -) - -NAME=( -"Friend's wall" -"Groups" -"Update status" -"Like by me" -"My wall" -) - -KEY=( -"dynamicbox_shortcut_type" -"dynamicbox_shortcut_type" -"dynamicbox_shortcut_type" -"dynamicbox_shortcut_type" -"dynamicbox_shortcut_type" -) - -VALUE=( -"shortcut_friends" -"shortcut_groups" -"shortcut_post" -"shortcut_like" -"shortcut_me" -) - -CNT=0 -ERR=0 -MAX=5 - -sqlite3 $DBFILE "CREATE TABLE shortcut_service (id INTEGER PRIMARY KEY AUTOINCREMENT, appid TEXT, icon TEXT, name TEXT, extra_key TEXT, extra_data TEXT)" -sqlite3 $DBFILE "CREATE TABLE shortcut_name (id INTEGER, lang TEXT, name TEXT)" -while [ $CNT -lt $MAX ] -do - echo "Insert a new record ('${APPID[$CNT]}', '${ICON[$CNT]}', '${NAME[$CNT]}', \"${KEY[$CNT]}\", \"${VALUE[$CNT]}\")" - sqlite3 $DBFILE "INSERT INTO shortcut_service (appid, icon, name, extra_key, extra_data) VALUES ('${APPID[$CNT]}', '${ICON[$CNT]}', \"${NAME[$CNT]}\", \"${KEY[$CNT]}\", \"${VALUE[$CNT]}\")" 2>/dev/null - if [ $? -ne 0 ]; then - let ERR=$ERR+1 - fi - ID=`sqlite3 $DBFILE "SELECT id FROM shortcut_service WHERE appid = \"${APPID[$CNT]}\" AND extra_key = \"${KEY[$CNT]}\" AND extra_data = \"${VALUE[$CNT]}\""` - echo "Insert a name: \"${NAME[$CNT]}\"" - sqlite3 $DBFILE "INSERT INTO shortcut_name (id, lang, name) VALUES ('$ID', 'en-us', \"${NAME[CNT]}\")" - let CNT=$CNT+1 -done - -echo "Error/Total: $ERR/$CNT" -- 2.7.4