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"
42 static Wifi *wifi_object = NULL;
43 static NetConnmanAgent *connman_agent_object = NULL;
44 static WifiFirmware *wififirmware_object = NULL;
46 Wifi *get_wifi_object(void){
50 static gboolean handle_check_black_list(Wifi *wifi, GDBusMethodInvocation *context,
51 const gchar *name, const gchar *security_type, const gchar *eap)
53 ERR("Name (%s)", name);
54 INFO("disable to check");
55 wifi_complete_check_black_list (wifi, context, TRUE);
59 static void _set_wifi_mac_address(void)
61 gchar *mac_addr = NULL;
63 mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
64 if (mac_addr != NULL) {
65 if (strlen(mac_addr) == 0)
66 netconfig_set_mac_address_from_file();
71 void wifi_object_create_and_init(void)
73 DBG("Create wifi object.");
74 GDBusInterfaceSkeleton *interface_wifi = NULL;
75 GDBusInterfaceSkeleton *interface_connman_agent = NULL;
76 GDBusInterfaceSkeleton *interface_wifi_firmware = NULL;
77 GDBusConnection *connection = NULL;
78 GDBusObjectManagerServer *server = netdbus_get_wifi_manager();
82 connection = netdbus_get_connection();
83 g_dbus_object_manager_server_set_connection(server, connection);
85 /*Interface netconfig.wifi*/
86 wifi_object = wifi_skeleton_new();
87 interface_wifi = G_DBUS_INTERFACE_SKELETON(wifi_object);
90 g_signal_connect(wifi_object, "handle-load-driver",
91 G_CALLBACK(handle_load_driver), NULL);
92 g_signal_connect(wifi_object, "handle-remove-driver",
93 G_CALLBACK(handle_remove_driver), NULL);
94 g_signal_connect(wifi_object, "handle-load-p2p-driver",
95 G_CALLBACK(handle_load_p2p_driver), NULL);
96 g_signal_connect(wifi_object, "handle-remove-p2p-driver",
97 G_CALLBACK(handle_remove_p2p_driver), NULL);
100 g_signal_connect(wifi_object, "handle-get-wifi-state",
101 G_CALLBACK(handle_get_wifi_state), NULL);
104 g_signal_connect(wifi_object, "handle-request-specific-scan",
105 G_CALLBACK(handle_request_specific_scan), NULL);
106 g_signal_connect(wifi_object, "handle-request-wps-scan",
107 G_CALLBACK(handle_request_wps_scan), NULL);
110 g_signal_connect(wifi_object, "handle-launch-direct",
111 G_CALLBACK(handle_launch_direct), NULL);
114 g_signal_connect(wifi_object, "handle-create-eap-config",
115 G_CALLBACK(handle_create_eap_config), NULL);
116 g_signal_connect(wifi_object, "handle-delete-eap-config",
117 G_CALLBACK(handle_delete_eap_config), NULL);
119 // WIFI configuration
120 g_signal_connect(wifi_object, "handle-save-configuration",
121 G_CALLBACK(handle_save_configuration), NULL);
122 g_signal_connect(wifi_object, "handle-remove-configuration",
123 G_CALLBACK(handle_remove_configuration), NULL);
124 g_signal_connect(wifi_object, "handle-get-config-ids",
125 G_CALLBACK(handle_get_config_ids), NULL);
126 g_signal_connect(wifi_object, "handle-load-configuration",
127 G_CALLBACK(handle_load_configuration), NULL);
128 g_signal_connect(wifi_object, "handle-set-config-field",
129 G_CALLBACK(handle_set_config_field), NULL);
130 g_signal_connect(wifi_object, "handle-get-config-passphrase",
131 G_CALLBACK(handle_get_config_passphrase), NULL);
132 // WIFI EAP configuration
133 g_signal_connect(wifi_object, "handle-save-eap-configuration",
134 G_CALLBACK(handle_save_eap_configuration), NULL);
135 g_signal_connect(wifi_object, "handle-load-eap-configuration",
136 G_CALLBACK(handle_load_eap_configuration), NULL);
139 g_signal_connect(wifi_object, "handle-set-bgscan",
140 G_CALLBACK(handle_set_bgscan), NULL);
141 g_signal_connect(wifi_object, "handle-resume-bgscan",
142 G_CALLBACK(handle_resume_bgscan), NULL);
143 g_signal_connect(wifi_object, "handle-pause-bgscan",
144 G_CALLBACK(handle_pause_bgscan), NULL);
147 g_signal_connect(wifi_object, "handle-set-passpoint",
148 G_CALLBACK(handle_set_passpoint), NULL);
149 g_signal_connect(wifi_object, "handle-get-passpoint",
150 G_CALLBACK(handle_get_passpoint), NULL);
152 // EAP authentication
153 g_signal_connect(wifi_object, "handle-get-aka-auth",
154 G_CALLBACK(handle_get_aka_auth), NULL);
155 g_signal_connect(wifi_object, "handle-get-sim-auth",
156 G_CALLBACK(handle_get_sim_auth), NULL);
157 g_signal_connect(wifi_object, "handle-get-sim-imsi",
158 G_CALLBACK(handle_get_sim_imsi), NULL);
159 g_signal_connect(wifi_object, "handle-req-aka-auth",
160 G_CALLBACK(handle_req_aka_auth), NULL);
161 g_signal_connect(wifi_object, "handle-req-sim-auth",
162 G_CALLBACK(handle_req_sim_auth), NULL);
164 // WIFI MDM blacklist
165 g_signal_connect(wifi_object, "handle-check-black-list",
166 G_CALLBACK(handle_check_black_list), NULL);
168 if (!g_dbus_interface_skeleton_export(interface_wifi, connection,
169 NETCONFIG_WIFI_PATH, NULL)) {
170 ERR("Export WIFI_PATH for wifi failed");
173 /*Interface connman.Agent*/
174 connman_agent_object = net_connman_agent_skeleton_new();
176 interface_connman_agent = G_DBUS_INTERFACE_SKELETON(connman_agent_object);
177 g_signal_connect(connman_agent_object, "handle-report-error",
178 G_CALLBACK(handle_report_error), NULL);
179 g_signal_connect(connman_agent_object, "handle-request-browser",
180 G_CALLBACK(handle_request_browser), NULL);
181 g_signal_connect(connman_agent_object, "handle-request-input",
182 G_CALLBACK(handle_request_input), NULL);
183 g_signal_connect(connman_agent_object, "handle-set-field",
184 G_CALLBACK(handle_set_field), NULL);
186 if (!g_dbus_interface_skeleton_export(interface_connman_agent, connection,
187 NETCONFIG_WIFI_PATH, NULL)) {
188 ERR("Export WIFI_PATH for agent failed");
191 /*Interface netconfig.wifi.Firmware*/
192 wififirmware_object = wifi_firmware_skeleton_new();
194 interface_wifi_firmware = G_DBUS_INTERFACE_SKELETON(wififirmware_object);
195 g_signal_connect(wififirmware_object, "handle-start",
196 G_CALLBACK(handle_start), NULL);
197 g_signal_connect(wififirmware_object, "handle-stop",
198 G_CALLBACK(handle_stop), NULL);
200 if (!g_dbus_interface_skeleton_export(interface_wifi_firmware, connection,
201 NETCONFIG_WIFI_PATH, NULL)) {
202 ERR("Export WIFI_PATH for firmware failed");
205 _set_wifi_mac_address();
207 wifi_power_initialize();
212 void wifi_object_deinit(void)
214 g_object_unref(wifi_object);
215 g_object_unref(connman_agent_object);
216 g_object_unref(wififirmware_object);
218 wifi_power_deinitialize();