core: use GetSecrets flags everywhere

This commit is contained in:
Dan Williams
2011-01-18 14:57:44 -06:00
parent 9cf13cc3e1
commit 68ab26143b
11 changed files with 57 additions and 33 deletions

View File

@@ -516,13 +516,16 @@ nm_modem_get_secrets (NMModem *self,
const char *hint)
{
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
guint32 flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
cancel_get_secrets (self);
if (request_new)
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
priv->secrets_id = nm_act_request_get_secrets (priv->act_request,
NULL,
setting_name,
request_new,
flags,
hint,
modem_secrets_cb,
self);
@@ -552,6 +555,7 @@ nm_modem_act_stage1_prepare (NMModem *self,
NMActStageReturn ret;
GPtrArray *hints = NULL;
const char *setting_name = NULL;
guint32 flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
if (priv->act_request)
g_object_unref (priv->act_request);
@@ -563,10 +567,13 @@ nm_modem_act_stage1_prepare (NMModem *self,
&setting_name,
reason);
if ((ret == NM_ACT_STAGE_RETURN_POSTPONE) && setting_name) {
if (priv->secrets_tries++)
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
priv->secrets_id = nm_act_request_get_secrets (req,
NULL,
setting_name,
priv->secrets_tries++ ? TRUE : FALSE,
flags,
hints ? g_ptr_array_index (hints, 0) : NULL,
modem_secrets_cb,
self);

View File

@@ -114,7 +114,7 @@ guint32
nm_act_request_get_secrets (NMActRequest *self,
NMConnection *connection,
const char *setting_name,
gboolean request_new,
guint32 flags,
const char *hint,
NMActRequestSecretsFunc callback,
gpointer callback_data)
@@ -137,7 +137,7 @@ nm_act_request_get_secrets (NMActRequest *self,
call_id = nm_agent_manager_get_secrets (priv->agent_mgr,
connection ? connection : priv->connection,
setting_name,
request_new,
flags,
hint,
get_secrets_cb,
self,

View File

@@ -95,7 +95,7 @@ typedef void (*NMActRequestSecretsFunc) (NMActRequest *req,
guint32 nm_act_request_get_secrets (NMActRequest *req,
NMConnection *connection, /* NULL == use activation request's connection */
const char *setting_name,
gboolean request_new,
guint32 flags,
const char *hint,
NMActRequestSecretsFunc callback,
gpointer callback_data);

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2010 - 2011 Red Hat, Inc.
*/
#include <config.h>
@@ -331,7 +331,7 @@ struct _Request {
NMConnection *connection;
char *setting_name;
gboolean request_new;
guint32 flags;
char *hint;
/* Current agent being asked for secrets */
@@ -365,7 +365,7 @@ struct _Request {
static Request *
request_new (NMConnection *connection,
const char *setting_name,
gboolean get_new,
guint32 flags,
const char *hint,
NMAgentSecretsResultFunc callback,
gpointer callback_data,
@@ -381,7 +381,7 @@ request_new (NMConnection *connection,
req->reqid = next_id++;
req->connection = g_object_ref (connection);
req->setting_name = g_strdup (setting_name);
req->request_new = get_new;
req->flags = flags;
req->hint = g_strdup (hint);
req->callback = callback;
req->callback_data = callback_data;
@@ -547,7 +547,7 @@ request_next (Request *req)
req->connection,
req->setting_name,
req->hint,
req->request_new,
req->flags,
request_secrets_done_cb,
req);
if (req->current_call_id == NULL) {
@@ -570,7 +570,7 @@ request_start_secrets (gpointer user_data)
secrets = nm_sysconfig_connection_get_secrets (NM_SYSCONFIG_CONNECTION (req->connection),
req->setting_name,
req->hint,
req->request_new,
req->flags ? TRUE : FALSE,
&error);
if (secrets)
setting_secrets = g_hash_table_lookup (secrets, req->setting_name);
@@ -773,7 +773,7 @@ guint32
nm_agent_manager_get_secrets (NMAgentManager *self,
NMConnection *connection,
const char *setting_name,
gboolean get_new,
guint32 flags,
const char *hint,
NMAgentSecretsResultFunc callback,
gpointer callback_data,
@@ -797,7 +797,7 @@ nm_agent_manager_get_secrets (NMAgentManager *self,
req = request_new (connection,
setting_name,
get_new,
flags,
hint,
callback,
callback_data,

View File

@@ -27,7 +27,7 @@
#include <nm-connection.h>
#include "nm-dbus-manager.h"
#include "nm-session-monitor.h"
#include "nm-secret-agent.h"
#define NM_TYPE_AGENT_MANAGER (nm_agent_manager_get_type ())
#define NM_AGENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AGENT_MANAGER, NMAgentManager))
@@ -59,7 +59,7 @@ typedef void (*NMAgentSecretsResultFunc) (NMAgentManager *manager,
guint32 nm_agent_manager_get_secrets (NMAgentManager *manager,
NMConnection *connection,
const char *setting_name,
gboolean get_new,
guint32 flags,
const char *hint,
NMAgentSecretsResultFunc callback,
gpointer callback_data,

View File

@@ -1023,7 +1023,7 @@ link_timeout_cb (gpointer user_data)
nm_act_request_get_secrets (req,
NULL,
setting_name,
TRUE,
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW,
NULL,
wired_secrets_cb,
self);
@@ -1204,16 +1204,18 @@ handle_auth_or_fail (NMDeviceEthernet *self,
nm_connection_clear_secrets (connection);
setting_name = nm_connection_need_secrets (connection, NULL);
if (setting_name) {
gboolean get_new;
guint32 flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
/* If the caller doesn't necessarily want completely new secrets,
* only ask for new secrets after the first failure.
*/
get_new = new_secrets ? TRUE : (tries ? TRUE : FALSE);
if (new_secrets || tries)
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
nm_act_request_get_secrets (req,
NULL,
setting_name,
get_new,
flags,
NULL,
wired_secrets_cb,
self);

View File

@@ -2488,7 +2488,7 @@ link_timeout_cb (gpointer user_data)
nm_act_request_get_secrets (req,
NULL,
setting_name,
TRUE,
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW,
NULL,
wifi_secrets_cb,
self);
@@ -2726,16 +2726,18 @@ handle_auth_or_fail (NMDeviceWifi *self,
nm_connection_clear_secrets (connection);
setting_name = nm_connection_need_secrets (connection, NULL);
if (setting_name) {
gboolean get_new;
guint32 flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
/* If the caller doesn't necessarily want completely new secrets,
* only ask for new secrets after the first failure.
*/
get_new = new_secrets ? TRUE : (tries ? TRUE : FALSE);
if (new_secrets || tries)
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
nm_act_request_get_secrets (req,
NULL,
setting_name,
get_new,
flags,
NULL,
wifi_secrets_cb,
self);

View File

@@ -172,7 +172,7 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
NMConnection *connection,
const char *setting_name,
const char *hint,
gboolean get_new,
guint32 flags,
NMSecretAgentCallback callback,
gpointer callback_data)
{
@@ -200,7 +200,7 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
DBUS_TYPE_G_OBJECT_PATH, nm_connection_get_path (connection),
G_TYPE_STRING, setting_name,
G_TYPE_STRV, hints,
G_TYPE_BOOLEAN, get_new,
G_TYPE_UINT, flags,
G_TYPE_INVALID);
g_hash_table_insert (priv->requests, r->call, r);

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2010 - 2011 Red Hat, Inc.
*/
#ifndef NM_SECRET_AGENT_H
@@ -29,6 +29,15 @@
#include <nm-connection.h>
#include "nm-dbus-manager.h"
/* NOTE: these values should match the NM_SECRET_AGENT_GET_SECRETS_FLAGS in
* the nm-secret-agent.xml introspection file.
*/
enum {
NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2
};
#define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ())
#define NM_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgent))
#define NM_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT, NMSecretAgentClass))
@@ -71,7 +80,7 @@ gconstpointer nm_secret_agent_get_secrets (NMSecretAgent *agent,
NMConnection *connection,
const char *setting_name,
const char *hint,
gboolean request_new,
guint32 flags,
NMSecretAgentCallback callback,
gpointer callback_data);

View File

@@ -442,6 +442,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
guint32 tries;
GPtrArray *hints = NULL;
GError *error = NULL;
guint32 flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
connection = nm_act_request_get_connection (priv->act_req);
@@ -461,15 +462,18 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
return;
}
tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES));
/* Only ask for completely new secrets after retrying them once; some PPP
* servers (T-Mobile USA) appear to ask a few times when they actually don't
* even care what you pass back.
/* Only ask for completely new secrets after retrying them once; some devices
* appear to ask a few times when they actually don't even care what you
* pass back.
*/
tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES));
if (tries > 1)
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
priv->secrets_id = nm_act_request_get_secrets (priv->act_req,
NULL,
setting_name,
tries > 1 ? TRUE : FALSE,
flags,
hints ? g_ptr_array_index (hints, 0) : NULL,
ppp_secrets_cb,
manager);

View File

@@ -839,7 +839,7 @@ connection_need_secrets_cb (DBusGProxy *proxy,
priv->secrets_id = nm_act_request_get_secrets (priv->act_request,
priv->connection,
setting_name,
FALSE,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION,
NULL,
vpn_secrets_cb,
self);