Commit 6000e6f0 authored by Dan Williams's avatar Dan Williams
Browse files

2004-10-27 Dan Williams <dcbw@redhat.com>

	* info-daemon/NetworkManagerInfo.c
	  info-daemon/NetworkManagerInfoDbus.c
	  info-daemon/NetworkManagerInfoPassphraseDialog.c
	  panel-applet/NMWirelessApplet.c
		- Properly escape gconf keys

	* src/NetworkManager.c
		- remove unused variables

	* src/NetworkManagerAP.c
		- (nm_ap_new_from_ap): Don't redundantly set new APs
			refcount since it got set in nm_ap_new()

	* src/NetworkManagerAPList.c
		- (nm_ap_list_combine): Give up ownership of newly created
			access points to the ap list, fixes memleak

	* src/NetworkManagerDevice.c
		- Remove cached_ap_list4 member since its not really needed
		- (nm_device_wireless_network_exists): Try to get correct
			encryption status of a found AP if its already in our
			device list
		- (nm_device_do_normal_scan): Clean up scanning a bit, make
			memory allocs/deallocs a bit clearer and shorter-lived


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@275 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent a8c239c0
2004-10-27 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c
info-daemon/NetworkManagerInfoDbus.c
info-daemon/NetworkManagerInfoPassphraseDialog.c
panel-applet/NMWirelessApplet.c
- Properly escape gconf keys
* src/NetworkManager.c
- remove unused variables
* src/NetworkManagerAP.c
- (nm_ap_new_from_ap): Don't redundantly set new APs
refcount since it got set in nm_ap_new()
* src/NetworkManagerAPList.c
- (nm_ap_list_combine): Give up ownership of newly created
access points to the ap list, fixes memleak
* src/NetworkManagerDevice.c
- Remove cached_ap_list4 member since its not really needed
- (nm_device_wireless_network_exists): Try to get correct
encryption status of a found AP if its already in our
device list
- (nm_device_do_normal_scan): Clean up scanning a bit, make
memory allocs/deallocs a bit clearer and shorter-lived
2004-10-26 Ray Strode <rstrode@redhat.com>
* panel-applet/NMWirelessApplet.c:
......
......@@ -75,7 +75,7 @@ void nmi_gconf_notify_callback (GConfClient *client, guint connection_id, GConfE
/* If its a key under the network name, zero out the slash so we
* are left with only the network name.
*/
unescaped_network = gnome_vfs_unescape_string (network, "");
unescaped_network = gconf_unescape_key (network, strlen (network));
if ((slash_pos = strchr (unescaped_network, '/')))
*slash_pos = '\0';
......
......@@ -25,7 +25,6 @@
#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <string.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include "NetworkManagerInfo.h"
#include "NetworkManagerInfoDbus.h"
......@@ -304,7 +303,7 @@ static DBusMessage *nmi_dbus_get_network_timestamp (NMIAppInfo *info, DBusMessag
}
/* Grab timestamp key for our access point from GConf */
escaped_network = gnome_vfs_escape_string (network);
escaped_network = gconf_escape_key (network, strlen (network));
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL);
......@@ -358,7 +357,7 @@ static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *m
}
/* Grab essid key for our access point from GConf */
escaped_network = gnome_vfs_escape_string (network);
escaped_network = gconf_escape_key (network, strlen (network));
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL);
......@@ -413,7 +412,7 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes
}
/* Grab user-key key for our access point from GConf */
escaped_network = gnome_vfs_escape_string (network);
escaped_network = gconf_escape_key (network, strlen (network));
key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
key_value = gconf_client_get (info->gconf_client, key, NULL);
g_free (key);
......@@ -473,7 +472,7 @@ static DBusMessage *nmi_dbus_get_network_trusted (NMIAppInfo *info, DBusMessage
}
/* Grab user-key key for our access point from GConf */
escaped_network = gnome_vfs_escape_string (network);
escaped_network = gconf_escape_key (network, strlen (network));
key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL);
......
......@@ -29,7 +29,6 @@
#include <glib.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#ifndef _
#define _(x) dgettext (GETTEXT_PACKAGE, x)
......@@ -153,7 +152,7 @@ void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer user_data)
nmi_dbus_return_user_key (info->connection, device, network, passphrase, key_type_return);
/* Update GConf with the new user key */
escaped_network = gnome_vfs_escape_string (network);
escaped_network = gconf_escape_key (network, strlen (network));
key = g_strdup_printf ("%s/%s", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
gconf_entry = gconf_client_get_entry (info->gconf_client, key, NULL, TRUE, NULL);
g_free (key);
......
......@@ -431,7 +431,8 @@ static void nmwa_destroy (NMWirelessApplet *applet, gpointer user_data)
*/
static void nmwa_update_network_timestamp (NMWirelessApplet *applet, const WirelessNetwork *network)
{
char *key;
char *key;
char *escaped_network;
g_return_if_fail (applet != NULL);
g_return_if_fail (network != NULL);
......@@ -441,14 +442,16 @@ static void nmwa_update_network_timestamp (NMWirelessApplet *applet, const Wirel
*/
/* Update timestamp on network */
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, network->essid);
escaped_network = gconf_escape_key (network->essid, strlen (network->essid));
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
g_free (key);
/* Force-set the essid too so that we have a semi-complete network entry */
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, network->essid);
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
gconf_client_set_string (applet->gconf_client, key, network->essid, NULL);
g_free (key);
g_free (escaped_network);
}
......
......@@ -47,7 +47,6 @@
* Globals
*/
static NMData *nm_data = NULL;
extern gboolean allowed_ap_worker_exit;
static void nm_data_free (NMData *data);
......
......@@ -94,8 +94,6 @@ NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *src_ap)
return (NULL);
}
new_ap->refcount = 1;
if (src_ap->essid && (strlen (src_ap->essid) > 0))
new_ap->essid = g_strdup (src_ap->essid);
if (src_ap->address)
......
......@@ -379,7 +379,10 @@ NMAccessPointList * nm_ap_list_combine (NMAccessPointList *list1, NMAccessPointL
{
NMAccessPoint *new_ap = nm_ap_new_from_ap (ap);
if (new_ap)
{
nm_ap_list_append_ap (final_list, new_ap);
nm_ap_unref (new_ap);
}
}
nm_ap_list_iter_free (iter);
}
......@@ -393,7 +396,10 @@ NMAccessPointList * nm_ap_list_combine (NMAccessPointList *list1, NMAccessPointL
{
NMAccessPoint *new_ap = nm_ap_new_from_ap (ap);
if (new_ap)
{
nm_ap_list_append_ap (final_list, new_ap);
nm_ap_unref (new_ap);
}
}
}
nm_ap_list_iter_free (iter);
......
......@@ -37,8 +37,6 @@
#include "NetworkManagerAPList.h"
#include "backends/NetworkManagerSystem.h"
extern gboolean debug;
/* Local static prototypes */
static gboolean mii_get_link (NMDevice *dev);
static gpointer nm_device_activation_worker (gpointer user_data);
......@@ -66,7 +64,6 @@ typedef struct NMDeviceWirelessOptions
NMAccessPointList *cached_ap_list1;
NMAccessPointList *cached_ap_list2;
NMAccessPointList *cached_ap_list3;
NMAccessPointList *cached_ap_list4;
NMAccessPoint *best_ap;
GMutex *best_ap_mutex;
......@@ -397,8 +394,6 @@ void nm_device_unref (NMDevice *dev)
nm_ap_list_unref (dev->options.wireless.cached_ap_list2);
if (dev->options.wireless.cached_ap_list3)
nm_ap_list_unref (dev->options.wireless.cached_ap_list3);
if (dev->options.wireless.cached_ap_list4)
nm_ap_list_unref (dev->options.wireless.cached_ap_list4);
nm_ap_unref (dev->options.wireless.best_ap);
g_mutex_free (dev->options.wireless.best_ap_mutex);
}
......@@ -2085,8 +2080,9 @@ void nm_device_update_best_ap (NMDevice *dev)
*/
gboolean nm_device_wireless_network_exists (NMDevice *dev, const char *network, struct ether_addr *ap_addr, gboolean *encrypted)
{
gboolean success = FALSE;
struct ether_addr addr;
gboolean success = FALSE;
struct ether_addr addr;
NMAccessPoint *ap = NULL;
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (network != NULL, FALSE);
......@@ -2142,6 +2138,12 @@ gboolean nm_device_wireless_network_exists (NMDevice *dev, const char *network,
}
}
/* If by some chance we could connect, but in the wrong encryption mode, return the
* encryption status of the access point if its in our scan, since that's more accurate.
*/
if ((ap = nm_ap_list_get_ap_by_essid (nm_device_ap_list_get (dev), network)))
*encrypted = nm_ap_get_encrypted (ap);
if (success)
fprintf (stderr, " found! (%s)\n", *encrypted ? "encrypted" : "unencrypted");
else
......@@ -2233,7 +2235,7 @@ static void nm_device_do_normal_scan (NMDevice *dev)
int iwlib_socket;
NMData *data;
g_return_if_fail (dev != NULL);
g_return_if_fail (dev != NULL);
g_return_if_fail (dev->app_data != NULL);
/* Test devices shouldn't get here since we fake the AP list earlier */
......@@ -2253,7 +2255,8 @@ static void nm_device_do_normal_scan (NMDevice *dev)
wireless_scan *tmp_ap;
int err;
NMAccessPointList *old_ap_list = NULL;
NMAccessPointList *temp_list;
NMAccessPointList *new_scan_list = NULL;
NMAccessPointList *earliest_scan = NULL;
gboolean have_blank_essids = FALSE;
NMAPListIter *iter;
NMAccessPoint *artificial_ap;
......@@ -2275,8 +2278,8 @@ static void nm_device_do_normal_scan (NMDevice *dev)
}
/* New list for current scan data */
temp_list = nm_ap_list_new (NETWORK_TYPE_DEVICE);
if (!temp_list)
new_scan_list = nm_ap_list_new (NETWORK_TYPE_DEVICE);
if (!new_scan_list)
{
nm_dispose_scan_results (scan_results.result);
close (iwlib_socket);
......@@ -2284,12 +2287,10 @@ static void nm_device_do_normal_scan (NMDevice *dev)
}
/* Shift all previous cached scan results and dispose of the oldest one. */
if (dev->options.wireless.cached_ap_list4)
nm_ap_list_unref (dev->options.wireless.cached_ap_list4);
dev->options.wireless.cached_ap_list4 = dev->options.wireless.cached_ap_list3;
earliest_scan = dev->options.wireless.cached_ap_list3;
dev->options.wireless.cached_ap_list3 = dev->options.wireless.cached_ap_list2;
dev->options.wireless.cached_ap_list2 = dev->options.wireless.cached_ap_list1;
dev->options.wireless.cached_ap_list1 = temp_list;
dev->options.wireless.cached_ap_list1 = new_scan_list;
/* Iterate over scan results and pick a "most" preferred access point. */
tmp_ap = scan_results.result;
......@@ -2349,7 +2350,7 @@ static void nm_device_do_normal_scan (NMDevice *dev)
if (have_blank_essids)
nm_ap_list_copy_essids_by_address (nm_device_ap_list_get (dev), old_ap_list);
/* Furthermore, if we have an "artificial" access points, ie ones that exist but don't show up in
/* Furthermore, if we have any "artificial" access points, ie ones that exist but don't show up in
* the scan for some reason, copy those over if we are associated with that access point right now.
* Some Cisco cards don't report non-ESSID-broadcasting access points in their scans even though
* the card associates with that AP just fine.
......@@ -2370,11 +2371,14 @@ static void nm_device_do_normal_scan (NMDevice *dev)
}
nm_ap_list_iter_free (iter);
}
nm_ap_list_unref (old_ap_list);
/* Generate the "old" list from the 3rd and 4th oldest scans we've done */
old_ap_list = nm_ap_list_combine (dev->options.wireless.cached_ap_list3, dev->options.wireless.cached_ap_list4);
old_ap_list = nm_ap_list_combine (dev->options.wireless.cached_ap_list3, earliest_scan);
/* Don't need the 4th scan around any more */
if (earliest_scan)
nm_ap_list_unref (earliest_scan);
/* Now do a diff of the old and new networks that we can see, and
* signal any changes over dbus, but only if we are active device.
......
......@@ -35,8 +35,6 @@
#include "NetworkManagerAPList.h"
#include "NetworkManagerDbus.h"
gboolean allowed_ap_worker_exit = FALSE;
/*
* nm_policy_auto_get_best_device
......@@ -59,12 +57,10 @@ static NMDevice * nm_policy_auto_get_best_device (NMData *data)
while (element)
{
NMDevice *dev = NULL;
guint dev_type;
gboolean link_active;
guint prio = 0;
dev = (NMDevice *)(element->data);
NMDevice *dev = (NMDevice *)(element->data);
/* Skip unsupported devices */
if (nm_device_get_driver_support_level (dev) == NM_DRIVER_UNSUPPORTED)
......
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