[evolution-data-server] Add imapx_lookup_capability().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add imapx_lookup_capability().
- Date: Thu, 30 Aug 2012 21:08:44 +0000 (UTC)
commit 7887e4533ec53deed8d9eabbbfd132f0b865d932
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Aug 29 13:05:07 2012 -0400
Add imapx_lookup_capability().
Just a thread-safe lookup function for the capabilities hash table.
camel/camel-imapx-utils.c | 26 +++++++++++++++++---------
camel/camel-imapx-utils.h | 1 +
2 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/camel/camel-imapx-utils.c b/camel/camel-imapx-utils.c
index a1e2782..2efadcc 100644
--- a/camel/camel-imapx-utils.c
+++ b/camel/camel-imapx-utils.c
@@ -408,7 +408,6 @@ imapx_parse_capability (CamelIMAPXStream *stream,
gint tok;
guint len;
guchar *token, *p, c;
- gpointer pp = NULL;
gboolean free_token = FALSE;
struct _capability_info * cinfo;
GError *local_error = NULL;
@@ -440,14 +439,7 @@ imapx_parse_capability (CamelIMAPXStream *stream,
}
case IMAPX_TOK_INT:
d (stream->tagprefix, " cap: '%s'\n", token);
- g_mutex_lock (&capa_htable_lock);
- pp = g_hash_table_lookup (capa_htable,
- (gchar *) token);
- g_mutex_unlock (&capa_htable_lock);
- if (pp != NULL) {
- guint32 capa_id = GPOINTER_TO_UINT (pp);
- cinfo->capa |= capa_id;
- }
+ cinfo->capa |= imapx_lookup_capability ((gchar *) token);
if (free_token) {
g_free (token);
token = NULL;
@@ -523,6 +515,22 @@ imapx_register_capability (const gchar *capability)
return capa_id;
}
+guint32
+imapx_lookup_capability (const gchar *capability)
+{
+ gpointer data;
+
+ g_return_val_if_fail (capability != NULL, 0);
+
+ g_mutex_lock (&capa_htable_lock);
+
+ data = g_hash_table_lookup (capa_htable, capability);
+
+ g_mutex_unlock (&capa_htable_lock);
+
+ return GPOINTER_TO_UINT (data);
+}
+
struct _CamelIMAPXNamespaceList *
imapx_parse_namespace_list (CamelIMAPXStream *stream,
GCancellable *cancellable,
diff --git a/camel/camel-imapx-utils.h b/camel/camel-imapx-utils.h
index b777065..afe018d 100644
--- a/camel/camel-imapx-utils.h
+++ b/camel/camel-imapx-utils.h
@@ -136,6 +136,7 @@ struct _capability_info {
struct _capability_info *imapx_parse_capability (struct _CamelIMAPXStream *stream, GCancellable *cancellable, GError **error);
void imapx_free_capability (struct _capability_info *);
guint32 imapx_register_capability (const gchar *capability);
+guint32 imapx_lookup_capability (const gchar *capability);
gboolean imapx_parse_param_list (struct _CamelIMAPXStream *is, struct _camel_header_param **plist, GCancellable *cancellable, GError **error) /* IO,PARSE */;
struct _CamelContentDisposition *imapx_parse_ext_optional (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error) /* IO,PARSE */;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]