edf0e8976ebe1f1154d3e0c699e78914fe204a96
[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 <Elementary.h>
41 #include <libintl.h>
42 #include <stdio.h>
43 #include <string.h>
44 #include <efl_extension.h>
45 #include <system_info.h>
46
47 #if !defined(HEREMAPS_UC_PKG)
48 #define HEREMAPS_UC_PKG "org.tizen.heremaps-uc"
49 #endif
50
51 #define DOMAIN_NAME HEREMAPS_UC_PKG
52
53 #define TAG_HEREMAPS_UC "HEREMAPS_UC"
54 #define HEREMAPS_UC_DLOG_DEBUG
55
56 #ifdef HEREMAPS_UC_DLOG_DEBUG        /**< if debug mode, show filename & line number */
57
58 #ifdef LOG_TAG
59 #undef LOG_TAG
60 #define LOG_TAG TAG_HEREMAPS_UC
61 #endif
62
63 #define LS_LOGD(fmt,args...)  LOGD(fmt, ##args)
64 #define LS_LOGW(fmt,args...)  LOGW(fmt, ##args)
65 #define LS_LOGI(fmt,args...)  LOGI(fmt, ##args)
66 #define LS_LOGE(fmt,args...)  LOGE(fmt, ##args)
67
68 #elif HEREMAPS_UC_DLOG_RELEASE      /* if release mode */
69
70 #ifdef LOG_TAG
71 #undef LOG_TAG
72 #define LOG_TAG TAG_HEREMAPS_UC
73 #endif
74
75 #define LS_LOGD(fmt,args...)  LOGD(fmt, ##args)
76 #define LS_LOGW(fmt,args...)  LOGW(fmt, ##args)
77 #define LS_LOGI(fmt,args...)  LOGI(fmt, ##args)
78 #define LS_LOGE(fmt,args...)  LOGE(fmt, ##args)
79 #else                       /* if do not use dlog */
80 #define LS_LOGD(...)  g_debug(__VA_ARGS__)
81 #define LS_LOGW(...)  g_warning(__VA_ARGS__)
82 #define LS_LOGI(...)  g_message(__VA_ARGS__)
83 #define LS_LOGE(...)  g_error(__VA_ARGS__)
84 #endif
85
86 #define P_(s)                   dgettext(HEREMAPS_UC_PKG, s)
87 #define S_(s)                   dgettext("sys_string", s)
88 #define dgettext_noop(s)        (s)
89 #define N_(s)                   dgettext_noop(s)
90
91 #define KEY_ENABLED     1
92 #define KEY_DISABLED 0
93
94 #define LS_FUNC_ENTER   LS_LOGD("(%s) ENTER", __FUNCTION__);
95 #define LS_FUNC_EXIT    LS_LOGD("(%s) EXIT", __FUNCTION__);
96
97 #define SAFE_STRDUP(src) (src) ? strdup(src) : NULL
98
99 #define LS_MEM_FREE(ptr)        \
100         do { \
101                 if (ptr != NULL) {      \
102                         free((void *)ptr);      \
103                         ptr = NULL;     \
104                 }       \
105         } while (0)
106
107
108 #define LS_MEM_NEW(ptr, num_elements, type)      \
109         do { \
110                 if ((int)(num_elements) <= 0) { \
111                         ptr = NULL; \
112                 } else { \
113                         ptr = (type *) calloc(num_elements, sizeof(type)); \
114                 } \
115         } while (0)
116
117
118 #define LS_RETURN_IF_FAILED(point) do { \
119                 if (point == NULL) { \
120                         LS_LOGE("critical error : LS_RETURN_IF_FAILED"); \
121                         return; \
122                 } \
123         } while (0)
124
125 #define LS_RETURN_VAL_IF_FAILED(point, val) do { \
126                 if (point == NULL) { \
127                         LS_LOGE("critical error : NAVI_RETURN_VAL_IS_FAILED"); \
128                         return val; \
129                 } \
130         } while (0)
131
132 typedef struct appdata
133 {
134         app_control_h app_control;
135
136         Evas_Object *win_main;
137         Evas_Object *conformant;
138         Evas_Object *layout_main;
139
140         Evas_Object *popup;
141 } heremaps_uc_app_data;
142
143 #ifdef __cplusplus
144 }
145 #endif /*__cplusplus */
146
147 #endif /* HEREMAPS_UC_COMMON_H_ */