mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 13:40:39 +01:00
2006-01-10 Robert Love <rml@novell.com>
* gnome/applet/applet-dbus-devices.c, gnome/applet/applet-dbus.h, gnome/applet/applet.c, gnome/applet/applet.h: Add 'Enable Networking' option to give users ability to globally disconnect and put NM to sleep. This is useful as a 'lockdown mode' for flying, security, and clean disconnect. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1308 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
16ca3c9055
commit
5f10fc0638
5 changed files with 89 additions and 7 deletions
|
|
@ -1,3 +1,11 @@
|
|||
2006-01-10 Robert Love <rml@novell.com>
|
||||
|
||||
* gnome/applet/applet-dbus-devices.c, gnome/applet/applet-dbus.h,
|
||||
gnome/applet/applet.c, gnome/applet/applet.h: Add 'Enable Networking'
|
||||
option to give users ability to globally disconnect and put NM to
|
||||
sleep. This is useful as a 'lockdown mode' for flying, security, and
|
||||
clean disconnect.
|
||||
|
||||
2006-01-09 Robert Love <rml@novell.com>
|
||||
|
||||
* src/nm-device-802-3-ethernet.h: The kernel headers <linux/mii.h> and
|
||||
|
|
|
|||
|
|
@ -66,8 +66,10 @@ static void nmwa_dbus_nm_state_cb (DBusPendingCall *pcall, void *user_data)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &nm_state, DBUS_TYPE_INVALID))
|
||||
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &nm_state, DBUS_TYPE_INVALID)) {
|
||||
applet->nm_state = nm_state;
|
||||
nmwa_enable_networking_set_active (applet);
|
||||
}
|
||||
|
||||
dbus_message_unref (reply);
|
||||
|
||||
|
|
@ -1212,6 +1214,33 @@ void nmwa_dbus_enable_wireless (NMWirelessApplet *applet, gboolean enabled)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* nmwa_dbus_enable_networking
|
||||
*
|
||||
* Tell NetworkManager to enabled or disable all wireless devices.
|
||||
*
|
||||
*/
|
||||
void nmwa_dbus_enable_networking (NMWirelessApplet *applet, gboolean enabled)
|
||||
{
|
||||
DBusMessage *message;
|
||||
const char *method;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
g_return_if_fail (applet->connection != NULL);
|
||||
|
||||
if (enabled)
|
||||
method = "wake";
|
||||
else
|
||||
method = "sleep";
|
||||
|
||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, method)))
|
||||
{
|
||||
dbus_connection_send (applet->connection, message, NULL);
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nmwa_dbus_update_strength (NMWirelessApplet *applet, const char *dev_path, const char *net_path, int strength)
|
||||
{
|
||||
NetworkDevice *dev;
|
||||
|
|
|
|||
|
|
@ -43,11 +43,8 @@ static inline gboolean message_is_error (DBusMessage *msg)
|
|||
}
|
||||
|
||||
void nmwa_dbus_init_helper (NMWirelessApplet *applet);
|
||||
|
||||
void nmwa_dbus_enable_scanning (NMWirelessApplet *applet, gboolean enabled);
|
||||
|
||||
void nmwa_dbus_enable_wireless (NMWirelessApplet *applet, gboolean enabled);
|
||||
|
||||
void nmwa_dbus_enable_networking (NMWirelessApplet *applet, gboolean enabled);
|
||||
void nmwa_free_gui_data_model (NMWirelessApplet *applet);
|
||||
void nmwa_free_dbus_data_model (NMWirelessApplet *applet);
|
||||
|
||||
|
|
|
|||
|
|
@ -1096,12 +1096,18 @@ static void nmwa_update_state (NMWirelessApplet *applet)
|
|||
goto done;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!act_dev)
|
||||
applet->nm_state = NM_STATE_DISCONNECTED;
|
||||
#endif
|
||||
|
||||
switch (applet->nm_state)
|
||||
{
|
||||
case NM_STATE_ASLEEP:
|
||||
pixbuf = applet->no_connection_icon;
|
||||
tip = g_strdup (_("Networking disabled"));
|
||||
break;
|
||||
|
||||
case NM_STATE_DISCONNECTED:
|
||||
pixbuf = applet->no_connection_icon;
|
||||
tip = g_strdup (_("No network connection"));
|
||||
|
|
@ -1828,6 +1834,12 @@ static void nmwa_menu_add_devices (GtkWidget *menu, NMWirelessApplet *applet)
|
|||
return;
|
||||
}
|
||||
|
||||
if (applet->nm_state == NM_STATE_ASLEEP)
|
||||
{
|
||||
nmwa_menu_add_text_item (menu, _("Networking disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
for (element = applet->device_list; element; element = element->next)
|
||||
{
|
||||
NetworkDevice *dev = (NetworkDevice *)(element->data);
|
||||
|
|
@ -1920,6 +1932,18 @@ static void nmwa_set_wireless_enabled_cb (GtkWidget *widget, NMWirelessApplet *a
|
|||
}
|
||||
|
||||
|
||||
static void nmwa_set_networking_enabled_cb (GtkWidget *widget, NMWirelessApplet *applet)
|
||||
{
|
||||
gboolean state;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
||||
state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
|
||||
if ((applet->nm_state == NM_STATE_ASLEEP && state) || (applet->nm_state != NM_STATE_ASLEEP && !state))
|
||||
nmwa_dbus_enable_networking (applet, state);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_menu_item_data_free
|
||||
*
|
||||
|
|
@ -2087,12 +2111,13 @@ static void nmwa_context_menu_update (NMWirelessApplet *applet)
|
|||
}
|
||||
}
|
||||
|
||||
if (have_wireless)
|
||||
if (have_wireless && applet->nm_state != NM_STATE_ASLEEP)
|
||||
gtk_widget_show_all (applet->stop_wireless_item);
|
||||
else
|
||||
gtk_widget_hide (applet->stop_wireless_item);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_enable_wireless_set_active
|
||||
*
|
||||
|
|
@ -2106,6 +2131,21 @@ void nmwa_enable_wireless_set_active (NMWirelessApplet *applet)
|
|||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->stop_wireless_item), applet->wireless_enabled);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_enable_networking_set_active
|
||||
*
|
||||
* Set the 'Enable Networking' menu item state to match the daemon's last DBUS
|
||||
* message. We cannot just do this at menu creation time because the DBUS
|
||||
* message might not have been sent yet or in case the daemon state changes
|
||||
* out from under us.
|
||||
*/
|
||||
void nmwa_enable_networking_set_active (NMWirelessApplet *applet)
|
||||
{
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->enable_networking_item), applet->nm_state != NM_STATE_ASLEEP);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_context_menu_create
|
||||
*
|
||||
|
|
@ -2122,6 +2162,12 @@ static GtkWidget *nmwa_context_menu_create (NMWirelessApplet *applet)
|
|||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
/* 'Enable Networking' item */
|
||||
applet->enable_networking_item = gtk_check_menu_item_new_with_mnemonic (_("Enable _Networking"));
|
||||
nmwa_enable_networking_set_active (applet);
|
||||
g_signal_connect (G_OBJECT (applet->enable_networking_item), "toggled", G_CALLBACK (nmwa_set_networking_enabled_cb), applet);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), applet->enable_networking_item);
|
||||
|
||||
/* 'Enable Wireless' item */
|
||||
applet->stop_wireless_item = gtk_check_menu_item_new_with_mnemonic (_("Enable _Wireless"));
|
||||
nmwa_enable_wireless_set_active (applet);
|
||||
|
|
@ -2444,7 +2490,6 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
|
|||
applet->nm_state = NM_STATE_DISCONNECTED;
|
||||
applet->tooltips = NULL;
|
||||
applet->passphrase_dialog = NULL;
|
||||
|
||||
applet->glade_file = g_build_filename (GLADEDIR, "wireless-applet.glade", NULL);
|
||||
if (!applet->glade_file || !g_file_test (applet->glade_file, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ typedef struct
|
|||
GtkTooltips * tooltips;
|
||||
|
||||
GtkWidget * context_menu;
|
||||
GtkWidget * enable_networking_item;
|
||||
GtkWidget * stop_wireless_item;
|
||||
GtkWidget * info_menu_item;
|
||||
|
||||
|
|
@ -148,6 +149,8 @@ VPNConnection * nmwa_get_first_active_vpn_connection (NMWirelessApplet *applet);
|
|||
|
||||
void nmwa_enable_wireless_set_active (NMWirelessApplet *applet);
|
||||
|
||||
void nmwa_enable_networking_set_active (NMWirelessApplet *applet);
|
||||
|
||||
int nm_null_safe_strcmp (const char *s1, const char *s2);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue