clients: add vpn_type member to secret structure in secret agent

It is useful to know what VPN type the secret belongs to.

(cherry picked from commit 8dfafac17c)
This commit is contained in:
Jiří Klimeš 2015-12-11 09:54:40 +01:00
parent dca2ded7e8
commit d6b98449a8
2 changed files with 20 additions and 0 deletions

View file

@ -164,6 +164,7 @@ nm_secret_agent_simple_secret_free (NMSecretAgentSimpleSecret *secret)
g_free (secret->prop_name);
g_free (secret->value);
g_free (secret->vpn_property);
g_free (secret->vpn_type);
g_free (real->property);
g_clear_object (&real->setting);
@ -175,6 +176,7 @@ nm_secret_agent_simple_secret_new (const char *name,
NMSetting *setting,
const char *property,
const char *vpn_property,
const char *vpn_type,
gboolean password)
{
NMSecretAgentSimpleSecretReal *real;
@ -185,6 +187,7 @@ nm_secret_agent_simple_secret_new (const char *name,
g_strdup_printf ("%s.%s.%s", nm_setting_get_name (setting), property, vpn_property) :
g_strdup_printf ("%s.%s", nm_setting_get_name (setting), property);
real->base.vpn_property = g_strdup (vpn_property);
real->base.vpn_type = g_strdup (vpn_type);
real->base.password = password;
if (setting) {
@ -224,12 +227,14 @@ add_8021x_secrets (NMSecretAgentSimpleRequest *request,
NM_SETTING (s_8021x),
NM_SETTING_802_1X_IDENTITY,
NULL,
NULL,
FALSE);
g_ptr_array_add (secrets, secret);
secret = nm_secret_agent_simple_secret_new (_("Password"),
NM_SETTING (s_8021x),
NM_SETTING_802_1X_PASSWORD,
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
@ -240,12 +245,14 @@ add_8021x_secrets (NMSecretAgentSimpleRequest *request,
NM_SETTING (s_8021x),
NM_SETTING_802_1X_IDENTITY,
NULL,
NULL,
FALSE);
g_ptr_array_add (secrets, secret);
secret = nm_secret_agent_simple_secret_new (_("Private key password"),
NM_SETTING (s_8021x),
NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD,
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
@ -270,6 +277,7 @@ add_wireless_secrets (NMSecretAgentSimpleRequest *request,
NM_SETTING (s_wsec),
NM_SETTING_WIRELESS_SECURITY_PSK,
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
@ -285,6 +293,7 @@ add_wireless_secrets (NMSecretAgentSimpleRequest *request,
NM_SETTING (s_wsec),
key,
NULL,
NULL,
TRUE);
g_free (key);
@ -298,6 +307,7 @@ add_wireless_secrets (NMSecretAgentSimpleRequest *request,
NM_SETTING (s_wsec),
NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
@ -322,18 +332,21 @@ add_pppoe_secrets (NMSecretAgentSimpleRequest *request,
NM_SETTING (s_pppoe),
NM_SETTING_PPPOE_USERNAME,
NULL,
NULL,
FALSE);
g_ptr_array_add (secrets, secret);
secret = nm_secret_agent_simple_secret_new (_("Service"),
NM_SETTING (s_pppoe),
NM_SETTING_PPPOE_SERVICE,
NULL,
NULL,
FALSE);
g_ptr_array_add (secrets, secret);
secret = nm_secret_agent_simple_secret_new (_("Password"),
NM_SETTING (s_pppoe),
NM_SETTING_PPPOE_PASSWORD,
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
@ -388,6 +401,7 @@ add_vpn_secret_helper (GPtrArray *secrets, NMSettingVpn *s_vpn, const char *name
NM_SETTING (s_vpn),
NM_SETTING_VPN_SECRETS,
name,
nm_setting_vpn_get_service_type (s_vpn),
TRUE);
g_ptr_array_add (secrets, secret);
}
@ -464,6 +478,7 @@ request_secrets_from_ui (NMSecretAgentSimpleRequest *request)
NM_SETTING (s_con),
NM_SETTING_CONNECTION_ID,
NULL,
NULL,
FALSE);
g_ptr_array_add (secrets, secret);
ok = add_8021x_secrets (request, secrets);
@ -482,6 +497,7 @@ request_secrets_from_ui (NMSecretAgentSimpleRequest *request)
secret = nm_secret_agent_simple_secret_new (_("PIN"),
NM_SETTING (s_gsm),
NM_SETTING_GSM_PIN,
NULL,
NULL,
FALSE);
g_ptr_array_add (secrets, secret);
@ -494,6 +510,7 @@ request_secrets_from_ui (NMSecretAgentSimpleRequest *request)
NM_SETTING (s_gsm),
NM_SETTING_GSM_PASSWORD,
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
}
@ -508,6 +525,7 @@ request_secrets_from_ui (NMSecretAgentSimpleRequest *request)
NM_SETTING (s_cdma),
NM_SETTING_CDMA_PASSWORD,
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
} else if (nm_connection_is_type (request->connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) {
@ -525,6 +543,7 @@ request_secrets_from_ui (NMSecretAgentSimpleRequest *request)
setting,
"password",
NULL,
NULL,
TRUE);
g_ptr_array_add (secrets, secret);
} else if (nm_connection_is_type (request->connection, NM_SETTING_VPN_SETTING_NAME)) {

View file

@ -44,6 +44,7 @@ typedef struct {
typedef struct {
char *name, *prop_name, *value;
char *vpn_property;
char *vpn_type;
gboolean password;
} NMSecretAgentSimpleSecret;