#define MOBILE_AP_WIFI_KEY_MAX_LEN 64 /**< Maximum length of wifi key */
#define MOBILE_AP_WIFI_PASSPHRASE_STORE_KEY "tethering_wifi_passphrase"
+#define MOBILE_AP_SOFTAP_PASSPHRASE_STORE_KEY "softap_passphrase"
static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *dst, softap_settings_t *src);
-static mobile_ap_error_code_e __get_passphrase(char *passphrase,
- unsigned int passphrase_size, unsigned int *passphrase_len);
-static mobile_ap_error_code_e __set_passphrase(const char *passphrase, const unsigned int size);
+static mobile_ap_error_code_e __get_passphrase(const char *key, char *passphrase,
+ unsigned int passphrase_size, unsigned int *passphrase_len);
+static mobile_ap_error_code_e __set_passphrase(const char *key, const char *passphrase,
+ const unsigned int size);
static char *__get_key_manager_alias(const char* name);
static int __turn_off_wifi(void *obj);
static unsigned int __generate_initial_passphrase(char *passphrase, unsigned int size);
return ret;
}
+ if (__set_passphrase(MOBILE_AP_SOFTAP_PASSPHRASE_STORE_KEY,
+ obj_softap_settings.key, strlen(obj_softap_settings.key)) != MOBILE_AP_ERROR_NONE)
+ ERR("__set_passphrase is failed"); //LCOV_EXCL_LINE
+
if (vconf_set_str(VCONFKEY_SOFTAP_SSID, obj_softap_settings.ssid) < 0)
ERR("vconf_set_str is failed"); //LCOV_EXCL_LINE
if (vconf_set_int(VCONFKEY_SOFTAP_SECURITY, obj_softap_settings.security_type) < 0)
ERR("vconf_set_str is failed"); //LCOV_EXCL_LINE
- if (vconf_set_str(VCONFKEY_SOFTAP_KEY, obj_softap_settings.key) < 0)
- ERR("vconf_set_str is failed"); //LCOV_EXCL_LINE
-
if (vconf_set_int(VCONFKEY_SOFTAP_CHANNEL, obj_softap_settings.channel) < 0)
ERR("vconf_set_str is failed"); //LCOV_EXCL_LINE
return ckmc_alias;
}
-static mobile_ap_error_code_e __set_passphrase(const char *passphrase, const unsigned int size)
+static mobile_ap_error_code_e __set_passphrase(const char *key,
+ const char *passphrase, const unsigned int size)
{
if (passphrase == NULL || size == 0)
return MOBILE_AP_ERROR_INVALID_PARAM;
ckmc_buf.data = (unsigned char *) passphrase;
ckmc_buf.size = strlen(passphrase) + 1;
- alias = __get_key_manager_alias(MOBILE_AP_WIFI_PASSPHRASE_STORE_KEY);
+ alias = __get_key_manager_alias(key);
ret = ckmc_remove_alias(alias);
if (ret != CKMC_ERROR_NONE && ret != CKMC_ERROR_DB_ALIAS_UNKNOWN) {
return index;
}
-static mobile_ap_error_code_e __get_passphrase(char *passphrase,
- unsigned int passphrase_size, unsigned int *passphrase_len)
+static mobile_ap_error_code_e __get_passphrase(const char *key,
+ char *passphrase, unsigned int passphrase_size, unsigned int *passphrase_len)
{
- if (passphrase == NULL || passphrase_size == 0) {
+ if (key == NULL || passphrase == NULL || passphrase_size == 0) {
ERR("Invalid parameter\n"); //LCOV_EXCL_LINE
return MOBILE_AP_ERROR_INVALID_PARAM;
}
char tmp[MOBILE_AP_WIFI_KEY_MAX_LEN + 1] = {0, };
ckmc_raw_buffer_s *ckmc_buf = NULL;
- alias = __get_key_manager_alias(MOBILE_AP_WIFI_PASSPHRASE_STORE_KEY);
+ alias = __get_key_manager_alias(key);
ret = ckmc_get_data(alias, passwd, &ckmc_buf);
if (ret < 0) {
DBG("Create new password\n");
*passphrase_len = ret;
g_strlcpy(passphrase, tmp, (*passphrase_len)+1);
- if (__set_passphrase(passphrase, *passphrase_len) != MOBILE_AP_ERROR_NONE) {
+ if (__set_passphrase(key, passphrase, *passphrase_len) != MOBILE_AP_ERROR_NONE) {
DBG("set_passphrase is failed : %s, %d", passphrase, *passphrase_len); //LCOV_EXCL_LINE
if (alias)
free(alias);
char passphrase_buf[MOBILE_AP_WIFI_KEY_MAX_LEN + 1] = {0, };
unsigned int len = 0;
- ret = __get_passphrase(passphrase_buf, sizeof(passphrase_buf), &len);
+ ret = __get_passphrase(MOBILE_AP_WIFI_PASSPHRASE_STORE_KEY,
+ passphrase_buf, sizeof(passphrase_buf), &len);
if (ret != MOBILE_AP_ERROR_NONE) {
ERR("__get_passphrase is failed"); //LCOV_EXCL_LINE
len = 0;
unsigned int passphrase_len = strlen(passphrase);
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
- ret = __get_passphrase(old_passphrase, sizeof(old_passphrase), &old_len);
+ ret = __get_passphrase(MOBILE_AP_WIFI_PASSPHRASE_STORE_KEY,
+ old_passphrase, sizeof(old_passphrase), &old_len);
if (ret == MOBILE_AP_ERROR_NONE &&
old_len == passphrase_len &&
!g_strcmp0(old_passphrase, passphrase))
goto DONE;
- ret = __set_passphrase(passphrase, passphrase_len);
+ ret = __set_passphrase(MOBILE_AP_WIFI_PASSPHRASE_STORE_KEY,
+ passphrase, passphrase_len);
DONE:
#ifndef TIZEN_FEATURE_UNITTEST
return TRUE;
}
+gboolean softap_get_passphrase(Softap *obj,
+ GDBusMethodInvocation *context)
+{
+ mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
+ char passphrase_buf[MOBILE_AP_WIFI_KEY_MAX_LEN + 1] = {0, };
+ unsigned int len = 0;
+
+ ret = __get_passphrase(MOBILE_AP_SOFTAP_PASSPHRASE_STORE_KEY,
+ passphrase_buf, sizeof(passphrase_buf), &len);
+ if (ret != MOBILE_AP_ERROR_NONE) {
+ ERR("__get_passphrase is failed"); //LCOV_EXCL_LINE
+ len = 0;
+ }
+
+#ifndef TIZEN_FEATURE_UNITTEST
+ softap_complete_get_passphrase(obj, context,
+ (len > 0 ? passphrase_buf : NULL), ret);
+#endif
+
+ return TRUE;
+}
+
gboolean softap_set_wps_pin(Softap *obj,
GDBusMethodInvocation *context, gchar *wps_pin)
{