From 76ef803caf8e474badabb71df485896853dc3ed8 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 27 Jul 2005 06:32:31 +0000 Subject: [PATCH] 2005-07-27 Dan Williams * src/nm-dbus-nm.c src/nm-dbus-net.c - Random cleanups of spacing * gnome/applet/applet.h gnome/applet/other-network-dialog.c gnome/applet/passphrase-dialog.c - Conslidate usage of NMWAEncryptionKeyTypes enum Patch from Bill Moss: - Make Other Wireless Networks work again with encryption keys git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@814 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 14 ++++++++++++ gnome/applet/applet-dbus-devices.c | 6 ++--- gnome/applet/applet-dbus-info.c | 5 +++-- gnome/applet/applet-dbus-info.h | 3 ++- gnome/applet/applet.h | 8 +++++++ gnome/applet/other-network-dialog.c | 7 +----- gnome/applet/passphrase-dialog.c | 15 +++---------- src/nm-dbus-net.c | 8 +++---- src/nm-dbus-nm.c | 35 +++++++++++++++-------------- 9 files changed, 56 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f0b15e7f1..80a789de20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-07-27 Dan Williams + + * src/nm-dbus-nm.c + src/nm-dbus-net.c + - Random cleanups of spacing + + * gnome/applet/applet.h + gnome/applet/other-network-dialog.c + gnome/applet/passphrase-dialog.c + - Conslidate usage of NMWAEncryptionKeyTypes enum + + Patch from Bill Moss: + - Make Other Wireless Networks work again with encryption keys + 2005-07-26 Dan Williams Patch from Steev : diff --git a/gnome/applet/applet-dbus-devices.c b/gnome/applet/applet-dbus-devices.c index b9dd9fca25..293d0ab5a5 100644 --- a/gnome/applet/applet-dbus-devices.c +++ b/gnome/applet/applet-dbus-devices.c @@ -988,7 +988,7 @@ void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const char *d * */ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, - NMEncKeyType key_type, const char *passphrase) + const NMEncKeyType key_type, const char *passphrase) { DBusMessage *message; @@ -1001,7 +1001,7 @@ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const if (network_device_is_wireless (dev) && essid) { - nm_info ("Forcing device '%s' and network '%s' %s passphrase\n", dev_path, essid, passphrase ? "with" : "without"); + int tmp_key_type = (int)key_type; if (passphrase == NULL) passphrase = ""; @@ -1009,7 +1009,7 @@ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_STRING, &essid, DBUS_TYPE_STRING, &passphrase, - DBUS_TYPE_INT32, &key_type, + DBUS_TYPE_INT32, &tmp_key_type, DBUS_TYPE_INVALID); } else diff --git a/gnome/applet/applet-dbus-info.c b/gnome/applet/applet-dbus-info.c index 732b7402d4..c8cdb23a27 100644 --- a/gnome/applet/applet-dbus-info.c +++ b/gnome/applet/applet-dbus-info.c @@ -95,11 +95,12 @@ static DBusMessage * nmi_dbus_get_key_for_network (NMWirelessApplet *applet, DBu * Alert NetworkManager of the new user key * */ -void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const int key_type) +void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const NMEncKeyType key_type) { DBusMessage * reply; const char * dev_path; const char * net_path; + const int tmp_key_type = (int)key_type; g_return_if_fail (connection != NULL); g_return_if_fail (passphrase != NULL); @@ -110,7 +111,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, return; } - dbus_message_append_args (reply, DBUS_TYPE_STRING, &passphrase, DBUS_TYPE_INT32, &key_type, DBUS_TYPE_INVALID); + dbus_message_append_args (reply, DBUS_TYPE_STRING, &passphrase, DBUS_TYPE_INT32, &tmp_key_type, DBUS_TYPE_INVALID); dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); } diff --git a/gnome/applet/applet-dbus-info.h b/gnome/applet/applet-dbus-info.h index a550ae4bbc..4caae11902 100644 --- a/gnome/applet/applet-dbus-info.h +++ b/gnome/applet/applet-dbus-info.h @@ -26,10 +26,11 @@ #include #include "nm-device.h" #include "wireless-network.h" +#include "NetworkManager.h" DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBusMessage *message, void *user_data); -void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const int key_type); +void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const NMEncKeyType key_type); void nmi_dbus_signal_update_scan_method (DBusConnection *connection); diff --git a/gnome/applet/applet.h b/gnome/applet/applet.h index 4bdff70f0d..94a3826058 100644 --- a/gnome/applet/applet.h +++ b/gnome/applet/applet.h @@ -45,6 +45,14 @@ typedef struct VPNConnection VPNConnection; +enum NMWAEncryptionKeyTypes +{ + KEY_TYPE_128_BIT_PASSPHRASE = 0, + KEY_TYPE_ASCII_KEY = 1, + KEY_TYPE_HEX_KEY = 2 +}; + + #define NM_TYPE_WIRELESS_APPLET (nmwa_get_type()) #define NM_WIRELESS_APPLET(object) (G_TYPE_CHECK_INSTANCE_CAST((object), NM_TYPE_WIRELESS_APPLET, NMWirelessApplet)) #define NM_WIRELESS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_WIRELESS_APPLET, NMWirelessAppletClass)) diff --git a/gnome/applet/other-network-dialog.c b/gnome/applet/other-network-dialog.c index 769a7ee08a..13dbe7b0ef 100644 --- a/gnome/applet/other-network-dialog.c +++ b/gnome/applet/other-network-dialog.c @@ -43,12 +43,6 @@ #include "applet-dbus-devices.h" #include "other-network-dialog.h" -enum NMWAEncryptionKeyTypes -{ - KEY_TYPE_128_BIT_PASSPHRASE = 0, - KEY_TYPE_ASCII_KEY = 1, - KEY_TYPE_HEX_KEY = 2 -}; static void update_button_cb (GtkWidget *widget, GladeXML *xml) { @@ -217,6 +211,7 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple essid_entry = glade_xml_get_widget (xml, "essid_entry"); button = glade_xml_get_widget (xml, "ok_button"); + gtk_widget_grab_default (GTK_WIDGET (button)); gtk_widget_grab_focus (essid_entry); gtk_entry_set_text (GTK_ENTRY (essid_entry), ""); diff --git a/gnome/applet/passphrase-dialog.c b/gnome/applet/passphrase-dialog.c index 5d78e5a02a..1bcfa5dc49 100644 --- a/gnome/applet/passphrase-dialog.c +++ b/gnome/applet/passphrase-dialog.c @@ -36,14 +36,7 @@ #include "applet-dbus-info.h" #include "passphrase-dialog.h" #include "nm-utils.h" - -enum NMIPassphraseDialogKeyTypes -{ - KEY_TYPE_128_BIT_PASSPHRASE = 0, - KEY_TYPE_ASCII_KEY = 1, - KEY_TYPE_HEX_KEY = 2 -}; - +#include "NetworkManager.h" static GladeXML *get_dialog_xml (GtkWidget *dialog) { @@ -194,13 +187,12 @@ static void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer use GladeXML * dialog_xml; GtkEntry * entry; GtkComboBox * key_type_combo; - int key_type; const char * passphrase; NetworkDevice * dev = g_object_get_data (G_OBJECT (dialog), "device"); WirelessNetwork * net = g_object_get_data (G_OBJECT (dialog), "network"); DBusMessage * message = g_object_get_data (G_OBJECT (dialog), "dbus-message"); char * key = NULL; - int key_type_return = NM_ENC_TYPE_UNKNOWN; + NMEncKeyType key_type_return = NM_ENC_TYPE_UNKNOWN; GConfEntry * gconf_entry; char * escaped_network; @@ -208,10 +200,9 @@ static void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer use entry = GTK_ENTRY (glade_xml_get_widget (dialog_xml, "passphrase_entry")); key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (dialog_xml, "key_type_combo")); - key_type = gtk_combo_box_get_active (key_type_combo); passphrase = gtk_entry_get_text (entry); - switch (key_type) + switch (gtk_combo_box_get_active (key_type_combo)) { case KEY_TYPE_128_BIT_PASSPHRASE: key_type_return = NM_ENC_TYPE_128_BIT_PASSPHRASE; diff --git a/src/nm-dbus-net.c b/src/nm-dbus-net.c index 4ff3807eea..efb2dd1cd3 100644 --- a/src/nm-dbus-net.c +++ b/src/nm-dbus-net.c @@ -102,11 +102,11 @@ static DBusMessage *nm_dbus_net_get_name (DBusConnection *connection, DBusMessag g_return_val_if_fail (data && data->data && data->dev && data->ap && connection && message, NULL); - if ((reply = dbus_message_new_method_return (message))) { - const char *essid; - essid = nm_ap_get_essid (data->ap); + if ((reply = dbus_message_new_method_return (message))) + { + const char *essid = nm_ap_get_essid (data->ap); dbus_message_append_args (reply, DBUS_TYPE_STRING, &essid, DBUS_TYPE_INVALID); - } + } return reply; } diff --git a/src/nm-dbus-nm.c b/src/nm-dbus-nm.c index 36c964a4dd..76373f5ff0 100644 --- a/src/nm-dbus-nm.c +++ b/src/nm-dbus-nm.c @@ -31,6 +31,7 @@ #include "NetworkManagerDbusUtils.h" #include "NetworkManagerUtils.h" #include "NetworkManagerPolicy.h" +#include "NetworkManager.h" /* @@ -117,9 +118,9 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB NMDevice * dev = NULL; DBusMessage * reply = NULL; char * dev_path = NULL; - const char * essid = NULL; - const char * key = NULL; - const int key_type = -1; + char * essid = NULL; + char * key = NULL; + int key_type = -1; NMActRequest * req = NULL; NMAccessPoint * ap = NULL; @@ -167,7 +168,7 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB nm_schedule_state_change_signal_broadcast (data->data); if (nm_device_is_wireless (dev)) - ap = nm_device_wireless_get_activation_ap (dev, essid, key, key_type); + ap = nm_device_wireless_get_activation_ap (dev, essid, key, (NMEncKeyType)key_type); nm_policy_schedule_device_activation (nm_act_request_new (data->data, dev, ap, TRUE)); out: @@ -182,14 +183,14 @@ out: */ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data) { - NMDevice *dev = NULL; - DBusMessage *reply = NULL; - char *dev_path = NULL; - NMAccessPoint *new_ap = NULL; - char *network = NULL; - char *key = NULL; - int key_type = -1; - DBusError error; + NMDevice * dev = NULL; + DBusMessage * reply = NULL; + char * dev_path = NULL; + NMAccessPoint * new_ap = NULL; + char * network = NULL; + char * key = NULL; + int key_type = -1; + DBusError error; g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (message != NULL, NULL); @@ -205,7 +206,7 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti { reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "InvalidArguments", "NetworkManager::createWirelessNetwork called with invalid arguments."); - return (reply); + return reply; } else nm_info ("Creating network '%s' on device '%s'.", network, dev_path); dev_path = nm_dbus_unescape_object_path (dev_path); @@ -215,7 +216,7 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti { reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound", "The requested network device does not exist."); - return (reply); + return reply; } nm_device_ref (dev); @@ -231,10 +232,10 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti /* Fill in the description of the network to create */ nm_ap_set_essid (new_ap, network); - if (nm_is_enc_key_valid (key, key_type)) + if (nm_is_enc_key_valid (key, (NMEncKeyType)key_type)) { nm_ap_set_encrypted (new_ap, TRUE); - nm_ap_set_enc_key_source (new_ap, key, key_type); + nm_ap_set_enc_key_source (new_ap, key, (NMEncKeyType)key_type); nm_ap_set_auth_method (new_ap, NM_DEVICE_AUTH_METHOD_OPEN_SYSTEM); } nm_ap_set_mode (new_ap, NETWORK_MODE_ADHOC); @@ -244,7 +245,7 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti out: nm_device_unref (dev); - return (reply); + return reply; }