[evolution-mapi] Camel is now GObject based.



commit 0a711ef46e83311a02b96cd3f926bdda1af3d105
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Apr 24 11:03:34 2010 -0400

    Camel is now GObject based.

 src/addressbook/e-book-backend-mapi.c |    4 +-
 src/camel/camel-mapi-folder.c         |  154 ++++++++++++++++-----------------
 src/camel/camel-mapi-folder.h         |   46 ++++++----
 src/camel/camel-mapi-notifications.c  |    4 +-
 src/camel/camel-mapi-notifications.h  |    6 +-
 src/camel/camel-mapi-private.h        |    2 +-
 src/camel/camel-mapi-store-summary.c  |  108 ++++++++++++------------
 src/camel/camel-mapi-store-summary.h  |   37 ++++++---
 src/camel/camel-mapi-store.c          |  151 ++++++++++++++------------------
 src/camel/camel-mapi-store.h          |   48 ++++++-----
 src/camel/camel-mapi-summary.c        |  124 ++++++++++++++------------
 src/camel/camel-mapi-summary.h        |   37 ++++++---
 src/camel/camel-mapi-transport.c      |   39 +++------
 src/camel/camel-mapi-transport.h      |   42 ++++++---
 src/camel/camel-mapi-utils.h          |    4 +-
 15 files changed, 414 insertions(+), 392 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index c4ab714..daa2a1e 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -743,7 +743,7 @@ mapi_book_write_props (ExchangeMapiConnection *conn, mapi_id_t fid, TALLOC_CTX *
 				}
 			}
 
-			camel_object_unref (addr);
+			g_object_unref (addr);
 			g_free (raw);
 		}
 
@@ -1370,7 +1370,7 @@ mapi_book_contact_from_props (ExchangeMapiConnection *conn, mapi_id_t fid, struc
 					e_vcard_attribute_add_value (attr, value);
 
 				g_free (value);
-				camel_object_unref (addr);
+				g_object_unref (addr);
 
 				str = g_strdup_printf ("%d", i + 1);
 				e_vcard_attribute_add_param_with_value (attr,
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 051ec7d..8dcff96 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -47,7 +47,9 @@
 #define SUMMARY_FETCH_BATCH_COUNT 150
 #define d(x)
 
-static CamelOfflineFolderClass *parent_class = NULL;
+#define CAMEL_MAPI_FOLDER_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), CAMEL_TYPE_MAPI_FOLDER, CamelMapiFolderPrivate))
 
 struct _CamelMapiFolderPrivate {
 
@@ -70,6 +72,8 @@ static CamelMimeMessage *mapi_folder_item_to_msg( CamelFolder *folder, MapiItem
 static void mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **changeinfo,
 			       CamelException *ex, gboolean uid_flag);
 
+G_DEFINE_TYPE (CamelMapiFolder, camel_mapi_folder, CAMEL_TYPE_OFFLINE_FOLDER)
+
 static GPtrArray *
 mapi_folder_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
 {
@@ -132,7 +136,7 @@ mapi_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
 	}
 
 	if (count)
-		return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+		return ((CamelObjectClass *)camel_mapi_folder_parent_class)->getv(object, ex, args);
 
 	return 0;
 
@@ -811,7 +815,7 @@ mapi_sync_deleted_free (CamelSession *session, CamelSessionThreadMsg *msg)
 		}
 	}
 
-	camel_object_unref (m->folder);
+	g_object_unref (m->folder);
 }
 
 static CamelSessionThreadOps deleted_items_sync_ops = {
@@ -1149,7 +1153,7 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
 		deleted_items_op_msg->folder = folder;
 		deleted_items_op_msg->folder_id = temp_folder_id;
 		deleted_items_op_msg->need_refresh = FALSE;
-		camel_object_ref (folder);
+		g_object_ref (folder);
 
 		camel_session_thread_queue (session, &deleted_items_op_msg->msg, 0);
 
@@ -1411,7 +1415,7 @@ mapi_mime_set_msg_headers (CamelFolder *folder, CamelMimeMessage *msg, MapiItem
 		parser = camel_mime_parser_new ();
 		camel_mime_parser_init_with_stream (parser, stream);
 		camel_mime_parser_scan_from (parser, FALSE);
-		camel_object_unref (stream);
+		g_object_unref (stream);
 
 		if (camel_mime_part_construct_from_parser (part, parser) != -1) {
 			struct _camel_header_raw *h;
@@ -1431,8 +1435,8 @@ mapi_mime_set_msg_headers (CamelFolder *folder, CamelMimeMessage *msg, MapiItem
 			}
 		}
 
-		camel_object_unref (parser);
-		camel_object_unref (part);
+		g_object_unref (parser);
+		g_object_unref (part);
 	}
 
 	/* Overwrite headers if we have specific properties available*/
@@ -1561,7 +1565,7 @@ mapi_mime_multipart_add_attachments (CamelMultipart *multipart, GSList *attachs)
 	while (attachs) {
 		part = attachs->data;
 		camel_multipart_add_part (multipart, part);
-		camel_object_unref (part);
+		g_object_unref (part);
 		attachs = attachs->next;
 	}
 }
@@ -1578,7 +1582,7 @@ mapi_mime_build_multipart_related (MapiItem *item, const ExchangeMAPIStream *str
 
 	part = mapi_mime_msg_body (item, stream);
 	camel_multipart_add_part (m_related, part);
-	camel_object_unref (part);
+	g_object_unref (part);
 
 	mapi_mime_multipart_add_attachments (m_related, inline_attachs);
 
@@ -1605,12 +1609,12 @@ mapi_mime_build_multipart_alternative (MapiItem *item, GSList *body_parts, GSLis
 								       inline_attachs);
 			camel_medium_set_content (CAMEL_MEDIUM (part),
 						  CAMEL_DATA_WRAPPER (m_related));
-			camel_object_unref (m_related);
+			g_object_unref (m_related);
 		} else
 			part = mapi_mime_msg_body (item, stream);
 
 		camel_multipart_add_part (m_alternative, part);
-		camel_object_unref (part);
+		g_object_unref (part);
 	}
 
 	return m_alternative;
@@ -1726,7 +1730,7 @@ mapi_folder_item_to_msg( CamelFolder *folder, MapiItem *item, CamelException *ex
 		camel_multipart_set_boundary (multipart_body, NULL);
 		part = mapi_mime_msg_body (item, item->msg.body_parts ? item->msg.body_parts->data : NULL);
 		camel_multipart_add_part (multipart_body, part);
-		camel_object_unref (part);
+		g_object_unref (part);
 	}
 
 	if (noninline_attachs) { /* multipart/mixed */
@@ -1735,7 +1739,7 @@ mapi_folder_item_to_msg( CamelFolder *folder, MapiItem *item, CamelException *ex
 	}
 
 	camel_medium_set_content (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER(multipart_body));
-	camel_object_unref (multipart_body);
+	g_object_unref (multipart_body);
 
 	return msg;
 }
@@ -1774,9 +1778,9 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
 		if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream) == -1) {
 			if (errno == EINTR) {
 				camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Message fetching cancelled by user."));
-				camel_object_unref (msg);
-				camel_object_unref (cache_stream);
-				camel_object_unref (stream);
+				g_object_unref (msg);
+				g_object_unref (cache_stream);
+				g_object_unref (stream);
 				camel_message_info_free (&mi->info);
 				return NULL;
 			} else {
@@ -1784,13 +1788,13 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
 				   the second %s is replaced with a detailed error string */
 				camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"),
 						uid, g_strerror (errno));
-				camel_object_unref (msg);
+				g_object_unref (msg);
 				msg = NULL;
 			}
 		}
-		camel_object_unref (cache_stream);
+		g_object_unref (cache_stream);
 	}
-	camel_object_unref (stream);
+	g_object_unref (stream);
 
 	if (msg != NULL) {
 		camel_message_info_free (&mi->info);
@@ -1850,7 +1854,7 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
 		if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream) == -1
 				|| camel_stream_flush (cache_stream) == -1)
 			camel_data_cache_remove (mapi_folder->cache, "cache", uid, NULL);
-		camel_object_unref (cache_stream);
+		g_object_unref (cache_stream);
 	}
 
 	CAMEL_MAPI_FOLDER_REC_UNLOCK (folder, cache_lock);
@@ -1875,17 +1879,6 @@ mapi_folder_search_free (CamelFolder *folder, GPtrArray *uids)
 
 }
 
-static void
-camel_mapi_folder_finalize (CamelObject *object)
-{
-	CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (object);
-
-	if (mapi_folder->priv)
-		g_free(mapi_folder->priv);
-	if (mapi_folder->cache)
-		camel_object_unref (mapi_folder->cache);
-}
-
 #if 0
 static CamelMessageInfo*
 mapi_get_message_info(CamelFolder *folder, const gchar *uid)
@@ -2088,7 +2081,7 @@ mapi_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
 static void
 mapi_folder_rename (CamelFolder *folder, const gchar *new)
 {
-	((CamelFolderClass *)parent_class)->rename(folder, new);
+	((CamelFolderClass *)camel_mapi_folder_parent_class)->rename(folder, new);
 }
 
 static gint
@@ -2158,41 +2151,60 @@ mapi_append_message (CamelFolder *folder, CamelMimeMessage *message,
 }
 
 static void
-camel_mapi_folder_class_init (CamelMapiFolderClass *camel_mapi_folder_class)
+mapi_folder_dispose (GObject *object)
 {
-	CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_mapi_folder_class);
-
-	parent_class = CAMEL_OFFLINE_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_offline_folder_get_type ()));
-
-	((CamelObjectClass *) camel_mapi_folder_class)->getv = mapi_getv;
-
-	camel_folder_class->get_message = mapi_folder_get_message;
-	camel_folder_class->rename = mapi_folder_rename;
-	camel_folder_class->search_by_expression = mapi_folder_search_by_expression;
-	camel_folder_class->cmp_uids = mapi_cmp_uids;
-/*	camel_folder_class->get_message_info = mapi_get_message_info; */
-	camel_folder_class->search_by_uids = mapi_folder_search_by_uids;
-	camel_folder_class->search_free = mapi_folder_search_free;
-	camel_folder_class->append_message = mapi_append_message;
-	camel_folder_class->refresh_info = mapi_refresh_info;
-	camel_folder_class->sync = mapi_sync;
-	camel_folder_class->expunge = mapi_expunge;
-	camel_folder_class->transfer_messages_to = mapi_transfer_messages_to;
+	CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (object);
+
+	if (mapi_folder->cache != NULL) {
+		g_object_unref (mapi_folder->cache);
+		mapi_folder->cache = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (camel_mapi_folder_parent_class)->dispose (object);
 }
 
 static void
-camel_mapi_folder_init (gpointer object, gpointer klass)
+camel_mapi_folder_class_init (CamelMapiFolderClass *class)
 {
-	CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (object);
-	CamelFolder *folder = CAMEL_FOLDER (object);
+	GObjectClass *object_class;
+	CamelObjectClass *camel_object_class;
+	CamelFolderClass *folder_class;
+
+	g_type_class_add_private (class, sizeof (CamelMapiFolderPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = mapi_folder_dispose;
+
+	camel_object_class = CAMEL_OBJECT_CLASS (class);
+	camel_object_class->getv = mapi_getv;
+
+	folder_class = CAMEL_FOLDER_CLASS (class);
+	folder_class->get_message = mapi_folder_get_message;
+	folder_class->rename = mapi_folder_rename;
+	folder_class->search_by_expression = mapi_folder_search_by_expression;
+	folder_class->cmp_uids = mapi_cmp_uids;
+	folder_class->search_by_uids = mapi_folder_search_by_uids;
+	folder_class->search_free = mapi_folder_search_free;
+	folder_class->append_message = mapi_append_message;
+	folder_class->refresh_info = mapi_refresh_info;
+	folder_class->sync = mapi_sync;
+	folder_class->expunge = mapi_expunge;
+	folder_class->transfer_messages_to = mapi_transfer_messages_to;
+}
+
+static void
+camel_mapi_folder_init (CamelMapiFolder *mapi_folder)
+{
+	CamelFolder *folder = CAMEL_FOLDER (mapi_folder);
+
+	mapi_folder->priv = CAMEL_MAPI_FOLDER_GET_PRIVATE (mapi_folder);
 
 	folder->permanent_flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_DELETED |
 		CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN;
 
 	folder->folder_flags = CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY | CAMEL_FOLDER_HAS_SEARCH_CAPABILITY;
 
-	mapi_folder->priv = g_malloc0 (sizeof(*mapi_folder->priv));
-
 #ifdef ENABLE_THREADS
 	g_static_mutex_init(&mapi_folder->priv->search_lock);
 	g_static_rec_mutex_init(&mapi_folder->priv->cache_lock);
@@ -2201,26 +2213,6 @@ camel_mapi_folder_init (gpointer object, gpointer klass)
 	mapi_folder->need_rescan = TRUE;
 }
 
-CamelType
-camel_mapi_folder_get_type (void)
-{
-	static CamelType camel_mapi_folder_type = CAMEL_INVALID_TYPE;
-
-	if (camel_mapi_folder_type == CAMEL_INVALID_TYPE) {
-		camel_mapi_folder_type =
-			camel_type_register (camel_offline_folder_get_type (),
-					"CamelMapiFolder",
-					sizeof (CamelMapiFolder),
-					sizeof (CamelMapiFolderClass),
-					(CamelObjectClassInitFunc) camel_mapi_folder_class_init,
-					NULL,
-					(CamelObjectInitFunc) camel_mapi_folder_init,
-					(CamelObjectFinalizeFunc) camel_mapi_folder_finalize);
-	}
-
-	return camel_mapi_folder_type;
-}
-
 CamelFolder *
 camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar *folder_dir,
 		      guint32 flags, CamelException *ex)
@@ -2234,7 +2226,7 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
 	gchar *short_name;
 	guint32 i = 0;
 
-	folder = CAMEL_FOLDER (camel_object_new(camel_mapi_folder_get_type ()) );
+	folder = g_object_new (CAMEL_TYPE_MAPI_FOLDER, NULL);
 
 	mapi_folder = CAMEL_MAPI_FOLDER(folder);
 	short_name = strrchr (folder_name, '/');
@@ -2250,7 +2242,7 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
 	g_free(summary_file);
 
 	if (!folder->summary) {
-		camel_object_unref (CAMEL_OBJECT (folder));
+		g_object_unref (CAMEL_OBJECT (folder));
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
 				_("Could not load summary for %s"),
 				folder_name);
@@ -2267,7 +2259,7 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
 	mapi_folder->cache = camel_data_cache_new (state_file, ex);
 	g_free (state_file);
 	if (!mapi_folder->cache) {
-		camel_object_unref (folder);
+		g_object_unref (folder);
 		return NULL;
 	}
 
@@ -2275,7 +2267,7 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
 /*	mapi_folder->journal = camel_mapi_journal_new (mapi_folder, journal_file); */
 /*	g_free (journal_file); */
 /*	if (!mapi_folder->journal) { */
-/*		camel_object_unref (folder); */
+/*		g_object_unref (folder); */
 /*		return NULL; */
 /*	} */
 
@@ -2284,7 +2276,7 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
 
 	mapi_folder->search = camel_folder_search_new ();
 	if (!mapi_folder->search) {
-		camel_object_unref (folder);
+		g_object_unref (folder);
 		return NULL;
 	}
 
diff --git a/src/camel/camel-mapi-folder.h b/src/camel/camel-mapi-folder.h
index 3658444..44ca31f 100644
--- a/src/camel/camel-mapi-folder.h
+++ b/src/camel/camel-mapi-folder.h
@@ -21,8 +21,8 @@
  *
  */
 
-#ifndef __MAPI_FOLDER_H__
-#define __MAPI_FOLDER_H__
+#ifndef CAMEL_MAPI_FOLDER_H
+#define CAMEL_MAPI_FOLDER_H
 
 #include <camel/camel.h>
 #include <libmapi/libmapi.h>
@@ -30,10 +30,24 @@
 
 #define PATH_FOLDER ".evolution/mail/mapi"
 
-#define CAMEL_MAPI_FOLDER_TYPE     (camel_mapi_folder_get_type ())
-#define CAMEL_MAPI_FOLDER(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_MAPI_FOLDER_TYPE, CamelMapiFolder))
-#define CAMEL_MAPI_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MAPI_FOLDER_TYPE, CamelMapiFolderClass))
-#define CAMEL_IS_MAPI_FOLDER(o)    (CAMEL_CHECK_TYPE((o), CAMEL_MAPI_FOLDER_TYPE))
+/* Standard GObject macros */
+#define CAMEL_TYPE_MAPI_FOLDER \
+	(camel_mapi_folder_get_type ())
+#define CAMEL_MAPI_FOLDER(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), CAMEL_TYPE_MAPI_FOLDER, CamelMapiFolder))
+#define CAMEL_MAPI_FOLDER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), CAMEL_TYPE_MAPI_FOLDER, CamelMapiFolderClass))
+#define CAMEL_IS_MAPI_FOLDER(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), CAMEL_TYPE_MAPI_FOLDER))
+#define CAMEL_IS_MAPI_FOLDER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), CAMEL_TYPE_MAPI_FOLDER))
+#define CAMEL_MAPI_FOLDER_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), CAMEL_TYPE_MAPI_FOLDER, CamelMapiFolderClass))
 
 /**
  * DATA STRUCTURES
@@ -96,13 +110,13 @@ typedef struct  {
 
 void mapi_item_free (MapiItem *item);
 
-typedef struct  _CamelMapiFolder CamelMapiFolder;
-typedef struct  _CamelMapiFolderClass CamelMapiFolderClass;
+typedef struct _CamelMapiFolder CamelMapiFolder;
+typedef struct _CamelMapiFolderClass CamelMapiFolderClass;
+typedef struct _CamelMapiFolderPrivate CamelMapiFolderPrivate;
 
 struct _CamelMapiFolder {
-	CamelOfflineFolder parent_object;
-
-	struct _CamelMapiFolderPrivate *priv;
+	CamelOfflineFolder parent;
+	CamelMapiFolderPrivate *priv;
 
 	CamelFolderSearch *search;
 
@@ -118,10 +132,7 @@ struct _CamelMapiFolder {
 
 struct _CamelMapiFolderClass {
 	CamelOfflineFolderClass parent_class;
-
-	/* Virtual methods */
-
-} ;
+};
 
 typedef struct {
 	GSList *items_list;
@@ -130,8 +141,7 @@ typedef struct {
 	CamelFolderChangeInfo *changes;
 }fetch_items_data;
 
-/* Standard Camel function */
-CamelType camel_mapi_folder_get_type (void);
+GType camel_mapi_folder_get_type (void);
 
 /* implemented */
 CamelFolder *
@@ -144,4 +154,4 @@ gboolean camel_mapi_folder_fetch_summary (CamelStore *store, const mapi_id_t fid
 
 G_END_DECLS
 
-#endif /* CAMEL_GROUPWISE_FOLDER_H */
+#endif /* CAMEL_MAPI_FOLDER_H */
diff --git a/src/camel/camel-mapi-notifications.c b/src/camel/camel-mapi-notifications.c
index a30c2ed..2ef3f37 100644
--- a/src/camel/camel-mapi-notifications.c
+++ b/src/camel/camel-mapi-notifications.c
@@ -284,9 +284,9 @@ camel_mapi_notification_listener_stop (CamelMapiStore *mstore, gpointer start_va
 	g_object_unref (thread_data->cancellable);
 	g_free (thread_data);
 
-	camel_object_ref (mstore);
+	g_object_ref (mstore);
 	camel_service_lock (CAMEL_SERVICE (mstore), CS_REC_CONNECT_LOCK);
 	camel_mapi_store_unset_notification_data (mstore);
 	camel_service_unlock (CAMEL_SERVICE (mstore), CS_REC_CONNECT_LOCK);
-	camel_object_unref (mstore);
+	g_object_unref (mstore);
 }
diff --git a/src/camel/camel-mapi-notifications.h b/src/camel/camel-mapi-notifications.h
index b4f00d5..9d9d414 100644
--- a/src/camel/camel-mapi-notifications.h
+++ b/src/camel/camel-mapi-notifications.h
@@ -23,8 +23,8 @@
 
 /* For push notification listener*/
 
-#ifndef _CAMEL_MAPI_NOTIFICATIONS_H
-#define _CAMEL_MAPI_NOTIFICATIONS_H
+#ifndef CAMEL_MAPI_NOTIFICATIONS_H
+#define CAMEL_MAPI_NOTIFICATIONS_H
 
 G_BEGIN_DECLS
 
@@ -33,4 +33,4 @@ void camel_mapi_notification_listener_stop (CamelMapiStore *store, gpointer star
 
 G_END_DECLS
 
-#endif
+#endif /* CAMEL_MAPI_NOTIFICATIONS_H */
diff --git a/src/camel/camel-mapi-private.h b/src/camel/camel-mapi-private.h
index 5d09429..aea8977 100644
--- a/src/camel/camel-mapi-private.h
+++ b/src/camel/camel-mapi-private.h
@@ -22,7 +22,7 @@
  */
 
 #ifndef CAMEL_MAPI_PRIVATE_H
-#define CAMEL_MAPI_PRIVATE_H 1
+#define CAMEL_MAPI_PRIVATE_H
 
 /* need a way to configure and save this data, if this header is to
    be installed.  For now, dont install it */
diff --git a/src/camel/camel-mapi-store-summary.c b/src/camel/camel-mapi-store-summary.c
index e82bde1..5b7f40c 100644
--- a/src/camel/camel-mapi-store-summary.c
+++ b/src/camel/camel-mapi-store-summary.c
@@ -49,76 +49,51 @@ static void store_info_set_string(CamelStoreSummary *s, CamelStoreInfo *mi, gint
 
 static const gchar *store_info_string(CamelStoreSummary *s, const CamelStoreInfo *mi, gint type);
 
-static void camel_mapi_store_summary_class_init (CamelMapiStoreSummaryClass *klass);
-static void camel_mapi_store_summary_init       (CamelMapiStoreSummary *obj);
-static void camel_mapi_store_summary_finalise   (CamelObject *obj);
-
-static CamelStoreSummaryClass *camel_mapi_store_summary_parent;
+G_DEFINE_TYPE (CamelMapiStoreSummary, camel_mapi_store_summary, CAMEL_TYPE_STORE_SUMMARY)
 
 static void
-camel_mapi_store_summary_class_init (CamelMapiStoreSummaryClass *klass)
+camel_mapi_store_summary_class_init (CamelMapiStoreSummaryClass *class)
 {
-	CamelStoreSummaryClass *ssklass = (CamelStoreSummaryClass *)klass;
-
-	ssklass->summary_header_load = summary_header_load;
-	ssklass->summary_header_save = summary_header_save;
-
-	ssklass->store_info_load = store_info_load;
-	ssklass->store_info_save = store_info_save;
-	ssklass->store_info_free = store_info_free;
-
-	ssklass->store_info_string = store_info_string;
-	ssklass->store_info_set_string = store_info_set_string;
-
+	CamelStoreSummaryClass *store_summary_class;
+
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (class);
+	store_summary_class->summary_header_load = summary_header_load;
+	store_summary_class->summary_header_save = summary_header_save;
+	store_summary_class->store_info_load = store_info_load;
+	store_summary_class->store_info_save = store_info_save;
+	store_summary_class->store_info_free = store_info_free;
+	store_summary_class->store_info_string = store_info_string;
+	store_summary_class->store_info_set_string = store_info_set_string;
 }
 
 static void
-camel_mapi_store_summary_init (CamelMapiStoreSummary *s)
+camel_mapi_store_summary_init (CamelMapiStoreSummary *mapi_store_summary)
 {
+	CamelStoreSummary *store_summary;
 
-	((CamelStoreSummary *)s)->store_info_size = sizeof(CamelMapiStoreInfo);
-	s->version = CAMEL_MAPI_STORE_SUMMARY_VERSION;
-}
-
-static void
-camel_mapi_store_summary_finalise (CamelObject *obj)
-{
-}
-
-CamelType
-camel_mapi_store_summary_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		camel_mapi_store_summary_parent = (CamelStoreSummaryClass *)camel_store_summary_get_type();
-		type = camel_type_register((CamelType)camel_mapi_store_summary_parent, "CamelMapiStoreSummary",
-				sizeof (CamelMapiStoreSummary),
-				sizeof (CamelMapiStoreSummaryClass),
-				(CamelObjectClassInitFunc) camel_mapi_store_summary_class_init,
-				NULL,
-				(CamelObjectInitFunc) camel_mapi_store_summary_init,
-				(CamelObjectFinalizeFunc) camel_mapi_store_summary_finalise);
-	}
+	store_summary = CAMEL_STORE_SUMMARY (mapi_store_summary);
+	store_summary->store_info_size = sizeof (CamelMapiStoreInfo);
 
-	return type;
+	mapi_store_summary->version = CAMEL_MAPI_STORE_SUMMARY_VERSION;
 }
 
 CamelMapiStoreSummary *
 camel_mapi_store_summary_new (void)
 {
-	CamelMapiStoreSummary *new = CAMEL_MAPI_STORE_SUMMARY ( camel_object_new (camel_mapi_store_summary_get_type ()));
-
-	return new;
+	return g_object_new (CAMEL_TYPE_MAPI_STORE_SUMMARY, NULL);
 }
 
 static gint
 summary_header_load(CamelStoreSummary *s, FILE *in)
 {
 	CamelMapiStoreSummary *summary = (CamelMapiStoreSummary *)s;
+	CamelStoreSummaryClass *store_summary_class;
+
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (
+		camel_mapi_store_summary_parent_class);
 
 	/* TODO */
-	if (camel_mapi_store_summary_parent->summary_header_load ((CamelStoreSummary *)s, in) == -1)
+	if (store_summary_class->summary_header_load (s, in) == -1)
 			/* || camel_file_util_decode_fixed_int32(in, &version) == -1) */
 		return -1;
 
@@ -130,8 +105,12 @@ summary_header_load(CamelStoreSummary *s, FILE *in)
 static gint
 summary_header_save(CamelStoreSummary *s, FILE *out)
 {
+	CamelStoreSummaryClass *store_summary_class;
+
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (
+		camel_mapi_store_summary_parent_class);
 
-	if (camel_mapi_store_summary_parent->summary_header_save((CamelStoreSummary *)s, out) == -1)
+	if (store_summary_class->summary_header_save (s, out) == -1)
 		return -1;
 
 	return 0;
@@ -140,9 +119,13 @@ summary_header_save(CamelStoreSummary *s, FILE *out)
 static CamelStoreInfo *
 store_info_load(CamelStoreSummary *s, FILE *in)
 {
+	CamelStoreSummaryClass *store_summary_class;
 	CamelMapiStoreInfo *si;
 
-	si = (CamelMapiStoreInfo *)camel_mapi_store_summary_parent->store_info_load(s, in);
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (
+		camel_mapi_store_summary_parent_class);
+
+	si = (CamelMapiStoreInfo *)store_summary_class->store_info_load(s, in);
 	if (si) {
 		if (camel_file_util_decode_string(in, &si->full_name) == -1
 		    || camel_file_util_decode_string(in, &si->folder_id) == -1
@@ -158,7 +141,12 @@ static gint
 store_info_save(CamelStoreSummary *s, FILE *out, CamelStoreInfo *mi)
 {
 	CamelMapiStoreInfo *summary = (CamelMapiStoreInfo *)mi;
-	if (camel_mapi_store_summary_parent->store_info_save(s, out, mi) == -1
+	CamelStoreSummaryClass *store_summary_class;
+
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (
+		camel_mapi_store_summary_parent_class);
+
+	if (store_summary_class->store_info_save(s, out, mi) == -1
 	    || camel_file_util_encode_string(out, summary->full_name) == -1
 	    || camel_file_util_encode_string(out, summary->folder_id) == -1
 	    || camel_file_util_encode_string(out, summary->parent_id) == -1)
@@ -171,18 +159,26 @@ static void
 store_info_free(CamelStoreSummary *s, CamelStoreInfo *mi)
 {
 	CamelMapiStoreInfo *si = (CamelMapiStoreInfo *)mi;
+	CamelStoreSummaryClass *store_summary_class;
+
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (
+		camel_mapi_store_summary_parent_class);
 
 	g_free (si->full_name);
 	g_free (si->folder_id);
 	g_free (si->parent_id);
 
-	camel_mapi_store_summary_parent->store_info_free(s, mi);
+	store_summary_class->store_info_free(s, mi);
 }
 
 static const gchar *
 store_info_string(CamelStoreSummary *s, const CamelStoreInfo *mi, gint type)
 {
 	CamelMapiStoreInfo *isi = (CamelMapiStoreInfo *)mi;
+	CamelStoreSummaryClass *store_summary_class;
+
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (
+		camel_mapi_store_summary_parent_class);
 
 	/* FIXME: Locks? */
 
@@ -196,7 +192,7 @@ store_info_string(CamelStoreSummary *s, const CamelStoreInfo *mi, gint type)
 		case CAMEL_MAPI_STORE_INFO_PARENT_ID:
 			return isi->parent_id;
 		default:
-			return camel_mapi_store_summary_parent->store_info_string(s, mi, type);
+			return store_summary_class->store_info_string(s, mi, type);
 	}
 }
 
@@ -204,9 +200,13 @@ static void
 store_info_set_string(CamelStoreSummary *s, CamelStoreInfo *mi, gint type, const gchar *str)
 {
 	CamelMapiStoreInfo *isi = (CamelMapiStoreInfo *)mi;
+	CamelStoreSummaryClass *store_summary_class;
 
 	g_assert(mi != NULL);
 
+	store_summary_class = CAMEL_STORE_SUMMARY_CLASS (
+		camel_mapi_store_summary_parent_class);
+
 	switch (type) {
 		case CAMEL_MAPI_STORE_INFO_FULL_NAME:
 			d(printf("Set full name %s -> %s\n", isi->full_name, str));
@@ -230,7 +230,7 @@ store_info_set_string(CamelStoreSummary *s, CamelStoreInfo *mi, gint type, const
 			camel_store_summary_unlock (s, CSS_SUMMARY_LOCK);
 			break;
 		default:
-			camel_mapi_store_summary_parent->store_info_set_string(s, mi, type, str);
+			store_summary_class->store_info_set_string(s, mi, type, str);
 			break;
 	}
 }
diff --git a/src/camel/camel-mapi-store-summary.h b/src/camel/camel-mapi-store-summary.h
index 679557d..7b8ad56 100644
--- a/src/camel/camel-mapi-store-summary.h
+++ b/src/camel/camel-mapi-store-summary.h
@@ -21,21 +21,37 @@
  *
  */
 
-#ifndef _CAMEL_MAPI_STORE_SUMMARY_H
-#define _CAMEL_MAPI_STORE_SUMMARY_H
+#ifndef CAMEL_MAPI_STORE_SUMMARY_H
+#define CAMEL_MAPI_STORE_SUMMARY_H
 
 #include <camel/camel.h>
 
 #define CAMEL_MAPI_STORE_SUMMARY_VERSION (0)
 
-#define CAMEL_MAPI_STORE_SUMMARY(obj)         CAMEL_CHECK_CAST (obj, camel_mapi_store_summary_get_type (), CamelMapiStoreSummary)
-#define CAMEL_MAPI_STORE_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mapi_store_summary_get_type (), CamelMapiStoreSummaryClass)
-#define CAMEL_IS_MAPI_STORE_SUMMARY(obj)      CAMEL_CHECK_TYPE (obj, camel_mapi_store_summary_get_type ())
+/* Standard GObject macros */
+#define CAMEL_TYPE_MAPI_STORE_SUMMARY \
+	(camel_mapi_store_summary_get_type ())
+#define CAMEL_MAPI_STORE_SUMMARY(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), CAMEL_TYPE_MAPI_STORE_SUMMARY, CamelMapiStoreSummary))
+#define CAMEL_MAPI_STORE_SUMMARY_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), CAMEL_TYPE_MAPI_STORE_SUMMARY, CamelMapiStoreSummaryClass))
+#define CAMEL_IS_MAPI_STORE_SUMMARY(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), CAMEL_TYPE_MAPI_STORE_SUMMARY))
+#define CAMEL_IS_MAPI_STORE_SUMMARY_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), CAMEL_TYPE_MAPI_STORE_SUMMARY))
+#define CAMEL_MAPI_STORE_SUMMARY_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), CAMEL_TYPE_MAPI_STORE_SUMMARY, CamelMapiStoreSummaryClass))
 
 G_BEGIN_DECLS
 
-typedef struct _CamelMapiStoreSummary      CamelMapiStoreSummary;
+typedef struct _CamelMapiStoreSummary CamelMapiStoreSummary;
 typedef struct _CamelMapiStoreSummaryClass CamelMapiStoreSummaryClass;
+typedef struct _CamelMapiStoreSummaryPrivate CamelMapiStoreSummaryPrivate;
 
 typedef struct _CamelMapiStoreInfo CamelMapiStoreInfo;
 
@@ -54,9 +70,8 @@ struct _CamelMapiStoreInfo {
 };
 
 struct _CamelMapiStoreSummary {
-	CamelStoreSummary summary;
-
-	struct _CamelMapiStoreSummaryPrivate *priv;
+	CamelStoreSummary parent;
+	CamelMapiStoreSummaryPrivate *priv;
 
 	/* header info */
 	guint32 version;        /* version of base part of file */
@@ -67,7 +82,7 @@ struct _CamelMapiStoreSummaryClass {
 	CamelStoreSummaryClass summary_class;
 };
 
-CamelType                        camel_mapi_store_summary_get_type      (void);
+GType                        camel_mapi_store_summary_get_type      (void);
 CamelMapiStoreSummary      *camel_mapi_store_summary_new        (void);
 CamelMapiStoreInfo *camel_mapi_store_summary_full_name(CamelMapiStoreSummary *s, const gchar *full_name);
 CamelMapiStoreInfo *camel_mapi_store_summary_add_from_full(CamelMapiStoreSummary *s, const gchar *full, gchar dir_sep,
@@ -83,4 +98,4 @@ gchar *camel_mapi_store_summary_full_from_path(CamelMapiStoreSummary *s, const g
 
 G_END_DECLS
 
-#endif /* _CAMEL_MAPI_STORE_SUMMARY_H */
+#endif /* CAMEL_MAPI_STORE_SUMMARY_H */
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 86a563d..a308218 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -57,6 +57,10 @@
 
 #define d(x) printf("%s:%s:%s \n", G_STRLOC, G_STRFUNC, x)
 
+#define CAMEL_MAPI_STORE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), CAMEL_TYPE_MAPI_STORE, CamelMapiStorePrivate))
+
 struct _CamelMapiStorePrivate {
 	gchar *profile;
 	ExchangeMapiConnection *conn;
@@ -73,11 +77,7 @@ struct _CamelMapiStorePrivate {
 	gpointer notification_data; /* pointer to a notification data; can be only one */
 };
 
-static CamelOfflineStoreClass *parent_class = NULL;
-
-static void	camel_mapi_store_class_init(CamelMapiStoreClass *);
-static void	camel_mapi_store_init(CamelMapiStore *, CamelMapiStoreClass *);
-static void	camel_mapi_store_finalize(CamelObject *);
+G_DEFINE_TYPE (CamelMapiStore, camel_mapi_store, CAMEL_TYPE_OFFLINE_STORE)
 
 /* service methods */
 static gboolean	mapi_construct(CamelService *, CamelSession *,
@@ -158,23 +158,71 @@ mapi_compare_folder_name(gconstpointer a, gconstpointer b)
 }
 
 static void
-camel_mapi_store_class_init(CamelMapiStoreClass *klass)
+mapi_store_dispose (GObject *object)
+{
+	CamelMapiStorePrivate *priv;
+
+	priv = CAMEL_MAPI_STORE_GET_PRIVATE (object);
+
+	if (priv->conn != NULL) {
+		g_object_unref (priv->conn);
+		priv->conn = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (camel_mapi_store_parent_class)->dispose (object);
+}
+
+static void
+mapi_store_finalize (GObject *object)
+{
+	CamelMapiStorePrivate *priv;
+
+	priv = CAMEL_MAPI_STORE_GET_PRIVATE (object);
+
+	g_free (priv->profile);
+	g_free (priv->storage_path);
+	g_free (priv->base_url);
+
+	if (priv->id_hash != NULL)
+		g_hash_table_destroy (priv->id_hash);
+
+	if (priv->name_hash != NULL)
+		g_hash_table_destroy (priv->name_hash);
+
+	if (priv->parent_hash != NULL)
+		g_hash_table_destroy (priv->parent_hash);
+
+	if (priv->default_folders != NULL)
+		g_hash_table_destroy (priv->default_folders);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (camel_mapi_store_parent_class)->finalize (object);
+}
+
+static void
+camel_mapi_store_class_init (CamelMapiStoreClass *class)
 {
-	CamelServiceClass	*service_class =
-		CAMEL_SERVICE_CLASS (klass);
-	CamelStoreClass		*store_class = (CamelStoreClass *) klass;
+	GObjectClass *object_class;
+	CamelServiceClass *service_class;
+	CamelStoreClass *store_class;
+
+	g_type_class_add_private (class, sizeof (CamelMapiStorePrivate));
 
-	parent_class = (CamelOfflineStoreClass *) camel_type_get_global_classfuncs(CAMEL_TYPE_OFFLINE_STORE);
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = mapi_store_dispose;
+	object_class->finalize = mapi_store_finalize;
 
+	service_class = CAMEL_SERVICE_CLASS (class);
 	service_class->construct = mapi_construct;
 	service_class->get_name = mapi_get_name;
 	service_class->connect = mapi_connect;
 	service_class->disconnect = mapi_disconnect;
 	service_class->query_auth_types = mapi_query_auth_types;
 
+	store_class = CAMEL_STORE_CLASS (class);
 	store_class->hash_folder_name = mapi_hash_folder_name;
 	store_class->compare_folder_name = mapi_compare_folder_name;
-	/* store_class->get_inbox = mapi_get_inbox; */
 	store_class->get_folder = mapi_get_folder;
 	store_class->create_folder = mapi_create_folder;
 	store_class->delete_folder = mapi_delete_folder;
@@ -187,84 +235,15 @@ camel_mapi_store_class_init(CamelMapiStoreClass *klass)
 	store_class->noop = mapi_noop;
 }
 
-CamelType
-camel_mapi_store_get_type(void)
-{
-	static CamelType camel_mapi_store_type = CAMEL_INVALID_TYPE;
-
-	if (camel_mapi_store_type == CAMEL_INVALID_TYPE) {
-		camel_mapi_store_type = camel_type_register(camel_offline_store_get_type (),
-							    "CamelMapiStores",
-							    sizeof (CamelMapiStore),
-							    sizeof (CamelMapiStoreClass),
-							    (CamelObjectClassInitFunc) camel_mapi_store_class_init,
-							    NULL,
-							    (CamelObjectInitFunc) camel_mapi_store_init,
-							    (CamelObjectFinalizeFunc) camel_mapi_store_finalize);
-	}
-
-	return camel_mapi_store_type;
-}
-
 /*
 ** store is already initilyse to NULL or 0 value
-** klass already have a parent_class
+** class already have a parent_class
 ** nothing must be doing here
 */
-static void camel_mapi_store_init(CamelMapiStore *store, CamelMapiStoreClass *klass)
-{
-	CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
-	CamelMapiStorePrivate *priv = g_new0 (CamelMapiStorePrivate, 1);
-
-	mapi_store->summary = NULL;
-
-	priv->conn = NULL;
-	priv->storage_path = NULL;
-	priv->base_url = NULL;
-	priv->folders_synced = FALSE;
-	priv->notification_data = NULL;
-
-	mapi_store->priv = priv;
-
-}
-
-static void camel_mapi_store_finalize(CamelObject *object)
+static void
+camel_mapi_store_init (CamelMapiStore *mapi_store)
 {
-	CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (object);
-
-	if (mapi_store && mapi_store->priv) {
-		CamelMapiStorePrivate *priv = mapi_store->priv;
-
-		#define freeStr(x)		\
-			if (x) {		\
-				g_free (x);	\
-				x = NULL;	\
-			}
-		#define destroyHash(h)				\
-			if (h) {				\
-				g_hash_table_destroy (h);	\
-				h = NULL;			\
-			}
-
-		freeStr (priv->profile);
-		freeStr (priv->storage_path);
-		freeStr (priv->base_url);
-		destroyHash (priv->id_hash);
-		destroyHash (priv->name_hash);
-		destroyHash (priv->parent_hash);
-		destroyHash (priv->default_folders);
-
-		if (priv->conn) {
-			g_object_unref (priv->conn);
-			priv->conn = NULL;
-		}
-
-		#undef freeStr
-		#undef destroyHash
-
-		g_free (mapi_store->priv);
-		mapi_store->priv = NULL;
-	}
+	mapi_store->priv = CAMEL_MAPI_STORE_GET_PRIVATE (mapi_store);
 }
 
 /* service methods */
@@ -277,7 +256,7 @@ static gboolean mapi_construct(CamelService *service, CamelSession *session,
 	CamelMapiStorePrivate *priv = mapi_store->priv;
 	gchar *path = NULL;
 
-	if (!CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex))
+	if (!CAMEL_SERVICE_CLASS (camel_mapi_store_parent_class)->construct (service, session, provider, url, ex))
 		return FALSE;
 
 /*	if (!(url->host || url->user)) { */
@@ -671,7 +650,7 @@ mapi_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *
 	if (status) {
 		/* Fixme ??  */
 /*		if (mapi_store->current_folder) */
-/*			camel_object_unref (mapi_store->current_folder); */
+/*			g_object_unref (mapi_store->current_folder); */
 		mapi_forget_folder(mapi_store,folder_name,ex);
 
 		/* remove from name_cache at the end, because the folder_id is from there */
diff --git a/src/camel/camel-mapi-store.h b/src/camel/camel-mapi-store.h
index 67137a0..fa25992 100644
--- a/src/camel/camel-mapi-store.h
+++ b/src/camel/camel-mapi-store.h
@@ -21,8 +21,8 @@
  *
  */
 
-#ifndef __CAMEL_MAPI_STORE_H__
-#define __CAMEL_MAPI_STORE_H__
+#ifndef CAMEL_MAPI_STORE_H
+#define CAMEL_MAPI_STORE_H
 
 #include <glib/gi18n.h>
 
@@ -31,10 +31,24 @@
 #include <exchange-mapi-connection.h>
 #include <exchange-mapi-folder.h>
 
-#define CAMEL_MAPI_STORE_TYPE     (camel_mapi_store_get_type ())
-#define CAMEL_MAPI_STORE(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_MAPI_STORE_TYPE, CamelMapiStore))
-#define CAMEL_MAPI_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MAPI_STORE_TYPE, CamelMapiStoreClass))
-#define CAMEL_IS_MAPI_STORE(o)    (CAMEL_CHECK_TYPE((o), CAMEL_MAPI_STORE_TYPE))
+/* Standard GObject macros */
+#define CAMEL_TYPE_MAPI_STORE \
+	(camel_mapi_store_get_type ())
+#define CAMEL_MAPI_STORE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), CAMEL_TYPE_MAPI_STORE, CamelMapiStore))
+#define CAMEL_MAPI_STORE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), CAMEL_TYPE_MAPI_STORE, CamelMapiStoreClass))
+#define CAMEL_IS_MAPI_STORE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), CAMEL_TYPE_MAPI_STORE))
+#define CAMEL_IS_MAPI_STORE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), CAMEL_TYPE_MAPI_STORE))
+#define CAMEL_MAPI_STORE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), CAMEL_TYPE_MAPI_STORE, CamelMapiStoreClass))
 
 /* TODO : Move this to libcamel. Task when merging */
 #define CAMEL_FOLDER_FLAGS_LAST (1<<13)
@@ -43,6 +57,8 @@
 #define CAMEL_MAPI_FOLDER_PERSONAL (CAMEL_FOLDER_FLAGS_LAST << 2)
 #define CAMEL_MAPI_FOLDER_FORIEGN (CAMEL_FOLDER_FLAGS_LAST << 3)
 
+G_BEGIN_DECLS
+
 /**
  * definition of CamelMAPIStore
  */
@@ -64,26 +80,14 @@ struct _CamelMapiStore{
 };
 
 struct _CamelMapiStoreClass {
-	CamelOfflineStoreClass		parent_class;
+	CamelOfflineStoreClass parent_class;
 };
 
 /**
  * PROTOTYPES
  */
 
-#ifndef __BEGIN_DECLS
-#ifdef __cplusplus
-#define __BEGIN_DECLS		extern "C" {
-#define __END_DECLS		}
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-#endif
-
-__BEGIN_DECLS
-/* Standard Camel function */
-CamelType camel_mapi_store_get_type(void);
+GType camel_mapi_store_get_type(void);
 gboolean camel_mapi_store_connected(CamelMapiStore *, CamelException *);
 
 const gchar * camel_mapi_store_folder_id_lookup (CamelMapiStore *mapi_store, const gchar *folder_name);
@@ -97,6 +101,6 @@ void camel_mapi_store_unset_notification_data (CamelMapiStore *mstore);
 
 ExchangeMapiConnection *camel_mapi_store_get_exchange_connection (CamelMapiStore *mapi_store);
 
-__END_DECLS
+G_END_DECLS
 
-#endif /* __CAMEL_OPENCHANGE_STORE_H__ */
+#endif /* CAMEL_OPENCHANGE_STORE_H */
diff --git a/src/camel/camel-mapi-summary.c b/src/camel/camel-mapi-summary.c
index 00b536c..b285af9 100644
--- a/src/camel/camel-mapi-summary.c
+++ b/src/camel/camel-mapi-summary.c
@@ -49,31 +49,19 @@ static CamelMIRecord *mapi_message_info_to_db (CamelFolderSummary *s, CamelMessa
 static CamelMessageContentInfo * mapi_content_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
 static gint mapi_content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir);
 
-static void camel_mapi_summary_class_init (CamelMapiSummaryClass *klass);
-static void camel_mapi_summary_init       (CamelMapiSummary *obj);
-static void camel_mapi_summary_finalize   (CamelObject *obj);
-
 /*End of Prototypes*/
 
-static CamelFolderSummaryClass *camel_mapi_summary_parent;
+G_DEFINE_TYPE (CamelMapiSummary, camel_mapi_summary, CAMEL_TYPE_FOLDER_SUMMARY)
 
-CamelType
-camel_mapi_summary_get_type (void)
+static void
+mapi_summary_finalize (GObject *object)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register(
-				camel_folder_summary_get_type(), "CamelMapiSummary",
-				sizeof (CamelMapiSummary),
-				sizeof (CamelMapiSummaryClass),
-				(CamelObjectClassInitFunc) camel_mapi_summary_class_init,
-				NULL,
-				(CamelObjectInitFunc) camel_mapi_summary_init,
-				(CamelObjectFinalizeFunc) camel_mapi_summary_finalize);
-	}
+	CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (object);
 
-	return type;
+	g_free (mapi_summary->sync_time_stamp);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (camel_mapi_summary_parent_class)->finalize (object);
 }
 
 static CamelMessageInfo *
@@ -81,8 +69,12 @@ mapi_message_info_clone(CamelFolderSummary *s, const CamelMessageInfo *mi)
 {
 	CamelMapiMessageInfo *to;
 	const CamelMapiMessageInfo *from = (const CamelMapiMessageInfo *)mi;
+	CamelFolderSummaryClass *folder_summary_class;
+
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
+		camel_mapi_summary_parent_class);
 
-	to = (CamelMapiMessageInfo *)camel_mapi_summary_parent->message_info_clone(s, mi);
+	to = (CamelMapiMessageInfo *)folder_summary_class->message_info_clone(s, mi);
 	to->server_flags = from->server_flags;
 
 	/* FIXME: parent clone should do this */
@@ -92,40 +84,33 @@ mapi_message_info_clone(CamelFolderSummary *s, const CamelMessageInfo *mi)
 }
 
 static void
-camel_mapi_summary_class_init (CamelMapiSummaryClass *klass)
+camel_mapi_summary_class_init (CamelMapiSummaryClass *class)
 {
-	CamelFolderSummaryClass *cfs_class = (CamelFolderSummaryClass *) klass;
-
-	camel_mapi_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS (camel_type_get_global_classfuncs (camel_folder_summary_get_type()));
-
-	cfs_class->message_info_size = sizeof(CamelMapiMessageInfo);
-	cfs_class->content_info_size = sizeof(CamelMapiMessageContentInfo);
-
-	cfs_class->message_info_clone = mapi_message_info_clone;
-
-	cfs_class->summary_header_to_db = mapi_summary_header_to_db;
-	cfs_class->summary_header_from_db = mapi_summary_header_from_db;
-	cfs_class->message_info_to_db = mapi_message_info_to_db;
-	cfs_class->message_info_from_db = mapi_message_info_from_db;
-	cfs_class->content_info_to_db = mapi_content_info_to_db;
-	cfs_class->content_info_from_db = mapi_content_info_from_db;
+	GObjectClass *object_class;
+	CamelFolderSummaryClass *folder_summary_class;
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = mapi_summary_finalize;
+
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+	folder_summary_class->message_info_size = sizeof (CamelMapiMessageInfo);
+	folder_summary_class->content_info_size = sizeof (CamelMapiMessageContentInfo);
+	folder_summary_class->message_info_clone = mapi_message_info_clone;
+	folder_summary_class->summary_header_to_db = mapi_summary_header_to_db;
+	folder_summary_class->summary_header_from_db = mapi_summary_header_from_db;
+	folder_summary_class->message_info_to_db = mapi_message_info_to_db;
+	folder_summary_class->message_info_from_db = mapi_message_info_from_db;
+	folder_summary_class->content_info_to_db = mapi_content_info_to_db;
+	folder_summary_class->content_info_from_db = mapi_content_info_from_db;
 }
 
 static void
-camel_mapi_summary_init (CamelMapiSummary *obj)
+camel_mapi_summary_init (CamelMapiSummary *mapi_summary)
 {
-	CamelFolderSummary *s = (CamelFolderSummary *)obj;
+	CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (mapi_summary);
 
 	/* Meta-summary - Overriding UID len */
-	s->meta_summary->uid_len = 2048;
-}
-
-static void
-camel_mapi_summary_finalize (CamelObject *obj)
-{
-	CamelMapiSummary *s = (CamelMapiSummary *)obj;
-
-	g_free (s->sync_time_stamp);
+	summary->meta_summary->uid_len = 2048;
 }
 
 /**
@@ -138,12 +123,12 @@ camel_mapi_summary_finalize (CamelObject *obj)
  * Return value: A new CamelMapiSummary object.
  **/
 CamelFolderSummary *
-camel_mapi_summary_new (struct _CamelFolder *folder, const gchar *filename)
+camel_mapi_summary_new (CamelFolder *folder, const gchar *filename)
 {
+	CamelFolderSummary *summary;
 	CamelException ex;
 
-	CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (
-			camel_object_new (camel_mapi_summary_get_type ()));
+	summary = g_object_new (CAMEL_TYPE_MAPI_SUMMARY, NULL);
 
 	camel_exception_init (&ex);
 
@@ -167,9 +152,13 @@ static gint
 mapi_summary_header_from_db (CamelFolderSummary *summary, CamelFIRecord *fir)
 {
 	CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (summary);
+	CamelFolderSummaryClass *folder_summary_class;
 	gchar *part;
 
-	if (camel_mapi_summary_parent->summary_header_from_db (summary, fir) == -1)
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
+		camel_mapi_summary_parent_class);
+
+	if (folder_summary_class->summary_header_from_db (summary, fir) == -1)
 		return -1;
 
 	part = fir->bdata;
@@ -188,9 +177,13 @@ static CamelFIRecord *
 mapi_summary_header_to_db (CamelFolderSummary *summary, CamelException *ex)
 {
 	CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY(summary);
+	CamelFolderSummaryClass *folder_summary_class;
 	struct _CamelFIRecord *fir;
 
-	fir = camel_mapi_summary_parent->summary_header_to_db (summary, ex);
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
+		camel_mapi_summary_parent_class);
+
+	fir = folder_summary_class->summary_header_to_db (summary, ex);
 
 	if (!fir)
 		return NULL;
@@ -203,9 +196,13 @@ mapi_summary_header_to_db (CamelFolderSummary *summary, CamelException *ex)
 static CamelMessageInfo*
 mapi_message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir)
 {
+	CamelFolderSummaryClass *folder_summary_class;
 	CamelMessageInfo *info;
 
-	info = camel_mapi_summary_parent->message_info_from_db (s, mir);
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
+		camel_mapi_summary_parent_class);
+
+	info = folder_summary_class->message_info_from_db (s, mir);
 
 	return info;
 }
@@ -213,9 +210,13 @@ mapi_message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir)
 static CamelMIRecord *
 mapi_message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info)
 {
+	CamelFolderSummaryClass *folder_summary_class;
 	struct _CamelMIRecord *mir;
 
-	mir = camel_mapi_summary_parent->message_info_to_db (s, info);
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
+		camel_mapi_summary_parent_class);
+
+	mir = folder_summary_class->message_info_to_db (s, info);
 
 	return mir;
 }
@@ -223,16 +224,20 @@ mapi_message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info)
 static CamelMessageContentInfo*
 mapi_content_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir)
 {
+	CamelFolderSummaryClass *folder_summary_class;
 	gchar *part = mir->cinfo;
 	guint32 type=0;
 
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
+		camel_mapi_summary_parent_class);
+
 	if (part)
 		MS_EXTRACT_FIRST_DIGIT (type);
 
 	mir->cinfo = part;
 
 	if (type)
-		return camel_mapi_summary_parent->content_info_from_db (s, mir);
+		return folder_summary_class->content_info_from_db (s, mir);
 	else
 		return camel_folder_summary_content_info_new (s);
 }
@@ -240,9 +245,14 @@ mapi_content_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir)
 static gint
 mapi_content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir)
 {
+	CamelFolderSummaryClass *folder_summary_class;
+
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
+		camel_mapi_summary_parent_class);
+
 	if (info->type) {
 		mir->cinfo = g_strdup ("1");
-		return camel_mapi_summary_parent->content_info_to_db (s, info, mir);
+		return folder_summary_class->content_info_to_db (s, info, mir);
 	} else {
 		mir->cinfo = g_strdup ("0");
 		return 0;
diff --git a/src/camel/camel-mapi-summary.h b/src/camel/camel-mapi-summary.h
index c1a133a..2311a19 100644
--- a/src/camel/camel-mapi-summary.h
+++ b/src/camel/camel-mapi-summary.h
@@ -21,14 +21,29 @@
  *
  */
 
-#ifndef _CAMEL_MAPI_SUMMARY_H
-#define _CAMEL_MAPI_SUMMARY_H
+#ifndef CAMEL_MAPI_SUMMARY_H
+#define CAMEL_MAPI_SUMMARY_H
 
 #include <camel/camel.h>
 
-#define CAMEL_MAPI_SUMMARY(obj)         CAMEL_CHECK_CAST (obj, camel_mapi_summary_get_type (), CamelMapiSummary)
-#define CAMEL_MAPI_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mapi_summary_get_type (), CamelMapiSummaryClass)
-#define CAMEL_IS_MAPI_SUMMARY(obj)      CAMEL_CHECK_TYPE (obj, camel_mapi_summary_get_type ())
+/* Standard GObject macros */
+#define CAMEL_TYPE_MAPI_SUMMARY \
+	(camel_mapi_summary_get_type ())
+#define CAMEL_MAPI_SUMMARY(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), CAMEL_TYPE_MAPI_SUMMARY, CamelMapiSummary))
+#define CAMEL_MAPI_SUMMARY_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), CAMEL_TYPE_MAPI_SUMMARY, CamelMapiSummaryClass)
+#define CAMEL_IS_MAPI_SUMMARY(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), CAMEL_TYPE_MAPI_SUMMARY))
+#define CAMEL_IS_MAPI_SUMMARY_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), CAMEL_TYPE_MAPI_SUMMARY))
+#define CAMEL_MAPI_SUMMARY_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), CAMEL_TYPE_MAPI_SUMMARY, CamelMapiSummaryClass))
 
 G_BEGIN_DECLS
 
@@ -47,11 +62,11 @@ struct _CamelMapiMessageInfo {
 	CamelMessageInfoBase info;
 
 	guint32 server_flags;
-} ;
+};
 
 struct _CamelMapiMessageContentInfo {
 	CamelMessageContentInfo info;
-} ;
+};
 
 struct _CamelMapiSummary {
 	CamelFolderSummary parent;
@@ -59,13 +74,13 @@ struct _CamelMapiSummary {
 	gchar *sync_time_stamp;
 	guint32 version;
 	guint32 validity;
-} ;
+};
 
 struct _CamelMapiSummaryClass {
 	CamelFolderSummaryClass parent_class;
-} ;
+};
 
-CamelType camel_mapi_summary_get_type (void);
+GType camel_mapi_summary_get_type (void);
 
 CamelFolderSummary *camel_mapi_summary_new (struct _CamelFolder *folder, const gchar *filename);
 
@@ -73,4 +88,4 @@ void mapi_summary_clear (CamelFolderSummary *summary, gboolean uncache);
 
 G_END_DECLS
 
-#endif /*_CAMEL_GW_SUMMARY_H*/
+#endif /* CAMEL_MAPI_SUMMARY_H*/
diff --git a/src/camel/camel-mapi-transport.c b/src/camel/camel-mapi-transport.c
index 6517ce6..c84190d 100644
--- a/src/camel/camel-mapi-transport.c
+++ b/src/camel/camel-mapi-transport.c
@@ -53,6 +53,8 @@ CamelStore *get_store(void);
 
 void	set_store(CamelStore *);
 
+G_DEFINE_TYPE (CamelMapiTransport, camel_mapi_transport, CAMEL_TYPE_TRANSPORT)
+
 /*CreateItem would return the MID of the new message or '0' if we fail.*/
 static mapi_id_t
 mapi_message_item_send (ExchangeMapiConnection *conn, MapiItem *item)
@@ -124,40 +126,21 @@ mapi_transport_get_name(CamelService *service, gboolean brief)
 }
 
 static void
-camel_mapi_transport_class_init(CamelMapiTransportClass *camel_mapi_transport_class)
+camel_mapi_transport_class_init (CamelMapiTransportClass *class)
 {
-	CamelTransportClass *camel_transport_class =
-		CAMEL_TRANSPORT_CLASS (camel_mapi_transport_class);
-	CamelServiceClass *camel_service_class =
-		CAMEL_SERVICE_CLASS (camel_mapi_transport_class);
+	CamelServiceClass *service_class;
+	CamelTransportClass *transport_class;
 
-	camel_service_class->get_name = mapi_transport_get_name;
-	camel_transport_class->send_to = mapi_send_to;
-}
-
-static void
-camel_mapi_transport_init (CamelTransport *transport)
-{
+	service_class = CAMEL_SERVICE_CLASS (class);
+	service_class->get_name = mapi_transport_get_name;
 
+	transport_class = CAMEL_TRANSPORT_CLASS (class);
+	transport_class->send_to = mapi_send_to;
 }
 
-CamelType
-camel_mapi_transport_get_type (void)
+static void
+camel_mapi_transport_init (CamelMapiTransport *transport)
 {
-	static CamelType camel_mapi_transport_type = CAMEL_INVALID_TYPE;
-
-	if (camel_mapi_transport_type == CAMEL_INVALID_TYPE) {
-		camel_mapi_transport_type =
-			camel_type_register (CAMEL_TRANSPORT_TYPE,
-					     "CamelMapiTransport",
-					     sizeof (CamelMapiTransport),
-					     sizeof (CamelMapiTransportClass),
-					     (CamelObjectClassInitFunc) camel_mapi_transport_class_init,
-					     NULL,
-					     (CamelObjectInitFunc) camel_mapi_transport_init,
-					     NULL);
-	}
 
-	return camel_mapi_transport_type;
 }
 
diff --git a/src/camel/camel-mapi-transport.h b/src/camel/camel-mapi-transport.h
index d2d9992..49a34b3 100644
--- a/src/camel/camel-mapi-transport.h
+++ b/src/camel/camel-mapi-transport.h
@@ -22,32 +22,46 @@
  */
 
 #ifndef CAMEL_MAPI_TRANSPORT_H
-#define CAMEL_MAPI_TRANSPORT_H 1
+#define CAMEL_MAPI_TRANSPORT_H
 
 #include <camel/camel.h>
 #include <libmapi/libmapi.h>
 #include <exchange-mapi-connection.h>
 
-#define CAMEL_MAPI_TRANSPORT_TYPE     (camel_mapi_transport_get_type ())
-#define CAMEL_MAPI_TRANSPORT(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_MAPI_TRANSPORT_TYPE, CamelMapiTransport))
-#define CAMEL_MAPI_TRANSPORT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MAPI_TRANSPORT_TYPE, CamelMapiTransportClass))
-#define CAMEL_IS_MAPI_TRANSPORT(o)    (CAMEL_CHECK_TYPE((o), CAMEL_MAPI_TRANSPORT_TYPE))
+/* Standard GObject macros */
+#define CAMEL_TYPE_MAPI_TRANSPORT \
+	(camel_mapi_transport_get_type ())
+#define CAMEL_MAPI_TRANSPORT(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), CAMEL_TYPE_MAPI_TRANSPORT, CamelMapiTransport))
+#define CAMEL_MAPI_TRANSPORT_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), CAMEL_TYPE_MAPI_TRANSPORT, CamelMapiTransportClass))
+#define CAMEL_IS_MAPI_TRANSPORT(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), CAMEL_TYPE_MAPI_TRANSPORT))
+#define CAMEL_IS_MAPI_TRANSPORT_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), CAMEL_TYPE_MAPI_TRANSPORT))
+#define CAMEL_MAPI_TRANSPORT_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), CAMEL_TYPE_MAPI_TRANSPORT, CamelMapiTransportClass))
 
 G_BEGIN_DECLS
 
-typedef struct {
-	CamelTransport parent_object;
-	gboolean connected;
+typedef struct _CamelMapiTransport CamelMapiTransport;
+typedef struct _CamelMapiTransportClass CamelMapiTransportClass;
 
-} CamelMapiTransport;
+struct _CamelMapiTransport {
+	CamelTransport parent;
+	gboolean connected;
+};
 
-typedef struct {
+struct _CamelMapiTransportClass {
 	CamelTransportClass parent_class;
+};
 
-} CamelMapiTransportClass;
-
-/* Standard Camel function */
-CamelType camel_mapi_transport_get_type (void);
+GType camel_mapi_transport_get_type (void);
 
 G_END_DECLS
 
diff --git a/src/camel/camel-mapi-utils.h b/src/camel/camel-mapi-utils.h
index b53633e..d28cfae 100644
--- a/src/camel/camel-mapi-utils.h
+++ b/src/camel/camel-mapi-utils.h
@@ -21,8 +21,8 @@
  *
  */
 
-#ifndef __CAMEL_MAPI_UTILS_H__
-#define __CAMEL_MAPI_UTILS_H__
+#ifndef CAMEL_MAPI_UTILS_H
+#define CAMEL_MAPI_UTILS_H
 
 G_BEGIN_DECLS
 



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