Fix memory leaks
[platform/core/connectivity/net-config.git] / include / wifi-state.h
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 __NETCONFIG_WIFI_STATE_H__
21 #define __NETCONFIG_WIFI_STATE_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <glib.h>
28
29 typedef enum {
30         NETCONFIG_WIFI_UNKNOWN          = 0x00,
31         NETCONFIG_WIFI_IDLE                     = 0x01,
32         NETCONFIG_WIFI_ASSOCIATION      = 0x02,
33         NETCONFIG_WIFI_CONFIGURATION    = 0x03,
34         NETCONFIG_WIFI_CONNECTED        = 0x04,
35         NETCONFIG_WIFI_FAILURE          = 0x05,
36 } wifi_service_state_e;
37
38 typedef enum {
39         NETCONFIG_WIFI_TECH_UNKNOWN             = 0x00,
40         NETCONFIG_WIFI_TECH_OFF                         = 0x01,
41         NETCONFIG_WIFI_TECH_WPS_ONLY            = 0x02,
42         NETCONFIG_WIFI_TECH_POWERED                     = 0x03,
43         NETCONFIG_WIFI_TECH_CONNECTED           = 0x04,
44         NETCONFIG_WIFI_TECH_TETHERED            = 0x05,
45 } wifi_tech_state_e;
46
47 typedef struct wifi_state_notifier{
48         struct wifi_state_notifier *notifier;
49         char *service;
50         void (*wifi_state_changed)(struct wifi_state_notifier *,
51                 char *, wifi_service_state_e, void *);
52         void *user_data;
53 } wifi_state_notifier_s;
54
55 typedef struct {
56         char *interface_name;
57         char *mac_address;
58         gboolean powered;
59         gboolean connected;
60         wifi_tech_state_e tech_state;
61         wifi_service_state_e service_state;
62         guint64 rx;
63         guint64 tx;
64         guint64 rx_diff;
65         guint64 tx_diff;
66 } wifi_device_data_s;
67
68 char *_convert_wifi_technology_state_to_string(wifi_tech_state_e wifi_tech_state_type);
69 char *_convert_wifi_service_state_to_string(wifi_service_state_e wifi_service_state_type);
70
71 void wifi_state_update_power_state(const char *interface_name, gboolean powered);
72 void wifi_state_emit_power_completed(const char *interface_name, gboolean power_on);
73 void wifi_state_emit_power_failed(const char *interface_name);
74
75 char *wifi_get_favorite_service(void);
76 void wifi_start_timer_network_notification(const char *interface_name);
77
78 void wifi_state_notifier_register(wifi_state_notifier_s *notifier);
79 void wifi_state_notifier_unregister(wifi_state_notifier_s *notifier);
80 void wifi_state_notifier_cleanup(void);
81
82 void wifi_state_set_bss_found(gboolean found);
83 gboolean wifi_state_is_bss_found(void);
84
85 gboolean wifi_state_update_device_list(void);
86 GSList *wifi_state_get_device_list(void);
87
88 void wifi_state_set_service_state(const char *interface_name,
89                 const char *service, wifi_service_state_e new_state);
90 wifi_service_state_e wifi_state_get_service_state(const char *interface_name);
91
92 void wifi_state_set_technology_state(const char *interface_name, wifi_tech_state_e new_state);
93 wifi_tech_state_e wifi_state_get_technology_state(const char *interface_name);
94
95 void wifi_state_set_powered(const char *interface_name, gboolean powered);
96 gboolean wifi_state_get_powered(const char *interface_name);
97
98 void wifi_state_set_connected(const char *interface_name, gboolean connected);
99 gboolean wifi_state_get_connected(const char *interface_name);
100
101 gboolean wifi_state_is_existed(const char *interface_name);
102 const char *wifi_state_get_interface_name(const char *mac_address);
103 const char *wifi_state_get_mac_address(const char *interface_name);
104
105 void wifi_state_set_connected_essid(void);
106 void wifi_state_get_connected_essid(gchar **essid);
107
108 void wifi_state_initialize(void);
109 void wifi_state_deinitialize(void);
110
111
112 #ifdef __cplusplus
113 }
114 #endif
115
116 #endif /* __NETCONFIG_WIFI_STATE_H__ */