[PATCH 7/7] dbus: Add PropertiesChanged signal to Peer object
Tomasz Bursztyka
tomasz.bursztyka
Tue May 20 04:51:14 PDT 2014
This signal will be thrown when a Peer gets in or goes away from a
group.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka at linux.intel.com>
---
wpa_supplicant/dbus/dbus_new.c | 84 ++++++++++++++++++++++++++++++++++++++++--
wpa_supplicant/dbus/dbus_new.h | 16 ++++++++
2 files changed, 97 insertions(+), 3 deletions(-)
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 09a7bc4..4d48909 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -24,6 +24,7 @@
#include "dbus_common_i.h"
#include "dbus_new_handlers_p2p.h"
#include "p2p/p2p.h"
+#include "../p2p_supplicant.h"
#ifdef CONFIG_AP /* until needed by something else */
@@ -1150,6 +1151,40 @@ static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
return 0;
}
+struct group_changed_data {
+ struct wpa_supplicant *wpa_s;
+ int check_client_only;
+};
+
+static void signal_peer_group_changed(struct p2p_peer_info *info,
+ void *user_data)
+{
+ struct group_changed_data *data = user_data;
+ struct wpa_supplicant *wpa_s_go;
+
+ wpa_s_go = wpas_get_go_p2p_client(data->wpa_s, info->p2p_device_addr);
+ if (wpa_s_go == NULL && !data->check_client_only)
+ wpa_s_go = wpas_get_go_p2p_go(data->wpa_s,
+ info->p2p_device_addr);
+ if (wpa_s_go != NULL && wpa_s_go == data->wpa_s)
+ wpas_dbus_signal_peer_group_changed(data->wpa_s->parent,
+ info->p2p_device_addr);
+}
+
+static void peer_group_changed(struct wpa_supplicant *wpa_s,
+ int check_client_only, int client)
+{
+ struct group_changed_data data;
+
+ if (check_client_only && !client)
+ return;
+
+ data.wpa_s = wpa_s;
+ data.check_client_only = check_client_only;
+
+ p2p_loop_on_known_peers(wpa_s->global->p2p,
+ signal_peer_group_changed, &data);
+}
/**
* wpas_dbus_signal_p2p_group_started - Signals P2P group has
@@ -1211,6 +1246,7 @@ void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
dbus_connection_send(iface->con, msg, NULL);
+ peer_group_changed(wpa_s, 1, client);
nomem:
dbus_message_unref(msg);
}
@@ -1335,6 +1371,10 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
goto err;
dbus_connection_send(iface->con, msg, NULL);
+
+ if (!res->status)
+ wpas_dbus_signal_peer_interface_addr_changed(wpa_s,
+ res->peer_device_addr);
err:
dbus_message_unref(msg);
}
@@ -1435,8 +1475,10 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
goto err;
dbus_connection_send(iface->con, msg, NULL);
-
dbus_message_unref(msg);
+
+ wpas_dbus_signal_peer_group_changed(wpa_s->parent, peer_addr);
+
return;
err:
@@ -1489,8 +1531,10 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
goto err;
dbus_connection_send(iface->con, msg, NULL);
-
dbus_message_unref(msg);
+
+ wpas_dbus_signal_peer_group_changed(wpa_s->parent, peer_addr);
+
return;
err:
@@ -3283,7 +3327,13 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
};
static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
-
+ /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
+ { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_P2P_PEER,
+ {
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
{ NULL, NULL, { END_ARGS } }
};
@@ -3466,6 +3516,32 @@ int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
return ret;
}
+void wpas_dbus_signal_peer_interface_addr_changed(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_new_path, MAC2STR(dev_addr));
+
+ wpa_dbus_mark_property_changed(wpa_s->global->dbus, peer_obj_path,
+ WPAS_DBUS_NEW_IFACE_P2P_PEER,
+ "InterfacedAddress");
+}
+
+void wpas_dbus_signal_peer_group_changed(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_new_path, MAC2STR(dev_addr));
+
+ wpa_dbus_mark_property_changed(wpa_s->global->dbus, peer_obj_path,
+ WPAS_DBUS_NEW_IFACE_P2P_PEER, "Group");
+}
static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
{ "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
@@ -3612,6 +3688,8 @@ void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
return;
}
+ peer_group_changed(wpa_s, 0, 0);
+
wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
wpa_s->dbus_groupobj_path);
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index 9e0ec89..6be7ccd 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -173,6 +173,10 @@ int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
const u8 *dev_addr);
void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
const u8 *dev_addr);
+void wpas_dbus_signal_peer_interface_addr_changed(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr);
+void wpas_dbus_signal_peer_group_changed(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr);
void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
const char *role);
void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
@@ -461,6 +465,18 @@ wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
}
static inline void
+wpas_dbus_signal_peer_intended_addr_changed(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+}
+
+static inline void
+wpas_dbus_signal_peer_group_changed(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+}
+
+static inline void
wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
const u8 *member)
{
--
1.8.3.2
More information about the Hostap
mailing list