[evolution-kolab/EDS_IMAPX_nobuild] updated IMAPX files as of EVOLUTION_DATA_SERVER_3_3_4
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/EDS_IMAPX_nobuild] updated IMAPX files as of EVOLUTION_DATA_SERVER_3_3_4
- Date: Mon, 16 Jan 2012 18:52:49 +0000 (UTC)
commit 82f5748f42f234cb397da5b245ede0bde7e6a0b8
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon Jan 16 19:37:45 2012 +0100
updated IMAPX files as of EVOLUTION_DATA_SERVER_3_3_4
* updated the local IMAPX code from upstream
* now at version EVOLUTION_DATA_SERVER_3_3_4
src/camel/providers/imapx/camel-imapx-server.c | 101 +++++++++++++++-------
src/camel/providers/imapx/camel-imapx-settings.c | 94 ++++++++++++++++++--
src/camel/providers/imapx/camel-imapx-settings.h | 4 +
src/camel/providers/imapx/camel-imapx-store.c | 24 ++++--
4 files changed, 172 insertions(+), 51 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 9ca9623..0781b64 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -2354,7 +2354,7 @@ imapx_run_job (CamelIMAPXServer *is,
CamelIMAPXJob *job,
GError **error)
{
- gulong cancel_id;
+ gulong cancel_id = 0;
g_warn_if_fail (job->done_flag == FALSE);
@@ -3004,8 +3004,8 @@ connect_to_server_process (CamelIMAPXServer *is,
gchar *full_cmd;
gchar *child_env[7];
const gchar *password;
- const gchar *host;
- const gchar *user;
+ gchar *host;
+ gchar *user;
guint16 port;
memset (&url, 0, sizeof (CamelURL));
@@ -3017,9 +3017,9 @@ connect_to_server_process (CamelIMAPXServer *is,
g_return_val_if_fail (password != NULL, FALSE);
network_settings = CAMEL_NETWORK_SETTINGS (settings);
- host = camel_network_settings_get_host (network_settings);
+ host = camel_network_settings_dup_host (network_settings);
port = camel_network_settings_get_port (network_settings);
- user = camel_network_settings_get_user (network_settings);
+ user = camel_network_settings_dup_user (network_settings);
/* Put full details in the environment, in case the connection
* program needs them */
@@ -3086,6 +3086,9 @@ connect_to_server_process (CamelIMAPXServer *is,
g_free (cmd_copy);
+ g_free (host);
+ g_free (user);
+
cmd_stream = camel_stream_process_new ();
ret = camel_stream_process_connect (
@@ -3126,19 +3129,20 @@ imapx_connect_to_server (CamelIMAPXServer *is,
guchar *token;
gint tok;
CamelIMAPXCommand *ic;
- const gchar *host;
+ gboolean success = TRUE;
+ gchar *host;
GError *local_error = NULL;
#ifndef G_OS_WIN32
gboolean use_shell_command;
- const gchar *command = NULL;
+ gchar *shell_command = NULL;
#endif
service = CAMEL_SERVICE (is->store);
settings = camel_service_get_settings (service);
network_settings = CAMEL_NETWORK_SETTINGS (settings);
- host = camel_network_settings_get_host (network_settings);
+ host = camel_network_settings_dup_host (network_settings);
method = camel_network_settings_get_security_method (network_settings);
#ifndef G_OS_WIN32
@@ -3146,22 +3150,31 @@ imapx_connect_to_server (CamelIMAPXServer *is,
CAMEL_IMAPX_SETTINGS (settings));
if (use_shell_command)
- command = camel_imapx_settings_get_shell_command (
+ shell_command = camel_imapx_settings_dup_shell_command (
CAMEL_IMAPX_SETTINGS (settings));
- if (command != NULL) {
- if (!connect_to_server_process (is, command, &local_error))
- goto exit;
- else
+ if (shell_command != NULL) {
+ gboolean success;
+
+ success = connect_to_server_process (
+ is, shell_command, &local_error);
+
+ g_free (shell_command);
+
+ if (success)
goto connected;
+ else
+ goto exit;
}
#endif
tcp_stream = camel_network_service_connect_sync (
CAMEL_NETWORK_SERVICE (is->store), cancellable, error);
- if (tcp_stream == NULL)
- return FALSE;
+ if (tcp_stream == NULL) {
+ success = FALSE;
+ goto exit;
+ }
is->stream = (CamelIMAPXStream *) camel_imapx_stream_new (tcp_stream);
g_object_unref (tcp_stream);
@@ -3185,20 +3198,25 @@ imapx_connect_to_server (CamelIMAPXServer *is,
error, G_IO_ERROR,
G_IO_ERROR_CANCELLED,
"Connection to server cancelled\n");
- return FALSE;
+ success = FALSE;
+ goto exit;
}
tok = camel_imapx_stream_token (is->stream, &token, &len, cancellable, error);
- if (tok < 0)
- return FALSE;
+ if (tok < 0) {
+ success = FALSE;
+ goto exit;
+ }
if (tok == '*') {
imapx_untagged (is, cancellable, error);
break;
}
camel_imapx_stream_ungettoken (is->stream, tok, token, len);
- if (camel_imapx_stream_text (is->stream, &token, cancellable, error))
- return FALSE;
+ if (camel_imapx_stream_text (is->stream, &token, cancellable, error)) {
+ success = FALSE;
+ goto exit;
+ }
e(is->tagprefix, "Got unexpected line before greeting: '%s'\n", token);
g_free (token);
}
@@ -3221,7 +3239,9 @@ imapx_connect_to_server (CamelIMAPXServer *is,
}
imapx_command_unref (ic);
- return FALSE;
+ success = FALSE;
+
+ goto exit;
}
imapx_command_unref (ic);
}
@@ -3307,10 +3327,12 @@ exit:
is->cinfo = NULL;
}
- return FALSE;
+ success = FALSE;
}
- return TRUE;
+ g_free (host);
+
+ return success;
}
CamelAuthenticationResult
@@ -3325,8 +3347,8 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
CamelIMAPXCommand *ic;
CamelService *service;
CamelSasl *sasl = NULL;
- const gchar *host;
- const gchar *user;
+ gchar *host;
+ gchar *user;
g_return_val_if_fail (
CAMEL_IS_IMAPX_SERVER (is),
@@ -3336,8 +3358,8 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
settings = camel_service_get_settings (service);
network_settings = CAMEL_NETWORK_SETTINGS (settings);
- host = camel_network_settings_get_host (network_settings);
- user = camel_network_settings_get_user (network_settings);
+ host = camel_network_settings_dup_host (network_settings);
+ user = camel_network_settings_dup_user (network_settings);
if (mechanism != NULL) {
if (!g_hash_table_lookup (is->cinfo->auth_types, mechanism)) {
@@ -3346,7 +3368,8 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("IMAP server %s does not support %s "
"authentication"), host, mechanism);
- return CAMEL_AUTHENTICATION_ERROR;
+ result = CAMEL_AUTHENTICATION_ERROR;
+ goto exit;
}
sasl = camel_sasl_new ("imap", mechanism, service);
@@ -3356,7 +3379,8 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("No support for %s authentication"),
mechanism);
- return CAMEL_AUTHENTICATION_ERROR;
+ result = CAMEL_AUTHENTICATION_ERROR;
+ goto exit;
}
}
@@ -3374,7 +3398,8 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Cannot authenticate without a username"));
- return CAMEL_AUTHENTICATION_ERROR;
+ result = CAMEL_AUTHENTICATION_ERROR;
+ goto exit;
}
if (password == NULL) {
@@ -3382,7 +3407,8 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Authentication password not available"));
- return CAMEL_AUTHENTICATION_ERROR;
+ result = CAMEL_AUTHENTICATION_ERROR;
+ goto exit;
}
ic = imapx_command_new (
@@ -3422,6 +3448,10 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
if (sasl != NULL)
g_object_unref (sasl);
+exit:
+ g_free (host);
+ g_free (user);
+
return result;
}
@@ -3434,7 +3464,7 @@ imapx_reconnect (CamelIMAPXServer *is,
CamelService *service;
CamelSession *session;
CamelSettings *settings;
- const gchar *mechanism;
+ gchar *mechanism;
gboolean use_idle;
gboolean use_qresync;
@@ -3442,7 +3472,7 @@ imapx_reconnect (CamelIMAPXServer *is,
session = camel_service_get_session (service);
settings = camel_service_get_settings (service);
- mechanism = camel_network_settings_get_auth_mechanism (
+ mechanism = camel_network_settings_dup_auth_mechanism (
CAMEL_NETWORK_SETTINGS (settings));
use_idle = camel_imapx_settings_get_use_idle (
@@ -3535,6 +3565,9 @@ imapx_reconnect (CamelIMAPXServer *is,
}
is->state = IMAPX_INITIALISED;
+
+ g_free (mechanism);
+
return TRUE;
exception:
@@ -3546,6 +3579,8 @@ exception:
is->cinfo = NULL;
}
+ g_free (mechanism);
+
return FALSE;
}
diff --git a/src/camel/providers/imapx/camel-imapx-settings.c b/src/camel/providers/imapx/camel-imapx-settings.c
index d880a0e..0ffdc46 100644
--- a/src/camel/providers/imapx/camel-imapx-settings.c
+++ b/src/camel/providers/imapx/camel-imapx-settings.c
@@ -26,6 +26,7 @@
((obj), CAMEL_TYPE_IMAPX_SETTINGS, CamelIMAPXSettingsPrivate))
struct _CamelIMAPXSettingsPrivate {
+ GMutex *property_lock;
gchar *namespace;
gchar *shell_command;
@@ -208,9 +209,9 @@ imapx_settings_get_property (GObject *object,
{
switch (property_id) {
case PROP_AUTH_MECHANISM:
- g_value_set_string (
+ g_value_take_string (
value,
- camel_network_settings_get_auth_mechanism (
+ camel_network_settings_dup_auth_mechanism (
CAMEL_NETWORK_SETTINGS (object)));
return;
@@ -264,16 +265,16 @@ imapx_settings_get_property (GObject *object,
return;
case PROP_HOST:
- g_value_set_string (
+ g_value_take_string (
value,
- camel_network_settings_get_host (
+ camel_network_settings_dup_host (
CAMEL_NETWORK_SETTINGS (object)));
return;
case PROP_NAMESPACE:
- g_value_set_string (
+ g_value_take_string (
value,
- camel_imapx_settings_get_namespace (
+ camel_imapx_settings_dup_namespace (
CAMEL_IMAPX_SETTINGS (object)));
return;
@@ -292,16 +293,16 @@ imapx_settings_get_property (GObject *object,
return;
case PROP_SHELL_COMMAND:
- g_value_set_string (
+ g_value_take_string (
value,
- camel_imapx_settings_get_shell_command (
+ camel_imapx_settings_dup_shell_command (
CAMEL_IMAPX_SETTINGS (object)));
return;
case PROP_USER:
- g_value_set_string (
+ g_value_take_string (
value,
- camel_network_settings_get_user (
+ camel_network_settings_dup_user (
CAMEL_NETWORK_SETTINGS (object)));
return;
@@ -351,6 +352,8 @@ imapx_settings_finalize (GObject *object)
priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (object);
+ g_mutex_free (priv->property_lock);
+
g_free (priv->namespace);
g_free (priv->shell_command);
@@ -579,6 +582,7 @@ static void
camel_imapx_settings_init (CamelIMAPXSettings *settings)
{
settings->priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (settings);
+ settings->priv->property_lock = g_mutex_new ();
}
/**
@@ -891,6 +895,37 @@ camel_imapx_settings_get_namespace (CamelIMAPXSettings *settings)
}
/**
+ * camel_imapx_settings_dup_namespace:
+ * @settings: a #CamelIMAPXSettings
+ *
+ * Thread-safe variation of camel_imapx_settings_get_namespace().
+ * Use this function when accessing @settings from a worker thread.
+ *
+ * The returned string should be freed with g_free() when no longer needed.
+ *
+ * Returns: a newly-allocated copy of #CamelIMAPXSettings:namespace
+ *
+ * Since: 3.4
+ **/
+gchar *
+camel_imapx_settings_dup_namespace (CamelIMAPXSettings *settings)
+{
+ const gchar *protected;
+ gchar *duplicate;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
+
+ g_mutex_lock (settings->priv->property_lock);
+
+ protected = camel_imapx_settings_get_namespace (settings);
+ duplicate = g_strdup (protected);
+
+ g_mutex_unlock (settings->priv->property_lock);
+
+ return duplicate;
+}
+
+/**
* camel_imapx_settings_set_namespace:
* @settings: a #CamelIMAPXSettings
* @namespace: an IMAP namespace, or %NULL
@@ -910,9 +945,13 @@ camel_imapx_settings_set_namespace (CamelIMAPXSettings *settings,
if (namespace == NULL)
namespace = "";
+ g_mutex_lock (settings->priv->property_lock);
+
g_free (settings->priv->namespace);
settings->priv->namespace = g_strdup (namespace);
+ g_mutex_unlock (settings->priv->property_lock);
+
g_object_notify (G_OBJECT (settings), "namespace");
}
@@ -942,6 +981,37 @@ camel_imapx_settings_get_shell_command (CamelIMAPXSettings *settings)
}
/**
+ * camel_imapx_settings_dup_shell_command:
+ * @settings: a #CamelIMAPXSettings
+ *
+ * Thread-safe variation of camel_imapx_settings_get_shell_command().
+ * Use this function when accessing @settings from a worker thread.
+ *
+ * The returned string should be freed with g_free() when no longer needed.
+ *
+ * Returns: a newly-allocated copy of #CamelIMAPXSettings:shell-command
+ *
+ * Since: 3.4
+ **/
+gchar *
+camel_imapx_settings_dup_shell_command (CamelIMAPXSettings *settings)
+{
+ const gchar *protected;
+ gchar *duplicate;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
+
+ g_mutex_lock (settings->priv->property_lock);
+
+ protected = camel_imapx_settings_get_shell_command (settings);
+ duplicate = g_strdup (protected);
+
+ g_mutex_unlock (settings->priv->property_lock);
+
+ return duplicate;
+}
+
+/**
* camel_imapx_settings_set_shell_command:
* @settings: a #CamelIMAPXSettings
* @shell_command: shell command for connecting to the server, or %NULL
@@ -967,9 +1037,13 @@ camel_imapx_settings_set_shell_command (CamelIMAPXSettings *settings,
if (shell_command != NULL && *shell_command == '\0')
shell_command = NULL;
+ g_mutex_lock (settings->priv->property_lock);
+
g_free (settings->priv->shell_command);
settings->priv->shell_command = g_strdup (shell_command);
+ g_mutex_unlock (settings->priv->property_lock);
+
g_object_notify (G_OBJECT (settings), "shell-command");
}
diff --git a/src/camel/providers/imapx/camel-imapx-settings.h b/src/camel/providers/imapx/camel-imapx-settings.h
index e63a01a..54f810c 100644
--- a/src/camel/providers/imapx/camel-imapx-settings.h
+++ b/src/camel/providers/imapx/camel-imapx-settings.h
@@ -93,11 +93,15 @@ void camel_imapx_settings_set_filter_junk_inbox
gboolean filter_junk_inbox);
const gchar * camel_imapx_settings_get_namespace
(CamelIMAPXSettings *settings);
+gchar * camel_imapx_settings_dup_namespace
+ (CamelIMAPXSettings *settings);
void camel_imapx_settings_set_namespace
(CamelIMAPXSettings *settings,
const gchar *namespace_);
const gchar * camel_imapx_settings_get_shell_command
(CamelIMAPXSettings *settings);
+gchar * camel_imapx_settings_dup_shell_command
+ (CamelIMAPXSettings *settings);
void camel_imapx_settings_set_shell_command
(CamelIMAPXSettings *settings,
const gchar *shell_command);
diff --git a/src/camel/providers/imapx/camel-imapx-store.c b/src/camel/providers/imapx/camel-imapx-store.c
index c8cb019..1cc4b1f 100644
--- a/src/camel/providers/imapx/camel-imapx-store.c
+++ b/src/camel/providers/imapx/camel-imapx-store.c
@@ -140,21 +140,27 @@ imapx_get_name (CamelService *service,
{
CamelNetworkSettings *network_settings;
CamelSettings *settings;
- const gchar *host;
- const gchar *user;
+ gchar *host;
+ gchar *user;
+ gchar *name;
settings = camel_service_get_settings (service);
network_settings = CAMEL_NETWORK_SETTINGS (settings);
- host = camel_network_settings_get_host (network_settings);
- user = camel_network_settings_get_user (network_settings);
+ host = camel_network_settings_dup_host (network_settings);
+ user = camel_network_settings_dup_user (network_settings);
if (brief)
- return g_strdup_printf (
+ name = g_strdup_printf (
_("IMAP server %s"), host);
else
- return g_strdup_printf (
+ name = g_strdup_printf (
_("IMAP service for %s on %s"), user, host);
+
+ g_free (host);
+ g_free (user);
+
+ return name;
}
CamelIMAPXServer *
@@ -692,10 +698,10 @@ get_folder_info_offline (CamelStore *store,
/* get starting point */
if (top[0] == 0) {
- const gchar *namespace = NULL;
+ gchar *namespace = NULL;
if (use_namespace)
- namespace = camel_imapx_settings_get_namespace (
+ namespace = camel_imapx_settings_dup_namespace (
CAMEL_IMAPX_SETTINGS (settings));
if (namespace != NULL) {
@@ -703,6 +709,8 @@ get_folder_info_offline (CamelStore *store,
top = imapx_store->summary->namespaces->personal->path;
} else
name = g_strdup("");
+
+ g_free (namespace);
} else {
name = camel_imapx_store_summary_full_from_path (imapx_store->summary, top);
if (name == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]