mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 17:30:16 +01:00
2005-12-16 Dan Williams <dcbw@redhat.com>
* Move nm_gconf_get_*_helper() functions to separate files, gconf-helpers.c & gconf-helpers.h * New NMGConfWSO objects for managing the gconf side of things. Eventually these should be merged with the WirelessSecurityOption objects and a common base (that can serialize/deserialize from dbus & gconf) should be refactored out, but for now they are separate. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1207 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
a877adb189
commit
77b3b18ffd
11 changed files with 1080 additions and 124 deletions
|
|
@ -73,6 +73,14 @@ nm_applet_SOURCES = \
|
|||
wso-wep-passphrase.h \
|
||||
wso-wpa-psk-passphrase.c \
|
||||
wso-wpa-psk-passphrase.h \
|
||||
nm-gconf-wso.c \
|
||||
nm-gconf-wso.h \
|
||||
nm-gconf-wso-wep.c \
|
||||
nm-gconf-wso-wep.h \
|
||||
nm-gconf-wso-wpa-psk.c \
|
||||
nm-gconf-wso-wpa-psk.h \
|
||||
gconf-helpers.c \
|
||||
gconf-helpers.h \
|
||||
$(NULL)
|
||||
|
||||
nm_applet_LDADD = \
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "applet-dbus-info.h"
|
||||
#include "passphrase-dialog.h"
|
||||
#include "nm-utils.h"
|
||||
#include "gconf-helpers.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -107,40 +108,28 @@ static void nmi_dbus_get_network_key_callback (GnomeKeyringResult result,
|
|||
GList *found_list,
|
||||
gpointer data)
|
||||
{
|
||||
NMGetNetworkKeyCBData *cb_data = (NMGetNetworkKeyCBData*) data;
|
||||
NMWirelessApplet *applet = cb_data->applet;
|
||||
DBusMessage *message = cb_data->message;
|
||||
NetworkDevice *dev = cb_data->dev;
|
||||
char *net_path = cb_data->net_path;
|
||||
char *essid = cb_data->essid;
|
||||
NMGetNetworkKeyCBData * cb_data = (NMGetNetworkKeyCBData*) data;
|
||||
NMWirelessApplet * applet = cb_data->applet;
|
||||
DBusMessage * message = cb_data->message;
|
||||
NetworkDevice * dev = cb_data->dev;
|
||||
char * net_path = cb_data->net_path;
|
||||
char * essid = cb_data->essid;
|
||||
|
||||
if (result == GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
gchar *key;
|
||||
gchar *gconf_key;
|
||||
gchar *escaped_network;
|
||||
GConfValue *value;
|
||||
NMEncKeyType key_type = -1;
|
||||
GnomeKeyringFound *found;
|
||||
gchar * key;
|
||||
gchar * escaped_network;
|
||||
GnomeKeyringFound * found;
|
||||
NMGConfWSO * gconf_wso;
|
||||
|
||||
found = found_list->data;
|
||||
key = g_strdup (found->secret);
|
||||
|
||||
/* Grab key type from GConf since we need it for return message */
|
||||
escaped_network = gconf_escape_key (essid, strlen (essid));
|
||||
gconf_key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||
gconf_wso = nm_gconf_wso_new_deserialize_gconf (applet->gconf_client, escaped_network);
|
||||
g_free (escaped_network);
|
||||
|
||||
value = gconf_client_get (applet->gconf_client, gconf_key, NULL);
|
||||
g_free (gconf_key);
|
||||
|
||||
if (value)
|
||||
{
|
||||
key_type = gconf_value_get_int (value);
|
||||
gconf_value_free (value);
|
||||
}
|
||||
|
||||
nmi_dbus_return_user_key (applet->connection, message, key, key_type);
|
||||
nmi_dbus_return_user_key (applet->connection, message, gconf_wso);
|
||||
g_free (key);
|
||||
}
|
||||
else
|
||||
|
|
@ -251,13 +240,16 @@ 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 NMEncKeyType key_type)
|
||||
void
|
||||
nmi_dbus_return_user_key (DBusConnection *connection,
|
||||
DBusMessage *message,
|
||||
NMGConfWSO *gconf_wso)
|
||||
{
|
||||
DBusMessage *reply;
|
||||
const int tmp_key_type = (int)key_type;
|
||||
DBusMessage * reply;
|
||||
DBusMessageIter iter;
|
||||
|
||||
g_return_if_fail (connection != NULL);
|
||||
g_return_if_fail (passphrase != NULL);
|
||||
g_return_if_fail (gconf_wso != NULL);
|
||||
|
||||
if (!(reply = dbus_message_new_method_return (message)))
|
||||
{
|
||||
|
|
@ -265,8 +257,11 @@ void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message,
|
|||
return;
|
||||
}
|
||||
|
||||
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_iter_append_init (reply, &iter);
|
||||
if (nm_gconf_wso_serialize_dbus (gconf_wso, &iter)
|
||||
dbus_connection_send (connection, reply, NULL);
|
||||
else
|
||||
nm_warning ("nmi_dbus_return_user_key(): couldn't serialize gconf_wso");
|
||||
dbus_message_unref (reply);
|
||||
}
|
||||
|
||||
|
|
@ -380,100 +375,6 @@ out:
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
nm_gconf_get_int_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
int *value)
|
||||
{
|
||||
char * gc_key;
|
||||
GConfValue * gc_value;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
g_return_val_if_fail (network != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
gc_key = g_strdup_printf ("%s/%s/%s", path, network, key);
|
||||
if ((gc_value = gconf_client_get (client, gc_key, NULL)))
|
||||
{
|
||||
if (gc_value->type == GCONF_VALUE_INT)
|
||||
{
|
||||
*value = gconf_value_get_int (gc_value);
|
||||
success = TRUE;
|
||||
}
|
||||
gconf_value_free (gc_value);
|
||||
}
|
||||
g_free (gc_key);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
nm_gconf_get_string_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
char **value)
|
||||
{
|
||||
char * gc_key;
|
||||
GConfValue * gc_value;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
g_return_val_if_fail (network != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
g_return_val_if_fail (*value == NULL, FALSE);
|
||||
|
||||
gc_key = g_strdup_printf ("%s/%s/%s", path, network, key);
|
||||
if ((gc_value = gconf_client_get (client, gc_key, NULL)))
|
||||
{
|
||||
if (gc_value->type == GCONF_VALUE_STRING)
|
||||
{
|
||||
*value = g_strdup (gconf_value_get_string (gc_value));
|
||||
success = TRUE;
|
||||
}
|
||||
gconf_value_free (gc_value);
|
||||
}
|
||||
g_free (gc_key);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
nm_gconf_get_bool_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
gboolean *value)
|
||||
{
|
||||
char * gc_key;
|
||||
GConfValue * gc_value;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
g_return_val_if_fail (network != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
gc_key = g_strdup_printf ("%s/%s/%s", path, network, key);
|
||||
if ((gc_value = gconf_client_get (client, gc_key, NULL)))
|
||||
{
|
||||
if (gc_value->type == GCONF_VALUE_STRING)
|
||||
{
|
||||
*value = gconf_value_get_bool (gc_value);
|
||||
success = TRUE;
|
||||
}
|
||||
gconf_value_free (gc_value);
|
||||
}
|
||||
g_free (gc_key);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
static void addr_list_append_helper (GConfValue *value, DBusMessageIter *iter)
|
||||
{
|
||||
const char *string = gconf_value_get_string (value);
|
||||
|
|
|
|||
120
gnome/applet/gconf-helpers.c
Normal file
120
gnome/applet/gconf-helpers.c
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "gconf-helpers.h"
|
||||
|
||||
|
||||
gboolean
|
||||
nm_gconf_get_int_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
int *value)
|
||||
{
|
||||
char * gc_key;
|
||||
GConfValue * gc_value;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
g_return_val_if_fail (network != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
gc_key = g_strdup_printf ("%s/%s/%s", path, network, key);
|
||||
if ((gc_value = gconf_client_get (client, gc_key, NULL)))
|
||||
{
|
||||
if (gc_value->type == GCONF_VALUE_INT)
|
||||
{
|
||||
*value = gconf_value_get_int (gc_value);
|
||||
success = TRUE;
|
||||
}
|
||||
gconf_value_free (gc_value);
|
||||
}
|
||||
g_free (gc_key);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
nm_gconf_get_string_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
char **value)
|
||||
{
|
||||
char * gc_key;
|
||||
GConfValue * gc_value;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
g_return_val_if_fail (network != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
g_return_val_if_fail (*value == NULL, FALSE);
|
||||
|
||||
gc_key = g_strdup_printf ("%s/%s/%s", path, network, key);
|
||||
if ((gc_value = gconf_client_get (client, gc_key, NULL)))
|
||||
{
|
||||
if (gc_value->type == GCONF_VALUE_STRING)
|
||||
{
|
||||
*value = g_strdup (gconf_value_get_string (gc_value));
|
||||
success = TRUE;
|
||||
}
|
||||
gconf_value_free (gc_value);
|
||||
}
|
||||
g_free (gc_key);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
nm_gconf_get_bool_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
gboolean *value)
|
||||
{
|
||||
char * gc_key;
|
||||
GConfValue * gc_value;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
g_return_val_if_fail (network != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
gc_key = g_strdup_printf ("%s/%s/%s", path, network, key);
|
||||
if ((gc_value = gconf_client_get (client, gc_key, NULL)))
|
||||
{
|
||||
if (gc_value->type == GCONF_VALUE_STRING)
|
||||
{
|
||||
*value = gconf_value_get_bool (gc_value);
|
||||
success = TRUE;
|
||||
}
|
||||
gconf_value_free (gc_value);
|
||||
}
|
||||
g_free (gc_key);
|
||||
|
||||
return success;
|
||||
}
|
||||
51
gnome/applet/gconf-helpers.h
Normal file
51
gnome/applet/gconf-helpers.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 GCONF_HELPERS_H
|
||||
#define GCONF_HELPERS_H
|
||||
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <glib.h>
|
||||
|
||||
gboolean
|
||||
nm_gconf_get_int_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
int *value);
|
||||
|
||||
gboolean
|
||||
nm_gconf_get_string_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
char **value);
|
||||
|
||||
gboolean
|
||||
nm_gconf_get_bool_helper (GConfClient *client,
|
||||
const char *path,
|
||||
const char *key,
|
||||
const char *network,
|
||||
gboolean *value);
|
||||
|
||||
|
||||
#endif /* GCONF_HELPERS_H */
|
||||
|
||||
29
gnome/applet/nm-gconf-wso-private.h
Normal file
29
gnome/applet/nm-gconf-wso-private.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 NM_GCONF_WSO_PRIVATE_H
|
||||
#define NM_GCONF_WSO_PRIVATE_H
|
||||
|
||||
#include "nm-gconf-wso.h"
|
||||
|
||||
void nm_gconf_wso_set_we_cipher (NMGConfWSO *self, int we_cipher);
|
||||
|
||||
#endif /* NM_GCONF_WSO_PRIVATE_H */
|
||||
157
gnome/applet/nm-gconf-wso-wep.c
Normal file
157
gnome/applet/nm-gconf-wso-wep.c
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <iwlib.h>
|
||||
|
||||
#include "applet.h"
|
||||
#include "nm-gconf-wso.h"
|
||||
#include "nm-gconf-wso-wep.h"
|
||||
#include "nm-gconf-wso-private.h"
|
||||
#include "dbus-helpers.h"
|
||||
#include "gconf-helpers.h"
|
||||
|
||||
#define WEP_PREFIX "wep_"
|
||||
|
||||
#define NM_GCONF_WSO_WEP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GCONF_WSO_WEP, NMGConfWSOWEPPrivate))
|
||||
|
||||
struct _NMGConfWSOWEPPrivate
|
||||
{
|
||||
int auth_algorithm;
|
||||
|
||||
gboolean dispose_has_run;
|
||||
};
|
||||
|
||||
NMGConfWSOWEP *
|
||||
nm_gconf_wso_wep_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher)
|
||||
{
|
||||
NMGConfWSOWEP * security = NULL;
|
||||
char * key = NULL;
|
||||
int key_len;
|
||||
int auth_algorithm;
|
||||
DBusMessageIter subiter;
|
||||
|
||||
g_return_val_if_fail (iter != NULL, NULL);
|
||||
g_return_val_if_fail ((we_cipher == IW_AUTH_CIPHER_WEP40) || (we_cipher == IW_AUTH_CIPHER_WEP104), NULL);
|
||||
|
||||
if (!nmu_security_deserialize_wep (iter, &key, &key_len, &auth_algorithm))
|
||||
goto out;
|
||||
|
||||
/* Success, build up our security object */
|
||||
security = g_object_new (NM_TYPE_GCONF_WSO_WEP, NULL);
|
||||
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
|
||||
nm_gconf_wso_set_key (NM_GCONF_WSO (security), key, key_len);
|
||||
security->priv->auth_algorithm = auth_algorithm;
|
||||
|
||||
out:
|
||||
return security;
|
||||
}
|
||||
|
||||
NMGConfWSOWEP *
|
||||
nm_gconf_wso_wep_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher)
|
||||
{
|
||||
NMGConfWSOWEP * security = NULL;
|
||||
char * key = NULL;
|
||||
int key_len;
|
||||
int auth_algorithm;
|
||||
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
g_return_val_if_fail (network != NULL, NULL);
|
||||
g_return_val_if_fail ((we_cipher == IW_AUTH_CIPHER_WEP40) || (we_cipher == IW_AUTH_CIPHER_WEP104), NULL);
|
||||
|
||||
if (!nm_gconf_get_int_helper (client,
|
||||
GCONF_PATH_WIRELESS_NETWORKS,
|
||||
WEP_PREFIX"auth_algorithm",
|
||||
network,
|
||||
&auth_algorithm))
|
||||
goto out;
|
||||
|
||||
/* Success, build up our security object */
|
||||
security = g_object_new (NM_TYPE_GCONF_WSO_WEP, NULL);
|
||||
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
|
||||
security->priv->auth_algorithm = auth_algorithm;
|
||||
|
||||
out:
|
||||
return security;
|
||||
}
|
||||
|
||||
static int
|
||||
real_serialize_dbus (NMGConfWSO *instance, DBusMessageIter *iter)
|
||||
{
|
||||
NMGConfWSOWEP * self = NM_GCONF_WSO_WEP (instance);
|
||||
|
||||
if (!nmu_security_serialize_wep (iter,
|
||||
nm_gconf_wso_get_key (instance),
|
||||
self->priv->auth_algorithm))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
real_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_gconf_wso_wep_init (NMGConfWSOWEP * self)
|
||||
{
|
||||
self->priv = NM_GCONF_WSO_WEP_GET_PRIVATE (self);
|
||||
self->priv->auth_algorithm = IW_AUTH_ALG_OPEN_SYSTEM;
|
||||
self->priv->dispose_has_run = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_gconf_wso_wep_class_init (NMGConfWSOWEPClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMGConfWSOClass *par_class = NM_GCONF_WSO_CLASS (klass);
|
||||
|
||||
par_class->serialize_dbus_func = real_serialize_dbus;
|
||||
par_class->serialize_gconf_func = real_serialize_gconf;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMGConfWSOWEPPrivate));
|
||||
}
|
||||
|
||||
GType
|
||||
nm_gconf_wso_wep_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof (NMGConfWSOWEPClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) nm_gconf_wso_wep_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (NMGConfWSOWEP),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) nm_gconf_wso_wep_init
|
||||
};
|
||||
type = g_type_register_static (NM_TYPE_GCONF_WSO,
|
||||
"NMGConfWSOWEP",
|
||||
&info, 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
61
gnome/applet/nm-gconf-wso-wep.h
Normal file
61
gnome/applet/nm-gconf-wso-wep.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 NM_GCONF_WSO_WEP_H
|
||||
#define NM_GCONF_WSO_WEP_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include "nm-gconf-wso-wep.h"
|
||||
|
||||
#define NM_TYPE_GCONF_WSO_WEP (nm_gconf_wso_wep_get_type ())
|
||||
#define NM_GCONF_WSO_WEP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GCONF_WSO_WEP, NMGConfWSOWEP))
|
||||
#define NM_GCONF_WSO_WEP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GCONF_WSO_WEP, NMGConfWSOWEPClass))
|
||||
#define NM_IS_GCONF_WSO_WEP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GCONF_WSO_WEP))
|
||||
#define NM_IS_GCONF_WSO_WEP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_GCONF_WSO_WEP))
|
||||
#define NM_GCONF_WSO_WEP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GCONF_WSO_WEP, NMGConfWSOWEPClass))
|
||||
|
||||
typedef struct _NMGConfWSOWEP NMGConfWSOWEP;
|
||||
typedef struct _NMGConfWSOWEPClass NMGConfWSOWEPClass;
|
||||
typedef struct _NMGConfWSOWEPPrivate NMGConfWSOWEPPrivate;
|
||||
|
||||
struct _NMGConfWSOWEP
|
||||
{
|
||||
NMGConfWSO parent;
|
||||
|
||||
/*< private >*/
|
||||
NMGConfWSOWEPPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NMGConfWSOWEPClass
|
||||
{
|
||||
NMGConfWSOClass parent;
|
||||
};
|
||||
|
||||
|
||||
GType nm_gconf_wso_wep_get_type (void);
|
||||
|
||||
NMGConfWSOWEP * nm_gconf_wso_wep_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher);
|
||||
|
||||
NMGConfWSOWEP * nm_gconf_wso_wep_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher);
|
||||
|
||||
#endif /* NM_GCONF_WSO_WEP_H */
|
||||
170
gnome/applet/nm-gconf-wso-wpa-psk.c
Normal file
170
gnome/applet/nm-gconf-wso-wpa-psk.c
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <iwlib.h>
|
||||
|
||||
#include "applet.h"
|
||||
#include "nm-gconf-wso.h"
|
||||
#include "nm-gconf-wso-wpa-psk.h"
|
||||
#include "nm-gconf-wso-private.h"
|
||||
#include "dbus-helpers.h"
|
||||
#include "gconf-helpers.h"
|
||||
|
||||
#define WPA_PSK_PREFIX "wpa_psk_"
|
||||
|
||||
#define NM_GCONF_WSO_WPA_PSK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GCONF_WSO_WPA_PSK, NMGConfWSOWPA_PSKPrivate))
|
||||
|
||||
struct _NMGConfWSOWPA_PSKPrivate
|
||||
{
|
||||
int wpa_version;
|
||||
int key_mgt;
|
||||
|
||||
gboolean dispose_has_run;
|
||||
};
|
||||
|
||||
NMGConfWSOWPA_PSK *
|
||||
nm_gconf_wso_wpa_psk_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher)
|
||||
{
|
||||
NMGConfWSOWPA_PSK * security = NULL;
|
||||
char * key;
|
||||
int key_len;
|
||||
int wpa_version;
|
||||
int key_mgt;
|
||||
|
||||
g_return_val_if_fail (iter != NULL, NULL);
|
||||
g_return_val_if_fail ((we_cipher == IW_AUTH_CIPHER_TKIP) || (we_cipher == IW_AUTH_CIPHER_CCMP), NULL);
|
||||
|
||||
if (!nmu_security_deserialize_wpa_psk (iter, &key, &key_len, &wpa_version, &key_mgt))
|
||||
goto out;
|
||||
|
||||
/* Success, build up our security object */
|
||||
security = g_object_new (NM_TYPE_GCONF_WSO_WPA_PSK, NULL);
|
||||
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
|
||||
nm_gconf_wso_set_key (NM_GCONF_WSO (security), key, key_len);
|
||||
security->priv->wpa_version = wpa_version;
|
||||
security->priv->key_mgt = key_mgt;
|
||||
|
||||
out:
|
||||
return security;
|
||||
}
|
||||
|
||||
NMGConfWSOWPA_PSK *
|
||||
nm_gconf_wso_wpa_psk_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher)
|
||||
{
|
||||
NMGConfWSOWPA_PSK * security = NULL;
|
||||
char * key;
|
||||
int key_len;
|
||||
int wpa_version;
|
||||
int key_mgt;
|
||||
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
g_return_val_if_fail (network != NULL, NULL);
|
||||
g_return_val_if_fail ((we_cipher == IW_AUTH_CIPHER_TKIP) || (we_cipher == IW_AUTH_CIPHER_CCMP), NULL);
|
||||
|
||||
if (!nm_gconf_get_int_helper (client,
|
||||
GCONF_PATH_WIRELESS_NETWORKS,
|
||||
WPA_PSK_PREFIX"wpa_version",
|
||||
network,
|
||||
&wpa_version))
|
||||
goto out;
|
||||
|
||||
if (!nm_gconf_get_int_helper (client,
|
||||
GCONF_PATH_WIRELESS_NETWORKS,
|
||||
WPA_PSK_PREFIX"key_mgt",
|
||||
network,
|
||||
&key_mgt))
|
||||
goto out;
|
||||
|
||||
/* Success, build up our security object */
|
||||
security = g_object_new (NM_TYPE_GCONF_WSO_WPA_PSK, NULL);
|
||||
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
|
||||
security->priv->wpa_version = wpa_version;
|
||||
security->priv->key_mgt = key_mgt;
|
||||
|
||||
out:
|
||||
return security;
|
||||
}
|
||||
|
||||
static int
|
||||
real_serialize_dbus (NMGConfWSO *instance, DBusMessageIter *iter)
|
||||
{
|
||||
NMGConfWSOWPA_PSK * self = NM_GCONF_WSO_WPA_PSK (instance);
|
||||
|
||||
if (!nmu_security_serialize_wpa_psk (iter,
|
||||
nm_gconf_wso_get_key (instance),
|
||||
self->priv->wpa_version,
|
||||
self->priv->key_mgt))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
real_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_gconf_wso_wpa_psk_init (NMGConfWSOWPA_PSK * self)
|
||||
{
|
||||
self->priv = NM_GCONF_WSO_WPA_PSK_GET_PRIVATE (self);
|
||||
self->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
|
||||
self->priv->key_mgt = IW_AUTH_KEY_MGMT_PSK;
|
||||
self->priv->dispose_has_run = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_gconf_wso_wpa_psk_class_init (NMGConfWSOWPA_PSKClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMGConfWSOClass *par_class = NM_GCONF_WSO_CLASS (klass);
|
||||
|
||||
par_class->serialize_dbus_func = real_serialize_dbus;
|
||||
par_class->serialize_gconf_func = real_serialize_gconf;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMGConfWSOWPA_PSKPrivate));
|
||||
}
|
||||
|
||||
GType
|
||||
nm_gconf_wso_wpa_psk_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof (NMGConfWSOWPA_PSKClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) nm_gconf_wso_wpa_psk_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (NMGConfWSOWPA_PSK),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) nm_gconf_wso_wpa_psk_init
|
||||
};
|
||||
type = g_type_register_static (NM_TYPE_GCONF_WSO,
|
||||
"NMGConfWSOWPA_PSK",
|
||||
&info, 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
61
gnome/applet/nm-gconf-wso-wpa-psk.h
Normal file
61
gnome/applet/nm-gconf-wso-wpa-psk.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 NM_GCONF_WSO_WPA_PSK_H
|
||||
#define NM_GCONF_WSO_WPA_PSK_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include "nm-gconf-wso-wpa-psk.h"
|
||||
|
||||
#define NM_TYPE_GCONF_WSO_WPA_PSK (nm_gconf_wso_wpa_psk_get_type ())
|
||||
#define NM_GCONF_WSO_WPA_PSK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GCONF_WSO_WPA_PSK, NMGConfWSOWPA_PSK))
|
||||
#define NM_GCONF_WSO_WPA_PSK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GCONF_WSO_WPA_PSK, NMGConfWSOWPA_PSKClass))
|
||||
#define NM_IS_GCONF_WSO_WPA_PSK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GCONF_WSO_WPA_PSK))
|
||||
#define NM_IS_GCONF_WSO_WPA_PSK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_GCONF_WSO_WPA_PSK))
|
||||
#define NM_GCONF_WSO_WPA_PSK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GCONF_WSO_WPA_PSK, NMGConfWSOWPA_PSKClass))
|
||||
|
||||
typedef struct _NMGConfWSOWPA_PSK NMGConfWSOWPA_PSK;
|
||||
typedef struct _NMGConfWSOWPA_PSKClass NMGConfWSOWPA_PSKClass;
|
||||
typedef struct _NMGConfWSOWPA_PSKPrivate NMGConfWSOWPA_PSKPrivate;
|
||||
|
||||
struct _NMGConfWSOWPA_PSK
|
||||
{
|
||||
NMGConfWSO parent;
|
||||
|
||||
/*< private >*/
|
||||
NMGConfWSOWPA_PSKPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NMGConfWSOWPA_PSKClass
|
||||
{
|
||||
NMGConfWSOClass parent;
|
||||
};
|
||||
|
||||
|
||||
GType nm_gconf_wso_wpa_psk_get_type (void);
|
||||
|
||||
NMGConfWSOWPA_PSK * nm_gconf_wso_wpa_psk_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher);
|
||||
|
||||
NMGConfWSOWPA_PSK * nm_gconf_wso_wpa_psk_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher);
|
||||
|
||||
#endif /* NM_GCONF_WSO_WPA_PSK_H */
|
||||
321
gnome/applet/nm-gconf-wso.c
Normal file
321
gnome/applet/nm-gconf-wso.c
Normal file
|
|
@ -0,0 +1,321 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <iwlib.h>
|
||||
|
||||
#include "applet.h"
|
||||
#include "nm-gconf-wso.h"
|
||||
#include "nm-gconf-wso-private.h"
|
||||
#include "nm-gconf-wso-wep.h"
|
||||
#include "nm-gconf-wso-wpa-psk.h"
|
||||
#include "gconf-helpers.h"
|
||||
|
||||
|
||||
#define NM_GCONF_WSO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GCONF_WSO, NMGConfWSOPrivate))
|
||||
|
||||
struct _NMGConfWSOPrivate
|
||||
{
|
||||
int we_cipher;
|
||||
char * key;
|
||||
|
||||
gboolean dispose_has_run;
|
||||
};
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
|
||||
static NMGConfWSO *
|
||||
nm_gconf_wso_new (int we_cipher)
|
||||
{
|
||||
NMGConfWSO * security;
|
||||
|
||||
security = g_object_new (NM_TYPE_GCONF_WSO, NULL);
|
||||
security->priv->we_cipher = we_cipher;
|
||||
security->priv->key = NULL;
|
||||
return security;
|
||||
}
|
||||
|
||||
|
||||
NMGConfWSO *
|
||||
nm_gconf_wso_new_deserialize_dbus (DBusMessageIter *iter)
|
||||
{
|
||||
NMGConfWSO * security = NULL;
|
||||
int we_cipher;
|
||||
|
||||
g_return_val_if_fail (iter != NULL, NULL);
|
||||
/* We require the WE cipher (an INT32) first */
|
||||
g_return_val_if_fail (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_INT32, NULL);
|
||||
|
||||
/* Get and validate WE cipher */
|
||||
dbus_message_iter_get_basic (iter, &we_cipher);
|
||||
|
||||
if (we_cipher == IW_AUTH_CIPHER_NONE)
|
||||
security = nm_gconf_wso_new (we_cipher);
|
||||
else
|
||||
{
|
||||
/* Advance to start of cipher-dependent options */
|
||||
if (!dbus_message_iter_next (iter))
|
||||
goto out;
|
||||
|
||||
switch (we_cipher)
|
||||
{
|
||||
case IW_AUTH_CIPHER_WEP40:
|
||||
case IW_AUTH_CIPHER_WEP104:
|
||||
security = NM_GCONF_WSO (nm_gconf_wso_wep_new_deserialize_dbus (iter, we_cipher));
|
||||
break;
|
||||
|
||||
case IW_AUTH_CIPHER_TKIP:
|
||||
case IW_AUTH_CIPHER_CCMP:
|
||||
security = NM_GCONF_WSO (nm_gconf_wso_wpa_psk_new_deserialize_dbus (iter, we_cipher));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return security;
|
||||
}
|
||||
|
||||
NMGConfWSO *
|
||||
nm_gconf_wso_new_deserialize_gconf (GConfClient *client, const char *network)
|
||||
{
|
||||
NMGConfWSO * security = NULL;
|
||||
int we_cipher;
|
||||
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
g_return_val_if_fail (network != NULL, NULL);
|
||||
|
||||
if (!nm_gconf_get_int_helper (client,
|
||||
GCONF_PATH_WIRELESS_NETWORKS,
|
||||
"we_cipher",
|
||||
network,
|
||||
&we_cipher))
|
||||
goto out;
|
||||
|
||||
if (we_cipher == IW_AUTH_CIPHER_NONE)
|
||||
security = nm_gconf_wso_new (we_cipher);
|
||||
else
|
||||
{
|
||||
switch (we_cipher)
|
||||
{
|
||||
case IW_AUTH_CIPHER_WEP40:
|
||||
case IW_AUTH_CIPHER_WEP104:
|
||||
security = NM_GCONF_WSO (nm_gconf_wso_wep_new_deserialize_gconf (client, network, we_cipher));
|
||||
break;
|
||||
|
||||
case IW_AUTH_CIPHER_TKIP:
|
||||
case IW_AUTH_CIPHER_CCMP:
|
||||
security = NM_GCONF_WSO (nm_gconf_wso_wpa_psk_new_deserialize_gconf (client, network, we_cipher));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return security;
|
||||
}
|
||||
|
||||
void
|
||||
nm_gconf_wso_set_we_cipher (NMGConfWSO *self, int we_cipher)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
/* Ensure the cipher is valid */
|
||||
g_return_if_fail (
|
||||
(we_cipher == IW_AUTH_CIPHER_NONE)
|
||||
|| (we_cipher == IW_AUTH_CIPHER_WEP40)
|
||||
|| (we_cipher == IW_AUTH_CIPHER_WEP104)
|
||||
|| (we_cipher == IW_AUTH_CIPHER_TKIP)
|
||||
|| (we_cipher == IW_AUTH_CIPHER_CCMP));
|
||||
|
||||
self->priv->we_cipher = we_cipher;
|
||||
}
|
||||
|
||||
void
|
||||
nm_gconf_wso_set_key (NMGConfWSO *self, const char *key, int key_len)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (key != NULL);
|
||||
g_return_if_fail (key_len > 0);
|
||||
|
||||
if (self->priv->key)
|
||||
g_free (self->priv->key);
|
||||
self->priv->key = g_malloc0 (key_len + 1);
|
||||
memcpy (self->priv->key, key, key_len);
|
||||
}
|
||||
|
||||
static int
|
||||
real_serialize_dbus (NMGConfWSO *self, DBusMessageIter *iter)
|
||||
{
|
||||
/* Nothing to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
real_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network)
|
||||
{
|
||||
/* Nothing to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nm_gconf_wso_get_we_cipher (NMGConfWSO *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, -1);
|
||||
|
||||
return self->priv->we_cipher;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_gconf_wso_get_key (NMGConfWSO *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
return self->priv->key;
|
||||
}
|
||||
|
||||
int
|
||||
nm_gconf_wso_serialize_dbus (NMGConfWSO *self, DBusMessageIter *iter)
|
||||
{
|
||||
dbus_int32_t dbus_we_cipher;
|
||||
|
||||
g_return_val_if_fail (self != NULL, -1);
|
||||
g_return_val_if_fail (iter != NULL, -1);
|
||||
|
||||
if (self->priv->dispose_has_run)
|
||||
return -1;
|
||||
|
||||
/* First arg: WE cipher (INT32) */
|
||||
dbus_we_cipher = (dbus_int32_t) self->priv->we_cipher;
|
||||
dbus_message_iter_append_basic (iter, DBUS_TYPE_INT32, &dbus_we_cipher);
|
||||
|
||||
return NM_GCONF_WSO_GET_CLASS (self)->serialize_dbus_func (self, iter);
|
||||
}
|
||||
|
||||
int
|
||||
nm_gconf_wso_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network)
|
||||
{
|
||||
dbus_int32_t dbus_we_cipher;
|
||||
|
||||
g_return_val_if_fail (self != NULL, -1);
|
||||
g_return_val_if_fail (client != NULL, -1);
|
||||
g_return_val_if_fail (network != NULL, -1);
|
||||
|
||||
if (self->priv->dispose_has_run)
|
||||
return -1;
|
||||
|
||||
#if 0
|
||||
/* First arg: WE cipher (INT32) */
|
||||
dbus_we_cipher = (dbus_int32_t) self->priv->we_cipher;
|
||||
dbus_message_iter_append_basic (iter, DBUS_TYPE_INT32, &dbus_we_cipher);
|
||||
#endif
|
||||
|
||||
return NM_GCONF_WSO_GET_CLASS (self)->serialize_gconf_func (self, client, network);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_gconf_wso_init (NMGConfWSO * self)
|
||||
{
|
||||
self->priv = NM_GCONF_WSO_GET_PRIVATE (self);
|
||||
self->priv->dispose_has_run = FALSE;
|
||||
self->priv->we_cipher = IW_AUTH_CIPHER_NONE;
|
||||
self->priv->key = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_gconf_wso_dispose (GObject *object)
|
||||
{
|
||||
NMGConfWSO *self = (NMGConfWSO *) object;
|
||||
|
||||
if (self->priv->dispose_has_run)
|
||||
/* If dispose did already run, return. */
|
||||
return;
|
||||
|
||||
/* Make sure dispose does not run twice. */
|
||||
self->priv->dispose_has_run = TRUE;
|
||||
|
||||
/*
|
||||
* In dispose, you are supposed to free all types referenced from this
|
||||
* object which might themselves hold a reference to self. Generally,
|
||||
* the most simple solution is to unref all members on which you own a
|
||||
* reference.
|
||||
*/
|
||||
|
||||
/* Chain up to the parent class */
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_gconf_wso_finalize (GObject *object)
|
||||
{
|
||||
NMGConfWSO *self = (NMGConfWSO *) object;
|
||||
|
||||
/* Complete object destruction */
|
||||
g_free (self->priv->key);
|
||||
|
||||
/* Chain up to the parent class */
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nm_gconf_wso_class_init (NMGConfWSOClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = nm_gconf_wso_dispose;
|
||||
object_class->finalize = nm_gconf_wso_finalize;
|
||||
|
||||
klass->serialize_dbus_func = real_serialize_dbus;
|
||||
klass->serialize_gconf_func = real_serialize_gconf;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMGConfWSOPrivate));
|
||||
}
|
||||
|
||||
GType
|
||||
nm_gconf_wso_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof (NMGConfWSOClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) nm_gconf_wso_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (NMGConfWSO),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) nm_gconf_wso_init
|
||||
};
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"NMGConfWSO",
|
||||
&info, 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
77
gnome/applet/nm-gconf-wso.h
Normal file
77
gnome/applet/nm-gconf-wso.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* 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 NM_GCONF_WSO_H
|
||||
#define NM_GCONF_WSO_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#define NM_TYPE_GCONF_WSO (nm_gconf_wso_get_type ())
|
||||
#define NM_GCONF_WSO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GCONF_WSO, NMGConfWSO))
|
||||
#define NM_GCONF_WSO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GCONF_WSO, NMGConfWSOClass))
|
||||
#define NM_IS_AP_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GCONF_WSO))
|
||||
#define NM_IS_AP_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_GCONF_WSO))
|
||||
#define NM_GCONF_WSO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GCONF_WSO, NMGConfWSOClass))
|
||||
|
||||
typedef struct _NMGConfWSO NMGConfWSO;
|
||||
typedef struct _NMGConfWSOClass NMGConfWSOClass;
|
||||
typedef struct _NMGConfWSOPrivate NMGConfWSOPrivate;
|
||||
|
||||
struct _NMGConfWSO
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
/*< private >*/
|
||||
NMGConfWSOPrivate *priv;
|
||||
};
|
||||
|
||||
struct NMDevice;
|
||||
|
||||
struct _NMGConfWSOClass
|
||||
{
|
||||
GObjectClass parent;
|
||||
|
||||
/* class members */
|
||||
int (*serialize_dbus_func) (NMGConfWSO *self, DBusMessageIter *iter);
|
||||
|
||||
int (*serialize_gconf_func) (NMGConfWSO *self, GConfClient *client, const char *network);
|
||||
};
|
||||
|
||||
|
||||
GType nm_gconf_wso_get_type (void);
|
||||
|
||||
NMGConfWSO * nm_gconf_wso_new_deserialize_dbus (DBusMessageIter *iter);
|
||||
|
||||
NMGConfWSO * nm_gconf_wso_new_deserialize_gconf (GConfClient *client, const char *network);
|
||||
|
||||
int nm_gconf_wso_get_we_cipher (NMGConfWSO *self);
|
||||
|
||||
const char * nm_gconf_wso_get_key (NMGConfWSO *self);
|
||||
|
||||
void nm_gconf_wso_set_key (NMGConfWSO *self, const char *key, int key_len);
|
||||
|
||||
int nm_gconf_wso_serialize_dbus (NMGConfWSO *self, DBusMessageIter *iter);
|
||||
|
||||
int nm_gconf_wso_serialize_gconf (NMGConfWSO *self, GConfClient *client, const char *network);
|
||||
|
||||
#endif /* NM_GCONF_WSO_H */
|
||||
Loading…
Add table
Reference in a new issue