D-Bus: Add DeviceFoundProperties signal for discovered peers

This signal sends the peer properties to applications for discovered
peers. The signature of this event is "oa{sv}". This event is needed
because the current DeviceFound signal provides only the peer object
path. If there are many peers in range there will be many DeviceFound
signals and for each DeviceFound signal, applications would need to use
GetAll to fetch peer properties. Doing this many times would create
extra load over application as well as over wpa_supplicant, so it is
better to send peer properties in the event so that applications can
extract found peer information without extra steps.

The existing DeviceFound signal is left as-is to avoid changing its
signature.

The issue is not applicable to the control interface because the
P2P-DEVICE-FOUND event includes peer info in it, but over D-Bus
interface DeviceFound provides only the peer object.

Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
This commit is contained in:
Nishant Chaprana 2016-06-20 10:18:21 +05:30 committed by Jouni Malinen
parent e18d170848
commit 82b9ec3125
2 changed files with 34 additions and 5 deletions

View file

@ -1631,6 +1631,20 @@ Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations.
<h3>DeviceFound ( o : path )</h3>
</li>
<li>
<h3>DeviceFoundProperties ( o : path, a{sv} : properties )</h3>
<p>A new peer device has been found.</p>
<h4>Arguments</h4>
<dl>
<dt>o : path</dt>
<dd>A D-Bus path to an object representing the found peer device.</dd>
</dl>
<dl>
<dt>a{sv} : properties</dt>
<dd>A dictionary containing properties of the found peer device.</dd>
</dl>
</li>
<li>
<h3>DeviceLost ( o : path )</h3>
</li>

View file

@ -3352,6 +3352,13 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
END_ARGS
}
},
{ "DeviceFoundProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
{ "path", "o", ARG_OUT },
{ "properties", "a{sv}", ARG_OUT },
END_ARGS
}
},
{ "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
{ "path", "o", ARG_OUT },
@ -3800,12 +3807,13 @@ static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
* In case of peer objects, it would be emitted by either
* the "interface object" or by "peer objects"
* @sig_name: signal name - DeviceFound
* @properties: Whether to add a second argument with object properties
*
* Notify listeners about event related with newly found p2p peer device
* Notify listeners about event related with p2p peer device
*/
static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, const char *interface,
const char *sig_name)
const char *sig_name, int properties)
{
struct wpas_dbus_priv *iface;
DBusMessage *msg;
@ -3833,7 +3841,10 @@ static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
dbus_message_iter_init_append(msg, &iter);
path = peer_obj_path;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&path))
&path) ||
(properties && !wpa_dbus_get_object_properties(
iface, peer_obj_path, WPAS_DBUS_NEW_IFACE_P2P_PEER,
&iter)))
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
else
dbus_connection_send(iface->con, msg, NULL);
@ -3854,7 +3865,11 @@ void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
{
wpas_dbus_signal_peer(wpa_s, dev_addr,
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
"DeviceFound");
"DeviceFound", FALSE);
wpas_dbus_signal_peer(wpa_s, dev_addr,
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
"DeviceFoundProperties", TRUE);
}
/**
@ -3869,7 +3884,7 @@ void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
{
wpas_dbus_signal_peer(wpa_s, dev_addr,
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
"DeviceLost");
"DeviceLost", FALSE);
}
/**