dbus: Rename old D-Bus API files to include "_old"
[hostap-gosc2009.git] / wpa_supplicant / notify.c
bloba95ce03157cc6abf4ac64d40e7838e2ae5648e1b
1 /*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "common/wpa_ctrl.h"
19 #include "config.h"
20 #include "wpa_supplicant_i.h"
21 #include "wps_supplicant.h"
22 #include "dbus/dbus_common.h"
23 #include "dbus/dbus_old.h"
24 #include "dbus/dbus_new.h"
25 #include "notify.h"
27 int wpas_notify_supplicant_initialized(struct wpa_global *global)
29 #ifdef CONFIG_DBUS
30 if (global->params.dbus_ctrl_interface) {
31 global->dbus = wpas_dbus_init(global);
32 if (global->dbus == NULL)
33 return -1;
35 #endif /* CONFIG_DBUS */
37 return 0;
41 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
43 #ifdef CONFIG_DBUS
44 if (global->dbus)
45 wpas_dbus_deinit(global->dbus);
46 #endif /* CONFIG_DBUS */
50 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
52 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
54 if (wpas_dbus_register_iface(wpa_s))
55 return -1;
57 if (cbs && cbs->register_interface(wpa_s))
58 return -1;
60 return 0;
65 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
67 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
69 /* unregister interface in old DBus ctrl iface */
70 wpas_dbus_unregister_iface(wpa_s);
72 /* unregister interface in new DBus ctrl iface */
73 if (cbs)
74 cbs->unregister_interface(wpa_s);
78 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
79 enum wpa_states new_state,
80 enum wpa_states old_state)
82 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
84 /* notify the old DBus API */
85 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
86 old_state);
88 /* notify the new DBus API */
89 if (cbs)
90 cbs->signal_state_changed(wpa_s, new_state, old_state);
94 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
96 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
97 if (cbs)
98 cbs->signal_prop_changed(wpa_s,
99 WPAS_DBUS_PROP_CURRENT_NETWORK);
103 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
105 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
106 if (cbs)
107 cbs->signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
111 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
113 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
114 if (cbs)
115 cbs->signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
119 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
120 struct wpa_ssid *ssid)
122 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
123 if (cbs)
124 cbs->signal_network_enabled_changed(wpa_s, ssid);
128 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
129 struct wpa_ssid *ssid)
131 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
132 if (cbs)
133 cbs->signal_network_selected(wpa_s, ssid->id);
137 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
139 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
140 /* notify the old DBus API */
141 wpa_supplicant_dbus_notify_scanning(wpa_s);
142 /* notify the new DBus API */
143 if (cbs)
144 cbs->signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
148 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
150 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
151 if (cbs)
152 cbs->signal_scan_done(wpa_s, success);
156 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
158 /* notify the old DBus API */
159 wpa_supplicant_dbus_notify_scan_results(wpa_s);
161 wpas_wps_notify_scan_results(wpa_s);
165 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
166 const struct wps_credential *cred)
168 #ifdef CONFIG_WPS
169 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
170 #endif /* CONFIG_WPS */
172 /* notify the old DBus API */
173 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
174 /* notify the new DBus API */
175 #ifdef CONFIG_WPS
176 if (cbs)
177 cbs->signal_wps_credentials(wpa_s, cred);
178 #endif /* CONFIG_WPS */
182 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
183 struct wps_event_m2d *m2d)
185 #ifdef CONFIG_WPS
186 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
187 if (cbs)
188 cbs->signal_wps_event_m2d(wpa_s, m2d);
189 #endif /* CONFIG_WPS */
193 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
194 struct wps_event_fail *fail)
196 #ifdef CONFIG_WPS
197 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
198 if (cbs)
199 cbs->signal_wps_event_fail(wpa_s, fail);
200 #endif /* CONFIG_WPS */
204 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
206 #ifdef CONFIG_WPS
207 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
208 if (cbs)
209 cbs->signal_wps_event_success(wpa_s);
210 #endif /* CONFIG_WPS */
214 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
215 struct wpa_ssid *ssid)
217 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
218 if (wpa_s->global->dbus && cbs)
219 cbs->register_network(wpa_s, ssid);
223 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
224 struct wpa_ssid *ssid)
226 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
227 if (wpa_s->global->dbus && cbs)
228 cbs->unregister_network(wpa_s, ssid->id);
232 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
233 u8 bssid[], unsigned int id)
235 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
236 if (cbs)
237 cbs->register_bss(wpa_s, bssid, id);
238 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
239 id, MAC2STR(bssid));
243 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
244 u8 bssid[], unsigned int id)
246 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
247 if (cbs)
248 cbs->unregister_bss(wpa_s, bssid, id);
249 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
250 id, MAC2STR(bssid));
254 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
256 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
257 if (cbs)
258 cbs->signal_blob_added(wpa_s, name);
262 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
264 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
265 if (cbs)
266 cbs->signal_blob_removed(wpa_s, name);
270 void wpas_notify_debug_params_changed(struct wpa_global *global)
272 struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks();
273 if (cbs)
274 cbs->signal_debug_params_changed(global);