[PATCH 8/9] dbus: Add PropertiesChanged signal to Peer object

Tomasz Bursztyka tomasz.bursztyka at linux.intel.com
Wed May 14 09:10:45 EDT 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 | 77 ++++++++++++++++++++++++++++++++++++++++--
 wpa_supplicant/dbus/dbus_new.h | 16 +++++++++
 2 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 3e18431..0742462 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -24,6 +24,8 @@
 #include "dbus_common_i.h"
 #include "dbus_new_handlers_p2p.h"
 #include "p2p/p2p.h"
+#include "p2p/p2p_i.h"
+#include "../p2p_supplicant.h"
 
 #ifdef CONFIG_AP /* until needed by something else */
 
@@ -1150,6 +1152,32 @@ static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
 	return 0;
 }
 
+static void peer_group_changed(struct wpa_supplicant *wpa_s,
+			       int check_client_only, int client)
+{
+	struct p2p_data *p2p = wpa_s->global->p2p;
+	struct wpa_supplicant *wpa_s_go;
+	struct p2p_device *dev, *n;
+
+	if (check_client_only && !client)
+		return;
+
+	dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) {
+		if (dev == p2p->go_neg_peer)
+			continue;
+
+		wpa_s_go = wpas_get_go_p2p_client(wpa_s,
+						  dev->info.p2p_device_addr);
+		if (wpa_s_go == NULL && !check_client_only)
+			wpa_s_go = wpas_get_go_p2p_go(wpa_s,
+						dev->info.p2p_device_addr);
+		if (wpa_s_go == NULL || wpa_s_go != wpa_s)
+			continue;
+
+		wpas_dbus_signal_peer_group_changed(wpa_s->parent,
+						    dev->info.p2p_device_addr);
+	}
+}
 
 /**
  * wpas_dbus_signal_p2p_group_started - Signals P2P group has
@@ -1211,6 +1239,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 +1364,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_intended_addr_changed(wpa_s,
+						res->peer_device_addr);
 err:
 	dbus_message_unref(msg);
 }
@@ -1435,8 +1468,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 +1524,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 +3320,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 +3509,32 @@ int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
 	return ret;
 }
 
+void wpas_dbus_signal_peer_intended_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,
+				       "IntendedAddress");
+}
+
+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 +3681,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 1aec9be..5ff31cd 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -177,6 +177,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_intended_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,
@@ -469,6 +473,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