Esempio n. 1
0
static NMConnection *
get_connection_for_active (NMApplet *applet, NMActiveConnection *active)
{
	GSList *list, *iter;
	NMConnection *connection = NULL;
	NMConnectionScope scope;
	const char *path;

	scope = nm_active_connection_get_scope (active);
	g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);

	path = nm_active_connection_get_connection (active);
	g_return_val_if_fail (path != NULL, NULL);

	list = applet_get_all_connections (applet);
	for (iter = list; iter; iter = g_slist_next (iter)) {
		NMConnection *candidate = NM_CONNECTION (iter->data);

		if (   (nm_connection_get_scope (candidate) == scope)
			   && !strcmp (nm_connection_get_path (candidate), path)) {
			connection = candidate;
			break;
		}
	}

	g_slist_free (list);

	return connection;
}
Esempio n. 2
0
static GtkWidget *
fill_password (GladeXML *xml,
               const char *widget_name,
               NMConnection *connection,
               const char *password_type)
{
    GtkWidget *widget = NULL;
    gchar *password = NULL;

    widget = glade_xml_get_widget (xml, widget_name);
    g_assert (widget);

    if (!connection)
        return widget;

    password = NULL;

    if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
        NMSettingVPN *s_vpn;

        s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
        if (s_vpn) {
            const gchar *tmp = NULL;

            tmp = nm_setting_vpn_get_secret (s_vpn, password_type);
            if (tmp)
                password = gnome_keyring_memory_strdup (tmp);
        }
    } else {
        NMSettingConnection *s_con = NULL;
        gboolean unused;
        const char *uuid;

        s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
        uuid = nm_setting_connection_get_uuid (s_con);
        password = keyring_helpers_lookup_secret (uuid,
                   password_type,
                   &unused);
    }

    if (password) {
        gtk_entry_set_text (GTK_ENTRY (widget), password);
        gnome_keyring_memory_free (password);
    }

    return widget;
}