2006-01-06 Robert Love <rml@novell.com>
* gnome/applet/applet-dbus-devices.c, gnome/applet/applet.c, gnome/applet/applet-dbus-devices.h, src/nm-dbus-nm.c: Remove global hangup code and add per-device hangup. Tie last commit into the GNOME applet. TODO: Save, understand, and respond to the state of each dialup device. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1273 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2006-01-06 Robert Love <rml@novell.com>
|
||||||
|
|
||||||
|
* gnome/applet/applet-dbus-devices.c, gnome/applet/applet.c,
|
||||||
|
gnome/applet/applet-dbus-devices.h, src/nm-dbus-nm.c: Remove global
|
||||||
|
hangup code and add per-device hangup. Tie last commit into the
|
||||||
|
GNOME applet. TODO: Save, understand, and respond to the state of
|
||||||
|
each dialup device.
|
||||||
|
|
||||||
2006-01-06 Robert Love <rml@novell.com>
|
2006-01-06 Robert Love <rml@novell.com>
|
||||||
|
|
||||||
Patch by Timo Hoenig <thoenig@suse.de>:
|
Patch by Timo Hoenig <thoenig@suse.de>:
|
||||||
|
@@ -1022,25 +1022,43 @@ void nmwa_dbus_dialup_activate_connection (NMWirelessApplet *applet, const char
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmwa_dbus_dialup_hangup_connections
|
* nmwa_dbus_dialup_activate_connection
|
||||||
*
|
*
|
||||||
* Tell NetworkManager to activate a particular dialup connection.
|
* Tell NetworkManager to activate a particular dialup connection.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void nmwa_dbus_dialup_hangup_connections (NMWirelessApplet *applet)
|
void nmwa_dbus_dialup_deactivate_connection (NMWirelessApplet *applet, const char *name)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "hangupDialup")))
|
g_return_if_fail (name != NULL);
|
||||||
{
|
|
||||||
nm_info ("Hanging up dialup connections ...");
|
|
||||||
|
|
||||||
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "deactivateDialup")))
|
||||||
|
{
|
||||||
|
|
||||||
|
nm_info ("Deactivating dialup connection '%s'.", name);
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
DBusMessageIter iter;
|
||||||
|
DBusMessageIter iter_array;
|
||||||
|
dbus_message_iter_init_append (message, &iter);
|
||||||
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &name);
|
||||||
|
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &iter_array);
|
||||||
|
|
||||||
|
for (i = passwords; i != NULL; i = g_slist_next (i)) {
|
||||||
|
dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_STRING, &(i->data));
|
||||||
|
}
|
||||||
|
dbus_message_iter_close_container (&iter, &iter_array);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dbus_message_append_args (message, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
|
||||||
if (!dbus_connection_send (applet->connection, message, NULL))
|
if (!dbus_connection_send (applet->connection, message, NULL))
|
||||||
nm_warning ("nmwa_dbus_dialup_hangup_connections(): Could not send hangupDialup message!");
|
nm_warning ("nmwa_dbus_dialup_deactivate_connection(): Could not send deactivateDialup message!");
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nm_warning ("nmwa_dbus_dialup_hangup_connections(): Couldn't allocate the dbus message!");
|
nm_warning ("nmwa_dbus_dialup_deactivate_connection(): Couldn't allocate the dbus message!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ void nmwa_dbus_update_nm_state (NMWirelessApplet *applet);
|
|||||||
void nmwa_dbus_update_devices (NMWirelessApplet *applet);
|
void nmwa_dbus_update_devices (NMWirelessApplet *applet);
|
||||||
void nmwa_dbus_update_dialup (NMWirelessApplet *applet);
|
void nmwa_dbus_update_dialup (NMWirelessApplet *applet);
|
||||||
void nmwa_dbus_dialup_activate_connection (NMWirelessApplet *applet, const char *name);
|
void nmwa_dbus_dialup_activate_connection (NMWirelessApplet *applet, const char *name);
|
||||||
void nmwa_dbus_dialup_hangup_connections (NMWirelessApplet *applet);
|
void nmwa_dbus_dialup_deactivate_connection (NMWirelessApplet *applet, const char *name);
|
||||||
void nmwa_dbus_device_update_one_device (NMWirelessApplet *applet, const char *dev_path);
|
void nmwa_dbus_device_update_one_device (NMWirelessApplet *applet, const char *dev_path);
|
||||||
void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const char *dev_path);
|
void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const char *dev_path);
|
||||||
|
|
||||||
|
@@ -1358,12 +1358,12 @@ static void nmwa_menu_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmwa_menu_dialup_item_activate
|
* nmwa_menu_connect_item_activate
|
||||||
*
|
*
|
||||||
* Signal function called when user clicks on a dialup menu item
|
* Signal function called when user clicks on a dialup menu item
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void nmwa_menu_dialup_item_activate (GtkMenuItem *item, gpointer user_data)
|
static void nmwa_menu_dialup_connect_item_activate (GtkMenuItem *item, gpointer user_data)
|
||||||
{
|
{
|
||||||
NMWirelessApplet *applet = (NMWirelessApplet *) user_data;
|
NMWirelessApplet *applet = (NMWirelessApplet *) user_data;
|
||||||
const char *dialup;
|
const char *dialup;
|
||||||
@@ -1387,7 +1387,7 @@ static void nmwa_menu_dialup_item_activate (GtkMenuItem *item, gpointer user_dat
|
|||||||
* Signal function called when user clicks on a dialup menu item
|
* Signal function called when user clicks on a dialup menu item
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void nmwa_menu_dialup_hangup_activate (GtkMenuItem *item, gpointer user_data)
|
static void nmwa_menu_dialup_disconnect_item_activate (GtkMenuItem *item, gpointer user_data)
|
||||||
{
|
{
|
||||||
NMWirelessApplet *applet = (NMWirelessApplet *) user_data;
|
NMWirelessApplet *applet = (NMWirelessApplet *) user_data;
|
||||||
const char *dialup;
|
const char *dialup;
|
||||||
@@ -1395,7 +1395,11 @@ static void nmwa_menu_dialup_hangup_activate (GtkMenuItem *item, gpointer user_d
|
|||||||
g_return_if_fail (item != NULL);
|
g_return_if_fail (item != NULL);
|
||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
nmwa_dbus_dialup_hangup_connections (applet);
|
dialup = g_object_get_data (G_OBJECT (item), "dialup");
|
||||||
|
if (!dialup)
|
||||||
|
return;
|
||||||
|
|
||||||
|
nmwa_dbus_dialup_deactivate_connection (applet, dialup);
|
||||||
|
|
||||||
nmi_dbus_signal_user_interface_activated (applet->connection);
|
nmi_dbus_signal_user_interface_activated (applet->connection);
|
||||||
}
|
}
|
||||||
@@ -1751,22 +1755,25 @@ static void nmwa_menu_add_dialup_menu (GtkWidget *menu, NMWirelessApplet *applet
|
|||||||
dialup_menu = GTK_MENU (gtk_menu_new ());
|
dialup_menu = GTK_MENU (gtk_menu_new ());
|
||||||
for (elt = applet->dialup_list; elt; elt = g_slist_next (elt))
|
for (elt = applet->dialup_list; elt; elt = g_slist_next (elt))
|
||||||
{
|
{
|
||||||
GtkMenuItem *dialup_item;
|
GtkMenuItem *connect_item, *disconnect_item;
|
||||||
char *name = elt->data;
|
char *name = elt->data;
|
||||||
const char *label;
|
const char *label;
|
||||||
|
|
||||||
|
/* FIXME: We should save and then check the state of the devices and show Connect _or_ Disconnect for each item */
|
||||||
|
|
||||||
label = g_strdup_printf (_("Connect to %s..."), name);
|
label = g_strdup_printf (_("Connect to %s..."), name);
|
||||||
dialup_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (label));
|
connect_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (label));
|
||||||
g_object_set_data (G_OBJECT (dialup_item), "dialup", name);
|
g_object_set_data (G_OBJECT (connect_item), "dialup", name);
|
||||||
|
g_signal_connect (G_OBJECT (connect_item), "activate", G_CALLBACK (nmwa_menu_dialup_connect_item_activate), applet);
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), GTK_WIDGET (connect_item));
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialup_item), "activate", G_CALLBACK (nmwa_menu_dialup_item_activate), applet);
|
label = g_strdup_printf (_("Disconnect from %s..."), name);
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), GTK_WIDGET (dialup_item));
|
disconnect_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (label));
|
||||||
|
g_object_set_data (G_OBJECT (disconnect_item), "dialup", name);
|
||||||
|
g_signal_connect (G_OBJECT (disconnect_item), "activate", G_CALLBACK (nmwa_menu_dialup_disconnect_item_activate), applet);
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), GTK_WIDGET (disconnect_item));
|
||||||
}
|
}
|
||||||
|
|
||||||
hangup_item = gtk_menu_item_new_with_mnemonic (_("_Hangup Connections..."));
|
|
||||||
g_signal_connect (G_OBJECT (hangup_item), "activate", G_CALLBACK (nmwa_menu_dialup_hangup_activate), NULL);
|
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), hangup_item);
|
|
||||||
|
|
||||||
gtk_menu_item_set_submenu (item, GTK_WIDGET (dialup_menu));
|
gtk_menu_item_set_submenu (item, GTK_WIDGET (dialup_menu));
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
|
||||||
gtk_widget_show_all (GTK_WIDGET (item));
|
gtk_widget_show_all (GTK_WIDGET (item));
|
||||||
|
@@ -210,31 +210,6 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DBusMessage *nm_dbus_nm_hangup_dialup (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
|
|
||||||
{
|
|
||||||
DBusMessage *reply = NULL;
|
|
||||||
NMData *nm_data = (NMData *) data->data;
|
|
||||||
const char *dialup;
|
|
||||||
|
|
||||||
g_return_val_if_fail (data != NULL, NULL);
|
|
||||||
g_return_val_if_fail (data->data != NULL, NULL);
|
|
||||||
g_return_val_if_fail (connection != NULL, NULL);
|
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
|
||||||
|
|
||||||
reply = dbus_message_new_method_return (message);
|
|
||||||
if (!reply)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
nm_lock_mutex (nm_data->dialup_list_mutex, __FUNCTION__);
|
|
||||||
nm_system_deactivate_all_dialup (nm_data->dialup_list);
|
|
||||||
nm_unlock_mutex (nm_data->dialup_list_mutex, __FUNCTION__);
|
|
||||||
|
|
||||||
out:
|
|
||||||
return reply;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_dbus_nm_set_active_device
|
* nm_dbus_nm_set_active_device
|
||||||
*
|
*
|
||||||
@@ -645,7 +620,6 @@ NMDbusMethodList *nm_dbus_nm_methods_setup (void)
|
|||||||
nm_dbus_method_list_add_method (list, "getDialup", nm_dbus_nm_get_dialup);
|
nm_dbus_method_list_add_method (list, "getDialup", nm_dbus_nm_get_dialup);
|
||||||
nm_dbus_method_list_add_method (list, "activateDialup", nm_dbus_nm_activate_dialup);
|
nm_dbus_method_list_add_method (list, "activateDialup", nm_dbus_nm_activate_dialup);
|
||||||
nm_dbus_method_list_add_method (list, "deactivateDialup", nm_dbus_nm_deactivate_dialup);
|
nm_dbus_method_list_add_method (list, "deactivateDialup", nm_dbus_nm_deactivate_dialup);
|
||||||
nm_dbus_method_list_add_method (list, "hangupDialup", nm_dbus_nm_hangup_dialup);
|
|
||||||
nm_dbus_method_list_add_method (list, "setActiveDevice", nm_dbus_nm_set_active_device);
|
nm_dbus_method_list_add_method (list, "setActiveDevice", nm_dbus_nm_set_active_device);
|
||||||
nm_dbus_method_list_add_method (list, "createWirelessNetwork", nm_dbus_nm_create_wireless_network);
|
nm_dbus_method_list_add_method (list, "createWirelessNetwork", nm_dbus_nm_create_wireless_network);
|
||||||
nm_dbus_method_list_add_method (list, "setWirelessEnabled", nm_dbus_nm_set_wireless_enabled);
|
nm_dbus_method_list_add_method (list, "setWirelessEnabled", nm_dbus_nm_set_wireless_enabled);
|
||||||
|
Reference in New Issue
Block a user