Remove broken and unused callback for joining networks
[framework/connectivity/connman.git] / plugins / wifi.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <errno.h>
27
28 #include <dbus/dbus.h>
29 #include <glib.h>
30
31 #define CONNMAN_API_SUBJECT_TO_CHANGE
32 #include <connman/plugin.h>
33 #include <connman/device.h>
34 #include <connman/log.h>
35
36 #include "supplicant.h"
37
38 #define CLEANUP_TIMEOUT   8     /* in seconds */
39 #define INACTIVE_TIMEOUT  12    /* in seconds */
40
41 struct wifi_data {
42         char *identifier;
43         connman_bool_t connected;
44 };
45
46 static int network_probe(struct connman_network *network)
47 {
48         DBG("network %p", network);
49
50         return 0;
51 }
52
53 static void network_remove(struct connman_network *network)
54 {
55         DBG("network %p", network);
56 }
57
58 static int network_connect(struct connman_network *network)
59 {
60         DBG("network %p", network);
61
62         return supplicant_connect(network);
63 }
64
65 static int network_disconnect(struct connman_network *network)
66 {
67         DBG("network %p", network);
68
69         return supplicant_disconnect(network);
70 }
71
72 static struct connman_network_driver network_driver = {
73         .name           = "wifi",
74         .type           = CONNMAN_NETWORK_TYPE_WIFI,
75         .probe          = network_probe,
76         .remove         = network_remove,
77         .connect        = network_connect,
78         .disconnect     = network_disconnect,
79 };
80
81 static int wifi_probe(struct connman_device *device)
82 {
83         struct wifi_data *data;
84
85         DBG("device %p", device);
86
87         data = g_try_new0(struct wifi_data, 1);
88         if (data == NULL)
89                 return -ENOMEM;
90
91         data->connected = FALSE;
92
93         connman_device_set_data(device, data);
94
95         return 0;
96 }
97
98 static void wifi_remove(struct connman_device *device)
99 {
100         struct wifi_data *data = connman_device_get_data(device);
101
102         DBG("device %p", device);
103
104         connman_device_set_data(device, NULL);
105
106         g_free(data->identifier);
107         g_free(data);
108 }
109
110 static int wifi_enable(struct connman_device *device)
111 {
112         DBG("device %p", device);
113
114         return supplicant_start(device);
115 }
116
117 static int wifi_disable(struct connman_device *device)
118 {
119         struct wifi_data *data = connman_device_get_data(device);
120
121         DBG("device %p", device);
122
123         data->connected = FALSE;
124
125         return supplicant_stop(device);
126 }
127
128 static int wifi_scan(struct connman_device *device)
129 {
130         DBG("device %p", device);
131
132         return supplicant_scan(device);
133 }
134
135 static struct connman_device_driver wifi_driver = {
136         .name           = "wifi",
137         .type           = CONNMAN_DEVICE_TYPE_WIFI,
138         .probe          = wifi_probe,
139         .remove         = wifi_remove,
140         .enable         = wifi_enable,
141         .disable        = wifi_disable,
142         .scan           = wifi_scan,
143 };
144
145 static void wifi_register(void)
146 {
147         DBG("");
148
149         if (connman_device_driver_register(&wifi_driver) < 0)
150                 connman_error("Failed to register WiFi driver");
151 }
152
153 static void wifi_unregister(void)
154 {
155         DBG("");
156
157         connman_device_driver_unregister(&wifi_driver);
158 }
159
160 static struct supplicant_driver supplicant = {
161         .name           = "wifi",
162         .probe          = wifi_register,
163         .remove         = wifi_unregister,
164 };
165
166 static int wifi_init(void)
167 {
168         int err;
169
170         err = connman_network_driver_register(&network_driver);
171         if (err < 0)
172                 return err;
173
174         err = supplicant_register(&supplicant);
175         if (err < 0) {
176                 connman_network_driver_unregister(&network_driver);
177                 return err;
178         }
179
180         return 0;
181 }
182
183 static void wifi_exit(void)
184 {
185         supplicant_unregister(&supplicant);
186
187         connman_network_driver_unregister(&network_driver);
188 }
189
190 CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
191                 CONNMAN_PLUGIN_PRIORITY_DEFAULT, wifi_init, wifi_exit)