This will be necessary to handle incoming connection request. Wifi
plugin will have to bring the necessary callback to forward this request
to the core Peer Agent API where the user will be able to accept or
reject the connection.
---
 gsupplicant/gsupplicant.h |  1 +
 gsupplicant/supplicant.c  | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index fc595b7..5ad88b0 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -319,6 +319,7 @@ struct _GSupplicantCallbacks {
        void (*peer_lost) (GSupplicantPeer *peer);
        void (*peer_changed) (GSupplicantPeer *peer,
                                        GSupplicantPeerGroupState state);
+       void (*peer_request) (GSupplicantPeer *peer);
        void (*debug) (const char *str);
 };
 
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index dbae8d5..049a5b2 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -508,6 +508,17 @@ static void callback_peer_changed(GSupplicantPeer *peer,
        callbacks_pointer->peer_changed(peer, state);
 }
 
+static void callback_peer_request(GSupplicantPeer *peer)
+{
+       if (!callbacks_pointer)
+               return;
+
+       if (!callbacks_pointer->peer_request)
+               return;
+
+       callbacks_pointer->peer_request(peer);
+}
+
 static void remove_group(gpointer data)
 {
        GSupplicantGroup *group = data;
@@ -2880,6 +2891,29 @@ static void signal_group_finished(const char *path, 
DBusMessageIter *iter)
        g_hash_table_remove(interface->group_table, data.group_obj_path);
 }
 
+static void signal_group_request(const char *path, DBusMessageIter *iter)
+{
+       GSupplicantInterface *interface;
+       GSupplicantPeer *peer;
+       const char *obj_path;
+
+       SUPPLICANT_DBG("");
+
+       interface = g_hash_table_lookup(interface_table, path);
+       if (!interface)
+               return;
+
+       dbus_message_iter_get_basic(iter, &obj_path);
+       if (!obj_path || !g_strcmp0(obj_path, "/"))
+               return;
+
+       peer = g_hash_table_lookup(interface->peer_table, obj_path);
+       if (!peer)
+               return;
+
+       callback_peer_request(peer);
+}
+
 static void signal_group_peer_joined(const char *path, DBusMessageIter *iter)
 {
        const char *peer_path = NULL;
@@ -2979,6 +3013,7 @@ static struct {
        { SUPPLICANT_INTERFACE ".Interface.P2PDevice", "GONegotiationFailure", 
signal_group_failure },
        { SUPPLICANT_INTERFACE ".Interface.P2PDevice", "GroupStarted", 
signal_group_started },
        { SUPPLICANT_INTERFACE ".Interface.P2PDevice", "GroupFinished", 
signal_group_finished },
+       { SUPPLICANT_INTERFACE ".Interface.P2PDevice", "GONegotiationRequest", 
signal_group_request },
 
        { SUPPLICANT_INTERFACE ".Group", "PeerJoined", signal_group_peer_joined 
},
        { SUPPLICANT_INTERFACE ".Group", "PeerDisconnected", 
signal_group_peer_disconnected },
-- 
1.8.5.5

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to