[evolution-kolab/ek-wip-acl] CamelIMAPXExtdServerMetadata: use command runner util function
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-acl] CamelIMAPXExtdServerMetadata: use command runner util function
- Date: Fri, 28 Sep 2012 13:40:30 +0000 (UTC)
commit 899395c022f75bc4e2e558bc69e25166e84c058a
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Sep 28 15:27:26 2012 +0200
CamelIMAPXExtdServerMetadata: use command runner util function
* avoids some code dupe
* same pattern will be followed in the ACL code
src/libekolab/camel-imapx-extd-server-metadata.c | 55 +++++++---------------
1 files changed, 18 insertions(+), 37 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-server-metadata.c b/src/libekolab/camel-imapx-extd-server-metadata.c
index fbac613..393198b 100644
--- a/src/libekolab/camel-imapx-extd-server-metadata.c
+++ b/src/libekolab/camel-imapx-extd-server-metadata.c
@@ -34,6 +34,9 @@
#include "camel-imapx-extd-store.h"
#include "camel-imapx-extd-store-friend.h"
#include "camel-imapx-extd-server.h"
+#include "camel-imapx-extd-utils.h"
+
+#include "camel-imapx-extd-server-metadata.h"
/*----------------------------------------------------------------------------*/
@@ -59,7 +62,7 @@ imapx_extd_server_untagged_annotation (CamelIMAPXServer *is,
GError **err)
{
static GMutex handler_lock;
- CamelIMAPXStore *store;
+ CamelIMAPXStore *store = NULL;
CamelIMAPXExtdStore *estore = NULL;
CamelImapxMetadata *md = NULL;
guint32 capa = 0;
@@ -73,7 +76,7 @@ imapx_extd_server_untagged_annotation (CamelIMAPXServer *is,
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
g_mutex_lock (&handler_lock);
-
+
store = camel_imapx_server_ref_store (is);
estore = CAMEL_IMAPX_EXTD_STORE (store);
@@ -108,7 +111,7 @@ exit:
g_object_unref (store);
g_mutex_unlock (&handler_lock);
-
+
return success;
}
@@ -129,8 +132,6 @@ camel_imapx_extd_server_get_metadata (CamelIMAPXServer *is,
GCancellable *cancellable,
GError **err)
{
- static GMutex getter_lock;
- CamelIMAPXCommand *ic = NULL;
gchar *cmd = NULL;
GError *tmp_err = NULL;
gboolean ok = FALSE;
@@ -140,8 +141,6 @@ camel_imapx_extd_server_get_metadata (CamelIMAPXServer *is,
/* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
- g_mutex_lock (&getter_lock);
-
/* TODO move GETANNOTATION string to -metadata.[hc]
* (add a function to return proper string depending
* on protocol type)
@@ -152,24 +151,17 @@ camel_imapx_extd_server_get_metadata (CamelIMAPXServer *is,
spec->entry_name,
spec->attrib_name);
- ic = camel_imapx_command_new (is,
- IMAPX_IMAP_TOKEN_GETANNOTATION,
- NULL,
- cmd);
-
/* run GETANNOTATION command */
- ok = camel_imapx_server_command_run (is,
- ic,
- cancellable,
- &tmp_err);
+ ok = camel_imapx_extd_utils_command_run (is,
+ IMAPX_IMAP_TOKEN_GETANNOTATION,
+ cmd,
+ cancellable,
+ &tmp_err);
g_free (cmd);
- camel_imapx_command_unref (ic);
if (! ok)
g_propagate_error (err, tmp_err);
- g_mutex_unlock (&getter_lock);
-
return ok;
}
@@ -180,7 +172,6 @@ camel_imapx_extd_server_set_metadata (CamelIMAPXServer *is,
GError **err)
{
static GMutex setter_lock;
- CamelIMAPXCommand *ic = NULL;
GSList *commands = NULL;
GSList *cur_cmd = NULL;
GError *tmp_err = NULL;
@@ -204,21 +195,11 @@ camel_imapx_extd_server_set_metadata (CamelIMAPXServer *is,
* (add a function to return proper string depending
* on protocol type)
*/
- ic = camel_imapx_command_new (is,
- IMAPX_IMAP_TOKEN_SETANNOTATION,
- NULL,
- (gchar *) cur_cmd->data);
-
- /* TODO set more job details like priority? */
-
- /* run SETANNOTATION command */
- ok = camel_imapx_server_command_run (is,
- ic,
- cancellable,
- &tmp_err);
-
- camel_imapx_command_unref (ic);
-
+ ok = camel_imapx_extd_utils_command_run (is,
+ IMAPX_IMAP_TOKEN_SETANNOTATION,
+ (gchar *) cur_cmd->data,
+ cancellable,
+ &tmp_err);
if (! ok)
goto exit;
@@ -232,9 +213,9 @@ camel_imapx_extd_server_set_metadata (CamelIMAPXServer *is,
}
if (commands != NULL)
g_slist_free (commands);
-
+
g_mutex_unlock (&setter_lock);
-
+
return ok;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]