dbus: Declare and implement GroupFinished as for GroupStarted

First for better concistancy but also to tell about the group_object
that is getting removed, thus the client will know about it and will be
able to act accordingly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2014-07-08 15:56:11 +03:00 committed by Jouni Malinen
parent 2fa980f0f1
commit 4a0693a4d5
2 changed files with 30 additions and 19 deletions

View file

@ -946,37 +946,49 @@ void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
const char *role)
{
int error = 1;
DBusMessage *msg;
DBusMessageIter iter;
DBusMessageIter iter, dict_iter;
struct wpas_dbus_priv *iface = wpa_s->global->dbus;
char *ifname = wpa_s->ifname;
/* Do nothing if the control interface is not turned on */
if (iface == NULL)
return;
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
if (!wpa_s->dbus_groupobj_path)
return;
msg = dbus_message_new_signal(wpa_s->parent->dbus_new_path,
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
"GroupFinished");
if (msg == NULL)
return;
dbus_message_iter_init_append(msg, &iter);
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
goto nomem;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &ifname)) {
wpa_printf(MSG_ERROR, "dbus: Failed to construct GroupFinished"
"signal -not enough memory for ifname ");
goto err;
}
if (!wpa_dbus_dict_append_object_path(&dict_iter,
"interface_object",
wpa_s->dbus_new_path))
goto nomem;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &role))
wpa_printf(MSG_ERROR, "dbus: Failed to construct GroupFinished"
"signal -not enough memory for role ");
else
if (!wpa_dbus_dict_append_string(&dict_iter, "role", role))
goto nomem;
if (!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
wpa_s->dbus_groupobj_path) ||
!wpa_dbus_dict_close_write(&iter, &dict_iter))
goto nomem;
error = 0;
dbus_connection_send(iface->con, msg, NULL);
err:
nomem:
if (error > 0)
wpa_printf(MSG_ERROR,
"dbus: Failed to construct GroupFinished");
dbus_message_unref(msg);
}
@ -3140,8 +3152,7 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
},
{ "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
{ "ifname", "s", ARG_OUT },
{ "role", "s", ARG_OUT },
{ "properties", "a{sv}", ARG_OUT },
END_ARGS
}
},

View file

@ -438,9 +438,9 @@ void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
const struct wpa_ssid *ssid,
const char *role)
{
wpas_dbus_unregister_p2p_group(wpa_s, ssid);
wpas_dbus_signal_p2p_group_removed(wpa_s, role);
wpas_dbus_unregister_p2p_group(wpa_s, ssid);
}