[evolution-kolab/ek-wip-porting: 2/3] CamelImapxMetadata: added API for setting protocol type
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting: 2/3] CamelImapxMetadata: added API for setting protocol type
- Date: Thu, 19 Jul 2012 14:23:05 +0000 (UTC)
commit 942faf6d6f190c5dd6aca667d5b28a611482db15
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Thu Jul 19 15:40:27 2012 +0200
CamelImapxMetadata: added API for setting protocol type
* added function to set the metadata protocol type
on an already-created CamelImapxMetadata instance
* minor code cleanup
src/libekolab/camel-imapx-metadata.c | 38 +++++++++++++++++++++++++++++----
src/libekolab/camel-imapx-metadata.h | 4 +++
2 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-metadata.c b/src/libekolab/camel-imapx-metadata.c
index 8434569..2671a39 100644
--- a/src/libekolab/camel-imapx-metadata.c
+++ b/src/libekolab/camel-imapx-metadata.c
@@ -209,20 +209,48 @@ camel_imapx_metadata_resect (CamelImapxMetadata **md)
camel_imapx_metadata_proto_t
camel_imapx_metadata_get_proto (CamelImapxMetadata *md)
{
- camel_imapx_metadata_proto_t mp = CAMEL_IMAPX_METADATA_PROTO_INVAL;
+ camel_imapx_metadata_proto_t proto = CAMEL_IMAPX_METADATA_PROTO_INVAL;
- if (md == NULL)
- return CAMEL_IMAPX_METADATA_PROTO_INVAL;
+ g_return_val_if_fail (md != NULL, CAMEL_IMAPX_METADATA_PROTO_INVAL);
/* (acquire md lock) */
g_mutex_lock (&(md->md_lock));
- mp = md->proto;
+ proto = md->proto;
+
+ /* (release md lock) */
+ g_mutex_unlock (&(md->md_lock));
+
+ return proto;
+}
+
+gboolean
+camel_imapx_metadata_set_proto (CamelImapxMetadata *md,
+ camel_imapx_metadata_proto_t proto)
+{
+ gboolean ok = FALSE;
+
+ g_return_val_if_fail (md != NULL, FALSE);
+ g_return_val_if_fail ((proto > CAMEL_IMAPX_METADATA_PROTO_INVAL) &&
+ (proto < CAMEL_IMAPX_METADATA_LAST_PROTO), FALSE);
/* (acquire md lock) */
+ g_mutex_lock (&(md->md_lock));
+
+ if (md->proto != CAMEL_IMAPX_METADATA_PROTO_INVAL) {
+ g_warning ("%s: Cannot reconfigure metadata protocol type",
+ __func__);
+ goto exit;
+ }
+
+ md->proto = proto;
+ ok = TRUE;
+
+ /* (release md lock) */
g_mutex_unlock (&(md->md_lock));
- return mp;
+ exit:
+ return ok;
}
/*----------------------------------------------------------------------------*/
diff --git a/src/libekolab/camel-imapx-metadata.h b/src/libekolab/camel-imapx-metadata.h
index e714393..8806ad6 100644
--- a/src/libekolab/camel-imapx-metadata.h
+++ b/src/libekolab/camel-imapx-metadata.h
@@ -145,6 +145,10 @@ camel_imapx_metadata_proto_t
camel_imapx_metadata_get_proto (CamelImapxMetadata *md);
gboolean
+camel_imapx_metadata_set_proto (CamelImapxMetadata *md,
+ camel_imapx_metadata_proto_t proto);
+
+gboolean
camel_imapx_metadata_add_from_server_response (CamelImapxMetadata *md,
CamelIMAPXStream *is,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]