int frequency);
/**
+ * @brief Gets access point passphrase from configuration.
+ * @since_tizen 9.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/wifi.secureinfo
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] config The access point configuration handle
+ * @param[out] passphrase The passphrase of access point
+ *
+ * @return 0 on success, otherwise negative error value.
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_config_get_passphrase(wifi_manager_h wifi,
+ wifi_manager_config_h config, char **passphrase);
+
+/**
* @brief Reset all WiFi configurations
* @since_tizen 7.5
* @privlevel public
message = _net_invoke_dbus_method(network_info,
NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "GetConfigPassphrase",
- g_variant_new("(s)", config_id), &Error);
+ g_variant_new("(ss)", network_info->interface_name, config_id), &Error);
if (message == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to GetConfigPassphrase");
return WIFI_MANAGER_ERROR_NONE;
}
+EXPORT_API int wifi_manager_config_get_passphrase(wifi_manager_h wifi,
+ wifi_manager_config_h config, char **passphrase)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ int ret = WIFI_MANAGER_ERROR_NONE;
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+
+ if (config == NULL || h->name == NULL || passphrase == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (_wifi_check_config_validity(config) == false) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ if (h->is_saved == TRUE) {
+ gchar *config_id = NULL;
+
+ config_id = _wifi_config_get_config_id(h->name, h->security_type);
+
+ ret = _wifi_configuration_get_passphrase(wifi, config_id, passphrase);
+ if (ret != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Fail to get passphrase [%d]", ret);
+
+ g_free(config_id);
+ }
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+
+ return ret;
+}
+
/**
* wifi configuration set field
*/
return 1;
}
+static bool __test_config_list_cb_for_passphrase(const wifi_manager_config_h config, void *user_data)
+{
+ char *name = NULL;
+ char *passphrase = NULL;
+ struct wman_public_info *data = user_data;
+ wifi_manager_security_type_e security_type;
+
+ wifi_manager_config_get_name(config, &name);
+ wifi_manager_config_get_security_type(config, &security_type);
+
+ if (wman_test_compare_ap_name(name, data->name) && security_type == data->type) {
+ int rv = wifi_manager_config_get_passphrase(data->wifi, config, &passphrase);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get passphrase [%s]\n", wman_test_strerror(rv));
+ } else {
+ printf("Success to get passphrase [%s][%s]\n", name, passphrase);
+ free(passphrase);
+ }
+ free(name);
+
+ return false;
+ }
+ free(name);
+
+ return true;
+}
+
+int wman_test_get_wifi_passphrase(wifi_manager_h wifi)
+{
+ int rv;
+ char name[33];
+ struct wman_public_info data = {wifi, name};
+
+ printf("Input AP configuration\n");
+ printf("Input AP Name : ");
+ rv = scanf(" %32[^\n]s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+ rv = scanf(" %d", &data.type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_config_foreach_configuration(wifi, __test_config_list_cb_for_passphrase, &data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get configurations [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
int wman_test_set_ip_conflict_period(wifi_manager_h wifi)
{
int rv = 0;
int wman_test_set_ap_auto_connect(wifi_manager_h wifi);
int wman_test_get_ap_auto_connect(wifi_manager_h wifi);
int wman_test_reset_wifi_configurations(wifi_manager_h wifi);
+int wman_test_get_wifi_passphrase(wifi_manager_h wifi);
int wman_test_set_ip_conflict_period(wifi_manager_h wifi);
int wman_test_get_ip_conflict_period(wifi_manager_h wifi);
int wman_test_netlink_scan(wifi_manager_h wifi);
printf("[ - Get Interval of Auto Scan\n");
printf("] - Set Interval of Auto Scan\n");
printf("; - Remove All Wi-Fi configurations\n");
+ printf(", - Get Wi-Fi passphrase\n");
printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
case ';':
rv = wman_test_reset_wifi_configurations(wifi);
break;
+ case ',':
+ rv = wman_test_get_wifi_passphrase(wifi);
+ break;
default:
break;
}