tizen 2.3.1 release
[apps/home/settings.git] / include / setting-debug.h
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 /**
22  * @defgroup setting-debug
23  * setting debug utility
24  */
25
26 #ifndef _SETTING_DEBUG_H_
27 #define _SETTING_DEBUG_H_
28 #include <stdio.h>
29 #include <glib.h>
30
31 /*#define DEBUG_CODE */
32 #define SETTING_USING_PLATFORM_DBG
33 #ifdef SETTING_USING_PLATFORM_DBG
34 #include <dlog.h>
35 #ifdef LOG_TAG
36 #undef LOG_TAG
37 #endif
38
39
40 #define LOG_TAG "SETTING"
41 #endif
42
43 /*#define LAUNCHING_DEBUG_LOG */
44
45 /* launching */
46 #ifdef LAUNCHING_DEBUG_LOG
47 #define LAUNCH_SETTING_IN(fmt, arg...)  LOG(LOG_DEBUG, "LAUNCH", "[setting:Application:%s:IN]" fmt, __FUNCTION__, ##arg)
48 #define LAUNCH_SETTING_OUT(fmt, arg...) LOG(LOG_DEBUG, "LAUNCH", "[setting:Application:%s:OUT]" fmt, __FUNCTION__, ##arg)
49 #else
50 #define LAUNCH_SETTING_IN(fmt, arg...)
51 #define LAUNCH_SETTING_OUT(fmt, arg...)
52 #endif
53
54 #if !defined(LOCALEDIR)
55 #define LOCALEDIR "/usr/apps/org.tizen.setting/res/locale"
56 #endif
57
58 #if !defined(EDJDIR)
59 #define EDJDIR "/usr/apps/org.tizen.setting/res/edje"
60 #endif
61
62 #define SUPPORT_BOTTOM_BTNS 1
63 #define SUPPORT_DRI 1
64
65
66 /*macros to control program flow*/
67 #define SUPPORT_MORE_ITEM_FUNCTION 1
68
69 #define SETTING_SEARCH 1
70
71 #if SETTING_SEARCH
72 /* do nothing */
73 #else
74 #define USE_RECENTLY_USED
75 #endif
76
77 #define SUPPORT_LIBEAS                  0
78 #define SUPPORT_FINGERPRINT             0
79 #define SUPPORT_TTS                             0
80 /*##menu options##*/
81 #define SUPPORT_AllShare_Memory                 0
82 #define SUPPORT_FMradio                         0
83 #define SUPPORT_FONT                            1
84 #define SUPPORT_WALLPAPER                       0
85 #define SUPPOR_SEPARATE_BRIGHTNESS              0
86 #define SUPPORT_LEDINDICATOR                    1
87 #define SUPPORT_SPLIT_DISPLAY                   0
88 #define SUPPORT_HELPUI 0
89
90 #define SUPPORT_ACCESSIBILITY                   1
91
92 /**
93  * @todo SUPPORT_PSMODE and SUPPORT_POWERSAVING is working exclusively.
94  * need to do refactoring
95  */
96 #define SUPPORT_PSMODE 1
97
98 #define SUPPORT_RUN_SYSTEM_COMMAND              0
99 #define SUPPORT_STORAGE                         1
100 #define SUPPORT_SIMSETTING 0
101 #define SUPPORT_WIFI_DIRECT                     1
102 #define SUPPORT_READY_TO_SHARE                     1
103 #define SUPPORT_DATA_USAGE                      1
104 #define SUPPORT_PERSONALPAGE                    0
105 #define SUPPORT_AUTO_ADJUST_SCREEN_TONE 1
106 #define SUPPORT_HIGH_TOUCH_SENS 1
107 #define SUPPORT_SCREEN_CAPTURE  1
108 #define SUPPORT_HDMI_APP        0
109 #define SUPPORT_POWER_USAGE_INFO 0
110 #define SUPPORT_NFC                     0
111 #define SUPPORT_TETHERING       0
112 #define SUPPORT_NETWORK_RESTRICTION     1
113 #define SUPPORT_SMARTSCREEN     0
114 #define SUPPORT_CALL                            0
115
116 /*#endif*/
117
118 #define SUPPORT_APP_ROATION                     1
119 #define SUPPORT_LCD_TIMEOUT_KEEPING             0
120 #define USE_DEVICE_SET_DISPLAY_BRT              1
121
122 #define  LOW_BATTERY_DO_NOTHING                 1       /**< 1 : turn the low batter handlding off */
123
124 #define APPLIED_DATATIME_FIRSTDAY_WEEK          0
125 #define SUPPORT_DATEFIELD_DATE_FORMAT_AUTOSET   0
126
127 #define SUPPORT_SIMLOCK 0
128 #define SUPPORT_FDN 0
129 #define SUPPORT_ENCRYPTION 0
130 #define SUPPORT_SD_ENCRYPTION 0
131 #define SUPPORT_SCREEN_SECURITY 1
132 #define SUPPORT_PARENTAL_MODE 0
133
134 #define SUPPORT_SECURITY_FIREWALL 1
135 #define SUPPORT_PRIVACY 1
136
137 #define SETTING_ENABLE_TRACE
138
139 #ifdef SETTING_ENABLE_TRACE
140 #ifdef SETTING_USING_PLATFORM_DBG
141 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) \
142         do {\
143                 SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
144         }while(0);
145
146 #define SETTING_TRACE_DEBUG(fmt, arg...) \
147         do {\
148                 SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
149         }while(0);
150
151 #define SETTING_TRACE(fmt, arg...) \
152         do {\
153                 SECURE_LOGI("\033[0;36m" fmt "\033[0m\n", ##arg);\
154         }while(0);
155
156 #define SETTING_TRACE_WARNING(fmt, arg...) \
157         do {\
158                 SECURE_LOGI("\033[0;33mWARRING: " fmt "\033[0m\n", ##arg);\
159         }while(0);
160
161 #define SETTING_TRACE_ERROR(fmt, arg...) \
162         do {\
163                 SECURE_LOGE("\033[0;31mERROR: " fmt "\033[0m\n", ##arg);\
164         }while(0);
165 #define SETTING_TRACE_BEGIN do {\
166                 SECURE_LOGD("\033[0;35mENTER FUNCTION: %s. \033[0m\n", __FUNCTION__);\
167         }while(0);
168
169 #define SETTING_TRACE_END  do {\
170                 SECURE_LOGD("\033[0;35mEXIT FUNCTION: %s. \033[0m\n", __FUNCTION__);\
171         }while(0);
172 #else
173 #define SETTING_TRACE(fmt, arg...) \
174         do {\
175                 printf("\n[SETTING]\033[0;36m" fmt "\033[0m\t%s:%d\n", \
176                        ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
177         }while(0);
178
179 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) \
180         do {\
181                 printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
182                        ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
183         }while(0);
184
185
186 #define SETTING_TRACE_DEBUG(fmt, arg...) \
187         do {\
188                 printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
189                        ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
190         }while(0);
191
192 #define SETTING_TRACE_WARNING(fmt, arg...) \
193         do {\
194                 {\
195                         printf("[SETTING]\033[0;33mWARRING: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
196         }while(0);
197
198 #define SETTING_TRACE_ERROR(fmt, arg...) \
199         do {\
200                 {fprintf(stderr, "[SETTING]\033[0;31mERROR: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
201         }while(0);
202
203 #define SETTING_TRACE_BEGIN do {\
204                 {\
205                         printf("\n[SETTING]\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
206                                __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
207                 }\
208         }while(0);
209
210 #define SETTING_TRACE_END  do {\
211                 {\
212                         printf("\n[SETTING]\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
213                                __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
214                 }\
215         }while(0);
216 #endif
217 #else
218 #define SETTING_TRACE(fmt, arg...)
219 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...)
220 #define SETTING_TRACE_DEBUG(fmt, arg...)
221 #define SETTING_TRACE_WARNING(fmt, arg...)
222 #define SETTING_TRACE_ERROR(fmt, arg...)
223 #define SETTING_TRACE_BEGIN
224 #define SETTING_TRACE_END
225 #endif
226
227 #define setting_retvm_if(expr, val, fmt, arg...) do { \
228                 if(expr) { \
229                         SETTING_TRACE_ERROR(fmt, ##arg); \
230                         return (val); \
231                 } \
232         } while (0);
233
234 #define setting_retm_if(expr, fmt, arg...) do { \
235                 if(expr) { \
236                         SETTING_TRACE_ERROR(fmt, ##arg); \
237                         return; \
238                 } \
239         } while (0);
240
241 #ifndef retm_if
242 #define retm_if setting_retm_if
243 #endif
244 #ifndef retvm_if
245 #define retvm_if setting_retvm_if
246 #endif
247
248 #ifndef retv_if
249 #define retv_if(expr, val) do { \
250                 if(expr) { \
251                         SETTING_TRACE_ERROR("(%s)", #expr); \
252                         return (val); \
253                 } \
254         } while (0)
255 #endif
256
257 #ifndef ret_if
258 #define ret_if(expr) do { \
259                 if(expr) { \
260                         SETTING_TRACE_ERROR("(%s)", #expr); \
261                         return ; \
262                 } \
263         } while (0)
264 #endif
265
266 #ifndef warn_if
267 #define warn_if(expr, fmt, arg...) do { \
268                 if (expr) { \
269                         SETTING_TRACE_ERROR(fmt, ##arg); \
270                 } \
271         } while (0)
272 #endif
273
274
275 #define __FREE(del, arg) do { \
276                 if(arg) { \
277                         del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
278                         arg = NULL; \
279                 } \
280         } while (0);
281 #define FREE(arg) __FREE(free, arg)
282 #define G_FREE(arg) __FREE(g_free, arg)
283
284
285 /*//// */
286 /*a trick:To manager back pointer. eg, */
287 /*For using genlist, whenever Setting side and Genlist side both keep pointers */
288 /*to a same block memory(here is genlis item data via calloc), must use __BACK_POINTER_SET to */
289 /*bind the Setting side point into the Genlist side pointer */
290 #define __BACK_POINTER_SET(pData) do { \
291                 if (pData)\
292                 {\
293                         pData->pBack = (void **)(&(pData));\
294                 }\
295         } while (0);
296
297 #define __BACK_POINTER_UNSET(pData) do { \
298                 if (pData && pData->pBack)/*release Setting side poniter handlers*/\
299                 {\
300                         *(pData->pBack) = NULL;\
301                 }\
302         } while (0);
303
304
305 #endif /* _SETTING_DEBUG_H_ */
306