2 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifndef __SHORTCUT_H__
19 #define __SHORTCUT_H__
26 * @addtogroup APPLICATION_FRAMEWORK
31 * @defgroup SHORTCUT Add to home (shortcut)
32 * @author Sung-jae Park <nicesj.park@samsung.com>
34 * @brief To enhance the Add to home feature. Two types of API set are supported.
35 * One for the homescreen developers.
36 * The others for the application developers who should implement the Add to home feature.
40 * @brief This function prototype is used to define a callback function for the add_to_home reqeust.
41 * The homescreen should define a callback as this type and implementing the service code
42 * for adding a new application shortcut.
43 * @param[in] appid Shortcut is added for this package.
44 * @param[in] name Name for created shortcut icon.
45 * @param[in] type 3 kinds of types are defined.
46 * @param[in] content_info Specific information for creating a new shortcut.
47 * @param[in] icon Absolute path of an icon file for this shortcut.
48 * @param[in] pid Process ID of who request add_to_home.
49 * @param[in] data Callback data.
50 * @return int Developer should returns the result of handling shortcut creation request.
51 * Returns 0, if succeed to handles the add_to_home request, or returns proper errno.
52 * @see shortcut_set_request_cb
57 typedef int (*request_cb_t)(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, double period, void *data);
60 * @brief This function prototype is used to define for receiving the result of add_to_home.
61 * @param[in] ret Result value, it could be 0 if succeed to add a shortcut, or errno.
62 * @param[in] pid Process ID of who handles this add_to_home request.
63 * @param[in] data Callback data.
64 * @return int Returns 0, if there is no error or returns errno.
65 * @see add_to_home_shortcut()
70 typedef int (*result_cb_t)(int ret, int pid, void *data);
73 * @brief Basically, three types of shortcut is defined.
74 * Every homescreen developer should support these types of shortcut.
75 * Or returns proper errno to figure out why the application failed to add a shortcut.
76 * LAUNCH_BY_PACKAGE is used for adding a package itself as a shortcut
77 * LAUNCH_BY_URI is used for adding a shortcut for "uri" data.
80 /*!< Deprecated type */
81 SHORTCUT_PACKAGE = 0x00000000, /**< Launch the package using given pakcage name. */
82 SHORTCUT_DATA = 0x00000001, /**< Launch the related package with given data(content_info). */
83 SHORTCUT_FILE = 0x00000002, /**< Launch the related package with given filename(content_info). */
86 LAUNCH_BY_PACKAGE = 0x00000000, /*!< Launch the package using given pakcage name. */
87 LAUNCH_BY_URI = 0x00000001, /*!< Launch the related package with given data(URI). */
89 LIVEBOX_TYPE_DEFAULT = 0x10000000,
90 LIVEBOX_TYPE_EASY_DEFAULT = 0x30000000,
91 LIVEBOX_TYPE_1x1 = 0x10010000,
92 LIVEBOX_TYPE_2x1 = 0x10020000,
93 LIVEBOX_TYPE_2x2 = 0x10040000,
94 LIVEBOX_TYPE_4x1 = 0x10080000,
95 LIVEBOX_TYPE_4x2 = 0x10100000,
96 LIVEBOX_TYPE_4x3 = 0x10200000,
97 LIVEBOX_TYPE_4x4 = 0x10400000,
98 LIVEBOX_TYPE_EASY_1x1 = 0x30010000,
99 LIVEBOX_TYPE_EASY_3x1 = 0x30020000,
100 LIVEBOX_TYPE_EASY_3x3 = 0x30040000,
101 LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000,
104 #define ADD_TO_HOME_IS_LIVEBOX(type) (!!((type) & 0x10000000))
107 * @fn int shortcut_set_request_cb(request_cb_t request_cb, void *data)
109 * @brief Homescreen should use this function to service the shortcut creating request.
111 * @par Sync (or) Async:
112 * This is an asynchronous API.
114 * @par Important Notes:
115 * - Should be used from the homescreen.
116 * - Should check the return value of this function
118 * @param[in] request_cb Callback function pointer which will be invoked when add_to_home is requested.
119 * @param[in] data Callback data to deliver to the callback function.
121 * @return Return Type (int)
122 * - 0 - callback function is successfully registered
123 * - < 0 - Failed to register the callback function for request.
127 * @pre - You have to prepare a callback function
129 * @post - If a request is sent from the application, the registered callback will be invoked.
133 * @par Prospective Clients:
138 * #include <shortcut.h>
140 * static int request_cb(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, void *data)
142 * printf("Package name: %s\n", appid);
143 * printf("Name: %s\n", name);
144 * printf("Type: %d\n", type);
145 * printf("Content: %s\n", content_info);
146 * printf("Icon: %s\n", icon);
147 * printf("Requested from: %d\n", pid);
148 * printf("CBDATA: %p\n", data);
149 * return 0; // returns success.
152 * static int app_create(void *data)
154 * shortcut_set_request_cb(request_cb, NULL);
158 * int main(int argc, char *argv[])
165 extern int shortcut_set_request_cb(request_cb_t request_cb, void *data);
168 * @fn int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, result_cb_t result_cb, void *data)
170 * @brief The application, which supporting the add_to_home feature, should invoke this.
172 * @par Sync (or) Async:
173 * This is an asynchronous API.
175 * @par Important Notes:
176 * - Application should check the return value of this function.
177 * - Application should check the return status from the callback function
178 * - Application should set the callback function to get the result of this request.
180 * @param[in] appid Package name of owner of this shortcut.
181 * @param[in] name Name for created shortcut icon.
182 * @param[in] type 3 kinds of types are defined.
183 * @param[in] content_info Specific information for delivering to the creating shortcut.
184 * @param[in] icon Absolute path of an icon file
185 * @param[in] result_cb Callback function pointer which will be invoked after add_to_home request.
186 * @param[in] data Callback data to deliver to the callback function.
188 * @return Return Type (int)
189 * - 0 - Succeed to send the request
190 * - <0 - Failed to send the request
194 * @pre - You have to prepare the callback function
196 * @post - You have to check the return status from callback function which is passed by argument.
198 * @remarks - If a homescreen does not support this feature, you will get proper error code.
200 * @par Prospective Clients:
207 * #include <shortcut.h>
209 * static int result_cb(int ret, int pid, void *data)
212 * printf("Failed to add a shortcut: %s\n", perror(ret));
214 * printf("Processed by the %d\n", pid);
218 * static int app_create(void *data)
220 * add_to_home_shortcut("org.tizen.gallery", "With friends",
221 * SHORTCUT_DATA, "gallery:0000-0000",
222 * "/opt/media/Pictures/Friends.jpg", result_cb, NULL);
226 * int main(int argc, char *argv[])
233 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);
235 extern int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, result_cb_t result_cb, void *data);
237 extern int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, result_cb_t result_cb, void *data);
241 * \brief Number of preview images for homescreen
243 extern int homescreen_get_image_count(const char *appid);
245 * \return string allocated in the heap - Path of image
247 extern char *homescreen_get_image(const char *appid, int idx);
250 * \brief Description of the homescreen (based on i18n)
252 extern int homescreen_get_description(const char *appid, void (*cb)(const char *appid, const char *icon, const char *name, const char *desc, void *data), void *data);
256 * These two functions are deprecated now.
258 * Please replace the "shortcut_add_to_home" with "add_to_home_shortcut"
259 * Please replace the "shortcut_add_to_home_with_period" with "add_to_home_livebox"
261 extern int shortcut_add_to_home(const char *appid, const char *name, int type, const char *content, const char *icon, result_cb_t result_cb, void *data) __attribute__ ((deprecated));
263 extern int shortcut_add_to_home_with_period(const char *appid, const char *name, int type, const char *content, const char *icon, double period, result_cb_t result_cb, void *data) __attribute__ ((deprecated));