return MESHD_ERROR_NONE;
}
-int mesh_ipc_connect_network(mesh_service *service, mesh_scan_result_s *info)
+static void on_response_connect_network(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
{
int ret = MESHD_ERROR_NONE;
- GVariant *variant = NULL;
GError *error = NULL;
+ GVariant *variant = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
+ NOTUSED(user_data);
- variant = g_dbus_connection_call_sync(service->connection,
- CONNMAN_SERVER_NAME,
- info->object_path,
- CONNMAN_INTERFACE_MESH,
- "Connect",
- NULL, NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, &error);
+ variant = g_dbus_connection_call_finish(
+ G_DBUS_CONNECTION(source_object), res, &error);
if (variant) {
MESH_LOGD("Successfully requested. [Connect]");
} else if (error) {
if (g_strrstr(error->message, "Already exists"))
ret = MESHD_ERROR_ALREADY_REGISTERED;
+ else if (g_strrstr(error->message, "In progress"))
+ ret = MESHD_ERROR_IN_PROGRESS;
else
ret = MESHD_ERROR_IO_ERROR;
g_error_free(error);
}
- return ret;
+ mesh_notify_mesh_connected(ret);
+}
+
+int mesh_ipc_connect_network(mesh_service *service, mesh_scan_result_s *info)
+{
+ meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
+ meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
+
+ g_dbus_connection_call(service->connection,
+ CONNMAN_SERVER_NAME,
+ info->object_path,
+ CONNMAN_INTERFACE_MESH,
+ "Connect",
+ NULL, NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ MESH_DBUS_PROXY_TIMEOUT * 2, /* Waits for long time */
+ NULL,
+ on_response_connect_network, service);
+
+ return MESHD_ERROR_NONE;
}
int mesh_ipc_disconnect_network(mesh_service *service, mesh_scan_result_s *info)