Commit 3b371056 authored by Robert Love's avatar Robert Love Committed by Robert Love
Browse files

2005-06-23 Robert Love <rml@novell.com>

        * gnome/applet/applet-dbus-info.c: gnome keyring support!
        * gnome/applet/passphrase-dialog.c: more of that keyring!


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@745 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 1e2564a2
2005-06-23 Robert Love <rml@novell.com>
* gnome/applet/applet-dbus-info.c: gnome keyring support!
* gnome/applet/passphrase-dialog.c: more of that keyring!
2005-06-23 Robert Love <rml@novell.com>
* configure.in: remove extraneous GNOMEKEYRING directives.
......
......@@ -29,6 +29,8 @@
#include <dbus/dbus.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gnome-keyring.h>
#include "NetworkManager.h"
#include "applet.h"
#include "applet-dbus.h"
......@@ -293,13 +295,14 @@ static DBusMessage *nmi_dbus_get_network_properties (NMWirelessApplet *applet, D
DBusError error;
NMNetworkType type;
char *escaped_network;
char *essid = NULL;
gint timestamp = -1;
gint32 i;
gint32 i;
char *key = NULL;
NMEncKeyType key_type = -1;
gboolean trusted = FALSE;
GList *found_list = NULL;
GnomeKeyringResult ret;
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
g_return_val_if_fail (applet != NULL, NULL);
......@@ -335,16 +338,21 @@ static DBusMessage *nmi_dbus_get_network_properties (NMWirelessApplet *applet, D
}
g_free (gconf_key);
/* Grab user-key key for our access point from GConf */
gconf_key = g_strdup_printf ("%s/%s/key", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
/* Get the essid key, if any, from the keyring */
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
&found_list,
"essid",
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
essid,
NULL);
if (ret == GNOME_KEYRING_RESULT_OK)
{
key = g_strdup (gconf_value_get_string (value));
gconf_value_free (value);
GnomeKeyringFound *found = found_list->data;
key = g_strdup (found->secret);
gnome_keyring_found_list_free (found_list);
}
else
key = g_strdup ("");
g_free (gconf_key);
gconf_key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
......
......@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <glib.h>
#include <gnome-keyring.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
......@@ -236,13 +237,39 @@ static void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer use
g_free (key);
if (gconf_entry)
{
GnomeKeyringAttributeList *attributes;
GnomeKeyringAttribute attr;
GnomeKeyringResult ret;
const char *essid, *name;
guint32 item_id;
/* Setup a request to the keyring to save the network passphrase */
essid = wireless_network_get_essid (net);
name = g_strdup_printf (_("Passphrase for wireless network %s"), essid);
attributes = gnome_keyring_attribute_list_new ();
attr.name = g_strdup ("essid"); /* FIXME: Do we need to free this ? */
attr.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
attr.value.string = g_strdup (essid);
g_array_append_val (attributes, attr);
ret = gnome_keyring_item_create_sync (NULL,
GNOME_KEYRING_ITEM_GENERIC_SECRET,
name,
attributes,
passphrase,
TRUE,
&item_id);
if (ret != GNOME_KEYRING_RESULT_OK)
g_warning ("Error saving passphrase in keyring. Ret=%d", ret);
else
gnome_keyring_attribute_list_free (attributes);
gconf_entry_unref (gconf_entry);
key = g_strdup_printf ("%s/%s/key", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
gconf_client_set_string (applet->gconf_client, key, passphrase, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
gconf_client_set_string (applet->gconf_client, key, wireless_network_get_essid (net), NULL);
gconf_client_set_string (applet->gconf_client, key, essid, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
gconf_client_set_int (applet->gconf_client, key, key_type_return, NULL);
g_free (key);
......
Markdown is supported
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