4
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
#include <e-util/e-config.h>
28
#include <e-util/e-plugin-util.h>
29
#include <calendar/gui/e-cal-config.h>
30
#include <libedataserver/e-source.h>
31
#include <libsoup/soup.h>
32
#include <glib/gi18n.h>
35
GtkWidget *e_calendar_http_url (EPlugin *epl, EConfigHookItemFactoryData *data);
36
GtkWidget *e_calendar_http_refresh (EPlugin *epl, EConfigHookItemFactoryData *data);
37
gboolean e_calendar_http_check (EPlugin *epl, EConfigHookPageCheckData *data);
38
GtkWidget * e_calendar_http_secure (EPlugin *epl, EConfigHookItemFactoryData *data);
39
GtkWidget *e_calendar_http_auth (EPlugin *epl, EConfigHookItemFactoryData *data);
41
gint e_plugin_lib_enable (EPlugin *ep, gint enable);
44
e_plugin_lib_enable (EPlugin *ep,
51
url_changed (GtkEntry *entry,
57
uri = soup_uri_new (gtk_entry_get_text (GTK_ENTRY (entry)));
62
if (uri->scheme && strncmp (uri->scheme, "https", sizeof ("https") - 1) == 0) {
63
gpointer secure_checkbox;
65
secure_checkbox = g_object_get_data (
66
G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (entry))),
69
gtk_toggle_button_set_active (
70
GTK_TOGGLE_BUTTON (secure_checkbox), TRUE);
73
soup_uri_set_user (uri, e_source_get_property (source, "username"));
74
relative_uri = e_plugin_util_uri_no_proto (uri);
75
e_source_set_relative_uri (source, relative_uri);
76
g_free (relative_uri);
81
e_calendar_http_url (EPlugin *epl,
82
EConfigHookItemFactoryData *data)
85
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
89
if ((!e_plugin_util_is_source_proto (t->source, "http") &&
90
!e_plugin_util_is_source_proto (t->source, "https") &&
91
!e_plugin_util_is_source_proto (t->source, "webcal"))) {
95
uri_text = e_source_get_uri (t->source);
96
uri = soup_uri_new (uri_text);
100
soup_uri_set_user (uri, NULL);
101
soup_uri_set_password (uri, NULL);
103
uri_text = soup_uri_to_string (uri, FALSE);
106
uri_text = g_strdup ("");
109
entry = e_plugin_util_add_entry (data->parent, _("_URL:"), NULL, NULL);
110
gtk_entry_set_text (GTK_ENTRY (entry), uri_text);
113
G_CALLBACK (url_changed), t->source);
120
e_calendar_http_refresh (EPlugin *epl,
121
EConfigHookItemFactoryData *data)
123
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
125
if ((!e_plugin_util_is_source_proto (t->source, "http") &&
126
!e_plugin_util_is_source_proto (t->source, "https") &&
127
!e_plugin_util_is_source_proto (t->source, "webcal"))) {
131
return e_plugin_util_add_refresh (
132
data->parent, _("Re_fresh:"), t->source, "refresh");
136
e_calendar_http_secure (EPlugin *epl,
137
EConfigHookItemFactoryData *data)
139
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
140
GtkWidget *secure_setting;
142
if ((!e_plugin_util_is_source_proto (t->source, "http") &&
143
!e_plugin_util_is_source_proto (t->source, "https") &&
144
!e_plugin_util_is_source_proto (t->source, "webcal"))) {
148
secure_setting = e_plugin_util_add_check (
149
data->parent, _("Use _secure connection"),
150
t->source, "use_ssl", "1", "0");
152
/* Store pointer to secure checkbox so we can retrieve it in url_changed() */
154
G_OBJECT (data->parent), "secure_checkbox",
155
(gpointer) secure_setting);
157
return secure_setting;
161
username_changed (GtkEntry *entry,
164
const gchar *username;
167
username = gtk_entry_get_text (GTK_ENTRY (entry));
169
if (username && username[0]) {
170
e_source_set_property (source, "auth", "1");
171
e_source_set_property (source, "username", username);
173
e_source_set_property (source, "auth", NULL);
174
e_source_set_property (source, "username", NULL);
178
uri = e_source_get_uri (source);
183
suri = soup_uri_new (uri);
187
soup_uri_set_user (suri, username);
188
soup_uri_set_password (suri, NULL);
190
ruri = e_plugin_util_uri_no_proto (suri);
191
e_source_set_relative_uri (source, ruri);
192
soup_uri_free (suri);
199
e_calendar_http_auth (EPlugin *epl,
200
EConfigHookItemFactoryData *data)
202
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
204
const gchar *username;
206
if ((!e_plugin_util_is_source_proto (t->source, "http") &&
207
!e_plugin_util_is_source_proto (t->source, "https") &&
208
!e_plugin_util_is_source_proto (t->source, "webcal"))) {
212
username = e_source_get_property (t->source, "username");
214
entry = e_plugin_util_add_entry (data->parent, _("Userna_me:"), NULL, NULL);
215
gtk_entry_set_text (GTK_ENTRY (entry), username ? username : "");
218
G_CALLBACK (username_changed), t->source);
224
e_calendar_http_check (EPlugin *epl,
225
EConfigHookPageCheckData *data)
227
/* FIXME - check pageid */
228
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
231
if (!e_plugin_util_is_group_proto (e_source_peek_group (t->source), "webcal"))
234
if (e_plugin_util_is_source_proto (t->source, "file"))
237
ok = e_plugin_util_is_source_proto (t->source, "webcal") ||
238
e_plugin_util_is_source_proto (t->source, "http") ||
239
e_plugin_util_is_source_proto (t->source, "https") ||
240
e_plugin_util_is_source_proto (t->source, "file");