a04c432c81fe304e02347fd9dd99eddef428a382
[apps/native/ug-wifi-efl.git] / sources / libraries / Common / include / common.h
1 /*
2  * Wi-Fi
3  *
4  * Copyright 2012 Samsung Electronics Co., Ltd
5  *
6  * Licensed under the Flora License, Version 1.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.tizenopensource.org/license
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __COMMON_H__
21 #define __COMMON_H__
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27
28 #include <dlog.h>
29 #include <assert.h>
30
31 #define COMMON_NAME_FUNC        "wifi/func"
32 #define COMMON_NAME_LIB         "wifi/lib"
33 #define COMMON_NAME_ERR         "wifi/err"
34 #define UG_NAME_NORMAL          "wifi_ug"
35 #define UG_NAME_RESP            "wifi_ug/resp"
36 #define UG_NAME_REQ                     "wifi_ug/req"
37 #define UG_NAME_SCAN            "wifi_ug/scan"
38 #define UG_NAME_ERR                     "wifi_ug/err"
39 #define SP_NAME_NORMAL          "wifi_sp"
40 #define SP_NAME_ERR                     "wifi_sp/err"
41
42 #define CUSTOM_EDITFIELD_PATH \
43                         "/usr/apps/wifi-efl-ug/res/edje/wifi-efl-UG/custom_editfield.edj"
44 #define SETUP_WIZARD_EDJ_PATH \
45                         "/usr/apps/wifi-efl-ug/res/edje/wifi-efl-UG/setup_wizard.edj"
46
47 /* Log Level */
48 #define COMMON_LOG_DEBUG        LOG_DEBUG
49 #define COMMON_LOG_INFO         LOG_INFO
50 #define COMMON_LOG_WARN         LOG_WARN
51 #define COMMON_LOG_ERROR        LOG_ERROR
52
53 #define MAX_DEVICE_ICON_PATH_STR_LEN                    256
54 #define SCREEN_TYPE_ID_KEY                              "screen_type_id_key"
55
56 /* Device-picker height for portrait mode*/
57 #define DEVICE_PICKER_POPUP_H           550
58
59 /* Device-picker height for portrait mode in EAP screen with keypad*/
60 #define DEVICE_PICKER_POPUP_EAP_KEYPAD_H                260
61
62 /* Device-picker height for landscape mode */
63 #define DEVICE_PICKER_POPUP_LN_H                220
64
65 /* Device-picker height for zero profiles (same as defined in EDC file)*/
66 #define DEVICE_PICKER_EMPTY_POPUP_H 100
67
68 /* Device-picker width for landscape mode */
69 #define DEVICE_PICKER_POPUP_LN_W                600
70
71 /* Genlist new style for Tizen 2.4 */
72 #define WIFI_GENLIST_1LINE_TEXT_STYLE "type1"
73 #define WIFI_GENLIST_1LINE_TEXT_ICON_STYLE "type1"
74 #define WIFI_GENLIST_2LINE_TOP_TEXT_STYLE "type1"
75 #define WIFI_GENLIST_2LINE_TOP_TEXT_ICON_STYLE "type1"
76 #define WIFI_GENLIST_2LINE_BOTTOM_TEXT_STYLE "type2"
77 #define WIFI_GENLIST_2LINE_BOTTOM_TEXT_ICON_STYLE "type2"
78 #define WIFI_GENLIST_MULTILINE_TEXT_STYLE "multiline"
79 #define WIFI_GENLIST_GROUP_INDEX_STYLE "group_index"
80
81 typedef enum {
82         UG_VIEW_DEFAULT = 0,
83         UG_VIEW_SETUP_WIZARD
84 } UG_TYPE;
85
86 typedef enum {
87         VIEW_MANAGER_VIEW_TYPE_MAIN,
88         VIEW_MANAGER_VIEW_TYPE_DETAIL,
89         VIEW_MANAGER_VIEW_TYPE_ADVANCED,
90         VIEW_MANAGER_VIEW_TYPE_EAP,
91         VIEW_MANAGER_VIEW_TYPE_PASSWD_POPUP,
92 } view_manager_view_type_t;
93
94 #define __COMMON_FUNC_ENTER__ \
95         FUNC_LOG(COMMON_NAME_FUNC, "[<Entering]: %s() [%d]", __func__, __LINE__)
96 #define __COMMON_FUNC_EXIT__ \
97         FUNC_LOG(COMMON_NAME_FUNC, "[Quit/>]: %s() [%d]", __func__, __LINE__)
98
99 #define FUNC_LOG(MID, format, args...) \
100         SLOG(LOG_INFO, MID, "\033[2m[%s:%d]\033[2m " format "\033[0m", __func__, __LINE__, ##args)
101 #define DEBUG_LOG(MID, format, args...) \
102         SLOG(LOG_DEBUG, MID, "\033[42m[%s:%d]\033[0m\033[32m " format "\033[0m", __func__, __LINE__, ##args)
103 #define INFO_LOG(MID, format, args...) \
104         SLOG(LOG_INFO, MID, "\033[0m[%s:%d]\033[0m " format, __func__, __LINE__, ##args)
105 #define WARN_LOG(MID, format, args...) \
106         SLOG(LOG_WARN, MID, "\033[43m[%s:%d]\033[0m\033[33m " format "\033[0m", __func__, __LINE__, ##args)
107 #define ERROR_LOG(MID, format, args...) \
108         SLOG(LOG_ERROR, MID, "\033[41m[%s:%d]\033[0m\033[31m " format "\033[0m", __func__, __LINE__, ##args)
109
110 #define SECURE_FUNC_LOG(MID, format, args...) \
111         SECURE_SLOG(LOG_INFO, MID, "\033[2m[%s:%d]\033[2m " format "\033[0m", __func__, __LINE__, ##args)
112 #define SECURE_DEBUG_LOG(MID, format, args...) \
113         SECURE_SLOG(LOG_DEBUG, MID, "\033[42m[%s:%d]\033[0m\033[32m " format "\033[0m", __func__, __LINE__, ##args)
114 #define SECURE_INFO_LOG(MID, format, args...) \
115         SECURE_SLOG(LOG_INFO, MID, "\033[0m[%s:%d]\033[0m " format, __func__, __LINE__, ##args)
116 #define SECURE_WARN_LOG(MID, format, args...) \
117         SECURE_SLOG(LOG_WARN, MID, "\033[43m[%s:%d]\033[0m\033[33m " format "\033[0m", __func__, __LINE__, ##args)
118 #define SECURE_ERROR_LOG(MID, format, args...) \
119         SECURE_SLOG(LOG_ERROR, MID, "\033[41m[%s:%d]\033[0m\033[31m " format "\033[0m", __func__, __LINE__, ##args)
120
121 #define retm_if(expr) do { \
122         if (expr) { \
123                 ERROR_LOG(COMMON_NAME_ERR, "[%s(): %d] (%s) [return]", __FUNCTION__, __LINE__, #expr); \
124                 return; \
125         } \
126 } while (0)
127
128 #define retvm_if(expr, val) do { \
129         if (expr) { \
130                 ERROR_LOG(COMMON_NAME_ERR, "[%s(): %d] (%s) [return]", __FUNCTION__, __LINE__, #expr); \
131                 return (val); \
132         } \
133 } while (0)
134
135 #define assertm_if(expr, fmt, arg...) do { \
136         if(expr) { \
137                 ERROR_LOG(COMMON_NAME_ERR, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
138                 assert(1); \
139         } \
140 } while (0) /* retvm if */
141
142 #ifdef __cplusplus
143 }
144 #endif
145
146 #endif