From fcfb1ff94e2899760905526438ee8c29cae75995 Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Sun, 1 Feb 2015 13:35:10 +0900 Subject: [PATCH] tizen 2.3 release --- TC/results/build-tar-result-1388117141.html | 12 +- TC/results/build-tar-result-1388117277.html | 12 +- TC/results/build-tar-result-1388117423.html | 6 +- TC/results/build-tar-result-1388117533.html | 8 +- TC/results/exec-tar-result-1388117150.html | 6 +- TC/testcase/utc_shortcut.c | 96 +-- .../23996aa/testcase/utc_dynamicbox_service.c | 732 ++++++++++++++++++ .../23996aa/testcase/utc_livebox_service.c | 732 ------------------ doc/shortcut_doc.h | 213 +----- lib/CMakeLists.txt | 5 +- lib/include/dlist.h | 9 +- lib/include/shortcut.h | 692 ++++++------------ lib/include/shortcut_internal.h | 37 - lib/include/shortcut_manager.h | 177 +++++ lib/include/shortcut_private.h | 204 ++++++ lib/shortcut.pc.in | 1 + lib/src/dlist.c | 9 +- lib/src/icon.c | 814 --------------------- lib/src/main.c | 283 +++++-- packaging/libshortcut.spec | 7 +- sample.xml | 14 +- test/application.c | 2 +- test/icon.c | 18 +- test_db_builder.sh | 20 +- 24 files changed, 1695 insertions(+), 2414 deletions(-) mode change 100644 => 100755 TC/results/build-tar-result-1388117141.html mode change 100644 => 100755 TC/results/build-tar-result-1388117277.html mode change 100644 => 100755 TC/results/build-tar-result-1388117423.html mode change 100644 => 100755 TC/results/build-tar-result-1388117533.html mode change 100644 => 100755 TC/results/exec-tar-result-1388117150.html mode change 100644 => 100755 TC/testcase/utc_shortcut.c create mode 100755 TC/tet_tmp_dir/23996aa/testcase/utc_dynamicbox_service.c delete mode 100644 TC/tet_tmp_dir/23996aa/testcase/utc_livebox_service.c mode change 100644 => 100755 doc/shortcut_doc.h mode change 100644 => 100755 lib/CMakeLists.txt mode change 100644 => 100755 lib/include/shortcut.h delete mode 100644 lib/include/shortcut_internal.h create mode 100755 lib/include/shortcut_manager.h create mode 100755 lib/include/shortcut_private.h mode change 100644 => 100755 lib/shortcut.pc.in delete mode 100644 lib/src/icon.c mode change 100644 => 100755 lib/src/main.c mode change 100644 => 100755 packaging/libshortcut.spec mode change 100644 => 100755 sample.xml mode change 100644 => 100755 test/application.c mode change 100644 => 100755 test/icon.c diff --git a/TC/results/build-tar-result-1388117141.html b/TC/results/build-tar-result-1388117141.html old mode 100644 new mode 100755 index 4785644..bbd1b16 --- a/TC/results/build-tar-result-1388117141.html +++ b/TC/results/build-tar-result-1388117141.html @@ -62,20 +62,20 @@ Execute mode summary

Inline report

-

/testcase/utc_livebox_service [build]

+

/testcase/utc_dynamicbox_service [build]

diff --git a/TC/results/build-tar-result-1388117277.html b/TC/results/build-tar-result-1388117277.html old mode 100644 new mode 100755 index fd2a32f..50f6aba --- a/TC/results/build-tar-result-1388117277.html +++ b/TC/results/build-tar-result-1388117277.html @@ -62,20 +62,20 @@ Execute mode summary
Captured Output
    -
  • cc -o utc_livebox_service utc_livebox_service.c -I. `pkg-config --cflags livebox glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs livebox glib-2.0` /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -ltcm_s -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -lapi_s -
  • Package livebox was not found in the pkg-config search path. -
  • Perhaps you should add the directory containing `livebox.pc' +
  • cc -o utc_dynamicbox_service utc_dynamicbox_service.c -I. `pkg-config --cflags dynamicbox glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs dynamicbox glib-2.0` /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -ltcm_s -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -lapi_s +
  • Package dynamicbox was not found in the pkg-config search path. +
  • Perhaps you should add the directory containing `dynamicbox.pc'
  • to the PKG_CONFIG_PATH environment variable -
  • No package 'livebox' found +
  • No package 'dynamicbox' found
  • cc: error: /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o: No such file or directory -
  • make: *** [utc_livebox_service] Error 1 +
  • make: *** [utc_dynamicbox_service] Error 1

Inline report

-

/testcase/utc_livebox_service [build]

+

/testcase/utc_dynamicbox_service [build]

diff --git a/TC/results/build-tar-result-1388117423.html b/TC/results/build-tar-result-1388117423.html old mode 100644 new mode 100755 index 93e2c80..8b9fd51 --- a/TC/results/build-tar-result-1388117423.html +++ b/TC/results/build-tar-result-1388117423.html @@ -62,16 +62,16 @@ Execute mode summary
Captured Output
    -
  • cc -o utc_livebox_service utc_livebox_service.c -I. `pkg-config --cflags livebox glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs livebox glib-2.0` /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -ltcm_s -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -lapi_s -
  • Package livebox was not found in the pkg-config search path. -
  • Perhaps you should add the directory containing `livebox.pc' +
  • cc -o utc_dynamicbox_service utc_dynamicbox_service.c -I. `pkg-config --cflags dynamicbox glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs dynamicbox glib-2.0` /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -ltcm_s -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -lapi_s +
  • Package dynamicbox was not found in the pkg-config search path. +
  • Perhaps you should add the directory containing `dynamicbox.pc'
  • to the PKG_CONFIG_PATH environment variable -
  • No package 'livebox' found +
  • No package 'dynamicbox' found
  • cc: error: /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o: No such file or directory -
  • make: *** [utc_livebox_service] Error 1 +
  • make: *** [utc_dynamicbox_service] Error 1

Inline report

-

/testcase/utc_livebox_service [build]

+

/testcase/utc_dynamicbox_service [build]

diff --git a/TC/results/build-tar-result-1388117533.html b/TC/results/build-tar-result-1388117533.html old mode 100644 new mode 100755 index 39b0215..7758fad --- a/TC/results/build-tar-result-1388117533.html +++ b/TC/results/build-tar-result-1388117533.html @@ -62,19 +62,19 @@ Execute mode summary
Captured Output
    -
  • cc -o utc_livebox_service utc_livebox_service.c -I. `pkg-config --cflags livebox-service glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs livebox-service glib-2.0` /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -ltcm_s -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -lapi_s +
  • cc -o utc_dynamicbox_service utc_dynamicbox_service.c -I. `pkg-config --cflags dynamicbox-service glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs dynamicbox-service glib-2.0` /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -ltcm_s -L/var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3 -lapi_s
  • cc: error: /var/tmp/dts_fw/TC/TETware/tetware-target/lib/tet3/tcm_s.o: No such file or directory -
  • make: *** [utc_livebox_service] Error 1 +
  • make: *** [utc_dynamicbox_service] Error 1

Inline report

-

/testcase/utc_livebox_service [build]

+

/testcase/utc_dynamicbox_service [build]

diff --git a/TC/results/exec-tar-result-1388117150.html b/TC/results/exec-tar-result-1388117150.html old mode 100644 new mode 100755 index c33c2fe..3558e97 --- a/TC/results/exec-tar-result-1388117150.html +++ b/TC/results/exec-tar-result-1388117150.html @@ -41,7 +41,7 @@ Execute mode summary
Captured Output
    -
  • cc -o utc_livebox_service utc_livebox_service.c -I. `pkg-config --cflags livebox-service glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs livebox-service glib-2.0` -
  • utc_livebox_service.c:18:21: fatal error: tet_api.h: No such file or directory +
  • cc -o utc_dynamicbox_service utc_dynamicbox_service.c -I. `pkg-config --cflags dynamicbox-service glib-2.0` -I/var/tmp/dts_fw/TC/TETware/tetware-target/inc/tet3 -Wall `pkg-config --libs dynamicbox-service glib-2.0` +
  • utc_dynamicbox_service.c:18:21: fatal error: tet_api.h: No such file or directory
  • #include <tet_api.h>
  • ^
  • compilation terminated. -
  • make: *** [utc_livebox_service] Error 1 +
  • make: *** [utc_dynamicbox_service] Error 1

Inline report

-

/testcase/utc_livebox_service [execute]

+

/testcase/utc_dynamicbox_service [execute]

@@ -52,8 +52,8 @@ Inline report
Test Status

Scenario Information


diff --git a/TC/testcase/utc_shortcut.c b/TC/testcase/utc_shortcut.c old mode 100644 new mode 100755 index 654dc68..d5879ee --- a/TC/testcase/utc_shortcut.c +++ b/TC/testcase/utc_shortcut.c @@ -20,9 +20,9 @@ #include -#define MUSIC_APP "com.samsung.music-player" -#define MUSIC_LIVEBOX MUSIC_APP ".livebox" -#define MUSIC_EASYBOX "com.samsung.music-player.easymode.livebox" +#define MUSIC_APP "org.tizen.music-player" +#define MUSIC_DYNAMICBOX MUSIC_APP ".dynamicbox" +#define MUSIC_EASYBOX "org.tizen.music-player.easymode.dynamicbox" enum { POSITIVE_TC_IDX = 0x01, @@ -66,18 +66,18 @@ static int shortcut_request_cb(const char *appid, const char *name, int type, co if (!strcmp(appid, "fail")) { return SHORTCUT_ERROR_UNSUPPORTED; } else if (!strcmp(appid, "success")) { - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } } - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } static void utc_shortcut_set_request_cb_p(void) { int ret; ret = shortcut_set_request_cb(shortcut_request_cb, NULL); - dts_check_eq("shortcut_set_request_cb", ret, SHORTCUT_SUCCESS, "success"); + dts_check_eq("shortcut_set_request_cb", ret, SHORTCUT_ERROR_NONE, "success"); } static int response_cb(int ret, int pid, void *data) @@ -85,7 +85,7 @@ static int response_cb(int ret, int pid, void *data) if ((int)data == 1) { dts_check_eq("add_to_home_shortcut", ret, SHORTCUT_ERROR_UNSUPPORTED, "success"); } else if ((int)data == 2) { - dts_check_eq("add_to_home_shortcut", ret, SHORTCUT_SUCCESS, "success"); + dts_check_eq("add_to_home_shortcut", ret, SHORTCUT_ERROR_NONE, "success"); } return 0; @@ -95,8 +95,8 @@ static void utc_add_to_home_shortcut_n(void) { int ret; ret = add_to_home_shortcut("fail", NULL, LAUNCH_BY_PACKAGE, NULL, NULL, 1, response_cb, (void *)1); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_shortcut", ret, SHORTCUT_SUCCESS, "success"); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_shortcut", ret, SHORTCUT_ERROR_NONE, "success"); } } @@ -104,8 +104,8 @@ static void utc_add_to_home_shortcut_p(void) { int ret; ret = add_to_home_shortcut("success", NULL, LAUNCH_BY_PACKAGE, NULL, NULL, 1, response_cb, (void *)2); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_shortcut", ret, SHORTCUT_SUCCESS, "success"); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_shortcut", ret, SHORTCUT_ERROR_NONE, "success"); } } @@ -130,21 +130,21 @@ static void utc_shortcut_get_list_p(void) dts_check_ge("shortcut_get_list", ret, 0, "get_list"); } -static void utc_add_to_home_livebox_n(void) +static void utc_add_to_home_dynamicbox_n(void) { int ret; - ret = add_to_home_livebox("fail", NULL, LIVEBOX_TYPE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)1); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_livebox", ret, SHORTCUT_SUCCESS, "success"); + ret = add_to_home_dynamicbox("fail", NULL, DYNAMICBOX_TYPE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)1); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_dynamicbox", ret, SHORTCUT_ERROR_NONE, "success"); } } -static void utc_add_to_home_livebox_p(void) +static void utc_add_to_home_dynamicbox_p(void) { int ret; - ret = add_to_home_livebox("success", NULL, LIVEBOX_TYPE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)2); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_livebox", ret, SHORTCUT_SUCCESS, "success"); + ret = add_to_home_dynamicbox("success", NULL, DYNAMICBOX_TYPE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)2); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_dynamicbox", ret, SHORTCUT_ERROR_NONE, "success"); } } @@ -152,8 +152,8 @@ static void utc_add_to_home_remove_shortcut_n(void) { int ret; ret = add_to_home_remove_shortcut("fail", NULL, NULL, response_cb, (void *)1); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID, "Invalid"); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "Invalid"); } } @@ -161,26 +161,26 @@ static void utc_add_to_home_remove_shortcut_p(void) { int ret; ret = add_to_home_remove_shortcut("success", NULL, NULL, response_cb, (void *)2); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID, "Invalid"); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "Invalid"); } } -static void utc_add_to_home_remove_livebox_n(void) +static void utc_add_to_home_remove_dynamicbox_n(void) { int ret; - ret = add_to_home_remove_livebox("fail", NULL, response_cb, (void *)1); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID, "Invalid"); + ret = add_to_home_remove_dynamicbox("fail", NULL, response_cb, (void *)1); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "Invalid"); } } -static void utc_add_to_home_remove_livebox_p(void) +static void utc_add_to_home_remove_dynamicbox_p(void) { int ret; - ret = add_to_home_remove_livebox("success", NULL, response_cb, (void *)2); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID, "Invalid"); + ret = add_to_home_remove_dynamicbox("success", NULL, response_cb, (void *)2); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("add_to_home_remove_shortcut", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "Invalid"); } } @@ -195,7 +195,7 @@ static void utc_shortcut_icon_service_init_n(void) static int icon_service_cb(int status, void *data) { - dts_check_eq("shortcut_icon_service_init", status, SHORTCUT_SUCCESS); + dts_check_eq("shortcut_icon_service_init", status, SHORTCUT_ERROR_NONE); return 0; } @@ -204,8 +204,8 @@ static void utc_shortcut_icon_service_init_p(void) int ret; ret = shortcut_icon_service_init(icon_service_cb, NULL); - if (ret != SHORTCUT_SUCCESS) { - dts_check_eq("shortcut_icon_service_init", ret, SHORTCUT_SUCCESS); + if (ret != SHORTCUT_ERROR_NONE) { + dts_check_eq("shortcut_icon_service_init", ret, SHORTCUT_ERROR_NONE); } } @@ -222,7 +222,7 @@ static void utc_shortcut_icon_service_fini_p(void) { int ret; ret = shortcut_icon_service_fini(); - dts_check_eq("shortcut_icon_service_fini", ret, SHORTCUT_SUCCESS, "success"); + dts_check_eq("shortcut_icon_service_fini", ret, SHORTCUT_ERROR_NONE, "success"); } static void utc_shortcut_icon_request_create_n(void) @@ -240,7 +240,7 @@ static void utc_shortcut_icon_request_set_info_n(void) { int ret; ret = shortcut_icon_request_set_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL); - dts_check_ne("shortcut_icon_request_set_info", ret, SHORTCUT_ERROR_INVALID, "invalid handle"); + dts_check_ne("shortcut_icon_request_set_info", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "invalid handle"); } static void utc_shortcut_icon_request_set_info_p(void) @@ -259,9 +259,9 @@ static void utc_shortcut_icon_request_set_info_p(void) static void utc_shortcut_icon_request_send_n(void) { int ret; - - ret = shortcut_icon_request_send(NULL, LIVEBOX_TYPE_1x1, NULL, NULL, NULL, NULL, NULL); - dts_check_eq("shortcut_icon_request_send", ret, SHORTCUT_ERROR_INVALID, "success"); + + ret = shortcut_icon_request_send(NULL, DYNAMICBOX_TYPE_1x1, NULL, NULL, NULL, NULL, NULL); + dts_check_eq("shortcut_icon_request_send", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "success"); } static int result_cb(struct shortcut_icon *handle, int ret, void *data) @@ -278,7 +278,7 @@ static void utc_shortcut_icon_request_send_p(void) return; } - ret = shortcut_icon_request_send(s_info.handle, LIVEBOX_TYPE_1x1, NULL, NULL, "/tmp/icon.png", result_cb, NULL); + ret = shortcut_icon_request_send(s_info.handle, DYNAMICBOX_TYPE_1x1, NULL, NULL, "/tmp/icon.png", result_cb, NULL); dts_check_eq("shortcut_icon_request_send", ret, 0, "success"); } @@ -287,7 +287,7 @@ static void utc_shortcut_icon_request_destroy_n(void) int ret; ret = shortcut_icon_request_destroy(NULL); - dts_check_eq("shortcut_icon_request_destroy", ret, SHORTCUT_ERROR_INVALID, "invalid"); + dts_check_eq("shortcut_icon_request_destroy", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "invalid"); } static void utc_shortcut_icon_request_destroy_p(void) @@ -300,7 +300,7 @@ static void utc_shortcut_icon_request_destroy_p(void) } ret = shortcut_icon_request_destroy(s_info.handle); - dts_check_eq("shortcut_icon_request_destroy", ret, SHORTCUT_SUCCESS, "Destroy"); + dts_check_eq("shortcut_icon_request_destroy", ret, SHORTCUT_ERROR_NONE, "Destroy"); s_info.handle = NULL; } @@ -308,7 +308,7 @@ static void utc_shortcut_icon_request_set_data_n(void) { int ret; ret = shortcut_icon_request_set_data(NULL, NULL); - dts_check_eq("shortcut_icon_request_set_data", ret, SHORTCUT_ERROR_INVALID, "invalid"); + dts_check_eq("shortcut_icon_request_set_data", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "invalid"); } static void utc_shortcut_icon_request_set_data_p(void) @@ -321,7 +321,7 @@ static void utc_shortcut_icon_request_set_data_p(void) } ret = shortcut_icon_request_set_data(s_info.handle, (void *)1); - dts_check_eq("shortcut_icon_request_set_data", ret, SHORTCUT_SUCCESS, "success"); + dts_check_eq("shortcut_icon_request_set_data", ret, SHORTCUT_ERROR_NONE, "success"); } static void utc_shortcut_icon_request_data_n(void) @@ -348,12 +348,12 @@ struct tet_testlist tet_testlist[] = { { utc_add_to_home_shortcut_p, POSITIVE_TC_IDX }, { utc_shortcut_get_list_n, NEGATIVE_TC_IDX }, { utc_shortcut_get_list_p, POSITIVE_TC_IDX }, - { utc_add_to_home_livebox_n, NEGATIVE_TC_IDX }, - { utc_add_to_home_livebox_p, POSITIVE_TC_IDX }, + { utc_add_to_home_dynamicbox_n, NEGATIVE_TC_IDX }, + { utc_add_to_home_dynamicbox_p, POSITIVE_TC_IDX }, { utc_add_to_home_remove_shortcut_n, NEGATIVE_TC_IDX }, { utc_add_to_home_remove_shortcut_p, POSITIVE_TC_IDX }, - { utc_add_to_home_remove_livebox_n, NEGATIVE_TC_IDX }, - { utc_add_to_home_remove_livebox_p, POSITIVE_TC_IDX }, + { utc_add_to_home_remove_dynamicbox_n, NEGATIVE_TC_IDX }, + { utc_add_to_home_remove_dynamicbox_p, POSITIVE_TC_IDX }, { utc_shortcut_icon_service_init_n, NEGATIVE_TC_IDX }, { utc_shortcut_icon_service_init_p, POSITIVE_TC_IDX }, { utc_shortcut_icon_request_create_n, NEGATIVE_TC_IDX }, diff --git a/TC/tet_tmp_dir/23996aa/testcase/utc_dynamicbox_service.c b/TC/tet_tmp_dir/23996aa/testcase/utc_dynamicbox_service.c new file mode 100755 index 0000000..689954f --- /dev/null +++ b/TC/tet_tmp_dir/23996aa/testcase/utc_dynamicbox_service.c @@ -0,0 +1,732 @@ +/* + * Copyright (c) 2011 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. + */ + + +#include +#include + +#include +#include + +#define MUSIC_APP "org.tizen.music-player" +#define MUSIC_DYNAMICBOX MUSIC_APP ".dynamicbox" +#define MUSIC_EASYBOX "org.tizen.music-player.easymode.dynamicbox" + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + + // Create DB file for testing +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + // Delete DB file for testing +} + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_dynamicbox_service_get_size_n(void) +{ + int ret; + int w; + int h; + + ret = dynamicbox_service_get_size(LB_SIZE_TYPE_UNKNOWN, &w, &h); + dts_check_eq("dynamicbox_service_get_size", ret, LB_STATUS_ERROR_INVALID, "invalid size should returns LB_STATUS_ERROR_INVALID\n"); +} + +static void utc_dynamicbox_service_get_size_p(void) +{ + int ret; + int w; + int h; + ret = dynamicbox_service_get_size(LB_SIZE_TYPE_1x1, &w, &h); + dts_check_eq("dynamicbox_service_get_size", ret, LB_STATUS_SUCCESS, "valid size should returns LB_STATUS_SUCCES\n"); +} + +static void utc_dynamicbox_service_size_type_n(void) +{ + int ret; + ret = dynamicbox_service_size_type(1, 1); + dts_check_eq("dynamicbox_service_size_type", ret, LB_SIZE_TYPE_UNKNOWN, "invalid size should returns LB_SIZE_TYPE_UNKNOWN\n"); +} + +static void utc_dynamicbox_service_size_type_p(void) +{ + int ret; + int w; + int h; + int old; + + old = dynamicbox_service_get_size(LB_SIZE_TYPE_1x1, &w, &h); + + ret = dynamicbox_service_size_type(w, h); + dts_check_eq("dynamicbox_service_size_type", ret, LB_SIZE_TYPE_1x1, "LB_SIZE_TYPE_1x1 should returns\n"); +} + +static void utc_dynamicbox_service_mouse_event_n(void) +{ + int ret; + ret = dynamicbox_service_mouse_event(NULL); + dts_check_eq("dynamicbox_service_mouse_event", ret, 0, "Invalid package name returns 0\n"); +} + +static void utc_dynamicbox_service_mouse_event_p(void) +{ + int ret; + ret = dynamicbox_service_mouse_event(MUSIC_EASYBOX); + dts_check_eq("dynamicbox_service_mouse_event", ret, 1, "music player returns 1\n"); +} + +static void utc_dynamicbox_service_touch_effect_n(void) +{ + int ret; + ret = dynamicbox_service_touch_effect(NULL, LB_SIZE_TYPE_1x1); + dts_check_eq("dynamicbox_service_touch_effect", ret, 1, "Default touch effect is 1\n"); +} + +static void utc_dynamicbox_service_touch_effect_p(void) +{ + int ret; + ret = dynamicbox_service_touch_effect(MUSIC_DYNAMICBOX, LB_SIZE_TYPE_1x1); + dts_check_eq("dynamicbox_service_touch_effect", ret, 1, "Default touch effect is 1\n"); +} + +static void utc_dynamicbox_service_need_frame_n(void) +{ + int ret; + ret = dynamicbox_service_need_frame(NULL, LB_SIZE_TYPE_1x1); + dts_check_eq("dynamicbox_service_need_frame", ret, 0, "Default need_frame is 0\n"); +} + +static void utc_dynamicbox_service_need_frame_p(void) +{ + int ret; + ret = dynamicbox_service_need_frame(MUSIC_DYNAMICBOX, LB_SIZE_TYPE_1x1); + dts_check_eq("dynamicbox_service_need_frame", ret, 0, "Default need_frame is 0\n"); +} + +static void utc_dynamicbox_service_trigger_update_n(void) +{ + int ret; + ret = dynamicbox_service_trigger_update(NULL, NULL, NULL, NULL, 0); + dts_check_eq("dynamicbox_service_trigger_update", ret, LB_STATUS_ERROR_INVALID, "Invalid dynamicbox\n"); +} + +static void utc_dynamicbox_service_trigger_update_p(void) +{ + int ret; + ret = dynamicbox_service_trigger_update(MUSIC_DYNAMICBOX, NULL, NULL, NULL, 0); + dts_check_eq("dynamicbox_service_trigger_update", ret, LB_STATUS_SUCCESS, "Invalid dynamicbox\n"); +} + +static void utc_dynamicbox_service_trigger_update_with_content_n(void) +{ + int ret; + ret = dynamicbox_service_trigger_update_with_content(NULL, NULL, NULL, NULL, NULL, 0); + dts_check_eq("dynamicbox_service_trigger_update_with_content", ret, LB_STATUS_ERROR_INVALID, "Invalid dynamicbox\n"); +} + +static void utc_dynamicbox_service_trigger_update_with_content_p(void) +{ + int ret; + ret = dynamicbox_service_trigger_update_with_content(MUSIC_DYNAMICBOX, NULL, NULL, NULL, NULL, 0); + dts_check_eq("dynamicbox_service_trigger_update_with_content", ret, LB_STATUS_ERROR_INVALID, "Invalid dynamicbox\n"); +} + +static void utc_dynamicbox_service_change_period_n(void) +{ + int ret; + + ret = dynamicbox_service_change_period(NULL, NULL, 0.0f); + dts_check_eq("dynamicbox_service_change_period", ret, LB_STATUS_ERROR_INVALID, "Invalid dynamicbox\n"); +} + +static void utc_dynamicbox_service_change_period_p(void) +{ + int ret; + + ret = dynamicbox_service_change_period(MUSIC_DYNAMICBOX, NULL, 1.0f); + dts_check_eq("dynamicbox_service_change_period", ret, LB_STATUS_SUCCESS, "Invalid dynamicbox\n"); +} + +static int get_pkglist_cb(const char *pkgid, const char *lbid, int is_prime, void *data) +{ +} + +static void utc_dynamicbox_service_get_pkglist_n(void) +{ + int ret; + ret = dynamicbox_service_get_pkglist(NULL, NULL); + dts_check_eq("dynamicbox_service_get_pkglist", ret, LB_STATUS_ERROR_INVALID, "Invalid callback\n"); +} + +static void utc_dynamicbox_service_get_pkglist_p(void) +{ + int ret; + ret = dynamicbox_service_get_pkglist(get_pkglist_cb, NULL); + dts_check_eq("dynamicbox_service_get_pkglist", ret, LB_STATUS_SUCCESS, "Valid callback\n"); +} + +static void utc_dynamicbox_service_get_applist_n(void) +{ + int ret; + ret = dynamicbox_service_get_applist(NULL, NULL, NULL); + dts_check_eq("dynamicbox_service_get_applist", ret, LB_STATUS_ERROR_INVALID, "LB_STATUS_ERROR_INVALID\n"); +} + +static void app_list_cb(const char *lbid, const char *appid, void *data) +{ +} + +static void utc_dynamicbox_service_get_applist_p(void) +{ + int ret; + + // Getting the UI-App list + ret = dynamicbox_service_get_applist(MUSIC_DYNAMICBOX, app_list_cb, NULL); + dts_check_eq("dynamicbox_service_get_applist", ret, LB_STATUS_SUCCESS, "LB_STATUS_ERROR_INVALID\n"); +} + +static void utc_dynamicbox_service_mainappid_n(void) +{ + const char *appid; + appid = dynamicbox_service_mainappid(NULL); + dts_check_eq("dynamicbox_service_mainappid", appid, NULL, "\"NULL\" should be returned\n"); +} + +static void utc_dynamicbox_service_mainappid_p(void) +{ + const char *appid; + appid = dynamicbox_service_mainappid(MUSIC_DYNAMICBOX); + dts_check_str_eq("dynamicbox_service_mainappid", appid, MUSIC_APP, "\"org.tizen.music-player\" should be returned\n"); +} + +static void utc_dynamicbox_service_get_pkglist_by_pkgid_n(void) +{ + int ret; + ret = dynamicbox_service_get_pkglist_by_pkgid(NULL, list_cb, NULL); + dts_check_eq("dynamicbox_service_get_pkglist_by_pkgid", ret, LB_STATUS_ERROR_INVALID, "INVALID should be returned"); +} + +static void utc_dynamicbox_service_get_pkglist_by_pkgid_p(void) +{ + int ret; + ret = dynamicbox_service_get_pkglist_by_pkgid(MUSIC_APP, list_cb, NULL); + dts_check_ge("dynamicbox_service_get_pkglist_by_pkgid", ret, 0, "greater than or equal to 0"); +} + +static void utc_dynamicbox_service_pkgname_n(void) +{ + char *pkgname; + pkgname = dynamicbox_service_pkgname(NULL); + dts_check_eq("dynamicbox_service_pkgname", pkgname, NULL, "lbid is not exists"); +} + +static void utc_dynamicbox_service_pkgname_p(void) +{ + char *pkgname; + pkgname = dynamicbox_service_pkgname(MUSIC_APP); + dts_check_str_eq("dynamicbox_service_pkgname", pkgname, MUSIC_DYNAMICBOX, "dynamicbox music-player"); +} + +static void utc_dynamicbox_service_is_primary_n(void) +{ + int ret; + ret = dynamicbox_service_is_primary(NULL); + dts_check_str_eq("dynamicbox_service_is_primary", ret, 0, "\"NULL\" is not primary(0)\n"); +} + +static void utc_dynamicbox_service_is_primary_p(void) +{ + int ret; + ret = dynamicbox_service_is_primary(MUSIC_DYNAMICBOX); + dts_check_str_eq("dynamicbox_service_is_primary", ret, 1, "\"org.tizen.music-player\" is primary(1)\n"); +} + +static void utc_dynamicbox_service_provider_name_n(void) +{ +//static char *dynamicbox_service_provider_name(const char *lbid); + char *provider; + provider = dynamicbox_service_provider_name(NULL); + dts_check_eq("dynamicbox_service_provider_name", provider, NULL, "returns NULL"); +} + +static void utc_dynamicbox_service_provider_name_p(void) +{ + char *provider; + provider = dynamicbox_service_provider_name(MUSIC_DYNAMICBOX); + dts_check_str_eq("dynamicbox_service_provider_name", provider, MUSIC_DYNAMICBOX, "inhouse dynamicbox"); +} + +static void utc_dynamicbox_service_setup_appid_n(void) +{ +//static char *dynamicbox_service_setup_appid(const char *lbid); + char *setup; + setup = dynamicbox_service_setup_appid(NULL); + dts_check_eq("dynamicbox_service_setup_appid", setup, NULL, "setup is NULL"); +} + +static void utc_dynamicbox_service_setup_appid_p(void) +{ + char *setup; + setup = dynamicbox_service_setup_appid(MUSIC_DYNAMICBOX); + dts_check_eq("dynamicbox_service_setup_appid", setup, MUSIC_DYNAMICBOX, "setup app"); +} + +static void utc_dynamicbox_service_appid_n(void) +{ + char *appid; + appid = dynamicbox_service_appid(NULL); + dts_check_eq("dynamicbox_service_appid", appid, NULL, "appid is NULL"); +} + +static void utc_dynamicbox_service_appid_p(void) +{ + char *appid; + appid = dynamicbox_service_appid(MUSIC_DYNAMICBOX); + dts_check_str_eq("dynamicbox_service_appid", appid, MUSIC_APP, "appid is org.tizen.music-player"); +} + +static void utc_dynamicbox_service_i18n_name_n(void) +{ + char *name; + name = dynamicbox_service_i18n_name(NULL, NULL); + dts_check_eq("dynamicbox_service_i18n_name", name, NULL, "name is NULL"); +} + +static void utc_dynamicbox_service_i18n_name_p(void) +{ + char *name; + name = dynamicbox_service_i18n_name(MUSIC_DYNAMICBOX, NULL); + dts_check_ne("dynamicbox_service_i18n_name", name, NULL, "name is not NULL"); +} + +static void utc_dynamicbox_service_privew_n(void) +{ + char *preview; + preview = dynamicbox_service_preview(MUSIC_DYNAMICBOX, LB_SIZE_TYPE_1x1); + dts_check_eq("dynamicbox_service_preview", preview, NULL, "preview is NULL"); +} + +static void utc_dynamicbox_service_preview_p(void) +{ + char *preview; + preview = dynamicbox_service_preview(MUSIC_DYNAMICBOX, LB_SIZE_TYPE_1x1); + dts_check_ne("dynamicbox_service_preview", preview, NULL, "preview is not NULL"); +} + +static void utc_dynamicbox_service_content_n(void) +{ + char *content; + content = dynamicbox_service_content(NULL); + dts_check_eq("dynamicbox_service_content", content, NULL, "content is NULL"); +} + +static void utc_dynamicbox_service_content_p(void) +{ + char *content; + content = dynamicbox_service_content(MUSIC_DYNAMICBOX); + dts_check_ne("dynamicbox_service_content", content, NULL, "content is not NULL"); +} + +static void utc_dynamicbox_service_i18n_icon_p(void) +{ + char *icon; + + icon = dynamicbox_service_i18n_icon(NULL, NULL); + dts_check_eq("dynamicbox_service_i18n_icon", icon, NULL, "icon is NULL"); +} + +static void utc_dynamicbox_service_i18n_icon_n(void) +{ + char *icon; + + icon = dynamicbox_service_i18n_icon(MUSIC_DYNAMICBOX, NULL); + dts_check_ne("dynamicbox_service_i18n_icon", icon, NULL, "icon is not NULL"); +} + +static void utc_dynamicbox_service_libexec_p(void) +{ + char *libexec; + libexec = dynamicbox_service_libexec(NULL); + dts_check_eq("dynamicbox_service_libexec", libexec, NULL, "libexec is NULL"); +} + +static void utc_dynamicbox_service_libexec_n(void) +{ + char *libexec; + libexec = dynamicbox_service_libexec(MUSIC_DYNAMICBOX); + dts_check_ne("dynamicbox_service_libexec", libexec, NULL, "libexec is not NULL"); +} + +static void utc_dynamicbox_service_nodisplay_p(void) +{ + int ret; + ret = dynamicbox_service_nodisplay(NULL); + dts_check_eq("dynamicbox_service_nodisplay", ret, 0, "nodisplay is false"); +} + +static void utc_dynamicbox_service_nodisplay_n(void) +{ + int ret; + ret = dynamicbox_service_nodisplay(MUSIC_DYNAMICBOX); + dts_check_eq("dynamicbox_service_nodisplay", ret, 0, "nodisplay is false"); +} + +static void utc_dynamicbox_service_abi_p(void) +{ + char *abi; + abi = dynamicbox_service_abi(NULL); + dts_check_eq("dynamicbox_service_abi", abi, NULL, "abi is NULL"); +} + +static void utc_dynamicbox_service_abi_n(void) +{ + char *abi; + abi = dynamicbox_service_abi(MUSIC_DYNAMICBOX); + dts_check_ne("dynamicbox_service_abi", abi, NULL, "abi is not NULL"); +} + +static void utc_dynamicbox_service_is_enabled_n(void) +{ + /*! + * static int dynamicbox_service_is_enabled(const char *lbid); + * - Not implemented + */ +} + +static void utc_dynamicbox_service_is_enabled_p(void) +{ + /*! + * static int dynamicbox_service_is_enabled(const char *lbid); + * - Not implemented + */ +} + +static void utc_dynamicbox_service_lb_script_path_n(void) +{ + char *lb_path; + lb_path = dynamicbox_service_lb_script_path(NULL); + dts_check_eq("dynamicbox_service_lb_script_path", lb_path, NULL, "lb_path is NULL"); +} + +static void utc_dynamicbox_service_lb_script_path_p(void) +{ + char *lb_path; + lb_path = dynamicbox_service_lb_script_path(MUSIC_DYNAMICBOX); + dts_check_ne("dynamicbox_service_lb_script_path", lb_path, NULL, "lb_path is NULL"); +} + +static void utc_dynamicbox_service_lb_script_group_n(void) +{ + char *lb_group; + lb_group = dynamicbox_service_lb_script_group(NULL); + dts_check_ne("dynamicbox_service_lb_script_group", lb_group, NULL, "lb_group is NULL"); +} + +static void utc_dynamicbox_service_lb_script_group_p(void) +{ + char *lb_group; + lb_group = dynamicbox_service_lb_script_group(MUSIC_DYNAMICBOX); + dts_check_ne("dynamicbox_service_lb_script_group", lb_group, NULL, "lb_group is NULL"); +} + +static void utc_dynamicbox_service_pd_script_path_n(void) +{ + char *pd_script; + pd_script = dynamicbox_service_pd_script_path(NULL); + dts_check_eq("dynamicbox_service_pd_script_path", pd_script, NULL, "pd_script is NULL"); +} + +static void utc_dynamicbox_service_pd_script_path_p(void) +{ + char *pd_script; + pd_script = dynamicbox_service_pd_script_path(MUSIC_DYNAMICBOX); + dts_check_ne("dynamicbox_service_pd_script_path", pd_script, NULL, "pd_script is NULL"); +} + +static void utc_dynamicbox_service_pd_script_group_p(void) +{ + char *pd_group; + pd_group = dynamicbox_service_pd_script_group(MUSIC_DYNAMICBOX); + dts_check_ne("dynamicbox_service_pd_script_group", pd_group, NULL, "pd_script is NULL"); +} + +static void utc_dynamicbox_service_pd_script_group_n(void) +{ + char *pd_group; + pd_group = dynamicbox_service_pd_script_group(MUSIC_DYNAMICBOX); + dts_check_eq("dynamicbox_service_pd_script_group", pd_group, NULL, "pd_script is NULL"); +} + +static void utc_dynamicbox_service_get_supported_sizes_n(void) +{ + int cnt = NR_OF_SIZE_LIST; + int w[NR_OF_SIZE_LIST]; + int h[NR_OF_SIZE_LIST]; + int ret; + + ret = dynamicbox_service_get_supported_sizes(NULL, &cnt, w, h); + dts_check_eq("dynamicbox_service_get_supported_sizes", ret, LB_STATUS_ERROR_INVALID, "supported sizes is 0"); +} + +static void utc_dynamicbox_service_get_supported_sizes_p(void) +{ + int cnt = NR_OF_SIZE_LIST; + int w[NR_OF_SIZE_LIST]; + int h[NR_OF_SIZE_LIST]; + int ret; + + ret = dynamicbox_service_get_supported_sizes(MUSIC_DYNAMICBOX, &cnt, w, h); + dts_check_eq("dynamicbox_service_get_supported_sizes", ret, 0, "supported sizes is 0"); +} + +static void utc_dynamicbox_service_get_supported_size_types_n(void) +{ + int cnt = NR_OF_SIZE_LIST; + int sizes[NR_OF_SIZE_LIST]; + int ret; + + ret = dynamicbox_service_get_supported_size_types(NULL, &cnt, sizes); + dts_check_eq("dynamicbox_service_get_supported_sizes", ret, LB_STATUS_ERROR_INVALID, "supported sizes is 0"); +} + +static void utc_dynamicbox_service_get_supported_size_types_p(void) +{ + int cnt = NR_OF_SIZE_LIST; + int sizes[NR_OF_SIZE_LIST]; + int ret; + + ret = dynamicbox_service_get_supported_size_types(MUSIC_DYNAMICBOX, &cnt, sizes); + dts_check_eq("dynamicbox_service_get_supported_sizes", ret, 0, "supported sizes is 0"); +} + +static int category_cb(const char *cluster, const char *category, void *data) +{ + return 0; +} + +static void utc_dynamicbox_service_enumerate_category_list_n(void) +{ + int ret; + ret = dynamicbox_service_enumerate_category_list(NULL, NULL, NULL); + dts_check_eq("dynamicbox_service_enumerate_category_list", ret, LB_STATUS_ERROR_INVALID, "invalid argument"); +} + +static void utc_dynamicbox_service_enumerate_category_list_p(void) +{ + int ret; + ret = dynamicbox_service_enumerate_category_list("default", category_cb, NULL); + dts_check_eq("dynamicbox_service_enumerate_category_list", ret, LB_STATUS_ERROR_INVALID, "invalid argument"); +} + +static void utc_dynamicbox_service_enumerate_cluster_list_n(void) +{ +//static int dynamicbox_service_enumerate_cluster_list(int (*cb)(const char *cluster, void *data), void *data); + int ret; + ret = dynamicbox_service_enumerate_cluster_list(NULL, NULL); + dts_check_eq("dynamicbox_service_enumerate_cluster_list", ret, LB_STATUS_ERROR_INVALID, "invalid argument"); +} + +static void utc_dynamicbox_service_enumerate_cluster_list_p(void) +{ + int ret; + ret = dynamicbox_service_enumerate_cluster_list(cluster_cb, NULL); + dts_check_ne("dynamicbox_service_enumerate_cluster_list", ret, 0, "invalid argument"); +} + +static void utc_dynamicbox_service_init_n(void) +{ + /*! + * \note + * Unable to test initialize function + */ +} + +static void utc_dynamicbox_service_init_p(void) +{ + int ret; + + ret = dynamicbox_service_init(); + dts_check_eq("dynamicbox_service_init", ret, LB_STATUS_SUCCESS, "Success"); +} + +static void utc_dynamicbox_service_fini_n(void) +{ + /*! + * \note + * Unable to test finalize function + */ +} + +static void utc_dynamicbox_service_fini_p(void) +{ + int ret; + ret = dynamicbox_service_fini(); + dts_check_eq("dynamicbox_service_fini", ret, LB_STATUS_SUCCESS, "Success"); +} + +static void utc_dynamicbox_service_pkglist_create_n(void) +{ + /*! + * \note + * Unable to test finalize function + */ +} + +static void utc_dynamicbox_service_pkglist_create_p(void) +{ + struct pkglist_handle *handle; + + handle = dynamicbox_service_pkglist_create(NULL, NULL); + dts_check_ne("dynamicbox_service_pkglist_create", handle, NULL, "Success"); +} + +static void utc_dynamicbox_service_get_pkglist_item_n(void) +{ + char *lbid; + char *pkgname; + int prime; + int ret; + + ret = dynamicbox_service_get_pkglist_item(NULL, &lbid, &pkgname, &prime); + dts_check_eq("dynamicbox_service_get_pkglist_item", ret, LB_STATUS_ERROR_INVALID, "Invalid"); +} + +static void utc_dynamicbox_service_get_pkglist_item_p(void) +{ + struct pkglist_handle *handle; + char *lbid; + char *pkgname; + int prime; + int ret; + + handle = dynamicbox_service_pkglist_create(NULL, NULL); + ret = dynamicbox_service_get_pkglist_item(handle, &lbid, &pkgname, &prime); + dts_check_eq("dynamicbox_service_get_pkglist_item", ret, LB_STATUS_SUCCESS, "Success"); +} + +static void utc_dynamicbox_service_pkglist_destroy_n(void) +{ + int ret; + + ret = dynamicbox_service_pkglist_destroy(NULL); + dts_check_eq("dynamicbox_service_pkglist_destroy", ret, LB_STATUS_ERROR_INVALID, "Invalid"); +} + +static void utc_dynamicbox_service_pkglist_destroy_p(void) +{ + struct pkglist_handle *handle; + int ret; + + handle = dynamicbox_service_pkglist_create(NULL, NULL); + ret = dynamicbox_service_pkglist_destroy(handle); + dts_check_eq("dynamicbox_service_pkglist_destroy", ret, LB_STATUS_ERROR_INVALID, "Invalid"); +} + +struct tet_testlist tet_testlist[] = { + { utc_dynamicbox_service_get_size_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_size_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_size_type_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_size_type_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_mouse_event_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_mouse_event_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_touch_effect_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_touch_effect_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_need_frame_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_need_frame_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_trigger_update_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_trigger_update_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_trigger_update_with_content_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_trigger_update_with_content_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_change_period_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_change_period_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_get_pkglist_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_pkglist_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_get_applist_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_applist_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_mainappid_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_mainappid_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_get_pkglist_by_pkgid_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_pkglist_by_pkgid_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_pkgname_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_pkgname_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_is_primary_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_is_primary_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_provider_name_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_provider_name_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_setup_appid_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_setup_appid_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_appid_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_appid_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_i18n_name_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_i18n_name_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_privew_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_preview_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_content_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_content_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_content_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_i18n_icon_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_i18n_icon_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_libexec_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_libexec_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_nodisplay_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_nodisplay_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_abi_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_abi_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_is_enabled_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_is_enabled_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_lb_script_path_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_lb_script_path_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_lb_script_group_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_lb_script_group_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_pd_script_path_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_pd_script_path_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_pd_script_group_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_pd_script_group_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_supported_sizes_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_supported_sizes_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_get_supported_size_types_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_supported_size_types_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_enumerate_category_list_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_enumerate_category_list_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_enumerate_cluster_list_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_enumerate_cluster_list_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_init_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_init_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_fini_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_fini_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_pkglist_create_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_pkglist_create_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_get_pkglist_item_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_get_pkglist_item_p, POSITIVE_TC_IDX }, + { utc_dynamicbox_service_pkglist_destroy_n, NEGATIVE_TC_IDX }, + { utc_dynamicbox_service_pkglist_destroy_p, POSITIVE_TC_IDX }, + { NULL, 0 }, +}; + diff --git a/TC/tet_tmp_dir/23996aa/testcase/utc_livebox_service.c b/TC/tet_tmp_dir/23996aa/testcase/utc_livebox_service.c deleted file mode 100644 index 75dbe49..0000000 --- a/TC/tet_tmp_dir/23996aa/testcase/utc_livebox_service.c +++ /dev/null @@ -1,732 +0,0 @@ -/* - * Copyright (c) 2011 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. - */ - - -#include -#include - -#include -#include - -#define MUSIC_APP "com.samsung.music-player" -#define MUSIC_LIVEBOX MUSIC_APP ".livebox" -#define MUSIC_EASYBOX "com.samsung.music-player.easymode.livebox" - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static void startup(void) -{ - /* start of TC */ - tet_printf("\n TC start"); - - // Create DB file for testing -} - - -static void cleanup(void) -{ - /* end of TC */ - tet_printf("\n TC end"); - // Delete DB file for testing -} - -void (*tet_startup)(void) = startup; -void (*tet_cleanup)(void) = cleanup; - -static void utc_livebox_service_get_size_n(void) -{ - int ret; - int w; - int h; - - ret = livebox_service_get_size(LB_SIZE_TYPE_UNKNOWN, &w, &h); - dts_check_eq("livebox_service_get_size", ret, LB_STATUS_ERROR_INVALID, "invalid size should returns LB_STATUS_ERROR_INVALID\n"); -} - -static void utc_livebox_service_get_size_p(void) -{ - int ret; - int w; - int h; - ret = livebox_service_get_size(LB_SIZE_TYPE_1x1, &w, &h); - dts_check_eq("livebox_service_get_size", ret, LB_STATUS_SUCCESS, "valid size should returns LB_STATUS_SUCCES\n"); -} - -static void utc_livebox_service_size_type_n(void) -{ - int ret; - ret = livebox_service_size_type(1, 1); - dts_check_eq("livebox_service_size_type", ret, LB_SIZE_TYPE_UNKNOWN, "invalid size should returns LB_SIZE_TYPE_UNKNOWN\n"); -} - -static void utc_livebox_service_size_type_p(void) -{ - int ret; - int w; - int h; - int old; - - old = livebox_service_get_size(LB_SIZE_TYPE_1x1, &w, &h); - - ret = livebox_service_size_type(w, h); - dts_check_eq("livebox_service_size_type", ret, LB_SIZE_TYPE_1x1, "LB_SIZE_TYPE_1x1 should returns\n"); -} - -static void utc_livebox_service_mouse_event_n(void) -{ - int ret; - ret = livebox_service_mouse_event(NULL); - dts_check_eq("livebox_service_mouse_event", ret, 0, "Invalid package name returns 0\n"); -} - -static void utc_livebox_service_mouse_event_p(void) -{ - int ret; - ret = livebox_service_mouse_event(MUSIC_EASYBOX); - dts_check_eq("livebox_service_mouse_event", ret, 1, "music player returns 1\n"); -} - -static void utc_livebox_service_touch_effect_n(void) -{ - int ret; - ret = livebox_service_touch_effect(NULL, LB_SIZE_TYPE_1x1); - dts_check_eq("livebox_service_touch_effect", ret, 1, "Default touch effect is 1\n"); -} - -static void utc_livebox_service_touch_effect_p(void) -{ - int ret; - ret = livebox_service_touch_effect(MUSIC_LIVEBOX, LB_SIZE_TYPE_1x1); - dts_check_eq("livebox_service_touch_effect", ret, 1, "Default touch effect is 1\n"); -} - -static void utc_livebox_service_need_frame_n(void) -{ - int ret; - ret = livebox_service_need_frame(NULL, LB_SIZE_TYPE_1x1); - dts_check_eq("livebox_service_need_frame", ret, 0, "Default need_frame is 0\n"); -} - -static void utc_livebox_service_need_frame_p(void) -{ - int ret; - ret = livebox_service_need_frame(MUSIC_LIVEBOX, LB_SIZE_TYPE_1x1); - dts_check_eq("livebox_service_need_frame", ret, 0, "Default need_frame is 0\n"); -} - -static void utc_livebox_service_trigger_update_n(void) -{ - int ret; - ret = livebox_service_trigger_update(NULL, NULL, NULL, NULL, 0); - dts_check_eq("livebox_service_trigger_update", ret, LB_STATUS_ERROR_INVALID, "Invalid livebox\n"); -} - -static void utc_livebox_service_trigger_update_p(void) -{ - int ret; - ret = livebox_service_trigger_update(MUSIC_LIVEBOX, NULL, NULL, NULL, 0); - dts_check_eq("livebox_service_trigger_update", ret, LB_STATUS_SUCCESS, "Invalid livebox\n"); -} - -static void utc_livebox_service_trigger_update_with_content_n(void) -{ - int ret; - ret = livebox_service_trigger_update_with_content(NULL, NULL, NULL, NULL, NULL, 0); - dts_check_eq("livebox_service_trigger_update_with_content", ret, LB_STATUS_ERROR_INVALID, "Invalid livebox\n"); -} - -static void utc_livebox_service_trigger_update_with_content_p(void) -{ - int ret; - ret = livebox_service_trigger_update_with_content(MUSIC_LIVEBOX, NULL, NULL, NULL, NULL, 0); - dts_check_eq("livebox_service_trigger_update_with_content", ret, LB_STATUS_ERROR_INVALID, "Invalid livebox\n"); -} - -static void utc_livebox_service_change_period_n(void) -{ - int ret; - - ret = livebox_service_change_period(NULL, NULL, 0.0f); - dts_check_eq("livebox_service_change_period", ret, LB_STATUS_ERROR_INVALID, "Invalid livebox\n"); -} - -static void utc_livebox_service_change_period_p(void) -{ - int ret; - - ret = livebox_service_change_period(MUSIC_LIVEBOX, NULL, 1.0f); - dts_check_eq("livebox_service_change_period", ret, LB_STATUS_SUCCESS, "Invalid livebox\n"); -} - -static int get_pkglist_cb(const char *pkgid, const char *lbid, int is_prime, void *data) -{ -} - -static void utc_livebox_service_get_pkglist_n(void) -{ - int ret; - ret = livebox_service_get_pkglist(NULL, NULL); - dts_check_eq("livebox_service_get_pkglist", ret, LB_STATUS_ERROR_INVALID, "Invalid callback\n"); -} - -static void utc_livebox_service_get_pkglist_p(void) -{ - int ret; - ret = livebox_service_get_pkglist(get_pkglist_cb, NULL); - dts_check_eq("livebox_service_get_pkglist", ret, LB_STATUS_SUCCESS, "Valid callback\n"); -} - -static void utc_livebox_service_get_applist_n(void) -{ - int ret; - ret = livebox_service_get_applist(NULL, NULL, NULL); - dts_check_eq("livebox_service_get_applist", ret, LB_STATUS_ERROR_INVALID, "LB_STATUS_ERROR_INVALID\n"); -} - -static void app_list_cb(const char *lbid, const char *appid, void *data) -{ -} - -static void utc_livebox_service_get_applist_p(void) -{ - int ret; - - // Getting the UI-App list - ret = livebox_service_get_applist(MUSIC_LIVEBOX, app_list_cb, NULL); - dts_check_eq("livebox_service_get_applist", ret, LB_STATUS_SUCCESS, "LB_STATUS_ERROR_INVALID\n"); -} - -static void utc_livebox_service_mainappid_n(void) -{ - const char *appid; - appid = livebox_service_mainappid(NULL); - dts_check_eq("livebox_service_mainappid", appid, NULL, "\"NULL\" should be returned\n"); -} - -static void utc_livebox_service_mainappid_p(void) -{ - const char *appid; - appid = livebox_service_mainappid(MUSIC_LIVEBOX); - dts_check_str_eq("livebox_service_mainappid", appid, MUSIC_APP, "\"com.samsung.music-player\" should be returned\n"); -} - -static void utc_livebox_service_get_pkglist_by_pkgid_n(void) -{ - int ret; - ret = livebox_service_get_pkglist_by_pkgid(NULL, list_cb, NULL); - dts_check_eq("livebox_service_get_pkglist_by_pkgid", ret, LB_STATUS_ERROR_INVALID, "INVALID should be returned"); -} - -static void utc_livebox_service_get_pkglist_by_pkgid_p(void) -{ - int ret; - ret = livebox_service_get_pkglist_by_pkgid(MUSIC_APP, list_cb, NULL); - dts_check_ge("livebox_service_get_pkglist_by_pkgid", ret, 0, "greater than or equal to 0"); -} - -static void utc_livebox_service_pkgname_n(void) -{ - char *pkgname; - pkgname = livebox_service_pkgname(NULL); - dts_check_eq("livebox_service_pkgname", pkgname, NULL, "lbid is not exists"); -} - -static void utc_livebox_service_pkgname_p(void) -{ - char *pkgname; - pkgname = livebox_service_pkgname(MUSIC_APP); - dts_check_str_eq("livebox_service_pkgname", pkgname, MUSIC_LIVEBOX, "livebox music-player"); -} - -static void utc_livebox_service_is_primary_n(void) -{ - int ret; - ret = livebox_service_is_primary(NULL); - dts_check_str_eq("livebox_service_is_primary", ret, 0, "\"NULL\" is not primary(0)\n"); -} - -static void utc_livebox_service_is_primary_p(void) -{ - int ret; - ret = livebox_service_is_primary(MUSIC_LIVEBOX); - dts_check_str_eq("livebox_service_is_primary", ret, 1, "\"com.samsung.music-player\" is primary(1)\n"); -} - -static void utc_livebox_service_provider_name_n(void) -{ -//static char *livebox_service_provider_name(const char *lbid); - char *provider; - provider = livebox_service_provider_name(NULL); - dts_check_eq("livebox_service_provider_name", provider, NULL, "returns NULL"); -} - -static void utc_livebox_service_provider_name_p(void) -{ - char *provider; - provider = livebox_service_provider_name(MUSIC_LIVEBOX); - dts_check_str_eq("livebox_service_provider_name", provider, MUSIC_LIVEBOX, "inhouse livebox"); -} - -static void utc_livebox_service_setup_appid_n(void) -{ -//static char *livebox_service_setup_appid(const char *lbid); - char *setup; - setup = livebox_service_setup_appid(NULL); - dts_check_eq("livebox_service_setup_appid", setup, NULL, "setup is NULL"); -} - -static void utc_livebox_service_setup_appid_p(void) -{ - char *setup; - setup = livebox_service_setup_appid(MUSIC_LIVEBOX); - dts_check_eq("livebox_service_setup_appid", setup, MUSIC_LIVEBOX, "setup app"); -} - -static void utc_livebox_service_appid_n(void) -{ - char *appid; - appid = livebox_service_appid(NULL); - dts_check_eq("livebox_service_appid", appid, NULL, "appid is NULL"); -} - -static void utc_livebox_service_appid_p(void) -{ - char *appid; - appid = livebox_service_appid(MUSIC_LIVEBOX); - dts_check_str_eq("livebox_service_appid", appid, MUSIC_APP, "appid is com.samsung.music-player"); -} - -static void utc_livebox_service_i18n_name_n(void) -{ - char *name; - name = livebox_service_i18n_name(NULL, NULL); - dts_check_eq("livebox_service_i18n_name", name, NULL, "name is NULL"); -} - -static void utc_livebox_service_i18n_name_p(void) -{ - char *name; - name = livebox_service_i18n_name(MUSIC_LIVEBOX, NULL); - dts_check_ne("livebox_service_i18n_name", name, NULL, "name is not NULL"); -} - -static void utc_livebox_service_privew_n(void) -{ - char *preview; - preview = livebox_service_preview(MUSIC_LIVEBOX, LB_SIZE_TYPE_1x1); - dts_check_eq("livebox_service_preview", preview, NULL, "preview is NULL"); -} - -static void utc_livebox_service_preview_p(void) -{ - char *preview; - preview = livebox_service_preview(MUSIC_LIVEBOX, LB_SIZE_TYPE_1x1); - dts_check_ne("livebox_service_preview", preview, NULL, "preview is not NULL"); -} - -static void utc_livebox_service_content_n(void) -{ - char *content; - content = livebox_service_content(NULL); - dts_check_eq("livebox_service_content", content, NULL, "content is NULL"); -} - -static void utc_livebox_service_content_p(void) -{ - char *content; - content = livebox_service_content(MUSIC_LIVEBOX); - dts_check_ne("livebox_service_content", content, NULL, "content is not NULL"); -} - -static void utc_livebox_service_i18n_icon_p(void) -{ - char *icon; - - icon = livebox_service_i18n_icon(NULL, NULL); - dts_check_eq("livebox_service_i18n_icon", icon, NULL, "icon is NULL"); -} - -static void utc_livebox_service_i18n_icon_n(void) -{ - char *icon; - - icon = livebox_service_i18n_icon(MUSIC_LIVEBOX, NULL); - dts_check_ne("livebox_service_i18n_icon", icon, NULL, "icon is not NULL"); -} - -static void utc_livebox_service_libexec_p(void) -{ - char *libexec; - libexec = livebox_service_libexec(NULL); - dts_check_eq("livebox_service_libexec", libexec, NULL, "libexec is NULL"); -} - -static void utc_livebox_service_libexec_n(void) -{ - char *libexec; - libexec = livebox_service_libexec(MUSIC_LIVEBOX); - dts_check_ne("livebox_service_libexec", libexec, NULL, "libexec is not NULL"); -} - -static void utc_livebox_service_nodisplay_p(void) -{ - int ret; - ret = livebox_service_nodisplay(NULL); - dts_check_eq("livebox_service_nodisplay", ret, 0, "nodisplay is false"); -} - -static void utc_livebox_service_nodisplay_n(void) -{ - int ret; - ret = livebox_service_nodisplay(MUSIC_LIVEBOX); - dts_check_eq("livebox_service_nodisplay", ret, 0, "nodisplay is false"); -} - -static void utc_livebox_service_abi_p(void) -{ - char *abi; - abi = livebox_service_abi(NULL); - dts_check_eq("livebox_service_abi", abi, NULL, "abi is NULL"); -} - -static void utc_livebox_service_abi_n(void) -{ - char *abi; - abi = livebox_service_abi(MUSIC_LIVEBOX); - dts_check_ne("livebox_service_abi", abi, NULL, "abi is not NULL"); -} - -static void utc_livebox_service_is_enabled_n(void) -{ - /*! - * static int livebox_service_is_enabled(const char *lbid); - * - Not implemented - */ -} - -static void utc_livebox_service_is_enabled_p(void) -{ - /*! - * static int livebox_service_is_enabled(const char *lbid); - * - Not implemented - */ -} - -static void utc_livebox_service_lb_script_path_n(void) -{ - char *lb_path; - lb_path = livebox_service_lb_script_path(NULL); - dts_check_eq("livebox_service_lb_script_path", lb_path, NULL, "lb_path is NULL"); -} - -static void utc_livebox_service_lb_script_path_p(void) -{ - char *lb_path; - lb_path = livebox_service_lb_script_path(MUSIC_LIVEBOX); - dts_check_ne("livebox_service_lb_script_path", lb_path, NULL, "lb_path is NULL"); -} - -static void utc_livebox_service_lb_script_group_n(void) -{ - char *lb_group; - lb_group = livebox_service_lb_script_group(NULL); - dts_check_ne("livebox_service_lb_script_group", lb_group, NULL, "lb_group is NULL"); -} - -static void utc_livebox_service_lb_script_group_p(void) -{ - char *lb_group; - lb_group = livebox_service_lb_script_group(MUSIC_LIVEBOX); - dts_check_ne("livebox_service_lb_script_group", lb_group, NULL, "lb_group is NULL"); -} - -static void utc_livebox_service_pd_script_path_n(void) -{ - char *pd_script; - pd_script = livebox_service_pd_script_path(NULL); - dts_check_eq("livebox_service_pd_script_path", pd_script, NULL, "pd_script is NULL"); -} - -static void utc_livebox_service_pd_script_path_p(void) -{ - char *pd_script; - pd_script = livebox_service_pd_script_path(MUSIC_LIVEBOX); - dts_check_ne("livebox_service_pd_script_path", pd_script, NULL, "pd_script is NULL"); -} - -static void utc_livebox_service_pd_script_group_p(void) -{ - char *pd_group; - pd_group = livebox_service_pd_script_group(MUSIC_LIVEBOX); - dts_check_ne("livebox_service_pd_script_group", pd_group, NULL, "pd_script is NULL"); -} - -static void utc_livebox_service_pd_script_group_n(void) -{ - char *pd_group; - pd_group = livebox_service_pd_script_group(MUSIC_LIVEBOX); - dts_check_eq("livebox_service_pd_script_group", pd_group, NULL, "pd_script is NULL"); -} - -static void utc_livebox_service_get_supported_sizes_n(void) -{ - int cnt = NR_OF_SIZE_LIST; - int w[NR_OF_SIZE_LIST]; - int h[NR_OF_SIZE_LIST]; - int ret; - - ret = livebox_service_get_supported_sizes(NULL, &cnt, w, h); - dts_check_eq("livebox_service_get_supported_sizes", ret, LB_STATUS_ERROR_INVALID, "supported sizes is 0"); -} - -static void utc_livebox_service_get_supported_sizes_p(void) -{ - int cnt = NR_OF_SIZE_LIST; - int w[NR_OF_SIZE_LIST]; - int h[NR_OF_SIZE_LIST]; - int ret; - - ret = livebox_service_get_supported_sizes(MUSIC_LIVEBOX, &cnt, w, h); - dts_check_eq("livebox_service_get_supported_sizes", ret, 0, "supported sizes is 0"); -} - -static void utc_livebox_service_get_supported_size_types_n(void) -{ - int cnt = NR_OF_SIZE_LIST; - int sizes[NR_OF_SIZE_LIST]; - int ret; - - ret = livebox_service_get_supported_size_types(NULL, &cnt, sizes); - dts_check_eq("livebox_service_get_supported_sizes", ret, LB_STATUS_ERROR_INVALID, "supported sizes is 0"); -} - -static void utc_livebox_service_get_supported_size_types_p(void) -{ - int cnt = NR_OF_SIZE_LIST; - int sizes[NR_OF_SIZE_LIST]; - int ret; - - ret = livebox_service_get_supported_size_types(MUSIC_LIVEBOX, &cnt, sizes); - dts_check_eq("livebox_service_get_supported_sizes", ret, 0, "supported sizes is 0"); -} - -static int category_cb(const char *cluster, const char *category, void *data) -{ - return 0; -} - -static void utc_livebox_service_enumerate_category_list_n(void) -{ - int ret; - ret = livebox_service_enumerate_category_list(NULL, NULL, NULL); - dts_check_eq("livebox_service_enumerate_category_list", ret, LB_STATUS_ERROR_INVALID, "invalid argument"); -} - -static void utc_livebox_service_enumerate_category_list_p(void) -{ - int ret; - ret = livebox_service_enumerate_category_list("default", category_cb, NULL); - dts_check_eq("livebox_service_enumerate_category_list", ret, LB_STATUS_ERROR_INVALID, "invalid argument"); -} - -static void utc_livebox_service_enumerate_cluster_list_n(void) -{ -//static int livebox_service_enumerate_cluster_list(int (*cb)(const char *cluster, void *data), void *data); - int ret; - ret = livebox_service_enumerate_cluster_list(NULL, NULL); - dts_check_eq("livebox_service_enumerate_cluster_list", ret, LB_STATUS_ERROR_INVALID, "invalid argument"); -} - -static void utc_livebox_service_enumerate_cluster_list_p(void) -{ - int ret; - ret = livebox_service_enumerate_cluster_list(cluster_cb, NULL); - dts_check_ne("livebox_service_enumerate_cluster_list", ret, 0, "invalid argument"); -} - -static void utc_livebox_service_init_n(void) -{ - /*! - * \note - * Unable to test initialize function - */ -} - -static void utc_livebox_service_init_p(void) -{ - int ret; - - ret = livebox_service_init(); - dts_check_eq("livebox_service_init", ret, LB_STATUS_SUCCESS, "Success"); -} - -static void utc_livebox_service_fini_n(void) -{ - /*! - * \note - * Unable to test finalize function - */ -} - -static void utc_livebox_service_fini_p(void) -{ - int ret; - ret = livebox_service_fini(); - dts_check_eq("livebox_service_fini", ret, LB_STATUS_SUCCESS, "Success"); -} - -static void utc_livebox_service_pkglist_create_n(void) -{ - /*! - * \note - * Unable to test finalize function - */ -} - -static void utc_livebox_service_pkglist_create_p(void) -{ - struct pkglist_handle *handle; - - handle = livebox_service_pkglist_create(NULL, NULL); - dts_check_ne("livebox_service_pkglist_create", handle, NULL, "Success"); -} - -static void utc_livebox_service_get_pkglist_item_n(void) -{ - char *lbid; - char *pkgname; - int prime; - int ret; - - ret = livebox_service_get_pkglist_item(NULL, &lbid, &pkgname, &prime); - dts_check_eq("livebox_service_get_pkglist_item", ret, LB_STATUS_ERROR_INVALID, "Invalid"); -} - -static void utc_livebox_service_get_pkglist_item_p(void) -{ - struct pkglist_handle *handle; - char *lbid; - char *pkgname; - int prime; - int ret; - - handle = livebox_service_pkglist_create(NULL, NULL); - ret = livebox_service_get_pkglist_item(handle, &lbid, &pkgname, &prime); - dts_check_eq("livebox_service_get_pkglist_item", ret, LB_STATUS_SUCCESS, "Success"); -} - -static void utc_livebox_service_pkglist_destroy_n(void) -{ - int ret; - - ret = livebox_service_pkglist_destroy(NULL); - dts_check_eq("livebox_service_pkglist_destroy", ret, LB_STATUS_ERROR_INVALID, "Invalid"); -} - -static void utc_livebox_service_pkglist_destroy_p(void) -{ - struct pkglist_handle *handle; - int ret; - - handle = livebox_service_pkglist_create(NULL, NULL); - ret = livebox_service_pkglist_destroy(handle); - dts_check_eq("livebox_service_pkglist_destroy", ret, LB_STATUS_ERROR_INVALID, "Invalid"); -} - -struct tet_testlist tet_testlist[] = { - { utc_livebox_service_get_size_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_size_p, POSITIVE_TC_IDX }, - { utc_livebox_service_size_type_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_size_type_p, POSITIVE_TC_IDX }, - { utc_livebox_service_mouse_event_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_mouse_event_p, POSITIVE_TC_IDX }, - { utc_livebox_service_touch_effect_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_touch_effect_p, POSITIVE_TC_IDX }, - { utc_livebox_service_need_frame_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_need_frame_p, POSITIVE_TC_IDX }, - { utc_livebox_service_trigger_update_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_trigger_update_p, POSITIVE_TC_IDX }, - { utc_livebox_service_trigger_update_with_content_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_trigger_update_with_content_p, POSITIVE_TC_IDX }, - { utc_livebox_service_change_period_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_change_period_p, POSITIVE_TC_IDX }, - { utc_livebox_service_get_pkglist_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_pkglist_p, POSITIVE_TC_IDX }, - { utc_livebox_service_get_applist_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_applist_p, POSITIVE_TC_IDX }, - { utc_livebox_service_mainappid_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_mainappid_p, POSITIVE_TC_IDX }, - { utc_livebox_service_get_pkglist_by_pkgid_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_pkglist_by_pkgid_p, POSITIVE_TC_IDX }, - { utc_livebox_service_pkgname_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_pkgname_p, POSITIVE_TC_IDX }, - { utc_livebox_service_is_primary_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_is_primary_p, POSITIVE_TC_IDX }, - { utc_livebox_service_provider_name_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_provider_name_p, POSITIVE_TC_IDX }, - { utc_livebox_service_setup_appid_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_setup_appid_p, POSITIVE_TC_IDX }, - { utc_livebox_service_appid_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_appid_p, POSITIVE_TC_IDX }, - { utc_livebox_service_i18n_name_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_i18n_name_p, POSITIVE_TC_IDX }, - { utc_livebox_service_privew_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_preview_p, POSITIVE_TC_IDX }, - { utc_livebox_service_content_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_content_p, POSITIVE_TC_IDX }, - { utc_livebox_service_content_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_i18n_icon_p, POSITIVE_TC_IDX }, - { utc_livebox_service_i18n_icon_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_libexec_p, POSITIVE_TC_IDX }, - { utc_livebox_service_libexec_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_nodisplay_p, POSITIVE_TC_IDX }, - { utc_livebox_service_nodisplay_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_abi_p, POSITIVE_TC_IDX }, - { utc_livebox_service_abi_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_is_enabled_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_is_enabled_p, POSITIVE_TC_IDX }, - { utc_livebox_service_lb_script_path_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_lb_script_path_p, POSITIVE_TC_IDX }, - { utc_livebox_service_lb_script_group_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_lb_script_group_p, POSITIVE_TC_IDX }, - { utc_livebox_service_pd_script_path_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_pd_script_path_p, POSITIVE_TC_IDX }, - { utc_livebox_service_pd_script_group_p, POSITIVE_TC_IDX }, - { utc_livebox_service_pd_script_group_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_supported_sizes_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_supported_sizes_p, POSITIVE_TC_IDX }, - { utc_livebox_service_get_supported_size_types_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_supported_size_types_p, POSITIVE_TC_IDX }, - { utc_livebox_service_enumerate_category_list_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_enumerate_category_list_p, POSITIVE_TC_IDX }, - { utc_livebox_service_enumerate_cluster_list_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_enumerate_cluster_list_p, POSITIVE_TC_IDX }, - { utc_livebox_service_init_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_init_p, POSITIVE_TC_IDX }, - { utc_livebox_service_fini_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_fini_p, POSITIVE_TC_IDX }, - { utc_livebox_service_pkglist_create_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_pkglist_create_p, POSITIVE_TC_IDX }, - { utc_livebox_service_get_pkglist_item_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_get_pkglist_item_p, POSITIVE_TC_IDX }, - { utc_livebox_service_pkglist_destroy_n, NEGATIVE_TC_IDX }, - { utc_livebox_service_pkglist_destroy_p, POSITIVE_TC_IDX }, - { NULL, 0 }, -}; - diff --git a/doc/shortcut_doc.h b/doc/shortcut_doc.h old mode 100644 new mode 100755 index 55b7c9a..2ac1878 --- a/doc/shortcut_doc.h +++ b/doc/shortcut_doc.h @@ -20,215 +20,14 @@ /** * @defgroup SHORTCUT_MODULE Shortcut - * @brief To enhance the Add to home feature. Two types of API set are supported. - * - One for the homescreen developers. - * - The others for the application developers who should implement the Add to home feature. - * @ingroup CORE_LIB_GROUP + * @brief To enhance the Add to home feature. + * - The other for the application developers who should implement the Add to home feature. + * @ingroup CAPI_APPLICATION_FRAMEWORK * @section SHORTCUT_MODULE_HEADER Required Header - * \#include + * \#include * @section SHORTCUT_MODULE_OVERVIEW Overview -

1. Shortcut

-Tizen is supporting the "add shortcut or add to home" for various applications. -Developers may use the shortcut library (libshortcut) to implement features sending (applications) and receiving (possibly home screen) shortcuts. -If home screen implements the shortcut service using the library, the applications are good to go for adding their shortcuts to the home screen(, and vice versa.) - -

2. How to add a new shortcut to the home screen

-

2.1 Add to home (From the app to home)

- -The followings are two separate APIs to support "add to home" feature. - -\code -typedef int (*result_cb_t)(int ret, int pid, void *data) - -extern int add_to_home_shortcut(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, result_cb_t result_cb, void *data) - -extern int add_to_home_livebox(const char *pkgname, const char *name, int type, const char *content, const char *icon, double period, result_cb_t result_cb, void *data) -\endcode - -Currently, our home screen can contain two different types of contents (that are pure shortcuts and liveboxes). - -To add a pure shortcut i.e., simply for launching an app, developers can use "add_to_home_shortcut" API to deliver their shortcuts to a home screen. - -If your application supports our livebox service and implments livebox type shortcut, then you can use "add_to_home_livebox" API to have a home screen add the livebox on its screen. - - - - - - - - - - - -
ParametersComment
pkgnamePackage name
nameApplication name wich will be displayed on the screen
typeBasically it describes launching options whether to use a package name or URI. LAUNCH_BY_PACKAGE or LAUNCH_BY_URI
content -Application data used for creating a pure shortcut or creating a livebox - - Shortcut - -1. if the type is Launch by package: None - -2. if the type is Launch by URI: put the URI in the content - - Livebox: any data necessary to create a livebox. Basically, it will passed to the livebox plug-in's create function. -
iconAbsolute path to the icon file, If you set this "NULL", the home screen will use the deafult icon file (but it is depends on the homescreen implementations)
period<Only for livebox> Update period. The period must be greater than 0.0f
result_cbResult callback. The callback will be called after a shortcut or livebox has been added. Don't forget to check the return value.
dataCallback data
- -

2.1.1 Supported types

-\snippet lib/include/shortcut.h Enumeration values for type of shortcuts - -

2.2 Add shortcut (Home screen retrieves shortcuts from app)

-"Add shortcut " service enables home screen to retrieve all shortcuts that applications promised to support and request an app to send their shortcuts to home directly, as opposed to "add to home". - -It is initiated by home screen as opposed to "add to home" which is initiated by an application."Add shortcut " service enables home screen to retrieve all shortcuts that applications promised to support and request an app to send their shortcuts to home directly, as opposed to "add to home". - -It is initiated by home screen as opposed to "add to home" which is initiated by an application. - -

2.2.1 Build the shortcut list DB

-\image html BuildShortcutList.png - -To recognize how many and what kinds of shortcuts have been registerred, each application who wants to support "add shortcut" service needs to install the XML file that defines "shortcut" information. -The following table describes the format and information necessary to define the shortcuts application can support. -Then, the information will be shown and used in home screen when a user selects "add shortcut" service. - - - - -
Syntax of the shortcut manifest file
-\code - -... - - - /opt/share/icons/default/small/com.samsung.myapp-shortcut.png - - - - - - - - - - - - - - - - - - - - - ... - - - /opt/share/icons/default/small/com.samsung.myapp2.png - - -... - -\endcode -
- -Install this XML file to /opt/share/packages/YOUR_PKGNAME.xml (Note: After manifest has been applied to the binary, simply copy the content to your manifest file.) -Shortcut listing application will list up these items on its screen and each item will be displayed using the string in label field. -When selected, it will launch the selected app using app service with "appid" and a bundle holding data in the pair of extra_key and extra-data fields. -Obviously, icon will be used to display visual information for given shortcut type.(that said the icon could be other than the application's default icon) - -

2.2.2 Jump to the APP

-\image html JumpToApp.png - -Shortcut listing application will launch your application using app-svc with package name and param attributes. -It will use the pkgname and param attrbute to launch your application. -Shortcut list view will launch your "[App] Shortcut list" using followed code. - - - - -
Launch your app from shortcut list viewer
-\code -service_h service; -service_create(&service); -service_set_package(service, APPID); /* */ -service_add_extra_data(service, EXTRA_KEY, EXTRA_DATA); /* */ -ret = service_send_launch_request(service, NULL, NULL); -if (ret ...) { } -service_destroy(service); -\endcode -
-When your app is launched, the app should send a selected item as a shortcut or livebox to the home screen using "add_to_home" series functions mentioned above. - -

2.2.3 What each app has to do

-You can implement your shortcut list view using App or UG. - -Who is going to handle the shortcut - -
    -
  • Handled by App -
  • App should prepare a shortcut-add view as guided
  • - -
  • Handeld by UG -
  • UG should be launched as an app and provide the shortcut-add view
  • - -
- -In your shortcut list view, you just call the "add_to_home_shortcut" or "add_to_home_livebox" which are described in the section 2.1 - -

2.2.3.1 Handled by App

-\image html ShortcutApp.png -When your application is launched by the shortcut list application (displayed on the left most of above figure). -Your application should go back to the normal view when you receive the PAUSE event. -If you didn't change the view of your application, the user will see this shortcut list view again even if the user -launches your application from the app-tray(or homescreen). -So you have to change the view from the shortcut list to the normal(or previous) view when you get the PAUSE event. - -

2.2.3.2 Handled by UG

-\image html ShortcutUG.png -In this case, the Shortcut List application will launch your UG as a process. -When you receive PAUSE event, or need to change to other view (not in the same UG), you should destroy current UG. -If you didn't destroy it, it will be reside on the process list. and it will not be destroyed automatically. - -Currently, UG container process only supporting the multiple instance for a process. -So if the user tries to add a new shortcut again from the shortcut list application, your UG will be launched again if you didn't -terminate previous UG process (when you got PAUSE event). - -

3. What the home screen should do

-\code -typedef int (*request_cb_t)(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, int pid, double period, void *data) -extern int shortcut_set_request_cb(request_cb_t request_cb, void *data) -\endcode - - - - - - - - - - - -
ParameterComment
pkgnamePackage name to be added
nameApplication name to be displayed on the screen
typeLAUNCH_BY_PACKAGE or LAUNCH_BY_URI
content_infoUsed for the livebox, or homescreen by itself if it required.
iconAbsolute path of the icon file. (If it is not exists, the homescreen can use the deafult icon file)
pidReuquestor's Process ID
periodUpdate period only for the livebox
dataCallback data
- -

4. To list up shortcuts registred in the device

- - - -
shortcut-list viewer will launch your app by this way
-\code -int shortcut_get_list(const char *pkgname, int (*cb)(const char *pkgname, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data) -\endcode -
- -If you specified the "pkgname", this API will only gathering the given Package's shortcut list. -If you set is to NULL, this API will gathering all shortcuts. -Every shortcut item will be passed via "cb" callback function. so it will be invoked N times if the number of registered shortcut item is N. -pkgname and name and param is described in the XML file of each application package. -It will returns the number of shortcut items, or return <0 as an error value. - --EIO : failed to access shortcut list DB -> 0 : Number of shortcut items (count of callback function calling) +It provides function of creating shortcut. +Developers can use the "shortcut_add_to_home" API to create their shortcut to a home screen. * */ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt old mode 100644 new mode 100755 index a0e7761..e277e96 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -18,6 +18,8 @@ pkg_check_modules(svc_pkgs REQUIRED db-util com-core vconf + capi-base-common + aul ) FOREACH(flag ${svc_pkgs_CFLAGS}) @@ -33,7 +35,6 @@ ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") ADD_LIBRARY(${PROJECT_NAME} SHARED src/main.c - src/icon.c src/dlist.c ) @@ -44,6 +45,8 @@ SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME} INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/include/shortcut.h DESTINATION include/${PROJECT_NAME}) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/include/shortcut_private.h DESTINATION include/${PROJECT_NAME}) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/include/shortcut_manager.h DESTINATION include/${PROJECT_NAME}) INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}") diff --git a/lib/include/dlist.h b/lib/include/dlist.h index cd1a421..04283eb 100644 --- a/lib/include/dlist.h +++ b/lib/include/dlist.h @@ -1,18 +1,19 @@ /* - * Copyright 2013 Samsung Electronics Co., Ltd + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Licensed under the Flora License, Version 1.1 (the "License"); + * 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://floralicense.org/license/ + * 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. - */ + * +*/ #define dlist_remove_data(list, data) do { \ struct dlist *l; \ diff --git a/lib/include/shortcut.h b/lib/include/shortcut.h old mode 100644 new mode 100755 index 14241d3..d7355a9 --- a/lib/include/shortcut.h +++ b/lib/include/shortcut.h @@ -18,227 +18,184 @@ #ifndef __SHORTCUT_H__ #define __SHORTCUT_H__ +#include +#include + #ifdef __cplusplus extern "C" { #endif /** + * @file shortcut.h + * @brief This file declares the API of the libshortcut library. + */ + +/** * @addtogroup SHORTCUT_MODULE * @{ */ -struct shortcut_icon; /** - * @brief This function prototype is used to define a callback function for the add_to_home reqeust. - * The homescreen should define a callback as this type and implementing the service code + * @internal + * @brief Called to the add_to_home request. + * @details The homescreen should define a callback as this type and implement the service code * for adding a new application shortcut. - * @param[in] appid Shortcut is added for this package. - * @param[in] name Name for created shortcut icon. - * @param[in] type 3 kinds of types are defined. - * @param[in] content_info Specific information for creating a new shortcut. - * @param[in] icon Absolute path of an icon file for this shortcut. - * @param[in] pid Process ID of who request add_to_home. - * @param[in] allow_duplicate 1 if shortcut can be duplicated or a shourtcut should be exists only one. - * @param[in] data Callback data. - * @return int Developer should returns the result of handling shortcut creation request. - * Returns 0, if succeed to handles the add_to_home request, or returns proper errno. - * @see shortcut_set_request_cb - * @pre None - * @post None - * @remarks None + * @since_tizen 2.3 + * @param[in] appid The shortcut that is added for this package + * @param[in] name The name of the created shortcut icon + * @param[in] type One of the three defined types + * @param[in] content_info The specific information for creating a new shortcut + * @param[in] icon The absolute path of an icon file for this shortcut + * @param[in] pid The process ID of who request add_to_home + * @param[in] allow_duplicate @c 1 if the shortcut can be duplicated, + * otherwise a shourtcut should exist only once + * @param[in] data The callback data + * @return The result of handling a shortcut creation request\n + * This returns @c 0 if the add_to_home request is handled successfully, + * otherwise it returns a proper errno. + * @see shortcut_set_request_cb() */ typedef int (*request_cb_t)(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, double period, int allow_duplicate, void *data); /** - * @brief This function prototype is used to define for receiving the result of add_to_home. - * @param[in] ret Result value, it could be 0 if succeed to add a shortcut, or errno. - * @param[in] pid Process ID of who handles this add_to_home request. - * @param[in] data Callback data. - * @return int Returns 0, if there is no error or returns errno. + * @brief Called to receive the result of add_to_home_shortcut(). + * @since_tizen 2.3 + * @param[in] ret The result value, it could be @c 0 if it succeeds to add a shortcut, + * otherwise it returns an errno + * @param[in] pid The process ID of who handle this add_to_home request + * @param[in] data The callback data + * @return int @c 0 if there is no error, + otherwise errno * @see add_to_home_shortcut() - * @pre None - * @post None - * @remarks None */ -typedef int (*result_cb_t)(int ret, int pid, void *data); +typedef int (*result_internal_cb_t)(int ret, int pid, void *data); /** - * @brief After send a request to create a icon snapshot image, this callback will be called with its result. - * @param[in] handle Handle of requestor - * @param[in] ret status of request - * @param[in] data Callback data - * @return int result state of callback call - * @retval 0 If it is successfully completed - * @see shortcut_icon_request_send() - * @pre None - * @post None - * @remarks None + * @brief Enumeration for shortcut types. + * @details Basically, three types of shortcuts are defined. + * Every homescreen developer should support these types of shortcuts. + * Or return a proper errno to figure out why the application failed to add a shortcut. + * #LAUNCH_BY_PACKAGE is used for adding a package itself as a shortcut. + * #LAUNCH_BY_URI is used for adding a shortcut for "uri" data. + * @since_tizen 2.3 */ -typedef int (*icon_request_cb_t)(struct shortcut_icon *handle, int ret, void *data); +enum shortcut_internal_type { + /**< Deprecated type */ + SHORTCUT_PACKAGE = 0x00000000, /**< Launch the package using the given package name */ + SHORTCUT_DATA = 0x00000001, /**< Launch the related package with the given data(content_info) */ + SHORTCUT_FILE = 0x00000002, /**< Launch the related package with the given filename(content_info) */ + + LAUNCH_BY_PACKAGE = 0x00000000, + + SHORTCUT_REMOVE = 0x40000000, /**< Remove a shortcut */ + DYNAMICBOX_REMOVE = 0x80000000, /**< Remove a dynamicbox */ + + DYNAMICBOX_TYPE_DEFAULT = 0x10000000, /**< Type mask for the default dynamicbox */ + DYNAMICBOX_TYPE_EASY_DEFAULT = 0x30000000, /**< Type mask for the easy mode dynamicbox */ + DYNAMICBOX_TYPE_1x1 = 0x10010000, /**< 1x1 */ + DYNAMICBOX_TYPE_2x1 = 0x10020000, /**< 2x1 */ + DYNAMICBOX_TYPE_2x2 = 0x10040000, /**< 2x2 */ + DYNAMICBOX_TYPE_4x1 = 0x10080000, /**< 4x1 */ + DYNAMICBOX_TYPE_4x2 = 0x10100000, /**< 4x2 */ + DYNAMICBOX_TYPE_4x3 = 0x10200000, /**< 4x3 */ + DYNAMICBOX_TYPE_4x4 = 0x10400000, /**< 4x4 */ + DYNAMICBOX_TYPE_4x5 = 0x11000000, /**< 4x5 */ + DYNAMICBOX_TYPE_4x6 = 0x12000000, /**< 4x6 */ + DYNAMICBOX_TYPE_EASY_1x1 = 0x30010000, /**< Easy mode 1x1 */ + DYNAMICBOX_TYPE_EASY_3x1 = 0x30020000, /**< Easy mode 3x2 */ + DYNAMICBOX_TYPE_EASY_3x3 = 0x30040000, /**< Easy mode 3x3 */ + DYNAMICBOX_TYPE_UNKNOWN = 0x1FFF0000, /**< Error */ +}; /** - * @brief Basically, three types of shortcut is defined. - * Every homescreen developer should support these types of shortcut. - * Or returns proper errno to figure out why the application failed to add a shortcut. - * LAUNCH_BY_PACKAGE is used for adding a package itself as a shortcut - * LAUNCH_BY_URI is used for adding a shortcut for "uri" data. + * @brief Enumeration for values of shortcut response types. + * @since_tizen 2.3 */ -//! [Enumeration values for type of shortcuts] -enum shortcut_type { - /*!< Deprecated type */ - SHORTCUT_PACKAGE = 0x00000000, /*!< Launch the package using given pakcage name. */ - SHORTCUT_DATA = 0x00000001, /*!< Launch the related package with given data(content_info). */ - SHORTCUT_FILE = 0x00000002, /*!< Launch the related package with given filename(content_info). */ - - /*!< Use these */ - LAUNCH_BY_PACKAGE = 0x00000000, /*!< Launch the package using given pakcage name. */ - LAUNCH_BY_URI = 0x00000001, /*!< Launch the related package with given data(URI). */ - - SHORTCUT_REMOVE = 0x40000000, /*!< Remove a shortcut */ - LIVEBOX_REMOVE = 0x80000000, /*!< Remove a livebox */ - - LIVEBOX_TYPE_DEFAULT = 0x10000000, /*!< Type mask for default livebox */ - LIVEBOX_TYPE_EASY_DEFAULT = 0x30000000, /*!< Type mask for easy mode livebox */ - LIVEBOX_TYPE_1x1 = 0x10010000, /*!< 1x1 */ - LIVEBOX_TYPE_2x1 = 0x10020000, /*!< 2x1 */ - LIVEBOX_TYPE_2x2 = 0x10040000, /*!< 2x2 */ - LIVEBOX_TYPE_4x1 = 0x10080000, /*!< 4x1 */ - LIVEBOX_TYPE_4x2 = 0x10100000, /*!< 4x2 */ - LIVEBOX_TYPE_4x3 = 0x10200000, /*!< 4x3 */ - LIVEBOX_TYPE_4x4 = 0x10400000, /*!< 4x4 */ - LIVEBOX_TYPE_4x5 = 0x11000000, /*!< 4x5 */ - LIVEBOX_TYPE_4x6 = 0x12000000, /*!< 4x6 */ - LIVEBOX_TYPE_EASY_1x1 = 0x30010000, /*!< Easy mode 1x1 */ - LIVEBOX_TYPE_EASY_3x1 = 0x30020000, /*!< Easy mode 3x2 */ - LIVEBOX_TYPE_EASY_3x3 = 0x30040000, /*!< Easy mode 3x3 */ - LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000 /*!< Error */ -}; -//! [Enumeration values for type of shortcuts] +enum shortcut_internal_error_e { + SHORTCUT_ERROR = 0x80000000, /**< MSB(1). Check this using the #SHORTCUT_STATUS_IS_ERROR macro */ -enum shortcut_response { - SHORTCUT_SUCCESS = 0x00000000, /*!< Successfully handled */ - SHORTCUT_ERROR = 0x80000000, /*!< MSB(1). Check this using SHORTCUT_STATUS_IS_ERROR macro */ - SHORTCUT_ERROR_NO_SPACE = SHORTCUT_ERROR | 0x0001, /*!< There is no space to add new shortcut */ - SHORTCUT_ERROR_EXIST = SHORTCUT_ERROR | 0x0002, /*!< Shortcut is already added */ - SHORTCUT_ERROR_FAULT = SHORTCUT_ERROR | 0x0004, /*!< Failed to add a shortcut. Unrecoverable error */ - SHORTCUT_ERROR_UNSUPPORTED = SHORTCUT_ERROR | 0x0008, /*!< Unsupported shortcut */ - SHORTCUT_ERROR_BUSY = SHORTCUT_ERROR | 0x0010, /*!< Receiver is busy, try again later */ - SHORTCUT_ERROR_INVALID = SHORTCUT_ERROR | 0x0020, /*!< Shortcut request is not valid, invalid parameter or invalid argument value */ - SHORTCUT_ERROR_COMM = SHORTCUT_ERROR | 0x0040, /*!< Connection is not estabilished. or there is a problem of communication */ - SHORTCUT_ERROR_MEMORY = SHORTCUT_ERROR | 0x0080, /*!< Memory is not enough to handle new request */ - SHORTCUT_ERROR_IO = SHORTCUT_ERROR | 0x0100, /*!< Unable to access file or DB. Check your resource files */ - SHORTCUT_ERROR_PERMISSION = SHORTCUT_ERROR | 0x0200, /*!< Has no permission to add a shortcut */ + SHORTCUT_STATUS_CARED = 0x08000000, /**< Shortcut status is already cared. Check this using the #SHORTCUT_STATUS_IS_CARED macro */ - SHORTCUT_STATUS_CARED = 0x08000000 /*!< Shortcut status is already cared. check this using SHORTCUT_STATUS_IS_CARED macro */ + SHORTCUT_ERROR_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Receiver is busy, try again later */ + SHORTCUT_ERROR_UNSUPPORTED = SHORTCUT_ERROR | 0x0400 /**< Shortcut is not supported */ }; -/*! - * \brief Macro function for checking the type - * \param[in] type Type of box - * \return bool - * \retval true(1) If it is a livebox - * \retval false(0) if it is not a livebox - * \see shortcut_type - * \pre None - * \post None - * \remarks None - */ -#define ADD_TO_HOME_IS_LIVEBOX(type) (!!((type) & 0x10000000)) - -/*! - * \brief Macro function for checking the request type - * \param[in] type Request type - * \return bool - * \retval true(1) Shortcut remove request - * \retval false(0) Not a remove request - * \see shortcut_type - * \pre None - * \post None - * \remarks None - */ -#define ADD_TO_HOME_IS_REMOVE_SHORTCUT(type) (!!((type) & SHORTCUT_REMOVE)) - -/*! - * \brief Macro function for checking the request type - * \param[in] type Request type - * \return bool - * \retval true(1) Livebox remove request - * \retval false(0) Not a remove request - * \see shortcut_type - * \pre None - * \post None - * \remarks None +/** + * @brief Definition for a macro to check type. + * @since_tizen 2.3 + * @param[in] type The type of box + * @return bool + * @retval true(1) If it is a dynamicbox + * @retval false(0) If it is not a dynamicbox + * @see shortcut_type */ -#define ADD_TO_HOME_IS_REMOVE_LIVEBOX(type) (!!((type) & LIVEBOX_REMOVE)) +#define ADD_TO_HOME_IS_DYNAMICBOX(type) (!!((type) & 0x10000000)) -/*! - * \brief Macro function for checking the status of request - * \param[in] type Status - * \return bool - * \retval true(1) Error - * \retval false(0) Not an error - * \see shortcut_response - * \pre None - * \post None - * \remarks None +/** + * @brief Definition for a macro to check the request status. + * @since_tizen 2.3 + * @param[in] type The status + * @return bool + * @retval true(1) Error + * @retval false(0) Not an error + * @see shortcut_error_e */ #define SHORTCUT_STATUS_IS_ERROR(type) (!!((type) & SHORTCUT_ERROR)) -/*! - * \brief Macro function for checking the status of request - * \param[in] type Status - * \return bool - * \retval true(1) Shortcut request is already handled by requestee (homescreen, viewer, ...) - * \retval false(0) Request result should be cared by requestor - * \see shortcut_response - * \pre None - * \post None - * \remarks None +/** + * @brief Definition for a macro to check the request status. + * @since_tizen 2.3 + * @param[in] type The status + * @return bool + * @retval true(1) Shortcut request is already handled by the requestee (homescreen, viewer, ...) + * @retval false(0) Request result should be cared by the requestor + * @see shortcut_error_e */ #define SHORTCUT_STATUS_IS_CARED(type) (!!((type) & SHORTCUT_STATUS_CARED)) -/*! - * \brief Filtering the pure error code from given status - * \param[in] status status - * \return status code (error) - * \see shortcut_response - * \pre None - * \post None - * \remarks None - * +/** + * @brief Definition for filtering the pure error code from the given status. + * @since_tizen 2.3 + * @param[in] status The status + * @return The status code (error) + * @see shortcut_error_e */ #define SHORTCUT_ERROR_CODE(status) ((status) & ~SHORTCUT_STATUS_CARED) /** - * @fn int shortcut_set_request_cb(request_cb_t request_cb, void *data) * - * @brief Homescreen should use this function to service the shortcut creating request. + * @internal + * + * @brief Supports the shortcut creating request. * - * @par Sync (or) Async: + * @details + * Sync (or) Async: * This is an asynchronous API. * - * @par Important Notes: - * - Should be used from the homescreen. - * - Should check the return value of this function + * Important Notes: \n + * Should be used from the homescreen.\n + * Should check the return value of this function. * - * @param[in] request_cb Callback function pointer which will be invoked when add_to_home is requested. - * @param[in] data Callback data to deliver to the callback function. + * Prospective Clients: + * Homescreen. * - * @return Return Type (int) - * - 0 - callback function is successfully registered - * - < 0 - Failed to register the callback function for request. + * @since_tizen 2.3 * - * @see request_cb_t + * @privlevel public + * @privilege %http://tizen.org/privilege/shortcut * - * @pre - You have to prepare a callback function + * @param[in] request_cb The callback function pointer that is invoked when add_to_home is requested + * @param[in] data The callback data to deliver to the callback function * - * @post - If a request is sent from the application, the registered callback will be invoked. + * @return The return type (int) + * @retval 0 Callback function is successfully registered + * @retval <0 Failed to register the callback function for the request * - * @remarks - None + * @pre You have to prepare a callback function. * - * @par Prospective Clients: - * Homescreen + * @post If a request is sent from the application, the registered callback will be invoked. * + * @see request_cb_t * @par Example * @code * #include @@ -271,46 +228,52 @@ enum shortcut_response { extern int shortcut_set_request_cb(request_cb_t request_cb, void *data); /** - * @fn add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data) * - * @brief The application, which supporting the add_to_home feature, should invoke this. + * @brief Supports the add_to_home feature, should invoke this. * - * @par Sync (or) Async: + * @details + * Sync (or) Async: * This is an asynchronous API. * - * @par Important Notes: - * - Application must check the return value of this function. - * - Application must check the return status from the callback function - * - Application should set the callback function to get the result of this request. + * Important Notes:\n + * Application must check the return value of this function.\n + * Application must check the return status from the callback function.\n + * Application should set the callback function to get the result of this request. * - * @param[in] appid Package name of owner of this shortcut. - * @param[in] name Name for created shortcut icon. - * @param[in] type Type of shortcuts (livebox or shortcut, and its size if it is for the livebox) - * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut. - * @param[in] icon Absolute path of an icon file - * @param[in] allow_duplicate set 1 If accept the duplicated shortcut or 0 - * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer. - * @param[in] data Callback data which will be used in callback function + * Prospective Clients: + * Inhouse Apps. * - * @return Return Type (int) - * \retval 0 Succeed to send the request - * \retval SHORTCUT_ERROR_FAULT Unrecoverable error - * \retval SHORTCUT_ERROR_INVALID Shortcut request is not valid, invalid parameter or invalid argument value - * \retval SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication - * \retval SHORTCUT_ERROR_MEMORY Memory is not enough to handle new request - * \retval SHORTCUT_ERROR_IO Unable to access file or DB. Check your resource files - * \retval SHORTCUT_ERROR_PERMISSION Has no permission to add a shortcut + * @since_tizen 2.3 * - * @see result_cb_t + * @privlevel public + * @privilege %http://tizen.org/privilege/shortcut * - * @pre You have to prepare the callback function + * @remarks If a homescreen does not support this feature, you will get a proper error code. + * @param[in] appid The package name of the owner of this shortcut + * @param[in] name The name of the created shortcut icon + * @param[in] type The type of shortcuts (dynamicbox or shortcut, and its size if it is for the dynamicbox) + * @param[in] content_info The specific information for delivering to the viewer for creating a shortcut + * @param[in] icon The absolute path of an icon file + * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut, + * otherwise @c 0 + * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer + * @param[in] data The callback data that is used in the callback function * - * @post You have to check the return status from callback function which is passed by argument. + * @return The return type (int) + * @retval 0 Succeeded to send the request + * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error + * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value + * @retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem in the communication + * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle a new request + * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB. Check your resource files + * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut + * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Shortcut is not supported * - * @remarks - If a homescreen does not support this feature, you will get proper error code. + * @pre You have to prepare the callback function. * - * @par Prospective Clients: - * Inhouse Apps. + * @post You have to check the return status from the callback function which is passed by the argument. + * + * @see result_internal_cb_t * * @par Example * @code @@ -329,7 +292,7 @@ extern int shortcut_set_request_cb(request_cb_t request_cb, void *data); * * static int app_create(void *data) * { - * add_to_home_shortcut("com.samsung.gallery", "With friends", + * add_to_home_shortcut("org.tizen.gallery", "With friends", * LAUNCH_BY_URI, "gallery:0000-0000", * "/opt/media/Pictures/Friends.jpg", 0, result_cb, NULL); * return 0; @@ -342,89 +305,98 @@ extern int shortcut_set_request_cb(request_cb_t request_cb, void *data); * * @endcode */ -extern int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data); +extern int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, int allow_duplicate, result_internal_cb_t result_cb, void *data); /** - * @fn shortcut_get_list(const char *appid, int (*cb)(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data) * - * @brief Getting the installed shortcut view list + * @internal + * + * @brief Gets the installed shortcut view list. * - * @par Sync (or) Async: + * @details + * Sync (or) Async: * This is a synchronous API. * - * @par Important Notes: - * - Application must check the return value of this function. - * - Application must check the return status from the callback function - * - Application should set the callback function to get the result of this request. + * Important Notes:\n + * Application must check the return value of this function.\n + * Application must check the return status from the callback function.\n + * Application should set the callback function to get the result of this request. * - * @param[in] appid Package name - * @param[in] cb Callback function to get the shortcut item information - * @param[in] data Callback data which will be used in callback function + * Prospective Clients: + * Inhouse Apps. * - * @return Return Type (int) - * \retval Number of items (call count of callback function) - * \retval SHORTCUT_ERROR_FAULT Unrecoverable error - * \retval SHORTCUT_ERROR_IO Unable to access file or DB. Check your resource files + * @since_tizen 2.3 * - * @see result_cb_t + * @privlevel public + * @privilege %http://tizen.org/privilege/shortcut * - * @pre You have to prepare the callback function + * @remarks If a homescreen does not support this feature, you will get a proper error code. + * @param[in] appid The package name + * @param[in] cb The callback function to get the shortcut item information + * @param[in] data The callback data that is used in the callback function * - * @post You have to check the return status from callback function which is passed by argument. + * @return The return type (int) + * @retval @c N Number of items (call count of the callback function) + * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error + * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB. Check your resource files * - * @remarks - If a homescreen does not support this feature, you will get proper error code. + * @pre You have to prepare the callback function. * - * @par Prospective Clients: - * Inhouse Apps. + * @post You have to check the return status from the callback function which is passed by the argument. * - * @par Example - * @code - * @endcode + * @see result_internal_cb_t */ extern int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data); /** - * @fn add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data); * - * @brief The application, which supporting the add_to_home feature, should invoke this. * - * @par Sync (or) Async: + * @brief Supports the add_to_home feature, should invoke this. + * + * @details + * Sync (or) Async: * This is an asynchronous API. * - * @par Important Notes: - * - Application must check the return value of this function. - * - Application must check the return status from the callback function - * - Application should set the callback function to get the result of this request. + * Important Notes:\n + * Application must check the return value of this function.\n + * Application must check the return status from the callback function.\n + * Application should set the callback function to get the result of this request. * - * @param[in] appid Package name of owner of this shortcut. - * @param[in] name Name for created shortcut icon. - * @param[in] type Type of shortcuts (livebox or shortcut, and its size if it is for the livebox) - * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut. - * @param[in] icon Absolute path of an icon file - * @param[in] period Update period - * @param[in] allow_duplicate set 1 If accept the duplicated shortcut or 0 - * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer. - * @param[in] data Callback data which will be used in callback function + * Prospective Clients: + * Inhouse Apps. * - * @return Return Type (int) - * \retval 0 Succeed to send the request - * \retval SHORTCUT_ERROR_FAULT Unrecoverable error - * \retval SHORTCUT_ERROR_INVALID Shortcut request is not valid, invalid parameter or invalid argument value - * \retval SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication - * \retval SHORTCUT_ERROR_MEMORY Memory is not enough to handle new request - * \retval SHORTCUT_ERROR_IO Unable to access file or DB. Check your resource files - * \retval SHORTCUT_ERROR_PERMISSION Has no permission to add a shortcut + * @since_tizen 2.3 * - * @see result_cb_t + * @privlevel public + * @privilege %http://tizen.org/privilege/shortcut * - * @pre You have to prepare the callback function + * @remarks If a homescreen does not support this feature, you will get a proper error code. + * @param[in] appid The package name of the owner of this shortcut + * @param[in] name The name of the created shortcut icon + * @param[in] type The type of shortcuts (dynamicbox or shortcut, and its size if it is for the dynamicbox) + * @param[in] content_info The specific information for delivering to the viewer for creating a shortcut + * @param[in] icon The absolute path of an icon file + * @param[in] period The update period + * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut, + * otherwise @c 0 + * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer + * @param[in] data The callback data that is used in the callback function * - * @post You have to check the return status from callback function which is passed by argument. + * @return The return type (int) + * @retval 0 Succeeded to send the request + * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error + * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value + * @retval #SHORTCUT_ERROR_COMM Connection is not established or there is a problem in the communication + * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle a new request + * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB Check your resource files + * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut + * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Shortcut is not supported * - * @remarks - If a homescreen does not support this feature, you will get proper error code. + * @pre You have to prepare the callback function. * - * @par Prospective Clients: - * Inhouse Apps. + * @post You have to check the return status from the callback function which is passed by the argument. + * + * @see result_internal_cb_t * * @par Example * @code @@ -443,7 +415,7 @@ extern int shortcut_get_list(const char *appid, int (*cb)(const char *appid, con * * static int app_create(void *data) * { - * add_to_home_livebox("com.samsung.gallery.livebox", "With friends", + * add_to_home_dynamicbox("org.tizen.gallery.dynamicbox", "With friends", * LAUNCH_BY_URI, "gallery:0000-0000", * "/opt/media/Pictures/Friends.jpg", -1.0f, 0, result_cb, NULL); * return 0; @@ -456,218 +428,14 @@ extern int shortcut_get_list(const char *appid, int (*cb)(const char *appid, con * * @endcode */ -extern int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data); - -extern int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_cb_t result_cb, void *data); - -extern int add_to_home_remove_livebox(const char *appid, const char *name, result_cb_t result_cb, void *data); - - - -/*! - * \note - * Example) - * - * \code - * static int init_cb(int status, void *data) - * { - * printf("Initializer returns: %d\n", status); - * if (status == 0) { - * printf("Succeed to initialize\n"); - * } else { - * printf("Failed to initialize: %d\n", status); - * } - * } - * - * int main(int argc, char *argv[]) - * { - * // Initialize the service request - * int ret; - * - * // After the init_cb is called, you can use below functions. - * struct shortcut_icon *handle; - * - * ret = shortcut_icon_init(init_cb, NULL); - * if (ret < 0) { - * ... - * - * // Create request for creating shortcut icon. - * handle = shortcut_icon_create(); - * if (!handle) { - * ... - * } - * - * // Send the request to the shortcut service - * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, "icon, "/usr/share/.../icon.png", NULL, NULL); - * if (ret < 0) { - * ... - * } - * - * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, "text, "app icon", NULL, NULL); - * if (ret < 0) { - * ... - * } - * - * ret = shortcut_icon_request_send(handle, LB_SIZE_TYPE_1x1, NULL, NULL, "/opt/usr/apps/com.samsung.cluster-home/data/out.png", result_cb, NULL); - * if (ret < 0) { - * ... - * } - * - * ret = shortcut_icon_request_destroy(handle); - * if (ret < 0) { - * ... - * } - * - * // Don't finalize the icon service if you don't get result callbacks of all requests - * ret = shortcut_icon_fini(); - * if (ret < 0) { - * ... - * } - * - * return 0; - * } - * \endcode - */ - -#define DEFAULT_ICON_PART "icon" -#define DEFAULT_NAME_PART "name" -#define SHORTCUT_ICON_TYPE_IMAGE "image" -#define SHORTCUT_ICON_TYPE_TEXT "text" -#define SHORTCUT_ICON_TYPE_SCRIPT "script" - -/*! - * \brief Initialize the icon creation service - * \remarks N/A - * \details N/A - * \param[in] init_cb Initialized result will be delievered via this callback - * \param[in] data Callback data - * \pre N/A - * \post N/A - * \return int - * \retval SHORTCUT_ERROR_INVALID Already initialized - * \retval SHORTCUT_ERROR_SUCCESS Successfully initialized - * \see shortcut_icon_service_fini - */ -extern int shortcut_icon_service_init(int (*init_cb)(int status, void *data), void *data); - -/*! - * \brief Finalize the icon creation service - * \remarks N/A - * \details N/A - * \pre N/A - * \post N/A - * \return int - * \retval SHORTCUT_SUCCESS Successfully initialized - * \retval SHORTCUT_ERROR_INVALID icon service is not initialized - * \see shortcut_icon_service_init - */ -extern int shortcut_icon_service_fini(void); - -/*! - * \brief Create a request object to create a new icon image - * \remarks N/A - * \details N/A - * \pre N/A - * \post N/A - * \return struct shortcut_icon * - * \retval NULL If it fails to create a new handle - * \retval pointer Handle address - * \see shortcut_icon_request_destroy - */ -extern struct shortcut_icon *shortcut_icon_request_create(void); - -/*! - * \brief Set infomration for creating icon image - * \details N/A - * \remarks N/A - * \param[in] handle Request handle - * \param[in] id Target ID to be affected by this data - * \param[in] type SHORTCUT_ICON_TYPE_IMAGE, SHORTCUT_ICON_TYPE_TEXT, SHORTCUT_ICON_TYPE_SCRIPT can be used - * \param[in] part Target part to be affect by this data - * \param[in] data type == IMAGE ? Image file path : type == TEXT ? text string : type == SCRIPT ? script file path : N/A - * \param[in] option Image load option or group name of script file to be loaded - * \param[in] subid ID for script. this ID will be used as "id" - * \pre N/A - * \post N/A - * \return int - * \retval Index of data set - * \retval SHORTCUT_ERROR_INVALID Invalid handle - * \retval SHORTCUT_ERROR_MEMORY Out of memory - * \see shortcut_icon_request_create - */ -extern int shortcut_icon_request_set_info(struct shortcut_icon *handle, const char *id, const char *type, const char *part, const char *data, const char *option, const char *subid); - -/*! - * \brief Send request to create an icon image - * \remarks N/A - * \details N/A - * \param[in] handle Icon request handle - * \param[in] size_type Size type to be created - * \param[in] layout layout filename (edje filename) - * \param[in] group group name - * \param[in] outfile output image filename - * \param[in] result_cb Result callback - * \param[in] data Callback data - * \pre N/A - * \post N/A - * \return int - * \retval SHORTCUT_ERROR_INVALID Invalid parameters - * \retval SHORTCUT_ERROR_MEMORY Out of memory - * \retval SHORTCUT_ERROR_FAULT Failed to send a request - * \retval SHORTCUT_SUCCESS Successfully sent - * \see shortcut_icon_service_fini - */ -extern int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type, const char *layout, const char *group, const char *outfile, icon_request_cb_t result_cb, void *data); - -/*! - * \brief Destroy handle of creating shortcut icon request - * \remarks N/A - * \details N/A - * \param[in] handle Shortcut request handle - * \pre N/A - * \post N/A - * \return int - * \retval SHORTCUT_ERROR_INVALID Invalid handle - * \retval SHORTCUT_SUCCESS Successfully destroyed - * \see shortcut_icon_service_fini - */ -extern int shortcut_icon_request_destroy(struct shortcut_icon *handle); - - -/*! - * \brief Set private data to the handle to carry it with a handle. - * \remarks N/A - * \details N/A - * \param[in] handle Handle to be used for carrying a data - * \param[in] data Private data - * \pre N/A - * \post N/A - * \return int - * \retval SHORTCUT_ERROR_INVALID Invalid handle - * \retval SHORTCUT_SUCCESS Successfully done - * \see shortcut_icon_service_fini - */ -extern int shortcut_icon_request_set_data(struct shortcut_icon *handle, void *data); +extern int add_to_home_dynamicbox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_internal_cb_t result_cb, void *data); -/*! - * \brief Get the private data from handle - * \remarks N/A - * \details N/A - * \param[in] handle - * \pre N/A - * \post N/A - * \return int - * \retval NULL If there is no data - * \retval pointer data pointer - * \see shortcut_icon_request_set_data +/** + * @} */ -extern void *shortcut_icon_request_data(struct shortcut_icon *handle); #ifdef __cplusplus } #endif #endif -/* @} - * End of a file - */ diff --git a/lib/include/shortcut_internal.h b/lib/include/shortcut_internal.h deleted file mode 100644 index e3186f6..0000000 --- a/lib/include/shortcut_internal.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 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. - * -*/ - -#if !defined(FLOG) -#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) -#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) -#else -extern FILE *__file_log_fp; -#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) - -#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) -#endif - -#define EAPI __attribute__((visibility("default"))) - -#if !defined(VCONFKEY_MASTER_STARTED) -#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started" -#endif - -#define DEFAULT_ICON_LAYOUT "" -#define DEFAULT_ICON_GROUP "" - -/* End of a file */ diff --git a/lib/include/shortcut_manager.h b/lib/include/shortcut_manager.h new file mode 100755 index 0000000..5cbab0b --- /dev/null +++ b/lib/include/shortcut_manager.h @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2000 - 2013 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. + * +*/ + +#ifndef __SHORTCUT_MANAGER_H__ +#define __SHORTCUT_MANAGER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file shortcut_manager.h + * @brief This file declares the API of the libshortcut library. + */ + +/** + * @addtogroup SHORTCUT_MODULE + * @{ + */ + +/** + * @brief Called to receive the result of shortcut_add_to_home(). + * @since_tizen 2.3 + * @param[in] ret The result value, it could be @c 0 if it succeeds to add a shortcut, + * otherwise it returns an errno + * @param[in] data The callback data + * @return int @c 0 if there is no error, + otherwise errno + * @see shortcut_add_to_home() + */ +typedef int (*result_cb_t)(int ret, void *data); + +/** + * @brief Enumeration for shortcut types. + * @details Basically, two types of shortcuts are defined. + * Every homescreen developer should support these types of shortcuts. + * Or return a proper errno to figure out why the application failed to add a shortcut. + * #LAUNCH_BY_APP is used for adding a package itself as a shortcut. + * #LAUNCH_BY_URI is used for adding a shortcut for "uri" data. + * @since_tizen 2.3 + */ +typedef enum _shortcut_type { + /**< Use these */ + LAUNCH_BY_APP = 0x00000000, /**< Launch the application itself */ + LAUNCH_BY_URI = 0x00000001, /**< Launch the application with the given data(URI) */ +} shortcut_type; + +/** + * @brief Enumeration for values of shortcut response types. + * @since_tizen 2.3 + */ +enum shortcut_error_e { + SHORTCUT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successfully handled */ + SHORTCUT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Shortcut request is not valid, invalid parameter or invalid argument value */ + SHORTCUT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Memory is not enough to handle a new request */ + SHORTCUT_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Unable to access the file or DB. Check your resource files */ + SHORTCUT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Has no permission to add a shortcut */ + SHORTCUT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported shortcut */ + SHORTCUT_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Receiver is busy, try again later */ + SHORTCUT_ERROR_NO_SPACE = TIZEN_ERROR_SHORTCUT | 0x0001, /**< There is no space to add a new shortcut */ + SHORTCUT_ERROR_EXIST = TIZEN_ERROR_SHORTCUT | 0x0002, /**< Shortcut is already added */ + SHORTCUT_ERROR_FAULT = TIZEN_ERROR_SHORTCUT | 0x0004, /**< Failed to add a shortcut. Unrecoverable error */ + SHORTCUT_ERROR_COMM = TIZEN_ERROR_SHORTCUT | 0x0040 /**< Connection is not established. or there is a problem in the communication */ +}; + +/** + * + * @brief Supports the add_to_home feature, should invoke this. + * + * @details + * Sync (or) Async: + * This is an asynchronous API. + * + * @since_tizen 2.3 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/shortcut + * + * @remarks Application must check the return value of this function.\n + * Application must check the return status from the callback function.\n + * Application should set the callback function to get the result of this request. + * @remarks If a homescreen does not support this feature, you will get a proper error code. + * + * @param[in] name The name of the created shortcut icon + * @param[in] type The type of shortcuts + * @param[in] uri The specific information for delivering to the viewer for creating a shortcut + * @param[in] icon The absolute path of an icon file + * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut, + * otherwise @c 0 + * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer + * @param[in] data The callback data that is used in the callback function + * + * @return @c 0 on success, otherwise a negative error value + * @retval #SHORTCUT_ERROR_NONE Successful + * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #SHORTCUT_ERROR_IO_ERROR I/O error + * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Permission denied + * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Not supported + * @retval #SHORTCUT_ERROR_RESOURCE_BUSY Device or resource busy + * @retval #SHORTCUT_ERROR_NO_SPACE No space + * @retval #SHORTCUT_ERROR_EXIST Already exist + * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error + * @retval #SHORTCUT_ERROR_COMM Connection failed + * + * @pre You have to prepare the callback function. + * + * @post You have to check the return status from the callback function which is passed by the argument. + * + * @see result_cb_t + * + * @par Example + * @code + * + * #include + * #include + * + * static int result_cb(int ret, int pid, void *data) + * { + * if (ret < 0) + * printf("Failed to add a shortcut: %s\n", perror(ret)); + * + * printf("Processed by the %d\n", pid); + * return 0; + * } + * + * static int app_create(void *data) + * { + * char* data_path = app_get_data_path(); + * int path_len = strlen(data_path)+10; + * char * path = malloc(path_len); + * memset(path, 0, path_len); + * strncat(path, data_path, path_len); + * strncat(path, "Friend.jpg", path_len); + * + * shortcut_add_to_home("With friends", + * LAUNCH_BY_URI, "gallery:0000-0000", + * path, 0, result_cb, NULL); + * free(path); + * + * return 0; + * } + * + * int main(int argc, char *argv[]) + * { + * appcore.... + * } + * + * @endcode + */ +extern int shortcut_add_to_home(const char *name, shortcut_type type, const char *uri, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/include/shortcut_private.h b/lib/include/shortcut_private.h new file mode 100755 index 0000000..5edf43e --- /dev/null +++ b/lib/include/shortcut_private.h @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2000 - 2013 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. + * +*/ + +#if !defined(FLOG) +#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) +#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) +#else +extern FILE *__file_log_fp; +#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) + +#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#endif + +#if !defined(EAPI) +#define EAPI __attribute__((visibility("default"))) +#endif + +#if !defined(VCONFKEY_MASTER_STARTED) +#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started" +#endif + +#define DEFAULT_ICON_LAYOUT "" +#define DEFAULT_ICON_GROUP "" + +/** + * @brief Definition for a macro to check the request type. + * @since_tizen 2.3 + * @param[in] type Request type + * @return bool + * @retval true(1) Shortcut remove request + * @retval false(0) Not a remove request + * @see shortcut_type + */ +#define ADD_TO_HOME_IS_REMOVE_SHORTCUT(type) (!!((type) & SHORTCUT_REMOVE)) + +/** + * @brief Definition for a macro to check the request type. + * @since_tizen 2.3 + * @param[in] type Request type + * @return bool + * @retval true(1) Dynamicbox remove request + * @retval false(0) Not a remove request + * @see shortcut_type + */ +#define ADD_TO_HOME_IS_REMOVE_DYNAMICBOX(type) (!!((type) & DYNAMICBOX_REMOVE)) + +/** + * + * + * @brief The application, which supporting the add_to_home feature, should invoke this. + * + * @details + * Sync (or) Async: + * This is an asynchronous API. + * + * Important Notes:\n + * Application must check the return value of this function.\n + * Application must check the return status from the callback function\n + * Application should set the callback function to get the result of this request. + * + * Prospective Clients: + * Inhouse Apps. + * + * @since_tizen 2.3 + * + * @remarks - If a homescreen does not support this feature, you will get proper error code. + * @param[in] appid Package name of owner of this shortcut. + * @param[in] name Name for created shortcut icon. + * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut. + * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer. + * @param[in] data Callback data which will be used in callback function + * + * @return Return Type (int) + * \retval 0 Succeed to send the request + * \retval #SHORTCUT_ERROR_FAULT Unrecoverable error + * \retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value + * \retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication + * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request + * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files + * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut + * + * @pre You have to prepare the callback function + * + * @post You have to check the return status from callback function which is passed by argument. + * + * @see result_internal_cb_t + * + * @par Example + * @code + * + * #include + * #include + * + * static int result_cb(int ret, int pid, void *data) + * { + * if (ret < 0) + * printf("Failed to add a shortcut: %s\n", perror(ret)); + * + * printf("Processed by the %d\n", pid); + * return 0; + * } + * + * static int app_create(void *data) + * { +5 * add_to_home_remove_shortcut("org.tizen.gallery.dynamicbox", "With friends", + * "gallery:0000-0000", + * result_cb, NULL); + * return 0; + * } + * + * int main(int argc, char *argv[]) + * { + * appcore.... + * } + * + * @endcode + */ +extern int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_internal_cb_t result_cb, void *data); + +/** + * + * + * @brief The application, which supporting the add_to_home feature, should invoke this. + * + * @details + * Sync (or) Async: + * This is an asynchronous API. + * + * Important Notes:\n + * Application must check the return value of this function.\n + * Application must check the return status from the callback function\n + * Application should set the callback function to get the result of this request. + * + * Prospective Clients: + * Inhouse Apps. + * + * @since_tizen 2.3 + * + * @remarks - If a homescreen does not support this feature, you will get proper error code. + * @param[in] appid Package name of owner of this shortcut. + * @param[in] name Name for created shortcut icon. + * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer. + * @param[in] data Callback data which will be used in callback function + * + * @return Return Type (int) + * \retval 0 Succeed to send the request + * \retval #SHORTCUT_ERROR_FAULT Unrecoverable error + * \retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value + * \retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication + * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request + * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files + * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut + * + * @pre You have to prepare the callback function + * + * @post You have to check the return status from callback function which is passed by argument. + * + * @see result_internal_cb_t + * + * @par Example + * @code + * + * #include + * #include + * + * static int result_cb(int ret, int pid, void *data) + * { + * if (ret < 0) + * printf("Failed to add a shortcut: %s\n", perror(ret)); + * + * printf("Processed by the %d\n", pid); + * return 0; + * } + * + * static int app_create(void *data) + * { + * add_to_home_remove_dynamicbox("org.tizen.gallery.dynamicbox", "With friends", result_cb, NULL); + * return 0; + * } + * + * int main(int argc, char *argv[]) + * { + * appcore.... + * } + * + * @endcode + */ +extern int add_to_home_remove_dynamicbox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data); + +/* End of a file */ diff --git a/lib/shortcut.pc.in b/lib/shortcut.pc.in old mode 100644 new mode 100755 index 8daf96d..060e119 --- a/lib/shortcut.pc.in +++ b/lib/shortcut.pc.in @@ -6,5 +6,6 @@ includedir=@INCLUDEDIR@ Name: shortcut Description: shortcut server platform library Version: @VERSION@ +Requires: capi-base-common Libs: -L${libdir} -lshortcut Cflags: -I${includedir} diff --git a/lib/src/dlist.c b/lib/src/dlist.c index 3ae571b..a92912c 100644 --- a/lib/src/dlist.c +++ b/lib/src/dlist.c @@ -1,18 +1,19 @@ /* - * Copyright 2013 Samsung Electronics Co., Ltd + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Licensed under the Flora License, Version 1.1 (the "License"); + * 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://floralicense.org/license/ + * 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. - */ + * +*/ #include #include diff --git a/lib/src/icon.c b/lib/src/icon.c deleted file mode 100644 index 8685f89..0000000 --- a/lib/src/icon.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 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. - * -*/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "shortcut_internal.h" -#include "shortcut.h" -#include "dlist.h" - - - -#define CREATED 0x00BEEF00 -#define DESTROYED 0x00DEAD00 - -static struct info { - int fd; - int (*init_cb)(int status, void *data); - void *cbdata; - int initialized; - - const char *utility_socket; - - struct dlist *pending_list; -#if defined(_USE_ECORE_TIME_GET) - clockid_t type; -#endif -} s_info = { - .fd = -1, - .init_cb = NULL, - .cbdata = NULL, - .initialized = 0, - - .utility_socket = "/tmp/.utility.service", - .pending_list = NULL, -#if defined(_USE_ECORE_TIME_GET) - .type = CLOCK_MONOTONIC, -#endif -}; - - - -struct request_item { - struct shortcut_icon *handle; - icon_request_cb_t result_cb; - void *data; -}; - - - -struct pending_item { - struct request_item *item; - struct packet *packet; -}; - - - -struct block { - unsigned int idx; - - char *type; - char *part; - char *data; - char *option; - char *id; - char *target_id; -}; - - - -struct shortcut_icon { - unsigned int state; - struct shortcut_desc *desc; - int refcnt; - void *data; -}; - - - -struct shortcut_desc { - int for_pd; - - unsigned int last_idx; - - struct dlist *block_list; -}; - - - -static inline void delete_block(struct block *block) -{ - DbgPrint("Release block: %p\n", block); - free(block->type); - free(block->part); - free(block->data); - free(block->option); - free(block->id); - free(block->target_id); - free(block); -} - - - -static inline int shortcut_icon_desc_close(struct shortcut_desc *handle) -{ - struct dlist *l; - struct dlist *n; - struct block *block; - - dlist_foreach_safe(handle->block_list, l, n, block) { - handle->block_list = dlist_remove(handle->block_list, l); - delete_block(block); - } - - free(handle); - return 0; -} - - - -static inline struct shortcut_icon *shortcut_icon_request_unref(struct shortcut_icon *handle) -{ - handle->refcnt--; - DbgPrint("Handle: refcnt[%d]\n", handle->refcnt); - - if (handle->refcnt == 0) { - handle->state = DESTROYED; - shortcut_icon_desc_close(handle->desc); - free(handle); - handle = NULL; - } - - return handle; -} - - - -static inline struct shortcut_icon *shortcut_icon_request_ref(struct shortcut_icon *handle) -{ - handle->refcnt++; - DbgPrint("Handle: refcnt[%d]\n", handle->refcnt); - return handle; -} - - - -static int disconnected_cb(int handle, void *data) -{ - if (s_info.fd != handle) { - return 0; - } - - ErrPrint("Disconnected\n"); - s_info.fd = -1; - s_info.init_cb = NULL; - s_info.cbdata = NULL; - s_info.initialized = 0; - return 0; -} - - - -static inline struct shortcut_desc *shortcut_icon_desc_open(void) -{ - struct shortcut_desc *handle; - - handle = calloc(1, sizeof(*handle)); - if (!handle) { - ErrPrint("Error: %s\n", strerror(errno)); - return NULL; - } - - return handle; -} - - - -static inline int shortcut_icon_desc_save(struct shortcut_desc *handle, const char *filename) -{ - struct dlist *l; - struct dlist *n; - struct block *block; - FILE *fp; - - if (!handle) { - return SHORTCUT_ERROR_INVALID; - } - - fp = fopen(filename, "w+t"); - if (!fp) { - ErrPrint("Error: %s\n", strerror(errno)); - return SHORTCUT_ERROR_IO; - } - - DbgPrint("Close and flush\n"); - dlist_foreach_safe(handle->block_list, l, n, block) { - DbgPrint("{\n"); - fprintf(fp, "{\n"); - if (block->type) { - fprintf(fp, "type=%s\n", block->type); - DbgPrint("type=%s\n", block->type); - } - - if (block->part) { - fprintf(fp, "part=%s\n", block->part); - DbgPrint("part=%s\n", block->part); - } - - if (block->data) { - fprintf(fp, "data=%s\n", block->data); - DbgPrint("data=%s\n", block->data); - } - - if (block->option) { - fprintf(fp, "option=%s\n", block->option); - DbgPrint("option=%s\n", block->option); - } - - if (block->id) { - fprintf(fp, "id=%s\n", block->id); - DbgPrint("id=%s\n", block->id); - } - - if (block->target_id) { - fprintf(fp, "target=%s\n", block->target_id); - DbgPrint("target=%s\n", block->target_id); - } - - fprintf(fp, "}\n"); - DbgPrint("}\n"); - } - - if (fclose(fp) != 0) { - ErrPrint("fclose: %s\n", strerror(errno)); - } - return SHORTCUT_SUCCESS; -} - - - -static inline struct block *find_block(struct shortcut_desc *handle, const char *id, const char *part) -{ - struct block *block; - struct dlist *l; - - dlist_foreach(handle->block_list, l, block) { - if (!strcmp(block->part, part) && (!id || !strcmp(block->id, id))) { - return block; - } - } - - return NULL; -} - - - -static inline int update_block(struct block *block, const char *data, const char *option) -{ - char *_data = NULL; - char *_option = NULL; - - if (data) { - _data = strdup(data); - if (!_data) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; - } - } - - if (option) { - _option = strdup(option); - if (!_option) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; - } - } - - free(block->data); - free(block->option); - - block->data = _data; - block->option = _option; - return 0; -} - - - -/*! - * \return idx - */ - - - -static inline int shortcut_icon_desc_add_block(struct shortcut_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *option, const char *target_id) -{ - struct block *block; - - if (!handle || !type) { - return SHORTCUT_ERROR_INVALID; - } - - if (!part) { - part = ""; - } - - if (!data) { - data = ""; - } - - if (target_id) { - if (strcmp(type, SHORTCUT_ICON_TYPE_SCRIPT)) { - ErrPrint("target id only can be used for script type\n"); - return SHORTCUT_ERROR_INVALID; - } - } - - block = find_block(handle, id, part); - if (!block) { - block = calloc(1, sizeof(*block)); - if (!block) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; - } - - block->type = strdup(type); - if (!block->type) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block); - return SHORTCUT_ERROR_MEMORY; - } - - block->part = strdup(part); - if (!block->part) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->type); - free(block); - return SHORTCUT_ERROR_MEMORY; - } - - block->data = strdup(data); - if (!block->data) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_MEMORY; - } - - if (option) { - block->option = strdup(option); - if (!block->option) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->data); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_MEMORY; - } - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->option); - free(block->data); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_MEMORY; - } - } - - if (target_id) { - block->target_id = strdup(target_id); - if (!block->target_id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->id); - free(block->option); - free(block->data); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_MEMORY; - } - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - } else { - if (strcmp(block->type, type)) { - ErrPrint("type is not valid (%s, %s)\n", block->type, type); - return SHORTCUT_ERROR_INVALID; - } - - if ((block->target_id && !target_id) || (!block->target_id && target_id)) { - ErrPrint("type is not valid (%s, %s)\n", block->type, type); - return SHORTCUT_ERROR_INVALID; - } - - if (block->target_id && target_id && strcmp(block->target_id, target_id)) { - ErrPrint("type is not valid (%s, %s)\n", block->type, type); - return SHORTCUT_ERROR_INVALID; - } - - update_block(block, data, option); - } - - return block->idx; -} - - - -static int icon_request_cb(pid_t pid, int handle, const struct packet *packet, void *data) -{ - struct request_item *item = data; - int ret; - - if (!packet) { - ret = -EFAULT; - DbgPrint("Disconnected?\n"); - } else { - if (packet_get(packet, "i", &ret) != 1) { - DbgPrint("Invalid packet\n"); - ret = -EINVAL; - } - } - - if (item->result_cb) { - item->result_cb(item->handle, ret, item->data); - } - - (void)shortcut_icon_request_unref(item->handle); - free(item); - return 0; -} - - - -static inline int make_connection(void) -{ - int ret; - static struct method service_table[] = { - { - .cmd = NULL, - .handler = NULL, - }, - }; - - s_info.fd = com_core_packet_client_init(s_info.utility_socket, 0, service_table); - if (s_info.fd < 0) { - ret = SHORTCUT_ERROR_COMM; - - if (s_info.init_cb) { - s_info.init_cb(ret, s_info.cbdata); - } - } else { - struct dlist *l; - struct dlist *n; - struct pending_item *pend; - - if (s_info.init_cb) { - s_info.init_cb(SHORTCUT_SUCCESS, s_info.cbdata); - } - - dlist_foreach_safe(s_info.pending_list, l, n, pend) { - s_info.pending_list = dlist_remove(s_info.pending_list, l); - - ret = com_core_packet_async_send(s_info.fd, pend->packet, 0.0f, icon_request_cb, pend->item); - packet_destroy(pend->packet); - if (ret < 0) { - ErrPrint("ret: %d\n", ret); - if (pend->item->result_cb) { - pend->item->result_cb(pend->item->handle, ret, pend->item->data); - } - free(pend->item); - } - - free(pend); - } - - ret = SHORTCUT_SUCCESS; - } - - return ret; -} - - - -static void master_started_cb(keynode_t *node, void *user_data) -{ - int state = 0; - - if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) { - ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED); - } - - if (state == 1 && make_connection() == SHORTCUT_SUCCESS) { - (void)vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb); - } -} - - - -EAPI int shortcut_icon_service_init(int (*init_cb)(int status, void *data), void *data) -{ - int ret; - - if (s_info.fd >= 0) { - return SHORTCUT_ERROR_INVALID; - } - - if (s_info.initialized) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - s_info.init_cb = init_cb; - s_info.cbdata = data; - - ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL); - if (ret < 0) { - ErrPrint("Failed to add vconf for service state [%d]\n", ret); - } else { - DbgPrint("vconf is registered\n"); - } - - master_started_cb(NULL, NULL); - return SHORTCUT_SUCCESS; -} - - - -EAPI int shortcut_icon_service_fini(void) -{ - struct dlist *l; - struct dlist *n; - struct pending_item *pend; - - if (s_info.initialized) { - com_core_del_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - s_info.initialized = 0; - } - - if (s_info.fd < 0) { - return SHORTCUT_ERROR_INVALID; - } - - com_core_packet_client_fini(s_info.fd); - s_info.init_cb = NULL; - s_info.cbdata = NULL; - s_info.fd = -1; - - dlist_foreach_safe(s_info.pending_list, l, n, pend) { - s_info.pending_list = dlist_remove(s_info.pending_list, l); - packet_unref(pend->packet); - if (pend->item->result_cb) { - pend->item->result_cb(pend->item->handle, SHORTCUT_ERROR_COMM, pend->item->data); - } - free(pend->item); - free(pend); - } - return SHORTCUT_SUCCESS; -} - - - -EAPI struct shortcut_icon *shortcut_icon_request_create(void) -{ - struct shortcut_icon *handle; - - handle = malloc(sizeof(*handle)); - if (!handle) { - ErrPrint("Heap: %s\n", strerror(errno)); - return NULL; - } - - handle->desc = shortcut_icon_desc_open(); - if (!handle->desc) { - ErrPrint("Uanble to open desc\n"); - free(handle); - return NULL; - } - - handle->state = CREATED; - handle->refcnt = 1; - return handle; -} - - -EAPI int shortcut_icon_request_set_data(struct shortcut_icon *handle, void *data) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID; - } - - handle->data = data; - return SHORTCUT_SUCCESS; -} - - - -EAPI void *shortcut_icon_request_data(struct shortcut_icon *handle) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return NULL; - } - - return handle->data; -} - - - -EAPI int shortcut_icon_request_set_info(struct shortcut_icon *handle, const char *id, const char *type, const char *part, const char *data, const char *option, const char *subid) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID; - } - - return shortcut_icon_desc_add_block(handle->desc, id, type, part, data, option, subid); -} - - - -EAPI int shortcut_icon_request_destroy(struct shortcut_icon *handle) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID; - } - - (void)shortcut_icon_request_unref(handle); - return SHORTCUT_SUCCESS; -} - - - -EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type, const char *layout, const char *group, const char *outfile, icon_request_cb_t result_cb, void *data) -{ - int ret; - struct packet *packet; - struct request_item *item; - char *filename; - int len; - - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID; - } - - if (!layout) { - layout = DEFAULT_ICON_LAYOUT; - } - - if (!group) { - group = DEFAULT_ICON_GROUP; - } - - len = strlen(outfile) + strlen(".desc") + 1 + 30; /* 30 == strlen(tv.tv_sec) + strlen(tv.tv_usec) + 10 (reserved) */ - filename = malloc(len); - if (!filename) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; - } - -#if defined(_USE_ECORE_TIME_GET) - struct timespec ts; - double tv; - do { - if (clock_gettime(s_info.type, &ts) == 0) { - tv = ts.tv_sec + ts.tv_nsec / 1000000000.0f; - break; - } - - ErrPrint("%d: %s\n", s_info.type, strerror(errno)); - if (s_info.type == CLOCK_MONOTONIC) { - s_info.type = CLOCK_REALTIME; - } else if (s_info.type == CLOCK_REALTIME) { - struct timeval _tv; - if (gettimeofday(&_tv, NULL) < 0) { - ErrPrint("gettimeofday: %s\n", strerror(errno)); - _tv.tv_sec = rand(); - _tv.tv_usec = rand(); - } - - tv = (double)_tv.tv_sec + (double)_tv.tv_usec / 1000000.0f; - break; - } - } while (1); - ret = snprintf(filename, len, "%s.%lf.desc", outfile, tv); -#else - struct timeval tv; - if (gettimeofday(&tv, NULL) != 0) { - ErrPrint("gettimeofday: %s\n", strerror(errno)); - tv.tv_sec = rand(); - tv.tv_usec = rand(); - } - - ret = snprintf(filename, len, "%s.%lu.%lu.desc", outfile, tv.tv_sec, tv.tv_usec); -#endif - if (ret < 0) { - ErrPrint("snprintf: %s\n", strerror(errno)); - goto out; - } - - ret = shortcut_icon_desc_save(handle->desc, filename); - if (ret < 0) { - goto out; - } - - item = malloc(sizeof(*item)); - if (!item) { - ErrPrint("Heap: %s\n", strerror(errno)); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - ret = SHORTCUT_ERROR_MEMORY; - goto out; - } - - item->result_cb = result_cb; - item->data = data; - item->handle = shortcut_icon_request_ref(handle); - - packet = packet_create("icon_create", "sssis", layout, group, filename, size_type, outfile); - if (!packet) { - ErrPrint("Failed to create a packet\n"); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - free(item); - (void)shortcut_icon_request_unref(handle); - ret = SHORTCUT_ERROR_FAULT; - goto out; - } - - if (s_info.fd >= 0 && !s_info.pending_list) { - ret = com_core_packet_async_send(s_info.fd, packet, 0.0f, icon_request_cb, item); - packet_destroy(packet); - if (ret < 0) { - ErrPrint("ret: %d\n", ret); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - free(item); - (void)shortcut_icon_request_unref(handle); - } - DbgPrint("Request is sent\n"); - } else { - struct pending_item *pend; - - pend = malloc(sizeof(*pend)); - if (!pend) { - ErrPrint("Heap: %s\n", strerror(errno)); - packet_destroy(packet); - free(item); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - (void)shortcut_icon_request_unref(handle); - ret = SHORTCUT_ERROR_MEMORY; - goto out; - } - - pend->packet = packet; - pend->item = item; - - s_info.pending_list = dlist_append(s_info.pending_list, pend); - DbgPrint("Request is pended\n"); - - ret = SHORTCUT_SUCCESS; - } - -out: - free(filename); - return ret; -} - -/* End of a file */ diff --git a/lib/src/main.c b/lib/src/main.c old mode 100644 new mode 100755 index 4261a39..eec57cf --- a/lib/src/main.c +++ b/lib/src/main.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,10 @@ #include #include "shortcut.h" -#include "shortcut_internal.h" +#include "shortcut_private.h" +#include "shortcut_manager.h" + +#define SHORTCUT_PKGNAME_LEN 512 int errno; @@ -98,7 +102,7 @@ static struct packet *remove_shortcut_handler(pid_t pid, int handle, const struc -static struct packet *remove_livebox_handler(pid_t pid, int handle, const struct packet *packet) +static struct packet *remove_dynamicbox_handler(pid_t pid, int handle, const struct packet *packet) { const char *appid; const char *name; @@ -118,7 +122,7 @@ static struct packet *remove_livebox_handler(pid_t pid, int handle, const struct DbgPrint("appid[%s], name[%s]\n", appid, name); if (s_info.server_cb.request_cb) { - ret = s_info.server_cb.request_cb(appid, name, LIVEBOX_REMOVE, NULL, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data); + ret = s_info.server_cb.request_cb(appid, name, DYNAMICBOX_REMOVE, NULL, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data); } else { ret = SHORTCUT_ERROR_UNSUPPORTED; } @@ -161,7 +165,7 @@ static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct p -static struct packet *add_livebox_handler(pid_t pid, int handle, const struct packet *packet) +static struct packet *add_dynamicbox_handler(pid_t pid, int handle, const struct packet *packet) { const char *appid; const char *name; @@ -203,13 +207,30 @@ static void master_started_cb(keynode_t *node, void *user_data) ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED); } - if (state == 1 && make_connection() == SHORTCUT_SUCCESS) { + if (state == 1 && make_connection() == SHORTCUT_ERROR_NONE) { (void)vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb); } } +int shortcut_is_master_ready(void) +{ + int ret = -1, is_master_started = 0; + + ret = vconf_get_bool(VCONFKEY_MASTER_STARTED, &is_master_started); + if (ret == 0 && is_master_started == 1) { + ErrPrint("the master has been started"); + } else { + is_master_started = 0; + ErrPrint("the master has been stopped"); + } + + return is_master_started; +} + + + static gboolean timeout_cb(void *data) { int ret; @@ -232,13 +253,13 @@ static gboolean timeout_cb(void *data) static int disconnected_cb(int handle, void *data) { if (s_info.client_fd == handle) { - s_info.client_fd = SHORTCUT_ERROR_INVALID; + s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; return 0; } if (s_info.server_fd == handle) { if (!s_info.timer_id) { - s_info.server_fd = SHORTCUT_ERROR_INVALID; + s_info.server_fd = SHORTCUT_ERROR_INVALID_PARAMETER; s_info.timer_id = g_timeout_add(1000, timeout_cb, NULL); if (!s_info.timer_id) { ErrPrint("Unable to add timer\n"); @@ -262,16 +283,16 @@ static inline int make_connection(void) .handler = add_shortcut_handler, }, { - .cmd = "add_livebox", - .handler = add_livebox_handler, + .cmd = "add_dynamicbox", + .handler = add_dynamicbox_handler, }, { .cmd = "rm_shortcut", .handler = remove_shortcut_handler, }, { - .cmd = "rm_livebox", - .handler = remove_livebox_handler, + .cmd = "rm_dynamicbox", + .handler = remove_dynamicbox_handler, }, { .cmd = NULL, @@ -304,7 +325,7 @@ static inline int make_connection(void) s_info.server_fd = -1; ret = SHORTCUT_ERROR_COMM; } else { - ret = SHORTCUT_SUCCESS; + ret = SHORTCUT_ERROR_NONE; } DbgPrint("Server FD: %d\n", s_info.server_fd); @@ -313,8 +334,60 @@ static inline int make_connection(void) +static char *_shortcut_get_pkgname_by_pid(void) +{ + char pkgname[SHORTCUT_PKGNAME_LEN + 1] = { 0, }; + int pid = 0, ret = 0; + int fd; + char *dup_pkgname; + + pid = getpid(); + + ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)); + if (ret != 0) { + char buf[SHORTCUT_PKGNAME_LEN + 1] = { 0, }; + + snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid); + + fd = open(buf, O_RDONLY); + if (fd < 0) { + return NULL; + } + + ret = read(fd, pkgname, sizeof(pkgname) - 1); + close(fd); + + if (ret <= 0) { + return NULL; + } + + pkgname[ret] = '\0'; + /*! + * \NOTE + * "ret" is not able to be larger than "sizeof(pkgname) - 1", + * if the system is not going wrong. + */ + } else { + if (strlen(pkgname) <= 0) { + return NULL; + } + } + + dup_pkgname = strdup(pkgname); + if (!dup_pkgname) + ErrPrint("Heap: %s\n", strerror(errno)); + + return dup_pkgname; +} + + + EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data) { + if (request_cb == NULL) { + return SHORTCUT_ERROR_INVALID_PARAMETER; + } + s_info.server_cb.request_cb = request_cb; s_info.server_cb.data = data; @@ -324,6 +397,7 @@ EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data) ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL); if (ret < 0) { ErrPrint("Failed to add vconf for service state [%d]\n", ret); + return SHORTCUT_ERROR_COMM; } else { DbgPrint("vconf is registered\n"); } @@ -331,12 +405,13 @@ EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data) master_started_cb(NULL, NULL); } - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } struct result_cb_item { + result_internal_cb_t result_internal_cb; result_cb_t result_cb; void *data; }; @@ -353,13 +428,15 @@ static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet, ret = SHORTCUT_ERROR_FAULT; } else if (packet_get(packet, "i", &ret) != 1) { ErrPrint("Packet is not valid\n"); - ret = SHORTCUT_ERROR_INVALID; + ret = SHORTCUT_ERROR_INVALID_PARAMETER; } - if (item->result_cb) { - ret = item->result_cb(ret, pid, item->data); + if (item->result_internal_cb) { + ret = item->result_internal_cb(ret, pid, item->data); + } else if (item->result_cb) { + ret = item->result_cb(ret, item->data); } else { - ret = SHORTCUT_SUCCESS; + ret = SHORTCUT_ERROR_NONE; } free(item); return ret; @@ -367,7 +444,7 @@ static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet, -EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_cb_t result_cb, void *data) +EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_internal_cb_t result_cb, void *data) { struct packet *packet; struct result_cb_item *item; @@ -375,7 +452,7 @@ EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const if (!appid || !name) { ErrPrint("Invalid argument\n"); - return SHORTCUT_ERROR_INVALID; + return SHORTCUT_ERROR_INVALID_PARAMETER; } if (!s_info.initialized) { @@ -401,10 +478,11 @@ EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const item = malloc(sizeof(*item)); if (!item) { ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; + return SHORTCUT_ERROR_OUT_OF_MEMORY; } - item->result_cb = result_cb; + item->result_internal_cb = result_cb; + item->result_cb = NULL; item->data = data; packet = packet_create("rm_shortcut", "isss", getpid(), appid, name, content_info); @@ -419,16 +497,16 @@ EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const packet_destroy(packet); free(item); com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID; + s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; return SHORTCUT_ERROR_COMM; } - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } -EAPI int add_to_home_remove_livebox(const char *appid, const char *name, result_cb_t result_cb, void *data) +EAPI int add_to_home_remove_dynamicbox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data) { struct packet *packet; struct result_cb_item *item; @@ -436,7 +514,7 @@ EAPI int add_to_home_remove_livebox(const char *appid, const char *name, result_ if (!appid || !name) { ErrPrint("Invalid argument\n"); - return SHORTCUT_ERROR_INVALID; + return SHORTCUT_ERROR_INVALID_PARAMETER; } if (!s_info.initialized) { @@ -463,13 +541,14 @@ EAPI int add_to_home_remove_livebox(const char *appid, const char *name, result_ item = malloc(sizeof(*item)); if (!item) { ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; + return SHORTCUT_ERROR_OUT_OF_MEMORY; } - item->result_cb = result_cb; + item->result_internal_cb = result_cb; + item->result_cb = NULL; item->data = data; - packet = packet_create("rm_livebox", "iss", getpid(), appid, name); + packet = packet_create("rm_dynamicbox", "iss", getpid(), appid, name); if (!packet) { ErrPrint("Failed to build a packet\n"); free(item); @@ -481,23 +560,24 @@ EAPI int add_to_home_remove_livebox(const char *appid, const char *name, result_ packet_destroy(packet); free(item); com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID; + s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; return SHORTCUT_ERROR_COMM; } - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } -EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data) +EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content, const char *icon, int allow_duplicate, result_internal_cb_t result_cb, void *data) { struct packet *packet; struct result_cb_item *item; int ret; - if (ADD_TO_HOME_IS_LIVEBOX(type)) { + if (!appid || ADD_TO_HOME_IS_DYNAMICBOX(type)) { ErrPrint("Invalid type used for adding a shortcut\n"); + return SHORTCUT_ERROR_INVALID_PARAMETER; } if (!s_info.initialized) { @@ -523,16 +603,13 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con item = malloc(sizeof(*item)); if (!item) { ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; + return SHORTCUT_ERROR_OUT_OF_MEMORY; } - item->result_cb = result_cb; + item->result_internal_cb = result_cb; + item->result_cb = NULL; item->data = data; - if (!appid) { - appid = ""; - } - if (!name) { name = ""; } @@ -557,23 +634,115 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con packet_destroy(packet); free(item); com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID; + s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; return SHORTCUT_ERROR_COMM; } - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } +EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *uri, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data) +{ + struct packet *packet; + struct result_cb_item *item; + char *appid = NULL; + int ret; + + if (ADD_TO_HOME_IS_DYNAMICBOX(type)) { + ErrPrint("Invalid type used for adding a shortcut\n"); + return SHORTCUT_ERROR_INVALID_PARAMETER; + } + + appid = _shortcut_get_pkgname_by_pid(); + + if (!s_info.initialized) { + s_info.initialized = 1; + com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); + } + + if (s_info.client_fd < 0) { + static struct method service_table[] = { + { + .cmd = NULL, + .handler = NULL, + }, + }; + + s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); + if (s_info.client_fd < 0) { + if (appid) { + free(appid); + } + if (shortcut_is_master_ready() == 1) { + return SHORTCUT_ERROR_PERMISSION_DENIED; + } + else { + return SHORTCUT_ERROR_COMM; + } + } + } + + item = malloc(sizeof(*item)); + if (!item) { + if (appid) { + free(appid); + } + ErrPrint("Heap: %s\n", strerror(errno)); + return SHORTCUT_ERROR_OUT_OF_MEMORY; + } + item->result_cb = result_cb; + item->result_internal_cb = NULL; + item->data = data; -EAPI int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data) + if (!name) { + name = ""; + } + + if (!uri) { + uri = ""; + } + + if (!icon) { + icon = ""; + } + + packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, uri, icon, allow_duplicate); + if (!packet) { + ErrPrint("Failed to build a packet\n"); + if (appid) { + free(appid); + } + if (item) { + free(item); + } + return SHORTCUT_ERROR_FAULT; + } + + ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item); + packet_destroy(packet); + if (ret < 0) { + if (item) { + free(item); + } + com_core_packet_client_fini(s_info.client_fd); + s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; + return SHORTCUT_ERROR_COMM; + } + + return SHORTCUT_ERROR_NONE; +} + + +EAPI int add_to_home_dynamicbox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_internal_cb_t result_cb, void *data) { struct packet *packet; struct result_cb_item *item; int ret; - if (!ADD_TO_HOME_IS_LIVEBOX(type)) { - ErrPrint("Invalid type is used for adding a livebox\n"); + if (!appid || !ADD_TO_HOME_IS_DYNAMICBOX(type)) { + ErrPrint("Invalid type is used for adding a dynamicbox\n"); + return SHORTCUT_ERROR_INVALID_PARAMETER; } if (!s_info.initialized) { @@ -598,13 +767,14 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons item = malloc(sizeof(*item)); if (!item) { ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_MEMORY; + return SHORTCUT_ERROR_OUT_OF_MEMORY; } - item->result_cb = result_cb; + item->result_internal_cb = result_cb; + item->result_cb = NULL; item->data = data; - packet = packet_create("add_livebox", "ississdi", getpid(), appid, name, type, content, icon, period, allow_duplicate); + packet = packet_create("add_dynamicbox", "ississdi", getpid(), appid, name, type, content, icon, period, allow_duplicate); if (!packet) { ErrPrint("Failed to build a packet\n"); free(item); @@ -616,14 +786,15 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons packet_destroy(packet); free(item); com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID; + s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; return SHORTCUT_ERROR_COMM; } - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } + static inline int open_db(void) { int ret; @@ -631,10 +802,10 @@ static inline int open_db(void) ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD); if (ret != SQLITE_OK) { DbgPrint("Failed to open a %s\n", s_info.dbfile); - return SHORTCUT_ERROR_IO; + return SHORTCUT_ERROR_IO_ERROR; } - return SHORTCUT_SUCCESS; + return SHORTCUT_ERROR_NONE; } @@ -768,13 +939,17 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const int cnt; char *language; + if (cb == NULL) { + return SHORTCUT_ERROR_INVALID_PARAMETER; + } + if (!s_info.db_opened) { s_info.db_opened = (open_db() == 0); } if (!s_info.db_opened) { ErrPrint("Failed to open a DB\n"); - return SHORTCUT_ERROR_IO; + return SHORTCUT_ERROR_IO_ERROR; } language = cur_locale(); @@ -789,7 +964,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const if (ret != SQLITE_OK) { ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle)); free(language); - return SHORTCUT_ERROR_IO; + return SHORTCUT_ERROR_IO_ERROR; } ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT); @@ -797,7 +972,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const ErrPrint("bind text: %s\n", sqlite3_errmsg(s_info.handle)); sqlite3_finalize(stmt); free(language); - return SHORTCUT_ERROR_IO; + return SHORTCUT_ERROR_IO_ERROR; } } else { query = "SELECT id, appid, name, extra_key, extra_data, icon FROM shortcut_service"; @@ -805,7 +980,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const if (ret != SQLITE_OK) { ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle)); free(language); - return SHORTCUT_ERROR_IO; + return SHORTCUT_ERROR_IO_ERROR; } } diff --git a/packaging/libshortcut.spec b/packaging/libshortcut.spec old mode 100644 new mode 100755 index 864bafe..5f9e8c2 --- a/packaging/libshortcut.spec +++ b/packaging/libshortcut.spec @@ -1,8 +1,7 @@ Name: libshortcut Summary: Shortcut add feature supporting library -Version: 0.6.12 +Version: 0.6.14 Release: 0 -VCS: magnolia/framework/appfw/shortcut#shortcut_0.3.20-37-g4af29465058bf4841fd5ee41f0d09594e88b8aa0 Group: HomeTF/Framework License: Apache Source0: %{name}-%{version}.tar.gz @@ -19,6 +18,8 @@ BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(com-core) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(aul) %description [Shortcut] AddToHome feature supporting library for menu/home screen developers. @@ -74,6 +75,8 @@ touch %{buildroot}/opt/dbspace/.shortcut_service.db-journal %manifest %{name}.manifest %defattr(-,root,root,-) %{_includedir}/shortcut/shortcut.h +%{_includedir}/shortcut/shortcut_private.h +%{_includedir}/shortcut/shortcut_manager.h %{_libdir}/pkgconfig/shortcut.pc # End of a file diff --git a/sample.xml b/sample.xml old mode 100644 new mode 100755 index f3a6bc8..0e471a0 --- a/sample.xml +++ b/sample.xml @@ -1,8 +1,8 @@ - + - - /opt/usr/apps/com.samsung.myapp/res/icon/myapp_shortcut01.png + + /opt/usr/apps/org.tizen.myapp/res/icon/myapp_shortcut01.png @@ -20,8 +20,8 @@ - - /opt/usr/apps/com.samsung.myapp/res/icon/gadget_shortcut01.png + + /opt/usr/apps/org.tizen.myapp/res/icon/gadget_shortcut01.png @@ -39,8 +39,8 @@ - - /opt/usr/apps/com.samsung.myapp/res/icon/mayapp_shortcut02.png + + /opt/usr/apps/org.tizen.myapp/res/icon/mayapp_shortcut02.png diff --git a/test/application.c b/test/application.c old mode 100644 new mode 100755 index 6c1e5f3..5d69981 --- a/test/application.c +++ b/test/application.c @@ -32,7 +32,7 @@ static Eina_Bool shortcut_add_cb(void *data) ret = add_to_home_shortcut("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", result_cb, NULL); printf("Client: shortcut_add_to_home returns: %d\n", ret); - ret = add_to_home_livebox("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", 1.0f, result_cb, NULL); + ret = add_to_home_dynamicbox("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", 1.0f, result_cb, NULL); printf("Client: shortcut_add_to_home_with_period returns: %d\n", ret); return ECORE_CALLBACK_RENEW; diff --git a/test/icon.c b/test/icon.c old mode 100644 new mode 100755 index 3086729..28d5b6f --- a/test/icon.c +++ b/test/icon.c @@ -41,7 +41,7 @@ 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/com.samsung.music-player.png", NULL, NULL); + 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); printf("NAME set_info: %d\n", ret); snprintf(filename, sizeof(filename), "App Name %d", idx); @@ -51,14 +51,14 @@ static Eina_Bool test_main(void *data) snprintf(filename, sizeof(filename), "/opt/usr/share/live_magazine/always/out%d.png", idx); switch (idx % 7) { - case 0: type = LIVEBOX_TYPE_1x1; break; - case 1: type = LIVEBOX_TYPE_2x1; break; - case 2: type = LIVEBOX_TYPE_2x2; break; - case 3: type = LIVEBOX_TYPE_4x1; break; - case 4: type = LIVEBOX_TYPE_4x2; break; - case 5: type = LIVEBOX_TYPE_4x3; break; - case 6: type = LIVEBOX_TYPE_4x4; break; - default: type = LIVEBOX_TYPE_1x1; break; + case 0: type = DYNAMICBOX_TYPE_1x1; break; + case 1: type = DYNAMICBOX_TYPE_2x1; break; + case 2: type = DYNAMICBOX_TYPE_2x2; break; + case 3: type = DYNAMICBOX_TYPE_4x1; break; + case 4: type = DYNAMICBOX_TYPE_4x2; break; + case 5: type = DYNAMICBOX_TYPE_4x3; break; + case 6: type = DYNAMICBOX_TYPE_4x4; break; + default: type = DYNAMICBOX_TYPE_1x1; break; } ret = shortcut_icon_request_send(handle, type, NULL, NULL, filename, result_cb, NULL); diff --git a/test_db_builder.sh b/test_db_builder.sh index d4c4322..302076e 100755 --- a/test_db_builder.sh +++ b/test_db_builder.sh @@ -19,11 +19,11 @@ DBFILE="/opt/dbspace/.shortcut_service.db" APPID=( -"com.samsung.facebook" -"com.samsung.facebook" -"com.samsung.facebook" -"com.samsung.facebook" -"com.samsung.facebook" +"org.tizen.facebook" +"org.tizen.facebook" +"org.tizen.facebook" +"org.tizen.facebook" +"org.tizen.facebook" ) ICON=( @@ -43,11 +43,11 @@ NAME=( ) KEY=( -"livebox_shortcut_type" -"livebox_shortcut_type" -"livebox_shortcut_type" -"livebox_shortcut_type" -"livebox_shortcut_type" +"dynamicbox_shortcut_type" +"dynamicbox_shortcut_type" +"dynamicbox_shortcut_type" +"dynamicbox_shortcut_type" +"dynamicbox_shortcut_type" ) VALUE=( -- 2.7.4