int _net_dbus_remove_vsie(unsigned int frame_id, const char *vsie_str);
int _net_dbus_get_vsie_list(GSList **vsie_list);
int _net_dbus_flush_bss(void);
-
+int _net_dbus_get_auto_connect_mode(int *connect_mode);
+int _net_dbus_set_auto_connect_mode(int connect_mode);
#ifdef __cplusplus
}
int net_wifi_remove_vsie(unsigned int frame_id, const char *vsie_str);
int net_wifi_get_vsie_list(GSList **vsie_list);
int net_wifi_flush_bss(void);
+int net_wifi_get_auto_connect_mode(int *connect_mode);
+int net_wifi_set_auto_connect_mode(int connect_mode);
int net_wifi_cancel_wps(void);
int _wifi_remove_vsie(wifi_manager_h wifi,
wifi_manager_vsie_frames_e frame_id, const char *vsie_str);
int _wifi_get_vsie_list(wifi_manager_vsie_list_cb callback, void *user_data);
+
int _wifi_flush_bss(void);
+int _wifi_get_auto_connect(int *connect_mode);
+int _wifi_set_auto_connect(int connect_mode);
/* WIFI Privilege Check */
int _wifi_check_get_privilege();
*/
int wifi_manager_flush_bss(wifi_manager_h wifi);
+/**
+ * @brief Gets auto connect mode
+ * @since_tizen 4.0
+ * @param[out] connect_mode pointer
+ * @return 0 on success, otherwise negative error value.
+ * @retval #WIFI_ERROR_NONE Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation
+ */
+int wifi_manager_get_auto_connect(wifi_manager_h wifi, int *connect_mode);
+
+/**
+ * @brief Sets auto connect mode
+ * @since_tizen 4.0
+ * @param[in] connect_mode
+ * @return 0 on success, otherwise negative error value.
+ * @retval #WIFI_ERROR_NONE Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation
+ */
+int wifi_manager_set_auto_connect(wifi_manager_h wifi, int connect_mode);
+
+
/**
* @}
*/
__NETWORK_FUNC_EXIT__;
}
+static void __net_set_auto_connect_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_e Error = NET_ERR_NONE;
+
+ WIFI_LOG(WIFI_INFO, "WiFi set auto connection reply");
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ Error = __net_netconfig_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "set auto connect failed[%d]", Error);
+ else
+ WIFI_LOG(WIFI_INFO, "set auto connect succeeded");
+
+ _net_dbus_pending_call_unref();
+ __NETWORK_FUNC_EXIT__;
+}
+
+
static char *__net_make_group_name(const char *ssid,
const char *net_mode, const char *sec)
{
g_variant_unref(message);
WIFI_LOG(WIFI_INFO, "Successfully flush bss\n");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_get_auto_connect_mode(int *connect_mode)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *value = NULL;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ gboolean status = TRUE;
+
+ message = _net_invoke_dbus_method(
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get service properties");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "AutoConnectMode") == 0) {
+ status = g_variant_get_boolean(value);
+ g_variant_unref(value);
+ g_free(key);
+ break;
+ }
+ }
+
+ *connect_mode = (int)status;
+
+ WIFI_LOG(WIFI_INFO, "Successfully auto connect mode: %d", *connect_mode);
+
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
return Error;
}
+
+int _net_dbus_set_auto_connect_mode(int connect_mode)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariant *params = NULL;
+ GVariant *param0 = NULL;
+ net_err_e Error = NET_ERR_NONE;
+ char key[] = "AutoConnectMode";
+ gboolean value_enable = TRUE;
+ gboolean value_disable = FALSE;
+
+ WIFI_LOG(WIFI_INFO, "Request auto connect mode [%s]",
+ connect_mode == 1 ? "enable" : "disable");
+
+ if (connect_mode == 1)
+ param0 = g_variant_new_boolean(value_enable);
+ else
+ param0 = g_variant_new_boolean(value_disable);
+
+ params = g_variant_new("(sv)", key, param0);
+
+ Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "SetProperty", params, 6 * DBUS_REPLY_TIMEOUT,
+ __net_set_auto_connect_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+
static void __net_wps_cancel_reply(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
__NETWORK_FUNC_EXIT__;
return Error;
}
-//LCOV_EXCL_STOP
EXPORT_API int net_wifi_flush_bss(void)
{
return NET_ERR_NONE;
}
+EXPORT_API int net_wifi_set_auto_connect_mode(int connect_mode)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if ((Error = _net_dbus_set_auto_connect_mode(connect_mode)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to set auto connect mode. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+EXPORT_API int net_wifi_get_auto_connect_mode(int *connect_mode)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if ((Error = _net_dbus_get_auto_connect_mode(connect_mode)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to set auto connect mode. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+//LCOV_EXCL_STOP
+
int net_open_connection_with_wifi_info(const net_wifi_connection_info_s *wifi_info)
{
__NETWORK_FUNC_ENTER__;
return WIFI_MANAGER_ERROR_NONE;
}
+int _wifi_set_auto_connect(int connect_mode)
+{
+ int rv;
+
+ rv = net_wifi_set_auto_connect_mode(connect_mode);
+
+ if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set auto connection mode");
+ }
+
+ return rv;
+}
+
+int _wifi_get_auto_connect(int *connect_mode)
+{
+ int rv;
+
+ rv = net_wifi_get_auto_connect_mode(connect_mode);
+
+ if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get auto connection mode");
+ }
+
+ return rv;
+}
+
int _wifi_get_connected_profile(wifi_manager_ap_h *ap)
{
int rv;
return rv;
}
+
+EXPORT_API int wifi_manager_get_auto_connect(wifi_manager_h wifi, int *connect_mode)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ WIFI_LOG(WIFI_INFO, "[App-->TizenMW] get auto connect mode");
+
+ int rv;
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_get_auto_connect(connect_mode);
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_set_auto_connect(wifi_manager_h wifi, int connect_mode)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ WIFI_LOG(WIFI_INFO, "[App-->TizenMW] set auto connect mode");
+
+ int rv;
+
+ rv = _wifi_set_auto_connect(connect_mode);
+
+ return rv;
+}
//LCOV_EXCL_STOP
EXPORT_API int wifi_manager_specific_scan_create(wifi_manager_h wifi,
return 1;
}
+int test_wifi_manager_set_auto_connect(void)
+{
+ int rv;
+ int mode;
+
+ printf("Auto connect mode (1:enable, 0:disable) : ");
+ rv = scanf("%d", &mode);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_auto_connect(wifi, mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set auto connect mode, rv = %d\n", rv);
+ }
+
+ printf("Request to set auto connect mode\n");
+ return 1;
+}
+
+int test_wifi_manager_get_auto_connect(void)
+{
+ int rv;
+ int mode;
+
+ rv = wifi_manager_get_auto_connect(wifi, &mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get auto connect mode, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Request to get auto connect mode = %d (1:enable, 0:disable)\n", mode);
+ return 1;
+}
+
int main(int argc, char **argv)
{
GMainLoop *mainloop;
printf("H - Remove VSIE\n");
printf("I - Start Multi Scan\n");
printf("J - Flush BSS\n");
+ printf("K - Set auto connect mode\n");
+ printf("L - Get auto connect mode\n");
printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
case 'J':
rv = test_wifi_manager_flush_bss();
break;
+ case 'K':
+ rv = test_wifi_manager_set_auto_connect();
+ break;
+ case 'L':
+ rv = test_wifi_manager_get_auto_connect();
+ break;
default:
break;
}