tizen 2.3 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_WIFI_DIRECT                     1
101 #define SUPPORT_READY_TO_SHARE                     1
102 #define SUPPORT_DATA_USAGE                      1
103 #define SUPPORT_PERSONALPAGE                    0
104 #define SUPPORT_AUTO_ADJUST_SCREEN_TONE 1
105 #define SUPPORT_HIGH_TOUCH_SENS 1
106 #define SUPPORT_SCREEN_CAPTURE  1
107 #define SUPPORT_HDMI_APP        0
108 #define SUPPORT_POWER_USAGE_INFO 0
109 #define SUPPORT_NFC                     0
110 #define SUPPORT_TETHERING       0
111 #define SUPPORT_NETWORK_RESTRICTION     1
112 #define SUPPORT_SMARTSCREEN     0
113 #define SUPPORT_CALL                            0
114
115 /*#endif*/
116
117 #define SUPPORT_APP_ROATION                     1
118 #define SUPPORT_LCD_TIMEOUT_KEEPING             0
119 #define USE_DEVICE_SET_DISPLAY_BRT              1
120
121 #define  LOW_BATTERY_DO_NOTHING                 1       /**< 1 : turn the low batter handlding off */
122
123 #define APPLIED_DATATIME_FIRSTDAY_WEEK          0
124 #define SUPPORT_DATEFIELD_DATE_FORMAT_AUTOSET   0
125
126 #define SUPPORT_SIMLOCK 0
127 #define SUPPORT_FDN 0
128 #define SUPPORT_ENCRYPTION 0
129 #define SUPPORT_SD_ENCRYPTION 0
130 #define SUPPORT_SCREEN_SECURITY 1
131 #define SUPPORT_PARENTAL_MODE 0
132
133 #define SUPPORT_SECURITY_FIREWALL 1
134 #define SUPPORT_PRIVACY 1
135
136 #define SETTING_ENABLE_TRACE
137
138 #ifdef SETTING_ENABLE_TRACE
139         #ifdef SETTING_USING_PLATFORM_DBG
140                 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) \
141                         do {\
142                                 SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
143                         }while(0);
144
145                 #define SETTING_TRACE_DEBUG(fmt, arg...) \
146                         do {\
147                                 SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
148                         }while(0);
149
150                 #define SETTING_TRACE(fmt, arg...) \
151                         do {\
152                                 SECURE_LOGI("\033[0;36m" fmt "\033[0m\n", ##arg);\
153                         }while(0);
154
155                 #define SETTING_TRACE_WARNING(fmt, arg...) \
156                         do {\
157                                 SECURE_LOGI("\033[0;33mWARRING: " fmt "\033[0m\n", ##arg);\
158                         }while(0);
159
160                 #define SETTING_TRACE_ERROR(fmt, arg...) \
161                         do {\
162                                 SECURE_LOGE("\033[0;31mERROR: " fmt "\033[0m\n", ##arg);\
163                         }while(0);
164                 #define SETTING_TRACE_BEGIN do {\
165                                 SECURE_LOGD("\033[0;35mENTER FUNCTION: %s. \033[0m\n", __FUNCTION__);\
166                         }while(0);
167
168                 #define SETTING_TRACE_END  do {\
169                                 SECURE_LOGD("\033[0;35mEXIT FUNCTION: %s. \033[0m\n", __FUNCTION__);\
170                         }while(0);
171         #else
172                 #define SETTING_TRACE(fmt, arg...) \
173                         do {\
174                                 printf("\n[SETTING]\033[0;36m" fmt "\033[0m\t%s:%d\n", \
175                                                 ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
176                         }while(0);
177
178                 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) \
179                         do {\
180                                 printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
181                                                 ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
182                         }while(0);
183
184
185                 #define SETTING_TRACE_DEBUG(fmt, arg...) \
186                         do {\
187                                 printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
188                                                 ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
189                         }while(0);
190
191                 #define SETTING_TRACE_WARNING(fmt, arg...) \
192                         do {\
193                         {\
194                                 printf("[SETTING]\033[0;33mWARRING: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
195                         }while(0);
196
197                 #define SETTING_TRACE_ERROR(fmt, arg...) \
198                         do {\
199                                 {fprintf(stderr, "[SETTING]\033[0;31mERROR: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
200                         }while(0);
201
202                 #define SETTING_TRACE_BEGIN do {\
203                                 {\
204                                         printf("\n[SETTING]\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
205                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
206                                 }\
207                         }while(0);
208
209                 #define SETTING_TRACE_END  do {\
210                                 {\
211                                         printf("\n[SETTING]\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
212                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
213                                 }\
214                         }while(0);
215         #endif
216 #else
217         #define SETTING_TRACE(fmt, arg...)
218         #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...)
219         #define SETTING_TRACE_DEBUG(fmt, arg...)
220         #define SETTING_TRACE_WARNING(fmt, arg...)
221         #define SETTING_TRACE_ERROR(fmt, arg...)
222         #define SETTING_TRACE_BEGIN
223         #define SETTING_TRACE_END
224 #endif
225
226 #define setting_retvm_if(expr, val, fmt, arg...) do { \
227                 if(expr) { \
228                         SETTING_TRACE_ERROR(fmt, ##arg); \
229                         return (val); \
230                 } \
231         } while (0);
232
233 #define setting_retm_if(expr, fmt, arg...) do { \
234                 if(expr) { \
235                         SETTING_TRACE_ERROR(fmt, ##arg); \
236                         return; \
237                 } \
238         } while (0);
239
240 #ifndef retm_if
241 #define retm_if setting_retm_if
242 #endif
243 #ifndef retvm_if
244 #define retvm_if setting_retvm_if
245 #endif
246
247 #ifndef retv_if
248 #define retv_if(expr, val) do { \
249    if(expr) { \
250       SETTING_TRACE_ERROR("(%s)", #expr); \
251       return (val); \
252    } \
253 } while (0)
254 #endif
255
256 #ifndef ret_if
257 #define ret_if(expr) do { \
258    if(expr) { \
259       SETTING_TRACE_ERROR("(%s)", #expr); \
260       return ; \
261    } \
262 } while (0)
263 #endif
264
265 #ifndef warn_if
266 #define warn_if(expr, fmt, arg...) do { \
267         if (expr) { \
268                 SETTING_TRACE_ERROR(fmt, ##arg); \
269         } \
270 } while (0)
271 #endif
272
273
274 #define __FREE(del, arg) do { \
275                 if(arg) { \
276                         del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
277                         arg = NULL; \
278                 } \
279         } while (0);
280 #define FREE(arg) __FREE(free, arg)
281 #define G_FREE(arg) __FREE(g_free, arg)
282
283
284 //////
285 //a trick:To manager back pointer. eg,
286 //For using genlist, whenever Setting side and Genlist side both keep pointers
287 //to a same block memory(here is genlis item data via calloc), must use __BACK_POINTER_SET to
288 //bind the Setting side point into the Genlist side pointer
289 #define __BACK_POINTER_SET(pData) do { \
290                         if (pData)\
291                         {\
292                                 pData->pBack = (void **)(&(pData));\
293                         }\
294                 } while (0);
295
296 #define __BACK_POINTER_UNSET(pData) do { \
297                         if (pData && pData->pBack)/*release Setting side poniter handlers*/\
298                         {\
299                                 *(pData->pBack) = NULL;\
300                         }\
301                 } while (0);
302
303
304 #endif /* _SETTING_DEBUG_H_ */
305