2005-01-27 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfoDbus.c - (nmi_dbus_add_network_address): if the network doesn't yet exist in GConf, make a minimal entry for it (essid & timestamp) * src/NetworkManagerAPList.c - (nm_ap_list_populate_from_nmi): Don't try to grab network data if NetworkManagerInfo isn't running * src/NetworkManagerDbus.[ch] - (nm_dbus_nmi_is_running): new function * src/NetworkManagerDevice.c - (nm_device_wireless_force_use): Don't set the created AP's MAC address to garbage. * src/NetworkManagerPolicy.c - (nm_policy_activation_finish): On successful activation, make sure the "best" AP has a MAC address, and don't tell NMI to add the current AP's MAC address to GConf if the AP is an Ad-hoc AP. - (nm_policy_allowed_ap_list_update): Update a wireless card's "best" access point after refreshing our allowed list if it doesn't already have a "best" access point. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@400 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
25
ChangeLog
25
ChangeLog
@@ -1,3 +1,28 @@
|
|||||||
|
2005-01-27 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* info-daemon/NetworkManagerInfoDbus.c
|
||||||
|
- (nmi_dbus_add_network_address): if the network doesn't yet exist in
|
||||||
|
GConf, make a minimal entry for it (essid & timestamp)
|
||||||
|
|
||||||
|
* src/NetworkManagerAPList.c
|
||||||
|
- (nm_ap_list_populate_from_nmi): Don't try to grab network data if
|
||||||
|
NetworkManagerInfo isn't running
|
||||||
|
|
||||||
|
* src/NetworkManagerDbus.[ch]
|
||||||
|
- (nm_dbus_nmi_is_running): new function
|
||||||
|
|
||||||
|
* src/NetworkManagerDevice.c
|
||||||
|
- (nm_device_wireless_force_use): Don't set the created AP's MAC
|
||||||
|
address to garbage.
|
||||||
|
|
||||||
|
* src/NetworkManagerPolicy.c
|
||||||
|
- (nm_policy_activation_finish): On successful activation, make sure
|
||||||
|
the "best" AP has a MAC address, and don't tell NMI to add the
|
||||||
|
current AP's MAC address to GConf if the AP is an Ad-hoc AP.
|
||||||
|
- (nm_policy_allowed_ap_list_update): Update a wireless card's "best"
|
||||||
|
access point after refreshing our allowed list if it doesn't already
|
||||||
|
have a "best" access point.
|
||||||
|
|
||||||
2005-01-25 Dan Williams <dcbw@redhat.com>
|
2005-01-25 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* panel-applet/NMWirelessAppletDbus.c
|
* panel-applet/NMWirelessAppletDbus.c
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "NetworkManagerInfo.h"
|
#include "NetworkManagerInfo.h"
|
||||||
#include "NetworkManagerInfoDbus.h"
|
#include "NetworkManagerInfoDbus.h"
|
||||||
@@ -580,12 +581,29 @@ static DBusMessage *nmi_dbus_add_network_address (NMIAppInfo *info, DBusMessage
|
|||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab user-key key for our access point from GConf */
|
/* Force-set the essid too so that we have a semi-complete network entry */
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
escaped_network = gconf_escape_key (network, strlen (network));
|
||||||
key = g_strdup_printf ("%s/%s/addresses", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_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);
|
value = gconf_client_get (info->gconf_client, key, NULL);
|
||||||
|
|
||||||
|
/* If the network doesn't already exist in GConf, add it and set its timestamp to now. */
|
||||||
|
if (!value || (!value && (value->type == GCONF_VALUE_STRING)))
|
||||||
|
{
|
||||||
|
/* Set the essid of the network. */
|
||||||
|
gconf_client_set_string (info->gconf_client, key, network, NULL);
|
||||||
|
g_free (key);
|
||||||
|
|
||||||
|
/* Update timestamp on network */
|
||||||
|
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
gconf_client_set_int (info->gconf_client, key, time (NULL), NULL);
|
||||||
|
}
|
||||||
|
g_free (key);
|
||||||
|
|
||||||
|
/* Get current list of access point MAC addresses for this AP from GConf */
|
||||||
|
key = g_strdup_printf ("%s/%s/addresses", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
value = gconf_client_get (info->gconf_client, key, NULL);
|
||||||
|
g_free (escaped_network);
|
||||||
|
|
||||||
if (value && (value->type == GCONF_VALUE_LIST) && (gconf_value_get_list_type (value) == GCONF_VALUE_STRING))
|
if (value && (value->type == GCONF_VALUE_LIST) && (gconf_value_get_list_type (value) == GCONF_VALUE_STRING))
|
||||||
{
|
{
|
||||||
GSList *elem;
|
GSList *elem;
|
||||||
@@ -671,6 +689,7 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
|
|||||||
GtkDialog *dialog;
|
GtkDialog *dialog;
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
|
dbus_error_free (&error);
|
||||||
text = g_strdup_printf ( "The requested wireless network '%s' does not appear to be in range. "
|
text = g_strdup_printf ( "The requested wireless network '%s' does not appear to be in range. "
|
||||||
"A different wireless network will be used if any are available.", network);
|
"A different wireless network will be used if any are available.", network);
|
||||||
dbus_free (network);
|
dbus_free (network);
|
||||||
@@ -678,7 +697,6 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
|
|||||||
dialog = GTK_DIALOG (gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text, NULL));
|
dialog = GTK_DIALOG (gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text, NULL));
|
||||||
gtk_dialog_run (dialog);
|
gtk_dialog_run (dialog);
|
||||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
dbus_error_free (&error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp ("getNetworks", method) == 0)
|
else if (strcmp ("getNetworks", method) == 0)
|
||||||
@@ -790,6 +808,7 @@ static gboolean nmi_dbus_nm_is_running (DBusConnection *connection)
|
|||||||
return (exists);
|
return (exists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_dbus_service_init
|
* nmi_dbus_service_init
|
||||||
*
|
*
|
||||||
|
@@ -347,6 +347,10 @@ void nm_ap_list_populate_from_nmi (NMAccessPointList *list, NMData *data)
|
|||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (list->type == NETWORK_TYPE_ALLOWED);
|
g_return_if_fail (list->type == NETWORK_TYPE_ALLOWED);
|
||||||
|
|
||||||
|
/* If NMI isn't running, don't try to talk to it. */
|
||||||
|
if (!nm_dbus_nmi_is_running (data->dbus_connection))
|
||||||
|
return;
|
||||||
|
|
||||||
networks = nm_dbus_get_networks (data->dbus_connection, list->type, &num_networks);
|
networks = nm_dbus_get_networks (data->dbus_connection, list->type, &num_networks);
|
||||||
if (networks && (num_networks > 0))
|
if (networks && (num_networks > 0))
|
||||||
{
|
{
|
||||||
|
@@ -1124,6 +1124,27 @@ char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_dbus_nmi_is_running
|
||||||
|
*
|
||||||
|
* Ask dbus whether or not NetworkManagerInfo is running
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
gboolean nm_dbus_nmi_is_running (DBusConnection *connection)
|
||||||
|
{
|
||||||
|
DBusError error;
|
||||||
|
gboolean exists;
|
||||||
|
|
||||||
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
exists = dbus_bus_service_exists (connection, NMI_DBUS_SERVICE, &error);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (exists);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_dbus_nmi_filter
|
* nm_dbus_nmi_filter
|
||||||
*
|
*
|
||||||
|
@@ -66,6 +66,8 @@ gboolean nm_dbus_add_network_address (DBusConnection *connection, NMNetworkTy
|
|||||||
|
|
||||||
gboolean nm_dbus_update_network_auth_method (DBusConnection *connection, const char *network, const NMDeviceAuthMethod auth_method);
|
gboolean nm_dbus_update_network_auth_method (DBusConnection *connection, const char *network, const NMDeviceAuthMethod auth_method);
|
||||||
|
|
||||||
|
gboolean nm_dbus_nmi_is_running (DBusConnection *connection);
|
||||||
|
|
||||||
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -2945,7 +2945,6 @@ typedef struct NMDeviceForceData
|
|||||||
|
|
||||||
static gboolean nm_device_wireless_force_use (NMDevice *dev, const char *essid, const char *key, NMEncKeyType key_type)
|
static gboolean nm_device_wireless_force_use (NMDevice *dev, const char *essid, const char *key, NMEncKeyType key_type)
|
||||||
{
|
{
|
||||||
struct ether_addr ap_addr;
|
|
||||||
gboolean encrypted = FALSE;
|
gboolean encrypted = FALSE;
|
||||||
NMAccessPoint *ap = NULL;
|
NMAccessPoint *ap = NULL;
|
||||||
NMAccessPoint *tmp_ap = NULL;
|
NMAccessPoint *tmp_ap = NULL;
|
||||||
@@ -2982,7 +2981,6 @@ static gboolean nm_device_wireless_force_use (NMDevice *dev, const char *essid,
|
|||||||
else
|
else
|
||||||
nm_ap_set_auth_method (ap, NM_DEVICE_AUTH_METHOD_NONE);
|
nm_ap_set_auth_method (ap, NM_DEVICE_AUTH_METHOD_NONE);
|
||||||
nm_ap_set_artificial (ap, TRUE);
|
nm_ap_set_artificial (ap, TRUE);
|
||||||
nm_ap_set_address (ap, &ap_addr);
|
|
||||||
nm_ap_list_append_ap (nm_device_ap_list_get (dev), ap);
|
nm_ap_list_append_ap (nm_device_ap_list_get (dev), ap);
|
||||||
nm_ap_unref (ap);
|
nm_ap_unref (ap);
|
||||||
}
|
}
|
||||||
@@ -3192,7 +3190,7 @@ static void nm_device_fake_ap_list (NMDevice *dev)
|
|||||||
nm_ap_set_strength (nm_ap, fake_qualities[i]);
|
nm_ap_set_strength (nm_ap, fake_qualities[i]);
|
||||||
nm_ap_set_freq (nm_ap, fake_freqs[i]);
|
nm_ap_set_freq (nm_ap, fake_freqs[i]);
|
||||||
|
|
||||||
/* Merge settings from wireless networks, mainly Keys */
|
/* Merge settings from wireless networks, mainly keys */
|
||||||
if ((list_ap = nm_ap_list_get_ap_by_essid (dev->app_data->allowed_ap_list, nm_ap_get_essid (nm_ap))))
|
if ((list_ap = nm_ap_list_get_ap_by_essid (dev->app_data->allowed_ap_list, nm_ap_get_essid (nm_ap))))
|
||||||
{
|
{
|
||||||
nm_ap_set_timestamp (nm_ap, nm_ap_get_timestamp (list_ap));
|
nm_ap_set_timestamp (nm_ap, nm_ap_get_timestamp (list_ap));
|
||||||
|
@@ -248,11 +248,23 @@ gboolean nm_policy_activation_finish (gpointer user_data)
|
|||||||
nm_dbus_signal_device_status_change (data->dbus_connection, dev, result->result);
|
nm_dbus_signal_device_status_change (data->dbus_connection, dev, result->result);
|
||||||
/* Tell NetworkManagerInfo to store the MAC address of the active device's AP */
|
/* Tell NetworkManagerInfo to store the MAC address of the active device's AP */
|
||||||
if (nm_device_is_wireless (dev))
|
if (nm_device_is_wireless (dev))
|
||||||
|
{
|
||||||
|
NMAccessPoint *ap = NULL;
|
||||||
|
|
||||||
|
if ((ap = nm_device_get_best_ap (dev)))
|
||||||
{
|
{
|
||||||
struct ether_addr addr;
|
struct ether_addr addr;
|
||||||
|
|
||||||
nm_device_get_ap_address (dev, &addr);
|
nm_device_get_ap_address (dev, &addr);
|
||||||
nm_dbus_add_network_address (data->dbus_connection, NETWORK_TYPE_ALLOWED, nm_device_get_essid (dev), &addr);
|
if (!nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
|
||||||
|
nm_ap_set_address (ap, &addr);
|
||||||
|
|
||||||
|
/* Don't store MAC addresses for non-infrastructure networks */
|
||||||
|
if (nm_ap_get_mode (ap) == NETWORK_MODE_INFRA)
|
||||||
|
nm_dbus_add_network_address (data->dbus_connection, NETWORK_TYPE_ALLOWED, nm_ap_get_essid (ap), &addr);
|
||||||
|
|
||||||
|
nm_ap_unref (ap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
syslog (LOG_INFO, "Activation (%s) successful, device activated.", nm_device_get_iface (data->active_device));
|
syslog (LOG_INFO, "Activation (%s) successful, device activated.", nm_device_get_iface (data->active_device));
|
||||||
break;
|
break;
|
||||||
@@ -471,6 +483,22 @@ static gboolean nm_policy_allowed_ap_list_update (gpointer user_data)
|
|||||||
if (data->allowed_ap_list)
|
if (data->allowed_ap_list)
|
||||||
nm_ap_list_populate_from_nmi (data->allowed_ap_list, data);
|
nm_ap_list_populate_from_nmi (data->allowed_ap_list, data);
|
||||||
|
|
||||||
|
/* If the active device doesn't have a best_ap already, make it update to
|
||||||
|
* get the new data.
|
||||||
|
*/
|
||||||
|
if ( data->active_device
|
||||||
|
&& nm_device_is_activating (data->active_device)
|
||||||
|
&& nm_device_is_wireless (data->active_device))
|
||||||
|
{
|
||||||
|
NMAccessPoint *best_ap;
|
||||||
|
|
||||||
|
best_ap = nm_device_get_best_ap (data->active_device);
|
||||||
|
if (!best_ap)
|
||||||
|
nm_device_update_best_ap (data->active_device);
|
||||||
|
else
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
|
}
|
||||||
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user