Merge "packaging: spec cleanup" into tizen
[apps/core/preloaded/settings.git] / include / setting-debug.h
1 /*
2  * setting
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.1 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 /**
18  * @defgroup setting-debug
19  * setting debug utility
20  */
21
22 #ifndef _SETTING_DEBUG_H_
23 #define _SETTING_DEBUG_H_
24 #include <stdio.h>
25
26 /*#define MTRACE_ENABLED*/
27
28 #define DISABLED_CODE 0
29
30 //#define DEBUG_CODE
31
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
44 #if !defined(LOCALEDIR)
45 #define LOCALEDIR "/usr/apps/org.tizen.setting/res/locale"
46 #endif
47
48 #if !defined(EDJDIR)
49 #define EDJDIR "/usr/apps/org.tizen.setting/res/edje"
50 #endif
51
52 #define SUPPORT_BOTTOM_BTNS 1
53 #define REMOVE_BACK_BUTTON_MAIN 0
54 #define SUPPORT_GL_ENGINE 1
55
56
57 /*macros to control program flow*/
58 #define SUPPORT_MORE_ITEM_FUNCTION 1
59
60 // #define SUPPORT_MDM
61
62 /*##menu options##*/
63 #define SUPPORT_AllShare_Memory                 0
64 #define SUPPORT_FMradio                         1
65 #define SUPPORT_FONT                            1
66 #define SUPPORT_MENUSCREEN                      1
67 #define SUPPORT_WALLPAPER                       1
68 #define SUPPOR_SEPARATE_BRIGHTNESS              1
69
70 #define SUPPORT_RCS_FOR_DEMO                    0
71 #define SUPPORT_ACCESSIBILITY                   1
72 #define SUPPORT_CERTIFICATES            0
73 #define SUPPORT_MOTIONS                         1
74 #define SUPPORT_POWERSAVING                     1
75 #define SUPPORT_RUN_SYSTEM_COMMAND              0
76 #define SUPPORT_STORAGE                         1
77 #define SUPPORT_WIFI_DIRECT                     1
78 #define SUPPORT_DATA_USAGE                      0
79 #define SUPPORT_SECURITY                        1
80 #define SUPPORT_WEB_APPLICATION                 0
81
82 /*#endif*/
83
84 #define SUPPORT_APP_ROATION                     1
85 #define SUPPORT_LCD_TIMEOUT_KEEPING             0
86 #define USE_DEVICE_SET_DISPLAY_BRT              1
87
88 #define  LOW_BATTERY_DO_NOTHING                 1       /**< 1 : turn the low batter handlding off */
89
90 #define APPLIED_BACK_KEY_UG                     0
91
92 #define APPLIED_DATATIME_FIRSTDAY_WEEK          0
93 #define SUPPORT_DATEFIELD_DATE_FORMAT_AUTOSET   0
94
95 #define SUPPORT_FDN 0
96 #define SUPPORT_PARENTAL_MODE 0
97 #define SUPPORT_PRIVACY 1
98
99 #define SETTING_ENABLE_TRACE
100
101 #ifdef SETTING_ENABLE_TRACE
102         #ifdef SETTING_USING_PLATFORM_DBG
103                 #define SETTING_TRACE_DEBUG(fmt, arg...) \
104                         do {\
105                                 LOGD("\n\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
106                                 ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
107                         }while(0);
108
109                 #define SETTING_TRACE(fmt, arg...) \
110                         do {\
111                                 LOGI("\n\033[0;36m" fmt "\033[0m\t%s:%d\n", \
112                                                 ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
113                         }while(0);
114
115                 #define SETTING_TRACE_WARNING(fmt, arg...) \
116                         do {\
117                                 LOGW("\033[0;33mWARRING: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
118                         }while(0);
119
120                 #define SETTING_TRACE_ERROR(fmt, arg...) \
121                         do {\
122                                 LOGE("\033[0;31mERROR: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
123                         }while(0);
124                 #define SETTING_TRACE_BEGIN do {\
125                                 {\
126                                         LOGD("\n\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
127                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
128                                 }\
129                         }while(0);
130
131                 #define SETTING_TRACE_END  do {\
132                                 {\
133                                         LOGD("\n\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
134                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
135                                 }\
136                         }while(0);
137         #else
138                 #define SETTING_TRACE(fmt, arg...) \
139                         do {\
140                                 printf("\n[SETTING]\033[0;36m" fmt "\033[0m\t%s:%d\n", \
141                                                 ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
142                         }while(0);
143
144
145                 #define SETTING_TRACE_DEBUG(fmt, arg...) \
146                         do {\
147                                 printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
148                                                 ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
149                         }while(0);
150
151                 #define SETTING_TRACE_WARNING(fmt, arg...) \
152                         do {\
153                         {\
154                                 printf("[SETTING]\033[0;33mWARRING: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
155                         }while(0);
156
157                 #define SETTING_TRACE_ERROR(fmt, arg...) \
158                         do {\
159                                 {fprintf(stderr, "[SETTING]\033[0;31mERROR: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
160                         }while(0);
161
162                 #define SETTING_TRACE_BEGIN do {\
163                                 {\
164                                         printf("\n[SETTING]\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
165                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
166                                 }\
167                         }while(0);
168
169                 #define SETTING_TRACE_END  do {\
170                                 {\
171                                         printf("\n[SETTING]\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
172                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
173                                 }\
174                         }while(0);
175         #endif
176 #else
177         #define SETTING_TRACE(fmt, arg...)
178         #define SETTING_TRACE_DEBUG(fmt, arg...)
179         #define SETTING_TRACE_WARNING(fmt, arg...)
180         #define SETTING_TRACE_ERROR(fmt, arg...)
181         #define SETTING_TRACE_BEGIN
182         #define SETTING_TRACE_END
183 #endif
184
185 #define setting_retvm_if(expr, val, fmt, arg...) do { \
186                 if(expr) { \
187                         SETTING_TRACE_ERROR(fmt, ##arg); \
188                         return (val); \
189                 } \
190         } while (0);
191
192 #define setting_retm_if(expr, fmt, arg...) do { \
193                 if(expr) { \
194                         SETTING_TRACE_ERROR(fmt, ##arg); \
195                         return; \
196                 } \
197         } while (0);
198
199 #ifndef retm_if
200 #define retm_if setting_retm_if
201 #endif
202 #ifndef retvm_if
203 #define retvm_if setting_retvm_if
204 #endif
205
206 #ifndef retv_if
207 #define retv_if(expr, val) do { \
208    if(expr) { \
209       return (val); \
210    } \
211 } while (0)
212 #endif
213 #ifndef ret_if
214 #define ret_if(expr) do { \
215    if(expr) { \
216       return ; \
217    } \
218 } while (0)
219 #endif
220
221 #define __FREE(del, arg) do { \
222                 if(arg) { \
223                         del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
224                         arg = NULL; \
225                 } \
226         } while (0);
227 #define FREE(arg) __FREE(free, arg)
228 #define G_FREE(arg) __FREE(g_free, arg)
229
230
231 //////
232 //a trick:To manager back pointer. eg,
233 //For using genlist, whenever Setting side and Genlist side both keep pointers
234 //to a same block memory(here is genlis item data via calloc), must use __BACK_POINTER_SET to
235 //bind the Setting side point into the Genlist side pointer
236 #define __BACK_POINTER_SET(pData) do { \
237                         if (pData)\
238                         {\
239                                 pData->pBack = (void **)(&(pData));\
240                         }\
241                 } while (0);
242
243 #define __BACK_POINTER_UNSET(pData) do { \
244                         if (pData && pData->pBack)/*release Setting side poniter handlers*/\
245                         {\
246                                 *(pData->pBack) = NULL;\
247                         }\
248                 } while (0);
249
250
251 #endif /* _SETTING_DEBUG_H_ */
252