From 8cb514d6dd9497893a35a089d07a132d51263ee7 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Thu, 10 Aug 2000 17:30:50 +0000 Subject: Merge with camel-async. svn path=/trunk/; revision=4687 --- camel/providers/Makefile.am | 1 + camel/providers/imap/camel-imap-folder.c | 73 +-- camel/providers/imap/camel-imap-folder.h | 11 +- camel/providers/imap/camel-imap-store.c | 84 ++-- camel/providers/imap/camel-imap-store.h | 12 +- camel/providers/imap/camel-imap-stream.c | 52 +-- camel/providers/imap/camel-imap-stream.h | 10 +- camel/providers/mbox/camel-mbox-folder.c | 485 ++++++++++---------- camel/providers/mbox/camel-mbox-folder.h | 11 +- camel/providers/mbox/camel-mbox-store.c | 34 +- camel/providers/mbox/camel-mbox-store.h | 11 +- camel/providers/mbox/camel-mbox-summary.c | 494 ++++++++++----------- camel/providers/mbox/camel-mbox-summary.h | 7 +- camel/providers/mh/camel-mh-folder.c | 64 ++- camel/providers/mh/camel-mh-folder.h | 11 +- camel/providers/mh/camel-mh-store.c | 44 +- camel/providers/mh/camel-mh-store.h | 11 +- camel/providers/mh/camel-mh-summary.c | 44 +- camel/providers/mh/camel-mh-summary.h | 9 +- camel/providers/nntp/Makefile.am | 5 +- camel/providers/nntp/camel-nntp-folder.c | 52 +-- camel/providers/nntp/camel-nntp-folder.h | 11 +- camel/providers/nntp/camel-nntp-provider.c | 7 +- camel/providers/nntp/camel-nntp-store.c | 46 +- camel/providers/nntp/camel-nntp-store.h | 11 +- camel/providers/pop3/camel-pop3-folder.c | 42 +- camel/providers/pop3/camel-pop3-folder.h | 11 +- camel/providers/pop3/camel-pop3-store.c | 38 +- camel/providers/pop3/camel-pop3-store.h | 11 +- .../providers/sendmail/camel-sendmail-transport.c | 30 +- .../providers/sendmail/camel-sendmail-transport.h | 10 +- camel/providers/smtp/camel-smtp-transport.c | 38 +- camel/providers/smtp/camel-smtp-transport.h | 10 +- camel/providers/vee/camel-vee-folder.c | 61 +-- camel/providers/vee/camel-vee-folder.h | 7 +- camel/providers/vee/camel-vee-store.c | 50 +-- camel/providers/vee/camel-vee-store.h | 7 +- 37 files changed, 901 insertions(+), 1014 deletions(-) (limited to 'camel/providers') diff --git a/camel/providers/Makefile.am b/camel/providers/Makefile.am index 357956d8c6..dedeaa0b3b 100644 --- a/camel/providers/Makefile.am +++ b/camel/providers/Makefile.am @@ -1,5 +1,6 @@ ## Process this file with automake to produce Makefile.in +# SUBDIRS = mbox pop3 sendmail smtp vee SUBDIRS = mbox pop3 sendmail smtp vee imap mh nntp # these ones are disabled for the moment. diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 9ab729d218..87554b120d 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -55,7 +55,7 @@ #define d(x) x -#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (GTK_OBJECT (o)->klass)) +#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(o))) static CamelFolderClass *parent_class = NULL; @@ -64,8 +64,6 @@ static void imap_init (CamelFolder *folder, CamelStore *parent_store, gchar *separator, gboolean path_begns_with_sep, CamelException *ex); -static void imap_finalize (GtkObject *object); - static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); static void imap_expunge (CamelFolder *folder, CamelException *ex); @@ -88,6 +86,8 @@ static const CamelMessageInfo *imap_get_message_info (CamelFolder *folder, const static GPtrArray *imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex); +static void imap_finalize (CamelObject *object); + /* flag methods */ static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid); static void imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); @@ -100,9 +100,8 @@ static void camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class) { CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_imap_folder_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_class); - parent_class = gtk_type_class (camel_folder_get_type ()); + parent_class = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs (camel_folder_get_type ())); /* virtual method definition */ @@ -133,8 +132,6 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class) camel_folder_class->set_message_flags = imap_set_message_flags; camel_folder_class->get_message_user_flag = imap_get_message_user_flag; camel_folder_class->set_message_user_flag = imap_set_message_user_flag; - - gtk_object_class->finalize = imap_finalize; } static void @@ -153,25 +150,19 @@ camel_imap_folder_init (gpointer object, gpointer klass) imap_folder->lsub = NULL; } -GtkType +CamelType camel_imap_folder_get_type (void) { - static GtkType camel_imap_folder_type = 0; - - if (!camel_imap_folder_type) { - GtkTypeInfo camel_imap_folder_info = - { - "CamelImapFolder", - sizeof (CamelImapFolder), - sizeof (CamelImapFolderClass), - (GtkClassInitFunc) camel_imap_folder_class_init, - (GtkObjectInitFunc) camel_imap_folder_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_imap_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_imap_folder_info); + static CamelType camel_imap_folder_type = CAMEL_INVALID_TYPE; + + if (camel_imap_folder_type == CAMEL_INVALID_TYPE) { + camel_imap_folder_type = camel_type_register (CAMEL_FOLDER_TYPE, "CamelImapFolder", + sizeof (CamelImapFolder), + sizeof (CamelImapFolderClass), + (CamelObjectClassInitFunc) camel_imap_folder_class_init, + NULL, + (CamelObjectInitFunc) camel_imap_folder_init, + (CamelObjectFinalizeFunc) imap_finalize); } return camel_imap_folder_type; @@ -180,7 +171,7 @@ camel_imap_folder_get_type (void) CamelFolder * camel_imap_folder_new (CamelStore *parent, char *folder_name, CamelException *ex) { - CamelFolder *folder = CAMEL_FOLDER (gtk_object_new (camel_imap_folder_get_type (), NULL)); + CamelFolder *folder = CAMEL_FOLDER (camel_object_new (camel_imap_folder_get_type ())); CamelURL *url = CAMEL_SERVICE (parent)->url; char *dir_sep; @@ -238,7 +229,7 @@ imap_folder_summary_free (CamelImapFolder *imap_folder) } static void -imap_finalize (GtkObject *object) +imap_finalize (CamelObject *object) { /* TODO: do we need to do more cleanup here? */ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object); @@ -964,9 +955,9 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex) camel_stream_filter_remove (f_stream, id); camel_stream_close (CAMEL_STREAM (f_stream)); #endif - gtk_object_unref (GTK_OBJECT (msgstream)); - /*gtk_object_unref (GTK_OBJECT (f_stream));*/ - + camel_object_unref (CAMEL_OBJECT (msgstream)); + /*camel_object_unref (CAMEL_OBJECT (f_stream));*/ + d(fprintf (stderr, "*** We're returning... ***\n")); return msg; @@ -991,7 +982,7 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex) /* Temp hack - basically we read in the entire message instead of getting a part as it's needed */ msgstream = camel_stream_mem_new (); camel_stream_write_to_stream (CAMEL_STREAM (imap_stream), msgstream); - gtk_object_unref (GTK_OBJECT (imap_stream)); + camel_object_unref (CAMEL_OBJECT (imap_stream)); f_stream = camel_stream_filter_new_with_stream (msgstream); filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS); @@ -1005,13 +996,13 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex) camel_stream_filter_remove (f_stream, id); camel_stream_close (CAMEL_STREAM (f_stream)); - gtk_object_unref (GTK_OBJECT (msgstream)); - gtk_object_unref (GTK_OBJECT (f_stream)); + camel_object_unref (CAMEL_OBJECT (msgstream)); + camel_object_unref (CAMEL_OBJECT (f_stream)); /*camel_data_wrapper_set_mime_type (cdw, "text/plain");*/ /*camel_medium_set_content_object (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (cdw));*/ - /*gtk_object_unref (GTK_OBJECT (cdw));*/ + /*camel_object_unref (CAMEL_OBJECT (cdw));*/ return msg; #endif @@ -1492,6 +1483,13 @@ imap_search_by_expression (CamelFolder *folder, const char *expression, CamelExc return uids; } +static guint32 +imap_get_permanent_flags (CamelFolder *folder, CamelException *ex) +{ + /* return permamnant flags */ + return folder->permanent_flags; +} + static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid) { @@ -1513,7 +1511,8 @@ imap_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, gui info->flags = (info->flags & ~flags) | (set & flags) | CAMEL_MESSAGE_FOLDER_FLAGGED; - gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid); + /*gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid);*/ + camel_object_trigger_event (CAMEL_OBJECT (folder), "message_changed", uid); } static gboolean @@ -1525,7 +1524,8 @@ imap_get_message_user_flag (CamelFolder *folder, const char *uid, const char *na static void imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value) { - gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid); + /*gtk_signal_emit_by_name (GTK_OBJECT (folder), "message_changed", uid);*/ + camel_object_trigger_event (CAMEL_OBJECT (folder), "message_changed", uid); } void @@ -1561,5 +1561,6 @@ camel_imap_folder_changed (CamelFolder *folder, gint recent, CamelException *ex) } } - gtk_signal_emit_by_name (GTK_OBJECT (folder), "folder_changed", 0); + /*gtk_signal_emit_by_name (GTK_OBJECT (folder), "folder_changed", 0);*/ + camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", GINT_TO_POINTER (0)); } diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h index d87df24905..bd1647c300 100644 --- a/camel/providers/imap/camel-imap-folder.h +++ b/camel/providers/imap/camel-imap-folder.h @@ -33,14 +33,13 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include "camel-folder.h" #include #define CAMEL_IMAP_FOLDER_TYPE (camel_imap_folder_get_type ()) -#define CAMEL_IMAP_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_IMAP_FOLDER_TYPE, CamelImapFolder)) -#define CAMEL_IMAP_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_IMAP_FOLDER_TYPE, CamelImapFolderClass)) -#define IS_CAMEL_IMAP_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_IMAP_FOLDER_TYPE)) +#define CAMEL_IMAP_FOLDER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_IMAP_FOLDER_TYPE, CamelImapFolder)) +#define CAMEL_IMAP_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_IMAP_FOLDER_TYPE, CamelImapFolderClass)) +#define IS_CAMEL_IMAP_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_IMAP_FOLDER_TYPE)) typedef struct { CamelFolder parent_object; @@ -68,8 +67,8 @@ CamelFolder *camel_imap_folder_new (CamelStore *parent, char *folder_name, void camel_imap_folder_changed (CamelFolder *folder, gint recent, CamelException *ex); -/* Standard Gtk function */ -GtkType camel_imap_folder_get_type (void); +/* Standard Camel function */ +CamelType camel_imap_folder_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 2fc530f357..374107250d 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -56,7 +56,7 @@ static CamelServiceClass *service_class = NULL; -static void finalize (GtkObject *object); +static void finalize (CamelObject *object); static gboolean imap_create (CamelFolder *folder, CamelException *ex); static gboolean imap_connect (CamelService *service, CamelException *ex); static gboolean imap_disconnect (CamelService *service, CamelException *ex); @@ -74,18 +74,14 @@ static void camel_imap_store_class_init (CamelImapStoreClass *camel_imap_store_class) { /* virtual method overload */ - GtkObjectClass *object_class = - GTK_OBJECT_CLASS (camel_imap_store_class); CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_imap_store_class); CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_imap_store_class); - service_class = gtk_type_class (camel_service_get_type ()); + service_class = CAMEL_SERVICE_CLASS(camel_type_get_global_classfuncs (camel_service_get_type ())); /* virtual method overload */ - object_class->finalize = finalize; - camel_service_class->connect = imap_connect; camel_service_class->disconnect = imap_disconnect; camel_service_class->query_auth_types = query_auth_types; @@ -107,37 +103,31 @@ camel_imap_store_init (gpointer object, gpointer klass) CAMEL_SERVICE_URL_ALLOW_PATH); store->folders = g_hash_table_new (g_str_hash, g_str_equal); - CAMEL_IMAP_STORE (store)->dir_sep = NULL; + CAMEL_IMAP_STORE (store)->dir_sep = g_strdup ("/"); /*default*/ CAMEL_IMAP_STORE (store)->current_folder = NULL; CAMEL_IMAP_STORE (store)->timeout_id = 0; } -GtkType +CamelType camel_imap_store_get_type (void) { - static GtkType camel_imap_store_type = 0; - - if (!camel_imap_store_type) { - GtkTypeInfo camel_imap_store_info = - { - "CamelImapStore", - sizeof (CamelImapStore), - sizeof (CamelImapStoreClass), - (GtkClassInitFunc) camel_imap_store_class_init, - (GtkObjectInitFunc) camel_imap_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_imap_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_imap_store_info); + static CamelType camel_imap_store_type = CAMEL_INVALID_TYPE; + + if (camel_imap_store_type == CAMEL_INVALID_TYPE) { + camel_imap_store_type = camel_type_register (CAMEL_STORE_TYPE, "CamelImapStore", + sizeof (CamelImapStore), + sizeof (CamelImapStoreClass), + (CamelObjectClassInitFunc) camel_imap_store_class_init, + NULL, + (CamelObjectInitFunc) camel_imap_store_init, + (CamelObjectFinalizeFunc) finalize); } return camel_imap_store_type; } static void -finalize (GtkObject *object) +finalize (CamelObject *object) { CamelException ex; @@ -239,11 +229,13 @@ imap_connect (CamelService *service, CamelException *ex) gboolean authenticated = FALSE; /* FIXME: do we really need this here? */ - if (store->timeout_id) { - gtk_timeout_remove (store->timeout_id); - store->timeout_id = 0; - } - + /* + *if (store->timeout_id) { + * gtk_timeout_remove (store->timeout_id); + * store->timeout_id = 0; + *} + */ + h = camel_service_gethost (service, ex); if (!h) return FALSE; @@ -399,7 +391,10 @@ imap_connect (CamelService *service, CamelException *ex) g_free (result); /* Lets add a timeout so that we can hopefully prevent getting disconnected */ - store->timeout_id = gtk_timeout_add (600000, imap_noop, store); + /* FIXME fast timeout */ + store->timeout_id = camel_session_register_timeout (camel_service_get_session (service), + 10 * 60 * 1000, imap_noop, service); + /*store->timeout_id = gtk_timeout_add (600000, imap_noop, store);*/ return TRUE; } @@ -423,27 +418,28 @@ imap_disconnect (CamelService *service, CamelException *ex) if (!service_class->disconnect (service, ex)) return FALSE; - + if (store->istream) { - gtk_object_unref (GTK_OBJECT (store->istream)); + camel_object_unref (CAMEL_OBJECT (store->istream)); store->istream = NULL; } - + if (store->ostream) { - gtk_object_unref (GTK_OBJECT (store->ostream)); + camel_object_unref (CAMEL_OBJECT (store->ostream)); store->ostream = NULL; } - + g_free (store->dir_sep); store->dir_sep = NULL; - + store->current_folder = NULL; - + if (store->timeout_id) { - gtk_timeout_remove (store->timeout_id); + camel_session_remove_timeout (camel_service_get_session (CAMEL_SERVICE (store)), + store->timeout_id); store->timeout_id = 0; } - + return TRUE; } @@ -466,6 +462,8 @@ imap_folder_exists (CamelFolder *folder) dir_sep = CAMEL_IMAP_STORE (folder->parent_store)->dir_sep; + g_return_val_if_fail (dir_sep, FALSE); + if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX")) folder_path = g_strdup_printf ("%s%s%s", url->path + 1, dir_sep, folder->full_name); else @@ -510,6 +508,8 @@ imap_create (CamelFolder *folder, CamelException *ex) /* create the directory for the subfolder */ dir_sep = CAMEL_IMAP_STORE (folder->parent_store)->dir_sep; + g_return_val_if_fail (dir_sep, FALSE); + if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX")) folder_path = g_strdup_printf ("%s%s%s", url->path + 1, dir_sep, folder->full_name); else @@ -581,7 +581,7 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelEx dir_sep = CAMEL_IMAP_STORE (store)->dir_sep; /* if we're trying to get the top-level dir, we really want the namespace */ - if (!strcmp (folder_name, dir_sep)) + if (!dir_sep || !strcmp (folder_name, dir_sep)) folder_path = g_strdup (url->path + 1); else folder_path = g_strdup (folder_name); @@ -599,7 +599,7 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelEx return new_folder; } else { g_free (folder_path); - gtk_object_unref (GTK_OBJECT (new_folder)); + camel_object_unref (CAMEL_OBJECT (new_folder)); return NULL; } } diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index b8bb19f31c..a860fb84bd 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -32,13 +32,12 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include "camel-store.h" #define CAMEL_IMAP_STORE_TYPE (camel_imap_store_get_type ()) -#define CAMEL_IMAP_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_IMAP_STORE_TYPE, CamelImapStore)) -#define CAMEL_IMAP_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_IMAP_STORE_TYPE, CamelImapStoreClass)) -#define IS_CAMEL_IMAP_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_IMAP_STORE_TYPE)) +#define CAMEL_IMAP_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_IMAP_STORE_TYPE, CamelImapStore)) +#define CAMEL_IMAP_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_IMAP_STORE_TYPE, CamelImapStoreClass)) +#define IS_CAMEL_IMAP_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_IMAP_STORE_TYPE)) typedef enum { IMAP_LEVEL_UNKNOWN, @@ -46,6 +45,7 @@ typedef enum { IMAP_LEVEL_IMAP4REV1 } CamelImapServerLevel; + typedef struct { CamelStore parent_object; @@ -80,8 +80,8 @@ enum { CAMEL_IMAP_OK = 0, CAMEL_IMAP_NO, CAMEL_IMAP_BAD, CAMEL_IMAP_FAIL }; gint camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...); gint camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...); -/* Standard Gtk function */ -GtkType camel_imap_store_get_type (void); +/* Standard Camel function */ +CamelType camel_imap_store_get_type (void); const gchar *camel_imap_store_get_toplevel_dir (CamelImapStore *store); diff --git a/camel/providers/imap/camel-imap-stream.c b/camel/providers/imap/camel-imap-stream.c index eb0a48a735..7b885437a2 100644 --- a/camel/providers/imap/camel-imap-stream.c +++ b/camel/providers/imap/camel-imap-stream.c @@ -30,30 +30,26 @@ static CamelStreamClass *parent_class = NULL; /* Returns the class for a CamelImapStream */ -#define CIS_CLASS(so) CAMEL_IMAP_STREAM_CLASS (GTK_OBJECT(so)->klass) +#define CIS_CLASS(so) CAMEL_IMAP_STREAM_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n); static int stream_reset (CamelStream *stream); static gboolean stream_eos (CamelStream *stream); -static void finalize (GtkObject *object); +static void finalize (CamelObject *object); static void camel_imap_stream_class_init (CamelImapStreamClass *camel_imap_stream_class) { CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_imap_stream_class); - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_imap_stream_class); - parent_class = gtk_type_class (camel_stream_get_type ()); + parent_class = CAMEL_STREAM_CLASS(camel_type_get_global_classfuncs (camel_stream_get_type ())); /* virtual method overload */ camel_stream_class->read = stream_read; camel_stream_class->reset = stream_reset; camel_stream_class->eos = stream_eos; - - gtk_object_class->finalize = finalize; } static void @@ -65,25 +61,19 @@ camel_imap_stream_init (gpointer object, gpointer klass) imap_stream->cache_ptr = NULL; } -GtkType +CamelType camel_imap_stream_get_type (void) { - static GtkType camel_imap_stream_type = 0; - - if (!camel_imap_stream_type) { - GtkTypeInfo camel_imap_stream_info = - { - "CamelImapStream", - sizeof (CamelImapStream), - sizeof (CamelImapStreamClass), - (GtkClassInitFunc) camel_imap_stream_class_init, - (GtkObjectInitFunc) camel_imap_stream_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_imap_stream_type = gtk_type_unique (camel_stream_get_type (), &camel_imap_stream_info); + static CamelType camel_imap_stream_type = CAMEL_INVALID_TYPE; + + if (camel_imap_stream_type == CAMEL_INVALID_TYPE) { + camel_imap_stream_type = camel_type_register (camel_stream_get_type (), "CamelImapStream", + sizeof (CamelImapStream), + sizeof (CamelImapStreamClass), + (CamelObjectClassInitFunc) camel_imap_stream_class_init, + NULL, + (CamelObjectInitFunc) camel_imap_stream_init, + (CamelObjectFinalizeFunc) finalize); } return camel_imap_stream_type; @@ -94,10 +84,10 @@ camel_imap_stream_new (CamelImapFolder *folder, char *command) { CamelImapStream *imap_stream; - imap_stream = gtk_type_new (camel_imap_stream_get_type ()); + imap_stream = CAMEL_IMAP_STREAM(camel_object_new (camel_imap_stream_get_type ())); imap_stream->folder = folder; - gtk_object_ref (GTK_OBJECT (imap_stream->folder)); + camel_object_ref (CAMEL_OBJECT (imap_stream->folder)); imap_stream->command = g_strdup (command); @@ -105,7 +95,7 @@ camel_imap_stream_new (CamelImapFolder *folder, char *command) } static void -finalize (GtkObject *object) +finalize (CamelObject *object) { CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (object); @@ -113,9 +103,7 @@ finalize (GtkObject *object) g_free (imap_stream->command); if (imap_stream->folder) - gtk_object_unref (GTK_OBJECT (imap_stream->folder)); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); + camel_object_unref (CAMEL_OBJECT (imap_stream->folder)); } static ssize_t @@ -141,13 +129,13 @@ stream_read (CamelStream *stream, char *buffer, size_t n) /* we got an error, dump this stuff */ g_free (result); imap_stream->cache = NULL; - gtk_object_unref (GTK_OBJECT (imap_stream->folder)); + camel_object_unref (CAMEL_OBJECT (imap_stream->folder)); return -1; } /* we don't need the folder anymore... */ - gtk_object_unref (GTK_OBJECT (imap_stream->folder)); + camel_object_unref (CAMEL_OBJECT (imap_stream->folder)); /* parse out the message part */ for (p = result; *p && *p != '{' && *p != '\n'; p++); diff --git a/camel/providers/imap/camel-imap-stream.h b/camel/providers/imap/camel-imap-stream.h index 2a6e2fc723..88881e7c1f 100644 --- a/camel/providers/imap/camel-imap-stream.h +++ b/camel/providers/imap/camel-imap-stream.h @@ -36,9 +36,9 @@ extern "C" { #include #define CAMEL_IMAP_STREAM_TYPE (camel_imap_stream_get_type ()) -#define CAMEL_IMAP_STREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_IMAP_STREAM_TYPE, CamelImapStream)) -#define CAMEL_IMAP_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_IMAP_STREAM_TYPE, CamelImapStreamClass)) -#define CAMEL_IS_IMAP_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_IMAP_STREAM_TYPE)) +#define CAMEL_IMAP_STREAM(obj) (CAMEL_CHECK_CAST((obj), CAMEL_IMAP_STREAM_TYPE, CamelImapStream)) +#define CAMEL_IMAP_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_IMAP_STREAM_TYPE, CamelImapStreamClass)) +#define CAMEL_IS_IMAP_STREAM(o) (CAMEL_CHECK_TYPE((o), CAMEL_IMAP_STREAM_TYPE)) typedef struct _CamelImapStream CamelImapStream; typedef struct _CamelImapStreamClass CamelImapStreamClass; @@ -58,8 +58,8 @@ struct _CamelImapStreamClass { /* Virtual methods */ }; -/* Standard Gtk function */ -GtkType camel_imap_stream_get_type (void); +/* Standard Camel function */ +CamelType camel_imap_stream_get_type (void); /* public methods */ CamelStream *camel_imap_stream_new (CamelImapFolder *folder, char *command); diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c index 68e0f5fd28..28defb7b87 100644 --- a/camel/providers/mbox/camel-mbox-folder.c +++ b/camel/providers/mbox/camel-mbox-folder.c @@ -48,47 +48,50 @@ #define d(x) -static CamelFolderClass *parent_class = NULL; +static CamelFolderClass *parent_class=NULL; /* Returns the class for a CamelMboxFolder */ -#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMBOXS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) +#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CMBOXS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) -static void mbox_init(CamelFolder * folder, CamelStore * parent_store, - CamelFolder * parent_folder, const gchar * name, - gchar * separator, gboolean path_begins_with_sep, CamelException * ex); -static void mbox_sync(CamelFolder * folder, gboolean expunge, CamelException * ex); -static gint mbox_get_message_count(CamelFolder * folder); -static gint mbox_get_unread_message_count(CamelFolder * folder); -static void mbox_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex); -static GPtrArray *mbox_get_uids(CamelFolder * folder); -static GPtrArray *mbox_get_subfolder_names(CamelFolder * folder); -static GPtrArray *mbox_get_summary(CamelFolder * folder); -static CamelMimeMessage *mbox_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex); +static void mbox_init (CamelFolder *folder, CamelStore *parent_store, + CamelFolder *parent_folder, const gchar *name, + gchar *separator, gboolean path_begins_with_sep, + CamelException *ex); -static void mbox_expunge(CamelFolder * folder, CamelException * ex); +static void mbox_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); +static gint mbox_get_message_count (CamelFolder *folder); +static gint mbox_get_unread_message_count (CamelFolder *folder); +static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex); +static GPtrArray *mbox_get_uids (CamelFolder *folder); +static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder); +static GPtrArray *mbox_get_summary (CamelFolder *folder); +static CamelMimeMessage *mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex); -static const CamelMessageInfo *mbox_get_message_info(CamelFolder * folder, const char *uid); +static void mbox_expunge (CamelFolder *folder, CamelException *ex); -static GPtrArray *mbox_search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex); +static const CamelMessageInfo *mbox_get_message_info (CamelFolder *folder, const char *uid); + +static GPtrArray *mbox_search_by_expression(CamelFolder *folder, const char *expression, CamelException *ex); static void mbox_search_free(CamelFolder * folder, GPtrArray * result); -static guint32 mbox_get_message_flags(CamelFolder * folder, const char *uid); -static void mbox_set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set); -static gboolean mbox_get_message_user_flag(CamelFolder * folder, const char *uid, const char *name); -static void mbox_set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value); +static guint32 mbox_get_message_flags (CamelFolder *folder, const char *uid); +static void mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, guint32 set); +static gboolean mbox_get_message_user_flag (CamelFolder *folder, const char *uid, const char *name); +static void mbox_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name, gboolean value); -static void mbox_finalize(GtkObject * object); -static void camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class) -{ - CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_mbox_folder_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS(camel_folder_class); +static void mbox_finalize (CamelObject *object); - parent_class = gtk_type_class(camel_folder_get_type()); +static void +camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class) +{ + CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_mbox_folder_class); + parent_class = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs (camel_folder_get_type ())); + /* virtual method definition */ /* virtual method overload */ @@ -116,59 +119,53 @@ static void camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folde camel_folder_class->set_message_flags = mbox_set_message_flags; camel_folder_class->get_message_user_flag = mbox_get_message_user_flag; camel_folder_class->set_message_user_flag = mbox_set_message_user_flag; - - gtk_object_class->finalize = mbox_finalize; - } -static void mbox_finalize(GtkObject * object) +static void +mbox_finalize (CamelObject *object) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(object); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (object); - g_free(mbox_folder->folder_file_path); - g_free(mbox_folder->summary_file_path); - g_free(mbox_folder->folder_dir_path); - g_free(mbox_folder->index_file_path); + g_free (mbox_folder->folder_file_path); + g_free (mbox_folder->summary_file_path); + g_free (mbox_folder->folder_dir_path); + g_free (mbox_folder->index_file_path); - GTK_OBJECT_CLASS(parent_class)->finalize(object); } -GtkType camel_mbox_folder_get_type(void) +CamelType +camel_mbox_folder_get_type (void) { - static GtkType camel_mbox_folder_type = 0; - - if (!camel_mbox_folder_type) { - GtkTypeInfo camel_mbox_folder_info = { - "CamelMboxFolder", - sizeof(CamelMboxFolder), - sizeof(CamelMboxFolderClass), - (GtkClassInitFunc) camel_mbox_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mbox_folder_type = gtk_type_unique(CAMEL_FOLDER_TYPE, &camel_mbox_folder_info); + static CamelType camel_mbox_folder_type = CAMEL_INVALID_TYPE; + + if (camel_mbox_folder_type == CAMEL_INVALID_TYPE) { + camel_mbox_folder_type = camel_type_register (CAMEL_FOLDER_TYPE, "CamelMboxFolder", + sizeof (CamelMboxFolder), + sizeof (CamelMboxFolderClass), + (CamelObjectClassInitFunc) camel_mbox_folder_class_init, + NULL, + (CamelObjectInitFunc) NULL, + (CamelObjectFinalizeFunc) mbox_finalize); } - + return camel_mbox_folder_type; } -static void -mbox_init(CamelFolder * folder, CamelStore * parent_store, - CamelFolder * parent_folder, const gchar * name, gchar * separator, - gboolean path_begins_with_sep, CamelException * ex) +static void +mbox_init (CamelFolder *folder, CamelStore *parent_store, + CamelFolder *parent_folder, const gchar *name, gchar *separator, + gboolean path_begins_with_sep, CamelException *ex) { - CamelMboxFolder *mbox_folder = (CamelMboxFolder *) folder; + CamelMboxFolder *mbox_folder = (CamelMboxFolder *)folder; const gchar *root_dir_path; gchar *real_name; int forceindex; struct stat st; /* call parent method */ - parent_class->init(folder, parent_store, parent_folder, name, separator, path_begins_with_sep, ex); - if (camel_exception_get_id(ex)) + parent_class->init (folder, parent_store, parent_folder, + name, separator, path_begins_with_sep, ex); + if (camel_exception_get_id (ex)) return; /* we assume that the parent init @@ -179,108 +176,120 @@ mbox_init(CamelFolder * folder, CamelStore * parent_store, folder->has_search_capability = TRUE; folder->permanent_flags = CAMEL_MESSAGE_ANSWERED | - CAMEL_MESSAGE_DELETED | - CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_USER; + CAMEL_MESSAGE_DELETED | + CAMEL_MESSAGE_DRAFT | + CAMEL_MESSAGE_FLAGGED | + CAMEL_MESSAGE_SEEN | + CAMEL_MESSAGE_USER; /* FIXME: we don't actually preserve user flags right now. */ - mbox_folder->summary = NULL; - mbox_folder->search = NULL; + mbox_folder->summary = NULL; + mbox_folder->search = NULL; /* now set the name info */ - g_free(mbox_folder->folder_file_path); - g_free(mbox_folder->folder_dir_path); - g_free(mbox_folder->index_file_path); + g_free (mbox_folder->folder_file_path); + g_free (mbox_folder->folder_dir_path); + g_free (mbox_folder->index_file_path); - root_dir_path = camel_mbox_store_get_toplevel_dir(CAMEL_MBOX_STORE(folder->parent_store)); + root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store)); - real_name = g_basename(folder->full_name); - mbox_folder->folder_file_path = g_strdup_printf("%s/%s", root_dir_path, real_name); - mbox_folder->summary_file_path = g_strdup_printf("%s/%s-ev-summary", root_dir_path, real_name); - mbox_folder->folder_dir_path = g_strdup_printf("%s/%s.sdb", root_dir_path, real_name); - mbox_folder->index_file_path = g_strdup_printf("%s/%s.ibex", root_dir_path, real_name); + real_name = g_basename (folder->full_name); + mbox_folder->folder_file_path = g_strdup_printf ("%s/%s", root_dir_path, real_name); + mbox_folder->summary_file_path = g_strdup_printf ("%s/%s-ev-summary", root_dir_path, real_name); + mbox_folder->folder_dir_path = g_strdup_printf ("%s/%s.sdb", root_dir_path, real_name); + mbox_folder->index_file_path = g_strdup_printf ("%s/%s.ibex", root_dir_path, real_name); /* if we have no index file, force it */ forceindex = stat(mbox_folder->index_file_path, &st) == -1; - mbox_folder->index = ibex_open(mbox_folder->index_file_path, O_CREAT | O_RDWR, 0600); + mbox_folder->index = ibex_open(mbox_folder->index_file_path, O_CREAT|O_RDWR, 0600); if (mbox_folder->index == NULL) { /* yes, this isn't fatal at all */ - g_warning("Could not open/create index file: %s: indexing not performed", strerror(errno)); + g_warning("Could not open/create index file: %s: indexing not performed", + strerror(errno)); } /* no summary (disk or memory), and we're proverbially screwed */ - mbox_folder->summary = camel_mbox_summary_new(mbox_folder->summary_file_path, - mbox_folder->folder_file_path, mbox_folder->index); - if (mbox_folder->summary == NULL || camel_mbox_summary_load(mbox_folder->summary, forceindex) == -1) { - camel_exception_set(ex, CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */ - "Could not create summary"); + mbox_folder->summary = camel_mbox_summary_new (mbox_folder->summary_file_path, + mbox_folder->folder_file_path, mbox_folder->index); + if (mbox_folder->summary == NULL + || camel_mbox_summary_load(mbox_folder->summary, forceindex) == -1) { + camel_exception_set (ex, + CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */ + "Could not create summary"); return; } } -static void mbox_sync(CamelFolder * folder, gboolean expunge, CamelException * ex) +static void +mbox_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); if (expunge) - mbox_expunge(folder, ex); + mbox_expunge (folder, ex); else - camel_mbox_summary_sync(mbox_folder->summary, FALSE, ex); + camel_mbox_summary_sync (mbox_folder->summary, FALSE, ex); /* save index */ if (mbox_folder->index) ibex_save(mbox_folder->index); if (mbox_folder->summary) - camel_folder_summary_save(CAMEL_FOLDER_SUMMARY(mbox_folder->summary)); + camel_folder_summary_save (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); } -static void mbox_expunge(CamelFolder * folder, CamelException * ex) +static void +mbox_expunge (CamelFolder *folder, CamelException *ex) { - CamelMboxFolder *mbox = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox = CAMEL_MBOX_FOLDER (folder); - camel_mbox_summary_sync(mbox->summary, TRUE, ex); + camel_mbox_summary_sync (mbox->summary, TRUE, ex); /* TODO: check it actually changed */ - gtk_signal_emit_by_name(GTK_OBJECT(folder), "folder_changed", 0); + camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", GINT_TO_POINTER(0)); } -static gint mbox_get_message_count(CamelFolder * folder) +static gint +mbox_get_message_count (CamelFolder *folder) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); - - g_return_val_if_fail(mbox_folder->summary != NULL, -1); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - return camel_folder_summary_count(CAMEL_FOLDER_SUMMARY(mbox_folder->summary)); + g_return_val_if_fail (mbox_folder->summary != NULL, -1); + + return camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); } -static gint mbox_get_unread_message_count(CamelFolder * folder) +static gint +mbox_get_unread_message_count (CamelFolder *folder) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); CamelMessageInfo *info; GPtrArray *infolist; gint i, max, count = 0; - g_return_val_if_fail(mbox_folder->summary != NULL, -1); + g_return_val_if_fail (mbox_folder->summary != NULL, -1); - max = camel_folder_summary_count(CAMEL_FOLDER_SUMMARY(mbox_folder->summary)); + max = camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); if (max == -1) return -1; - infolist = mbox_get_summary(folder); - + infolist = mbox_get_summary (folder); + for (i = 0; i < infolist->len; i++) { - info = (CamelMessageInfo *) g_ptr_array_index(infolist, i); + info = (CamelMessageInfo *) g_ptr_array_index (infolist, i); if (!(info->flags & CAMEL_MESSAGE_SEEN)) count++; } - + return count; } /* FIXME: this may need some tweaking for performance? */ -static void mbox_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex) +static void +mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, + const CamelMessageInfo *info, CamelException *ex) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); CamelStream *output_stream = NULL, *filter_stream = NULL; CamelMimeFilter *filter_from = NULL; CamelMessageInfo *newinfo; @@ -290,135 +299,147 @@ static void mbox_append_message(CamelFolder * folder, CamelMimeMessage * message guint32 uid; char *fromline = NULL; - if (stat(mbox_folder->folder_file_path, &st) != 0) + if (stat (mbox_folder->folder_file_path, &st) != 0) goto fail; - output_stream = camel_stream_fs_new_with_name(mbox_folder->folder_file_path, O_RDWR, 0600); + output_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDWR, 0600); if (output_stream == NULL) goto fail; if (st.st_size) { - seek = camel_seekable_stream_seek((CamelSeekableStream *) output_stream, st.st_size - 1, SEEK_SET); + seek = camel_seekable_stream_seek ((CamelSeekableStream *)output_stream, st.st_size - 1, SEEK_SET); if (++seek != st.st_size) goto fail; /* If the mbox doesn't end with a newline, fix that. */ - if (camel_stream_read(output_stream, &last, 1) != 1) + if (camel_stream_read (output_stream, &last, 1) != 1) goto fail; if (last != '\n') - camel_stream_write(output_stream, "\n", 1); + camel_stream_write (output_stream, "\n", 1); } else seek = 0; /* assign a new x-evolution header/uid */ - camel_medium_remove_header(CAMEL_MEDIUM(message), "X-Evolution"); - uid = camel_folder_summary_next_uid(CAMEL_FOLDER_SUMMARY(mbox_folder->summary)); + camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution"); + uid = camel_folder_summary_next_uid (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); /* important that the header matches exactly 00000000-0000 */ - xev = g_strdup_printf("%08x-%04x", uid, info?info->flags&0xffff:0); - camel_medium_add_header(CAMEL_MEDIUM(message), "X-Evolution", xev); - g_free(xev); + if (info) + xev = g_strdup_printf ("%08x-%04x", uid, info->flags & 0xFFFF); + else + xev = g_strdup_printf ("%08x-%04x", uid, 0); + camel_medium_add_header (CAMEL_MEDIUM (message), "X-Evolution", xev); + g_free (xev); /* we must write this to the non-filtered stream ... */ - fromline = camel_mbox_summary_build_from(CAMEL_MIME_PART(message)->headers); - if (camel_stream_write_string(output_stream, fromline) == -1) + fromline = camel_mbox_summary_build_from (CAMEL_MIME_PART (message)->headers); + if (camel_stream_write_string (output_stream, fromline) == -1) goto fail; /* and write the content to the filtering stream, that translated '\nFrom' into '\n>From' */ - filter_stream = (CamelStream *) camel_stream_filter_new_with_stream(output_stream); - filter_from = (CamelMimeFilter *) camel_mime_filter_from_new(); - camel_stream_filter_add((CamelStreamFilter *) filter_stream, filter_from); - if (camel_data_wrapper_write_to_stream(CAMEL_DATA_WRAPPER(message), filter_stream) == -1) + filter_stream = (CamelStream *)camel_stream_filter_new_with_stream (output_stream); + filter_from = (CamelMimeFilter *)camel_mime_filter_from_new (); + camel_stream_filter_add ((CamelStreamFilter *)filter_stream, filter_from); + if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), filter_stream) == -1) goto fail; - if (camel_stream_close(filter_stream) == -1) + if (camel_stream_close (filter_stream) == -1) goto fail; /* filter stream ref's the output stream itself, so we need to unref it too */ - gtk_object_unref(GTK_OBJECT(filter_from)); - gtk_object_unref(GTK_OBJECT(filter_stream)); - gtk_object_unref(GTK_OBJECT(output_stream)); - g_free(fromline); + camel_object_unref (CAMEL_OBJECT (filter_from)); + camel_object_unref (CAMEL_OBJECT (filter_stream)); + camel_object_unref (CAMEL_OBJECT (output_stream)); + g_free (fromline); /* force a summary update - will only update from the new position, if it can */ - if (camel_mbox_summary_update(mbox_folder->summary, seek) == 0) { + if (camel_mbox_summary_update (mbox_folder->summary, seek) == 0) { char uidstr[16]; - sprintf(uidstr, "%u", uid); - if (info - && (newinfo = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mbox_folder->summary), uidstr))) { + + sprintf (uidstr, "%u", uid); + newinfo = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mbox_folder->summary), uidstr); + + if (info && newinfo) { CamelFlag *flag = info->user_flags; CamelTag *tag = info->user_tags; + while (flag) { - camel_flag_set(&newinfo->user_flags, flag->name, TRUE); + camel_flag_set (&(newinfo->user_flags), flag->name, TRUE); flag = flag->next; } + while (tag) { - camel_tag_set(&newinfo->user_tags, tag->name, tag->value); + camel_tag_set (&(newinfo->user_tags), tag->name, tag->value); tag = tag->next; } } - gtk_signal_emit_by_name(GTK_OBJECT(folder), "folder_changed", 0); + camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", GINT_TO_POINTER(0)); } + return; - fail: - if (camel_exception_is_set(ex)) { - camel_exception_setv(ex, camel_exception_get_id(ex), - "Cannot append message to mbox file: %s", camel_exception_get_description(ex)); +fail: + if (camel_exception_is_set (ex)) { + camel_exception_setv (ex, camel_exception_get_id (ex), + "Cannot append message to mbox file: %s", + camel_exception_get_description (ex)); } else { - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - "Cannot append message to mbox file: %s", g_strerror(errno)); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Cannot append message to mbox file: %s", + g_strerror (errno)); } if (filter_stream) { - /*camel_stream_close (filter_stream); */ - gtk_object_unref(GTK_OBJECT(filter_stream)); + /*camel_stream_close (filter_stream);*/ + camel_object_unref (CAMEL_OBJECT (filter_stream)); } if (output_stream) - gtk_object_unref(GTK_OBJECT(output_stream)); + camel_object_unref (CAMEL_OBJECT (output_stream)); if (filter_from) - gtk_object_unref(GTK_OBJECT(filter_from)); - - g_free(fromline); + camel_object_unref (CAMEL_OBJECT (filter_from)); + + g_free (fromline); /* make sure the file isn't munged by us */ if (seek != -1) { - int fd = open(mbox_folder->folder_file_path, O_WRONLY, 0600); - + int fd = open (mbox_folder->folder_file_path, O_WRONLY, 0600); + if (fd != -1) { - ftruncate(fd, st.st_size); + ftruncate (fd, st.st_size); close(fd); } } } -static GPtrArray *mbox_get_uids(CamelFolder * folder) +static GPtrArray * +mbox_get_uids (CamelFolder *folder) { GPtrArray *array; - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); int i, count; - count = camel_folder_summary_count(CAMEL_FOLDER_SUMMARY(mbox_folder->summary)); - array = g_ptr_array_new(); - g_ptr_array_set_size(array, count); + count = camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary)); + array = g_ptr_array_new (); + g_ptr_array_set_size (array, count); for (i = 0; i < count; i++) { - CamelMboxMessageInfo *info = - (CamelMboxMessageInfo *) camel_folder_summary_index(CAMEL_FOLDER_SUMMARY(mbox_folder->summary), i); - - array->pdata[i] = g_strdup(info->info.uid); + CamelMboxMessageInfo *info = (CamelMboxMessageInfo *) camel_folder_summary_index ( + CAMEL_FOLDER_SUMMARY (mbox_folder->summary), i); + array->pdata[i] = g_strdup (info->info.uid); } - + return array; } -static GPtrArray *mbox_get_subfolder_names(CamelFolder * folder) +static GPtrArray * +mbox_get_subfolder_names (CamelFolder *folder) { /* No subfolders. */ - return g_ptr_array_new(); + return g_ptr_array_new (); } -static CamelMimeMessage *mbox_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex) +static CamelMimeMessage * +mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); CamelStream *message_stream = NULL; CamelMimeMessage *message = NULL; CamelMboxMessageInfo *info; @@ -435,142 +456,156 @@ static CamelMimeMessage *mbox_get_message(CamelFolder * folder, const gchar * ui } /* if this has no content, its an error in the library */ - g_assert(info->info.content); - g_assert(info->frompos != -1); + g_assert (info->info.content); + g_assert (info->frompos != -1); /* where we read from */ - message_stream = camel_stream_fs_new_with_name(mbox_folder->folder_file_path, O_RDONLY, 0); + message_stream = camel_stream_fs_new_with_name (mbox_folder->folder_file_path, O_RDONLY, 0); if (message_stream == NULL) goto fail; /* we use a parser to verify the message is correct, and in the correct position */ - parser = camel_mime_parser_new(); - camel_mime_parser_init_with_stream(parser, message_stream); - gtk_object_unref(GTK_OBJECT(message_stream)); - camel_mime_parser_scan_from(parser, TRUE); - - camel_mime_parser_seek(parser, info->frompos, SEEK_SET); - if (camel_mime_parser_step(parser, &buffer, &len) != HSCAN_FROM) { - g_warning("File appears truncated"); + parser = camel_mime_parser_new (); + camel_mime_parser_init_with_stream (parser, message_stream); + camel_object_unref (CAMEL_OBJECT (message_stream)); + camel_mime_parser_scan_from (parser, TRUE); + + camel_mime_parser_seek (parser, info->frompos, SEEK_SET); + if (camel_mime_parser_step (parser, &buffer, &len) != HSCAN_FROM) { + g_warning ("File appears truncated"); goto fail; } - if (camel_mime_parser_tell_start_from(parser) != info->frompos) { - g_warning("Summary doesn't match the folder contents! eek!\n" - " expecting offset %ld got %ld", (long int)info->frompos, - (long int)camel_mime_parser_tell_start_from(parser)); + if (camel_mime_parser_tell_start_from (parser) != info->frompos) { + g_warning ("Summary doesn't match the folder contents! eek!\n" + " expecting offset %ld got %ld", (long int)info->frompos, + (long int)camel_mime_parser_tell_start_from (parser)); errno = EINVAL; goto fail; } - message = camel_mime_message_new(); - if (camel_mime_part_construct_from_parser(CAMEL_MIME_PART(message), parser) == -1) { - g_warning("Construction failed"); + message = camel_mime_message_new (); + if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (message), parser) == -1) { + g_warning ("Construction failed"); goto fail; } - gtk_object_unref(GTK_OBJECT(parser)); + camel_object_unref (CAMEL_OBJECT (parser)); return message; - fail: - camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, "Cannot get message: %s", g_strerror(errno)); +fail: + camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, + "Cannot get message: %s", + g_strerror(errno)); if (parser) - gtk_object_unref(GTK_OBJECT(parser)); + camel_object_unref (CAMEL_OBJECT (parser)); if (message) - gtk_object_unref(GTK_OBJECT(message)); + camel_object_unref (CAMEL_OBJECT (message)); return NULL; } -GPtrArray *mbox_get_summary(CamelFolder * folder) +GPtrArray * +mbox_get_summary (CamelFolder *folder) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - return CAMEL_FOLDER_SUMMARY(mbox_folder->summary)->messages; + return CAMEL_FOLDER_SUMMARY (mbox_folder->summary)->messages; } /* get a single message info, by uid */ -static const CamelMessageInfo *mbox_get_message_info(CamelFolder * folder, const char *uid) +static const CamelMessageInfo * +mbox_get_message_info (CamelFolder *folder, const char *uid) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); - return camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mbox_folder->summary), uid); + return camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mbox_folder->summary), uid); } -static GPtrArray *mbox_search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex) +static GPtrArray * +mbox_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex) { - CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder); if (mbox_folder->search == NULL) { - mbox_folder->search = camel_folder_search_new(); + mbox_folder->search = camel_folder_search_new (); } - camel_folder_search_set_folder(mbox_folder->search, folder); + camel_folder_search_set_folder (mbox_folder->search, folder); if (mbox_folder->summary) { /* FIXME: dont access summary array directly? */ - camel_folder_search_set_summary(mbox_folder->search, - CAMEL_FOLDER_SUMMARY(mbox_folder->summary)->messages); + camel_folder_search_set_summary (mbox_folder->search, + CAMEL_FOLDER_SUMMARY (mbox_folder->summary)->messages); } + + camel_folder_search_set_body_index (mbox_folder->search, mbox_folder->index); - camel_folder_search_set_body_index(mbox_folder->search, mbox_folder->index); - - return camel_folder_search_execute_expression(mbox_folder->search, expression, ex); + return camel_folder_search_execute_expression (mbox_folder->search, expression, ex); } -static void mbox_search_free(CamelFolder * folder, GPtrArray * result) +static void +mbox_search_free(CamelFolder * folder, GPtrArray * result) { CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); camel_folder_search_free_result(mbox_folder->search, result); } -static guint32 mbox_get_message_flags(CamelFolder * folder, const char *uid) +static guint32 +mbox_get_message_flags (CamelFolder *folder, const char *uid) { CamelMessageInfo *info; - CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); - info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid); - g_return_val_if_fail(info != NULL, 0); + info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); + g_return_val_if_fail (info != NULL, 0); return info->flags; } -static void mbox_set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set) +static void +mbox_set_message_flags (CamelFolder *folder, const char *uid, guint32 flags, + guint32 set) { CamelMessageInfo *info; - CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); - info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid); - g_return_if_fail(info != NULL); + info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); + g_return_if_fail (info != NULL); - info->flags = (info->flags & ~flags) | (set & flags) | CAMEL_MESSAGE_FOLDER_FLAGGED; - camel_folder_summary_touch(CAMEL_FOLDER_SUMMARY(mf->summary)); + info->flags = (info->flags & ~flags) | (set & flags) | + CAMEL_MESSAGE_FOLDER_FLAGGED; + camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary)); - gtk_signal_emit_by_name(GTK_OBJECT(folder), "message_changed", uid); + camel_object_trigger_event (CAMEL_OBJECT (folder), "message_changed", uid); } -static gboolean mbox_get_message_user_flag(CamelFolder * folder, const char *uid, const char *name) +static gboolean +mbox_get_message_user_flag (CamelFolder *folder, const char *uid, + const char *name) { CamelMessageInfo *info; - CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); - info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid); - g_return_val_if_fail(info != NULL, FALSE); + info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); + g_return_val_if_fail (info != NULL, FALSE); - return camel_flag_get(&info->user_flags, name); + return camel_flag_get (&info->user_flags, name); } -static void mbox_set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value) +static void +mbox_set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value) { CamelMessageInfo *info; - CamelMboxFolder *mf = CAMEL_MBOX_FOLDER(folder); + CamelMboxFolder *mf = CAMEL_MBOX_FOLDER (folder); - info = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mf->summary), uid); - g_return_if_fail(info != NULL); + info = camel_folder_summary_uid (CAMEL_FOLDER_SUMMARY (mf->summary), uid); + g_return_if_fail (info != NULL); - camel_flag_set(&info->user_flags, name, value); + camel_flag_set (&info->user_flags, name, value); info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED; - camel_folder_summary_touch(CAMEL_FOLDER_SUMMARY(mf->summary)); - gtk_signal_emit_by_name(GTK_OBJECT(folder), "message_changed", uid); + camel_folder_summary_touch (CAMEL_FOLDER_SUMMARY (mf->summary)); + camel_object_trigger_event (CAMEL_OBJECT (folder), "message_changed", uid); } diff --git a/camel/providers/mbox/camel-mbox-folder.h b/camel/providers/mbox/camel-mbox-folder.h index d7dc361f14..7c5558f362 100644 --- a/camel/providers/mbox/camel-mbox-folder.h +++ b/camel/providers/mbox/camel-mbox-folder.h @@ -33,7 +33,6 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include #include #include @@ -42,9 +41,9 @@ extern "C" { /* #include "camel-store.h" */ #define CAMEL_MBOX_FOLDER_TYPE (camel_mbox_folder_get_type ()) -#define CAMEL_MBOX_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MBOX_FOLDER_TYPE, CamelMboxFolder)) -#define CAMEL_MBOX_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MBOX_FOLDER_TYPE, CamelMboxFolderClass)) -#define IS_CAMEL_MBOX_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MBOX_FOLDER_TYPE)) +#define CAMEL_MBOX_FOLDER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MBOX_FOLDER_TYPE, CamelMboxFolder)) +#define CAMEL_MBOX_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MBOX_FOLDER_TYPE, CamelMboxFolderClass)) +#define IS_CAMEL_MBOX_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_MBOX_FOLDER_TYPE)) typedef struct { CamelFolder parent_object; @@ -71,8 +70,8 @@ typedef struct { /* public methods */ -/* Standard Gtk function */ -GtkType camel_mbox_folder_get_type (void); +/* Standard Camel function */ +CamelType camel_mbox_folder_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c index 475fbd1352..e90c90275e 100644 --- a/camel/providers/mbox/camel-mbox-store.c +++ b/camel/providers/mbox/camel-mbox-store.c @@ -35,9 +35,9 @@ #include "camel-url.h" /* Returns the class for a CamelMboxStore */ -#define CMBOXS_CLASS(so) CAMEL_MBOX_STORE_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass) +#define CMBOXS_CLASS(so) CAMEL_MBOX_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static char *get_name (CamelService *service, gboolean brief); static CamelFolder *get_folder (CamelStore *store, const char *folder_name, @@ -75,25 +75,19 @@ camel_mbox_store_init (gpointer object, gpointer klass) store->folders = g_hash_table_new (g_str_hash, g_str_equal); } -GtkType +CamelType camel_mbox_store_get_type (void) { - static GtkType camel_mbox_store_type = 0; + static CamelType camel_mbox_store_type = CAMEL_INVALID_TYPE; - if (!camel_mbox_store_type) { - GtkTypeInfo camel_mbox_store_info = - { - "CamelMboxStore", - sizeof (CamelMboxStore), - sizeof (CamelMboxStoreClass), - (GtkClassInitFunc) camel_mbox_store_class_init, - (GtkObjectInitFunc) camel_mbox_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mbox_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_mbox_store_info); + if (camel_mbox_store_type == CAMEL_INVALID_TYPE) { + camel_mbox_store_type = camel_type_register (CAMEL_STORE_TYPE, "CamelMboxStore", + sizeof (CamelMboxStore), + sizeof (CamelMboxStoreClass), + (CamelObjectClassInitFunc) camel_mbox_store_class_init, + NULL, + (CamelObjectInitFunc) camel_mbox_store_init, + NULL); } return camel_mbox_store_type; @@ -156,7 +150,7 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create, return NULL; } - new_folder = gtk_type_new (CAMEL_MBOX_FOLDER_TYPE); + new_folder = CAMEL_FOLDER (camel_object_new (CAMEL_MBOX_FOLDER_TYPE)); CF_CLASS (new_folder)->init (new_folder, store, NULL, folder_name, "/", TRUE, ex); diff --git a/camel/providers/mbox/camel-mbox-store.h b/camel/providers/mbox/camel-mbox-store.h index 06a971ada4..7b298b67f6 100644 --- a/camel/providers/mbox/camel-mbox-store.h +++ b/camel/providers/mbox/camel-mbox-store.h @@ -31,13 +31,12 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include "camel-store.h" #define CAMEL_MBOX_STORE_TYPE (camel_mbox_store_get_type ()) -#define CAMEL_MBOX_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MBOX_STORE_TYPE, CamelMboxStore)) -#define CAMEL_MBOX_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MBOX_STORE_TYPE, CamelMboxStoreClass)) -#define IS_CAMEL_MBOX_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MBOX_STORE_TYPE)) +#define CAMEL_MBOX_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MBOX_STORE_TYPE, CamelMboxStore)) +#define CAMEL_MBOX_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MBOX_STORE_TYPE, CamelMboxStoreClass)) +#define IS_CAMEL_MBOX_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_MBOX_STORE_TYPE)) typedef struct { @@ -55,8 +54,8 @@ typedef struct { /* public methods */ -/* Standard Gtk function */ -GtkType camel_mbox_store_get_type (void); +/* Standard Camel function */ +CamelType camel_mbox_store_get_type (void); const gchar *camel_mbox_store_get_toplevel_dir (CamelMboxStore *store); diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c index fc1eacafe7..b656205b1a 100644 --- a/camel/providers/mbox/camel-mbox-summary.c +++ b/camel/providers/mbox/camel-mbox-summary.c @@ -40,73 +40,58 @@ struct _CamelMboxSummaryPrivate { #define _PRIVATE(o) (((CamelMboxSummary *)(o))->priv) -static int summary_header_load(CamelFolderSummary *, FILE *); -static int summary_header_save(CamelFolderSummary *, FILE *); - -static CamelMessageInfo *message_info_new(CamelFolderSummary *, struct _header_raw *); -static CamelMessageInfo *message_info_new_from_parser(CamelFolderSummary *, CamelMimeParser *); -static CamelMessageInfo *message_info_load(CamelFolderSummary *, FILE *); -static int message_info_save(CamelFolderSummary *, FILE *, CamelMessageInfo *); +static int summary_header_load (CamelFolderSummary *, FILE *); +static int summary_header_save (CamelFolderSummary *, FILE *); +static CamelMessageInfo * message_info_new (CamelFolderSummary *, struct _header_raw *); +static CamelMessageInfo * message_info_new_from_parser (CamelFolderSummary *, CamelMimeParser *); +static CamelMessageInfo * message_info_load (CamelFolderSummary *, FILE *); +static int message_info_save (CamelFolderSummary *, FILE *, CamelMessageInfo *); /*static void message_info_free (CamelFolderSummary *, CamelMessageInfo *);*/ -static void camel_mbox_summary_class_init(CamelMboxSummaryClass * klass); -static void camel_mbox_summary_init(CamelMboxSummary *obj); -static void camel_mbox_summary_finalise(GtkObject * obj); +static void camel_mbox_summary_class_init (CamelMboxSummaryClass *klass); +static void camel_mbox_summary_init (CamelMboxSummary *obj); +static void camel_mbox_summary_finalise (CamelObject *obj); static CamelFolderSummaryClass *camel_mbox_summary_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint camel_mbox_summary_get_type(void) +CamelType +camel_mbox_summary_get_type (void) { - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelMboxSummary", - sizeof(CamelMboxSummary), - sizeof(CamelMboxSummaryClass), - (GtkClassInitFunc) camel_mbox_summary_class_init, - (GtkObjectInitFunc) camel_mbox_summary_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique(camel_folder_summary_get_type(), &type_info); + static CamelType type = CAMEL_INVALID_TYPE; + + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_folder_summary_get_type (), "CamelMboxSummary", + sizeof (CamelMboxSummary), + sizeof (CamelMboxSummaryClass), + (CamelObjectClassInitFunc) camel_mbox_summary_class_init, + NULL, + (CamelObjectInitFunc) camel_mbox_summary_init, + (CamelObjectFinalizeFunc) camel_mbox_summary_finalise); } - + return type; } static void -camel_mbox_summary_class_init(CamelMboxSummaryClass * klass) +camel_mbox_summary_class_init (CamelMboxSummaryClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelFolderSummaryClass *sklass = (CamelFolderSummaryClass *) klass; - - camel_mbox_summary_parent = gtk_type_class(camel_folder_summary_get_type()); - - object_class->finalize = camel_mbox_summary_finalise; + + camel_mbox_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS(camel_type_get_global_classfuncs (camel_folder_summary_get_type ())); sklass->summary_header_load = summary_header_load; sklass->summary_header_save = summary_header_save; - sklass->message_info_new = message_info_new; + sklass->message_info_new = message_info_new; sklass->message_info_new_from_parser = message_info_new_from_parser; sklass->message_info_load = message_info_load; sklass->message_info_save = message_info_save; - /*sklass->message_info_free = message_info_free; */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); + /*sklass->message_info_free = message_info_free;*/ } static void -camel_mbox_summary_init(CamelMboxSummary *obj) +camel_mbox_summary_init (CamelMboxSummary *obj) { struct _CamelMboxSummaryPrivate *p; struct _CamelFolderSummary *s = (CamelFolderSummary *)obj; @@ -122,13 +107,11 @@ camel_mbox_summary_init(CamelMboxSummary *obj) } static void -camel_mbox_summary_finalise(GtkObject * obj) +camel_mbox_summary_finalise (CamelObject *obj) { - CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(obj); + CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (obj); - g_free(mbs->folder_path); - - ((GtkObjectClass *) (camel_mbox_summary_parent))->finalize(GTK_OBJECT(obj)); + g_free (mbs->folder_path); } /** @@ -139,203 +122,204 @@ camel_mbox_summary_finalise(GtkObject * obj) * Return value: A new CamelMboxSummary widget. **/ CamelMboxSummary * -camel_mbox_summary_new(const char *filename, const char *mbox_name, ibex * index) +camel_mbox_summary_new (const char *filename, const char *mbox_name, ibex *index) { - CamelMboxSummary *new = CAMEL_MBOX_SUMMARY(gtk_type_new(camel_mbox_summary_get_type())); - + CamelMboxSummary *new = CAMEL_MBOX_SUMMARY (camel_object_new (camel_mbox_summary_get_type ())); + if (new) { /* ?? */ - camel_folder_summary_set_build_content(CAMEL_FOLDER_SUMMARY(new), TRUE); - camel_folder_summary_set_filename(CAMEL_FOLDER_SUMMARY(new), filename); - new->folder_path = g_strdup(mbox_name); + camel_folder_summary_set_build_content (CAMEL_FOLDER_SUMMARY (new), TRUE); + camel_folder_summary_set_filename (CAMEL_FOLDER_SUMMARY (new), filename); + new->folder_path = g_strdup (mbox_name); new->index = index; } return new; } static int -summary_header_load(CamelFolderSummary *s, FILE * in) +summary_header_load (CamelFolderSummary *s, FILE *in) { - CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(s); + CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (s); - if (((CamelFolderSummaryClass *) camel_mbox_summary_parent)->summary_header_load(s, in) == -1) + if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_load (s, in) == -1) return -1; - return camel_folder_summary_decode_uint32(in, &mbs->folder_size); + return camel_folder_summary_decode_uint32 (in, &mbs->folder_size); } static int -summary_header_save(CamelFolderSummary *s, FILE * out) +summary_header_save (CamelFolderSummary *s, FILE *out) { - CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(s); + CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (s); - if (((CamelFolderSummaryClass *) camel_mbox_summary_parent)->summary_header_save(s, out) == -1) + if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_save (s, out) == -1) return -1; - return camel_folder_summary_encode_uint32(out, mbs->folder_size); + return camel_folder_summary_encode_uint32 (out, mbs->folder_size); } static int -header_evolution_decode(const char *in, guint32 * uid, guint32 * flags) +header_evolution_decode (const char *in, guint32 *uid, guint32 *flags) { - char *header; - - if (in && (header = header_token_decode(in))) { - if (strlen(header) == strlen("00000000-0000") - && sscanf(header, "%08x-%04x", uid, flags) == 2) { - g_free(header); - return *uid; - } - g_free(header); - } - - return -1; + char *header; + + if (in && (header = header_token_decode(in))) { + if (strlen (header) == strlen ("00000000-0000") + && sscanf (header, "%08x-%04x", uid, flags) == 2) { + g_free (header); + return *uid; + } + g_free (header); + } + + return -1; } static char * -header_evolution_encode(guint32 uid, guint32 flags) +header_evolution_encode (guint32 uid, guint32 flags) { - return g_strdup_printf("%08x-%04x", uid, flags & 0xffff); + return g_strdup_printf ("%08x-%04x", uid, flags & 0xffff); } static CamelMessageInfo * -message_info_new(CamelFolderSummary *s, struct _header_raw *h) +message_info_new (CamelFolderSummary *s, struct _header_raw *h) { CamelMessageInfo *mi; - mi = ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_new(s, h); + mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new (s, h); if (mi) { const char *xev; guint32 uid, flags; - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi; + CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - xev = header_raw_find(&h, "X-Evolution", NULL); + xev = header_raw_find (&h, "X-Evolution", NULL); if (xev && header_evolution_decode(xev, &uid, &flags) != -1) { - g_free(mi->uid); - mi->uid = g_strdup_printf("%u", uid); + g_free (mi->uid); + mi->uid = g_strdup_printf ("%u", uid); mi->flags = flags; } else { /* to indicate it has no xev header? */ mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_FOLDER_NOXEV; - mi->uid = g_strdup_printf("%u", camel_folder_summary_next_uid(s)); + mi->uid = g_strdup_printf ("%u", camel_folder_summary_next_uid (s)); } mbi->frompos = -1; } - + return mi; } static CamelMessageInfo * -message_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser * mp) +message_info_new_from_parser (CamelFolderSummary *s, CamelMimeParser *mp) { CamelMessageInfo *mi; - CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(s); + CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY (s); - mi = ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_new_from_parser(s, mp); + mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new_from_parser (s, mp); if (mi) { - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi; + CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - mbi->frompos = camel_mime_parser_tell_start_from(mp); + mbi->frompos = camel_mime_parser_tell_start_from (mp); /* do we want to index this message as we add it, as well? */ - if (mbs->index_force || (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0 + if (mbs->index_force + || (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0 || !ibex_contains_name(mbs->index, mi->uid)) { - camel_folder_summary_set_index(s, mbs->index); + + camel_folder_summary_set_index (s, mbs->index); } else { - camel_folder_summary_set_index(s, NULL); + camel_folder_summary_set_index (s, NULL); } } - + return mi; } static CamelMessageInfo * -message_info_load(CamelFolderSummary *s, FILE * in) +message_info_load (CamelFolderSummary *s, FILE *in) { CamelMessageInfo *mi; - io(printf("loading mbox message info\n")); + io (printf ("loading mbox message info\n")); - mi = ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_load(s, in); + mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_load (s, in); if (mi) { - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi; + CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - camel_folder_summary_decode_uint32(in, &mbi->frompos); + camel_folder_summary_decode_uint32 (in, &mbi->frompos); } - + return mi; } static int -message_info_save(CamelFolderSummary *s, FILE * out, CamelMessageInfo * mi) +message_info_save (CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi) { - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *) mi; + CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; - io(printf("saving mbox message info\n")); + io (printf ("saving mbox message info\n")); - ((CamelFolderSummaryClass *) camel_mbox_summary_parent)->message_info_save(s, out, mi); + ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_save (s, out, mi); - return camel_folder_summary_encode_uint32(out, mbi->frompos); + return camel_folder_summary_encode_uint32 (out, mbi->frompos); } static int -summary_rebuild(CamelMboxSummary *mbs, off_t offset) +summary_rebuild (CamelMboxSummary *mbs, off_t offset) { - CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY(mbs); + CamelFolderSummary *s = CAMEL_FOLDER_SUMMARY (mbs); CamelMimeParser *mp; int fd; int ok = 0; - fd = open(mbs->folder_path, O_RDONLY); + fd = open (mbs->folder_path, O_RDONLY); if (fd == -1) { - printf("%s failed to open: %s", mbs->folder_path, strerror(errno)); + printf ("%s failed to open: %s", mbs->folder_path, strerror (errno)); return -1; } - - mp = camel_mime_parser_new(); - camel_mime_parser_init_with_fd(mp, fd); - camel_mime_parser_scan_from(mp, TRUE); - camel_mime_parser_seek(mp, offset, SEEK_SET); + + mp = camel_mime_parser_new (); + camel_mime_parser_init_with_fd (mp, fd); + camel_mime_parser_scan_from (mp, TRUE); + camel_mime_parser_seek (mp, offset, SEEK_SET); if (offset > 0) { - if (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) { - if (camel_mime_parser_tell_start_from(mp) != offset) { - g_warning - ("The next message didn't start where I expected\nbuilding summary from start"); - camel_mime_parser_drop_step(mp); + if (camel_mime_parser_step (mp, NULL, NULL) == HSCAN_FROM) { + if (camel_mime_parser_tell_start_from (mp) != offset) { + g_warning ("The next message didn't start where I expected\nbuilding summary from start"); + camel_mime_parser_drop_step (mp); offset = 0; - camel_mime_parser_seek(mp, offset, SEEK_SET); - camel_folder_summary_clear(CAMEL_FOLDER_SUMMARY(mbs)); + camel_mime_parser_seek (mp, offset, SEEK_SET); + camel_folder_summary_clear (CAMEL_FOLDER_SUMMARY (mbs)); } else { - camel_mime_parser_unstep(mp); + camel_mime_parser_unstep (mp); } } else { - gtk_object_unref(GTK_OBJECT(mp)); + camel_object_unref (CAMEL_OBJECT (mp)); /* end of file - no content? */ return -1; } } - while (camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM) { + while (camel_mime_parser_step (mp, NULL, NULL) == HSCAN_FROM) { CamelMessageInfo *info; - info = camel_folder_summary_add_from_parser(CAMEL_FOLDER_SUMMARY(mbs), mp); + info = camel_folder_summary_add_from_parser (CAMEL_FOLDER_SUMMARY (mbs), mp); if (info == NULL) { - printf("Could not build info from file?\n"); + printf ("Could not build info from file?\n"); ok = -1; break; } - g_assert(camel_mime_parser_step(mp, NULL, NULL) == HSCAN_FROM_END); + g_assert (camel_mime_parser_step (mp, NULL, NULL) == HSCAN_FROM_END); } - gtk_object_unref(GTK_OBJECT(mp)); - + camel_object_unref (CAMEL_OBJECT (mp)); + /* update the file size/mtime in the summary */ if (ok != -1) { struct stat st; - if (stat(mbs->folder_path, &st) == 0) { + if (stat (mbs->folder_path, &st) == 0) { mbs->folder_size = st.st_size; s->time = st.st_mtime; } @@ -627,246 +611,260 @@ camel_mbox_summary_sync(CamelMboxSummary *mbs, gboolean expunge, CamelException char *fromline; /* make sure we're in sync */ - count = camel_folder_summary_count(s); + count = camel_folder_summary_count (s); if (count > 0) { - CamelMessageInfo *mi = camel_folder_summary_index(s, count - 1); - - camel_mbox_summary_update(mbs, mi->content->endpos); + CamelMessageInfo *mi = camel_folder_summary_index (s, count - 1); + camel_mbox_summary_update (mbs, mi->content->endpos); } else { - camel_mbox_summary_update(mbs, 0); + camel_mbox_summary_update (mbs, 0); } /* check if we have any work to do */ - d(printf("Performing sync, %d messages in inbox\n", count)); + d(printf ("Performing sync, %d messages in inbox\n", count)); for (i = 0; quick && i < count; i++) { - info = (CamelMboxMessageInfo *) camel_folder_summary_index(s, i); - if ((expunge && (info->info.flags & CAMEL_MESSAGE_DELETED)) - || (info->info.flags & CAMEL_MESSAGE_FOLDER_NOXEV)) + info = (CamelMboxMessageInfo *)camel_folder_summary_index (s, i); + if ((expunge && (info->info.flags & CAMEL_MESSAGE_DELETED)) || + (info->info.flags & CAMEL_MESSAGE_FOLDER_NOXEV)) quick = FALSE; else work |= (info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0; } - d(printf("Options: %s %s %s\n", expunge ? "expunge" : "", quick ? "quick" : "", work ? "Work" : "")); + d(printf ("Options: %s %s %s\n", expunge ? "expunge" : "", quick ? "quick" : "", work ? "Work" : "")); if (quick && !work) return 0; - fd = open(mbs->folder_path, O_RDWR); + fd = open (mbs->folder_path, O_RDWR); if (fd == -1) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not open summary %s", mbs->folder_path); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not open summary %s", mbs->folder_path); return -1; } - mp = camel_mime_parser_new(); - camel_mime_parser_scan_from(mp, TRUE); - camel_mime_parser_init_with_fd(mp, fd); + mp = camel_mime_parser_new (); + camel_mime_parser_scan_from (mp, TRUE); + camel_mime_parser_init_with_fd (mp, fd); if (!quick) { - tmpname = alloca(strlen(mbs->folder_path) + 5); - sprintf(tmpname, "%s.tmp", mbs->folder_path); - d(printf("Writing tmp file to %s\n", tmpname)); - retry_out: - fdout = open(tmpname, O_WRONLY | O_CREAT | O_EXCL, 0600); + tmpname = alloca (strlen (mbs->folder_path) + 5); + sprintf (tmpname, "%s.tmp", mbs->folder_path); + d(printf ("Writing tmp file to %s\n", tmpname)); + retry_out: + fdout = open (tmpname, O_WRONLY | O_CREAT | O_EXCL, 0600); if (fdout == -1) { if (errno == EEXIST) if (unlink(tmpname) != -1) goto retry_out; - - free(tmpname); + + free (tmpname); tmpname = NULL; - g_warning("Something failed (yo!)"); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Cannot open temporary mailbox: %s", - strerror(errno)); + g_warning ("Something failed (yo!)"); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Cannot open temporary mailbox: %s", strerror (errno)); goto error; } } for (i = 0; i < count; i++) { off_t frompos, bodypos, lastpos; - /* This has to be an int, not an off_t, because that's * what camel_mime_parser_header returns... FIXME. */ int xevoffset; - info = (CamelMboxMessageInfo *) camel_folder_summary_index(s, i); + info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i); - g_assert(info); + g_assert (info); - d(printf("Looking at message %s\n", info->info.uid)); + d(printf ("Looking at message %s\n", info->info.uid)); if (expunge && info->info.flags & CAMEL_MESSAGE_DELETED) { - d(printf("Deleting %s\n", info->info.uid)); + d(printf ("Deleting %s\n", info->info.uid)); - g_assert(!quick); + g_assert (!quick); offset -= (info->info.content->endpos - info->frompos); if (mbs->index) - ibex_unindex(mbs->index, info->info.uid); - camel_folder_summary_remove(s, (CamelMessageInfo *) info); + ibex_unindex (mbs->index, info->info.uid); + camel_folder_summary_remove (s, (CamelMessageInfo *)info); count--; i--; info = NULL; } else if (info->info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV | CAMEL_MESSAGE_FOLDER_FLAGGED)) { int xevok = FALSE; - d(printf("Updating header for %s flags = %08x\n", info->info.uid, info->info.flags)); + d(printf ("Updating header for %s flags = %08x\n", info->info.uid, info->info.flags)); /* find the next message, header parts */ - camel_mime_parser_seek(mp, info->frompos, SEEK_SET); - if (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_FROM) { - g_warning("camel_mime_parser_step failed (1)"); + camel_mime_parser_seek (mp, info->frompos, SEEK_SET); + if (camel_mime_parser_step (mp, &buffer, &len) != HSCAN_FROM) { + g_warning ("camel_mime_parser_step failed (1)"); goto error; } - if (camel_mime_parser_tell_start_from(mp) != info->frompos) { - g_warning("Summary/mbox mismatch, aborting sync"); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Summary mismatch, aborting sync"); + if (camel_mime_parser_tell_start_from (mp) != info->frompos) { + g_warning ("Summary/mbox mismatch, aborting sync"); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Summary mismatch, aborting sync"); goto error; } - - if (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_FROM_END) { - g_warning("camel_mime_parser_step failed (2)"); + + if (camel_mime_parser_step (mp, &buffer, &len) == HSCAN_FROM_END) { + g_warning ("camel_mime_parser_step failed (2)"); goto error; } /* Check if the X-Evolution header is valid. */ - xev = camel_mime_parser_header(mp, "X-Evolution", &xevoffset); - if (xev && header_evolution_decode(xev, &uid, &flags) != -1) + xev = camel_mime_parser_header (mp, "X-Evolution", &xevoffset); + if (xev && header_evolution_decode (xev, &uid, &flags) != -1) xevok = TRUE; - xevnew = header_evolution_encode(strtoul(info->info.uid, NULL, 10), info->info.flags & 0xffff); + xevnew = header_evolution_encode (strtoul (info->info.uid, NULL, 10), info->info.flags & 0xffff); if (quick) { if (!xevok) { - g_warning("The summary told me I had an X-Evolution header, but i dont!"); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - "Summary mismatch, X-Evolution header missing"); + g_warning ("The summary told me I had an X-Evolution header, but i dont!"); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Summary mismatch, X-Evolution header missing"); goto error; } - buffer = g_strdup_printf("X-Evolution: %s", xevnew); - lastpos = lseek(fd, 0, SEEK_CUR); - lseek(fd, xevoffset, SEEK_SET); + buffer = g_strdup_printf ("X-Evolution: %s", xevnew); + lastpos = lseek (fd, 0, SEEK_CUR); + lseek (fd, xevoffset, SEEK_SET); do { - len = write(fd, buffer, strlen(buffer)); + len = write (fd, buffer, strlen (buffer)); } while (len == -1 && errno == EINTR); - lseek(fd, lastpos, SEEK_SET); - g_free(buffer); + lseek (fd, lastpos, SEEK_SET); + g_free (buffer); if (len == -1) { - g_warning("Yahoo! len == -1"); + g_warning ("Yahoo! len == -1"); goto error; } } else { - frompos = lseek(fdout, 0, SEEK_CUR); - fromline = camel_mbox_summary_build_from(camel_mime_parser_headers_raw(mp)); - write(fdout, fromline, strlen(fromline)); - g_free(fromline); - if (header_write(fdout, camel_mime_parser_headers_raw(mp), xevnew) == -1) { - d(printf("Error writing to tmp mailbox\n")); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - "Error writing to temp mailbox: %s", strerror(errno)); + frompos = lseek (fdout, 0, SEEK_CUR); + fromline = camel_mbox_summary_build_from (camel_mime_parser_headers_raw (mp)); + write (fdout, fromline, strlen(fromline)); + g_free (fromline); + if (header_write (fdout, camel_mime_parser_headers_raw (mp), xevnew) == -1) { + d(printf ("Error writing to tmp mailbox\n")); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Error writing to temp mailbox: %s", + strerror (errno)); goto error; } - bodypos = lseek(fdout, 0, SEEK_CUR); - d(printf("pos = %d, endpos = %d, bodypos = %d\n", - (int)info->info.content->pos, - (int)info->info.content->endpos, - (int)info->info.content->bodypos)); - if (copy_block(fd, fdout, info->info.content->bodypos, - info->info.content->endpos - info->info.content->bodypos) == -1) { - g_warning("Cannot copy data to output fd"); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - "Cannot copy data to output fd: %s", strerror(errno)); + bodypos = lseek (fdout, 0, SEEK_CUR); + d(printf ("pos = %d, endpos = %d, bodypos = %d\n", + (int) info->info.content->pos, + (int) info->info.content->endpos, + (int) info->info.content->bodypos)); + if (copy_block (fd, fdout, info->info.content->bodypos, + info->info.content->endpos - info->info.content->bodypos) == -1) { + g_warning ("Cannot copy data to output fd"); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Cannot copy data to output fd: %s", + strerror (errno)); goto error; } info->frompos = frompos; offset = bodypos - info->info.content->bodypos; } info->info.flags &= 0xffff; - g_free(xevnew); + g_free (xevnew); xevnew = NULL; - camel_mime_parser_drop_step(mp); - camel_mime_parser_drop_step(mp); + camel_mime_parser_drop_step (mp); + camel_mime_parser_drop_step (mp); } else { if (!quick) { - if (copy_block(fd, fdout, info->frompos, info->info.content->endpos - info->frompos) == -1) { - g_warning("Cannot copy data to output fd"); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - "Cannot copy data to output fd: %s", strerror(errno)); + if (copy_block (fd, fdout, info->frompos, + info->info.content->endpos - info->frompos) == -1) { + g_warning ("Cannot copy data to output fd"); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Cannot copy data to output fd: %s", + strerror (errno)); goto error; } /* update from pos here? */ info->frompos += offset; } else { - d(printf("Nothing to do for this message\n")); + d(printf ("Nothing to do for this message\n")); } } if (!quick && info != NULL && offset != 0) { - d(printf("offsetting content: %d\n", (int)offset)); - camel_folder_summary_offset_content(info->info.content, offset); - d(printf("pos = %d, endpos = %d, bodypos = %d\n", - (int)info->info.content->pos, - (int)info->info.content->endpos, - (int)info->info.content->bodypos)); + d(printf ("offsetting content: %d\n", (int) offset)); + camel_folder_summary_offset_content (info->info.content, offset); + d(printf ("pos = %d, endpos = %d, bodypos = %d\n", + (int) info->info.content->pos, + (int) info->info.content->endpos, + (int) info->info.content->bodypos)); } } - d(printf("Closing folders\n")); + d(printf ("Closing folders\n")); - if (close(fd) == -1) { - g_warning("Cannot close source folder: %s", strerror(errno)); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not close source folder %s: %s", - mbs->folder_path, strerror(errno)); + if (close (fd) == -1) { + g_warning ("Cannot close source folder: %s", strerror (errno)); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not close source folder %s: %s", + mbs->folder_path, strerror (errno)); goto error; } if (!quick) { - if (close(fdout) == -1) { - g_warning("Cannot close tmp folder: %s", strerror(errno)); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not close temp folder: %s", - strerror(errno)); + if (close (fdout) == -1) { + g_warning ("Cannot close tmp folder: %s", strerror (errno)); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not close temp folder: %s", + strerror (errno)); goto error; } - if (rename(tmpname, mbs->folder_path) == -1) { - g_warning("Cannot rename folder: %s", strerror(errno)); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not rename folder: %s", - strerror(errno)); + if (rename (tmpname, mbs->folder_path) == -1) { + g_warning ("Cannot rename folder: %s", strerror (errno)); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not rename folder: %s", + strerror (errno)); goto error; } tmpname = NULL; if (mbs->index) - ibex_save(mbs->index); + ibex_save (mbs->index); } - if (stat(mbs->folder_path, &st) == -1) { - g_warning("Hmm... stat(mbs->folder_path, &st) == -1"); - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Unknown error: %s", strerror(errno)); + if (stat (mbs->folder_path, &st) == -1) { + g_warning ("Hmm... stat(mbs->folder_path, &st) == -1"); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Unknown error: %s", + strerror (errno)); goto error; } - camel_folder_summary_touch(s); + camel_folder_summary_touch (s); s->time = st.st_mtime; mbs->folder_size = st.st_size; - camel_folder_summary_save(s); - - gtk_object_unref(GTK_OBJECT(mp)); + camel_folder_summary_save (s); + camel_object_unref (CAMEL_OBJECT (mp)); + return 0; - error: + error: if (fd != -1) - close(fd); - + close (fd); + if (fdout != -1) - close(fdout); - - g_free(xevnew); - + close (fdout); + + g_free (xevnew); + if (tmpname) - unlink(tmpname); + unlink (tmpname); if (mp) - gtk_object_unref(GTK_OBJECT(mp)); + camel_object_unref (CAMEL_OBJECT (mp)); return -1; } + + + + + diff --git a/camel/providers/mbox/camel-mbox-summary.h b/camel/providers/mbox/camel-mbox-summary.h index b4e59fa343..2462b72078 100644 --- a/camel/providers/mbox/camel-mbox-summary.h +++ b/camel/providers/mbox/camel-mbox-summary.h @@ -22,14 +22,13 @@ #ifndef _CAMEL_MBOX_SUMMARY_H #define _CAMEL_MBOX_SUMMARY_H -#include #include #include #include -#define CAMEL_MBOX_SUMMARY(obj) GTK_CHECK_CAST (obj, camel_mbox_summary_get_type (), CamelMboxSummary) -#define CAMEL_MBOX_SUMMARY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mbox_summary_get_type (), CamelMboxSummaryClass) -#define IS_CAMEL_MBOX_SUMMARY(obj) GTK_CHECK_TYPE (obj, camel_mbox_summary_get_type ()) +#define CAMEL_MBOX_SUMMARY(obj) CAMEL_CHECK_CAST (obj, camel_mbox_summary_get_type (), CamelMboxSummary) +#define CAMEL_MBOX_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mbox_summary_get_type (), CamelMboxSummaryClass) +#define IS_CAMEL_MBOX_SUMMARY(obj) CAMEL_CHECK_TYPE (obj, camel_mbox_summary_get_type ()) typedef struct _CamelMboxSummary CamelMboxSummary; typedef struct _CamelMboxSummaryClass CamelMboxSummaryClass; diff --git a/camel/providers/mh/camel-mh-folder.c b/camel/providers/mh/camel-mh-folder.c index b10c8b1a65..e20b3fabb5 100644 --- a/camel/providers/mh/camel-mh-folder.c +++ b/camel/providers/mh/camel-mh-folder.c @@ -49,9 +49,9 @@ static CamelFolderClass *parent_class = NULL; /* Returns the class for a CamelMhFolder */ -#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMHS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) +#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CMHS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static void mh_init(CamelFolder * folder, CamelStore * parent_store, CamelFolder * parent_folder, const gchar * name, @@ -78,14 +78,13 @@ static void mh_set_message_flags(CamelFolder * folder, const char *uid, guint32 static gboolean mh_get_message_user_flag(CamelFolder * folder, const char *uid, const char *name); static void mh_set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value); -static void mh_finalize(GtkObject * object); +static void mh_finalize(CamelObject * object); -static void camel_mh_folder_class_init(CamelMhFolderClass * camel_mh_folder_class) +static void camel_mh_folder_class_init(CamelObjectClass * camel_mh_folder_class) { CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_mh_folder_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS(camel_folder_class); - parent_class = gtk_type_class(camel_folder_get_type()); + parent_class = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs(camel_folder_get_type())); /* virtual method definition */ @@ -114,11 +113,9 @@ static void camel_mh_folder_class_init(CamelMhFolderClass * camel_mh_folder_clas camel_folder_class->set_message_flags = mh_set_message_flags; camel_folder_class->get_message_user_flag = mh_get_message_user_flag; camel_folder_class->set_message_user_flag = mh_set_message_user_flag; - - gtk_object_class->finalize = mh_finalize; } -static void mh_finalize(GtkObject * object) +static void mh_finalize(CamelObject * object) { CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(object); @@ -126,27 +123,20 @@ static void mh_finalize(GtkObject * object) g_free(mh_folder->summary_file_path); g_free(mh_folder->folder_dir_path); g_free(mh_folder->index_file_path); - - GTK_OBJECT_CLASS(parent_class)->finalize(object); } -GtkType camel_mh_folder_get_type(void) +CamelType camel_mh_folder_get_type(void) { - static GtkType camel_mh_folder_type = 0; - - if (!camel_mh_folder_type) { - GtkTypeInfo camel_mh_folder_info = { - "CamelMhFolder", - sizeof(CamelMhFolder), - sizeof(CamelMhFolderClass), - (GtkClassInitFunc) camel_mh_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mh_folder_type = gtk_type_unique(CAMEL_FOLDER_TYPE, &camel_mh_folder_info); + static CamelType camel_mh_folder_type = CAMEL_INVALID_TYPE; + + if (camel_mh_folder_type == CAMEL_INVALID_TYPE) { + camel_mh_folder_type = camel_type_register(CAMEL_FOLDER_TYPE, "CamelMhFolder", + sizeof(CamelMhFolder), + sizeof(CamelMhFolderClass), + (CamelObjectClassInitFunc) camel_mh_folder_class_init, + NULL, + (CamelObjectInitFunc) NULL, + (CamelObjectFinalizeFunc) mh_finalize); } return camel_mh_folder_type; @@ -238,7 +228,7 @@ static void mh_expunge(CamelFolder * folder, CamelException * ex) camel_mh_summary_sync(mh->summary, TRUE, ex); /* TODO: check it actually changed */ - gtk_signal_emit_by_name(GTK_OBJECT(folder), "folder_changed", 0); + camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", GINT_TO_POINTER (0)); } static gint mh_get_message_count(CamelFolder * folder) @@ -301,6 +291,7 @@ static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, /* index/summarise the message. Yes this re-reads it, its just simpler */ camel_mh_summary_add(mh_folder->summary, uid, TRUE); + if (info && (newinfo = camel_folder_summary_uid(CAMEL_FOLDER_SUMMARY(mh_folder->summary), uid))) { CamelFlag *flag = info->user_flags; @@ -316,7 +307,8 @@ static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, tag = tag->next; } } - gtk_signal_emit_by_name(GTK_OBJECT(folder), "folder_changed", 0); + + camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", GPOINTER_TO_INT (0)); g_free(name); g_free(uid); return; @@ -330,7 +322,7 @@ fail: "Cannot append message to mh file: %s", g_strerror(errno)); } if (output_stream) - gtk_object_unref(GTK_OBJECT(output_stream)); + camel_object_unref(CAMEL_OBJECT(output_stream)); if (name) { unlink(name); g_free(name); @@ -394,7 +386,7 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, errno = EINVAL; goto fail; } - gtk_object_unref(GTK_OBJECT(message_stream)); + camel_object_unref(CAMEL_OBJECT(message_stream)); g_free(name); return message; @@ -404,10 +396,10 @@ fail: name, g_strerror(errno)); if (message_stream) - gtk_object_unref(GTK_OBJECT(message_stream)); + camel_object_unref(CAMEL_OBJECT(message_stream)); if (message) - gtk_object_unref(GTK_OBJECT(message)); + camel_object_unref(CAMEL_OBJECT(message)); g_free(name); @@ -478,7 +470,7 @@ static void mh_set_message_flags(CamelFolder * folder, const char *uid, guint32 info->flags = (info->flags & ~flags) | (set & flags) | CAMEL_MESSAGE_FOLDER_FLAGGED; camel_folder_summary_touch(CAMEL_FOLDER_SUMMARY(mf->summary)); - gtk_signal_emit_by_name(GTK_OBJECT(folder), "message_changed", uid); + camel_object_trigger_event (CAMEL_OBJECT(folder), "message_changed", uid); } static gboolean mh_get_message_user_flag(CamelFolder * folder, const char *uid, const char *name) @@ -503,5 +495,5 @@ static void mh_set_message_user_flag(CamelFolder * folder, const char *uid, cons camel_flag_set(&info->user_flags, name, value); info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED; camel_folder_summary_touch(CAMEL_FOLDER_SUMMARY(mf->summary)); - gtk_signal_emit_by_name(GTK_OBJECT(folder), "message_changed", uid); + camel_object_trigger_event (CAMEL_OBJECT(folder), "message_changed", uid); } diff --git a/camel/providers/mh/camel-mh-folder.h b/camel/providers/mh/camel-mh-folder.h index e014197442..37ff133c9e 100644 --- a/camel/providers/mh/camel-mh-folder.h +++ b/camel/providers/mh/camel-mh-folder.h @@ -31,16 +31,15 @@ extern "C" { #pragma } #endif /* __cplusplus } */ -#include #include #include #include #include "camel-mh-summary.h" #define CAMEL_MH_FOLDER_TYPE (camel_mh_folder_get_type ()) -#define CAMEL_MH_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_FOLDER_TYPE, CamelMhFolder)) -#define CAMEL_MH_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_FOLDER_TYPE, CamelMhFolderClass)) -#define IS_CAMEL_MH_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MH_FOLDER_TYPE)) +#define CAMEL_MH_FOLDER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MH_FOLDER_TYPE, CamelMhFolder)) +#define CAMEL_MH_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MH_FOLDER_TYPE, CamelMhFolderClass)) +#define IS_CAMEL_MH_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_MH_FOLDER_TYPE)) typedef struct { CamelFolder parent_object; @@ -64,8 +63,8 @@ typedef struct { /* public methods */ -/* Standard Gtk function */ -GtkType camel_mh_folder_get_type(void); +/* Standard Camel function */ +CamelType camel_mh_folder_get_type(void); #ifdef __cplusplus } diff --git a/camel/providers/mh/camel-mh-store.c b/camel/providers/mh/camel-mh-store.c index 42f3b474f6..c720cb1c91 100644 --- a/camel/providers/mh/camel-mh-store.c +++ b/camel/providers/mh/camel-mh-store.c @@ -36,9 +36,9 @@ #include "camel-url.h" /* Returns the class for a CamelMhStore */ -#define CMHS_CLASS(so) CAMEL_MH_STORE_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (GTK_OBJECT(so)->klass) +#define CMHS_CLASS(so) CAMEL_MH_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static char *get_name(CamelService * service, gboolean brief); static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboolean create, CamelException * ex); @@ -46,7 +46,7 @@ static void delete_folder(CamelStore * store, const char *folder_name, CamelExce static void rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex); static char *get_folder_name(CamelStore * store, const char *folder_name, CamelException * ex); -static void camel_mh_store_class_init(CamelMhStoreClass * camel_mh_store_class) +static void camel_mh_store_class_init(CamelObjectClass * camel_mh_store_class) { CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS(camel_mh_store_class); CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS(camel_mh_store_class); @@ -60,7 +60,7 @@ static void camel_mh_store_class_init(CamelMhStoreClass * camel_mh_store_class) camel_store_class->get_folder_name = get_folder_name; } -static void camel_mh_store_init(gpointer object, gpointer klass) +static void camel_mh_store_init(CamelObject * object) { CamelService *service = CAMEL_SERVICE(object); CamelStore *store = CAMEL_STORE(object); @@ -71,23 +71,18 @@ static void camel_mh_store_init(gpointer object, gpointer klass) store->folders = g_hash_table_new(g_str_hash, g_str_equal); } -GtkType camel_mh_store_get_type(void) +CamelType camel_mh_store_get_type(void) { - static GtkType camel_mh_store_type = 0; - - if (!camel_mh_store_type) { - GtkTypeInfo camel_mh_store_info = { - "CamelMhStore", - sizeof(CamelMhStore), - sizeof(CamelMhStoreClass), - (GtkClassInitFunc) camel_mh_store_class_init, - (GtkObjectInitFunc) camel_mh_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mh_store_type = gtk_type_unique(CAMEL_STORE_TYPE, &camel_mh_store_info); + static CamelType camel_mh_store_type = CAMEL_INVALID_TYPE; + + if (camel_mh_store_type == CAMEL_INVALID_TYPE) { + camel_mh_store_type = camel_type_register(CAMEL_STORE_TYPE, "CamelMhStore", + sizeof(CamelMhStore), + sizeof(CamelMhStoreClass), + (CamelObjectClassInitFunc) camel_mh_store_class_init, + NULL, + (CamelObjectInitFunc) camel_mh_store_init, + NULL); } return camel_mh_store_type; @@ -109,10 +104,9 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboo name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name); - printf("getting folder: %s\n", name); + printf("getting folder: %s\n", name); if (stat(name, &st) == -1) { - printf("doesn't exist ...\n"); - + printf("doesn't exist ...\n"); if (errno != ENOENT) { camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "Could not open folder `%s':" "\n%s", folder_name, g_strerror(errno)); @@ -137,7 +131,7 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboo goto done; } - new_folder = gtk_type_new(CAMEL_MH_FOLDER_TYPE); + new_folder = CAMEL_FOLDER (camel_object_new(CAMEL_MH_FOLDER_TYPE)); CF_CLASS(new_folder)->init(new_folder, store, NULL, folder_name, "/", TRUE, ex); done: diff --git a/camel/providers/mh/camel-mh-store.h b/camel/providers/mh/camel-mh-store.h index 7040b27ffe..e2e2bbb656 100644 --- a/camel/providers/mh/camel-mh-store.h +++ b/camel/providers/mh/camel-mh-store.h @@ -30,12 +30,11 @@ extern "C" { #pragma } #endif /* __cplusplus } */ -#include #include "camel-store.h" #define CAMEL_MH_STORE_TYPE (camel_mh_store_get_type ()) -#define CAMEL_MH_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_STORE_TYPE, CamelMhStore)) -#define CAMEL_MH_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_STORE_TYPE, CamelMhStoreClass)) -#define IS_CAMEL_MH_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MH_STORE_TYPE)) +#define CAMEL_MH_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MH_STORE_TYPE, CamelMhStore)) +#define CAMEL_MH_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MH_STORE_TYPE, CamelMhStoreClass)) +#define IS_CAMEL_MH_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_MH_STORE_TYPE)) typedef struct { CamelStore parent_object; @@ -49,8 +48,8 @@ typedef struct { /* public methods */ -/* Standard Gtk function */ -GtkType camel_mh_store_get_type(void); +/* Standard Camel function */ +CamelType camel_mh_store_get_type(void); const gchar *camel_mh_store_get_toplevel_dir(CamelMhStore * store); diff --git a/camel/providers/mh/camel-mh-summary.c b/camel/providers/mh/camel-mh-summary.c index 36bfd2f2cf..dff025b258 100644 --- a/camel/providers/mh/camel-mh-summary.c +++ b/camel/providers/mh/camel-mh-summary.c @@ -18,8 +18,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include - #include "camel-mh-summary.h" #include @@ -43,7 +41,7 @@ static CamelMessageInfo *message_info_new(CamelFolderSummary *, struct _header_r static void camel_mh_summary_class_init (CamelMhSummaryClass *class); static void camel_mh_summary_init (CamelMhSummary *gspaper); -static void camel_mh_summary_finalise (GtkObject *obj); +static void camel_mh_summary_finalise (CamelObject *obj); #define _PRIVATE(x) (((CamelMhSummary *)(x))->priv) @@ -53,23 +51,19 @@ struct _CamelMhSummaryPrivate { static CamelFolderSummaryClass *parent_class; -guint +CamelType camel_mh_summary_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelMhSummary", - sizeof(CamelMhSummary), - sizeof(CamelMhSummaryClass), - (GtkClassInitFunc)camel_mh_summary_class_init, - (GtkObjectInitFunc)camel_mh_summary_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL - }; - - type = gtk_type_unique(camel_folder_summary_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register(camel_folder_summary_get_type (), "CamelMhSummary", + sizeof(CamelMhSummary), + sizeof(CamelMhSummaryClass), + (CamelObjectClassInitFunc)camel_mh_summary_class_init, + NULL, + (CamelObjectInitFunc)camel_mh_summary_init, + (CamelObjectFinalizeFunc)camel_mh_summary_finalise); } return type; @@ -78,17 +72,12 @@ camel_mh_summary_get_type (void) static void camel_mh_summary_class_init (CamelMhSummaryClass *class) { - GtkObjectClass *object_class; CamelFolderSummaryClass *sklass = (CamelFolderSummaryClass *) class; - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(camel_folder_summary_get_type ()); - - object_class->finalize = camel_mh_summary_finalise; + parent_class = CAMEL_FOLDER_SUMMARY_CLASS (camel_type_get_global_classfuncs(camel_folder_summary_get_type ())); /* override methods */ sklass->message_info_new = message_info_new; - } static void @@ -103,13 +92,12 @@ camel_mh_summary_init (CamelMhSummary *o) } static void -camel_mh_summary_finalise(GtkObject *obj) +camel_mh_summary_finalise(CamelObject *obj) { CamelMhSummary *o = (CamelMhSummary *)obj; g_free(o->mh_path); - - ((GtkObjectClass *)(parent_class))->finalize(obj); + g_free(o->priv); } /** @@ -121,7 +109,7 @@ camel_mh_summary_finalise(GtkObject *obj) **/ CamelMhSummary *camel_mh_summary_new (const char *filename, const char *mhdir, ibex *index) { - CamelMhSummary *o = (CamelMhSummary *)gtk_type_new(camel_mh_summary_get_type ()); + CamelMhSummary *o = (CamelMhSummary *)camel_object_new(camel_mh_summary_get_type ()); camel_folder_summary_set_build_content((CamelFolderSummary *)o, TRUE); camel_folder_summary_set_filename((CamelFolderSummary *)o, filename); @@ -181,7 +169,7 @@ int camel_mh_summary_add(CamelMhSummary * mhs, const char *name, int forceindex } mhs->priv->current_uid = (char *)name; camel_folder_summary_add_from_parser((CamelFolderSummary *)mhs, mp); - gtk_object_unref((GtkObject *)mp); + camel_object_unref((CamelObject *)mp); mhs->priv->current_uid = NULL; camel_folder_summary_set_index((CamelFolderSummary *)mhs, NULL); g_free(filename); diff --git a/camel/providers/mh/camel-mh-summary.h b/camel/providers/mh/camel-mh-summary.h index b7c8867959..28376c5d9b 100644 --- a/camel/providers/mh/camel-mh-summary.h +++ b/camel/providers/mh/camel-mh-summary.h @@ -21,14 +21,13 @@ #ifndef _CAMEL_MH_SUMMARY_H #define _CAMEL_MH_SUMMARY_H -#include #include #include #include -#define CAMEL_MH_SUMMARY(obj) GTK_CHECK_CAST (obj, camel_mh_summary_get_type (), CamelMhSummary) -#define CAMEL_MH_SUMMARY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mh_summary_get_type (), CamelMhSummaryClass) -#define IS_CAMEL_MH_SUMMARY(obj) GTK_CHECK_TYPE (obj, camel_mh_summary_get_type ()) +#define CAMEL_MH_SUMMARY(obj) CAMEL_CHECK_CAST (obj, camel_mh_summary_get_type (), CamelMhSummary) +#define CAMEL_MH_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mh_summary_get_type (), CamelMhSummaryClass) +#define IS_CAMEL_MH_SUMMARY(obj) CAMEL_CHECK_TYPE (obj, camel_mh_summary_get_type ()) typedef struct _CamelMhSummary CamelMhSummary; typedef struct _CamelMhSummaryClass CamelMhSummaryClass; @@ -49,7 +48,7 @@ struct _CamelMhSummaryClass { /* signals */ }; -guint camel_mh_summary_get_type (void); +CamelType camel_mh_summary_get_type (void); CamelMhSummary *camel_mh_summary_new (const char *filename, const char *mhdir, ibex *index); /* methods */ diff --git a/camel/providers/nntp/Makefile.am b/camel/providers/nntp/Makefile.am index 247dffbfd4..4b7c385872 100644 --- a/camel/providers/nntp/Makefile.am +++ b/camel/providers/nntp/Makefile.am @@ -7,15 +7,14 @@ providerdir = $(pkglibdir)/camel-providers/$(VERSION) provider_LTLIBRARIES = libcamelnntp.la provider_DATA = libcamelnntp.urls -INCLUDES = -I.. \ - -I$(srcdir)/.. \ +INCLUDES = -I../.. \ -I$(top_srcdir)/camel \ -I$(top_srcdir)/intl \ -I$(top_srcdir)/libibex \ -I$(top_srcdir)/e-util \ -I$(top_srcdir) \ -I$(includedir) \ - $(GTK_INCLUDEDIR) \ + $(GTK_INCLUDEDIR) \ -DG_LOG_DOMAIN=\"camel-nntp-provider\" libcamelnntp_la_SOURCES = \ diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c index dae572136e..5beabb5587 100644 --- a/camel/providers/nntp/camel-nntp-folder.c +++ b/camel/providers/nntp/camel-nntp-folder.c @@ -52,9 +52,9 @@ static CamelFolderClass *parent_class=NULL; /* Returns the class for a CamelNNTPFolder */ -#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CNNTPS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) +#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CNNTPS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static void @@ -270,21 +270,21 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException * message = camel_mime_message_new (); if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, message_stream) == -1) { - gtk_object_unref (GTK_OBJECT (message)); - gtk_object_unref (GTK_OBJECT (message_stream)); + camel_object_unref (CAMEL_OBJECT (message)); + camel_object_unref (CAMEL_OBJECT (message_stream)); camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, /* XXX */ "Could not create message for message_id %s.", message_id); return NULL; } - gtk_object_unref (GTK_OBJECT (message_stream)); + camel_object_unref (CAMEL_OBJECT (message_stream)); /* init other fields? */ - gtk_object_ref (GTK_OBJECT (folder)); + camel_object_ref (CAMEL_OBJECT (folder)); #if 0 - gtk_signal_connect (GTK_OBJECT (message), "message_changed", message_changed, folder); + gtk_signal_connect (CAMEL_OBJECT (message), "message_changed", message_changed, folder); #endif return message; @@ -356,22 +356,19 @@ nntp_folder_get_message_info (CamelFolder *folder, const char *uid) } static void -nntp_folder_finalize (GtkObject *object) +nntp_folder_finalize (CamelObject *object) { CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (object); g_free (nntp_folder->summary_file_path); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); } static void camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class) { CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_nntp_folder_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_class); - parent_class = gtk_type_class (camel_folder_get_type ()); + parent_class = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ())); /* virtual method definition */ @@ -393,30 +390,21 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class) camel_folder_class->free_subfolder_names = nntp_folder_free_subfolder_names; camel_folder_class->search_by_expression = nntp_folder_search_by_expression; camel_folder_class->get_message_info = nntp_folder_get_message_info; - - gtk_object_class->finalize = nntp_folder_finalize; - } -GtkType +CamelType camel_nntp_folder_get_type (void) { - static GtkType camel_nntp_folder_type = 0; + static CamelType camel_nntp_folder_type = CAMEL_INVALID_TYPE; - if (!camel_nntp_folder_type) { - GtkTypeInfo camel_nntp_folder_info = - { - "CamelNNTPFolder", - sizeof (CamelNNTPFolder), - sizeof (CamelNNTPFolderClass), - (GtkClassInitFunc) camel_nntp_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_nntp_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_nntp_folder_info); + if (camel_nntp_folder_type == CAMEL_INVALID_TYPE) { + camel_nntp_folder_type = camel_type_register (CAMEL_FOLDER_TYPE, "CamelNNTPFolder", + sizeof (CamelNNTPFolder), + sizeof (CamelNNTPFolderClass), + (CamelObjectClassInitFunc) camel_nntp_folder_class_init, + NULL, + (CamelObjectInitFunc) NULL, + (CamelObjectFinalizeFunc) nntp_folder_finalize); } return camel_nntp_folder_type; diff --git a/camel/providers/nntp/camel-nntp-folder.h b/camel/providers/nntp/camel-nntp-folder.h index f6c04bb005..9bbd1466b9 100644 --- a/camel/providers/nntp/camel-nntp-folder.h +++ b/camel/providers/nntp/camel-nntp-folder.h @@ -33,15 +33,14 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include "camel-folder.h" /* #include "camel-store.h" */ #define CAMEL_NNTP_FOLDER_TYPE (camel_nntp_folder_get_type ()) -#define CAMEL_NNTP_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolder)) -#define CAMEL_NNTP_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolderClass)) -#define IS_CAMEL_NNTP_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_NNTP_FOLDER_TYPE)) +#define CAMEL_NNTP_FOLDER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolder)) +#define CAMEL_NNTP_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolderClass)) +#define IS_CAMEL_NNTP_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_NNTP_FOLDER_TYPE)) typedef struct { @@ -64,8 +63,8 @@ typedef struct { /* public methods */ -/* Standard Gtk function */ -GtkType camel_nntp_folder_get_type (void); +/* Standard Camel function */ +CamelType camel_nntp_folder_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c index 8badba0e9c..214fd4b0fa 100644 --- a/camel/providers/nntp/camel-nntp-provider.c +++ b/camel/providers/nntp/camel-nntp-provider.c @@ -68,10 +68,13 @@ camel_provider_module_init (CamelSession *session) nntp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_nntp_transport_get_type(); #endif - + news_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); nntp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); - + camel_session_register_provider (session, &news_provider); camel_session_register_provider (session, &nntp_provider); } + + + diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index a7b8f7df01..48537ed2b3 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -51,9 +51,9 @@ static CamelServiceClass *service_class = NULL; /* Returns the class for a CamelNNTPStore */ -#define CNNTPS_CLASS(so) CAMEL_NNTP_STORE_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (GTK_OBJECT(so)->klass) +#define CNNTPS_CLASS(so) CAMEL_NNTP_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static gboolean ensure_news_dir_exists (CamelNNTPStore *store); @@ -134,8 +134,8 @@ nntp_store_disconnect (CamelService *service, CamelException *ex) if (!service_class->disconnect (service, ex)) return FALSE; - gtk_object_unref (GTK_OBJECT (store->ostream)); - gtk_object_unref (GTK_OBJECT (store->istream)); + camel_object_unref (CAMEL_OBJECT (store->ostream)); + camel_object_unref (CAMEL_OBJECT (store->istream)); store->ostream = NULL; store->istream = NULL; return TRUE; @@ -165,7 +165,7 @@ nntp_store_get_folder (CamelStore *store, const gchar *folder_name, /* call the standard routine for that when */ /* it is done ... */ - new_nntp_folder = gtk_type_new (CAMEL_NNTP_FOLDER_TYPE); + new_nntp_folder = CAMEL_NNTP_FOLDER (camel_object_new (CAMEL_NNTP_FOLDER_TYPE)); new_folder = CAMEL_FOLDER (new_nntp_folder); /* XXX We shouldn't be passing NULL here, but it's equivalent to @@ -186,7 +186,7 @@ nntp_store_get_folder_name (CamelStore *store, const char *folder_name, } static void -finalize (GtkObject *object) +finalize (CamelObject *object) { CamelException ex; @@ -198,16 +198,12 @@ finalize (GtkObject *object) static void camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class) { - GtkObjectClass *object_class = - GTK_OBJECT_CLASS (camel_nntp_store_class); CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_nntp_store_class); CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_nntp_store_class); - service_class = gtk_type_class (camel_service_get_type ()); + service_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ())); /* virtual method overload */ - object_class->finalize = finalize; - camel_service_class->connect = nntp_store_connect; camel_service_class->disconnect = nntp_store_disconnect; camel_service_class->get_name = nntp_store_get_name; @@ -226,25 +222,19 @@ camel_nntp_store_init (gpointer object, gpointer klass) service->url_flags = CAMEL_SERVICE_URL_NEED_HOST; } -GtkType +CamelType camel_nntp_store_get_type (void) { - static GtkType camel_nntp_store_type = 0; + static CamelType camel_nntp_store_type = CAMEL_INVALID_TYPE; - if (!camel_nntp_store_type) { - GtkTypeInfo camel_nntp_store_info = - { - "CamelNNTPStore", - sizeof (CamelNNTPStore), - sizeof (CamelNNTPStoreClass), - (GtkClassInitFunc) camel_nntp_store_class_init, - (GtkObjectInitFunc) camel_nntp_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_nntp_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_nntp_store_info); + if (camel_nntp_store_type == CAMEL_INVALID_TYPE) { + camel_nntp_store_type = camel_type_register (CAMEL_STORE_TYPE, "CamelNNTPStore", + sizeof (CamelNNTPStore), + sizeof (CamelNNTPStoreClass), + (CamelObjectClassInitFunc) camel_nntp_store_class_init, + NULL, + (CamelObjectInitFunc) camel_nntp_store_init, + (CamelObjectFinalizeFunc) finalize); } return camel_nntp_store_type; diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h index 9d4d6edebc..3099f84962 100644 --- a/camel/providers/nntp/camel-nntp-store.h +++ b/camel/providers/nntp/camel-nntp-store.h @@ -31,14 +31,13 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include "camel-store.h" #include "camel-nntp-newsrc.h" #define CAMEL_NNTP_STORE_TYPE (camel_nntp_store_get_type ()) -#define CAMEL_NNTP_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_NNTP_STORE_TYPE, CamelNNTPStore)) -#define CAMEL_NNTP_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_NNTP_STORE_TYPE, CamelNNTPStoreClass)) -#define IS_CAMEL_NNTP_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_NNTP_STORE_TYPE)) +#define CAMEL_NNTP_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_NNTP_STORE_TYPE, CamelNNTPStore)) +#define CAMEL_NNTP_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_NNTP_STORE_TYPE, CamelNNTPStoreClass)) +#define IS_CAMEL_NNTP_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_NNTP_STORE_TYPE)) typedef struct { @@ -76,8 +75,8 @@ enum { CAMEL_NNTP_OK, CAMEL_NNTP_ERR, CAMEL_NNTP_FAIL }; int camel_nntp_command (CamelNNTPStore *store, char **ret, char *fmt, ...); char *camel_nntp_command_get_additional_data (CamelNNTPStore *store); -/* Standard Gtk function */ -GtkType camel_nntp_store_get_type (void); +/* Standard Camel function */ +CamelType camel_nntp_store_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c index 9733a5f114..6dbba64c20 100644 --- a/camel/providers/pop3/camel-pop3-folder.c +++ b/camel/providers/pop3/camel-pop3-folder.c @@ -33,10 +33,10 @@ #include #include -#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (GTK_OBJECT (o)->klass)) +#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(o))) static CamelFolderClass *parent_class; -static void pop3_finalize (GtkObject *object); +static void pop3_finalize (CamelObject *object); static void pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); @@ -56,10 +56,8 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class) { CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_pop3_folder_class); - GtkObjectClass *object_class = - GTK_OBJECT_CLASS (camel_pop3_folder_class); - parent_class = gtk_type_class (camel_folder_get_type ()); + parent_class = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs (camel_folder_get_type ())); /* virtual method overload */ camel_folder_class->sync = pop3_sync; @@ -70,12 +68,10 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class) camel_folder_class->get_message = pop3_get_message; camel_folder_class->set_message_flags = pop3_set_message_flags; - - object_class->finalize = pop3_finalize; } static void -camel_pop3_folder_init (gpointer object, gpointer klass) +camel_pop3_folder_init (gpointer object) { CamelFolder *folder = CAMEL_FOLDER (object); @@ -85,32 +81,26 @@ camel_pop3_folder_init (gpointer object, gpointer klass) folder->has_search_capability = FALSE; } -GtkType +CamelType camel_pop3_folder_get_type (void) { - static GtkType camel_pop3_folder_type = 0; + static CamelType camel_pop3_folder_type = CAMEL_INVALID_TYPE; if (!camel_pop3_folder_type) { - GtkTypeInfo camel_pop3_folder_info = - { - "CamelPop3Folder", - sizeof (CamelPop3Folder), - sizeof (CamelPop3FolderClass), - (GtkClassInitFunc) camel_pop3_folder_class_init, - (GtkObjectInitFunc) camel_pop3_folder_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_pop3_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_pop3_folder_info); + camel_pop3_folder_type = camel_type_register (CAMEL_FOLDER_TYPE, "CamelPop3Folder", + sizeof (CamelPop3Folder), + sizeof (CamelPop3FolderClass), + (CamelObjectClassInitFunc) camel_pop3_folder_class_init, + NULL, + (CamelObjectInitFunc) camel_pop3_folder_init, + (CamelObjectFinalizeFunc) pop3_finalize); } return camel_pop3_folder_type; } void -pop3_finalize (GtkObject *object) +pop3_finalize (CamelObject *object) { CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object); @@ -171,7 +161,7 @@ camel_pop3_folder_new (CamelStore *parent, CamelException *ex) } } - pop3_folder = gtk_type_new (CAMEL_POP3_FOLDER_TYPE); + pop3_folder = CAMEL_POP3_FOLDER(camel_object_new (CAMEL_POP3_FOLDER_TYPE)); CF_CLASS (pop3_folder)->init ((CamelFolder *)pop3_folder, parent, NULL, "inbox", "/", TRUE, ex); pop3_folder->uids = uids; @@ -304,7 +294,7 @@ pop3_get_message (CamelFolder *folder, const char *uid, CamelException *ex) camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), CAMEL_STREAM (msgstream)); - gtk_object_unref (GTK_OBJECT (msgstream)); + camel_object_unref (CAMEL_OBJECT (msgstream)); return msg; } diff --git a/camel/providers/pop3/camel-pop3-folder.h b/camel/providers/pop3/camel-pop3-folder.h index 89c16c4c89..b4cfd469b6 100644 --- a/camel/providers/pop3/camel-pop3-folder.h +++ b/camel/providers/pop3/camel-pop3-folder.h @@ -33,13 +33,12 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include "camel-folder.h" #define CAMEL_POP3_FOLDER_TYPE (camel_pop3_folder_get_type ()) -#define CAMEL_POP3_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_POP3_FOLDER_TYPE, CamelPop3Folder)) -#define CAMEL_POP3_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_POP3_FOLDER_TYPE, CamelPop3FolderClass)) -#define IS_CAMEL_POP3_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_POP3_FOLDER_TYPE)) +#define CAMEL_POP3_FOLDER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_POP3_FOLDER_TYPE, CamelPop3Folder)) +#define CAMEL_POP3_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_POP3_FOLDER_TYPE, CamelPop3FolderClass)) +#define IS_CAMEL_POP3_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_POP3_FOLDER_TYPE)) typedef struct { @@ -63,8 +62,8 @@ typedef struct { /* public methods */ CamelFolder *camel_pop3_folder_new (CamelStore *parent, CamelException *ex); -/* Standard Gtk function */ -GtkType camel_pop3_folder_get_type (void); +/* Standard Camel function */ +CamelType camel_pop3_folder_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index 953a286a25..3cab99e0dd 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -58,7 +58,7 @@ static CamelServiceClass *service_class = NULL; -static void finalize (GtkObject *object); +static void finalize (CamelObject *object); static gboolean pop3_connect (CamelService *service, CamelException *ex); static gboolean pop3_disconnect (CamelService *service, CamelException *ex); @@ -78,18 +78,14 @@ static int pop3_get_response (CamelPop3Store *store, char **ret); static void camel_pop3_store_class_init (CamelPop3StoreClass *camel_pop3_store_class) { - GtkObjectClass *object_class = - GTK_OBJECT_CLASS (camel_pop3_store_class); CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_pop3_store_class); CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_pop3_store_class); - service_class = gtk_type_class (camel_service_get_type ()); + service_class = CAMEL_SERVICE_CLASS(camel_type_get_global_classfuncs (camel_service_get_type ())); /* virtual method overload */ - object_class->finalize = finalize; - camel_service_class->connect = pop3_connect; camel_service_class->disconnect = pop3_disconnect; camel_service_class->query_auth_types = query_auth_types; @@ -111,32 +107,26 @@ camel_pop3_store_init (gpointer object, gpointer klass) service->url_flags = (CAMEL_SERVICE_URL_NEED_USER | CAMEL_SERVICE_URL_NEED_HOST); } -GtkType +CamelType camel_pop3_store_get_type (void) { - static GtkType camel_pop3_store_type = 0; + static CamelType camel_pop3_store_type = CAMEL_INVALID_TYPE; if (!camel_pop3_store_type) { - GtkTypeInfo camel_pop3_store_info = - { - "CamelPop3Store", - sizeof (CamelPop3Store), - sizeof (CamelPop3StoreClass), - (GtkClassInitFunc) camel_pop3_store_class_init, - (GtkObjectInitFunc) camel_pop3_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_pop3_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_pop3_store_info); + camel_pop3_store_type = camel_type_register (CAMEL_STORE_TYPE, "CamelPop3Store", + sizeof (CamelPop3Store), + sizeof (CamelPop3StoreClass), + (CamelObjectClassInitFunc) camel_pop3_store_class_init, + NULL, + (CamelObjectInitFunc) camel_pop3_store_init, + finalize); } return camel_pop3_store_type; } static void -finalize (GtkObject *object) +finalize (CamelObject *object) { CamelPop3Store *pop3_store = CAMEL_POP3_STORE (object); CamelException ex; @@ -548,11 +538,11 @@ pop3_disconnect (CamelService *service, CamelException *ex) d(printf ("POP3: Disconnecting from %s\n", service->url->host)); if (store->ostream) { - gtk_object_unref (GTK_OBJECT (store->ostream)); + camel_object_unref (CAMEL_OBJECT (store->ostream)); store->ostream = NULL; } if (store->istream) { - gtk_object_unref (GTK_OBJECT (store->istream)); + camel_object_unref (CAMEL_OBJECT (store->istream)); store->istream = NULL; } diff --git a/camel/providers/pop3/camel-pop3-store.h b/camel/providers/pop3/camel-pop3-store.h index 74174a32f2..f5e447d9ea 100644 --- a/camel/providers/pop3/camel-pop3-store.h +++ b/camel/providers/pop3/camel-pop3-store.h @@ -33,14 +33,13 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include #include "camel-types.h" #include "camel-store.h" #define CAMEL_POP3_STORE_TYPE (camel_pop3_store_get_type ()) -#define CAMEL_POP3_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_POP3_STORE_TYPE, CamelPop3Store)) -#define CAMEL_POP3_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_POP3_STORE_TYPE, CamelPop3StoreClass)) -#define IS_CAMEL_POP3_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_POP3_STORE_TYPE)) +#define CAMEL_POP3_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_POP3_STORE_TYPE, CamelPop3Store)) +#define CAMEL_POP3_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_POP3_STORE_TYPE, CamelPop3StoreClass)) +#define IS_CAMEL_POP3_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_POP3_STORE_TYPE)) typedef struct { @@ -70,8 +69,8 @@ int camel_pop3_command (CamelPop3Store *store, char **ret, char *fmt, ...); char *camel_pop3_command_get_additional_data (CamelPop3Store *store, CamelException *ex); -/* Standard Gtk function */ -GtkType camel_pop3_store_get_type (void); +/* Standard Camel function */ +CamelType camel_pop3_store_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c index 3facc42676..c53512ccb4 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ b/camel/providers/sendmail/camel-sendmail-transport.c @@ -64,25 +64,19 @@ camel_sendmail_transport_class_init (CamelSendmailTransportClass *camel_sendmail camel_transport_class->send_to = _send_to; } -GtkType +CamelType camel_sendmail_transport_get_type (void) { - static GtkType camel_sendmail_transport_type = 0; + static CamelType camel_sendmail_transport_type = CAMEL_INVALID_TYPE; - if (!camel_sendmail_transport_type) { - GtkTypeInfo camel_sendmail_transport_info = - { - "CamelSendmailTransport", - sizeof (CamelSendmailTransport), - sizeof (CamelSendmailTransportClass), - (GtkClassInitFunc) camel_sendmail_transport_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_sendmail_transport_type = gtk_type_unique (CAMEL_TRANSPORT_TYPE, &camel_sendmail_transport_info); + if (camel_sendmail_transport_type == CAMEL_INVALID_TYPE) { + camel_sendmail_transport_type = camel_type_register (CAMEL_TRANSPORT_TYPE, "CamelSendmailTransport", + sizeof (CamelSendmailTransport), + sizeof (CamelSendmailTransportClass), + (CamelObjectClassInitFunc) camel_sendmail_transport_class_init, + NULL, + (CamelObjectInitFunc) NULL, + NULL); } return camel_sendmail_transport_type; @@ -148,13 +142,13 @@ _send_internal (CamelMedium *message, char **argv, CamelException *ex) out = camel_stream_fs_new_with_fd (fd[1]); if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1 || camel_stream_close(out) == -1) { - gtk_object_unref (GTK_OBJECT (out)); + camel_object_unref (CAMEL_OBJECT (out)); camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "Could not send message: %s", strerror(errno)); return FALSE; } - gtk_object_unref (GTK_OBJECT (out)); + camel_object_unref (CAMEL_OBJECT (out)); /* Wait for sendmail to exit. */ while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR) diff --git a/camel/providers/sendmail/camel-sendmail-transport.h b/camel/providers/sendmail/camel-sendmail-transport.h index 3f3714584a..bb5dca071b 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.h +++ b/camel/providers/sendmail/camel-sendmail-transport.h @@ -37,9 +37,9 @@ extern "C" { #include "camel-transport.h" #define CAMEL_SENDMAIL_TRANSPORT_TYPE (camel_sendmail_transport_get_type ()) -#define CAMEL_SENDMAIL_TRANSPORT(obj) (GTK_CHECK_CAST((obj), CAMEL_SENDMAIL_TRANSPORT_TYPE, CamelSendmailTransport)) -#define CAMEL_SENDMAIL_TRANSPORT_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SENDMAIL_TRANSPORT_TYPE, CamelSendmailTransportClass)) -#define CAMEL_IS_SENDMAIL_TRANSPORT(o) (GTK_CHECK_TYPE((o), CAMEL_SENDMAIL_TRANSPORT_TYPE)) +#define CAMEL_SENDMAIL_TRANSPORT(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SENDMAIL_TRANSPORT_TYPE, CamelSendmailTransport)) +#define CAMEL_SENDMAIL_TRANSPORT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SENDMAIL_TRANSPORT_TYPE, CamelSendmailTransportClass)) +#define CAMEL_IS_SENDMAIL_TRANSPORT(o) (CAMEL_CHECK_TYPE((o), CAMEL_SENDMAIL_TRANSPORT_TYPE)) typedef struct { @@ -54,8 +54,8 @@ typedef struct { } CamelSendmailTransportClass; -/* Standard Gtk function */ -GtkType camel_sendmail_transport_get_type (void); +/* Standard Camel function */ +CamelType camel_sendmail_transport_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 0f70d6314e..83241b2cad 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -83,7 +83,7 @@ camel_smtp_transport_class_init (CamelSmtpTransportClass *camel_smtp_transport_c CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_smtp_transport_class); - service_class = gtk_type_class (camel_service_get_type ()); + service_class = CAMEL_SERVICE_CLASS(camel_type_get_global_classfuncs (camel_service_get_type ())); /* virtual method overload */ camel_service_class->connect = smtp_connect; @@ -98,32 +98,26 @@ camel_smtp_transport_class_init (CamelSmtpTransportClass *camel_smtp_transport_c } static void -camel_smtp_transport_init (gpointer object, gpointer klass) +camel_smtp_transport_init (gpointer object) { CamelService *service = CAMEL_SERVICE (object); service->url_flags = CAMEL_SERVICE_URL_NEED_HOST; } -GtkType +CamelType camel_smtp_transport_get_type (void) { - static GtkType camel_smtp_transport_type = 0; - - if (!camel_smtp_transport_type) { - GtkTypeInfo camel_smtp_transport_info = - { - "CamelSmtpTransport", - sizeof (CamelSmtpTransport), - sizeof (CamelSmtpTransportClass), - (GtkClassInitFunc) camel_smtp_transport_class_init, - (GtkObjectInitFunc) camel_smtp_transport_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_smtp_transport_type = gtk_type_unique (CAMEL_TRANSPORT_TYPE, &camel_smtp_transport_info); + static CamelType camel_smtp_transport_type = CAMEL_INVALID_TYPE; + + if (camel_smtp_transport_type == CAMEL_INVALID_TYPE) { + camel_smtp_transport_type = camel_type_register (CAMEL_TRANSPORT_TYPE, "CamelSmtpTransport", + sizeof (CamelSmtpTransport), + sizeof (CamelSmtpTransportClass), + (CamelObjectClassInitFunc) camel_smtp_transport_class_init, + NULL, + (CamelObjectInitFunc) camel_smtp_transport_init, + NULL); } return camel_smtp_transport_type; @@ -241,8 +235,8 @@ smtp_disconnect (CamelService *service, CamelException *ex) g_free (transport->esmtp_supported_authtypes); transport->esmtp_supported_authtypes = NULL; - gtk_object_unref (GTK_OBJECT (transport->ostream)); - gtk_object_unref (GTK_OBJECT (transport->istream)); + camel_object_unref (CAMEL_OBJECT (transport->ostream)); + camel_object_unref (CAMEL_OBJECT (transport->istream)); transport->ostream = NULL; transport->istream = NULL; @@ -691,7 +685,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException * camel_stream_filter_remove (filtered_stream, id); camel_stream_flush (CAMEL_STREAM(filtered_stream)); - gtk_object_unref (GTK_OBJECT(filtered_stream)); + camel_object_unref (CAMEL_OBJECT(filtered_stream)); /* terminate the message body */ diff --git a/camel/providers/smtp/camel-smtp-transport.h b/camel/providers/smtp/camel-smtp-transport.h index c11b8b4738..21bdaa03f7 100644 --- a/camel/providers/smtp/camel-smtp-transport.h +++ b/camel/providers/smtp/camel-smtp-transport.h @@ -43,9 +43,9 @@ extern "C" { #include "camel-transport.h" #define CAMEL_SMTP_TRANSPORT_TYPE (camel_smtp_transport_get_type ()) -#define CAMEL_SMTP_TRANSPORT(obj) (GTK_CHECK_CAST((obj), CAMEL_SMTP_TRANSPORT_TYPE, CamelSmtpTransport)) -#define CAMEL_SMTP_TRANSPORT_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SMTP_TRANSPORT_TYPE, CamelSmtpTransportClass)) -#define IS_CAMEL_SMTP_TRANSPORT(o) (GTK_CHECK_TYPE((o), CAMEL_SMTP_TRANSPORT_TYPE)) +#define CAMEL_SMTP_TRANSPORT(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SMTP_TRANSPORT_TYPE, CamelSmtpTransport)) +#define CAMEL_SMTP_TRANSPORT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SMTP_TRANSPORT_TYPE, CamelSmtpTransportClass)) +#define IS_CAMEL_SMTP_TRANSPORT(o) (CAMEL_CHECK_TYPE((o), CAMEL_SMTP_TRANSPORT_TYPE)) typedef struct { @@ -69,8 +69,8 @@ typedef struct { } CamelSmtpTransportClass; -/* Standard Gtk function */ -GtkType camel_smtp_transport_get_type (void); +/* Standard Camel function */ +CamelType camel_smtp_transport_get_type (void); #ifdef __cplusplus } diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c index 18eb49bc98..87f2be856b 100644 --- a/camel/providers/vee/camel-vee-folder.c +++ b/camel/providers/vee/camel-vee-folder.c @@ -63,36 +63,26 @@ static void vee_set_message_user_flag (CamelFolder *folder, const char *uid, con static void camel_vee_folder_class_init (CamelVeeFolderClass *klass); static void camel_vee_folder_init (CamelVeeFolder *obj); -static void camel_vee_folder_finalise (GtkObject *obj); +static void camel_vee_folder_finalise (CamelObject *obj); static void vee_folder_build(CamelVeeFolder *vf, CamelException *ex); static void vee_folder_build_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex); static CamelFolderClass *camel_vee_folder_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint +CamelType camel_vee_folder_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelVeeFolder", - sizeof (CamelVeeFolder), - sizeof (CamelVeeFolderClass), - (GtkClassInitFunc) camel_vee_folder_class_init, - (GtkObjectInitFunc) camel_vee_folder_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_folder_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_folder_get_type (), "CamelVeeFolder", + sizeof (CamelVeeFolder), + sizeof (CamelVeeFolderClass), + (CamelObjectClassInitFunc) camel_vee_folder_class_init, + NULL, + (CamelObjectInitFunc) camel_vee_folder_init, + (CamelObjectFinalizeFunc) camel_vee_folder_finalise); } return type; @@ -101,10 +91,9 @@ camel_vee_folder_get_type (void) static void camel_vee_folder_class_init (CamelVeeFolderClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelFolderClass *folder_class = (CamelFolderClass *) klass; - camel_vee_folder_parent = gtk_type_class (camel_folder_get_type ()); + camel_vee_folder_parent = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs (camel_folder_get_type ())); folder_class->init = vee_init; folder_class->sync = vee_sync; @@ -125,10 +114,6 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass) folder_class->set_message_flags = vee_set_message_flags; folder_class->get_message_user_flag = vee_get_message_user_flag; folder_class->set_message_user_flag = vee_set_message_user_flag; - - object_class->finalize = camel_vee_folder_finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -140,7 +125,7 @@ camel_vee_folder_init (CamelVeeFolder *obj) } static void -camel_vee_folder_finalise (GtkObject *obj) +camel_vee_folder_finalise (CamelObject *obj) { CamelVeeFolder *vf = (CamelVeeFolder *)obj; struct _CamelVeeFolderPrivate *p = _PRIVATE(vf); @@ -149,11 +134,9 @@ camel_vee_folder_finalise (GtkObject *obj) node = p->folders; while (node) { CamelFolder *f = node->data; - gtk_object_unref((GtkObject *)f); + camel_object_unref((CamelObject *)f); node = g_list_next(node); } - - ((GtkObjectClass *)(camel_vee_folder_parent))->finalize((GtkObject *)obj); } /** @@ -166,12 +149,12 @@ camel_vee_folder_finalise (GtkObject *obj) CamelVeeFolder * camel_vee_folder_new (void) { - CamelVeeFolder *new = CAMEL_VEE_FOLDER ( gtk_type_new (camel_vee_folder_get_type ())); + CamelVeeFolder *new = CAMEL_VEE_FOLDER ( camel_object_new (camel_vee_folder_get_type ())); return new; } static void -folder_changed(CamelFolder *sub, int type, CamelVeeFolder *vf) +folder_changed(CamelFolder *sub, gpointer type, CamelVeeFolder *vf) { CamelException *ex; @@ -179,7 +162,7 @@ folder_changed(CamelFolder *sub, int type, CamelVeeFolder *vf) vee_folder_build_folder(vf, sub, ex); camel_exception_free(ex); /* FIXME: should only raise follow-on event if the result changed */ - gtk_signal_emit_by_name((GtkObject *)vf, "folder_changed", 0); + camel_object_trigger_event( CAMEL_OBJECT(vf), "folder_changed", GINT_TO_POINTER(0)); } /* track flag changes in the summary */ @@ -203,7 +186,7 @@ message_changed(CamelFolder *f, const char *uid, CamelVeeFolder *mf) camel_flag_set(&vinfo->user_flags, flag->name, TRUE); flag = flag->next; } - gtk_signal_emit_by_name((GtkObject *)mf, "message_changed", vinfo->uid); + camel_object_trigger_event( CAMEL_OBJECT(mf), "message_changed", vinfo->uid); } g_free(vuid); } @@ -214,17 +197,17 @@ camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub) struct _CamelVeeFolderPrivate *p = _PRIVATE(vf); CamelException *ex; - gtk_object_ref((GtkObject *)sub); + camel_object_ref((CamelObject *)sub); p->folders = g_list_append(p->folders, sub); - gtk_signal_connect((GtkObject *)sub, "folder_changed", folder_changed, vf); - gtk_signal_connect((GtkObject *)sub, "message_changed", message_changed, vf); + camel_object_hook_event ((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf); + camel_object_hook_event ((CamelObject *)sub, "message_changed", (CamelObjectEventHookFunc) message_changed, vf); ex = camel_exception_new(); vee_folder_build_folder(vf, sub, ex); camel_exception_free(ex); /* FIXME: should only raise follow-on event if the result changed */ - gtk_signal_emit_by_name((GtkObject *)vf, "folder_changed", 0); + camel_object_trigger_event( CAMEL_OBJECT(vf), "folder_changed", GINT_TO_POINTER(0)); } diff --git a/camel/providers/vee/camel-vee-folder.h b/camel/providers/vee/camel-vee-folder.h index ea2a82a25b..6f7c788125 100644 --- a/camel/providers/vee/camel-vee-folder.h +++ b/camel/providers/vee/camel-vee-folder.h @@ -22,12 +22,11 @@ #ifndef _CAMEL_VEE_FOLDER_H #define _CAMEL_VEE_FOLDER_H -#include #include -#define CAMEL_VEE_FOLDER(obj) GTK_CHECK_CAST (obj, camel_vee_folder_get_type (), CamelVeeFolder) -#define CAMEL_VEE_FOLDER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_vee_folder_get_type (), CamelVeeFolderClass) -#define IS_CAMEL_VEE_FOLDER(obj) GTK_CHECK_TYPE (obj, camel_vee_folder_get_type ()) +#define CAMEL_VEE_FOLDER(obj) CAMEL_CHECK_CAST (obj, camel_vee_folder_get_type (), CamelVeeFolder) +#define CAMEL_VEE_FOLDER_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_vee_folder_get_type (), CamelVeeFolderClass) +#define IS_CAMEL_VEE_FOLDER(obj) CAMEL_CHECK_TYPE (obj, camel_vee_folder_get_type ()) typedef struct _CamelVeeFolder CamelVeeFolder; typedef struct _CamelVeeFolderClass CamelVeeFolderClass; diff --git a/camel/providers/vee/camel-vee-store.c b/camel/providers/vee/camel-vee-store.c index 4b1fc3f23b..8be8298b2c 100644 --- a/camel/providers/vee/camel-vee-store.c +++ b/camel/providers/vee/camel-vee-store.c @@ -32,33 +32,22 @@ struct _CamelVeeStorePrivate { static void camel_vee_store_class_init (CamelVeeStoreClass *klass); static void camel_vee_store_init (CamelVeeStore *obj); -static void camel_vee_store_finalise (GtkObject *obj); static CamelStoreClass *camel_vee_store_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint +CamelType camel_vee_store_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelVeeStore", - sizeof (CamelVeeStore), - sizeof (CamelVeeStoreClass), - (GtkClassInitFunc) camel_vee_store_class_init, - (GtkObjectInitFunc) camel_vee_store_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_store_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_store_get_type (), "CamelVeeStore", + sizeof (CamelVeeStore), + sizeof (CamelVeeStoreClass), + (CamelObjectClassInitFunc) camel_vee_store_class_init, + NULL, + (CamelObjectInitFunc) camel_vee_store_init, + NULL); } return type; @@ -68,18 +57,13 @@ static void camel_vee_store_class_init (CamelVeeStoreClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelStoreClass *store_class = (CamelStoreClass *) klass; - camel_vee_store_parent = gtk_type_class (camel_store_get_type ()); + camel_vee_store_parent = CAMEL_STORE_CLASS(camel_type_get_global_classfuncs (camel_store_get_type ())); /* virtual method overload */ store_class->get_folder = vee_get_folder; store_class->get_folder_name = vee_get_folder_name; - - object_class->finalize = camel_vee_store_finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -90,12 +74,6 @@ camel_vee_store_init (CamelVeeStore *obj) p = _PRIVATE(obj) = g_malloc0(sizeof(*p)); } -static void -camel_vee_store_finalise (GtkObject *obj) -{ - ((GtkObjectClass *)(camel_vee_store_parent))->finalize((GtkObject *)obj); -} - /** * camel_vee_store_new: * @@ -106,7 +84,7 @@ camel_vee_store_finalise (GtkObject *obj) CamelVeeStore * camel_vee_store_new (void) { - CamelVeeStore *new = CAMEL_VEE_STORE ( gtk_type_new (camel_vee_store_get_type ())); + CamelVeeStore *new = CAMEL_VEE_STORE ( camel_object_new (camel_vee_store_get_type ())); return new; } @@ -115,9 +93,9 @@ vee_get_folder (CamelStore *store, const char *folder_name, gboolean create, Cam { CamelFolder *folder; - folder = gtk_type_new (camel_vee_folder_get_type()); + folder = CAMEL_FOLDER (camel_object_new (camel_vee_folder_get_type())); - ((CamelFolderClass *)((GtkObject *)folder)->klass)->init (folder, store, NULL, folder_name, "/", TRUE, ex); + ((CamelFolderClass *)(CAMEL_OBJECT_GET_CLASS(folder)))->init (folder, store, NULL, folder_name, "/", TRUE, ex); return folder; } diff --git a/camel/providers/vee/camel-vee-store.h b/camel/providers/vee/camel-vee-store.h index 848769296a..d4ed7a0610 100644 --- a/camel/providers/vee/camel-vee-store.h +++ b/camel/providers/vee/camel-vee-store.h @@ -22,12 +22,11 @@ #ifndef _CAMEL_VEE_STORE_H #define _CAMEL_VEE_STORE_H -#include #include -#define CAMEL_VEE_STORE(obj) GTK_CHECK_CAST (obj, camel_vee_store_get_type (), CamelVeeStore) -#define CAMEL_VEE_STORE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_vee_store_get_type (), CamelVeeStoreClass) -#define IS_CAMEL_VEE_STORE(obj) GTK_CHECK_TYPE (obj, camel_vee_store_get_type ()) +#define CAMEL_VEE_STORE(obj) CAMEL_CHECK_CAST (obj, camel_vee_store_get_type (), CamelVeeStore) +#define CAMEL_VEE_STORE_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_vee_store_get_type (), CamelVeeStoreClass) +#define IS_CAMEL_VEE_STORE(obj) CAMEL_CHECK_TYPE (obj, camel_vee_store_get_type ()) typedef struct _CamelVeeStore CamelVeeStore; typedef struct _CamelVeeStoreClass CamelVeeStoreClass; -- cgit v1.2.3