[evolution-data-server] Add CamelSession.remove_service() method.



commit 3a34e74b64990dd60d82c247fdf462336a948815
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Dec 11 13:32:54 2011 -0500

    Add CamelSession.remove_service() method.
    
    So subclasses can be notified when a service is removed.
    
    Changes camel_session_remove_service() slightly.  Now takes a
    CamelService instead of a UID, and does not return a gboolean.
    
    Minor ABI + API break; soname bumped.

 camel/camel-session.c |   44 +++++++++++++++++++++++++++-----------------
 camel/camel-session.h |    6 ++++--
 configure.ac          |    2 +-
 3 files changed, 32 insertions(+), 20 deletions(-)
---
diff --git a/camel/camel-session.c b/camel/camel-session.c
index a661988..8500f21 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -414,6 +414,20 @@ session_add_service (CamelSession *session,
 	return service;
 }
 
+static void
+session_remove_service (CamelSession *session,
+                        CamelService *service)
+{
+	const gchar *uid;
+
+	camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+
+	uid = camel_service_get_uid (service);
+	g_hash_table_remove (session->priv->services, uid);
+
+	camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+}
+
 static gboolean
 session_authenticate_sync (CamelSession *session,
                            CamelService *service,
@@ -596,6 +610,7 @@ camel_session_class_init (CamelSessionClass *class)
 	object_class->finalize = session_finalize;
 
 	class->add_service = session_add_service;
+	class->remove_service = session_remove_service;
 
 	class->authenticate_sync = session_authenticate_sync;
 
@@ -805,33 +820,28 @@ camel_session_add_service (CamelSession *session,
 /**
  * camel_session_remove_service:
  * @session: a #CamelSession
- * @uid: a unique identifier for #CamelService to remove
- *
- * Removes previously added #CamelService by camel_session_add_service().
- * Internally stored #CamelService is unreffed, if found.
+ * @service: the #CamelService to remove
  *
- * Returns: %TRUE when service with given @uid was found and removed,
- *    %FALSE otherwise.
+ * Removes a #CamelService previously added by camel_session_add_service().
  *
  * Since: 3.2
  **/
-gboolean
+void
 camel_session_remove_service (CamelSession *session,
-                              const gchar *uid)
+                              CamelService *service)
 {
-	gboolean removed;
-
-	g_return_val_if_fail (session, FALSE);
-	g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE);
-	g_return_val_if_fail (uid != NULL, FALSE);
+	CamelSessionClass *class;
 
-	camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
+	g_return_if_fail (CAMEL_IS_SESSION (session));
+	g_return_if_fail (CAMEL_IS_SERVICE (service));
 
-	removed = g_hash_table_remove (session->priv->services, uid);
+	/* Verify the service belongs to this session. */
+	g_return_if_fail (camel_service_get_session (service) == session);
 
-	camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
+	class = CAMEL_SESSION_GET_CLASS (session);
+	g_return_if_fail (class->remove_service != NULL);
 
-	return removed;
+	class->remove_service (session, service);
 }
 
 /**
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 6216fee..3ecb0bc 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -110,6 +110,8 @@ struct _CamelSessionClass {
 						 const gchar *protocol,
 						 CamelProviderType type,
 						 GError **error);
+	void		(*remove_service)	(CamelSession *session,
+						 CamelService *service);
 	gchar *		(*get_password)		(CamelSession *session,
 						 CamelService *service,
 						 const gchar *prompt,
@@ -180,8 +182,8 @@ CamelService *	camel_session_add_service	(CamelSession *session,
 						 const gchar *protocol,
 						 CamelProviderType type,
 						 GError **error);
-gboolean	camel_session_remove_service	(CamelSession *session,
-						 const gchar *uid);
+void		camel_session_remove_service	(CamelSession *session,
+						 CamelService *service);
 CamelService *	camel_session_get_service	(CamelSession *session,
 						 const gchar *uid);
 CamelService *	camel_session_get_service_by_url
diff --git a/configure.ac b/configure.ac
index 8f27e52..9099d48 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,7 +101,7 @@ LIBEBOOK_CURRENT=16
 LIBEBOOK_REVISION=1
 LIBEBOOK_AGE=3
 
-LIBCAMEL_CURRENT=31
+LIBCAMEL_CURRENT=32
 LIBCAMEL_REVISION=0
 LIBCAMEL_AGE=0
 



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