network-manager-applet r811 - in branches/mbca: . src src/connection-editor src/wireless-security
- From: kaijanma svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r811 - in branches/mbca: . src src/connection-editor src/wireless-security
- Date: Thu, 31 Jul 2008 13:07:44 +0000 (UTC)
Author: kaijanma
Date: Thu Jul 31 13:07:43 2008
New Revision: 811
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=811&view=rev
Log:
merge from trunk
Modified:
branches/mbca/ChangeLog
branches/mbca/src/applet-device-wifi.c
branches/mbca/src/applet.c
branches/mbca/src/connection-editor/page-ip4.c
branches/mbca/src/connection-editor/page-wireless-security.c
branches/mbca/src/connection-editor/vpn-helpers.c
branches/mbca/src/wireless-dialog.c
branches/mbca/src/wireless-security/ws-wep-key.c
branches/mbca/src/wireless-security/ws-wep-key.h
Modified: branches/mbca/src/applet-device-wifi.c
==============================================================================
--- branches/mbca/src/applet-device-wifi.c (original)
+++ branches/mbca/src/applet-device-wifi.c Thu Jul 31 13:07:43 2008
@@ -907,7 +907,8 @@
NMApplet *applet;
NMDeviceWifi *device;
guint id;
- gulong last_notification_time;
+ gulong last_notification_time;
+ guint new_con_id;
};
/* Scan the list of access points, looking for the case where we have no
@@ -1029,12 +1030,23 @@
}
static void
+free_ap_notification_data (gpointer user_data)
+{
+ struct ap_notification_data *data = user_data;
+
+ g_signal_handler_disconnect (applet_get_settings (data->applet), data->new_con_id);
+ memset (data, 0, sizeof (*data));
+ g_free (data);
+}
+
+static void
wireless_device_added (NMDevice *device, NMApplet *applet)
{
NMDeviceWifi *wdev = NM_DEVICE_WIFI (device);
const GPtrArray *aps;
int i;
struct ap_notification_data *data;
+ guint id;
g_signal_connect (wdev,
"notify::" NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT,
@@ -1052,13 +1064,17 @@
data = g_new0 (struct ap_notification_data, 1);
data->applet = applet;
data->device = wdev;
- g_object_set_data_full (G_OBJECT (wdev), "notify-wireless-avail-data", data, g_free);
/* We also need to hook up to the settings to find out when we have new connections
- * that might be candididates.
+ * that might be candididates. Keep the ID around so we can disconnect
+ * when the device is destroyed.
*/
- g_signal_connect (applet_get_settings (applet), "new-connection",
- G_CALLBACK (on_new_connection),
- data);
+ id = g_signal_connect (applet_get_settings (applet), "new-connection",
+ G_CALLBACK (on_new_connection),
+ data);
+ data->new_con_id = id;
+ g_object_set_data_full (G_OBJECT (wdev), "notify-wireless-avail-data",
+ data, free_ap_notification_data);
+
queue_avail_access_point_notification (device);
/* Hash all APs this device knows about */
Modified: branches/mbca/src/applet.c
==============================================================================
--- branches/mbca/src/applet.c (original)
+++ branches/mbca/src/applet.c Thu Jul 31 13:07:43 2008
@@ -149,11 +149,8 @@
const GPtrArray *devices;
devices = nm_active_connection_get_devices (candidate);
- if (!devices || !devices->len) {
- g_warning ("Active connection %s had no devices!",
- nm_object_get_path (NM_OBJECT (candidate)));
+ if (!devices || !devices->len)
continue;
- }
if (nm_active_connection_get_default (candidate)) {
if (!default_ac) {
Modified: branches/mbca/src/connection-editor/page-ip4.c
==============================================================================
--- branches/mbca/src/connection-editor/page-ip4.c (original)
+++ branches/mbca/src/connection-editor/page-ip4.c Thu Jul 31 13:07:43 2008
@@ -300,63 +300,6 @@
}
static void
-dns_servers_changed (GtkEditable *entry, gpointer user_data)
-{
- const char *text;
- char **ips = NULL, **iter;
- gboolean valid = TRUE;
-
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- if (!text || !strlen (text))
- goto out;
-
- ips = g_strsplit (text, ",", 0);
- for (iter = ips; *iter; iter++) {
- struct in_addr tmp_addr;
-
- if (inet_aton (g_strstrip (*iter), &tmp_addr) == 0) {
- valid = FALSE;
- break;
- }
- }
-
- if (ips)
- g_strfreev (ips);
- if (valid)
- ce_page_changed (CE_PAGE (user_data));
-out:
- return;
-}
-
-static void
-dns_searches_changed (GtkEditable *entry, gpointer user_data)
-{
- const char *text;
- char **searches = NULL, **iter;
- gboolean valid = TRUE;
-
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- if (!text || !strlen (text))
- goto out;
-
- searches = g_strsplit (text, ",", 0);
- for (iter = searches; *iter; iter++) {
- /* Need at least one . in the search domain */
- if (!strchr (g_strstrip (*iter), '.')) {
- valid = FALSE;
- break;
- }
- }
-
- if (searches)
- g_strfreev (searches);
- if (valid)
- ce_page_changed (CE_PAGE (user_data));
-out:
- return;
-}
-
-static void
addr_add_clicked (GtkButton *button, gpointer user_data)
{
CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (user_data);
@@ -605,8 +548,8 @@
selection = gtk_tree_view_get_selection (priv->addr_list);
g_signal_connect (selection, "changed", G_CALLBACK (list_selection_changed), priv->addr_delete);
- g_signal_connect (priv->dns_servers, "changed", G_CALLBACK (dns_servers_changed), self);
- g_signal_connect (priv->dns_searches, "changed", G_CALLBACK (dns_searches_changed), self);
+ g_signal_connect_swapped (priv->dns_servers, "changed", G_CALLBACK (ce_page_changed), self);
+ g_signal_connect_swapped (priv->dns_searches, "changed", G_CALLBACK (ce_page_changed), self);
method_changed (priv->method, self);
g_signal_connect (priv->method, "changed", G_CALLBACK (method_changed), self);
@@ -622,7 +565,7 @@
g_array_free ((GArray *) data, TRUE);
}
-static void
+static gboolean
ui_to_setting (CEPageIP4 *self)
{
CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
@@ -630,14 +573,14 @@
GtkTreeIter tree_iter;
int int_method = IP4_METHOD_AUTO;
const char *method;
- GArray *dns_servers;
+ GArray *dns_servers = NULL;
GSList *search_domains = NULL;
GPtrArray *addresses = NULL;
- gboolean valid;
+ gboolean valid = FALSE, iter_valid;
const char *text;
- char **items = NULL, **iter;
gboolean ignore_dhcp_dns = FALSE;
const char *dhcp_client_id = NULL;
+ char **items = NULL, **iter;
/* Method */
if (gtk_combo_box_get_active_iter (priv->method, &tree_iter)) {
@@ -665,49 +608,52 @@
/* IP addresses */
model = gtk_tree_view_get_model (priv->addr_list);
- valid = gtk_tree_model_get_iter_first (model, &tree_iter);
+ iter_valid = gtk_tree_model_get_iter_first (model, &tree_iter);
addresses = g_ptr_array_sized_new (1);
- while (valid) {
- char *str_address = NULL;
- char *str_prefix = NULL;
- char *str_gateway = NULL;
+ while (iter_valid) {
+ char *item = NULL;
struct in_addr tmp_addr, tmp_gateway = { 0 };
GArray *addr;
guint32 empty_val = 0, prefix;
long int tmp_prefix;
-
- gtk_tree_model_get (model, &tree_iter, COL_ADDRESS, &str_address, -1);
- gtk_tree_model_get (model, &tree_iter, COL_PREFIX, &str_prefix, -1);
- gtk_tree_model_get (model, &tree_iter, COL_GATEWAY, &str_gateway, -1);
- if (!str_address || !inet_aton (str_address, &tmp_addr)) {
+ gtk_tree_model_get (model, &tree_iter, COL_ADDRESS, &item, -1);
+ if (!item || !inet_aton (item, &tmp_addr)) {
g_warning ("%s: IPv4 address '%s' missing or invalid!",
- __func__, str_address ? str_address : "<none>");
- goto next;
+ __func__, item ? item : "<none>");
+ g_free (item);
+ goto out;
}
+ g_free (item);
- if (!str_prefix) {
+ gtk_tree_model_get (model, &tree_iter, COL_PREFIX, &item, -1);
+ if (!item) {
g_warning ("%s: IPv4 prefix '%s' missing!",
- __func__, str_prefix ? str_prefix : "<none>");
- goto next;
+ __func__, item ? item : "<none>");
+ goto out;
}
errno = 0;
- tmp_prefix = strtol (str_prefix, NULL, 10);
+ tmp_prefix = strtol (item, NULL, 10);
if (errno || tmp_prefix < 0 || tmp_prefix > 32) {
g_warning ("%s: IPv4 prefix '%s' invalid!",
- __func__, str_prefix ? str_prefix : "<none>");
- goto next;
+ __func__, item ? item : "<none>");
+ g_free (item);
+ goto out;
}
+ g_free (item);
prefix = (guint32) tmp_prefix;
/* Gateway is optional... */
- if (str_gateway && !inet_aton (str_gateway, &tmp_gateway)) {
- g_warning ("%s: IPv4 gateway '%s' missing or invalid!",
- __func__, str_gateway ? str_gateway : "<none>");
- goto next;
+ gtk_tree_model_get (model, &tree_iter, COL_GATEWAY, &item, -1);
+ if (item && !inet_aton (item, &tmp_gateway)) {
+ g_warning ("%s: IPv4 gateway '%s' invalid!",
+ __func__, item ? item : "<none>");
+ g_free (item);
+ goto out;
}
+ g_free (item);
addr = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
g_array_append_val (addr, tmp_addr.s_addr);
@@ -718,10 +664,10 @@
g_array_append_val (addr, empty_val);
g_ptr_array_add (addresses, addr);
-next:
- valid = gtk_tree_model_iter_next (model, &tree_iter);
+ iter_valid = gtk_tree_model_iter_next (model, &tree_iter);
}
+ /* Don't pass empty array to the setting */
if (!addresses->len) {
g_ptr_array_free (addresses, TRUE);
addresses = NULL;
@@ -736,12 +682,14 @@
for (iter = items; *iter; iter++) {
struct in_addr tmp_addr;
- if (inet_aton (g_strstrip (*iter), &tmp_addr))
+ if (inet_pton (AF_INET, g_strstrip (*iter), &tmp_addr))
g_array_append_val (dns_servers, tmp_addr.s_addr);
+ else {
+ g_strfreev (items);
+ goto out;
+ }
}
-
- if (items)
- g_strfreev (items);
+ g_strfreev (items);
}
/* Search domains */
@@ -773,15 +721,21 @@
NM_SETTING_IP4_CONFIG_IGNORE_DHCP_DNS, ignore_dhcp_dns,
NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, dhcp_client_id,
NULL);
+ valid = TRUE;
+out:
if (addresses) {
g_ptr_array_foreach (addresses, (GFunc) free_one_addr, NULL);
g_ptr_array_free (addresses, TRUE);
}
- g_array_free (dns_servers, TRUE);
+ if (dns_servers)
+ g_array_free (dns_servers, TRUE);
+
g_slist_foreach (search_domains, (GFunc) g_free, NULL);
g_slist_free (search_domains);
+
+ return valid;
}
static gboolean
@@ -790,7 +744,8 @@
CEPageIP4 *self = CE_PAGE_IP4 (page);
CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
- ui_to_setting (self);
+ if (!ui_to_setting (self))
+ return FALSE;
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
Modified: branches/mbca/src/connection-editor/page-wireless-security.c
==============================================================================
--- branches/mbca/src/connection-editor/page-wireless-security.c (original)
+++ branches/mbca/src/connection-editor/page-wireless-security.c Thu Jul 31 13:07:43 2008
@@ -252,7 +252,7 @@
if (default_type == NMU_SEC_STATIC_WEP)
default_wep_type = ws_wep_guess_key_type (connection, connection_id);
- ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_PASSPHRASE);
+ ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_PASSPHRASE, FALSE);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
&iter, _("WEP 128-bit Passphrase"));
@@ -261,7 +261,7 @@
item++;
}
- ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_HEX);
+ ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_HEX, FALSE);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
&iter, _("WEP 40/128-bit Hexadecimal"));
@@ -270,7 +270,7 @@
item++;
}
- ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_ASCII);
+ ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_ASCII, FALSE);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
&iter, _("WEP 40/128-bit ASCII"));
Modified: branches/mbca/src/connection-editor/vpn-helpers.c
==============================================================================
--- branches/mbca/src/connection-editor/vpn-helpers.c (original)
+++ branches/mbca/src/connection-editor/vpn-helpers.c Thu Jul 31 13:07:43 2008
@@ -98,7 +98,7 @@
*/
so_name = g_path_get_basename (so_path);
g_free (so_path);
- so_path = g_strdup_printf ("%s/%s", LIBDIR, so_name);
+ so_path = g_strdup_printf ("%s/NetworkManager/%s", LIBDIR, so_name);
g_free (so_name);
module = g_module_open (so_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
Modified: branches/mbca/src/wireless-dialog.c
==============================================================================
--- branches/mbca/src/wireless-dialog.c (original)
+++ branches/mbca/src/wireless-dialog.c Thu Jul 31 13:07:43 2008
@@ -746,7 +746,7 @@
if (default_type == NMU_SEC_STATIC_WEP)
default_wep_type = ws_wep_guess_key_type (priv->connection, connection_id);
- ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_PASSPHRASE);
+ ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_PASSPHRASE, priv->adhoc_create);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
&iter, _("WEP 128-bit Passphrase"));
@@ -755,7 +755,7 @@
item++;
}
- ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_HEX);
+ ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_HEX, priv->adhoc_create);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
&iter, _("WEP 40/128-bit Hexadecimal"));
@@ -764,7 +764,7 @@
item++;
}
- ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_ASCII);
+ ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_ASCII, priv->adhoc_create);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
&iter, _("WEP 40/128-bit ASCII"));
Modified: branches/mbca/src/wireless-security/ws-wep-key.c
==============================================================================
--- branches/mbca/src/wireless-security/ws-wep-key.c (original)
+++ branches/mbca/src/wireless-security/ws-wep-key.c Thu Jul 31 13:07:43 2008
@@ -268,14 +268,15 @@
ws_wep_key_new (const char *glade_file,
NMConnection *connection,
const char *connection_id,
- WEPKeyType type)
+ WEPKeyType type,
+ gboolean adhoc_create)
{
WirelessSecurityWEPKey *sec;
GtkWidget *widget;
GladeXML *xml;
NMSettingWirelessSecurity *s_wsec = NULL;
guint8 default_key_idx = 0;
- gboolean is_adhoc = FALSE;
+ gboolean is_adhoc = adhoc_create;
gboolean is_shared_key = FALSE;
g_return_val_if_fail (glade_file != NULL, NULL);
@@ -376,6 +377,13 @@
(GCallback) key_index_combo_changed_cb,
sec);
+ /* Key index is useless with adhoc networks */
+ if (is_adhoc) {
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (xml, "key_index_label");
+ gtk_widget_hide (widget);
+ }
+
/* Fill the key entry with the key for that index */
widget = glade_xml_get_widget (xml, "wep_key_entry");
if (strlen (sec->keys[default_key_idx]))
@@ -393,7 +401,9 @@
/* Ad-Hoc connections can't use Shared Key auth */
if (is_adhoc) {
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
- gtk_widget_set_sensitive (widget, FALSE);
+ gtk_widget_hide (widget);
+ widget = glade_xml_get_widget (xml, "auth_method_label");
+ gtk_widget_hide (widget);
}
return sec;
Modified: branches/mbca/src/wireless-security/ws-wep-key.h
==============================================================================
--- branches/mbca/src/wireless-security/ws-wep-key.h (original)
+++ branches/mbca/src/wireless-security/ws-wep-key.h Thu Jul 31 13:07:43 2008
@@ -39,7 +39,8 @@
WirelessSecurityWEPKey * ws_wep_key_new (const char *glade_file,
NMConnection *connection,
const char *connection_id,
- WEPKeyType type);
+ WEPKeyType type,
+ gboolean adhoc_create);
WEPKeyType ws_wep_guess_key_type (NMConnection *connection, const char *connection_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]