Commit 43c61d4d authored by Dan Williams's avatar Dan Williams
Browse files

applet: only handle VPN secrets with GNOME Shell < 3.4

GNOME Shell 3.2 and lower don't handle VPN secrets, so the applet
still needs to do that.  But they do handle other secrets, so instead
of having the applet and the Shell fight over who gets to handle
secrets, defer non-VPN secrets to the Shell.
parent a5b3e567
......@@ -45,6 +45,7 @@ G_DEFINE_TYPE (AppletAgent, applet_agent, NM_TYPE_SECRET_AGENT);
typedef struct {
GHashTable *requests;
gboolean vpn_only;
gboolean disposed;
} AppletAgentPrivate;
......@@ -487,6 +488,16 @@ get_secrets (NMSecretAgent *agent,
return;
}
/* Only handle non-VPN secrets if we're supposed to */
if (priv->vpn_only == TRUE) {
error = g_error_new_literal (NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_NO_SECRETS,
"Only handling VPN secrets at this time.");
callback (agent, connection, NULL, error, callback_data);
g_error_free (error);
return;
}
/* For everything else we scrape the keyring for secrets first, and ask
* later if required.
*/
......@@ -782,6 +793,15 @@ delete_secrets (NMSecretAgent *agent,
r->keyring_calls = g_slist_append (r->keyring_calls, call);
}
void
applet_agent_handle_vpn_only (AppletAgent *agent, gboolean vpn_only)
{
g_return_if_fail (agent != NULL);
g_return_if_fail (APPLET_IS_AGENT (agent));
APPLET_AGENT_GET_PRIVATE (agent)->vpn_only = vpn_only;
}
/*******************************************************/
AppletAgent *
......
......@@ -64,5 +64,7 @@ GType applet_agent_get_type (void) G_GNUC_CONST;
AppletAgent *applet_agent_new (void);
void applet_agent_handle_vpn_only (AppletAgent *agent, gboolean vpn_only);
#endif /* _APPLET_AGENT_H_ */
......@@ -3255,23 +3255,32 @@ shell_version_changed_cb (NMShellWatcher *watcher, GParamSpec *pspec, gpointer u
{
NMApplet *applet = user_data;
if (nm_shell_watcher_version_at_least (watcher, 3, 4)) {
if (applet->agent_start_id)
g_source_remove (applet->agent_start_id);
if (applet->agent_start_id) {
g_source_remove (applet->agent_start_id);
applet->agent_start_id = 0;
}
if (applet->agent && nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent))) {
if (!applet->agent)
return;
if (nm_shell_watcher_version_at_least (watcher, 3, 4)) {
/* GNOME Shell handles all secrets requests */
if (nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent))) {
g_message ("Stopping applet secret agent because GNOME Shell appeared");
nm_secret_agent_unregister (NM_SECRET_AGENT (applet->agent));
}
} else if (nm_shell_watcher_version_at_least (watcher, 3, 2)) {
/* GNOME Shell handles everything except VPN secrets requests */
if (nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)))
g_message ("Applet secret agent handling only VPN secrets because GNOME Shell appeared");
applet_agent_handle_vpn_only (applet->agent, TRUE);
} else {
/* If the shell quit and our agent wasn't already registered, do it
* now on a delay (just in case the shell is restarting.
* now on a delay (just in case the shell is restarting).
*/
if (applet->agent_start_id)
g_source_remove (applet->agent_start_id);
if (nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)) == FALSE)
if (!nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)))
applet->agent_start_id = g_timeout_add_seconds (4, delayed_start_agent, applet);
applet_agent_handle_vpn_only (applet->agent, FALSE);
}
}
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment