mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-04 23:28:08 +02:00
2006-05-17 Robert Love <rml@novell.com>
Functionality to differentiate Ad-Hoc networks from infrastructure networks in the applet, by displaying a special icon: * gnome/applet/applet-dbus-devices.c: Set the mode for new networks. * gnome/applet/applet.c: Pass 'applet' to network_menu_item_update(). * gnome/applet/menu-items.c: Set a special icon in the scan list for ad-hoc networks. TODO: Add a third icon representing "encrypted and Ad-Hoc". Right now, we display the same icon for all Ad-Hoc wireless networks, encrypted or not. * gnome/applet/wireless-network.c, gnome/applet/wireless-network.h: New accessor functions to get and set the mode of a given network, wireless_network_get_mode() and wireless_network_set_mode(). git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1741 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
b428d9d8a2
commit
8b11dc086a
7 changed files with 86 additions and 32 deletions
14
ChangeLog
14
ChangeLog
|
|
@ -1,3 +1,17 @@
|
|||
2006-05-17 Robert Love <rml@novell.com>
|
||||
|
||||
Functionality to differentiate Ad-Hoc networks from infrastructure
|
||||
networks in the applet, by displaying a special icon:
|
||||
* gnome/applet/applet-dbus-devices.c: Set the mode for new networks.
|
||||
* gnome/applet/applet.c: Pass 'applet' to network_menu_item_update().
|
||||
* gnome/applet/menu-items.c: Set a special icon in the scan list for
|
||||
ad-hoc networks. TODO: Add a third icon representing "encrypted and
|
||||
Ad-Hoc". Right now, we display the same icon for all Ad-Hoc wireless
|
||||
networks, encrypted or not.
|
||||
* gnome/applet/wireless-network.c, gnome/applet/wireless-network.h: New
|
||||
accessor functions to get and set the mode of a given network,
|
||||
wireless_network_get_mode() and wireless_network_set_mode().
|
||||
|
||||
2006-05-17 Robert Love <rml@novell.com>
|
||||
|
||||
Functionality to automatically add BSSIDs to the allowed-MAC list as
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ void nma_dbus_update_nm_state (NMApplet *applet)
|
|||
|
||||
typedef struct DriverCBData
|
||||
{
|
||||
NMApplet * applet;
|
||||
NMApplet * applet;
|
||||
NetworkDevice * dev;
|
||||
} DriverCBData;
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ typedef struct DriverCBData
|
|||
static void nma_dbus_device_get_driver_cb (DBusPendingCall *pcall, void *user_data)
|
||||
{
|
||||
DBusMessage * reply;
|
||||
NMApplet * applet = (NMApplet *) user_data;
|
||||
NMApplet * applet = (NMApplet *) user_data;
|
||||
DriverCBData * data = (DriverCBData *) user_data;
|
||||
const char * driver;
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ out:
|
|||
/*
|
||||
* nma_dbus_device_get_driver
|
||||
*
|
||||
* Get the a device's driver name
|
||||
* Get the device's driver name
|
||||
*
|
||||
*/
|
||||
static void nma_dbus_device_get_driver (NetworkDevice *dev, NMApplet *applet)
|
||||
|
|
@ -607,6 +607,7 @@ static void nma_dbus_net_properties_cb (DBusPendingCall *pcall, void *user_data)
|
|||
network_device_remove_wireless_network (dev, tmp_net);
|
||||
}
|
||||
|
||||
wireless_network_set_mode (net, mode);
|
||||
wireless_network_set_capabilities (net, capabilities);
|
||||
wireless_network_set_strength (net, strength);
|
||||
if (act_net && strlen (act_net) && (strcmp (act_net, op) == 0))
|
||||
|
|
|
|||
|
|
@ -1585,6 +1585,7 @@ static void nma_add_networks_helper (NetworkDevice *dev, WirelessNetwork *net, g
|
|||
AddNetworksCB * cb_data = (AddNetworksCB *)user_data;
|
||||
NMNetworkMenuItem * item;
|
||||
GtkCheckMenuItem * gtk_item;
|
||||
NMApplet * applet;
|
||||
|
||||
g_return_if_fail (dev != NULL);
|
||||
g_return_if_fail (net != NULL);
|
||||
|
|
@ -1592,22 +1593,23 @@ static void nma_add_networks_helper (NetworkDevice *dev, WirelessNetwork *net, g
|
|||
g_return_if_fail (cb_data->menu != NULL);
|
||||
g_return_if_fail (cb_data->applet != NULL);
|
||||
|
||||
item = network_menu_item_new (cb_data->applet->encryption_size_group);
|
||||
applet = cb_data->applet;
|
||||
item = network_menu_item_new (applet->encryption_size_group);
|
||||
gtk_item = network_menu_item_get_check_item (item);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (cb_data->menu), GTK_WIDGET (gtk_item));
|
||||
if ( (cb_data->applet->nm_state == NM_STATE_CONNECTED)
|
||||
|| (cb_data->applet->nm_state == NM_STATE_CONNECTING))
|
||||
if ( (applet->nm_state == NM_STATE_CONNECTED)
|
||||
|| (applet->nm_state == NM_STATE_CONNECTING))
|
||||
{
|
||||
if (network_device_get_active (dev) && wireless_network_get_active (net))
|
||||
gtk_check_menu_item_set_active (gtk_item, TRUE);
|
||||
}
|
||||
network_menu_item_update (item, net, cb_data->has_encrypted);
|
||||
network_menu_item_update (applet, item, net, cb_data->has_encrypted);
|
||||
|
||||
g_object_set_data (G_OBJECT (gtk_item), "network", g_strdup (wireless_network_get_essid (net)));
|
||||
g_object_set_data (G_OBJECT (gtk_item), "device", g_strdup (network_device_get_nm_path (dev)));
|
||||
g_object_set_data (G_OBJECT (gtk_item), "nm-item-data", item);
|
||||
g_signal_connect (G_OBJECT (gtk_item), "activate", G_CALLBACK (nma_menu_item_activate), cb_data->applet);
|
||||
g_signal_connect (G_OBJECT (gtk_item), "activate", G_CALLBACK (nma_menu_item_activate), applet);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (gtk_item));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include <stdio.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <string.h>
|
||||
#include <iwlib.h>
|
||||
|
||||
#include "menu-items.h"
|
||||
#include "applet-dbus.h"
|
||||
|
|
@ -234,14 +235,16 @@ GtkCheckMenuItem *network_menu_item_get_check_item (NMNetworkMenuItem *item)
|
|||
}
|
||||
|
||||
|
||||
/* has_encrypted means that the wireless network has an encrypted
|
||||
/* is_encrypted means that the wireless network has an encrypted
|
||||
* area, and thus we need to allow for spacing.
|
||||
*/
|
||||
void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted)
|
||||
void network_menu_item_update (NMApplet *applet, NMNetworkMenuItem *item,
|
||||
WirelessNetwork *network, const gboolean is_encrypted)
|
||||
{
|
||||
char * display_essid;
|
||||
gdouble percent;
|
||||
int capabilities;
|
||||
gboolean encrypted = FALSE;
|
||||
gboolean adhoc = FALSE;
|
||||
|
||||
g_return_if_fail (item != NULL);
|
||||
g_return_if_fail (network != NULL);
|
||||
|
|
@ -256,10 +259,22 @@ void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network
|
|||
/* Deal with the encrypted icon */
|
||||
g_object_set (item->security_image, "visible", is_encrypted, NULL);
|
||||
|
||||
capabilities = wireless_network_get_capabilities (network);
|
||||
if ( (capabilities & NM_802_11_CAP_PROTO_WEP)
|
||||
|| (capabilities & NM_802_11_CAP_PROTO_WPA)
|
||||
|| (capabilities & NM_802_11_CAP_PROTO_WPA2))
|
||||
if (wireless_network_get_capabilities (network) & (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_PROTO_WPA2))
|
||||
encrypted = TRUE;
|
||||
|
||||
if (wireless_network_get_mode (network) == IW_MODE_ADHOC)
|
||||
adhoc = TRUE;
|
||||
|
||||
/*
|
||||
* Set a special icon for special circumstances: encrypted or ad-hoc.
|
||||
*
|
||||
* FIXME: We do not currently differentiate between encrypted and non-encrypted Ad-Hoc
|
||||
* networks; they all receive the same icon. Ideally, we should have a third icon
|
||||
* type for encrypted Ad-Hoc networks.
|
||||
*/
|
||||
if (adhoc)
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (item->security_image), applet->adhoc_icon);
|
||||
else if (encrypted)
|
||||
{
|
||||
/*
|
||||
* We want to use "network-wireless-encrypted," which was recently added to the icon spec,
|
||||
|
|
@ -267,7 +282,12 @@ void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network
|
|||
*
|
||||
* XXX: Would be nice to require gtk-2.6. For now, we have an ugly and a simple version.
|
||||
*/
|
||||
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
|
||||
#if GTK_CHECK_VERSION(2,6,0)
|
||||
if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), "network-wireless-encrypted"))
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "network-wireless-encrypted", GTK_ICON_SIZE_MENU);
|
||||
else
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "gnome-lockscreen", GTK_ICON_SIZE_MENU);
|
||||
# else
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkIconTheme *icon_theme;
|
||||
|
||||
|
|
@ -276,20 +296,13 @@ void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network
|
|||
if (!pixbuf)
|
||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, "gnome-lockscreen", GTK_ICON_SIZE_MENU, 0, NULL);
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (item->security_image), pixbuf);
|
||||
# else
|
||||
if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), "network-wireless-encrypted"))
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "network-wireless-encrypted", GTK_ICON_SIZE_MENU);
|
||||
else
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "gnome-lockscreen", GTK_ICON_SIZE_MENU);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
else /* neither encrypted nor Ad-Hoc */
|
||||
gtk_image_set_from_stock (GTK_IMAGE (item->security_image), NULL, GTK_ICON_SIZE_MENU);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Utility stuff
|
||||
****************************************************************/
|
||||
|
|
@ -299,34 +312,34 @@ void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network
|
|||
static char *eel_make_valid_utf8 (const char *name)
|
||||
{
|
||||
GString *string;
|
||||
const char *remainder, *invalid;
|
||||
const char *rem, *invalid;
|
||||
int remaining_bytes, valid_bytes;
|
||||
|
||||
string = NULL;
|
||||
remainder = name;
|
||||
rem = name;
|
||||
remaining_bytes = strlen (name);
|
||||
|
||||
while (remaining_bytes != 0) {
|
||||
if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
|
||||
if (g_utf8_validate (rem, remaining_bytes, &invalid)) {
|
||||
break;
|
||||
}
|
||||
valid_bytes = invalid - remainder;
|
||||
valid_bytes = invalid - rem;
|
||||
|
||||
if (string == NULL) {
|
||||
string = g_string_sized_new (remaining_bytes);
|
||||
}
|
||||
g_string_append_len (string, remainder, valid_bytes);
|
||||
g_string_append_len (string, rem, valid_bytes);
|
||||
g_string_append_c (string, '?');
|
||||
|
||||
remaining_bytes -= valid_bytes + 1;
|
||||
remainder = invalid + 1;
|
||||
rem = invalid + 1;
|
||||
}
|
||||
|
||||
if (string == NULL) {
|
||||
return g_strdup (name);
|
||||
}
|
||||
|
||||
g_string_append (string, remainder);
|
||||
g_string_append (string, rem);
|
||||
g_string_append (string, _(" (invalid Unicode)"));
|
||||
g_assert (g_utf8_validate (string->str, -1, NULL));
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void wireless_menu_item_update (NMWirelessMenuItem *item, NetworkDevice *dev
|
|||
|
||||
NMNetworkMenuItem *network_menu_item_new (GtkSizeGroup *encryption_size_group);
|
||||
GtkCheckMenuItem *network_menu_item_get_check_item (NMNetworkMenuItem *item);
|
||||
void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted);
|
||||
void network_menu_item_update (NMApplet *applet, NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted);
|
||||
|
||||
/* Helper function; escapes an essid for human readable display. */
|
||||
char *nm_menu_network_escape_essid_for_display (const char *essid);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
|
||||
#include <glib.h>
|
||||
#include <iwlib.h>
|
||||
|
||||
#include "wireless-network.h"
|
||||
|
||||
/*
|
||||
|
|
@ -35,6 +37,7 @@ struct WirelessNetwork
|
|||
char * essid;
|
||||
gboolean active;
|
||||
gint8 strength;
|
||||
int mode;
|
||||
int capabilities;
|
||||
};
|
||||
|
||||
|
|
@ -172,6 +175,24 @@ void wireless_network_set_capabilities (WirelessNetwork *net, int capabilities)
|
|||
net->capabilities = capabilities;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accessors for mode
|
||||
*/
|
||||
int wireless_network_get_mode (WirelessNetwork *net)
|
||||
{
|
||||
g_return_val_if_fail (net != NULL, FALSE);
|
||||
|
||||
return net->mode;
|
||||
}
|
||||
|
||||
void wireless_network_set_mode (WirelessNetwork *net, int mode)
|
||||
{
|
||||
g_return_if_fail (net != NULL);
|
||||
g_return_if_fail ((mode == IW_MODE_ADHOC) || (mode == IW_MODE_INFRA));
|
||||
|
||||
net->mode = mode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accessors for strength
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ const char * wireless_network_get_nm_path (WirelessNetwork *net);
|
|||
int wireless_network_get_capabilities (WirelessNetwork *net);
|
||||
void wireless_network_set_capabilities (WirelessNetwork *net, int capabilities);
|
||||
|
||||
int wireless_network_get_mode (WirelessNetwork *net);
|
||||
void wireless_network_set_mode (WirelessNetwork *net, int mode);
|
||||
|
||||
gint8 wireless_network_get_strength (WirelessNetwork *net);
|
||||
void wireless_network_set_strength (WirelessNetwork *net, gint8 strength);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue