summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-09-25 08:00:40 +0000
committerDan Williams <dcbw@redhat.com>2007-09-25 08:00:40 +0000
commit58fff4ce0484d88eb562c35dc7e68b4cef46db36 (patch)
tree72b0a8507c6bc436c28767fc1e7d808ea38adb52
parent6e1c10d31bc0da2bfb22a0ca5f1826c3a755bf13 (diff)
downloadNetworkManager-58fff4ce0484d88eb562c35dc7e68b4cef46db36.tar.gz
2007-09-25 Dan Williams <dcbw@redhat.com>
* src/supplicant-manager/nm-supplicant-manager.c - (poke_supplicant_cb, nm_supplicant_manager_init, nm_supplicant_manager_dispose, nm_supplicant_manager_name_owner_changed, nm_supplicant_manager_startup): when the supplicant isn't running, try to start it periodically via system bus activation. Fixes a problem where if wpa_supplicant goes away, NM gets stuck waiting for the supplicant to come back git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2875 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
-rw-r--r--ChangeLog10
-rw-r--r--src/supplicant-manager/nm-supplicant-manager.c100
2 files changed, 74 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index ab85d21c27..d244873995 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2007-09-25 Dan Williams <dcbw@redhat.com>
+ * src/supplicant-manager/nm-supplicant-manager.c
+ - (poke_supplicant_cb, nm_supplicant_manager_init,
+ nm_supplicant_manager_dispose, nm_supplicant_manager_name_owner_changed,
+ nm_supplicant_manager_startup): when the supplicant isn't running,
+ try to start it periodically via system bus activation. Fixes
+ a problem where if wpa_supplicant goes away, NM gets stuck waiting
+ for the supplicant to come back
+
+2007-09-25 Dan Williams <dcbw@redhat.com>
+
Ensure that old activation requests are forgotten about; previously
hitting Cancel in the password dialog would deactivate whatever device
that password was requested for, even if that wasn't the currently
diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c
index 61ececc945..0c92f15ac8 100644
--- a/src/supplicant-manager/nm-supplicant-manager.c
+++ b/src/supplicant-manager/nm-supplicant-manager.c
@@ -29,11 +29,14 @@
#include "nm-supplicant-marshal.h"
#include "nm-utils.h"
+#define SUPPLICANT_POKE_INTERVAL 6000
+
typedef struct {
NMDBusManager * dbus_mgr;
guint32 state;
GSList * ifaces;
gboolean dispose_has_run;
+ guint poke_id;
} NMSupplicantManagerPrivate;
#define NM_SUPPLICANT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
@@ -52,7 +55,7 @@ static void nm_supplicant_manager_name_owner_changed (NMDBusManager *dbus_mgr,
static void nm_supplicant_manager_set_state (NMSupplicantManager * self,
guint32 new_state);
-static void nm_supplicant_manager_startup (NMSupplicantManager * self);
+static gboolean nm_supplicant_manager_startup (NMSupplicantManager * self);
/* Signals */
@@ -78,56 +81,58 @@ nm_supplicant_manager_get (void)
return singleton;
}
-static void
-poke_supplicant_cb (DBusGProxy *proxy,
- DBusGProxyCall *call_id,
- gpointer user_data)
+static gboolean
+poke_supplicant_cb (gpointer user_data)
{
- /* Ignore the response, just trying to service-activate the supplicant */
+ NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data);
+ NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
+ DBusGConnection *g_connection;
+ DBusGProxy *proxy;
+ const char *tmp = "ignoreme";
+
+ g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
+ proxy = dbus_g_proxy_new_for_name (g_connection,
+ WPAS_DBUS_SERVICE,
+ WPAS_DBUS_PATH,
+ WPAS_DBUS_INTERFACE);
+ if (!proxy) {
+ nm_warning ("Error: could not init wpa_supplicant proxy");
+ return TRUE;
+ }
+
+ nm_info ("Trying to start the supplicant...");
+ dbus_g_proxy_call_no_reply (proxy, "getInterface", G_TYPE_STRING, tmp, G_TYPE_INVALID);
+ g_object_unref (proxy);
+
+ return TRUE;
}
static void
nm_supplicant_manager_init (NMSupplicantManager * self)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
- NMDBusManager *dbus_mgr;
- DBusGConnection *g_connection;
- DBusGProxy *proxy;
+ gboolean running;
priv->dispose_has_run = FALSE;
priv->state = NM_SUPPLICANT_MANAGER_STATE_DOWN;
priv->dbus_mgr = nm_dbus_manager_get ();
+ priv->poke_id = 0;
- nm_supplicant_manager_startup (self);
+ running = nm_supplicant_manager_startup (self);
g_signal_connect (priv->dbus_mgr,
"name-owner-changed",
G_CALLBACK (nm_supplicant_manager_name_owner_changed),
self);
- /* Poke the supplicant so that it gets activated by dbus system bus
- * activation.
- */
- dbus_mgr = nm_dbus_manager_get ();
- g_connection = nm_dbus_manager_get_connection (dbus_mgr);
- proxy = dbus_g_proxy_new_for_name (g_connection,
- WPAS_DBUS_SERVICE,
- WPAS_DBUS_PATH,
- WPAS_DBUS_INTERFACE);
- if (!proxy) {
- nm_warning ("Error: could not init wpa_supplicant proxy");
- } else {
- DBusGProxyCall *call;
- const char *tmp = "ignore";
-
- call = dbus_g_proxy_begin_call (proxy, "getInterface",
- poke_supplicant_cb,
- NULL,
- NULL,
- G_TYPE_STRING, tmp,
- G_TYPE_INVALID);
+ if (!running) {
+ /* Poke the supplicant so that it gets activated by dbus system bus
+ * activation.
+ */
+ priv->poke_id = g_timeout_add (SUPPLICANT_POKE_INTERVAL,
+ poke_supplicant_cb,
+ (gpointer) self);
}
- g_object_unref (dbus_mgr);
}
static void
@@ -143,6 +148,11 @@ nm_supplicant_manager_dispose (GObject *object)
/* Make sure dispose does not run twice. */
priv->dispose_has_run = TRUE;
+ if (priv->poke_id) {
+ g_source_remove (priv->poke_id);
+ priv->poke_id = 0;
+ }
+
/*
* In dispose, you are supposed to free all types referenced from this
* object which might themselves hold a reference to self. Generally,
@@ -186,6 +196,7 @@ nm_supplicant_manager_name_owner_changed (NMDBusManager *dbus_mgr,
gpointer user_data)
{
NMSupplicantManager * self = (NMSupplicantManager *) user_data;
+ NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
gboolean old_owner_good = (old_owner && strlen (old_owner));
gboolean new_owner_good = (new_owner && strlen (new_owner));
@@ -194,9 +205,25 @@ nm_supplicant_manager_name_owner_changed (NMDBusManager *dbus_mgr,
return;
if (!old_owner_good && new_owner_good) {
- nm_supplicant_manager_startup (self);
+ gboolean running;
+
+ running = nm_supplicant_manager_startup (self);
+
+ if (running && priv->poke_id) {
+ g_source_remove (priv->poke_id);
+ priv->poke_id = 0;
+ }
} else if (old_owner_good && !new_owner_good) {
nm_supplicant_manager_set_state (self, NM_SUPPLICANT_MANAGER_STATE_DOWN);
+
+ if (!priv->poke_id) {
+ /* Poke the supplicant so that it gets activated by dbus system bus
+ * activation.
+ */
+ priv->poke_id = g_timeout_add (SUPPLICANT_POKE_INTERVAL,
+ poke_supplicant_cb,
+ (gpointer) self);
+ }
}
}
@@ -227,7 +254,7 @@ nm_supplicant_manager_set_state (NMSupplicantManager * self, guint32 new_state)
old_state);
}
-static void
+static gboolean
nm_supplicant_manager_startup (NMSupplicantManager * self)
{
gboolean running;
@@ -235,9 +262,10 @@ nm_supplicant_manager_startup (NMSupplicantManager * self)
/* FIXME: convert to pending call */
running = nm_dbus_manager_name_has_owner (NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->dbus_mgr,
WPAS_DBUS_SERVICE);
- if (running) {
+ if (running)
nm_supplicant_manager_set_state (self, NM_SUPPLICANT_MANAGER_STATE_IDLE);
- }
+
+ return running;
}
NMSupplicantInterface *