From: Anjali Nijhara Date: Tue, 23 Jan 2024 08:21:24 +0000 (+0530) Subject: Add signal handling for P2P Tethering X-Git-Tag: accepted/tizen/9.0/unified/20241030.235550~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F304768%2F1;p=platform%2Fcore%2Fapi%2Ftethering.git Add signal handling for P2P Tethering Change-Id: Iac6541785d78a223d5640fd2a88f0e3e932de71c Signed-off-by: Anjali Nijhara --- diff --git a/include/tethering_private.h b/include/tethering_private.h index 882edf1..b6a36c2 100644 --- a/include/tethering_private.h +++ b/include/tethering_private.h @@ -194,6 +194,8 @@ typedef enum { E_SIGNAL_NET_CLOSED = 0, E_SIGNAL_WIFI_TETHER_ON, E_SIGNAL_WIFI_TETHER_OFF, + E_SIGNAL_P2P_TETHER_ON, + E_SIGNAL_P2P_TETHER_OFF, E_SIGNAL_USB_TETHER_ON, E_SIGNAL_USB_TETHER_OFF, E_SIGNAL_BT_TETHER_ON, @@ -220,6 +222,8 @@ typedef enum { #define SIGNAL_NAME_STA_DISCONNECT "sta_disconnected" #define SIGNAL_NAME_WIFI_TETHER_ON "wifi_on" #define SIGNAL_NAME_WIFI_TETHER_OFF "wifi_off" +#define SIGNAL_NAME_P2P_TETHER_ON "p2p_on" +#define SIGNAL_NAME_P2P_TETHER_OFF "p2p_off" #define SIGNAL_NAME_USB_TETHER_ON "usb_on" #define SIGNAL_NAME_USB_TETHER_OFF "usb_off" #define SIGNAL_NAME_BT_TETHER_ON "bluetooth_on" diff --git a/src/tethering.c b/src/tethering.c index acca9ae..55fc98a 100755 --- a/src/tethering.c +++ b/src/tethering.c @@ -78,6 +78,14 @@ static void __handle_wifi_tether_off(GDBusConnection *connection, const gchar *s const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data); +static void __handle_p2p_tether_on(GDBusConnection *connection, const gchar *sender_name, + const gchar *object_path, const gchar *interface_name, const gchar *signal_name, + GVariant *parameters, gpointer user_data); + +static void __handle_p2p_tether_off(GDBusConnection *connection, const gchar *sender_name, + const gchar *object_path, const gchar *interface_name, const gchar *signal_name, + GVariant *parameters, gpointer user_data); + static void __handle_usb_tether_on(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data); @@ -130,6 +138,8 @@ static __tethering_sig_t sigs[] = { {0, SIGNAL_NAME_NET_CLOSED, __handle_net_closed}, {0, SIGNAL_NAME_WIFI_TETHER_ON, __handle_wifi_tether_on}, {0, SIGNAL_NAME_WIFI_TETHER_OFF, __handle_wifi_tether_off}, + {0, SIGNAL_NAME_P2P_TETHER_ON, __handle_p2p_tether_on}, + {0, SIGNAL_NAME_P2P_TETHER_OFF, __handle_p2p_tether_off}, {0, SIGNAL_NAME_USB_TETHER_ON, __handle_usb_tether_on}, {0, SIGNAL_NAME_USB_TETHER_OFF, __handle_usb_tether_off}, {0, SIGNAL_NAME_BT_TETHER_ON, __handle_bt_tether_on}, @@ -566,6 +576,28 @@ static void __handle_wifi_tether_off(GDBusConnection *connection, const gchar *s DBG("-\n"); } +static void __handle_p2p_tether_on(GDBusConnection *connection, const gchar *sender_name, + const gchar *object_path, const gchar *interface_name, const gchar *signal_name, + GVariant *parameters, gpointer user_data) +{ + DBG("+\n"); + TETHERING_LOCK; + __invoke_enable_cb((__tethering_h *)user_data, TETHERING_TYPE_P2P, false); + TETHERING_UNLOCK; + DBG("-\n"); +} + +static void __handle_p2p_tether_off(GDBusConnection *connection, const gchar *sender_name, + const gchar *object_path, const gchar *interface_name, const gchar *signal_name, + GVariant *parameters, gpointer user_data) +{ + DBG("+\n"); + TETHERING_LOCK; + __invoke_disabled_cb((__tethering_h *)user_data, TETHERING_TYPE_P2P, parameters); + TETHERING_UNLOCK; + DBG("-\n"); +} + static void __handle_usb_tether_on(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) diff --git a/tools/tethering_test.c b/tools/tethering_test.c index 6a01a38..1f5ed94 100755 --- a/tools/tethering_test.c +++ b/tools/tethering_test.c @@ -751,7 +751,7 @@ static int test_tethering_enable(void) if (!__get_tethering_type(&type)) return -1; - if (type != TETHERING_TYPE_WIFI) + if (type != TETHERING_TYPE_WIFI && type != TETHERING_TYPE_P2P) return -1; printf("Select 0: Normal, 1: Wi-Fi sharing, 2: Dual band hotspot\n");