Reduce unnecessary directory depth
[apps/native/ug-wifi-efl.git] / sources / libraries / WlanManager / connection_manager.c
1 #include <vconf.h>
2 #include <vconf-keys.h>
3 #include <net_connection.h>
4
5 #include "common.h"
6 #include "wlan_manager.h"
7 #include "connection_manager.h"
8
9 static connection_h connection = NULL;
10
11 static void _connection_type_changed_cb(connection_type_e type, void* user_data)
12 {
13         __COMMON_FUNC_ENTER__;
14
15         if (wlan_manager_state_get() != WLAN_MANAGER_CONNECTED)
16                 return;
17
18         if (type == CONNECTION_TYPE_CELLULAR ||
19                         type == CONNECTION_TYPE_WIFI)
20                 wlan_manager_scanned_profile_refresh();
21
22         __COMMON_FUNC_EXIT__;
23 }
24
25 gboolean connection_manager_create(void)
26 {
27         __COMMON_FUNC_ENTER__;
28
29         int ret;
30
31         ret = connection_create(&connection);
32         if (ret != CONNECTION_ERROR_NONE)
33                 return FALSE;
34
35         ret = connection_set_type_changed_cb(connection, _connection_type_changed_cb, NULL);
36         if (ret != CONNECTION_ERROR_NONE)
37                 return FALSE;
38
39         __COMMON_FUNC_EXIT__;
40         return TRUE;
41 }
42
43 gboolean connection_manager_destroy(void)
44 {
45         __COMMON_FUNC_ENTER__;
46
47         int ret;
48
49         if (connection == NULL)
50                 return FALSE;
51
52         ret = connection_destroy(connection);
53         if (ret != CONNECTION_ERROR_NONE)
54                 return FALSE;
55
56         connection = NULL;
57
58         __COMMON_FUNC_EXIT__;
59         return TRUE;
60 }
61
62 gboolean connection_manager_is_wifi_connection_used(void)
63 {
64         __COMMON_FUNC_ENTER__;
65
66         int ret;
67         connection_type_e type;
68
69         if (connection == NULL)
70                 return FALSE;
71
72         ret = connection_get_type(connection, &type);
73         if (ret != CONNECTION_ERROR_NONE)
74                 return FALSE;
75
76         if (type != CONNECTION_TYPE_WIFI)
77                 return FALSE;
78
79         __COMMON_FUNC_EXIT__;
80         return TRUE;
81 }