Apply ACR
[platform/core/appfw/shortcut.git] / lib / include / shortcut_private.h
1 /*
2  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16 */
17
18 #if !defined(FLOG)
19 #define DbgPrint(format, arg...)        SECURE_LOGD(format, ##arg)
20 #define ErrPrint(format, arg...)        SECURE_LOGE(format, ##arg)
21 #else
22 extern FILE *__file_log_fp;
23 #define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
24
25 #define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
26 #endif
27
28 #if !defined(EAPI)
29 #define EAPI __attribute__((visibility("default")))
30 #endif
31
32 #if !defined(VCONFKEY_MASTER_STARTED)
33 #define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
34 #endif
35
36 #define DEFAULT_ICON_LAYOUT ""
37 #define DEFAULT_ICON_GROUP ""
38
39 /**
40  * @brief Definition for a macro to check the request type.
41  * @since_tizen 2.3
42  * @param[in] type Request type
43  * @return bool
44  * @retval true(1) Shortcut remove request
45  * @retval false(0) Not a remove request
46  * @see shortcut_type
47  */
48 #define ADD_TO_HOME_IS_REMOVE_SHORTCUT(type)    (!!((type) & SHORTCUT_REMOVE))
49
50 /**
51  * @brief Definition for a macro to check the request type.
52  * @since_tizen 2.3
53  * @param[in] type Request type
54  * @return bool
55  * @retval true(1) Dynamicbox remove request
56  * @retval false(0) Not a remove request
57  * @see shortcut_type
58  */
59 #define ADD_TO_HOME_IS_REMOVE_DYNAMICBOX(type)  (!!((type) & DYNAMICBOX_REMOVE))
60
61 /**
62  *
63  *
64  * @brief The application, which supporting the add_to_home feature, should invoke this.
65  *
66  * @details
67  * Sync (or) Async:
68  * This is an asynchronous API.
69  *
70  * Important Notes:\n
71  * Application must check the return value of this function.\n
72  * Application must check the return status from the callback function\n
73  * Application should set the callback function to get the result of this request.
74  *
75  * Prospective Clients:
76  * Inhouse Apps.
77  *
78  * @since_tizen 2.3
79  *
80  * @remarks - If a homescreen does not support this feature, you will get proper error code.
81  * @param[in] appid Package name of owner of this shortcut.
82  * @param[in] name Name for created shortcut icon.
83  * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut.
84  * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer.
85  * @param[in] data Callback data which will be used in callback function
86  *
87  * @return Return Type (int)
88  * \retval 0 Succeed to send the request
89  * \retval #SHORTCUT_ERROR_FAULT Unrecoverable error
90  * \retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value
91  * \retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication
92  * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request
93  * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files
94  * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut
95  *
96  * @pre You have to prepare the callback function
97  *
98  * @post You have to check the return status from callback function which is passed by argument.
99  *
100  * @see result_internal_cb_t
101  *
102  * @par Example
103  * @code
104  *
105  * #include <stdio.h>
106  * #include <shortcut.h>
107  *
108  * static int result_cb(int ret, int pid, void *data)
109  * {
110  *      if (ret < 0)
111  *              printf("Failed to add a shortcut: %s\n", perror(ret));
112  *
113  *      printf("Processed by the %d\n", pid);
114  *      return 0;
115  * }
116  *
117  * static int app_create(void *data)
118  * {
119  *      add_to_home_remove_shortcut("com.samsung.gallery.dynamicbox", "With friends",
120  *                                      "gallery:0000-0000",
121  *                                      result_cb, NULL);
122  *      return 0;
123  * }
124  *
125  * int main(int argc, char *argv[])
126  * {
127  *      appcore....
128  * }
129  *
130  * @endcode
131  */
132 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);
133
134 /**
135  *
136  *
137  * @brief The application, which supporting the add_to_home feature, should invoke this.
138  *
139  * @details
140  * Sync (or) Async:
141  * This is an asynchronous API.
142  *
143  * Important Notes:\n
144  * Application must check the return value of this function.\n
145  * Application must check the return status from the callback function\n
146  * Application should set the callback function to get the result of this request.
147  *
148  * Prospective Clients:
149  * Inhouse Apps.
150  *
151  * @since_tizen 2.3
152  *
153  * @remarks - If a homescreen does not support this feature, you will get proper error code.
154  * @param[in] appid Package name of owner of this shortcut.
155  * @param[in] name Name for created shortcut icon.
156  * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer.
157  * @param[in] data Callback data which will be used in callback function
158  *
159  * @return Return Type (int)
160  * \retval 0 Succeed to send the request
161  * \retval #SHORTCUT_ERROR_FAULT Unrecoverable error
162  * \retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value
163  * \retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication
164  * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request
165  * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files
166  * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut
167  *
168  * @pre You have to prepare the callback function
169  *
170  * @post You have to check the return status from callback function which is passed by argument.
171  *
172  * @see result_internal_cb_t
173  *
174  * @par Example
175  * @code
176  *
177  * #include <stdio.h>
178  * #include <shortcut.h>
179  *
180  * static int result_cb(int ret, int pid, void *data)
181  * {
182  *      if (ret < 0)
183  *              printf("Failed to add a shortcut: %s\n", perror(ret));
184  *
185  *      printf("Processed by the %d\n", pid);
186  *      return 0;
187  * }
188  *
189  * static int app_create(void *data)
190  * {
191  *      add_to_home_remove_dynamicbox("com.samsung.gallery.dynamicbox", "With friends", result_cb, NULL);
192  *      return 0;
193  * }
194  *
195  * int main(int argc, char *argv[])
196  * {
197  *      appcore....
198  * }
199  *
200  * @endcode
201  */
202 extern int add_to_home_remove_dynamicbox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data);
203
204 /* End of a file */