5749c17f3993d6f7a54323210e3653dca27436bd
[apps/core/preloaded/quickpanel.git] / daemon / common.h
1 /*
2  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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
18
19 #ifndef __QP_COMMON_H_
20 #define __QP_COMMON_H_
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <errno.h>
25 #include <Elementary.h>
26 #include "quickpanel_debug_util.h"
27
28 #define QP_OK   (0)
29 #define QP_FAIL (-1)
30 #define QP_UTIL_PHONE_NUMBER_MAX_LEN    40
31 #define EDATA_BACKKEY_CB "bk_cb"
32
33 #ifdef _DLOG_USED
34 #undef LOG_TAG
35 #define LOG_TAG "QUICKPANEL"
36 #include <dlog.h>
37
38 #define HAPI __attribute__((visibility("hidden")))
39
40 #define DBG(fmt , args...) \
41         do { \
42                 LOGD("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
43         } while (0)
44
45 #define INFO(fmt , args...) \
46         do { \
47                 LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
48         } while (0)
49
50 #define WARN(fmt , args...) \
51         do { \
52                 LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
53         } while (0)
54
55 #define ERR(fmt , args...) \
56         do { \
57                 LOGE("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
58         } while (0)
59
60 #define SDBG(fmt , args...) \
61         do { \
62                 SECURE_LOGD("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
63         } while (0)
64
65 #define SINFO(fmt , args...) \
66         do { \
67                 SECURE_LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
68         } while (0)
69
70 #define SERR(fmt , args...) \
71         do { \
72                 SECURE_LOGE("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
73         } while (0)
74
75 #elif FILE_DEBUG /*_DLOG_USED*/
76 #define DBG(fmt , args...) \
77         do { \
78                 debug_printf("[D]%s : %d] "fmt"\n", \
79                         __func__, __LINE__, ##args); \
80         } while (0)
81
82 #define INFO(fmt , args...) \
83         do { \
84                 debug_printf("[I][%s : %d] "fmt"\n",\
85                         __func__, __LINE__, ##args); \
86         } while (0)
87
88 #define WARN(fmt , args...) \
89         do { \
90                 debug_printf("[W][%s : %d] "fmt"\n", \
91                         __func__, __LINE__, ##args); \
92         } while (0)
93
94 #define ERR(fmt , args...) \
95         do { \
96                 debug_printf("[E][%s : %d] "fmt"\n", \
97                         __func__, __LINE__, ##args); \
98         } while (0)
99
100 #else /*_DLOG_USED*/
101 #define DBG(fmt , args...) \
102         do { \
103                 fprintf("[D][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
104         } while (0)
105
106 #define INFO(fmt , args...) \
107         do { \
108                 fprintf("[I][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
109         } while (0)
110
111 #define WARN(fmt , args...) \
112         do { \
113                 fprintf("[W][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
114         } while (0)
115
116 #define ERR(fmt , args...) \
117         do { \
118                 fprintf("[E][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \
119         } while (0)
120 #endif /*_DLOG_USED*/
121
122 #define msgif(cond, str, args...) do { \
123         if (cond) { \
124                 ERR(str, ##args);\
125         } \
126 } while (0);
127
128 #define retif(cond, ret, str, args...) do { \
129         if (cond) { \
130                 ERR(str, ##args);\
131                 return ret;\
132         } \
133 } while (0);
134
135 #define retif_nomsg(cond, ret) do { \
136         if (cond) { \
137                 return ret;\
138         } \
139 } while (0);
140
141 #define gotoif(cond, target, str, args...) do { \
142         if (cond) { \
143                 WARN(str, ##args); \
144                 goto target; \
145         } \
146 } while (0);
147
148
149 void quickpanel_common_util_char_trim(char *text);
150 void quickpanel_common_util_char_replace(char *text, char s, char t);
151 void quickpanel_common_util_add_char_to_each_charactor(char *dst, const char *src, char t);
152 int quickpanel_common_util_is_phone_number(const char *address);
153 void quickpanel_common_util_phone_number_tts_make(char *dst, const char *src, int size);
154 void quickpanel_common_ui_set_current_popup(Evas_Object *popup, Evas_Smart_Cb func_close);
155 void quickpanel_common_ui_del_current_popup(void);
156 void *quickpanel_common_ui_get_buffer_from_image(const char *file_path, size_t *memfile_size, char *ext, int ext_size);
157 char *quickpanel_common_ui_get_pkginfo_icon(const char *pkgid);
158 char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid);
159 int quickpanel_common_ui_is_package_exist(const char *pkgid);
160
161 #endif                          /* __QP_COMMON_H_ */