Tizen C++ Coding Rules
[platform/core/location/maps-plugin-here.git] / heremaps-uc / src / heremaps-uc-common.h
1 /*
2  * heremaps-uc
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jongmun Woo <jongmun.woo@samsung.com>, Young-Ae Kang <youngae.kang@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
23
24 #ifndef HEREMAPS_UC_COMMON_H_
25 #define HEREMAPS_UC_COMMON_H_
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #include <app.h>
32 #include <dlog.h>
33 #include <glib.h>
34 #include <vconf.h>
35 #include <vconf-internal-location-keys.h>
36 #ifndef Eina_Bool
37 #include <stdbool.h>
38 #endif
39 #include <Elementary.h>
40 #include <libintl.h>
41 #include <stdio.h>
42 #include <string.h>
43 #include <efl_extension.h>
44 #include <system_info.h>
45
46 #if !defined(HEREMAPS_UC_PKG)
47 #define HEREMAPS_UC_PKG "org.tizen.heremaps-uc"
48 #endif
49
50 #define DOMAIN_NAME HEREMAPS_UC_PKG
51
52 #define TAG_HEREMAPS_UC "HEREMAPS_UC"
53 #define HEREMAPS_UC_DLOG_DEBUG
54
55 #ifdef HEREMAPS_UC_DLOG_DEBUG        /**< if debug mode, show filename & line number */
56
57 #ifdef LOG_TAG
58 #undef LOG_TAG
59 #define LOG_TAG TAG_HEREMAPS_UC
60 #endif
61
62 #define LS_LOGD(fmt,args...)  LOGD(fmt, ##args)
63 #define LS_LOGW(fmt,args...)  LOGW(fmt, ##args)
64 #define LS_LOGI(fmt,args...)  LOGI(fmt, ##args)
65 #define LS_LOGE(fmt,args...)  LOGE(fmt, ##args)
66
67 #elif HEREMAPS_UC_DLOG_RELEASE      /* if release mode */
68
69 #ifdef LOG_TAG
70 #undef LOG_TAG
71 #define LOG_TAG TAG_HEREMAPS_UC
72 #endif
73
74 #define LS_LOGD(fmt,args...)  LOGD(fmt, ##args)
75 #define LS_LOGW(fmt,args...)  LOGW(fmt, ##args)
76 #define LS_LOGI(fmt,args...)  LOGI(fmt, ##args)
77 #define LS_LOGE(fmt,args...)  LOGE(fmt, ##args)
78 #else                       /* if do not use dlog */
79 #define LS_LOGD(...)  g_debug(__VA_ARGS__)
80 #define LS_LOGW(...)  g_warning(__VA_ARGS__)
81 #define LS_LOGI(...)  g_message(__VA_ARGS__)
82 #define LS_LOGE(...)  g_error(__VA_ARGS__)
83 #endif
84
85 #define P_(s)                   dgettext(HEREMAPS_UC_PKG, s)
86 #define S_(s)                   dgettext("sys_string", s)
87 #define dgettext_noop(s)        (s)
88 #define N_(s)                   dgettext_noop(s)
89
90 #define KEY_ENABLED     1
91 #define KEY_DISABLED 0
92
93 #define LS_FUNC_ENTER   LS_LOGD("(%s) ENTER", __FUNCTION__);
94 #define LS_FUNC_EXIT    LS_LOGD("(%s) EXIT", __FUNCTION__);
95
96 #define SAFE_STRDUP(src) (src) ? strdup(src) : NULL
97
98 #define LS_MEM_FREE(ptr)        \
99         do { \
100                 if (ptr != NULL) {      \
101                         free((void *)ptr);      \
102                         ptr = NULL;     \
103                 }       \
104         } while (0)
105
106
107 #define LS_MEM_NEW(ptr, num_elements, type)      \
108         do { \
109                 if ((int)(num_elements) <= 0) { \
110                         ptr = NULL; \
111                 } else { \
112                         ptr = (type *) calloc(num_elements, sizeof(type)); \
113                 } \
114         } while (0)
115
116
117 #define LS_RETURN_IF_FAILED(point) do { \
118                 if (point == NULL) { \
119                         LS_LOGE("critical error : LS_RETURN_IF_FAILED"); \
120                         return; \
121                 } \
122         } while (0)
123
124 #define LS_RETURN_VAL_IF_FAILED(point, val) do { \
125                 if (point == NULL) { \
126                         LS_LOGE("critical error : NAVI_RETURN_VAL_IS_FAILED"); \
127                         return val; \
128                 } \
129         } while (0)
130
131 typedef struct appdata
132 {
133         app_control_h app_control;
134
135         Evas_Object *win_main;
136         Evas_Object *conformant;
137         Evas_Object *layout_main;
138
139         Evas_Object *popup;
140 } heremaps_uc_app_data;
141
142 #ifdef __cplusplus
143 }
144 #endif /*__cplusplus */
145
146 #endif /* HEREMAPS_UC_COMMON_H_ */