[TSAM-1605] Fixed the issue Confusing error code is returned if wifi is already initi...
[platform/core/api/wifi.git] / include / net_wifi_private.h
1 /*
2  * Copyright (c) 2012-2013 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 #ifndef __NET_CONNECTION_PRIVATE_H__
18 #define __NET_CONNECTION_PRIVATE_H__
19
20 #include <dlog.h>
21 #include <network-cm-intf.h>
22 #include <network-wifi-intf.h>
23 #include <system_info.h>
24
25 #include "wifi.h"
26 #include "wifi_dbus_private.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 #undef LOG_TAG
33 #define LOG_TAG "CAPI_NETWORK_WIFI"
34
35 #define WIFI_INFO       1
36 #define WIFI_ERROR      2
37 #define WIFI_WARN       3
38
39 #define WIFI_FEATURE    "http://tizen.org/feature/network.wifi"
40 #define WIFI_TDLS_FEATURE       "http://tizen.org/feature/network.wifi.tdls"
41
42 typedef enum
43 {
44         WIFI_SUPPORTED_FEATURE_WIFI,
45         WIFI_SUPPORTED_FEATURE_WIFI_TDLS,
46         WIFI_SUPPORTED_FEATURE_MAX,
47 } wifi_supported_feature_e;
48
49
50 #define CHECK_FEATURE_SUPPORTED(...) \
51         do { \
52                 int rv = _wifi_check_feature_supported(__VA_ARGS__, NULL); \
53                 if( rv != WIFI_ERROR_NONE ) \
54                         return rv; \
55         } while(0)
56
57 #define WIFI_LOG(log_level, format, args...) \
58         do { \
59                 switch (log_level) { \
60                 case WIFI_ERROR: \
61                         LOGE(format, ## args); \
62                         break; \
63                 case WIFI_WARN: \
64                         LOGW(format, ## args); \
65                         break; \
66                 default: \
67                         LOGI(format, ## args); \
68                 } \
69         } while(0)
70
71 #define SECURE_WIFI_LOG(log_level, format, args...) \
72         do { \
73                 switch (log_level) { \
74                 case WIFI_ERROR: \
75                         SECURE_LOGE(format, ## args); \
76                         break; \
77                 case WIFI_WARN: \
78                         SECURE_LOGW(format, ## args); \
79                         break; \
80                 default: \
81                         SECURE_LOGI(format, ## args); \
82                 } \
83         } while(0)
84
85 bool _wifi_is_init(void);
86
87 int _wifi_libnet_init(void);
88 bool _wifi_libnet_deinit(void);
89 int _wifi_activate(wifi_activated_cb callback, gboolean wifi_picker_test, void *user_data);
90 int _wifi_deactivate(wifi_deactivated_cb callback, void *user_data);
91
92 bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h);
93 void _wifi_libnet_add_to_ap_list(wifi_ap_h ap_h);
94 void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h);
95 bool _wifi_libnet_check_profile_name_validity(const char *profile_name);
96
97 int _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state);
98 int _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state);
99 int _wifi_libnet_get_intf_name(char** name);
100 int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void *user_data);
101 int _wifi_libnet_scan_specific_ap(const char *essid, wifi_scan_finished_cb callback, void *user_data);
102 int _wifi_libnet_get_connected_profile(wifi_ap_h *ap);
103 int _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data);
104 int _wifi_libnet_foreach_found_specific_aps(wifi_found_ap_cb callback, void *user_data);
105
106 int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void *user_data);
107 int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void *user_data);
108 int _wifi_libnet_connect_with_wps_pbc(wifi_ap_h ap,
109                 wifi_connected_cb callback, void *user_data);
110 int _wifi_libnet_connect_with_wps_pin(wifi_ap_h ap, const char *pin,
111                 wifi_connected_cb callback, void *user_data);
112 int _wifi_libnet_forget_ap(wifi_ap_h ap);
113
114 int _wifi_set_power_on_off_cb(wifi_device_state_changed_cb callback, void *user_data);
115 int _wifi_unset_power_on_off_cb(void);
116 int _wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data);
117 int _wifi_unset_background_scan_cb(void);
118 int _wifi_set_connection_state_cb(wifi_connection_state_changed_cb callback, void *user_data);
119 int _wifi_unset_connection_state_cb();
120
121 int _wifi_update_ap_info(net_profile_info_t *ap_info);
122 wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state);
123
124 guint _wifi_callback_add(GSourceFunc func, gpointer user_data);
125 void _wifi_callback_cleanup(void);
126
127 int _wifi_libnet_check_get_privilege();
128 int _wifi_libnet_check_profile_privilege();
129
130 bool __libnet_check_feature_supported(const char *key, wifi_supported_feature_e feature);
131 int _wifi_check_feature_supported(const char *feature_name, ...);
132
133 int        _wifi_dbus_init(void);
134 int        _wifi_dbus_deinit(void);
135 wifi_dbus *_wifi_get_dbus_handle(void);
136
137 #ifdef __cplusplus
138 }
139 #endif /* __cplusplus */
140
141 #endif