tizen 2.4 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
46 #define USE_TIMER_UPDATE_TIME_IN_TIME_VIEW
47
48 /* launching */
49 #ifdef LAUNCHING_DEBUG_LOG
50 #define LAUNCH_SETTING_IN(fmt, arg...)  LOG(LOG_DEBUG, "LAUNCH", "[setting:Application:%s:IN]" fmt, __FUNCTION__, ##arg)
51 #define LAUNCH_SETTING_OUT(fmt, arg...) LOG(LOG_DEBUG, "LAUNCH", "[setting:Application:%s:OUT]" fmt, __FUNCTION__, ##arg)
52 #else
53 #define LAUNCH_SETTING_IN(fmt, arg...)
54 #define LAUNCH_SETTING_OUT(fmt, arg...)
55 #endif
56
57 #if !defined(LOCALEDIR)
58 #define LOCALEDIR "/usr/apps/org.tizen.setting/res/locale"
59 #endif
60
61 #if !defined(EDJDIR)
62 #define EDJDIR "/usr/apps/org.tizen.setting/res/edje"
63 #endif
64
65 #define SUPPORT_BOTTOM_BTNS 1
66 #define SUPPORT_DRI 1
67
68 /*macros to control program flow*/
69
70 /* Genlist Update is in progress. */
71 #if 0
72 #define OLD_GENLIST_STYLE
73 #endif
74
75 #define FUNCTION_SYSTEM_SETTING 1
76 #define SETTING_SEARCH 1
77
78 /*##menu options##*/
79 #define SUPPORT_FONT                            1
80 #define SUPPORT_WALLPAPER                       0
81 #define SUPPOR_SEPARATE_BRIGHTNESS              0
82
83 #define SUPPORT_ACCESSIBILITY                   1
84
85 #define SUPPORT_STORAGE                         1
86 #define SUPPORT_WIFI_DIRECT                     1
87 #define SUPPORT_DATA_USAGE                      1
88 #define SUPPORT_TETHERING       0
89
90 /*#endif*/
91
92 #define SUPPORT_APP_ROATION                     1
93
94 #define  LOW_BATTERY_DO_NOTHING                 1       /**< 1 : turn the low batter handlding off */
95
96
97 #define SUPPORT_SIMLOCK 0
98 #define SUPPORT_FDN 0
99 #define SUPPORT_ENCRYPTION 0
100 #define SUPPORT_SD_ENCRYPTION 0
101 #define SUPPORT_SCREEN_SECURITY 1
102
103 #define SUPPORT_SECURITY_FIREWALL 1
104 #define SUPPORT_PRIVACY 1
105
106 #define SETTING_ENABLE_TRACE
107
108 #ifdef SETTING_ENABLE_TRACE
109 #ifdef SETTING_USING_PLATFORM_DBG
110 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) \
111         do {\
112                 SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
113         }while(0);
114
115 #define SETTING_TRACE_DEBUG(fmt, arg...) \
116         do {\
117                 SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
118         }while(0);
119
120 #define SETTING_TRACE(fmt, arg...) \
121         do {\
122                 SECURE_LOGI("\033[0;36m" fmt "\033[0m\n", ##arg);\
123         }while(0);
124
125 #define SETTING_TRACE_WARNING(fmt, arg...) \
126         do {\
127                 SECURE_LOGI("\033[0;33mWARRING: " fmt "\033[0m\n", ##arg);\
128         }while(0);
129
130 #define SETTING_TRACE_ERROR(fmt, arg...) \
131         do {\
132                 SECURE_LOGE("\033[0;31mERROR: " fmt "\033[0m\n", ##arg);\
133         }while(0);
134 #define SETTING_TRACE_BEGIN do {\
135                 SECURE_LOGD("\033[0;35mENTER FUNCTION: %s. \033[0m\n", __FUNCTION__);\
136         }while(0);
137
138 #define SETTING_TRACE_END  do {\
139                 SECURE_LOGD("\033[0;35mEXIT FUNCTION: %s. \033[0m\n", __FUNCTION__);\
140         }while(0);
141 #else
142 #define SETTING_TRACE(fmt, arg...) \
143         do {\
144                 printf("\n[SETTING]\033[0;36m" fmt "\033[0m\t%s:%d\n", \
145                        ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
146         }while(0);
147
148 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) \
149         do {\
150                 printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
151                        ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
152         }while(0);
153
154
155 #define SETTING_TRACE_DEBUG(fmt, arg...) \
156         do {\
157                 printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
158                        ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
159         }while(0);
160
161 #define SETTING_TRACE_WARNING(fmt, arg...) \
162         do {\
163                 {\
164                         printf("[SETTING]\033[0;33mWARRING: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
165         }while(0);
166
167 #define SETTING_TRACE_ERROR(fmt, arg...) \
168         do {\
169                 {fprintf(stderr, "[SETTING]\033[0;31mERROR: " fmt "\033[0m\t%s:%d\n", ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);}\
170         }while(0);
171
172 #define SETTING_TRACE_BEGIN do {\
173                 {\
174                         printf("\n[SETTING]\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
175                                __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
176                 }\
177         }while(0);
178
179 #define SETTING_TRACE_END  do {\
180                 {\
181                         printf("\n[SETTING]\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
182                                __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
183                 }\
184         }while(0);
185 #endif
186 #else
187 #define SETTING_TRACE(fmt, arg...)
188 #define SETTING_TRACE_SECURE_DEBUG(fmt, arg...)
189 #define SETTING_TRACE_DEBUG(fmt, arg...)
190 #define SETTING_TRACE_WARNING(fmt, arg...)
191 #define SETTING_TRACE_ERROR(fmt, arg...)
192 #define SETTING_TRACE_BEGIN
193 #define SETTING_TRACE_END
194 #endif
195
196 #define setting_retvm_if(expr, val, fmt, arg...) do { \
197                 if(expr) { \
198                         SETTING_TRACE_ERROR(fmt, ##arg); \
199                         return (val); \
200                 } \
201         } while (0);
202
203 #define setting_retm_if(expr, fmt, arg...) do { \
204                 if(expr) { \
205                         SETTING_TRACE_ERROR(fmt, ##arg); \
206                         return; \
207                 } \
208         } while (0);
209
210 #ifndef retm_if
211 #define retm_if setting_retm_if
212 #endif
213 #ifndef retvm_if
214 #define retvm_if setting_retvm_if
215 #endif
216
217 #ifndef retv_if
218 #define retv_if(expr, val) do { \
219                 if(expr) { \
220                         SETTING_TRACE_ERROR("(%s)", #expr); \
221                         return (val); \
222                 } \
223         } while (0)
224 #endif
225
226 #ifndef ret_if
227 #define ret_if(expr) do { \
228                 if(expr) { \
229                         SETTING_TRACE_ERROR("(%s)", #expr); \
230                         return ; \
231                 } \
232         } while (0)
233 #endif
234
235 #ifndef warn_if
236 #define warn_if(expr, fmt, arg...) do { \
237                 if (expr) { \
238                         SETTING_TRACE_ERROR(fmt, ##arg); \
239                 } \
240         } while (0)
241 #endif
242
243
244 #define __FREE(del, arg) do { \
245                 if(arg) { \
246                         del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
247                         arg = NULL; \
248                 } \
249         } while (0);
250 #define FREE(arg) __FREE(free, arg)
251 #define G_FREE(arg) __FREE(g_free, arg)
252
253
254 /*//// */
255 /*a trick:To manager back pointer. eg, */
256 /*For using genlist, whenever Setting side and Genlist side both keep pointers */
257 /*to a same block memory(here is genlis item data via calloc), must use __BACK_POINTER_SET to */
258 /*bind the Setting side point into the Genlist side pointer */
259 #define __BACK_POINTER_SET(pData) do { \
260                 if (pData)\
261                 {\
262                         pData->pBack = (void **)(&(pData));\
263                 }\
264         } while (0);
265
266 #define __BACK_POINTER_UNSET(pData) do { \
267                 if (pData && pData->pBack)/*release Setting side poniter handlers*/\
268                 {\
269                         *(pData->pBack) = NULL;\
270                 }\
271         } while (0);
272
273
274 #endif /* _SETTING_DEBUG_H_ */
275