~ubuntu-branches/ubuntu/saucy/evolution-data-server/saucy

« back to all changes in this revision

Viewing changes to libedataserver/e-source-webdav.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        gchar *display_name;
60
60
        gchar *email_address;
61
61
        gchar *resource_path;
 
62
        gchar *resource_query;
62
63
        gboolean avoid_ifmatch;
63
64
        gboolean calendar_auto_schedule;
64
65
        gboolean ignore_invalid_cert;
65
 
        SoupURI *uri;
 
66
        SoupURI *soup_uri;
66
67
};
67
68
 
68
69
enum {
73
74
        PROP_EMAIL_ADDRESS,
74
75
        PROP_IGNORE_INVALID_CERT,
75
76
        PROP_RESOURCE_PATH,
 
77
        PROP_RESOURCE_QUERY,
76
78
        PROP_SOUP_URI
77
79
};
78
80
 
81
83
        e_source_webdav,
82
84
        E_TYPE_SOURCE_EXTENSION)
83
85
 
84
 
static gboolean
85
 
source_webdav_host_to_soup_uri (GBinding *binding,
86
 
                                const GValue *source_value,
87
 
                                GValue *target_value,
88
 
                                gpointer user_data)
89
 
{
90
 
        GObject *target;
91
 
        SoupURI *soup_uri;
92
 
        const gchar *host;
93
 
 
94
 
        host = g_value_get_string (source_value);
95
 
 
96
 
        target = g_binding_get_target (binding);
97
 
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
98
 
 
99
 
        soup_uri = e_source_webdav_dup_soup_uri (E_SOURCE_WEBDAV (target));
100
 
        soup_uri_set_host (soup_uri, host);
101
 
        g_value_take_boxed (target_value, soup_uri);
102
 
 
103
 
        return TRUE;
104
 
}
105
 
 
106
 
static gboolean
107
 
source_webdav_soup_uri_to_host (GBinding *binding,
108
 
                                const GValue *source_value,
109
 
                                GValue *target_value,
110
 
                                gpointer user_data)
111
 
{
112
 
        SoupURI *soup_uri;
113
 
 
114
 
        soup_uri = g_value_get_boxed (source_value);
115
 
        g_value_set_string (target_value, soup_uri->host);
116
 
 
117
 
        return TRUE;
118
 
}
119
 
 
120
 
static gboolean
121
 
source_webdav_path_to_soup_uri (GBinding *binding,
122
 
                                const GValue *source_value,
123
 
                                GValue *target_value,
124
 
                                gpointer user_data)
125
 
{
126
 
        GObject *target;
127
 
        SoupURI *soup_uri;
128
 
        const gchar *path;
129
 
 
130
 
        path = g_value_get_string (source_value);
131
 
 
132
 
        /* soup_uri_set_path() warns on NULL. */
133
 
        if (path == NULL)
134
 
                path = "";
135
 
 
136
 
        target = g_binding_get_target (binding);
137
 
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
138
 
 
139
 
        soup_uri = e_source_webdav_dup_soup_uri (E_SOURCE_WEBDAV (target));
140
 
        soup_uri_set_path (soup_uri, path);
141
 
        g_value_take_boxed (target_value, soup_uri);
142
 
 
143
 
        return TRUE;
144
 
}
145
 
 
146
 
static gboolean
147
 
source_webdav_soup_uri_to_path (GBinding *binding,
148
 
                                const GValue *source_value,
149
 
                                GValue *target_value,
150
 
                                gpointer user_data)
151
 
{
152
 
        SoupURI *soup_uri;
153
 
 
154
 
        soup_uri = g_value_get_boxed (source_value);
155
 
        g_value_set_string (target_value, soup_uri->path);
156
 
 
157
 
        return TRUE;
158
 
}
159
 
 
160
 
static gboolean
161
 
source_webdav_port_to_soup_uri (GBinding *binding,
162
 
                                const GValue *source_value,
163
 
                                GValue *target_value,
164
 
                                gpointer user_data)
165
 
{
166
 
        GObject *target;
167
 
        SoupURI *soup_uri;
168
 
        guint port;
169
 
 
170
 
        port = g_value_get_uint (source_value);
171
 
 
172
 
        target = g_binding_get_target (binding);
173
 
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
174
 
 
175
 
        soup_uri = e_source_webdav_dup_soup_uri (E_SOURCE_WEBDAV (target));
176
 
        soup_uri_set_port (soup_uri, port);
177
 
        g_value_take_boxed (target_value, soup_uri);
178
 
 
179
 
        return TRUE;
180
 
}
181
 
 
182
 
static gboolean
183
 
source_webdav_soup_uri_to_port (GBinding *binding,
184
 
                                const GValue *source_value,
185
 
                                GValue *target_value,
186
 
                                gpointer user_data)
187
 
{
188
 
        SoupURI *soup_uri;
189
 
 
190
 
        soup_uri = g_value_get_boxed (source_value);
191
 
        g_value_set_uint (target_value, soup_uri->port);
192
 
 
193
 
        return TRUE;
194
 
}
195
 
 
196
 
static gboolean
197
 
source_webdav_secure_to_soup_uri (GBinding *binding,
198
 
                                  const GValue *source_value,
199
 
                                  GValue *target_value,
200
 
                                  gpointer user_data)
201
 
{
202
 
        GObject *target;
203
 
        SoupURI *soup_uri;
204
 
        gboolean secure;
205
 
 
206
 
        secure = g_value_get_boolean (source_value);
207
 
 
208
 
        target = g_binding_get_target (binding);
209
 
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
210
 
 
211
 
        soup_uri = e_source_webdav_dup_soup_uri (E_SOURCE_WEBDAV (target));
212
 
        if (secure)
213
 
                soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTPS);
214
 
        else
215
 
                soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTP);
216
 
        g_value_take_boxed (target_value, soup_uri);
217
 
 
218
 
        return TRUE;
219
 
}
220
 
 
221
 
static gboolean
222
 
source_webdav_soup_uri_to_secure (GBinding *binding,
223
 
                                  const GValue *source_value,
224
 
                                  GValue *target_value,
225
 
                                  gpointer user_data)
226
 
{
227
 
        SoupURI *soup_uri;
228
 
        gboolean secure;
229
 
 
230
 
        soup_uri = g_value_get_boxed (source_value);
231
 
        secure = (soup_uri->scheme == SOUP_URI_SCHEME_HTTPS);
232
 
        g_value_set_boolean (target_value, secure);
233
 
 
234
 
        return TRUE;
235
 
}
236
 
 
237
 
static gboolean
238
 
source_webdav_user_to_soup_uri (GBinding *binding,
239
 
                                const GValue *source_value,
240
 
                                GValue *target_value,
241
 
                                gpointer user_data)
242
 
{
243
 
        GObject *target;
244
 
        SoupURI *soup_uri;
245
 
        const gchar *user;
246
 
 
247
 
        user = g_value_get_string (source_value);
248
 
 
249
 
        target = g_binding_get_target (binding);
250
 
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
251
 
 
252
 
        soup_uri = e_source_webdav_dup_soup_uri (E_SOURCE_WEBDAV (target));
253
 
        soup_uri_set_user (soup_uri, user);
254
 
        g_value_take_boxed (target_value, soup_uri);
255
 
 
256
 
        return TRUE;
257
 
}
258
 
 
259
 
static gboolean
260
 
source_webdav_soup_uri_to_user (GBinding *binding,
261
 
                                const GValue *source_value,
262
 
                                GValue *target_value,
263
 
                                gpointer user_data)
264
 
{
265
 
        SoupURI *soup_uri;
266
 
 
267
 
        soup_uri = g_value_get_boxed (source_value);
268
 
        g_value_set_string (target_value, soup_uri->user);
269
 
 
270
 
        return TRUE;
 
86
static void
 
87
source_webdav_notify_cb (GObject *object,
 
88
                         GParamSpec *pspec,
 
89
                         ESourceWebdav *extension)
 
90
{
 
91
        g_object_notify (G_OBJECT (extension), "soup-uri");
271
92
}
272
93
 
273
94
static gboolean
288
109
}
289
110
 
290
111
static void
 
112
source_webdav_update_properties_from_soup_uri (ESourceWebdav *webdav_extension)
 
113
{
 
114
        ESource *source;
 
115
        ESourceExtension *extension;
 
116
        SoupURI *soup_uri;
 
117
        const gchar *extension_name;
 
118
 
 
119
        /* Do not use e_source_webdav_dup_soup_uri() here.  That
 
120
         * builds the URI from properties we haven't yet updated. */
 
121
        g_mutex_lock (webdav_extension->priv->property_lock);
 
122
        soup_uri = soup_uri_copy (webdav_extension->priv->soup_uri);
 
123
        g_mutex_unlock (webdav_extension->priv->property_lock);
 
124
 
 
125
        extension = E_SOURCE_EXTENSION (webdav_extension);
 
126
        source = e_source_extension_get_source (extension);
 
127
 
 
128
        g_object_set (
 
129
                extension,
 
130
                "resource-path", soup_uri->path,
 
131
                "resource-query", soup_uri->query,
 
132
                NULL);
 
133
 
 
134
        extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
 
135
        extension = e_source_get_extension (source, extension_name);
 
136
 
 
137
        g_object_set (
 
138
                extension,
 
139
                "host", soup_uri->host,
 
140
                "port", soup_uri->port,
 
141
                "user", soup_uri->user,
 
142
                NULL);
 
143
 
 
144
        extension_name = E_SOURCE_EXTENSION_SECURITY;
 
145
        extension = e_source_get_extension (source, extension_name);
 
146
 
 
147
        g_object_set (
 
148
                extension,
 
149
                "secure", (soup_uri->scheme == SOUP_URI_SCHEME_HTTPS),
 
150
                NULL);
 
151
 
 
152
        soup_uri_free (soup_uri);
 
153
}
 
154
 
 
155
static void
 
156
source_webdav_update_soup_uri_from_properties (ESourceWebdav *webdav_extension)
 
157
{
 
158
        ESource *source;
 
159
        ESourceExtension *extension;
 
160
        SoupURI *soup_uri;
 
161
        const gchar *extension_name;
 
162
        gchar *user;
 
163
        gchar *host;
 
164
        gchar *path;
 
165
        gchar *query;
 
166
        guint port;
 
167
        gboolean secure;
 
168
 
 
169
        extension = E_SOURCE_EXTENSION (webdav_extension);
 
170
        source = e_source_extension_get_source (extension);
 
171
 
 
172
        g_object_get (
 
173
                extension,
 
174
                "resource-path", &path,
 
175
                "resource-query", &query,
 
176
                NULL);
 
177
 
 
178
        extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
 
179
        extension = e_source_get_extension (source, extension_name);
 
180
 
 
181
        g_object_get (
 
182
                extension,
 
183
                "user", &user,
 
184
                "host", &host,
 
185
                "port", &port,
 
186
                NULL);
 
187
 
 
188
        extension_name = E_SOURCE_EXTENSION_SECURITY;
 
189
        extension = e_source_get_extension (source, extension_name);
 
190
 
 
191
        g_object_get (
 
192
                extension,
 
193
                "secure", &secure,
 
194
                NULL);
 
195
 
 
196
        g_mutex_lock (webdav_extension->priv->property_lock);
 
197
 
 
198
        soup_uri = webdav_extension->priv->soup_uri;
 
199
 
 
200
        /* Try not to disturb the scheme, in case it's "webcal" or some
 
201
         * other non-standard value.  But if we have to change it, do it. */
 
202
        if (secure && soup_uri->scheme != SOUP_URI_SCHEME_HTTPS)
 
203
                soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTPS);
 
204
        if (!secure && soup_uri->scheme == SOUP_URI_SCHEME_HTTPS)
 
205
                soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTP);
 
206
 
 
207
        soup_uri_set_user (soup_uri, user);
 
208
        soup_uri_set_host (soup_uri, host);
 
209
        soup_uri_set_port (soup_uri, port);
 
210
 
 
211
        /* SoupURI doesn't like NULL paths. */
 
212
        soup_uri_set_path (soup_uri, (path != NULL) ? path : "");
 
213
 
 
214
        soup_uri_set_query (soup_uri, query);
 
215
 
 
216
        g_mutex_unlock (webdav_extension->priv->property_lock);
 
217
 
 
218
        g_free (user);
 
219
        g_free (host);
 
220
        g_free (path);
 
221
        g_free (query);
 
222
}
 
223
 
 
224
static void
291
225
source_webdav_set_property (GObject *object,
292
226
                            guint property_id,
293
227
                            const GValue *value,
330
264
                                g_value_get_string (value));
331
265
                        return;
332
266
 
 
267
                case PROP_RESOURCE_QUERY:
 
268
                        e_source_webdav_set_resource_query (
 
269
                                E_SOURCE_WEBDAV (object),
 
270
                                g_value_get_string (value));
 
271
                        return;
 
272
 
333
273
                case PROP_SOUP_URI:
334
274
                        e_source_webdav_set_soup_uri (
335
275
                                E_SOURCE_WEBDAV (object),
389
329
                                E_SOURCE_WEBDAV (object)));
390
330
                        return;
391
331
 
 
332
                case PROP_RESOURCE_QUERY:
 
333
                        g_value_take_string (
 
334
                                value,
 
335
                                e_source_webdav_dup_resource_query (
 
336
                                E_SOURCE_WEBDAV (object)));
 
337
                        return;
 
338
 
392
339
                case PROP_SOUP_URI:
393
340
                        g_value_take_boxed (
394
341
                                value,
412
359
        g_free (priv->display_name);
413
360
        g_free (priv->email_address);
414
361
        g_free (priv->resource_path);
 
362
        g_free (priv->resource_query);
415
363
 
416
 
        soup_uri_free (priv->uri);
 
364
        soup_uri_free (priv->soup_uri);
417
365
 
418
366
        /* Chain up to parent's finalize() method. */
419
367
        G_OBJECT_CLASS (e_source_webdav_parent_class)->finalize (object);
423
371
source_webdav_constructed (GObject *object)
424
372
{
425
373
        ESource *source;
426
 
        ESourceExtension *this_extension;
427
 
        ESourceExtension *other_extension;
 
374
        ESourceExtension *extension;
428
375
        const gchar *extension_name;
429
376
 
430
377
        /* Chain up to parent's constructed() method. */
431
378
        G_OBJECT_CLASS (e_source_webdav_parent_class)->constructed (object);
432
379
 
433
 
        this_extension = E_SOURCE_EXTENSION (object);
434
 
        source = e_source_extension_get_source (this_extension);
435
 
 
436
 
        g_object_bind_property_full (
437
 
                this_extension, "resource-path",
438
 
                this_extension, "soup-uri",
439
 
                G_BINDING_BIDIRECTIONAL |
440
 
                G_BINDING_SYNC_CREATE,
441
 
                source_webdav_path_to_soup_uri,
442
 
                source_webdav_soup_uri_to_path,
443
 
                NULL, (GDestroyNotify) NULL);
444
 
 
445
 
        /* Bind to properties of other extensions for convenience. */
 
380
        /* XXX I *think* we don't need to worry about disconnecting the
 
381
         *     signals.  ESourceExtensions are only added, never removed,
 
382
         *     and they all finalize with their ESource.  At least that's
 
383
         *     how it's supposed to work if everyone follows the rules. */
 
384
 
 
385
        extension = E_SOURCE_EXTENSION (object);
 
386
        source = e_source_extension_get_source (extension);
 
387
 
 
388
        g_signal_connect (
 
389
                extension, "notify::resource-path",
 
390
                G_CALLBACK (source_webdav_notify_cb), object);
 
391
 
 
392
        g_signal_connect (
 
393
                extension, "notify::resource-query",
 
394
                G_CALLBACK (source_webdav_notify_cb), object);
446
395
 
447
396
        extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
448
 
        other_extension = e_source_get_extension (source, extension_name);
449
 
 
450
 
        g_object_bind_property_full (
451
 
                other_extension, "host",
452
 
                this_extension, "soup-uri",
453
 
                G_BINDING_BIDIRECTIONAL |
454
 
                G_BINDING_SYNC_CREATE,
455
 
                source_webdav_host_to_soup_uri,
456
 
                source_webdav_soup_uri_to_host,
457
 
                NULL, (GDestroyNotify) NULL);
458
 
 
459
 
        g_object_bind_property_full (
460
 
                other_extension, "port",
461
 
                this_extension, "soup-uri",
462
 
                G_BINDING_BIDIRECTIONAL |
463
 
                G_BINDING_SYNC_CREATE,
464
 
                source_webdav_port_to_soup_uri,
465
 
                source_webdav_soup_uri_to_port,
466
 
                NULL, (GDestroyNotify) NULL);
467
 
 
468
 
        g_object_bind_property_full (
469
 
                other_extension, "user",
470
 
                this_extension, "soup-uri",
471
 
                G_BINDING_BIDIRECTIONAL |
472
 
                G_BINDING_SYNC_CREATE,
473
 
                source_webdav_user_to_soup_uri,
474
 
                source_webdav_soup_uri_to_user,
475
 
                NULL, (GDestroyNotify) NULL);
476
 
 
477
 
        g_object_bind_property_full (
478
 
                other_extension, "user",
479
 
                other_extension, "method",
 
397
        extension = e_source_get_extension (source, extension_name);
 
398
 
 
399
        g_signal_connect (
 
400
                extension, "notify::host",
 
401
                G_CALLBACK (source_webdav_notify_cb), object);
 
402
 
 
403
        g_signal_connect (
 
404
                extension, "notify::port",
 
405
                G_CALLBACK (source_webdav_notify_cb), object);
 
406
 
 
407
        g_signal_connect (
 
408
                extension, "notify::user",
 
409
                G_CALLBACK (source_webdav_notify_cb), object);
 
410
 
 
411
        /* This updates the authentication method
 
412
         * based on whether a user name was given. */
 
413
        g_object_bind_property_full (
 
414
                extension, "user",
 
415
                extension, "method",
480
416
                G_BINDING_SYNC_CREATE,
481
417
                source_webdav_user_to_method,
482
418
                NULL,
483
419
                NULL, (GDestroyNotify) NULL);
484
420
 
485
421
        extension_name = E_SOURCE_EXTENSION_SECURITY;
486
 
        other_extension = e_source_get_extension (source, extension_name);
 
422
        extension = e_source_get_extension (source, extension_name);
487
423
 
488
 
        g_object_bind_property_full (
489
 
                other_extension, "secure",
490
 
                this_extension, "soup-uri",
491
 
                G_BINDING_BIDIRECTIONAL |
492
 
                G_BINDING_SYNC_CREATE,
493
 
                source_webdav_secure_to_soup_uri,
494
 
                source_webdav_soup_uri_to_secure,
495
 
                NULL, (GDestroyNotify) NULL);
 
424
        g_signal_connect (
 
425
                extension, "notify::secure",
 
426
                G_CALLBACK (source_webdav_notify_cb), object);
496
427
}
497
428
 
498
429
static void
587
518
 
588
519
        g_object_class_install_property (
589
520
                object_class,
 
521
                PROP_RESOURCE_QUERY,
 
522
                g_param_spec_string (
 
523
                        "resource-query",
 
524
                        "Resource Query",
 
525
                        "Query to access a WebDAV resource",
 
526
                        NULL,
 
527
                        G_PARAM_READWRITE |
 
528
                        G_PARAM_CONSTRUCT |
 
529
                        E_SOURCE_PARAM_SETTING));
 
530
 
 
531
        g_object_class_install_property (
 
532
                object_class,
590
533
                PROP_SOUP_URI,
591
534
                g_param_spec_boxed (
592
535
                        "soup-uri",
603
546
        extension->priv->property_lock = g_mutex_new ();
604
547
 
605
548
        /* Initialize this enough for SOUP_URI_IS_VALID() to pass. */
606
 
        extension->priv->uri = soup_uri_new (NULL);
607
 
        extension->priv->uri->scheme = SOUP_URI_SCHEME_HTTP;
608
 
        extension->priv->uri->path = g_strdup ("");
 
549
        extension->priv->soup_uri = soup_uri_new (NULL);
 
550
        extension->priv->soup_uri->scheme = SOUP_URI_SCHEME_HTTP;
 
551
        extension->priv->soup_uri->path = g_strdup ("");
609
552
}
610
553
 
611
554
/**
661
604
{
662
605
        g_return_if_fail (E_IS_SOURCE_WEBDAV (extension));
663
606
 
664
 
        if ((extension->priv->avoid_ifmatch ? 1 : 0) == (avoid_ifmatch ? 1 : 0))
 
607
        if (extension->priv->avoid_ifmatch == avoid_ifmatch)
665
608
                return;
666
609
 
667
610
        extension->priv->avoid_ifmatch = avoid_ifmatch;
701
644
{
702
645
        g_return_if_fail (E_IS_SOURCE_WEBDAV (extension));
703
646
 
704
 
        if ((extension->priv->calendar_auto_schedule ? 1 : 0) == (calendar_auto_schedule ? 1 : 0))
 
647
        if (extension->priv->calendar_auto_schedule == calendar_auto_schedule)
705
648
                return;
706
649
 
707
650
        extension->priv->calendar_auto_schedule = calendar_auto_schedule;
921
864
{
922
865
        g_return_if_fail (E_IS_SOURCE_WEBDAV (extension));
923
866
 
924
 
        if ((extension->priv->ignore_invalid_cert ? 1 : 0) == (ignore_invalid_cert ? 1 : 0))
 
867
        if (extension->priv->ignore_invalid_cert == ignore_invalid_cert)
925
868
                return;
926
869
 
927
870
        extension->priv->ignore_invalid_cert = ignore_invalid_cert;
1014
957
}
1015
958
 
1016
959
/**
 
960
 * e_source_webdav_get_resource_query:
 
961
 * @extension: an #ESourceWebdav
 
962
 *
 
963
 * Returns the URI query required to access a resource on a WebDAV server.
 
964
 *
 
965
 * This is typically used when the #ESourceWebdav:resource-path points not
 
966
 * to the resource itself but to a web program that generates the resource
 
967
 * content on-the-fly.  The #ESourceWebdav:resource-query holds the input
 
968
 * values for the program.
 
969
 *
 
970
 * Returns: the query to access a WebDAV resource
 
971
 *
 
972
 * Since: 3.6
 
973
 **/
 
974
const gchar *
 
975
e_source_webdav_get_resource_query (ESourceWebdav *extension)
 
976
{
 
977
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (extension), NULL);
 
978
 
 
979
        return extension->priv->resource_query;
 
980
}
 
981
 
 
982
/**
 
983
 * e_source_webdav_dup_resource_query:
 
984
 * @extension: an #ESourceWebdav
 
985
 *
 
986
 * Thread-safe variation of e_source_webdav_get_resource_query().
 
987
 * Use this function when accessing @extension from multiple threads.
 
988
 *
 
989
 * The returned string should be freed with g_free() when no longer needed.
 
990
 *
 
991
 * Returns: the newly-allocated copy of #ESourceWebdav:resource-query
 
992
 *
 
993
 * Since: 3.6
 
994
 **/
 
995
gchar *
 
996
e_source_webdav_dup_resource_query (ESourceWebdav *extension)
 
997
{
 
998
        const gchar *protected;
 
999
        gchar *duplicate;
 
1000
 
 
1001
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (extension), NULL);
 
1002
 
 
1003
        g_mutex_lock (extension->priv->property_lock);
 
1004
 
 
1005
        protected = e_source_webdav_get_resource_query (extension);
 
1006
        duplicate = g_strdup (protected);
 
1007
 
 
1008
        g_mutex_unlock (extension->priv->property_lock);
 
1009
 
 
1010
        return duplicate;
 
1011
}
 
1012
 
 
1013
/**
 
1014
 * e_source_webdav_set_resource_query:
 
1015
 * @extension: an #ESourceWebdav
 
1016
 * @resource_query: (allow-none): the query to access a WebDAV resource,
 
1017
 *                  or %NULL
 
1018
 *
 
1019
 * Sets the URI query required to access a resource on a WebDAV server.
 
1020
 *
 
1021
 * This is typically used when the #ESourceWebdav:resource-path points not
 
1022
 * to the resource itself but to a web program that generates the resource
 
1023
 * content on-the-fly.  The #ESourceWebdav:resource-query holds the input
 
1024
 * values for the program.
 
1025
 *
 
1026
 * The internal copy of @resource_query is automatically stripped of leading
 
1027
 * and trailing whitespace.  If the resulting string is empty, %NULL is set
 
1028
 * instead.
 
1029
 *
 
1030
 * Since: 3.6
 
1031
 **/
 
1032
void
 
1033
e_source_webdav_set_resource_query (ESourceWebdav *extension,
 
1034
                                    const gchar *resource_query)
 
1035
{
 
1036
        g_return_if_fail (E_IS_SOURCE_WEBDAV (extension));
 
1037
 
 
1038
        g_mutex_lock (extension->priv->property_lock);
 
1039
 
 
1040
        if (g_strcmp0 (extension->priv->resource_query, resource_query) == 0) {
 
1041
                g_mutex_unlock (extension->priv->property_lock);
 
1042
                return;
 
1043
        }
 
1044
 
 
1045
        g_free (extension->priv->resource_query);
 
1046
        extension->priv->resource_query = e_util_strdup_strip (resource_query);
 
1047
 
 
1048
        g_mutex_unlock (extension->priv->property_lock);
 
1049
 
 
1050
        g_object_notify (G_OBJECT (extension), "resource-query");
 
1051
}
 
1052
 
 
1053
/**
1017
1054
 * e_source_webdav_dup_soup_uri:
1018
1055
 * @extension: an #ESourceWebdav
1019
1056
 *
1033
1070
 
1034
1071
        g_return_val_if_fail (E_IS_SOURCE_WEBDAV (extension), NULL);
1035
1072
 
 
1073
        /* Keep this outside of the property lock. */
 
1074
        source_webdav_update_soup_uri_from_properties (extension);
 
1075
 
1036
1076
        g_mutex_lock (extension->priv->property_lock);
1037
1077
 
1038
 
        duplicate = soup_uri_copy (extension->priv->uri);
 
1078
        duplicate = soup_uri_copy (extension->priv->soup_uri);
1039
1079
 
1040
1080
        g_mutex_unlock (extension->priv->property_lock);
1041
1081
 
1045
1085
/**
1046
1086
 * e_source_webdav_set_soup_uri:
1047
1087
 * @extension: an #ESourceWebdav
1048
 
 * @uri: a #SoupURI
 
1088
 * @soup_uri: a #SoupURI
1049
1089
 *
1050
1090
 * This is a convenience function which propagates the components of
1051
1091
 * @uri to the #ESourceAuthentication extension, the #ESourceSecurity
1052
 
 * extension, and @extension itself.  (The "query" and "fragment"
1053
 
 * components of @uri are ignored.)
 
1092
 * extension, and @extension itself.  (The "fragment" component of
 
1093
 * @uri is ignored.)
1054
1094
 *
1055
1095
 * Since: 3.6
1056
1096
 **/
1057
1097
void
1058
1098
e_source_webdav_set_soup_uri (ESourceWebdav *extension,
1059
 
                              SoupURI *uri)
 
1099
                              SoupURI *soup_uri)
1060
1100
{
1061
1101
        g_return_if_fail (E_IS_SOURCE_WEBDAV (extension));
1062
 
        g_return_if_fail (SOUP_URI_IS_VALID (uri));
 
1102
        g_return_if_fail (SOUP_URI_IS_VALID (soup_uri));
1063
1103
 
1064
1104
        g_mutex_lock (extension->priv->property_lock);
1065
1105
 
1066
 
        if (extension->priv->uri && soup_uri_equal (extension->priv->uri, uri)) {
1067
 
                g_mutex_unlock (extension->priv->property_lock);
1068
 
                return;
1069
 
        }
 
1106
        /* Do not test for URI equality because our
 
1107
         * internal SoupURI might not be up-to-date. */
1070
1108
 
1071
 
        soup_uri_free (extension->priv->uri);
1072
 
        extension->priv->uri = soup_uri_copy (uri);
 
1109
        soup_uri_free (extension->priv->soup_uri);
 
1110
        extension->priv->soup_uri = soup_uri_copy (soup_uri);
1073
1111
 
1074
1112
        g_mutex_unlock (extension->priv->property_lock);
1075
1113
 
 
1114
        g_object_freeze_notify (G_OBJECT (extension));
 
1115
        source_webdav_update_properties_from_soup_uri (extension);
1076
1116
        g_object_notify (G_OBJECT (extension), "soup-uri");
 
1117
        g_object_thaw_notify (G_OBJECT (extension));
1077
1118
}
1078
1119