Migrated NM frontend plugin to NetworkManager 0.9

Use GtkBuilder, drop gconf dependency.
This commit is contained in:
Martin Willi
2011-09-05 17:14:28 +02:00
parent 2feb3d9e0b
commit 791c93f3ea
7 changed files with 294 additions and 283 deletions
+2 -5
View File
@@ -7,11 +7,7 @@ nm_strongswan_auth_dialog_CPPFLAGS = \
$(GNOMEKEYRING_CFLAGS) \ $(GNOMEKEYRING_CFLAGS) \
$(NETWORK_MANAGER_CFLAGS) \ $(NETWORK_MANAGER_CFLAGS) \
$(NM_UTILS_CFLAGS) \ $(NM_UTILS_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \
-DBINDIR=\""$(bindir)"\" \
-DG_DISABLE_DEPRECATED \ -DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGNOME_DISABLE_DEPRECATED \ -DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \ -DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-DVERSION=\"$(VERSION)\" -DVERSION=\"$(VERSION)\"
@@ -22,5 +18,6 @@ nm_strongswan_auth_dialog_SOURCES = \
nm_strongswan_auth_dialog_LDADD = \ nm_strongswan_auth_dialog_LDADD = \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(LIBGNOMEUI_LIBS) \ $(LIBGNOMEUI_LIBS) \
$(GNOMEKEYRING_LIBS) $(GNOMEKEYRING_LIBS) \
$(NM_UTILS_LIBS)
+65 -65
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2008 Martin Willi * Copyright (C) 2008-2011 Martin Willi
* Hochschule fuer Technik Rapperswil * Hochschule fuer Technik Rapperswil
* Copyright (C) 2004 Dan Williams * Copyright (C) 2004 Dan Williams
* Red Hat, Inc. * Red Hat, Inc.
@@ -24,10 +24,10 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gnome-keyring.h> #include <gnome-keyring.h>
#include <libgnomeui/libgnomeui.h> #include <libgnomeui/libgnomeui.h>
#include <gconf/gconf-client.h>
#include <nm-vpn-plugin.h> #include <nm-vpn-plugin.h>
#include <nm-setting-vpn.h> #include <nm-setting-vpn.h>
#include <nm-setting-connection.h> #include <nm-setting-connection.h>
#include <nm-vpn-plugin-utils.h>
#define NM_DBUS_SERVICE_STRONGSWAN "org.freedesktop.NetworkManager.strongswan" #define NM_DBUS_SERVICE_STRONGSWAN "org.freedesktop.NetworkManager.strongswan"
@@ -60,63 +60,64 @@ static char *lookup_password(char *name, char *service)
return pass; return pass;
} }
/**
* Wait for quit input
*/
static void wait_for_quit (void)
{
GString *str;
char c;
ssize_t n;
time_t start;
str = g_string_sized_new (10);
start = time (NULL);
do {
errno = 0;
n = read (0, &c, 1);
if (n == 0 || (n < 0 && errno == EAGAIN))
g_usleep (G_USEC_PER_SEC / 10);
else if (n == 1) {
g_string_append_c (str, c);
if (strstr (str->str, "QUIT") || (str->len > 10))
break;
} else
break;
} while (time (NULL) < start + 20);
g_string_free (str, TRUE);
}
/** /**
* get the connection type * get the connection type
*/ */
static char* get_connection_type(char *uuid) static char* get_connection_type(char *uuid)
{ {
GConfClient *client = NULL; GHashTable *data = NULL, *secrets = NULL;
GSList *list; char *method;
GSList *iter;
char *key, *str, *path, *found = NULL, *method = NULL;
client = gconf_client_get_default(); if (!nm_vpn_plugin_utils_read_vpn_details (0, &data, &secrets)) {
fprintf (stderr, "Failed to read data and secrets from stdin.\n");
list = gconf_client_all_dirs(client, "/system/networking/connections", NULL); return NULL;
g_return_val_if_fail(list, NULL);
for (iter = list; iter; iter = iter->next)
{
path = (char *) iter->data;
key = g_strdup_printf("%s/%s/%s", path,
NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_UUID);
str = gconf_client_get_string(client, key, NULL);
g_free (key);
if (str && !strcmp(str, uuid))
{
found = g_strdup(path);
}
g_free (str);
if (found)
{
break;
}
} }
g_slist_foreach(list, (GFunc)g_free, NULL);
g_slist_free(list); method = g_hash_table_lookup (data, "method");
if (method)
method = g_strdup(method);
if (data)
g_hash_table_unref (data);
if (secrets)
g_hash_table_unref (secrets);
if (found)
{
key = g_strdup_printf ("%s/%s/%s", found,
NM_SETTING_VPN_SETTING_NAME, "method");
method = gconf_client_get_string(client, key, NULL);
g_free(found);
g_free(key);
}
g_object_unref(client);
return method; return method;
} }
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
gboolean retry = FALSE; gboolean retry = FALSE, allow_interaction = FALSE;
gchar *name = NULL, *uuid = NULL, *service = NULL, *keyring = NULL, *pass; gchar *name = NULL, *uuid = NULL, *service = NULL, *keyring = NULL, *pass;
GOptionContext *context; GOptionContext *context;
GnomeProgram *program = NULL; char *agent, *type;
char buf, *agent, *type;
guint32 itemid; guint32 itemid;
GtkWidget *dialog; GtkWidget *dialog;
GOptionEntry entries[] = { GOptionEntry entries[] = {
@@ -124,6 +125,7 @@ int main (int argc, char *argv[])
{ "uuid", 'u', 0, G_OPTION_ARG_STRING, &uuid, "UUID of VPN connection", NULL}, { "uuid", 'u', 0, G_OPTION_ARG_STRING, &uuid, "UUID of VPN connection", NULL},
{ "name", 'n', 0, G_OPTION_ARG_STRING, &name, "Name of VPN connection", NULL}, { "name", 'n', 0, G_OPTION_ARG_STRING, &name, "Name of VPN connection", NULL},
{ "service", 's', 0, G_OPTION_ARG_STRING, &service, "VPN service type", NULL}, { "service", 's', 0, G_OPTION_ARG_STRING, &service, "VPN service type", NULL},
{ "allow-interaction", 'i', 0, G_OPTION_ARG_NONE, &allow_interaction, "Allow user interaction", NULL},
{ NULL } { NULL }
}; };
@@ -131,19 +133,16 @@ int main (int argc, char *argv[])
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE); textdomain(GETTEXT_PACKAGE);
gtk_init (&argc, &argv);
context = g_option_context_new ("- strongswan auth dialog"); context = g_option_context_new ("- strongswan auth dialog");
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, NULL);
program = gnome_program_init ("nm-strongswan-auth-dialog", VERSION, g_option_context_free (context);
LIBGNOMEUI_MODULE,
argc, argv,
GNOME_PARAM_GOPTION_CONTEXT, context,
GNOME_PARAM_NONE);
if (uuid == NULL || name == NULL || service == NULL) if (uuid == NULL || name == NULL || service == NULL)
{ {
fprintf (stderr, "Have to supply UUID, name, and service\n"); fprintf (stderr, "Have to supply UUID, name, and service\n");
g_object_unref (program);
return 1; return 1;
} }
@@ -151,7 +150,6 @@ int main (int argc, char *argv[])
{ {
fprintf(stderr, "This dialog only works with the '%s' service\n", fprintf(stderr, "This dialog only works with the '%s' service\n",
NM_DBUS_SERVICE_STRONGSWAN); NM_DBUS_SERVICE_STRONGSWAN);
g_object_unref (program);
return 1; return 1;
} }
@@ -159,13 +157,12 @@ int main (int argc, char *argv[])
if (!type) if (!type)
{ {
fprintf(stderr, "Connection lookup failed\n"); fprintf(stderr, "Connection lookup failed\n");
g_object_unref (program);
return 1; return 1;
} }
if (!strcmp(type, "eap") || !strcmp(type, "key") || !strcmp(type, "smartcard")) if (!strcmp(type, "eap") || !strcmp(type, "key") || !strcmp(type, "smartcard"))
{ {
pass = lookup_password(name, service); pass = lookup_password(name, service);
if (!pass || retry) if ((!pass || retry) && allow_interaction)
{ {
if (!strcmp(type, "eap")) if (!strcmp(type, "eap"))
{ {
@@ -195,7 +192,6 @@ int main (int argc, char *argv[])
} }
if (!gnome_password_dialog_run_and_block(GNOME_PASSWORD_DIALOG(dialog))) if (!gnome_password_dialog_run_and_block(GNOME_PASSWORD_DIALOG(dialog)))
{ {
g_object_unref (program);
return 1; return 1;
} }
@@ -217,7 +213,10 @@ int main (int argc, char *argv[])
break; break;
} }
} }
printf("password\n%s\n", pass); if (pass)
{
printf("password\n%s\n", pass);
}
} }
else else
{ {
@@ -228,20 +227,21 @@ int main (int argc, char *argv[])
} }
else else
{ {
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, if (allow_interaction)
GTK_BUTTONS_OK, {
_("Configuration uses ssh-agent for authentication, " dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR,
"but ssh-agent is not running!")); GTK_BUTTONS_OK,
gtk_dialog_run (GTK_DIALOG (dialog)); _("Configuration uses ssh-agent for authentication, "
gtk_widget_destroy (dialog); "but ssh-agent is not running!"));
return 1; gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
} }
} }
printf("\n\n"); printf("\n\n");
/* flush output, wait for input */ /* flush output, wait for input */
fflush(stdout); fflush(stdout);
if (fread(&buf, 1, sizeof(buf), stdin)); wait_for_quit ();
g_object_unref(program);
return 0; return 0;
} }
+12 -26
View File
@@ -1,6 +1,6 @@
AC_PREREQ(2.52) AC_PREREQ(2.52)
AC_INIT(NetworkManager-strongswan, 1.2.0, [email protected], NetworkManager-strongswan) AC_INIT(NetworkManager-strongswan, 1.3.0, [email protected], NetworkManager-strongswan)
AM_INIT_AUTOMAKE([subdir-objects]) AM_INIT_AUTOMAKE([subdir-objects])
AM_MAINTAINER_MODE AM_MAINTAINER_MODE
@@ -50,35 +50,21 @@ PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.30)
AC_SUBST(DBUS_CFLAGS) AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS) AC_SUBST(DBUS_LIBS)
if test x"$with_gnome" != xno; then PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6)
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6) AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_LIBS)
PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0) PKG_CHECK_MODULES(LIBGNOMEUI, libgnomeui-2.0)
AC_SUBST(GDK_PIXBUF_CFLAGS) AC_SUBST(LIBGNOMEUI_CFLAGS)
AC_SUBST(GDK_PIXBUF_LIBS) AC_SUBST(LIBGNOMEUI_LIBS)
PKG_CHECK_MODULES(GLADE, libglade-2.0) PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
AC_SUBST(GLADE_CFLAGS) AC_SUBST(GNOMEKEYRING_CFLAGS)
AC_SUBST(GLADE_LIBS) AC_SUBST(GNOMEKEYRING_LIBS)
PKG_CHECK_MODULES(LIBGNOMEUI, libgnomeui-2.0)
AC_SUBST(LIBGNOMEUI_CFLAGS)
AC_SUBST(LIBGNOMEUI_LIBS)
PKG_CHECK_MODULES(GCONF, gconf-2.0)
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(GCONF_LIBS)
PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
AC_SUBST(GNOMEKEYRING_CFLAGS)
AC_SUBST(GNOMEKEYRING_LIBS)
fi
PKG_CHECK_EXISTS([libnm-glib], PKG_CHECK_EXISTS([libnm-glib],
[PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.7.0 libnm-util libnm-glib libnm-glib-vpn)], [PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.9.0 libnm-util libnm-glib libnm-glib-vpn)],
[PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.7.0 libnm-util libnm_glib libnm_glib_vpn)] [PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.9.0 libnm-util libnm_glib libnm_glib_vpn)]
) )
AC_SUBST(NM_UTILS_CFLAGS) AC_SUBST(NM_UTILS_CFLAGS)
AC_SUBST(NM_UTILS_LIBS) AC_SUBST(NM_UTILS_LIBS)
+1 -1
View File
@@ -1,5 +1,5 @@
# List of source files containing translatable strings. # List of source files containing translatable strings.
# Please keep this file sorted alphabetically. # Please keep this file sorted alphabetically.
properties/nm-strongswan.c properties/nm-strongswan.c
properties/nm-strongswan-dialog.glade properties/nm-strongswan-dialog.ui
auth-dialog/main.c auth-dialog/main.c
+15 -26
View File
@@ -2,36 +2,25 @@ plugindir = $(libdir)/NetworkManager
plugin_LTLIBRARIES = libnm-strongswan-properties.la plugin_LTLIBRARIES = libnm-strongswan-properties.la
libnm_strongswan_properties_la_SOURCES = \ libnm_strongswan_properties_la_SOURCES = \
nm-strongswan.c \ nm-strongswan.c \
nm-strongswan.h nm-strongswan.h
gladedir = $(datadir)/gnome-vpn-properties/strongswan uidir = $(datadir)/gnome-vpn-properties/strongswan
glade_DATA = nm-strongswan-dialog.glade ui_DATA = nm-strongswan-dialog.ui
libnm_strongswan_properties_la_CFLAGS = \ libnm_strongswan_properties_la_CFLAGS = \
$(GLADE_CFLAGS) \ $(GTK_CFLAGS) \
$(GTK_CFLAGS) \ $(NM_UTILS_CFLAGS) \
$(GCONF_CFLAGS) \ -DUIDIR=\""$(uidir)"\" \
$(LIBGNOMEUI_CFLAGS) \ -DG_DISABLE_DEPRECATED \
$(NM_UTILS_CFLAGS) \ -DGDK_DISABLE_DEPRECATED \
-DICONDIR=\""$(datadir)/pixmaps"\" \ -DVERSION=\"$(VERSION)\"
-DGLADEDIR=\""$(gladedir)"\" \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-DVERSION=\"$(VERSION)\"
libnm_strongswan_properties_la_LIBADD = \ libnm_strongswan_properties_la_LIBADD = \
$(GLADE_LIBS) \ $(GTK_LIBS) \
$(GTK_LIBS) \ $(NM_UTILS_LIBS)
$(GCONF_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(NM_UTILS_LIBS)
libnm_strongswan_properties_la_LDFLAGS = \ libnm_strongswan_properties_la_LDFLAGS = \
-avoid-version -avoid-version
CLEANFILES = *.bak *.gladep *~ EXTRA_DIST = $(ui_DATA)
EXTRA_DIST = $(glade_DATA)
@@ -1,27 +1,29 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<glade-interface> <interface>
<!-- interface-requires gtk+ 2.12 --> <!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide --> <object class="GtkWindow" id="strongswan-widget">
<widget class="GtkWindow" id="strongswan-widget"> <property name="can_focus">False</property>
<property name="title" translatable="yes">window1</property> <property name="title" translatable="yes">window1</property>
<child> <child>
<widget class="GtkVBox" id="strongswan-vbox"> <object class="GtkVBox" id="strongswan-vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="border_width">12</property> <property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">16</property> <property name="spacing">16</property>
<child> <child>
<widget class="GtkVBox" id="gateway-vbox"> <object class="GtkVBox" id="gateway-vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="can_focus">False</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<widget class="GtkLabel" id="gateway-label"> <object class="GtkLabel" id="gateway-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Gateway&lt;/b&gt;</property> <property name="label" translatable="yes">&lt;b&gt;Gateway&lt;/b&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
@@ -29,36 +31,39 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkAlignment" id="gateway-alignement"> <object class="GtkAlignment" id="gateway-alignement">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<widget class="GtkTable" id="gateway-table"> <object class="GtkTable" id="gateway-table">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">2</property> <property name="n_rows">2</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">6</property> <property name="column_spacing">6</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<child> <child>
<widget class="GtkLabel" id="address-label"> <object class="GtkLabel" id="address-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">_Address:</property> <property name="label" translatable="yes">_Address:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">address-entry</property> <property name="mnemonic_widget">address-entry</property>
</widget> </object>
<packing> <packing>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkEntry" id="address-entry"> <object class="GtkEntry" id="address-entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="has_tooltip">True</property> <property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">An IP address or hostname the Gateway can be contacted.</property> <property name="tooltip_text" translatable="yes">An IP address or hostname the Gateway can be contacted.</property>
</widget> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@@ -66,13 +71,14 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="certificate-label"> <object class="GtkLabel" id="certificate-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">C_ertificate:</property> <property name="label" translatable="yes">C_ertificate:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">certificate-button</property> <property name="mnemonic_widget">certificate-button</property>
</widget> </object>
<packing> <packing>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="bottom_attach">2</property> <property name="bottom_attach">2</property>
@@ -81,10 +87,11 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkFileChooserButton" id="certificate-button"> <object class="GtkFileChooserButton" id="certificate-button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Gateway or CA certificate to use for gateway authentication. If none is specified, pre-installed CA certificates are used.</property> <property name="can_focus">False</property>
</widget> <property name="tooltip_text" translatable="yes">Gateway or CA certificate to use for gateway authentication. If none is specified, pre-installed CA certificates are used.</property>
</object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@@ -92,31 +99,35 @@
<property name="bottom_attach">2</property> <property name="bottom_attach">2</property>
</packing> </packing>
</child> </child>
</widget> </object>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkVBox" id="client-vbox"> <object class="GtkVBox" id="client-vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="can_focus">False</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<widget class="GtkLabel" id="client-label"> <object class="GtkLabel" id="client-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Client&lt;/b&gt;</property> <property name="label" translatable="yes">&lt;b&gt;Client&lt;/b&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
@@ -124,21 +135,24 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkAlignment" id="client-aligement"> <object class="GtkAlignment" id="client-aligement">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<widget class="GtkTable" id="client-table"> <object class="GtkTable" id="client-table">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">4</property> <property name="n_rows">4</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">6</property> <property name="column_spacing">6</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<child> <child>
<widget class="GtkFileChooserButton" id="userkey-button"> <object class="GtkFileChooserButton" id="userkey-button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Private key to use for client authentication. This key has to match the certificates public key and may be encrypted.</property> <property name="can_focus">False</property>
</widget> <property name="tooltip_text" translatable="yes">Private key to use for client authentication. This key has to match the certificates public key and may be encrypted.</property>
</object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@@ -147,13 +161,14 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="userkey-label"> <object class="GtkLabel" id="userkey-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Private _key:</property> <property name="label" translatable="yes">Private _key:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">userkey-button</property> <property name="mnemonic_widget">userkey-button</property>
</widget> </object>
<packing> <packing>
<property name="top_attach">3</property> <property name="top_attach">3</property>
<property name="bottom_attach">4</property> <property name="bottom_attach">4</property>
@@ -162,38 +177,27 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkComboBox" id="method-combo"> <object class="GtkLabel" id="method-label">
<property name="visible">True</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Authentication Method to use for authentication against the Gateway. </property>
<property name="items"></property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="method-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Au_thentication:</property> <property name="label" translatable="yes">Au_thentication:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">method-combo</property> </object>
</widget>
<packing> <packing>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="user-label"> <object class="GtkLabel" id="user-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">_Username:</property> <property name="label" translatable="yes">_Username:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">user-entry</property> <property name="mnemonic_widget">user-entry</property>
</widget> </object>
<packing> <packing>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="bottom_attach">2</property> <property name="bottom_attach">2</property>
@@ -202,12 +206,12 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkEntry" id="user-entry"> <object class="GtkEntry" id="user-entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="has_tooltip">True</property> <property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">The username (identity) to use for authentication against the gateway.</property> <property name="tooltip_text" translatable="yes">The username (identity) to use for authentication against the gateway.</property>
</widget> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@@ -217,13 +221,14 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="usercert-label"> <object class="GtkLabel" id="usercert-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Ce_rtificate:</property> <property name="label" translatable="yes">Ce_rtificate:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">usercert-button</property> <property name="mnemonic_widget">usercert-button</property>
</widget> </object>
<packing> <packing>
<property name="top_attach">2</property> <property name="top_attach">2</property>
<property name="bottom_attach">3</property> <property name="bottom_attach">3</property>
@@ -232,10 +237,11 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkFileChooserButton" id="usercert-button"> <object class="GtkFileChooserButton" id="usercert-button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Client certificate to use for client authentication.</property> <property name="can_focus">False</property>
</widget> <property name="tooltip_text" translatable="yes">Client certificate to use for client authentication.</property>
</object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@@ -243,31 +249,45 @@
<property name="bottom_attach">3</property> <property name="bottom_attach">3</property>
</packing> </packing>
</child> </child>
</widget> <child>
<object class="GtkComboBoxText" id="method-combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</object>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkVBox" id="options-vbox"> <object class="GtkVBox" id="options-vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="can_focus">False</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<widget class="GtkLabel" id="options-label"> <object class="GtkLabel" id="options-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property> <property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
@@ -275,72 +295,85 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkAlignment" id="options-alignement"> <object class="GtkAlignment" id="options-alignement">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<widget class="GtkVBox" id="options-inner-vbox"> <object class="GtkVBox" id="options-inner-vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="can_focus">False</property>
<child> <child>
<widget class="GtkCheckButton" id="virtual-check"> <object class="GtkCheckButton" id="virtual-check">
<property name="label" translatable="yes">Request an _inner IP address</property> <property name="label" translatable="yes">Request an _inner IP address</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="has_tooltip">True</property> <property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">The Gateway may provide addresses from a pool to use for communication in the Gateways network. Check to request such an address.</property> <property name="tooltip_text" translatable="yes">The Gateway may provide addresses from a pool to use for communication in the Gateways network. Check to request such an address.</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="encap-check"> <object class="GtkCheckButton" id="encap-check">
<property name="label" translatable="yes">En_force UDP encapsulation</property> <property name="label" translatable="yes">En_force UDP encapsulation</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="has_tooltip">True</property> <property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Some firewalls block ESP traffic. Enforcing UDP capsulation even if no NAT situation is detected might help in such cases.</property> <property name="tooltip_text" translatable="yes">Some firewalls block ESP traffic. Enforcing UDP capsulation even if no NAT situation is detected might help in such cases.</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="ipcomp-check"> <object class="GtkCheckButton" id="ipcomp-check">
<property name="label" translatable="yes">Use IP c_ompression</property> <property name="label" translatable="yes">Use IP c_ompression</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="has_tooltip">True</property> <property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">IPComp compresses raw IP packets before they get encrypted. This saves some bandwidth, but uses more processing power.</property> <property name="tooltip_text" translatable="yes">IPComp compresses raw IP packets before they get encrypted. This saves some bandwidth, but uses more processing power.</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</widget> </object>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</widget> </object>
</child> </child>
</widget> </object>
</glade-interface> </interface>
+80 -74
View File
@@ -24,7 +24,6 @@
#include <glib.h> #include <glib.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <glade/glade.h>
#define NM_VPN_API_SUBJECT_TO_CHANGE #define NM_VPN_API_SUBJECT_TO_CHANGE
@@ -59,7 +58,7 @@ G_DEFINE_TYPE_EXTENDED (StrongswanPluginUiWidget, strongswan_plugin_ui_widget, G
#define STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidgetPrivate)) #define STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidgetPrivate))
typedef struct { typedef struct {
GladeXML *xml; GtkBuilder *builder;
GtkWidget *widget; GtkWidget *widget;
} StrongswanPluginUiWidgetPrivate; } StrongswanPluginUiWidgetPrivate;
@@ -106,7 +105,7 @@ check_validity (StrongswanPluginUiWidget *self, GError **error)
GtkWidget *widget; GtkWidget *widget;
char *str; char *str;
widget = glade_xml_get_widget (priv->xml, "address-entry"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "address-entry"));
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
if (!str || !strlen (str)) { if (!str || !strlen (str)) {
g_set_error (error, g_set_error (error,
@@ -126,36 +125,36 @@ static void update_layout (GtkWidget *widget, StrongswanPluginUiWidgetPrivate *p
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
/* FALL */ /* FALL */
case 0: case 0:
gtk_widget_show (glade_xml_get_widget (priv->xml, "usercert-label")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-label")));
gtk_widget_show (glade_xml_get_widget (priv->xml, "usercert-button")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button")));
gtk_widget_show (glade_xml_get_widget (priv->xml, "userkey-label")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-label")));
gtk_widget_show (glade_xml_get_widget (priv->xml, "userkey-button")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "user-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "user-entry")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry")));
break; break;
case 1: case 1:
gtk_widget_show (glade_xml_get_widget (priv->xml, "usercert-label")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-label")));
gtk_widget_show (glade_xml_get_widget (priv->xml, "usercert-button")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "user-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "user-entry")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "userkey-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "userkey-button")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button")));
break; break;
case 2: case 2:
gtk_widget_hide (glade_xml_get_widget (priv->xml, "usercert-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "usercert-button")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "user-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "user-entry")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "userkey-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "userkey-button")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button")));
break; break;
case 3: case 3:
gtk_widget_show (glade_xml_get_widget (priv->xml, "user-label")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-label")));
gtk_widget_show (glade_xml_get_widget (priv->xml, "user-entry")); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "usercert-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "usercert-button")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "userkey-label")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-label")));
gtk_widget_hide (glade_xml_get_widget (priv->xml, "userkey-button")); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button")));
break; break;
} }
@@ -167,9 +166,9 @@ settings_changed_cb (GtkWidget *widget, gpointer user_data)
StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (user_data); StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (user_data);
StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self); StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
if (widget == glade_xml_get_widget (priv->xml, "method-combo")) if (widget == GTK_WIDGET (gtk_builder_get_object (priv->builder, "method-combo")))
{ {
update_layout(glade_xml_get_widget (priv->xml, "method-combo"), priv); update_layout(GTK_WIDGET (gtk_builder_get_object (priv->builder, "method-combo")), priv);
} }
g_signal_emit_by_name (STRONGSWAN_PLUGIN_UI_WIDGET (user_data), "changed"); g_signal_emit_by_name (STRONGSWAN_PLUGIN_UI_WIDGET (user_data), "changed");
} }
@@ -183,32 +182,32 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
const char *value; const char *value;
settings = NM_SETTING_VPN(nm_connection_get_setting(connection, NM_TYPE_SETTING_VPN)); settings = NM_SETTING_VPN(nm_connection_get_setting(connection, NM_TYPE_SETTING_VPN));
widget = glade_xml_get_widget (priv->xml, "address-entry"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "address-entry"));
value = nm_setting_vpn_get_data_item (settings, "address"); value = nm_setting_vpn_get_data_item (settings, "address");
if (value) if (value)
gtk_entry_set_text (GTK_ENTRY (widget), value); gtk_entry_set_text (GTK_ENTRY (widget), value);
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "certificate-button"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "certificate-button"));
value = nm_setting_vpn_get_data_item (settings, "certificate"); value = nm_setting_vpn_get_data_item (settings, "certificate");
if (value) if (value)
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value);
g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "user-label"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-label"));
gtk_widget_set_no_show_all (widget, TRUE); gtk_widget_set_no_show_all (widget, TRUE);
widget = glade_xml_get_widget (priv->xml, "user-entry"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry"));
gtk_widget_set_no_show_all (widget, TRUE); gtk_widget_set_no_show_all (widget, TRUE);
value = nm_setting_vpn_get_data_item (settings, "user"); value = nm_setting_vpn_get_data_item (settings, "user");
if (value) if (value)
gtk_entry_set_text (GTK_ENTRY (widget), value); gtk_entry_set_text (GTK_ENTRY (widget), value);
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "method-combo"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "method-combo"));
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Certificate/private key")); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Certificate/private key"));
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Certificate/ssh-agent")); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Certificate/ssh-agent"));
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Smartcard")); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Smartcard"));
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("EAP")); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("EAP"));
value = nm_setting_vpn_get_data_item (settings, "method"); value = nm_setting_vpn_get_data_item (settings, "method");
if (value) { if (value) {
if (g_strcmp0 (value, "key") == 0) { if (g_strcmp0 (value, "key") == 0) {
@@ -231,25 +230,25 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
update_layout (widget, priv); update_layout (widget, priv);
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "usercert-label"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-label"));
gtk_widget_set_no_show_all (widget, TRUE); gtk_widget_set_no_show_all (widget, TRUE);
widget = glade_xml_get_widget (priv->xml, "usercert-button"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button"));
gtk_widget_set_no_show_all (widget, TRUE); gtk_widget_set_no_show_all (widget, TRUE);
value = nm_setting_vpn_get_data_item (settings, "usercert"); value = nm_setting_vpn_get_data_item (settings, "usercert");
if (value) if (value)
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value);
g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "userkey-label"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-label"));
gtk_widget_set_no_show_all (widget, TRUE); gtk_widget_set_no_show_all (widget, TRUE);
widget = glade_xml_get_widget (priv->xml, "userkey-button"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button"));
gtk_widget_set_no_show_all (widget, TRUE); gtk_widget_set_no_show_all (widget, TRUE);
value = nm_setting_vpn_get_data_item (settings, "userkey"); value = nm_setting_vpn_get_data_item (settings, "userkey");
if (value) if (value)
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value);
g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "virtual-check"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "virtual-check"));
value = nm_setting_vpn_get_data_item (settings, "virtual"); value = nm_setting_vpn_get_data_item (settings, "virtual");
if (value && strcmp(value, "yes") == 0) if (value && strcmp(value, "yes") == 0)
{ {
@@ -257,7 +256,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
} }
g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "encap-check"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "encap-check"));
value = nm_setting_vpn_get_data_item (settings, "encap"); value = nm_setting_vpn_get_data_item (settings, "encap");
if (value && strcmp(value, "yes") == 0) if (value && strcmp(value, "yes") == 0)
{ {
@@ -265,7 +264,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
} }
g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self);
widget = glade_xml_get_widget (priv->xml, "ipcomp-check"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ipcomp-check"));
value = nm_setting_vpn_get_data_item (settings, "ipcomp"); value = nm_setting_vpn_get_data_item (settings, "ipcomp");
if (value && strcmp(value, "yes") == 0) if (value && strcmp(value, "yes") == 0)
{ {
@@ -304,29 +303,29 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
g_object_set (settings, NM_SETTING_VPN_SERVICE_TYPE, g_object_set (settings, NM_SETTING_VPN_SERVICE_TYPE,
NM_DBUS_SERVICE_STRONGSWAN, NULL); NM_DBUS_SERVICE_STRONGSWAN, NULL);
widget = glade_xml_get_widget (priv->xml, "address-entry"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "address-entry"));
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
if (str && strlen (str)) { if (str && strlen (str)) {
nm_setting_vpn_add_data_item (settings, "address", str); nm_setting_vpn_add_data_item (settings, "address", str);
} }
widget = glade_xml_get_widget (priv->xml, "certificate-button"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "certificate-button"));
str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
if (str) { if (str) {
nm_setting_vpn_add_data_item (settings, "certificate", str); nm_setting_vpn_add_data_item (settings, "certificate", str);
} }
widget = glade_xml_get_widget (priv->xml, "method-combo"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "method-combo"));
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget))) switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)))
{ {
default: default:
case 0: case 0:
widget = glade_xml_get_widget (priv->xml, "userkey-button"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button"));
str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
if (str) { if (str) {
nm_setting_vpn_add_data_item (settings, "userkey", str); nm_setting_vpn_add_data_item (settings, "userkey", str);
} }
widget = glade_xml_get_widget (priv->xml, "usercert-button"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button"));
str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
if (str) { if (str) {
nm_setting_vpn_add_data_item (settings, "usercert", str); nm_setting_vpn_add_data_item (settings, "usercert", str);
@@ -334,7 +333,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
str = "key"; str = "key";
break; break;
case 1: case 1:
widget = glade_xml_get_widget (priv->xml, "usercert-button"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button"));
str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
if (str) { if (str) {
nm_setting_vpn_add_data_item (settings, "usercert", str); nm_setting_vpn_add_data_item (settings, "usercert", str);
@@ -345,7 +344,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
str = "smartcard"; str = "smartcard";
break; break;
case 3: case 3:
widget = glade_xml_get_widget (priv->xml, "user-entry"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry"));
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
if (str && strlen (str)) { if (str && strlen (str)) {
nm_setting_vpn_add_data_item (settings, "user", str); nm_setting_vpn_add_data_item (settings, "user", str);
@@ -355,27 +354,30 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
} }
nm_setting_vpn_add_data_item (settings, "method", str); nm_setting_vpn_add_data_item (settings, "method", str);
widget = glade_xml_get_widget (priv->xml, "virtual-check"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "virtual-check"));
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
nm_setting_vpn_add_data_item (settings, "virtual", active ? "yes" : "no"); nm_setting_vpn_add_data_item (settings, "virtual", active ? "yes" : "no");
widget = glade_xml_get_widget (priv->xml, "encap-check"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "encap-check"));
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
nm_setting_vpn_add_data_item (settings, "encap", active ? "yes" : "no"); nm_setting_vpn_add_data_item (settings, "encap", active ? "yes" : "no");
widget = glade_xml_get_widget (priv->xml, "ipcomp-check"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ipcomp-check"));
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
nm_setting_vpn_add_data_item (settings, "ipcomp", active ? "yes" : "no"); nm_setting_vpn_add_data_item (settings, "ipcomp", active ? "yes" : "no");
nm_connection_add_setting (connection, NM_SETTING (settings));
return TRUE;
}
static gboolean if (!nm_setting_set_secret_flags (NM_SETTING (settings),
save_secrets (NMVpnPluginUiWidgetInterface *iface, "password", NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL))
NMConnection *connection, GError **error) {
{ fprintf(stderr, "no\n");
/* no secrets to save */ }
else
{
fprintf(stderr, "yes\n");
}
nm_connection_add_setting (connection, NM_SETTING (settings));
return TRUE; return TRUE;
} }
@@ -384,7 +386,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
{ {
NMVpnPluginUiWidgetInterface *object; NMVpnPluginUiWidgetInterface *object;
StrongswanPluginUiWidgetPrivate *priv; StrongswanPluginUiWidgetPrivate *priv;
char *glade_file; char *ui_file;
if (error) if (error)
g_return_val_if_fail (*error == NULL, NULL); g_return_val_if_fail (*error == NULL, NULL);
@@ -396,19 +398,24 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
} }
priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (object); priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (object);
ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-strongswan-dialog.ui");
priv->builder = gtk_builder_new ();
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, "nm-strongswan-dialog.glade"); gtk_builder_set_translation_domain (priv->builder, GETTEXT_PACKAGE);
priv->xml = glade_xml_new (glade_file, "strongswan-vbox", GETTEXT_PACKAGE);
if (priv->xml == NULL) { if (!gtk_builder_add_from_file (priv->builder, ui_file, error)) {
g_warning ("Couldn't load builder file: %s",
error && *error ? (*error)->message : "(unknown)");
g_clear_error (error);
g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0,
"could not load required resources at %s", glade_file); "could not load required resources at %s", ui_file);
g_free (glade_file); g_free (ui_file);
g_object_unref (object); g_object_unref (object);
return NULL; return NULL;
} }
g_free (glade_file); g_free (ui_file);
priv->widget = glade_xml_get_widget (priv->xml, "strongswan-vbox"); priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "strongswan-vbox") );
if (!priv->widget) { if (!priv->widget) {
g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, "could not load UI widget"); g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, "could not load UI widget");
g_object_unref (object); g_object_unref (object);
@@ -433,8 +440,8 @@ dispose (GObject *object)
if (priv->widget) if (priv->widget)
g_object_unref (priv->widget); g_object_unref (priv->widget);
if (priv->xml) if (priv->builder)
g_object_unref (priv->xml); g_object_unref (priv->builder);
G_OBJECT_CLASS (strongswan_plugin_ui_widget_parent_class)->dispose (object); G_OBJECT_CLASS (strongswan_plugin_ui_widget_parent_class)->dispose (object);
} }
@@ -460,7 +467,6 @@ strongswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_
/* interface implementation */ /* interface implementation */
iface_class->get_widget = get_widget; iface_class->get_widget = get_widget;
iface_class->update_connection = update_connection; iface_class->update_connection = update_connection;
iface_class->save_secrets = save_secrets;
} }
static guint32 static guint32