82
84
E_TYPE_SOURCE_EXTENSION)
85
source_webdav_host_to_soup_uri (GBinding *binding,
86
const GValue *source_value,
94
host = g_value_get_string (source_value);
96
target = g_binding_get_target (binding);
97
g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
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);
107
source_webdav_soup_uri_to_host (GBinding *binding,
108
const GValue *source_value,
109
GValue *target_value,
114
soup_uri = g_value_get_boxed (source_value);
115
g_value_set_string (target_value, soup_uri->host);
121
source_webdav_path_to_soup_uri (GBinding *binding,
122
const GValue *source_value,
123
GValue *target_value,
130
path = g_value_get_string (source_value);
132
/* soup_uri_set_path() warns on NULL. */
136
target = g_binding_get_target (binding);
137
g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
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);
147
source_webdav_soup_uri_to_path (GBinding *binding,
148
const GValue *source_value,
149
GValue *target_value,
154
soup_uri = g_value_get_boxed (source_value);
155
g_value_set_string (target_value, soup_uri->path);
161
source_webdav_port_to_soup_uri (GBinding *binding,
162
const GValue *source_value,
163
GValue *target_value,
170
port = g_value_get_uint (source_value);
172
target = g_binding_get_target (binding);
173
g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
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);
183
source_webdav_soup_uri_to_port (GBinding *binding,
184
const GValue *source_value,
185
GValue *target_value,
190
soup_uri = g_value_get_boxed (source_value);
191
g_value_set_uint (target_value, soup_uri->port);
197
source_webdav_secure_to_soup_uri (GBinding *binding,
198
const GValue *source_value,
199
GValue *target_value,
206
secure = g_value_get_boolean (source_value);
208
target = g_binding_get_target (binding);
209
g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
211
soup_uri = e_source_webdav_dup_soup_uri (E_SOURCE_WEBDAV (target));
213
soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTPS);
215
soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTP);
216
g_value_take_boxed (target_value, soup_uri);
222
source_webdav_soup_uri_to_secure (GBinding *binding,
223
const GValue *source_value,
224
GValue *target_value,
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);
238
source_webdav_user_to_soup_uri (GBinding *binding,
239
const GValue *source_value,
240
GValue *target_value,
247
user = g_value_get_string (source_value);
249
target = g_binding_get_target (binding);
250
g_return_val_if_fail (E_IS_SOURCE_WEBDAV (target), FALSE);
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);
260
source_webdav_soup_uri_to_user (GBinding *binding,
261
const GValue *source_value,
262
GValue *target_value,
267
soup_uri = g_value_get_boxed (source_value);
268
g_value_set_string (target_value, soup_uri->user);
87
source_webdav_notify_cb (GObject *object,
89
ESourceWebdav *extension)
91
g_object_notify (G_OBJECT (extension), "soup-uri");
112
source_webdav_update_properties_from_soup_uri (ESourceWebdav *webdav_extension)
115
ESourceExtension *extension;
117
const gchar *extension_name;
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);
125
extension = E_SOURCE_EXTENSION (webdav_extension);
126
source = e_source_extension_get_source (extension);
130
"resource-path", soup_uri->path,
131
"resource-query", soup_uri->query,
134
extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
135
extension = e_source_get_extension (source, extension_name);
139
"host", soup_uri->host,
140
"port", soup_uri->port,
141
"user", soup_uri->user,
144
extension_name = E_SOURCE_EXTENSION_SECURITY;
145
extension = e_source_get_extension (source, extension_name);
149
"secure", (soup_uri->scheme == SOUP_URI_SCHEME_HTTPS),
152
soup_uri_free (soup_uri);
156
source_webdav_update_soup_uri_from_properties (ESourceWebdav *webdav_extension)
159
ESourceExtension *extension;
161
const gchar *extension_name;
169
extension = E_SOURCE_EXTENSION (webdav_extension);
170
source = e_source_extension_get_source (extension);
174
"resource-path", &path,
175
"resource-query", &query,
178
extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
179
extension = e_source_get_extension (source, extension_name);
188
extension_name = E_SOURCE_EXTENSION_SECURITY;
189
extension = e_source_get_extension (source, extension_name);
196
g_mutex_lock (webdav_extension->priv->property_lock);
198
soup_uri = webdav_extension->priv->soup_uri;
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);
207
soup_uri_set_user (soup_uri, user);
208
soup_uri_set_host (soup_uri, host);
209
soup_uri_set_port (soup_uri, port);
211
/* SoupURI doesn't like NULL paths. */
212
soup_uri_set_path (soup_uri, (path != NULL) ? path : "");
214
soup_uri_set_query (soup_uri, query);
216
g_mutex_unlock (webdav_extension->priv->property_lock);
291
225
source_webdav_set_property (GObject *object,
292
226
guint property_id,
293
227
const GValue *value,
423
371
source_webdav_constructed (GObject *object)
426
ESourceExtension *this_extension;
427
ESourceExtension *other_extension;
374
ESourceExtension *extension;
428
375
const gchar *extension_name;
430
377
/* Chain up to parent's constructed() method. */
431
378
G_OBJECT_CLASS (e_source_webdav_parent_class)->constructed (object);
433
this_extension = E_SOURCE_EXTENSION (object);
434
source = e_source_extension_get_source (this_extension);
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);
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. */
385
extension = E_SOURCE_EXTENSION (object);
386
source = e_source_extension_get_source (extension);
389
extension, "notify::resource-path",
390
G_CALLBACK (source_webdav_notify_cb), object);
393
extension, "notify::resource-query",
394
G_CALLBACK (source_webdav_notify_cb), object);
447
396
extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
448
other_extension = e_source_get_extension (source, extension_name);
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);
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);
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);
477
g_object_bind_property_full (
478
other_extension, "user",
479
other_extension, "method",
397
extension = e_source_get_extension (source, extension_name);
400
extension, "notify::host",
401
G_CALLBACK (source_webdav_notify_cb), object);
404
extension, "notify::port",
405
G_CALLBACK (source_webdav_notify_cb), object);
408
extension, "notify::user",
409
G_CALLBACK (source_webdav_notify_cb), object);
411
/* This updates the authentication method
412
* based on whether a user name was given. */
413
g_object_bind_property_full (
480
416
G_BINDING_SYNC_CREATE,
481
417
source_webdav_user_to_method,
483
419
NULL, (GDestroyNotify) NULL);
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);
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);
425
extension, "notify::secure",
426
G_CALLBACK (source_webdav_notify_cb), object);
960
* e_source_webdav_get_resource_query:
961
* @extension: an #ESourceWebdav
963
* Returns the URI query required to access a resource on a WebDAV server.
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.
970
* Returns: the query to access a WebDAV resource
975
e_source_webdav_get_resource_query (ESourceWebdav *extension)
977
g_return_val_if_fail (E_IS_SOURCE_WEBDAV (extension), NULL);
979
return extension->priv->resource_query;
983
* e_source_webdav_dup_resource_query:
984
* @extension: an #ESourceWebdav
986
* Thread-safe variation of e_source_webdav_get_resource_query().
987
* Use this function when accessing @extension from multiple threads.
989
* The returned string should be freed with g_free() when no longer needed.
991
* Returns: the newly-allocated copy of #ESourceWebdav:resource-query
996
e_source_webdav_dup_resource_query (ESourceWebdav *extension)
998
const gchar *protected;
1001
g_return_val_if_fail (E_IS_SOURCE_WEBDAV (extension), NULL);
1003
g_mutex_lock (extension->priv->property_lock);
1005
protected = e_source_webdav_get_resource_query (extension);
1006
duplicate = g_strdup (protected);
1008
g_mutex_unlock (extension->priv->property_lock);
1014
* e_source_webdav_set_resource_query:
1015
* @extension: an #ESourceWebdav
1016
* @resource_query: (allow-none): the query to access a WebDAV resource,
1019
* Sets the URI query required to access a resource on a WebDAV server.
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.
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
1033
e_source_webdav_set_resource_query (ESourceWebdav *extension,
1034
const gchar *resource_query)
1036
g_return_if_fail (E_IS_SOURCE_WEBDAV (extension));
1038
g_mutex_lock (extension->priv->property_lock);
1040
if (g_strcmp0 (extension->priv->resource_query, resource_query) == 0) {
1041
g_mutex_unlock (extension->priv->property_lock);
1045
g_free (extension->priv->resource_query);
1046
extension->priv->resource_query = e_util_strdup_strip (resource_query);
1048
g_mutex_unlock (extension->priv->property_lock);
1050
g_object_notify (G_OBJECT (extension), "resource-query");
1017
1054
* e_source_webdav_dup_soup_uri:
1018
1055
* @extension: an #ESourceWebdav
1046
1086
* e_source_webdav_set_soup_uri:
1047
1087
* @extension: an #ESourceWebdav
1088
* @soup_uri: a #SoupURI
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
1058
1098
e_source_webdav_set_soup_uri (ESourceWebdav *extension,
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));
1064
1104
g_mutex_lock (extension->priv->property_lock);
1066
if (extension->priv->uri && soup_uri_equal (extension->priv->uri, uri)) {
1067
g_mutex_unlock (extension->priv->property_lock);
1106
/* Do not test for URI equality because our
1107
* internal SoupURI might not be up-to-date. */
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);
1074
1112
g_mutex_unlock (extension->priv->property_lock);
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));