2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <vconf-keys.h>
32 #include "wifi-power.h"
33 #include "wifi-state.h"
34 #include "wifi-agent.h"
35 #include "wifi-firmware.h"
36 #include "wifi-ssid-scan.h"
37 #include "wifi-passpoint.h"
38 #include "wifi-eap-config.h"
39 #include "wifi-background-scan.h"
40 #include "wifi-config.h"
41 #include "wifi-tdls.h"
43 #if defined TIZEN_WLAN_BOARD_SPRD
44 #define SPRD_CP2_FIRMWARE_PATH "/usr/bin/cp2-downloader"
45 static int is_wifi_firmware_downloaded = FALSE;
48 static Wifi *wifi_object = NULL;
49 static NetConnmanAgent *connman_agent_object = NULL;
50 static WifiFirmware *wififirmware_object = NULL;
52 Wifi *get_wifi_object(void){
56 static gboolean handle_check_black_list(Wifi *wifi, GDBusMethodInvocation *context,
57 const gchar *name, const gchar *security_type, const gchar *eap)
59 ERR("Name (%s)", name);
60 INFO("disable to check");
61 wifi_complete_check_black_list(wifi, context, TRUE);
65 static void _set_wifi_mac_address(void)
67 gchar *mac_addr = NULL;
69 mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
70 if (mac_addr != NULL) {
71 if (strlen(mac_addr) == 0)
72 netconfig_set_mac_address_from_file();
77 void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
80 GDBusConnection *conn = NULL;
83 DBG("WiFi Connection Reply");
85 conn = G_DBUS_CONNECTION(source_object);
86 g_dbus_connection_call_finish(conn, res, &error);
88 ERR("WiFi Connection Error [%s]", error->message);
89 /* No need to emit WiFiConnectFail signal if Connection is
91 if (error->code == G_IO_ERROR_TIMED_OUT) {
93 DBG("WiFi Connection in Progress");
94 netconfig_gdbus_pending_call_unref();
98 if (netconfig_dbus_emit_signal(NULL, NETCONFIG_WIFI_PATH,
99 NETCONFIG_WIFI_INTERFACE, "WiFiConnectFail",
101 ERR("Failed to emit WiFiConnectFail signal");
103 DBG("Successfully sent WiFiConnectFail signal");
105 DBG("WiFi Connection has been initiated successfully");
107 netconfig_gdbus_pending_call_unref();
111 #if defined TIZEN_WLAN_BOARD_SPRD
112 int wifi_firmware_download(void)
115 const char *path = SPRD_CP2_FIRMWARE_PATH;
116 char *const args[] = { SPRD_CP2_FIRMWARE_PATH, NULL };
117 char *const envs[] = { NULL };
119 if (!is_wifi_firmware_downloaded) {
120 rv = netconfig_execute_file(path, args, envs);
122 DBG("wifi firmware download fails");
125 is_wifi_firmware_downloaded = TRUE;
126 DBG("wifi firmware download successes");
133 void wifi_object_create_and_init(void)
135 DBG("Create wifi object.");
136 GDBusInterfaceSkeleton *interface_wifi = NULL;
137 GDBusInterfaceSkeleton *interface_connman_agent = NULL;
138 GDBusInterfaceSkeleton *interface_wifi_firmware = NULL;
139 GDBusConnection *connection = NULL;
140 GDBusObjectManagerServer *server = netdbus_get_wifi_manager();
144 connection = netdbus_get_connection();
145 g_dbus_object_manager_server_set_connection(server, connection);
147 /*Interface netconfig.wifi*/
148 wifi_object = wifi_skeleton_new();
149 interface_wifi = G_DBUS_INTERFACE_SKELETON(wifi_object);
152 g_signal_connect(wifi_object, "handle-load-driver",
153 G_CALLBACK(handle_load_driver), NULL);
154 g_signal_connect(wifi_object, "handle-remove-driver",
155 G_CALLBACK(handle_remove_driver), NULL);
156 g_signal_connect(wifi_object, "handle-load-p2p-driver",
157 G_CALLBACK(handle_load_p2p_driver), NULL);
158 g_signal_connect(wifi_object, "handle-remove-p2p-driver",
159 G_CALLBACK(handle_remove_p2p_driver), NULL);
162 g_signal_connect(wifi_object, "handle-get-wifi-state",
163 G_CALLBACK(handle_get_wifi_state), NULL);
166 g_signal_connect(wifi_object, "handle-request-specific-scan",
167 G_CALLBACK(handle_request_specific_scan), NULL);
168 g_signal_connect(wifi_object, "handle-request-wps-scan",
169 G_CALLBACK(handle_request_wps_scan), NULL);
172 g_signal_connect(wifi_object, "handle-launch-direct",
173 G_CALLBACK(handle_launch_direct), NULL);
176 g_signal_connect(wifi_object, "handle-create-eap-config",
177 G_CALLBACK(handle_create_eap_config), NULL);
178 g_signal_connect(wifi_object, "handle-delete-eap-config",
179 G_CALLBACK(handle_delete_eap_config), NULL);
181 /* WIFI configuration */
182 g_signal_connect(wifi_object, "handle-save-configuration",
183 G_CALLBACK(handle_save_configuration), NULL);
184 g_signal_connect(wifi_object, "handle-remove-configuration",
185 G_CALLBACK(handle_remove_configuration), NULL);
186 g_signal_connect(wifi_object, "handle-get-config-ids",
187 G_CALLBACK(handle_get_config_ids), NULL);
188 g_signal_connect(wifi_object, "handle-load-configuration",
189 G_CALLBACK(handle_load_configuration), NULL);
190 g_signal_connect(wifi_object, "handle-set-config-field",
191 G_CALLBACK(handle_set_config_field), NULL);
192 g_signal_connect(wifi_object, "handle-get-config-passphrase",
193 G_CALLBACK(handle_get_config_passphrase), NULL);
194 /* WIFI EAP configuration */
195 g_signal_connect(wifi_object, "handle-save-eap-configuration",
196 G_CALLBACK(handle_save_eap_configuration), NULL);
197 g_signal_connect(wifi_object, "handle-load-eap-configuration",
198 G_CALLBACK(handle_load_eap_configuration), NULL);
201 g_signal_connect(wifi_object, "handle-set-bgscan",
202 G_CALLBACK(handle_set_bgscan), NULL);
203 g_signal_connect(wifi_object, "handle-resume-bgscan",
204 G_CALLBACK(handle_resume_bgscan), NULL);
205 g_signal_connect(wifi_object, "handle-pause-bgscan",
206 G_CALLBACK(handle_pause_bgscan), NULL);
209 g_signal_connect(wifi_object, "handle-set-passpoint",
210 G_CALLBACK(handle_set_passpoint), NULL);
211 g_signal_connect(wifi_object, "handle-get-passpoint",
212 G_CALLBACK(handle_get_passpoint), NULL);
214 /* EAP authentication */
215 g_signal_connect(wifi_object, "handle-get-aka-auth",
216 G_CALLBACK(handle_get_aka_auth), NULL);
217 g_signal_connect(wifi_object, "handle-get-sim-auth",
218 G_CALLBACK(handle_get_sim_auth), NULL);
219 g_signal_connect(wifi_object, "handle-get-sim-imsi",
220 G_CALLBACK(handle_get_sim_imsi), NULL);
221 g_signal_connect(wifi_object, "handle-req-aka-auth",
222 G_CALLBACK(handle_req_aka_auth), NULL);
223 g_signal_connect(wifi_object, "handle-req-sim-auth",
224 G_CALLBACK(handle_req_sim_auth), NULL);
226 /* WIFI MDM blacklist */
227 g_signal_connect(wifi_object, "handle-check-black-list",
228 G_CALLBACK(handle_check_black_list), NULL);
231 g_signal_connect(wifi_object, "handle-tdls-disconnect",
232 G_CALLBACK(handle_tdls_disconnect), NULL);
233 g_signal_connect(wifi_object, "handle-tdls-connected-peer",
234 G_CALLBACK(handle_tdls_connected_peer), NULL);
236 if (!g_dbus_interface_skeleton_export(interface_wifi, connection,
237 NETCONFIG_WIFI_PATH, NULL)) {
238 ERR("Export WIFI_PATH for wifi failed");
241 /* Interface connman.Agent */
242 connman_agent_object = net_connman_agent_skeleton_new();
244 interface_connman_agent = G_DBUS_INTERFACE_SKELETON(connman_agent_object);
245 g_signal_connect(connman_agent_object, "handle-report-error",
246 G_CALLBACK(handle_report_error), NULL);
247 g_signal_connect(connman_agent_object, "handle-request-browser",
248 G_CALLBACK(handle_request_browser), NULL);
249 g_signal_connect(connman_agent_object, "handle-request-input",
250 G_CALLBACK(handle_request_input), NULL);
251 g_signal_connect(connman_agent_object, "handle-set-field",
252 G_CALLBACK(handle_set_field), NULL);
254 if (!g_dbus_interface_skeleton_export(interface_connman_agent, connection,
255 NETCONFIG_WIFI_PATH, NULL)) {
256 ERR("Export WIFI_PATH for agent failed");
259 /*Interface netconfig.wifi.Firmware*/
260 wififirmware_object = wifi_firmware_skeleton_new();
262 interface_wifi_firmware = G_DBUS_INTERFACE_SKELETON(wififirmware_object);
263 g_signal_connect(wififirmware_object, "handle-start",
264 G_CALLBACK(handle_start), NULL);
265 g_signal_connect(wififirmware_object, "handle-stop",
266 G_CALLBACK(handle_stop), NULL);
268 if (!g_dbus_interface_skeleton_export(interface_wifi_firmware, connection,
269 NETCONFIG_WIFI_PATH, NULL)) {
270 ERR("Export WIFI_PATH for firmware failed");
273 _set_wifi_mac_address();
275 wifi_power_initialize();
280 void wifi_object_deinit(void)
282 g_object_unref(wifi_object);
283 g_object_unref(connman_agent_object);
284 g_object_unref(wififirmware_object);
286 wifi_power_deinitialize();