2005-04-27 Dan Williams <dcbw@redhat.com>
* Merge the applet and the info-daemon, and move the converged applet under gnome/applet * Move libnm_glib to gnome/libnm_glib * Convert most dbus calls between the applet, info-daemon, and NM into async calls * Fix a few things valgrind noticed * Make NM broadcast state more reliably git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@586 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
2005-04-27 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* Merge the applet and the info-daemon, and move the converged
|
||||||
|
applet under gnome/applet
|
||||||
|
* Move libnm_glib to gnome/libnm_glib
|
||||||
|
* Convert most dbus calls between the applet, info-daemon, and NM
|
||||||
|
into async calls
|
||||||
|
* Fix a few things valgrind noticed
|
||||||
|
* Make NM broadcast state more reliably
|
||||||
|
|
||||||
2005-04-22 Pawan chitrakar <pawan@nplinux.org>
|
2005-04-22 Pawan chitrakar <pawan@nplinux.org>
|
||||||
|
|
||||||
* configure.in: Added ne in ALL_LINGUAS
|
* configure.in: Added ne in ALL_LINGUAS
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = utils dhcpcd src libnm_glib dispatcher-daemon $(notification_icon_dir) info-daemon vpn-daemons initscript test po
|
SUBDIRS = utils dhcpcd src dispatcher-daemon gnome vpn-daemons initscript test po
|
||||||
|
|
||||||
EXTRA_DIST = CONTRIBUTING NetworkManager.pc.in NetworkManager.h
|
EXTRA_DIST = CONTRIBUTING NetworkManager.pc.in NetworkManager.h
|
||||||
|
|
||||||
|
@@ -44,12 +44,14 @@
|
|||||||
/*
|
/*
|
||||||
* Some common errors
|
* Some common errors
|
||||||
*/
|
*/
|
||||||
#define NM_DBUS_NO_ACTIVE_NET_ERROR "org.freedesktop.NetworkManager.NoActiveNetwork"
|
#define NM_DBUS_NO_DEVICES_ERROR "org.freedesktop.NetworkManager.NoDevices"
|
||||||
#define NM_DBUS_NO_ACTIVE_DEVICE_ERROR "org.freedesktop.NetworkManager.NoActiveDevice"
|
|
||||||
#define NM_DBUS_NO_NETWORKS_ERROR "org.freedesktop.NetworkManager.NoNetworks"
|
#define NM_DBUS_NO_NETWORKS_ERROR "org.freedesktop.NetworkManager.NoNetworks"
|
||||||
|
#define NM_DBUS_NO_ACTIVE_DEVICE_ERROR "org.freedesktop.NetworkManager.NoActiveDevice"
|
||||||
|
#define NM_DBUS_NO_ACTIVE_NET_ERROR "org.freedesktop.NetworkManager.NoActiveNetwork"
|
||||||
|
|
||||||
#define NM_DBUS_NO_ACTIVE_VPN_CONNECTION "org.freedesktop.NetworkManager.VPNConnections.NoActiveVPNConnection"
|
#define NM_DBUS_NO_ACTIVE_VPN_CONNECTION "org.freedesktop.NetworkManager.VPNConnections.NoActiveVPNConnection"
|
||||||
#define NM_DBUS_NO_VPN_CONNECTIONS "org.freedesktop.NetworkManager.VPNConnections.NoVPNConnections"
|
#define NM_DBUS_NO_VPN_CONNECTIONS "org.freedesktop.NetworkManager.VPNConnections.NoVPNConnections"
|
||||||
|
#define NM_DBUS_INVALID_VPN_CONNECTION "org.freedesktop.NetworkManager.VPNConnections.InvalidVPNConnection"
|
||||||
|
|
||||||
#define NM_DBUS_VPN_STARTING_IN_PROGRESS "StartingInProgress"
|
#define NM_DBUS_VPN_STARTING_IN_PROGRESS "StartingInProgress"
|
||||||
#define NM_DBUS_VPN_ALREADY_STARTED "AlreadyStarted"
|
#define NM_DBUS_VPN_ALREADY_STARTED "AlreadyStarted"
|
||||||
@@ -58,12 +60,36 @@
|
|||||||
#define NM_DBUS_VPN_WRONG_STATE "WrongState"
|
#define NM_DBUS_VPN_WRONG_STATE "WrongState"
|
||||||
#define NM_DBUS_VPN_BAD_ARGUMENTS "BadArguments"
|
#define NM_DBUS_VPN_BAD_ARGUMENTS "BadArguments"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* VPN daemon signals
|
||||||
|
*/
|
||||||
#define NM_DBUS_VPN_SIGNAL_LOGIN_FAILED "LoginFailed"
|
#define NM_DBUS_VPN_SIGNAL_LOGIN_FAILED "LoginFailed"
|
||||||
#define NM_DBUS_VPN_SIGNAL_CONFIG_BAD "ConfigurationBad"
|
#define NM_DBUS_VPN_SIGNAL_CONFIG_BAD "ConfigurationBad"
|
||||||
#define NM_DBUS_VPN_SIGNAL_STATE_CHANGE "StateChange"
|
#define NM_DBUS_VPN_SIGNAL_STATE_CHANGE "StateChange"
|
||||||
#define NM_DBUS_VPN_SIGNAL_IP4_CONFIG "IP4Config"
|
#define NM_DBUS_VPN_SIGNAL_IP4_CONFIG "IP4Config"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NetworkManager signals
|
||||||
|
*/
|
||||||
|
#define NM_DBUS_SIGNAL_STATE_CHANGE "StateChange"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types of NetworkManager devices
|
||||||
|
*/
|
||||||
|
typedef enum NMState
|
||||||
|
{
|
||||||
|
NM_STATE_UNKNOWN = 0,
|
||||||
|
NM_STATE_ASLEEP,
|
||||||
|
NM_STATE_SCANNING,
|
||||||
|
NM_STATE_CONNECTING,
|
||||||
|
NM_STATE_CONNECTED,
|
||||||
|
NM_STATE_DISCONNECTED
|
||||||
|
} NMState;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Types of NetworkManager devices
|
* Types of NetworkManager devices
|
||||||
*/
|
*/
|
||||||
@@ -161,10 +187,4 @@ typedef enum NMVPNState
|
|||||||
NM_VPN_STATE_STOPPED
|
NM_VPN_STATE_STOPPED
|
||||||
} NMVPNState;
|
} NMVPNState;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Info-daemon specific preference locations
|
|
||||||
*/
|
|
||||||
#define NMI_GCONF_WIRELESS_NETWORKS_PATH "/system/networking/wireless/networks"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
17
configure.in
@@ -193,15 +193,6 @@ AC_DEFINE_UNQUOTED(NM_NAMED_BINARY_PATH, "$with_named", [Define to path of named
|
|||||||
AC_DEFINE_UNQUOTED(NM_NAMED_DATA_DIR, "$with_named_dir", [Define to path of named data directory])
|
AC_DEFINE_UNQUOTED(NM_NAMED_DATA_DIR, "$with_named_dir", [Define to path of named data directory])
|
||||||
AC_DEFINE_UNQUOTED(NM_NAMED_USER, "$with_named_user", [Define to named username])
|
AC_DEFINE_UNQUOTED(NM_NAMED_USER, "$with_named_user", [Define to named username])
|
||||||
|
|
||||||
AC_ARG_ENABLE(notification-icon, AC_HELP_STRING([--enable-notification-icon], [builds the wireless applet as a notification icon]), enable_notification_icon=$enableval, enable_notification_icon=yes)
|
|
||||||
|
|
||||||
AM_CONDITIONAL(BUILD_NOTIFICATION_ICON, test x$enable_notification_icon = xyes)
|
|
||||||
if test x$enable_notification_icon == xyes ; then
|
|
||||||
AC_DEFINE_UNQUOTED(BUILD_NOTIFICATION_ICON, "$BUILD_NOTIFICATION_ICON", [Should we build the notification icon instead of the applet])
|
|
||||||
notification_icon_dir="panel-applet"
|
|
||||||
AC_SUBST(notification_icon_dir)
|
|
||||||
fi
|
|
||||||
|
|
||||||
#### find the actual value for $prefix that we'll end up with
|
#### find the actual value for $prefix that we'll end up with
|
||||||
## (I know this is broken and should be done in the Makefile, but
|
## (I know this is broken and should be done in the Makefile, but
|
||||||
## that's a major pain and almost nobody actually seems to care)
|
## that's a major pain and almost nobody actually seems to care)
|
||||||
@@ -274,11 +265,14 @@ src/named-manager/Makefile
|
|||||||
src/vpn-manager/Makefile
|
src/vpn-manager/Makefile
|
||||||
src/backends/Makefile
|
src/backends/Makefile
|
||||||
dispatcher-daemon/Makefile
|
dispatcher-daemon/Makefile
|
||||||
info-daemon/Makefile
|
gnome/Makefile
|
||||||
|
gnome/applet/Makefile
|
||||||
|
gnome/applet/icons/Makefile
|
||||||
|
gnome/libnm_glib/libnm_glib.pc
|
||||||
|
gnome/libnm_glib/Makefile
|
||||||
panel-applet/Makefile
|
panel-applet/Makefile
|
||||||
panel-applet/icons/Makefile
|
panel-applet/icons/Makefile
|
||||||
dhcpcd/Makefile
|
dhcpcd/Makefile
|
||||||
libnm_glib/Makefile
|
|
||||||
test/Makefile
|
test/Makefile
|
||||||
initscript/Makefile
|
initscript/Makefile
|
||||||
initscript/RedHat/Makefile
|
initscript/RedHat/Makefile
|
||||||
@@ -287,7 +281,6 @@ initscript/Debian/Makefile
|
|||||||
initscript/Slackware/Makefile
|
initscript/Slackware/Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
NetworkManager.pc
|
NetworkManager.pc
|
||||||
libnm_glib/libnm_glib.pc
|
|
||||||
vpn-daemons/Makefile
|
vpn-daemons/Makefile
|
||||||
vpn-daemons/vpnc/Makefile
|
vpn-daemons/vpnc/Makefile
|
||||||
])
|
])
|
||||||
|
1
gnome/Makefile.am
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SUBDIRS = applet libnm_glib
|
89
gnome/applet/Makefile.am
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
SUBDIRS=icons
|
||||||
|
|
||||||
|
NULL=
|
||||||
|
|
||||||
|
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
|
||||||
|
|
||||||
|
libexec_PROGRAMS = nm-applet
|
||||||
|
|
||||||
|
nm_applet_CFLAGS = \
|
||||||
|
$(DBUS_CFLAGS) \
|
||||||
|
$(GTHREAD_CFLAGS) \
|
||||||
|
$(HAL_CFLAGS) \
|
||||||
|
$(DBUS_GLIB_CFLAGS) \
|
||||||
|
$(GLADE_CFLAGS) \
|
||||||
|
$(GTK_CFLAGS) \
|
||||||
|
$(GCONF_CFLAGS) \
|
||||||
|
$(LIBGNOMEUI_CFLAGS) \
|
||||||
|
$(PANEL_APPLET_CFLAGS) \
|
||||||
|
$(GNOMEKEYRING_CFLAGS) \
|
||||||
|
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||||
|
-DGLADEDIR=\""$(gladedir)"\" \
|
||||||
|
-DDBUS_API_SUBJECT_TO_CHANGE \
|
||||||
|
-DG_DISABLE_DEPRECATED \
|
||||||
|
-DGDK_DISABLE_DEPRECATED \
|
||||||
|
-DGNOME_DISABLE_DEPRECATED \
|
||||||
|
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
|
||||||
|
-DVERSION=\"$(VERSION)\" \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
nm_applet_SOURCES = \
|
||||||
|
main.c \
|
||||||
|
applet.c \
|
||||||
|
applet.h \
|
||||||
|
applet-dbus.c \
|
||||||
|
applet-dbus.h \
|
||||||
|
applet-dbus-devices.c \
|
||||||
|
applet-dbus-devices.h \
|
||||||
|
applet-dbus-vpn.c \
|
||||||
|
applet-dbus-vpn.h \
|
||||||
|
applet-dbus-info.c \
|
||||||
|
applet-dbus-info.h \
|
||||||
|
wireless-network.c \
|
||||||
|
wireless-network.h \
|
||||||
|
nm-device.c \
|
||||||
|
nm-device.h \
|
||||||
|
other-network-dialog.c \
|
||||||
|
other-network-dialog.h \
|
||||||
|
passphrase-dialog.c \
|
||||||
|
passphrase-dialog.h \
|
||||||
|
menu-items.c \
|
||||||
|
menu-items.h \
|
||||||
|
gtkcellview.c \
|
||||||
|
gtkcellview.h \
|
||||||
|
gtkcellrendererprogress.c \
|
||||||
|
gtkcellrendererprogress.h \
|
||||||
|
eggtrayicon.c \
|
||||||
|
eggtrayicon.h \
|
||||||
|
vpn-password-dialog.c \
|
||||||
|
vpn-password-dialog.h \
|
||||||
|
vpn-connection.c \
|
||||||
|
vpn-connection.h \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
nm_applet_LDADD = \
|
||||||
|
$(DBUS_LIBS) \
|
||||||
|
$(HAL_LIBS) \
|
||||||
|
$(GTHREAD_LIBS) \
|
||||||
|
$(GLADE_LIBS) \
|
||||||
|
$(DBUS_GLIB_LIBS) \
|
||||||
|
$(PANEL_APPLET_LIBS) \
|
||||||
|
$(GTK_LIBS) \
|
||||||
|
$(GCONF_LIBS) \
|
||||||
|
$(LIBGNOMEUI_LIBS) \
|
||||||
|
$(GNOMEKEYRING_LIBS) \
|
||||||
|
$(top_builddir)/utils/libnmutils.la \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
|
||||||
|
gladedir = $(datadir)/NetworkManagerNotification
|
||||||
|
glade_DATA = wireless-applet.glade keyring.png
|
||||||
|
|
||||||
|
dbusservicedir = $(DBUS_SYS_DIR)
|
||||||
|
dbusservice_DATA = nm-applet.conf
|
||||||
|
|
||||||
|
CLEANFILES = $(server_DATA) *.bak *.gladep
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
$(glade_DATA) \
|
||||||
|
$(NULL)
|
1476
gnome/applet/applet-dbus-devices.c
Normal file
50
gnome/applet/applet-dbus-devices.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
|
/* 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 2004-2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APPLET_DBUS_DEVICES_H
|
||||||
|
#define APPLET_DBUS_DEVICES_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
#include "applet.h"
|
||||||
|
#include "nm-device.h"
|
||||||
|
#include "wireless-network.h"
|
||||||
|
|
||||||
|
void nmwa_dbus_update_one_vpn_connection (DBusConnection *connection, const char *name, NMWirelessApplet *applet, gboolean is_active);
|
||||||
|
void nmwa_dbus_update_vpn_connections (NMWirelessApplet *applet);
|
||||||
|
gboolean nmwa_dbus_update_active_device_strength (NMWirelessApplet *applet);
|
||||||
|
|
||||||
|
void nmwa_dbus_update_nm_state (NMWirelessApplet *applet);
|
||||||
|
|
||||||
|
void nmwa_dbus_get_active_device (NMWirelessApplet *applet);
|
||||||
|
void nmwa_dbus_update_devices (NMWirelessApplet *applet);
|
||||||
|
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_update_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path, const char *active_net_path);
|
||||||
|
void nmwa_dbus_device_remove_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path);
|
||||||
|
|
||||||
|
void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, WirelessNetwork *net, NMEncKeyType key_type, const char *passphrase);
|
||||||
|
void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, const char *essid, NMEncKeyType key_type, const char *passphrase);
|
||||||
|
|
||||||
|
#endif
|
@@ -1,5 +1,5 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
* for WEP key entry
|
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
|
||||||
*
|
*
|
||||||
* Dan Williams <dcbw@redhat.com>
|
* Dan Williams <dcbw@redhat.com>
|
||||||
*
|
*
|
||||||
@@ -17,46 +17,25 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004-2005 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
#include "NetworkManagerInfo.h"
|
#include <dbus/dbus.h>
|
||||||
#include "NetworkManagerInfoDbus.h"
|
#include <gtk/gtk.h>
|
||||||
#include "NetworkManagerInfoPassphraseDialog.h"
|
#include <glade/glade.h>
|
||||||
#include "NetworkManagerInfoVPN.h"
|
#include "NetworkManager.h"
|
||||||
|
#include "applet.h"
|
||||||
|
#include "applet-dbus.h"
|
||||||
|
#include "applet-dbus-info.h"
|
||||||
|
#include "passphrase-dialog.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_show_warning_dialog
|
|
||||||
*
|
|
||||||
* pop up a warning or error dialog with certain text
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void nmi_show_warning_dialog (gboolean error, gchar *mesg, ...)
|
|
||||||
{
|
|
||||||
GtkWidget *dialog;
|
|
||||||
char *tmp;
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start (ap,mesg);
|
|
||||||
tmp = g_strdup_vprintf (mesg,ap);
|
|
||||||
dialog = gtk_message_dialog_new (NULL, 0, error ? GTK_MESSAGE_ERROR : GTK_MESSAGE_WARNING,
|
|
||||||
GTK_BUTTONS_OK, mesg, NULL);
|
|
||||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
g_free (tmp);
|
|
||||||
va_end (ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_network_type_valid
|
* nmi_network_type_valid
|
||||||
@@ -70,83 +49,42 @@ inline gboolean nmi_network_type_valid (NMNetworkType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_create_error_message
|
|
||||||
*
|
|
||||||
* Make a DBus error message
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static DBusMessage *nmi_dbus_create_error_message (DBusMessage *message, const char *exception_namespace,
|
|
||||||
const char *exception, const char *format, ...)
|
|
||||||
{
|
|
||||||
char *exception_text;
|
|
||||||
DBusMessage *reply_message;
|
|
||||||
va_list args;
|
|
||||||
char error_text[512];
|
|
||||||
|
|
||||||
|
|
||||||
va_start (args, format);
|
|
||||||
vsnprintf (error_text, 512, format, args);
|
|
||||||
va_end (args);
|
|
||||||
|
|
||||||
exception_text = g_strdup_printf ("%s.%s", exception_namespace, exception);
|
|
||||||
reply_message = dbus_message_new_error (message, exception_text, error_text);
|
|
||||||
g_free (exception_text);
|
|
||||||
|
|
||||||
return (reply_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_dbus_get_key_for_network
|
* nmi_dbus_get_key_for_network
|
||||||
*
|
*
|
||||||
* Throw up the user key dialog
|
* Throw up the user key dialog
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void nmi_dbus_get_key_for_network (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage * nmi_dbus_get_key_for_network (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
DBusError error;
|
char * dev_path = NULL;
|
||||||
char *device = NULL;
|
char * net_path = NULL;
|
||||||
char *network = NULL;
|
int attempt = 0;
|
||||||
int attempt = 0;
|
gboolean success = FALSE;
|
||||||
|
|
||||||
dbus_error_init (&error);
|
if (dbus_message_get_args (message, NULL,
|
||||||
if (dbus_message_get_args (message, &error,
|
DBUS_TYPE_OBJECT_PATH, &dev_path,
|
||||||
DBUS_TYPE_STRING, &device,
|
DBUS_TYPE_OBJECT_PATH, &net_path,
|
||||||
DBUS_TYPE_STRING, &network,
|
|
||||||
DBUS_TYPE_INT32, &attempt,
|
DBUS_TYPE_INT32, &attempt,
|
||||||
DBUS_TYPE_INVALID))
|
DBUS_TYPE_INVALID))
|
||||||
{
|
{
|
||||||
nmi_passphrase_dialog_show (device, network, info);
|
NetworkDevice *dev = NULL;
|
||||||
}
|
WirelessNetwork *net = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if ((dev = nmwa_get_device_for_nm_device (applet->gui_device_list, dev_path)))
|
||||||
* nmi_dbus_get_user_pass
|
{
|
||||||
*
|
if ((net = network_device_get_wireless_network_by_nm_path (dev, net_path)))
|
||||||
* Request a username/password for VPN login
|
{
|
||||||
*
|
nmi_passphrase_dialog_show (applet->passphrase_dialog, dev, net, message);
|
||||||
*/
|
success = TRUE;
|
||||||
static void nmi_dbus_get_vpn_userpass (NMIAppInfo *info, DBusMessage *message)
|
}
|
||||||
{
|
|
||||||
DBusError error;
|
|
||||||
char *vpn;
|
|
||||||
char *username;
|
|
||||||
dbus_bool_t retry;
|
|
||||||
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if (dbus_message_get_args (message, &error,
|
|
||||||
DBUS_TYPE_STRING, &vpn,
|
|
||||||
DBUS_TYPE_STRING, &username,
|
|
||||||
DBUS_TYPE_BOOLEAN, &retry,
|
|
||||||
DBUS_TYPE_INVALID))
|
|
||||||
{
|
|
||||||
if (username[0] == '\0') {
|
|
||||||
username = NULL;
|
|
||||||
}
|
}
|
||||||
nmi_vpn_request_password (info, message, vpn, username, retry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
return dbus_message_new_error (message, "GetKeyError", "Could not get user key for network.");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,66 +94,27 @@ static void nmi_dbus_get_vpn_userpass (NMIAppInfo *info, DBusMessage *message)
|
|||||||
* Alert NetworkManager of the new user key
|
* Alert NetworkManager of the new user key
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const int key_type)
|
||||||
const char *network, const char *passphrase, const int key_type)
|
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage * reply;
|
||||||
|
const char * dev_path;
|
||||||
|
const char * net_path;
|
||||||
|
|
||||||
g_return_if_fail (connection != NULL);
|
g_return_if_fail (connection != NULL);
|
||||||
g_return_if_fail (device != NULL);
|
|
||||||
g_return_if_fail (network != NULL);
|
|
||||||
g_return_if_fail (passphrase != NULL);
|
g_return_if_fail (passphrase != NULL);
|
||||||
|
|
||||||
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setKeyForNetwork")))
|
if (!(reply = dbus_message_new_method_return (message)))
|
||||||
{
|
{
|
||||||
nm_warning ("nmi_dbus_return_user_key(): Couldn't allocate the dbus message");
|
nm_warning ("nmi_dbus_return_user_key(): Couldn't allocate the dbus message");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add network name and passphrase */
|
dbus_message_append_args (reply, DBUS_TYPE_STRING, &passphrase, DBUS_TYPE_INT32, &key_type, DBUS_TYPE_INVALID);
|
||||||
if (dbus_message_append_args (message, DBUS_TYPE_STRING, &device,
|
|
||||||
DBUS_TYPE_STRING, &network,
|
|
||||||
DBUS_TYPE_STRING, &passphrase,
|
|
||||||
DBUS_TYPE_INT32, &key_type,
|
|
||||||
DBUS_TYPE_INVALID))
|
|
||||||
{
|
|
||||||
if (!dbus_connection_send (connection, message, NULL))
|
|
||||||
nm_warning ("nmi_dbus_return_user_key(): dbus could not send the message");
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_unref (message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_return_userpass
|
|
||||||
*
|
|
||||||
* Alert caller of the username/password
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_dbus_return_vpn_password (DBusConnection *connection, DBusMessage *message, const char *password)
|
|
||||||
{
|
|
||||||
DBusMessage *reply;
|
|
||||||
|
|
||||||
g_return_if_fail (connection != NULL);
|
|
||||||
g_return_if_fail (message != NULL);
|
|
||||||
g_return_if_fail (password != NULL);
|
|
||||||
|
|
||||||
if (password == NULL)
|
|
||||||
{
|
|
||||||
reply = dbus_message_new_error (message, NMI_DBUS_INTERFACE ".Cancelled", "Operation cancelled by user");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reply = dbus_message_new_method_return (message);
|
|
||||||
dbus_message_append_args (reply,
|
|
||||||
DBUS_TYPE_STRING, &password,
|
|
||||||
DBUS_TYPE_INVALID);
|
|
||||||
}
|
|
||||||
dbus_connection_send (connection, reply, NULL);
|
dbus_connection_send (connection, reply, NULL);
|
||||||
dbus_message_unref (reply);
|
dbus_message_unref (reply);
|
||||||
dbus_message_unref (message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_dbus_signal_update_network
|
* nmi_dbus_signal_update_network
|
||||||
*
|
*
|
||||||
@@ -255,7 +154,7 @@ void nmi_dbus_signal_update_network (DBusConnection *connection, const char *net
|
|||||||
* of a string array in a dbus message.
|
* of a string array in a dbus message.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_get_networks (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
GSList *dir_list = NULL;
|
GSList *dir_list = NULL;
|
||||||
GSList *element = NULL;
|
GSList *element = NULL;
|
||||||
@@ -265,23 +164,23 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag
|
|||||||
DBusMessageIter iter_array;
|
DBusMessageIter iter_array;
|
||||||
NMNetworkType type;
|
NMNetworkType type;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID)
|
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID)
|
||||||
|| !nmi_network_type_valid (type))
|
|| !nmi_network_type_valid (type))
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
reply_message = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManagerInfo::getNetworks called with invalid arguments.");
|
"NetworkManagerInfo::getNetworks called with invalid arguments.");
|
||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List all allowed access points that gconf knows about */
|
/* List all allowed access points that gconf knows about */
|
||||||
element = dir_list = gconf_client_all_dirs (info->gconf_client, NMI_GCONF_WIRELESS_NETWORKS_PATH, NULL);
|
element = dir_list = gconf_client_all_dirs (applet->gconf_client, GCONF_PATH_WIRELESS_NETWORKS, NULL);
|
||||||
if (!dir_list)
|
if (!dir_list)
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoNetworks",
|
reply_message = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoNetworks",
|
||||||
"There were are no wireless networks stored.");
|
"There were are no wireless networks stored.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -301,7 +200,7 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag
|
|||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
|
|
||||||
g_snprintf (&key[0], 99, "%s/essid", (char *)(element->data));
|
g_snprintf (&key[0], 99, "%s/essid", (char *)(element->data));
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
value = gconf_client_get (applet->gconf_client, key, NULL);
|
||||||
if (value && gconf_value_get_string (value))
|
if (value && gconf_value_get_string (value))
|
||||||
{
|
{
|
||||||
const gchar *essid;
|
const gchar *essid;
|
||||||
@@ -321,7 +220,7 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag
|
|||||||
if (!value_added)
|
if (!value_added)
|
||||||
{
|
{
|
||||||
dbus_message_unref (reply_message);
|
dbus_message_unref (reply_message);
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoNetworks",
|
reply_message = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoNetworks",
|
||||||
"There were are no wireless networks stored.");
|
"There were are no wireless networks stored.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,7 +235,7 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag
|
|||||||
* Returns the properties of a specific wireless network from gconf
|
* Returns the properties of a specific wireless network from gconf
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_get_network_properties (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
DBusMessage *reply = NULL;
|
DBusMessage *reply = NULL;
|
||||||
gchar *gconf_key = NULL;
|
gchar *gconf_key = NULL;
|
||||||
@@ -355,7 +254,7 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
gboolean trusted = FALSE;
|
gboolean trusted = FALSE;
|
||||||
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
|
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
@@ -363,7 +262,7 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
|| !nmi_network_type_valid (type)
|
|| !nmi_network_type_valid (type)
|
||||||
|| (strlen (network) <= 0))
|
|| (strlen (network) <= 0))
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManagerInfo::getNetworkProperties called with invalid arguments.");
|
"NetworkManagerInfo::getNetworkProperties called with invalid arguments.");
|
||||||
return (reply);
|
return (reply);
|
||||||
}
|
}
|
||||||
@@ -371,8 +270,8 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
escaped_network = gconf_escape_key (network, strlen (network));
|
||||||
|
|
||||||
/* Grab essid key for our access point from GConf */
|
/* Grab essid key for our access point from GConf */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
essid = g_strdup (gconf_value_get_string (value));
|
essid = g_strdup (gconf_value_get_string (value));
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -380,8 +279,8 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab timestamp key for our access point from GConf */
|
/* Grab timestamp key for our access point from GConf */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
timestamp = gconf_value_get_int (value);
|
timestamp = gconf_value_get_int (value);
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -389,8 +288,8 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab user-key key for our access point from GConf */
|
/* Grab user-key key for our access point from GConf */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/key", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
key = g_strdup (gconf_value_get_string (value));
|
key = g_strdup (gconf_value_get_string (value));
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -399,8 +298,8 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
key = g_strdup ("");
|
key = g_strdup ("");
|
||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
gconf_key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
key_type = gconf_value_get_int (value);
|
key_type = gconf_value_get_int (value);
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -408,8 +307,8 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab the network's last authentication mode, if known */
|
/* Grab the network's last authentication mode, if known */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/auth_method", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/auth_method", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
auth_method = gconf_value_get_int (value);
|
auth_method = gconf_value_get_int (value);
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -417,8 +316,8 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab the network's trusted status */
|
/* Grab the network's trusted status */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/trusted", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
trusted = gconf_value_get_bool (value);
|
trusted = gconf_value_get_bool (value);
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -426,25 +325,25 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab the list of stored AP MAC addresses */
|
/* Grab the list of stored AP MAC addresses */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/addresses", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/addresses", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
ap_addrs_value = gconf_client_get (info->gconf_client, gconf_key, NULL);
|
ap_addrs_value = gconf_client_get (applet->gconf_client, gconf_key, NULL);
|
||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
if (!essid || (timestamp < 0) || (key_type < 0))
|
if (!essid || (timestamp < 0) || (key_type < 0))
|
||||||
{
|
{
|
||||||
if (!essid)
|
if (!essid)
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
||||||
"NetworkManagerInfo::getNetworkProperties could not access essid for network '%s'", network);
|
"NetworkManagerInfo::getNetworkProperties could not access essid for network '%s'", network);
|
||||||
}
|
}
|
||||||
else if (timestamp < 0)
|
else if (timestamp < 0)
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
||||||
"NetworkManagerInfo::getNetworkProperties could not access timestamp for network '%s'", network);
|
"NetworkManagerInfo::getNetworkProperties could not access timestamp for network '%s'", network);
|
||||||
}
|
}
|
||||||
else if (key_type < 0)
|
else if (key_type < 0)
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData",
|
||||||
"NetworkManagerInfo::getNetworkProperties could not access key_type for network '%s'", network);
|
"NetworkManagerInfo::getNetworkProperties could not access key_type for network '%s'", network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -533,33 +432,33 @@ void nmi_dbus_signal_update_vpn_connection (DBusConnection *connection, const ch
|
|||||||
* of a string array in a dbus message.
|
* of a string array in a dbus message.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_get_vpn_connections (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_get_vpn_connections (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
GSList *dir_list = NULL;
|
GSList *dir_list = NULL;
|
||||||
GSList *element = NULL;
|
GSList *element = NULL;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
DBusMessage *reply_message = NULL;
|
DBusMessage *reply = NULL;
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter;
|
||||||
DBusMessageIter iter_array;
|
DBusMessageIter iter_array;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
|
|
||||||
/* List all VPN connections that gconf knows about */
|
/* List all VPN connections that gconf knows about */
|
||||||
element = dir_list = gconf_client_all_dirs (info->gconf_client, NMI_GCONF_VPN_CONNECTIONS_PATH, NULL);
|
element = dir_list = gconf_client_all_dirs (applet->gconf_client, GCONF_PATH_VPN_CONNECTIONS, NULL);
|
||||||
if (!dir_list)
|
if (!dir_list)
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoVPNConnections",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoVPNConnections",
|
||||||
"There are no VPN connections stored.");
|
"There are no VPN connections stored.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gboolean value_added = FALSE;
|
gboolean value_added = FALSE;
|
||||||
|
|
||||||
reply_message = dbus_message_new_method_return (message);
|
reply = dbus_message_new_method_return (message);
|
||||||
dbus_message_iter_init_append (reply_message, &iter);
|
dbus_message_iter_init_append (reply, &iter);
|
||||||
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &iter_array);
|
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &iter_array);
|
||||||
|
|
||||||
/* Append the essid of every allowed or ignored access point we know of
|
/* Append the essid of every allowed or ignored access point we know of
|
||||||
@@ -571,7 +470,7 @@ static DBusMessage *nmi_dbus_get_vpn_connections (NMIAppInfo *info, DBusMessage
|
|||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
|
|
||||||
g_snprintf (&key[0], 99, "%s/name", (char *)(element->data));
|
g_snprintf (&key[0], 99, "%s/name", (char *)(element->data));
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
value = gconf_client_get (applet->gconf_client, key, NULL);
|
||||||
if (value && gconf_value_get_string (value))
|
if (value && gconf_value_get_string (value))
|
||||||
{
|
{
|
||||||
const gchar *essid;
|
const gchar *essid;
|
||||||
@@ -590,13 +489,13 @@ static DBusMessage *nmi_dbus_get_vpn_connections (NMIAppInfo *info, DBusMessage
|
|||||||
|
|
||||||
if (!value_added)
|
if (!value_added)
|
||||||
{
|
{
|
||||||
dbus_message_unref (reply_message);
|
dbus_message_unref (reply);
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoVPNConnections",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoVPNConnections",
|
||||||
"There are no VPN connections stored.");
|
"There are no VPN connections stored.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (reply_message);
|
return (reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -606,7 +505,7 @@ static DBusMessage *nmi_dbus_get_vpn_connections (NMIAppInfo *info, DBusMessage
|
|||||||
* Returns the properties of a specific VPN connection from gconf
|
* Returns the properties of a specific VPN connection from gconf
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
DBusMessage *reply = NULL;
|
DBusMessage *reply = NULL;
|
||||||
gchar *gconf_key = NULL;
|
gchar *gconf_key = NULL;
|
||||||
@@ -618,14 +517,14 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMIAppInfo *info, DB
|
|||||||
char *service_name = NULL;
|
char *service_name = NULL;
|
||||||
char *user_name = NULL;
|
char *user_name = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &vpn_connection, DBUS_TYPE_INVALID)
|
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &vpn_connection, DBUS_TYPE_INVALID)
|
||||||
|| (strlen (vpn_connection) <= 0))
|
|| (strlen (vpn_connection) <= 0))
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManagerInfo::getVPNConnectionProperties called with invalid arguments.");
|
"NetworkManagerInfo::getVPNConnectionProperties called with invalid arguments.");
|
||||||
return (reply);
|
return (reply);
|
||||||
}
|
}
|
||||||
@@ -633,8 +532,8 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMIAppInfo *info, DB
|
|||||||
escaped_name = gconf_escape_key (vpn_connection, strlen (vpn_connection));
|
escaped_name = gconf_escape_key (vpn_connection, strlen (vpn_connection));
|
||||||
|
|
||||||
/* User-visible name of connection */
|
/* User-visible name of connection */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/name", NMI_GCONF_VPN_CONNECTIONS_PATH, escaped_name);
|
gconf_key = g_strdup_printf ("%s/%s/name", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
name = g_strdup (gconf_value_get_string (value));
|
name = g_strdup (gconf_value_get_string (value));
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -642,8 +541,8 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMIAppInfo *info, DB
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Service name of connection */
|
/* Service name of connection */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/service_name", NMI_GCONF_VPN_CONNECTIONS_PATH, escaped_name);
|
gconf_key = g_strdup_printf ("%s/%s/service_name", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
service_name = g_strdup (gconf_value_get_string (value));
|
service_name = g_strdup (gconf_value_get_string (value));
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -651,8 +550,8 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMIAppInfo *info, DB
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* User name of connection */
|
/* User name of connection */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/user_name", NMI_GCONF_VPN_CONNECTIONS_PATH, escaped_name);
|
gconf_key = g_strdup_printf ("%s/%s/user_name", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
user_name = g_strdup (gconf_value_get_string (value));
|
user_name = g_strdup (gconf_value_get_string (value));
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
@@ -661,17 +560,17 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMIAppInfo *info, DB
|
|||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
||||||
"NetworkManagerInfo::getVPNConnectionProperties could not access the name for connection '%s'", vpn_connection);
|
"NetworkManagerInfo::getVPNConnectionProperties could not access the name for connection '%s'", vpn_connection);
|
||||||
}
|
}
|
||||||
else if (!service_name)
|
else if (!service_name)
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
||||||
"NetworkManagerInfo::getVPNConnectionProperties could not access the service name for connection '%s'", vpn_connection);
|
"NetworkManagerInfo::getVPNConnectionProperties could not access the service name for connection '%s'", vpn_connection);
|
||||||
}
|
}
|
||||||
else if (!user_name)
|
else if (!user_name)
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
||||||
"NetworkManagerInfo::getVPNConnectionProperties could not access the user name for connection '%s'", vpn_connection);
|
"NetworkManagerInfo::getVPNConnectionProperties could not access the user name for connection '%s'", vpn_connection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -700,7 +599,7 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMIAppInfo *info, DB
|
|||||||
* Returns vpn-daemon specific properties for a particular VPN connection.
|
* Returns vpn-daemon specific properties for a particular VPN connection.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_get_vpn_connection_vpn_data (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_get_vpn_connection_vpn_data (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
DBusMessage *reply = NULL;
|
DBusMessage *reply = NULL;
|
||||||
gchar *gconf_key = NULL;
|
gchar *gconf_key = NULL;
|
||||||
@@ -712,14 +611,14 @@ static DBusMessage *nmi_dbus_get_vpn_connection_vpn_data (NMIAppInfo *info, DBus
|
|||||||
DBusMessageIter iter, array_iter;
|
DBusMessageIter iter, array_iter;
|
||||||
GSList *elt;
|
GSList *elt;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)
|
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)
|
||||||
|| (strlen (name) <= 0))
|
|| (strlen (name) <= 0))
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManagerInfo::getVPNConnectionVPNData called with invalid arguments.");
|
"NetworkManagerInfo::getVPNConnectionVPNData called with invalid arguments.");
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
@@ -727,10 +626,10 @@ static DBusMessage *nmi_dbus_get_vpn_connection_vpn_data (NMIAppInfo *info, DBus
|
|||||||
escaped_name = gconf_escape_key (name, strlen (name));
|
escaped_name = gconf_escape_key (name, strlen (name));
|
||||||
|
|
||||||
/* User-visible name of connection */
|
/* User-visible name of connection */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/name", NMI_GCONF_VPN_CONNECTIONS_PATH, escaped_name);
|
gconf_key = g_strdup_printf ("%s/%s/name", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
|
||||||
if (!(value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if (!(value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
||||||
"NetworkManagerInfo::getVPNConnectionVPNData could not access the name for connection '%s'", name);
|
"NetworkManagerInfo::getVPNConnectionVPNData could not access the name for connection '%s'", name);
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
@@ -738,12 +637,12 @@ static DBusMessage *nmi_dbus_get_vpn_connection_vpn_data (NMIAppInfo *info, DBus
|
|||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab vpn-daemon specific data */
|
/* Grab vpn-daemon specific data */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/vpn_data", NMI_GCONF_VPN_CONNECTIONS_PATH, escaped_name);
|
gconf_key = g_strdup_printf ("%s/%s/vpn_data", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
|
||||||
if (!(vpn_data_value = gconf_client_get (info->gconf_client, gconf_key, NULL))
|
if (!(vpn_data_value = gconf_client_get (applet->gconf_client, gconf_key, NULL))
|
||||||
|| !(vpn_data_value->type == GCONF_VALUE_LIST)
|
|| !(vpn_data_value->type == GCONF_VALUE_LIST)
|
||||||
|| !(gconf_value_get_list_type (vpn_data_value) == GCONF_VALUE_STRING))
|
|| !(gconf_value_get_list_type (vpn_data_value) == GCONF_VALUE_STRING))
|
||||||
{
|
{
|
||||||
reply = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
|
||||||
"NetworkManagerInfo::getVPNConnectionVPNData could not access the VPN data for connection '%s'", name);
|
"NetworkManagerInfo::getVPNConnectionVPNData could not access the VPN data for connection '%s'", name);
|
||||||
if (vpn_data_value)
|
if (vpn_data_value)
|
||||||
gconf_value_free (vpn_data_value);
|
gconf_value_free (vpn_data_value);
|
||||||
@@ -777,7 +676,7 @@ static DBusMessage *nmi_dbus_get_vpn_connection_vpn_data (NMIAppInfo *info, DBus
|
|||||||
* Update a network's authentication method entry in gconf
|
* Update a network's authentication method entry in gconf
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_update_network_auth_method (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_update_network_auth_method (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
DBusMessage *reply_message = NULL;
|
DBusMessage *reply_message = NULL;
|
||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
@@ -787,7 +686,7 @@ static DBusMessage *nmi_dbus_update_network_auth_method (NMIAppInfo *info, DBusM
|
|||||||
DBusError error;
|
DBusError error;
|
||||||
char *escaped_network;
|
char *escaped_network;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
@@ -795,21 +694,21 @@ static DBusMessage *nmi_dbus_update_network_auth_method (NMIAppInfo *info, DBusM
|
|||||||
|| (strlen (network) <= 0)
|
|| (strlen (network) <= 0)
|
||||||
|| (auth_method == NM_DEVICE_AUTH_METHOD_UNKNOWN))
|
|| (auth_method == NM_DEVICE_AUTH_METHOD_UNKNOWN))
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
reply_message = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManagerInfo::updateNetworkAuthMethod called with invalid arguments.");
|
"NetworkManagerInfo::updateNetworkAuthMethod called with invalid arguments.");
|
||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure the access point exists in GConf */
|
/* Ensure the access point exists in GConf */
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
escaped_network = gconf_escape_key (network, strlen (network));
|
||||||
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
value = gconf_client_get (applet->gconf_client, key, NULL);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
|
|
||||||
if (value && (value->type == GCONF_VALUE_STRING))
|
if (value && (value->type == GCONF_VALUE_STRING))
|
||||||
{
|
{
|
||||||
key = g_strdup_printf ("%s/%s/auth_method", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
key = g_strdup_printf ("%s/%s/auth_method", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
gconf_client_set_int (info->gconf_client, key, auth_method, NULL);
|
gconf_client_set_int (applet->gconf_client, key, auth_method, NULL);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
}
|
}
|
||||||
if (value)
|
if (value)
|
||||||
@@ -827,7 +726,7 @@ static DBusMessage *nmi_dbus_update_network_auth_method (NMIAppInfo *info, DBusM
|
|||||||
* Add an AP's MAC address to a wireless network entry in gconf
|
* Add an AP's MAC address to a wireless network entry in gconf
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusMessage *nmi_dbus_add_network_address (NMIAppInfo *info, DBusMessage *message)
|
static DBusMessage *nmi_dbus_add_network_address (NMWirelessApplet *applet, DBusMessage *message)
|
||||||
{
|
{
|
||||||
DBusMessage *reply_message = NULL;
|
DBusMessage *reply_message = NULL;
|
||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
@@ -840,7 +739,7 @@ static DBusMessage *nmi_dbus_add_network_address (NMIAppInfo *info, DBusMessage
|
|||||||
GSList *new_mac_list = NULL;
|
GSList *new_mac_list = NULL;
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
@@ -850,39 +749,39 @@ static DBusMessage *nmi_dbus_add_network_address (NMIAppInfo *info, DBusMessage
|
|||||||
|| !addr
|
|| !addr
|
||||||
|| (strlen (addr) < 11))
|
|| (strlen (addr) < 11))
|
||||||
{
|
{
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
reply_message = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManagerInfo::addNetworkAddress called with invalid arguments.");
|
"NetworkManagerInfo::addNetworkAddress called with invalid arguments.");
|
||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Force-set the essid too so that we have a semi-complete network entry */
|
/* Force-set the essid too so that we have a semi-complete network entry */
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
escaped_network = gconf_escape_key (network, strlen (network));
|
||||||
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
value = gconf_client_get (applet->gconf_client, key, NULL);
|
||||||
|
|
||||||
/* If the network doesn't already exist in GConf, add it and set its timestamp to now. */
|
/* If the network doesn't already exist in GConf, add it and set its timestamp to now. */
|
||||||
if (!value || (!value && (value->type == GCONF_VALUE_STRING)))
|
if (!value || (!value && (value->type == GCONF_VALUE_STRING)))
|
||||||
{
|
{
|
||||||
/* Set the essid of the network. */
|
/* Set the essid of the network. */
|
||||||
gconf_client_set_string (info->gconf_client, key, network, NULL);
|
gconf_client_set_string (applet->gconf_client, key, network, NULL);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
|
|
||||||
/* Update timestamp on network */
|
/* Update timestamp on network */
|
||||||
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
gconf_client_set_int (info->gconf_client, key, time (NULL), NULL);
|
gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
|
||||||
}
|
}
|
||||||
g_free (key);
|
g_free (key);
|
||||||
|
|
||||||
/* Get current list of access point MAC addresses for this AP from GConf */
|
/* Get current list of access point MAC addresses for this AP from GConf */
|
||||||
key = g_strdup_printf ("%s/%s/addresses", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
key = g_strdup_printf ("%s/%s/addresses", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
value = gconf_client_get (info->gconf_client, key, NULL);
|
value = gconf_client_get (applet->gconf_client, key, NULL);
|
||||||
g_free (escaped_network);
|
g_free (escaped_network);
|
||||||
|
|
||||||
if (value && (value->type == GCONF_VALUE_LIST) && (gconf_value_get_list_type (value) == GCONF_VALUE_STRING))
|
if (value && (value->type == GCONF_VALUE_LIST) && (gconf_value_get_list_type (value) == GCONF_VALUE_STRING))
|
||||||
{
|
{
|
||||||
GSList *elem;
|
GSList *elem;
|
||||||
|
|
||||||
new_mac_list = gconf_client_get_list (info->gconf_client, key, GCONF_VALUE_STRING, NULL);
|
new_mac_list = gconf_client_get_list (applet->gconf_client, key, GCONF_VALUE_STRING, NULL);
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
|
|
||||||
/* Ensure that the MAC isn't already in the list */
|
/* Ensure that the MAC isn't already in the list */
|
||||||
@@ -902,7 +801,7 @@ static DBusMessage *nmi_dbus_add_network_address (NMIAppInfo *info, DBusMessage
|
|||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
new_mac_list = g_slist_append (new_mac_list, g_strdup (addr));
|
new_mac_list = g_slist_append (new_mac_list, g_strdup (addr));
|
||||||
gconf_client_set_list (info->gconf_client, key, GCONF_VALUE_STRING, new_mac_list, NULL);
|
gconf_client_set_list (applet->gconf_client, key, GCONF_VALUE_STRING, new_mac_list, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the list, since gconf_client_set_list deep-copies it */
|
/* Free the list, since gconf_client_set_list deep-copies it */
|
||||||
@@ -916,45 +815,33 @@ static DBusMessage *nmi_dbus_add_network_address (NMIAppInfo *info, DBusMessage
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_dbus_nmi_message_handler
|
* nmi_dbus_info_message_handler
|
||||||
*
|
*
|
||||||
* Responds to requests for our services
|
* Respond to requests against the NetworkManagerInfo object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connection, DBusMessage *message, void *user_data)
|
DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBusMessage *message, void *user_data)
|
||||||
{
|
{
|
||||||
const char *method;
|
const char * method;
|
||||||
const char *path;
|
const char * path;
|
||||||
NMIAppInfo *info = (NMIAppInfo *)user_data;
|
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
|
||||||
DBusMessage *reply_message = NULL;
|
DBusMessage * reply = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, DBUS_HANDLER_RESULT_HANDLED);
|
g_return_val_if_fail (applet != NULL, DBUS_HANDLER_RESULT_HANDLED);
|
||||||
|
|
||||||
method = dbus_message_get_member (message);
|
method = dbus_message_get_member (message);
|
||||||
path = dbus_message_get_path (message);
|
path = dbus_message_get_path (message);
|
||||||
|
|
||||||
/* nm_warning ("nmi_dbus_nmi_message_handler() got method %s for path %s", method, path);*/
|
/* nm_warning ("nmi_dbus_nmi_message_handler() got method %s for path %s", method, path); */
|
||||||
|
|
||||||
if (strcmp ("getKeyForNetwork", method) == 0)
|
if (strcmp ("getKeyForNetwork", method) == 0)
|
||||||
{
|
reply = nmi_dbus_get_key_for_network (applet, message);
|
||||||
GtkWidget *dialog = glade_xml_get_widget (info->passphrase_dialog, "passphrase_dialog");
|
|
||||||
if (dialog && !GTK_WIDGET_VISIBLE (dialog))
|
|
||||||
nmi_dbus_get_key_for_network (info, message);
|
|
||||||
}
|
|
||||||
else if (strcmp ("cancelGetKeyForNetwork", method) == 0)
|
else if (strcmp ("cancelGetKeyForNetwork", method) == 0)
|
||||||
{
|
nmi_passphrase_dialog_cancel (applet->passphrase_dialog);
|
||||||
GtkWidget *dialog = glade_xml_get_widget (info->passphrase_dialog, "passphrase_dialog");
|
|
||||||
if (dialog && GTK_WIDGET_VISIBLE (dialog))
|
|
||||||
nmi_passphrase_dialog_cancel (info);
|
|
||||||
}
|
|
||||||
else if (strcmp ("getVPNUserPass", method) == 0)
|
|
||||||
{
|
|
||||||
nmi_dbus_get_vpn_userpass (info, message);
|
|
||||||
}
|
|
||||||
else if (strcmp ("networkNotFound", method) == 0)
|
else if (strcmp ("networkNotFound", method) == 0)
|
||||||
{
|
{
|
||||||
const char *network;
|
const char * network;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID))
|
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID))
|
||||||
@@ -963,8 +850,8 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
|
|||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
dbus_error_free (&error);
|
dbus_error_free (&error);
|
||||||
text = g_strdup_printf ( "The requested wireless network '%s' does not appear to be in range. "
|
text = g_strdup_printf (_("The requested wireless network '%s' does not appear to be in range. "
|
||||||
"A different wireless network will be used if any are available.", network);
|
"A different wireless network will be used if any are available."), network);
|
||||||
|
|
||||||
dialog = GTK_DIALOG (gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text, NULL));
|
dialog = GTK_DIALOG (gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text, NULL));
|
||||||
gtk_dialog_run (dialog);
|
gtk_dialog_run (dialog);
|
||||||
@@ -972,180 +859,26 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp ("getNetworks", method) == 0)
|
else if (strcmp ("getNetworks", method) == 0)
|
||||||
reply_message = nmi_dbus_get_networks (info, message);
|
reply = nmi_dbus_get_networks (applet, message);
|
||||||
else if (strcmp ("getNetworkProperties", method) == 0)
|
else if (strcmp ("getNetworkProperties", method) == 0)
|
||||||
reply_message = nmi_dbus_get_network_properties (info, message);
|
reply = nmi_dbus_get_network_properties (applet, message);
|
||||||
else if (strcmp ("updateNetworkAuthMethod", method) == 0)
|
else if (strcmp ("updateNetworkAuthMethod", method) == 0)
|
||||||
nmi_dbus_update_network_auth_method (info, message);
|
nmi_dbus_update_network_auth_method (applet, message);
|
||||||
else if (strcmp ("addNetworkAddress", method) == 0)
|
else if (strcmp ("addNetworkAddress", method) == 0)
|
||||||
nmi_dbus_add_network_address (info, message);
|
nmi_dbus_add_network_address (applet, message);
|
||||||
else if (strcmp ("getVPNConnections", method) == 0)
|
else if (strcmp ("getVPNConnections", method) == 0)
|
||||||
reply_message = nmi_dbus_get_vpn_connections (info, message);
|
reply = nmi_dbus_get_vpn_connections (applet, message);
|
||||||
else if (strcmp ("getVPNConnectionProperties", method) == 0)
|
else if (strcmp ("getVPNConnectionProperties", method) == 0)
|
||||||
reply_message = nmi_dbus_get_vpn_connection_properties (info, message);
|
reply = nmi_dbus_get_vpn_connection_properties (applet, message);
|
||||||
else if (strcmp ("getVPNConnectionVPNData", method) == 0)
|
else if (strcmp ("getVPNConnectionVPNData", method) == 0)
|
||||||
reply_message = nmi_dbus_get_vpn_connection_vpn_data (info, message);
|
reply = nmi_dbus_get_vpn_connection_vpn_data (applet, message);
|
||||||
else
|
|
||||||
{
|
|
||||||
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "UnknownMethod",
|
|
||||||
"NetworkManagerInfo knows nothing about the method %s for object %s", method, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply_message)
|
if (reply)
|
||||||
{
|
{
|
||||||
dbus_connection_send (connection, reply_message, NULL);
|
dbus_connection_send (connection, reply, NULL);
|
||||||
dbus_message_unref (reply_message);
|
dbus_message_unref (reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (DBUS_HANDLER_RESULT_HANDLED);
|
return (DBUS_HANDLER_RESULT_HANDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_nmi_unregister_handler
|
|
||||||
*
|
|
||||||
* Nothing happens here.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_dbus_nmi_unregister_handler (DBusConnection *connection, void *user_data)
|
|
||||||
{
|
|
||||||
/* do nothing */
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean shutdown_callback (gpointer data)
|
|
||||||
{
|
|
||||||
gtk_main_quit ();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DBusHandlerResult nmi_dbus_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
|
|
||||||
{
|
|
||||||
gboolean handled = FALSE;
|
|
||||||
NMIAppInfo *info = (NMIAppInfo *) user_data;
|
|
||||||
gboolean appeared = FALSE;
|
|
||||||
gboolean disappeared = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
||||||
|
|
||||||
if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkAppeared"))
|
|
||||||
appeared = TRUE;
|
|
||||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkDisappeared"))
|
|
||||||
disappeared = TRUE;
|
|
||||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivationFailed"))
|
|
||||||
{
|
|
||||||
char *dev = NULL;
|
|
||||||
char *net = NULL;
|
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev, DBUS_TYPE_STRING, &net, DBUS_TYPE_INVALID))
|
|
||||||
{
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
dbus_error_free (&error);
|
|
||||||
dbus_error_init (&error);
|
|
||||||
dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev, DBUS_TYPE_INVALID);
|
|
||||||
}
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
dbus_error_free (&error);
|
|
||||||
if (dev && net)
|
|
||||||
{
|
|
||||||
char *string = g_strdup_printf ("Connection to the wireless network '%s' failed.\n", net);
|
|
||||||
nmi_show_warning_dialog (TRUE, string);
|
|
||||||
g_free (string);
|
|
||||||
}
|
|
||||||
else if (dev)
|
|
||||||
nmi_show_warning_dialog (TRUE, "Connection to the wired network failed.\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* nmi_dbus_nm_is_running
|
|
||||||
*
|
|
||||||
* Ask dbus whether or not NetworkManager is running
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static gboolean nmi_dbus_nm_is_running (DBusConnection *connection)
|
|
||||||
{
|
|
||||||
DBusError error;
|
|
||||||
gboolean exists;
|
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, FALSE);
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
exists = dbus_bus_name_has_owner (connection, NM_DBUS_SERVICE, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
dbus_error_free (&error);
|
|
||||||
return (exists);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_dbus_service_init
|
|
||||||
*
|
|
||||||
* Connect to the system messagebus and register ourselves as a service.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
DBusError dbus_error;
|
|
||||||
DBusObjectPathVTable nmi_vtable = { &nmi_dbus_nmi_unregister_handler, &nmi_dbus_nmi_message_handler, NULL, NULL, NULL, NULL };
|
|
||||||
int acquisition;
|
|
||||||
|
|
||||||
dbus_error_init (&dbus_error);
|
|
||||||
acquisition = dbus_bus_request_name (dbus_connection, NMI_DBUS_SERVICE,
|
|
||||||
DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT,
|
|
||||||
&dbus_error);
|
|
||||||
if (dbus_error_is_set (&dbus_error))
|
|
||||||
{
|
|
||||||
nm_warning ("nmi_dbus_service_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'", dbus_error.message);
|
|
||||||
dbus_error_free (&dbus_error);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (acquisition == DBUS_REQUEST_NAME_REPLY_EXISTS) {
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!nmi_dbus_nm_is_running (dbus_connection))
|
|
||||||
return (-1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!dbus_connection_register_object_path (dbus_connection, NMI_DBUS_PATH, &nmi_vtable, info))
|
|
||||||
{
|
|
||||||
nm_warning ("nmi_dbus_service_init() could not register a handler for NetworkManagerInfo. Not enough memory?");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dbus_connection_add_filter (dbus_connection, nmi_dbus_filter, info, NULL))
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
dbus_error_init (&dbus_error);
|
|
||||||
dbus_bus_add_match (dbus_connection,
|
|
||||||
"type='signal',"
|
|
||||||
"interface='" NM_DBUS_INTERFACE "',"
|
|
||||||
"sender='" NM_DBUS_SERVICE "',"
|
|
||||||
"path='" NM_DBUS_PATH "'", &dbus_error);
|
|
||||||
if (dbus_error_is_set (&dbus_error))
|
|
||||||
{
|
|
||||||
dbus_error_free (&dbus_error);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_bus_add_match(dbus_connection,
|
|
||||||
"type='signal',"
|
|
||||||
"interface='" DBUS_INTERFACE_DBUS "',"
|
|
||||||
"sender='" DBUS_SERVICE_DBUS "'",
|
|
||||||
&dbus_error);
|
|
||||||
if (dbus_error_is_set (&dbus_error))
|
|
||||||
{
|
|
||||||
dbus_error_free (&dbus_error);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
@@ -1,5 +1,5 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
* for WEP key entry
|
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
|
||||||
*
|
*
|
||||||
* Dan Williams <dcbw@redhat.com>
|
* Dan Williams <dcbw@redhat.com>
|
||||||
*
|
*
|
||||||
@@ -17,18 +17,18 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004-2005 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NETWORK_MANAGER_INFO_PASSPHRASE_DIALOG_H
|
#ifndef APPLET_DBUS_INFO_H
|
||||||
#define NETWORK_MANAGER_INFO_PASSPHRASE_DIALOG_H
|
#define APPLET_DBUS_INFO_H
|
||||||
|
|
||||||
#include "NetworkManagerInfo.h"
|
#include <dbus/dbus.h>
|
||||||
|
#include "nm-device.h"
|
||||||
|
#include "wireless-network.h"
|
||||||
|
|
||||||
int nmi_passphrase_dialog_init (NMIAppInfo *info);
|
DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBusMessage *message, void *user_data);
|
||||||
|
|
||||||
void nmi_passphrase_dialog_show (const char *device, const char *network, NMIAppInfo *info);
|
void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const int key_type);
|
||||||
|
|
||||||
void nmi_passphrase_dialog_cancel (NMIAppInfo *info);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
504
gnome/applet/applet-dbus-vpn.c
Normal file
@@ -0,0 +1,504 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
|
/* 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 2004-2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
#include "applet-dbus-vpn.h"
|
||||||
|
#include "applet-dbus.h"
|
||||||
|
#include "applet.h"
|
||||||
|
#include "vpn-connection.h"
|
||||||
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
static void nmwa_free_gui_vpn_connections (NMWirelessApplet *applet);
|
||||||
|
static void nmwa_free_dbus_vpn_connections (NMWirelessApplet *applet);
|
||||||
|
static void nmwa_dbus_vpn_schedule_copy (NMWirelessApplet *applet);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_get_active_vpn_connection_cb
|
||||||
|
*
|
||||||
|
* Callback from nmwa_dbus_vpn_get_active_vpn_connection
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_get_active_vpn_connection_cb (DBusPendingCall *pcall, void *user_data)
|
||||||
|
{
|
||||||
|
DBusMessage * reply;
|
||||||
|
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
|
||||||
|
const char * act_vpn;
|
||||||
|
|
||||||
|
g_return_if_fail (pcall != NULL);
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
dbus_pending_call_ref (pcall);
|
||||||
|
|
||||||
|
if (!dbus_pending_call_get_completed (pcall))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if ( dbus_message_is_error (reply, NM_DBUS_NO_ACTIVE_VPN_CONNECTION)
|
||||||
|
|| dbus_message_is_error (reply, NM_DBUS_NO_VPN_CONNECTIONS))
|
||||||
|
{
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_OBJECT_PATH, &act_vpn, DBUS_TYPE_INVALID))
|
||||||
|
{
|
||||||
|
g_free (applet->dbus_active_vpn_name);
|
||||||
|
applet->dbus_active_vpn_name = g_strdup (act_vpn);
|
||||||
|
}
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
|
||||||
|
out:
|
||||||
|
applet->vpn_pending_call_list = g_slist_remove (applet->vpn_pending_call_list, pcall);
|
||||||
|
nmwa_dbus_vpn_schedule_copy (applet);
|
||||||
|
|
||||||
|
dbus_pending_call_unref (pcall);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_get_active_vpn_connection
|
||||||
|
*
|
||||||
|
* Get the active VPN connection from NetworkManager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_get_active_vpn_connection (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusPendingCall * pcall = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getActiveVPNConnection")))
|
||||||
|
{
|
||||||
|
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (pcall)
|
||||||
|
{
|
||||||
|
dbus_pending_call_set_notify (pcall, nmwa_dbus_vpn_get_active_vpn_connection_cb, applet, NULL);
|
||||||
|
applet->vpn_pending_call_list = g_slist_append (applet->vpn_pending_call_list, pcall);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct VpnPropsCBData
|
||||||
|
{
|
||||||
|
NMWirelessApplet * applet;
|
||||||
|
char * name;
|
||||||
|
} VpnPropsCBData;
|
||||||
|
|
||||||
|
void free_vpn_props_cb_data (VpnPropsCBData *data)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
g_free (data->name);
|
||||||
|
memset (data, 0, sizeof (VpnPropsCBData));
|
||||||
|
g_free (data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_properties_cb
|
||||||
|
*
|
||||||
|
* Callback for each VPN connection we called "getVPNConnectionProperties" on.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data)
|
||||||
|
{
|
||||||
|
DBusMessage * reply;
|
||||||
|
VpnPropsCBData * cb_data = user_data;
|
||||||
|
NMWirelessApplet * applet;
|
||||||
|
const char * name;
|
||||||
|
const char * user_name;
|
||||||
|
|
||||||
|
g_return_if_fail (pcall != NULL);
|
||||||
|
g_return_if_fail (cb_data != NULL);
|
||||||
|
g_return_if_fail (cb_data->applet != NULL);
|
||||||
|
g_return_if_fail (cb_data->name != NULL);
|
||||||
|
|
||||||
|
dbus_pending_call_ref (pcall);
|
||||||
|
|
||||||
|
applet = cb_data->applet;
|
||||||
|
|
||||||
|
if (!dbus_pending_call_get_completed (pcall))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
|
||||||
|
{
|
||||||
|
if (dbus_message_is_error (reply, NM_DBUS_INVALID_VPN_CONNECTION))
|
||||||
|
{
|
||||||
|
VPNConnection * vpn;
|
||||||
|
|
||||||
|
if ((vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, cb_data->name)))
|
||||||
|
{
|
||||||
|
applet->dbus_vpn_connections = g_slist_remove (applet->dbus_vpn_connections, vpn);
|
||||||
|
nmwa_vpn_connection_unref (vpn);
|
||||||
|
if (applet->dbus_active_vpn == vpn);
|
||||||
|
{
|
||||||
|
nmwa_vpn_connection_unref (vpn);
|
||||||
|
applet->dbus_active_vpn = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name, DBUS_TYPE_INVALID))
|
||||||
|
{
|
||||||
|
VPNConnection * vpn;
|
||||||
|
|
||||||
|
/* If its already there, update the user_name, otherwise add it to the list */
|
||||||
|
if ((vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, name)))
|
||||||
|
nmwa_vpn_connection_set_user_name (vpn, user_name);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vpn = nmwa_vpn_connection_new (name);
|
||||||
|
nmwa_vpn_connection_set_user_name (vpn, user_name);
|
||||||
|
applet->dbus_vpn_connections = g_slist_append (applet->dbus_vpn_connections, vpn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
|
||||||
|
out:
|
||||||
|
applet->vpn_pending_call_list = g_slist_remove (applet->vpn_pending_call_list, pcall);
|
||||||
|
nmwa_dbus_vpn_schedule_copy (applet);
|
||||||
|
|
||||||
|
dbus_pending_call_unref (pcall);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_update_one_vpn_connection
|
||||||
|
*
|
||||||
|
* Get properties on one VPN connection
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_update_one_vpn_connection (NMWirelessApplet *applet, const char *vpn_name)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusPendingCall * pcall = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
g_return_if_fail (vpn_name != NULL);
|
||||||
|
|
||||||
|
nmwa_dbus_vpn_get_active_vpn_connection (applet);
|
||||||
|
|
||||||
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnectionProperties")))
|
||||||
|
{
|
||||||
|
dbus_message_append_args (message, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_INVALID);
|
||||||
|
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (pcall)
|
||||||
|
{
|
||||||
|
VpnPropsCBData * cb_data = g_malloc0 (sizeof (VpnPropsCBData));
|
||||||
|
|
||||||
|
cb_data->applet = applet;
|
||||||
|
cb_data->name = g_strdup (vpn_name);
|
||||||
|
dbus_pending_call_set_notify (pcall, nmwa_dbus_vpn_properties_cb, cb_data, (DBusFreeFunction) free_vpn_props_cb_data);
|
||||||
|
applet->vpn_pending_call_list = g_slist_append (applet->vpn_pending_call_list, pcall);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_update_vpn_connections_cb
|
||||||
|
*
|
||||||
|
* nmwa_dbus_vpn_update_vpn_connections callback.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_update_vpn_connections_cb (DBusPendingCall *pcall, void *user_data)
|
||||||
|
{
|
||||||
|
DBusMessage * reply;
|
||||||
|
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
|
||||||
|
char ** vpn_names;
|
||||||
|
int num_vpn_names;
|
||||||
|
|
||||||
|
g_return_if_fail (pcall != NULL);
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
dbus_pending_call_ref (pcall);
|
||||||
|
|
||||||
|
if (!dbus_pending_call_get_completed (pcall))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (dbus_message_is_error (reply, NM_DBUS_NO_VPN_CONNECTIONS))
|
||||||
|
{
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &vpn_names, &num_vpn_names, DBUS_TYPE_INVALID))
|
||||||
|
{
|
||||||
|
char ** item;
|
||||||
|
|
||||||
|
/* For each connection, fire off a "getVPNConnectionProperties" call */
|
||||||
|
for (item = vpn_names; *item; item++)
|
||||||
|
nmwa_dbus_vpn_update_one_vpn_connection (applet, *item);
|
||||||
|
|
||||||
|
dbus_free_string_array (vpn_names);
|
||||||
|
}
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
|
||||||
|
out:
|
||||||
|
applet->vpn_pending_call_list = g_slist_remove (applet->vpn_pending_call_list, pcall);
|
||||||
|
nmwa_dbus_vpn_schedule_copy (applet);
|
||||||
|
|
||||||
|
dbus_pending_call_unref (pcall);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_update_vpn_connections
|
||||||
|
*
|
||||||
|
* Do a full update of vpn connections from NetworkManager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_update_vpn_connections (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusPendingCall * pcall;
|
||||||
|
|
||||||
|
nmwa_free_dbus_vpn_connections (applet);
|
||||||
|
|
||||||
|
nmwa_dbus_vpn_get_active_vpn_connection (applet);
|
||||||
|
|
||||||
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnections")))
|
||||||
|
{
|
||||||
|
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (pcall)
|
||||||
|
{
|
||||||
|
dbus_pending_call_set_notify (pcall, nmwa_dbus_vpn_update_vpn_connections_cb, applet, NULL);
|
||||||
|
applet->vpn_pending_call_list = g_slist_append (applet->vpn_pending_call_list, pcall);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_remove_one_vpn_connection
|
||||||
|
*
|
||||||
|
* Remove one vpn connection from the list
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_remove_one_vpn_connection (NMWirelessApplet *applet, const char *vpn_name)
|
||||||
|
{
|
||||||
|
VPNConnection * vpn;
|
||||||
|
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
g_return_if_fail (vpn_name != NULL);
|
||||||
|
|
||||||
|
if ((vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, vpn_name)))
|
||||||
|
{
|
||||||
|
applet->dbus_vpn_connections = g_slist_remove (applet->dbus_vpn_connections, vpn);
|
||||||
|
nmwa_vpn_connection_unref (vpn);
|
||||||
|
if (applet->dbus_active_vpn == vpn)
|
||||||
|
{
|
||||||
|
nmwa_vpn_connection_unref (vpn);
|
||||||
|
applet->dbus_active_vpn = NULL;
|
||||||
|
}
|
||||||
|
nmwa_dbus_vpn_schedule_copy (applet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int vpn_copy_idle_id = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_connections_lock_and_copy
|
||||||
|
*
|
||||||
|
* Copy VPN connections over to gui side.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static gboolean nmwa_dbus_vpn_connections_lock_and_copy (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
vpn_copy_idle_id = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (applet != NULL, FALSE);
|
||||||
|
|
||||||
|
/* Only copy over if we have a complete data model */
|
||||||
|
if (g_slist_length (applet->vpn_pending_call_list) == 0)
|
||||||
|
{
|
||||||
|
GSList * elt;
|
||||||
|
|
||||||
|
/* Match up the active vpn with a device in the list */
|
||||||
|
if (applet->dbus_active_vpn_name &&
|
||||||
|
(applet->dbus_active_vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, applet->dbus_active_vpn_name)))
|
||||||
|
nmwa_vpn_connection_ref (applet->dbus_active_vpn);
|
||||||
|
|
||||||
|
/* Now copy the data over to the GUI side */
|
||||||
|
g_mutex_lock (applet->data_mutex);
|
||||||
|
|
||||||
|
nmwa_free_gui_vpn_connections (applet);
|
||||||
|
|
||||||
|
/* Deep-copy VPN connections to GUI data model */
|
||||||
|
for (elt = applet->dbus_vpn_connections; elt; elt = g_slist_next (elt))
|
||||||
|
{
|
||||||
|
VPNConnection *src_vpn = elt->data;
|
||||||
|
VPNConnection *new_vpn;
|
||||||
|
|
||||||
|
new_vpn = nmwa_vpn_connection_copy (src_vpn);
|
||||||
|
if (new_vpn)
|
||||||
|
{
|
||||||
|
applet->gui_vpn_connections = g_slist_append (applet->gui_vpn_connections, new_vpn);
|
||||||
|
if (applet->dbus_active_vpn == src_vpn)
|
||||||
|
{
|
||||||
|
nmwa_vpn_connection_ref (new_vpn);
|
||||||
|
applet->gui_active_vpn = new_vpn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_mutex_unlock (applet->data_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_schedule_copy
|
||||||
|
*
|
||||||
|
* Schedule a copy VPN connections over to gui side, batching requests.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void nmwa_dbus_vpn_schedule_copy (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
if (vpn_copy_idle_id == 0)
|
||||||
|
{
|
||||||
|
GSource *source = g_idle_source_new ();
|
||||||
|
|
||||||
|
/* We want this idle source to run before any other idle source */
|
||||||
|
g_source_set_priority (source, G_PRIORITY_HIGH_IDLE);
|
||||||
|
g_source_set_callback (source, (GSourceFunc) nmwa_dbus_vpn_connections_lock_and_copy, applet, NULL);
|
||||||
|
vpn_copy_idle_id = g_source_attach (source, applet->thread_context);
|
||||||
|
g_source_unref (source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void nmwa_free_gui_vpn_connections (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
if (applet->gui_active_vpn)
|
||||||
|
nmwa_vpn_connection_unref (applet->gui_active_vpn);
|
||||||
|
applet->gui_active_vpn = NULL;
|
||||||
|
|
||||||
|
if (applet->gui_vpn_connections)
|
||||||
|
{
|
||||||
|
g_slist_foreach (applet->gui_vpn_connections, (GFunc) nmwa_vpn_connection_unref, NULL);
|
||||||
|
g_slist_free (applet->gui_vpn_connections);
|
||||||
|
applet->gui_vpn_connections = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void nmwa_free_dbus_vpn_connections (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
GSList *elt;
|
||||||
|
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
if (applet->dbus_active_vpn)
|
||||||
|
nmwa_vpn_connection_unref (applet->dbus_active_vpn);
|
||||||
|
applet->dbus_active_vpn = NULL;
|
||||||
|
|
||||||
|
g_free (applet->dbus_active_vpn_name);
|
||||||
|
applet->dbus_active_vpn_name = NULL;
|
||||||
|
|
||||||
|
if (applet->dbus_vpn_connections)
|
||||||
|
{
|
||||||
|
g_slist_foreach (applet->dbus_vpn_connections, (GFunc) nmwa_vpn_connection_unref, NULL);
|
||||||
|
g_slist_free (applet->dbus_vpn_connections);
|
||||||
|
applet->dbus_vpn_connections = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_vpn_activate_connection
|
||||||
|
*
|
||||||
|
* Tell NetworkManager to activate a particular VPN connection.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_activate_connection (DBusConnection *connection, const char *name, const char *password)
|
||||||
|
{
|
||||||
|
DBusMessage *message;
|
||||||
|
|
||||||
|
g_return_if_fail (connection != NULL);
|
||||||
|
g_return_if_fail (name != NULL);
|
||||||
|
g_return_if_fail (password != NULL);
|
||||||
|
|
||||||
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "activateVPNConnection")))
|
||||||
|
{
|
||||||
|
nm_info ("Activating VPN connection '%s'.\n", name);
|
||||||
|
|
||||||
|
dbus_message_append_args (message, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &password, DBUS_TYPE_INVALID);
|
||||||
|
dbus_connection_send (connection, message, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nm_warning ("nmwa_dbus_activate_vpn_connection(): Couldn't allocate the dbus message\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_deactivate_vpn_connection
|
||||||
|
*
|
||||||
|
* Tell NetworkManager to deactivate the currently active VPN connection.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_dbus_vpn_deactivate_connection (DBusConnection *connection)
|
||||||
|
{
|
||||||
|
DBusMessage *message;
|
||||||
|
|
||||||
|
g_return_if_fail (connection != NULL);
|
||||||
|
|
||||||
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "deactivateVPNConnection")))
|
||||||
|
{
|
||||||
|
nm_info ("Deactivating the current VPN connection.\n");
|
||||||
|
dbus_connection_send (connection, message, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nm_warning ("nmwa_dbus_activate_vpn_connection(): Couldn't allocate the dbus message\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
39
gnome/applet/applet-dbus-vpn.h
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
|
/* 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 2004-2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APPLET_DBUS_VPN_H
|
||||||
|
#define APPLET_DBUS_VPN_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
#include "vpn-connection.h"
|
||||||
|
|
||||||
|
void nmwa_dbus_vpn_update_one_vpn_connection (NMWirelessApplet *applet, const char *vpn_name);
|
||||||
|
void nmwa_dbus_vpn_update_vpn_connections (NMWirelessApplet *applet);
|
||||||
|
void nmwa_dbus_vpn_remove_one_vpn_connection (NMWirelessApplet *applet, const char *vpn_name);
|
||||||
|
void nmwa_dbus_vpn_get_active_vpn_connection (NMWirelessApplet *applet);
|
||||||
|
|
||||||
|
void nmwa_dbus_vpn_activate_connection (DBusConnection *connection, const char *name, const char *password);
|
||||||
|
void nmwa_dbus_vpn_deactivate_connection (DBusConnection *connection);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
755
gnome/applet/applet-dbus.c
Normal file
@@ -0,0 +1,755 @@
|
|||||||
|
/* 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 2004 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
|
#include "applet.h"
|
||||||
|
#include "applet-dbus.h"
|
||||||
|
#include "applet-dbus-devices.h"
|
||||||
|
#include "applet-dbus-vpn.h"
|
||||||
|
#include "applet-dbus-info.h"
|
||||||
|
#include "vpn-connection.h"
|
||||||
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_dbus_create_error_message
|
||||||
|
*
|
||||||
|
* Convenience function to make a DBus error message
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
DBusMessage *nmwa_dbus_create_error_message (DBusMessage *message, const char *exception_namespace, const char *exception, const char *format, ...)
|
||||||
|
{
|
||||||
|
char * exception_text;
|
||||||
|
DBusMessage * reply_message;
|
||||||
|
va_list args;
|
||||||
|
char error_text[512];
|
||||||
|
|
||||||
|
|
||||||
|
va_start (args, format);
|
||||||
|
vsnprintf (error_text, 512, format, args);
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
exception_text = g_strdup_printf ("%s.%s", exception_namespace, exception);
|
||||||
|
reply_message = dbus_message_new_error (message, exception_text, error_text);
|
||||||
|
g_free (exception_text);
|
||||||
|
|
||||||
|
return (reply_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* deal_with_dbus_error
|
||||||
|
*
|
||||||
|
* Ignore some common dbus errors
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static int deal_with_dbus_error (const char *function, const char *method, DBusError *error)
|
||||||
|
{
|
||||||
|
int ret = RETURN_FAILURE;
|
||||||
|
|
||||||
|
if (!strcmp (error->name, DBUS_NO_SERVICE_ERROR))
|
||||||
|
ret = RETURN_NO_NM;
|
||||||
|
else if (!strcmp (error->name, NM_DBUS_NO_ACTIVE_NET_ERROR))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
else if (!strcmp (error->name, NM_DBUS_NO_ACTIVE_DEVICE_ERROR))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
else if (!strcmp (error->name, NM_DBUS_NO_NETWORKS_ERROR))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
else if (!strcmp (error->name, NM_DBUS_NO_ACTIVE_VPN_CONNECTION))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
else if (!strcmp (error->name, NM_DBUS_NO_VPN_CONNECTIONS))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
|
||||||
|
if ((ret != RETURN_SUCCESS) && (ret != RETURN_NO_NM))
|
||||||
|
nm_warning ("%s(): %s raised on method '%s':\n %s\n\n", function, error->name, method, error->message);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_call_method_string
|
||||||
|
*
|
||||||
|
* Do a method call on NetworkManager that returns a string.
|
||||||
|
*
|
||||||
|
* Returns: RETURN_SUCCESS on success
|
||||||
|
* RETURN_FAILURE on failure
|
||||||
|
* RETURN_NO_NM if NetworkManager service no longer exists
|
||||||
|
*/
|
||||||
|
int nmwa_dbus_call_method_string (DBusConnection *con, const char *path, const char *interface, const char *method, gboolean is_obj_path, char **string)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusMessage * reply;
|
||||||
|
DBusError error;
|
||||||
|
char * dbus_string = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (con != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (path != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (method != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (string != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (*string == NULL, RETURN_FAILURE);
|
||||||
|
|
||||||
|
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, interface, method)))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_string(): Couldn't allocate the dbus message\n");
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
reply = dbus_connection_send_with_reply_and_block (con, message, -1, &error);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
int ret = deal_with_dbus_error (__FUNCTION__, method, &error);
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply == NULL)
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_string(): dbus reply message was NULL\n" );
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
dbus_message_get_args (reply, &error, is_obj_path ? DBUS_TYPE_OBJECT_PATH : DBUS_TYPE_STRING, &dbus_string, DBUS_TYPE_INVALID);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_string(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
*string = g_strdup (dbus_string);
|
||||||
|
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
return (RETURN_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_call_method_uint32
|
||||||
|
*
|
||||||
|
* Do a method call on NetworkManager that returns a DBUS_TYPE_UINT32.
|
||||||
|
*
|
||||||
|
* Returns: RETURN_SUCCESS on success
|
||||||
|
* RETURN_FAILURE on failure
|
||||||
|
* RETURN_NO_NM if NetworkManager service no longer exists
|
||||||
|
*/
|
||||||
|
int nmwa_dbus_call_method_uint32 (DBusConnection *con, const char *path, const char *interface, const char *method, guint32 *num)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusMessage * reply;
|
||||||
|
DBusError error;
|
||||||
|
|
||||||
|
g_return_val_if_fail (con != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (path != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (method != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (num != NULL, RETURN_FAILURE);
|
||||||
|
|
||||||
|
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, interface, method)))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_uint32(): Couldn't allocate the dbus message\n");
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
reply = dbus_connection_send_with_reply_and_block (con, message, -1, &error);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
int ret = deal_with_dbus_error (__FUNCTION__, method, &error);
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply == NULL)
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_uint32(): dbus reply message was NULL\n" );
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, num, DBUS_TYPE_INVALID);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
nm_warning ("nnmwa_dbus_call_method_uint32(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (RETURN_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_call_method_int32
|
||||||
|
*
|
||||||
|
* Do a method call on NetworkManager that returns a DBUS_TYPE_INT32.
|
||||||
|
*
|
||||||
|
* Returns: RETURN_SUCCESS on success
|
||||||
|
* RETURN_FAILURE on failure
|
||||||
|
* RETURN_NO_NM if NetworkManager service no longer exists
|
||||||
|
*/
|
||||||
|
int nmwa_dbus_call_method_int32 (DBusConnection *con, const char *path, const char *interface, const char *method, gint32 *num)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusMessage * reply;
|
||||||
|
DBusError error;
|
||||||
|
|
||||||
|
g_return_val_if_fail (con != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (path != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (method != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (num != NULL, RETURN_FAILURE);
|
||||||
|
|
||||||
|
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, interface, method)))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_int32(): Couldn't allocate the dbus message\n");
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
reply = dbus_connection_send_with_reply_and_block (con, message, -1, &error);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
int ret = deal_with_dbus_error (__FUNCTION__, method, &error);
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply == NULL)
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_int32(): dbus reply message was NULL\n" );
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, num, DBUS_TYPE_INVALID);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
nm_warning ("nnmwa_dbus_call_method_int32(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (RETURN_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_call_method_boolean
|
||||||
|
*
|
||||||
|
* Do a method call on NetworkManager that returns a DBUS_TYPE_BOOLEAN.
|
||||||
|
*
|
||||||
|
* Returns: RETURN_SUCCESS on success
|
||||||
|
* RETURN_FAILURE on failure
|
||||||
|
* RETURN_NO_NM if NetworkManager service no longer exists
|
||||||
|
*/
|
||||||
|
int nmwa_dbus_call_method_boolean (DBusConnection *con, const char *path, const char *interface, const char *method, gboolean *num)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusMessage * reply;
|
||||||
|
DBusError error;
|
||||||
|
|
||||||
|
g_return_val_if_fail (con != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (path != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (method != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (num != NULL, RETURN_FAILURE);
|
||||||
|
|
||||||
|
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, interface, method)))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_boolean(): Couldn't allocate the dbus message\n");
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
reply = dbus_connection_send_with_reply_and_block (con, message, -1, &error);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
int ret = deal_with_dbus_error (__FUNCTION__, method, &error);
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply == NULL)
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_boolean(): dbus reply message was NULL\n" );
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
dbus_message_get_args (reply, &error, DBUS_TYPE_BOOLEAN, num, DBUS_TYPE_INVALID);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
nm_warning ("nnmwa_dbus_call_method_boolean(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (RETURN_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_call_method_string_array
|
||||||
|
*
|
||||||
|
* Do a method call on NetworkManager that returns a string array.
|
||||||
|
*
|
||||||
|
* Returns: RETURN_SUCCESS on success
|
||||||
|
* RETURN_FAILURE on failure
|
||||||
|
* RETURN_NO_NM if NetworkManager service no longer exists
|
||||||
|
*/
|
||||||
|
int nmwa_dbus_call_method_string_array (DBusConnection *con, const char *path, const char *interface, const char *method,
|
||||||
|
gboolean is_obj_path, char ***array, guint32 *array_len)
|
||||||
|
{
|
||||||
|
DBusMessage * message;
|
||||||
|
DBusMessage * reply;
|
||||||
|
DBusError error;
|
||||||
|
char ** dbus_array;
|
||||||
|
int dbus_array_len;
|
||||||
|
|
||||||
|
g_return_val_if_fail (con != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (path != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (method != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (array != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (*array == NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (array_len != NULL, RETURN_FAILURE);
|
||||||
|
|
||||||
|
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, interface, method)))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_string_array(): Couldn't allocate the dbus message\n");
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
reply = dbus_connection_send_with_reply_and_block (con, message, -1, &error);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
int ret = deal_with_dbus_error (__FUNCTION__, method, &error);
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply == NULL)
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_call_method_string_array(): dbus reply message was NULL\n" );
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
dbus_message_get_args (reply, &error, DBUS_TYPE_ARRAY, is_obj_path ? DBUS_TYPE_OBJECT_PATH : DBUS_TYPE_STRING, &dbus_array, &dbus_array_len, DBUS_TYPE_INVALID);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
nm_warning ("nnmwa_dbus_call_method_string_array(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
*array = g_strdupv (dbus_array);
|
||||||
|
*array_len = dbus_array_len;
|
||||||
|
dbus_free_string_array (dbus_array);
|
||||||
|
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
return (RETURN_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_filter
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
|
||||||
|
{
|
||||||
|
NMWirelessApplet *applet = (NMWirelessApplet *)user_data;
|
||||||
|
gboolean handled = TRUE;
|
||||||
|
DBusError error;
|
||||||
|
|
||||||
|
g_return_val_if_fail (applet != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||||
|
g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||||
|
g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
|
||||||
|
if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged"))
|
||||||
|
{
|
||||||
|
char *service;
|
||||||
|
char *old_owner;
|
||||||
|
char *new_owner;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, &error,
|
||||||
|
DBUS_TYPE_STRING, &service,
|
||||||
|
DBUS_TYPE_STRING, &old_owner,
|
||||||
|
DBUS_TYPE_STRING, &new_owner,
|
||||||
|
DBUS_TYPE_INVALID))
|
||||||
|
{
|
||||||
|
if (strcmp (service, NM_DBUS_SERVICE) == 0)
|
||||||
|
{
|
||||||
|
gboolean old_owner_good = (old_owner && (strlen (old_owner) > 0));
|
||||||
|
gboolean new_owner_good = (new_owner && (strlen (new_owner) > 0));
|
||||||
|
|
||||||
|
if (!old_owner_good && new_owner_good && !applet->nm_running)
|
||||||
|
{
|
||||||
|
/* NetworkManager started up */
|
||||||
|
applet->nm_running = TRUE;
|
||||||
|
applet->gui_nm_state = NM_STATE_DISCONNECTED;
|
||||||
|
applet->dbus_nm_state = NM_STATE_DISCONNECTED;
|
||||||
|
nmwa_dbus_update_nm_state (applet);
|
||||||
|
nmwa_dbus_update_devices (applet);
|
||||||
|
nmwa_dbus_vpn_update_vpn_connections (applet);
|
||||||
|
}
|
||||||
|
else if (old_owner_good && !new_owner_good)
|
||||||
|
applet->nm_running = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, NM_DBUS_SIGNAL_STATE_CHANGE))
|
||||||
|
{
|
||||||
|
NMState state = NM_STATE_UNKNOWN;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID))
|
||||||
|
{
|
||||||
|
/* If we've switched to connecting, update the active device to ensure that we have
|
||||||
|
* valid wireless network information for it.
|
||||||
|
*/
|
||||||
|
if ( (state == NM_STATE_CONNECTING)
|
||||||
|
&& applet->dbus_active_device
|
||||||
|
&& (network_device_get_type (applet->dbus_active_device) == DEVICE_TYPE_WIRELESS_ETHERNET))
|
||||||
|
{
|
||||||
|
nmwa_dbus_device_update_one_device (applet, network_device_get_nm_path (applet->dbus_active_device));
|
||||||
|
}
|
||||||
|
applet->dbus_nm_state = state;
|
||||||
|
applet->gui_nm_state = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceAdded")
|
||||||
|
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive")
|
||||||
|
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive")
|
||||||
|
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivating"))
|
||||||
|
{
|
||||||
|
char *path = NULL;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_dbus_device_update_one_device (applet, path);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceRemoved"))
|
||||||
|
{
|
||||||
|
char *path = NULL;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_dbus_device_remove_one_device (applet, path);
|
||||||
|
}
|
||||||
|
else if ( dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionAdded")
|
||||||
|
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionUpdate")) /* VPN connection properties changed */
|
||||||
|
{
|
||||||
|
char *name = NULL;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_dbus_vpn_update_one_vpn_connection (applet, name);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionChange")) /* Active VPN connection changed */
|
||||||
|
{
|
||||||
|
nmwa_dbus_vpn_get_active_vpn_connection (applet);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionRemoved"))
|
||||||
|
{
|
||||||
|
char *name = NULL;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_dbus_vpn_remove_one_vpn_connection (applet, name);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkAppeared"))
|
||||||
|
{
|
||||||
|
char *dev_path = NULL;
|
||||||
|
char *net_path = NULL;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_OBJECT_PATH, &net_path, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_dbus_device_update_one_network (applet, dev_path, net_path, NULL);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkDisappeared"))
|
||||||
|
{
|
||||||
|
char *dev_path = NULL;
|
||||||
|
char *net_path = NULL;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_OBJECT_PATH, &net_path, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_dbus_device_remove_one_network (applet, dev_path, net_path);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkStrengthChanged"))
|
||||||
|
{
|
||||||
|
char * dev_path = NULL;
|
||||||
|
char * net_path = NULL;
|
||||||
|
int strength = -1;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_OBJECT_PATH, &net_path, DBUS_TYPE_INT32, &strength, DBUS_TYPE_INVALID))
|
||||||
|
{
|
||||||
|
/* FIXME actually use strength rather than querying all network properties */
|
||||||
|
nmwa_dbus_device_update_one_network (applet, dev_path, net_path, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNLoginFailed"))
|
||||||
|
{
|
||||||
|
char *vpn_name;
|
||||||
|
char *error_msg;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_STRING, &error_msg, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_schedule_vpn_login_failure_dialog (applet, vpn_name, error_msg);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNLoginBanner"))
|
||||||
|
{
|
||||||
|
char *vpn_name;
|
||||||
|
char *banner;
|
||||||
|
|
||||||
|
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_STRING, &banner, DBUS_TYPE_INVALID))
|
||||||
|
nmwa_schedule_vpn_login_banner_dialog (applet, vpn_name, banner);
|
||||||
|
}
|
||||||
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivationFailed"))
|
||||||
|
{
|
||||||
|
char *dev = NULL;
|
||||||
|
char *net = NULL;
|
||||||
|
DBusError error;
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev, DBUS_TYPE_STRING, &net, DBUS_TYPE_INVALID))
|
||||||
|
{
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
dbus_error_init (&error);
|
||||||
|
dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev, DBUS_TYPE_INVALID);
|
||||||
|
}
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
if (dev && net)
|
||||||
|
{
|
||||||
|
char *string = g_strdup_printf (_("Connection to the wireless network '%s' failed.\n"), net);
|
||||||
|
nmwa_schedule_warning_dialog (applet, string);
|
||||||
|
g_free (string);
|
||||||
|
}
|
||||||
|
else if (dev)
|
||||||
|
nmwa_schedule_warning_dialog (applet, _("Connection to the wired network failed.\n"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
handled = FALSE;
|
||||||
|
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
|
||||||
|
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_nm_is_running
|
||||||
|
*
|
||||||
|
* Ask dbus whether or not NetworkManager is running
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static gboolean nmwa_dbus_nm_is_running (DBusConnection *connection)
|
||||||
|
{
|
||||||
|
DBusError error;
|
||||||
|
gboolean exists;
|
||||||
|
|
||||||
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
exists = dbus_bus_name_has_owner (connection, NM_DBUS_SERVICE, &error);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (exists);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_init
|
||||||
|
*
|
||||||
|
* Initialize a connection to NetworkManager if we can get one
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static DBusConnection * nmwa_dbus_init (NMWirelessApplet *applet, GMainContext *context)
|
||||||
|
{
|
||||||
|
DBusConnection * connection = NULL;
|
||||||
|
DBusError error;
|
||||||
|
DBusObjectPathVTable vtable = { NULL, &nmi_dbus_info_message_handler, NULL, NULL, NULL, NULL };
|
||||||
|
int acquisition;
|
||||||
|
|
||||||
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
|
g_return_val_if_fail (context != NULL, NULL);
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
nm_warning ("%s raised:\n %s\n\n", error.name, error.message);
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
acquisition = dbus_bus_request_name (connection, NMI_DBUS_SERVICE, DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT, &error);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'", error.message);
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (acquisition == DBUS_REQUEST_NAME_REPLY_EXISTS)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!dbus_connection_register_object_path (connection, NMI_DBUS_PATH, &vtable, applet))
|
||||||
|
{
|
||||||
|
nm_warning ("nmwa_dbus_init() could not register a handler for NetworkManagerInfo. Not enough memory?");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dbus_connection_add_filter (connection, nmwa_dbus_filter, applet, NULL))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
dbus_connection_set_exit_on_disconnect (connection, FALSE);
|
||||||
|
dbus_connection_setup_with_g_main (connection, context);
|
||||||
|
|
||||||
|
dbus_bus_add_match(connection,
|
||||||
|
"type='signal',"
|
||||||
|
"interface='" DBUS_INTERFACE_DBUS "',"
|
||||||
|
"sender='" DBUS_SERVICE_DBUS "'",
|
||||||
|
&error);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
|
||||||
|
dbus_bus_add_match(connection,
|
||||||
|
"type='signal',"
|
||||||
|
"interface='" NM_DBUS_INTERFACE "',"
|
||||||
|
"path='" NM_DBUS_PATH "',"
|
||||||
|
"sender='" NM_DBUS_SERVICE "'",
|
||||||
|
&error);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
|
||||||
|
dbus_bus_add_match(connection,
|
||||||
|
"type='signal',"
|
||||||
|
"interface='" NM_DBUS_INTERFACE_VPN "',"
|
||||||
|
"path='" NM_DBUS_PATH_VPN "',"
|
||||||
|
"sender='" NM_DBUS_SERVICE "'",
|
||||||
|
&error);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
|
||||||
|
return (connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_connection_watcher
|
||||||
|
*
|
||||||
|
* Try to reconnect if we ever get disconnected from the bus
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static gboolean nmwa_dbus_connection_watcher (gpointer user_data)
|
||||||
|
{
|
||||||
|
NMWirelessApplet *applet = (NMWirelessApplet *)user_data;
|
||||||
|
|
||||||
|
g_return_val_if_fail (applet != NULL, TRUE);
|
||||||
|
|
||||||
|
if (!applet->connection)
|
||||||
|
{
|
||||||
|
if ((applet->connection = nmwa_dbus_init (applet, applet->thread_context)))
|
||||||
|
{
|
||||||
|
applet->nm_running = nmwa_dbus_nm_is_running (applet->connection);
|
||||||
|
applet->dbus_nm_state = NM_STATE_DISCONNECTED;
|
||||||
|
nmwa_dbus_update_nm_state (applet);
|
||||||
|
nmwa_dbus_update_devices (applet);
|
||||||
|
nmwa_dbus_vpn_update_vpn_connections (applet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_worker
|
||||||
|
*
|
||||||
|
* Thread worker function that periodically grabs the NetworkManager state
|
||||||
|
* and updates our local applet state to reflect that.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
gpointer nmwa_dbus_worker (gpointer user_data)
|
||||||
|
{
|
||||||
|
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
|
||||||
|
GSource * timeout_source;
|
||||||
|
GSource * strength_source;
|
||||||
|
|
||||||
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
|
|
||||||
|
dbus_g_thread_init ();
|
||||||
|
|
||||||
|
if (!(applet->thread_context = g_main_context_new ()))
|
||||||
|
return (NULL);
|
||||||
|
if (!(applet->thread_loop = g_main_loop_new (applet->thread_context, FALSE)))
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
applet->connection = nmwa_dbus_init (applet, applet->thread_context);
|
||||||
|
|
||||||
|
timeout_source = g_timeout_source_new (2000);
|
||||||
|
g_source_set_callback (timeout_source, nmwa_dbus_connection_watcher, applet, NULL);
|
||||||
|
g_source_attach (timeout_source, applet->thread_context);
|
||||||
|
|
||||||
|
strength_source = g_timeout_source_new (2000);
|
||||||
|
g_source_set_callback (strength_source, (GSourceFunc) nmwa_dbus_update_active_device_strength, applet, NULL);
|
||||||
|
g_source_attach (strength_source, applet->thread_context);
|
||||||
|
|
||||||
|
if (applet->connection && nmwa_dbus_nm_is_running (applet->connection))
|
||||||
|
{
|
||||||
|
applet->nm_running = TRUE;
|
||||||
|
nmwa_dbus_update_nm_state (applet);
|
||||||
|
nmwa_dbus_update_devices (applet);
|
||||||
|
nmwa_dbus_vpn_update_vpn_connections (applet);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_main_loop_run (applet->thread_loop);
|
||||||
|
|
||||||
|
g_source_destroy (timeout_source);
|
||||||
|
#if 0
|
||||||
|
g_source_destroy (strength_source);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
66
gnome/applet/applet-dbus.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* 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 2004 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APPLET_DBUS_H
|
||||||
|
#define APPLET_DBUS_H
|
||||||
|
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
#include "applet.h"
|
||||||
|
|
||||||
|
/* Return codes for functions that use dbus */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RETURN_SUCCESS = 1,
|
||||||
|
RETURN_FAILURE = 0,
|
||||||
|
RETURN_NO_NM = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline gboolean message_is_error (DBusMessage *msg)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (msg != NULL, FALSE);
|
||||||
|
|
||||||
|
return (dbus_message_get_type (msg) == DBUS_MESSAGE_TYPE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
int nmwa_dbus_call_method_string (DBusConnection *con, const char *path, const char *interface, const char *method, gboolean is_obj_path, char **string);
|
||||||
|
int nmwa_dbus_call_method_uint32 (DBusConnection *con, const char *path, const char *interface, const char *method, guint32 *num);
|
||||||
|
int nmwa_dbus_call_method_int32 (DBusConnection *con, const char *path, const char *interface, const char *method, gint32 *num);
|
||||||
|
int nmwa_dbus_call_method_boolean (DBusConnection *con, const char *path, const char *interface, const char *method, gboolean *num);
|
||||||
|
int nmwa_dbus_call_method_string_array (DBusConnection *con, const char *path, const char *interface, const char *method,
|
||||||
|
gboolean is_obj_path, char ***array, guint32 *array_len);
|
||||||
|
|
||||||
|
DBusMessage * nmwa_dbus_create_error_message (DBusMessage *message, const char *exception_namespace, const char *exception, const char *format, ...);
|
||||||
|
|
||||||
|
gpointer nmwa_dbus_worker (gpointer user_data);
|
||||||
|
|
||||||
|
void nmwa_dbus_enable_scanning (NMWirelessApplet *applet, gboolean enabled);
|
||||||
|
|
||||||
|
void nmwa_dbus_enable_wireless (NMWirelessApplet *applet, gboolean enabled);
|
||||||
|
|
||||||
|
void nmwa_free_gui_data_model (NMWirelessApplet *applet);
|
||||||
|
void nmwa_free_dbus_data_model (NMWirelessApplet *applet);
|
||||||
|
|
||||||
|
void nmwa_dbus_vpn_activate_connection (DBusConnection *connection, const char *name, const char *password);
|
||||||
|
void nmwa_dbus_vpn_deactivate_connection (DBusConnection *connection);
|
||||||
|
|
||||||
|
#endif
|
158
gnome/applet/applet.h
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
/* 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 2004 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APPLET_H
|
||||||
|
#define APPLET_H
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <gconf/gconf-client.h>
|
||||||
|
#include <glade/glade.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include "eggtrayicon.h"
|
||||||
|
#include <net/ethernet.h>
|
||||||
|
|
||||||
|
#include "nm-device.h"
|
||||||
|
#include "wireless-network.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Preference locations
|
||||||
|
*/
|
||||||
|
#define GCONF_PATH_WIRELESS_NETWORKS "/system/networking/wireless/networks"
|
||||||
|
#define GCONF_PATH_VPN_CONNECTIONS "/system/networking/vpn_connections"
|
||||||
|
#define GCONF_PATH_PREFS "/apps/NetworkManagerApplet"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct VPNConnection VPNConnection;
|
||||||
|
|
||||||
|
|
||||||
|
#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))
|
||||||
|
#define NM_IS_WIRELESS_APPLET(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), NM_TYPE_WIRELESS_APPLET))
|
||||||
|
#define NM_IS_WIRELESS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_WIRELESS_APPLET))
|
||||||
|
#define NM_WIRELESS_APPLET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), NM_TYPE_WIRELESS_APPLET, NMWirelessAppletClass))
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
EggTrayIconClass parent_class;
|
||||||
|
} NMWirelessAppletClass;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Applet instance data
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
EggTrayIcon parent;
|
||||||
|
|
||||||
|
DBusConnection * connection;
|
||||||
|
GConfClient * gconf_client;
|
||||||
|
guint gconf_net_notify_id;
|
||||||
|
guint gconf_vpn_notify_id;
|
||||||
|
char * glade_file;
|
||||||
|
guint redraw_timeout_id;
|
||||||
|
|
||||||
|
/* dbus thread stuff */
|
||||||
|
GThread * dbus_thread;
|
||||||
|
GMainContext * thread_context;
|
||||||
|
GMainLoop * thread_loop;
|
||||||
|
gboolean thread_done;
|
||||||
|
|
||||||
|
/* Data model elements */
|
||||||
|
GMutex * data_mutex;
|
||||||
|
gboolean is_adhoc;
|
||||||
|
gboolean scanning_enabled;
|
||||||
|
gboolean wireless_enabled;
|
||||||
|
gboolean nm_running;
|
||||||
|
|
||||||
|
GSList * gui_device_list;
|
||||||
|
NetworkDevice * gui_active_device;
|
||||||
|
NMState gui_nm_state;
|
||||||
|
|
||||||
|
GSList * dev_pending_call_list;
|
||||||
|
GSList * dbus_device_list;
|
||||||
|
NetworkDevice * dbus_active_device;
|
||||||
|
char * dbus_active_device_path;
|
||||||
|
NMState dbus_nm_state;
|
||||||
|
|
||||||
|
GSList * gui_vpn_connections;
|
||||||
|
VPNConnection * gui_active_vpn;
|
||||||
|
|
||||||
|
GSList * vpn_pending_call_list;
|
||||||
|
char * dbus_active_vpn_name;
|
||||||
|
GSList * dbus_vpn_connections;
|
||||||
|
VPNConnection * dbus_active_vpn;
|
||||||
|
|
||||||
|
GdkPixbuf * no_nm_icon;
|
||||||
|
GdkPixbuf * no_connection_icon;
|
||||||
|
GdkPixbuf * wired_icon;
|
||||||
|
GdkPixbuf * adhoc_icon;
|
||||||
|
#define NUM_WIRED_CONNECTING_FRAMES 11
|
||||||
|
GdkPixbuf * wired_connecting_icons[NUM_WIRED_CONNECTING_FRAMES];
|
||||||
|
GdkPixbuf * wireless_00_icon;
|
||||||
|
GdkPixbuf * wireless_25_icon;
|
||||||
|
GdkPixbuf * wireless_50_icon;
|
||||||
|
GdkPixbuf * wireless_75_icon;
|
||||||
|
GdkPixbuf * wireless_100_icon;
|
||||||
|
#define NUM_WIRELESS_CONNECTING_FRAMES 11
|
||||||
|
GdkPixbuf * wireless_connecting_icons[NUM_WIRELESS_CONNECTING_FRAMES];
|
||||||
|
#define NUM_WIRELESS_SCANNING_FRAMES 16
|
||||||
|
GdkPixbuf * wireless_scanning_icons[NUM_WIRELESS_SCANNING_FRAMES];
|
||||||
|
GdkPixbuf * vpn_lock_icon;
|
||||||
|
|
||||||
|
/* Animation stuff */
|
||||||
|
int animation_step;
|
||||||
|
guint animation_id;
|
||||||
|
|
||||||
|
/* Direct UI elements */
|
||||||
|
GtkWidget * pixmap;
|
||||||
|
GtkWidget * top_menu_item;
|
||||||
|
GtkWidget * dropdown_menu;
|
||||||
|
GtkWidget * vpn_menu;
|
||||||
|
GtkWidget * event_box;
|
||||||
|
GtkSizeGroup * encryption_size_group;
|
||||||
|
GtkTooltips * tooltips;
|
||||||
|
|
||||||
|
GtkWidget * context_menu;
|
||||||
|
GtkWidget * pause_scanning_item;
|
||||||
|
GtkWidget * stop_wireless_item;
|
||||||
|
|
||||||
|
GtkWidget * passphrase_dialog;
|
||||||
|
} NMWirelessApplet;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
NMWirelessApplet * applet;
|
||||||
|
NetworkDevice * dev;
|
||||||
|
GladeXML * xml;
|
||||||
|
} DriverNotifyCBData;
|
||||||
|
|
||||||
|
NetworkDevice * nmwa_get_device_for_nm_device (GSList *dev_list, const char *nm_dev);
|
||||||
|
NMWirelessApplet * nmwa_new (void);
|
||||||
|
void nmwa_schedule_warning_dialog (NMWirelessApplet *applet, const char *msg);
|
||||||
|
gboolean nmwa_driver_notify (gpointer user_data);
|
||||||
|
void nmwa_schedule_vpn_login_failure_dialog (NMWirelessApplet *applet, const char *vpn_name, const char *error_msg);
|
||||||
|
void nmwa_schedule_vpn_login_banner_dialog (NMWirelessApplet *applet, const char *vpn_name, const char *banner);
|
||||||
|
|
||||||
|
int nm_null_safe_strcmp (const char *s1, const char *s2);
|
||||||
|
|
||||||
|
#endif
|
Before Width: | Height: | Size: 748 B After Width: | Height: | Size: 748 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 658 B After Width: | Height: | Size: 658 B |
Before Width: | Height: | Size: 743 B After Width: | Height: | Size: 743 B |
Before Width: | Height: | Size: 760 B After Width: | Height: | Size: 760 B |
Before Width: | Height: | Size: 746 B After Width: | Height: | Size: 746 B |
Before Width: | Height: | Size: 627 B After Width: | Height: | Size: 627 B |
Before Width: | Height: | Size: 800 B After Width: | Height: | Size: 800 B |
Before Width: | Height: | Size: 751 B After Width: | Height: | Size: 751 B |
Before Width: | Height: | Size: 802 B After Width: | Height: | Size: 802 B |
Before Width: | Height: | Size: 780 B After Width: | Height: | Size: 780 B |
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 827 B |
Before Width: | Height: | Size: 774 B After Width: | Height: | Size: 774 B |
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 812 B |
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 806 B |
Before Width: | Height: | Size: 794 B After Width: | Height: | Size: 794 B |
Before Width: | Height: | Size: 923 B After Width: | Height: | Size: 923 B |
Before Width: | Height: | Size: 787 B After Width: | Height: | Size: 787 B |
Before Width: | Height: | Size: 828 B After Width: | Height: | Size: 828 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 490 B After Width: | Height: | Size: 490 B |
Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 409 B |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 492 B |
Before Width: | Height: | Size: 470 B After Width: | Height: | Size: 470 B |
Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 409 B |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
71
gnome/applet/main.c
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/* 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.
|
||||||
|
*
|
||||||
|
* This applet used the GNOME Wireless Applet as a skeleton to build from.
|
||||||
|
*
|
||||||
|
* (C) Copyright 2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <libgnomeui/libgnomeui.h>
|
||||||
|
#include "applet.h"
|
||||||
|
|
||||||
|
static void session_die (GnomeClient *client, gpointer client_data)
|
||||||
|
{
|
||||||
|
gtk_main_quit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean session_save (GnomeClient *client, gpointer client_data)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
NMWirelessApplet * nmwa;
|
||||||
|
GnomeClient * client;
|
||||||
|
GPtrArray * restart_argv;
|
||||||
|
|
||||||
|
gnome_program_init ("nm-applet", VERSION, LIBGNOMEUI_MODULE,
|
||||||
|
argc, argv,
|
||||||
|
GNOME_PARAM_NONE);
|
||||||
|
|
||||||
|
client = gnome_master_client ();
|
||||||
|
restart_argv = g_ptr_array_new ();
|
||||||
|
g_ptr_array_add (restart_argv, g_get_prgname ());
|
||||||
|
gnome_client_set_restart_command (client, restart_argv->len, (char**) restart_argv->pdata);
|
||||||
|
g_ptr_array_free (restart_argv, TRUE);
|
||||||
|
gnome_client_set_restart_style (client, GNOME_RESTART_IMMEDIATELY);
|
||||||
|
|
||||||
|
g_signal_connect (client, "save_yourself", G_CALLBACK (session_save), NULL);
|
||||||
|
g_signal_connect (client, "die", G_CALLBACK (session_die), NULL);
|
||||||
|
|
||||||
|
nmwa = nmwa_new ();
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (nmwa));
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
|
|
||||||
|
gnome_client_set_restart_style (client, GNOME_RESTART_ANYWAY);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -33,14 +33,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "menu-info.h"
|
#include "menu-items.h"
|
||||||
|
|
||||||
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
|
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
|
||||||
#include "gtkcellview.h"
|
#include "gtkcellview.h"
|
||||||
#include "gtkcellrendererprogress.h"
|
#include "gtkcellrendererprogress.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "NMWirelessAppletDbus.h"
|
#include "applet-dbus.h"
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
@@ -78,14 +78,14 @@ GtkCheckMenuItem *wired_menu_item_get_check_item (NMWiredMenuItem *item)
|
|||||||
|
|
||||||
void wired_menu_item_update (NMWiredMenuItem *item, NetworkDevice *dev, const gint n_devices)
|
void wired_menu_item_update (NMWiredMenuItem *item, NetworkDevice *dev, const gint n_devices)
|
||||||
{
|
{
|
||||||
gchar *text;
|
char *text;
|
||||||
gchar *dev_name;
|
const char *dev_name;
|
||||||
|
|
||||||
g_return_if_fail (dev != NULL);
|
g_return_if_fail (dev != NULL);
|
||||||
g_return_if_fail (item != NULL);
|
g_return_if_fail (item != NULL);
|
||||||
g_assert (dev->type == DEVICE_TYPE_WIRED_ETHERNET);
|
g_assert (network_device_get_type (dev) == DEVICE_TYPE_WIRED_ETHERNET);
|
||||||
|
|
||||||
dev_name = dev->hal_name ? dev->hal_name : dev->nm_name;
|
dev_name = network_device_get_desc (dev) ? network_device_get_desc (dev) : network_device_get_iface (dev);
|
||||||
|
|
||||||
if (n_devices > 1)
|
if (n_devices > 1)
|
||||||
text = g_strdup_printf (_("Wired Network (%s)"), dev_name);
|
text = g_strdup_printf (_("Wired Network (%s)"), dev_name);
|
||||||
@@ -97,8 +97,8 @@ void wired_menu_item_update (NMWiredMenuItem *item, NetworkDevice *dev, const gi
|
|||||||
/* Only dim the item if the device supports carrier detection AND
|
/* Only dim the item if the device supports carrier detection AND
|
||||||
* we know it doesn't have a link.
|
* we know it doesn't have a link.
|
||||||
*/
|
*/
|
||||||
if (dev->driver_support_level != NM_DRIVER_NO_CARRIER_DETECT)
|
if (network_device_get_driver_support_level (dev) != NM_DRIVER_NO_CARRIER_DETECT)
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (item->check_item), dev->link);
|
gtk_widget_set_sensitive (GTK_WIDGET (item->check_item), network_device_get_link (dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -155,12 +155,12 @@ void wireless_menu_item_update (NMWirelessMenuItem *item, NetworkDevice *dev, co
|
|||||||
const char *dev_name;
|
const char *dev_name;
|
||||||
gint n_essids;
|
gint n_essids;
|
||||||
|
|
||||||
n_essids = g_slist_length (dev->networks);
|
|
||||||
dev_name = dev->hal_name ? dev->hal_name : dev->nm_name;
|
|
||||||
|
|
||||||
g_return_if_fail (dev != NULL);
|
g_return_if_fail (dev != NULL);
|
||||||
g_return_if_fail (item != NULL);
|
g_return_if_fail (item != NULL);
|
||||||
g_assert (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET);
|
g_assert (network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET);
|
||||||
|
|
||||||
|
n_essids = network_device_get_num_wireless_networks (dev);
|
||||||
|
dev_name = network_device_get_desc (dev) ? network_device_get_desc (dev) : network_device_get_iface (dev);
|
||||||
|
|
||||||
if (n_devices > 1)
|
if (n_devices > 1)
|
||||||
text = g_strdup_printf (ngettext ("Wireless Network (%s)", "Wireless Networks (%s)", n_essids), dev_name);
|
text = g_strdup_printf (ngettext ("Wireless Network (%s)", "Wireless Networks (%s)", n_essids), dev_name);
|
||||||
@@ -236,16 +236,16 @@ void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network
|
|||||||
g_return_if_fail (item != NULL);
|
g_return_if_fail (item != NULL);
|
||||||
g_return_if_fail (network != NULL);
|
g_return_if_fail (network != NULL);
|
||||||
|
|
||||||
display_essid = nm_menu_network_escape_essid_for_display (network->essid);
|
display_essid = nm_menu_network_escape_essid_for_display (wireless_network_get_essid (network));
|
||||||
gtk_label_set_text (GTK_LABEL (item->label), display_essid);
|
gtk_label_set_text (GTK_LABEL (item->label), display_essid);
|
||||||
g_free (display_essid);
|
g_free (display_essid);
|
||||||
|
|
||||||
g_object_set (G_OBJECT (item->progress_bar), "value", CLAMP ((int) network->strength, 0, 100), NULL);
|
g_object_set (G_OBJECT (item->progress_bar), "value", CLAMP ((int) wireless_network_get_strength (network), 0, 100), NULL);
|
||||||
|
|
||||||
/* Deal with the encrypted icon */
|
/* Deal with the encrypted icon */
|
||||||
g_object_set (item->security_image, "visible", is_encrypted, NULL);
|
g_object_set (item->security_image, "visible", is_encrypted, NULL);
|
||||||
|
|
||||||
if (network->encrypted)
|
if (wireless_network_get_encrypted (network))
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (item->security_image), "gnome-lockscreen", GTK_ICON_SIZE_MENU);
|
gtk_image_set_from_stock (GTK_IMAGE (item->security_image), "gnome-lockscreen", GTK_ICON_SIZE_MENU);
|
||||||
else
|
else
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (item->security_image), NULL, GTK_ICON_SIZE_MENU);
|
gtk_image_set_from_stock (GTK_IMAGE (item->security_image), NULL, GTK_ICON_SIZE_MENU);
|
@@ -19,11 +19,11 @@
|
|||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_INFO_H
|
#ifndef MENU_ITEMS_H
|
||||||
#define MENU_INFO_H
|
#define MENU_ITEMS_H
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "NMWirelessApplet.h"
|
#include "applet.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct NMWiredMenuItem NMWiredMenuItem;
|
typedef struct NMWiredMenuItem NMWiredMenuItem;
|
493
gnome/applet/nm-device.c
Normal file
@@ -0,0 +1,493 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
|
/* 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 2004-2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "nm-device.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Representation of network device
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct NetworkDevice
|
||||||
|
{
|
||||||
|
int refcount;
|
||||||
|
char * iface;
|
||||||
|
char * desc;
|
||||||
|
char * nm_path;
|
||||||
|
NMDeviceType type;
|
||||||
|
gboolean link;
|
||||||
|
NMDriverSupportLevel driver_support_level;
|
||||||
|
char * addr;
|
||||||
|
char * udi;
|
||||||
|
gint strength;
|
||||||
|
GSList * networks;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_new
|
||||||
|
*
|
||||||
|
* Create a new network device representation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NetworkDevice *network_device_new (const char *iface, NMDeviceType type, const char *nm_path)
|
||||||
|
{
|
||||||
|
NetworkDevice *dev = NULL;
|
||||||
|
|
||||||
|
if ((dev = g_malloc0 (sizeof (NetworkDevice))))
|
||||||
|
{
|
||||||
|
dev->refcount = 1;
|
||||||
|
dev->iface = g_strdup (iface);
|
||||||
|
dev->type = type;
|
||||||
|
dev->nm_path = g_strdup (nm_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_copy
|
||||||
|
*
|
||||||
|
* Create a new network device representation, filling its
|
||||||
|
* data in from an already existing one. Deep-copies the
|
||||||
|
* wireless networks too.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NetworkDevice *network_device_copy (NetworkDevice *src)
|
||||||
|
{
|
||||||
|
NetworkDevice *dev = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (src != NULL, NULL);
|
||||||
|
|
||||||
|
if ((dev = g_malloc0 (sizeof (NetworkDevice))))
|
||||||
|
{
|
||||||
|
GSList *elt;
|
||||||
|
|
||||||
|
network_device_ref (dev);
|
||||||
|
dev->nm_path = g_strdup (src->nm_path);
|
||||||
|
dev->type = src->type;
|
||||||
|
dev->link = src->link;
|
||||||
|
dev->addr = g_strdup (src->addr);
|
||||||
|
dev->driver_support_level = src->driver_support_level;
|
||||||
|
dev->iface = g_strdup (src->iface);
|
||||||
|
dev->desc = g_strdup (src->desc);
|
||||||
|
dev->udi = g_strdup (src->udi);
|
||||||
|
dev->strength = src->strength;
|
||||||
|
|
||||||
|
for (elt = src->networks; elt; elt = g_slist_next (elt))
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = (WirelessNetwork *)elt->data;
|
||||||
|
if (net)
|
||||||
|
{
|
||||||
|
WirelessNetwork *copy = wireless_network_copy (net);
|
||||||
|
dev->networks = g_slist_append (dev->networks, copy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_ref
|
||||||
|
*
|
||||||
|
* Increment the reference count of the network device
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void network_device_ref (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
dev->refcount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_unref
|
||||||
|
*
|
||||||
|
* Unrefs (and possibly frees) the representation of a network device
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void network_device_unref (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
dev->refcount--;
|
||||||
|
if (dev->refcount < 1)
|
||||||
|
{
|
||||||
|
if (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
||||||
|
network_device_clear_wireless_networks (dev);
|
||||||
|
g_free (dev->nm_path);
|
||||||
|
g_free (dev->iface);
|
||||||
|
g_free (dev->udi);
|
||||||
|
g_free (dev->desc);
|
||||||
|
g_free (dev->addr);
|
||||||
|
g_free (dev);
|
||||||
|
memset (dev, 0, sizeof (NetworkDevice));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_get_active_wireless_network
|
||||||
|
*
|
||||||
|
* Return the active wireless network.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
WirelessNetwork *network_device_get_active_wireless_network (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
GSList * list;
|
||||||
|
WirelessNetwork * active = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
g_return_val_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET, NULL);
|
||||||
|
|
||||||
|
for (list = dev->networks; list; list = list->next)
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = (WirelessNetwork *) list->data;
|
||||||
|
|
||||||
|
if (wireless_network_get_active (net))
|
||||||
|
{
|
||||||
|
active = net;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_get_wireless_network_by_essid
|
||||||
|
*
|
||||||
|
* Return the wireless network with the specified essid.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
WirelessNetwork *network_device_get_wireless_network_by_essid (NetworkDevice *dev, const char *essid)
|
||||||
|
{
|
||||||
|
GSList * list;
|
||||||
|
WirelessNetwork * return_net = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
g_return_val_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET, NULL);
|
||||||
|
g_return_val_if_fail (essid != NULL, NULL);
|
||||||
|
|
||||||
|
for (list = dev->networks; list; list = list->next)
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = (WirelessNetwork *) list->data;
|
||||||
|
|
||||||
|
if (!strcmp (wireless_network_get_essid (net), essid))
|
||||||
|
{
|
||||||
|
return_net = net;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_net;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_get_wireless_network_by_nm_path
|
||||||
|
*
|
||||||
|
* Return the wireless network with the specified NetworkManager object path.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
WirelessNetwork *network_device_get_wireless_network_by_nm_path (NetworkDevice *dev, const char *nm_path)
|
||||||
|
{
|
||||||
|
GSList * list;
|
||||||
|
WirelessNetwork * return_net = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
g_return_val_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET, NULL);
|
||||||
|
g_return_val_if_fail (nm_path != NULL, NULL);
|
||||||
|
|
||||||
|
for (list = dev->networks; list; list = list->next)
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = (WirelessNetwork *) list->data;
|
||||||
|
|
||||||
|
if (!strcmp (wireless_network_get_nm_path (net), nm_path))
|
||||||
|
{
|
||||||
|
return_net = net;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_net;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_get_wireless_network_by_nm_path
|
||||||
|
*
|
||||||
|
* Return the wireless network with the specified NetworkManager object path.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void network_device_foreach_wireless_network (NetworkDevice *dev, WirelessNetworkForeach func, gpointer user_data)
|
||||||
|
{
|
||||||
|
GSList * list;
|
||||||
|
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
g_return_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET);
|
||||||
|
g_return_if_fail (func != NULL);
|
||||||
|
|
||||||
|
for (list = dev->networks; list; list = list->next)
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = (WirelessNetwork *) list->data;
|
||||||
|
|
||||||
|
if (net)
|
||||||
|
(*func)(dev, net, user_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_add_wireless_network
|
||||||
|
*
|
||||||
|
* Adds a wireless network to the network device's network list
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void network_device_add_wireless_network (NetworkDevice *dev, WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
g_return_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET);
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
|
||||||
|
wireless_network_ref (net);
|
||||||
|
dev->networks = g_slist_append (dev->networks, net);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_clear_wireless_networks
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void network_device_clear_wireless_networks (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
g_return_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET);
|
||||||
|
|
||||||
|
g_slist_foreach (dev->networks, (GFunc) wireless_network_unref, NULL);
|
||||||
|
g_slist_free (dev->networks);
|
||||||
|
dev->networks = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_remove_wireless_network
|
||||||
|
*
|
||||||
|
* Remove one wireless network from the wireless network list
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void network_device_remove_wireless_network (NetworkDevice *dev, WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
GSList *elt;
|
||||||
|
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
g_return_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET);
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
|
||||||
|
for (elt = dev->networks; elt; elt = g_slist_next (elt))
|
||||||
|
{
|
||||||
|
if (elt->data == net)
|
||||||
|
{
|
||||||
|
dev->networks = g_slist_remove_link (dev->networks, elt);
|
||||||
|
wireless_network_unref ((WirelessNetwork *)elt->data);
|
||||||
|
g_slist_free (elt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* network_device_get_num_wireless_networks
|
||||||
|
*
|
||||||
|
* Return the number of wireless networks this device knows about.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
guint network_device_get_num_wireless_networks (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, 0);
|
||||||
|
g_return_val_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET, 0);
|
||||||
|
|
||||||
|
return g_slist_length (dev->networks);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for hardware address
|
||||||
|
*/
|
||||||
|
const char *network_device_get_address (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
|
return (dev->addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_device_set_address (NetworkDevice *dev, const char *addr)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
if (dev->addr)
|
||||||
|
{
|
||||||
|
g_free (dev->addr);
|
||||||
|
dev->addr = NULL;
|
||||||
|
}
|
||||||
|
if (addr)
|
||||||
|
dev->addr = g_strdup (addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for driver support level
|
||||||
|
*/
|
||||||
|
NMDriverSupportLevel network_device_get_driver_support_level (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, NM_DRIVER_UNSUPPORTED);
|
||||||
|
|
||||||
|
return (dev->driver_support_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_device_set_driver_support_level (NetworkDevice *dev, NMDriverSupportLevel level)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
dev->driver_support_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for NM object path
|
||||||
|
*/
|
||||||
|
const char *network_device_get_nm_path (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
|
return (dev->nm_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for device type
|
||||||
|
*/
|
||||||
|
NMDeviceType network_device_get_type (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, DEVICE_TYPE_DONT_KNOW);
|
||||||
|
|
||||||
|
return (dev->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for strength
|
||||||
|
*/
|
||||||
|
gint network_device_get_strength (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, -1);
|
||||||
|
g_return_val_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET, -1);
|
||||||
|
|
||||||
|
return (dev->strength);
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_device_set_strength (NetworkDevice *dev, gint strength)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
g_return_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET);
|
||||||
|
|
||||||
|
dev->strength = strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for device's interface name
|
||||||
|
*/
|
||||||
|
const char *network_device_get_iface (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
|
return (dev->iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for HAL udi
|
||||||
|
*/
|
||||||
|
const char *network_device_get_hal_udi (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
|
return (dev->udi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_device_set_hal_udi (NetworkDevice *dev, const char *hal_udi)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
if (dev->udi)
|
||||||
|
{
|
||||||
|
g_free (dev->udi);
|
||||||
|
dev->udi = NULL;
|
||||||
|
}
|
||||||
|
if (hal_udi)
|
||||||
|
dev->udi = g_strdup (hal_udi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for link
|
||||||
|
*/
|
||||||
|
gboolean network_device_get_link (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
|
|
||||||
|
return (dev->link);
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_device_set_link (NetworkDevice *dev, gboolean link)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
dev->link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for desc
|
||||||
|
*/
|
||||||
|
const char *network_device_get_desc (NetworkDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
|
return (dev->desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_device_set_desc (NetworkDevice *dev, const char *desc)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
if (dev->desc)
|
||||||
|
{
|
||||||
|
g_free (dev->desc);
|
||||||
|
dev->desc = NULL;
|
||||||
|
}
|
||||||
|
if (desc)
|
||||||
|
dev->desc = g_strdup (desc);
|
||||||
|
}
|
||||||
|
|
79
gnome/applet/nm-device.h
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
|
/* 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 2004-2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NM_DEVICE_H
|
||||||
|
#define NM_DEVICE_H
|
||||||
|
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
#include "wireless-network.h"
|
||||||
|
|
||||||
|
typedef struct NetworkDevice NetworkDevice;
|
||||||
|
typedef void (*WirelessNetworkForeach) (NetworkDevice *dev, WirelessNetwork *net, gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
|
NetworkDevice * network_device_new (const char *iface, NMDeviceType type, const char *nm_path);
|
||||||
|
NetworkDevice * network_device_copy (NetworkDevice *src);
|
||||||
|
|
||||||
|
void network_device_ref (NetworkDevice *dev);
|
||||||
|
void network_device_unref (NetworkDevice *dev);
|
||||||
|
|
||||||
|
NMDeviceType network_device_get_type (NetworkDevice *dev);
|
||||||
|
|
||||||
|
WirelessNetwork * network_device_get_wireless_network_by_essid (NetworkDevice *dev, const char *essid);
|
||||||
|
WirelessNetwork * network_device_get_wireless_network_by_nm_path(NetworkDevice *dev, const char *essid);
|
||||||
|
|
||||||
|
WirelessNetwork * network_device_get_active_wireless_network (NetworkDevice *dev);
|
||||||
|
|
||||||
|
void network_device_foreach_wireless_network (NetworkDevice *dev, WirelessNetworkForeach func, gpointer user_data);
|
||||||
|
|
||||||
|
void network_device_add_wireless_network (NetworkDevice *dev, WirelessNetwork *net);
|
||||||
|
void network_device_remove_wireless_network (NetworkDevice *dev, WirelessNetwork *net);
|
||||||
|
void network_device_clear_wireless_networks (NetworkDevice *dev);
|
||||||
|
|
||||||
|
guint network_device_get_num_wireless_networks (NetworkDevice *dev);
|
||||||
|
|
||||||
|
const char * network_device_get_address (NetworkDevice *dev);
|
||||||
|
void network_device_set_address (NetworkDevice *dev, const char *addr);
|
||||||
|
|
||||||
|
NMDriverSupportLevel network_device_get_driver_support_level (NetworkDevice *dev);
|
||||||
|
void network_device_set_driver_support_level (NetworkDevice *dev, NMDriverSupportLevel level);
|
||||||
|
|
||||||
|
const char * network_device_get_iface (NetworkDevice *dev);
|
||||||
|
|
||||||
|
const char * network_device_get_nm_path (NetworkDevice *dev);
|
||||||
|
|
||||||
|
gint network_device_get_strength (NetworkDevice *dev);
|
||||||
|
void network_device_set_strength (NetworkDevice *dev, gint strength);
|
||||||
|
|
||||||
|
const char * network_device_get_iface (NetworkDevice *dev);
|
||||||
|
|
||||||
|
const char * network_device_get_hal_udi (NetworkDevice *dev);
|
||||||
|
void network_device_set_hal_udi (NetworkDevice *dev, const char *hal_udi);
|
||||||
|
|
||||||
|
gboolean network_device_get_link (NetworkDevice *dev);
|
||||||
|
void network_device_set_link (NetworkDevice *dev, gboolean link);
|
||||||
|
|
||||||
|
const char * network_device_get_desc (NetworkDevice *dev);
|
||||||
|
void network_device_set_desc (NetworkDevice *dev, const char *desc);
|
||||||
|
|
||||||
|
#endif
|
@@ -38,9 +38,10 @@
|
|||||||
#include <glade/glade.h>
|
#include <glade/glade.h>
|
||||||
|
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "NMWirelessApplet.h"
|
#include "applet.h"
|
||||||
#include "NMWirelessAppletDbus.h"
|
#include "applet-dbus.h"
|
||||||
#include "NMWirelessAppletOtherNetworkDialog.h"
|
#include "applet-dbus-devices.h"
|
||||||
|
#include "other-network-dialog.h"
|
||||||
|
|
||||||
enum NMWAEncryptionKeyTypes
|
enum NMWAEncryptionKeyTypes
|
||||||
{
|
{
|
||||||
@@ -107,21 +108,18 @@ static GtkTreeModel *create_wireless_adapter_model (NMWirelessApplet *applet)
|
|||||||
/* We should have already locked applet->data_mutex */
|
/* We should have already locked applet->data_mutex */
|
||||||
for (element = applet->gui_device_list; element; element = element->next)
|
for (element = applet->gui_device_list; element; element = element->next)
|
||||||
{
|
{
|
||||||
NetworkDevice *network = (NetworkDevice *)(element->data);
|
NetworkDevice *dev = (NetworkDevice *)(element->data);
|
||||||
|
|
||||||
g_assert (network);
|
g_assert (dev);
|
||||||
if (network->type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
if (network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
const char *network_name;
|
const char *dev_name;
|
||||||
|
|
||||||
network_name = network->hal_name ? network->hal_name : network->nm_name;
|
dev_name = network_device_get_desc (dev) ? network_device_get_desc (dev) : network_device_get_iface (dev);
|
||||||
|
|
||||||
gtk_list_store_append (retval, &iter);
|
gtk_list_store_append (retval, &iter);
|
||||||
gtk_list_store_set (retval, &iter,
|
gtk_list_store_set (retval, &iter, 0, dev_name, 1, dev, -1);
|
||||||
0, network_name,
|
|
||||||
1, network,
|
|
||||||
-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GTK_TREE_MODEL (retval);
|
return GTK_TREE_MODEL (retval);
|
||||||
@@ -214,8 +212,7 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
|
|||||||
g_return_val_if_fail (*def_dev == NULL, NULL);
|
g_return_val_if_fail (*def_dev == NULL, NULL);
|
||||||
|
|
||||||
/* Set up the dialog */
|
/* Set up the dialog */
|
||||||
dialog = GTK_DIALOG (glade_xml_get_widget (xml, "custom_essid_dialog"));
|
if (!(dialog = GTK_DIALOG (glade_xml_get_widget (xml, "custom_essid_dialog"))))
|
||||||
if (!dialog)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
essid_entry = glade_xml_get_widget (xml, "essid_entry");
|
essid_entry = glade_xml_get_widget (xml, "essid_entry");
|
||||||
@@ -247,7 +244,7 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
|
|||||||
NetworkDevice *dev = (NetworkDevice *)(element->data);
|
NetworkDevice *dev = (NetworkDevice *)(element->data);
|
||||||
|
|
||||||
g_assert (dev);
|
g_assert (dev);
|
||||||
if (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
if (network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET)
|
||||||
{
|
{
|
||||||
if (!*def_dev)
|
if (!*def_dev)
|
||||||
{
|
{
|
||||||
@@ -291,7 +288,7 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
|
|||||||
|
|
||||||
/* Set initial passphrase entry label and key type combo box item */
|
/* Set initial passphrase entry label and key type combo box item */
|
||||||
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
|
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
|
||||||
gtk_combo_box_set_active (key_type_combo, 0);
|
gtk_combo_box_set_active (key_type_combo, KEY_TYPE_128_BIT_PASSPHRASE);
|
||||||
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_key_type_combo_changed), xml);
|
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_key_type_combo_changed), xml);
|
||||||
nmwa_other_network_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), xml);
|
nmwa_other_network_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), xml);
|
||||||
|
|
||||||
@@ -313,10 +310,9 @@ void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_ne
|
|||||||
g_return_if_fail (applet != NULL);
|
g_return_if_fail (applet != NULL);
|
||||||
g_return_if_fail (applet->glade_file != NULL);
|
g_return_if_fail (applet->glade_file != NULL);
|
||||||
|
|
||||||
xml = glade_xml_new (applet->glade_file, NULL, NULL);
|
if (!(xml = glade_xml_new (applet->glade_file, "custom_essid_dialog", NULL)))
|
||||||
if (xml == NULL)
|
|
||||||
{
|
{
|
||||||
show_warning_dialog (TRUE, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
|
nmwa_schedule_warning_dialog (applet, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +347,8 @@ void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_ne
|
|||||||
|
|
||||||
if (essid[0] != '\000')
|
if (essid[0] != '\000')
|
||||||
{
|
{
|
||||||
WirelessNetwork *net = wireless_network_new_with_essid (essid);
|
NMEncKeyType nm_key_type;
|
||||||
|
WirelessNetwork * net = network_device_get_wireless_network_by_essid (def_dev, essid);
|
||||||
|
|
||||||
/* FIXME: allow picking of the wireless device, we currently just
|
/* FIXME: allow picking of the wireless device, we currently just
|
||||||
* use the first one found in our device list.
|
* use the first one found in our device list.
|
||||||
@@ -359,32 +356,30 @@ void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_ne
|
|||||||
* FIXME: default_dev might have gone away by the time the dialog
|
* FIXME: default_dev might have gone away by the time the dialog
|
||||||
* gets dismissed and we get here...
|
* gets dismissed and we get here...
|
||||||
*/
|
*/
|
||||||
if (net)
|
switch (key_type)
|
||||||
{
|
{
|
||||||
NMEncKeyType nm_key_type;
|
case KEY_TYPE_128_BIT_PASSPHRASE:
|
||||||
|
nm_key_type = NM_ENC_TYPE_128_BIT_PASSPHRASE;
|
||||||
switch (key_type)
|
break;
|
||||||
{
|
case KEY_TYPE_ASCII_KEY:
|
||||||
case KEY_TYPE_128_BIT_PASSPHRASE:
|
nm_key_type = NM_ENC_TYPE_ASCII_KEY;
|
||||||
nm_key_type = NM_ENC_TYPE_128_BIT_PASSPHRASE;
|
break;
|
||||||
break;
|
case KEY_TYPE_HEX_KEY:
|
||||||
case KEY_TYPE_ASCII_KEY:
|
nm_key_type = NM_ENC_TYPE_HEX_KEY;
|
||||||
nm_key_type = NM_ENC_TYPE_ASCII_KEY;
|
break;
|
||||||
break;
|
default:
|
||||||
case KEY_TYPE_HEX_KEY:
|
nm_key_type = NM_ENC_TYPE_UNKNOWN;
|
||||||
nm_key_type = NM_ENC_TYPE_HEX_KEY;
|
break;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
nm_key_type = NM_ENC_TYPE_UNKNOWN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (create_network)
|
|
||||||
nmwa_dbus_create_network (applet->connection, def_dev, net, nm_key_type, passphrase);
|
|
||||||
else
|
|
||||||
nmwa_dbus_set_device (applet->connection, def_dev, net, nm_key_type, passphrase);
|
|
||||||
network_device_unref (def_dev);
|
|
||||||
wireless_network_unref (net);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (create_network)
|
||||||
|
nmwa_dbus_create_network (applet->connection, def_dev, essid, nm_key_type, passphrase);
|
||||||
|
else
|
||||||
|
nmwa_dbus_set_device (applet->connection, def_dev, net, nm_key_type, passphrase);
|
||||||
|
|
||||||
|
if (net)
|
||||||
|
wireless_network_unref (net);
|
||||||
|
network_device_unref (def_dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@@ -19,11 +19,11 @@
|
|||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NMWirelessApplet.h"
|
#include "applet.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef NM_WIRELESS_APPLET_OTHER_NETWORK_DIALOG_H
|
#ifndef OTHER_NETWORK_DIALOG_H
|
||||||
#define NM_WIRELESS_APPLET_OTHER_NETWORK_DIALOG_H
|
#define OTHER_NETWORK_DIALOG_H
|
||||||
|
|
||||||
void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_network);
|
void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_network);
|
||||||
|
|
430
gnome/applet/passphrase-dialog.c
Normal file
@@ -0,0 +1,430 @@
|
|||||||
|
/* 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 <config.h>
|
||||||
|
#include <libintl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <glade/glade.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
#include <dbus/dbus-glib.h>
|
||||||
|
|
||||||
|
#include "applet.h"
|
||||||
|
#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
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static GladeXML *get_dialog_xml (GtkWidget *dialog)
|
||||||
|
{
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
g_return_val_if_fail (dialog != NULL, NULL);
|
||||||
|
|
||||||
|
if ((data = g_object_get_data (G_OBJECT (dialog), "glade-xml")))
|
||||||
|
return (GladeXML *)data;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void update_button_cb (GtkWidget *widget, GladeXML *xml)
|
||||||
|
{
|
||||||
|
GtkButton *button;
|
||||||
|
GtkComboBox *combo;
|
||||||
|
GtkEntry *passphrase_entry;
|
||||||
|
const char *passphrase_text;
|
||||||
|
gboolean enable = TRUE;
|
||||||
|
|
||||||
|
g_return_if_fail (xml != NULL);
|
||||||
|
|
||||||
|
button = GTK_BUTTON (glade_xml_get_widget (xml, "login_button"));
|
||||||
|
combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
|
||||||
|
passphrase_entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
|
||||||
|
passphrase_text = gtk_entry_get_text (passphrase_entry);
|
||||||
|
|
||||||
|
if (passphrase_text[0] == '\000')
|
||||||
|
enable = FALSE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int combo_choice = gtk_combo_box_get_active (combo);
|
||||||
|
switch (combo_choice)
|
||||||
|
{
|
||||||
|
case KEY_TYPE_ASCII_KEY:
|
||||||
|
if ((strlen (passphrase_text) != 5) && (strlen (passphrase_text) != 13))
|
||||||
|
enable = FALSE;
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_HEX_KEY:
|
||||||
|
if ((strlen (passphrase_text) != 10) && (strlen (passphrase_text) != 26))
|
||||||
|
enable = FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_set_sensitive (GTK_WIDGET (button), enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_clear
|
||||||
|
*
|
||||||
|
* Return dialog to its original state; clear out any network or device qdatas,
|
||||||
|
* clear the passphrase entry, and hide the dialog.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmi_passphrase_dialog_clear (GtkWidget *dialog)
|
||||||
|
{
|
||||||
|
char * data;
|
||||||
|
GtkWidget * entry = NULL;
|
||||||
|
GladeXML * xml = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (dialog != NULL);
|
||||||
|
|
||||||
|
if ((data = g_object_get_data (G_OBJECT (dialog), "device")))
|
||||||
|
{
|
||||||
|
network_device_unref ((NetworkDevice *)data);
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "device", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((data = g_object_get_data (G_OBJECT (dialog), "network")))
|
||||||
|
{
|
||||||
|
wireless_network_unref ((WirelessNetwork *)data);
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "network", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((data = g_object_get_data (G_OBJECT (dialog), "dbus-message")))
|
||||||
|
{
|
||||||
|
dbus_message_unref ((DBusMessage *) data);
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "dbus-message", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((xml = (GladeXML *)g_object_get_data (G_OBJECT (dialog), "glade-xml")))
|
||||||
|
{
|
||||||
|
entry = glade_xml_get_widget (xml, "passphrase_entry");
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_hide (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_key_type_combo_changed
|
||||||
|
*
|
||||||
|
* Change the text of the passphrase entry label to match the selected
|
||||||
|
* key type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmi_passphrase_dialog_key_type_combo_changed (GtkWidget *key_type_combo, gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget * dialog = gtk_widget_get_toplevel (key_type_combo);
|
||||||
|
|
||||||
|
if (GTK_WIDGET_TOPLEVEL (dialog))
|
||||||
|
{
|
||||||
|
GtkLabel * entry_label;
|
||||||
|
int combo_choice;
|
||||||
|
GladeXML * dialog_xml;
|
||||||
|
|
||||||
|
g_return_if_fail ((dialog_xml = get_dialog_xml (dialog)) != NULL);
|
||||||
|
|
||||||
|
entry_label = GTK_LABEL (glade_xml_get_widget (dialog_xml, "passphrase_entry_label"));
|
||||||
|
switch ((combo_choice = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo))))
|
||||||
|
{
|
||||||
|
case KEY_TYPE_128_BIT_PASSPHRASE:
|
||||||
|
gtk_label_set_label (entry_label, _("Passphrase:"));
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_ASCII_KEY:
|
||||||
|
gtk_label_set_label (entry_label, _("Ascii Key:"));
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_HEX_KEY:
|
||||||
|
gtk_label_set_label (entry_label, _("Hex Key:"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_ok_clicked
|
||||||
|
*
|
||||||
|
* OK button handler; grab the passphrase and send it back
|
||||||
|
* to NetworkManager. Get rid of the dialog.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget * dialog = gtk_widget_get_toplevel (ok_button);
|
||||||
|
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
|
||||||
|
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
if (GTK_WIDGET_TOPLEVEL (dialog))
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
GConfEntry * gconf_entry;
|
||||||
|
char * escaped_network;
|
||||||
|
|
||||||
|
g_return_if_fail ((dialog_xml = get_dialog_xml (dialog)) != NULL);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
case KEY_TYPE_128_BIT_PASSPHRASE:
|
||||||
|
key_type_return = NM_ENC_TYPE_128_BIT_PASSPHRASE;
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_ASCII_KEY:
|
||||||
|
key_type_return = NM_ENC_TYPE_ASCII_KEY;
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_HEX_KEY:
|
||||||
|
key_type_return = NM_ENC_TYPE_HEX_KEY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
key_type_return = NM_ENC_TYPE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tell NetworkManager about the key the user typed in */
|
||||||
|
nmi_dbus_return_user_key (applet->connection, message, passphrase, key_type_return);
|
||||||
|
|
||||||
|
/* Update GConf with the new user key */
|
||||||
|
escaped_network = gconf_escape_key (wireless_network_get_essid (net), strlen (wireless_network_get_essid (net)));
|
||||||
|
key = g_strdup_printf ("%s/%s", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
|
gconf_entry = gconf_client_get_entry (applet->gconf_client, key, NULL, TRUE, NULL);
|
||||||
|
g_free (key);
|
||||||
|
if (gconf_entry)
|
||||||
|
{
|
||||||
|
gconf_entry_unref (gconf_entry);
|
||||||
|
key = g_strdup_printf ("%s/%s/key", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
|
gconf_client_set_string (applet->gconf_client, key, passphrase, NULL);
|
||||||
|
g_free (key);
|
||||||
|
key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
|
gconf_client_set_string (applet->gconf_client, key, wireless_network_get_essid (net), NULL);
|
||||||
|
g_free (key);
|
||||||
|
key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||||
|
gconf_client_set_int (applet->gconf_client, key, key_type_return, NULL);
|
||||||
|
g_free (key);
|
||||||
|
}
|
||||||
|
g_free (escaped_network);
|
||||||
|
|
||||||
|
nmi_passphrase_dialog_clear (dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_cancel_clicked
|
||||||
|
*
|
||||||
|
* Cancel button handler; return a cancellation message to NetworkManager
|
||||||
|
* and get rid of the dialog.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmi_passphrase_dialog_cancel_clicked (GtkWidget *cancel_button, gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget * dialog = gtk_widget_get_toplevel (cancel_button);
|
||||||
|
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
|
||||||
|
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
if (GTK_WIDGET_TOPLEVEL (dialog))
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
|
||||||
|
nmi_dbus_return_user_key (applet->connection, message, "***canceled***", NM_ENC_TYPE_UNKNOWN);
|
||||||
|
nmi_passphrase_dialog_clear (dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_show
|
||||||
|
*
|
||||||
|
* Pop up the user key dialog in response to a dbus message
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmi_passphrase_dialog_show (GtkWidget *dialog, NetworkDevice *dev, WirelessNetwork *net, DBusMessage *message)
|
||||||
|
{
|
||||||
|
GladeXML * dialog_xml;
|
||||||
|
const char * orig_label_text;
|
||||||
|
|
||||||
|
g_return_if_fail (dialog != NULL);
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
g_return_if_fail ((dialog_xml = get_dialog_xml (dialog)) != NULL);
|
||||||
|
|
||||||
|
if (GTK_WIDGET_VISIBLE (dialog))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(orig_label_text = g_object_get_data (G_OBJECT (dialog), "orig-label-text")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
network_device_ref (dev);
|
||||||
|
wireless_network_ref (net);
|
||||||
|
|
||||||
|
nmi_passphrase_dialog_clear (dialog);
|
||||||
|
|
||||||
|
/* Insert the Network name into the dialog text */
|
||||||
|
if (orig_label_text)
|
||||||
|
{
|
||||||
|
GtkWidget * label = glade_xml_get_widget (dialog_xml, "label1");
|
||||||
|
char * new_label_text = g_strdup_printf (orig_label_text, wireless_network_get_essid (net));
|
||||||
|
|
||||||
|
gtk_label_set_label (GTK_LABEL (label), new_label_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "device", dev);
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "network", net);
|
||||||
|
dbus_message_ref (message);
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "dbus-message", message);
|
||||||
|
|
||||||
|
gtk_widget_show (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_cancel
|
||||||
|
*
|
||||||
|
* Cancel and hide any user key dialog that might be up
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmi_passphrase_dialog_cancel (GtkWidget *dialog)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dialog != NULL);
|
||||||
|
|
||||||
|
if (GTK_WIDGET_VISIBLE (dialog))
|
||||||
|
nmi_passphrase_dialog_clear (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_init
|
||||||
|
*
|
||||||
|
* Initialize the passphrase dialog
|
||||||
|
*
|
||||||
|
* Returns: TRUE on success
|
||||||
|
* FALSE on failure
|
||||||
|
*/
|
||||||
|
GtkWidget *nmi_passphrase_dialog_init (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
GtkWidget * dialog;
|
||||||
|
GtkButton * ok_button;
|
||||||
|
GtkButton * cancel_button;
|
||||||
|
GtkEntry * entry;
|
||||||
|
GtkComboBox * key_type_combo;
|
||||||
|
GtkLabel * label;
|
||||||
|
GladeXML * dialog_xml;
|
||||||
|
char * orig_label_text;
|
||||||
|
|
||||||
|
if (!(dialog_xml = glade_xml_new (applet->glade_file, "passphrase_dialog", NULL)))
|
||||||
|
{
|
||||||
|
nmwa_schedule_warning_dialog (applet, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog = glade_xml_get_widget (dialog_xml, "passphrase_dialog");
|
||||||
|
gtk_widget_hide (dialog);
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "glade-xml", dialog_xml);
|
||||||
|
|
||||||
|
/* Save original label text to preserve the '%s' and other formatting that gets overwritten
|
||||||
|
* when the dialog is first shown.
|
||||||
|
*/
|
||||||
|
label = GTK_LABEL (glade_xml_get_widget (dialog_xml, "label1"));
|
||||||
|
orig_label_text = g_strdup (gtk_label_get_label (label));
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "orig-label-text", orig_label_text);
|
||||||
|
|
||||||
|
ok_button = GTK_BUTTON (glade_xml_get_widget (dialog_xml, "login_button"));
|
||||||
|
g_signal_connect (G_OBJECT (ok_button), "clicked", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_ok_clicked), applet);
|
||||||
|
gtk_widget_grab_default (GTK_WIDGET (ok_button));
|
||||||
|
cancel_button = GTK_BUTTON (glade_xml_get_widget (dialog_xml, "cancel_button"));
|
||||||
|
g_signal_connect (G_OBJECT (cancel_button), "clicked", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_cancel_clicked), applet);
|
||||||
|
|
||||||
|
entry = GTK_ENTRY (glade_xml_get_widget (dialog_xml, "passphrase_entry"));
|
||||||
|
nmi_passphrase_dialog_clear (dialog);
|
||||||
|
gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
|
||||||
|
g_signal_connect (entry, "changed", G_CALLBACK (update_button_cb), dialog_xml);
|
||||||
|
|
||||||
|
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (dialog_xml, "key_type_combo"));
|
||||||
|
gtk_combo_box_set_active (key_type_combo, 0);
|
||||||
|
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_key_type_combo_changed), applet);
|
||||||
|
nmi_passphrase_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), applet);
|
||||||
|
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_passphrase_dialog_destroy
|
||||||
|
*
|
||||||
|
* Dispose of the passphrase dialog and its data
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmi_passphrase_dialog_destroy (GtkWidget *dialog)
|
||||||
|
{
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
g_return_if_fail (dialog != NULL);
|
||||||
|
|
||||||
|
nmi_passphrase_dialog_clear (dialog);
|
||||||
|
|
||||||
|
if ((data = g_object_get_data (G_OBJECT (dialog), "glade-xml")))
|
||||||
|
{
|
||||||
|
g_object_unref (G_OBJECT (data));
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "glade-xml", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((data = g_object_get_data (G_OBJECT (dialog), "orig-label-text")))
|
||||||
|
{
|
||||||
|
g_free (data);
|
||||||
|
g_object_set_data (G_OBJECT (dialog), "orig-label-text", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_destroy (dialog);
|
||||||
|
}
|
@@ -16,34 +16,22 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* This applet used the GNOME Wireless Applet as a skeleton to build from.
|
|
||||||
*
|
|
||||||
* (C) Copyright 2005 Red Hat, Inc.
|
* (C) Copyright 2005 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifndef PASSPHRASE_DIALOG_H
|
||||||
#include <config.h>
|
#define PASSPHRASE_DIALOG_H
|
||||||
|
|
||||||
|
#include "applet.h"
|
||||||
|
#include "nm-device.h"
|
||||||
|
#include "wireless-network.h"
|
||||||
|
|
||||||
|
GtkWidget * nmi_passphrase_dialog_init (NMWirelessApplet *applet);
|
||||||
|
|
||||||
|
void nmi_passphrase_dialog_destroy (GtkWidget *dialog);
|
||||||
|
|
||||||
|
void nmi_passphrase_dialog_show (GtkWidget *dialog, NetworkDevice *dev, WirelessNetwork *net, DBusMessage *message);
|
||||||
|
|
||||||
|
void nmi_passphrase_dialog_cancel (GtkWidget *dialog);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <libgnomeui/libgnomeui.h>
|
|
||||||
#include "NMWirelessApplet.h"
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
NMWirelessApplet *nmwa;
|
|
||||||
|
|
||||||
gnome_program_init ("NMWirelessApplet", VERSION, LIBGNOMEUI_MODULE,
|
|
||||||
argc, argv,
|
|
||||||
GNOME_PARAM_NONE);
|
|
||||||
|
|
||||||
nmwa = nmwa_new ();
|
|
||||||
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (nmwa));
|
|
||||||
|
|
||||||
gtk_main ();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "nmwa-vpn-connection.h"
|
#include "vpn-connection.h"
|
||||||
|
|
||||||
|
|
||||||
struct VPNConnection
|
struct VPNConnection
|
||||||
@@ -31,7 +31,7 @@ struct VPNConnection
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
VPNConnection *nmwa_vpn_connection_new (const char *name, const char *func)
|
VPNConnection *nmwa_vpn_connection_new (const char *name)
|
||||||
{
|
{
|
||||||
VPNConnection *vpn;
|
VPNConnection *vpn;
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ VPNConnection *nmwa_vpn_connection_new (const char *name, const char *func)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VPNConnection *nmwa_vpn_connection_copy (VPNConnection *src_vpn, const char *func)
|
VPNConnection *nmwa_vpn_connection_copy (VPNConnection *src_vpn)
|
||||||
{
|
{
|
||||||
VPNConnection *dst_vpn;
|
VPNConnection *dst_vpn;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ VPNConnection *nmwa_vpn_connection_copy (VPNConnection *src_vpn, const char *fun
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nmwa_vpn_connection_ref (VPNConnection *vpn, const char *func)
|
void nmwa_vpn_connection_ref (VPNConnection *vpn)
|
||||||
{
|
{
|
||||||
g_return_if_fail (vpn != NULL);
|
g_return_if_fail (vpn != NULL);
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ void nmwa_vpn_connection_ref (VPNConnection *vpn, const char *func)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nmwa_vpn_connection_unref (VPNConnection *vpn, const char *func)
|
void nmwa_vpn_connection_unref (VPNConnection *vpn)
|
||||||
{
|
{
|
||||||
g_return_if_fail (vpn != NULL);
|
g_return_if_fail (vpn != NULL);
|
||||||
|
|
@@ -19,15 +19,15 @@
|
|||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NMWA_VPN_CONNECTION_H
|
#ifndef VPN_CONNECTION_H
|
||||||
#define NMWA_VPN_CONNECTION_H
|
#define VPN_CONNECTION_H
|
||||||
|
|
||||||
#include "NMWirelessApplet.h"
|
#include "applet.h"
|
||||||
|
|
||||||
VPNConnection * nmwa_vpn_connection_new (const char *name, const char *func);
|
VPNConnection * nmwa_vpn_connection_new (const char *name);
|
||||||
VPNConnection * nmwa_vpn_connection_copy (VPNConnection *vpn, const char *func);
|
VPNConnection * nmwa_vpn_connection_copy (VPNConnection *vpn);
|
||||||
void nmwa_vpn_connection_ref (VPNConnection *vpn, const char *func);
|
void nmwa_vpn_connection_ref (VPNConnection *vpn);
|
||||||
void nmwa_vpn_connection_unref (VPNConnection *vpn, const char *func);
|
void nmwa_vpn_connection_unref (VPNConnection *vpn);
|
||||||
|
|
||||||
const char * nmwa_vpn_connection_get_name (VPNConnection *vpn);
|
const char * nmwa_vpn_connection_get_name (VPNConnection *vpn);
|
||||||
|
|
@@ -37,8 +37,8 @@
|
|||||||
#define N_(x) x
|
#define N_(x) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "NMWirelessApplet.h"
|
#include "applet.h"
|
||||||
#include "nmwa-vpn-password-dialog.h"
|
#include "vpn-password-dialog.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
static gboolean lookup_pass (const char *vpn, const char *username, char **password)
|
static gboolean lookup_pass (const char *vpn, const char *username, char **password)
|
@@ -19,10 +19,10 @@
|
|||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NMWA_VPN_PASSWORD_DIALOG_H
|
#ifndef VPN_PASSWORD_DIALOG_H
|
||||||
#define NMWA_VPN_PASSWORD_DIALOG_H
|
#define VPN_PASSWORD_DIALOG_H
|
||||||
|
|
||||||
#include "NMWirelessApplet.h"
|
#include "applet.h"
|
||||||
|
|
||||||
char *nmwa_vpn_request_password (NMWirelessApplet *applet, const char *vpn, const char *username, gboolean retry);
|
char *nmwa_vpn_request_password (NMWirelessApplet *applet, const char *vpn, const char *username, gboolean retry);
|
||||||
|
|
@@ -667,4 +667,241 @@ Hex key (WEP)</property>
|
|||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
|
<widget class="GtkDialog" id="passphrase_dialog">
|
||||||
|
<property name="border_width">6</property>
|
||||||
|
<property name="has_focus">True</property>
|
||||||
|
<property name="title" translatable="yes">Wireless Network Key Required</property>
|
||||||
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
|
<property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
|
||||||
|
<property name="modal">False</property>
|
||||||
|
<property name="resizable">False</property>
|
||||||
|
<property name="destroy_with_parent">False</property>
|
||||||
|
<property name="decorated">True</property>
|
||||||
|
<property name="skip_taskbar_hint">False</property>
|
||||||
|
<property name="skip_pager_hint">False</property>
|
||||||
|
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||||
|
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||||
|
<property name="has_separator">False</property>
|
||||||
|
|
||||||
|
<child internal-child="vbox">
|
||||||
|
<widget class="GtkVBox" id="dialog-vbox1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
|
||||||
|
<child internal-child="action_area">
|
||||||
|
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkButton" id="cancel_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_default">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="label">gtk-cancel</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
<property name="focus_on_click">True</property>
|
||||||
|
<property name="response_id">-6</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkButton" id="login_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_default">True</property>
|
||||||
|
<property name="has_default">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="label" translatable="yes">_Login to Network</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
<property name="focus_on_click">True</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="pack_type">GTK_PACK_END</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="hbox1">
|
||||||
|
<property name="border_width">6</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImage" id="image1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="pixbuf">keyring.png</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkVBox" id="vbox1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes"><span weight="bold" size="larger">Passphrase Required by Wireless Network</span>
|
||||||
|
|
||||||
|
A passphrase or encryption key is required to access the wireless network '%s'.</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
|
<property name="use_markup">True</property>
|
||||||
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="hbox3">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label3">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Key Type:</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
|
<property name="use_markup">False</property>
|
||||||
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
<property name="wrap">False</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkComboBox" id="key_type_combo">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="items" translatable="yes">128-bit Passphrase (WEP)
|
||||||
|
Ascii Key (WEP)
|
||||||
|
Hex Key (WEP)</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="hbox2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="passphrase_entry_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Passphrase:</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
|
<property name="use_markup">False</property>
|
||||||
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
<property name="wrap">False</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkEntry" id="passphrase_entry">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="has_focus">True</property>
|
||||||
|
<property name="editable">True</property>
|
||||||
|
<property name="visibility">True</property>
|
||||||
|
<property name="max_length">0</property>
|
||||||
|
<property name="text" translatable="yes"></property>
|
||||||
|
<property name="has_frame">True</property>
|
||||||
|
<property name="invisible_char" translatable="yes">*</property>
|
||||||
|
<property name="activates_default">True</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
|
||||||
</glade-interface>
|
</glade-interface>
|
195
gnome/applet/wireless-network.c
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
|
/* 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 2004-2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include "wireless-network.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Representation of a wireless network
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct WirelessNetwork
|
||||||
|
{
|
||||||
|
int refcount;
|
||||||
|
char * nm_path;
|
||||||
|
char * essid;
|
||||||
|
gboolean encrypted;
|
||||||
|
gboolean active;
|
||||||
|
gint8 strength;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wireless_network_new
|
||||||
|
*
|
||||||
|
* Create a new wireless network structure
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
WirelessNetwork *wireless_network_new (const char *essid, const char *nm_path)
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (essid != NULL, NULL);
|
||||||
|
g_return_val_if_fail (nm_path != NULL, NULL);
|
||||||
|
|
||||||
|
if ((net = g_malloc0 (sizeof (WirelessNetwork))))
|
||||||
|
{
|
||||||
|
net->essid = g_strdup (essid);
|
||||||
|
net->nm_path = g_strdup (nm_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (net);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wireless_network_copy
|
||||||
|
*
|
||||||
|
* Create a new wireless network structure from an existing one
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
WirelessNetwork *wireless_network_copy (WirelessNetwork *src)
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (src != NULL, NULL);
|
||||||
|
|
||||||
|
if ((net = g_malloc0 (sizeof (WirelessNetwork))))
|
||||||
|
{
|
||||||
|
net->refcount = 1;
|
||||||
|
net->nm_path = g_strdup (src->nm_path);
|
||||||
|
net->essid = g_strdup (src->essid);
|
||||||
|
net->active = src->active;
|
||||||
|
net->encrypted = src->encrypted;
|
||||||
|
net->strength = src->strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (net);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wireless_network_ref
|
||||||
|
*
|
||||||
|
* Increment the reference count of the wireless network
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void wireless_network_ref (WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
|
||||||
|
net->refcount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wireless_network_unref
|
||||||
|
*
|
||||||
|
* Unrefs (and possibly frees) the representation of a wireless network
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void wireless_network_unref (WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
|
||||||
|
net->refcount--;
|
||||||
|
if (net->refcount < 1)
|
||||||
|
{
|
||||||
|
g_free (net->nm_path);
|
||||||
|
g_free (net->essid);
|
||||||
|
g_free (net);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for active
|
||||||
|
*/
|
||||||
|
gboolean wireless_network_get_active (WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (net != NULL, FALSE);
|
||||||
|
|
||||||
|
return net->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wireless_network_set_active (WirelessNetwork *net, gboolean active)
|
||||||
|
{
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
|
||||||
|
net->active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for essid
|
||||||
|
*/
|
||||||
|
const char *wireless_network_get_essid (WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (net != NULL, FALSE);
|
||||||
|
|
||||||
|
return net->essid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for nm_path
|
||||||
|
*/
|
||||||
|
const char *wireless_network_get_nm_path (WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (net != NULL, FALSE);
|
||||||
|
|
||||||
|
return net->nm_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for encrypted
|
||||||
|
*/
|
||||||
|
gboolean wireless_network_get_encrypted (WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (net != NULL, FALSE);
|
||||||
|
|
||||||
|
return net->encrypted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wireless_network_set_encrypted (WirelessNetwork *net, gboolean encrypted)
|
||||||
|
{
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
|
||||||
|
net->encrypted = encrypted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessors for strength
|
||||||
|
*/
|
||||||
|
gint8 wireless_network_get_strength (WirelessNetwork *net)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (net != NULL, FALSE);
|
||||||
|
|
||||||
|
return net->strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wireless_network_set_strength (WirelessNetwork *net, gint8 strength)
|
||||||
|
{
|
||||||
|
g_return_if_fail (net != NULL);
|
||||||
|
|
||||||
|
net->strength = strength;
|
||||||
|
}
|
||||||
|
|
47
gnome/applet/wireless-network.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
||||||
|
/* 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 2004-2005 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WIRELESS_NETWORK_H
|
||||||
|
#define WIRELESS_NETWORK_H
|
||||||
|
|
||||||
|
typedef struct WirelessNetwork WirelessNetwork;
|
||||||
|
|
||||||
|
WirelessNetwork * wireless_network_new (const char *essid, const char *nm_path);
|
||||||
|
WirelessNetwork * wireless_network_copy (WirelessNetwork *src);
|
||||||
|
|
||||||
|
void wireless_network_ref (WirelessNetwork *net);
|
||||||
|
void wireless_network_unref (WirelessNetwork *net);
|
||||||
|
|
||||||
|
gboolean wireless_network_get_active (WirelessNetwork *net);
|
||||||
|
void wireless_network_set_active (WirelessNetwork *net, gboolean active);
|
||||||
|
|
||||||
|
const char * wireless_network_get_essid (WirelessNetwork *net);
|
||||||
|
|
||||||
|
const char * wireless_network_get_nm_path (WirelessNetwork *net);
|
||||||
|
|
||||||
|
gboolean wireless_network_get_encrypted (WirelessNetwork *net);
|
||||||
|
void wireless_network_set_encrypted (WirelessNetwork *net, gboolean encrypted);
|
||||||
|
|
||||||
|
gint8 wireless_network_get_strength (WirelessNetwork *net);
|
||||||
|
void wireless_network_set_strength (WirelessNetwork *net, gint8 strength);
|
||||||
|
|
||||||
|
#endif
|
@@ -33,29 +33,29 @@
|
|||||||
|
|
||||||
struct libnm_glib_ctx
|
struct libnm_glib_ctx
|
||||||
{
|
{
|
||||||
unsigned char check;
|
unsigned char check;
|
||||||
|
|
||||||
GMainContext *g_main_ctx;
|
GMainContext * g_main_ctx;
|
||||||
GMainLoop *g_main_loop;
|
GMainLoop * g_main_loop;
|
||||||
DBusConnection *dbus_con;
|
DBusConnection * dbus_con;
|
||||||
guint dbus_watcher;
|
guint dbus_watcher;
|
||||||
gboolean thread_done;
|
gboolean thread_done;
|
||||||
gboolean thread_inited;
|
gboolean thread_inited;
|
||||||
|
|
||||||
GSList *callbacks;
|
GSList * callbacks;
|
||||||
GMutex *callbacks_lock;
|
GMutex * callbacks_lock;
|
||||||
gint callback_id_last;
|
gint callback_id_last;
|
||||||
|
|
||||||
libnm_glib_status nm_status;
|
libnm_glib_state nm_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct libnm_glib_callback
|
typedef struct libnm_glib_callback
|
||||||
{
|
{
|
||||||
gint id;
|
gint id;
|
||||||
GMainContext *gmain_ctx;
|
GMainContext * gmain_ctx;
|
||||||
libnm_glib_ctx *libnm_glib_ctx;
|
libnm_glib_ctx * libnm_glib_ctx;
|
||||||
libnm_glib_callback_func func;
|
libnm_glib_callback_func func;
|
||||||
gpointer user_data;
|
gpointer user_data;
|
||||||
} libnm_glib_callback;
|
} libnm_glib_callback;
|
||||||
|
|
||||||
|
|
||||||
@@ -64,20 +64,19 @@ static DBusConnection * libnm_glib_dbus_init (gpointer *user_data, GMainContext
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static char *libnm_glib_get_nm_status (DBusConnection *con)
|
static NMState libnm_glib_get_nm_state (DBusConnection *con)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage * message;
|
||||||
DBusMessage *reply;
|
DBusMessage * reply;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
char *status = NULL;
|
NMState state = NM_STATE_UNKNOWN;
|
||||||
char *ret = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (con != NULL, NULL);
|
g_return_val_if_fail (con != NULL, NM_STATE_UNKNOWN);
|
||||||
|
|
||||||
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "status")))
|
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "state")))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "libnm_glib_get_nm_status(): Couldn't allocate the dbus message\n");
|
fprintf (stderr, "libnm_glib_get_nm_state(): Couldn't allocate the dbus message\n");
|
||||||
return NULL;
|
return NM_STATE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
@@ -85,30 +84,25 @@ static char *libnm_glib_get_nm_status (DBusConnection *con)
|
|||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
if (dbus_error_is_set (&error))
|
if (dbus_error_is_set (&error))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "libnm_glib_get_nm_status(): %s raised:\n %s\n\n", error.name, error.message);
|
fprintf (stderr, "libnm_glib_get_nm_state(): %s raised:\n %s\n\n", error.name, error.message);
|
||||||
dbus_error_free (&error);
|
goto out;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reply)
|
if (!reply)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "libnm_glib_get_nm_status(): dbus reply message was NULL\n" );
|
fprintf (stderr, "libnm_glib_get_nm_state(): dbus reply message was NULL\n" );
|
||||||
return NULL;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if (!(dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &status, DBUS_TYPE_INVALID)))
|
if (!(dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID)))
|
||||||
{
|
fprintf (stderr, "libnm_glib_get_nm_state(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
||||||
fprintf (stderr, "libnm_glib_get_nm_status(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
dbus_error_free (&error);
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
return g_strdup ("error");
|
|
||||||
}
|
|
||||||
ret = g_strdup (status);
|
|
||||||
dbus_message_unref (reply);
|
dbus_message_unref (reply);
|
||||||
|
|
||||||
return ret;
|
out:
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -158,21 +152,31 @@ static void libnm_glib_call_callbacks (libnm_glib_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void libnm_glib_update_status (libnm_glib_ctx *ctx, char *status)
|
static void libnm_glib_update_state (libnm_glib_ctx *ctx, NMState state)
|
||||||
{
|
{
|
||||||
libnm_glib_status old_status;
|
libnm_glib_state old_state;
|
||||||
|
|
||||||
g_return_if_fail (ctx != NULL);
|
g_return_if_fail (ctx != NULL);
|
||||||
|
|
||||||
old_status = ctx->nm_status;
|
old_state = ctx->nm_state;
|
||||||
if (!status)
|
switch (state)
|
||||||
ctx->nm_status = LIBNM_NO_NETWORKMANAGER;
|
{
|
||||||
else if (strcmp (status, "connected") == 0)
|
case NM_STATE_CONNECTED:
|
||||||
ctx->nm_status = LIBNM_ACTIVE_NETWORK_CONNECTION;
|
ctx->nm_state = LIBNM_ACTIVE_NETWORK_CONNECTION;
|
||||||
else
|
break;
|
||||||
ctx->nm_status = LIBNM_NO_NETWORK_CONNECTION;
|
|
||||||
|
|
||||||
if (old_status != ctx->nm_status)
|
case NM_STATE_SCANNING:
|
||||||
|
case NM_STATE_DISCONNECTED:
|
||||||
|
ctx->nm_state = LIBNM_NO_NETWORK_CONNECTION;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NM_STATE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
ctx->nm_state = LIBNM_NO_NETWORKMANAGER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old_state != ctx->nm_state)
|
||||||
libnm_glib_call_callbacks (ctx);
|
libnm_glib_call_callbacks (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +195,7 @@ static DBusHandlerResult libnm_glib_dbus_filter (DBusConnection *connection, DBu
|
|||||||
if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected"))
|
if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected"))
|
||||||
{
|
{
|
||||||
/* Try to reactivate our connection to dbus on the next pass through the event loop */
|
/* Try to reactivate our connection to dbus on the next pass through the event loop */
|
||||||
ctx->nm_status = LIBNM_NO_DBUS;
|
ctx->nm_state = LIBNM_NO_DBUS;
|
||||||
dbus_connection_disconnect (ctx->dbus_con);
|
dbus_connection_disconnect (ctx->dbus_con);
|
||||||
libnm_glib_schedule_dbus_watcher (ctx);
|
libnm_glib_schedule_dbus_watcher (ctx);
|
||||||
}
|
}
|
||||||
@@ -215,13 +219,9 @@ static DBusHandlerResult libnm_glib_dbus_filter (DBusConnection *connection, DBu
|
|||||||
gboolean new_owner_good = (new_owner && (strlen (new_owner) > 0));
|
gboolean new_owner_good = (new_owner && (strlen (new_owner) > 0));
|
||||||
|
|
||||||
if (!old_owner_good && new_owner_good) /* Equivalent to old ServiceCreated signal */
|
if (!old_owner_good && new_owner_good) /* Equivalent to old ServiceCreated signal */
|
||||||
{
|
libnm_glib_update_state (ctx, libnm_glib_get_nm_state (ctx->dbus_con));
|
||||||
char *status_string = libnm_glib_get_nm_status (ctx->dbus_con);
|
|
||||||
libnm_glib_update_status (ctx, status_string);
|
|
||||||
g_free (status_string);
|
|
||||||
}
|
|
||||||
else if (old_owner_good && !new_owner_good) /* Equivalent to old ServiceDeleted signal */
|
else if (old_owner_good && !new_owner_good) /* Equivalent to old ServiceDeleted signal */
|
||||||
ctx->nm_status = LIBNM_NO_NETWORKMANAGER;
|
ctx->nm_state = LIBNM_NO_NETWORKMANAGER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,21 +234,14 @@ static DBusHandlerResult libnm_glib_dbus_filter (DBusConnection *connection, DBu
|
|||||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivating")
|
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivating")
|
||||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DevicesChanged"))
|
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DevicesChanged"))
|
||||||
{
|
{
|
||||||
char *status_string = libnm_glib_get_nm_status (ctx->dbus_con);
|
libnm_glib_update_state (ctx, libnm_glib_get_nm_state (ctx->dbus_con));
|
||||||
libnm_glib_update_status (ctx, status_string);
|
|
||||||
g_free (status_string);
|
|
||||||
}
|
}
|
||||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "NetworkStatusChange"))
|
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, NM_DBUS_SIGNAL_STATE_CHANGE))
|
||||||
{
|
{
|
||||||
char *status_string = NULL;
|
NMState state = NM_STATE_UNKNOWN;
|
||||||
|
|
||||||
if (!(dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &status_string, DBUS_TYPE_INVALID)))
|
dbus_message_get_args (message, &error, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID);
|
||||||
status_string = g_strdup ("error");
|
libnm_glib_update_state (ctx, state);
|
||||||
else
|
|
||||||
status_string = g_strdup (status_string);
|
|
||||||
|
|
||||||
libnm_glib_update_status (ctx, status_string);
|
|
||||||
g_free (status_string);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
handled = FALSE;
|
handled = FALSE;
|
||||||
@@ -374,13 +367,10 @@ static gpointer libnm_glib_dbus_worker (gpointer user_data)
|
|||||||
*/
|
*/
|
||||||
if (!ctx->dbus_con)
|
if (!ctx->dbus_con)
|
||||||
libnm_glib_schedule_dbus_watcher (ctx);
|
libnm_glib_schedule_dbus_watcher (ctx);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
char *status_string = NULL;
|
|
||||||
|
|
||||||
/* Get initial status */
|
/* Get initial status */
|
||||||
status_string = libnm_glib_get_nm_status (ctx->dbus_con);
|
libnm_glib_update_state (ctx, libnm_glib_get_nm_state (ctx->dbus_con));
|
||||||
libnm_glib_update_status (ctx, status_string);
|
|
||||||
g_free (status_string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->thread_inited = TRUE;
|
ctx->thread_inited = TRUE;
|
||||||
@@ -463,11 +453,7 @@ libnm_glib_ctx *libnm_glib_init (void)
|
|||||||
*/
|
*/
|
||||||
ctx->dbus_con = libnm_glib_dbus_init ((gpointer)ctx, ctx->g_main_ctx);
|
ctx->dbus_con = libnm_glib_dbus_init ((gpointer)ctx, ctx->g_main_ctx);
|
||||||
if (ctx->dbus_con)
|
if (ctx->dbus_con)
|
||||||
{
|
libnm_glib_update_state (ctx, libnm_glib_get_nm_state (ctx->dbus_con));
|
||||||
char *status_string = libnm_glib_get_nm_status (ctx->dbus_con);
|
|
||||||
libnm_glib_update_status (ctx, status_string);
|
|
||||||
g_free (status_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_thread_create (libnm_glib_dbus_worker, ctx, FALSE, &error))
|
if (!g_thread_create (libnm_glib_dbus_worker, ctx, FALSE, &error))
|
||||||
{
|
{
|
||||||
@@ -501,12 +487,12 @@ void libnm_glib_shutdown (libnm_glib_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
libnm_glib_status libnm_glib_get_network_status (const libnm_glib_ctx *ctx)
|
libnm_glib_state libnm_glib_get_network_state (const libnm_glib_ctx *ctx)
|
||||||
{
|
{
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return LIBNM_INVALID_CONTEXT;
|
return LIBNM_INVALID_CONTEXT;
|
||||||
|
|
||||||
return ctx->nm_status;
|
return ctx->nm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@@ -28,14 +28,14 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum libnm_glib_status
|
typedef enum libnm_glib_state
|
||||||
{
|
{
|
||||||
LIBNM_NO_DBUS = 0,
|
LIBNM_NO_DBUS = 0,
|
||||||
LIBNM_NO_NETWORKMANAGER,
|
LIBNM_NO_NETWORKMANAGER,
|
||||||
LIBNM_NO_NETWORK_CONNECTION,
|
LIBNM_NO_NETWORK_CONNECTION,
|
||||||
LIBNM_ACTIVE_NETWORK_CONNECTION,
|
LIBNM_ACTIVE_NETWORK_CONNECTION,
|
||||||
LIBNM_INVALID_CONTEXT
|
LIBNM_INVALID_CONTEXT
|
||||||
} libnm_glib_status;
|
} libnm_glib_state;
|
||||||
|
|
||||||
typedef struct libnm_glib_ctx libnm_glib_ctx;
|
typedef struct libnm_glib_ctx libnm_glib_ctx;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ typedef void (*libnm_glib_callback_func) (libnm_glib_ctx *libnm_ctx, gpointer us
|
|||||||
libnm_glib_ctx *libnm_glib_init (void);
|
libnm_glib_ctx *libnm_glib_init (void);
|
||||||
void libnm_glib_shutdown (libnm_glib_ctx *ctx);
|
void libnm_glib_shutdown (libnm_glib_ctx *ctx);
|
||||||
|
|
||||||
libnm_glib_status libnm_glib_get_network_status (const libnm_glib_ctx *ctx);
|
libnm_glib_state libnm_glib_get_network_state (const libnm_glib_ctx *ctx);
|
||||||
|
|
||||||
gint libnm_glib_register_callback (libnm_glib_ctx *ctx, libnm_glib_callback_func func, gpointer user_data, GMainContext *g_main_ctx);
|
gint libnm_glib_register_callback (libnm_glib_ctx *ctx, libnm_glib_callback_func func, gpointer user_data, GMainContext *g_main_ctx);
|
||||||
void libnm_glib_unregister_callback (libnm_glib_ctx *ctx, gint id);
|
void libnm_glib_unregister_callback (libnm_glib_ctx *ctx, gint id);
|
@@ -1,6 +0,0 @@
|
|||||||
Makefile
|
|
||||||
Makefile.in
|
|
||||||
NetworkManagerInfo
|
|
||||||
passphrase.glade.bak
|
|
||||||
passphrase.gladep
|
|
||||||
passphrase.gladep.bak
|
|
@@ -1,57 +0,0 @@
|
|||||||
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
|
|
||||||
|
|
||||||
AM_CPPFLAGS = \
|
|
||||||
$(DBUS_CFLAGS) \
|
|
||||||
$(GTHREAD_CFLAGS) \
|
|
||||||
$(GTK_CFLAGS) \
|
|
||||||
$(GDK_PIXBUF_CFLAGS) \
|
|
||||||
$(GLADE_CFLAGS) \
|
|
||||||
$(GCONF_CFLAGS) \
|
|
||||||
$(LIBGNOMEUI_CFLAGS) \
|
|
||||||
$(GNOME_KEYRING_CFLAGS) \
|
|
||||||
-Wall \
|
|
||||||
-DDBUS_API_SUBJECT_TO_CHANGE \
|
|
||||||
-DG_DISABLE_DEPRECATED \
|
|
||||||
-DGTK_DISABLE_DEPRECATED \
|
|
||||||
-DGLADEDIR=\""$(datadir)/NetworkManagerInfo/glade"\" \
|
|
||||||
-DBINDIR=\"$(bindir)\" \
|
|
||||||
-DPREFIX=\""$(prefix)"\" \
|
|
||||||
-DSYSCONFDIR=\""$(sysconfdir)"\" \
|
|
||||||
-DVERSION="\"$(VERSION)\"" \
|
|
||||||
-DLIBDIR=\""$(libdir)"\" \
|
|
||||||
-DLIBEXECDIR=\""$(libexecdir)"\" \
|
|
||||||
-DDATADIR=\"$(datadir)\"
|
|
||||||
|
|
||||||
bin_PROGRAMS = NetworkManagerInfo
|
|
||||||
|
|
||||||
NetworkManagerInfo_SOURCES = NetworkManagerInfo.h \
|
|
||||||
NetworkManagerInfo.c \
|
|
||||||
NetworkManagerInfoDbus.h \
|
|
||||||
NetworkManagerInfoDbus.c \
|
|
||||||
NetworkManagerInfoPassphraseDialog.c \
|
|
||||||
NetworkManagerInfoPassphraseDialog.h \
|
|
||||||
NetworkManagerInfoVPN.c \
|
|
||||||
NetworkManagerInfoVPN.h \
|
|
||||||
NetworkManagerInfoNetworksDialog.c \
|
|
||||||
NetworkManagerInfoNetworksDialog.h
|
|
||||||
|
|
||||||
NetworkManagerInfo_LDADD = \
|
|
||||||
$(DBUS_LIBS) \
|
|
||||||
$(GTHREAD_LIBS) \
|
|
||||||
$(GLADE_LIBS) \
|
|
||||||
$(GCONF_LIBS) \
|
|
||||||
$(GTK_LIBS) \
|
|
||||||
$(GDK_PIXBUF_LIBS) \
|
|
||||||
$(GNOME_KEYRING_LIBS) \
|
|
||||||
$(LIBGNOMEUI_LIBS) \
|
|
||||||
$(top_builddir)/utils/libnmutils.la
|
|
||||||
|
|
||||||
|
|
||||||
gladedir = $(datadir)/NetworkManagerInfo/glade
|
|
||||||
glade_DATA = passphrase.glade keyring.png networks.glade
|
|
||||||
|
|
||||||
dbusservicedir=$(DBUS_SYS_DIR)
|
|
||||||
dbusservice_DATA = NetworkManagerInfo.conf
|
|
||||||
|
|
||||||
EXTRA_DIST = $(glade_DATA) $(dbusservice_DATA)
|
|
||||||
|
|
@@ -1,336 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* 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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libgnomeui/gnome-client.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib-lowlevel.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <glade/glade.h>
|
|
||||||
#include <gconf/gconf-client.h>
|
|
||||||
#include <libgnome/gnome-init.h>
|
|
||||||
#include <libgnomeui/gnome-ui-init.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <libgnomevfs/gnome-vfs-utils.h>
|
|
||||||
#include "config.h"
|
|
||||||
#include "NetworkManagerInfoDbus.h"
|
|
||||||
#include "NetworkManagerInfo.h"
|
|
||||||
#include "NetworkManagerInfoPassphraseDialog.h"
|
|
||||||
#include "nm-utils.h"
|
|
||||||
|
|
||||||
static void nmi_spawn_notification_icon (NMIAppInfo *info);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_gconf_networks_notify_callback
|
|
||||||
*
|
|
||||||
* Callback from gconf when wireless networking key/values have changed.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void nmi_gconf_networks_notify_callback (GConfClient *client, guint connection_id, GConfEntry *entry, gpointer user_data)
|
|
||||||
{
|
|
||||||
NMIAppInfo *info = (NMIAppInfo *)user_data;
|
|
||||||
const char *key = NULL;
|
|
||||||
|
|
||||||
g_return_if_fail (client != NULL);
|
|
||||||
g_return_if_fail (entry != NULL);
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
|
|
||||||
if ((key = gconf_entry_get_key (entry)))
|
|
||||||
{
|
|
||||||
int path_len = strlen (NMI_GCONF_WIRELESS_NETWORKS_PATH) + 1;
|
|
||||||
|
|
||||||
if (strncmp (NMI_GCONF_WIRELESS_NETWORKS_PATH"/", key, path_len) == 0)
|
|
||||||
{
|
|
||||||
char *network = g_strdup ((key + path_len));
|
|
||||||
char *slash_pos;
|
|
||||||
char *unescaped_network;
|
|
||||||
|
|
||||||
/* If its a key under the network name, zero out the slash so we
|
|
||||||
* are left with only the network name.
|
|
||||||
*/
|
|
||||||
unescaped_network = gconf_unescape_key (network, strlen (network));
|
|
||||||
if ((slash_pos = strchr (unescaped_network, '/')))
|
|
||||||
*slash_pos = '\0';
|
|
||||||
|
|
||||||
nmi_dbus_signal_update_network (info->connection, unescaped_network, NETWORK_TYPE_ALLOWED);
|
|
||||||
g_free (unescaped_network);
|
|
||||||
g_free (network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_gconf_vpn_connections_notify_callback
|
|
||||||
*
|
|
||||||
* Callback from gconf when VPN connection values have changed.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void nmi_gconf_vpn_connections_notify_callback (GConfClient *client, guint connection_id, GConfEntry *entry, gpointer user_data)
|
|
||||||
{
|
|
||||||
NMIAppInfo *info = (NMIAppInfo *)user_data;
|
|
||||||
const char *key = NULL;
|
|
||||||
|
|
||||||
g_return_if_fail (client != NULL);
|
|
||||||
g_return_if_fail (entry != NULL);
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
|
|
||||||
if ((key = gconf_entry_get_key (entry)))
|
|
||||||
{
|
|
||||||
int path_len = strlen (NMI_GCONF_VPN_CONNECTIONS_PATH) + 1;
|
|
||||||
|
|
||||||
if (strncmp (NMI_GCONF_VPN_CONNECTIONS_PATH"/", key, path_len) == 0)
|
|
||||||
{
|
|
||||||
char *name = g_strdup ((key + path_len));
|
|
||||||
char *slash_pos;
|
|
||||||
char *unescaped_name;
|
|
||||||
|
|
||||||
/* If its a key under the the VPN name, zero out the slash so we
|
|
||||||
* are left with only the VPN name.
|
|
||||||
*/
|
|
||||||
unescaped_name = gconf_unescape_key (name, strlen (name));
|
|
||||||
if ((slash_pos = strchr (unescaped_name, '/')))
|
|
||||||
*slash_pos = '\0';
|
|
||||||
|
|
||||||
nmi_dbus_signal_update_vpn_connection (info->connection, unescaped_name);
|
|
||||||
g_free (unescaped_name);
|
|
||||||
g_free (name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BUILD_NOTIFICATION_ICON
|
|
||||||
static void
|
|
||||||
on_icon_exit_callback (GPid pid, int status, gpointer data)
|
|
||||||
{
|
|
||||||
NMIAppInfo *info;
|
|
||||||
info = (NMIAppInfo *) data;
|
|
||||||
|
|
||||||
nmi_spawn_notification_icon (info);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
nmi_spawn_notification_icon (NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
GError *error;
|
|
||||||
|
|
||||||
gchar *notification_icon_cmd[] = {LIBEXECDIR"/NetworkManagerNotification", NULL};
|
|
||||||
|
|
||||||
if (info->notification_icon_pid > 0)
|
|
||||||
g_spawn_close_pid (info->notification_icon_pid);
|
|
||||||
|
|
||||||
if (info->notification_icon_watch != 0)
|
|
||||||
g_source_remove (info->notification_icon_watch);
|
|
||||||
|
|
||||||
if (info->notification_icon_respawn_timer == NULL)
|
|
||||||
info->notification_icon_respawn_timer = g_timer_new();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gdouble elapsed_time;
|
|
||||||
gulong dummy;
|
|
||||||
|
|
||||||
elapsed_time = g_timer_elapsed (info->notification_icon_respawn_timer, &dummy);
|
|
||||||
|
|
||||||
/*5 seconds between respawns*/
|
|
||||||
if (elapsed_time > 5)
|
|
||||||
info->notification_icon_respawn_counter = 0;
|
|
||||||
else
|
|
||||||
info->notification_icon_respawn_counter++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
g_timer_start (info->notification_icon_respawn_timer);
|
|
||||||
|
|
||||||
/*spawn the panel notification icon unless it has crashed numerous times within a time frame*/
|
|
||||||
if (info->notification_icon_respawn_counter < 5)
|
|
||||||
{
|
|
||||||
if (!g_spawn_async (NULL,
|
|
||||||
notification_icon_cmd,
|
|
||||||
NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL,
|
|
||||||
&(info->notification_icon_pid),
|
|
||||||
&error))
|
|
||||||
{
|
|
||||||
g_warning ("Could not spawn NetworkManager's notification icon (%s)", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
info->notification_icon_watch = g_child_watch_add (info->notification_icon_pid, on_icon_exit_callback, info);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
g_timer_destroy (info->notification_icon_respawn_timer);
|
|
||||||
info->notification_icon_respawn_timer = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void session_die (GnomeClient *client, gpointer client_data)
|
|
||||||
{
|
|
||||||
gtk_main_quit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean session_save (GnomeClient *client, gpointer client_data)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* main
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int main( int argc, char *argv[] )
|
|
||||||
{
|
|
||||||
GnomeProgram *program;
|
|
||||||
GnomeClient *client;
|
|
||||||
GPtrArray *restart_argv;
|
|
||||||
gboolean no_daemon;
|
|
||||||
DBusError dbus_error;
|
|
||||||
DBusConnection *dbus_connection;
|
|
||||||
int err;
|
|
||||||
NMIAppInfo *app_info = NULL;
|
|
||||||
guint notify_id;
|
|
||||||
|
|
||||||
struct poptOption options[] =
|
|
||||||
{
|
|
||||||
{ "no-daemon", 'n', POPT_ARG_NONE, NULL, 0,
|
|
||||||
"Don't detatch from the console and run in the background.", NULL },
|
|
||||||
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
options[0].arg = &no_daemon;
|
|
||||||
|
|
||||||
program = gnome_program_init ("NetworkManagerInfo", VERSION,
|
|
||||||
LIBGNOMEUI_MODULE, argc, argv,
|
|
||||||
GNOME_PROGRAM_STANDARD_PROPERTIES,
|
|
||||||
GNOME_PARAM_POPT_TABLE, options,
|
|
||||||
GNOME_PARAM_HUMAN_READABLE_NAME, "Network Manager User Info Service",
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
client = gnome_master_client ();
|
|
||||||
|
|
||||||
openlog("NetworkManagerInfo", (no_daemon) ? LOG_CONS | LOG_PERROR : LOG_CONS, (no_daemon) ? LOG_USER : LOG_DAEMON);
|
|
||||||
|
|
||||||
if (!no_daemon && daemon (FALSE, FALSE) < 0)
|
|
||||||
{
|
|
||||||
nm_warning ("NetworkManagerInfo could not daemonize. errno = %d", errno );
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
app_info = g_new0 (NMIAppInfo, 1);
|
|
||||||
if (!app_info)
|
|
||||||
{
|
|
||||||
nm_error ("Not enough memory for application data.");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_type_init ();
|
|
||||||
if (!g_thread_supported ())
|
|
||||||
g_thread_init (NULL);
|
|
||||||
|
|
||||||
/* Set up our connection to the message bus */
|
|
||||||
dbus_error_init (&dbus_error);
|
|
||||||
dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
|
|
||||||
if (dbus_connection == NULL)
|
|
||||||
{
|
|
||||||
nm_error ("NetworkManagerInfo could not get the system bus. Make sure the message bus daemon is running?");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
dbus_connection_set_change_sigpipe (TRUE);
|
|
||||||
dbus_connection_set_exit_on_disconnect (dbus_connection, FALSE);
|
|
||||||
dbus_connection_setup_with_g_main (dbus_connection, NULL);
|
|
||||||
app_info->connection = dbus_connection;
|
|
||||||
|
|
||||||
/* Grab a connection to the GConf daemon. We also want to
|
|
||||||
* get change notifications for our wireless networking data.
|
|
||||||
*/
|
|
||||||
app_info->gconf_client = gconf_client_get_default ();
|
|
||||||
gconf_client_add_dir (app_info->gconf_client, NMI_GCONF_WIRELESS_NETWORKS_PATH,
|
|
||||||
GCONF_CLIENT_PRELOAD_NONE, NULL);
|
|
||||||
notify_id = gconf_client_notify_add (app_info->gconf_client, NMI_GCONF_WIRELESS_NETWORKS_PATH,
|
|
||||||
nmi_gconf_networks_notify_callback, app_info, NULL, NULL);
|
|
||||||
notify_id = gconf_client_notify_add (app_info->gconf_client, NMI_GCONF_VPN_CONNECTIONS_PATH,
|
|
||||||
nmi_gconf_vpn_connections_notify_callback, app_info, NULL, NULL);
|
|
||||||
|
|
||||||
/* Create our own dbus service */
|
|
||||||
err = nmi_dbus_service_init (dbus_connection, app_info);
|
|
||||||
if (err == -1)
|
|
||||||
exit (1);
|
|
||||||
|
|
||||||
gnome_program_init ("NetworkManagerInfo", VERSION, LIBGNOMEUI_MODULE,
|
|
||||||
argc, argv,
|
|
||||||
GNOME_PARAM_NONE);
|
|
||||||
|
|
||||||
|
|
||||||
app_info->notification_icon_pid = 0;
|
|
||||||
|
|
||||||
#ifdef BUILD_NOTIFICATION_ICON
|
|
||||||
nmi_spawn_notification_icon (app_info);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
restart_argv = g_ptr_array_new ();
|
|
||||||
g_ptr_array_add (restart_argv, g_get_prgname ());
|
|
||||||
gnome_client_set_restart_command (client, restart_argv->len, (char**) restart_argv->pdata);
|
|
||||||
g_ptr_array_free (restart_argv, TRUE);
|
|
||||||
gnome_client_set_restart_style (client, GNOME_RESTART_IMMEDIATELY);
|
|
||||||
|
|
||||||
if (nmi_passphrase_dialog_init (app_info) != 0)
|
|
||||||
{
|
|
||||||
gnome_client_set_restart_style (client, GNOME_RESTART_ANYWAY);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_signal_connect (client,
|
|
||||||
"save_yourself",
|
|
||||||
G_CALLBACK (session_save),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_signal_connect (client,
|
|
||||||
"die",
|
|
||||||
G_CALLBACK (session_die),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_main ();
|
|
||||||
|
|
||||||
if (app_info->notification_icon_pid > 0)
|
|
||||||
kill (app_info->notification_icon_pid, SIGTERM);
|
|
||||||
|
|
||||||
gnome_client_set_restart_style (client, GNOME_RESTART_ANYWAY);
|
|
||||||
|
|
||||||
gconf_client_notify_remove (app_info->gconf_client, notify_id);
|
|
||||||
g_object_unref (G_OBJECT (app_info->gconf_client));
|
|
||||||
/*g_object_unref (app_info->notification_icon);*/
|
|
||||||
g_free (app_info);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* 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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NETWORK_MANAGER_INFO_H
|
|
||||||
#define NETWORK_MANAGER_INFO_H
|
|
||||||
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
||||||
#include <glade/glade.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
#include <gconf/gconf-client.h>
|
|
||||||
|
|
||||||
#define NMI_GCONF_VPN_CONNECTIONS_PATH "/system/networking/vpn_connections"
|
|
||||||
|
|
||||||
struct NMIAppInfo
|
|
||||||
{
|
|
||||||
GladeXML *passphrase_dialog;
|
|
||||||
GtkWidget *vpn_password_dialog;
|
|
||||||
DBusMessage *vpn_password_message;
|
|
||||||
char *orig_label_text;
|
|
||||||
DBusConnection *connection;
|
|
||||||
GConfClient *gconf_client;
|
|
||||||
|
|
||||||
GladeXML *networks_dialog;
|
|
||||||
GtkListStore *networks_list_store;
|
|
||||||
|
|
||||||
GdkPixbuf *padlock_pixbuf;
|
|
||||||
|
|
||||||
/*
|
|
||||||
GtkWidget *notification_icon;
|
|
||||||
*/
|
|
||||||
GPid notification_icon_pid;
|
|
||||||
guint notification_icon_watch;
|
|
||||||
guint notification_icon_respawn_counter;
|
|
||||||
GTimer *notification_icon_respawn_timer;
|
|
||||||
|
|
||||||
GSource *shutdown_timeout;
|
|
||||||
};
|
|
||||||
typedef struct NMIAppInfo NMIAppInfo;
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,48 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* 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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NETWORK_MANAGER_INFO_DBUS_SERVICE_H
|
|
||||||
#define NETWORK_MANAGER_INFO_DBUS_SERVICE_H
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
#include "NetworkManager.h"
|
|
||||||
#include "NetworkManagerInfo.h"
|
|
||||||
|
|
||||||
|
|
||||||
int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info);
|
|
||||||
|
|
||||||
const char * nmi_dbus_nm_get_network_essid (DBusConnection *connection, const char *ap_path);
|
|
||||||
|
|
||||||
gboolean nmi_dbus_nm_get_network_encrypted (DBusConnection *connection, const char *ap_path);
|
|
||||||
|
|
||||||
void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
|
||||||
const char *network, const char *passphrase, const int key_type);
|
|
||||||
|
|
||||||
void nmi_dbus_return_vpn_password (DBusConnection *connection, DBusMessage *message, const char *password);
|
|
||||||
|
|
||||||
void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMNetworkType type);
|
|
||||||
|
|
||||||
void nmi_dbus_signal_update_vpn_connection (DBusConnection *connection, const char *name);
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,86 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* 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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <glade/glade.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
|
|
||||||
#include "NetworkManagerInfo.h"
|
|
||||||
#include "NetworkManagerInfoNetworksDialog.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_networks_dialog_init
|
|
||||||
*
|
|
||||||
* Initialize the networks modification dialog
|
|
||||||
*
|
|
||||||
* Returns: 0 on success
|
|
||||||
* -1 on failure
|
|
||||||
*/
|
|
||||||
int nmi_networks_dialog_init (NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
GtkWidget *dialog;
|
|
||||||
|
|
||||||
info->networks_dialog = glade_xml_new(GLADEDIR"/networks.glade", NULL, NULL);
|
|
||||||
if (!info->networks_dialog)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Could not open the networks dialog glade file!\n");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (info->networks_dialog, "networks_dialog");
|
|
||||||
gtk_widget_hide (dialog);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
save_button = GTK_BUTTON (glade_xml_get_widget (info->networks_dialog, "save_button"));
|
|
||||||
g_signal_connect (G_OBJECT (save_button), "clicked", GTK_SIGNAL_FUNC (nmi_networks_dialog_save_clicked), info);
|
|
||||||
cancel_button = GTK_BUTTON (glade_xml_get_widget (info->networks_dialog, "cancel_button"));
|
|
||||||
g_signal_connect (G_OBJECT (cancel_button), "clicked", GTK_SIGNAL_FUNC (nmi_networks_dialog_cancel_clicked), info);
|
|
||||||
|
|
||||||
/* Create data store for our networks list */
|
|
||||||
info->networks_list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN);
|
|
||||||
if (!info->networks_list_store)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
/* Tell the list to use our data store */
|
|
||||||
list_view = glade_xml_get_widget (info->networks_dialog, "networks_list");
|
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (list_view), GTK_TREE_MODEL (info->networks_list_store));
|
|
||||||
|
|
||||||
/* Set up the columns and renderers for our list */
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
|
||||||
column = gtk_tree_view_column_new ();
|
|
||||||
gtk_tree_view_column_set_expand (column, TRUE);
|
|
||||||
gtk_tree_view_column_pack_start (column, renderer, TRUE);
|
|
||||||
gtk_tree_view_column_set_attributes (column, renderer, "markup", TEXT_COLUMN, NULL);
|
|
||||||
gtk_tree_view_append_column (GTK_TREE_VIEW (list_view), column);
|
|
||||||
|
|
||||||
info->padlock_pixbuf = gdk_pixbuf_new_from_file_at_size (GLADEDIR"/keyring.png", 16, 16, &error);
|
|
||||||
if (!info->padlock_pixbuf)
|
|
||||||
fprintf (stderr, "nmi_new_networks_dialog_init(): could not load padlock image\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
@@ -1,30 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* 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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NETWORK_MANAGER_INFO_NETWORKS_DIALOG_H
|
|
||||||
#define NETWORK_MANAGER_INFO_NETWORKS_DIALOG_H
|
|
||||||
|
|
||||||
#include "NetworkManagerInfo.h"
|
|
||||||
|
|
||||||
int nmi_networks_dialog_init (NMIAppInfo *info);
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,352 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* 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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
#include <libintl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <glade/glade.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
|
|
||||||
#ifndef _
|
|
||||||
#define _(x) dgettext (GETTEXT_PACKAGE, x)
|
|
||||||
#define N_(x) x
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "NetworkManagerInfoDbus.h"
|
|
||||||
#include "NetworkManagerInfoPassphraseDialog.h"
|
|
||||||
#include "nm-utils.h"
|
|
||||||
|
|
||||||
enum NMIPassphraseDialogKeyTypes
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
GtkButton *button;
|
|
||||||
GtkComboBox *combo;
|
|
||||||
GtkEntry *passphrase_entry;
|
|
||||||
const char *passphrase_text;
|
|
||||||
gboolean enable = TRUE;
|
|
||||||
|
|
||||||
g_return_if_fail (xml != NULL);
|
|
||||||
|
|
||||||
button = GTK_BUTTON (glade_xml_get_widget (xml, "login_button"));
|
|
||||||
combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
|
|
||||||
passphrase_entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
|
|
||||||
passphrase_text = gtk_entry_get_text (passphrase_entry);
|
|
||||||
|
|
||||||
if (passphrase_text[0] == '\000')
|
|
||||||
enable = FALSE;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int combo_choice = gtk_combo_box_get_active (combo);
|
|
||||||
switch (combo_choice)
|
|
||||||
{
|
|
||||||
case KEY_TYPE_ASCII_KEY:
|
|
||||||
if ((strlen (passphrase_text) != 5) && (strlen (passphrase_text) != 13))
|
|
||||||
enable = FALSE;
|
|
||||||
break;
|
|
||||||
case KEY_TYPE_HEX_KEY:
|
|
||||||
if ((strlen (passphrase_text) != 10) && (strlen (passphrase_text) != 26))
|
|
||||||
enable = FALSE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (button), enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_passphrase_dialog_clear
|
|
||||||
*
|
|
||||||
* Return dialog to its original state; clear out any network or device qdatas,
|
|
||||||
* clear the passphrase entry, and hide the dialog.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_passphrase_dialog_clear (GtkWidget *dialog, GtkWidget *entry)
|
|
||||||
{
|
|
||||||
char *data;
|
|
||||||
|
|
||||||
g_return_if_fail (dialog != NULL);
|
|
||||||
g_return_if_fail (entry != NULL);
|
|
||||||
|
|
||||||
data = g_object_get_data (G_OBJECT (dialog), "device");
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
g_free (data);
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "device", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_object_get_data (G_OBJECT (dialog), "network");
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
g_free (data);
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "network", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
|
||||||
gtk_widget_hide (dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_passphrase_dialog_key_type_combo_changed
|
|
||||||
*
|
|
||||||
* Change the text of the passphrase entry label to match the selected
|
|
||||||
* key type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_passphrase_dialog_key_type_combo_changed (GtkWidget *key_type_combo, gpointer user_data)
|
|
||||||
{
|
|
||||||
GtkLabel *entry_label;
|
|
||||||
int combo_choice;
|
|
||||||
NMIAppInfo *info = (NMIAppInfo *)user_data;
|
|
||||||
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
|
|
||||||
entry_label = GTK_LABEL (glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry_label"));
|
|
||||||
switch ((combo_choice = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo))))
|
|
||||||
{
|
|
||||||
case KEY_TYPE_128_BIT_PASSPHRASE:
|
|
||||||
gtk_label_set_label (entry_label, _("Passphrase:"));
|
|
||||||
break;
|
|
||||||
case KEY_TYPE_ASCII_KEY:
|
|
||||||
gtk_label_set_label (entry_label, _("Ascii Key:"));
|
|
||||||
break;
|
|
||||||
case KEY_TYPE_HEX_KEY:
|
|
||||||
gtk_label_set_label (entry_label, _("Hex Key:"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_passphrase_dialog_ok_clicked
|
|
||||||
*
|
|
||||||
* OK button handler; grab the passphrase and send it back
|
|
||||||
* to NetworkManager. Get rid of the dialog.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer user_data)
|
|
||||||
{
|
|
||||||
GtkWidget *dialog = gtk_widget_get_toplevel (ok_button);
|
|
||||||
NMIAppInfo *info = (NMIAppInfo *)user_data;
|
|
||||||
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
|
|
||||||
if (GTK_WIDGET_TOPLEVEL (dialog))
|
|
||||||
{
|
|
||||||
GtkEntry *entry = GTK_ENTRY (glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry"));
|
|
||||||
GtkComboBox *key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (info->passphrase_dialog, "key_type_combo"));
|
|
||||||
int key_type = gtk_combo_box_get_active (key_type_combo);
|
|
||||||
const char *passphrase = gtk_entry_get_text (entry);
|
|
||||||
const char *device = g_object_get_data (G_OBJECT (dialog), "device");
|
|
||||||
const char *network = g_object_get_data (G_OBJECT (dialog), "network");
|
|
||||||
char *key = NULL;
|
|
||||||
int key_type_return = NM_ENC_TYPE_UNKNOWN;
|
|
||||||
GConfEntry *gconf_entry;
|
|
||||||
char *escaped_network;
|
|
||||||
|
|
||||||
switch (key_type)
|
|
||||||
{
|
|
||||||
case KEY_TYPE_128_BIT_PASSPHRASE:
|
|
||||||
key_type_return = NM_ENC_TYPE_128_BIT_PASSPHRASE;
|
|
||||||
break;
|
|
||||||
case KEY_TYPE_ASCII_KEY:
|
|
||||||
key_type_return = NM_ENC_TYPE_ASCII_KEY;
|
|
||||||
break;
|
|
||||||
case KEY_TYPE_HEX_KEY:
|
|
||||||
key_type_return = NM_ENC_TYPE_HEX_KEY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
key_type_return = NM_ENC_TYPE_UNKNOWN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tell NetworkManager about the key the user typed in */
|
|
||||||
nmi_dbus_return_user_key (info->connection, device, network, passphrase, key_type_return);
|
|
||||||
|
|
||||||
/* Update GConf with the new user key */
|
|
||||||
escaped_network = gconf_escape_key (network, strlen (network));
|
|
||||||
key = g_strdup_printf ("%s/%s", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
gconf_entry = gconf_client_get_entry (info->gconf_client, key, NULL, TRUE, NULL);
|
|
||||||
g_free (key);
|
|
||||||
if (gconf_entry)
|
|
||||||
{
|
|
||||||
gconf_entry_unref (gconf_entry);
|
|
||||||
key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
gconf_client_set_string (info->gconf_client, key, passphrase, NULL);
|
|
||||||
g_free (key);
|
|
||||||
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
gconf_client_set_string (info->gconf_client, key, network, NULL);
|
|
||||||
g_free (key);
|
|
||||||
key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
|
||||||
gconf_client_set_int (info->gconf_client, key, key_type_return, NULL);
|
|
||||||
g_free (key);
|
|
||||||
}
|
|
||||||
g_free (escaped_network);
|
|
||||||
|
|
||||||
nmi_passphrase_dialog_clear (dialog, GTK_WIDGET (entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_passphrase_dialog_cancel_clicked
|
|
||||||
*
|
|
||||||
* Cancel button handler; return a cancellation message to NetworkManager
|
|
||||||
* and get rid of the dialog.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_passphrase_dialog_cancel_clicked (GtkWidget *cancel_button, gpointer user_data)
|
|
||||||
{
|
|
||||||
GtkWidget *dialog = gtk_widget_get_toplevel (cancel_button);
|
|
||||||
NMIAppInfo *info = (NMIAppInfo *)user_data;
|
|
||||||
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
|
|
||||||
if (GTK_WIDGET_TOPLEVEL (dialog))
|
|
||||||
{
|
|
||||||
const char *device = g_object_get_data (G_OBJECT (dialog), "device");
|
|
||||||
const char *network = g_object_get_data (G_OBJECT (dialog), "network");
|
|
||||||
|
|
||||||
nmi_dbus_return_user_key (info->connection, device, network, "***canceled***", NM_ENC_TYPE_UNKNOWN);
|
|
||||||
nmi_passphrase_dialog_clear (dialog, glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_passphrase_dialog_show
|
|
||||||
*
|
|
||||||
* Pop up the user key dialog in response to a dbus message
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_passphrase_dialog_show (const char *device, const char *network, NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
GtkWidget *dialog;
|
|
||||||
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
g_return_if_fail (device != NULL);
|
|
||||||
g_return_if_fail (network != NULL);
|
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (info->passphrase_dialog, "passphrase_dialog");
|
|
||||||
nmi_passphrase_dialog_clear (dialog, glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry"));
|
|
||||||
|
|
||||||
/* Insert the Network name into the dialog text */
|
|
||||||
if (info->orig_label_text)
|
|
||||||
{
|
|
||||||
GtkWidget *label = glade_xml_get_widget (info->passphrase_dialog, "label1");
|
|
||||||
char *new_label_text = g_strdup_printf (info->orig_label_text, network);
|
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (label), new_label_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "device", g_strdup (device));
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "network", g_strdup (network));
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_passphrase_dialog_cancel
|
|
||||||
*
|
|
||||||
* Cancel and hide any user key dialog that might be up
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nmi_passphrase_dialog_cancel (NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
GtkWidget *dialog;
|
|
||||||
GtkWidget *entry;
|
|
||||||
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (info->passphrase_dialog, "passphrase_dialog");
|
|
||||||
entry = glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry");
|
|
||||||
nmi_passphrase_dialog_clear (dialog, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nmi_passphrase_dialog_init
|
|
||||||
*
|
|
||||||
* Initialize the passphrase dialog
|
|
||||||
*
|
|
||||||
* Returns: 0 on success
|
|
||||||
* -1 on failure
|
|
||||||
*/
|
|
||||||
int nmi_passphrase_dialog_init (NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
GtkWidget *dialog;
|
|
||||||
GtkButton *ok_button;
|
|
||||||
GtkButton *cancel_button;
|
|
||||||
GtkEntry *entry;
|
|
||||||
GtkComboBox *key_type_combo;
|
|
||||||
GtkLabel *label;
|
|
||||||
|
|
||||||
info->passphrase_dialog = glade_xml_new(GLADEDIR"/passphrase.glade", NULL, NULL);
|
|
||||||
if (!info->passphrase_dialog)
|
|
||||||
{
|
|
||||||
nm_warning ("Could not open the passphrase dialog glade file!");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (info->passphrase_dialog, "passphrase_dialog");
|
|
||||||
gtk_widget_hide (dialog);
|
|
||||||
|
|
||||||
ok_button = GTK_BUTTON (glade_xml_get_widget (info->passphrase_dialog, "login_button"));
|
|
||||||
g_signal_connect (G_OBJECT (ok_button), "clicked", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_ok_clicked), info);
|
|
||||||
gtk_widget_grab_default (GTK_WIDGET (ok_button));
|
|
||||||
cancel_button = GTK_BUTTON (glade_xml_get_widget (info->passphrase_dialog, "cancel_button"));
|
|
||||||
g_signal_connect (G_OBJECT (cancel_button), "clicked", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_cancel_clicked), info);
|
|
||||||
|
|
||||||
entry = GTK_ENTRY (glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry"));
|
|
||||||
nmi_passphrase_dialog_clear (dialog, GTK_WIDGET (entry));
|
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
|
|
||||||
g_signal_connect (entry, "changed", G_CALLBACK (update_button_cb), info->passphrase_dialog);
|
|
||||||
|
|
||||||
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (info->passphrase_dialog, "key_type_combo"));
|
|
||||||
gtk_combo_box_set_active (key_type_combo, 0);
|
|
||||||
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_key_type_combo_changed), info);
|
|
||||||
nmi_passphrase_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), info);
|
|
||||||
|
|
||||||
/* Save original label text to preserve the '%s' and other formatting that gets overwritten
|
|
||||||
* when the dialog is first shown.
|
|
||||||
*/
|
|
||||||
label = GTK_LABEL (glade_xml_get_widget (info->passphrase_dialog, "label1"));
|
|
||||||
info->orig_label_text = g_strdup (gtk_label_get_label (label));
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
@@ -1,188 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* Colin Walters <walters@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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
#include <libintl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <glade/glade.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
#include <gnome-keyring.h>
|
|
||||||
#include <libgnomeui/gnome-password-dialog.h>
|
|
||||||
|
|
||||||
#ifndef _
|
|
||||||
#define _(x) dgettext (GETTEXT_PACKAGE, x)
|
|
||||||
#define N_(x) x
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "NetworkManagerInfoDbus.h"
|
|
||||||
#include "NetworkManagerInfoVPN.h"
|
|
||||||
#include "nm-utils.h"
|
|
||||||
|
|
||||||
int nmi_vpn_init (NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
info->vpn_password_dialog = NULL;
|
|
||||||
info->vpn_password_message = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean lookup_pass (const char *vpn, const char *username, char **password)
|
|
||||||
{
|
|
||||||
GList *result;
|
|
||||||
|
|
||||||
if (gnome_keyring_find_network_password_sync (username,
|
|
||||||
NULL,
|
|
||||||
vpn,
|
|
||||||
NULL,
|
|
||||||
"vpn",
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&result) != GNOME_KEYRING_RESULT_OK)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
GnomeKeyringNetworkPasswordData *data = result->data;
|
|
||||||
*password = g_strdup (data->password);
|
|
||||||
gnome_keyring_network_password_list_free (result);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void save_vpn_password (const char *vpn, const char *keyring, const char *username, const char *password)
|
|
||||||
{
|
|
||||||
guint32 item_id;
|
|
||||||
GnomeKeyringResult keyring_result;
|
|
||||||
|
|
||||||
keyring_result = gnome_keyring_set_network_password_sync (NULL,
|
|
||||||
username,
|
|
||||||
NULL,
|
|
||||||
vpn,
|
|
||||||
NULL,
|
|
||||||
"vpn",
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
password,
|
|
||||||
&item_id);
|
|
||||||
|
|
||||||
if (keyring_result != GNOME_KEYRING_RESULT_OK)
|
|
||||||
{
|
|
||||||
nm_warning ("Couldn't store password in keyring, code %d",
|
|
||||||
(int) keyring_result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void close_cb (GtkWidget *dialog, gpointer user_data)
|
|
||||||
{
|
|
||||||
NMIAppInfo *info = user_data;
|
|
||||||
nmi_dbus_return_vpn_password (info->connection, info->vpn_password_message, NULL);
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
info->vpn_password_dialog = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void response_cb (GtkWidget *dialog, int response, gpointer user_data)
|
|
||||||
{
|
|
||||||
NMIAppInfo *info = user_data;
|
|
||||||
GnomePasswordDialog *passwd_dialog;
|
|
||||||
char *password;
|
|
||||||
const char *vpn, *username;
|
|
||||||
|
|
||||||
if (response != GTK_RESPONSE_OK)
|
|
||||||
{
|
|
||||||
close_cb (dialog, user_data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
passwd_dialog = GNOME_PASSWORD_DIALOG (dialog);
|
|
||||||
username = g_object_get_data (G_OBJECT (passwd_dialog), "NetworkManagerInfoVPN-username");
|
|
||||||
vpn = g_object_get_data (G_OBJECT (passwd_dialog), "NetworkManagerInfoVPN-vpn");
|
|
||||||
password = gnome_password_dialog_get_password (passwd_dialog);
|
|
||||||
nm_warning ("returning VPN vpn_password for %s@%s: %s", username, vpn, password);
|
|
||||||
nmi_dbus_return_vpn_password (info->connection, info->vpn_password_message, password);
|
|
||||||
switch (gnome_password_dialog_get_remember (passwd_dialog))
|
|
||||||
{
|
|
||||||
case GNOME_PASSWORD_DIALOG_REMEMBER_SESSION:
|
|
||||||
save_vpn_password (vpn, "session", username, password);
|
|
||||||
break;
|
|
||||||
case GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER:
|
|
||||||
save_vpn_password (vpn, NULL, username, password);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (password);
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
info->vpn_password_dialog = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nmi_vpn_request_password (NMIAppInfo *info, DBusMessage *message, const char *vpn, const char *username, gboolean retry)
|
|
||||||
{
|
|
||||||
char *prompt;
|
|
||||||
char *password;
|
|
||||||
|
|
||||||
if (!username)
|
|
||||||
username = g_get_user_name ();
|
|
||||||
|
|
||||||
if (!retry && lookup_pass (vpn, username, &password))
|
|
||||||
{
|
|
||||||
nmi_dbus_return_vpn_password (info->connection, message, password);
|
|
||||||
g_free (password);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
prompt = g_strdup_printf (_("You must log in to access the private network %s"), vpn);
|
|
||||||
|
|
||||||
info->vpn_password_dialog = gnome_password_dialog_new ("",
|
|
||||||
prompt,
|
|
||||||
username,
|
|
||||||
NULL,
|
|
||||||
FALSE);
|
|
||||||
g_free (prompt);
|
|
||||||
info->vpn_password_message = message;
|
|
||||||
dbus_message_ref (info->vpn_password_message);
|
|
||||||
gnome_password_dialog_set_show_username (GNOME_PASSWORD_DIALOG (info->vpn_password_dialog), TRUE);
|
|
||||||
gnome_password_dialog_set_readonly_username (GNOME_PASSWORD_DIALOG (info->vpn_password_dialog), TRUE);
|
|
||||||
gnome_password_dialog_set_show_userpass_buttons (GNOME_PASSWORD_DIALOG (info->vpn_password_dialog), FALSE);
|
|
||||||
gnome_password_dialog_set_show_domain (GNOME_PASSWORD_DIALOG (info->vpn_password_dialog), FALSE);
|
|
||||||
gnome_password_dialog_set_show_remember (GNOME_PASSWORD_DIALOG (info->vpn_password_dialog), TRUE);
|
|
||||||
g_object_set_data_full (G_OBJECT (info->vpn_password_dialog), "NetworkManagerInfoVPN-username", g_strdup (username), (GDestroyNotify) g_free);
|
|
||||||
g_object_set_data_full (G_OBJECT (info->vpn_password_dialog), "NetworkManagerInfoVPN-vpn", g_strdup (vpn), (GDestroyNotify) g_free);
|
|
||||||
g_signal_connect (info->vpn_password_dialog, "response", G_CALLBACK (response_cb), info);
|
|
||||||
g_signal_connect (info->vpn_password_dialog, "close", G_CALLBACK (close_cb), info);
|
|
||||||
gtk_widget_show (info->vpn_password_dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nmi_vpn_cancel_request_password (NMIAppInfo *info)
|
|
||||||
{
|
|
||||||
if (info->vpn_password_dialog)
|
|
||||||
{
|
|
||||||
gtk_widget_destroy (info->vpn_password_dialog);
|
|
||||||
dbus_message_unref (info->vpn_password_message);
|
|
||||||
info->vpn_password_message = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,34 +0,0 @@
|
|||||||
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
|
|
||||||
* for WEP key entry
|
|
||||||
*
|
|
||||||
* Colin Walters <walters@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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NETWORK_MANAGER_INFO_VPN_H
|
|
||||||
#define NETWORK_MANAGER_INFO_VPN_H
|
|
||||||
|
|
||||||
#include "NetworkManagerInfo.h"
|
|
||||||
|
|
||||||
int nmi_vpn_init (NMIAppInfo *info);
|
|
||||||
|
|
||||||
void nmi_vpn_request_password (NMIAppInfo *info, DBusMessage *message, const char *vpn, const char *username, gboolean retry);
|
|
||||||
|
|
||||||
void nmi_vpn_cancel_request_password (NMIAppInfo *info);
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,226 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
|
||||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
|
||||||
|
|
||||||
<glade-interface>
|
|
||||||
<requires lib="gnome"/>
|
|
||||||
|
|
||||||
<widget class="GtkDialog" id="networks_dialog">
|
|
||||||
<property name="border_width">6</property>
|
|
||||||
<property name="width_request">400</property>
|
|
||||||
<property name="height_request">400</property>
|
|
||||||
<property name="title" translatable="yes">Modify Wireless Networks</property>
|
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
|
||||||
<property name="modal">False</property>
|
|
||||||
<property name="resizable">True</property>
|
|
||||||
<property name="destroy_with_parent">False</property>
|
|
||||||
<property name="decorated">True</property>
|
|
||||||
<property name="skip_taskbar_hint">False</property>
|
|
||||||
<property name="skip_pager_hint">False</property>
|
|
||||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
|
||||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
|
||||||
<property name="has_separator">True</property>
|
|
||||||
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<widget class="GtkVBox" id="dialog-vbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="help_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-help</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="response_id">-11</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="cancel_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-cancel</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="response_id">-6</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="save_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-save</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="response_id">-5</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack_type">GTK_PACK_END</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVBox" id="vbox1">
|
|
||||||
<property name="border_width">6</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="label2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes"><span weight="bold">Wireless Networks:</span></property>
|
|
||||||
<property name="use_underline">False</property>
|
|
||||||
<property name="use_markup">True</property>
|
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
|
||||||
<property name="wrap">False</property>
|
|
||||||
<property name="selectable">False</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHBox" id="hbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
|
|
||||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
|
||||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
|
||||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkTreeView" id="networks_list_view">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="headers_visible">True</property>
|
|
||||||
<property name="rules_hint">False</property>
|
|
||||||
<property name="reorderable">False</property>
|
|
||||||
<property name="enable_search">True</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVBox" id="vbox2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">67</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVButtonBox" id="vbuttonbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
|
|
||||||
<property name="spacing">0</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="up_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-go-up</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">False</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="down_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-go-down</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">28</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="delete_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-delete</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
|
|
||||||
</glade-interface>
|
|
@@ -1,243 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
|
||||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
|
||||||
|
|
||||||
<glade-interface>
|
|
||||||
|
|
||||||
<widget class="GtkDialog" id="passphrase_dialog">
|
|
||||||
<property name="border_width">6</property>
|
|
||||||
<property name="has_focus">True</property>
|
|
||||||
<property name="title" translatable="yes">Wireless Network Key Required</property>
|
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
|
|
||||||
<property name="modal">False</property>
|
|
||||||
<property name="resizable">False</property>
|
|
||||||
<property name="destroy_with_parent">False</property>
|
|
||||||
<property name="decorated">True</property>
|
|
||||||
<property name="skip_taskbar_hint">False</property>
|
|
||||||
<property name="skip_pager_hint">False</property>
|
|
||||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
|
||||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
|
||||||
<property name="has_separator">False</property>
|
|
||||||
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<widget class="GtkVBox" id="dialog-vbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="cancel_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label">gtk-cancel</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="response_id">-6</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="login_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="has_default">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">_Login to Network</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="response_id">0</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack_type">GTK_PACK_END</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHBox" id="hbox1">
|
|
||||||
<property name="border_width">6</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkImage" id="image1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="pixbuf">keyring.png</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="yalign">0</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVBox" id="vbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="label1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes"><span weight="bold" size="larger">Passphrase Required by Wireless Network</span>
|
|
||||||
|
|
||||||
A passphrase or encryption key is required to access the wireless network '%s'.</property>
|
|
||||||
<property name="use_underline">False</property>
|
|
||||||
<property name="use_markup">True</property>
|
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
|
||||||
<property name="wrap">True</property>
|
|
||||||
<property name="selectable">False</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHBox" id="hbox3">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="label3">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">Key Type:</property>
|
|
||||||
<property name="use_underline">False</property>
|
|
||||||
<property name="use_markup">False</property>
|
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
|
||||||
<property name="wrap">False</property>
|
|
||||||
<property name="selectable">False</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkComboBox" id="key_type_combo">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="items" translatable="yes">128-bit Passphrase (WEP)
|
|
||||||
Ascii Key (WEP)
|
|
||||||
Hex Key (WEP)</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHBox" id="hbox2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="passphrase_entry_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">Passphrase:</property>
|
|
||||||
<property name="use_underline">False</property>
|
|
||||||
<property name="use_markup">False</property>
|
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
|
||||||
<property name="wrap">False</property>
|
|
||||||
<property name="selectable">False</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkEntry" id="passphrase_entry">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="has_focus">True</property>
|
|
||||||
<property name="editable">True</property>
|
|
||||||
<property name="visibility">True</property>
|
|
||||||
<property name="max_length">0</property>
|
|
||||||
<property name="text" translatable="yes"></property>
|
|
||||||
<property name="has_frame">True</property>
|
|
||||||
<property name="invisible_char" translatable="yes">*</property>
|
|
||||||
<property name="activates_default">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
|
|
||||||
</glade-interface>
|
|
@@ -1,3 +0,0 @@
|
|||||||
Makefile
|
|
||||||
Makefile.in
|
|
||||||
NetworkManagerNotification
|
|
@@ -1,84 +0,0 @@
|
|||||||
SUBDIRS=icons
|
|
||||||
|
|
||||||
NULL=
|
|
||||||
NOTIFICATION_ICON_SOURCE=@NOTIFICATION_ICON_SRC@
|
|
||||||
|
|
||||||
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
|
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libnm_notification_applet.la
|
|
||||||
|
|
||||||
gladedir = $(datadir)/NetworkManagerNotification
|
|
||||||
glade_DATA = wireless-applet.glade
|
|
||||||
|
|
||||||
libnm_notification_applet_la_CPPFLAGS = \
|
|
||||||
$(DBUS_CFLAGS) \
|
|
||||||
$(GTHREAD_CFLAGS) \
|
|
||||||
$(HAL_CFLAGS) \
|
|
||||||
$(DBUS_GLIB_CFLAGS) \
|
|
||||||
$(GLADE_CFLAGS) \
|
|
||||||
$(GTK_CFLAGS) \
|
|
||||||
$(GCONF_CFLAGS) \
|
|
||||||
$(LIBGNOMEUI_CFLAGS) \
|
|
||||||
$(PANEL_APPLET_CFLAGS) \
|
|
||||||
$(GNOMEKEYRING_CFLAGS) \
|
|
||||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
|
||||||
-DGLADEDIR=\""$(gladedir)"\" \
|
|
||||||
-DDBUS_API_SUBJECT_TO_CHANGE \
|
|
||||||
-DG_DISABLE_DEPRECATED \
|
|
||||||
-DGDK_DISABLE_DEPRECATED \
|
|
||||||
-DGNOME_DISABLE_DEPRECATED \
|
|
||||||
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
|
|
||||||
-DVERSION=\"$(VERSION)\" \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
libnm_notification_applet_la_SOURCES = \
|
|
||||||
NMWirelessApplet.c \
|
|
||||||
NMWirelessApplet.h \
|
|
||||||
NMWirelessAppletDbus.c \
|
|
||||||
NMWirelessAppletDbus.h \
|
|
||||||
NMWirelessAppletOtherNetworkDialog.c \
|
|
||||||
NMWirelessAppletOtherNetworkDialog.h \
|
|
||||||
menu-info.c \
|
|
||||||
menu-info.h \
|
|
||||||
gtkcellview.c \
|
|
||||||
gtkcellview.h \
|
|
||||||
gtkcellrendererprogress.c \
|
|
||||||
gtkcellrendererprogress.h \
|
|
||||||
nmwa-vpn-password-dialog.c \
|
|
||||||
nmwa-vpn-password-dialog.h \
|
|
||||||
nmwa-vpn-connection.c \
|
|
||||||
nmwa-vpn-connection.h \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
libnm_notification_applet_la_SOURCES += \
|
|
||||||
eggtrayicon.c \
|
|
||||||
eggtrayicon.h
|
|
||||||
|
|
||||||
libnm_notification_applet_la_LIBADD = \
|
|
||||||
$(DBUS_LIBS) \
|
|
||||||
$(HAL_LIBS) \
|
|
||||||
$(GTHREAD_LIBS) \
|
|
||||||
$(GLADE_LIBS) \
|
|
||||||
$(DBUS_GLIB_LIBS) \
|
|
||||||
$(PANEL_APPLET_LIBS) \
|
|
||||||
$(GTK_LIBS) \
|
|
||||||
$(GCONF_LIBS) \
|
|
||||||
$(LIBGNOMEUI_LIBS) \
|
|
||||||
$(GNOMEKEYRING_LIBS) \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
libexec_PROGRAMS = NetworkManagerNotification
|
|
||||||
|
|
||||||
NetworkManagerNotification_CFLAGS = $(libnm_notification_applet_la_CPPFLAGS)
|
|
||||||
NetworkManagerNotification_SOURCES = main.c
|
|
||||||
NetworkManagerNotification_LDADD = \
|
|
||||||
./libnm_notification_applet.la \
|
|
||||||
$(top_builddir)/utils/libnmutils.la
|
|
||||||
|
|
||||||
|
|
||||||
CLEANFILES = $(server_DATA) *.bak *.gladep
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
$(glade_DATA) \
|
|
||||||
$(NULL)
|
|
||||||
|
|
@@ -1,194 +0,0 @@
|
|||||||
/* 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 2004 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NM_WIRELESS_APPLET_H
|
|
||||||
#define NM_WIRELESS_APPLET_H
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <gconf/gconf-client.h>
|
|
||||||
#include <glade/glade.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
#ifndef BUILD_NOTIFICATION_ICON
|
|
||||||
#include <panel-applet.h>
|
|
||||||
#include <panel-applet-gconf.h>
|
|
||||||
#else
|
|
||||||
#include "eggtrayicon.h"
|
|
||||||
#endif
|
|
||||||
#include <net/ethernet.h>
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
APPLET_STATE_NO_NM,
|
|
||||||
APPLET_STATE_NO_CONNECTION,
|
|
||||||
APPLET_STATE_WIRED,
|
|
||||||
APPLET_STATE_WIRED_CONNECTING,
|
|
||||||
APPLET_STATE_WIRELESS,
|
|
||||||
APPLET_STATE_WIRELESS_CONNECTING,
|
|
||||||
APPLET_STATE_WIRELESS_SCANNING,
|
|
||||||
APPLET_STATE_IGNORE
|
|
||||||
} AppletState;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Representation of a wireless network
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int refcount;
|
|
||||||
char *nm_name;
|
|
||||||
char *essid;
|
|
||||||
gboolean encrypted;
|
|
||||||
gboolean active;
|
|
||||||
gint8 strength;
|
|
||||||
} WirelessNetwork;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Representation of network device
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int refcount;
|
|
||||||
char *nm_device;
|
|
||||||
int type;
|
|
||||||
gboolean link;
|
|
||||||
guint32 driver_support_level;
|
|
||||||
char *addr;
|
|
||||||
char *nm_name;
|
|
||||||
char *hal_name;
|
|
||||||
char *udi;
|
|
||||||
gint strength;
|
|
||||||
GSList *networks;
|
|
||||||
} NetworkDevice;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct VPNConnection VPNConnection;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BUILD_NOTIFICATION_ICON
|
|
||||||
|
|
||||||
#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))
|
|
||||||
#define NM_IS_WIRELESS_APPLET(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), NM_TYPE_WIRELESS_APPLET))
|
|
||||||
#define NM_IS_WIRELESS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_WIRELESS_APPLET))
|
|
||||||
#define NM_WIRELESS_APPLET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), NM_TYPE_WIRELESS_APPLET, NMWirelessAppletClass))
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
EggTrayIconClass parent_class;
|
|
||||||
} NMWirelessAppletClass;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Applet instance data
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
#ifdef BUILD_NOTIFICATION_ICON
|
|
||||||
EggTrayIcon parent;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DBusConnection *connection;
|
|
||||||
GConfClient *gconf_client;
|
|
||||||
char *glade_file;
|
|
||||||
guint redraw_timeout_id;
|
|
||||||
|
|
||||||
/* dbus thread stuff */
|
|
||||||
GThread *dbus_thread;
|
|
||||||
GMainContext *thread_context;
|
|
||||||
GMainLoop *thread_loop;
|
|
||||||
gboolean thread_done;
|
|
||||||
|
|
||||||
/* Data model elements */
|
|
||||||
GMutex *data_mutex;
|
|
||||||
AppletState applet_state;
|
|
||||||
gboolean is_adhoc;
|
|
||||||
gboolean scanning_enabled;
|
|
||||||
gboolean wireless_enabled;
|
|
||||||
|
|
||||||
GSList *gui_device_list;
|
|
||||||
NetworkDevice *gui_active_device;
|
|
||||||
char *gui_nm_status;
|
|
||||||
GSList *gui_vpn_connections;
|
|
||||||
VPNConnection *gui_active_vpn;
|
|
||||||
|
|
||||||
GSList *dbus_device_list;
|
|
||||||
NetworkDevice *dbus_active_device;
|
|
||||||
char *dbus_nm_status;
|
|
||||||
GSList *dbus_vpn_connections;
|
|
||||||
VPNConnection *dbus_active_vpn;
|
|
||||||
|
|
||||||
GdkPixbuf *no_nm_icon;
|
|
||||||
GdkPixbuf *no_connection_icon;
|
|
||||||
GdkPixbuf *wired_icon;
|
|
||||||
GdkPixbuf *adhoc_icon;
|
|
||||||
#define NUM_WIRED_CONNECTING_FRAMES 11
|
|
||||||
GdkPixbuf *wired_connecting_icons[NUM_WIRED_CONNECTING_FRAMES];
|
|
||||||
GdkPixbuf *wireless_00_icon;
|
|
||||||
GdkPixbuf *wireless_25_icon;
|
|
||||||
GdkPixbuf *wireless_50_icon;
|
|
||||||
GdkPixbuf *wireless_75_icon;
|
|
||||||
GdkPixbuf *wireless_100_icon;
|
|
||||||
#define NUM_WIRELESS_CONNECTING_FRAMES 11
|
|
||||||
GdkPixbuf *wireless_connecting_icons[NUM_WIRELESS_CONNECTING_FRAMES];
|
|
||||||
#define NUM_WIRELESS_SCANNING_FRAMES 16
|
|
||||||
GdkPixbuf *wireless_scanning_icons[NUM_WIRELESS_SCANNING_FRAMES];
|
|
||||||
GdkPixbuf *vpn_lock_icon;
|
|
||||||
|
|
||||||
/* Animation stuff */
|
|
||||||
int animation_step;
|
|
||||||
guint animation_id;
|
|
||||||
|
|
||||||
/* Direct UI elements */
|
|
||||||
GtkWidget *pixmap;
|
|
||||||
GtkWidget *top_menu_item;
|
|
||||||
GtkWidget *dropdown_menu;
|
|
||||||
GtkWidget *vpn_menu;
|
|
||||||
GtkWidget *event_box;
|
|
||||||
GtkSizeGroup *encryption_size_group;
|
|
||||||
GtkTooltips *tooltips;
|
|
||||||
|
|
||||||
GtkWidget *context_menu;
|
|
||||||
GtkWidget *pause_scanning_item;
|
|
||||||
GtkWidget *stop_wireless_item;
|
|
||||||
|
|
||||||
} NMWirelessApplet;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
NMWirelessApplet *applet;
|
|
||||||
NetworkDevice *dev;
|
|
||||||
GladeXML *xml;
|
|
||||||
} DriverNotifyCBData;
|
|
||||||
|
|
||||||
NetworkDevice * nmwa_get_device_for_nm_device (GSList *dev_list, const char *nm_dev);
|
|
||||||
WirelessNetwork * nmwa_get_net_for_nm_net (NetworkDevice *dev, const char *net_path);
|
|
||||||
WirelessNetwork * nmwa_get_net_by_essid (NetworkDevice *dev, const char *essid);
|
|
||||||
NMWirelessApplet * nmwa_new (void);
|
|
||||||
void show_warning_dialog (gboolean error, gchar *mesg, ...);
|
|
||||||
gboolean nmwa_driver_notify (gpointer user_data);
|
|
||||||
void nmwa_schedule_vpn_login_failure_dialog (NMWirelessApplet *applet, const char *vpn_name, const char *error_msg);
|
|
||||||
void nmwa_schedule_vpn_login_banner_dialog (NMWirelessApplet *applet, const char *vpn_name, const char *banner);
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,36 +0,0 @@
|
|||||||
<oaf_info>
|
|
||||||
|
|
||||||
<oaf_server iid="OAFIID:NMWirelessApplet_Factory"
|
|
||||||
type="exe"
|
|
||||||
location="@LIBEXECDIR@/NMWirelessApplet">
|
|
||||||
|
|
||||||
<oaf_attribute name="repo_ids" type="stringv">
|
|
||||||
<item value="IDL:Bonobo/GenericFactory:1.0"/>
|
|
||||||
<item value="IDL:Bonobo/Unknown:1.0"/>
|
|
||||||
</oaf_attribute>
|
|
||||||
<oaf_attribute name="name" type="string" value="Wireless Applet"/>
|
|
||||||
<oaf_attribute name="description" type="string" value="Monitor the quality of a wireless network link"/>
|
|
||||||
|
|
||||||
</oaf_server>
|
|
||||||
|
|
||||||
<oaf_server iid="OAFIID:NMWirelessApplet"
|
|
||||||
type="factory"
|
|
||||||
location="OAFIID:NMWirelessApplet_Factory">
|
|
||||||
|
|
||||||
<oaf_attribute name="repo_ids" type="stringv">
|
|
||||||
<item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
|
|
||||||
<item value="IDL:Bonobo/Control:1.0"/>
|
|
||||||
<item value="IDL:Bonobo/Unknown:1.0"/>
|
|
||||||
</oaf_attribute>
|
|
||||||
<oaf_attribute name="name" type="string" value="Wireless Applet"/>
|
|
||||||
<oaf_attribute name="description" type="string" value="Monitor the quality of a wireless network link"/>
|
|
||||||
<oaf_attribute name="panel:category" type="string" value="Internet"/>
|
|
||||||
<oaf_attribute name="panel:icon" type="string" value="NMWirelessApplet/wireless-applet.png"/>
|
|
||||||
<oaf_attribute name="bugzilla:bugzilla" type="string" value="GNOME"/>
|
|
||||||
<oaf_attribute name="bugzilla:product" type="string" value="gnome-applets"/>
|
|
||||||
<oaf_attribute name="bugzilla:component" type="string" value="NMWirelessApplet"/>
|
|
||||||
<oaf_attribute name="bugzilla:other_binaries" type="string" value="NMWirelessApplet"/>
|
|
||||||
|
|
||||||
</oaf_server>
|
|
||||||
|
|
||||||
</oaf_info>
|
|
@@ -1,8 +0,0 @@
|
|||||||
<Root>
|
|
||||||
<popups>
|
|
||||||
<popup name="button3">
|
|
||||||
<menuitem name="Wireless About Item" verb="NMWirelessAbout" _label="_About..."
|
|
||||||
pixtype="stock" pixname="gnome-stock-about"/>
|
|
||||||
</popup>
|
|
||||||
</popups>
|
|
||||||
</Root>
|
|