mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 03:30:14 +01:00
2005-12-12 Dan Williams <dcbw@redhat.com>
* libnm-util/dbus-helpers.[ch] libnm-util/Makefile.am - new helper calls to consolidate locations where NM's setDevice method is called * gnome/applet/applet-dbus-devices.c gnome/applet/wireless-security-option.c gnome/applet/wso-* - Implement dbus message param append function for all wireless security options git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1174 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
702cb0a500
commit
e8a0e3c5d7
10 changed files with 242 additions and 15 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
|||
2005-12-12 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-util/dbus-helpers.[ch]
|
||||
libnm-util/Makefile.am
|
||||
- new helper calls to consolidate locations where
|
||||
NM's setDevice method is called
|
||||
|
||||
* gnome/applet/applet-dbus-devices.c
|
||||
gnome/applet/wireless-security-option.c
|
||||
gnome/applet/wso-*
|
||||
- Implement dbus message param append function for
|
||||
all wireless security options
|
||||
|
||||
2005-12-12 Robert Love <rml@novell.com>
|
||||
|
||||
* libnm-util/cipher-wep-passphrase.c,
|
||||
|
|
|
|||
|
|
@ -1071,7 +1071,8 @@ void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const char *d
|
|||
void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid,
|
||||
WirelessSecurityOption * opt)
|
||||
{
|
||||
DBusMessage *message;
|
||||
DBusMessage * message;
|
||||
gboolean success = TRUE;
|
||||
|
||||
g_return_if_fail (connection != NULL);
|
||||
g_return_if_fail (dev != NULL);
|
||||
|
|
@ -1091,14 +1092,15 @@ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const
|
|||
|
||||
/* If we've got specific wireless security options, add them */
|
||||
if (opt)
|
||||
wso_append_dbus_params (opt, essid, message);
|
||||
success = wso_append_dbus_params (opt, essid, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
nm_info ("Forcing device '%s'\n", network_device_get_nm_path (dev));
|
||||
dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID);
|
||||
}
|
||||
dbus_connection_send (connection, message, NULL);
|
||||
// if (success)
|
||||
// dbus_connection_send (connection, message, NULL);
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, con
|
|||
g_return_val_if_fail (ssid != NULL, FALSE);
|
||||
|
||||
if (out_cipher)
|
||||
g_return_val_if_fail (*out_cipher != NULL, FALSE);
|
||||
g_return_val_if_fail (*out_cipher == NULL, FALSE);
|
||||
|
||||
/* Try each of our ciphers in turn, if one validates that's enough */
|
||||
for (elt = opt->ciphers; elt; elt = g_slist_next (elt))
|
||||
|
|
@ -118,7 +118,8 @@ gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, con
|
|||
IEEE_802_11_Cipher * cipher = (IEEE_802_11_Cipher *) (elt->data);
|
||||
if (ieee_802_11_cipher_validate (cipher, ssid, input) == 0)
|
||||
{
|
||||
*out_cipher = cipher;
|
||||
if (out_cipher)
|
||||
*out_cipher = cipher;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "wso-private.h"
|
||||
#include "cipher.h"
|
||||
#include "cipher-wep-ascii.h"
|
||||
#include "dbus-helpers.h"
|
||||
|
||||
|
||||
struct OptData
|
||||
|
|
@ -94,10 +95,8 @@ static gboolean append_dbus_params_func (WirelessSecurityOption *opt, const char
|
|||
IEEE_802_11_Cipher * cipher = NULL;
|
||||
GtkWidget * auth_combo;
|
||||
int auth_alg = -1;
|
||||
int we_cipher = -1;
|
||||
GtkWidget * entry;
|
||||
const char * input;
|
||||
char * hashed = NULL;
|
||||
|
||||
g_return_val_if_fail (opt != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data != NULL, FALSE);
|
||||
|
|
@ -112,11 +111,7 @@ static gboolean append_dbus_params_func (WirelessSecurityOption *opt, const char
|
|||
auth_combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name);
|
||||
auth_alg = wso_wep_auth_combo_get_auth_alg (opt, GTK_COMBO_BOX (auth_combo));
|
||||
|
||||
we_cipher = ieee_802_11_cipher_get_we_cipher (cipher);
|
||||
hashed = ieee_802_11_cipher_hash (cipher, ssid, input);
|
||||
|
||||
g_free (hashed);
|
||||
|
||||
nmu_dbus_message_append_wep_args (message, cipher, ssid, input, auth_alg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "wireless-security-option.h"
|
||||
#include "wso-wep-hex.h"
|
||||
#include "wso-private.h"
|
||||
#include "cipher.h"
|
||||
#include "cipher-wep-hex.h"
|
||||
#include "dbus-helpers.h"
|
||||
|
||||
|
||||
struct OptData
|
||||
|
|
@ -85,6 +87,32 @@ static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ss
|
|||
}
|
||||
|
||||
|
||||
static gboolean append_dbus_params_func (WirelessSecurityOption *opt, const char *ssid, DBusMessage *message)
|
||||
{
|
||||
IEEE_802_11_Cipher * cipher = NULL;
|
||||
GtkWidget * auth_combo;
|
||||
int auth_alg = -1;
|
||||
GtkWidget * entry;
|
||||
const char * input;
|
||||
|
||||
g_return_val_if_fail (opt != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data->auth_combo_name != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data->entry_name != NULL, FALSE);
|
||||
|
||||
entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name);
|
||||
input = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (!wso_validate_helper (opt, ssid, input, &cipher) || !cipher)
|
||||
return FALSE;
|
||||
|
||||
auth_combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name);
|
||||
auth_alg = wso_wep_auth_combo_get_auth_alg (opt, GTK_COMBO_BOX (auth_combo));
|
||||
|
||||
nmu_dbus_message_append_wep_args (message, cipher, ssid, input, auth_alg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
WirelessSecurityOption * wso_wep_hex_new (const char *glade_file)
|
||||
{
|
||||
WirelessSecurityOption * opt = NULL;
|
||||
|
|
@ -99,6 +127,7 @@ WirelessSecurityOption * wso_wep_hex_new (const char *glade_file)
|
|||
opt->data_free_func = data_free_func;
|
||||
opt->validate_input_func = validate_input_func;
|
||||
opt->widget_create_func = widget_create_func;
|
||||
opt->append_dbus_params_func = append_dbus_params_func;
|
||||
|
||||
if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "wireless-security-option.h"
|
||||
#include "wso-wep-passphrase.h"
|
||||
#include "wso-private.h"
|
||||
#include "cipher.h"
|
||||
#include "cipher-wep-passphrase.h"
|
||||
#include "dbus-helpers.h"
|
||||
|
||||
|
||||
struct OptData
|
||||
|
|
@ -85,6 +87,32 @@ static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ss
|
|||
}
|
||||
|
||||
|
||||
static gboolean append_dbus_params_func (WirelessSecurityOption *opt, const char *ssid, DBusMessage *message)
|
||||
{
|
||||
IEEE_802_11_Cipher * cipher = NULL;
|
||||
GtkWidget * auth_combo;
|
||||
int auth_alg = -1;
|
||||
GtkWidget * entry;
|
||||
const char * input;
|
||||
|
||||
g_return_val_if_fail (opt != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data->auth_combo_name != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data->entry_name != NULL, FALSE);
|
||||
|
||||
entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name);
|
||||
input = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (!wso_validate_helper (opt, ssid, input, &cipher) || !cipher)
|
||||
return FALSE;
|
||||
|
||||
auth_combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name);
|
||||
auth_alg = wso_wep_auth_combo_get_auth_alg (opt, GTK_COMBO_BOX (auth_combo));
|
||||
|
||||
nmu_dbus_message_append_wep_args (message, cipher, ssid, input, auth_alg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
WirelessSecurityOption * wso_wep_passphrase_new (const char *glade_file)
|
||||
{
|
||||
WirelessSecurityOption * opt = NULL;
|
||||
|
|
@ -99,6 +127,7 @@ WirelessSecurityOption * wso_wep_passphrase_new (const char *glade_file)
|
|||
opt->data_free_func = data_free_func;
|
||||
opt->validate_input_func = validate_input_func;
|
||||
opt->widget_create_func = widget_create_func;
|
||||
opt->append_dbus_params_func = append_dbus_params_func;
|
||||
|
||||
if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,12 +23,15 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <iwlib.h>
|
||||
|
||||
#include "wireless-security-option.h"
|
||||
#include "wso-wpa-psk-passphrase.h"
|
||||
#include "wso-private.h"
|
||||
#include "cipher.h"
|
||||
#include "cipher-wpa-psk-passphrase.h"
|
||||
#include "dbus-helpers.h"
|
||||
|
||||
|
||||
struct OptData
|
||||
|
|
@ -74,6 +77,30 @@ static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ss
|
|||
}
|
||||
|
||||
|
||||
static gboolean append_dbus_params_func (WirelessSecurityOption *opt, const char *ssid, DBusMessage *message)
|
||||
{
|
||||
IEEE_802_11_Cipher * cipher = NULL;
|
||||
GtkWidget * auth_combo;
|
||||
int auth_alg = -1;
|
||||
GtkWidget * entry;
|
||||
const char * input;
|
||||
|
||||
g_return_val_if_fail (opt != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data != NULL, FALSE);
|
||||
g_return_val_if_fail (opt->data->entry_name != NULL, FALSE);
|
||||
|
||||
entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name);
|
||||
input = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (!wso_validate_helper (opt, ssid, input, &cipher) || !cipher)
|
||||
return FALSE;
|
||||
|
||||
nmu_dbus_message_append_wpa_psk_args (message, cipher, ssid, input,
|
||||
IW_AUTH_WPA_VERSION_WPA, IW_AUTH_KEY_MGMT_PSK);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
WirelessSecurityOption * wso_wpa_psk_passphrase_new (const char *glade_file)
|
||||
{
|
||||
WirelessSecurityOption * opt = NULL;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,14 @@ INCLUDES = -I${top_srcdir} -I${top_srcdir}/include
|
|||
|
||||
lib_LTLIBRARIES=libnm-util.la
|
||||
|
||||
libnm_util_la_CPPFLAGS = $(GLIB_CFLAGS)
|
||||
libnm_util_la_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-DDBUS_API_SUBJECT_TO_CHANGE \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGNOME_DISABLE_DEPRECATED \
|
||||
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
|
||||
|
||||
if WITH_GCRYPT
|
||||
libnm_util_la_CPPFLAGS += $(LIBGCRYPT_CFLAGS)
|
||||
|
|
@ -24,6 +31,8 @@ libnm_util_la_SOURCES= \
|
|||
cipher-wpa-psk-passphrase.h \
|
||||
gnome-keyring-md5.c \
|
||||
gnome-keyring-md5.h \
|
||||
dbus-helpers.c \
|
||||
dbus-helpers.h \
|
||||
sha1.c \
|
||||
sha1.h
|
||||
|
||||
|
|
@ -31,7 +40,7 @@ if !WITH_GCRYPT
|
|||
libnm_util_la_SOURCES += gnome-keyring-md5.c gnome-keyring-md5.h
|
||||
endif
|
||||
|
||||
libnm_util_la_LDFLAGS= $(GLIB_LIBS)
|
||||
libnm_util_la_LDFLAGS= $(GLIB_LIBS) $(DBUS_LIBS)
|
||||
|
||||
if WITH_GCRYPT
|
||||
libnm_util_la_LDFLAGS += $(LIBGCRYPT_LIBS)
|
||||
|
|
@ -45,7 +54,8 @@ libnm_util_include_HEADERS = \
|
|||
cipher-wep-passphrase.h \
|
||||
cipher-wep-ascii.h \
|
||||
cipher-wpa-psk-hex.h \
|
||||
cipher-wpa-psk-passphrase.h
|
||||
cipher-wpa-psk-passphrase.h \
|
||||
dbus-helpers.h
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libnm-util.pc
|
||||
|
|
|
|||
85
libnm-util/dbus-helpers.c
Normal file
85
libnm-util/dbus-helpers.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
|
||||
*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* (C) Copyright 2005 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <glib.h>
|
||||
#include <iwlib.h>
|
||||
|
||||
#include "dbus-helpers.h"
|
||||
#include "cipher.h"
|
||||
|
||||
|
||||
dbus_bool_t nmu_dbus_message_append_wep_args (DBusMessage *message, IEEE_802_11_Cipher *cipher,
|
||||
const char *ssid, const char *input, int auth_alg)
|
||||
{
|
||||
int we_cipher = -1;
|
||||
char * hashed = NULL;
|
||||
int hashed_len;
|
||||
dbus_bool_t result;
|
||||
|
||||
g_return_val_if_fail (message != NULL, FALSE);
|
||||
g_return_val_if_fail (cipher != NULL, FALSE);
|
||||
g_return_val_if_fail ((auth_alg == IW_AUTH_ALG_OPEN_SYSTEM) || (auth_alg == IW_AUTH_ALG_SHARED_KEY), FALSE);
|
||||
|
||||
we_cipher = ieee_802_11_cipher_get_we_cipher (cipher);
|
||||
fprintf (stderr, "Cipher=%d, ssid='%s', input='%s'\n", we_cipher, ssid, input);
|
||||
hashed = ieee_802_11_cipher_hash (cipher, ssid, input);
|
||||
hashed_len = strlen (hashed);
|
||||
fprintf (stderr, "hashed = '%s', len = %d\n", hashed, hashed_len);
|
||||
|
||||
result = dbus_message_append_args (message, DBUS_TYPE_INT32, &we_cipher,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &hashed, hashed_len,
|
||||
DBUS_TYPE_INT32, &auth_alg,
|
||||
DBUS_TYPE_INVALID);
|
||||
g_free (hashed);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
dbus_bool_t nmu_dbus_message_append_wpa_psk_args (DBusMessage *message, IEEE_802_11_Cipher *cipher,
|
||||
const char *ssid, const char *input, int wpa_version, int key_mgt)
|
||||
{
|
||||
int we_cipher = -1;
|
||||
char * hashed = NULL;
|
||||
int hashed_len;
|
||||
dbus_bool_t result;
|
||||
|
||||
g_return_val_if_fail (message != NULL, FALSE);
|
||||
g_return_val_if_fail (cipher != NULL, FALSE);
|
||||
g_return_val_if_fail ((wpa_version == IW_AUTH_WPA_VERSION_WPA) || (wpa_version == IW_AUTH_WPA_VERSION_WPA2), FALSE);
|
||||
g_return_val_if_fail ((key_mgt == IW_AUTH_KEY_MGMT_802_1X) || (key_mgt == IW_AUTH_KEY_MGMT_PSK), FALSE);
|
||||
|
||||
we_cipher = ieee_802_11_cipher_get_we_cipher (cipher);
|
||||
hashed = ieee_802_11_cipher_hash (cipher, ssid, input);
|
||||
hashed_len = strlen (hashed);
|
||||
|
||||
result = dbus_message_append_args (message, DBUS_TYPE_INT32, &we_cipher,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &hashed, hashed_len,
|
||||
DBUS_TYPE_INT32, &wpa_version,
|
||||
DBUS_TYPE_INT32, &key_mgt,
|
||||
DBUS_TYPE_INVALID);
|
||||
g_free (hashed);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
36
libnm-util/dbus-helpers.h
Normal file
36
libnm-util/dbus-helpers.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
|
||||
*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* (C) Copyright 2005 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef DBUS_HELPERS_H
|
||||
#define DBUS_HELPERS_H
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "cipher.h"
|
||||
|
||||
dbus_bool_t nmu_dbus_message_append_wep_args (DBusMessage *message, IEEE_802_11_Cipher *cipher,
|
||||
const char *ssid, const char *input, int auth_alg);
|
||||
|
||||
dbus_bool_t nmu_dbus_message_append_wpa_psk_args (DBusMessage *message, IEEE_802_11_Cipher *cipher,
|
||||
const char *ssid, const char *input, int wpa_version, int key_mgt);
|
||||
|
||||
|
||||
#endif /* DBUS_HELPERS_H */
|
||||
Loading…
Add table
Reference in a new issue