[evolution-kolab/ek-wip-porting-imapx: 1/7] CamelIMAPXConnManager: updated "friend" API and defs



commit 7ab532dad879c9034a6696e6e95ebd42a30c01e7
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Feb 3 14:42:31 2012 +0100

    CamelIMAPXConnManager: updated "friend" API and defs
    
    * updated definitions helper header for new
      CamelIMAPXConnManager locking mechanism
      (reder/writer locks)
    * exported some more CamelIMAPXConnManager
      internal functions via the "friend" API
      (for use in CamelIMAPXExtdConnManager)

 .../imapx/camel-imapx-conn-manager-defs.h          |   23 +++++++---
 .../imapx/camel-imapx-conn-manager-friend.h        |   16 +++++++
 .../providers/imapx/camel-imapx-conn-manager.c     |   43 ++++++++++++++++++++
 3 files changed, 75 insertions(+), 7 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-conn-manager-defs.h b/src/camel/providers/imapx/camel-imapx-conn-manager-defs.h
index 8952caa..38abfe3 100644
--- a/src/camel/providers/imapx/camel-imapx-conn-manager-defs.h
+++ b/src/camel/providers/imapx/camel-imapx-conn-manager-defs.h
@@ -39,22 +39,31 @@
 
 #define c(...) camel_imapx_debug(conman, __VA_ARGS__)
 
-#define CON_LOCK(x) (g_static_rec_mutex_lock(&(x)->priv->con_man_lock))
-#define CON_UNLOCK(x) (g_static_rec_mutex_unlock(&(x)->priv->con_man_lock))
+#define CON_READ_LOCK(x) \
+	(g_static_rw_lock_reader_lock (&(x)->priv->rw_lock))
+#define CON_READ_UNLOCK(x) \
+	(g_static_rw_lock_reader_unlock (&(x)->priv->rw_lock))
+#define CON_WRITE_LOCK(x) \
+	(g_static_rw_lock_writer_lock (&(x)->priv->rw_lock))
+#define CON_WRITE_UNLOCK(x) \
+	(g_static_rw_lock_writer_unlock (&(x)->priv->rw_lock))
 
 /* typedef of CamelIMAPXConnManagerPrivate done in camel-imapx-conn-manager.h */
+
 struct _CamelIMAPXConnManagerPrivate {
+	/* XXX Might be easier for this to be a hash table,
+	 *     with CamelIMAPXServer pointers as the keys. */
 	GList *connections;
 	gpointer store;  /* weak pointer */
-	GStaticRecMutex con_man_lock;
-	gboolean clearing_connections;
+	GStaticRWLock rw_lock;
 };
 
-typedef struct _ConnectionInfo ConnectionInfo;
 struct _ConnectionInfo {
-	GHashTable *folders;
-	CamelIMAPXServer *conn;
+	GMutex *lock;
+	CamelIMAPXServer *is;
+	GHashTable *folder_names;
 	gchar *selected_folder;
+	volatile gint ref_count;
 };
 
 enum {
diff --git a/src/camel/providers/imapx/camel-imapx-conn-manager-friend.h b/src/camel/providers/imapx/camel-imapx-conn-manager-friend.h
index 6ba59e1..63ea107 100644
--- a/src/camel/providers/imapx/camel-imapx-conn-manager-friend.h
+++ b/src/camel/providers/imapx/camel-imapx-conn-manager-friend.h
@@ -41,6 +41,22 @@ CamelIMAPXServer*
 camel_imapx_conn_manager_find_connection_unlocked (CamelIMAPXConnManager *con_man,
                                                    const gchar *folder_name);
 
+void
+camel_imapx_conn_manager_conn_shutdown (CamelIMAPXServer *is,
+                                        CamelIMAPXConnManager *con_man);
+
+void
+camel_imapx_conn_manager_conn_update_select (CamelIMAPXServer *is,
+                                             const gchar *selected_folder,
+                                             CamelIMAPXConnManager *con_man);
+
+struct _ConnectionInfo*
+camel_imapx_conn_manager_connection_info_new (CamelIMAPXServer *is);
+
+void
+camel_imapx_conn_manager_connection_info_insert_folder_name (struct _ConnectionInfo *cinfo,
+                                                             const gchar *folder_name);
+
 /*----------------------------------------------------------------------------*/
 
 #endif /* _CAMEL_IMAPX_CONN_MANAGER_FRIEND_H_ */
diff --git a/src/camel/providers/imapx/camel-imapx-conn-manager.c b/src/camel/providers/imapx/camel-imapx-conn-manager.c
index 504fcef..b2e0876 100644
--- a/src/camel/providers/imapx/camel-imapx-conn-manager.c
+++ b/src/camel/providers/imapx/camel-imapx-conn-manager.c
@@ -736,5 +736,48 @@ CamelIMAPXServer*
 camel_imapx_conn_manager_find_connection_unlocked (CamelIMAPXConnManager *con_man,
                                                    const gchar *folder_name)
 {
+	g_assert (CAMEL_IS_IMAPX_CONN_MANAGER (con_man));
+	g_assert (folder_name != NULL);
+
 	return imapx_find_connection_unlocked (con_man, folder_name);
 }
+
+void
+camel_imapx_conn_manager_conn_shutdown (CamelIMAPXServer *is,
+                                        CamelIMAPXConnManager *con_man)
+{
+	g_assert (CAMEL_IS_IMAPX_SERVER (is));
+	g_assert (CAMEL_IS_IMAPX_CONN_MANAGER (con_man));
+
+	imapx_conn_shutdown (is, con_man);
+}
+
+void
+camel_imapx_conn_manager_conn_update_select (CamelIMAPXServer *is,
+                                             const gchar *selected_folder,
+                                             CamelIMAPXConnManager *con_man)
+{
+	g_assert (CAMEL_IS_IMAPX_SERVER (is));
+	g_assert (selected_folder != NULL);
+	g_assert (CAMEL_IS_IMAPX_CONN_MANAGER (con_man));
+
+	imapx_conn_update_select (is, selected_folder, con_man);
+}
+
+ConnectionInfo*
+camel_imapx_conn_manager_connection_info_new (CamelIMAPXServer *is)
+{
+	g_assert (CAMEL_IS_IMAPX_SERVER (is));
+
+	return connection_info_new (is);
+}
+
+void
+camel_imapx_conn_manager_connection_info_insert_folder_name (ConnectionInfo *cinfo,
+                                                             const gchar *folder_name)
+{
+	g_assert (cinfo != NULL);
+	g_assert (folder_name != NULL);
+
+	connection_info_insert_folder_name (cinfo, folder_name);
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]