2005-12-17 Dan Williams <dcbw@redhat.com>

* include/NetworkManager.h
		- Finally kill NMEncKeyType

	* gnome/applet/applet-dbus-info.c
		- (nmi_save_network_info): convert to NMGConfWSO

	* gnome/applet/nm-gconf-wso-*.c
		- Implement gconf serialization functions

	* src/NetworkManagerPolicy.c
		- (nm_policy_activation_finish): fix up meaning of
			automatic/user_requested


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1211 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2005-12-17 21:39:19 +00:00
parent a601e80848
commit f003ba8ef7
7 changed files with 121 additions and 99 deletions

View File

@@ -1,3 +1,18 @@
2005-12-17 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Finally kill NMEncKeyType
* gnome/applet/applet-dbus-info.c
- (nmi_save_network_info): convert to NMGConfWSO
* gnome/applet/nm-gconf-wso-*.c
- Implement gconf serialization functions
* src/NetworkManagerPolicy.c
- (nm_policy_activation_finish): fix up meaning of
automatic/user_requested
2005-12-17 Dan Williams <dcbw@redhat.com>
* gnome/applet/*

View File

@@ -30,6 +30,7 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gnome-keyring.h>
#include <iwlib.h>
#include "NetworkManager.h"
#include "applet.h"
@@ -794,31 +795,34 @@ nmi_dbus_get_vpn_connection_routes (DBusConnection *connection,
* Save information about a wireless network in gconf and the gnome keyring.
*
*/
static void nmi_save_network_info (NMWirelessApplet *applet, const char *essid, const char *enc_key_source,
const NMEncKeyType enc_key_type, int auth_method, gboolean user_requested)
static void
nmi_save_network_info (NMWirelessApplet *applet,
const char *essid,
gboolean automatic,
NMGConfWSO * gconf_wso)
{
GnomeKeyringAttributeList * attributes;
GnomeKeyringAttribute attr;
char * key;
GConfEntry * gconf_entry;
char * escaped_network;
GnomeKeyringResult ret;
const char * name;
guint32 item_id;
g_return_if_fail (applet != NULL);
g_return_if_fail (essid != NULL);
g_return_if_fail (gconf_wso != NULL);
escaped_network = gconf_escape_key (essid, strlen (essid));
key = g_strdup_printf ("%s/%s", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
gconf_entry = gconf_client_get_entry (applet->gconf_client, key, NULL, TRUE, NULL);
g_free (key);
if (gconf_entry)
{
GnomeKeyringAttributeList *attributes;
GnomeKeyringAttribute attr;
GnomeKeyringResult ret;
const char *name;
guint32 item_id;
goto out;
gconf_entry_unref (gconf_entry);
if (enc_key_source && strlen (enc_key_source)
&& (enc_key_type != NM_ENC_TYPE_UNKNOWN) && (enc_key_type != NM_ENC_TYPE_NONE))
if (nm_gconf_wso_get_we_cipher (gconf_wso) != IW_AUTH_CIPHER_NONE)
{
/* Setup a request to the keyring to save the network passphrase */
name = g_strdup_printf (_("Passphrase for wireless network %s"), essid);
@@ -832,7 +836,7 @@ static void nmi_save_network_info (NMWirelessApplet *applet, const char *essid,
GNOME_KEYRING_ITEM_GENERIC_SECRET,
name,
attributes,
enc_key_source,
nm_gconf_wso_get_key (gconf_wso),
TRUE,
&item_id);
if (ret != GNOME_KEYRING_RESULT_OK)
@@ -841,33 +845,21 @@ static void nmi_save_network_info (NMWirelessApplet *applet, const char *essid,
gnome_keyring_attribute_list_free (attributes);
}
gconf_entry_unref (gconf_entry);
key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
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, (int)enc_key_type, NULL);
g_free (key);
/* We only update the timestamp if the user requested a particular network, not if
* NetworkManager decided to switch access points by itself.
*/
if (user_requested)
if (!automatic)
{
key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
g_free (key);
}
if (auth_method != -1)
{
key = g_strdup_printf ("%s/%s/auth_method", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
gconf_client_set_int (applet->gconf_client, key, auth_method, NULL);
g_free (key);
}
}
out:
g_free (escaped_network);
}
@@ -885,28 +877,36 @@ nmi_dbus_update_network_info (DBusConnection *connection,
void *user_data)
{
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
char * network = NULL;
int auth_method = -1;
char * enc_key_source = NULL;
int enc_key_type = -1;
gboolean user_requested;
char * essid = NULL;
gboolean automatic;
dbus_bool_t args_good;
NMGConfWSO * gconf_wso = NULL;
DBusMessageIter iter;
g_return_val_if_fail (applet != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
args_good = dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &network,
DBUS_TYPE_STRING, &enc_key_source,
DBUS_TYPE_INT32, &enc_key_type,
DBUS_TYPE_INT32, &auth_method,
DBUS_TYPE_BOOLEAN, &user_requested,
DBUS_TYPE_INVALID);
if (!args_good || (strlen (network) <= 0) || (auth_method == -1))
return NULL;
if (enc_key_source && strlen (enc_key_source) && ((enc_key_type == NM_ENC_TYPE_UNKNOWN) || (enc_key_type == NM_ENC_TYPE_NONE)))
return NULL;
dbus_message_iter_init (message, &iter);
nmi_save_network_info (applet, network, enc_key_source, (NMEncKeyType) enc_key_type, auth_method, user_requested);
/* First argument: ESSID (STRING) */
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
goto out;
dbus_message_iter_get_basic (&iter, &essid);
if (strlen (essid) <= 0)
goto out;
/* Second argument: Automatic (BOOLEAN) */
if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN))
goto out;
dbus_message_iter_get_basic (&iter, &automatic);
/* Deserialize the sercurity option out of the message */
if (!(gconf_wso = nm_gconf_wso_new_deserialize_dbus (&iter)))
goto out;
nmi_save_network_info (applet, essid, automatic, gconf_wso);
out:
return NULL;
}

View File

@@ -108,8 +108,15 @@ real_serialize_dbus (NMGConfWSO *instance, DBusMessageIter *iter)
}
static int
real_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network)
real_serialize_gconf (NMGConfWSO *instance, GConfClient *client, const char *network)
{
NMGConfWSOWEP *self = NM_GCONF_WSO_WEP (instance);
char * key;
key = g_strdup_printf ("%s/%s/%sauth_algorithm", GCONF_PATH_WIRELESS_NETWORKS, network, WEP_PREFIX);
gconf_client_set_int (client, key, self->priv->auth_algorithm, NULL);
g_free (key);
return 0;
}

View File

@@ -120,8 +120,19 @@ real_serialize_dbus (NMGConfWSO *instance, DBusMessageIter *iter)
}
static int
real_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network)
real_serialize_gconf (NMGConfWSO *instance, GConfClient *client, const char *network)
{
NMGConfWSOWPA_PSK * self = NM_GCONF_WSO_WPA_PSK (instance);
char * key;
key = g_strdup_printf ("%s/%s/%swpa_version", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_PSK_PREFIX);
gconf_client_set_int (client, key, self->priv->wpa_version, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%skey_mgt", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_PSK_PREFIX);
gconf_client_set_int (client, key, self->priv->key_mgt, NULL);
g_free (key);
return 0;
}

View File

@@ -247,6 +247,7 @@ int
nm_gconf_wso_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network)
{
dbus_int32_t dbus_we_cipher;
char * key;
g_return_val_if_fail (self != NULL, -1);
g_return_val_if_fail (client != NULL, -1);
@@ -255,11 +256,11 @@ nm_gconf_wso_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char
if (self->priv->dispose_has_run)
return -1;
#if 0
/* First arg: WE cipher (INT32) */
dbus_we_cipher = (dbus_int32_t) self->priv->we_cipher;
dbus_message_iter_append_basic (iter, DBUS_TYPE_INT32, &dbus_we_cipher);
#endif
key = g_strdup_printf ("%s/%s/we_cipher", GCONF_PATH_WIRELESS_NETWORKS, network);
gconf_client_set_int (client, key, self->priv->we_cipher, NULL);
g_free (key);
/* Encryption key doesn't get serialized since its stored in the keyring */
return NM_GCONF_WSO_GET_CLASS (self)->serialize_gconf_func (self, client, network);
}

View File

@@ -79,20 +79,6 @@ typedef enum NMDeviceType
} NMDeviceType;
/*
* Encryption key types
*/
typedef enum NMEncKeyType
{
NM_ENC_TYPE_UNKNOWN = 0,
NM_ENC_TYPE_NONE,
NM_ENC_TYPE_HEX_KEY,
NM_ENC_TYPE_ASCII_KEY,
NM_ENC_TYPE_128_BIT_PASSPHRASE
/* FIXME: 802.1x support */
} NMEncKeyType;
/*
* General device capability bits
*

View File

@@ -64,9 +64,11 @@ static gboolean nm_policy_activation_finish (NMActRequest *req)
struct ether_addr addr;
NMAccessPoint * ap = nm_act_request_get_ap (req);
NMAccessPoint * tmp_ap;
gboolean automatic;
/* Cache details in the info-daemon since the connect was successful */
nm_dbus_update_network_info (data->dbus_connection, ap, nm_act_request_get_user_requested (req));
automatic = !nm_act_request_get_user_requested (req);
nm_dbus_update_network_info (data->dbus_connection, ap, automatic);
nm_device_get_ap_address (dev, &addr);
if (!nm_ap_get_address (ap) || !nm_ethernet_address_is_valid (nm_ap_get_address (ap)))