diff options
author | Peter Williams <peterw@src.gnome.org> | 2000-08-11 01:30:50 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2000-08-11 01:30:50 +0800 |
commit | 8cb514d6dd9497893a35a089d07a132d51263ee7 (patch) | |
tree | 9f4e5d1f929da7e0be900919753d419fe4c9c61a /camel | |
parent | bcbb63c59f80eb4e684036c5ef58ab141fb01b03 (diff) | |
download | gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.gz gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.zst gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.zip |
Merge with camel-async.
svn path=/trunk/; revision=4687
Diffstat (limited to 'camel')
106 files changed, 3455 insertions, 2641 deletions
diff --git a/camel/.cvsignore b/camel/.cvsignore index fd6b811c68..521f6065df 100644 --- a/camel/.cvsignore +++ b/camel/.cvsignore @@ -5,3 +5,4 @@ Makefile.in .deps *.lo *.la +temp-test diff --git a/camel/ChangeLog b/camel/ChangeLog index 7152df91ba..ce492be3e7 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -61,6 +61,15 @@ (camel_tag_list_size): (camel_tag_list_free): Operations for working with CamelTags. +2000-08-09 Peter Williams <peterw@helixcode.com> + + * camel-store.c (camel_store_get_folder): Connect beforehand, if + necessary. + + * providers/imap/camel-imap-store.c (camel_imap_store_init): Default + the dir_sep to "/" so that certain functions can safely assume that + dir_sep is valid (at least, nonnull). + 2000-08-09 Ettore Perazzoli <ettore@helixcode.com> * providers/nntp/camel-nntp-folder.c @@ -92,35 +101,22 @@ * camel-mime-message.c (process_header): Add another subject g_strstrip that fejj's earlier commit missed. -2000-08-07 Not Zed <NotZed@HelixCode.com> - - * providers/mh/camel-mh-folder.c (mh_append_message): Only retry - another uid if we had a name clash, otherwise fail. - -2000-08-04 Not Zed <NotZed@HelixCode.com> - - * camel-url.c (camel_url_set_protocol): - (camel_url_set_host): - (camel_url_set_path): - (camel_url_set_port): Url editing functions. - -2000-08-02 Not Zed <NotZed@HelixCode.com> - - * providers/mh/camel-mh-summary.c (camel_mh_summary_sync): Expunge - from the end, so the index isn't messed up when you remove a - message. +2000-08-08 Peter Williams <peterw@helixcode.com> - * providers/mh/camel-mh-folder.c (mh_append_message): Fix a bug - where it would never open an output file/uid. + * camel-provider.h: Remove some GTK stuff that I missed. - * providers/mbox/camel-mbox-store.c (rename_folder): - Implementation for mbox as well. + * providers/imap/camel-imap-store.c (imap_noop): Turn this + back on with the new timeout interface in CamelSession. - * camel-store.c (camel_store_rename_folder): New method to rename folders. - (rename_folder): Default implementation. + * camel-session.[ch] (camel_session_register_timeout): New + interface for Camel to register timeouts. Basically the + GTK timeout interface is copied. We do this because Camel isn't + allowed to use GTK anymore. + +2000-08-07 Not Zed <NotZed@HelixCode.com> - * providers/mh/camel-mh-store.c (delete_folder): Implement this. - (rename_folder): Implement a rename operation. + * providers/mh/camel-mh-folder.c (mh_append_message): Only retry + another uid if we had a name clash, otherwise fail. 2000-08-07 Jeffrey Stedfast <fejj@helixcode.com> @@ -132,6 +128,14 @@ * providers/imap/camel-imap-utils.c (imap_parse_list_response): Check for NIL as a directory separator. +2000-08-07 Peter Williams <peterw@helixcode.com> + + * providers/nntp/Makefile.am: Reorder the INCLUDES to pull + in the camel headers from the local source tree before + the ones in $(includedir). This was causing compile problems + because the installed, Gtk-based camel-object.h was included + before the uninstall Camel-based one. + 2000-08-07 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-utils.c (imap_translate_sexp): Strip @@ -160,6 +164,18 @@ * providers/imap/camel-imap-store.c (get_folder): Prevent a coredump when get_folder()ing from a store with dir_sep = NULL. +2000-08-04 Peter Williams <peterw@helixcode.com> + + * camel-store.h: Include camel-object.h. Ettore said this wasn't + compiling. + +2000-08-04 Not Zed <NotZed@HelixCode.com> + + * camel-url.c (camel_url_set_protocol): + (camel_url_set_host): + (camel_url_set_path): + (camel_url_set_port): Url editing functions. + 2000-08-04 Dan Winship <danw@helixcode.com> * providers/pop3/camel-pop3-folder.c (pop3_set_message_flags): @@ -182,6 +198,24 @@ * providers/nntp/Makefile.am (INCLUDES): Add -I$(top_srcdir) to pull in libibex/ibex.h +2000-08-02 Not Zed <NotZed@HelixCode.com> + + * providers/mh/camel-mh-summary.c (camel_mh_summary_sync): Expunge + from the end, so the index isn't messed up when you remove a + message. + + * providers/mh/camel-mh-folder.c (mh_append_message): Fix a bug + where it would never open an output file/uid. + + * providers/mbox/camel-mbox-store.c (rename_folder): + Implementation for mbox as well. + + * camel-store.c (camel_store_rename_folder): New method to rename folders. + (rename_folder): Default implementation. + + * providers/mh/camel-mh-store.c (delete_folder): Implement this. + (rename_folder): Implement a rename operation. + 2000-08-02 Dan Winship <danw@helixcode.com> * providers/MH: Kill this. It doesn't have any code to do anything @@ -540,6 +574,19 @@ (imap_get_message_info): Oops. Fix UID parser to allow 0 and 9 to be in the range of valid UID chars. +2000-07-20 Peter Williams <peterw@helixcode.com> + + * camel-object.c (camel_object_unref): Add a new global mutex + 'refcount' held when refcounting operations occur. + +2000-07-19 Peter Williams <peterw@helixcode.com> + + * camel-object.c (camel_type_lock_up): Correct the recursiveness; + the locklevel is stored as a private, so each thread has its own + idea of the locklevel. Thus one thread can relock, but a different + one will think that it's a level 0 and try to lock the type_system + mutex. + 2000-07-19 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-folder.c: General cleanup working @@ -578,6 +625,16 @@ (imap_get_subfolder_names): Let the subfolder parser trim the namespace off the folder name. +2000-07-17 Peter Williams <peterw@helixcode.com> + + * camel-object.c (camel_type_lock_up): New function; the + Camel type_system lock is now fakey-recursive, being controlled + by a semaphore that goes up and down and is protected by another + lock. Theoretically all we need is the lock on the semaphore, + but this we catch exceptions "better" (by deadlocking). + (camel_type_lock_down): Corresponding to above. + (all functions): s,G_LOCK,camel_type_lock_up, etc. + 2000-07-17 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-store.c (imap_disconnect): Send a @@ -617,6 +674,31 @@ * providers/imap/camel-imap-folder.c (camel_imap_folder_new): One last fix to get rid of hard-coded "/" directory separators +2000-07-14 Peter Williams <peterw@helixcode.com> + + * camel-object.c : Implement 'events', which are suspiciously + like signals except without all the marshalling baggage, and + with quasi-thread-safety. + (camel_object_class_declare_event): New func. + (camel_object_hook_event): Ditto. + (camel_object_trigger_event): Ditto. + (obj_class_init): Declare the "finalize" event. + (obj_class_finalize): Free the hashtable of events->preps + (obj_finalize): Free the hashtable of events->hooklists + (camel_object_unref): Trigger the finalize event (ourselves, + to prevent massively unpleasant looping things.) + +2000-07-14 Peter Williams <peterw@helixcode.com> + + * camel-object.c (make_global_classfuncs): Change to return + a CamelObjectClass. Change parents to a GSList and free it + when done. + (camel_object_new): Don't allocate a classfuncs for every object; + merely give it a reference to the global_classfuncs. Convert + parents to a GSList and free it when done. + (camel_object_unref): Don't free the classfuncs. Free the parents + list, which is changed to a GSList. + 2000-07-14 Jeffrey Stedfast <fejj@helixcode.com> * string-utils.c (string_unquote): New convenience function @@ -634,6 +716,30 @@ Deals with the case where the user edits the mbox and makes it bigger, without adding new messages. +2000-07-13 Peter Williams <peterw@helixcode.com> + + * camel-object.c: Rewritten to not be based on GtkObject, + but a tiny threadsafe ripoff thereof. Objects still cannot + be shared across threads, but ref/unref/destroy/new/etc + will work. Signals are not implemented because doing it + robustly would be a major pain in the butt, but class + functions are. There's a small demonstration that it doesn't + crash in ./temp-test.c: build it with ./make-test.sh. + * camel-stream.c, camel-seekable-stream.c, camel-stream-mem.c: + moved over to CamelObject. Proof of concept: two levels of + subclass and class functions, all working without coredumps. + To port to CamelObject: + - s,GTK_,CAMEL_,g in the cast checks + - s,gtk_type_new,camel_object_new,g + - s,GtkType,CamelType,g + - Change get_type function over to camel_type_declare + - instead of hooking to finalize function, it goes into the + type declaration. + - remove signals. + - instead of GTK_OBJECT(so)->klass, CAMEL_OBJECT_GET_CLASS(so) + - s,gtk_type_class,camel_type_get_global_classfuncs,g + - don't chain finalize handlers; it will be done for you + 2000-07-13 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-folder.c: @@ -834,6 +940,20 @@ * providers/imap/camel-imap-folder.c (imap_append_message): Updated. +2000-07-11 Dan Winship <danw@helixcode.com> + + * camel-folder.c: Remove exceptions from a number of methods + that work on what ought to be static data: get_parent_folder, + get_parent_store, get_message_count, get_unread_message_count, + get_permanent_flags, get_message_flags, set_message_flags, + get_message_user_flag, set_message_user_flag, get_message_uid, + get_uids, get_summary, get_subfolder_names. Turn + camel_folder_delete_message into a macro. + + * providers/{mbox,pop3,vee}: Update for CamelFolder changes + + * providers/Makefile.am: Disable imap and nntp for now + 2000-07-11 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-folder.c (imap_search_by_expression): diff --git a/camel/Makefile.am b/camel/Makefile.am index a265d3a027..4d2c29a4ca 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -7,10 +7,10 @@ providerdir = $(libdir)/evolution/camel-providers/$(VERSION) lib_LTLIBRARIES = libcamel.la -INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) \ - $(UNICODE_CFLAGS) \ +INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ + -I$(top_srcdir)/intl \ + $(GLIB_CFLAGS) \ + $(UNICODE_CFLAGS) \ -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" \ -DG_LOG_DOMAIN=\"camel\" diff --git a/camel/camel-address.c b/camel/camel-address.c index 8056c121c8..8f7cea3d67 100644 --- a/camel/camel-address.c +++ b/camel/camel-address.c @@ -23,48 +23,14 @@ static void camel_address_class_init (CamelAddressClass *klass); static void camel_address_init (CamelAddress *obj); -static void camel_address_finalise (GtkObject *obj); +static void camel_address_finalize (CamelObject *obj); static CamelObjectClass *camel_address_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -camel_address_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelAddress", - sizeof (CamelAddress), - sizeof (CamelAddressClass), - (GtkClassInitFunc) camel_address_class_init, - (GtkObjectInitFunc) camel_address_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_object_get_type (), &type_info); - } - - return type; -} - static void camel_address_class_init (CamelAddressClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - camel_address_parent = gtk_type_class (camel_object_get_type ()); - - object_class->finalize = camel_address_finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); + camel_address_parent = camel_type_get_global_classfuncs (camel_object_get_type ()); } static void @@ -74,11 +40,27 @@ camel_address_init (CamelAddress *obj) } static void -camel_address_finalise (GtkObject *obj) +camel_address_finalize (CamelObject *obj) { camel_address_remove((CamelAddress *)obj, -1); +} - ((GtkObjectClass *)(camel_address_parent))->finalize((GtkObject *)obj); +CamelType +camel_address_get_type (void) +{ + static CamelType type = CAMEL_INVALID_TYPE; + + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_object_get_type (), "CamelAddress", + sizeof (CamelAddress), + sizeof (CamelAddressClass), + (CamelObjectClassInitFunc) camel_address_class_init, + NULL, + (CamelObjectInitFunc) camel_address_init, + (CamelObjectFinalizeFunc) camel_address_finalize); + } + + return type; } /** @@ -91,7 +73,7 @@ camel_address_finalise (GtkObject *obj) CamelAddress * camel_address_new (void) { - CamelAddress *new = CAMEL_ADDRESS ( gtk_type_new (camel_address_get_type ())); + CamelAddress *new = CAMEL_ADDRESS ( camel_object_new (camel_address_get_type ())); return new; } @@ -111,7 +93,7 @@ camel_address_decode (CamelAddress *a, const char *raw) { g_return_val_if_fail(IS_CAMEL_ADDRESS(a), -1); - return ((CamelAddressClass *)((GtkObject *)a)->klass)->decode(a, raw); + return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->decode(a, raw); } /** @@ -127,7 +109,7 @@ camel_address_encode (CamelAddress *a) { g_return_val_if_fail(IS_CAMEL_ADDRESS(a), NULL); - return ((CamelAddressClass *)((GtkObject *)a)->klass)->encode(a); + return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->encode(a); } /** @@ -144,8 +126,8 @@ camel_address_remove (CamelAddress *a, int index) if (index == -1) { for (index=a->addresses->len; index>-1; index--) - ((CamelAddressClass *)((GtkObject *)a)->klass)->remove(a, index); + CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->remove(a, index); } else { - ((CamelAddressClass *)((GtkObject *)a)->klass)->remove(a, index); + CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->remove(a, index); } } diff --git a/camel/camel-address.h b/camel/camel-address.h index d035f20e00..a2d6fe34dd 100644 --- a/camel/camel-address.h +++ b/camel/camel-address.h @@ -23,9 +23,9 @@ #include <camel/camel-object.h> -#define CAMEL_ADDRESS(obj) GTK_CHECK_CAST (obj, camel_address_get_type (), CamelAddress) -#define CAMEL_ADDRESS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_address_get_type (), CamelAddressClass) -#define IS_CAMEL_ADDRESS(obj) GTK_CHECK_TYPE (obj, camel_address_get_type ()) +#define CAMEL_ADDRESS(obj) CAMEL_CHECK_CAST (obj, camel_address_get_type (), CamelAddress) +#define CAMEL_ADDRESS_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_address_get_type (), CamelAddressClass) +#define IS_CAMEL_ADDRESS(obj) CAMEL_CHECK_TYPE (obj, camel_address_get_type ()) typedef struct _CamelAddressClass CamelAddressClass; diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c index 94c222e9a4..52cf60bd33 100644 --- a/camel/camel-data-wrapper.c +++ b/camel/camel-data-wrapper.c @@ -33,7 +33,7 @@ static CamelObjectClass *parent_class = NULL; /* Returns the class for a CamelDataWrapper */ -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT (so)->klass) +#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static int construct_from_stream(CamelDataWrapper *, CamelStream *); @@ -42,15 +42,11 @@ static void set_mime_type (CamelDataWrapper *data_wrapper, const gchar *mime_typ static gchar *get_mime_type (CamelDataWrapper *data_wrapper); static GMimeContentField *get_mime_type_field (CamelDataWrapper *data_wrapper); static void set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type); -static void finalize (GtkObject *object); static void camel_data_wrapper_class_init (CamelDataWrapperClass *camel_data_wrapper_class) { - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_data_wrapper_class); - - parent_class = gtk_type_class (camel_object_get_type ()); + parent_class = camel_type_get_global_classfuncs (camel_object_get_type ()); /* virtual method definition */ camel_data_wrapper_class->write_to_stream = write_to_stream; @@ -60,9 +56,6 @@ camel_data_wrapper_class_init (CamelDataWrapperClass *camel_data_wrapper_class) camel_data_wrapper_class->set_mime_type_field = set_mime_type_field; camel_data_wrapper_class->construct_from_stream = construct_from_stream; - - /* virtual method overload */ - gtk_object_class->finalize = finalize; } static void @@ -73,35 +66,8 @@ camel_data_wrapper_init (gpointer object, gpointer klass) camel_data_wrapper->mime_type = gmime_content_field_new (NULL, NULL); } - - -GtkType -camel_data_wrapper_get_type (void) -{ - static GtkType camel_data_wrapper_type = 0; - - if (!camel_data_wrapper_type) { - GtkTypeInfo camel_data_wrapper_info = - { - "CamelDataWrapper", - sizeof (CamelDataWrapper), - sizeof (CamelDataWrapperClass), - (GtkClassInitFunc) camel_data_wrapper_class_init, - (GtkObjectInitFunc) camel_data_wrapper_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_data_wrapper_type = gtk_type_unique (camel_object_get_type (), &camel_data_wrapper_info); - } - - return camel_data_wrapper_type; -} - - static void -finalize (GtkObject *object) +camel_data_wrapper_finalize (CamelObject *object) { CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object); @@ -109,9 +75,25 @@ finalize (GtkObject *object) gmime_content_field_unref (camel_data_wrapper->mime_type); if (camel_data_wrapper->stream) - gtk_object_unref (GTK_OBJECT (camel_data_wrapper->stream)); + camel_object_unref (CAMEL_OBJECT (camel_data_wrapper->stream)); +} - GTK_OBJECT_CLASS (parent_class)->finalize (object); +CamelType +camel_data_wrapper_get_type (void) +{ + static CamelType camel_data_wrapper_type = CAMEL_INVALID_TYPE; + + if (camel_data_wrapper_type == CAMEL_INVALID_TYPE) { + camel_data_wrapper_type = camel_type_register (CAMEL_OBJECT_TYPE, "CamelDataWrapper", + sizeof (CamelDataWrapper), + sizeof (CamelDataWrapperClass), + (CamelObjectClassInitFunc) camel_data_wrapper_class_init, + NULL, + (CamelObjectInitFunc) camel_data_wrapper_init, + (CamelObjectFinalizeFunc) camel_data_wrapper_finalize); + } + + return camel_data_wrapper_type; } static int @@ -130,7 +112,7 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) CamelDataWrapper * camel_data_wrapper_new(void) { - return (CamelDataWrapper *)gtk_type_new(camel_data_wrapper_get_type()); + return (CamelDataWrapper *)camel_object_new(camel_data_wrapper_get_type()); } /** @@ -160,10 +142,10 @@ static int construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) { if (data_wrapper->stream) - gtk_object_unref((GtkObject *)data_wrapper->stream); + camel_object_unref((CamelObject *)data_wrapper->stream); data_wrapper->stream = stream; - gtk_object_ref (GTK_OBJECT (stream)); + camel_object_ref (CAMEL_OBJECT (stream)); return 0; } diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h index 8df09fa848..4a3074ae20 100644 --- a/camel/camel-data-wrapper.h +++ b/camel/camel-data-wrapper.h @@ -38,9 +38,9 @@ extern "C" { #include <camel/gmime-content-field.h> #define CAMEL_DATA_WRAPPER_TYPE (camel_data_wrapper_get_type ()) -#define CAMEL_DATA_WRAPPER(obj) (GTK_CHECK_CAST((obj), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapper)) -#define CAMEL_DATA_WRAPPER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapperClass)) -#define CAMEL_IS_DATA_WRAPPER(o) (GTK_CHECK_TYPE((o), CAMEL_DATA_WRAPPER_TYPE)) +#define CAMEL_DATA_WRAPPER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapper)) +#define CAMEL_DATA_WRAPPER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapperClass)) +#define CAMEL_IS_DATA_WRAPPER(o) (CAMEL_CHECK_TYPE((o), CAMEL_DATA_WRAPPER_TYPE)) struct _CamelDataWrapper { @@ -72,8 +72,8 @@ typedef struct { CamelStream *); } CamelDataWrapperClass; -/* Standard Gtk function */ -GtkType camel_data_wrapper_get_type (void); +/* Standard Camel function */ +CamelType camel_data_wrapper_get_type (void); /* public methods */ CamelDataWrapper * camel_data_wrapper_new(void); diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c index 5c6fa111bb..c15b6d7d40 100644 --- a/camel/camel-folder-search.c +++ b/camel/camel-folder-search.c @@ -48,54 +48,19 @@ static ESExpResult *search_dummy(struct _ESExp *f, int argc, struct _ESExpResult static void camel_folder_search_class_init (CamelFolderSearchClass *klass); static void camel_folder_search_init (CamelFolderSearch *obj); -static void camel_folder_search_finalise (GtkObject *obj); +static void camel_folder_search_finalize (CamelObject *obj); static CamelObjectClass *camel_folder_search_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -camel_folder_search_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelFolderSearch", - sizeof (CamelFolderSearch), - sizeof (CamelFolderSearchClass), - (GtkClassInitFunc) camel_folder_search_class_init, - (GtkObjectInitFunc) camel_folder_search_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_object_get_type (), &type_info); - } - - return type; -} - static void camel_folder_search_class_init (CamelFolderSearchClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - camel_folder_search_parent = gtk_type_class (camel_object_get_type ()); - - object_class->finalize = camel_folder_search_finalise; + camel_folder_search_parent = camel_type_get_global_classfuncs (camel_object_get_type ()); klass->match_all = search_match_all; klass->body_contains = search_body_contains; klass->header_contains = search_header_contains; - klass->user_flag = search_user_flag; klass->user_flag = search_user_tag; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -109,51 +74,72 @@ camel_folder_search_init (CamelFolderSearch *obj) } static void -camel_folder_search_finalise (GtkObject *obj) +camel_folder_search_finalize (CamelObject *obj) { CamelFolderSearch *search = (CamelFolderSearch *)obj; if (search->sexp) - gtk_object_unref((GtkObject *)search->sexp); + camel_object_unref((CamelObject *)search->sexp); g_free(search->last_search); +} - ((GtkObjectClass *)(camel_folder_search_parent))->finalize((GtkObject *)obj); +CamelType +camel_folder_search_get_type (void) +{ + static CamelType type = CAMEL_INVALID_TYPE; + + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_object_get_type (), "CamelFolderSearch", + sizeof (CamelFolderSearch), + sizeof (CamelFolderSearchClass), + (CamelObjectClassInitFunc) camel_folder_search_class_init, + NULL, + (CamelObjectInitFunc) camel_folder_search_init, + (CamelObjectFinalizeFunc) camel_folder_search_finalize); + } + + return type; } +#ifdef offsetof +#define CAMEL_STRUCT_OFFSET(type, field) ((gint) offsetof (type, field)) +#else +#define CAMEL_STRUCT_OFFSET(type, field) ((gint) ((gchar*) &((type *) 0)->field)) +#endif + struct { char *name; int offset; int flags; /* 0x02 = immediate, 0x01 = always enter */ } builtins[] = { /* these have default implementations in e-sexp */ - { "and", GTK_STRUCT_OFFSET(CamelFolderSearchClass, and), 2 }, - { "or", GTK_STRUCT_OFFSET(CamelFolderSearchClass, or), 2 }, - { "not", GTK_STRUCT_OFFSET(CamelFolderSearchClass, not), 2 }, - { "<", GTK_STRUCT_OFFSET(CamelFolderSearchClass, lt), 2 }, - { ">", GTK_STRUCT_OFFSET(CamelFolderSearchClass, gt), 2 }, - { "=", GTK_STRUCT_OFFSET(CamelFolderSearchClass, eq), 2 }, + { "and", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, and), 2 }, + { "or", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, or), 2 }, + { "not", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, not), 2 }, + { "<", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, lt), 2 }, + { ">", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, gt), 2 }, + { "=", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, eq), 2 }, /* these we have to use our own default if there is none */ /* they should all be defined in the language? so it poarses, or should they not?? */ - { "match-all", GTK_STRUCT_OFFSET(CamelFolderSearchClass, match_all), 3 }, - { "body-contains", GTK_STRUCT_OFFSET(CamelFolderSearchClass, body_contains), 1 }, - { "header-contains", GTK_STRUCT_OFFSET(CamelFolderSearchClass, header_contains), 1 }, - { "user-flag", GTK_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 }, - { "user-tag", GTK_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 }, + { "match-all", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, match_all), 3 }, + { "body-contains", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, body_contains), 1 }, + { "header-contains", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_contains), 1 }, + { "user-tag", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 }, }; void camel_folder_search_construct (CamelFolderSearch *search) { int i; - CamelFolderSearchClass *klass = (CamelFolderSearchClass *)GTK_OBJECT(search)->klass; + CamelFolderSearchClass *klass = (CamelFolderSearchClass *)CAMEL_OBJECT_GET_CLASS(search); for (i=0;i<sizeof(builtins)/sizeof(builtins[0]);i++) { void *func; /* c is sure messy sometimes */ func = *((void **)(((char *)klass)+builtins[i].offset)); if (func == NULL && builtins[i].flags&1) { - g_warning("Search class doesn't implement '%s' method: %s", builtins[i].name, gtk_type_name(GTK_OBJECT(search)->klass->type)); + g_warning("Search class doesn't implement '%s' method: %s", builtins[i].name, camel_type_to_name(CAMEL_OBJECT_GET_CLASS(search)->s.type)); func = (void *)search_dummy; } if (func != NULL) { @@ -181,7 +167,7 @@ camel_folder_search_construct (CamelFolderSearch *search) CamelFolderSearch * camel_folder_search_new (void) { - CamelFolderSearch *new = CAMEL_FOLDER_SEARCH ( gtk_type_new (camel_folder_search_get_type ())); + CamelFolderSearch *new = CAMEL_FOLDER_SEARCH ( camel_object_new (camel_folder_search_get_type ())); camel_folder_search_construct(new); return new; diff --git a/camel/camel-folder-search.h b/camel/camel-folder-search.h index 61c8d52a07..d1f165d842 100644 --- a/camel/camel-folder-search.h +++ b/camel/camel-folder-search.h @@ -28,9 +28,9 @@ #include <libibex/ibex.h> #include <camel/camel-folder.h> -#define CAMEL_FOLDER_SEARCH(obj) GTK_CHECK_CAST (obj, camel_folder_search_get_type (), CamelFolderSearch) -#define CAMEL_FOLDER_SEARCH_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_folder_search_get_type (), CamelFolderSearchClass) -#define IS_CAMEL_FOLDER_SEARCH(obj) GTK_CHECK_TYPE (obj, camel_folder_search_get_type ()) +#define CAMEL_FOLDER_SEARCH(obj) CAMEL_CHECK_CAST (obj, camel_folder_search_get_type (), CamelFolderSearch) +#define CAMEL_FOLDER_SEARCH_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_folder_search_get_type (), CamelFolderSearchClass) +#define IS_CAMEL_FOLDER_SEARCH(obj) CAMEL_CHECK_TYPE (obj, camel_folder_search_get_type ()) typedef struct _CamelFolderSearchClass CamelFolderSearchClass; diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index a47d98a46a..6bae5cecec 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -90,46 +90,14 @@ static CamelMessageContentInfo * summary_build_content_info(CamelFolderSummary * static void camel_folder_summary_class_init (CamelFolderSummaryClass *klass); static void camel_folder_summary_init (CamelFolderSummary *obj); -static void camel_folder_summary_finalise (GtkObject *obj); +static void camel_folder_summary_finalize (CamelObject *obj); static CamelObjectClass *camel_folder_summary_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -camel_folder_summary_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelFolderSummary", - sizeof (CamelFolderSummary), - sizeof (CamelFolderSummaryClass), - (GtkClassInitFunc) camel_folder_summary_class_init, - (GtkObjectInitFunc) camel_folder_summary_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_object_get_type (), &type_info); - } - - return type; -} - static void camel_folder_summary_class_init (CamelFolderSummaryClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - camel_folder_summary_parent = gtk_type_class (camel_object_get_type ()); - - object_class->finalize = camel_folder_summary_finalise; + camel_folder_summary_parent = camel_type_get_global_classfuncs (camel_object_get_type ()); klass->summary_header_load = summary_header_load; klass->summary_header_save = summary_header_save; @@ -145,8 +113,6 @@ camel_folder_summary_class_init (CamelFolderSummaryClass *klass) klass->content_info_load = content_info_load; klass->content_info_save = content_info_save; klass->content_info_free = content_info_free; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -172,12 +138,12 @@ camel_folder_summary_init (CamelFolderSummary *s) static void free_o_name(void *key, void *value, void *data) { - gtk_object_unref((GtkObject *)value); + camel_object_unref((CamelObject *)value); g_free(key); } static void -camel_folder_summary_finalise (GtkObject *obj) +camel_folder_summary_finalize (CamelObject *obj) { struct _CamelFolderSummaryPrivate *p; CamelFolderSummary *s = (CamelFolderSummary *)obj; @@ -194,17 +160,33 @@ camel_folder_summary_finalise (GtkObject *obj) g_free(s->summary_path); if (p->filter_index) - gtk_object_unref ((GtkObject *)p->filter_index); + camel_object_unref ((CamelObject *)p->filter_index); if (p->filter_64) - gtk_object_unref ((GtkObject *)p->filter_64); + camel_object_unref ((CamelObject *)p->filter_64); if (p->filter_qp) - gtk_object_unref ((GtkObject *)p->filter_qp); + camel_object_unref ((CamelObject *)p->filter_qp); if (p->filter_save) - gtk_object_unref ((GtkObject *)p->filter_save); + camel_object_unref ((CamelObject *)p->filter_save); g_free(p); +} - ((GtkObjectClass *)(camel_folder_summary_parent))->finalize((GtkObject *)obj); +CamelType +camel_folder_summary_get_type (void) +{ + static CamelType type = CAMEL_INVALID_TYPE; + + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_object_get_type (), "CamelFolderSummary", + sizeof (CamelFolderSummary), + sizeof (CamelFolderSummaryClass), + (CamelObjectClassInitFunc) camel_folder_summary_class_init, + NULL, + (CamelObjectInitFunc) camel_folder_summary_init, + (CamelObjectFinalizeFunc) camel_folder_summary_finalize); + } + + return type; } /** @@ -217,7 +199,7 @@ camel_folder_summary_finalise (GtkObject *obj) CamelFolderSummary * camel_folder_summary_new (void) { - CamelFolderSummary *new = CAMEL_FOLDER_SUMMARY ( gtk_type_new (camel_folder_summary_get_type ())); + CamelFolderSummary *new = CAMEL_FOLDER_SUMMARY ( camel_object_new (camel_folder_summary_get_type ())); return new; } @@ -283,7 +265,7 @@ perform_content_info_load(CamelFolderSummary *s, FILE *in) guint32 count; CamelMessageContentInfo *ci, *part; - ci = ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->content_info_load(s, in); + ci = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_load(s, in); camel_folder_summary_decode_uint32(in, &count); for (i=0;i<count;i++) { part = perform_content_info_load(s, in); @@ -311,7 +293,7 @@ camel_folder_summary_load(CamelFolderSummary *s) return -1; } - if ( ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->summary_header_load(s, in) == -1) { + if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in) == -1) { fclose(in); return -1; } @@ -319,7 +301,7 @@ camel_folder_summary_load(CamelFolderSummary *s) /* now read in each message ... */ /* FIXME: check returns */ for (i=0;i<s->saved_count;i++) { - mi = ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->message_info_load(s, in); + mi = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_load(s, in); if (s->build_content) { mi->content = perform_content_info_load(s, in); @@ -342,7 +324,7 @@ perform_content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentI { CamelMessageContentInfo *part; - ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->content_info_save(s, out, ci); + ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_save(s, out, ci); camel_folder_summary_encode_uint32(out, my_list_size((struct _node **)&ci->childs)); part = ci->childs; while (part) { @@ -377,7 +359,7 @@ camel_folder_summary_save(CamelFolderSummary *s) io(printf("saving header\n")); - if ( ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->summary_header_save(s, out) == -1) { + if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_save(s, out) == -1) { fclose(out); return -1; } @@ -387,7 +369,7 @@ camel_folder_summary_save(CamelFolderSummary *s) count = camel_folder_summary_count(s); for (i=0;i<count;i++) { mi = camel_folder_summary_index(s, i); - ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->message_info_save(s, out, mi); + ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_save(s, out, mi); if (s->build_content) { perform_content_info_save(s, out, mi->content); @@ -425,7 +407,7 @@ CamelMessageInfo *camel_folder_summary_add_from_header(CamelFolderSummary *s, st { CamelMessageInfo *info = NULL; - info = ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->message_info_new(s, h); + info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s))) -> message_info_new(s, h); camel_folder_summary_add(s, info); return info; @@ -441,7 +423,7 @@ CamelMessageInfo *camel_folder_summary_add_from_parser(CamelFolderSummary *s, Ca /* should this check the parser is in the right state, or assume it is?? */ if (camel_mime_parser_step(mp, &buffer, &len) != HSCAN_EOF) { - info = ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->message_info_new_from_parser(s, mp); + info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_new_from_parser(s, mp); camel_mime_parser_unstep(mp); @@ -472,7 +454,7 @@ perform_content_info_free(CamelFolderSummary *s, CamelMessageContentInfo *ci) CamelMessageContentInfo *pw, *pn; pw = ci->childs; - ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->content_info_free(s, ci); + ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_free(s, ci); while (pw) { pn = pw->next; perform_content_info_free(s, pw); @@ -498,7 +480,7 @@ camel_folder_summary_clear(CamelFolderSummary *s) CamelMessageInfo *mi = camel_folder_summary_index(s, i); CamelMessageContentInfo *ci = mi->content; - ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->message_info_free(s, mi); + ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_free(s, mi); if (s->build_content && ci) { perform_content_info_free(s, ci); } @@ -516,7 +498,7 @@ void camel_folder_summary_remove(CamelFolderSummary *s, CamelMessageInfo *info) g_hash_table_remove(s->messages_uid, info->uid); g_ptr_array_remove(s->messages, info); - ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->message_info_free(s, info); + ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_free(s, info); if (s->build_content && ci) { perform_content_info_free(s, ci); } @@ -875,7 +857,7 @@ static CamelMessageInfo * message_info_new_from_parser(CamelFolderSummary *s, Ca case HSCAN_HEADER: case HSCAN_MESSAGE: case HSCAN_MULTIPART: - mi = ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->message_info_new(s, camel_mime_parser_headers_raw(mp)); + mi = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_new(s, camel_mime_parser_headers_raw(mp)); break; default: g_error("Invalid parser state"); @@ -892,7 +874,7 @@ static CamelMessageContentInfo * content_info_new_from_parser(CamelFolderSummary case HSCAN_HEADER: case HSCAN_MESSAGE: case HSCAN_MULTIPART: - ci = ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->content_info_new(s, camel_mime_parser_headers_raw(mp)); + ci = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_new(s, camel_mime_parser_headers_raw(mp)); if (ci) { ci->type = camel_mime_parser_content_type(mp); header_content_type_ref(ci->type); @@ -1212,7 +1194,7 @@ summary_build_content_info(CamelFolderSummary *s, CamelMimeParser *mp) state = camel_mime_parser_step(mp, &buffer, &len); body = camel_mime_parser_tell(mp); - info = ((CamelFolderSummaryClass *)((GtkObject *)s)->klass)->content_info_new_from_parser(s, mp); + info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_new_from_parser(s, mp); info->pos = camel_mime_parser_tell_start_headers(mp); info->bodypos = body; @@ -1571,7 +1553,7 @@ int main(int argc, char **argv) int i; ibex *index; - gtk_init(&argc, &argv); + /*g_tk_init(&argc, &argv);*/ #if 0 { @@ -1640,12 +1622,12 @@ int main(int argc, char **argv) for (i=0;i<camel_folder_summary_count(n);i++) { message_info_dump(camel_folder_summary_index(n, i)); } - gtk_object_unref(n); + camel_object_unref(n); } - gtk_object_unref(mp); - gtk_object_unref(s); + camel_object_unref(mp); + camel_object_unref(s); printf("summarised %d messages\n", camel_folder_summary_count(s)); #if 0 diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h index 93438fcd7a..22a108192a 100644 --- a/camel/camel-folder-summary.h +++ b/camel/camel-folder-summary.h @@ -28,9 +28,9 @@ #include <camel/camel-mime-parser.h> #include <libibex/ibex.h> -#define CAMEL_FOLDER_SUMMARY(obj) GTK_CHECK_CAST (obj, camel_folder_summary_get_type (), CamelFolderSummary) -#define CAMEL_FOLDER_SUMMARY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_folder_summary_get_type (), CamelFolderSummaryClass) -#define IS_CAMEL_FOLDER_SUMMARY(obj) GTK_CHECK_TYPE (obj, camel_folder_summary_get_type ()) +#define CAMEL_FOLDER_SUMMARY(obj) CAMEL_CHECK_CAST (obj, camel_folder_summary_get_type (), CamelFolderSummary) +#define CAMEL_FOLDER_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_folder_summary_get_type (), CamelFolderSummaryClass) +#define IS_CAMEL_FOLDER_SUMMARY(obj) CAMEL_CHECK_TYPE (obj, camel_folder_summary_get_type ()) /*typedef struct _CamelFolderSummary CamelFolderSummary;*/ typedef struct _CamelFolderSummaryClass CamelFolderSummaryClass; diff --git a/camel/camel-folder.c b/camel/camel-folder.c index dd469e78aa..8e498ad57b 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -34,76 +34,105 @@ static CamelObjectClass *parent_class = NULL; /* Returns the class for a CamelFolder */ -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT (so)->klass) +#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) -enum SIGNALS { - FOLDER_CHANGED, - MESSAGE_CHANGED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; +static void init (CamelFolder *folder, CamelStore *parent_store, + CamelFolder *parent_folder, const gchar *name, + gchar *separator, gboolean path_begins_with_sep, + CamelException *ex); -static void init(CamelFolder * folder, CamelStore * parent_store, - CamelFolder * parent_folder, const gchar * name, - gchar * separator, gboolean path_begins_with_sep, CamelException * ex); +static void camel_folder_finalize (CamelObject *object); -static void finalize(GtkObject * object); -static void folder_sync(CamelFolder * folder, gboolean expunge, CamelException * ex); +static void folder_sync (CamelFolder *folder, gboolean expunge, + CamelException *ex); -static const gchar *get_name(CamelFolder * folder); -static const gchar *get_full_name(CamelFolder * folder); +static const gchar *get_name (CamelFolder *folder); +static const gchar *get_full_name (CamelFolder *folder); -static gboolean can_hold_folders(CamelFolder * folder); -static gboolean can_hold_messages(CamelFolder * folder); -static guint32 get_permanent_flags(CamelFolder * folder); -static guint32 get_message_flags(CamelFolder * folder, const char *uid); -static void set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set); -static gboolean get_message_user_flag(CamelFolder * folder, const char *uid, const char *name); -static void set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value); -static GPtrArray *get_subfolder_names(CamelFolder * folder); -static void free_subfolder_names(CamelFolder * folder, GPtrArray * array); -static CamelFolder *get_subfolder(CamelFolder * folder, +static gboolean can_hold_folders (CamelFolder *folder); +static gboolean can_hold_messages (CamelFolder *folder); +static guint32 get_permanent_flags (CamelFolder *folder); +static guint32 get_message_flags (CamelFolder *folder, const char *uid); +static void set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set); +static gboolean get_message_user_flag (CamelFolder *folder, const char *uid, + const char *name); +static void set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value); - const gchar * folder_name, gboolean create, CamelException * ex); -static CamelFolder *get_parent_folder(CamelFolder * folder); -static CamelStore *get_parent_store(CamelFolder * folder); -static gint get_message_count(CamelFolder * folder); -static gint get_unread_message_count(CamelFolder * folder); +static GPtrArray *get_subfolder_names (CamelFolder *folder); +static void free_subfolder_names (CamelFolder *folder, + GPtrArray *array); +static CamelFolder *get_subfolder (CamelFolder *folder, + const gchar *folder_name, + gboolean create, + CamelException *ex); +static CamelFolder *get_parent_folder (CamelFolder *folder); +static CamelStore *get_parent_store (CamelFolder *folder); -static void expunge(CamelFolder * folder, CamelException * ex); +static gint get_message_count (CamelFolder *folder); +static gint get_unread_message_count (CamelFolder *folder); -static void append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex); +static void expunge (CamelFolder *folder, + CamelException *ex); -static GPtrArray *get_uids(CamelFolder * folder); -static void free_uids(CamelFolder * folder, GPtrArray * array); -static GPtrArray *get_summary(CamelFolder * folder); -static void free_summary(CamelFolder * folder, GPtrArray * array); -static CamelMimeMessage *get_message(CamelFolder * folder, const gchar * uid, CamelException * ex); -static const CamelMessageInfo *get_message_info(CamelFolder * folder, const char *uid); +static void append_message (CamelFolder *folder, CamelMimeMessage *message, + const CamelMessageInfo *info, CamelException *ex); -static GPtrArray *search_by_expression(CamelFolder * folder, const char *exp, CamelException * ex); -static void search_free(CamelFolder * folder, GPtrArray * result); -static void copy_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex); +static GPtrArray *get_uids (CamelFolder *folder); +static void free_uids (CamelFolder *folder, + GPtrArray *array); +static GPtrArray *get_summary (CamelFolder *folder); +static void free_summary (CamelFolder *folder, + GPtrArray *array); -static void move_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex); +static const gchar *get_message_uid (CamelFolder *folder, + CamelMimeMessage *message); -static void freeze(CamelFolder * folder); -static void thaw(CamelFolder * folder); +static CamelMimeMessage *get_message (CamelFolder *folder, + const gchar *uid, + CamelException *ex); -static void folder_changed(CamelFolder * folder, int type); -static void message_changed(CamelFolder * folder, const char *uid); +static const CamelMessageInfo *get_message_info (CamelFolder *folder, + const char *uid); -static void camel_folder_class_init(CamelFolderClass * camel_folder_class) +static GPtrArray *search_by_expression (CamelFolder *folder, + const char *exp, + CamelException *ex); +static void search_free (CamelFolder * folder, + GPtrArray * result); + +static void copy_message_to (CamelFolder *source, + const char *uid, + CamelFolder *dest, + CamelException *ex); + +static void move_message_to (CamelFolder *source, + const char *uid, + CamelFolder *dest, + CamelException *ex); + +static void freeze (CamelFolder *folder); +static void thaw (CamelFolder *folder); + +static gboolean folder_changed (CamelObject *object, + /*int type*/gpointer event_data); +static gboolean message_changed (CamelObject *object, + /*const char *uid*/gpointer event_data); + +static void +camel_folder_class_init (CamelFolderClass *camel_folder_class) { - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS(camel_folder_class); + CamelObjectClass *camel_object_class = + CAMEL_OBJECT_CLASS (camel_folder_class); - parent_class = gtk_type_class(camel_object_get_type()); + parent_class = camel_type_get_global_classfuncs (camel_object_get_type ()); /* virtual method definition */ camel_folder_class->init = init; @@ -138,72 +167,71 @@ static void camel_folder_class_init(CamelFolderClass * camel_folder_class) camel_folder_class->move_message_to = move_message_to; camel_folder_class->freeze = freeze; camel_folder_class->thaw = thaw; - camel_folder_class->folder_changed = folder_changed; - camel_folder_class->message_changed = message_changed; /* virtual method overload */ - gtk_object_class->finalize = finalize; + camel_object_class_declare_event (camel_object_class, "folder_changed", folder_changed); + camel_object_class_declare_event (camel_object_class, "message_changed", message_changed); + + /* + signals[FOLDER_CHANGED] = + gt_k_signal_new ("folder_changed", + GT_K_RUN_FIRST, + camel_object_class->type, + GT_K_SIGNAL_OFFSET (CamelFolderClass, + folder_changed), + gt_k_marshal_NONE__INT, + GT_K_TYPE_NONE, 1, GT_K_TYPE_INT); + + signals[MESSAGE_CHANGED] = + gt_k_signal_new ("message_changed", + GT_K_RUN_FIRST, + camel_object_class->type, + GT_K_SIGNAL_OFFSET (CamelFolderClass, + message_changed), + gt_k_marshal_NONE__STRING, + GT_K_TYPE_NONE, 1, GT_K_TYPE_STRING); + + camel_object_class_add_signals (camel_object_class, signals, LAST_SIGNAL); + */ +} - signals[FOLDER_CHANGED] = - gtk_signal_new("folder_changed", - GTK_RUN_FIRST, - gtk_object_class->type, - GTK_SIGNAL_OFFSET(CamelFolderClass, - folder_changed), gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); +static void +camel_folder_finalize (CamelObject *object) +{ + CamelFolder *camel_folder = CAMEL_FOLDER (object); + GList *m; - signals[MESSAGE_CHANGED] = - gtk_signal_new("message_changed", - GTK_RUN_FIRST, - gtk_object_class->type, - GTK_SIGNAL_OFFSET(CamelFolderClass, - message_changed), - gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + g_free (camel_folder->name); + g_free (camel_folder->full_name); - gtk_object_class_add_signals(gtk_object_class, signals, LAST_SIGNAL); + if (camel_folder->parent_store) + camel_object_unref (CAMEL_OBJECT (camel_folder->parent_store)); + if (camel_folder->parent_folder) + camel_object_unref (CAMEL_OBJECT (camel_folder->parent_folder)); + for (m = camel_folder->messages_changed; m; m = m->next) + g_free (m->data); + g_list_free (camel_folder->messages_changed); } -GtkType camel_folder_get_type(void) +CamelType +camel_folder_get_type (void) { - static GtkType camel_folder_type = 0; - - if (!camel_folder_type) { - GtkTypeInfo camel_folder_info = { - "CamelFolder", - sizeof(CamelFolder), - sizeof(CamelFolderClass), - (GtkClassInitFunc) camel_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; + static CamelType camel_folder_type = CAMEL_INVALID_TYPE; - camel_folder_type = gtk_type_unique(camel_object_get_type(), &camel_folder_info); + if (camel_folder_type == CAMEL_INVALID_TYPE) { + camel_folder_type = camel_type_register (CAMEL_OBJECT_TYPE, "CamelFolder", + sizeof (CamelFolder), + sizeof (CamelFolderClass), + (CamelObjectClassInitFunc) camel_folder_class_init, + NULL, + NULL, + (CamelObjectFinalizeFunc) camel_folder_finalize ); } return camel_folder_type; } -static void finalize(GtkObject * object) -{ - CamelFolder *camel_folder = CAMEL_FOLDER(object); - GList *m; - - g_free(camel_folder->name); - g_free(camel_folder->full_name); - - if (camel_folder->parent_store) - gtk_object_unref(GTK_OBJECT(camel_folder->parent_store)); - if (camel_folder->parent_folder) - gtk_object_unref(GTK_OBJECT(camel_folder->parent_folder)); - - for (m = camel_folder->messages_changed; m; m = m->next) - g_free(m->data); - g_list_free(camel_folder->messages_changed); - - GTK_OBJECT_CLASS(parent_class)->finalize(object); -} /** * init: init the folder @@ -218,31 +246,32 @@ static void finalize(GtkObject * object) * and name. **/ static void -init(CamelFolder * folder, CamelStore * parent_store, - CamelFolder * parent_folder, const gchar * name, - gchar * separator, gboolean path_begins_with_sep, CamelException * ex) +init (CamelFolder *folder, CamelStore *parent_store, + CamelFolder *parent_folder, const gchar *name, + gchar *separator, gboolean path_begins_with_sep, + CamelException *ex) { gchar *full_name; const gchar *parent_full_name; - g_return_if_fail(CAMEL_IS_FOLDER(folder)); - g_return_if_fail(CAMEL_IS_STORE(parent_store)); - g_return_if_fail(parent_folder == NULL || CAMEL_IS_FOLDER(parent_folder)); - g_return_if_fail(folder->parent_store == NULL); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + g_return_if_fail (CAMEL_IS_STORE (parent_store)); + g_return_if_fail (parent_folder == NULL || CAMEL_IS_FOLDER (parent_folder)); + g_return_if_fail (folder->parent_store == NULL); folder->parent_store = parent_store; - gtk_object_ref(GTK_OBJECT(parent_store)); + camel_object_ref (CAMEL_OBJECT (parent_store)); folder->parent_folder = parent_folder; if (parent_folder) - gtk_object_ref(GTK_OBJECT(parent_folder)); + camel_object_ref (CAMEL_OBJECT (parent_folder)); folder->separator = separator; folder->path_begins_with_sep = path_begins_with_sep; /* if the folder already has a name, free it */ - g_free(folder->name); - g_free(folder->full_name); + g_free (folder->name); + g_free (folder->full_name); /* set those fields to NULL now, so that if an exception occurs, they will be set anyway */ @@ -268,9 +297,12 @@ init(CamelFolder * folder, CamelStore * parent_store, folder->messages_changed = NULL; } -static void folder_sync(CamelFolder * folder, gboolean expunge, CamelException * ex) + +static void +folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) { - g_warning("CamelFolder::sync not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::sync not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); } /** @@ -409,16 +441,20 @@ static CamelStore *get_parent_store(CamelFolder * folder) * * Return value: the parent store of the folder. **/ -CamelStore *camel_folder_get_parent_store(CamelFolder * folder) +CamelStore * +camel_folder_get_parent_store (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS(folder)->get_parent_store(folder); + return CF_CLASS (folder)->get_parent_store (folder); } -static GPtrArray *get_subfolder_names(CamelFolder * folder) + +static GPtrArray * +get_subfolder_names (CamelFolder *folder) { - g_warning("CamelFolder::get_subfolder_names not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_subfolder_names not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return NULL; } @@ -430,17 +466,20 @@ static GPtrArray *get_subfolder_names(CamelFolder * folder) * subfolders. The array should not be modified and must be freed with * camel_folder_free_subfolder_names(). **/ -GPtrArray *camel_folder_get_subfolder_names(CamelFolder * folder) +GPtrArray * +camel_folder_get_subfolder_names (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS(folder)->get_subfolder_names(folder); + return CF_CLASS (folder)->get_subfolder_names (folder); } -static void free_subfolder_names(CamelFolder * folder, GPtrArray * array) + +static void +free_subfolder_names (CamelFolder *folder, GPtrArray *array) { - g_warning("CamelFolder::free_subfolder_names not implemented " - "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::free_subfolder_names not implemented " + "for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); } /** @@ -450,18 +489,23 @@ static void free_subfolder_names(CamelFolder * folder, GPtrArray * array) * * Frees the array of names returned by camel_folder_get_subfolder_names(). **/ -void camel_folder_free_subfolder_names(CamelFolder * folder, GPtrArray * array) +void +camel_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *array) { - g_return_if_fail(CAMEL_IS_FOLDER(folder)); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); - CF_CLASS(folder)->free_subfolder_names(folder, array); + CF_CLASS (folder)->free_subfolder_names (folder, array); } -static void expunge(CamelFolder * folder, CamelException * ex) + +static void +expunge (CamelFolder *folder, CamelException *ex) { - g_warning("CamelFolder::expunge not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::expunge not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); } + /** * camel_folder_expunge: * @folder: the folder @@ -469,16 +513,20 @@ static void expunge(CamelFolder * folder, CamelException * ex) * * Delete messages which have been marked as "DELETED" **/ -void camel_folder_expunge(CamelFolder * folder, CamelException * ex) +void +camel_folder_expunge (CamelFolder *folder, CamelException *ex) { - g_return_if_fail(CAMEL_IS_FOLDER(folder)); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); - CF_CLASS(folder)->expunge(folder, ex); + CF_CLASS (folder)->expunge (folder, ex); } -static gint get_message_count(CamelFolder * folder) + +static gint +get_message_count (CamelFolder *folder) { - g_warning("CamelFolder::get_message_count not implemented " "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_message_count not implemented " + "for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return -1; } @@ -488,17 +536,19 @@ static gint get_message_count(CamelFolder * folder) * * Return value: the number of messages in the folder, or -1 if unknown. **/ -gint camel_folder_get_message_count(CamelFolder * folder) +gint +camel_folder_get_message_count (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), -1); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1); - return CF_CLASS(folder)->get_message_count(folder); + return CF_CLASS (folder)->get_message_count (folder); } -static gint get_unread_message_count(CamelFolder * folder) +static gint +get_unread_message_count (CamelFolder *folder) { - g_warning("CamelFolder::get_unread_message_count not implemented " - "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_unread_message_count not implemented " + "for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return -1; } @@ -508,16 +558,21 @@ static gint get_unread_message_count(CamelFolder * folder) * * Return value: the number of unread messages in the folder, or -1 if unknown. **/ -gint camel_folder_get_unread_message_count(CamelFolder * folder) +gint +camel_folder_get_unread_message_count (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), -1); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1); - return CF_CLASS(folder)->get_unread_message_count(folder); + return CF_CLASS (folder)->get_unread_message_count (folder); } -static void append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex) + +static void +append_message (CamelFolder *folder, CamelMimeMessage *message, + const CamelMessageInfo *info, CamelException *ex) { - g_warning("CamelFolder::append_message not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::append_message not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return; } @@ -551,16 +606,20 @@ static guint32 get_permanent_flags(CamelFolder * folder) * stored on a message between sessions. If it includes %CAMEL_FLAG_USER, * then user-defined flags will be remembered. **/ -guint32 camel_folder_get_permanent_flags(CamelFolder * folder) +guint32 +camel_folder_get_permanent_flags (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), 0); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); - return CF_CLASS(folder)->get_permanent_flags(folder); + return CF_CLASS (folder)->get_permanent_flags (folder); } -static guint32 get_message_flags(CamelFolder * folder, const char *uid) + +static guint32 +get_message_flags (CamelFolder *folder, const char *uid) { - g_warning("CamelFolder::get_message_flags not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_message_flags not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return 0; } @@ -572,16 +631,21 @@ static guint32 get_message_flags(CamelFolder * folder, const char *uid) * Return value: the CamelMessageFlags that are set on the indicated * message. **/ -guint32 camel_folder_get_message_flags(CamelFolder * folder, const char *uid) +guint32 +camel_folder_get_message_flags (CamelFolder *folder, const char *uid) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), 0); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); - return CF_CLASS(folder)->get_message_flags(folder, uid); + return CF_CLASS (folder)->get_message_flags (folder, uid); } -static void set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set) + +static void +set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set) { - g_warning("CamelFolder::set_message_flags not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::set_message_flags not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); } /** @@ -595,17 +659,22 @@ static void set_message_flags(CamelFolder * folder, const char *uid, guint32 fla * on the indicated message. (This may or may not persist after the * folder or store is closed. See camel_folder_get_permanent_flags().) **/ -void camel_folder_set_message_flags(CamelFolder * folder, const char *uid, guint32 flags, guint32 set) +void +camel_folder_set_message_flags (CamelFolder *folder, const char *uid, + guint32 flags, guint32 set) { - g_return_if_fail(CAMEL_IS_FOLDER(folder)); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); - CF_CLASS(folder)->set_message_flags(folder, uid, flags, set); + CF_CLASS (folder)->set_message_flags (folder, uid, flags, set); } -static gboolean get_message_user_flag(CamelFolder * folder, const char *uid, const char *name) + +static gboolean +get_message_user_flag (CamelFolder *folder, const char *uid, + const char *name) { - g_warning("CamelFolder::get_message_user_flag not implemented " - "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_message_user_flag not implemented " + "for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return FALSE; } @@ -617,17 +686,22 @@ static gboolean get_message_user_flag(CamelFolder * folder, const char *uid, con * * Return value: whether or not the given user flag is set on the message. **/ -gboolean camel_folder_get_message_user_flag(CamelFolder * folder, const char *uid, const char *name) +gboolean +camel_folder_get_message_user_flag (CamelFolder *folder, const char *uid, + const char *name) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), 0); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0); - return CF_CLASS(folder)->get_message_user_flag(folder, uid, name); + return CF_CLASS (folder)->get_message_user_flag (folder, uid, name); } -static void set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value) + +static void +set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value) { - g_warning("CamelFolder::set_message_user_flag not implemented " - "for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::set_message_user_flag not implemented " + "for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); } /** @@ -641,16 +715,21 @@ static void set_message_user_flag(CamelFolder * folder, const char *uid, const c * on the indicated message. (This may or may not persist after the * folder or store is closed. See camel_folder_get_permanent_flags().) **/ -void camel_folder_set_message_user_flag(CamelFolder * folder, const char *uid, const char *name, gboolean value) +void +camel_folder_set_message_user_flag (CamelFolder *folder, const char *uid, + const char *name, gboolean value) { - g_return_if_fail(CAMEL_IS_FOLDER(folder)); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); - CF_CLASS(folder)->set_message_user_flag(folder, uid, name, value); + CF_CLASS (folder)->set_message_user_flag (folder, uid, name, value); } -static const CamelMessageInfo *get_message_info(CamelFolder * folder, const char *uid) + +static const CamelMessageInfo * +get_message_info (CamelFolder *folder, const char *uid) { - g_warning("CamelFolder::get_message_info not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_message_info not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return NULL; } @@ -661,27 +740,33 @@ static const CamelMessageInfo *get_message_info(CamelFolder * folder, const char * * Return value: the summary information for the indicated message **/ -const CamelMessageInfo *camel_folder_get_message_info(CamelFolder * folder, const char *uid) +const CamelMessageInfo * +camel_folder_get_message_info (CamelFolder *folder, const char *uid) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL); - g_return_val_if_fail(uid != NULL, NULL); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); + g_return_val_if_fail (uid != NULL, NULL); - return CF_CLASS(folder)->get_message_info(folder, uid); + return CF_CLASS (folder)->get_message_info (folder, uid); } + /* TODO: is this function required anyway? */ -gboolean camel_folder_has_summary_capability(CamelFolder * folder) +gboolean +camel_folder_has_summary_capability (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), FALSE); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); return folder->has_summary_capability; } + /* UIDs stuff */ -static CamelMimeMessage *get_message(CamelFolder * folder, const gchar * uid, CamelException * ex) +static CamelMimeMessage * +get_message (CamelFolder *folder, const gchar *uid, CamelException *ex) { - g_warning("CamelFolder::get_message not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_message not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return NULL; } @@ -697,16 +782,21 @@ static CamelMimeMessage *get_message(CamelFolder * folder, const gchar * uid, Ca * * Return value: Message corresponding to the UID **/ -CamelMimeMessage *camel_folder_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex) +CamelMimeMessage * +camel_folder_get_message (CamelFolder *folder, const gchar *uid, + CamelException *ex) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS(folder)->get_message(folder, uid, ex); + return CF_CLASS (folder)->get_message (folder, uid, ex); } -static GPtrArray *get_uids(CamelFolder * folder) + +static GPtrArray * +get_uids (CamelFolder *folder) { - g_warning("CamelFolder::get_uids not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_uids not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return NULL; } @@ -722,16 +812,20 @@ static GPtrArray *get_uids(CamelFolder * folder) * Return value: GPtrArray of UIDs corresponding to the messages * available in the folder. **/ -GPtrArray *camel_folder_get_uids(CamelFolder * folder) +GPtrArray * +camel_folder_get_uids (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS(folder)->get_uids(folder); + return CF_CLASS (folder)->get_uids (folder); } -static void free_uids(CamelFolder * folder, GPtrArray * array) + +static void +free_uids (CamelFolder *folder, GPtrArray *array) { - g_warning("CamelFolder::free_uids not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::free_uids not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); } /** @@ -741,16 +835,20 @@ static void free_uids(CamelFolder * folder, GPtrArray * array) * * Frees the array of UIDs returned by camel_folder_get_uids(). **/ -void camel_folder_free_uids(CamelFolder * folder, GPtrArray * array) +void +camel_folder_free_uids (CamelFolder *folder, GPtrArray *array) { - g_return_if_fail(CAMEL_IS_FOLDER(folder)); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); - CF_CLASS(folder)->free_uids(folder, array); + CF_CLASS (folder)->free_uids (folder, array); } -static GPtrArray *get_summary(CamelFolder * folder) + +static GPtrArray * +get_summary (CamelFolder *folder) { - g_warning("CamelFolder::get_summary not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::get_summary not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return NULL; } @@ -764,16 +862,20 @@ static GPtrArray *get_summary(CamelFolder * folder) * * Return value: an array of CamelMessageInfo **/ -GPtrArray *camel_folder_get_summary(CamelFolder * folder) +GPtrArray * +camel_folder_get_summary (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - return CF_CLASS(folder)->get_summary(folder); + return CF_CLASS (folder)->get_summary (folder); } -static void free_summary(CamelFolder * folder, GPtrArray * array) + +static void +free_summary (CamelFolder *folder, GPtrArray *array) { - g_warning("CamelFolder::free_summary not implemented for `%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::free_summary not implemented for `%s'", + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); } /** @@ -798,17 +900,20 @@ void camel_folder_free_summary(CamelFolder * folder, GPtrArray * array) * * Return value: %TRUE if the folder supports searching **/ -gboolean camel_folder_has_search_capability(CamelFolder * folder) +gboolean +camel_folder_has_search_capability (CamelFolder *folder) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), FALSE); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); return folder->has_search_capability; } -static GPtrArray *search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex) +static GPtrArray * +search_by_expression (CamelFolder *folder, const char *expression, + CamelException *ex) { - g_warning("CamelFolder::search_by_expression not implemented for " - "`%s'", gtk_type_name(GTK_OBJECT_TYPE(folder))); + g_warning ("CamelFolder::search_by_expression not implemented for " + "`%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))); return NULL; } @@ -823,15 +928,18 @@ static GPtrArray *search_by_expression(CamelFolder * folder, const char *express * Return value: a list of uids of matching messages. The caller must * free the list and each of the elements when it is done. **/ -GPtrArray *camel_folder_search_by_expression(CamelFolder * folder, const char *expression, CamelException * ex) +GPtrArray * +camel_folder_search_by_expression (CamelFolder *folder, const char *expression, + CamelException *ex) { - g_return_val_if_fail(CAMEL_IS_FOLDER(folder), NULL); - g_return_val_if_fail(folder->has_search_capability, NULL); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); + g_return_val_if_fail (folder->has_search_capability, NULL); - return CF_CLASS(folder)->search_by_expression(folder, expression, ex); + return CF_CLASS (folder)->search_by_expression (folder, expression, ex); } -void search_free(CamelFolder * folder, GPtrArray * result) +static void +search_free(CamelFolder * folder, GPtrArray * result) { int i; @@ -847,7 +955,8 @@ void search_free(CamelFolder * folder, GPtrArray * result) * * Free the result of a search. **/ -void camel_folder_search_free(CamelFolder * folder, GPtrArray * result) +void +camel_folder_search_free(CamelFolder * folder, GPtrArray * result) { g_return_if_fail(CAMEL_IS_FOLDER(folder)); g_return_if_fail(folder->has_search_capability); @@ -855,20 +964,23 @@ void camel_folder_search_free(CamelFolder * folder, GPtrArray * result) return CF_CLASS(folder)->search_free(folder, result); } -static void copy_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex) + +static void +copy_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, + CamelException *ex) { CamelMimeMessage *msg; const CamelMessageInfo *info; /* Default implementation. */ - - msg = camel_folder_get_message(source, uid, ex); + + msg = camel_folder_get_message (source, uid, ex); if (!msg) return; - info = camel_folder_get_message_info(source, uid); - camel_folder_append_message(dest, msg, info, ex); - gtk_object_unref(GTK_OBJECT(msg)); - if (camel_exception_is_set(ex)) + info = camel_folder_get_message_info (source, uid); + camel_folder_append_message (dest, msg, info ? info->flags : 0, ex); + camel_object_unref (CAMEL_OBJECT (msg)); + if (camel_exception_is_set (ex)) return; } @@ -883,34 +995,40 @@ static void copy_message_to(CamelFolder * source, const char *uid, CamelFolder * * @dest folders have the same parent_store, this may be more efficient * than a camel_folder_append_message(). **/ -void camel_folder_copy_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex) +void +camel_folder_copy_message_to (CamelFolder *source, const char *uid, + CamelFolder *dest, CamelException *ex) { - g_return_if_fail(CAMEL_IS_FOLDER(source)); - g_return_if_fail(CAMEL_IS_FOLDER(dest)); - g_return_if_fail(uid != NULL); + g_return_if_fail (CAMEL_IS_FOLDER (source)); + g_return_if_fail (CAMEL_IS_FOLDER (dest)); + g_return_if_fail (uid != NULL); if (source->parent_store == dest->parent_store) { - return CF_CLASS(source)->copy_message_to(source, uid, dest, ex); + return CF_CLASS (source)->copy_message_to (source, uid, + dest, ex); } else - return copy_message_to(source, uid, dest, ex); + return copy_message_to (source, uid, dest, ex); } -static void move_message_to(CamelFolder * source, const char *uid, CamelFolder * dest, CamelException * ex) + +static void +move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, + CamelException *ex) { CamelMimeMessage *msg; const CamelMessageInfo *info; /* Default implementation. */ - - msg = camel_folder_get_message(source, uid, ex); + + msg = camel_folder_get_message (source, uid, ex); if (!msg) return; - info = camel_folder_get_message_info(source, uid); - camel_folder_append_message(dest, msg, info, ex); - gtk_object_unref(GTK_OBJECT(msg)); - if (camel_exception_is_set(ex)) + info = camel_folder_get_message_info (source, uid); + camel_folder_append_message (dest, msg, info ? info->flags : 0, ex); + camel_object_unref (CAMEL_OBJECT (msg)); + if (camel_exception_is_set (ex)) return; - camel_folder_delete_message(source, uid); + camel_folder_delete_message (source, uid); } /** @@ -978,23 +1096,23 @@ static void thaw(CamelFolder * folder) if (folder->folder_changed) { folder->folder_changed = FALSE; - gtk_signal_emit(GTK_OBJECT(folder), signals[FOLDER_CHANGED], 0); + camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", GINT_TO_POINTER(0)); } else if (folder->messages_changed) { /* FIXME: would be nice to not emit more than once for * a given message */ for (m = messages; m; m = m->next) { - gtk_signal_emit_by_name(GTK_OBJECT(folder), "message_changed", m->data); - g_free(m->data); + camel_object_trigger_event (CAMEL_OBJECT (folder), "message_changed", m->data); + g_free (m->data); } - g_list_free(messages); + g_list_free (messages); return; } if (messages) { for (m = messages; m; m = m->next) - g_free(m->data); - g_list_free(messages); + g_free (m->data); + g_list_free (messages); } } @@ -1005,38 +1123,54 @@ static void thaw(CamelFolder * folder) * Thaws the folder and emits any pending folder_changed or * message_changed signals. **/ -void camel_folder_thaw(CamelFolder * folder) +void +camel_folder_thaw (CamelFolder *folder) { - g_return_if_fail(CAMEL_IS_FOLDER(folder)); - g_return_if_fail(folder->frozen != 0); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + g_return_if_fail (folder->frozen != 0); - CF_CLASS(folder)->thaw(folder); + CF_CLASS (folder)->thaw (folder); } -/* Default signal implementations, which block emission when we're - * frozen. - */ -static void folder_changed(CamelFolder * folder, int type) + +/* Event hooks that block emission when frozen */ +static gboolean folder_changed (CamelObject *obj, /*int type*/gpointer event_data) { + CamelFolder *folder = CAMEL_FOLDER (obj); + if (folder->frozen) { - gtk_signal_emit_stop(GTK_OBJECT(folder), signals[FOLDER_CHANGED]); folder->folder_changed = TRUE; + return FALSE; } + + return TRUE; } -static void message_changed(CamelFolder * folder, const char *uid) +static gboolean message_changed (CamelObject *obj, /*const char *uid*/gpointer event_data) { + CamelFolder *folder = CAMEL_FOLDER (obj); + if (folder->frozen) { - gtk_signal_emit_stop(GTK_OBJECT(folder), signals[MESSAGE_CHANGED]); + /* + * if g_tk_signal_handler_pending (CAMEL_OBJECT (folder), + * signals[MESSAGE_CHANGED], + * FALSE)) { + */ /* Only record the UID if it will be useful later. */ - if (!folder->folder_changed && - gtk_signal_handler_pending(GTK_OBJECT(folder), signals[MESSAGE_CHANGED], FALSE)) { - folder->messages_changed = g_list_prepend(folder->messages_changed, g_strdup(uid)); + if (!folder->folder_changed) { + folder->messages_changed = + g_list_prepend (folder->messages_changed, + g_strdup ((gchar *)event_data)); } + + return FALSE; } + + return TRUE; } + /** * camel_folder_free_nop: * @folder: a folder diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 949dbae52a..b394013d5d 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -37,9 +37,9 @@ extern "C" { #include <camel/camel-folder-summary.h> #define CAMEL_FOLDER_TYPE (camel_folder_get_type ()) -#define CAMEL_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_FOLDER_TYPE, CamelFolder)) -#define CAMEL_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_TYPE, CamelFolderClass)) -#define CAMEL_IS_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_FOLDER_TYPE)) +#define CAMEL_FOLDER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_FOLDER_TYPE, CamelFolder)) +#define CAMEL_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_TYPE, CamelFolderClass)) +#define CAMEL_IS_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_FOLDER_TYPE)) struct _CamelFolder { @@ -68,10 +68,12 @@ typedef struct { CamelObjectClass parent_class; /* signals */ - void (*folder_changed) (CamelFolder *, int type); - void (*message_changed) (CamelFolder *, - const char *uid); - + /* Not anymore! bwahahahah! + * void (*folder_changed) (CamelFolder *, int type); + * void (*message_changed) (CamelFolder *, + * const char *uid); + */ + /* Virtual methods */ void (*init) (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_folder, const gchar *name, @@ -171,8 +173,8 @@ typedef struct { -/* Standard Gtk function */ -GtkType camel_folder_get_type (void); +/* Standard Camel function */ +CamelType camel_folder_get_type (void); /* public methods */ diff --git a/camel/camel-internet-address.c b/camel/camel-internet-address.c index 9abbc8c632..0e68f718c2 100644 --- a/camel/camel-internet-address.c +++ b/camel/camel-internet-address.c @@ -35,47 +35,16 @@ struct _address { char *address; }; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint -camel_internet_address_get_type (void) -{ - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelInternetAddress", - sizeof (CamelInternetAddress), - sizeof (CamelInternetAddressClass), - (GtkClassInitFunc) camel_internet_address_class_init, - (GtkObjectInitFunc) camel_internet_address_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_address_get_type (), &type_info); - } - - return type; -} - static void camel_internet_address_class_init (CamelInternetAddressClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelAddressClass *address = (CamelAddressClass *) klass; - camel_internet_address_parent = gtk_type_class (camel_address_get_type ()); + camel_internet_address_parent = CAMEL_ADDRESS_CLASS (camel_type_get_global_classfuncs (camel_address_get_type ())); address->decode = internet_decode; address->encode = internet_encode; address->remove = internet_remove; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -83,6 +52,24 @@ camel_internet_address_init (CamelInternetAddress *obj) { } +CamelType +camel_internet_address_get_type (void) +{ + static CamelType type = CAMEL_INVALID_TYPE; + + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_address_get_type (), "CamelInternetAddress", + sizeof (CamelInternetAddress), + sizeof (CamelInternetAddressClass), + (CamelObjectClassInitFunc) camel_internet_address_class_init, + NULL, + (CamelObjectInitFunc) camel_internet_address_init, + NULL); + } + + return type; +} + static int internet_decode (CamelAddress *a, const char *raw) { @@ -164,7 +151,7 @@ static void internet_remove (CamelAddress *a, int index) CamelInternetAddress * camel_internet_address_new (void) { - CamelInternetAddress *new = CAMEL_INTERNET_ADDRESS ( gtk_type_new (camel_internet_address_get_type ())); + CamelInternetAddress *new = CAMEL_INTERNET_ADDRESS ( camel_object_new (camel_internet_address_get_type ())); return new; } diff --git a/camel/camel-internet-address.h b/camel/camel-internet-address.h index 14fbd5436a..6b303eef8f 100644 --- a/camel/camel-internet-address.h +++ b/camel/camel-internet-address.h @@ -23,9 +23,9 @@ #include <camel/camel-address.h> -#define CAMEL_INTERNET_ADDRESS(obj) GTK_CHECK_CAST (obj, camel_internet_address_get_type (), CamelInternetAddress) -#define CAMEL_INTERNET_ADDRESS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_internet_address_get_type (), CamelInternetAddressClass) -#define IS_CAMEL_INTERNET_ADDRESS(obj) GTK_CHECK_TYPE (obj, camel_internet_address_get_type ()) +#define CAMEL_INTERNET_ADDRESS(obj) CAMEL_CHECK_CAST (obj, camel_internet_address_get_type (), CamelInternetAddress) +#define CAMEL_INTERNET_ADDRESS_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_internet_address_get_type (), CamelInternetAddressClass) +#define IS_CAMEL_INTERNET_ADDRESS(obj) CAMEL_CHECK_TYPE (obj, camel_internet_address_get_type ()) typedef struct _CamelInternetAddressClass CamelInternetAddressClass; diff --git a/camel/camel-medium.c b/camel/camel-medium.c index dcc5d31d67..4507c93595 100644 --- a/camel/camel-medium.c +++ b/camel/camel-medium.c @@ -35,7 +35,7 @@ static CamelDataWrapperClass *parent_class = NULL; /* Returns the class for a CamelMedium */ -#define CM_CLASS(so) CAMEL_MEDIUM_CLASS (GTK_OBJECT (so)->klass) +#define CM_CLASS(so) CAMEL_MEDIUM_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static void add_header (CamelMedium *medium, const gchar *header_name, const void *header_value); @@ -46,17 +46,16 @@ static const void *get_header (CamelMedium *medium, const gchar *header_name); static CamelDataWrapper *get_content_object (CamelMedium *medium); static void set_content_object (CamelMedium *medium, CamelDataWrapper *content); -static void finalize (GtkObject *object); static void camel_medium_class_init (CamelMediumClass *camel_medium_class) { - CamelDataWrapperClass *camel_data_wrapper_class = - CAMEL_DATA_WRAPPER_CLASS (camel_medium_class); - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_data_wrapper_class); + /* + * CamelDataWrapperClass *camel_data_wrapper_class = + * CAMEL_DATA_WRAPPER_CLASS (camel_medium_class); + */ - parent_class = gtk_type_class (camel_data_wrapper_get_type ()); + parent_class = CAMEL_DATA_WRAPPER_CLASS (camel_type_get_global_classfuncs (camel_data_wrapper_get_type ())); /* virtual method definition */ camel_medium_class->add_header = add_header; @@ -66,8 +65,6 @@ camel_medium_class_init (CamelMediumClass *camel_medium_class) camel_medium_class->set_content_object = set_content_object; camel_medium_class->get_content_object = get_content_object; - - gtk_object_class->finalize = finalize; } static void @@ -78,47 +75,39 @@ camel_medium_init (gpointer object, gpointer klass) camel_medium->content = NULL; } - -GtkType -camel_medium_get_type (void) -{ - static GtkType camel_medium_type = 0; - - if (!camel_medium_type) { - GtkTypeInfo camel_medium_info = - { - "CamelMedium", - sizeof (CamelMedium), - sizeof (CamelMediumClass), - (GtkClassInitFunc) camel_medium_class_init, - (GtkObjectInitFunc) camel_medium_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_medium_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_medium_info); - } - - return camel_medium_type; -} - static void -finalize (GtkObject *object) +camel_medium_finalize (CamelObject *object) { CamelMedium *medium = CAMEL_MEDIUM (object); if (medium->content) - gtk_object_unref (GTK_OBJECT (medium->content)); + camel_object_unref (CAMEL_OBJECT (medium->content)); +} + + +CamelType +camel_medium_get_type (void) +{ + static CamelType camel_medium_type = CAMEL_INVALID_TYPE; + + if (camel_medium_type == CAMEL_INVALID_TYPE) { + camel_medium_type = camel_type_register (CAMEL_DATA_WRAPPER_TYPE, "medium", + sizeof (CamelMedium), + sizeof (CamelMediumClass), + (CamelObjectClassInitFunc) camel_medium_class_init, + NULL, + (CamelObjectInitFunc) camel_medium_init, + (CamelObjectFinalizeFunc) camel_medium_finalize); + } - GTK_OBJECT_CLASS (parent_class)->finalize (object); + return camel_medium_type; } static void add_header (CamelMedium *medium, const gchar *header_name, const void *header_value) { - g_warning("No %s::add_header implemented, adding %s", gtk_type_name(((GtkObject *)medium)->klass->type), header_name); + g_warning("No %s::add_header implemented, adding %s", camel_type_to_name(CAMEL_OBJECT_GET_TYPE(medium)), header_name); } /** @@ -147,7 +136,7 @@ camel_medium_add_header (CamelMedium *medium, const gchar *header_name, static void set_header (CamelMedium *medium, const gchar *header_name, const void *header_value) { - g_warning("No %s::set_header implemented, setting %s", gtk_type_name(((GtkObject *)medium)->klass->type), header_name); + g_warning("No %s::set_header implemented, setting %s", camel_type_to_name(CAMEL_OBJECT_GET_TYPE(medium)), header_name); } /** @@ -172,7 +161,7 @@ camel_medium_set_header (CamelMedium *medium, const gchar *header_name, const vo static void remove_header (CamelMedium *medium, const gchar *header_name) { - g_warning("No %s::remove_header implemented, removing %s", gtk_type_name(((GtkObject *)medium)->klass->type), header_name); + g_warning("No %s::remove_header implemented, removing %s", camel_type_to_name(CAMEL_OBJECT_GET_TYPE(medium)), header_name); } /** @@ -196,7 +185,7 @@ camel_medium_remove_header (CamelMedium *medium, const gchar *header_name) static const void * get_header (CamelMedium *medium, const gchar *header_name) { - g_warning("No %s::get_header implemented, getting %s", gtk_type_name(((GtkObject *)medium)->klass->type), header_name); + g_warning("No %s::get_header implemented, getting %s", camel_type_to_name(CAMEL_OBJECT_GET_TYPE(medium)), header_name); return NULL; } @@ -252,8 +241,8 @@ static void set_content_object (CamelMedium *medium, CamelDataWrapper *content) { if (medium->content) - gtk_object_unref (GTK_OBJECT (medium->content)); - gtk_object_ref (GTK_OBJECT (content)); + camel_object_unref (CAMEL_OBJECT (medium->content)); + camel_object_ref (CAMEL_OBJECT (content)); medium->content = content; } diff --git a/camel/camel-medium.h b/camel/camel-medium.h index 2b6f77f825..9ce548ba1d 100644 --- a/camel/camel-medium.h +++ b/camel/camel-medium.h @@ -37,9 +37,9 @@ extern "C" { #include <camel/camel-data-wrapper.h> #define CAMEL_MEDIUM_TYPE (camel_medium_get_type ()) -#define CAMEL_MEDIUM(obj) (GTK_CHECK_CAST((obj), CAMEL_MEDIUM_TYPE, CamelMedium)) -#define CAMEL_MEDIUM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MEDIUM_TYPE, CamelMediumClass)) -#define CAMEL_IS_MEDIUM(o) (GTK_CHECK_TYPE((o), CAMEL_MEDIUM_TYPE)) +#define CAMEL_MEDIUM(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MEDIUM_TYPE, CamelMedium)) +#define CAMEL_MEDIUM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MEDIUM_TYPE, CamelMediumClass)) +#define CAMEL_IS_MEDIUM(o) (CAMEL_CHECK_TYPE((o), CAMEL_MEDIUM_TYPE)) struct _CamelMedium @@ -70,8 +70,8 @@ typedef struct { } CamelMediumClass; -/* Standard Gtk function */ -GtkType camel_medium_get_type (void); +/* Standard Camel function */ +CamelType camel_medium_get_type (void); /* Header get/set interface */ void camel_medium_add_header (CamelMedium *medium, const gchar *header_name, const void *header_value); diff --git a/camel/camel-mime-filter-basic.c b/camel/camel-mime-filter-basic.c index 082fa209ad..4b351e4ff4 100644 --- a/camel/camel-mime-filter-basic.c +++ b/camel/camel-mime-filter-basic.c @@ -22,45 +22,57 @@ #include "camel-mime-utils.h" +static void reset(CamelMimeFilter *mf); +static void complete(CamelMimeFilter *mf, char *in, size_t len, + size_t prespace, char **out, + size_t *outlen, size_t *outprespace); +static void filter(CamelMimeFilter *mf, char *in, size_t len, + size_t prespace, char **out, + size_t *outlen, size_t *outprespace); + static void camel_mime_filter_basic_class_init (CamelMimeFilterBasicClass *klass); static void camel_mime_filter_basic_init (CamelMimeFilterBasic *obj); static CamelMimeFilterClass *camel_mime_filter_basic_parent; -enum SIGNALS { - LAST_SIGNAL -}; +static void +camel_mime_filter_basic_class_init (CamelMimeFilterBasicClass *klass) +{ + CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass; + + camel_mime_filter_basic_parent = CAMEL_MIME_FILTER_CLASS(camel_type_get_global_classfuncs (camel_mime_filter_get_type ())); -static guint signals[LAST_SIGNAL] = { 0 }; + filter_class->reset = reset; + filter_class->filter = filter; + filter_class->complete = complete; +} -guint +static void +camel_mime_filter_basic_init (CamelMimeFilterBasic *obj) +{ + obj->state = 0; + obj->save = 0; +} + + +CamelType camel_mime_filter_basic_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeFilterBasic", - sizeof (CamelMimeFilterBasic), - sizeof (CamelMimeFilterBasicClass), - (GtkClassInitFunc) camel_mime_filter_basic_class_init, - (GtkObjectInitFunc) camel_mime_filter_basic_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_mime_filter_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterBasic", + sizeof (CamelMimeFilterBasic), + sizeof (CamelMimeFilterBasicClass), + (CamelObjectClassInitFunc) camel_mime_filter_basic_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_filter_basic_init, + NULL); } return type; } -static void -finalise(GtkObject *o) -{ - ((GtkObjectClass *)camel_mime_filter_basic_parent)->finalize (o); -} - /* should this 'flush' outstanding state/data bytes? */ static void reset(CamelMimeFilter *mf) @@ -164,30 +176,6 @@ donothing: *outprespace = prespace; } -static void -camel_mime_filter_basic_class_init (CamelMimeFilterBasicClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass; - - camel_mime_filter_basic_parent = gtk_type_class (camel_mime_filter_get_type ()); - - object_class->finalize = finalise; - - filter_class->reset = reset; - filter_class->filter = filter; - filter_class->complete = complete; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_mime_filter_basic_init (CamelMimeFilterBasic *obj) -{ - obj->state = 0; - obj->save = 0; -} - /** * camel_mime_filter_basic_new: * @@ -198,7 +186,7 @@ camel_mime_filter_basic_init (CamelMimeFilterBasic *obj) CamelMimeFilterBasic * camel_mime_filter_basic_new (void) { - CamelMimeFilterBasic *new = CAMEL_MIME_FILTER_BASIC ( gtk_type_new (camel_mime_filter_basic_get_type ())); + CamelMimeFilterBasic *new = CAMEL_MIME_FILTER_BASIC ( camel_object_new (camel_mime_filter_basic_get_type ())); return new; } diff --git a/camel/camel-mime-filter-basic.h b/camel/camel-mime-filter-basic.h index f700997fd2..42713e334d 100644 --- a/camel/camel-mime-filter-basic.h +++ b/camel/camel-mime-filter-basic.h @@ -23,9 +23,9 @@ #include <camel/camel-mime-filter.h> -#define CAMEL_MIME_FILTER_BASIC(obj) GTK_CHECK_CAST (obj, camel_mime_filter_basic_get_type (), CamelMimeFilterBasic) -#define CAMEL_MIME_FILTER_BASIC_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mime_filter_basic_get_type (), CamelMimeFilterBasicClass) -#define IS_CAMEL_MIME_FILTER_BASIC(obj) GTK_CHECK_TYPE (obj, camel_mime_filter_basic_get_type ()) +#define CAMEL_MIME_FILTER_BASIC(obj) CAMEL_CHECK_CAST (obj, camel_mime_filter_basic_get_type (), CamelMimeFilterBasic) +#define CAMEL_MIME_FILTER_BASIC_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_basic_get_type (), CamelMimeFilterBasicClass) +#define IS_CAMEL_MIME_FILTER_BASIC(obj) CAMEL_CHECK_TYPE (obj, camel_mime_filter_basic_get_type ()) typedef struct _CamelMimeFilterBasicClass CamelMimeFilterBasicClass; diff --git a/camel/camel-mime-filter-charset.c b/camel/camel-mime-filter-charset.c index eb9db60802..18c0c64c3a 100644 --- a/camel/camel-mime-filter-charset.c +++ b/camel/camel-mime-filter-charset.c @@ -29,39 +29,30 @@ static void camel_mime_filter_charset_class_init (CamelMimeFilterCharsetClass *klass); static void camel_mime_filter_charset_init (CamelMimeFilterCharset *obj); +static void camel_mime_filter_charset_finalize (CamelObject *o); static CamelMimeFilterClass *camel_mime_filter_charset_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint +CamelType camel_mime_filter_charset_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeFilterCharset", - sizeof (CamelMimeFilterCharset), - sizeof (CamelMimeFilterCharsetClass), - (GtkClassInitFunc) camel_mime_filter_charset_class_init, - (GtkObjectInitFunc) camel_mime_filter_charset_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_mime_filter_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterCharset", + sizeof (CamelMimeFilterCharset), + sizeof (CamelMimeFilterCharsetClass), + (CamelObjectClassInitFunc) camel_mime_filter_charset_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_filter_charset_init, + (CamelObjectFinalizeFunc) camel_mime_filter_charset_finalize); } return type; } static void -finalise(GtkObject *o) +camel_mime_filter_charset_finalize(CamelObject *o) { CamelMimeFilterCharset *f = (CamelMimeFilterCharset *)o; @@ -71,8 +62,6 @@ finalise(GtkObject *o) unicode_iconv_close(f->ic); f->ic = (unicode_iconv_t) -1; } - - ((GtkObjectClass *)camel_mime_filter_charset_parent)->finalize (o); } static void @@ -191,18 +180,13 @@ donothing: static void camel_mime_filter_charset_class_init (CamelMimeFilterCharsetClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass; - camel_mime_filter_charset_parent = gtk_type_class (camel_mime_filter_get_type ()); - - object_class->finalize = finalise; + camel_mime_filter_charset_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ())); filter_class->reset = reset; filter_class->filter = filter; filter_class->complete = complete; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -221,19 +205,19 @@ camel_mime_filter_charset_init (CamelMimeFilterCharset *obj) CamelMimeFilterCharset * camel_mime_filter_charset_new (void) { - CamelMimeFilterCharset *new = CAMEL_MIME_FILTER_CHARSET ( gtk_type_new (camel_mime_filter_charset_get_type ())); + CamelMimeFilterCharset *new = CAMEL_MIME_FILTER_CHARSET ( camel_object_new (camel_mime_filter_charset_get_type ())); return new; } CamelMimeFilterCharset * camel_mime_filter_charset_new_convert(const char *from_charset, const char *to_charset) { - CamelMimeFilterCharset *new = CAMEL_MIME_FILTER_CHARSET ( gtk_type_new (camel_mime_filter_charset_get_type ())); + CamelMimeFilterCharset *new = CAMEL_MIME_FILTER_CHARSET ( camel_object_new (camel_mime_filter_charset_get_type ())); new->ic = unicode_iconv_open(to_charset, from_charset); if (new->ic == (unicode_iconv_t) -1) { g_warning("Cannot create charset conversion from %s to %s: %s", from_charset, to_charset, strerror(errno)); - gtk_object_unref((GtkObject *)new); + camel_object_unref((CamelObject *)new); new = NULL; } else { new->from = g_strdup(from_charset); diff --git a/camel/camel-mime-filter-charset.h b/camel/camel-mime-filter-charset.h index 866a9fd6bf..c53254c8ab 100644 --- a/camel/camel-mime-filter-charset.h +++ b/camel/camel-mime-filter-charset.h @@ -24,9 +24,9 @@ #include <camel/camel-mime-filter.h> #include <unicode.h> -#define CAMEL_MIME_FILTER_CHARSET(obj) GTK_CHECK_CAST (obj, camel_mime_filter_charset_get_type (), CamelMimeFilterCharset) -#define CAMEL_MIME_FILTER_CHARSET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mime_filter_charset_get_type (), CamelMimeFilterCharsetClass) -#define IS_CAMEL_MIME_FILTER_CHARSET(obj) GTK_CHECK_TYPE (obj, camel_mime_filter_charset_get_type ()) +#define CAMEL_MIME_FILTER_CHARSET(obj) CAMEL_CHECK_CAST (obj, camel_mime_filter_charset_get_type (), CamelMimeFilterCharset) +#define CAMEL_MIME_FILTER_CHARSET_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_charset_get_type (), CamelMimeFilterCharsetClass) +#define IS_CAMEL_MIME_FILTER_CHARSET(obj) CAMEL_CHECK_TYPE (obj, camel_mime_filter_charset_get_type ()) typedef struct _CamelMimeFilterCharsetClass CamelMimeFilterCharsetClass; diff --git a/camel/camel-mime-filter-crlf.c b/camel/camel-mime-filter-crlf.c index 8e3ff2175c..71a3e8bace 100644 --- a/camel/camel-mime-filter-crlf.c +++ b/camel/camel-mime-filter-crlf.c @@ -41,25 +41,19 @@ camel_mime_filter_crlf_class_init (CamelMimeFilterCRLFClass *klass) mime_filter_class->reset = reset; } -GtkType +CamelType camel_mime_filter_crlf_get_type (void) { - static GtkType type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeFilterCRLF", - sizeof (CamelMimeFilterCRLF), - sizeof (CamelMimeFilterCRLFClass), - (GtkClassInitFunc) camel_mime_filter_crlf_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (camel_mime_filter_get_type (), - &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterCRLF", + sizeof (CamelMimeFilterCRLF), + sizeof (CamelMimeFilterCRLFClass), + (CamelObjectClassInitFunc) camel_mime_filter_crlf_class_init, + NULL, + NULL, + NULL); } return type; @@ -146,7 +140,7 @@ reset (CamelMimeFilter *f) CamelMimeFilter * camel_mime_filter_crlf_new (CamelMimeFilterCRLFDirection direction, CamelMimeFilterCRLFMode mode) { - CamelMimeFilterCRLF *crlf = gtk_type_new (CAMEL_MIME_FILTER_CRLF_TYPE); + CamelMimeFilterCRLF *crlf = CAMEL_MIME_FILTER_CRLF(camel_object_new (CAMEL_MIME_FILTER_CRLF_TYPE)); crlf->direction = direction; crlf->mode = mode; diff --git a/camel/camel-mime-filter-crlf.h b/camel/camel-mime-filter-crlf.h index 27f78030e3..6ba109d154 100644 --- a/camel/camel-mime-filter-crlf.h +++ b/camel/camel-mime-filter-crlf.h @@ -26,9 +26,9 @@ #include <camel/camel-mime-filter.h> #define CAMEL_MIME_FILTER_CRLF_TYPE (camel_mime_filter_crlf_get_type ()) -#define CAMEL_MIME_FILTER_CRLF(obj) GTK_CHECK_CAST (obj, CAMEL_MIME_FILTER_CRLF_TYPE, CamelMimeFilterCRLF) -#define CAMEL_MIME_FILTER_CRLF_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, CAMEL_MIME_FILTER_CRLF_TYPE, CamelMimeFilterCRLFClass) -#define CAMEL_IS_MIME_FILTER_CRLF(obj) GTK_CHECK_TYPE (obj, CAMEL_MIME_FILTER_CRLF_TYPE) +#define CAMEL_MIME_FILTER_CRLF(obj) CAMEL_CHECK_CAST (obj, CAMEL_MIME_FILTER_CRLF_TYPE, CamelMimeFilterCRLF) +#define CAMEL_MIME_FILTER_CRLF_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, CAMEL_MIME_FILTER_CRLF_TYPE, CamelMimeFilterCRLFClass) +#define CAMEL_IS_MIME_FILTER_CRLF(obj) CAMEL_CHECK_TYPE (obj, CAMEL_MIME_FILTER_CRLF_TYPE) typedef struct _CamelMimeFilterCRLFClass CamelMimeFilterCRLFClass; @@ -55,7 +55,7 @@ struct _CamelMimeFilterCRLFClass { CamelMimeFilterClass parent_class; }; -GtkType camel_mime_filter_crlf_get_type (void); +CamelType camel_mime_filter_crlf_get_type (void); CamelMimeFilter *camel_mime_filter_crlf_new (CamelMimeFilterCRLFDirection direction, CamelMimeFilterCRLFMode mode); diff --git a/camel/camel-mime-filter-from.c b/camel/camel-mime-filter-from.c index 719b9d708a..017a256471 100644 --- a/camel/camel-mime-filter-from.c +++ b/camel/camel-mime-filter-from.c @@ -32,33 +32,22 @@ struct _CamelMimeFilterFromPrivate { static void camel_mime_filter_from_class_init (CamelMimeFilterFromClass *klass); static void camel_mime_filter_from_init (CamelMimeFilterFrom *obj); -static void camel_mime_filter_from_finalise (GtkObject *obj); static CamelMimeFilterClass *camel_mime_filter_from_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint +CamelType camel_mime_filter_from_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeFilterFrom", - sizeof (CamelMimeFilterFrom), - sizeof (CamelMimeFilterFromClass), - (GtkClassInitFunc) camel_mime_filter_from_class_init, - (GtkObjectInitFunc) camel_mime_filter_from_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_mime_filter_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterFrom", + sizeof (CamelMimeFilterFrom), + sizeof (CamelMimeFilterFromClass), + (CamelObjectClassInitFunc) camel_mime_filter_from_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_filter_from_init, + NULL); } return type; @@ -166,17 +155,12 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s static void camel_mime_filter_from_class_init (CamelMimeFilterFromClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass; - camel_mime_filter_from_parent = gtk_type_class (camel_mime_filter_get_type ()); - - object_class->finalize = camel_mime_filter_from_finalise; + camel_mime_filter_from_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ())); filter_class->filter = filter; filter_class->complete = complete; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -188,12 +172,6 @@ camel_mime_filter_from_init (CamelMimeFilterFrom *obj) obj->midline = FALSE; } -static void -camel_mime_filter_from_finalise (GtkObject *obj) -{ - ((GtkObjectClass *)(camel_mime_filter_from_parent))->finalize((GtkObject *)obj); -} - /** * camel_mime_filter_from_new: * @@ -204,7 +182,7 @@ camel_mime_filter_from_finalise (GtkObject *obj) CamelMimeFilterFrom * camel_mime_filter_from_new (void) { - CamelMimeFilterFrom *new = CAMEL_MIME_FILTER_FROM ( gtk_type_new (camel_mime_filter_from_get_type ())); + CamelMimeFilterFrom *new = CAMEL_MIME_FILTER_FROM ( camel_object_new (camel_mime_filter_from_get_type ())); return new; } @@ -218,7 +196,7 @@ int main(int argc, char **argv) char *buffer; int len, prespace; - gtk_init(&argc, &argv); + g_tk_init(&argc, &argv); f = camel_mime_filter_from_new(); diff --git a/camel/camel-mime-filter-from.h b/camel/camel-mime-filter-from.h index 2a97bcc0f0..ac526b6e15 100644 --- a/camel/camel-mime-filter-from.h +++ b/camel/camel-mime-filter-from.h @@ -22,12 +22,11 @@ #ifndef _CAMEL_MIME_FILTER_FROM_H #define _CAMEL_MIME_FILTER_FROM_H -#include <gtk/gtk.h> #include <camel/camel-mime-filter.h> -#define CAMEL_MIME_FILTER_FROM(obj) GTK_CHECK_CAST (obj, camel_mime_filter_from_get_type (), CamelMimeFilterFrom) -#define CAMEL_MIME_FILTER_FROM_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mime_filter_from_get_type (), CamelMimeFilterFromClass) -#define IS_CAMEL_MIME_FILTER_FROM(obj) GTK_CHECK_TYPE (obj, camel_mime_filter_from_get_type ()) +#define CAMEL_MIME_FILTER_FROM(obj) CAMEL_CHECK_CAST (obj, camel_mime_filter_from_get_type (), CamelMimeFilterFrom) +#define CAMEL_MIME_FILTER_FROM_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_from_get_type (), CamelMimeFilterFromClass) +#define IS_CAMEL_MIME_FILTER_FROM(obj) CAMEL_CHECK_TYPE (obj, camel_mime_filter_from_get_type ()) typedef struct _CamelMimeFilterFrom CamelMimeFilterFrom; typedef struct _CamelMimeFilterFromClass CamelMimeFilterFromClass; diff --git a/camel/camel-mime-filter-index.c b/camel/camel-mime-filter-index.c index 53a9f72920..46e0f3f5e8 100644 --- a/camel/camel-mime-filter-index.c +++ b/camel/camel-mime-filter-index.c @@ -22,47 +22,35 @@ static void camel_mime_filter_index_class_init (CamelMimeFilterIndexClass *klass); -static void camel_mime_filter_index_init (CamelMimeFilterIndex *obj); +static void camel_mime_filter_index_finalize (CamelObject *o); static CamelMimeFilterClass *camel_mime_filter_index_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint +CamelType camel_mime_filter_index_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeFilterIndex", - sizeof (CamelMimeFilterIndex), - sizeof (CamelMimeFilterIndexClass), - (GtkClassInitFunc) camel_mime_filter_index_class_init, - (GtkObjectInitFunc) camel_mime_filter_index_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_mime_filter_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterIndex", + sizeof (CamelMimeFilterIndex), + sizeof (CamelMimeFilterIndexClass), + (CamelObjectClassInitFunc) camel_mime_filter_index_class_init, + NULL, + NULL, + (CamelObjectFinalizeFunc) camel_mime_filter_index_finalize); } return type; } static void -finalise(GtkObject *o) +camel_mime_filter_index_finalize(CamelObject *o) { CamelMimeFilterIndex *f = (CamelMimeFilterIndex *)o; g_free(f->name); f->index = NULL; /* ibex's need refcounting? */ - - ((GtkObjectClass *)camel_mime_filter_index_parent)->finalize (o); } static void @@ -112,23 +100,13 @@ donothing: static void camel_mime_filter_index_class_init (CamelMimeFilterIndexClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass; - camel_mime_filter_index_parent = gtk_type_class (camel_mime_filter_get_type ()); - - object_class->finalize = finalise; + camel_mime_filter_index_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ())); /*filter_class->reset = reset;*/ filter_class->filter = filter; filter_class->complete = complete; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_mime_filter_index_init (CamelMimeFilterIndex *obj) -{ } /** @@ -141,7 +119,7 @@ camel_mime_filter_index_init (CamelMimeFilterIndex *obj) CamelMimeFilterIndex * camel_mime_filter_index_new (void) { - CamelMimeFilterIndex *new = CAMEL_MIME_FILTER_INDEX ( gtk_type_new (camel_mime_filter_index_get_type ())); + CamelMimeFilterIndex *new = CAMEL_MIME_FILTER_INDEX ( camel_object_new (camel_mime_filter_index_get_type ())); return new; } diff --git a/camel/camel-mime-filter-index.h b/camel/camel-mime-filter-index.h index 7dcc76b8ea..b0a9107852 100644 --- a/camel/camel-mime-filter-index.h +++ b/camel/camel-mime-filter-index.h @@ -24,9 +24,9 @@ #include <camel/camel-mime-filter.h> #include <libibex/ibex.h> -#define CAMEL_MIME_FILTER_INDEX(obj) GTK_CHECK_CAST (obj, camel_mime_filter_index_get_type (), CamelMimeFilterIndex) -#define CAMEL_MIME_FILTER_INDEX_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mime_filter_index_get_type (), CamelMimeFilterIndexClass) -#define IS_CAMEL_MIME_FILTER_INDEX(obj) GTK_CHECK_TYPE (obj, camel_mime_filter_index_get_type ()) +#define CAMEL_MIME_FILTER_INDEX(obj) CAMEL_CHECK_CAST (obj, camel_mime_filter_index_get_type (), CamelMimeFilterIndex) +#define CAMEL_MIME_FILTER_INDEX_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_index_get_type (), CamelMimeFilterIndexClass) +#define IS_CAMEL_MIME_FILTER_INDEX(obj) CAMEL_CHECK_TYPE (obj, camel_mime_filter_index_get_type ()) typedef struct _CamelMimeFilterIndexClass CamelMimeFilterIndexClass; diff --git a/camel/camel-mime-filter-save.c b/camel/camel-mime-filter-save.c index b5b54a2ee6..e1761994ed 100644 --- a/camel/camel-mime-filter-save.c +++ b/camel/camel-mime-filter-save.c @@ -30,39 +30,30 @@ static void camel_mime_filter_save_class_init (CamelMimeFilterSaveClass *klass); static void camel_mime_filter_save_init (CamelMimeFilterSave *obj); +static void camel_mime_filter_save_finalize (CamelObject *o); static CamelMimeFilterClass *camel_mime_filter_save_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -guint +CamelType camel_mime_filter_save_get_type (void) { - static guint type = 0; + static CamelType type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeFilterSave", - sizeof (CamelMimeFilterSave), - sizeof (CamelMimeFilterSaveClass), - (GtkClassInitFunc) camel_mime_filter_save_class_init, - (GtkObjectInitFunc) camel_mime_filter_save_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_mime_filter_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterSave", + sizeof (CamelMimeFilterSave), + sizeof (CamelMimeFilterSaveClass), + (CamelObjectClassInitFunc) camel_mime_filter_save_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_filter_save_init, + (CamelObjectFinalizeFunc) camel_mime_filter_save_finalize); } return type; } static void -finalise(GtkObject *o) +camel_mime_filter_save_finalize(CamelObject *o) { CamelMimeFilterSave *f = (CamelMimeFilterSave *)o; @@ -71,8 +62,6 @@ finalise(GtkObject *o) /* FIXME: what do we do with failed writes???? */ close(f->fd); } - - ((GtkObjectClass *)camel_mime_filter_save_parent)->finalize (o); } static void @@ -107,17 +96,12 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s static void camel_mime_filter_save_class_init (CamelMimeFilterSaveClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass; - camel_mime_filter_save_parent = gtk_type_class (camel_mime_filter_get_type ()); - - object_class->finalize = finalise; + camel_mime_filter_save_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ())); filter_class->reset = reset; filter_class->filter = filter; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -136,7 +120,7 @@ camel_mime_filter_save_init (CamelMimeFilterSave *f) CamelMimeFilterSave * camel_mime_filter_save_new (void) { - CamelMimeFilterSave *new = CAMEL_MIME_FILTER_SAVE ( gtk_type_new (camel_mime_filter_save_get_type ())); + CamelMimeFilterSave *new = CAMEL_MIME_FILTER_SAVE ( camel_object_new (camel_mime_filter_save_get_type ())); return new; } @@ -151,7 +135,7 @@ camel_mime_filter_save_new_name (const char *name, int flags, int mode) if (new->fd != -1) { new->filename = g_strdup(name); } else { - gtk_object_unref((GtkObject *)new); + camel_object_unref((CamelObject *)new); new = NULL; } } diff --git a/camel/camel-mime-filter-save.h b/camel/camel-mime-filter-save.h index eb6e448560..abc1bf1186 100644 --- a/camel/camel-mime-filter-save.h +++ b/camel/camel-mime-filter-save.h @@ -23,9 +23,9 @@ #include <camel/camel-mime-filter.h> -#define CAMEL_MIME_FILTER_SAVE(obj) GTK_CHECK_CAST (obj, camel_mime_filter_save_get_type (), CamelMimeFilterSave) -#define CAMEL_MIME_FILTER_SAVE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mime_filter_save_get_type (), CamelMimeFilterSaveClass) -#define IS_CAMEL_MIME_FILTER_SAVE(obj) GTK_CHECK_TYPE (obj, camel_mime_filter_save_get_type ()) +#define CAMEL_MIME_FILTER_SAVE(obj) CAMEL_CHECK_CAST (obj, camel_mime_filter_save_get_type (), CamelMimeFilterSave) +#define CAMEL_MIME_FILTER_SAVE_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_save_get_type (), CamelMimeFilterSaveClass) +#define IS_CAMEL_MIME_FILTER_SAVE(obj) CAMEL_CHECK_TYPE (obj, camel_mime_filter_save_get_type ()) typedef struct _CamelMimeFilterSaveClass CamelMimeFilterSaveClass; diff --git a/camel/camel-mime-filter.c b/camel/camel-mime-filter.c index 27cee890fe..19c4e095fe 100644 --- a/camel/camel-mime-filter.c +++ b/camel/camel-mime-filter.c @@ -28,43 +28,38 @@ struct _CamelMimeFilterPrivate { #define PRE_HEAD (64) #define BACK_HEAD (64) #define _PRIVATE(o) (((CamelMimeFilter *)(o))->priv) -#define FCLASS(o) ((CamelMimeFilterClass *)((GtkObject *)(o))->klass) - -static void camel_mime_filter_class_init (CamelMimeFilterClass *klass); -static void camel_mime_filter_init (CamelMimeFilter *obj); +#define FCLASS(o) ((CamelMimeFilterClass *)(CAMEL_OBJECT_GET_CLASS(o))) static CamelObjectClass *camel_mime_filter_parent; -enum SIGNALS { - LAST_SIGNAL -}; +static void complete (CamelMimeFilter *mf, char *in, size_t len, + size_t prespace, char **out, size_t *outlen, + size_t *outprespace); -static guint signals[LAST_SIGNAL] = { 0 }; +static void +camel_mime_filter_class_init (CamelMimeFilterClass *klass) +{ + camel_mime_filter_parent = camel_type_get_global_classfuncs (camel_object_get_type ()); -guint -camel_mime_filter_get_type (void) + klass->complete = complete; +} + +static void +camel_mime_filter_init (CamelMimeFilter *obj) { - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeFilter", - sizeof (CamelMimeFilter), - sizeof (CamelMimeFilterClass), - (GtkClassInitFunc) camel_mime_filter_class_init, - (GtkObjectInitFunc) camel_mime_filter_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_object_get_type (), &type_info); - } - - return type; + obj->outreal = NULL; + obj->outbuf = NULL; + obj->outsize = 0; + + obj->backbuf = NULL; + obj->backsize = 0; + obj->backlen = 0; + + _PRIVATE(obj) = g_malloc0(sizeof(*obj->priv)); } static void -finalise(GtkObject *o) +camel_mime_filter_finalize(CamelObject *o) { CamelMimeFilter *f = (CamelMimeFilter *)o; struct _CamelMimeFilterPrivate *p = _PRIVATE(f); @@ -73,42 +68,30 @@ finalise(GtkObject *o) g_free(f->backbuf); g_free(p->inbuf); g_free(p); - - ((GtkObjectClass *)camel_mime_filter_parent)->finalize (o); } -static void -complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace) -{ - /* default - do nothing */ -} - -static void -camel_mime_filter_class_init (CamelMimeFilterClass *klass) +CamelType +camel_mime_filter_get_type (void) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; + static CamelType camel_mime_filter_type = CAMEL_INVALID_TYPE; - camel_mime_filter_parent = gtk_type_class (camel_object_get_type ()); - - object_class->finalize = finalise; - - klass->complete = complete; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); + if (camel_mime_filter_type == CAMEL_INVALID_TYPE) { + camel_mime_filter_type = camel_type_register (CAMEL_OBJECT_TYPE, "CamelMimeFilter", + sizeof (CamelMimeFilter), + sizeof (CamelMimeFilterClass), + (CamelObjectClassInitFunc) camel_mime_filter_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_filter_init, + (CamelObjectFinalizeFunc) camel_mime_filter_finalize); + } + + return camel_mime_filter_type; } static void -camel_mime_filter_init (CamelMimeFilter *obj) +complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace) { - obj->outreal = NULL; - obj->outbuf = NULL; - obj->outsize = 0; - - obj->backbuf = NULL; - obj->backsize = 0; - obj->backlen = 0; - - _PRIVATE(obj) = g_malloc0(sizeof(*obj->priv)); + /* default - do nothing */ } /** @@ -121,7 +104,7 @@ camel_mime_filter_init (CamelMimeFilter *obj) CamelMimeFilter * camel_mime_filter_new (void) { - CamelMimeFilter *new = CAMEL_MIME_FILTER ( gtk_type_new (camel_mime_filter_get_type ())); + CamelMimeFilter *new = CAMEL_MIME_FILTER ( camel_object_new (camel_mime_filter_get_type ())); return new; } diff --git a/camel/camel-mime-filter.h b/camel/camel-mime-filter.h index 4576596bab..6e729b13c2 100644 --- a/camel/camel-mime-filter.h +++ b/camel/camel-mime-filter.h @@ -26,9 +26,10 @@ #include <camel/camel-object.h> #include <sys/types.h> -#define CAMEL_MIME_FILTER(obj) GTK_CHECK_CAST (obj, camel_mime_filter_get_type (), CamelMimeFilter) -#define CAMEL_MIME_FILTER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mime_filter_get_type (), CamelMimeFilterClass) -#define IS_CAMEL_MIME_FILTER(obj) GTK_CHECK_TYPE (obj, camel_mime_filter_get_type ()) +#define CAMEL_MIME_FILTER_TYPE (camel_mime_filter_get_type ()) +#define CAMEL_MIME_FILTER(obj) CAMEL_CHECK_CAST (obj, camel_mime_filter_get_type (), CamelMimeFilter) +#define CAMEL_MIME_FILTER_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_filter_get_type (), CamelMimeFilterClass) +#define IS_CAMEL_MIME_FILTER(obj) CAMEL_CHECK_TYPE (obj, camel_mime_filter_get_type ()) typedef struct _CamelMimeFilterClass CamelMimeFilterClass; @@ -61,7 +62,7 @@ struct _CamelMimeFilterClass { void (*reset)(CamelMimeFilter *f); }; -guint camel_mime_filter_get_type (void); +CamelType camel_mime_filter_get_type (void); CamelMimeFilter *camel_mime_filter_new (void); void camel_mime_filter_filter(CamelMimeFilter *f, diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index d7a8775b43..c3bd02cd05 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -58,27 +58,26 @@ static char *recipient_names[] = { }; static int write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void finalize (GtkObject *object); static void add_header (CamelMedium *medium, const char *header_name, const void *header_value); static void set_header (CamelMedium *medium, const char *header_name, const void *header_value); static void remove_header (CamelMedium *medium, const char *header_name); static int construct_from_parser (CamelMimePart *, CamelMimeParser *); +static void g_lib_is_uber_crappy_shit(gpointer whocares, gpointer getlost, gpointer blah); /* Returns the class for a CamelMimeMessage */ -#define CMM_CLASS(so) CAMEL_MIME_MESSAGE_CLASS (GTK_OBJECT(so)->klass) -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) -#define CMD_CLASS(so) CAMEL_MEDIUM_CLASS (GTK_OBJECT(so)->klass) +#define CMM_CLASS(so) CAMEL_MIME_MESSAGE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CMD_CLASS(so) CAMEL_MEDIUM_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static void camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) { CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_message_class); CamelMimePartClass *camel_mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_message_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_mime_message_class); CamelMediumClass *camel_medium_class = CAMEL_MEDIUM_CLASS (camel_mime_message_class); int i; - parent_class = gtk_type_class (camel_mime_part_get_type ()); + parent_class = CAMEL_MIME_PART_CLASS(camel_type_get_global_classfuncs (camel_mime_part_get_type ())); header_name_table = g_hash_table_new (g_strcase_hash, g_strcase_equal); for (i=0;header_names[i];i++) @@ -92,8 +91,6 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) camel_medium_class->remove_header = remove_header; camel_mime_part_class->construct_from_parser = construct_from_parser; - - gtk_object_class->finalize = finalize; } @@ -120,39 +117,8 @@ camel_mime_message_init (gpointer object, gpointer klass) mime_message->date_str = NULL; } -GtkType -camel_mime_message_get_type (void) -{ - static GtkType camel_mime_message_type = 0; - - if (!camel_mime_message_type) { - GtkTypeInfo camel_mime_message_info = - { - "CamelMimeMessage", - sizeof (CamelMimeMessage), - sizeof (CamelMimeMessageClass), - (GtkClassInitFunc) camel_mime_message_class_init, - (GtkObjectInitFunc) camel_mime_message_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_message_type = gtk_type_unique (camel_mime_part_get_type (), &camel_mime_message_info); - } - - return camel_mime_message_type; -} - -/* annoying way to free objects in a hashtable, i mean, its not like anyone - would want to store them in a hashtable, really */ -static void g_lib_is_uber_crappy_shit(gpointer whocares, gpointer getlost, gpointer blah) -{ - gtk_object_unref((GtkObject *)getlost); -} - static void -finalize (GtkObject *object) +camel_mime_message_finalize (CamelObject *object) { CamelMimeMessage *message = CAMEL_MIME_MESSAGE (object); @@ -163,8 +129,33 @@ finalize (GtkObject *object) g_hash_table_foreach (message->recipients, g_lib_is_uber_crappy_shit, NULL); g_hash_table_destroy(message->recipients); +} + + +CamelType +camel_mime_message_get_type (void) +{ + static CamelType camel_mime_message_type = CAMEL_INVALID_TYPE; + + if (camel_mime_message_type == CAMEL_INVALID_TYPE) { + camel_mime_message_type = camel_type_register (camel_mime_part_get_type(), "CamelMimeMessage", + sizeof (CamelMimeMessage), + sizeof (CamelMimeMessageClass), + (CamelObjectClassInitFunc) camel_mime_message_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_message_init, + (CamelObjectFinalizeFunc) camel_mime_message_finalize); + } + + return camel_mime_message_type; +} - GTK_OBJECT_CLASS (parent_class)->finalize (object); +/* annoying way to free objects in a hashtable, i mean, its not like anyone + would want to store them in a hashtable, really */ +/* peterw: somebody's not bitter :-) */ +static void g_lib_is_uber_crappy_shit(gpointer whocares, gpointer getlost, gpointer blah) +{ + camel_object_unref((CamelObject *)getlost); } @@ -173,7 +164,7 @@ CamelMimeMessage * camel_mime_message_new (void) { CamelMimeMessage *mime_message; - mime_message = gtk_type_new (CAMEL_MIME_MESSAGE_TYPE); + mime_message = CAMEL_MIME_MESSAGE(camel_object_new (CAMEL_MIME_MESSAGE_TYPE)); return mime_message; } diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h index b52da923a9..7e90d7cbcc 100644 --- a/camel/camel-mime-message.h +++ b/camel/camel-mime-message.h @@ -42,9 +42,9 @@ extern "C" { #define CAMEL_MIME_MESSAGE_TYPE (camel_mime_message_get_type ()) -#define CAMEL_MIME_MESSAGE(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessage)) -#define CAMEL_MIME_MESSAGE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessageClass)) -#define CAMEL_IS_MIME_MESSAGE(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_MESSAGE_TYPE)) +#define CAMEL_MIME_MESSAGE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessage)) +#define CAMEL_MIME_MESSAGE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessageClass)) +#define CAMEL_IS_MIME_MESSAGE(o) (CAMEL_CHECK_TYPE((o), CAMEL_MIME_MESSAGE_TYPE)) /* specify local time */ @@ -76,8 +76,8 @@ typedef struct { -/* Standard Gtk function */ -GtkType camel_mime_message_get_type (void); +/* Standard Camel function */ +CamelType camel_mime_message_get_type (void); /* public methods */ diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c index a781479aeb..4b7b23ae37 100644 --- a/camel/camel-mime-parser.c +++ b/camel/camel-mime-parser.c @@ -303,65 +303,47 @@ static char *states[] = { static CamelObjectClass *camel_mime_parser_parent; -enum SIGNALS { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; +static void +camel_mime_parser_class_init (CamelMimeParserClass *klass) +{ + camel_mime_parser_parent = camel_type_get_global_classfuncs (camel_object_get_type ()); +} -guint -camel_mime_parser_get_type (void) +static void +camel_mime_parser_init (CamelMimeParser *obj) { - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelMimeParser", - sizeof (CamelMimeParser), - sizeof (CamelMimeParserClass), - (GtkClassInitFunc) camel_mime_parser_class_init, - (GtkObjectInitFunc) camel_mime_parser_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_object_get_type (), &type_info); - } - - return type; + struct _header_scan_state *s; + + s = folder_scan_init(); + _PRIVATE(obj) = s; } static void -finalise(GtkObject *o) +camel_mime_parser_finalize(CamelObject *o) { struct _header_scan_state *s = _PRIVATE(o); #ifdef PURIFY purify_watch_remove_all(); #endif folder_scan_close(s); - - ((GtkObjectClass *)camel_mime_parser_parent)->finalize (o); } -static void -camel_mime_parser_class_init (CamelMimeParserClass *klass) +CamelType +camel_mime_parser_get_type (void) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; + static CamelType type = CAMEL_INVALID_TYPE; - camel_mime_parser_parent = gtk_type_class (camel_object_get_type ()); - - object_class->finalize = finalise; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_mime_parser_init (CamelMimeParser *obj) -{ - struct _header_scan_state *s; - - s = folder_scan_init(); - _PRIVATE(obj) = s; + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_object_get_type (), "CamelMimeParser", + sizeof (CamelMimeParser), + sizeof (CamelMimeParserClass), + (CamelObjectClassInitFunc) camel_mime_parser_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_parser_init, + (CamelObjectFinalizeFunc) camel_mime_parser_finalize); + } + + return type; } /** @@ -374,7 +356,7 @@ camel_mime_parser_init (CamelMimeParser *obj) CamelMimeParser * camel_mime_parser_new (void) { - CamelMimeParser *new = CAMEL_MIME_PARSER ( gtk_type_new (camel_mime_parser_get_type ())); + CamelMimeParser *new = CAMEL_MIME_PARSER ( camel_object_new (camel_mime_parser_get_type ())); return new; } @@ -407,7 +389,7 @@ camel_mime_parser_filter_add(CamelMimeParser *m, CamelMimeFilter *mf) if (s->filterid == -1) s->filterid++; new->next = 0; - gtk_object_ref((GtkObject *)mf); + camel_object_ref((CamelObject *)mf); /* yes, this is correct, since 'next' is the first element of the struct */ f = (struct _header_scan_filter *)&s->filters; @@ -435,7 +417,7 @@ camel_mime_parser_filter_remove(CamelMimeParser *m, int id) while (f && f->next) { old = f->next; if (old->id == id) { - gtk_object_unref((GtkObject *)old->filter); + camel_object_unref((CamelObject *)old->filter); f->next = old->next; g_free(old); /* there should only be a single matching id, but @@ -1366,7 +1348,7 @@ folder_scan_close(struct _header_scan_state *s) if (s->fd != -1) close(s->fd); if (s->stream) { - gtk_object_unref((GtkObject *)s->stream); + camel_object_unref((CamelObject *)s->stream); } g_free(s); } @@ -1427,7 +1409,7 @@ folder_scan_init_with_fd(struct _header_scan_state *s, int fd) close(s->fd); s->fd = fd; if (s->stream) { - gtk_object_unref((GtkObject *)s->stream); + camel_object_unref((CamelObject *)s->stream); s->stream = NULL; } return 0; @@ -1447,9 +1429,9 @@ folder_scan_init_with_stream(struct _header_scan_state *s, CamelStream *stream) s->inptr = s->inbuf; s->inend[0] = '\n'; if (s->stream) - gtk_object_unref((GtkObject *)s->stream); + camel_object_unref((CamelObject *)s->stream); s->stream = stream; - gtk_object_ref((GtkObject *)stream); + camel_object_ref((CamelObject *)stream); if (s->fd != -1) { close(s->fd); s->fd = -1; diff --git a/camel/camel-mime-parser.h b/camel/camel-mime-parser.h index 2283ec6f98..5baa58c88e 100644 --- a/camel/camel-mime-parser.h +++ b/camel/camel-mime-parser.h @@ -27,9 +27,9 @@ #include <camel/camel-mime-filter.h> #include <camel/camel-stream.h> -#define CAMEL_MIME_PARSER(obj) GTK_CHECK_CAST (obj, camel_mime_parser_get_type (), CamelMimeParser) -#define CAMEL_MIME_PARSER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_mime_parser_get_type (), CamelMimeParserClass) -#define IS_CAMEL_MIME_PARSER(obj) GTK_CHECK_TYPE (obj, camel_mime_parser_get_type ()) +#define CAMEL_MIME_PARSER(obj) CAMEL_CHECK_CAST (obj, camel_mime_parser_get_type (), CamelMimeParser) +#define CAMEL_MIME_PARSER_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_mime_parser_get_type (), CamelMimeParserClass) +#define IS_CAMEL_MIME_PARSER(obj) CAMEL_CHECK_TYPE (obj, camel_mime_parser_get_type ()) typedef struct _CamelMimeParserClass CamelMimeParserClass; diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 656520030c..68b1f1da75 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -61,7 +61,7 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser /* if we can't seek, dont have a stream/etc, then we must cache it */ source = camel_mime_parser_stream(mp); if (source) { - gtk_object_ref((GtkObject *)source); + camel_object_ref((CamelObject *)source); if (CAMEL_IS_SEEKABLE_STREAM (source)) { seekable_source = CAMEL_SEEKABLE_STREAM (source); cache = FALSE; @@ -135,7 +135,7 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser d(printf("Small message part, kept in memory!\n")); mem = camel_stream_mem_new_with_byte_array(buffer); camel_data_wrapper_construct_from_stream (dw, mem); - gtk_object_unref ((GtkObject *)mem); + camel_object_unref ((CamelObject *)mem); } else { CamelStream *sub; CamelStreamFilter *filter; @@ -159,11 +159,11 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser camel_stream_filter_add(filter, fch); } camel_data_wrapper_construct_from_stream (dw, (CamelStream *)filter); - gtk_object_unref ((GtkObject *)filter); + camel_object_unref ((CamelObject *)filter); } else { camel_data_wrapper_construct_from_stream (dw, sub); } - gtk_object_unref ((GtkObject *)sub); + camel_object_unref ((CamelObject *)sub); } camel_mime_parser_filter_remove(mp, decid); @@ -171,13 +171,13 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser camel_mime_parser_filter_remove(mp, chrid); if (fdec) - gtk_object_unref((GtkObject *)fdec); + camel_object_unref((CamelObject *)fdec); if (fcrlf) - gtk_object_unref((GtkObject *)fcrlf); + camel_object_unref((CamelObject *)fcrlf); if (fch) - gtk_object_unref((GtkObject *)fch); + camel_object_unref((CamelObject *)fch); if (source) - gtk_object_unref((GtkObject *)source); + camel_object_unref((CamelObject *)source); } @@ -214,7 +214,7 @@ camel_mime_part_construct_content_from_parser(CamelMimePart *dw, CamelMimeParser bodypart = (CamelDataWrapper *)camel_mime_part_new(); camel_mime_part_construct_from_parser((CamelMimePart *)bodypart, mp); camel_multipart_add_part((CamelMultipart *)content, (CamelMimePart *)bodypart); - gtk_object_unref ((GtkObject *)bodypart); + camel_object_unref ((CamelObject *)bodypart); } d(printf("Created multi-part\n")); @@ -228,7 +228,7 @@ camel_mime_part_construct_content_from_parser(CamelMimePart *dw, CamelMimeParser camel_data_wrapper_set_mime_type_field (content, camel_mime_part_get_content_type ((CamelMimePart *)dw)); camel_medium_set_content_object((CamelMedium *)dw, content); - gtk_object_unref ((GtkObject *)content); + camel_object_unref ((CamelObject *)content); } } diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index ab4c44b82f..4112857667 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -59,12 +59,9 @@ static GHashTable *header_name_table; static CamelMediumClass *parent_class=NULL; /* Returns the class for a CamelMimePart */ -#define CMP_CLASS(so) CAMEL_MIME_PART_CLASS (GTK_OBJECT(so)->klass) -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) -#define CMD_CLASS(so) CAMEL_MEDIUM_CLASS (GTK_OBJECT(so)->klass) - -/* from GtkObject */ -static void finalize (GtkObject *object); +#define CMP_CLASS(so) CAMEL_MIME_PART_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +#define CMD_CLASS(so) CAMEL_MEDIUM_CLASS (CAMEL_OBJECT_GET_CLASS(so)) /* from CamelDataWrapper */ static int write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); @@ -106,9 +103,8 @@ camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class) { CamelMediumClass *camel_medium_class = CAMEL_MEDIUM_CLASS (camel_mime_part_class); CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_part_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class); - parent_class = gtk_type_class (camel_medium_get_type ()); + parent_class = CAMEL_MEDIUM_CLASS (camel_type_get_global_classfuncs (camel_medium_get_type ())); init_header_name_table(); camel_mime_part_class->construct_from_parser = construct_from_parser; @@ -122,8 +118,6 @@ camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class) camel_data_wrapper_class->write_to_stream = write_to_stream; camel_data_wrapper_class->construct_from_stream= construct_from_stream; - - gtk_object_class->finalize = finalize; } static void @@ -144,35 +138,8 @@ camel_mime_part_init (gpointer object, gpointer klass) } - - -GtkType -camel_mime_part_get_type (void) -{ - static GtkType camel_mime_part_type = 0; - - if (!camel_mime_part_type) { - GtkTypeInfo camel_mime_part_info = - { - "CamelMimePart", - sizeof (CamelMimePart), - sizeof (CamelMimePartClass), - (GtkClassInitFunc) camel_mime_part_class_init, - (GtkObjectInitFunc) camel_mime_part_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_part_type = gtk_type_unique (camel_medium_get_type (), &camel_mime_part_info); - } - - return camel_mime_part_type; -} - - static void -finalize (GtkObject *object) +camel_mime_part_finalize (CamelObject *object) { CamelMimePart *mime_part = CAMEL_MIME_PART (object); @@ -185,13 +152,32 @@ finalize (GtkObject *object) if (mime_part->content_type) gmime_content_field_unref (mime_part->content_type); if (mime_part->temp_message_buffer) g_byte_array_free (mime_part->temp_message_buffer, TRUE); - if (mime_part->content_input_stream) gtk_object_unref (GTK_OBJECT (mime_part->content_input_stream)); + if (mime_part->content_input_stream) camel_object_unref (CAMEL_OBJECT (mime_part->content_input_stream)); header_raw_clear(&mime_part->headers); +} + - GTK_OBJECT_CLASS (parent_class)->finalize (object); + +CamelType +camel_mime_part_get_type (void) +{ + static CamelType camel_mime_part_type = CAMEL_INVALID_TYPE; + + if (camel_mime_part_type == CAMEL_INVALID_TYPE) { + camel_mime_part_type = camel_type_register (CAMEL_MEDIUM_TYPE, "CamelMimePart", + sizeof (CamelMimePart), + sizeof (CamelMimePartClass), + (CamelObjectClassInitFunc) camel_mime_part_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_part_init, + (CamelObjectFinalizeFunc) camel_mime_part_finalize); + } + + return camel_mime_part_type; } + /* **** */ static gboolean @@ -533,10 +519,10 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) CamelMimeFilter *crlf = camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); camel_stream_filter_add(filter_stream, crlf); - gtk_object_unref((GtkObject *)crlf); + camel_object_unref((CamelObject *)crlf); } camel_stream_filter_add(filter_stream, filter); - gtk_object_unref((GtkObject *)filter); + camel_object_unref((CamelObject *)filter); stream = (CamelStream *)filter_stream; } @@ -544,7 +530,7 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) count = camel_data_wrapper_write_to_stream (content, stream); if (filter_stream) { camel_stream_flush((CamelStream *)filter_stream); - gtk_object_unref((GtkObject *)filter_stream); + camel_object_unref((CamelObject *)filter_stream); } if (count == -1) return -1; @@ -618,7 +604,7 @@ construct_from_stream(CamelDataWrapper *dw, CamelStream *s) } else { ret = camel_mime_part_construct_from_parser((CamelMimePart *)dw, mp); } - gtk_object_unref((GtkObject *)mp); + camel_object_unref((CamelObject *)mp); return ret; } @@ -675,7 +661,7 @@ camel_mime_part_encoding_from_string (const gchar *string) CamelMimePart * camel_mime_part_new (void) { - return (CamelMimePart *)gtk_object_new (CAMEL_MIME_PART_TYPE, NULL); + return (CamelMimePart *)camel_object_new (CAMEL_MIME_PART_TYPE); } /** @@ -705,12 +691,12 @@ camel_mime_part_set_content (CamelMimePart *camel_mime_part, camel_data_wrapper_set_mime_type (dw, type); stream = camel_stream_mem_new_with_buffer (data, length); camel_data_wrapper_construct_from_stream (dw, stream); - gtk_object_unref (GTK_OBJECT (stream)); + camel_object_unref (CAMEL_OBJECT (stream)); camel_medium_set_content_object (medium, dw); - gtk_object_unref (GTK_OBJECT (dw)); + camel_object_unref (CAMEL_OBJECT (dw)); } else { if (medium->content) - gtk_object_unref (GTK_OBJECT (medium->content)); + camel_object_unref (CAMEL_OBJECT (medium->content)); medium->content = NULL; } } diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h index 00a7bec876..e423553318 100644 --- a/camel/camel-mime-part.h +++ b/camel/camel-mime-part.h @@ -39,9 +39,9 @@ extern "C" { #include <camel/camel-mime-parser.h> #define CAMEL_MIME_PART_TYPE (camel_mime_part_get_type ()) -#define CAMEL_MIME_PART(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_PART_TYPE, CamelMimePart)) -#define CAMEL_MIME_PART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_PART_TYPE, CamelMimePartClass)) -#define CAMEL_IS_MIME_PART(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_PART_TYPE)) +#define CAMEL_MIME_PART(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MIME_PART_TYPE, CamelMimePart)) +#define CAMEL_MIME_PART_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MIME_PART_TYPE, CamelMimePartClass)) +#define CAMEL_IS_MIME_PART(o) (CAMEL_CHECK_TYPE((o), CAMEL_MIME_PART_TYPE)) enum _CamelMimePartEncodingType { @@ -82,8 +82,8 @@ typedef struct _CamelMimePartClass { int (*construct_from_parser) (CamelMimePart *, CamelMimeParser *); } CamelMimePartClass; -/* Standard Gtk function */ -GtkType camel_mime_part_get_type (void); +/* Standard Camel function */ +CamelType camel_mime_part_get_type (void); /* public methods */ CamelMimePart * camel_mime_part_new (void); diff --git a/camel/camel-movemail.c b/camel/camel-movemail.c index d5cc335481..f587914a31 100644 --- a/camel/camel-movemail.c +++ b/camel/camel-movemail.c @@ -565,8 +565,8 @@ camel_movemail_solaris (int sfd, int dfd, CamelException *ex) } } - gtk_object_unref((GtkObject *)mp); - gtk_object_unref((GtkObject *)ffrom); + camel_object_unref((CamelObject *)mp); + camel_object_unref((CamelObject *)ffrom); return ret; @@ -577,8 +577,8 @@ fail: g_strerror (errno)); - gtk_object_unref((GtkObject *)mp); - gtk_object_unref((GtkObject *)ffrom); + camel_object_unref((CamelObject *)mp); + camel_object_unref((CamelObject *)ffrom); return -1; } diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index e28c6542bf..ebbad07047 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -56,17 +56,17 @@ static void set_boundary (CamelMultipart *multipart, static const gchar * get_boundary (CamelMultipart *multipart); static int write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void finalize (GtkObject *object); +static void unref_part (gpointer data, gpointer user_data); static CamelDataWrapperClass *parent_class = NULL; /* Returns the class for a CamelMultipart */ -#define CMP_CLASS(so) CAMEL_MULTIPART_CLASS (GTK_OBJECT(so)->klass) +#define CMP_CLASS(so) CAMEL_MULTIPART_CLASS (CAMEL_OBJECT_GET_CLASS(so)) /* Returns the class for a CamelDataWrapper */ -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) +#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static void @@ -74,10 +74,8 @@ camel_multipart_class_init (CamelMultipartClass *camel_multipart_class) { CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_multipart_class); - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_multipart_class); - parent_class = gtk_type_class (camel_data_wrapper_get_type ()); + parent_class = CAMEL_DATA_WRAPPER_CLASS (camel_type_get_global_classfuncs (camel_data_wrapper_get_type ())); /* virtual method definition */ camel_multipart_class->add_part = add_part; @@ -91,8 +89,6 @@ camel_multipart_class_init (CamelMultipartClass *camel_multipart_class) /* virtual method overload */ camel_data_wrapper_class->write_to_stream = write_to_stream; - - gtk_object_class->finalize = finalize; } static void @@ -106,41 +102,8 @@ camel_multipart_init (gpointer object, gpointer klass) multipart->postface = NULL; } - -GtkType -camel_multipart_get_type (void) -{ - static GtkType camel_multipart_type = 0; - - if (!camel_multipart_type) { - GtkTypeInfo camel_multipart_info = - { - "CamelMultipart", - sizeof (CamelMultipart), - sizeof (CamelMultipartClass), - (GtkClassInitFunc) camel_multipart_class_init, - (GtkObjectInitFunc) camel_multipart_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_multipart_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_multipart_info); - } - - return camel_multipart_type; -} - -static void -unref_part (gpointer data, gpointer user_data) -{ - GtkObject *part = GTK_OBJECT (data); - - gtk_object_unref (part); -} - static void -finalize (GtkObject *object) +camel_multipart_finalize (CamelObject *object) { CamelMultipart *multipart = CAMEL_MULTIPART (object); @@ -152,11 +115,34 @@ finalize (GtkObject *object) g_free (multipart->preface); if (multipart->postface) g_free (multipart->postface); +} + - GTK_OBJECT_CLASS (parent_class)->finalize (object); +CamelType +camel_multipart_get_type (void) +{ + static CamelType camel_multipart_type = CAMEL_INVALID_TYPE; + + if (camel_multipart_type == CAMEL_INVALID_TYPE) { + camel_multipart_type = camel_type_register (camel_data_wrapper_get_type (), "CamelMultipart", + sizeof (CamelMultipart), + sizeof (CamelMultipartClass), + (CamelObjectClassInitFunc) camel_multipart_class_init, + NULL, + (CamelObjectInitFunc) camel_multipart_init, + (CamelObjectFinalizeFunc) camel_multipart_finalize); + } + + return camel_multipart_type; } +static void +unref_part (gpointer data, gpointer user_data) +{ + CamelObject *part = CAMEL_OBJECT (data); + camel_object_unref (part); +} /** * camel_multipart_new: @@ -170,7 +156,7 @@ camel_multipart_new (void) { CamelMultipart *multipart; - multipart = (CamelMultipart *)gtk_type_new (CAMEL_MULTIPART_TYPE); + multipart = (CamelMultipart *)camel_object_new (CAMEL_MULTIPART_TYPE); multipart->preface = NULL; multipart->postface = NULL; @@ -182,7 +168,7 @@ static void add_part (CamelMultipart *multipart, CamelMimePart *part) { multipart->parts = g_list_append (multipart->parts, part); - gtk_object_ref (GTK_OBJECT (part)); + camel_object_ref (CAMEL_OBJECT (part)); } /** @@ -206,7 +192,7 @@ static void add_part_at (CamelMultipart *multipart, CamelMimePart *part, guint index) { multipart->parts = g_list_insert (multipart->parts, part, index); - gtk_object_ref (GTK_OBJECT (part)); + camel_object_ref (CAMEL_OBJECT (part)); } /** @@ -236,7 +222,7 @@ remove_part (CamelMultipart *multipart, CamelMimePart *part) if (!multipart->parts) return; multipart->parts = g_list_remove (multipart->parts, part); - gtk_object_unref (GTK_OBJECT (part)); + camel_object_unref (CAMEL_OBJECT (part)); } /** @@ -278,7 +264,7 @@ remove_part_at (CamelMultipart *multipart, guint index) multipart->parts = g_list_remove_link (parts_list, part_to_remove); if (part_to_remove->data) - gtk_object_unref (GTK_OBJECT (part_to_remove->data)); + camel_object_unref (CAMEL_OBJECT (part_to_remove->data)); g_list_free_1 (part_to_remove); return removed_part; @@ -291,7 +277,7 @@ remove_part_at (CamelMultipart *multipart, guint index) * * Remove the indicated part from the multipart object. * - * Return value: the removed part. Note that it is gtk_object_unref()ed + * Return value: the removed part. Note that it is camel_object_unref()ed * before being returned, which may cause it to be destroyed. **/ CamelMimePart * diff --git a/camel/camel-multipart.h b/camel/camel-multipart.h index 709e73e51d..642cdb5255 100644 --- a/camel/camel-multipart.h +++ b/camel/camel-multipart.h @@ -37,9 +37,9 @@ extern "C" { #include <camel/camel-data-wrapper.h> #define CAMEL_MULTIPART_TYPE (camel_multipart_get_type ()) -#define CAMEL_MULTIPART(obj) (GTK_CHECK_CAST((obj), CAMEL_MULTIPART_TYPE, CamelMultipart)) -#define CAMEL_MULTIPART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MULTIPART_TYPE, CamelMultipartClass)) -#define CAMEL_IS_MULTIPART(o) (GTK_CHECK_TYPE((o), CAMEL_MULTIPART_TYPE)) +#define CAMEL_MULTIPART(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MULTIPART_TYPE, CamelMultipart)) +#define CAMEL_MULTIPART_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MULTIPART_TYPE, CamelMultipartClass)) +#define CAMEL_IS_MULTIPART(o) (CAMEL_CHECK_TYPE((o), CAMEL_MULTIPART_TYPE)) struct _CamelMultipart @@ -72,8 +72,8 @@ typedef struct { } CamelMultipartClass; -/* Standard Gtk function */ -GtkType camel_multipart_get_type (void); +/* Standard Camel function */ +CamelType camel_multipart_get_type (void); /* public methods */ diff --git a/camel/camel-news-address.c b/camel/camel-news-address.c index 671f0a5559..ebd35b80c7 100644 --- a/camel/camel-news-address.c +++ b/camel/camel-news-address.c @@ -22,53 +22,34 @@ static void camel_news_address_class_init (CamelNewsAddressClass *klass); -static void camel_news_address_init (CamelNewsAddress *obj); static CamelAddressClass *camel_news_address_parent; -enum SIGNALS { - LAST_SIGNAL -}; +static void +camel_news_address_class_init (CamelNewsAddressClass *klass) +{ + camel_news_address_parent = CAMEL_ADDRESS_CLASS (camel_type_get_global_classfuncs (camel_address_get_type ())); +} -static guint signals[LAST_SIGNAL] = { 0 }; -guint +CamelType camel_news_address_get_type (void) { - static guint type = 0; + static guint type = CAMEL_INVALID_TYPE; - if (!type) { - GtkTypeInfo type_info = { - "CamelNewsAddress", - sizeof (CamelNewsAddress), - sizeof (CamelNewsAddressClass), - (GtkClassInitFunc) camel_news_address_class_init, - (GtkObjectInitFunc) camel_news_address_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_address_get_type (), &type_info); + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_address_get_type (), "CamelNewsAddress", + sizeof (CamelNewsAddress), + sizeof (CamelNewsAddressClass), + (CamelObjectClassInitFunc) camel_news_address_class_init, + NULL, + NULL, + NULL); } return type; } -static void -camel_news_address_class_init (CamelNewsAddressClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - camel_news_address_parent = gtk_type_class (camel_address_get_type ()); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_news_address_init (CamelNewsAddress *obj) -{ -} - /** * camel_news_address_new: * @@ -79,6 +60,6 @@ camel_news_address_init (CamelNewsAddress *obj) CamelNewsAddress * camel_news_address_new (void) { - CamelNewsAddress *new = CAMEL_NEWS_ADDRESS ( gtk_type_new (camel_news_address_get_type ())); + CamelNewsAddress *new = CAMEL_NEWS_ADDRESS ( camel_object_new (camel_news_address_get_type ())); return new; } diff --git a/camel/camel-news-address.h b/camel/camel-news-address.h index e25f907351..8d2aa03968 100644 --- a/camel/camel-news-address.h +++ b/camel/camel-news-address.h @@ -23,9 +23,9 @@ #include <camel/camel-address.h> -#define CAMEL_NEWS_ADDRESS(obj) GTK_CHECK_CAST (obj, camel_news_address_get_type (), CamelNewsAddress) -#define CAMEL_NEWS_ADDRESS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_news_address_get_type (), CamelNewsAddressClass) -#define IS_CAMEL_NEWS_ADDRESS(obj) GTK_CHECK_TYPE (obj, camel_news_address_get_type ()) +#define CAMEL_NEWS_ADDRESS(obj) CAMEL_CHECK_CAST (obj, camel_news_address_get_type (), CamelNewsAddress) +#define CAMEL_NEWS_ADDRESS_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_news_address_get_type (), CamelNewsAddressClass) +#define IS_CAMEL_NEWS_ADDRESS(obj) CAMEL_CHECK_TYPE (obj, camel_news_address_get_type ()) typedef struct _CamelNewsAddressClass CamelNewsAddressClass; diff --git a/camel/camel-object.c b/camel/camel-object.c index 3edce10d8a..849d47612e 100644 --- a/camel/camel-object.c +++ b/camel/camel-object.c @@ -26,32 +26,945 @@ #include <config.h> #include "camel-object.h" +/* I just mashed the keyboard for these... */ +#define CAMEL_OBJECT_MAGIC_VALUE 0x77A344EF +#define CAMEL_OBJECT_CLASS_MAGIC_VALUE 0xEE26A990 +#define CAMEL_OBJECT_FINALIZED_VALUE 0x84AC3656 +#define CAMEL_OBJECT_CLASS_FINALIZED_VALUE 0x7621ABCD + +#define DEFAULT_PREALLOCS 8 + +#define BAST_CASTARD 1 /* Define to return NULL when casts fail */ + +#define NULL_PREP_VALUE ((gpointer)make_global_classfuncs) /* See camel_object_class_declare_event */ + +/* ** Quickie type system ************************************************* */ + +typedef struct _CamelTypeInfo +{ + CamelType self; + CamelType parent; + const gchar *name; + + size_t instance_size; + GMemChunk *instance_chunk; + CamelObjectInitFunc instance_init; + CamelObjectFinalizeFunc instance_finalize; + GList *free_instances; + + size_t classfuncs_size; + CamelObjectClassInitFunc class_init; + CamelObjectClassFinalizeFunc class_finalize; + CamelObjectClass *global_classfuncs; +} +CamelTypeInfo; + +typedef struct _CamelHookPair +{ + CamelObjectEventHookFunc func; + gpointer user_data; +} +CamelHookPair; + +/* ************************************************************************ */ + +static void camel_type_lock_up (void); +static void camel_type_lock_down (void); + +static void obj_init (CamelObject * obj); +static void obj_finalize (CamelObject * obj); +static void obj_class_init (CamelObjectClass * class); +static void obj_class_finalize (CamelObjectClass * class); + +static gboolean shared_is_of_type (CamelObjectShared * sh, CamelType ctype, + gboolean is_obj); +static void make_global_classfuncs (CamelTypeInfo * type_info); + +/* ************************************************************************ */ + +G_LOCK_DEFINE_STATIC (type_system); +G_LOCK_DEFINE_STATIC (type_system_level); +static GPrivate *type_system_locklevel = NULL; + +G_LOCK_DEFINE_STATIC (refcount); + +static gboolean type_system_initialized = FALSE; +static GHashTable *ctype_to_typeinfo = NULL; +static const CamelType camel_object_type = 1; +static CamelType cur_max_type = CAMEL_INVALID_TYPE; + +/* ************************************************************************ */ + +#define LOCK_VAL (GPOINTER_TO_INT (g_private_get (type_system_locklevel))) +#define LOCK_SET( val ) g_private_set (type_system_locklevel, GINT_TO_POINTER (val)) + static void -camel_object_init (gpointer object, gpointer klass) +camel_type_lock_up (void) { - GTK_OBJECT_UNSET_FLAGS (object, GTK_FLOATING); + G_LOCK (type_system_level); + + if (type_system_locklevel == NULL) + type_system_locklevel = g_private_new (GINT_TO_POINTER (0)); + + if (LOCK_VAL == 0) { + G_UNLOCK (type_system_level); + G_LOCK (type_system); + G_LOCK (type_system_level); + } + + LOCK_SET (LOCK_VAL + 1); + + G_UNLOCK (type_system_level); } -GtkType -camel_object_get_type (void) +static void +camel_type_lock_down (void) +{ + G_LOCK (type_system_level); + + if (type_system_locklevel == NULL) { + g_warning + ("camel_type_lock_down: lock down before a lock up?"); + type_system_locklevel = g_private_new (GINT_TO_POINTER (0)); + return; + } + + LOCK_SET (LOCK_VAL - 1); + + if (LOCK_VAL == 0) + G_UNLOCK (type_system); + + G_UNLOCK (type_system_level); +} + +void +camel_type_init (void) +{ + CamelTypeInfo *obj_info; + + camel_type_lock_up (); + + if (type_system_initialized) { + g_warning + ("camel_type_init: type system already initialized."); + camel_type_lock_down (); + return; + } + + type_system_initialized = TRUE; + ctype_to_typeinfo = g_hash_table_new (g_direct_hash, g_direct_equal); + + obj_info = g_new (CamelTypeInfo, 1); + obj_info->self = camel_object_type; + obj_info->parent = CAMEL_INVALID_TYPE; + obj_info->name = "CamelObject"; + + obj_info->instance_size = sizeof (CamelObject); + obj_info->instance_chunk = + g_mem_chunk_create (CamelObject, DEFAULT_PREALLOCS, + G_ALLOC_ONLY); + obj_info->instance_init = obj_init; + obj_info->instance_finalize = obj_finalize; + obj_info->free_instances = NULL; + + obj_info->classfuncs_size = sizeof (CamelObjectClass); + obj_info->class_init = obj_class_init; + obj_info->class_finalize = obj_class_finalize; + + g_hash_table_insert (ctype_to_typeinfo, + GINT_TO_POINTER (CAMEL_INVALID_TYPE), NULL); + g_hash_table_insert (ctype_to_typeinfo, + GINT_TO_POINTER (camel_object_type), obj_info); + + /* Sigh. Ugly */ + make_global_classfuncs (obj_info); + + cur_max_type = camel_object_type; + + camel_type_lock_down (); +} + +CamelType +camel_type_register (CamelType parent, const gchar * name, + size_t instance_size, size_t classfuncs_size, + CamelObjectClassInitFunc class_init, + CamelObjectClassFinalizeFunc class_finalize, + CamelObjectInitFunc instance_init, + CamelObjectFinalizeFunc instance_finalize) { - static GtkType camel_object_type = 0; + CamelTypeInfo *parent_info; + CamelTypeInfo *obj_info; + gchar *chunkname; + + g_return_val_if_fail (parent != CAMEL_INVALID_TYPE, + CAMEL_INVALID_TYPE); + g_return_val_if_fail (name, CAMEL_INVALID_TYPE); + g_return_val_if_fail (instance_size, CAMEL_INVALID_TYPE); + g_return_val_if_fail (classfuncs_size, CAMEL_INVALID_TYPE); + + camel_type_lock_up (); - if (!camel_object_type) { - GtkTypeInfo camel_object_info = - { - "CamelObject", - sizeof (CamelObject), - sizeof (CamelObjectClass), - (GtkClassInitFunc) NULL, - (GtkObjectInitFunc) camel_object_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; + if (type_system_initialized == FALSE) { + G_UNLOCK (type_system); + camel_type_init (); + G_LOCK (type_system); + } + + parent_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (parent)); - camel_object_type = gtk_type_unique (gtk_object_get_type (), &camel_object_info); + if (parent_info == NULL) { + g_warning + ("camel_type_register: no such parent type %d of class `%s'", + parent, name); + camel_type_lock_down (); + return CAMEL_INVALID_TYPE; } + if (parent_info->instance_size > instance_size) { + g_warning + ("camel_type_register: instance of class `%s' would be smaller than parent `%s'", + name, parent_info->name); + camel_type_lock_down (); + return CAMEL_INVALID_TYPE; + } + + if (parent_info->classfuncs_size > classfuncs_size) { + g_warning + ("camel_type_register: classfuncs of class `%s' would be smaller than parent `%s'", + name, parent_info->name); + camel_type_lock_down (); + return CAMEL_INVALID_TYPE; + } + + cur_max_type++; + + obj_info = g_new (CamelTypeInfo, 1); + obj_info->self = cur_max_type; + obj_info->parent = parent; + obj_info->name = name; + + obj_info->instance_size = instance_size; + chunkname = + g_strdup_printf ("chunk for instances of Camel type `%s'", + name); + obj_info->instance_chunk = + g_mem_chunk_new (chunkname, instance_size, + instance_size * DEFAULT_PREALLOCS, + G_ALLOC_ONLY); + g_free (chunkname); + obj_info->instance_init = instance_init; + obj_info->instance_finalize = instance_finalize; + obj_info->free_instances = NULL; + + obj_info->classfuncs_size = classfuncs_size; + obj_info->class_init = class_init; + obj_info->class_finalize = class_finalize; + + g_hash_table_insert (ctype_to_typeinfo, + GINT_TO_POINTER (obj_info->self), obj_info); + + /* Sigh. Ugly. */ + make_global_classfuncs (obj_info); + + camel_type_lock_down (); + return obj_info->self; +} + +CamelObjectClass * +camel_type_get_global_classfuncs (CamelType type) +{ + CamelTypeInfo *type_info; + + g_return_val_if_fail (type != CAMEL_INVALID_TYPE, NULL); + + camel_type_lock_up (); + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (type)); + camel_type_lock_down (); + + g_return_val_if_fail (type_info != NULL, NULL); + + return type_info->global_classfuncs; +} + +const gchar * +camel_type_to_name (CamelType type) +{ + CamelTypeInfo *type_info; + + g_return_val_if_fail (type != CAMEL_INVALID_TYPE, + "(the invalid type)"); + + camel_type_lock_up (); + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (type)); + camel_type_lock_down (); + + g_return_val_if_fail (type_info != NULL, + "(a bad type parameter was specified)"); + + return type_info->name; +} + +/* ** The CamelObject ***************************************************** */ + +static void +obj_init (CamelObject * obj) +{ + obj->s.magic = CAMEL_OBJECT_MAGIC_VALUE; + obj->ref_count = 1; + obj->event_to_hooklist = NULL; + obj->in_event = 0; +} + +static void +obj_finalize (CamelObject * obj) +{ + g_return_if_fail (obj->s.magic == CAMEL_OBJECT_MAGIC_VALUE); + g_return_if_fail (obj->ref_count == 0); + g_return_if_fail (obj->in_event == 0); + + obj->s.magic = CAMEL_OBJECT_FINALIZED_VALUE; + + if (obj->event_to_hooklist) { + g_hash_table_foreach (obj->event_to_hooklist, (GHFunc) g_free, + NULL); + g_hash_table_destroy (obj->event_to_hooklist); + obj->event_to_hooklist = NULL; + } +} + +static void +obj_class_init (CamelObjectClass * class) +{ + class->s.magic = CAMEL_OBJECT_CLASS_MAGIC_VALUE; + + camel_object_class_declare_event (class, "finalize", NULL); +} + +static void +obj_class_finalize (CamelObjectClass * class) +{ + g_return_if_fail (class->s.magic == CAMEL_OBJECT_CLASS_MAGIC_VALUE); + + class->s.magic = CAMEL_OBJECT_CLASS_FINALIZED_VALUE; + + if (class->event_to_preplist) { + g_hash_table_foreach (class->event_to_preplist, + (GHFunc) g_free, NULL); + g_hash_table_destroy (class->event_to_preplist); + class->event_to_preplist = NULL; + } +} + +CamelType +camel_object_get_type (void) +{ + if (type_system_initialized == FALSE) + camel_type_init (); + return camel_object_type; } + +CamelObject * +camel_object_new (CamelType type) +{ + CamelTypeInfo *type_info; + GSList *parents = NULL; + GSList *head = NULL; + CamelObject *instance; + + g_return_val_if_fail (type != CAMEL_INVALID_TYPE, NULL); + + /* Look up the type */ + + camel_type_lock_up (); + + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (type)); + + if (type_info == NULL) { + g_warning + ("camel_object_new: trying to create object of invalid type %d", + type); + camel_type_lock_down (); + return NULL; + } + + /* Grab an instance out of the freed ones if possible, alloc otherwise */ + + if (type_info->free_instances) { + GList *first; + + first = g_list_first (type_info->free_instances); + instance = first->data; + type_info->free_instances = + g_list_remove_link (type_info->free_instances, first); + g_list_free_1 (first); + } else { + instance = g_mem_chunk_alloc0 (type_info->instance_chunk); + } + + /* Init the instance and classfuncs a bit */ + + instance->s.type = type; + instance->classfuncs = type_info->global_classfuncs; + + /* Loop through the parents in simplest -> most complex order, initing the class and instance. + + * When parent = CAMEL_INVALID_TYPE and we're at the end of the line, _lookup returns NULL + * because we inserted it as corresponding to CAMEL_INVALID_TYPE. Clever, eh? + */ + + while (type_info) { + parents = g_slist_prepend (parents, type_info); + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (type_info-> + parent)); + } + + head = parents; + + for (; parents && parents->data; parents = parents->next) { + CamelTypeInfo *thisinfo; + + thisinfo = parents->data; + if (thisinfo->instance_init) + (thisinfo->instance_init) (instance); + } + + g_slist_free (head); + + camel_type_lock_down (); + return instance; +} + +void +camel_object_ref (CamelObject * obj) +{ + g_return_if_fail (CAMEL_IS_OBJECT (obj)); + + G_LOCK (refcount); + obj->ref_count++; + G_UNLOCK (refcount); +} + +void +camel_object_unref (CamelObject * obj) +{ + CamelTypeInfo *type_info; + CamelTypeInfo *iter; + GSList *parents = NULL; + GSList *head = NULL; + + g_return_if_fail (CAMEL_IS_OBJECT (obj)); + + G_LOCK (refcount); + obj->ref_count--; + + if (obj->ref_count > 0) { + G_UNLOCK (refcount); + return; + } + + G_UNLOCK (refcount); + + /* Oh no! We want to emit a "finalized" event, but that function refs the object + * because it's not supposed to get finalized in an event, but it is being finalized + * right now, and AAUGH AAUGH AUGH AUGH! + * + * So we don't call camel_object_trigger_event. We do it ourselves. We even know + * that CamelObject doesn't provide a prep for the finalized event, so we plunge + * right in and call our hooks. + * + * And there was much rejoicing. + */ + +#define hooklist parents /*cough */ + + if (obj->event_to_hooklist) { + CamelHookPair *pair; + + hooklist = + g_hash_table_lookup (obj->event_to_hooklist, + "finalize"); + + while (hooklist && hooklist->data) { + pair = hooklist->data; + (pair->func) (obj, NULL, pair->user_data); + hooklist = hooklist->next; + } + } + + hooklist = NULL; /* Don't mess with this line */ + +#undef hooklist + + /* Destroy it! hahaha! */ + + camel_type_lock_up (); + + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (obj->s.type)); + + if (type_info == NULL) { + g_warning + ("camel_object_unref: seemingly valid object has a bad type %d", + obj->s.type); + camel_type_lock_down (); + return; + } + + /* Loop through the parents in most complex -> simplest order, finalizing the class + * and instance. + * + * When parent = CAMEL_INVALID_TYPE and we're at the end of the line, _lookup returns NULL + * because we inserted it as corresponding to CAMEL_INVALID_TYPE. Clever, eh? + * + * Use iter to preserve type_info for free_{instance,classfunc}s + */ + + iter = type_info; + + while (iter) { + parents = g_slist_prepend (parents, iter); + iter = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (iter->parent)); + } + + parents = g_slist_reverse (parents); + head = parents; + + for (; parents && parents->data; parents = parents->next) { + CamelTypeInfo *thisinfo; + + thisinfo = parents->data; + if (thisinfo->instance_finalize) + (thisinfo->instance_finalize) (obj); + } + + g_slist_free (head); + + /* A little bit of cleaning up. + + * Don't erase the type, so we can peek at it if a finalized object + * is check_cast'ed somewhere. + */ + + memset (obj, 0, type_info->instance_size); + obj->s.type = type_info->self; + obj->s.magic = CAMEL_OBJECT_FINALIZED_VALUE; + + /* Tuck away the pointer for use in a new object */ + + type_info->free_instances = + g_list_prepend (type_info->free_instances, obj); + + camel_type_lock_down (); +} + +gboolean +camel_object_is_of_type (CamelObject * obj, CamelType ctype) +{ + return shared_is_of_type ((CamelObjectShared *) obj, ctype, TRUE); +} + +gboolean +camel_object_class_is_of_type (CamelObjectClass * class, CamelType ctype) +{ + return shared_is_of_type ((CamelObjectShared *) class, ctype, FALSE); +} + +#ifdef BAST_CASTARD +#define ERRVAL NULL +#else +#define ERRVAL obj +#endif + +CamelObject * +camel_object_check_cast (CamelObject * obj, CamelType ctype) +{ + if (shared_is_of_type ((CamelObjectShared *) obj, ctype, TRUE)) + return obj; + return ERRVAL; +} + +CamelObjectClass * +camel_object_class_check_cast (CamelObjectClass * class, CamelType ctype) +{ + if (shared_is_of_type ((CamelObjectShared *) class, ctype, FALSE)) + return class; + return ERRVAL; +} + +#undef ERRVAL + +gchar * +camel_object_describe (CamelObject * obj) +{ + if (obj == NULL) + return g_strdup ("a NULL pointer"); + + if (obj->s.magic == CAMEL_OBJECT_MAGIC_VALUE) { + return g_strdup_printf ("an instance of `%s' at %p", + camel_type_to_name (obj->s.type), + obj); + } else if (obj->s.magic == CAMEL_OBJECT_FINALIZED_VALUE) { + return g_strdup_printf ("a finalized instance of `%s' at %p", + camel_type_to_name (obj->s.type), + obj); + } else if (obj->s.magic == CAMEL_OBJECT_CLASS_MAGIC_VALUE) { + return g_strdup_printf ("the classfuncs of `%s' at %p", + camel_type_to_name (obj->s.type), + obj); + } else if (obj->s.magic == CAMEL_OBJECT_CLASS_FINALIZED_VALUE) { + return + g_strdup_printf + ("the finalized classfuncs of `%s' at %p", + camel_type_to_name (obj->s.type), obj); + } + + return g_strdup ("not a CamelObject"); +} + +/* This is likely to be called in the class_init callback, + * and the type will likely be somewhat uninitialized. + * Is this a problem? We'll see.... + */ +void +camel_object_class_declare_event (CamelObjectClass * class, + const gchar * name, + CamelObjectEventPrepFunc prep) +{ + g_return_if_fail (CAMEL_IS_OBJECT_CLASS (class)); + g_return_if_fail (name); + + if (class->event_to_preplist == NULL) + class->event_to_preplist = + g_hash_table_new (g_str_hash, g_str_equal); + else if (g_hash_table_lookup (class->event_to_preplist, name) != NULL) { + g_warning + ("camel_object_class_declare_event: event `%s' already declared for `%s'", + name, camel_type_to_name (class->s.type)); + return; + } + + /* AIEEEEEEEEEEEEEEEEEEEEEE + + * I feel so naughty. Since it's valid to declare an event and not + * provide a hook, it should be valid to insert a NULL value into + * the table. However, then our lookup in trigger_event would be + * ambiguous, not telling us whether the event is undefined or whether + * it merely has no hook. + * + * So we create an 'NULL prep' value that != NULL... specifically, it + * equals the address of one of our static functions , because that + * can't possibly be your hook. + * + * Just don't forget to check for the 'evil value' and it'll work, + * I promise. + */ + + if (prep == NULL) + prep = NULL_PREP_VALUE; + + g_hash_table_insert (class->event_to_preplist, g_strdup (name), prep); +} + +void +camel_object_hook_event (CamelObject * obj, const gchar * name, + CamelObjectEventHookFunc hook, gpointer user_data) +{ + GSList *hooklist; + CamelHookPair *pair; + + g_return_if_fail (CAMEL_IS_OBJECT (obj)); + g_return_if_fail (name); + g_return_if_fail (hook); + + if (obj->event_to_hooklist == NULL) + obj->event_to_hooklist = + g_hash_table_new (g_str_hash, g_str_equal); + + pair = g_new (CamelHookPair, 1); + pair->func = hook; + pair->user_data = user_data; + + hooklist = g_hash_table_lookup (obj->event_to_hooklist, name); + hooklist = g_slist_prepend (hooklist, pair); + g_hash_table_insert (obj->event_to_hooklist, g_strdup (name), + hooklist); +} + +void +camel_object_unhook_event (CamelObject * obj, const gchar * name, + CamelObjectEventHookFunc hook, gpointer user_data) +{ + GSList *hooklist; + GSList *head; + + g_return_if_fail (CAMEL_IS_OBJECT (obj)); + g_return_if_fail (name); + g_return_if_fail (hook); + + if (obj->event_to_hooklist == NULL) { + g_warning + ("camel_object_unhook_event: trying to unhook `%s' from an instance " + "of `%s' with no hooks attached", name, + camel_type_to_name (obj->s.type)); + return; + } + + hooklist = g_hash_table_lookup (obj->event_to_hooklist, name); + + if (hooklist == NULL) { + g_warning + ("camel_object_unhook_event: trying to unhook `%s' from an instance " + "of `%s' with no hooks attached to that event.", + name, camel_type_to_name (obj->s.type)); + return; + } + + head = hooklist; + + while (hooklist) { + CamelHookPair *pair = (CamelHookPair *) hooklist->data; + + if (pair->func == hook && pair->user_data == user_data) { + g_free (hooklist->data); + head = g_slist_remove_link (head, hooklist); + g_slist_free_1 (hooklist); + g_hash_table_insert (obj->event_to_hooklist, name, + head); + return; + } + + hooklist = hooklist->next; + } + + g_warning + ("camel_object_unhook_event: cannot find hook/data pair %p/%p in an " + "instance of `%s' attached to `%s'", hook, user_data, + camel_type_to_name (obj->s.type), name); +} + +void +camel_object_trigger_event (CamelObject * obj, const gchar * name, + gpointer event_data) +{ + GSList *hooklist; + CamelHookPair *pair; + CamelObjectEventPrepFunc prep; + + g_return_if_fail (CAMEL_IS_OBJECT (obj)); + g_return_if_fail (name); + + if (obj->in_event) { + g_warning + ("camel_object_trigger_event: trying to trigger `%s' in class " + "`%s' while already triggering another event", name, + camel_type_to_name (obj->s.type)); + return; + } + + if (obj->classfuncs->event_to_preplist == NULL) { + g_warning + ("camel_object_trigger_event: trying to trigger `%s' in class " + "`%s' with no defined events.", name, + camel_type_to_name (obj->s.type)); + return; + } + + prep = g_hash_table_lookup (obj->classfuncs->event_to_preplist, name); + + if (prep == NULL) { + g_warning + ("camel_object_trigger_event: trying to trigger undefined " + "event `%s' in class `%s'.", name, + camel_type_to_name (obj->s.type)); + return; + } + + /* Ref so that it can't get destroyed in the event, which would + * be Bad. And it's a valid ref anyway... + */ + + camel_object_ref (obj); + obj->in_event = 1; + + if ((prep != NULL_PREP_VALUE && !prep (obj, event_data)) + || obj->event_to_hooklist == NULL) { + obj->in_event = 0; + camel_object_unref (obj); + return; + } + + hooklist = g_hash_table_lookup (obj->event_to_hooklist, name); + + while (hooklist && hooklist->data) { + pair = hooklist->data; + (pair->func) (obj, event_data, pair->user_data); + hooklist = hooklist->next; + } + + obj->in_event = 0; + camel_object_unref (obj); +} + +/* ** Static helpers ****************************************************** */ + +static gboolean +shared_is_of_type (CamelObjectShared * sh, CamelType ctype, gboolean is_obj) +{ + CamelTypeInfo *type_info; + gchar *targtype; + + if (is_obj) + targtype = "instance"; + else + targtype = "classdata"; + + if (ctype == CAMEL_INVALID_TYPE) { + g_warning + ("shared_is_of_type: trying to cast to CAMEL_INVALID_TYPE"); + return FALSE; + } + + if (sh == NULL) { + g_warning + ("shared_is_of_type: trying to cast NULL to %s of `%s'", + targtype, camel_type_to_name (ctype)); + return FALSE; + } + + if (sh->magic == CAMEL_OBJECT_FINALIZED_VALUE) { + g_warning + ("shared_is_of_type: trying to cast finalized instance " + "of `%s' into %s of `%s'", + camel_type_to_name (sh->type), targtype, + camel_type_to_name (ctype)); + return FALSE; + } + + if (sh->magic == CAMEL_OBJECT_CLASS_FINALIZED_VALUE) { + g_warning + ("shared_is_of_type: trying to cast finalized classdata " + "of `%s' into %s of `%s'", + camel_type_to_name (sh->type), targtype, + camel_type_to_name (ctype)); + return FALSE; + } + + if (is_obj) { + if (sh->magic == CAMEL_OBJECT_CLASS_MAGIC_VALUE) { + g_warning + ("shared_is_of_type: trying to cast classdata " + "of `%s' into instance of `%s'", + camel_type_to_name (sh->type), + camel_type_to_name (ctype)); + return FALSE; + } + + if (sh->magic != CAMEL_OBJECT_MAGIC_VALUE) { + g_warning + ("shared_is_of_type: trying to cast junk data " + "into instance of `%s'", + camel_type_to_name (ctype)); + return FALSE; + } + } else { + if (sh->magic == CAMEL_OBJECT_MAGIC_VALUE) { + g_warning + ("shared_is_of_type: trying to cast instance " + "of `%s' into classdata of `%s'", + camel_type_to_name (sh->type), + camel_type_to_name (ctype)); + return FALSE; + } + + if (sh->magic != CAMEL_OBJECT_CLASS_MAGIC_VALUE) { + g_warning + ("shared_is_of_type: trying to cast junk data " + "into classdata of `%s'", + camel_type_to_name (ctype)); + return FALSE; + } + } + + camel_type_lock_up (); + + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (sh->type)); + + if (type_info == NULL) { + g_warning ("shared_is_of_type: seemingly valid %s has " + "bad type %d.", targtype, sh->type); + camel_type_lock_down (); + return FALSE; + } + + while (type_info) { + if (type_info->self == ctype) { + camel_type_lock_down (); + return TRUE; + } + + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (type_info-> + parent)); + } + + g_warning + ("shared_is_of_type: %s of `%s' (@%p) is not also %s of `%s'", + targtype, camel_type_to_name (sh->type), sh, targtype, + camel_type_to_name (ctype)); + + camel_type_lock_down (); + return FALSE; +} + +static void +make_global_classfuncs (CamelTypeInfo * type_info) +{ + CamelObjectClass *funcs; + GSList *parents; + GSList *head; + + g_assert (type_info); + + funcs = g_malloc0 (type_info->classfuncs_size); + funcs->s.type = type_info->self; + + type_info->global_classfuncs = funcs; + + parents = NULL; + while (type_info) { + parents = g_slist_prepend (parents, type_info); + type_info = + g_hash_table_lookup (ctype_to_typeinfo, + GINT_TO_POINTER (type_info-> + parent)); + } + + head = parents; + + for (; parents && parents->data; parents = parents->next) { + CamelTypeInfo *thisinfo; + + thisinfo = parents->data; + if (thisinfo->class_init) + (thisinfo->class_init) (funcs); + } + + g_slist_free (head); +} diff --git a/camel/camel-object.h b/camel/camel-object.h index 2c6b4d0d5c..fdcf7b4a15 100644 --- a/camel/camel-object.h +++ b/camel/camel-object.h @@ -26,40 +26,120 @@ #ifndef CAMEL_OBJECT_H #define CAMEL_OBJECT_H 1 - #ifdef __cplusplus -extern "C" { +extern "C" +{ #pragma } -#endif /* __cplusplus }*/ +#endif /* __cplusplus } */ -#include <gtk/gtk.h> +#include <stdlib.h> /* size_t */ #include <camel/camel-types.h> - -#define CAMEL_OBJECT_TYPE (camel_object_get_type ()) -#define CAMEL_OBJECT(obj) (GTK_CHECK_CAST((obj), CAMEL_OBJECT_TYPE, CamelObject)) -#define CAMEL_OBJECT_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_OBJECT_TYPE, CamelObjectClass)) -#define CAMEL_IS_OBJECT(o) (GTK_CHECK_TYPE((o), CAMEL_OBJECT_TYPE)) - - -struct _CamelObject -{ - GtkObject parent_object; - -}; - - -typedef struct { - GtkObjectClass parent_class; - -} CamelObjectClass; - - -/* Standard Gtk function */ -GtkType camel_object_get_type (void); - +#include <glib.h> + +#ifdef G_DISABLE_CHECKS +#define CAMEL_CHECK_CAST( obj, ctype, ptype ) ((ptype *) obj) +#define CAMEL_CHECK_CLASS_CAST( class, ctype, ptype ) ((ptype *) class) +#define CAMEL_CHECK_TYPE( obj, ctype ) (TRUE) +#define CAMEL_CHECK_CLASS_TYPE( class, ctype ) (TRUE) +#else +#define CAMEL_CHECK_CAST( obj, ctype, ptype ) ((ptype *) camel_object_check_cast( (CamelObject *)(obj), (CamelType)(ctype) )) +#define CAMEL_CHECK_CLASS_CAST( class, ctype, ptype ) ((ptype *) camel_object_class_check_cast( (CamelObjectClass *)(class), (CamelType)(ctype) )) +#define CAMEL_CHECK_TYPE( obj, ctype ) (camel_object_is_of_type( (CamelObject *)(obj), (CamelType)(ctype) )) +#define CAMEL_CHECK_CLASS_TYPE( class, ctype ) (camel_object_class_is_of_type( (CamelObjectClass *)(class), (CamelType)(ctype) )) +#endif + +#define CAMEL_INVALID_TYPE ((CamelType)0) + +#define CAMEL_OBJECT_TYPE (camel_object_get_type ()) + +#define CAMEL_OBJECT(obj) (CAMEL_CHECK_CAST((obj), CAMEL_OBJECT_TYPE, CamelObject)) +#define CAMEL_OBJECT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_OBJECT_TYPE, CamelObjectClass)) +#define CAMEL_IS_OBJECT(o) (CAMEL_CHECK_TYPE((o), CAMEL_OBJECT_TYPE)) +#define CAMEL_IS_OBJECT_CLASS(k) (CAMEL_CHECK_CLASS_TYPE((k), CAMEL_OBJECT_TYPE)) + +#define CAMEL_OBJECT_GET_CLASS(o) ((CamelObjectClass *)(CAMEL_OBJECT(o))->classfuncs) +#define CAMEL_OBJECT_GET_TYPE(o) ((CamelType)(CAMEL_OBJECT(o))->s.type) + + typedef guint32 CamelType; + + typedef struct _CamelObjectShared + { + guint32 magic; + CamelType type; + } + CamelObjectShared; + + typedef struct _CamelObjectClass + { + CamelObjectShared s; + + GHashTable *event_to_preplist; + } + CamelObjectClass; + + typedef struct _CamelObject + { + CamelObjectShared s; + guint32 ref_count:31; + guint32 in_event:1; + CamelObjectClass *classfuncs; + GHashTable *event_to_hooklist; + } + CamelObject; + + typedef void (*CamelObjectClassInitFunc) (CamelObjectClass *); + typedef void (*CamelObjectClassFinalizeFunc) (CamelObjectClass *); + typedef void (*CamelObjectInitFunc) (CamelObject *); + typedef void (*CamelObjectFinalizeFunc) (CamelObject *); + + typedef gboolean (*CamelObjectEventPrepFunc) (CamelObject *, + gpointer); + typedef void (*CamelObjectEventHookFunc) (CamelObject *, gpointer, + gpointer); + +/* The type system .... it's pretty simple..... */ + + void camel_type_init (void); + CamelType camel_type_register (CamelType parent, const gchar * name, + size_t instance_size, + size_t classfuncs_size, + CamelObjectClassInitFunc class_init, + CamelObjectClassFinalizeFunc + class_finalize, + CamelObjectInitFunc instance_init, + CamelObjectFinalizeFunc + instance_finalize); + CamelObjectClass *camel_type_get_global_classfuncs (CamelType type); + const gchar *camel_type_to_name (CamelType type); + + CamelType camel_object_get_type (void); + CamelObject *camel_object_new (CamelType type); + void camel_object_ref (CamelObject * obj); + void camel_object_unref (CamelObject * obj); + CamelObject *camel_object_check_cast (CamelObject * obj, + CamelType ctype); + CamelObjectClass *camel_object_class_check_cast (CamelObjectClass * + class, + CamelType ctype); + gboolean camel_object_is_of_type (CamelObject * obj, CamelType ctype); + gboolean camel_object_class_is_of_type (CamelObjectClass * class, + CamelType ctype); + gchar *camel_object_describe (CamelObject * obj); + void camel_object_class_declare_event (CamelObjectClass * class, + const gchar * name, + CamelObjectEventPrepFunc prep); + void camel_object_hook_event (CamelObject * obj, const gchar * name, + CamelObjectEventHookFunc hook, + gpointer user_data); + void camel_object_unhook_event (CamelObject * obj, const gchar * name, + CamelObjectEventHookFunc hook, + gpointer user_data); + void camel_object_trigger_event (CamelObject * obj, + const gchar * name, + gpointer event_data); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* CAMEL_OBJECT_H */ +#endif /* CAMEL_OBJECT_H */ diff --git a/camel/camel-provider.h b/camel/camel-provider.h index 4f2a67839f..00375029db 100644 --- a/camel/camel-provider.h +++ b/camel/camel-provider.h @@ -35,8 +35,8 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ -#include <gtk/gtk.h> #include <camel/camel-types.h> +#include <camel/camel-object.h> #define CAMEL_PROVIDER(obj) ((CamelProvider *)(obj)) @@ -78,7 +78,7 @@ typedef struct { int flags; - GtkType object_types [CAMEL_NUM_PROVIDER_TYPES]; + CamelType object_types [CAMEL_NUM_PROVIDER_TYPES]; GHashTable *service_cache; diff --git a/camel/camel-seekable-stream.c b/camel/camel-seekable-stream.c index 507c69dd48..c4ca950baa 100644 --- a/camel/camel-seekable-stream.c +++ b/camel/camel-seekable-stream.c @@ -29,7 +29,7 @@ static CamelStreamClass *parent_class = NULL; /* Returns the class for a CamelSeekableStream */ -#define CSS_CLASS(so) CAMEL_SEEKABLE_STREAM_CLASS (GTK_OBJECT(so)->klass) +#define CSS_CLASS(so) CAMEL_SEEKABLE_STREAM_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static off_t seek (CamelSeekableStream *stream, off_t offset, CamelStreamSeekPolicy policy); @@ -43,7 +43,7 @@ camel_seekable_stream_class_init (CamelSeekableStreamClass *camel_seekable_strea CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_seekable_stream_class); - parent_class = gtk_type_class (camel_stream_get_type ()); + parent_class = CAMEL_STREAM_CLASS( camel_type_get_global_classfuncs( CAMEL_STREAM_TYPE ) ); /* seekable stream methods */ camel_seekable_stream_class->seek = seek; @@ -63,25 +63,20 @@ camel_seekable_stream_init (void *o) stream->bound_end = CAMEL_STREAM_UNBOUND; } -GtkType +CamelType camel_seekable_stream_get_type (void) { - static GtkType camel_seekable_stream_type = 0; - - if (!camel_seekable_stream_type) { - GtkTypeInfo camel_seekable_stream_info = - { - "CamelSeekableStream", - sizeof (CamelSeekableStream), - sizeof (CamelSeekableStreamClass), - (GtkClassInitFunc) camel_seekable_stream_class_init, - (GtkObjectInitFunc) camel_seekable_stream_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_seekable_stream_type = gtk_type_unique (camel_stream_get_type (), &camel_seekable_stream_info); + static CamelType camel_seekable_stream_type = CAMEL_INVALID_TYPE; + + if (camel_seekable_stream_type == CAMEL_INVALID_TYPE) { + camel_seekable_stream_type = camel_type_register( CAMEL_STREAM_TYPE, + "CamelSeekableStream", + sizeof( CamelSeekableStream ), + sizeof( CamelSeekableStreamClass ), + (CamelObjectClassInitFunc) camel_seekable_stream_class_init, + NULL, + (CamelObjectInitFunc) camel_seekable_stream_init, + NULL ); } return camel_seekable_stream_type; diff --git a/camel/camel-seekable-stream.h b/camel/camel-seekable-stream.h index f1cd5cdbca..0fc67d59f8 100644 --- a/camel/camel-seekable-stream.h +++ b/camel/camel-seekable-stream.h @@ -38,9 +38,9 @@ extern "C" { #include <unistd.h> #define CAMEL_SEEKABLE_STREAM_TYPE (camel_seekable_stream_get_type ()) -#define CAMEL_SEEKABLE_STREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStream)) -#define CAMEL_SEEKABLE_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStreamClass)) -#define CAMEL_IS_SEEKABLE_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_SEEKABLE_STREAM_TYPE)) +#define CAMEL_SEEKABLE_STREAM(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStream)) +#define CAMEL_SEEKABLE_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStreamClass)) +#define CAMEL_IS_SEEKABLE_STREAM(o) (CAMEL_CHECK_TYPE((o), CAMEL_SEEKABLE_STREAM_TYPE)) typedef enum @@ -72,8 +72,8 @@ typedef struct { off_t start, off_t end); } CamelSeekableStreamClass; -/* Standard Gtk function */ -GtkType camel_seekable_stream_get_type (void); +/* Standard Camel function */ +CamelType camel_seekable_stream_get_type (void); /* public methods */ off_t camel_seekable_stream_seek (CamelSeekableStream *stream, off_t offset, diff --git a/camel/camel-seekable-substream.c b/camel/camel-seekable-substream.c index 4fc5b5d853..d62fc3bba4 100644 --- a/camel/camel-seekable-substream.c +++ b/camel/camel-seekable-substream.c @@ -27,7 +27,7 @@ static CamelSeekableStreamClass *parent_class = NULL; /* Returns the class for a CamelSeekableSubStream */ -#define CSS_CLASS(so) CAMEL_SEEKABLE_SUBSTREAM_CLASS (GTK_OBJECT(so)->klass) +#define CSS_CLASS(so) CAMEL_SEEKABLE_SUBSTREAM_CLASS (CAMEL_OBJECT(so)->klass) static int stream_read (CamelStream *stream, char *buffer, unsigned int n); static int stream_write (CamelStream *stream, const char *buffer, unsigned int n); @@ -36,8 +36,6 @@ static int stream_close (CamelStream *stream); static gboolean eos (CamelStream *stream); static off_t stream_seek (CamelSeekableStream *stream, off_t offset, CamelStreamSeekPolicy policy); -static void finalize (GtkObject *object); - static void camel_seekable_substream_class_init (CamelSeekableSubstreamClass *camel_seekable_substream_class) @@ -46,10 +44,8 @@ camel_seekable_substream_class_init (CamelSeekableSubstreamClass *camel_seekable CAMEL_SEEKABLE_STREAM_CLASS (camel_seekable_substream_class); CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_seekable_substream_class); - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_seekable_substream_class); - parent_class = gtk_type_class (camel_seekable_stream_get_type ()); + parent_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_type_get_global_classfuncs (camel_seekable_stream_get_type ())); /* virtual method definition */ @@ -62,44 +58,35 @@ camel_seekable_substream_class_init (CamelSeekableSubstreamClass *camel_seekable camel_seekable_stream_class->seek = stream_seek; - gtk_object_class->finalize = finalize; -} - - -GtkType -camel_seekable_substream_get_type (void) -{ - static GtkType camel_seekable_substream_type = 0; - - if (!camel_seekable_substream_type) { - GtkTypeInfo camel_seekable_substream_info = - { - "CamelSeekableSubstream", - sizeof (CamelSeekableSubstream), - sizeof (CamelSeekableSubstreamClass), - (GtkClassInitFunc) camel_seekable_substream_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_seekable_substream_type = gtk_type_unique (camel_seekable_stream_get_type (), &camel_seekable_substream_info); - } - - return camel_seekable_substream_type; } static void -finalize (GtkObject *object) +camel_seekable_substream_finalize (CamelObject *object) { CamelSeekableSubstream *seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (object); if (seekable_substream->parent_stream) - gtk_object_unref (GTK_OBJECT (seekable_substream->parent_stream)); + camel_object_unref (CAMEL_OBJECT (seekable_substream->parent_stream)); +} + + +CamelType +camel_seekable_substream_get_type (void) +{ + static CamelType camel_seekable_substream_type = CAMEL_INVALID_TYPE; + + if (camel_seekable_substream_type == CAMEL_INVALID_TYPE) { + camel_seekable_substream_type = camel_type_register (camel_seekable_stream_get_type (), "CamelSeekableSubstream", + sizeof (CamelSeekableSubstream), + sizeof (CamelSeekableSubstreamClass), + (CamelObjectClassInitFunc) camel_seekable_substream_class_init, + NULL, + NULL, + (CamelObjectFinalizeFunc) camel_seekable_substream_finalize); + } - GTK_OBJECT_CLASS (parent_class)->finalize (object); + return camel_seekable_substream_type; } /** @@ -128,11 +115,11 @@ camel_seekable_substream_new_with_seekable_stream_and_bounds (CamelSeekableStrea g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (parent_stream), NULL); /* Create the seekable substream. */ - seekable_substream = gtk_type_new (camel_seekable_substream_get_type ()); + seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (camel_object_new (camel_seekable_substream_get_type ())); /* Initialize it. */ seekable_substream->parent_stream = parent_stream; - gtk_object_ref (GTK_OBJECT (parent_stream)); + camel_object_ref (CAMEL_OBJECT (parent_stream)); /* Set the bound of the substream. We can ignore any possible error * here, because if we fail to seek now, it will try again later. diff --git a/camel/camel-seekable-substream.h b/camel/camel-seekable-substream.h index 721d33380a..6ac5588a42 100644 --- a/camel/camel-seekable-substream.h +++ b/camel/camel-seekable-substream.h @@ -36,9 +36,9 @@ extern "C" { #include <camel/camel-seekable-stream.h> #define CAMEL_SEEKABLE_SUBSTREAM_TYPE (camel_seekable_substream_get_type ()) -#define CAMEL_SEEKABLE_SUBSTREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_SEEKABLE_SUBSTREAM_TYPE, CamelSeekableSubstream)) -#define CAMEL_SEEKABLE_SUBSTREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SEEKABLE_SUBSTREAM_TYPE, CamelSeekableSubstreamClass)) -#define CAMEL_IS_SEEKABLE_SUBSTREAM(o) (GTK_CHECK_TYPE((o), CAMEL_SEEKABLE_SUBSTREAM_TYPE)) +#define CAMEL_SEEKABLE_SUBSTREAM(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SEEKABLE_SUBSTREAM_TYPE, CamelSeekableSubstream)) +#define CAMEL_SEEKABLE_SUBSTREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SEEKABLE_SUBSTREAM_TYPE, CamelSeekableSubstreamClass)) +#define CAMEL_IS_SEEKABLE_SUBSTREAM(o) (CAMEL_CHECK_TYPE((o), CAMEL_SEEKABLE_SUBSTREAM_TYPE)) struct _CamelSeekableSubstream { @@ -53,8 +53,8 @@ typedef struct { } CamelSeekableSubstreamClass; -/* Standard Gtk function */ -GtkType camel_seekable_substream_get_type (void); +/* Standard Camel function */ +CamelType camel_seekable_substream_get_type (void); /* public methods */ diff --git a/camel/camel-service.c b/camel/camel-service.c index ec2e4d3712..5631b6caf5 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -34,7 +34,7 @@ static CamelObjectClass *parent_class = NULL; /* Returns the class for a CamelService */ -#define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (GTK_OBJECT(so)->klass) +#define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static gboolean service_connect(CamelService *service, CamelException *ex); static gboolean service_disconnect(CamelService *service, CamelException *ex); @@ -42,18 +42,13 @@ static gboolean is_connected (CamelService *service); static GList * query_auth_types (CamelService *service, CamelException *ex); static void free_auth_types (CamelService *service, GList *authtypes); static char * get_name (CamelService *service, gboolean brief); -static void finalize (GtkObject *object); - static gboolean check_url (CamelService *service, CamelException *ex); static void camel_service_class_init (CamelServiceClass *camel_service_class) { - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_service_class); - - parent_class = gtk_type_class (camel_object_get_type ()); + parent_class = camel_type_get_global_classfuncs (CAMEL_OBJECT_TYPE); /* virtual method definition */ camel_service_class->connect = service_connect; @@ -62,50 +57,39 @@ camel_service_class_init (CamelServiceClass *camel_service_class) camel_service_class->query_auth_types = query_auth_types; camel_service_class->free_auth_types = free_auth_types; camel_service_class->get_name = get_name; - - /* virtual method overload */ - gtk_object_class->finalize = finalize; -} - -GtkType -camel_service_get_type (void) -{ - static GtkType camel_service_type = 0; - - if (!camel_service_type) { - GtkTypeInfo camel_service_info = - { - "CamelService", - sizeof (CamelService), - sizeof (CamelServiceClass), - (GtkClassInitFunc) camel_service_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_service_type = gtk_type_unique (camel_object_get_type (), - &camel_service_info); - } - - return camel_service_type; } static void -finalize (GtkObject *object) +camel_service_finalize (CamelObject *object) { CamelService *camel_service = CAMEL_SERVICE (object); if (camel_service->url) camel_url_free (camel_service->url); if (camel_service->session) - gtk_object_unref (GTK_OBJECT (camel_service->session)); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); + camel_object_unref (CAMEL_OBJECT (camel_service->session)); } + +CamelType +camel_service_get_type (void) +{ + static CamelType camel_service_type = CAMEL_INVALID_TYPE; + + if (camel_service_type == CAMEL_INVALID_TYPE) { + camel_service_type = camel_type_register( CAMEL_OBJECT_TYPE, "CamelService", + sizeof (CamelService), + sizeof (CamelServiceClass), + (CamelObjectClassInitFunc) camel_service_class_init, + NULL, + NULL, + camel_service_finalize ); + } + + return camel_service_type; +} + static gboolean check_url (CamelService *service, CamelException *ex) { @@ -142,7 +126,7 @@ check_url (CamelService *service, CamelException *ex) /** * camel_service_new: create a new CamelService or subtype - * @type: the GtkType of the class to create + * @type: the CamelType of the class to create * @session: the session for the service * @url: the default URL for the service (may be NULL) * @ex: a CamelException @@ -153,22 +137,22 @@ check_url (CamelService *service, CamelException *ex) * Return value: the CamelService, or NULL. **/ CamelService * -camel_service_new (GtkType type, CamelSession *session, CamelURL *url, +camel_service_new (CamelType type, CamelSession *session, CamelURL *url, CamelException *ex) { CamelService *service; g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL); - service = CAMEL_SERVICE (gtk_object_new (type, NULL)); + service = CAMEL_SERVICE (camel_object_new (type)); service->url = url; if (!url->empty && !check_url (service, ex)) { - gtk_object_unref (GTK_OBJECT (service)); + camel_object_unref (CAMEL_OBJECT (service)); return NULL; } service->session = session; - gtk_object_ref (GTK_OBJECT (session)); + camel_object_ref (CAMEL_OBJECT (session)); return service; } @@ -268,7 +252,7 @@ static char * get_name (CamelService *service, gboolean brief) { g_warning ("CamelService::get_name not implemented for `%s'", - gtk_type_name (GTK_OBJECT_TYPE (service))); + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (service))); return "???"; } diff --git a/camel/camel-service.h b/camel/camel-service.h index 1541e32e4a..50f0c2d4b4 100644 --- a/camel/camel-service.h +++ b/camel/camel-service.h @@ -39,9 +39,9 @@ extern "C" { #include <netdb.h> #define CAMEL_SERVICE_TYPE (camel_service_get_type ()) -#define CAMEL_SERVICE(obj) (GTK_CHECK_CAST((obj), CAMEL_SERVICE_TYPE, CamelService)) -#define CAMEL_SERVICE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass)) -#define CAMEL_IS_SERVICE(o) (GTK_CHECK_TYPE((o), CAMEL_SERVICE_TYPE)) +#define CAMEL_SERVICE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SERVICE_TYPE, CamelService)) +#define CAMEL_SERVICE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass)) +#define CAMEL_IS_SERVICE(o) (CAMEL_CHECK_TYPE((o), CAMEL_SERVICE_TYPE)) struct _CamelService { @@ -105,7 +105,7 @@ typedef struct { /* public methods */ -CamelService * camel_service_new (GtkType type, +CamelService * camel_service_new (CamelType type, CamelSession *session, CamelURL *url, CamelException *ex); @@ -131,8 +131,8 @@ struct hostent * camel_service_gethost (CamelService *service, CamelException *ex); -/* Standard Gtk function */ -GtkType camel_service_get_type (void); +/* Standard Camel function */ +CamelType camel_service_get_type (void); #ifdef __cplusplus } diff --git a/camel/camel-session.c b/camel/camel-session.c index ec99e17964..f9f0584294 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -56,46 +56,34 @@ camel_session_destroy_provider (gpointer key, gpointer value, gpointer user_data } static void -camel_session_finalise (GtkObject *o) +camel_session_finalise (CamelObject *o) { CamelSession *session = (CamelSession *)o; g_hash_table_foreach_remove (session->providers, camel_session_destroy_provider, NULL); g_hash_table_destroy (session->providers); - - GTK_OBJECT_CLASS (parent_class)->finalize (o); } static void -camel_session_class_init (CamelServiceClass *camel_service_class) +camel_session_class_init (CamelSessionClass *camel_session_class) { - GtkObjectClass *object_class = (GtkObjectClass *)camel_service_class; - - parent_class = gtk_type_class (camel_object_get_type ()); - object_class->finalize = camel_session_finalise; + parent_class = camel_type_get_global_classfuncs (camel_object_get_type ()); } -GtkType +CamelType camel_session_get_type (void) { - static GtkType camel_session_type = 0; - - if (!camel_session_type) { - GtkTypeInfo camel_session_info = - { - "CamelSession", - sizeof (CamelSession), - sizeof (CamelSessionClass), - (GtkClassInitFunc) camel_session_class_init, - (GtkObjectInitFunc) camel_session_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_session_type = gtk_type_unique (camel_object_get_type (), - &camel_session_info); + static CamelType camel_session_type = CAMEL_INVALID_TYPE; + + if (camel_session_type == CAMEL_INVALID_TYPE) { + camel_session_type = camel_type_register (camel_object_get_type (), "CamelSession", + sizeof (CamelSession), + sizeof (CamelSessionClass), + (CamelObjectClassInitFunc) camel_session_class_init, + NULL, + (CamelObjectInitFunc) camel_session_init, + (CamelObjectFinalizeFunc) camel_session_finalise); } return camel_session_type; @@ -103,11 +91,15 @@ camel_session_get_type (void) CamelSession * -camel_session_new (CamelAuthCallback authenticator) +camel_session_new (CamelAuthCallback authenticator, + CamelTimeoutRegisterCallback registrar, + CamelTimeoutRemoveCallback remover) { - CamelSession *session = gtk_type_new (CAMEL_SESSION_TYPE); + CamelSession *session = CAMEL_SESSION (camel_object_new (CAMEL_SESSION_TYPE)); session->authenticator = authenticator; + session->registrar = registrar; + session->remover = remover; return session; } @@ -191,9 +183,10 @@ camel_session_list_providers (CamelSession *session, gboolean load) } static void -service_cache_remove (CamelService *service, CamelSession *session) +service_cache_remove (CamelService *service, gpointer event_data, gpointer user_data) { CamelProvider *provider; + CamelSession *session = CAMEL_SESSION (user_data); g_return_if_fail (CAMEL_IS_SESSION (session)); g_return_if_fail (service != NULL); @@ -247,14 +240,14 @@ camel_session_get_service (CamelSession *session, const char *url_string, service = g_hash_table_lookup (provider->service_cache, url); if (service != NULL) { camel_url_free (url); - gtk_object_ref (GTK_OBJECT (service)); + camel_object_ref (CAMEL_OBJECT (service)); return service; } service = camel_service_new (provider->object_types[type], session, url, ex); if (service) { g_hash_table_insert (provider->service_cache, url, service); - gtk_signal_connect (GTK_OBJECT (service), "destroy", service_cache_remove, session); + camel_object_hook_event (CAMEL_OBJECT (service), "finalize", (CamelObjectEventHookFunc) service_cache_remove, session); } return service; @@ -302,3 +295,52 @@ camel_session_query_authenticator (CamelSession *session, return session->authenticator (mode, prompt, secret, service, item, ex); } + +/** + * camel_session_register_timeout: Register a timeout to be called + * periodically. + * + * @session: the CamelSession + * @interval: the number of milliseconds interval between calls + * @callback: the function to call + * @user_data: extra data to be passed to the callback + * + * This function will use the registrar callback provided upon + * camel_session_new to register the timeout. The callback will + * be called every @interval milliseconds until it returns @FALSE. + * It will be passed one argument, @user_data. + * + * Returns a nonzero handle that can be used with + * camel_session_remove_timeout on success, and 0 on failure to + * register the timeout. + **/ + +guint +camel_session_register_timeout (CamelSession *session, + guint32 interval, + CamelTimeoutCallback callback, + gpointer user_data) +{ + g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE); + + return session->registrar (interval, callback, user_data); +} + +/** + * camel_session_remove_timeout: Remove a previously registered + * timeout. + * + * @session: the CamelSession + * @handle: a value returned from camel_session_register_timeout + * + * This function will use the remover callback provided upon + * camel_session_new to remove the timeout. + * + * Returns TRUE on success and FALSE on failure. + **/ + +gboolean camel_session_remove_timeout (CamelSession *session, + guint handle) +{ + return session->remover (handle); +} diff --git a/camel/camel-session.h b/camel/camel-session.h index 67dfe729fc..704ae6a613 100644 --- a/camel/camel-session.h +++ b/camel/camel-session.h @@ -38,9 +38,9 @@ extern "C" { #include <camel/camel-provider.h> #define CAMEL_SESSION_TYPE (camel_session_get_type ()) -#define CAMEL_SESSION(obj) (GTK_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession)) -#define CAMEL_SESSION_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SESSION_TYPE, CamelSessionClass)) -#define CAMEL_IS_SESSION(o) (GTK_CHECK_TYPE((o), CAMEL_SESSION_TYPE)) +#define CAMEL_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession)) +#define CAMEL_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SESSION_TYPE, CamelSessionClass)) +#define CAMEL_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), CAMEL_SESSION_TYPE)) typedef enum { @@ -51,12 +51,19 @@ typedef char *(*CamelAuthCallback) (CamelAuthCallbackMode mode, char *data, gboolean secret, CamelService *service, char *item, CamelException *ex); +typedef gboolean (*CamelTimeoutCallback) (gpointer data); +typedef guint (*CamelTimeoutRegisterCallback) (guint32 interval, + CamelTimeoutCallback cb, + gpointer camel_data); +typedef gboolean (*CamelTimeoutRemoveCallback) (guint id); struct _CamelSession { CamelObject parent_object; CamelAuthCallback authenticator; + CamelTimeoutRegisterCallback registrar; + CamelTimeoutRemoveCallback remover; GHashTable *providers, *modules; }; @@ -69,13 +76,16 @@ typedef struct { /* public methods */ -/* Standard Gtk function */ -GtkType camel_session_get_type (void); +/* Standard Camel function */ +CamelType camel_session_get_type (void); CamelSession * camel_session_new (CamelAuthCallback - authenticator); - + authenticator, + CamelTimeoutRegisterCallback + registrar, + CamelTimeoutRemoveCallback + remover); void camel_session_register_provider (CamelSession *session, CamelProvider *provider); GList * camel_session_list_providers (CamelSession *session, @@ -99,6 +109,14 @@ char * camel_session_query_authenticator (CamelSession *session, char *item, CamelException *ex); +guint camel_session_register_timeout (CamelSession *session, + guint32 interval, + CamelTimeoutCallback callback, + gpointer user_data); + +gboolean camel_session_remove_timeout (CamelSession *session, + guint handle); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/camel/camel-store.c b/camel/camel-store.c index 3be983e081..dd2d5e41a0 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -32,7 +32,7 @@ static CamelServiceClass *parent_class = NULL; /* Returns the class for a CamelStore */ -#define CS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) +#define CS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static CamelFolder *get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex); @@ -51,15 +51,10 @@ static void cache_folder (CamelStore *store, const char *folder_name, CamelFolder *folder); static void uncache_folder (CamelStore *store, CamelFolder *folder); -static void finalize (GtkObject *object); - static void camel_store_class_init (CamelStoreClass *camel_store_class) { - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_store_class); - - parent_class = gtk_type_class (camel_service_get_type ()); + parent_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ())); /* virtual method definition */ camel_store_class->get_folder = get_folder; @@ -71,9 +66,6 @@ camel_store_class_init (CamelStoreClass *camel_store_class) camel_store_class->lookup_folder = lookup_folder; camel_store_class->cache_folder = cache_folder; camel_store_class->uncache_folder = uncache_folder; - - /* virtual method override */ - gtk_object_class->finalize = finalize; } static void @@ -84,33 +76,8 @@ camel_store_init (void *o, void *k) store->folders = g_hash_table_new (g_str_hash, g_str_equal); } -GtkType -camel_store_get_type (void) -{ - static GtkType camel_store_type = 0; - - if (!camel_store_type) { - GtkTypeInfo camel_store_info = - { - "CamelStore", - sizeof (CamelStore), - sizeof (CamelStoreClass), - (GtkClassInitFunc) camel_store_class_init, - (GtkObjectInitFunc) camel_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_store_type = gtk_type_unique (CAMEL_SERVICE_TYPE, &camel_store_info); - } - - return camel_store_type; -} - - static void -finalize (GtkObject *object) +camel_store_finalize (CamelObject *object) { CamelStore *store = CAMEL_STORE (object); @@ -125,12 +92,31 @@ finalize (GtkObject *object) } +CamelType +camel_store_get_type (void) +{ + static CamelType camel_store_type = CAMEL_INVALID_TYPE; + + if (camel_store_type == CAMEL_INVALID_TYPE) { + camel_store_type = camel_type_register (CAMEL_SERVICE_TYPE, "CamelStore", + sizeof (CamelStore), + sizeof (CamelStoreClass), + (CamelObjectClassInitFunc) camel_store_class_init, + NULL, + (CamelObjectInitFunc) camel_store_init, + (CamelObjectFinalizeFunc) camel_store_finalize ); + } + + return camel_store_type; +} + + static CamelFolder * get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex) { g_warning ("CamelStore::get_folder not implemented for `%s'", - gtk_type_name (GTK_OBJECT_TYPE (store))); + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))); return NULL; } @@ -138,17 +124,17 @@ static void delete_folder (CamelStore *store, const char *folder_name, CamelException *ex) { g_warning ("CamelStore::delete_folder not implemented for `%s'", - gtk_type_name (GTK_OBJECT_TYPE (store))); + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))); } static void rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex) { g_warning ("CamelStore::rename_folder not implemented for `%s'", - gtk_type_name (GTK_OBJECT_TYPE (store))); + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))); camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "rename folder unimplemented for: %s", - gtk_type_name (GTK_OBJECT_TYPE (store))); + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))); } @@ -164,7 +150,7 @@ get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex) { g_warning ("CamelStore::get_folder_name not implemented for `%s'", - gtk_type_name (GTK_OBJECT_TYPE (store))); + camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))); return NULL; } @@ -186,12 +172,17 @@ lookup_folder (CamelStore *store, const char *folder_name) if (store->folders) { CamelFolder *folder = g_hash_table_lookup (store->folders, folder_name); if (folder) - gtk_object_ref(GTK_OBJECT(folder)); + camel_object_ref(CAMEL_OBJECT(folder)); return folder; } return NULL; } +static void folder_finalize (CamelObject *folder, gpointer event_data, gpointer user_data) +{ + CS_CLASS (user_data)->uncache_folder (CAMEL_STORE(user_data), CAMEL_FOLDER(folder)); +} + static void cache_folder (CamelStore *store, const char *folder_name, CamelFolder *folder) { @@ -203,9 +194,16 @@ cache_folder (CamelStore *store, const char *folder_name, CamelFolder *folder) folder_name); } g_hash_table_insert (store->folders, g_strdup (folder_name), folder); - gtk_signal_connect_object (GTK_OBJECT (folder), "destroy", - GTK_SIGNAL_FUNC (CS_CLASS (store)->uncache_folder), - GTK_OBJECT (store)); + + camel_object_hook_event (CAMEL_OBJECT (folder), "finalize", folder_finalize, store); + + /* + * gt_k so as not to get caught by my little gt_k cleanliness detector. + * + * gt_k_signal_connect_object (CAMEL_OBJECT (folder), "destroy", + * GT_K_SIGNAL_FUNC (CS_CLASS (store)->uncache_folder), + * CAMEL_OBJECT (store)); + */ } static gboolean @@ -270,6 +268,9 @@ camel_store_get_folder (CamelStore *store, const char *folder_name, char *name; CamelFolder *folder = NULL; + if (!camel_service_is_connected (CAMEL_SERVICE (store))) + camel_service_connect (CAMEL_SERVICE (store), ex); + name = CS_CLASS (store)->get_folder_name (store, folder_name, ex); if (name) { folder = get_folder_internal (store, name, create, ex); diff --git a/camel/camel-store.h b/camel/camel-store.h index 3fc029d8c9..1ba2ff9869 100644 --- a/camel/camel-store.h +++ b/camel/camel-store.h @@ -34,12 +34,13 @@ extern "C" { #pragma } #endif /* __cplusplus }*/ +#include <camel/camel-object.h> #include <camel/camel-service.h> #define CAMEL_STORE_TYPE (camel_store_get_type ()) -#define CAMEL_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_STORE_TYPE, CamelStore)) -#define CAMEL_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STORE_TYPE, CamelStoreClass)) -#define CAMEL_IS_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_STORE_TYPE)) +#define CAMEL_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STORE_TYPE, CamelStore)) +#define CAMEL_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STORE_TYPE, CamelStoreClass)) +#define CAMEL_IS_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_STORE_TYPE)) struct _CamelStore @@ -86,8 +87,8 @@ typedef struct { } CamelStoreClass; -/* Standard Gtk function */ -GtkType camel_store_get_type (void); +/* Standard Camel function */ +CamelType camel_store_get_type (void); /* public methods */ CamelFolder * camel_store_get_folder (CamelStore *store, diff --git a/camel/camel-stream-buffer.c b/camel/camel-stream-buffer.c index 633e42095b..c25cda09bc 100644 --- a/camel/camel-stream-buffer.c +++ b/camel/camel-stream-buffer.c @@ -30,7 +30,7 @@ #include <fcntl.h> #include <errno.h> -static CamelStreamBufferClass *parent_class = NULL; +static CamelStreamClass *parent_class = NULL; enum { BUF_USER = 1<<0, /* user-supplied buffer, do not free */ @@ -44,9 +44,6 @@ static int stream_flush (CamelStream *stream); static int stream_close (CamelStream *stream); static gboolean stream_eos (CamelStream *stream); -static void finalize (GtkObject *object); -static void destroy (GtkObject *object); - static void init_vbuf(CamelStreamBuffer *sbf, CamelStream *s, CamelStreamBufferMode mode, char *buf, guint32 size); static void init(CamelStreamBuffer *sbuf, CamelStream *s, CamelStreamBufferMode mode); @@ -54,9 +51,8 @@ static void camel_stream_buffer_class_init (CamelStreamBufferClass *camel_stream_buffer_class) { CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_buffer_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_buffer_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 definition */ camel_stream_buffer_class->init = init; @@ -68,10 +64,6 @@ camel_stream_buffer_class_init (CamelStreamBufferClass *camel_stream_buffer_clas camel_stream_class->flush = stream_flush; camel_stream_class->close = stream_close; camel_stream_class->eos = stream_eos; - - gtk_object_class->finalize = finalize; - gtk_object_class->destroy = destroy; - } static void @@ -90,46 +82,8 @@ camel_stream_buffer_init (gpointer object, gpointer klass) sbf->linebuf = g_malloc(sbf->linesize); } -GtkType -camel_stream_buffer_get_type (void) -{ - static GtkType camel_stream_buffer_type = 0; - - gdk_threads_enter (); - if (!camel_stream_buffer_type) { - GtkTypeInfo camel_stream_buffer_info = - { - "CamelStreamBuffer", - sizeof (CamelStreamBuffer), - sizeof (CamelStreamBufferClass), - (GtkClassInitFunc) camel_stream_buffer_class_init, - (GtkObjectInitFunc) camel_stream_buffer_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_buffer_type = gtk_type_unique (camel_stream_get_type (), &camel_stream_buffer_info); - } - gdk_threads_leave (); - return camel_stream_buffer_type; -} - - static void -destroy (GtkObject *object) -{ - CamelStreamBuffer *stream_buffer = CAMEL_STREAM_BUFFER (object); - - /* NOP to remove warnings */ - stream_buffer->buf = stream_buffer->buf; - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -static void -finalize (GtkObject *object) +camel_stream_buffer_finalize (CamelObject *object) { CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (object); @@ -137,13 +91,31 @@ finalize (GtkObject *object) g_free(sbf->buf); } if (sbf->stream) - gtk_object_unref(GTK_OBJECT(sbf->stream)); + camel_object_unref(CAMEL_OBJECT(sbf->stream)); g_free(sbf->linebuf); +} + - GTK_OBJECT_CLASS (parent_class)->finalize (object); +CamelType +camel_stream_buffer_get_type (void) +{ + static CamelType camel_stream_buffer_type = CAMEL_INVALID_TYPE; + + if (camel_stream_buffer_type == CAMEL_INVALID_TYPE) { + camel_stream_buffer_type = camel_type_register (camel_stream_get_type (), "CamelStreamBuffer", + sizeof (CamelStreamBuffer), + sizeof (CamelStreamBufferClass), + (CamelObjectClassInitFunc) camel_stream_buffer_class_init, + NULL, + (CamelObjectInitFunc) camel_stream_buffer_init, + (CamelObjectFinalizeFunc) camel_stream_buffer_finalize); + } + + return camel_stream_buffer_type; } + static void set_vbuf(CamelStreamBuffer *sbf, char *buf, CamelStreamBufferMode mode, int size) { @@ -166,9 +138,9 @@ init_vbuf(CamelStreamBuffer *sbf, CamelStream *s, CamelStreamBufferMode mode, ch { set_vbuf(sbf, buf, mode, size); if (sbf->stream) - gtk_object_unref(GTK_OBJECT(sbf->stream)); + camel_object_unref(CAMEL_OBJECT(sbf->stream)); sbf->stream = s; - gtk_object_ref(GTK_OBJECT(sbf->stream)); + camel_object_ref(CAMEL_OBJECT(sbf->stream)); } static void @@ -196,8 +168,8 @@ CamelStream * camel_stream_buffer_new (CamelStream *stream, CamelStreamBufferMode mode) { CamelStreamBuffer *sbf; - sbf = gtk_type_new (camel_stream_buffer_get_type ()); - CAMEL_STREAM_BUFFER_CLASS (GTK_OBJECT(sbf)->klass)->init (sbf, stream, mode); + sbf = CAMEL_STREAM_BUFFER (camel_object_new (camel_stream_buffer_get_type ())); + CAMEL_STREAM_BUFFER_CLASS (CAMEL_OBJECT_GET_CLASS(sbf))->init (sbf, stream, mode); return CAMEL_STREAM (sbf); } @@ -240,8 +212,8 @@ camel_stream_buffer_new (CamelStream *stream, CamelStreamBufferMode mode) CamelStream *camel_stream_buffer_new_with_vbuf (CamelStream *stream, CamelStreamBufferMode mode, char *buf, guint32 size) { CamelStreamBuffer *sbf; - sbf = gtk_type_new (camel_stream_buffer_get_type ()); - CAMEL_STREAM_BUFFER_CLASS (GTK_OBJECT(sbf)->klass)->init_vbuf (sbf, stream, mode, buf, size); + sbf = CAMEL_STREAM_BUFFER (camel_object_new (camel_stream_buffer_get_type ())); + CAMEL_STREAM_BUFFER_CLASS (CAMEL_OBJECT_GET_CLASS(sbf))->init_vbuf (sbf, stream, mode, buf, size); return CAMEL_STREAM (sbf); } diff --git a/camel/camel-stream-buffer.h b/camel/camel-stream-buffer.h index 367735e4e1..5c9037595a 100644 --- a/camel/camel-stream-buffer.h +++ b/camel/camel-stream-buffer.h @@ -38,9 +38,9 @@ extern "C" { #include <stdio.h> #define CAMEL_STREAM_BUFFER_TYPE (camel_stream_buffer_get_type ()) -#define CAMEL_STREAM_BUFFER(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBuffer)) -#define CAMEL_STREAM_BUFFER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBufferClass)) -#define CAMEL_IS_STREAM_BUFFER(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_BUFFER_TYPE)) +#define CAMEL_STREAM_BUFFER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBuffer)) +#define CAMEL_STREAM_BUFFER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBufferClass)) +#define CAMEL_IS_STREAM_BUFFER(o) (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_BUFFER_TYPE)) typedef enum { @@ -83,8 +83,8 @@ typedef struct { } CamelStreamBufferClass; -/* Standard Gtk function */ -GtkType camel_stream_buffer_get_type (void); +/* Standard Camel function */ +CamelType camel_stream_buffer_get_type (void); /* public methods */ diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c index 9051bdb64f..7d66928bf5 100644 --- a/camel/camel-stream-filter.c +++ b/camel/camel-stream-filter.c @@ -57,36 +57,35 @@ static int do_reset (CamelStream *stream); static CamelStreamClass *camel_stream_filter_parent; -enum SIGNALS { - LAST_SIGNAL -}; +static void +camel_stream_filter_class_init (CamelStreamFilterClass *klass) +{ + CamelStreamClass *camel_stream_class = (CamelStreamClass *) klass; -static guint signals[LAST_SIGNAL] = { 0 }; + camel_stream_filter_parent = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ())); -guint -camel_stream_filter_get_type (void) + camel_stream_class->read = do_read; + camel_stream_class->write = do_write; + camel_stream_class->flush = do_flush; + camel_stream_class->close = do_close; + camel_stream_class->eos = do_eos; + camel_stream_class->reset = do_reset; + +} + +static void +camel_stream_filter_init (CamelStreamFilter *obj) { - static guint type = 0; - - if (!type) { - GtkTypeInfo type_info = { - "CamelStreamFilter", - sizeof (CamelStreamFilter), - sizeof (CamelStreamFilterClass), - (GtkClassInitFunc) camel_stream_filter_class_init, - (GtkObjectInitFunc) camel_stream_filter_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - type = gtk_type_unique (camel_stream_get_type (), &type_info); - } + struct _CamelStreamFilterPrivate *p; - return type; + _PRIVATE(obj) = p = g_malloc0(sizeof(*p)); + p->realbuffer = g_malloc(READ_SIZE + READ_PAD); + p->buffer = p->realbuffer + READ_PAD; + p->last_was_read = TRUE; } static void -finalise(GtkObject *o) +camel_stream_filter_finalize(CamelObject *o) { CamelStreamFilter *filter = (CamelStreamFilter *)o; struct _CamelStreamFilterPrivate *p = _PRIVATE(filter); @@ -95,49 +94,35 @@ finalise(GtkObject *o) f = p->filters; while (f) { fn = f->next; - gtk_object_unref((GtkObject *)f->filter); + camel_object_unref((CamelObject *)f->filter); g_free(f); f = fn; } g_free(p->realbuffer); g_free(p); - gtk_object_unref((GtkObject *)filter->source); - - GTK_OBJECT_CLASS (camel_stream_filter_parent)->finalize (o); + camel_object_unref((CamelObject *)filter->source); } -static void -camel_stream_filter_class_init (CamelStreamFilterClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - CamelStreamClass *camel_stream_class = (CamelStreamClass *) klass; - - camel_stream_filter_parent = gtk_type_class (camel_stream_get_type ()); - - object_class->finalize = finalise; - - camel_stream_class->read = do_read; - camel_stream_class->write = do_write; - camel_stream_class->flush = do_flush; - camel_stream_class->close = do_close; - camel_stream_class->eos = do_eos; - camel_stream_class->reset = do_reset; - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -camel_stream_filter_init (CamelStreamFilter *obj) +CamelType +camel_stream_filter_get_type (void) { - struct _CamelStreamFilterPrivate *p; + static CamelType type = CAMEL_INVALID_TYPE; - _PRIVATE(obj) = p = g_malloc0(sizeof(*p)); - p->realbuffer = g_malloc(READ_SIZE + READ_PAD); - p->buffer = p->realbuffer + READ_PAD; - p->last_was_read = TRUE; + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (CAMEL_STREAM_TYPE, "CamelStreamFilter", + sizeof (CamelStreamFilter), + sizeof (CamelStreamFilterClass), + (CamelObjectClassInitFunc) camel_stream_filter_class_init, + NULL, + (CamelObjectInitFunc) camel_stream_filter_init, + (CamelObjectFinalizeFunc) camel_stream_filter_finalize); + } + + return type; } + /** * camel_stream_filter_new: * @@ -148,10 +133,10 @@ camel_stream_filter_init (CamelStreamFilter *obj) CamelStreamFilter * camel_stream_filter_new_with_stream(CamelStream *stream) { - CamelStreamFilter *new = CAMEL_STREAM_FILTER ( gtk_type_new (camel_stream_filter_get_type ())); + CamelStreamFilter *new = CAMEL_STREAM_FILTER ( camel_object_new (camel_stream_filter_get_type ())); new->source = stream; - gtk_object_ref ((GtkObject *)stream); + camel_object_ref ((CamelObject *)stream); return new; } @@ -179,7 +164,7 @@ camel_stream_filter_add(CamelStreamFilter *filter, CamelMimeFilter *mf) fn = g_malloc(sizeof(*fn)); fn->id = p->filterid++; fn->filter = mf; - gtk_object_ref((GtkObject *)mf); + camel_object_ref((CamelObject *)mf); /* sure, we could use a GList, but we wouldn't save much */ f = (struct _filter *)&p->filters; @@ -208,7 +193,7 @@ camel_stream_filter_remove(CamelStreamFilter *filter, int id) fn = f->next; if (fn->id == id) { f->next = fn->next; - gtk_object_unref((GtkObject *)fn->filter); + camel_object_unref((CamelObject *)fn->filter); g_free(fn); } f = f->next; diff --git a/camel/camel-stream-filter.h b/camel/camel-stream-filter.h index 0bc73732ec..d0683135c7 100644 --- a/camel/camel-stream-filter.h +++ b/camel/camel-stream-filter.h @@ -24,9 +24,9 @@ #include <camel/camel-stream.h> #include <camel/camel-mime-filter.h> -#define CAMEL_STREAM_FILTER(obj) GTK_CHECK_CAST (obj, camel_stream_filter_get_type (), CamelStreamFilter) -#define CAMEL_STREAM_FILTER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, camel_stream_filter_get_type (), CamelStreamFilterClass) -#define IS_CAMEL_STREAM_FILTER(obj) GTK_CHECK_TYPE (obj, camel_stream_filter_get_type ()) +#define CAMEL_STREAM_FILTER(obj) CAMEL_CHECK_CAST (obj, camel_stream_filter_get_type (), CamelStreamFilter) +#define CAMEL_STREAM_FILTER_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_stream_filter_get_type (), CamelStreamFilterClass) +#define IS_CAMEL_STREAM_FILTER(obj) CAMEL_CHECK_TYPE (obj, camel_stream_filter_get_type ()) typedef struct _CamelStreamFilterClass CamelStreamFilterClass; diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index b1a7dde41a..17c6b98e08 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -35,7 +35,7 @@ static CamelSeekableStreamClass *parent_class = NULL; /* Returns the class for a CamelStreamFS */ -#define CSFS_CLASS(so) CAMEL_STREAM_FS_CLASS (GTK_OBJECT(so)->klass) +#define CSFS_CLASS(so) CAMEL_STREAM_FS_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n); static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n); @@ -43,7 +43,6 @@ static int stream_flush (CamelStream *stream); static int stream_close (CamelStream *stream); static off_t stream_seek (CamelSeekableStream *stream, off_t offset, CamelStreamSeekPolicy policy); -static void finalize (GtkObject *object); static void camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class) @@ -52,10 +51,8 @@ camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class) CAMEL_SEEKABLE_STREAM_CLASS (camel_stream_fs_class); CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_fs_class); - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_stream_fs_class); - parent_class = gtk_type_class (camel_seekable_stream_get_type ()); + parent_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_type_get_global_classfuncs (camel_seekable_stream_get_type ())); /* virtual method overload */ camel_stream_class->read = stream_read; @@ -64,8 +61,6 @@ camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class) camel_stream_class->close = stream_close; camel_seekable_stream_class->seek = stream_seek; - - gtk_object_class->finalize = finalize; } static void @@ -76,39 +71,32 @@ camel_stream_fs_init (gpointer object, gpointer klass) stream->fd = -1; } -GtkType -camel_stream_fs_get_type (void) -{ - static GtkType camel_stream_fs_type = 0; - - if (!camel_stream_fs_type) { - GtkTypeInfo camel_stream_fs_info = - { - "CamelStreamFs", - sizeof (CamelStreamFs), - sizeof (CamelStreamFsClass), - (GtkClassInitFunc) camel_stream_fs_class_init, - (GtkObjectInitFunc) camel_stream_fs_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_fs_type = gtk_type_unique (camel_seekable_stream_get_type (), &camel_stream_fs_info); - } - - return camel_stream_fs_type; -} - static void -finalize (GtkObject *object) +camel_stream_fs_finalize (CamelObject *object) { CamelStreamFs *stream_fs = CAMEL_STREAM_FS (object); if (stream_fs->fd != -1) close (stream_fs->fd); +} + - GTK_OBJECT_CLASS (parent_class)->finalize (object); +CamelType +camel_stream_fs_get_type (void) +{ + static CamelType camel_stream_fs_type = CAMEL_INVALID_TYPE; + + if (camel_stream_fs_type == CAMEL_INVALID_TYPE) { + camel_stream_fs_type = camel_type_register (camel_seekable_stream_get_type (), "CamelStreamFs", + sizeof (CamelStreamFs), + sizeof (CamelStreamFsClass), + (CamelObjectClassInitFunc) camel_stream_fs_class_init, + NULL, + (CamelObjectInitFunc) camel_stream_fs_init, + (CamelObjectFinalizeFunc) camel_stream_fs_finalize); + } + + return camel_stream_fs_type; } /** @@ -126,7 +114,7 @@ camel_stream_fs_new_with_fd (int fd) CamelStreamFs *stream_fs; off_t offset; - stream_fs = gtk_type_new (camel_stream_fs_get_type ()); + stream_fs = CAMEL_STREAM_FS (camel_object_new (camel_stream_fs_get_type ())); stream_fs->fd = fd; offset = lseek (fd, 0, SEEK_CUR); if (offset == -1) diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h index 08ae49bddf..ea403f584f 100644 --- a/camel/camel-stream-fs.h +++ b/camel/camel-stream-fs.h @@ -41,9 +41,9 @@ extern "C" { #include <fcntl.h> #define CAMEL_STREAM_FS_TYPE (camel_stream_fs_get_type ()) -#define CAMEL_STREAM_FS(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_FS_TYPE, CamelStreamFs)) -#define CAMEL_STREAM_FS_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_FS_TYPE, CamelStreamFsClass)) -#define CAMEL_IS_STREAM_FS(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_FS_TYPE)) +#define CAMEL_STREAM_FS(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_FS_TYPE, CamelStreamFs)) +#define CAMEL_STREAM_FS_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_FS_TYPE, CamelStreamFsClass)) +#define CAMEL_IS_STREAM_FS(o) (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_FS_TYPE)) struct _CamelStreamFs { @@ -57,8 +57,8 @@ typedef struct { } CamelStreamFsClass; -/* Standard Gtk function */ -GtkType camel_stream_fs_get_type (void); +/* Standard Camel function */ +CamelType camel_stream_fs_get_type (void); /* public methods */ CamelStream * camel_stream_fs_new_with_name (const char *name, int flags, mode_t mode); diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c index 08c5e266d4..f5dab54a41 100644 --- a/camel/camel-stream-mem.c +++ b/camel/camel-stream-mem.c @@ -30,10 +30,10 @@ #include <fcntl.h> #include <errno.h> -static CamelStreamClass *parent_class = NULL; +static CamelSeekableStreamClass *parent_class = NULL; /* Returns the class for a CamelStreamMem */ -#define CSM_CLASS(so) CAMEL_STREAM_MEM_CLASS (GTK_OBJECT(so)->klass) +#define CSM_CLASS(so) CAMEL_STREAM_MEM_CLASS(CAMEL_OBJECT_GET_CLASS(so)) static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n); static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n); @@ -41,7 +41,7 @@ static gboolean stream_eos (CamelStream *stream); static off_t stream_seek (CamelSeekableStream *stream, off_t offset, CamelStreamSeekPolicy policy); -static void finalize (GtkObject *object); +static void camel_stream_mem_finalize (CamelObject *object); static void camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class) @@ -50,10 +50,8 @@ camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class) CAMEL_SEEKABLE_STREAM_CLASS (camel_stream_mem_class); CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_mem_class); - GtkObjectClass *gtk_object_class = - GTK_OBJECT_CLASS (camel_stream_mem_class); - parent_class = gtk_type_class (camel_stream_get_type ()); + parent_class = CAMEL_SEEKABLE_STREAM_CLASS( camel_type_get_global_classfuncs( CAMEL_SEEKABLE_STREAM_TYPE ) ); /* virtual method overload */ camel_stream_class->read = stream_read; @@ -61,12 +59,10 @@ camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class) camel_stream_class->eos = stream_eos; camel_seekable_stream_class->seek = stream_seek; - - gtk_object_class->finalize = finalize; } static void -camel_stream_mem_init (gpointer object, gpointer klass) +camel_stream_mem_init (CamelObject *object) { CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (object); @@ -74,25 +70,20 @@ camel_stream_mem_init (gpointer object, gpointer klass) stream_mem->buffer = 0; } -GtkType +CamelType camel_stream_mem_get_type (void) { - static GtkType camel_stream_mem_type = 0; - - if (!camel_stream_mem_type) { - GtkTypeInfo camel_stream_mem_info = - { - "CamelStreamMem", - sizeof (CamelStreamMem), - sizeof (CamelStreamMemClass), - (GtkClassInitFunc) camel_stream_mem_class_init, - (GtkObjectInitFunc) camel_stream_mem_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_mem_type = gtk_type_unique (camel_seekable_stream_get_type (), &camel_stream_mem_info); + static CamelType camel_stream_mem_type = CAMEL_INVALID_TYPE; + + if (camel_stream_mem_type == CAMEL_INVALID_TYPE) { + camel_stream_mem_type = camel_type_register( CAMEL_SEEKABLE_STREAM_TYPE, + "CamelStreamMem", + sizeof( CamelStreamMem ), + sizeof( CamelStreamMemClass ), + (CamelObjectClassInitFunc) camel_stream_mem_class_init, + NULL, + (CamelObjectInitFunc) camel_stream_mem_init, + (CamelObjectFinalizeFunc) camel_stream_mem_finalize ); } return camel_stream_mem_type; @@ -120,7 +111,7 @@ camel_stream_mem_new_with_byte_array (GByteArray *byte_array) { CamelStreamMem *stream_mem; - stream_mem = gtk_type_new (camel_stream_mem_get_type ()); + stream_mem = CAMEL_STREAM_MEM( camel_object_new (CAMEL_STREAM_MEM_TYPE) ); stream_mem->buffer = byte_array; stream_mem->owner = TRUE; @@ -147,14 +138,17 @@ void camel_stream_mem_set_buffer (CamelStreamMem *s, const char *buffer, } static void -finalize (GtkObject *object) +camel_stream_mem_finalize (CamelObject *object) { CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (object); if (stream_mem->buffer && stream_mem->owner) g_byte_array_free (stream_mem->buffer, TRUE); - GTK_OBJECT_CLASS (parent_class)->finalize (object); + /* Will be called automagically in the Camel Type System! + * Wheeee! + * G_TK_OBJECT_CLASS (parent_class)->finalize (object); + */ } static ssize_t diff --git a/camel/camel-stream-mem.h b/camel/camel-stream-mem.h index cf62f09547..b27503efb6 100644 --- a/camel/camel-stream-mem.h +++ b/camel/camel-stream-mem.h @@ -37,9 +37,9 @@ extern "C" { #include <sys/types.h> #define CAMEL_STREAM_MEM_TYPE (camel_stream_mem_get_type ()) -#define CAMEL_STREAM_MEM(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_MEM_TYPE, CamelStreamMem)) -#define CAMEL_STREAM_MEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_MEM_TYPE, CamelStreamMemClass)) -#define CAMEL_IS_STREAM_MEM(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_MEM_TYPE)) +#define CAMEL_STREAM_MEM(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_MEM_TYPE, CamelStreamMem)) +#define CAMEL_STREAM_MEM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_MEM_TYPE, CamelStreamMemClass)) +#define CAMEL_IS_STREAM_MEM(o) (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_MEM_TYPE)) typedef struct _CamelStreamMemClass CamelStreamMemClass; @@ -56,8 +56,8 @@ struct _CamelStreamMemClass { /* Virtual methods */ }; -/* Standard Gtk function */ -GtkType camel_stream_mem_get_type (void); +/* Standard Camel function */ +CamelType camel_stream_mem_get_type (void); /* public methods */ CamelStream *camel_stream_mem_new (void); diff --git a/camel/camel-stream.c b/camel/camel-stream.c index 2cdabacaba..f649494b2d 100644 --- a/camel/camel-stream.c +++ b/camel/camel-stream.c @@ -29,7 +29,7 @@ static CamelObjectClass *parent_class = NULL; /* Returns the class for a CamelStream */ -#define CS_CLASS(so) CAMEL_STREAM_CLASS (GTK_OBJECT(so)->klass) +#define CS_CLASS(so) CAMEL_STREAM_CLASS(CAMEL_OBJECT_GET_CLASS(so)) static int stream_flush (CamelStream *stream); static int stream_close (CamelStream *stream); @@ -39,7 +39,7 @@ static gboolean stream_eos (CamelStream *stream); static void camel_stream_class_init (CamelStreamClass *camel_stream_class) { - parent_class = gtk_type_class (camel_object_get_type ()); + parent_class = camel_type_get_global_classfuncs( CAMEL_OBJECT_TYPE ); /* virtual method definition */ camel_stream_class->flush = stream_flush; @@ -47,26 +47,20 @@ camel_stream_class_init (CamelStreamClass *camel_stream_class) camel_stream_class->eos = stream_eos; } -GtkType +CamelType camel_stream_get_type (void) { - static GtkType camel_stream_type = 0; - - if (!camel_stream_type) { - GtkTypeInfo camel_stream_info = - { - "CamelStream", - sizeof (CamelStream), - sizeof (CamelStreamClass), - (GtkClassInitFunc) camel_stream_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_type = gtk_type_unique (camel_object_get_type (), - &camel_stream_info); + static CamelType camel_stream_type = CAMEL_INVALID_TYPE; + + if (camel_stream_type == CAMEL_INVALID_TYPE) { + camel_stream_type = camel_type_register( CAMEL_OBJECT_TYPE, + "CamelStream", + sizeof( CamelStream ), + sizeof( CamelStreamClass ), + (CamelObjectClassInitFunc) camel_stream_class_init, + NULL, + NULL, + NULL ); } return camel_stream_type; diff --git a/camel/camel-stream.h b/camel/camel-stream.h index 5660ca6e4c..dec4e638e1 100644 --- a/camel/camel-stream.h +++ b/camel/camel-stream.h @@ -38,9 +38,9 @@ extern "C" { #include <unistd.h> #define CAMEL_STREAM_TYPE (camel_stream_get_type ()) -#define CAMEL_STREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_TYPE, CamelStream)) -#define CAMEL_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_TYPE, CamelStreamClass)) -#define CAMEL_IS_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_TYPE)) +#define CAMEL_STREAM(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_TYPE, CamelStream)) +#define CAMEL_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_TYPE, CamelStreamClass)) +#define CAMEL_IS_STREAM(o) (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_TYPE)) struct _CamelStream { @@ -63,8 +63,8 @@ typedef struct { } CamelStreamClass; -/* Standard Gtk function */ -GtkType camel_stream_get_type (void); +/* Standard Camel function */ +CamelType camel_stream_get_type (void); /* public methods */ ssize_t camel_stream_read (CamelStream *stream, char *buffer, size_t n); diff --git a/camel/camel-transport.c b/camel/camel-transport.c index 849248a6e7..ff07728f5f 100644 --- a/camel/camel-transport.c +++ b/camel/camel-transport.c @@ -28,27 +28,21 @@ #include "camel-exception.h" /* Returns the class for a CamelTransport */ -#define CT_CLASS(so) CAMEL_TRANSPORT_CLASS (GTK_OBJECT(so)->klass) +#define CT_CLASS(so) CAMEL_TRANSPORT_CLASS (CAMEL_OBJECT_GET_CLASS(so)) -GtkType +CamelType camel_transport_get_type (void) { - static GtkType camel_transport_type = 0; + static CamelType camel_transport_type = CAMEL_INVALID_TYPE; - if (!camel_transport_type) { - GtkTypeInfo camel_transport_info = - { - "CamelTransport", - sizeof (CamelTransport), - sizeof (CamelTransportClass), - (GtkClassInitFunc) NULL, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_transport_type = gtk_type_unique (CAMEL_SERVICE_TYPE, &camel_transport_info); + if (camel_transport_type == CAMEL_INVALID_TYPE) { + camel_transport_type = camel_type_register (CAMEL_SERVICE_TYPE, "CamelTransport", + sizeof (CamelTransport), + sizeof (CamelTransportClass), + NULL, + NULL, + NULL, + NULL); } return camel_transport_type; diff --git a/camel/camel-transport.h b/camel/camel-transport.h index fc8f0e3076..0b66bd8eac 100644 --- a/camel/camel-transport.h +++ b/camel/camel-transport.h @@ -37,9 +37,9 @@ extern "C" { #include <camel/camel-service.h> #define CAMEL_TRANSPORT_TYPE (camel_transport_get_type ()) -#define CAMEL_TRANSPORT(obj) (GTK_CHECK_CAST((obj), CAMEL_TRANSPORT_TYPE, CamelTransport)) -#define CAMEL_TRANSPORT_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_TRANSPORT_TYPE, CamelTransportClass)) -#define CAMEL_IS_TRANSPORT(o) (GTK_CHECK_TYPE((o), CAMEL_TRANSPORT_TYPE)) +#define CAMEL_TRANSPORT(obj) (CAMEL_CHECK_CAST((obj), CAMEL_TRANSPORT_TYPE, CamelTransport)) +#define CAMEL_TRANSPORT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TRANSPORT_TYPE, CamelTransportClass)) +#define CAMEL_IS_TRANSPORT(o) (CAMEL_CHECK_TYPE((o), CAMEL_TRANSPORT_TYPE)) struct _CamelTransport @@ -75,8 +75,8 @@ gboolean camel_transport_send_to (CamelTransport *transport, GList *recipients, CamelException *ex); -/* Standard Gtk function */ -GtkType camel_transport_get_type (void); +/* Standard Camel function */ +CamelType camel_transport_get_type (void); #ifdef __cplusplus } diff --git a/camel/camel-types.h b/camel/camel-types.h index 62567da1d6..d6813cb863 100644 --- a/camel/camel-types.h +++ b/camel/camel-types.h @@ -46,7 +46,6 @@ typedef struct _CamelMimeParser CamelMimeParser; typedef struct _CamelMimePart CamelMimePart; typedef struct _CamelMultipart CamelMultipart; typedef struct _CamelNewsAddress CamelNewsAddress; -typedef struct _CamelObject CamelObject; typedef struct _CamelSeekableStream CamelSeekableStream; typedef struct _CamelSeekableSubstream CamelSeekableSubstream; typedef struct _CamelService CamelService; 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 @@ -1493,6 +1484,13 @@ imap_search_by_expression (CamelFolder *folder, const char *expression, CamelExc } 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) { const CamelMessageInfo *info; @@ -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 <gtk/gtk.h> #include "camel-folder.h" #include <camel/camel-folder-search.h> #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 <gtk/gtk.h> #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 <sys/types.h> #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 <gtk/gtk.h> #include <camel/camel-folder.h> #include <camel/camel-folder-search.h> #include <libibex/ibex.h> @@ -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 <gtk/gtk.h> #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 <gtk/gtk.h> #include <camel/camel-folder-summary.h> #include <camel/camel-exception.h> #include <libibex/ibex.h> -#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 <gtk/gtk.h> #include <camel/camel-folder.h> #include <camel/camel-folder-search.h> #include <libibex/ibex.h> #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 <gtk/gtk.h> #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 <gtk/gtk.h> - #include "camel-mh-summary.h" #include <camel/camel-mime-message.h> @@ -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 <gtk/gtk.h> #include <camel/camel-folder-summary.h> #include <camel/camel-exception.h> #include <libibex/ibex.h> -#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 <gtk/gtk.h> #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 <gtk/gtk.h> #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 <stdlib.h> #include <string.h> -#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 <gtk/gtk.h> #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 <gtk/gtk.h> #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 <gtk/gtk.h> #include <camel/camel-folder.h> -#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 <gtk/gtk.h> #include <camel/camel-store.h> -#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; |