summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2016-03-02 15:17:35 +0900
committerHyunho Kang <hhstark.kang@samsung.com>2016-03-04 08:55:54 +0900
commitceaa10aea74977f098bcaf492d4da4926be794e9 (patch)
tree2f6db3aec057ac0e8a3c01b498b88e76c2916e61
parent04d9b191fed389550cd98014bba4be3ba05eae93 (diff)
downloadshortcut-ceaa10aea74977f098bcaf492d4da4926be794e9.tar.gz
shortcut-ceaa10aea74977f098bcaf492d4da4926be794e9.tar.bz2
shortcut-ceaa10aea74977f098bcaf492d4da4926be794e9.zip
Remove hard coded path
Change-Id: I15e7efb5293f4acf7627dab8525dc7e10ab24007 Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rwxr-xr-xlib/include/shortcut_manager.h9
-rwxr-xr-xsample.xml62
-rwxr-xr-xtest/icon.c11
-rwxr-xr-xtest_db_builder.sh80
4 files changed, 17 insertions, 145 deletions
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 <stdio.h>
* #include <shortcut.h>
+ * #include <storage.h>
+ *
+ * #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 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.myapp" version="0.3.5" install-location="auto">
-<shortcut-list test="a">
- <shortcut appid="org.tizen.myapp" extra_key="key" extra_data="SERVICE INFORMATION 1">
- <icon>/opt/usr/apps/org.tizen.myapp/res/icon/myapp_shortcut01.png</icon>
- <label>Default Name</label>
- <label xml:lang="en-us">Name en</label>
- <label xml:lang="nl-nl">Name nl</label>
- <label xml:lang="de-de">Name de</label>
- <label xml:lang="zh-hk">Name hk</label>
- <label xml:lang="zh-cn">Name cn</label>
- <label xml:lang="ru-ru">Name ru</label>
- <label xml:lang="zh-tw">Name tw</label>
- <label xml:lang="ja-jp">Name jp</label>
- <label xml:lang="es-es">Name es</label>
- <label xml:lang="el-gr">Name gr</label>
- <label xml:lang="it-it">Name it</label>
- <label xml:lang="tr-tr">Name tr</label>
- <label xml:lang="pt-pt">Name pt</label>
- <label xml:lang="fr-fr">Name fr</label>
- <label xml:lang="kor-kr">Name kr</label>
- </shortcut>
- <shortcut appid="org.tizen.myapp-gadget" extra_key="key" extra_data="SERVICE INFORMATION 2">
- <icon>/opt/usr/apps/org.tizen.myapp/res/icon/gadget_shortcut01.png</icon>
- <label>Default Name 02</label>
- <label xml:lang="en-us">Name en</label>
- <label xml:lang="nl-nl">Name nl</label>
- <label xml:lang="de-de">Name de</label>
- <label xml:lang="zh-hk">Name hk</label>
- <label xml:lang="zh-cn">Name cn</label>
- <label xml:lang="ru-ru">Name ru</label>
- <label xml:lang="zh-tw">Name tw</label>
- <label xml:lang="ja-jp">Name jp</label>
- <label xml:lang="es-es">Name es</label>
- <label xml:lang="el-gr">Name gr</label>
- <label xml:lang="it-it">Name it</label>
- <label xml:lang="tr-tr">Name tr</label>
- <label xml:lang="pt-pt">Name pt</label>
- <label xml:lang="fr-fr">Name fr</label>
- <label xml:lang="kor-kr">Name kr</label>
- </shortcut>
- <shortcut appid="org.tizen.myapp" extra_key="key" extra_data="SERVICE INFORMATION 3">
- <icon>/opt/usr/apps/org.tizen.myapp/res/icon/mayapp_shortcut02.png</icon>
- <label>Default Name 03</label>
- <label xml:lang="en-us">Name en</label>
- <label xml:lang="nl-nl">Name nl</label>
- <label xml:lang="de-de">Name de</label>
- <label xml:lang="zh-hk">Name hk</label>
- <label xml:lang="zh-cn">Name cn</label>
- <label xml:lang="ru-ru">Name ru</label>
- <label xml:lang="zh-tw">Name tw</label>
- <label xml:lang="ja-jp">Name jp</label>
- <label xml:lang="es-es">Name es</label>
- <label xml:lang="el-gr">Name gr</label>
- <label xml:lang="it-it">Name it</label>
- <label xml:lang="tr-tr">Name tr</label>
- <label xml:lang="pt-pt">Name pt</label>
- <label xml:lang="fr-fr">Name fr</label>
- <label xml:lang="kor-kr">Name kr</label>
- </shortcut>
-</shortcut-list>
-</manifest>
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 <Elementary.h>
#include <shortcut.h>
+#include <tzplatform_config.h>
+
+#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"