</li>
<li>
- <h3>StateChanged ( s : newState, s : oldState )</h3>
- <p>Interface state has changed.</p>
- <h4>Arguments</h4>
- <dl>
- <dt>s : newState</dt>
- <dd>A state which the interface goes to</dd>
- <dt>s : oldState</dt>
- <dd>A state which the interface goes from</dd>
- </dl>
- </li>
-
- <li>
<h3>BSSAdded ( o : BSS, a{sv} : properties )</h3>
<p>Interface became aware of a new BSS.</p>
<h4>Arguments</h4>
<h4>Arguments</h4>
<dl>
<dt>a{sv} : properties</dt>
- <dd>A dictionary with pairs of properties names which have changed and theirs new values. Possible dictionary keys are: "ApScan", "Scanning", "CurrentBSS", "CurrentNetwork"</dd>
+ <dd>A dictionary with pairs of properties names which have changed and theirs new values. Possible dictionary keys are: "ApScan", "Scanning", "State", "CurrentBSS", "CurrentNetwork"</dd>
</dl>
</li>
</ul>
}
-static void str_to_lower(char *s)
-{
- while (*s) {
- *s = tolower(*s);
- s++;
- }
-}
-
-
-/**
- * wpas_dbus_signal_state_changed - Send a state changed signal
- * @wpa_s: %wpa_supplicant network interface data
- * @new_state: new state wpa_supplicant is entering
- * @old_state: old state wpa_supplicant is leaving
- *
- * Notify listeners that wpa_supplicant has changed state
- */
-void wpas_dbus_signal_state_changed(struct wpa_supplicant *wpa_s,
- enum wpa_states new_state,
- enum wpa_states old_state)
-{
- struct wpas_dbus_priv *iface;
- DBusMessage *msg;
- char *new_state_str, *old_state_str;
-
- /* Do nothing if the control interface is not turned on */
- if (wpa_s->global == NULL)
- return;
- iface = wpa_s->global->dbus;
- if (iface == NULL)
- return;
-
- /* Only send signal if state really changed */
- if (new_state == old_state)
- return;
-
- msg = dbus_message_new_signal(wpa_s->dbus_new_path,
- WPAS_DBUS_NEW_IFACE_INTERFACE,
- "StateChanged");
- if (msg == NULL)
- return;
-
- new_state_str = os_strdup(wpa_supplicant_state_txt(new_state));
- old_state_str = os_strdup(wpa_supplicant_state_txt(old_state));
- if (new_state_str == NULL || old_state_str == NULL)
- goto out;
-
- /* make state string lowercase to fit new DBus API convention */
- str_to_lower(new_state_str);
- str_to_lower(old_state_str);
-
- if (!dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &new_state_str,
- DBUS_TYPE_STRING, &old_state_str,
- DBUS_TYPE_INVALID)) {
- wpa_printf(MSG_ERROR, "dbus: Failed to construct state change "
- "signal");
- goto out;
- }
-
- dbus_connection_send(iface->con, msg, NULL);
-
-out:
- dbus_message_unref(msg);
- os_free(new_state_str);
- os_free(old_state_str);
-}
-
-
/**
* wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
* @wpa_s: %wpa_supplicant network interface data
getter = (WPADBusPropertyAccessor) wpas_dbus_getter_scanning;
prop = "Scanning";
break;
+ case WPAS_DBUS_PROP_STATE:
+ getter = (WPADBusPropertyAccessor) wpas_dbus_getter_state;
+ prop = "State";
+ break;
case WPAS_DBUS_PROP_CURRENT_BSS:
getter = (WPADBusPropertyAccessor)
wpas_dbus_getter_current_bss;
END_ARGS
}
},
- { "StateChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "newState", "s", ARG_OUT },
- { "oldState", "s", ARG_OUT },
- END_ARGS
- }
- },
{ "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
{
{ "path", "o", ARG_OUT },
enum wpas_dbus_prop {
WPAS_DBUS_PROP_AP_SCAN,
WPAS_DBUS_PROP_SCANNING,
+ WPAS_DBUS_PROP_STATE,
WPAS_DBUS_PROP_CURRENT_BSS,
WPAS_DBUS_PROP_CURRENT_NETWORK,
};
int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s);
int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s);
-void wpas_dbus_signal_state_changed(struct wpa_supplicant *wpa_s,
- enum wpa_states new_state,
- enum wpa_states old_state);
void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
enum wpas_dbus_prop property);
void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
old_state);
/* notify the new DBus API */
- wpas_dbus_signal_state_changed(wpa_s, new_state, old_state);
+ wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
}
{
/* notify the old DBus API */
wpa_supplicant_dbus_notify_scanning(wpa_s);
+
/* notify the new DBus API */
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
}
void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
enum wpa_states state)
{
+ enum wpa_states old_state = wpa_s->wpa_state;
+
wpa_printf(MSG_DEBUG, "State: %s -> %s",
wpa_supplicant_state_txt(wpa_s->wpa_state),
wpa_supplicant_state_txt(state));
if (state != WPA_SCANNING)
wpa_supplicant_notify_scanning(wpa_s, 0);
- wpas_notify_state_changed(wpa_s, state, wpa_s->wpa_state);
-
if (state == WPA_COMPLETED && wpa_s->new_connection) {
#if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
struct wpa_ssid *ssid = wpa_s->current_ssid;
wpa_drv_set_operstate(wpa_s, 0);
}
wpa_s->wpa_state = state;
+
+ if (wpa_s->wpa_state != old_state)
+ wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
}
static void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
{
enum wpa_states old_state = wpa_s->wpa_state;
+
wpa_s->pairwise_cipher = 0;
wpa_s->group_cipher = 0;
wpa_s->mgmt_group_cipher = 0;
wpa_s->key_mgmt = 0;
wpa_s->wpa_state = WPA_DISCONNECTED;
- wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
+
+ if (wpa_s->wpa_state != old_state)
+ wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
}