Commit c357c61e authored by David Zeuthen's avatar David Zeuthen
Browse files

2005-06-12 David Zeuthen <davidz@redhat.com>

	* gnome/vpn-properties/nm-vpn-ui-interface.h: New file

	* gnome/vpn-properties/nm-vpn-properties.glade: New file

	* gnome/vpn-properties/nm-vpn-properties.c: New file

	* gnome/vpn-properties/Makefile.am: New file

	* src/vpn-manager/nm-vpn-manager.h: Rework prototypes to take an
	array of passwords

	* src/vpn-manager/nm-vpn-manager.c
	(nm_vpn_manager_activate_vpn_connection): Take an array of passwords
	instead of just a single one

	* src/vpn-manager/nm-dbus-vpn.c:
	(nm_dbus_vpn_get_vpn_connection_properties): Also append service_name
	here
	(nm_dbus_vpn_activate_connection): Rework to take an array of passwords

	* gnome/applet/vpn-password-dialog.h (nmwa_vpn_request_password):
	Change the interface here to give a list of passwords. Also, don't
	require username, but do require service

	* gnome/applet/vpn-password-dialog.c: Look up the VPN .name files for
	the binary for the auth-dialog and use that instead of putting up a
	dialog asking for a single password

	* gnome/applet/vpn-connection.[ch]: Don't remember the user_name,
	however do remember the service

	* gnome/applet/main.c (main): Setup i18n

	* gnome/applet/applet.c (nmwa_update_state): Add a line "VPN
	connection to '%s'" to the tooltip if we are connected using VPN
	(nmwa_menu_vpn_item_activate): Check last_attempt_success gconf
	key to determine whether we the auth-dialog needs to
	reprompt. Also cope with the fact that the auth-dialog now returns
	an array of passwords.
	(nmwa_menu_configure_vpn_item_activate): New handler for
	"Configure VPN..." menu item
	(nmwa_menu_add_vpn_menu): Add the "Configure VPN..." menu item
	(is_vpn_available): New function to determine if we got any
	NM-compatible VPN software installed
	(nmwa_menu_add_devices): Use is_vpn_available to add VPN menu
	items only if we have NM-compatible VPN software installed
	(nmwa_gconf_vpn_connections_notify_callback): Slightly rework the
	logic for detecting when VPN connections are removed

	* gnome/applet/applet-dbus.h: Removed the prototypes for
	nmwa_dbus_vpn_activate_connection, nmwa_dbus_vpn_deactivate_connection
	since these are defined elsewhere

	* gnome/applet/applet-dbus.c (set_vpn_last_attempt_status): New
	function used to keep track of whether the last attempt succeded
	(nmwa_dbus_filter): Update last_attempt according to whether the
	VPN connection could be established or not

	* gnome/applet/applet-dbus-vpn.h (nmwa_dbus_vpn_deactivate_connection):
	Change prototype to take an array of passwords, not just a single
	password

	* gnome/applet/applet-dbus-vpn.c (nmwa_dbus_vpn_properties_cb): Only
	update service, not user
	(nmwa_dbus_vpn_remove_one_vpn_connection): Check that applet->
	dbus_active_vpn_name is not NULL before using it
	(nmwa_dbus_vpn_activate_connection): Send the passwords as a
	string array instead of assuming a single password

	* gnome/applet/applet-dbus-info.c:
	(nmi_dbus_get_vpn_connection_properties): Use the logged in user for
	user name; don't read from gconf

	* gnome/applet/Makefile.am: Also export SYSCONFDIR and
	VPN_NAME_FILES_DIR

	* gnome/Makefile.am (SUBDIRS): Add vpn-properties

	* configure.in: Add checks for gmodule-2.0.
	Generate gnome/vpn-properties/Makefile. Don't generate any Makefile's
	in vpn-daemons nor vpn-daemons/vpnc. We have separate autotooled
	projects under vpn-daemons now.	 See vpn-daemons/vpnc/Changelog
	for details

	* vpn-daemons/Makefile.am: Removed

	* vpn-daemons/README: New file to describe extensions points for VPN
	software


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@664 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 628aedd1
2005-06-12 David Zeuthen <davidz@redhat.com>
* gnome/vpn-properties/nm-vpn-ui-interface.h: New file
* gnome/vpn-properties/nm-vpn-properties.glade: New file
* gnome/vpn-properties/nm-vpn-properties.c: New file
* gnome/vpn-properties/Makefile.am: New file
* src/vpn-manager/nm-vpn-manager.h: Rework prototypes to take an
array of passwords
* src/vpn-manager/nm-vpn-manager.c
(nm_vpn_manager_activate_vpn_connection): Take an array of passwords
instead of just a single one
* src/vpn-manager/nm-dbus-vpn.c:
(nm_dbus_vpn_get_vpn_connection_properties): Also append service_name
here
(nm_dbus_vpn_activate_connection): Rework to take an array of passwords
* gnome/applet/vpn-password-dialog.h (nmwa_vpn_request_password):
Change the interface here to give a list of passwords. Also, don't
require username, but do require service
* gnome/applet/vpn-password-dialog.c: Look up the VPN .name files for
the binary for the auth-dialog and use that instead of putting up a
dialog asking for a single password
* gnome/applet/vpn-connection.[ch]: Don't remember the user_name,
however do remember the service
* gnome/applet/main.c (main): Setup i18n
* gnome/applet/applet.c (nmwa_update_state): Add a line "VPN
connection to '%s'" to the tooltip if we are connected using VPN
(nmwa_menu_vpn_item_activate): Check last_attempt_success gconf
key to determine whether we the auth-dialog needs to
reprompt. Also cope with the fact that the auth-dialog now returns
an array of passwords.
(nmwa_menu_configure_vpn_item_activate): New handler for
"Configure VPN..." menu item
(nmwa_menu_add_vpn_menu): Add the "Configure VPN..." menu item
(is_vpn_available): New function to determine if we got any
NM-compatible VPN software installed
(nmwa_menu_add_devices): Use is_vpn_available to add VPN menu
items only if we have NM-compatible VPN software installed
(nmwa_gconf_vpn_connections_notify_callback): Slightly rework the
logic for detecting when VPN connections are removed
* gnome/applet/applet-dbus.h: Removed the prototypes for
nmwa_dbus_vpn_activate_connection, nmwa_dbus_vpn_deactivate_connection
since these are defined elsewhere
* gnome/applet/applet-dbus.c (set_vpn_last_attempt_status): New
function used to keep track of whether the last attempt succeded
(nmwa_dbus_filter): Update last_attempt according to whether the
VPN connection could be established or not
* gnome/applet/applet-dbus-vpn.h (nmwa_dbus_vpn_deactivate_connection):
Change prototype to take an array of passwords, not just a single
password
* gnome/applet/applet-dbus-vpn.c (nmwa_dbus_vpn_properties_cb): Only
update service, not user
(nmwa_dbus_vpn_remove_one_vpn_connection): Check that applet->
dbus_active_vpn_name is not NULL before using it
(nmwa_dbus_vpn_activate_connection): Send the passwords as a
string array instead of assuming a single password
* gnome/applet/applet-dbus-info.c:
(nmi_dbus_get_vpn_connection_properties): Use the logged in user for
user name; don't read from gconf
* gnome/applet/Makefile.am: Also export SYSCONFDIR and
VPN_NAME_FILES_DIR
* gnome/Makefile.am (SUBDIRS): Add vpn-properties
* configure.in: Add checks for gmodule-2.0.
Generate gnome/vpn-properties/Makefile. Don't generate any Makefile's
in vpn-daemons nor vpn-daemons/vpnc. We have separate autotooled
projects under vpn-daemons now. See vpn-daemons/vpnc/Changelog
for details
* vpn-daemons/Makefile.am: Removed
* vpn-daemons/README: New file to describe extensions points for VPN
software
2005-06-10 Dan Williams <dcbw@redhat.com>
* src/backends/NetworkManagerRedHat.c
......
SUBDIRS = utils src dispatcher-daemon gnome vpn-daemons initscript test po
SUBDIRS = utils src dispatcher-daemon gnome initscript test po
EXTRA_DIST = CONTRIBUTING NetworkManager.pc.in NetworkManager.h
......
......@@ -115,6 +115,10 @@ PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
AC_SUBST(GTHREAD_CFLAGS)
AC_SUBST(GTHREAD_LIBS)
PKG_CHECK_MODULES(GMODULE, gmodule-2.0)
AC_SUBST(GMODULE_CFLAGS)
AC_SUBST(GMODULE_LIBS)
PKG_CHECK_MODULES(HAL, hal >= 0.2.91)
AC_SUBST(HAL_CFLAGS)
AC_SUBST(HAL_LIBS)
......@@ -277,6 +281,7 @@ gnome/applet/Makefile
gnome/applet/icons/Makefile
gnome/libnm_glib/libnm_glib.pc
gnome/libnm_glib/Makefile
gnome/vpn-properties/Makefile
test/Makefile
initscript/Makefile
initscript/RedHat/Makefile
......@@ -285,8 +290,6 @@ initscript/Debian/Makefile
initscript/Slackware/Makefile
po/Makefile.in
NetworkManager.pc
vpn-daemons/Makefile
vpn-daemons/vpnc/Makefile
])
echo
......
SUBDIRS = applet libnm_glib
SUBDIRS = applet libnm_glib vpn-properties
......@@ -6,59 +6,62 @@ INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
libexec_PROGRAMS = nm-applet
nm_applet_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)\" \
nm_applet_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)"\" \
-DBINDIR=\""$(bindir)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DVPN_NAME_FILES_DIR=\""$(sysconfdir)/NetworkManager/VPN"\" \
-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 \
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 \
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 \
passphrase-dialog.c \
passphrase-dialog.h \
menu-items.c \
menu-items.h \
gtkcellview.c \
gtkcellview.h \
gtkcellrendererprogress.c \
gtkcellrendererprogress.h \
eggtrayicon.c \
eggtrayicon.h \
eggtrayicon.c \
eggtrayicon.h \
vpn-password-dialog.c \
vpn-password-dialog.h \
vpn-connection.c \
vpn-connection.h \
vpn-connection.c \
vpn-connection.h \
$(NULL)
nm_applet_LDADD = \
......
......@@ -494,6 +494,8 @@ static DBusMessage *nmi_dbus_get_vpn_connections (NMWirelessApplet *applet, DBus
dbus_error_init (&error);
/*g_debug ("entering nmi_dbus_get_vpn_connections");*/
/* List all VPN connections that gconf knows about */
element = dir_list = gconf_client_all_dirs (applet->gconf_client, GCONF_PATH_VPN_CONNECTIONS, NULL);
if (!dir_list)
......@@ -524,10 +526,12 @@ static DBusMessage *nmi_dbus_get_vpn_connections (NMWirelessApplet *applet, DBus
const gchar *essid;
essid = gconf_value_get_string (value);
dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_STRING, &essid);
/*g_debug ("vpnid = '%s'", essid);*/
value_added = TRUE;
gconf_value_free (value);
}
g_free (element->data);
element = element->next;
}
......@@ -563,7 +567,7 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMWirelessApplet *ap
char *escaped_name;
char *name = NULL;
char *service_name = NULL;
char *user_name = NULL;
const char *user_name = NULL;
g_return_val_if_fail (applet != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
......@@ -579,12 +583,15 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMWirelessApplet *ap
escaped_name = gconf_escape_key (vpn_connection, strlen (vpn_connection));
/*g_debug ("entering nmi_dbus_get_vpn_connection_properties for '%s'", escaped_name);*/
/* User-visible name of connection */
gconf_key = g_strdup_printf ("%s/%s/name", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
{
name = g_strdup (gconf_value_get_string (value));
gconf_value_free (value);
/*g_debug ("name '%s'", name);*/
}
g_free (gconf_key);
......@@ -594,32 +601,24 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMWirelessApplet *ap
{
service_name = g_strdup (gconf_value_get_string (value));
gconf_value_free (value);
/*g_debug ("service '%s'", service_name);*/
}
g_free (gconf_key);
/* User name of connection */
gconf_key = g_strdup_printf ("%s/%s/user_name", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
{
user_name = g_strdup (gconf_value_get_string (value));
gconf_value_free (value);
}
g_free (gconf_key);
/* User name of connection - use the logged in user */
user_name = g_get_user_name ();
if (!name)
{
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
"NetworkManagerInfo::getVPNConnectionProperties could not access the name for connection '%s'", vpn_connection);
/*g_warning ("BadVPNConnectionData for '%s'", escaped_name);*/
}
else if (!service_name)
{
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
"NetworkManagerInfo::getVPNConnectionProperties could not access the service name for connection '%s'", vpn_connection);
}
else if (!user_name)
{
reply = nmwa_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadVPNConnectionData",
"NetworkManagerInfo::getVPNConnectionProperties could not access the user name for connection '%s'", vpn_connection);
/*g_warning ("BadVPNConnectionData for '%s'", escaped_name);*/
}
else
{
......@@ -632,7 +631,6 @@ static DBusMessage *nmi_dbus_get_vpn_connection_properties (NMWirelessApplet *ap
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &user_name);
}
g_free (user_name);
g_free (service_name);
g_free (name);
g_free (escaped_name);
......
......@@ -147,7 +147,8 @@ void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data)
VpnPropsCBData * cb_data = user_data;
NMWirelessApplet * applet;
const char * name;
const char * user_name;
const char * user_name;
const char * service;
g_return_if_fail (pcall != NULL);
g_return_if_fail (cb_data != NULL);
......@@ -181,17 +182,19 @@ void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data)
goto out;
}
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name, DBUS_TYPE_INVALID))
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID))
{
VPNConnection * vpn;
/* If its already there, update the user_name, otherwise add it to the list */
/* If its already there, update the service, 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);
{
nmwa_vpn_connection_set_service (vpn, service);
}
else
{
vpn = nmwa_vpn_connection_new (name);
nmwa_vpn_connection_set_user_name (vpn, user_name);
nmwa_vpn_connection_set_service (vpn, service);
applet->dbus_vpn_connections = g_slist_append (applet->dbus_vpn_connections, vpn);
}
}
......@@ -333,7 +336,8 @@ void nmwa_dbus_vpn_remove_one_vpn_connection (NMWirelessApplet *applet, const ch
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);
if (!strcmp (applet->dbus_active_vpn_name, nmwa_vpn_connection_get_name (vpn)))
if (applet->dbus_active_vpn_name != NULL &&
!strcmp (applet->dbus_active_vpn_name, nmwa_vpn_connection_get_name (vpn)))
{
g_free (applet->dbus_active_vpn_name);
applet->dbus_active_vpn_name = NULL;
......@@ -461,19 +465,29 @@ static void nmwa_free_dbus_vpn_connections (NMWirelessApplet *applet)
* Tell NetworkManager to activate a particular VPN connection.
*
*/
void nmwa_dbus_vpn_activate_connection (DBusConnection *connection, const char *name, const char *password)
void nmwa_dbus_vpn_activate_connection (DBusConnection *connection, const char *name, GSList *passwords)
{
DBusMessage *message;
DBusMessageIter iter;
DBusMessageIter iter_array;
g_return_if_fail (connection != NULL);
g_return_if_fail (name != NULL);
g_return_if_fail (password != NULL);
g_return_if_fail (passwords != NULL);
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "activateVPNConnection")))
{
GSList *i;
nm_info ("Activating VPN connection '%s'.\n", name);
dbus_message_iter_init_append (message, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &name);
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &iter_array);
dbus_message_append_args (message, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &password, DBUS_TYPE_INVALID);
for (i = passwords; i != NULL; i = g_slist_next (i)) {
dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_STRING, &(i->data));
}
dbus_message_iter_close_container (&iter, &iter_array);
dbus_connection_send (connection, message, NULL);
}
else
......
......@@ -32,7 +32,7 @@ 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_activate_connection (DBusConnection *connection, const char *name, GSList *passwords);
void nmwa_dbus_vpn_deactivate_connection (DBusConnection *connection);
......
......@@ -395,6 +395,20 @@ int nmwa_dbus_call_method_string_array (DBusConnection *con, const char *path, c
}
static void
set_vpn_last_attempt_status (NMWirelessApplet *applet, const char *vpn_name, gboolean last_attempt_success)
{
char *gconf_key;
char *escaped_name;
escaped_name = gconf_escape_key (vpn_name, strlen (vpn_name));
gconf_key = g_strdup_printf ("%s/%s/last_attempt_success", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
gconf_client_set_bool (applet->gconf_client, gconf_key, last_attempt_success, NULL);
g_free (gconf_key);
g_free (escaped_name);
}
/*
* nmwa_dbus_filter
......@@ -553,16 +567,22 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
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))
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_STRING, &error_msg, DBUS_TYPE_INVALID)) {
nmwa_schedule_vpn_failure_dialog (applet, member, vpn_name, error_msg);
/* clear the 'last_attempt_success' key in gconf so we prompt for password next time */
set_vpn_last_attempt_status (applet, vpn_name, FALSE);
}
}
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, NM_DBUS_VPN_SIGNAL_LOGIN_BANNER))
{
char *vpn_name;
char *banner;
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_STRING, &banner, DBUS_TYPE_INVALID))
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);
/* set the 'last_attempt_success' key in gconf so we DON'T prompt for password next time */
set_vpn_last_attempt_status (applet, vpn_name, TRUE);
}
}
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivationFailed"))
{
......
......@@ -60,7 +60,4 @@ 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
......@@ -42,8 +42,8 @@
#include <dirent.h>
#include <time.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#if !GTK_CHECK_VERSION(2,6,0)
#include <gnome.h>
......@@ -62,6 +62,7 @@
#include "menu-items.h"
#include "vpn-password-dialog.h"
#include "vpn-connection.h"
#include "nm-utils.h"
/* Compat for GTK 2.4 and lower... */
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
......@@ -899,6 +900,18 @@ done:
if (!applet->tooltips)
applet->tooltips = gtk_tooltips_new ();
if (applet->gui_active_vpn != NULL) {
char *newtip;
char *vpntip;
vpntip = g_strdup_printf (_("VPN connection to '%s'"), nmwa_vpn_connection_get_name (applet->gui_active_vpn));
newtip = g_strconcat (tip, "\n", vpntip, NULL);
g_free (vpntip);
g_free (tip);
tip = newtip;
}
gtk_tooltips_set_tip (applet->tooltips, applet->event_box, tip, NULL);
g_free (tip);
......@@ -1106,24 +1119,59 @@ static void nmwa_menu_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
{
VPNConnection *vpn = (VPNConnection *)tag;
const char *name = nmwa_vpn_connection_get_name (vpn);
char *password = NULL;
GSList *passwords;
if (vpn != applet->gui_active_vpn)
{
if ((password = nmwa_vpn_request_password (applet, name, nmwa_vpn_connection_get_user_name (vpn), FALSE)))
char *gconf_key;
char *escaped_name;
gboolean last_attempt_success;
gboolean reprompt;
escaped_name = gconf_escape_key (name, strlen (name));
gconf_key = g_strdup_printf ("%s/%s/last_attempt_success", GCONF_PATH_VPN_CONNECTIONS, escaped_name);
last_attempt_success = gconf_client_get_bool (applet->gconf_client, gconf_key, NULL);
g_free (gconf_key);
g_free (escaped_name);
reprompt = ! last_attempt_success; /* it's obvious, but.. */
if ((passwords = nmwa_vpn_request_password (applet,
name,
nmwa_vpn_connection_get_service (vpn),
reprompt)) != NULL)
{
nmwa_dbus_vpn_activate_connection (applet->connection, name, password);
g_free (password);
nmwa_dbus_vpn_activate_connection (applet->connection, name, passwords);
g_slist_foreach (passwords, (GFunc)g_free, NULL);
g_slist_free (passwords);
}
}
}
}
/*
* nmwa_menu_configure_vpn_item_activate
*
* Signal function called when user clicks "Configure VPN..."
*
*/
static void nmwa_menu_configure_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
{
NMWirelessApplet *applet = (NMWirelessApplet *)user_data;
char *argv[2] = {BINDIR "/nm-vpn-properties", NULL};
g_return_if_fail (item != NULL);
g_return_if_fail (applet != NULL);
g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL);
}
/*
* nmwa_menu_disconnect_vpn_item_activate
*
* Signal function called when user clicks on a VPN menu item
* Signal function called when user clicks "Disconnect VPN..."
*
*/
static void nmwa_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
......@@ -1437,6 +1485,10 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
other_item = GTK_MENU_ITEM (gtk_separator_menu_item_new ());
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (other_item));
other_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (_("Configure VPN...")));
g_signal_connect (G_OBJECT (other_item), "activate", G_CALLBACK (nmwa_menu_configure_vpn_item_activate), applet);
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (other_item));
other_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (_("Disconnect VPN...")));
g_signal_connect (G_OBJECT (other_item), "activate", G_CALLBACK (nmwa_menu_disconnect_vpn_item_activate), applet);
if (!applet->gui_active_vpn)
......@@ -1450,6 +1502,27 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
}
/** Returns TRUE if, and only if, we have VPN support installed
*
* Algorithm: just check whether any .name files exist in
* /etc/NetworkManager/VPN
*/
static gboolean is_vpn_available (void)
{
GDir *dir;
gboolean result;
result = FALSE;
if ((dir = g_dir_open (VPN_NAME_FILES_DIR, 0, NULL)) != NULL) {
const char *f;
if (g_dir_read_name (dir) != NULL)
result = TRUE;
g_dir_close (dir);
}
return result;
}
/*
* nmwa_menu_add_devices
*
......@@ -1521,8 +1594,10 @@ static void nmwa_menu_add_devices (GtkWidget *menu, NMWirelessApplet *applet)
}
}
nmwa_menu_add_separator_item (menu);
nmwa_menu_add_vpn_menu (menu, applet);
if (is_vpn_available ()) {
nmwa_menu_add_separator_item (menu);