[evolution-data-server] CamelSession: Add camel_session_remove_services()



commit 2e2f4dad47cc90e564a547a09c0ff4a49b4d36ec
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Jul 15 08:45:42 2011 -0400

    CamelSession: Add camel_session_remove_services()
    
    Helps ensure CamelService instances are finalized during application
    shutdown, even if CamelSession itself is caught in reference cycles.

 camel/camel-session.c                        |   24 ++++++++++++++++++++++++
 camel/camel-session.h                        |    1 +
 docs/reference/camel/camel-sections.txt      |    1 +
 docs/reference/camel/tmpl/camel-session.sgml |    8 ++++++++
 4 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-session.c b/camel/camel-session.c
index cea1ec6..362c5f4 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -698,6 +698,30 @@ camel_session_list_services (CamelSession *session)
 }
 
 /**
+ * camel_session_remove_services:
+ * @session: a #CamelSession
+ *
+ * Removes all #CamelService instances added by camel_session_add_service().
+ *
+ * This can be useful during application shutdown to ensure all #CamelService
+ * instances are freed properly, especially since #CamelSession instances are
+ * prone to reference cycles.
+ *
+ * Since: 3.2
+ **/
+void
+camel_session_remove_services (CamelSession *session)
+{
+	g_return_if_fail (CAMEL_IS_SESSION (session));
+
+	camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+
+	g_hash_table_remove_all (session->priv->services);
+
+	camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+}
+
+/**
  * camel_session_get_password:
  * @session: a #CamelSession
  * @service: the #CamelService this query is being made by
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 071a3c5..59bd411 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -169,6 +169,7 @@ CamelService *	camel_session_get_service_by_url
 						 CamelURL *url,
 						 CamelProviderType type);
 GList *		camel_session_list_services	(CamelSession *session);
+void		camel_session_remove_services	(CamelSession *session);
 gchar *		camel_session_get_password	(CamelSession *session,
 						 CamelService *service,
 						 const gchar *prompt,
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 4569e4d..1e25685 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -1939,6 +1939,7 @@ camel_session_add_service
 camel_session_get_service
 camel_session_get_service_by_url
 camel_session_list_services
+camel_session_remove_services
 camel_session_get_password
 camel_session_forget_password
 camel_session_alert_user
diff --git a/docs/reference/camel/tmpl/camel-session.sgml b/docs/reference/camel/tmpl/camel-session.sgml
index be37afb..39ebbb0 100644
--- a/docs/reference/camel/tmpl/camel-session.sgml
+++ b/docs/reference/camel/tmpl/camel-session.sgml
@@ -149,6 +149,14 @@ CamelSession
 @Returns: 
 
 
+<!-- ##### FUNCTION camel_session_remove_services ##### -->
+<para>
+
+</para>
+
+ session: 
+
+
 <!-- ##### FUNCTION camel_session_get_password ##### -->
 <para>
 



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