Remove obsolete file.
[connman] / 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 int wifi_join(struct connman_device *device,
136                                         struct connman_network *network)
137 {
138         int err;
139
140         DBG("device %p", device);
141
142         err = supplicant_connect(network);
143         if (err < 0)
144                 return err;
145
146         connman_network_ref(network);
147
148         connman_device_add_network(device, network);
149
150         connman_network_set_available(network, TRUE);
151
152         return 0;
153 }
154
155 static struct connman_device_driver wifi_driver = {
156         .name           = "wifi",
157         .type           = CONNMAN_DEVICE_TYPE_WIFI,
158         .probe          = wifi_probe,
159         .remove         = wifi_remove,
160         .enable         = wifi_enable,
161         .disable        = wifi_disable,
162         .scan           = wifi_scan,
163         .join           = wifi_join,
164 };
165
166 static void wifi_register(void)
167 {
168         DBG("");
169
170         if (connman_device_driver_register(&wifi_driver) < 0)
171                 connman_error("Failed to register WiFi driver");
172 }
173
174 static void wifi_unregister(void)
175 {
176         DBG("");
177
178         connman_device_driver_unregister(&wifi_driver);
179 }
180
181 static struct supplicant_driver supplicant = {
182         .name           = "wifi",
183         .probe          = wifi_register,
184         .remove         = wifi_unregister,
185 };
186
187 static int wifi_init(void)
188 {
189         int err;
190
191         err = connman_network_driver_register(&network_driver);
192         if (err < 0)
193                 return err;
194
195         err = supplicant_register(&supplicant);
196         if (err < 0) {
197                 connman_network_driver_unregister(&network_driver);
198                 return err;
199         }
200
201         return 0;
202 }
203
204 static void wifi_exit(void)
205 {
206         supplicant_unregister(&supplicant);
207
208         connman_network_driver_unregister(&network_driver);
209 }
210
211 CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
212                 CONNMAN_PLUGIN_PRIORITY_DEFAULT, wifi_init, wifi_exit)