Sync with Tizen 2.4(v1.0.57) 07/49007/5 accepted/tizen/mobile/20151020.110954 accepted/tizen/tv/20151020.111016 accepted/tizen/wearable/20151020.111027 submit/tizen/20151020.082803
authortaesub.kim <taesub.kim@samsung.com>
Mon, 5 Oct 2015 05:24:15 +0000 (14:24 +0900)
committertaesub.kim <taesub.kim@samsung.com>
Wed, 7 Oct 2015 00:26:00 +0000 (09:26 +0900)
Change-Id: I3f1ededa3242f9ff80904d8d72542d6071df3dde
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
18 files changed:
CMakeLists.txt [changed mode: 0644->0755]
LICENSE [changed mode: 0644->0755]
NOTICE [changed mode: 0644->0755]
capi-network-wifi.manifest [changed mode: 0644->0755]
capi-network-wifi.pc.in [changed mode: 0644->0755]
doc/wifi_doc.h
include/net_wifi_private.h
include/wifi.h
include/wifi_config_private.h [new file with mode: 0644]
include/wifi_dbus_private.h [new file with mode: 0644]
packaging/capi-network-wifi.spec [changed mode: 0644->0755]
src/libnetwork.c
src/net_wifi.c
src/net_wifi_config.c [new file with mode: 0644]
src/wifi_config.c [new file with mode: 0644]
src/wifi_dbus.c [new file with mode: 0644]
test/CMakeLists.txt [changed mode: 0644->0755]
test/wifi_test.c

old mode 100644 (file)
new mode 100755 (executable)
index 76db0c6..7d1ed57
@@ -11,7 +11,7 @@ SET(LIBDIR ${PREFIX}/${LIB_PATH})
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-SET(dependents "dlog vconf capi-base-common glib-2.0 network capi-system-info")
+SET(dependents "dlog vconf capi-base-common capi-system-info glib-2.0 gio-2.0 gthread-2.0 network ")
 SET(pc_dependents "capi-base-common")
 
 IF(TIZEN_DUALSIM_ENABLE)
diff --git a/LICENSE b/LICENSE
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/NOTICE b/NOTICE
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 6e63093..59eb4d2 100755 (executable)
@@ -40,7 +40,7 @@
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
  *
  */
 
@@ -68,7 +68,7 @@
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
  *
  */
 
@@ -92,7 +92,7 @@
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
  *
  */
 
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
  *
  */
 
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
  *
  */
 
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
  *
  */
 
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
  *
  */
 
 
+/**
+ * @defgroup CAPI_NETWORK_WIFI_CONFIG_MODULE  Wi-Fi Configuration
+ * @brief The Configuration API provides functions for managing the configuration of Wi-Fi.
+ * @ingroup CAPI_NETWORK_WIFI_MODULE
+ *
+ * @section CAPI_NETWORK_WIFI_CONFIG_MODULE  Required Header
+ *   \#include <wifi.h>
+ *
+ * @section CAPI_NETWORK_WIFI_CONFIG_MODULE_OVERVIEW Overview
+ * The Configuration API provides functions for managing the configuration of Wi-Fi. You can manage the configuration information using the functions.
+ * @section CAPI_NETWORK_WIFI_CONFIG_MODULE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a>
+ *
+ */
 
 #endif /* __TIZEN_NETWORK_WIFI_DOC_H__ */
index ba2d954..f5b74e5 100755 (executable)
@@ -23,6 +23,7 @@
 #include <system_info.h>
 
 #include "wifi.h"
+#include "wifi_dbus_private.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -116,6 +117,10 @@ void _wifi_callback_cleanup(void);
 
 int _wifi_check_feature_supported(const char *feature_name);
 
+int        _wifi_dbus_init(void);
+int        _wifi_dbus_deinit(void);
+wifi_dbus *_wifi_get_dbus_handle(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 126d8cc..5c26608 100755 (executable)
@@ -243,6 +243,20 @@ typedef void* wifi_ap_h;
 * @}
 */
 
+/**
+* @addtogroup CAPI_NETWORK_WIFI_CONFIG_MODULE
+* @{
+*/
+
+/**
+ * @brief The Wi-Fi access point configuration handle
+ * @since_tizen 2.4
+ */
+typedef void *wifi_config_h;
+
+/**
+* @}
+*/
 
 /**
 * @addtogroup CAPI_NETWORK_WIFI_MANAGER_MODULE
@@ -363,6 +377,28 @@ typedef void(*wifi_rssi_level_changed_cb)(wifi_rssi_level_e rssi_level, void *us
 * @}
 */
 
+/**
+* @addtogroup CAPI_NETWORK_WIFI_CONFIG_MODULE
+* @{
+*/
+
+/**
+ * @brief Called when you get the found access point configurations repeatedly.
+ * @since_tizen 2.4
+ * @remarks @a config is valid only in this function. In order to use @a config outside this function, you must copy the config with wifi_config_clone().
+ *
+ * @param[in]  config          The access point configuration handle
+ * @param[in]  user_data       The user data passed from the request function
+ *
+ * @return  @c true to continue with the next iteration of the loop, otherwise @c false to break out of the loop \n
+ * @pre  wifi_config_foreach_configuration() will invoke this callback.
+ * @see  wifi_config_foreach_configuration()
+ */
+typedef bool (*wifi_config_list_cb)(const wifi_config_h config, void *user_data);
+
+/**
+* @}
+*/
 
 /**
 * @addtogroup CAPI_NETWORK_WIFI_MODULE
@@ -1616,6 +1652,429 @@ int wifi_ap_set_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e type);
 * @}
 */
 
+/**
+* @addtogroup CAPI_NETWORK_WIFI_CONFIG_MODULE
+* @{
+*/
+
+/**
+ * @brief Gets access point configuration handle.
+ * @since_tizen 2.4
+ * @remarks You must release @a config using wifi_config_destroy().
+ *
+ * @param[in] name                             The access point name
+ * @param[in] passphrase               The access point passphrase
+ * @param[in] security_type            The access point security type
+ * @param[out] config                  The access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ * @see wifi_config_destroy()
+ * @pre This API needs wifi_initialize() before use
+ */
+int wifi_config_create(const char *name, const char *passphrase, wifi_security_type_e security_type, wifi_config_h *config);
+
+/**
+ * @brief Clones the access point configuration handle.
+ * @since_tizen 2.4
+ * @remarks You must release @a cloned_config using wifi_config_destroy().
+ *
+ * @param[in] origin                           The origin access point configuration handle
+ * @param[out] cloned_config   The cloned access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ * @see wifi_config_destroy()
+ */
+int wifi_config_clone(wifi_config_h origin, wifi_config_h *cloned_config);
+
+/**
+ * @brief Destroys the access point configuration handle.
+ * @since_tizen 2.4
+ *
+ * @param[in] config   The access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ * @see wifi_config_create()
+ * @see wifi_config_clone()
+ */
+int wifi_config_destroy(wifi_config_h config);
+
+/**
+ * @brief Saves Wi-Fi configuration of access point.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config   The access point configuration handle
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission denied
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ * @see wifi_config_create()
+ */
+int wifi_config_save_configuration(wifi_config_h config);
+
+/**
+ * @brief Gets the result of access point configurations repeatedly.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] callback         The callback to be called
+ * @param[in] user_data                The user data passed to the callback function
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission denied
+ * @retval #WIFI_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ * @pre This API needs wifi_initialize() before use.
+ * @post This function invokes wifi_config_list_cb().
+ */
+int wifi_config_foreach_configuration(wifi_config_list_cb callback, void *user_data);
+
+/**
+ * @brief Gets the name of access point from configuration.
+ * @since_tizen 2.4
+ * @remarks You must release @a name using free().
+ *
+ * @param[in] config   The access point configuration handle
+ * @param[out] name            The name of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ */
+int wifi_config_get_name(wifi_config_h config, char **name);
+
+/**
+ * @brief Gets the security type of access point from configuration.
+ * @since_tizen 2.4
+ *
+ * @param[in] config                   The access point configuration handle
+ * @param[out] security_type   The security type of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ */
+int wifi_config_get_security_type(wifi_config_h config, wifi_security_type_e *security_type);
+
+/**
+ * @brief Sets access point proxy address configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config                   The access point configuration handle
+ * @param[in] address_family   The address family
+ * @param[in] proxy_address            The proxy address
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission denied
+ * @retval #WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ */
+int wifi_config_set_proxy_address(wifi_config_h config, wifi_address_family_e address_family, const char *proxy_address);
+
+/**
+ * @brief Gets the proxy address of access point from configuration.
+ * @since_tizen 2.4
+ * @remarks You must release @a proxy_address using free().
+ *
+ * @param[in] config                   The access point configuration handle
+ * @param[out] address_family  The address family
+ * @param[out] proxy_address   The proxy address
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ */
+int wifi_config_get_proxy_address(wifi_config_h config, wifi_address_family_e *address_family, char **proxy_address);
+
+/**
+ * @brief Sets the hidden property of access point from the configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[in] is_hidden                true to enable and false to disable
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission denied
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ */
+int wifi_config_set_hidden_ap_property(wifi_config_h config, bool is_hidden);
+
+/**
+ * @brief Gets the hidden property of access point from the configuration.
+ * @since_tizen 2.4
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[out] is_hidden       The hidden property of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_NOT_SUPPORTED           Not supported
+ */
+int wifi_config_get_hidden_ap_property(wifi_config_h config, bool *is_hidden);
+
+/**
+ * @brief Gets access point anonymous identity from configuration.
+ * @since_tizen 2.4
+ * @remarks You must release @a anonymous_identity using free().
+ *
+ * @param[in] config                           The access point configuration handle
+ * @param[out] anonymous_identity      The anonymous identity of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ */
+int wifi_config_get_eap_anonymous_identity(wifi_config_h config, char** anonymous_identity);
+
+/**
+ * @brief Sets access point anonymous identity to configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config                           The access point configuration handle
+ * @param[in] anonymous_identity       The anonymous identity
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission Denied
+ */
+int wifi_config_set_eap_anonymous_identity(wifi_config_h config, const char* anonymous_identity);
+
+/**
+ * @brief Gets access point cacert file from configuration.
+ * @since_tizen 2.4
+ * @remarks You must release @a ca_cert using free().
+ * @remarks The mediastorage privilege http://tizen.org/privilege/mediastorage is needed \n
+ *                      if @a image_path is relevant to media storage.\n
+ *                      The externalstorage privilege http://tizen.org/privilege/externalstorage is needed \n
+ *                      if @a image_path is relevant to external storage.
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[out] ca_cert         The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ */
+int wifi_config_get_eap_ca_cert_file(wifi_config_h config, char** ca_cert);
+
+/**
+ * @brief Sets access point cacert file to configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ * @remarks The mediastorage privilege http://tizen.org/privilege/mediastorage is needed \n
+ *                      if @a image_path is relevant to media storage.\n
+ *                      The externalstorage privilege http://tizen.org/privilege/externalstorage is needed \n
+ *                      if @a image_path is relevant to external storage.
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[in] ca_cert          The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission Denied
+ */
+int wifi_config_set_eap_ca_cert_file(wifi_config_h config, const char* ca_cert);
+
+/**
+ * @brief Gets access point client cert file from configuration.
+ * @since_tizen 2.4
+ * @remarks You must release @a client_crt using free().
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[out] client_crt      The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ */
+int wifi_config_get_eap_client_cert_file(wifi_config_h config, char** client_cert);
+
+/**
+ * @brief Sets access point client cert file to configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[in] private_key      The private key file
+ * @param[in] client_crt               The certification authority(CA) certificates file of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission Denied
+ */
+int wifi_config_set_eap_client_cert_file(wifi_config_h config, const char* private_key, const char* client_cert);
+
+/**
+ * @brief Gets access point identity from configuration.
+ * @since_tizen 2.4
+ * @remarks You must release @a identity using free().
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[out] identity                The identity of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ */
+int wifi_config_get_eap_identity(wifi_config_h config, char** identity);
+
+/**
+ * @brief Sets access point identity to configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[in] identity         The identity
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission Denied
+ */
+int wifi_config_set_eap_identity(wifi_config_h config, const char* identity);
+
+/**
+ * @brief Gets access point eap type from configuration.
+ * @since_tizen 2.4
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[out] eap_type        The eap type of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ */
+int wifi_config_get_eap_type(wifi_config_h config, wifi_eap_type_e *eap_type);
+
+/**
+ * @brief Sets access point eap type to configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config           The access point configuration handle
+ * @param[in] eap_type         The eap type
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission Denied
+ */
+int wifi_config_set_eap_type(wifi_config_h config, wifi_eap_type_e eap_type);
+
+/**
+ * @brief Gets access point eap auth type from configuration.
+ * @since_tizen 2.4
+ *
+ * @param[in] config                   The access point configuration handle
+ * @param[out] eap_auth_type   The eap auth type of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ */
+int wifi_config_get_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e* eap_auth_type);
+
+/**
+ * @brief Sets access point eap auth type to configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config                   The access point configuration handle
+ * @param[in] eap_auth_type    The eap auth type
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission Denied
+ */
+int wifi_config_set_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e eap_auth_type);
+
+/**
+ * @brief Gets access point subject match from configuration.
+ * @since_tizen 2.4
+ * @remarks You must release @a subject_match using free().
+ *
+ * @param[in] config                   The access point configuration handle
+ * @param[out] subject_match   The subject match of access point
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ */
+int wifi_config_get_eap_subject_match(wifi_config_h config, char** subject_match);
+
+/**
+ * @brief Sets access point subject match to configuration.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ *
+ * @param[in] config                   The access point configuration handle
+ * @param[in] subject_match    The subject match
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                                    Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #WIFI_ERROR_PERMISSION_DENIED       Permission Denied
+ */
+int wifi_config_set_eap_subject_match(wifi_config_h config, const char* subject_match);
+
+/**
+* @}
+*/
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/wifi_config_private.h b/include/wifi_config_private.h
new file mode 100644 (file)
index 0000000..e3da460
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef __WIFI_CONFIG_H__
+#define __WIFI_CONFIG_H__
+
+#include <glib.h>
+
+#include "wifi.h"
+#include "wifi_dbus_private.h"
+
+#define WIFI_CONFIG_NAME                        "Name"
+#define WIFI_CONFIG_SSID                "SSID"
+#define WIFI_CONFIG_PASSPHRASE                  "Passphrase"
+#define WIFI_CONFIG_SECURITY_TYPE       "Security"
+#define WIFI_CONFIG_PROXYADDRESS                "ProxyAddress"
+#define WIFI_CONFIG_HIDDEN                              "Hidden"
+#define WIFI_CONFIG_FAILURE                    "Failure"
+#define WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY                     "AnonymousIdentity"
+#define WIFI_CONFIG_EAP_CACERT                 "CACertFile"
+#define WIFI_CONFIG_EAP_CLIENTCERT                     "ClientCertFile"
+#define WIFI_CONFIG_EAP_PRIVATEKEY             "PrivateKeyFile"
+#define WIFI_CONFIG_EAP_IDENTITY               "Identity"
+#define WIFI_CONFIG_EAP_TYPE           "EapType"
+#define WIFI_CONFIG_EAP_AUTH_TYPE      "EapAuthType"
+#define WIFI_CONFIG_EAP_SUBJECT_MATCH  "SubjectMatch"
+
+struct _wifi_eap_config {
+       gchar *ca_cert;
+       gchar *private_key;
+       gchar *client_cert;
+       gchar *anonymous_identity;
+       gchar *identity;
+       gchar *subject_match;
+       wifi_eap_type_e eap_type;
+       wifi_eap_auth_type_e eap_auth_type;
+};
+
+struct _wifi_config {
+       // mandatory
+       gchar *name;
+       gchar *passphrase;
+       wifi_security_type_e security_type;
+       gboolean is_saved;
+
+       // optional field is set using wifi_config_set_field
+       gboolean is_hidden;
+       gchar *proxy_address;
+       wifi_address_family_e address_family;
+       struct _wifi_eap_config *eap_config;
+       wifi_error_e last_error;
+};
+
+gchar * wifi_config_get_config_id(const gchar *name, wifi_security_type_e security_type);
+GSList *wifi_config_get_config_id_list(wifi_dbus *handle);
+
+int wifi_config_get_last_error(wifi_config_h config, wifi_error_e *last_error);
+
+int wifi_save_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden);
+int wifi_load_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, wifi_error_e *last_error);
+int wifi_configuration_set_field(wifi_dbus *handle, const gchar *config_id, const gchar *key, const gchar *value);
+int wifi_configuration_get_passphrase(wifi_dbus *handle, const gchar *config_id, gchar **passphrase);
+
+int wifi_save_eap_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, struct _wifi_eap_config *eap_config, gboolean is_hidden);
+int wifi_load_eap_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, struct _wifi_eap_config **eap_config,wifi_error_e *last_error);
+wifi_eap_type_e wifi_eap_type_to_int(const gchar *type);
+wifi_eap_auth_type_e wifi_eap_auth_type_to_int(const gchar *type);
+gchar *wifi_eap_type_to_string(wifi_eap_type_e eap_type);
+gchar *wifi_eap_auth_type_to_string(wifi_eap_auth_type_e eap_auth_type);
+
+#endif
+
diff --git a/include/wifi_dbus_private.h b/include/wifi_dbus_private.h
new file mode 100644 (file)
index 0000000..5d41865
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __WIFI_DBUS_H__
+#define __WIFI_DBUS_H__
+
+#include <gio/gio.h>
+
+#define DBUS_REPLY_TIMEOUT      (120 * 1000)
+
+#define NETCONFIG_SERVICE                                       "net.netconfig"
+#define NETCONFIG_IWIFI                                         "net.netconfig.wifi"
+#define NETCONFIG_INETWORK                                      "net.netconfig.network"
+#define NETCONFIG_ISTATISTICS                           "net.netconfig.network_statistics"
+
+#define NETCONFIG_WIFI_PATH                             "/net/netconfig/wifi"
+#define NETCONFIG_NETWORK_PATH                  "/net/netconfig/network"
+#define NETCONFIG_STATISTICS_PATH                       "/net/netconfig/network_statistics"
+
+struct _wifi_dbus {
+       GDBusConnection *dbus_conn;
+       GCancellable *ca;
+};
+
+typedef struct _wifi_dbus wifi_dbus;
+
+int wifi_dbus_init(wifi_dbus **handle);
+int wifi_dbus_deinit(wifi_dbus *handle);
+
+#endif
old mode 100644 (file)
new mode 100755 (executable)
index c7c0ae0..230fb0c
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.0.58
+Version:       1.0.59
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
@@ -10,6 +10,8 @@ BuildRequires:        pkgconfig(dlog)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(network)
 BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(gthread-2.0)
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(capi-system-info)
 Requires(post):                /sbin/ldconfig
index 113145c..bae7d92 100755 (executable)
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "wifi_dbus_private.h"
 #include "net_wifi_private.h"
 
 static __thread bool is_init = false;
@@ -69,6 +70,8 @@ static __thread bool is_feature_checked = false;
 static __thread bool feature_supported = false;
 static __thread GSList *managed_idler_list = NULL;
 
+wifi_dbus *g_dbus_h = NULL;
+
 bool _wifi_is_init(void)
 {
        return is_init;
@@ -870,43 +873,42 @@ int _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state)
        return WIFI_ERROR_NONE;
 }
 
-int _wifi_libnet_get_wifi_state(wifi_connection_state_econnection_state)
+int _wifi_libnet_get_wifi_state(wifi_connection_state_e *connection_state)
 {
-       int rv;
-       net_wifi_state_t wlan_state = 0;
-       net_profile_name_t profile_name;
+       wifi_dbus *dbus_h = NULL;
+       GError *error = NULL;
+       GVariant *result = NULL;
+       gint state = 0;
 
-       rv = net_get_wifi_state(&wlan_state, &profile_name);
-       if (rv == NET_ERR_ACCESS_DENIED) {
-               WIFI_LOG(WIFI_ERROR, "Access denied");
-               return WIFI_ERROR_PERMISSION_DENIED;
-       } else if (rv != NET_ERR_NONE) {
-               WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state");
-               return WIFI_ERROR_OPERATION_FAILED;
+       dbus_h = _wifi_get_dbus_handle();
+       if (dbus_h == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+               return WIFI_ERROR_INVALID_OPERATION;
        }
 
-       switch (wlan_state) {
-       case WIFI_OFF:
-       case WIFI_ON:
-               *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
-               break;
-       case WIFI_ASSOCIATION:
-               *connection_state = WIFI_CONNECTION_STATE_ASSOCIATION;
-               break;
-       case WIFI_CONFIGURATION:
-               *connection_state = WIFI_CONNECTION_STATE_CONFIGURATION;
-               break;
-       case WIFI_CONNECTED:
-               *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
-               break;
-       case WIFI_DISCONNECTING:
-               *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
-               break;
-       default :
-               WIFI_LOG(WIFI_ERROR, "Unknown state");
+       result = g_dbus_connection_call_sync(dbus_h->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "GetWifiState",
+                                            g_variant_new("()"),
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, dbus_h->ca,
+                                            &error);
+
+       if (error) {
+               WIFI_LOG(WIFI_ERROR, "Fail to GetWifiState [%d: %s]", error->code, error->message);
+               g_error_free(error);
                return WIFI_ERROR_OPERATION_FAILED;
        }
 
+       if (result != NULL) {
+               g_variant_get(result, "(i)", &state);
+               g_variant_unref(result);
+       }
+
+       *connection_state = state;
+
        return WIFI_ERROR_NONE;
 }
 
@@ -1357,3 +1359,32 @@ int _wifi_check_feature_supported(const char *feature_name)
 
        return WIFI_ERROR_NONE;
 }
+
+int _wifi_dbus_init(void)
+{
+       int rv;
+
+       rv = wifi_dbus_init(&g_dbus_h);
+       if (rv != NET_ERR_NONE)
+               return rv;
+
+       return NET_ERR_NONE;
+}
+
+int _wifi_dbus_deinit(void)
+{
+       wifi_dbus_deinit(g_dbus_h);
+       g_dbus_h = NULL;
+
+       return NET_ERR_NONE;
+}
+
+wifi_dbus *_wifi_get_dbus_handle(void)
+{
+       if (g_dbus_h == NULL) {
+               WIFI_LOG(WIFI_ERROR, "g_dbus_h is NULL");
+               return NULL;
+       }
+
+       return g_dbus_h;
+}
index e7e31d0..4095564 100755 (executable)
@@ -76,6 +76,8 @@ EXPORT_API int wifi_initialize(void)
                return WIFI_ERROR_OPERATION_FAILED;
        }
 
+       _wifi_dbus_init();
+
        WIFI_LOG(WIFI_INFO, "Wi-Fi successfully initialized");
 
        return WIFI_ERROR_NONE;
@@ -98,6 +100,8 @@ EXPORT_API int wifi_deinitialize(void)
        wifi_unset_rssi_level_changed_cb();
        _wifi_callback_cleanup();
 
+       _wifi_dbus_deinit();
+
        WIFI_LOG(WIFI_INFO, "Wi-Fi successfully de-initialized");
 
        return WIFI_ERROR_NONE;
@@ -185,14 +189,13 @@ EXPORT_API int wifi_get_mac_address(char** mac_address)
 {
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
-       FILE *fp = NULL;
-       char buf[WIFI_MAC_ADD_LENGTH+ 1];
-
        if (mac_address == NULL) {
                WIFI_LOG(WIFI_ERROR, "Invalid parameter");
                return WIFI_ERROR_INVALID_PARAMETER;
        }
 
+       FILE *fp = NULL;
+       char buf[WIFI_MAC_ADD_LENGTH + 1];
        if (0 == access(WIFI_MAC_ADD_PATH, F_OK))
                fp = fopen(WIFI_MAC_ADD_PATH, "r");
 
diff --git a/src/net_wifi_config.c b/src/net_wifi_config.c
new file mode 100644 (file)
index 0000000..08d439d
--- /dev/null
@@ -0,0 +1,816 @@
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi.h"
+#include "wifi_config_private.h"
+#include "net_wifi_private.h"
+
+/**
+ * wifi configuration
+ */
+EXPORT_API int wifi_config_create(const char *name, const char *passphrase, wifi_security_type_e security_type, wifi_config_h *config)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = NULL;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL || name == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       h = g_new0(struct _wifi_config, 1);
+       if (h == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       h->name = g_strdup(name);
+       h->passphrase = g_strdup(passphrase);
+       h->security_type = security_type;
+       h->is_saved = FALSE;
+       h->is_hidden = FALSE;
+       h->proxy_address = NULL;
+       h->address_family = WIFI_ADDRESS_FAMILY_IPV4;
+       h->eap_config = NULL;
+
+       if (security_type == WIFI_SECURITY_TYPE_EAP) {
+               h->eap_config = g_new0(struct _wifi_eap_config, 1);
+               if (h->eap_config == NULL)
+                       return WIFI_ERROR_OUT_OF_MEMORY;
+
+               h->eap_config->ca_cert = NULL;
+               h->eap_config->client_cert = NULL;
+               h->eap_config->private_key = NULL;
+               h->eap_config->anonymous_identity = NULL;
+               h->eap_config->identity = NULL;
+               h->eap_config->subject_match = NULL;
+               h->eap_config->eap_type = -1;
+               h->eap_config->eap_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
+       }
+
+       *config = (wifi_config_h)h;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_clone(wifi_config_h origin, wifi_config_h *cloned_config)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = NULL;
+       struct _wifi_config *config = NULL;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (origin == NULL || cloned_config == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       config = (struct _wifi_config *)origin;
+
+       h = g_new0(struct _wifi_config, 1);
+       if (h == NULL)
+               return WIFI_ERROR_OUT_OF_MEMORY;
+
+       h->name = g_strdup(config->name);
+       h->passphrase = g_strdup(config->passphrase);
+       h->security_type = config->security_type;
+       h->is_saved = config->is_saved;
+       h->is_hidden = config->is_hidden;
+       h->proxy_address = g_strdup(config->proxy_address);
+       h->address_family = config->address_family;
+
+       if (config->eap_config) {
+               h->eap_config = g_new0(struct _wifi_eap_config, 1);
+               if (h->eap_config == NULL)
+                       return WIFI_ERROR_OUT_OF_MEMORY;
+
+               h->eap_config->ca_cert = g_strdup(config->eap_config->ca_cert);
+               h->eap_config->client_cert = g_strdup(config->eap_config->client_cert);
+               h->eap_config->private_key = g_strdup(config->eap_config->private_key);
+               h->eap_config->anonymous_identity = g_strdup(config->eap_config->anonymous_identity);
+               h->eap_config->identity = g_strdup(config->eap_config->identity);
+               h->eap_config->subject_match = g_strdup(config->eap_config->subject_match);
+               h->eap_config->eap_type = config->eap_config->eap_type;
+               h->eap_config->eap_auth_type = config->eap_config->eap_auth_type;
+       }
+
+       *cloned_config = (wifi_config_h)h;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_destroy(wifi_config_h config)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       g_free(h->name);
+       g_free(h->passphrase);
+       g_free(h->proxy_address);
+       if (h->eap_config) {
+               g_free(h->eap_config->ca_cert);
+               g_free(h->eap_config->client_cert);
+               g_free(h->eap_config->private_key);
+               g_free(h->eap_config->anonymous_identity);
+               g_free(h->eap_config->identity);
+               g_free(h->eap_config->subject_match);
+               g_free(h->eap_config);
+       }
+       g_free(h);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_save_configuration(wifi_config_h config)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       int ret = WIFI_ERROR_NONE;
+       wifi_dbus *dbus_h = NULL;
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL || h->name == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       dbus_h = _wifi_get_dbus_handle();
+       if (dbus_h == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (h->security_type == WIFI_SECURITY_TYPE_EAP) {
+               ret = wifi_save_eap_configurations(dbus_h, h->name, h->passphrase, h->security_type, h->proxy_address, h->eap_config, h->is_hidden);
+               if (ret != WIFI_ERROR_NONE) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_eap_configurations");
+               }
+       }
+       else {
+               ret = wifi_save_configurations(dbus_h, h->name, h->passphrase, h->security_type, h->proxy_address, h->is_hidden);
+               if (ret != WIFI_ERROR_NONE) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to save configurations [%d]", ret);
+               }
+       }
+
+       h->is_saved = TRUE;
+
+       return ret;
+}
+
+EXPORT_API int wifi_config_foreach_configuration(wifi_config_list_cb callback, void *user_data)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       int ret = WIFI_ERROR_NONE;
+       wifi_dbus *dbus_h = NULL;
+       GSList *config_ids = NULL;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       dbus_h = _wifi_get_dbus_handle();
+       if (dbus_h == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       config_ids = wifi_config_get_config_id_list(dbus_h);
+       if (config_ids == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Fail to wifi_get_config_id_list");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       while (config_ids) {
+               bool rv = 0;
+               struct _wifi_config *h;
+               gchar *id = config_ids->data;
+
+               h = g_new0(struct _wifi_config, 1);
+               if (h == NULL) {
+                       ret = WIFI_ERROR_OUT_OF_MEMORY;
+                       break;
+               }
+
+               if (g_str_has_suffix(id, "ieee8021x") == TRUE) {
+                       h->eap_config = g_new0(struct _wifi_eap_config, 1);
+                       if (h->eap_config == NULL) {
+                               ret = WIFI_ERROR_OUT_OF_MEMORY;
+                               break;
+                       }
+                       ret = wifi_load_eap_configurations(dbus_h, id, &h->name,
+                               &h->security_type, &h->proxy_address, &h->is_hidden, &h->eap_config, &h->last_error);
+               }
+               else {
+                       ret = wifi_load_configurations(dbus_h, id, &h->name,
+                               &h->security_type, &h->proxy_address, &h->is_hidden, &h->last_error);
+               }
+
+               if (ret != WIFI_ERROR_NONE) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", ret);
+                       return ret;
+               }
+
+               h->address_family = WIFI_ADDRESS_FAMILY_IPV4;
+               h->is_saved = TRUE;
+               rv = callback((wifi_config_h)h, user_data);
+               g_free(h->name);
+               g_free(h->proxy_address);
+               if (h->eap_config) {
+                       g_free(h->eap_config->ca_cert);
+                       g_free(h->eap_config->client_cert);
+                       g_free(h->eap_config->private_key);
+                       g_free(h->eap_config->anonymous_identity);
+                       g_free(h->eap_config->identity);
+                       g_free(h->eap_config->subject_match);
+                       g_free(h->eap_config);
+               }
+               g_free(h);
+
+               if (rv == false)
+                       break;
+
+               config_ids = config_ids->next;
+       }
+
+       config_ids = g_slist_nth(config_ids, 0);
+       g_slist_free_full(config_ids, g_free);
+
+       return ret;
+}
+
+EXPORT_API int wifi_config_get_name(wifi_config_h config, char **name)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL || name == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (h->name != NULL)
+               *name = g_strdup(h->name);
+       else
+               *name = NULL;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_security_type(wifi_config_h config, wifi_security_type_e *security_type)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL || security_type == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       *security_type = h->security_type;
+
+       return WIFI_ERROR_NONE;
+}
+
+/**
+ * wifi configuration set field
+ */
+EXPORT_API int wifi_config_set_proxy_address(wifi_config_h config, wifi_address_family_e address_family, const char *proxy_address)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+       int ret = WIFI_ERROR_NONE;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+       if ((address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
+               WIFI_LOG(WIFI_ERROR, "Not supported yet");
+               return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+       }
+
+       h->address_family = address_family;
+       h->proxy_address = g_strdup(proxy_address);
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_PROXYADDRESS, proxy_address);
+               if (ret != WIFI_ERROR_NONE) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to set proxy address [%d]", ret);
+               }
+
+               g_free(config_id);
+       }
+
+       return ret;
+}
+
+EXPORT_API int wifi_config_get_proxy_address(wifi_config_h config, wifi_address_family_e *address_family, char **proxy_address)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL || address_family == NULL || proxy_address == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       *address_family = h->address_family;
+       *proxy_address = g_strdup(h->proxy_address);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_hidden_ap_property(wifi_config_h config, bool hidden)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+       int ret = WIFI_ERROR_NONE;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       h->is_hidden = hidden;
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               char *config_id = NULL;
+               char *hidden = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               if (h->is_hidden == TRUE) {
+                       hidden = g_strdup("TRUE");
+               } else {
+                       hidden = g_strdup("FALSE");
+               }
+               ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_HIDDEN, hidden);
+               if (ret != WIFI_ERROR_NONE) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to set hidden [%d]", ret);
+               }
+
+               g_free(hidden);
+               g_free(config_id);
+       }
+
+       return ret;
+}
+
+EXPORT_API int wifi_config_get_hidden_ap_property(wifi_config_h config, bool *hidden)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL || hidden == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       *hidden = h->is_hidden;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_eap_anonymous_identity(wifi_config_h config, char** anonymous_identity)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (anonymous_identity == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       *anonymous_identity = g_strdup(h->eap_config->anonymous_identity);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_eap_anonymous_identity(wifi_config_h config, const char* anonymous_identity)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       h->eap_config->anonymous_identity = g_strdup(anonymous_identity);
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, anonymous_identity);
+
+               g_free(config_id);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_eap_ca_cert_file(wifi_config_h config, char** ca_cert)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (ca_cert == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       *ca_cert = g_strdup(h->eap_config->ca_cert);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_eap_ca_cert_file(wifi_config_h config, const char* ca_cert)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       h->eap_config->ca_cert = g_strdup(ca_cert);
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CACERT, ca_cert);
+
+               g_free(config_id);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_eap_client_cert_file(wifi_config_h config, char** client_cert)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (client_cert == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       *client_cert = g_strdup(h->eap_config->client_cert);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_eap_client_cert_file(wifi_config_h config, const char* private_key, const char* client_cert)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       h->eap_config->private_key = g_strdup(private_key);
+       h->eap_config->client_cert = g_strdup(client_cert);
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CLIENTCERT, client_cert);
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_PRIVATEKEY, private_key);
+
+               g_free(config_id);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_eap_identity(wifi_config_h config, char** identity)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (identity == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       *identity = g_strdup(h->eap_config->identity);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_eap_identity(wifi_config_h config, const char* identity)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       h->eap_config->identity = g_strdup(identity);
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_IDENTITY, identity);
+
+               g_free(config_id);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_eap_type(wifi_config_h config, wifi_eap_type_e *eap_type)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (eap_type == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       *eap_type = h->eap_config->eap_type;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_eap_type(wifi_config_h config, wifi_eap_type_e eap_type)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       h->eap_config->eap_type = eap_type;
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+               gchar *value = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               value = wifi_eap_type_to_string(eap_type);
+
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_TYPE, value);
+
+               g_free(config_id);
+               g_free(value);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e* eap_auth_type)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (eap_auth_type == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       *eap_auth_type = h->eap_config->eap_auth_type;
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e eap_auth_type)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       h->eap_config->eap_auth_type = eap_auth_type;
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+               gchar *value = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               value = wifi_eap_auth_type_to_string(eap_auth_type);
+
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_AUTH_TYPE, value);
+
+               g_free(config_id);
+               g_free(value);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_get_eap_subject_match(wifi_config_h config, char** subject_match)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (subject_match == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       *subject_match = g_strdup(h->eap_config->subject_match);
+
+       return WIFI_ERROR_NONE;
+}
+
+EXPORT_API int wifi_config_set_eap_subject_match(wifi_config_h config, const char* subject_match)
+{
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+       if (h->eap_config == NULL)
+               return WIFI_ERROR_INVALID_PARAMETER;
+
+       h->eap_config->subject_match = g_strdup(subject_match);
+
+       if (h->is_saved == TRUE) {
+               wifi_dbus *dbus_h = NULL;
+               gchar *config_id = NULL;
+
+               dbus_h = _wifi_get_dbus_handle();
+               if (dbus_h == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
+                       return WIFI_ERROR_INVALID_OPERATION;
+               }
+
+               config_id = wifi_config_get_config_id(h->name, h->security_type);
+
+               wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_SUBJECT_MATCH, subject_match);
+
+               g_free(config_id);
+       }
+
+       return WIFI_ERROR_NONE;
+}
diff --git a/src/wifi_config.c b/src/wifi_config.c
new file mode 100644 (file)
index 0000000..6427ca2
--- /dev/null
@@ -0,0 +1,706 @@
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <string.h>
+
+#include "wifi.h"
+#include "wifi_dbus_private.h"
+#include "wifi_config_private.h"
+#include "net_wifi_private.h"
+
+#define WIFI_SECURITY_NONE                     "none"
+#define WIFI_SECURITY_WEP                      "wep"
+#define WIFI_SECURITY_WPA_PSK          "psk"
+#define WIFI_SECURITY_EAP                      "ieee8021x"
+
+static wifi_error_e _wifi_error_to_enum(const gchar *error)
+{
+       if (NULL != strstr(error, "NoReply"))
+               return WIFI_ERROR_NO_REPLY;
+       else if (NULL != strstr(error, "Failed"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "UnknownMethod"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "InvalidArguments"))
+               return WIFI_ERROR_INVALID_PARAMETER;
+       else if (NULL != strstr(error, "AccessDenied"))
+               return WIFI_ERROR_PERMISSION_DENIED;
+       else if (NULL != strstr(error, "PermissionDenied"))
+               return WIFI_ERROR_PERMISSION_DENIED;
+       else if (NULL != strstr(error, "PassphraseRequired"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "NotRegistered"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "NotUnique"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "NotSupported"))
+               return WIFI_ERROR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, "NotImplemented"))
+               return WIFI_ERROR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, "NotFound"))
+               return WIFI_ERROR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, "NoCarrier"))
+               return WIFI_ERROR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, "InProgress"))
+               return WIFI_ERROR_NOW_IN_PROGRESS;
+       else if (NULL != strstr(error, "AlreadyExists"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "AlreadyEnabled"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "AlreadyDisabled"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "AlreadyConnected"))
+               return WIFI_ERROR_ALREADY_EXISTS;
+       else if (NULL != strstr(error, "NotConnected"))
+               return WIFI_ERROR_NO_CONNECTION;
+       else if (NULL != strstr(error, "OperationAborted"))
+               return WIFI_ERROR_OPERATION_FAILED;
+       else if (NULL != strstr(error, "OperationTimeout"))
+               return WIFI_ERROR_OPERATION_FAILED;
+       else if (NULL != strstr(error, "InvalidService"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "InvalidProperty"))
+               return WIFI_ERROR_INVALID_OPERATION;
+       return WIFI_ERROR_INVALID_OPERATION;
+}
+
+static wifi_error_e _wifi_last_error_to_enum(const gchar *last_error)
+{
+       wifi_error_e ret = WIFI_ERROR_OPERATION_FAILED;
+
+       if (g_strcmp0(last_error, "ERROR_NONE") == 0) {
+               ret = WIFI_ERROR_NONE;
+       } else if (g_strcmp0(last_error, "invalid-key") == 0) {
+               ret = WIFI_ERROR_INVALID_KEY;
+       } else if (g_strcmp0(last_error, "dhcp-failed") == 0) {
+               ret = WIFI_ERROR_DHCP_FAILED;
+       } else {
+               WIFI_LOG(WIFI_ERROR, "Not supported error type (%s)", last_error);
+               ret = WIFI_ERROR_NONE;
+       }
+
+       return ret;
+}
+
+static gchar *_wifi_change_name_to_hexadecimal(const gchar *name)
+{
+       GString *string;
+       gint i = 0;
+       gint length = 0;
+       gchar *hex = NULL;
+
+       if (name == NULL) {
+               return NULL;
+       }
+
+       length = strlen(name);
+
+       string = g_string_sized_new((gsize)(length * 2));
+       if (string == NULL)
+               return NULL;
+
+       for (i = 0; i < length; i++) {
+               g_string_append_printf(string, "%02x", name[i]);
+       }
+
+       hex = g_strdup_printf("%s", string->str);
+       g_string_free(string, TRUE);
+
+       return hex;
+}
+
+gchar *wifi_eap_type_to_string(wifi_eap_type_e eap_type)
+{
+       gchar *type = NULL;
+
+       switch(eap_type) {
+               case WIFI_EAP_TYPE_PEAP:
+                       type = g_strdup("PEAP");
+                       break;
+               case WIFI_EAP_TYPE_TLS:
+                       type = g_strdup("TLS");
+                       break;
+               case WIFI_EAP_TYPE_TTLS:
+                       type = g_strdup("TTLS");
+                       break;
+               case WIFI_EAP_TYPE_SIM:
+                       type = g_strdup("SIM");
+                       break;
+               case WIFI_EAP_TYPE_AKA:
+                       type = g_strdup("AKA");
+                       break;
+       }
+       return type;
+}
+
+gchar *wifi_eap_auth_type_to_string(wifi_eap_auth_type_e eap_auth_type)
+{
+       gchar *type = NULL;
+
+       switch(eap_auth_type) {
+               case WIFI_EAP_AUTH_TYPE_PAP:
+                       type = g_strdup("PAP");
+                       break;
+               case WIFI_EAP_AUTH_TYPE_MSCHAP:
+                       type = g_strdup("MSCHAP");
+                       break;
+               case WIFI_EAP_AUTH_TYPE_MSCHAPV2:
+                       type = g_strdup("MSCHAPV2");
+                       break;
+               case WIFI_EAP_AUTH_TYPE_GTC:
+                       type = g_strdup("GTC");
+                       break;
+               case WIFI_EAP_AUTH_TYPE_MD5:
+                       type = g_strdup("MD5");
+                       break;
+               default:
+               case WIFI_EAP_AUTH_TYPE_NONE:
+                       type = NULL;
+                       break;
+       }
+       return type;
+}
+
+wifi_eap_type_e wifi_eap_type_to_int(const gchar *type)
+{
+       wifi_eap_type_e ret = -1;
+
+       if (type == NULL) {
+               return ret;
+       }
+
+       if (g_strcmp0(type, "PEAP") == 0) {
+               ret = WIFI_EAP_TYPE_PEAP;
+       } else if (g_strcmp0(type, "TLS") == 0) {
+               ret = WIFI_EAP_TYPE_TLS;
+       } else if (g_strcmp0(type, "TTLS") == 0) {
+               ret = WIFI_EAP_TYPE_TTLS;
+       } else if (g_strcmp0(type, "SIM") == 0) {
+               ret = WIFI_EAP_TYPE_SIM;
+       } else if (g_strcmp0(type, "AKA") == 0) {
+               ret = WIFI_EAP_TYPE_AKA;
+       } else {
+               WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type);
+       }
+
+       return ret;
+}
+
+wifi_eap_auth_type_e wifi_eap_auth_type_to_int(const gchar *type)
+{
+       wifi_eap_auth_type_e ret = WIFI_EAP_AUTH_TYPE_NONE;
+
+       if (type == NULL) {
+               return ret;
+       }
+
+       if (g_strcmp0(type, "PAP") == 0) {
+               ret = WIFI_EAP_AUTH_TYPE_PAP;
+       } else if (g_strcmp0(type, "MSCHAP") == 0) {
+               ret = WIFI_EAP_AUTH_TYPE_MSCHAP;
+       } else if (g_strcmp0(type, "MSCHAPV2") == 0) {
+               ret = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
+       } else if (g_strcmp0(type, "GTC") == 0) {
+               ret = WIFI_EAP_AUTH_TYPE_GTC;
+       } else if (g_strcmp0(type, "MD5") == 0) {
+               ret = WIFI_EAP_AUTH_TYPE_MD5;
+       } else {
+               WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type);
+       }
+
+       return ret;
+}
+
+static wifi_security_type_e _wifi_security_type_to_int(const gchar *type)
+{
+       wifi_security_type_e ret = WIFI_SECURITY_TYPE_NONE;
+
+       if (type == NULL) {
+               return ret;
+       }
+
+       if (g_strcmp0(type, WIFI_SECURITY_NONE) == 0) {
+               ret = WIFI_SECURITY_TYPE_NONE;
+       } else if (g_strcmp0(type, WIFI_SECURITY_WEP) == 0) {
+               ret = WIFI_SECURITY_TYPE_WEP;
+       } else if (g_strcmp0(type, WIFI_SECURITY_WPA_PSK) == 0) {
+               ret = WIFI_SECURITY_TYPE_WPA_PSK;
+       } else if (g_strcmp0(type, WIFI_SECURITY_EAP) == 0) {
+               ret = WIFI_SECURITY_TYPE_EAP;
+       } else {
+               WIFI_LOG(WIFI_ERROR, "Not supported type (%s)", type);
+       }
+
+       return ret;
+}
+
+static gchar *_wifi_security_type_to_string(wifi_security_type_e security_type)
+{
+       switch (security_type) {
+       case WIFI_SECURITY_TYPE_NONE:
+               return WIFI_SECURITY_NONE;
+
+       case WIFI_SECURITY_TYPE_WEP:
+               return WIFI_SECURITY_WEP;
+
+       case WIFI_SECURITY_TYPE_WPA_PSK:
+       case WIFI_SECURITY_TYPE_WPA2_PSK:
+               return WIFI_SECURITY_WPA_PSK;
+
+       case WIFI_SECURITY_TYPE_EAP:
+               return WIFI_SECURITY_EAP;
+
+       default:
+               return NULL;
+       }
+}
+
+int wifi_config_get_last_error(wifi_config_h config, wifi_error_e *last_error)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       struct _wifi_config *h = (struct _wifi_config *)config;
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == NULL || last_error == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       *last_error = h->last_error;
+
+       return WIFI_ERROR_NONE;
+}
+
+gchar *wifi_config_get_config_id(const gchar *name, wifi_security_type_e security_type)
+{
+       gchar *config_id = NULL;
+       gchar *ssid = NULL;
+       gchar *type = NULL;
+
+       ssid = _wifi_change_name_to_hexadecimal(name);
+       type = g_strdup(_wifi_security_type_to_string(security_type));
+       config_id = g_strdup_printf("%s_managed_%s", ssid, type);
+
+       g_free(ssid);
+       g_free(type);
+
+       return config_id;
+}
+
+GSList *wifi_config_get_config_id_list(wifi_dbus *handle)
+{
+       GError *error = NULL;
+       GVariant *result = NULL;
+       GVariantIter *iter = NULL;
+       GSList *list = NULL;
+       gchar *config_id = NULL;
+
+       result = g_dbus_connection_call_sync(handle->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "GetConfigIds",
+                                            g_variant_new("()"),
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, handle->ca,
+                                            &error);
+
+       if (error) {
+               WIFI_LOG(WIFI_ERROR, "Fail to GetConfigId [%d: %s]", error->code, error->message);
+               g_error_free(error);
+               return NULL;
+       }
+
+       g_variant_get(result, "(as)", &iter);
+       while (g_variant_iter_loop(iter, "s", &config_id)) {
+               list = g_slist_append(list, g_strdup(config_id));
+       }
+
+       g_variant_iter_free(iter);
+       g_variant_unref(result);
+
+
+       return list;
+}
+
+int wifi_save_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden)
+{
+       wifi_error_e ret = WIFI_ERROR_NONE;
+       GError *error = NULL;
+       GVariant *result = NULL;
+       GVariant *params = NULL;
+       GVariantBuilder *b = NULL;
+       gchar *config_id = NULL;
+       gchar *ssid = NULL;
+
+       if (security_type != WIFI_SECURITY_TYPE_NONE) {
+               if (passphrase == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations [secu_type is not NONE[%d] but passphrase is NULL]", security_type);
+                       return WIFI_ERROR_INVALID_PARAMETER;
+               } else {
+                       if (strlen(passphrase) == 0) {
+                               WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations passphrase length is 0");
+                               return WIFI_ERROR_INVALID_PARAMETER;
+                       }
+               }
+       }
+
+       config_id = wifi_config_get_config_id(name, security_type);
+       ssid = _wifi_change_name_to_hexadecimal(name);
+
+       b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name));
+       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SSID, g_variant_new_string(ssid));
+       if (passphrase != NULL)
+               g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PASSPHRASE, g_variant_new_string(passphrase));
+       if (proxy_address != NULL)
+               g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(proxy_address));
+       if (is_hidden == TRUE)
+               g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string("TRUE"));
+
+       params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b));
+       g_variant_builder_unref(b);
+       g_free(config_id);
+
+       result = g_dbus_connection_call_sync(handle->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "SaveConfiguration",
+                                            params,
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, handle->ca,
+                                            &error);
+
+       if (error) {
+               WIFI_LOG(WIFI_ERROR, "Fail to SaveConfiguration [%d: %s]", error->code, error->message);
+               ret = _wifi_error_to_enum(error->message);
+               g_error_free(error);
+       }
+
+       if (result != NULL)
+               g_variant_unref(result);
+
+       return ret;
+}
+
+int wifi_load_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, wifi_error_e *last_error)
+{
+       GError *error = NULL;
+       GVariant *result = NULL;
+       wifi_error_e ret = WIFI_ERROR_NONE;
+
+       result = g_dbus_connection_call_sync(handle->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "LoadConfiguration",
+                                            g_variant_new("(s)", config_id),
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, handle->ca,
+                                            &error);
+
+       if (error) {
+               WIFI_LOG(WIFI_ERROR, "Fail to LoadConfiguration [%d: %s]", error->code, error->message);
+               ret = _wifi_error_to_enum(error->message);
+               g_error_free(error);
+               return ret;
+       }
+
+       if (result) {
+               GVariantIter *iter;
+               gchar *field;
+               GVariant *value;
+
+               g_variant_get(result, "(a{sv})", &iter);
+               while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+                       if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                               if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
+                                       *name = g_strdup(g_variant_get_string(value, NULL));
+                               } else if (g_strcmp0(field, WIFI_CONFIG_SECURITY_TYPE) == 0) {
+                                       *security_type = _wifi_security_type_to_int(g_variant_get_string(value, NULL));
+                               } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
+                                       const gchar *r_hidden = g_variant_get_string(value, NULL);
+                                       if (g_strcmp0(r_hidden, "TRUE") == 0) {
+                                               *is_hidden = TRUE;
+                                       } else {
+                                               *is_hidden = FALSE;
+                                       }
+                               } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
+                                       const gchar *r_proxy_address = g_variant_get_string(value, NULL);
+                                       if (g_strcmp0(r_proxy_address, "NONE") == 0) {
+                                               *proxy_address = NULL;
+                                       } else {
+                                               *proxy_address = g_strdup(r_proxy_address);
+                                       }
+                               } else if (g_strcmp0(field, WIFI_CONFIG_FAILURE) == 0) {
+                                       *last_error = _wifi_last_error_to_enum(g_variant_get_string(value, NULL));
+                               }
+                       }
+               }
+
+               g_variant_iter_free(iter);
+               g_variant_unref(result);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+int wifi_save_eap_configurations(wifi_dbus *handle, const gchar *name, const gchar *passphrase, wifi_security_type_e security_type, const gchar *proxy_address, struct _wifi_eap_config *eap_config, gboolean is_hidden)
+{
+       wifi_error_e ret = WIFI_ERROR_NONE;
+       GError *error = NULL;
+       GVariant *result = NULL;
+       GVariant *params = NULL;
+       GVariantBuilder *b = NULL;
+       gchar *config_id = NULL;
+       gchar *ssid = NULL;
+
+       if (security_type != WIFI_SECURITY_TYPE_EAP) {
+               WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations [secu_type is not EAP[%d]]", security_type);
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (security_type != WIFI_SECURITY_TYPE_NONE) {
+               if (security_type == (WIFI_EAP_TYPE_SIM | WIFI_EAP_TYPE_AKA)) {
+                       WIFI_LOG(WIFI_INFO, "security_type: %d", security_type);
+                       goto eap_save_config;
+               }
+               if (passphrase == NULL) {
+                       WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations [secu_type is not NONE[%d] but passphrase is NULL]", security_type);
+                       return WIFI_ERROR_INVALID_PARAMETER;
+               } else {
+                       if (strlen(passphrase) == 0) {
+                               WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_configurations passphrase length is 0");
+                               return WIFI_ERROR_INVALID_PARAMETER;
+                       }
+               }
+       }
+
+eap_save_config:
+       config_id = wifi_config_get_config_id(name, security_type);
+       ssid = _wifi_change_name_to_hexadecimal(name);
+
+       b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name));
+       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SSID, g_variant_new_string(ssid));
+       if (passphrase != NULL)
+               g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PASSPHRASE, g_variant_new_string(passphrase));
+       if (proxy_address != NULL)
+               g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(proxy_address));
+       if (is_hidden == TRUE)
+               g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string("TRUE"));
+
+       if (eap_config != NULL) {
+               gchar* auth_type = NULL;
+               gchar* eap_type = NULL;
+               if (eap_config->anonymous_identity != NULL)
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, g_variant_new_string(eap_config->anonymous_identity));
+               if (eap_config->ca_cert != NULL)
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CACERT, g_variant_new_string(eap_config->ca_cert));
+               if (eap_config->client_cert != NULL)
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string(eap_config->client_cert));
+               if (eap_config->private_key != NULL)
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string(eap_config->private_key));
+               if (eap_config->identity != NULL)
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string(eap_config->identity));
+               if (eap_config->subject_match != NULL)
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_SUBJECT_MATCH, g_variant_new_string(eap_config->subject_match));
+
+               auth_type = wifi_eap_auth_type_to_string(eap_config->eap_auth_type);
+               if (auth_type != NULL) {
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_AUTH_TYPE, g_variant_new_string(auth_type));
+               }
+               eap_type = wifi_eap_type_to_string(eap_config->eap_type);
+               if (eap_type != NULL) {
+                       g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_TYPE, g_variant_new_string(eap_type));
+               }
+
+               g_free(auth_type);
+               g_free(eap_type);
+       }
+
+       params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b));
+       g_variant_builder_unref(b);
+       g_free(config_id);
+
+       result = g_dbus_connection_call_sync(handle->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "SaveEapConfiguration",
+                                            params,
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, handle->ca,
+                                            &error);
+
+       if (error) {
+               WIFI_LOG(WIFI_ERROR, "Fail to SaveEapConfiguration [%d: %s]", error->code, error->message);
+               ret = _wifi_error_to_enum(error->message);
+               g_error_free(error);
+       }
+
+       if (result != NULL)
+               g_variant_unref(result);
+
+       return ret;
+}
+
+int wifi_load_eap_configurations(wifi_dbus *handle, const gchar *config_id, gchar **name, wifi_security_type_e *security_type, gchar **proxy_address, gboolean *is_hidden, struct _wifi_eap_config **eap_config, wifi_error_e *last_error)
+{
+       GError *error = NULL;
+       GVariant *result = NULL;
+
+       result = g_dbus_connection_call_sync(handle->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "LoadEapConfiguration",
+                                            g_variant_new("(s)", config_id),
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, handle->ca,
+                                            &error);
+
+       if (result) {
+               GVariantIter *iter;
+               gchar *field;
+               GVariant *value;
+
+               g_variant_get(result, "(a{sv})", &iter);
+               while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+                       if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                               if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
+                                       *name = g_strdup(g_variant_get_string(value, NULL));
+                               } else if (g_strcmp0(field, WIFI_CONFIG_SECURITY_TYPE) == 0) {
+                                       *security_type = _wifi_security_type_to_int(g_variant_get_string(value, NULL));
+                               } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
+                                       const gchar *r_hidden = g_variant_get_string(value, NULL);
+                                       if (g_strcmp0(r_hidden, "TRUE") == 0) {
+                                               *is_hidden = TRUE;
+                                       } else {
+                                               *is_hidden = FALSE;
+                                       }
+                               } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
+                                       const gchar *r_proxy_address = g_variant_get_string(value, NULL);
+                                       if (g_strcmp0(r_proxy_address, "NONE") == 0) {
+                                               *proxy_address = NULL;
+                                       } else {
+                                               *proxy_address = g_strdup(r_proxy_address);
+                                       }
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
+                                       const gchar *anonymous_identity = g_variant_get_string(value, NULL);
+                                       (*eap_config)->anonymous_identity = g_strdup(anonymous_identity);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CACERT) == 0) {
+                                       const gchar *ca_cert = g_variant_get_string(value, NULL);
+                                       (*eap_config)->ca_cert = g_strdup(ca_cert);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CLIENTCERT) == 0) {
+                                       const gchar *client_cert = g_variant_get_string(value, NULL);
+                                       (*eap_config)->client_cert = g_strdup(client_cert);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) {
+                                       const gchar *private_key = g_variant_get_string(value, NULL);
+                                       (*eap_config)->private_key = g_strdup(private_key);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_IDENTITY) == 0) {
+                                       const gchar *identity = g_variant_get_string(value, NULL);
+                                       (*eap_config)->identity = g_strdup(identity);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_TYPE) == 0) {
+                                       const gchar *eap_type = g_variant_get_string(value, NULL);
+                                       (*eap_config)->eap_type = wifi_eap_type_to_int(eap_type);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) {
+                                       const gchar *auth_type = g_variant_get_string(value, NULL);
+                                       (*eap_config)->eap_auth_type = wifi_eap_auth_type_to_int(auth_type);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) {
+                                       const gchar *subject_match = g_variant_get_string(value, NULL);
+                                       (*eap_config)->subject_match = g_strdup(subject_match);
+                               } else if (g_strcmp0(field, WIFI_CONFIG_FAILURE) == 0) {
+                                       *last_error = _wifi_last_error_to_enum(g_variant_get_string(value, NULL));
+                               }
+                       }
+               }
+               g_variant_iter_free(iter);
+               g_variant_unref(result);
+       }
+
+       return WIFI_ERROR_NONE;
+}
+
+int wifi_configuration_set_field(wifi_dbus *handle, const gchar *config_id, const gchar *key, const gchar *value)
+{
+       wifi_error_e ret = WIFI_ERROR_NONE;
+       GError *error = NULL;
+       GVariant *result = NULL;
+
+       result = g_dbus_connection_call_sync(handle->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "SetConfigField",
+                                            g_variant_new("(sss)", config_id, key, value),
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, handle->ca,
+                                            &error);
+
+       if (error) {
+               WIFI_LOG(WIFI_ERROR, "Fail to SetConfigField [%d: %s]", error->code, error->message);
+               ret = _wifi_error_to_enum(error->message);
+               g_error_free(error);
+       }
+
+       if (result != NULL)
+               g_variant_unref(result);
+
+       return ret;
+}
+
+int wifi_configuration_get_passphrase(wifi_dbus *handle, const gchar *config_id, gchar **passphrase)
+{
+       wifi_error_e ret = WIFI_ERROR_NONE;
+       GError *error = NULL;
+       GVariant *result = NULL;
+       gchar *val = NULL;
+
+       result = g_dbus_connection_call_sync(handle->dbus_conn,
+                                            NETCONFIG_SERVICE,
+                                            NETCONFIG_WIFI_PATH,
+                                            NETCONFIG_IWIFI,
+                                            "GetConfigPassphrase",
+                                            g_variant_new("(s)", config_id),
+                                            NULL, G_DBUS_CALL_FLAGS_NONE,
+                                            DBUS_REPLY_TIMEOUT, handle->ca,
+                                            &error);
+
+       if (error) {
+               WIFI_LOG(WIFI_ERROR, "Fail to GetConfigPassphrase [%d: %s]", error->code, error->message);
+               ret = _wifi_error_to_enum(error->message);
+               g_error_free(error);
+               return ret;
+       }
+
+       if (result != NULL) {
+               g_variant_get(result, "(s)", &val);
+               g_variant_unref(result);
+       }
+
+       *passphrase = g_strdup(val);
+       g_free(val);
+
+       return ret;
+}
diff --git a/src/wifi_dbus.c b/src/wifi_dbus.c
new file mode 100644 (file)
index 0000000..85bd5a1
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+
+#include "wifi.h"
+#include "wifi_dbus_private.h"
+#include "net_wifi_private.h"
+
+int wifi_dbus_init(wifi_dbus **handle)
+{
+       struct _wifi_dbus *h;
+       GError *error = NULL;
+
+       h = g_new0(struct _wifi_dbus, 1);
+       if (!h) {
+               WIFI_LOG(WIFI_ERROR, "_wifi_dbus alloc error");
+               return WIFI_ERROR_OUT_OF_MEMORY;
+       }
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+       g_type_init();
+#endif
+
+       h->dbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!h->dbus_conn) {
+               WIFI_LOG(WIFI_ERROR, "dbus connection get failed: %s", error->message);
+               g_error_free(error);
+               g_free(h);
+               return WIFI_ERROR_OUT_OF_MEMORY;
+       }
+       h->ca = g_cancellable_new();
+
+       *handle = (wifi_dbus *)h;
+
+       return WIFI_ERROR_NONE;
+}
+
+int wifi_dbus_deinit(wifi_dbus *handle)
+{
+       g_return_val_if_fail(handle != NULL, WIFI_ERROR_INVALID_PARAMETER);
+
+       g_cancellable_cancel(handle->ca);
+       g_object_unref(handle->ca);
+       g_object_unref(handle->dbus_conn);
+
+       memset(handle, 0, sizeof(struct _wifi_dbus));
+       g_free(handle);
+
+       return WIFI_ERROR_NONE;
+}
old mode 100644 (file)
new mode 100755 (executable)
index 1bc1063..3f744a6 100755 (executable)
@@ -827,6 +827,31 @@ static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data)
        return true;
 }
 
+static bool _test_config_list_cb(const wifi_config_h config, void *user_data)
+{
+       gchar *name = NULL;
+       wifi_security_type_e security_type;
+
+       wifi_config_get_name(config, &name);
+       wifi_config_get_security_type(config, &security_type);
+
+       printf("Name[%s] ", name);
+       printf("Security type[%d] ", security_type);
+       if (security_type == WIFI_SECURITY_TYPE_EAP) {
+               wifi_eap_type_e eap_type;
+               wifi_eap_auth_type_e eap_auth_type;
+               wifi_config_get_eap_type(config, &eap_type);
+               printf("Eap type[%d] ", eap_type);
+               wifi_config_get_eap_auth_type(config, &eap_auth_type);
+               printf("Eap auth type[%d]", eap_auth_type);
+       }
+       printf("\n");
+
+       g_free(name);
+
+       return true;
+}
+
 static bool __test_found_specific_aps_callback(wifi_ap_h ap, void *user_data)
 {
        printf("Found specific ap Completed\n");
@@ -930,7 +955,6 @@ static void __test_scan_specific_ap_callback(wifi_error_e error_code, void* user
        }
 }
 
-
 int test_wifi_init(void)
 {
        int rv = wifi_initialize();
@@ -948,7 +972,7 @@ int test_wifi_init(void)
        printf("Wifi init succeeded\n");
        return 1;
 }
+
 int  test_wifi_deinit(void)
 {
        int rv = 0;
@@ -1350,6 +1374,160 @@ int test_get_ap_info(void)
        return 1;
 }
 
+int test_load_configuration(void)
+{
+       int rv;
+
+       rv = wifi_config_foreach_configuration(_test_config_list_cb, NULL);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       return 1;
+}
+
+int test_save_configuration(void)
+{
+       int rv;
+       char name[33] = { 0, };
+       char passphrase[100] = { 0, };
+       int type = 0;
+       wifi_config_h config;
+
+       printf("Input AP configuration\n");
+       printf("Name : ");
+       rv = scanf("%32s", name);
+       if (rv <= 0)
+               return -1;
+
+       printf("Passphrase : ");
+       rv = scanf("%99s", passphrase);
+       if (rv <= 0)
+               return -1;
+
+       printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+       rv = scanf("%d", &type);
+       if (rv <= 0)
+               return -1;
+
+       rv = wifi_config_create(name, passphrase, type, &config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_save_configuration(config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_destroy(config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       return 1;
+}
+
+int test_set_configuration_proxy_and_hidden(void)
+{
+       int rv;
+       char name[33] = { 0, };
+       char passphrase[100] = { 0, };
+       int type = 0;
+       char proxy[100] = { 0, };
+       int hidden = 0;
+       wifi_config_h config;
+
+       printf("Input AP configuration\n");
+       printf("Name : ");
+       rv = scanf("%32s", name);
+       if (rv <= 0)
+               return -1;
+
+       printf("Passphrase : ");
+       rv = scanf("%99s", passphrase);
+       if (rv <= 0)
+               return -1;
+
+       printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+       rv = scanf("%d", &type);
+       if (rv <= 0)
+               return -1;
+
+       printf("Proxy(server:port) : ");
+       rv = scanf("%99s", proxy);
+       if (rv <= 0)
+               return -1;
+
+       printf("Hidden(1:Hidden) : ");
+       rv = scanf("%d", &hidden);
+       if (rv <= 0)
+               return -1;
+
+       rv = wifi_config_create(name, passphrase, type, &config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_save_configuration(config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_set_proxy_address(config, WIFI_ADDRESS_FAMILY_IPV4, proxy);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       if (hidden == 1)
+               rv = wifi_config_set_hidden_ap_property(config, TRUE);
+       else
+               rv = wifi_config_set_hidden_ap_property(config, FALSE);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_destroy(config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       return 1;
+}
+
+int test_set_eap_configuration(void)
+{
+       int rv;
+       char name[33] = { 0, };
+       char passphrase[100] = { 0, };
+       int type = WIFI_SECURITY_TYPE_EAP;
+       wifi_config_h config;
+
+       printf("Input EAP configuration\n");
+       printf("Name : ");
+       rv = scanf("%32s", name);
+       if (rv <= 0)
+               return -1;
+
+       printf("Passphrase : ");
+       rv = scanf("%99s", passphrase);
+       if (rv <= 0)
+               return -1;
+
+       rv = wifi_config_create(name, passphrase, type, &config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_save_configuration(config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_set_eap_type(config, WIFI_EAP_TYPE_TLS);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_set_eap_auth_type(config, WIFI_EAP_AUTH_TYPE_MD5);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       rv = wifi_config_destroy(config);
+       if (rv != WIFI_ERROR_NONE)
+               return -1;
+
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -1407,6 +1585,10 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("i       - Set Proxy method type\n");
                printf("j       - Get Ap info\n");
                printf("k       - Connect Specific AP\n");
+               printf("l       - Load configuration\n");
+               printf("m       - Save configuration\n");
+               printf("n       - Set configuration proxy and hidden\n");
+               printf("o       - Set EAP configuration\n");
                printf("0       - Exit \n");
 
                printf("ENTER  - Show options menu.......\n");
@@ -1473,6 +1655,19 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'k':
                rv = test_connect_specific_ap();
                break;
+       case 'l':
+               rv = test_load_configuration();
+               break;
+       case 'm':
+               rv = test_save_configuration();
+               break;
+       case 'n':
+               rv = test_set_configuration_proxy_and_hidden();
+               break;
+       case 'o':
+               rv = test_set_eap_configuration();
+               break;
+
        default:
                break;
        }