Add peer ip assigned signal handler and fix dbus issues 50/85650/1
authorYu Jiung <jiung.yu@samsung.com>
Fri, 26 Aug 2016 08:47:57 +0000 (17:47 +0900)
committerYu Jiung <jiung.yu@samsung.com>
Fri, 26 Aug 2016 08:48:11 +0000 (17:48 +0900)
Change-Id: Id427bc43444a2aa82686af0f0fbbcf60324d9a9b
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
include/asp-manager-gdbus.h
src/asp-manager-gdbus.c
src/asp-manager.c
src/tech/asp-tech-p2p.c

index e55e621..0b38025 100755 (executable)
@@ -45,7 +45,7 @@ void asp_manager_gdbus_notify_search_result(guint32 search_id,
 
 void asp_manager_gdbus_notify_session_request(gint32 error_code,
                gchar *session_mac, guint32 session_id, guint32 adv_id,
-               gchar *device_name, guint8 *session_info,
+               gchar *device_name, gchar *session_info,
                gboolean get_pin, gchar *pin);
 
 void asp_manager_gdbus_notify_session_config_request(guint32 sessoin_id,
index ce28b3c..cf9836b 100755 (executable)
@@ -566,7 +566,7 @@ static gboolean __asp_manager_gdbus_confirm_session(AspSession *object,
        }
        DEBUG_PARAMS(parameters);
 
-       g_variant_get(parameters, "(a{sv})", &iter);
+       g_variant_get(parameters, "a{sv}", &iter);
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
                if (!g_strcmp0(key, "session_mac"))
                        g_variant_get(var, "&s", &session_mac);
@@ -579,7 +579,7 @@ static gboolean __asp_manager_gdbus_confirm_session(AspSession *object,
                else
                        ;/* Do Nothing */
        }
-       if (session_id == 0 || session_mac == NULL) {
+       if (session_mac == NULL) {
                ASP_LOGE("Invalid parameter");
                ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_INVALIED_PARAMS);
                goto out;
@@ -593,7 +593,8 @@ static gboolean __asp_manager_gdbus_confirm_session(AspSession *object,
        ASP_LOGD("session ID [%u] session mac [%s]", session_id, session_mac);
 
        macaddr_atoe(session_mac, mac_addr);
-       pin = (guint32)atoi(pin_str);
+       if(pin_str != NULL)
+               pin = (guint32)atoi(pin_str);
        res = asp_session_confirm_session(mac_addr, session_id, confirmed, pin);
        if (!res) {
                ASP_LOGE("Operation Failed");
@@ -630,7 +631,7 @@ static gboolean __asp_manager_gdbus_get_session(AspSession *object,
                goto out;
        }
 
-       if (session_id == 0 || session_mac == NULL) {
+       if (session_mac == NULL) {
                ASP_LOGE("Invalid parameter");
                ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_INVALIED_PARAMS);
                goto out;
@@ -650,10 +651,11 @@ static gboolean __asp_manager_gdbus_get_session(AspSession *object,
                goto out;
        }
 
+       ASP_LOGD("adv id [%u]", adv_id);
        builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
        g_variant_builder_add(builder, "{sv}", "adv_id", g_variant_new("u", adv_id));
 
-       session = g_variant_new("(a{sv})", builder);
+       session = g_variant_new("a{sv}", builder);
        g_variant_builder_unref(builder);
 
        asp_session_complete_get_session(object, invocation, result, session);
@@ -957,7 +959,7 @@ void asp_manager_gdbus_notify_search_result(guint32 search_id,
 
 void asp_manager_gdbus_notify_session_request(gint32 error_code,
                gchar * session_mac, guint32 session_id, guint32 adv_id,
-               gchar * device_name, guint8 * session_info,
+               gchar * device_name, gchar * session_info,
                gboolean get_pin, gchar *pin)
 {
        __ASP_LOG_FUNC_ENTER__;
index d80d672..77b2204 100755 (executable)
@@ -60,13 +60,19 @@ static void __session_request_cb(gint32 error_code, guint8 *session_mac,
 {
        __ASP_LOG_FUNC_ENTER__;
 
+       gchar *session_info_str = NULL;
        gchar session_mac_str[MACSTR_LEN + 1] = {0,};
        gchar pin_str[MACSTR_LEN + 1] = {0,};
 
+       if(info_length != 0) {
+               session_info_str = g_try_malloc0(info_length + 1);
+               memcpy(session_info_str, session_info, info_length);
+       }
+
        g_snprintf(session_mac_str, MACSTR_LEN + 1, MACSTR, MAC2STR(session_mac));
        g_snprintf(pin_str, PINSTR_LEN + 1, "%u", pin);
        asp_manager_gdbus_notify_session_request(error_code, session_mac_str,
-                       session_id, adv_id, device_name, session_info, get_pin, pin_str);
+                       session_id, adv_id, device_name, session_info_str, get_pin, pin_str);
 
        __ASP_LOG_FUNC_EXIT__;
        return;
index 42345cb..e0dba81 100755 (executable)
@@ -92,6 +92,10 @@ void asp_tech_p2p_process_session_config_request(GDBusConnection *connection,
 
 void asp_tech_p2p_process_connect_status(GDBusConnection *connection,
                const gchar *object_path, GVariant *parameters);
+
+void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+
 /*****************************************************************************
  * Global Variables
  *****************************************************************************/
@@ -137,6 +141,11 @@ static struct {
                                asp_tech_p2p_process_connect_status
                },
                {
+                               WFD_MANAGER_ASP_INTERFACE,
+                               "SessionPeerIPAssigned",
+                               asp_tech_p2p_process_session_peer_ip
+               },
+               {
                                NULL,
                                NULL,
                                NULL
@@ -510,6 +519,60 @@ void asp_tech_p2p_process_connect_status(GDBusConnection *connection,
        return;
 }
 
+void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_ENTER__;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const gchar *key = NULL;
+       const gchar *str = NULL;
+       guint8 session_mac[MAC_LEN] = {0,};
+       guint8 service_mac[MAC_LEN] = {0,};
+       guint32 session_id = 0;
+       gchar *peer_ip = NULL;
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "session_mac")) {
+                       if (asp_dbus_unpack_ay(session_mac, var, MAC_LEN) < 0)
+                               return;
+               } else if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &session_id);
+               } else if (!g_strcmp0(key, "service_mac")) {
+                       if (asp_dbus_unpack_ay(service_mac, var, MAC_LEN) < 0)
+                               return;
+               } else if (!g_strcmp0(key, "assigned_ip_address")) {
+                       g_variant_get(var, "&s", &str);
+                       peer_ip = g_strdup(str);
+               } else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       if(peer_ip == NULL) {
+               ASP_LOGE("Invalid peer IP address");
+               return;
+       }
+
+       if (asp_tech_p2p_ops.ip_assigned_cb) {
+               asp_tech_p2p_ops.ip_assigned_cb(0,
+                               session_mac, session_id, service_mac, peer_ip,
+                               strlen(peer_ip), asp_tech_p2p_ops.ip_assigned_cb_user_data);
+       }
+
+       g_free(peer_ip);
+
+       __ASP_LOG_FUNC_EXIT__;
+       return;
+}
+
 gint32 asp_tech_p2p_advertise(asp_service_advertise_s *service, gint32 replace)
 {
        __ASP_LOG_FUNC_ENTER__;