Uploaded initial version.
[guivpn] / trunk / vpngui / src / vpngui.h
1 /*
2  * This file is part of vpngui
3  *
4  * Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * */
20
21
22 #ifndef VPNGUI_PLUGIN_H
23 #define VPNGUI_PLUGIN_H
24
25 #include <libhildondesktop/libhildondesktop.h>
26
27 G_BEGIN_DECLS
28
29 #define VPNGUI_TYPE_PLUGIN            (vpngui_plugin_get_type ())
30 #define VPNGUI_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VPNGUI_TYPE_PLUGIN, PluginInfo))
31 #define VPNGUI_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VPNGUI_TYPE_PLUGIN, PluginInfoClass))
32 #define VPNGUI_IS_PLUGIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VPNGUI_TYPE_PLUGIN))
33 #define VPNGUI_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VPNGUI_TYPE_PLUGIN))
34 #define VPNGUI_PLUGIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), VPNGUI_TYPE_PLUGIN, PluginInfoClass))
35
36 #include <libosso.h>
37 #include <gconf/gconf-client.h>
38
39 #include "vpn_notify.h"
40
41 #define ICON_ACTIVE "/usr/share/pixmaps/hiro-vpn/vpngui-on.png"
42 #define ICON_INACTIVE "/usr/share/pixmaps/hiro-vpn/vpngui-off.png"
43 #define ICON_SUSPENDED "/usr/share/pixmaps/hiro-vpn/vpngui-pending.png"
44 #define ICON_ACTIVE_SMALL "/usr/share/pixmaps/hiro-vpn/vpngui-on-small.png"
45 #define ICON_SUSPENDED_SMALL "/usr/share/pixmaps/hiro-vpn/vpngui-pending-small.png"
46 #define VPNC_CONNECT "sudo /usr/sbin/vpngui-helper connect"
47 #define VPNC_DISCONNECT "sudo /usr/sbin/vpngui-helper disconnect"
48
49 /* gconf paths */
50 #define VPN_GCONF_PATH "/apps/osso/vpngui/ap"
51 #define VPN_GCONF_AP_PATH VPN_GCONF_PATH "/%s"
52 #define VPN_GCONF_AP_PATH_NO VPN_GCONF_PATH "/%d"
53 /* allow future expansion for more than one access point */
54 #define VPN_GCONF_VPN_NAME VPN_GCONF_AP_PATH "/name"
55 #define VPN_GCONF_VPN_NAME_NO VPN_GCONF_AP_PATH_NO "/name"
56 #define VPN_GCONF_USER VPN_GCONF_AP_PATH "/username"
57 #define VPN_GCONF_PASSWD VPN_GCONF_AP_PATH "/password"
58 #define VPN_GCONF_PASSWD_OBF VPN_GCONF_AP_PATH "/password_obf"
59 #define VPN_GCONF_GWADDR VPN_GCONF_AP_PATH "/gateway"
60 #define VPN_GCONF_GROUP VPN_GCONF_AP_PATH "/group"
61 #define VPN_GCONF_SECRET VPN_GCONF_AP_PATH "/secret"
62 #define VPN_GCONF_SECRET_OBF VPN_GCONF_AP_PATH "/secret_obf"
63 #define VPN_GCONF_PROXY_MODE VPN_GCONF_AP_PATH "/proxytype"
64 #define VPN_GCONF_PROXY_SERVER VPN_GCONF_AP_PATH "/proxy_server"
65 #define VPN_GCONF_PROXY_PORT VPN_GCONF_AP_PATH "/proxy_port"
66 #define VPN_GCONF_PROXY_AUTOCONFIG_URL VPN_GCONF_AP_PATH "/proxy_autoconfig_url"
67 #define VPN_GCONF_PROXY_IGNORE_HOSTS VPN_GCONF_AP_PATH "/proxy_ignore_hosts"
68
69 /* Placeholders */
70 #define VPN_GCONF_REKEY_INTERVAL VPN_GCONF_AP_PATH "/rekey_interval"
71 #define VPN_GCONF_NAT_KEEPALIVE VPN_GCONF_AP_PATH "/nat_keepalive"
72
73 /* Common for all connections */
74 //#define VPN_REKEY_INTERVAL 3000
75 #define VPN_REKEY_INTERVAL 17280
76 #define VPN_NAT_KEEPALIVE 50
77 #define VPN_DEFAULT_HIRO_VPN 0
78 #define VPNGUI_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj, VPNGUI_TYPE_PLUGIN, PluginInfoPrivate))
79 enum {
80         PIXBUF_ACTIVE,
81         PIXBUF_INACTIVE,
82         PIXBUF_SUSPENDED,
83         PIXBUF_ACTIVE_SMALL,
84         PIXBUF_SUSPENDED_SMALL,
85         NUM_PIXBUFS,
86 };
87
88 enum VpnStates {
89         VPN_CONNECTING,
90         VPN_CONNECTED,
91         VPN_CONNECT_FAILED,
92         VPN_DISCONNECTING,
93         VPN_DISCONNECTED,
94         VPN_DISCONNECT_FAILED,
95         VPN_FORCED_DISCONNECTING,
96 };
97
98 /** responses emitted by the settings dialog */
99 enum vpn_settings_dialogs_response {
100          VPN_ACCESS_POINT_NEW,
101          VPN_ACCESS_POINT_DELETE,
102          VPN_ACCESS_POINT_SETTINGS ,
103          VPN_ACCESS_POINT_CONNECT,
104          VPN_ACCESS_POINT_CANCEL
105 };
106
107
108 typedef struct _PluginInfo        PluginInfo;
109 typedef struct _PluginInfoClass   PluginInfoClass;
110 typedef struct _PluginInfoPrivate PluginInfoPrivate;
111 typedef struct _PrivateVpnDetails PrivateVpnDetails;
112
113 struct _PluginInfo
114 {
115         HDStatusMenuItem       parent;
116         PluginInfoPrivate     *priv;
117 };
118
119 struct _PluginInfoClass
120 {
121         HDStatusMenuItemClass  parent;
122 };
123
124 GType vpngui_plugin_get_type (void);
125
126 struct _PrivateVpnDetails{
127         gchar *vpn_name;
128         gchar *username;
129         gchar *password;
130         gboolean password_obf;
131         gchar *gwaddress;
132         gchar *group;
133         gchar *secret;
134         gboolean secret_obf;
135         int rekeyinterval;
136         int natkeepalive;
137         gchar *proxytype;
138         gchar *proxy_server;
139         gint proxy_port;
140         gchar *proxy_autoconfig_url;
141         GSList *proxy_ignore_hosts;
142         GConfChangeSet *proxy_saved;
143 };
144
145 struct _PluginInfoPrivate{
146         int state;
147         GtkWidget *button;
148         GtkWidget *button2;  // for connect and disconnect
149         GtkWidget *connect_button;  // for connect
150         GtkWidget *delete_button;  // for delete
151         GtkWidget *settings_button;  // for settings
152         GtkWidget *menu;
153         GtkWidget *menu_connect;
154         GtkWidget *menu_disconnect;
155         GtkWidget *menu_settings;
156         GtkWidget *menu_ap;
157         GtkWidget *item_ap;
158         GList *list;
159         GtkWidget *icon;
160         GtkWidget *banner;
161         GdkPixbuf *pixbuf[NUM_PIXBUFS];
162
163         guint timer;
164         gboolean have_network;
165
166         /* vpn settings */
167         PrivateVpnDetails vpn_settings;
168         gchar *vpnc_config;
169         gchar *old_ip;
170
171         GPid vpnc_pid;
172         guint vpnc_watch_id;
173         
174         gboolean show_connect_dialog;
175         osso_context_t *osso_context;
176
177         VpnNotify *vpn_notify;
178         GtkDialog *main_dialog;
179         int connected_vpn_ap_ui;
180         int connected_vpn_ap_gconf;
181
182 //have to remove them eventually- Rakesh
183  GtkWidget* container_hbox;
184  GtkWidget* vbox1;
185  GtkWidget* vbox2;
186  GtkWidget* sync_name_label;
187  GtkWidget* prof_name_label;
188  int total_items ; //Total number of VPN access points
189 gboolean show_icon; 
190
191 };
192         
193 //} _PluginInfoPrivate;
194 void error_msg(const char *format, ...);
195 void set_state(PluginInfo *info, int state);
196
197 gboolean vpnc_start(PluginInfo *info);
198 gboolean vpnc_stop(PluginInfo *info, const gboolean forced);
199 gboolean vpnc_restart(PluginInfo *info);
200 gboolean vpnc_config_write (PluginInfo *info);
201
202 G_END_DECLS
203 #endif