~ubuntu-branches/ubuntu/wily/evolution/wily

« back to all changes in this revision

Viewing changes to plugins/calendar-http/calendar-http.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-07-03 23:07:40 UTC
  • mfrom: (1.1.92)
  • Revision ID: package-import@ubuntu.com-20120703230740-0hjh6kfpxsyb88gx
Tags: 3.5.3.1-0ubuntu1
* New upstream release 3.5.3.1.
* debian/control:
  - Add libwebkitgtk-3.0-dev, libjavascriptcoregtk-3.0-dev >= 1.8.0 to build
    dependencies.
  - Adjust Build-Depends for the new minimum versions required for EDS 3.5.
  - Also update evolution's Depends to require evolution-data-server >= 3.5,
    and << 3.6.
* debian/rules:
  - Update ELIBDIR to point to /usr/lib/evolution/3.6 now, as per the base
    version defined in configure.
  - Build all plugins rather than enabling experimental specifically; we can
    sort them to other packages after.
  - Drop the binary-install/evolution-common target.
* debian/patches/01_ubuntu_signature.patch: dropped; upstream code has changed
  sufficiently that it would pretty much need a rewrite; and Evolution is no
  longer the default shipped mail client on Desktop.
* debian/patches/04_delay_alarm_notifier.patch: refreshed.
* debian/patches/89_remove_component_id_registration.patch: dropped: we don't
  have UNE anymore and component ID registration has been moved to GSettings.
* debian/patches/10_revert_libevolution_avoid-version.patch: refreshed.
* debian/patches/91_add_u1_email_translations.patch: refreshed.
* debian/evolution-common.install:
  - Drop debian/signature.py.
  - Don't install /usr/share/mime-info; it's not built anymore.
* debian/signature.py: dropped; since we dropped the Ubuntu signature patch.
* debian/evolution.install: don't try to install files in /etc/gconf; evo
  has migrated to GSettings so there are no such files anymore.
* debian/evolution.install,
  debian/evolution-plugins.install,
  debian/evolution-plugins-experimental.install: remove the plugins that were
  converted to modules. Modules are already installed by libevolution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *
3
 
 *
4
 
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
5
 
 *
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
 
 *
20
 
 */
21
 
 
22
 
#ifdef HAVE_CONFIG_H
23
 
#include <config.h>
24
 
#endif
25
 
 
26
 
#include <gtk/gtk.h>
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>
33
 
#include <string.h>
34
 
 
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);
40
 
 
41
 
gint e_plugin_lib_enable (EPlugin *ep, gint enable);
42
 
 
43
 
gint
44
 
e_plugin_lib_enable (EPlugin *ep,
45
 
                     gint enable)
46
 
{
47
 
        return 0;
48
 
}
49
 
 
50
 
static void
51
 
url_changed (GtkEntry *entry,
52
 
             ESource *source)
53
 
{
54
 
        SoupURI *uri;
55
 
        gchar *relative_uri;
56
 
 
57
 
        uri = soup_uri_new (gtk_entry_get_text (GTK_ENTRY (entry)));
58
 
 
59
 
        if (!uri)
60
 
                return;
61
 
 
62
 
        if (uri->scheme && strncmp (uri->scheme, "https", sizeof ("https") - 1) == 0) {
63
 
                gpointer secure_checkbox;
64
 
 
65
 
                secure_checkbox = g_object_get_data (
66
 
                        G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (entry))),
67
 
                        "secure_checkbox");
68
 
 
69
 
                gtk_toggle_button_set_active (
70
 
                        GTK_TOGGLE_BUTTON (secure_checkbox), TRUE);
71
 
        }
72
 
 
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);
77
 
        soup_uri_free (uri);
78
 
}
79
 
 
80
 
GtkWidget *
81
 
e_calendar_http_url (EPlugin *epl,
82
 
                     EConfigHookItemFactoryData *data)
83
 
{
84
 
        GtkWidget *entry;
85
 
        ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
86
 
        SoupURI *uri;
87
 
        gchar *uri_text;
88
 
 
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"))) {
92
 
                return NULL;
93
 
        }
94
 
 
95
 
        uri_text = e_source_get_uri (t->source);
96
 
        uri = soup_uri_new (uri_text);
97
 
        g_free (uri_text);
98
 
 
99
 
        if (uri) {
100
 
                soup_uri_set_user (uri, NULL);
101
 
                soup_uri_set_password (uri, NULL);
102
 
 
103
 
                uri_text = soup_uri_to_string (uri, FALSE);
104
 
                soup_uri_free (uri);
105
 
        } else {
106
 
                uri_text = g_strdup ("");
107
 
        }
108
 
 
109
 
        entry = e_plugin_util_add_entry (data->parent, _("_URL:"), NULL, NULL);
110
 
        gtk_entry_set_text (GTK_ENTRY (entry), uri_text);
111
 
        g_signal_connect (
112
 
                entry, "changed",
113
 
                G_CALLBACK (url_changed), t->source);
114
 
        g_free (uri_text);
115
 
 
116
 
        return entry;
117
 
}
118
 
 
119
 
GtkWidget *
120
 
e_calendar_http_refresh (EPlugin *epl,
121
 
                         EConfigHookItemFactoryData *data)
122
 
{
123
 
        ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
124
 
 
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"))) {
128
 
                return NULL;
129
 
        }
130
 
 
131
 
        return e_plugin_util_add_refresh (
132
 
                data->parent, _("Re_fresh:"), t->source, "refresh");
133
 
}
134
 
 
135
 
GtkWidget *
136
 
e_calendar_http_secure (EPlugin *epl,
137
 
                        EConfigHookItemFactoryData *data)
138
 
{
139
 
        ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
140
 
        GtkWidget *secure_setting;
141
 
 
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"))) {
145
 
                return NULL;
146
 
        }
147
 
 
148
 
        secure_setting = e_plugin_util_add_check (
149
 
                data->parent, _("Use _secure connection"),
150
 
                t->source, "use_ssl", "1", "0");
151
 
 
152
 
        /* Store pointer to secure checkbox so we can retrieve it in url_changed() */
153
 
        g_object_set_data (
154
 
                G_OBJECT (data->parent), "secure_checkbox",
155
 
                (gpointer) secure_setting);
156
 
 
157
 
        return secure_setting;
158
 
}
159
 
 
160
 
static void
161
 
username_changed (GtkEntry *entry,
162
 
                  ESource *source)
163
 
{
164
 
        const gchar *username;
165
 
        gchar *uri;
166
 
 
167
 
        username = gtk_entry_get_text (GTK_ENTRY (entry));
168
 
 
169
 
        if (username && username[0]) {
170
 
                e_source_set_property (source, "auth", "1");
171
 
                e_source_set_property (source, "username", username);
172
 
        } else {
173
 
                e_source_set_property (source, "auth", NULL);
174
 
                e_source_set_property (source, "username", NULL);
175
 
                username = NULL;
176
 
        }
177
 
 
178
 
        uri = e_source_get_uri (source);
179
 
        if (uri != NULL) {
180
 
                SoupURI *suri;
181
 
                gchar *ruri;
182
 
 
183
 
                suri = soup_uri_new (uri);
184
 
                if (!suri)
185
 
                        return;
186
 
 
187
 
                soup_uri_set_user (suri, username);
188
 
                soup_uri_set_password (suri, NULL);
189
 
 
190
 
                ruri = e_plugin_util_uri_no_proto (suri);
191
 
                e_source_set_relative_uri (source, ruri);
192
 
                soup_uri_free (suri);
193
 
                g_free (ruri);
194
 
                g_free (uri);
195
 
        }
196
 
}
197
 
 
198
 
GtkWidget *
199
 
e_calendar_http_auth (EPlugin *epl,
200
 
                      EConfigHookItemFactoryData *data)
201
 
{
202
 
        ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
203
 
        GtkWidget *entry;
204
 
        const gchar *username;
205
 
 
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"))) {
209
 
                return NULL;
210
 
        }
211
 
 
212
 
        username = e_source_get_property (t->source, "username");
213
 
 
214
 
        entry = e_plugin_util_add_entry (data->parent, _("Userna_me:"), NULL, NULL);
215
 
        gtk_entry_set_text (GTK_ENTRY (entry), username ? username : "");
216
 
        g_signal_connect (
217
 
                entry, "changed",
218
 
                G_CALLBACK (username_changed), t->source);
219
 
 
220
 
        return entry;
221
 
}
222
 
 
223
 
gboolean
224
 
e_calendar_http_check (EPlugin *epl,
225
 
                       EConfigHookPageCheckData *data)
226
 
{
227
 
        /* FIXME - check pageid */
228
 
        ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
229
 
        gboolean ok = FALSE;
230
 
 
231
 
        if (!e_plugin_util_is_group_proto (e_source_peek_group (t->source), "webcal"))
232
 
                return TRUE;
233
 
 
234
 
        if (e_plugin_util_is_source_proto (t->source, "file"))
235
 
                return FALSE;
236
 
 
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");
241
 
 
242
 
        return ok;
243
 
}