2004-09-30 Dan Williams <dcbw@redhat.com>

* info-daemon/NetworkManagerInfo.c
	  info-daemon/NetworkManagerInfoDbus.c
	  test/nminfotest.c
		- Escape ESSIDs in gconf


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@181 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2004-10-01 00:44:30 +00:00
parent 78bb8a008f
commit 2f00a08a11
4 changed files with 44 additions and 18 deletions

View file

@ -1,3 +1,10 @@
2004-09-30 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c
info-daemon/NetworkManagerInfoDbus.c
test/nminfotest.c
- Escape ESSIDs in gconf
Wed Sep 29 18:18:24 2004 Jonathan Blandford <jrb@redhat.com> Wed Sep 29 18:18:24 2004 Jonathan Blandford <jrb@redhat.com>
* configure.in: Add a temporary --enable-notification-icon. This * configure.in: Add a temporary --enable-notification-icon. This

View file

@ -37,6 +37,7 @@
#include <libgnomeui/gnome-ui-init.h> #include <libgnomeui/gnome-ui-init.h>
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include "config.h" #include "config.h"
#include "NetworkManagerInfoDbus.h" #include "NetworkManagerInfoDbus.h"
#include "NetworkManagerInfo.h" #include "NetworkManagerInfo.h"
@ -66,6 +67,7 @@ void nmi_gconf_notify_callback (GConfClient *client, guint connection_id, GConfE
{ {
char *network = g_strdup ((key + path_len)); char *network = g_strdup ((key + path_len));
char *slash_pos; char *slash_pos;
char *escaped_network;
/* If its a key under the network name, zero out the slash so we /* If its a key under the network name, zero out the slash so we
* are left with only the network name. * are left with only the network name.
@ -73,7 +75,9 @@ void nmi_gconf_notify_callback (GConfClient *client, guint connection_id, GConfE
if ((slash_pos = strchr (network, '/'))) if ((slash_pos = strchr (network, '/')))
*slash_pos = '\0'; *slash_pos = '\0';
escaped_network = gnome_vfs_escape_string (network);
nmi_dbus_signal_update_network (info->connection, network, NETWORK_TYPE_ALLOWED); nmi_dbus_signal_update_network (info->connection, network, NETWORK_TYPE_ALLOWED);
g_free (escaped_network);
g_free (network); g_free (network);
} }
} }

View file

@ -25,6 +25,7 @@
#include <dbus/dbus-glib.h> #include <dbus/dbus-glib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include "NetworkManagerInfo.h" #include "NetworkManagerInfo.h"
#include "NetworkManagerInfoDbus.h" #include "NetworkManagerInfoDbus.h"
@ -98,7 +99,6 @@ static void nmi_dbus_get_key_for_network (NMIAppInfo *info, DBusMessage *message
DBUS_TYPE_STRING, &network, DBUS_TYPE_STRING, &network,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
fprintf( stderr, "getUserKey\n");
nmi_passphrase_dialog_show (device, network, info); nmi_passphrase_dialog_show (device, network, info);
dbus_free (device); dbus_free (device);
@ -230,10 +230,12 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag
*/ */
while (element) while (element)
{ {
gchar key[100]; char key[100];
GConfValue *value; GConfValue *value;
char *escaped_network = gnome_vfs_escape_string ((char *)(element->data));
g_snprintf (&key[0], 99, "%s/essid", (char *)(element->data)); g_snprintf (&key[0], 99, "%s/essid", escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL); value = gconf_client_get (info->gconf_client, key, NULL);
if (value && gconf_value_get_string (value)) if (value && gconf_value_get_string (value))
{ {
@ -275,6 +277,7 @@ static DBusMessage *nmi_dbus_get_network_timestamp (NMIAppInfo *info, DBusMessag
GConfValue *value; GConfValue *value;
DBusError error; DBusError error;
NMINetworkType type; NMINetworkType type;
char *escaped_network;
g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL); g_return_val_if_fail (message != NULL, NULL);
@ -290,7 +293,9 @@ static DBusMessage *nmi_dbus_get_network_timestamp (NMIAppInfo *info, DBusMessag
} }
/* Grab timestamp key for our access point from GConf */ /* Grab timestamp key for our access point from GConf */
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, network); escaped_network = gnome_vfs_escape_string (network);
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL); value = gconf_client_get (info->gconf_client, key, NULL);
g_free (key); g_free (key);
@ -326,6 +331,7 @@ static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *m
GConfValue *value; GConfValue *value;
DBusError error; DBusError error;
NMINetworkType type; NMINetworkType type;
char *escaped_network;
g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL); g_return_val_if_fail (message != NULL, NULL);
@ -341,7 +347,9 @@ static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *m
} }
/* Grab essid key for our access point from GConf */ /* Grab essid key for our access point from GConf */
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, network); escaped_network = gnome_vfs_escape_string (network);
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL); value = gconf_client_get (info->gconf_client, key, NULL);
g_free (key); g_free (key);
@ -377,6 +385,7 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes
GConfValue *value; GConfValue *value;
DBusError error; DBusError error;
NMINetworkType type; NMINetworkType type;
char *escaped_network;
g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL); g_return_val_if_fail (message != NULL, NULL);
@ -392,7 +401,9 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes
} }
/* Grab user-key key for our access point from GConf */ /* Grab user-key key for our access point from GConf */
key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, network); escaped_network = gnome_vfs_escape_string (network);
key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL); value = gconf_client_get (info->gconf_client, key, NULL);
g_free (key); g_free (key);
@ -425,6 +436,7 @@ static DBusMessage *nmi_dbus_get_network_trusted (NMIAppInfo *info, DBusMessage
GConfValue *value; GConfValue *value;
DBusError error; DBusError error;
NMINetworkType type; NMINetworkType type;
char *escaped_network;
g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL); g_return_val_if_fail (message != NULL, NULL);
@ -440,7 +452,9 @@ static DBusMessage *nmi_dbus_get_network_trusted (NMIAppInfo *info, DBusMessage
} }
/* Grab user-key key for our access point from GConf */ /* Grab user-key key for our access point from GConf */
key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, network); escaped_network = gnome_vfs_escape_string (network);
key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
g_free (escaped_network);
value = gconf_client_get (info->gconf_client, key, NULL); value = gconf_client_get (info->gconf_client, key, NULL);
g_free (key); g_free (key);

View file

@ -37,8 +37,7 @@
typedef enum typedef enum
{ {
NETWORK_TYPE_UNKNOWN = 0, NETWORK_TYPE_UNKNOWN = 0,
NETWORK_TYPE_TRUSTED, NETWORK_TYPE_ALLOWED,
NETWORK_TYPE_PREFERRED,
NETWORK_TYPE_INVALID, NETWORK_TYPE_INVALID,
NETWORK_TYPE_DEVICE NETWORK_TYPE_DEVICE
} NMINetworkType; } NMINetworkType;
@ -95,7 +94,7 @@ char * get_network_string_property (DBusConnection *connection, char *network, c
return (ret_string); return (ret_string);
} }
int get_network_prio (DBusConnection *connection, char *network, NMINetworkType type) gboolean get_network_trusted (DBusConnection *connection, char *network, NMINetworkType type)
{ {
DBusMessage *message; DBusMessage *message;
DBusMessage *reply; DBusMessage *reply;
@ -108,7 +107,7 @@ int get_network_prio (DBusConnection *connection, char *network, NMINetworkType
message = dbus_message_new_method_call (NMI_DBUS_NMI_NAMESPACE, message = dbus_message_new_method_call (NMI_DBUS_NMI_NAMESPACE,
NMI_DBUS_NMI_OBJECT_PATH_PREFIX, NMI_DBUS_NMI_OBJECT_PATH_PREFIX,
NMI_DBUS_NMI_NAMESPACE, NMI_DBUS_NMI_NAMESPACE,
"getNetworkPriority"); "getNetworkTrusted");
if (message == NULL) if (message == NULL)
{ {
fprintf (stderr, "Couldn't allocate the dbus message\n"); fprintf (stderr, "Couldn't allocate the dbus message\n");
@ -133,14 +132,17 @@ int get_network_prio (DBusConnection *connection, char *network, NMINetworkType
} }
/* now analyze reply */ /* now analyze reply */
dbus_message_iter_init (reply, &iter); gboolean trusted = FALSE;
int dbus_type; dbus_error_init (&error);
dbus_type = dbus_message_iter_get_uint32 (&iter); if (!dbus_message_get_args (reply, &error, DBUS_TYPE_BOOLEAN, &trusted, DBUS_TYPE_INVALID))
trusted = FALSE;
if (dbus_error_is_set (&error))
dbus_error_free (&error);
dbus_message_unref (reply); dbus_message_unref (reply);
dbus_message_unref (message); dbus_message_unref (message);
return (dbus_type); return (trusted);
} }
@ -209,7 +211,7 @@ void get_networks_of_type (DBusConnection *connection, NMINetworkType type)
char *essid = get_network_string_property (connection, networks[i], "getNetworkEssid", type); char *essid = get_network_string_property (connection, networks[i], "getNetworkEssid", type);
char *key = get_network_string_property (connection, networks[i], "getNetworkKey", type); char *key = get_network_string_property (connection, networks[i], "getNetworkKey", type);
fprintf( stderr, " %d:\t%s\t%s\n", get_network_prio (connection, networks[i], type), essid, key); fprintf(stderr, " %s\t%s\t%s\n", essid, key, get_network_trusted (connection, networks[i], type) ? "trusted" : "untrusted");
} }
} }
@ -345,8 +347,7 @@ int main( int argc, char *argv[] )
exit (1); exit (1);
} }
get_networks_of_type (connection, NETWORK_TYPE_TRUSTED); get_networks_of_type (connection, NETWORK_TYPE_ALLOWED);
get_networks_of_type (connection, NETWORK_TYPE_PREFERRED);
get_networks_of_type (connection, NETWORK_TYPE_DEVICE); get_networks_of_type (connection, NETWORK_TYPE_DEVICE);
get_user_key_for_network (connection); get_user_key_for_network (connection);