2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include <glade/glade.h>
20 #define NM_VPN_API_SUBJECT_TO_CHANGE
21 #include <nm-vpn-ui-interface.h>
24 typedef struct private_nm_applet_gui_t private_nm_applet_gui_t
;
27 * Private data of an nm_applet_gui_t object.
29 struct private_nm_applet_gui_t
{
32 * Implements NetworkManagerVpnUI interface.
34 NetworkManagerVpnUI
public;
37 * callback registered by NM to update validity
39 NetworkManagerVpnUIDialogValidityCallback callback
;
42 * loaded Glade XML interface description
47 * root widget to return to druid
52 * name of the connection
57 static const char *get_display_name(private_nm_applet_gui_t
*this)
59 return "strongSwan (IPsec/IKEv2)";
62 static const char *get_service_name(private_nm_applet_gui_t
*this)
64 return "org.freedesktop.NetworkManager.strongswan";
67 static GtkWidget
*get_widget(private_nm_applet_gui_t
*this, GSList
*properties
,
68 GSList
*routes
, const char *connection_name
)
72 gtk_entry_set_text(this->name
, "");
73 /*gtk_entry_set_text(this->gateway, "");*/
77 gtk_entry_set_text(this->name
, connection_name
);
85 key
= properties
->data
;
86 properties
= g_slist_next(properties
);
89 value
= properties
->data
;
91 if (strcmp(key, "gateway") == 0)
93 gtk_entry_set_text(this->gateway, value);
95 properties
= g_slist_next(properties
);
102 static GSList
*get_properties(private_nm_applet_gui_t
*this)
104 GSList
*props
= NULL
;
106 /*props = g_slist_append(props, g_strdup("gateway"));
107 props = g_slist_append(props, g_strdup(gtk_entry_get_text(this->gateway)));*/
112 static GSList
*get_routes(private_nm_applet_gui_t
*this)
117 static char *get_connection_name(private_nm_applet_gui_t
*this)
121 name
= gtk_entry_get_text(this->name
);
124 return g_strdup(name
);
129 static gboolean
is_valid(private_nm_applet_gui_t
*this)
134 static void set_validity_changed_callback(private_nm_applet_gui_t
*this,
135 NetworkManagerVpnUIDialogValidityCallback callback
,
138 this->callback
= callback
;
141 static void get_confirmation_details(private_nm_applet_gui_t
*this, gchar
**retval
)
143 *retval
= g_strdup_printf("connection %s\n", gtk_entry_get_text(this->name
));
146 static gboolean
can_export(private_nm_applet_gui_t
*this)
151 static gboolean
import_file (private_nm_applet_gui_t
*this, const char *path
)
156 static gboolean
export(private_nm_applet_gui_t
*this, GSList
*properties
,
157 GSList
*routes
, const char *connection_name
)
162 NetworkManagerVpnUI
* nm_vpn_properties_factory(void)
164 private_nm_applet_gui_t
*this = g_new0(private_nm_applet_gui_t
, 1);
166 this->public.get_display_name
= (const char *(*)(NetworkManagerVpnUI
*))get_display_name
;
167 this->public.get_service_name
= (const char *(*) (NetworkManagerVpnUI
*))get_service_name
;
168 this->public.get_widget
= (GtkWidget
*(*) (NetworkManagerVpnUI
*self
, GSList
*, GSList
*, const char *))get_widget
;
169 this->public.get_connection_name
= (char *(*) (NetworkManagerVpnUI
*))get_connection_name
;
170 this->public.get_properties
= (GSList
*(*) (NetworkManagerVpnUI
*))get_properties
;
171 this->public.get_routes
= (GSList
*(*) (NetworkManagerVpnUI
*))get_routes
;
172 this->public.set_validity_changed_callback
= (void (*) (NetworkManagerVpnUI
*, NetworkManagerVpnUIDialogValidityCallback
, gpointer
))set_validity_changed_callback
;
173 this->public.is_valid
= (gboolean (*) (NetworkManagerVpnUI
*))is_valid
;
174 this->public.get_confirmation_details
= (void (*)(NetworkManagerVpnUI
*, gchar
**))get_confirmation_details
;
175 this->public.can_export
= (gboolean (*) (NetworkManagerVpnUI
*))can_export
;
176 this->public.import_file
= (gboolean (*) (NetworkManagerVpnUI
*, const char *))import_file
;
177 this->public.export
= (gboolean (*) (NetworkManagerVpnUI
*, GSList
*, GSList
*, const char *))export
;
178 this->public.data
= NULL
;
180 this->callback
= NULL
;
181 this->xml
= glade_xml_new("/home/martin/strongswan/trunk/src/networkmanager/nm_applet_gui.xml", NULL
, NULL
);
183 if (this->xml
!= NULL
)
185 this->widget
= glade_xml_get_widget(this->xml
, "main");
186 this->name
= GTK_ENTRY(glade_xml_get_widget(this->xml
, "name"));
188 if (this->widget
&& this->name
)
190 return &this->public;