[ug-wifi-direct]Sync with Tizen 2.4
[apps/native/ug-wifi-direct.git] / popup-wifidirect / include / wfd-app-util.h
1 /*
2 *  WiFi-Direct UG
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 /**
21  * This file declares wifi direct application util functions.
22  *
23  * @file    wfd-app-util.h
24  * @author  Sungsik Jang (sungsik.jang@samsung.com)
25  * @version 0.1
26  */
27
28
29 #ifndef __WFD_APP_UTIL_H__
30 #define __WFD_APP_UTIL_H__
31
32 #ifdef VITA_FEATURE
33 #include <dlog.h>
34
35 #define WIFI_DIRECT_APP_MID             "wfd-app"
36
37 #define WFD_APP_LOG_LOW LOG_INFO
38 #define WFD_APP_LOG_HIGH        LOG_INFO
39 #define WFD_APP_LOG_ERROR       LOG_ERROR
40 #define WFD_APP_LOG_WARN        LOG_WARN
41 #define WFD_APP_LOG_ASSERT      LOG_FATAL
42 #define WFD_APP_LOG_EXCEPTION   LOG_FATAL
43 #define WFD_MAX_SIZE            128
44 #define WFD_MAC_ADDRESS_SIZE    18
45
46 char *wfd_app_trim_path(const char *filewithpath);
47 int wfd_app_gettid();
48 /* TODO:: To change the log level as LOG_INFO */
49 #define WFD_APP_LOG(log_level, format, args...) \
50         LOG(LOG_ERROR, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__),  __LINE__, wfd_app_gettid(), ##args)
51 #define WFD_APP_LOGSECURE(log_level, format, args...) \
52         SECURE_LOG(LOG_ERROR, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__),  __LINE__, wfd_app_gettid(), ##args)
53
54 #if 0
55 #define __WFD_APP_FUNC_ENTER__  LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Enter: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
56 #define __WFD_APP_FUNC_EXIT__   LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
57 #else
58 #define __WFD_APP_FUNC_ENTER__
59 #define __WFD_APP_FUNC_EXIT__
60 #endif
61
62 #else /** _DLOG_UTIL */
63
64 #define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), ##args)
65 #if 0
66 #define __WFD_APP_FUNC_ENTER__  printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
67 #define __WFD_APP_FUNC_EXIT__   printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
68 #else
69 #define __WFD_APP_FUNC_ENTER__
70 #define __WFD_APP_FUNC_EXIT__
71 #endif
72
73 #endif /** _USE_DLOG_UTIL */
74
75 #define WFD_RET_IF(expr, fmt, args...) \
76         do { \
77                 if(expr) { \
78                         WFD_APP_LOG(WFD_APP_LOG_ERROR, "[%s] Return, message "fmt, #expr, ##args );\
79                         return; \
80                 } \
81         } while (0)
82
83 #define WFD_IF_FREE_MEM(mem) \
84         do { \
85                 if(mem) { \
86                         free(mem); \
87                         mem = NULL; \
88                 } \
89         } while (0)
90
91 #define WFD_RETV_IF(expr, val, fmt, args...) \
92         do { \
93                 if(expr) { \
94                         WFD_APP_LOG(WFD_APP_LOG_ERROR, "[%s] Return value, message "fmt, #expr, ##args );\
95                         return (val); \
96                 } \
97         } while (0)
98
99 #define assertm_if(expr, fmt, arg...) do { \
100         if (expr) { \
101           WFD_APP_LOG(WFD_APP_LOG_ASSERT, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
102                  exit(1); \
103         } \
104 } while (0)
105
106 int wfd_app_util_register_hard_key_down_cb(void *data);
107 int wfd_app_util_register_vconf_callbacks(void *data);
108 int wfd_app_util_deregister_vconf_callbacks(void *data);
109
110 void wfd_app_util_del_notification(wfd_appdata_t *ad);
111 #ifdef NOT_CONNECTED_INDICATOR_ICON
112 void wfd_app_util_add_indicator_icon(void *user_data);
113 #endif
114 void wfd_app_util_add_wfd_turn_off_notification(void *user_data);
115
116 #ifdef WFD_SCREEN_MIRRORING_ENABLED
117 void wfd_app_util_set_screen_mirroring_deactivated(wfd_appdata_t *ad);
118 #endif
119 void wfd_app_util_del_wfd_connected_notification(wfd_appdata_t *ad);
120 #endif /* __WFD_APP_UTIL_H__ */