sync with private git. updated the license and the boilerplates
[apps/home/quickpanel.git] / daemon / common.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 #ifndef __QP_COMMON_H_
18 #define __QP_COMMON_H_
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <errno.h>
23 #include <Elementary.h>
24 #include "quickpanel_debug_util.h"
25
26 #define QP_OK   (0)
27 #define QP_FAIL (-1)
28
29 #ifdef _DLOG_USED
30 #define LOG_TAG "QUICKPANEL"
31 #include <dlog.h>
32
33 #define HAPI __attribute__((visibility("hidden")))
34
35 #define DBG(fmt , args...) \
36         do { \
37                 LOGD("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
38         } while (0)
39
40 #define INFO(fmt , args...) \
41         do { \
42                 LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
43         } while (0)
44
45 #define WARN(fmt , args...) \
46         do { \
47                 LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
48         } while (0)
49
50 #define ERR(fmt , args...) \
51         do { \
52                 LOGE("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
53         } while (0)
54
55 #elif FILE_DEBUG /*_DLOG_USED*/
56 #define DBG(fmt , args...) \
57         do { \
58                 debug_printf("[D]%s : %d] "fmt"\n", \
59                         __func__, __LINE__, ##args); \
60         } while (0)
61
62 #define INFO(fmt , args...) \
63         do { \
64                 debug_printf("[I][%s : %d] "fmt"\n",\
65                         __func__, __LINE__, ##args); \
66         } while (0)
67
68 #define WARN(fmt , args...) \
69         do { \
70                 debug_printf("[W][%s : %d] "fmt"\n", \
71                         __func__, __LINE__, ##args); \
72         } while (0)
73
74 #define ERR(fmt , args...) \
75         do { \
76                 debug_printf("[E][%s : %d] "fmt"\n", \
77                         __func__, __LINE__, ##args); \
78         } while (0)
79
80 #else /*_DLOG_USED*/
81 #define DBG(fmt , args...) \
82         do { \
83                 fprintf("[D][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
84         } while (0)
85
86 #define INFO(fmt , args...) \
87         do { \
88                 fprintf("[I][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
89         } while (0)
90
91 #define WARN(fmt , args...) \
92         do { \
93                 fprintf("[W][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
94         } while (0)
95
96 #define ERR(fmt , args...) \
97         do { \
98                 fprintf("[E][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
99         } while (0)
100 #endif /*_DLOG_USED*/
101
102 #define msgif(cond, str, args...) do { \
103         if (cond) { \
104                 ERR(str, ##args);\
105         } \
106 } while (0);
107
108 #define retif(cond, ret, str, args...) do { \
109         if (cond) { \
110                 ERR(str, ##args);\
111                 return ret;\
112         } \
113 } while (0);
114
115 #define gotoif(cond, target, str, args...) do { \
116         if (cond) { \
117                 WARN(str, ##args); \
118                 goto target; \
119         } \
120 } while (0);
121
122
123 void quickpanel_util_char_replace(char *text, char s, char t);
124 void quickpanel_ui_set_current_popup(Evas_Object *popup);
125 void quickpanel_ui_del_current_popup(void);
126
127 #endif                          /* __QP_COMMON_H_ */