aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cvsignore23
-rw-r--r--ChangeLog18
-rw-r--r--Makefile.am46
-rw-r--r--calendar/ChangeLog3
-rw-r--r--camel/.cvsignore1
-rw-r--r--camel/ChangeLog170
-rw-r--r--camel/Makefile.am8
-rw-r--r--camel/camel-address.c68
-rw-r--r--camel/camel-address.h6
-rw-r--r--camel/camel-data-wrapper.c66
-rw-r--r--camel/camel-data-wrapper.h10
-rw-r--r--camel/camel-folder-search.c94
-rw-r--r--camel/camel-folder-search.h6
-rw-r--r--camel/camel-folder-summary.c106
-rw-r--r--camel/camel-folder-summary.h6
-rw-r--r--camel/camel-folder.c636
-rw-r--r--camel/camel-folder.h20
-rw-r--r--camel/camel-internet-address.c53
-rw-r--r--camel/camel-internet-address.h6
-rw-r--r--camel/camel-medium.c75
-rw-r--r--camel/camel-medium.h10
-rw-r--r--camel/camel-mime-filter-basic.c86
-rw-r--r--camel/camel-mime-filter-basic.h6
-rw-r--r--camel/camel-mime-filter-charset.c48
-rw-r--r--camel/camel-mime-filter-charset.h6
-rw-r--r--camel/camel-mime-filter-crlf.c28
-rw-r--r--camel/camel-mime-filter-crlf.h8
-rw-r--r--camel/camel-mime-filter-from.c48
-rw-r--r--camel/camel-mime-filter-from.h7
-rw-r--r--camel/camel-mime-filter-index.c50
-rw-r--r--camel/camel-mime-filter-index.h6
-rw-r--r--camel/camel-mime-filter-save.c46
-rw-r--r--camel/camel-mime-filter-save.h6
-rw-r--r--camel/camel-mime-filter.c97
-rw-r--r--camel/camel-mime-filter.h9
-rw-r--r--camel/camel-mime-message.c75
-rw-r--r--camel/camel-mime-message.h10
-rw-r--r--camel/camel-mime-parser.c84
-rw-r--r--camel/camel-mime-parser.h6
-rw-r--r--camel/camel-mime-part-utils.c20
-rw-r--r--camel/camel-mime-part.c82
-rw-r--r--camel/camel-mime-part.h10
-rw-r--r--camel/camel-movemail.c8
-rw-r--r--camel/camel-multipart.c84
-rw-r--r--camel/camel-multipart.h10
-rw-r--r--camel/camel-news-address.c51
-rw-r--r--camel/camel-news-address.h6
-rw-r--r--camel/camel-object.c949
-rw-r--r--camel/camel-object.h138
-rw-r--r--camel/camel-provider.h4
-rw-r--r--camel/camel-seekable-stream.c33
-rw-r--r--camel/camel-seekable-stream.h10
-rw-r--r--camel/camel-seekable-substream.c61
-rw-r--r--camel/camel-seekable-substream.h10
-rw-r--r--camel/camel-service.c74
-rw-r--r--camel/camel-service.h12
-rw-r--r--camel/camel-session.c104
-rw-r--r--camel/camel-session.h32
-rw-r--r--camel/camel-store.c91
-rw-r--r--camel/camel-store.h11
-rw-r--r--camel/camel-stream-buffer.c86
-rw-r--r--camel/camel-stream-buffer.h10
-rw-r--r--camel/camel-stream-filter.c101
-rw-r--r--camel/camel-stream-filter.h6
-rw-r--r--camel/camel-stream-fs.c56
-rw-r--r--camel/camel-stream-fs.h10
-rw-r--r--camel/camel-stream-mem.c52
-rw-r--r--camel/camel-stream-mem.h10
-rw-r--r--camel/camel-stream.c34
-rw-r--r--camel/camel-stream.h10
-rw-r--r--camel/camel-transport.c28
-rw-r--r--camel/camel-transport.h10
-rw-r--r--camel/camel-types.h1
-rw-r--r--camel/providers/Makefile.am1
-rw-r--r--camel/providers/imap/camel-imap-folder.c73
-rw-r--r--camel/providers/imap/camel-imap-folder.h11
-rw-r--r--camel/providers/imap/camel-imap-store.c84
-rw-r--r--camel/providers/imap/camel-imap-store.h12
-rw-r--r--camel/providers/imap/camel-imap-stream.c52
-rw-r--r--camel/providers/imap/camel-imap-stream.h10
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c485
-rw-r--r--camel/providers/mbox/camel-mbox-folder.h11
-rw-r--r--camel/providers/mbox/camel-mbox-store.c34
-rw-r--r--camel/providers/mbox/camel-mbox-store.h11
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c494
-rw-r--r--camel/providers/mbox/camel-mbox-summary.h7
-rw-r--r--camel/providers/mh/camel-mh-folder.c64
-rw-r--r--camel/providers/mh/camel-mh-folder.h11
-rw-r--r--camel/providers/mh/camel-mh-store.c44
-rw-r--r--camel/providers/mh/camel-mh-store.h11
-rw-r--r--camel/providers/mh/camel-mh-summary.c44
-rw-r--r--camel/providers/mh/camel-mh-summary.h9
-rw-r--r--camel/providers/nntp/Makefile.am5
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c52
-rw-r--r--camel/providers/nntp/camel-nntp-folder.h11
-rw-r--r--camel/providers/nntp/camel-nntp-provider.c7
-rw-r--r--camel/providers/nntp/camel-nntp-store.c46
-rw-r--r--camel/providers/nntp/camel-nntp-store.h11
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c42
-rw-r--r--camel/providers/pop3/camel-pop3-folder.h11
-rw-r--r--camel/providers/pop3/camel-pop3-store.c38
-rw-r--r--camel/providers/pop3/camel-pop3-store.h11
-rw-r--r--camel/providers/sendmail/camel-sendmail-transport.c30
-rw-r--r--camel/providers/sendmail/camel-sendmail-transport.h10
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c38
-rw-r--r--camel/providers/smtp/camel-smtp-transport.h10
-rw-r--r--camel/providers/vee/camel-vee-folder.c61
-rw-r--r--camel/providers/vee/camel-vee-folder.h7
-rw-r--r--camel/providers/vee/camel-vee-store.c50
-rw-r--r--camel/providers/vee/camel-vee-store.h7
-rw-r--r--composer/e-msg-composer-attachment.c8
-rw-r--r--composer/e-msg-composer-select-file.c2
-rw-r--r--composer/e-msg-composer.c16
-rw-r--r--composer/main.c2
-rw-r--r--configure.in20
-rw-r--r--filter/ChangeLog26
-rw-r--r--filter/filter-driver.c328
-rw-r--r--filter/filter-driver.h4
-rw-r--r--filter/filter.glade160
-rw-r--r--mail/ChangeLog260
-rw-r--r--mail/Makefile.am12
-rw-r--r--mail/component-factory.c177
-rw-r--r--mail/folder-browser-factory.c2
-rw-r--r--mail/folder-browser.c153
-rw-r--r--mail/folder-browser.h4
-rw-r--r--mail/local-config.glade20
-rw-r--r--mail/mail-config-gui.c12
-rw-r--r--mail/mail-display.c29
-rw-r--r--mail/mail-display.h3
-rw-r--r--mail/mail-format.c66
-rw-r--r--mail/mail-identify.c2
-rw-r--r--mail/mail-local.c319
-rw-r--r--mail/mail-local.h27
-rw-r--r--mail/mail-ops.c2404
-rw-r--r--mail/mail-threads.c1016
-rw-r--r--mail/mail-threads.h48
-rw-r--r--mail/mail-vfolder.c29
-rw-r--r--mail/mail-vfolder.h2
-rw-r--r--mail/mail-view.c144
-rw-r--r--mail/mail.h12
-rw-r--r--mail/main.c6
-rw-r--r--mail/message-list.c387
-rw-r--r--mail/message-list.h1
-rw-r--r--mail/message-thread.c129
-rw-r--r--mail/message-thread.h12
-rw-r--r--mail/session.c92
-rw-r--r--mail/test-thread.c149
-rw-r--r--shell/ChangeLog11
-rw-r--r--shell/evolution-shell-client.c19
149 files changed, 7538 insertions, 4761 deletions
diff --git a/.cvsignore b/.cvsignore
index 00c805b196..282522db03 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,25 +1,2 @@
-ABOUT-NLS
Makefile
Makefile.in
-aclocal.m4
-config.cache
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-configure
-install-sh
-intl
-libtool
-ltconfig
-ltmain.sh
-missing
-mkinstalldirs
-stamp-h
-stamp-h.in
-stamp.h
-xlibtool
-xltmain.sh
-evolution.spec
diff --git a/ChangeLog b/ChangeLog
index 4ddf6a7ee0..b55754d5f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,14 @@
* data/Makefile.am (mime_DATA): add evolution.keys
+2000-08-09 Peter Williams <peterw@helixcode.com>
+
+ * configure.in (EVOLUTION_DIR): Remove the warning about camel-async.
+
+2000-08-08 Peter Williams <peterw@helixcode.com>
+
+ * Makefile.am (SUBDIRS): Reenable the calendar. Oops.
+
2000-08-05 Dan Winship <danw@helixcode.com>
* tools/verify-evolution-install.sh: Look for oafinfo files in
@@ -84,6 +92,11 @@
* calendar/gui/event-editor.c: Typo fix
+2000-07-20 Peter Williams <peterw@helixcode.com>
+
+ * configure.in (THREADS_CFLAGS): Make threads mandatory
+ again.
+
2000-07-19 Fatih Demir <kabalak@gmx.net>
* evolution.desktop & data/evolution.desktop: Added
@@ -97,6 +110,11 @@
(EVOLUTION_DIR): Substitute EVOLUTION_DIR for the top_srcdir.
Added checks for gtk-doc.
+2000-07-13 Peter Williams <peterw@curious-george.helixcode.com>
+
+ * configure.in (end): Bigass warnings for camel-async branch
+ (remove them later).
+
2000-07-12 Federico Mena Quintero <federico@helixcode.com>
* configure.in: Make gnome-print-0.20 mandatory. We will bail out
diff --git a/Makefile.am b/Makefile.am
index a032ebadde..42ffacc264 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,45 +1 @@
-changelogs = \
- ChangeLog
-
-appicondir = $(datadir)/pixmaps
-appicon_DATA = evolution.png
-
-applicationdir = $(datadir)/gnome/apps/Applications
-application_DATA = evolution.desktop
-
-EXTRA_DIST = \
- AUTHORS \
- $(changelogs) \
- README \
- HACKING \
- MAINTAINERS \
- NEWS \
- evolution.spec.in \
- $(appicon_DATA) \
- $(application_DATA)
-
-SUBDIRS = \
- intl \
- macros \
- data \
- e-util \
- widgets \
- shell \
- libibex \
- camel \
- filter \
- composer \
- mail \
- libical \
- libversit \
- addressbook \
- calendar \
- wombat \
- art \
- default_user \
- tools \
- po \
- doc
-
-dist-hook: evolution.spec
- cp evolution.spec $(distdir)
+SUBDIRS = C
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 51cb7a39ab..f09ff0bab0 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -173,6 +173,9 @@
* gui/calendar-model.c: compile fix for Solaris
(works under Linux, too; don't know about others)
+ * this is a test of whether CVS merge does what I
+ think it will do.
+
2000-07-26 Federico Mena Quintero <federico@helixcode.com>
OK, it seems that we have all the interesting properties for
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;
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c
index a0d7398c25..9883640e23 100644
--- a/composer/e-msg-composer-attachment.c
+++ b/composer/e-msg-composer-attachment.c
@@ -74,7 +74,7 @@ destroy (GtkObject *object)
attachment = E_MSG_COMPOSER_ATTACHMENT (object);
- gtk_object_unref (GTK_OBJECT (attachment->body));
+ camel_object_unref (CAMEL_OBJECT (attachment->body));
}
@@ -168,12 +168,12 @@ e_msg_composer_attachment_new (const gchar *file_name)
return NULL;
wrapper = camel_data_wrapper_new ();
camel_data_wrapper_construct_from_stream (wrapper, data);
- gtk_object_unref (GTK_OBJECT (data));
+ camel_object_unref (CAMEL_OBJECT (data));
camel_data_wrapper_set_mime_type (wrapper, get_mime_type (file_name));
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);
- gtk_object_unref (GTK_OBJECT (wrapper));
+ camel_object_unref (CAMEL_OBJECT (wrapper));
camel_mime_part_set_disposition (part, "attachment");
if (strchr (file_name, '/'))
@@ -209,7 +209,7 @@ e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part)
new->editor_gui = NULL;
new->body = part;
- gtk_object_ref (GTK_OBJECT (part));
+ camel_object_ref (CAMEL_OBJECT (part));
new->guessed_type = FALSE;
new->size = 0;
diff --git a/composer/e-msg-composer-select-file.c b/composer/e-msg-composer-select-file.c
index 0fd8a73418..e9f4e421a3 100644
--- a/composer/e-msg-composer-select-file.c
+++ b/composer/e-msg-composer-select-file.c
@@ -160,7 +160,9 @@ e_msg_composer_select_file (EMsgComposer *composer,
gtk_window_set_title (GTK_WINDOW (info->widget), title);
gtk_widget_show (info->widget);
+ GDK_THREADS_ENTER();
gtk_main ();
+ GDK_THREADS_LEAVE();
retval = info->selected_file;
info->selected_file = NULL;
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 0c195a8327..ac22995e28 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -248,13 +248,13 @@ build_message (EMsgComposer *composer)
camel_mime_part_set_content (part, fmt, strlen (fmt), "text/plain");
g_free (fmt);
camel_multipart_add_part (body, part);
- gtk_object_unref (GTK_OBJECT (part));
+ camel_object_unref (CAMEL_OBJECT (part));
part = camel_mime_part_new ();
camel_mime_part_set_content (part, html, strlen (html), "text/html");
g_free (html);
camel_multipart_add_part (body, part);
- gtk_object_unref (GTK_OBJECT (part));
+ camel_object_unref (CAMEL_OBJECT (part));
}
if (e_msg_composer_attachment_bar_get_num_attachments (attachment_bar)) {
@@ -268,7 +268,7 @@ build_message (EMsgComposer *composer)
case MSG_FORMAT_ALTERNATIVE:
camel_medium_set_content_object (CAMEL_MEDIUM (part),
CAMEL_DATA_WRAPPER (body));
- gtk_object_unref (GTK_OBJECT (body));
+ camel_object_unref (CAMEL_OBJECT (body));
break;
case MSG_FORMAT_PLAIN:
camel_mime_part_set_content (part, fmt, strlen (fmt), "text/plain");
@@ -276,30 +276,30 @@ build_message (EMsgComposer *composer)
break;
}
camel_multipart_add_part (multipart, part);
- gtk_object_unref (GTK_OBJECT (part));
+ camel_object_unref (CAMEL_OBJECT (part));
e_msg_composer_attachment_bar_to_multipart (attachment_bar, multipart);
camel_medium_set_content_object (CAMEL_MEDIUM (new), CAMEL_DATA_WRAPPER (multipart));
- gtk_object_unref (GTK_OBJECT (multipart));
+ camel_object_unref (CAMEL_OBJECT (multipart));
} else {
CamelDataWrapper *cdw;
CamelStream *stream;
switch (type) {
case MSG_FORMAT_ALTERNATIVE:
camel_medium_set_content_object (CAMEL_MEDIUM (new), CAMEL_DATA_WRAPPER (body));
- gtk_object_unref (GTK_OBJECT (body));
+ camel_object_unref (CAMEL_OBJECT (body));
break;
case MSG_FORMAT_PLAIN:
stream = camel_stream_mem_new_with_buffer (fmt, strlen (fmt));
cdw = camel_data_wrapper_new ();
camel_data_wrapper_construct_from_stream (cdw, stream);
- gtk_object_unref (GTK_OBJECT (stream));
+ camel_object_unref (CAMEL_OBJECT (stream));
camel_data_wrapper_set_mime_type (cdw, "text/plain");
camel_medium_set_content_object (CAMEL_MEDIUM (new), CAMEL_DATA_WRAPPER (cdw));
- gtk_object_unref (GTK_OBJECT (cdw));
+ camel_object_unref (CAMEL_OBJECT (cdw));
g_free (fmt);
break;
diff --git a/composer/main.c b/composer/main.c
index 9a29e95666..383504d30d 100644
--- a/composer/main.c
+++ b/composer/main.c
@@ -28,7 +28,7 @@ send_cb (EMsgComposer *composer,
stream);
camel_stream_close (stream);
- gtk_object_unref (GTK_OBJECT (message));
+ camel_object_unref (CAMEL_OBJECT (message));
#if 0
gtk_widget_destroy (GTK_WIDGET (composer));
diff --git a/configure.in b/configure.in
index 0beb68b2c2..257b1d0ef9 100644
--- a/configure.in
+++ b/configure.in
@@ -165,31 +165,21 @@ dnl FIXME: support more thread types, pth at least
GNOME_PTHREAD_CHECK
-dnl if test "x$PTHREAD_LIB" = "x" ; then
-dnl AC_MSG_ERROR([POSIX threads are currently required for Evolution])
-dnl fi
+if test "x$PTHREAD_LIB" = "x" ; then
+ AC_MSG_ERROR([POSIX threads are currently required for Evolution])
+fi
dnl
dnl Notice that this is a hack, and we wont be able to use this forever, but
dnl at least for some time
dnl
-dnl THREADS_LIBS="$PTHREAD_LIB `glib-config --libs gthread`"
-dnl THREADS_CFLAGS="`glib-config --cflags gthread`"
+THREADS_LIBS="$PTHREAD_LIB `glib-config --libs gthread`"
+THREADS_CFLAGS="`glib-config --cflags gthread`"
AC_SUBST(THREADS_LIBS)
AC_SUBST(THREADS_CFLAGS)
-AC_ARG_ENABLE([broken-threads],[ --enable-broken-threads Enable the broken threads in evolution-mail],[
- use_bt=$enableval
-],[
- use_bt=no
-])
-
-if test x"$use_bt" = xyes ; then
- AC_DEFINE(USE_BROKEN_THREADS)
-fi
-
dnl **************************************************
dnl * Print check
dnl **************************************************
diff --git a/filter/ChangeLog b/filter/ChangeLog
index aa95acd936..149132854c 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -18,12 +18,22 @@
* filter-context.c (filter_context_create_action): Implement,
helper to aid filter generation.
+2000-08-08 Peter Williams <peterw@helixcode.com>
+
+ * filter-driver.c (close_folder): Fix an accidental GTK unref
+ of a CamelObject.
+
2000-08-03 Ettore Perazzoli <ettore@helixcode.com>
* filter-folder.c (button_clicked): Use the base name of the
Evoluton URI for the button's label.
(get_widget): Likewise.
+2000-08-03 Peter Williams <peterw@helixcode.com>
+
+ * filter-driver.c (op_filter_mail): Conform to the new mail-threads
+ interface.
+
2000-08-01 Not Zed <NotZed@HelixCode.com>
* vfolder-editor.c (rule_add): Oops, create a vfolder_rule when we
@@ -71,6 +81,22 @@
CamelFolder API changes. (delete_message and get_uids don't take
exceptions any more.)
+2000-07-21 Peter Williams <peterw@helixcode.com>
+
+ * filter-driver.c (cleanup_filter_mail): Use the exception
+ provided to us by the async manager instead of allocating
+ our own; use mail_tool_camel_lock_{up,down} around camel
+ operations.
+ (filter_driver_run): Make it return void.
+
+2000-07-20 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * filter-driver.c: Update to make "async".
+
+2000-07-11 Dan Winship <danw@helixcode.com>
+
+ * filter-driver.c: Update for CamelFolder API changes
+
2000-07-11 Jeffrey Stedfast <fejj@helixcode.com>
* filter-driver.c (filter_driver_run): Updated to reflect changes to
diff --git a/filter/filter-driver.c b/filter/filter-driver.c
index 01b64a5eac..20950ad3eb 100644
--- a/filter/filter-driver.c
+++ b/filter/filter-driver.c
@@ -1,7 +1,9 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2000 Helix Code Inc.
*
* Authors: Michael Zucchi <notzed@helixcode.com>
+ * Jeffrey Stedfast <fejj@helixcode.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -30,12 +32,28 @@
#include <gnome-xml/parser.h>
#include <camel/camel.h>
-
+#include "mail/mail-tools.h" /*mail_tool_camel_lock_up*/
#include "filter-context.h"
#include "filter-filter.h"
-
#include "e-util/e-sexp.h"
+/* mail-thread filter input data type */
+typedef struct {
+ FilterDriver *driver;
+ CamelFolder *source;
+ CamelFolder *inbox;
+ gboolean self_destruct;
+ gpointer unhook_func;
+ gpointer unhook_data;
+} filter_mail_input_t;
+
+/* mail-thread filter functions */
+static gchar *describe_filter_mail (gpointer in_data, gboolean gerund);
+static void setup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex);
+static void do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex);
+static void cleanup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex);
+
+
struct _FilterDriverPrivate {
GHashTable *globals; /* global variables */
@@ -68,8 +86,8 @@ static void filter_driver_class_init (FilterDriverClass *klass);
static void filter_driver_init (FilterDriver *obj);
static void filter_driver_finalise (GtkObject *obj);
-static CamelFolder *open_folder(FilterDriver *d, const char *folder_url);
-static int close_folders(FilterDriver *d);
+static CamelFolder *open_folder (FilterDriver *d, const char *folder_url);
+static int close_folders (FilterDriver *d);
static ESExpResult *do_delete(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *);
static ESExpResult *mark_forward(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *);
@@ -138,46 +156,49 @@ filter_driver_init (FilterDriver *obj)
struct _FilterDriverPrivate *p;
int i;
- p = _PRIVATE(obj) = g_malloc0(sizeof(*p));
+ p = _PRIVATE (obj) = g_malloc0 (sizeof (*p));
- p->eval = e_sexp_new();
+ p->eval = e_sexp_new ();
/* Load in builtin symbols */
- for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) {
+ for (i = 0; i < sizeof (symbols) / sizeof (symbols[0]); i++) {
if (symbols[i].type == 1) {
- e_sexp_add_ifunction(p->eval, 0, symbols[i].name, (ESExpIFunc *)symbols[i].func, obj);
+ e_sexp_add_ifunction (p->eval, 0, symbols[i].name, (ESExpIFunc *)symbols[i].func, obj);
} else {
- e_sexp_add_function(p->eval, 0, symbols[i].name, symbols[i].func, obj);
+ e_sexp_add_function (p->eval, 0, symbols[i].name, symbols[i].func, obj);
}
}
- p->globals = g_hash_table_new(g_str_hash, g_str_equal);
+ p->globals = g_hash_table_new (g_str_hash, g_str_equal);
- p->ex = camel_exception_new ();
+ /* Will get set in filter_driver_run */
+ p->ex = NULL;
}
static void
-free_hash_strings(void *key, void *value, void *data)
+free_hash_strings (void *key, void *value, void *data)
{
- g_free(key);
- g_free(value);
+ g_free (key);
+ g_free (value);
}
static void
filter_driver_finalise (GtkObject *obj)
{
- FilterDriver *d = (FilterDriver *)obj;
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ FilterDriver *d = (FilterDriver *) obj;
+ struct _FilterDriverPrivate *p = _PRIVATE (d);
- g_hash_table_foreach(p->globals, free_hash_strings, d);
- g_hash_table_destroy(p->globals);
+ g_hash_table_foreach (p->globals, free_hash_strings, d);
+ g_hash_table_destroy (p->globals);
- gtk_object_unref((GtkObject *)p->eval);
+ gtk_object_unref (GTK_OBJECT (p->eval));
- camel_exception_free(p->ex);
+ /*Was set to the mail_operation_queue exception,
+ * not our responsibility to free it.*/
+ /*camel_exception_free (p->ex);*/
- g_free(p);
+ g_free (p);
- ((GtkObjectClass *)(filter_driver_parent))->finalize((GtkObject *)obj);
+ ((GtkObjectClass *)(filter_driver_parent))->finalize (GTK_OBJECT (obj));
}
/**
@@ -210,61 +231,63 @@ filter_driver_new (FilterContext *context, FilterGetFolderFunc get_folder, void
void filter_driver_set_global(FilterDriver *d, const char *name, const char *value)
{
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ struct _FilterDriverPrivate *p = _PRIVATE (d);
char *oldkey, *oldvalue;
- if (g_hash_table_lookup_extended(p->globals, name, (void *)&oldkey, (void *)&oldvalue)) {
- g_free(oldvalue);
- g_hash_table_insert(p->globals, oldkey, g_strdup(value));
+ if (g_hash_table_lookup_extended (p->globals, name, (void *)&oldkey, (void *)&oldvalue)) {
+ g_free (oldvalue);
+ g_hash_table_insert (p->globals, oldkey, g_strdup (value));
} else {
- g_hash_table_insert(p->globals, g_strdup(name), g_strdup(value));
+ g_hash_table_insert (p->globals, g_strdup (name), g_strdup (value));
}
}
static ESExpResult *
-do_delete(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d)
+do_delete (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver)
{
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
char *uid;
int i;
- printf("doing delete\n");
+ printf ("doing delete\n");
for (i = 0; i < p->matches->len; i++) {
uid = p->matches->pdata[i];
- printf(" %s\n", uid);
+ printf (" %s\n", uid);
- camel_folder_delete_message(p->source, uid);
+ mail_tool_camel_lock_up ();
+ camel_folder_delete_message (p->source, uid);
+ mail_tool_camel_lock_down ();
}
return NULL;
}
static ESExpResult *
-mark_forward(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d)
+mark_forward (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver)
{
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
int i;
- printf("marking the following messages for forwarding:\n");
+ printf ("marking the following messages for forwarding:\n");
for (i = 0; i < p->matches->len; i++) {
- printf(" %s\n", (char *)p->matches->pdata[i]);
+ printf (" %s\n", (char *)p->matches->pdata[i]);
}
return NULL;
}
static ESExpResult *
-mark_copy(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d)
+mark_copy (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver)
{
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
int i, m;
char *uid;
- struct _FilterDriverPrivate *p = _PRIVATE(d);
- printf("marking for copy\n");
+ printf ("marking for copy\n");
for (i = 0; i < argc; i++) {
if (argv[i]->type == ESEXP_RES_STRING) {
char *folder = argv[i]->value.string;
CamelFolder *outbox;
- outbox = open_folder(d, folder);
+ outbox = open_folder (driver, folder);
if (outbox == NULL)
continue;
@@ -272,12 +295,12 @@ mark_copy(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *
gpointer old_key, old_value;
uid = p->matches->pdata[m];
- printf(" %s\n", uid);
+ printf (" %s\n", uid);
- if (g_hash_table_lookup_extended(p->copies, uid, &old_key, &old_value))
- g_hash_table_insert(p->copies, old_key, g_list_prepend(old_value, outbox));
+ if (g_hash_table_lookup_extended (p->copies, uid, &old_key, &old_value))
+ g_hash_table_insert (p->copies, old_key, g_list_prepend (old_value, outbox));
else
- g_hash_table_insert(p->copies, uid, g_list_append(NULL, outbox));
+ g_hash_table_insert (p->copies, uid, g_list_append (NULL, outbox));
}
}
}
@@ -286,17 +309,17 @@ mark_copy(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *
}
static ESExpResult *
-do_stop(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d)
+do_stop (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver)
{
- int i;
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
char *uid;
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ int i;
- printf("doing stop on the following messages:\n");
- for (i=0; i<p->matches->len; i++) {
+ printf ("doing stop on the following messages:\n");
+ for (i = 0; i < p->matches->len; i++) {
uid = p->matches->pdata[i];
- printf(" %s\n", uid);
- g_hash_table_insert(p->terminated, uid, (void *)1);
+ printf (" %s\n", uid);
+ g_hash_table_insert (p->terminated, uid, GINT_TO_POINTER (1));
}
return NULL;
}
@@ -324,56 +347,136 @@ do_colour(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *
}
static CamelFolder *
-open_folder(FilterDriver *d, const char *folder_url)
+open_folder (FilterDriver *driver, const char *folder_url)
{
CamelFolder *camelfolder;
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
/* we have a lookup table of currently open folders */
- camelfolder = g_hash_table_lookup(p->folders, folder_url);
+ camelfolder = g_hash_table_lookup (p->folders, folder_url);
if (camelfolder)
return camelfolder;
- camelfolder = p->get_folder(d, folder_url, p->data);
+ camelfolder = p->get_folder(driver, folder_url, p->data);
+
if (camelfolder) {
- g_hash_table_insert(p->folders, g_strdup(folder_url), camelfolder);
- camel_folder_freeze(camelfolder);
+ g_hash_table_insert (p->folders, g_strdup (folder_url), camelfolder);
+ mail_tool_camel_lock_up ();
+ camel_folder_freeze (camelfolder);
+ mail_tool_camel_lock_down ();
}
return camelfolder;
}
static void
-close_folder(void *key, void *value, void *data)
+close_folder (void *key, void *value, void *data)
{
- CamelFolder *f = value;
- FilterDriver *d = data;
- struct _FilterDriverPrivate *p = _PRIVATE(d);
-
- g_free(key);
- camel_folder_sync(f, FALSE, p->ex);
- camel_folder_thaw(f);
- gtk_object_unref((GtkObject *)f);
+ CamelFolder *folder = value;
+ FilterDriver *driver = data;
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
+
+ g_free (key);
+ mail_tool_camel_lock_up ();
+ camel_folder_sync (folder, FALSE, p->ex);
+ camel_folder_thaw (folder);
+ mail_tool_camel_lock_down ();
+ camel_object_unref (CAMEL_OBJECT (folder));
}
/* flush/close all folders */
static int
-close_folders(FilterDriver *d)
+close_folders (FilterDriver *driver)
{
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
- g_hash_table_foreach(p->folders, close_folder, d);
- g_hash_table_destroy(p->folders);
- p->folders = g_hash_table_new(g_str_hash, g_str_equal);
+ g_hash_table_foreach (p->folders, close_folder, driver);
+ g_hash_table_destroy (p->folders);
+ p->folders = g_hash_table_new (g_str_hash, g_str_equal);
- /* FIXME: status from d */
+ /* FIXME: status from driver */
return 0;
}
-int
-filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox)
+static void
+free_key (gpointer key, gpointer value, gpointer user_data)
{
- struct _FilterDriverPrivate *p = _PRIVATE(d);
+ g_free (key);
+}
+
+static const mail_operation_spec op_filter_mail =
+{
+ describe_filter_mail,
+ 0,
+ setup_filter_mail,
+ do_filter_mail,
+ cleanup_filter_mail
+};
+
+void
+filter_driver_run (FilterDriver *d, CamelFolder *source, CamelFolder *inbox,
+ gboolean self_destruct, gpointer unhook_func, gpointer unhook_data)
+{
+ filter_mail_input_t *input;
+
+ input = g_new (filter_mail_input_t, 1);
+ input->driver = d;
+ input->source = source;
+ input->inbox = inbox;
+ input->self_destruct = self_destruct;
+ input->unhook_func = unhook_func;
+ input->unhook_data = unhook_data;
+
+ mail_operation_queue (&op_filter_mail, input, TRUE);
+}
+
+static gchar *describe_filter_mail (gpointer in_data, gboolean gerund)
+{
+ filter_mail_input_t *input = (filter_mail_input_t *) in_data;
+
+ if (gerund)
+ return g_strdup_printf ("Filtering messages into \"%s\"",
+ input->inbox->full_name);
+ else
+ return g_strdup_printf ("Filter messages into \"%s\"",
+ input->inbox->full_name);
+}
+
+static void
+setup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ filter_mail_input_t *input = (filter_mail_input_t *) in_data;
+
+ if (!input->driver) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Bad filter driver passed to filter_mail");
+ return;
+ }
+
+ if (!CAMEL_IS_FOLDER (input->source)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Bad source folder passed to filter_mail");
+ return;
+ }
+
+ if (!CAMEL_IS_FOLDER (input->inbox)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Bad Inbox passed to filter_mail");
+ return;
+ }
+
+ camel_object_ref (CAMEL_OBJECT (input->source));
+ camel_object_ref (CAMEL_OBJECT (input->inbox));
+}
+
+static void
+do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ filter_mail_input_t *input = (filter_mail_input_t *) in_data;
+ FilterDriver *d = input->driver;
+ CamelFolder *source = input->source;
+ CamelFolder *inbox = input->inbox;
+ struct _FilterDriverPrivate *p = _PRIVATE (d);
ESExpResult *r;
GString *s, *a;
GPtrArray *all;
@@ -391,8 +494,9 @@ filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox)
p->processed = g_hash_table_new(g_str_hash, g_str_equal);
p->copies = g_hash_table_new(g_str_hash, g_str_equal);
- camel_exception_init(p->ex);
+ mail_tool_camel_lock_up ();
camel_folder_freeze(inbox);
+ mail_tool_camel_lock_down ();
s = g_string_new("");
a = g_string_new("");
@@ -407,7 +511,9 @@ filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox)
printf("applying rule %s\n action %s\n", s->str, a->str);
+ mail_tool_camel_lock_up ();
p->matches = camel_folder_search_by_expression (p->source, s->str, p->ex);
+ mail_tool_camel_lock_down ();
/* remove uid's for which processing is complete ... */
for (i = 0; i < p->matches->len; i++) {
@@ -415,13 +521,12 @@ filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox)
#if 0
/* for all matching id's, so we can work out what to default */
- if (g_hash_table_lookup(p->processed, uid) == NULL) {
- g_hash_table_insert(p->processed, uid, (void *)1);
+ if (g_hash_table_lookup (p->processed, uid) == NULL) {
+ g_hash_table_insert (p->processed, uid, GINT_TO_POINTER (1));
}
#endif
-
- if (g_hash_table_lookup(p->terminated, uid)) {
- g_ptr_array_remove_index_fast(p->matches, i);
+ if (g_hash_table_lookup (p->terminated, uid)) {
+ g_ptr_array_remove_index_fast (p->matches, i);
i--;
}
}
@@ -442,52 +547,75 @@ filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox)
* the source. If we have an inbox, anything that didn't get
* processed otherwise goes there.
*/
- all = camel_folder_get_uids(p->source);
+ mail_tool_camel_lock_up ();
+ all = camel_folder_get_uids (p->source);
+ mail_tool_camel_lock_down ();
for (i = 0; i < all->len; i++) {
char *uid = all->pdata[i], *procuid;
GList *copies, *tmp;
CamelMimeMessage *mm;
const CamelMessageInfo *info;
- copies = g_hash_table_lookup(p->copies, uid);
- procuid = g_hash_table_lookup(p->processed, uid);
+ copies = g_hash_table_lookup (p->copies, uid);
+ procuid = g_hash_table_lookup (p->processed, uid);
+
+ mail_tool_camel_lock_up ();
+ info = camel_folder_get_message_info (p->source, uid);
- info = camel_folder_get_message_info(p->source, uid);
-
if (copies || !procuid) {
- mm = camel_folder_get_message(p->source, uid, p->ex);
+ mm = camel_folder_get_message (p->source, uid, p->ex);
while (copies) {
camel_folder_append_message(copies->data, mm, info, p->ex);
tmp = copies->next;
- g_list_free_1(copies);
+ g_list_free_1 (copies);
copies = tmp;
}
if (!procuid) {
+ printf("Applying default rule to message %s\n", uid);
camel_folder_append_message(inbox, mm, info, p->ex);
}
- gtk_object_unref((GtkObject *)mm);
+ camel_object_unref (CAMEL_OBJECT (mm));
}
- camel_folder_delete_message(p->source, uid);
+ camel_folder_delete_message (p->source, uid);
+ mail_tool_camel_lock_down ();
+
}
- camel_folder_free_uids(p->source, all);
+ mail_tool_camel_lock_up ();
+ camel_folder_free_uids (p->source, all);
+ if (input->unhook_func)
+ camel_object_unhook_event (CAMEL_OBJECT (input->inbox), "folder_changed",
+ input->unhook_func, input->unhook_data);
+ mail_tool_camel_lock_down ();
/* now we no longer need our keys */
l = p->searches;
while (l) {
- camel_folder_search_free(p->source, l->data);
+ camel_folder_search_free (p->source, l->data);
l = l->next;
}
- g_list_free(p->searches);
+ g_list_free (p->searches);
+
+ g_hash_table_destroy (p->copies);
+ g_hash_table_destroy (p->processed);
+ g_hash_table_destroy (p->terminated);
+ close_folders (d);
+ g_hash_table_destroy (p->folders);
+ mail_tool_camel_lock_up ();
+ camel_folder_thaw (inbox);
+ mail_tool_camel_lock_down ();
+}
- g_hash_table_destroy(p->copies);
- g_hash_table_destroy(p->processed);
- g_hash_table_destroy(p->terminated);
- close_folders(d);
- g_hash_table_destroy(p->folders);
- camel_folder_thaw(inbox);
+static void
+cleanup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ filter_mail_input_t *input = (filter_mail_input_t *) in_data;
- return 0;
+ camel_object_unref (CAMEL_OBJECT (input->source));
+ camel_object_unref (CAMEL_OBJECT (input->inbox));
+
+ if (input->self_destruct)
+ gtk_object_unref (GTK_OBJECT (input->driver));
}
diff --git a/filter/filter-driver.h b/filter/filter-driver.h
index 9c3b56824a..338243212a 100644
--- a/filter/filter-driver.h
+++ b/filter/filter-driver.h
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <camel/camel-session.h>
#include <camel/camel-folder.h>
+#include <mail/mail-threads.h>
#include "filter-context.h"
@@ -54,7 +55,8 @@ FilterDriver *filter_driver_new (FilterContext *ctx, FilterGetFolderFunc fe
void filter_driver_set_global(FilterDriver *, const char *name, const char *value);*/
/* apply rules to a folder, unmatched messages goto inbox, if not NULL */
-int filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox);
+void filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox,
+ gboolean self_destruct, gpointer unhook_func, gpointer unhook_data);
#if 0
/* generate the search query/action string for a filter option */
diff --git a/filter/filter.glade b/filter/filter.glade
index ff40068aa7..d9b26e4489 100644
--- a/filter/filter.glade
+++ b/filter/filter.glade
@@ -540,4 +540,164 @@ Outgoing
</widget>
</widget>
+<widget>
+ <class>GnomeDialog</class>
+ <name>vfolder_source</name>
+ <type>GTK_WINDOW_TOPLEVEL</type>
+ <position>GTK_WIN_POS_NONE</position>
+ <modal>False</modal>
+ <allow_shrink>False</allow_shrink>
+ <allow_grow>False</allow_grow>
+ <auto_shrink>False</auto_shrink>
+ <auto_close>False</auto_close>
+ <hide_on_close>False</hide_on_close>
+
+ <widget>
+ <class>GtkVBox</class>
+ <child_name>GnomeDialog:vbox</child_name>
+ <name>dialog-vbox3</name>
+ <homogeneous>False</homogeneous>
+ <spacing>8</spacing>
+ <child>
+ <padding>4</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkHButtonBox</class>
+ <child_name>GnomeDialog:action_area</child_name>
+ <name>dialog-action_area3</name>
+ <layout_style>GTK_BUTTONBOX_END</layout_style>
+ <spacing>8</spacing>
+ <child_min_width>85</child_min_width>
+ <child_min_height>27</child_min_height>
+ <child_ipad_x>7</child_ipad_x>
+ <child_ipad_y>0</child_ipad_y>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ <pack>GTK_PACK_END</pack>
+ </child>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button16</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button17</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button18</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkFrame</class>
+ <name>vfolder_source_frame</name>
+ <label>vFolder Sources</label>
+ <label_xalign>0</label_xalign>
+ <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox3</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+
+ <widget>
+ <class>GtkScrolledWindow</class>
+ <name>scrolledwindow3</name>
+ <width>256</width>
+ <height>125</height>
+ <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
+ <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
+ <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
+ <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkViewport</class>
+ <name>viewport3</name>
+ <shadow_type>GTK_SHADOW_IN</shadow_type>
+
+ <widget>
+ <class>GtkList</class>
+ <name>source_list</name>
+ <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox3</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkVButtonBox</class>
+ <name>vbuttonbox3</name>
+ <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
+ <spacing>0</spacing>
+ <child_min_width>85</child_min_width>
+ <child_min_height>27</child_min_height>
+ <child_ipad_x>6</child_ipad_x>
+ <child_ipad_y>0</child_ipad_y>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>source_add</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <label>Add</label>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>source_remove</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <label>Remove</label>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
+</widget>
+
</GTK-Interface>
diff --git a/mail/ChangeLog b/mail/ChangeLog
index e734e79217..17591f38f1 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -9,13 +9,17 @@
assigned in the summary.
(message_list_init_renderers): Init colour column.
+2000-08-09 Peter Williams <peterw@helixcode.com>
+
+ * mail-display.c (part_for_url): Remove a gtk_object_get_data
+
2000-08-09 Cody Russell <bratsche@gnome.org>
* folder-browser-factory.c, mail-view.c: Make the toolbars
honor the user's gnomecc settings for detachable toolbars.
2000-08-09 Jeffrey Stedfast <fejj@helixcode.com>
-
+
* mail-ops.c (composer_send_cb): Get the from address set in the
composer, if that fails ONLY THEN get the default from mail config
@@ -42,7 +46,7 @@
separator between VFolder and Filter stuff.
* mail-ops.c (real_view_msg): Set the UID of the message that is
- being displayed
+ being displayed
2000-08-09 Ettore Perazzoli <ettore@helixcode.com>
@@ -50,6 +54,14 @@
`GNOME_STOCK_MENU_*' things instead of `GNOME_STOCK_PIXMAP_*'
things, that are too big and look bad.
+2000-08-09 Peter Williams <peterw@helixcode.com>
+
+ * mail-view.c (mail_view_create): Save the top window so that on_close
+ can find it [with set_data].
+ (on_close): Recover the top window.
+
+ * mail-threads.c (read_msg): Destroy the window instead of hiding it.
+
2000-08-09 Not Zed <NotZed@HelixCode.com>
* mail-autofilter.c (filter_gui_add_from_message): Helper function
@@ -144,6 +156,38 @@
* mail-view.c: Lets get rid of the last separator in the toolbar
until we add n/p
+2000-08-08 Ettore Perazzoli <ettore@helixcode.com>
+
+ * mail-threads.c (queue_window_delete_event_cb): Callback for
+ "delete_event", just doing nothing.
+ (create_queue_window): Connect it to the "delete_event" signal of
+ the progress dialog.
+
+2000-08-08 Peter Williams <peterw@helixcode.com>
+
+ * mail-threads.c (remove_next_pending): Sanity check for
+ job queue, which seems to have some issues.
+ (read_msg): Make sure that the next operation isn't started
+ before the last one is cleaned up.
+
+ * mail-callbacks.c (fetch_mail): Fix erroneous free.
+
+ * mail-config-gui.c (mail_config_druid): Wrap the gtk_main call.
+
+ * mail-ops.c (do_flag_messages): Allow specification of whether
+ to set the flags unconditionally or toggle their current state.
+
+ * message-list.c (ml_tree_set_value_at): Toggle the seen status;
+ don't set it unconditionally.
+
+ * mail-callbacks.c (delete_msg): Toggle the deletion status;
+ don't set it unconditionally.
+
+ * mail-tools.c (mail_tool_do_movemail): Fix for undeclared tmpfd.
+
+ * mail-local.c (local_reconfigure_folder): Big rewrite; make into
+ an asynchronous operation. Use some mail tools to make life easy.
+
2000-08-08 Dan Winship <danw@helixcode.com>
* main.c (main): Move mail_config_init after session_init, since
@@ -226,6 +270,18 @@
(create_imap_storage): Updated.
(create_news_storage): Updated.
+2000-08-07 Peter Williams <peterw@helixcode.com>
+
+ * mail-ops.c (cleanup_edit_messages): New operation: edit_messages
+ For continuing draft messages.
+ (attach_messages): Fix accidental 0 datasize.
+ (do_setup_draftbox): New operation: setup_draftbox. Soooo hacky.
+
+ * mail-callbacks.c: Move fejj's edit message to the async home.
+
+ * component-factory.c (owner_set_cb): Use mail_do_setup_draftbox.
+
+
2000-08-07 Jeffrey Stedfast <fejj@helixcode.com>
* mail-display.c:
@@ -299,9 +355,35 @@
* folder-browser-factory.c (control_activate): Remove bonobo 0.15
vs 0.15-and-a-half ifdef, since we require post-0.16 now.
+2000-08-04 Dan Winship <danw@helixcode.com>
+
+ * mail-threads.c (mail_operation_wait_for_finish): Don't use
+ "while (gtk_events_pending ()) gtk_main_iteration ();" inside
+ another tight loop, because it makes the thread spin rather than
+ blocking and waiting like it should.
+
2000-08-04 Peter Williams <peterw@helixcode.com>
- * mail-ops.c (move_msg): Fixed a pretty silly uninitialization bug.
+ * message-thread.c (do_thread_messages): Uninitialized variable
+ fix.
+
+ * mail-threads.c (read_msg): Small leak fix.
+
+ * component-factory.c (owner_unset_cb): Use mail_operations_
+ terminate() instead of wait_for_finish().
+
+ * mail-threads.c (mail_operation_queue): Centralize the clur
+ handling functions; fix a race condition where the dispatcher
+ would overwrite the closure before the main thread could
+ free the old one.
+ (mail_operations_terminate): New function, wait for ops to
+ finished and kill the other thread.
+ (dispatch): changes to die when terminate is called (abort
+ on NULL spec).
+
+ * mail-ops.c (cleanup_display_message): Fix improper handling
+ of displaying a NULL message (which means clear the message
+ display).
2000-08-04 Ettore Perazzoli <ettore@helixcode.com>
@@ -337,6 +419,20 @@
2000-08-03 Peter Williams <peterw@helixcode.com>
+ * mail-ops.c (op_forward_messages): Use the new dynamic
+ operation naming.
+
+ * message-thread.c (describe_thread_messages): Ditto.
+
+ * message-list.c (describe_regenerate_messagelist): Ditto.
+
+ * mail-threads.c (get_password_clicked): Dynamic generation
+ of descriptive text for mail operations. "Opening a folder" ->
+ "Opening INBOX". Supported only so far, will be implemented
+ quickly.
+ g_strdup() the old_message when changing the queue_window_label's
+ text.
+
* main.c (main): One more gconf reference to take out...
* mail-ops.c (composer_send_cb): Check for an identity before
@@ -366,6 +462,11 @@
* mail-config-druid.glade: Make the icon background dark blue
like the surrounding area.
+2000-08-02 Peter Williams <peterw@helixcode.com>
+
+ * component-factory.c (owner_unset_cb): Wait for async operations
+ to finish before exiting.
+
2000-08-02 Christopher James Lahey <clahey@helixcode.com>
* mail-ops.c, message-list.c: Emit "model_pre_change" where
@@ -375,6 +476,12 @@
* mail-config.h: #ifdef _MAIL_CONFIG_H protect the header.
+2000-08-01 Peter Williams <peterw@helixcode.com>
+
+ * mail-threads.c: Implement Solaris threads. Attempt
+ to join to the thread upon exit -- hopefully prevents
+ all those nasty zombie processes from popping up :-(
+
2000-08-01 Dan Winship <danw@helixcode.com>
* mail-crypto.c: New code to spawn off GPG/PGP to do stuff.
@@ -591,6 +698,33 @@
(main): More "guess the build mistake" fun, this time for the
failure to initialize Bonobo case.
+2000-07-24 Peter Williams <peterw@helixcode.com>
+
+ * mail-tools.c (mail_tool_set_uid_flags): Change
+ function to faithfully pass parameters to
+ camel_folder_set_message_flags; this function is
+ somewhat useless now. Other files synced with
+ API change.
+
+ * mail-ops.c (op_display_message): Change "display
+ a message" into "retrieve a messsage" in the
+ description of mail_op_display_message.
+
+ * mail-threads.c (display_timeout): New function.
+ Only display the progress dialog if the operation
+ takes more than a second to perform.
+ (hide_queue_window): New function. Hide the queue
+ window as an idle function... I'm thinking maybe
+ the problem with hiding it was due to us not
+ being in a GTK event sequence? Perhaps it's only
+ the timeout, which was not being cancelled, which
+ is now.
+
+ * message-list.c (get_message_uid): New function,
+ copy of get_message_info, except gets only the
+ UID, as that's all that most functions want, and
+ we avoid a Camel call.
+
2000-07-23 Ettore Perazzoli <ettore@helixcode.com>
* mail-ops.c (create_message_composer): New.
@@ -601,6 +735,94 @@
* folder-browser-factory.c (control_activate): Use `_()' instead
of `N_()'.
+2000-07-21 Peter Williams <peterw@helixcode.com>
+
+ * message-thread.c (setup_thread_messages): New
+ operation: thread_messages, simple wrapper around
+ thread_messages () and thread_messages_free();
+
+ * message-list.c (cleanup_regenerate_messagelist):
+ Use new thread_messages operation instead of just
+ calling ... thread_messages :-)
+
+ * folder-browser.c (folder_browser_destroy): Use new
+ sync_folder operation instead of calling camel_folder_sync
+ directly.
+
+ * component-factory.c (create_folder): Changed to use
+ new create_folder operation.
+
+ * mail-ops.c (mail_do_create_folder): New operation: create
+ folder. New operation: sync folder.
+
+ * mail-format.c (cmm_destroyed): Remove the url hashtable from
+ the larger hashtable when it gets destroyed.
+
+ * mail-callbacks.c (fetch_mail): Pass a hook function and data
+ down the chain to pick up the folder_changed and change the view.
+
+ * mail-ops.c: Rename from mail-ops-new.c now that it's a little more
+ solid.
+ (fetch_mail): Add new options to hook and unhook an event while the
+ filter driver runs. A hack, but all of the operations are to some
+ extent.
+ (cleanup_fetch_mail): Unref the destination folder if not NULL.
+ * mail-tools.c (mail_tool_filter_contents_into): Intermediate the
+ event hook/unhook hack here.
+
+2000-07-20 Peter Williams <peterw@helixcode.com>
+
+ * mail-ops-new.c (setup_send_mail): Fix silly forgetting-to-ref
+ problem on some sends (when not replying). Note the early exit
+ path with a big comment.
+
+ * message-list.c (message_list_set_folder): Don't call
+ folder_changed, call mail_do_regenerate_messagelist, as
+ the GDK_THREADS_ENTER in the former can deadlock us!
+
+ * folder-browser.c (folder_browser_set_uri): Ah, screw it.
+ Make 'load folder' asynchronous and pretend that it always
+ succeeds.
+
+ * mail-ops-new.c (mail_do_load_folder): New operation, loads
+ a folder into a FolderBrowser.
+
+ * mail-threads.c (read_msg): Check if the exception is
+ a user cancel; don't complain if it is.
+ (mail_operation_queue): Same.
+ (dispatch_func): Same.
+
+2000-07-20 Peter Williams <peterw@helixcode.com>
+
+ * mail-ops-new.c (cleanup_send_mail): Fix evil mistaken
+ unref.
+
+ * test-thread.c: Fit the new mail_operation_spec prototype.
+
+ * mail-callbacks.c (composer_send_cb): Hide the composer upon
+ start of send operation.
+
+ * folder-browser.c: #include "mail-ops-new.h"
+
+ * mail-threads.h: Change text fields of mail_operation_spec to
+ provide two forms of the name.
+
+ * mail-threads.c: Use appropriate new string fields.
+ (dispatch_func): Hide the progressbar by default.
+
+ * message-list.c (op_regenerate_messagelist): Fix the datasize from
+ 0 -> sizeof (regenerate_messagelist_data_t). Add the new gerund and
+ infinitive strings.
+ (do_regenerate_messagelist): Include some code that fell between the
+ cracks.
+
+ * mail-ops-new.c (op_scan_subfolders): Same datasize fix for
+ scan_subfolders.
+ (op_forward_message): Same.
+ (all): Add new gerund and inifinitive strings for mail_operation_spec.
+ (cleanup_send_mail): Destroy the composer on success; re-show it on
+ error. I'm so clever!
+
2000-07-20 Ettore Perazzoli <ettore@helixcode.com>
* component-factory.c (factory_fn): Updated for the new
@@ -610,6 +832,24 @@
* message-thread.c (thread_messages): What if message info is NULL?
+2000-07-17 Peter Williams <peterw@helixcode.com>
+
+ * component-factory.c (real_create_{imap,news}_storage): Instead of
+ directly calling evolution_storage_new_folder, queue up a list of
+ folders to register so that we don't do our CORBA in The Other Thread.
+ (create_{imap,news}_storage): Changes ancillary to the above.
+ (add_new_mailbox): New function to queue up a folder
+ (cleanup_create_info): New function to dequeue the folders and free mem.
+
+ * test-thread.c: s,ENABLE_BROKEN_THREADS,USE_BROKEN_THREADS -- oops
+
+ * mail-format.c: (mail_lookup_url_table): New function to get the url
+ table associated with a CamelMimeMessage because we can no longer
+ gtk_object_get_data on it.
+
+ * mail-display.c: replace 'gtk_object_get_data( message, "urls" )'
+ with 'mail_lookup_url_table( message )'
+
2000-07-16 Jeffrey Stedfast <fejj@helixcode.com>
* folder-browser.c, component-factory.c: Initial code to support
@@ -622,6 +862,16 @@
Preview]".
(real_send_mail): Call it.
+2000-07-14 Peter Williams <peterw@curious-george.helixcode.com>
+
+ * message-list.c (message_list_set_folder): Ported to CamelObject:
+ GTK_OBJECT->CAMEL_OBJECT; gtk_signal_connect->camel_object_hook_event;
+ GDK_THREADS_ENTER/LEAVE around "changed" event hooks.
+
+ * folder-browser.c (folder_browser_destroy): likewise.
+ (mail_uri_to_folder): likewise.
+ (folder_browser_load_folder): likewise.
+
2000-07-14 Ettore Perazzoli <ettore@helixcode.com>
* Makefile.am (evolution_mail_LDADD): Add `GCONF_LIBS'.
@@ -695,6 +945,10 @@
* mail-display.c (save_data): Change from evolution_dir to
g_get_home_dir() for default location of save file.
+2000-07-11 Dan Winship <danw@helixcode.com>
+
+ * Update for CamelFolder API changes
+
2000-07-11 Jeffrey Stedfast <fejj@helixcode.com>
* mail-ops.c (real_fetch_mail): Changed to use
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 63c15e7e7e..f8f63885ce 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -44,6 +44,7 @@ evolution_mail_SOURCES = \
folder-browser-factory.c \
mail-autofilter.c \
mail-autofilter.h \
+ mail-callbacks.c \
mail-config.c \
mail-config.h \
mail-config-gui.c \
@@ -54,8 +55,11 @@ evolution_mail_SOURCES = \
mail-format.c \
mail-identify.c \
mail-ops.c \
+ mail-ops.h \
mail-threads.c \
mail-threads.h \
+ mail-tools.c \
+ mail-tools.h \
mail-types.h \
mail-vfolder.c \
mail-vfolder.h \
@@ -97,8 +101,12 @@ test_thread_SOURCES = \
mail-threads.h \
test-thread.c
-test_thread_LDADD = \
- $(BONOBO_HTML_GNOME_LIBS) \
+test_thread_LDADD = \
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libibex/libibex.la \
+ $(BONOBO_HTML_GNOME_LIBS) \
+ $(UNICODE_LIBS) \
$(THREADS_LIBS)
test_thread_CFLAGS = -g $(THREADS_CFLAGS)
diff --git a/mail/component-factory.c b/mail/component-factory.c
index e565313901..2a96b11dfe 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -35,7 +35,8 @@
#include "evolution-shell-component.h"
#include "folder-browser.h"
#include "mail.h" /* YUCK FIXME */
-#include "mail-threads.h"
+#include "mail-tools.h"
+#include "mail-ops.h"
#include "e-util/e-gui-utils.h"
#include "e-util/e-setup.h"
@@ -45,7 +46,6 @@ CamelFolder *drafts_folder = NULL;
static void create_vfolder_storage (EvolutionShellComponent *shell_component);
static void create_imap_storage (EvolutionShellComponent *shell_component);
-static void real_create_generic_storage( gpointer user_data );
static void create_news_storage (EvolutionShellComponent *shell_component);
#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"
@@ -97,41 +97,7 @@ create_folder (EvolutionShellComponent *shell_component,
const Evolution_ShellComponentListener listener,
void *closure)
{
- CORBA_Environment ev;
- CamelStore *store;
- CamelFolder *folder;
- CamelException ex;
- Evolution_ShellComponentListener_Result result;
-
- camel_exception_init (&ex);
- if (strcmp (type, "mail") != 0)
- result = Evolution_ShellComponentListener_UNSUPPORTED_TYPE;
- else {
- char *camel_url = g_strdup_printf ("mbox://%s", physical_uri);
-
- store = camel_session_get_store (session, camel_url, &ex);
- g_free (camel_url);
- if (!camel_exception_is_set (&ex)) {
- folder = camel_store_get_folder (store, "mbox",
- TRUE, &ex);
- gtk_object_unref (GTK_OBJECT (store));
- } else {
- folder = NULL;
- }
-
- if (!camel_exception_is_set (&ex)) {
- gtk_object_unref (GTK_OBJECT (folder));
- result = Evolution_ShellComponentListener_OK;
- } else {
- result = Evolution_ShellComponentListener_INVALID_URI;
- }
- }
-
- camel_exception_clear (&ex);
-
- CORBA_exception_init (&ev);
- Evolution_ShellComponentListener_report_result (listener, result, &ev);
- CORBA_exception_free (&ev);
+ mail_do_create_folder (listener, physical_uri, type);
}
static void
@@ -139,27 +105,12 @@ owner_set_cb (EvolutionShellComponent *shell_component,
EvolutionShellClient *shell_client,
gpointer user_data)
{
- CamelException *ex;
- CamelStore *store;
- char *url;
-
g_print ("evolution-mail: Yeeeh! We have an owner!\n"); /* FIXME */
/* GROSS HACK */
/*global_shell_client = shell_client;*/
- ex = camel_exception_new ();
- url = g_strdup_printf ("mbox://%s/local/Drafts", evolution_dir);
- store = camel_session_get_store (session, url, ex);
- g_free (url);
- if (!camel_exception_is_set (ex)) {
- drafts_folder = camel_store_get_folder (store, "mbox", TRUE, ex);
- gtk_object_unref (GTK_OBJECT (store));
- } else {
- drafts_folder = NULL;
- }
- camel_exception_free (ex);
-
+ mail_do_setup_draftbox ();
create_vfolder_storage (shell_component);
create_imap_storage (shell_component);
create_news_storage (shell_component);
@@ -168,6 +119,7 @@ owner_set_cb (EvolutionShellComponent *shell_component,
static void
owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data)
{
+ mail_operations_terminate ();
gtk_main_quit ();
}
@@ -236,11 +188,6 @@ create_vfolder_storage (EvolutionShellComponent *shell_component)
vfolder_create_storage(shell_component);
}
-struct create_info_s {
- EvolutionStorage *storage;
- char *source;
-};
-
static void
create_imap_storage (EvolutionShellComponent *shell_component)
{
@@ -249,15 +196,14 @@ create_imap_storage (EvolutionShellComponent *shell_component)
Evolution_Shell corba_shell;
EvolutionStorage *storage;
char *source = NULL, *server, *p;
- struct create_info_s *ii;
-
+
config = mail_config_fetch ();
if (config->sources) {
const MailConfigService *s;
s = (MailConfigService *)config->sources->data;
source = s->url;
}
-
+
if (!source || g_strncasecmp (source, "imap://", 7))
return;
@@ -276,106 +222,19 @@ create_imap_storage (EvolutionShellComponent *shell_component)
server++;
for (p = server; *p && *p != '/'; p++);
-
+
server = g_strndup (server, (gint)(p - server));
storage = evolution_storage_new (server);
g_free (server);
-
+
if (evolution_storage_register_on_shell (storage, corba_shell) != EVOLUTION_STORAGE_OK) {
g_warning ("Cannot register storage");
g_free (source);
return;
}
-
- ii = g_new (struct create_info_s, 1);
- ii->storage = storage;
- ii->source = g_strdup (source);
-
-#ifdef USE_BROKEN_THREADS
- mail_operation_try ("Create IMAP Storage", real_create_generic_storage, g_free, ii);
-#else
- real_create_generic_storage (ii);
- g_free (ii);
-#endif
- /* Note the g_free as our cleanup function deleting the ii struct when we're done */
-}
-static void
-real_create_generic_storage (gpointer user_data)
-{
- CamelException *ex;
- EvolutionStorage *storage;
- char *source;
- CamelStore *store;
- CamelFolder *folder;
- GPtrArray *lsub;
- int i, max;
- struct create_info_s *ii;
-
- ii = (struct create_info_s *) user_data;
- storage = ii->storage;
- source = ii->source;
-
-#ifdef USE_BROKEN_THREADS
- mail_op_hide_progressbar ();
- mail_op_set_message ("Connecting to service...");
-#endif
- ex = camel_exception_new ();
-
- store = camel_session_get_store (session, source, ex);
- if (!store) {
- goto cleanup;
- }
-
- camel_service_connect (CAMEL_SERVICE (store), ex);
- if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
- goto cleanup;
- }
-
-#ifdef USE_BROKEN_THREADS
- mail_op_set_message ("Connected. Examining folders...");
-#endif
-
- folder = camel_store_get_root_folder (store, ex);
- if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
- goto cleanup;
- }
-
- lsub = camel_folder_get_subfolder_names (folder);
-
- max = lsub->len;
- for (i = 0; i < max; i++) {
- char *path, *buf, *dirname;
-
-#if 0
- if (strcmp (dir_sep, "/")) {
- dirname = e_strreplace ((char *)lsub->pdata[i], dir_sep, "/");
- } else {
- dirname = g_strdup ((char *)lsub->pdata[i]);
- }
-#endif
- dirname = g_strdup ((char *)lsub->pdata[i]);
-
- path = g_strdup_printf ("/%s", dirname);
- g_free (dirname);
- buf = g_strdup_printf ("%s/%s", source, path + 1);
- printf ("buf = %s\n", buf);
-
-#ifdef USE_BROKEN_THREADS
- mail_op_set_message ("Adding %s", path);
-#endif
-
- evolution_storage_new_folder (storage, path, "mail", buf, "description");
- }
-
- cleanup:
- g_free (ii->source);
-#ifdef USE_BROKEN_THREADS
- if (camel_exception_is_set (ex))
- mail_op_error ("%s", camel_exception_get_description (ex));
-#endif
- camel_exception_free (ex);
+ mail_do_scan_subfolders (source, TRUE, storage);
}
static void
@@ -386,7 +245,6 @@ create_news_storage (EvolutionShellComponent *shell_component)
Evolution_Shell corba_shell;
EvolutionStorage *storage;
char *source=NULL, *server, *p;
- struct create_info_s *ni;
config = mail_config_fetch ();
if (config->news) {
@@ -419,16 +277,7 @@ create_news_storage (EvolutionShellComponent *shell_component)
g_free (source);
return;
}
-
- ni = g_new( struct create_info_s, 1 );
- ni->storage = storage;
- ni->source = g_strdup( source );
-
-#ifdef USE_BROKEN_THREADS
- mail_operation_try( "Create News Storage", real_create_generic_storage, g_free, ni );
-#else
- real_create_generic_storage( ni );
- g_free( ni );
-#endif
- /* again note the g_free cleanup func */
+
+ mail_do_scan_subfolders (source, FALSE, storage);
}
+
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index ae170867d1..ba861969e3 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -117,7 +117,7 @@ control_activate (BonoboControl *control, BonoboUIHandler *uih,
NULL, -1,
BONOBO_UI_HANDLER_PIXMAP_NONE,
0,
- 0, 0, providers_config, NULL);
+ 0, 0, mail_config, NULL);
bonobo_ui_handler_menu_new_item (uih, "/Tools/Forget Passwords", _("Forget _Passwords"),
NULL, -1,
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 4eb300214d..60feba556f 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -14,7 +14,10 @@
#include "e-util/e-sexp.h"
#include "folder-browser.h"
#include "mail.h"
+#include "mail-tools.h"
#include "message-list.h"
+#include "mail-threads.h"
+#include "mail-ops.h"
#include <widgets/e-paned/e-vpaned.h>
#include "mail-vfolder.h"
@@ -30,7 +33,6 @@
static GtkObjectClass *folder_browser_parent_class;
-
static void
folder_browser_destroy (GtkObject *object)
{
@@ -48,10 +50,10 @@ folder_browser_destroy (GtkObject *object)
g_free (folder_browser->uri);
if (folder_browser->folder) {
- camel_folder_sync (folder_browser->folder, FALSE, NULL);
- gtk_object_unref (GTK_OBJECT (folder_browser->folder));
+ mail_do_sync_folder (folder_browser->folder);
+ camel_object_unref (CAMEL_OBJECT (folder_browser->folder));
}
-
+
if (folder_browser->message_list)
bonobo_object_unref (BONOBO_OBJECT (folder_browser->message_list));
@@ -66,120 +68,31 @@ folder_browser_class_init (GtkObjectClass *object_class)
folder_browser_parent_class = gtk_type_class (PARENT_TYPE);
}
-CamelFolder *
-mail_uri_to_folder (const char *name)
-{
- char *msg;
- CamelStore *store = NULL;
- CamelFolder *folder = NULL;
- CamelException *ex;
-
- ex = camel_exception_new ();
-
- if (!strncmp (name, "vfolder:", 8)) {
- folder = vfolder_uri_to_folder(name);
- } else if (!strncmp (name, "imap:", 5)) {
- char *service, *ptr;
-
- service = g_strdup_printf ("%s/", name);
- for (ptr = service + 7; *ptr && *ptr != '/'; ptr++);
- ptr++;
- *ptr = '\0';
-
- store = camel_session_get_store (session, service, ex);
- g_free (service);
-
- if (store) {
- CamelURL *url = CAMEL_SERVICE (store)->url;
- char *folder_name;
-
- /*dir_sep = CAMEL_IMAP_STORE (store)->dir_sep;*/
-
- for (ptr = (char *)(name + 7); *ptr && *ptr != '/'; ptr++);
- if (*ptr == '/') {
- if (url && url->path) {
- ptr += strlen (url->path);
- if (*ptr == '/')
- ptr++;
- }
-
- if (*ptr == '/')
- ptr++;
- /*for ( ; *ptr && *ptr == '/'; ptr++);*/
-
- folder_name = g_strdup (ptr);
- /*tree_name = g_strdup (ptr);*/
- /*folder_name = e_strreplace (tree_name, "/", dir_sep);*/
-
- folder = camel_store_get_folder (store, folder_name, TRUE, ex);
- g_free (folder_name);
- }
- }
- } else if (!strncmp(name, "news:", 5)) {
- store = camel_session_get_store (session, name, ex);
- if (store) {
- const char *folder_name;
-
- folder_name = name + 5;
-
- folder = camel_store_get_folder (store, folder_name, FALSE, ex);
- }
- } else if (!strncmp (name, "file:", 5)) {
- folder = local_uri_to_folder(name, ex);
- } else {
- msg = g_strdup_printf ("Can't open URI %s", name);
- gnome_error_dialog (msg);
- g_free (msg);
- }
-
- if (camel_exception_get_id (ex)) {
- msg = g_strdup_printf ("Unable to get folder %s: %s\n", name,
- camel_exception_get_description (ex));
- gnome_error_dialog (msg);
- if (folder) {
- gtk_object_unref (GTK_OBJECT (folder));
- folder = NULL;
- }
- }
- camel_exception_free (ex);
-
- if (store)
- gtk_object_unref (GTK_OBJECT (store));
-
- return folder;
-}
-
-static gboolean
-folder_browser_load_folder (FolderBrowser *fb, const char *name)
-{
- CamelFolder *new_folder;
-
- new_folder = mail_uri_to_folder (name);
- if (!new_folder)
- return FALSE;
-
- if (fb->folder)
- gtk_object_unref (GTK_OBJECT (fb->folder));
- fb->folder = new_folder;
-
- gtk_widget_set_sensitive (GTK_WIDGET (fb->search_entry), camel_folder_has_search_capability (fb->folder));
- gtk_widget_set_sensitive (GTK_WIDGET (fb->search_menu), camel_folder_has_search_capability (fb->folder));
-
- message_list_set_folder (fb->message_list, new_folder);
-
- return TRUE;
-}
+/*
+ * static gboolean
+ * folder_browser_load_folder (FolderBrowser *fb, const char *name)
+ * {
+ * CamelFolder *new_folder;
+ *
+ * new_folder = mail_tool_uri_to_folder_noex (name);
+ *
+ * if (!new_folder)
+ * return FALSE;
+ *
+ * if (fb->folder)
+ * camel_object_unref (CAMEL_OBJECT (fb->folder));
+ * fb->folder = new_folder;
+ * message_list_set_folder (fb->message_list, new_folder);
+ * return TRUE;
+ * }
+ */
#define EQUAL(a,b) (strcmp (a,b) == 0)
-gboolean
-folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri)
+gboolean folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri)
{
- if (folder_browser->uri)
- g_free (folder_browser->uri);
-
- folder_browser->uri = g_strdup (uri);
- return folder_browser_load_folder (folder_browser, folder_browser->uri);
+ mail_do_load_folder (folder_browser, uri);
+ return TRUE;
}
void
@@ -223,7 +136,7 @@ search_set(FolderBrowser *fb)
text = gtk_entry_get_text((GtkEntry *)fb->search_entry);
if (text == NULL || text[0] == 0) {
- message_list_regenerate (fb->message_list, NULL);
+ mail_do_regenerate_messagelist (fb->message_list, NULL);
return;
}
@@ -243,7 +156,7 @@ search_set(FolderBrowser *fb)
str++;
}
}
- message_list_regenerate (fb->message_list, out->str);
+ mail_do_regenerate_messagelist (fb->message_list, out->str);
g_string_free(out, TRUE);
}
@@ -358,7 +271,7 @@ folder_browser_clear_search (FolderBrowser *fb)
{
gtk_entry_set_text (GTK_ENTRY (fb->search_entry), "");
gtk_option_menu_set_history (GTK_OPTION_MENU (fb->search_menu), 0);
- message_list_regenerate (fb->message_list, NULL);
+ mail_do_regenerate_messagelist (fb->message_list, NULL);
}
static int
@@ -481,7 +394,7 @@ my_folder_browser_init (GtkObject *object)
* Our instance data
*/
fb->message_list = MESSAGE_LIST (message_list_new (fb));
- fb->mail_display = MAIL_DISPLAY (mail_display_new (fb));
+ fb->mail_display = MAIL_DISPLAY (mail_display_new ());
gtk_signal_connect (GTK_OBJECT (fb->message_list->etable),
"key_press", GTK_SIGNAL_FUNC (etable_key), fb);
@@ -504,7 +417,3 @@ folder_browser_new (void)
E_MAKE_TYPE (folder_browser, "FolderBrowser", FolderBrowser, folder_browser_class_init, folder_browser_init, PARENT_TYPE);
-
-
-
-
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index 0bc3edf9c8..53bcb5b925 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -57,8 +57,8 @@ typedef struct {
GtkType folder_browser_get_type (void);
GtkWidget *folder_browser_new (void);
-gboolean folder_browser_set_uri (FolderBrowser *folder_browser,
- const char *uri);
+gboolean folder_browser_set_uri (FolderBrowser *folder_browser,
+ const char *uri);
void folder_browser_set_message_preview (FolderBrowser *folder_browser,
gboolean show_message_preview);
void folder_browser_clear_search (FolderBrowser *fb);
diff --git a/mail/local-config.glade b/mail/local-config.glade
index 3601433d78..3eaadbc833 100644
--- a/mail/local-config.glade
+++ b/mail/local-config.glade
@@ -214,26 +214,6 @@ recoverable. Please use this feature with care.</label>
<fill>False</fill>
</child>
</widget>
-
- <widget>
- <class>GtkProgressBar</class>
- <name>progress_format</name>
- <value>0</value>
- <lower>0</lower>
- <upper>100</upper>
- <bar_style>GTK_PROGRESS_CONTINUOUS</bar_style>
- <orientation>GTK_PROGRESS_LEFT_TO_RIGHT</orientation>
- <activity_mode>False</activity_mode>
- <show_text>False</show_text>
- <format>%P %%</format>
- <text_xalign>0.5</text_xalign>
- <text_yalign>0.5</text_yalign>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
</widget>
</widget>
diff --git a/mail/mail-config-gui.c b/mail/mail-config-gui.c
index 12d944e4e3..7ebcb09c6a 100644
--- a/mail/mail-config-gui.c
+++ b/mail/mail-config-gui.c
@@ -1259,7 +1259,9 @@ identity_dialog (const MailConfigIdentity *id, GtkWidget *parent)
GTK_SIGNAL_FUNC (iddialog_ok_clicked),
iddialog);
+ /*GDK_THREADS_ENTER ();*/
gnome_dialog_run_and_close (GNOME_DIALOG (iddialog->dialog));
+ /*GDK_THREADS_LEAVE ();*/
returnid = iddialog->id;
g_free (iddialog);
@@ -1356,7 +1358,9 @@ source_dialog (MailConfigService *source, GtkWidget *parent)
GTK_SIGNAL_FUNC (sdialog_ok_clicked),
sdialog);
+ /*GDK_THREADS_ENTER ();*/
gnome_dialog_run_and_close (GNOME_DIALOG (sdialog->dialog));
+ /*GDK_THREADS_LEAVE ();*/
returnsource = sdialog->source;
g_free (sdialog);
@@ -1452,7 +1456,9 @@ news_dialog (MailConfigService *source, GtkWidget *parent)
GTK_SIGNAL_FUNC (ndialog_ok_clicked),
ndialog);
+ /*GDK_THREADS_ENTER ();*/
gnome_dialog_run_and_close (GNOME_DIALOG (ndialog->dialog));
+ /*GDK_THREADS_LEAVE ();*/
returnsource = ndialog->source;
g_free (ndialog);
@@ -1679,8 +1685,10 @@ mail_config_druid (void)
gtk_signal_connect (GTK_OBJECT (fpage), "finish",
GTK_SIGNAL_FUNC (mail_druid_finish),
dialog);
-
+
+ GDK_THREADS_ENTER ();
gtk_main ();
+ GDK_THREADS_LEAVE ();
}
/* Main configuration dialog */
@@ -2131,7 +2139,9 @@ mail_config (void)
GTK_SIGNAL_FUNC (mail_config_apply_clicked),
dialog);
+ GDK_THREADS_ENTER ();
gnome_dialog_run (GNOME_DIALOG (dialog->dialog));
+ GDK_THREADS_LEAVE ();
/* Clean up */
gtk_object_unref (GTK_OBJECT (gui));
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 9da2dcd4f0..f32887c3de 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -30,6 +30,8 @@
static GtkObjectClass *mail_display_parent_class;
+/* Sigh... gtk_object_set_data is nice to have... */
+extern GHashTable *mail_lookup_url_table (CamelMimeMessage *mime_message);
/*----------------------------------------------------------------------*
* Callbacks
@@ -61,7 +63,9 @@ write_data_to_file (CamelMimePart *part, const char *name, gboolean unique)
gnome_ok_cancel_dialog_modal (
"A file by that name already exists.\nOverwrite it?",
save_data_eexist_cb, &ok);
+ GDK_THREADS_ENTER();
gtk_main ();
+ GDK_THREADS_LEAVE();
if (!ok)
return FALSE;
fd = open (name, O_WRONLY | O_TRUNC);
@@ -86,11 +90,10 @@ write_data_to_file (CamelMimePart *part, const char *name, gboolean unique)
strerror (errno));
gnome_error_dialog (msg);
g_free (msg);
- gtk_object_unref (GTK_OBJECT (stream_fs));
+ camel_object_unref (CAMEL_OBJECT (stream_fs));
return FALSE;
}
- gtk_object_unref (GTK_OBJECT (stream_fs));
-
+ camel_object_unref (CAMEL_OBJECT (stream_fs));
return TRUE;
}
@@ -129,7 +132,7 @@ part_for_url (const char *url, CamelMimeMessage *message)
{
GHashTable *urls;
- urls = gtk_object_get_data (GTK_OBJECT (message), "urls");
+ urls = mail_lookup_url_table (message);
g_return_val_if_fail (urls != NULL, NULL);
return g_hash_table_lookup (urls, url);
}
@@ -252,7 +255,7 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
if (strncmp (eb->classid, "cid:", 4) != 0)
return FALSE;
message = gtk_object_get_data (GTK_OBJECT (html), "message");
- urls = gtk_object_get_data (GTK_OBJECT (message), "urls");
+ urls = mail_lookup_url_table (message);
medium = g_hash_table_lookup (urls, eb->classid);
g_return_val_if_fail (CAMEL_IS_MEDIUM (medium), FALSE);
wrapper = camel_medium_get_content_object (medium);
@@ -283,7 +286,7 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
/* ...convert the CamelStreamMem to a BonoboStreamMem... */
bstream = bonobo_stream_mem_create (ba->data, ba->len, TRUE, FALSE);
- gtk_object_unref (GTK_OBJECT (cstream));
+ camel_object_unref (CAMEL_OBJECT (cstream));
/* ...and hydrate the PersistStream from the BonoboStream. */
CORBA_exception_init (&ev);
@@ -316,7 +319,7 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
GHashTable *urls;
message = gtk_object_get_data (GTK_OBJECT (html), "message");
- urls = gtk_object_get_data (GTK_OBJECT (message), "urls");
+ urls = mail_lookup_url_table (message);
user_data = g_hash_table_lookup (urls, url);
if (user_data == NULL)
@@ -335,7 +338,7 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
stream_mem = camel_stream_mem_new_with_byte_array (ba);
camel_data_wrapper_write_to_stream (data, stream_mem);
gtk_html_write (html, handle, ba->data, ba->len);
- gtk_object_unref (GTK_OBJECT (stream_mem));
+ camel_object_unref (CAMEL_OBJECT (stream_mem));
} else if (strncmp (url, "x-evolution-data:", 17) == 0) {
GByteArray *ba = user_data;
@@ -426,7 +429,7 @@ mail_display_set_message (MailDisplay *mail_display,
/* Clean up from previous message. */
if (mail_display->current_message)
- gtk_object_unref (GTK_OBJECT (mail_display->current_message));
+ camel_object_unref (CAMEL_OBJECT (mail_display->current_message));
mail_display->current_message = (CamelMimeMessage*)medium;
@@ -435,7 +438,7 @@ mail_display_set_message (MailDisplay *mail_display,
"<BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\">\n");
if (medium) {
- gtk_object_ref (GTK_OBJECT (medium));
+ camel_object_ref (CAMEL_OBJECT (medium));
gtk_object_set_data (GTK_OBJECT (mail_display->html),
"message", medium);
mail_format_mime_message (CAMEL_MIME_MESSAGE (medium),
@@ -485,15 +488,11 @@ mail_display_class_init (GtkObjectClass *object_class)
}
GtkWidget *
-mail_display_new (FolderBrowser *parent_folder_browser)
+mail_display_new (void)
{
MailDisplay *mail_display = gtk_type_new (mail_display_get_type ());
GtkWidget *scroll, *html;
- g_assert (parent_folder_browser);
-
- mail_display->parent_folder_browser = parent_folder_browser;
-
gtk_box_set_homogeneous (GTK_BOX (mail_display), FALSE);
gtk_widget_show (GTK_WIDGET (mail_display));
diff --git a/mail/mail-display.h b/mail/mail-display.h
index d839978371..129b059612 100644
--- a/mail/mail-display.h
+++ b/mail/mail-display.h
@@ -25,7 +25,6 @@ struct _MailDisplay {
EScrollFrame *scroll;
GtkHTML *html;
- FolderBrowser *parent_folder_browser;
CamelMimeMessage *current_message;
};
@@ -34,7 +33,7 @@ typedef struct {
} MailDisplayClass;
GtkType mail_display_get_type (void);
-GtkWidget * mail_display_new (FolderBrowser *parent_folder_browser);
+GtkWidget * mail_display_new (void);
void mail_display_set_message (MailDisplay *mail_display,
CamelMedium *medium);
diff --git a/mail/mail-format.c b/mail/mail-format.c
index a96619631f..95d595fef9 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -104,8 +104,38 @@ static void write_headers (CamelMimeMessage *message,
static gboolean call_handler_function (CamelMimePart *part,
struct mail_format_data *mfd);
-static void free_urls (gpointer data);
+/* no gtk_object_set_data, sorry..... */
+
+static GHashTable *cmm_to_urls = NULL;
+
+static void
+free_url (gpointer key, gpointer value, gpointer data)
+{
+ g_free (key);
+}
+
+static void cmm_destroyed (CamelObject *cmm, gpointer event_data, gpointer user_data)
+{
+ GHashTable *ht;
+
+ g_return_if_fail (cmm);
+
+ ht = g_hash_table_lookup (cmm_to_urls, cmm);
+ g_hash_table_foreach (ht, free_url, NULL);
+ g_hash_table_destroy (ht);
+ g_hash_table_insert (cmm_to_urls, cmm, NULL);
+}
+
+GHashTable *mail_lookup_url_table (CamelMimeMessage *mime_message)
+{
+ if (!cmm_to_urls) {
+ cmm_to_urls = g_hash_table_new (g_direct_hash, g_direct_equal);
+ return NULL;
+ }
+
+ return g_hash_table_lookup (cmm_to_urls, mime_message);
+}
/**
* mail_format_mime_message:
@@ -128,32 +158,21 @@ mail_format_mime_message (CamelMimeMessage *mime_message,
mfd.html = html;
mfd.stream = stream;
mfd.root = root;
- mfd.urls = gtk_object_get_data (GTK_OBJECT (root), "urls");
+
+ if (!cmm_to_urls)
+ cmm_to_urls = g_hash_table_new (g_direct_hash, g_direct_equal);
+ mfd.urls = g_hash_table_lookup (cmm_to_urls, root);
+
if (!mfd.urls) {
mfd.urls = g_hash_table_new (g_str_hash, g_str_equal);
- gtk_object_set_data_full (GTK_OBJECT (root), "urls",
- mfd.urls, free_urls);
+ g_hash_table_insert (cmm_to_urls, root, mfd.urls);
+ camel_object_hook_event (CAMEL_OBJECT (root), "finalize", cmm_destroyed, NULL);
}
write_headers (mime_message, &mfd);
call_handler_function (CAMEL_MIME_PART (mime_message), &mfd);
}
-static void
-free_url (gpointer key, gpointer value, gpointer data)
-{
- g_free (key);
-}
-
-static void
-free_urls (gpointer data)
-{
- GHashTable *urls = data;
-
- g_hash_table_foreach (urls, free_url, NULL);
- g_hash_table_destroy (urls);
-}
-
static const char *
get_cid (CamelMimePart *part, struct mail_format_data *mfd)
{
@@ -500,7 +519,7 @@ get_data_wrapper_text (CamelDataWrapper *data)
} else
text = NULL;
- gtk_object_unref (GTK_OBJECT (memstream));
+ camel_object_unref (CAMEL_OBJECT (memstream));
return text;
}
@@ -662,7 +681,7 @@ fake_mime_part_from_data (const char *data, int len, const char *type)
return part;
}
-static void
+ static void
destroy_part (GtkObject *root, GtkObject *part)
{
gtk_object_unref (part);
@@ -787,7 +806,7 @@ try_inline_binhex (char *start, struct mail_format_data *mfd)
}
static void
-free_byte_array (GtkWidget *widget, gpointer user_data)
+free_byte_array (CamelObject *obj, gpointer event_data, gpointer user_data)
{
g_byte_array_free (user_data, TRUE);
}
@@ -946,8 +965,7 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type,
xed = g_strdup_printf ("x-evolution-data:%p", part);
g_hash_table_insert (mfd->urls, xed, ba);
- gtk_signal_connect (GTK_OBJECT (mfd->root), "destroy",
- GTK_SIGNAL_FUNC (free_byte_array), ba);
+ camel_object_hook_event (CAMEL_OBJECT (mfd->root), "finalize", free_byte_array, ba);
mail_html_write (mfd->html, mfd->stream,
"<iframe src=\"%s\" frameborder=0 scrolling=no>"
"</iframe>", xed);
diff --git a/mail/mail-identify.c b/mail/mail-identify.c
index ba8a943f38..91c4efd5d7 100644
--- a/mail/mail-identify.c
+++ b/mail/mail-identify.c
@@ -101,7 +101,7 @@ mail_identify_mime_part (CamelMimePart *part)
gnome_vfs_mime_sniff_buffer_free (sniffer);
} else
type = NULL;
- gtk_object_unref (GTK_OBJECT (memstream));
+ camel_object_unref (CAMEL_OBJECT (memstream));
if (type)
return g_strdup (type);
diff --git a/mail/mail-local.c b/mail/mail-local.c
index 36ae9770a4..840df79f28 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -1,3 +1,29 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* mail-local.c: Local mailbox support. */
+
+/*
+ * Author:
+ * Michael Zucchi <NotZed@helixcode.com>
+ * Peter Williams <peterw@helixcode.com>
+ *
+ * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
/*
code for handling local mail boxes
@@ -24,6 +50,8 @@
#include "mail.h"
#include "mail-local.h"
+#include "mail-tools.h"
+#include "mail-threads.h"
#define d(x)
@@ -105,12 +133,11 @@ save_metainfo(struct _local_meta *meta)
}
CamelFolder *
-local_uri_to_folder(const char *uri, CamelException *ex)
+mail_tool_local_uri_to_folder(const char *uri, CamelException *ex)
{
CamelURL *url;
char *metapath;
char *storename;
- CamelStore *store;
CamelFolder *folder = NULL;
struct _local_meta *meta;
@@ -136,12 +163,7 @@ local_uri_to_folder(const char *uri, CamelException *ex)
printf("store name is %s\n", storename);
- store = camel_session_get_store(session, storename, ex);
- g_free(storename);
- if (store) {
- folder = camel_store_get_folder(store, meta->name, FALSE, ex);
- gtk_object_unref((GtkObject *)store);
- }
+ folder = mail_tool_get_folder_from_urlname (storename, meta->name, ex);
camel_url_free(url);
free_metainfo(meta);
@@ -167,36 +189,86 @@ local_uri_to_folder(const char *uri, CamelException *ex)
*/
-static void update_progress(GtkProgress *progress, char *fmt, float percent)
+static void update_progress(char *fmt, float percent)
{
if (fmt)
- gtk_progress_set_format_string(progress, fmt);
- gtk_progress_set_percentage(progress, percent);
- while( gtk_events_pending() )
- gtk_main_iteration();
+ mail_op_set_message ("%s", fmt);
+ mail_op_set_percentage (percent);
+}
+
+/* ******************** */
+
+typedef struct reconfigure_folder_input_s {
+ FolderBrowser *fb;
+ gchar *newtype;
+ GtkWidget *frame;
+ GtkWidget *apply;
+ GtkWidget *cancel;
+ GtkOptionMenu *optionlist;
+} reconfigure_folder_input_t;
+
+static gchar *describe_reconfigure_folder (gpointer in_data, gboolean gerund);
+static void setup_reconfigure_folder (gpointer in_data, gpointer op_data, CamelException *ex);
+static void do_reconfigure_folder (gpointer in_data, gpointer op_data, CamelException *ex);
+static void cleanup_reconfigure_folder (gpointer in_data, gpointer op_data, CamelException *ex);
+
+static gchar *
+describe_reconfigure_folder (gpointer in_data, gboolean gerund)
+{
+ reconfigure_folder_input_t *input = (reconfigure_folder_input_t *) in_data;
+
+ if (gerund)
+ return g_strdup_printf (_("Changing folder \"%s\" to \"%s\" format"),
+ input->fb->uri,
+ input->newtype);
+ else
+ return g_strdup_printf (_("Change folder \"%s\" to \"%s\" format"),
+ input->fb->uri,
+ input->newtype);
}
static void
-do_local_reconfigure_folder(FolderBrowser *fb, char *newtype, GtkProgress *progress, CamelException *ex)
+setup_reconfigure_folder (gpointer in_data, gpointer op_data, CamelException *ex)
{
- CamelStore *fromstore, *tostore;
- char *fromurl, *tourl, *uri;
- CamelFolder *fromfolder, *tofolder;
- GPtrArray *uids;
- int i;
+ reconfigure_folder_input_t *input = (reconfigure_folder_input_t *) in_data;
+
+ if (!IS_FOLDER_BROWSER (input->fb)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Input has a bad FolderBrowser in reconfigure_folder");
+ return;
+ }
+
+ if (!input->newtype) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No new folder type in reconfigure_folder");
+ return;
+ }
+
+ gtk_object_ref (GTK_OBJECT (input->fb));
+}
+
+static void
+do_reconfigure_folder(gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ reconfigure_folder_input_t *input = (reconfigure_folder_input_t *) in_data;
+
+ CamelStore *fromstore = NULL, *tostore = NULL;
+ char *fromurl = NULL, *tourl = NULL;
+ CamelFolder *fromfolder = NULL, *tofolder = NULL;
+
char *metapath;
char *tmpname;
- CamelURL *url;
+ char *uri;
+ CamelURL *url = NULL;
struct _local_meta *meta;
- printf("reconfiguring folder: %s to type %s\n", fb->uri, newtype);
+ printf("reconfiguring folder: %s to type %s\n", input->fb->uri, input->newtype);
/* get the actual location of the mailbox */
- url = camel_url_new(fb->uri, ex);
- if (url == NULL || camel_exception_is_set(ex)) {
- camel_exception_free(ex);
- g_warning("%s is not a workable url!", fb->uri);
- return;
+ url = camel_url_new(input->fb->uri, ex);
+ if (camel_exception_is_set(ex)) {
+ g_warning("%s is not a workable url!", input->fb->uri);
+ goto cleanup;
}
metapath = g_strdup_printf("%s/local-metadata.xml", url->path);
@@ -204,173 +276,158 @@ do_local_reconfigure_folder(FolderBrowser *fb, char *newtype, GtkProgress *progr
g_free(metapath);
/* first, 'close' the old folder */
- if (fb->folder != NULL) {
- update_progress(progress, "Closing current folder", 0.0);
- printf("Closing old folder ...\n");
- camel_folder_sync(fb->folder, FALSE, ex);
- gtk_object_unref (GTK_OBJECT (fb->folder));
- fb->folder = NULL;
+ if (input->fb->folder != NULL) {
+ update_progress("Closing current folder", 0.0);
+
+ mail_tool_camel_lock_up ();
+ camel_folder_sync(input->fb->folder, FALSE, ex);
+ mail_tool_camel_lock_down ();
+ camel_object_unref (CAMEL_OBJECT (input->fb->folder));
+ input->fb->folder = NULL;
}
camel_url_set_protocol(url, meta->format);
fromurl = camel_url_to_string(url, TRUE);
- camel_url_set_protocol(url, newtype);
+ camel_url_set_protocol(url, input->newtype);
tourl = camel_url_to_string(url, TRUE);
printf("opening stores %s and %s\n", fromurl, tourl);
+
+ mail_tool_camel_lock_up ();
fromstore = camel_session_get_store(session, fromurl, ex);
- if (camel_exception_is_set(ex)) {
- return;
- }
+ mail_tool_camel_lock_down ();
+
+ if (camel_exception_is_set(ex))
+ goto cleanup;
+
+ mail_tool_camel_lock_up ();
tostore = camel_session_get_store(session, tourl, ex);
- if (camel_exception_is_set(ex)) {
- return;
- }
+ mail_tool_camel_lock_down ();
+ if (camel_exception_is_set(ex))
+ goto cleanup;
/* rename the old mbox and open it again */
tmpname = g_strdup_printf("%s_reconfig", meta->name);
- printf("renaming mbox to mboxtmp, and opening it\n");
- update_progress(progress, "Renaming old folder and opening", 0.0);
+ printf("renaming %s to %s, and opening it\n", meta->name, tmpname);
+ update_progress("Renaming old folder and opening", 0.0);
+
+ mail_tool_camel_lock_up ();
camel_store_rename_folder(fromstore, meta->name, tmpname, ex);
if (camel_exception_is_set(ex)) {
- return;
+ mail_tool_camel_lock_down ();
+ goto cleanup;
}
+
fromfolder = camel_store_get_folder(fromstore, tmpname, TRUE, ex);
if (fromfolder == NULL || camel_exception_is_set(ex)) {
/* try and recover ... */
+ camel_exception_clear (ex);
camel_store_rename_folder(fromstore, tmpname, meta->name, ex);
- return;
+ mail_tool_camel_lock_down ();
+ goto cleanup;
}
/* create a new mbox */
printf("Creating the destination mbox\n");
- update_progress(progress, "Creating new folder", 0.0);
+ update_progress("Creating new folder", 0.0);
+
tofolder = camel_store_get_folder(tostore, meta->name, TRUE, ex);
if (tofolder == NULL || camel_exception_is_set(ex)) {
printf("cannot open destination folder\n");
/* try and recover ... */
+ camel_exception_clear (ex);
camel_store_rename_folder(fromstore, tmpname, meta->name, ex);
- return;
+ mail_tool_camel_lock_down ();
+ goto cleanup;
}
- /* copy the messages across */
- uids = camel_folder_get_uids (fromfolder);
- printf("got %d messages in source\n", uids->len);
- update_progress(progress, "Copying messages", 0.0);
- for (i = 0; i < uids->len; i++) {
- CamelMimeMessage *msg;
- char *uid = uids->pdata[i];
- const CamelMessageInfo *info;
-
- update_progress(progress, NULL, i/uids->len);
-
- printf("copying message %s\n", uid);
- msg = camel_folder_get_message(fromfolder, uid, ex);
- if (camel_exception_is_set(ex)) {
- /* we're fucked a bit ... */
- /* need to: delete new folder
- rename old back again */
- g_warning("cannot get message");
- return;
- }
- info = camel_folder_get_message_info(fromfolder, uid);
- camel_folder_append_message(tofolder, msg, info, ex);
- if (camel_exception_is_set(ex)) {
- /* we're fucked a bit ... */
- /* need to: delete new folder
- rename old back again */
- g_warning("cannot append message");
- return;
- }
- gtk_object_unref((GtkObject *)msg);
- }
- update_progress(progress, "Synchronising", 0.0);
+ mail_tool_move_folder_contents (fromfolder, tofolder, FALSE, ex);
- /* sync while we're doing i/o, just to make sure */
- camel_folder_sync(tofolder, FALSE, ex);
- if (camel_exception_is_set(ex)) {
- /* same again */
- }
-
- /* delete everything in the old mailbox */
- printf("deleting old mbox contents\n");
- for (i = 0; i < uids->len; i++) {
- char *uid = uids->pdata[i];
- camel_folder_delete_message(fromfolder, uid);
- }
- camel_folder_sync(fromfolder, TRUE, ex);
- gtk_object_unref((GtkObject *)fromfolder);
- printf("and old mbox ...\n");
+ printf("delete old mbox ...\n");
camel_store_delete_folder(fromstore, tmpname, ex);
+ mail_tool_camel_lock_down ();
/* switch format */
g_free(meta->format);
- meta->format = g_strdup(newtype);
+ meta->format = g_strdup(input->newtype);
if (save_metainfo(meta) == -1) {
- g_warning("Cannot save folder metainfo, you'll probably find you can't\n"
- "open this folder anymore: %s", tourl);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "Cannot save folder metainfo; "
+ "you'll probably find you can't\n"
+ "open this folder anymore: %s", tourl);
}
free_metainfo(meta);
/* force a reload of the newly formatted folder */
printf("opening new source\n");
- uri = g_strdup(fb->uri);
- folder_browser_set_uri(fb, uri);
+ uri = g_strdup(input->fb->uri);
+ folder_browser_set_uri(input->fb, uri);
g_free(uri);
/* and unref our copy of the new folder ... */
- gtk_object_unref((GtkObject *)tofolder);
- g_free(fromurl);
- g_free(tourl);
+ cleanup:
+ if (tofolder)
+ camel_object_unref (CAMEL_OBJECT (tofolder));
+ if (fromfolder)
+ camel_object_unref (CAMEL_OBJECT (fromfolder));
+ if (fromstore)
+ camel_object_unref (CAMEL_OBJECT (fromstore));
+ if (tostore)
+ camel_object_unref (CAMEL_OBJECT (tostore));
+ if (fromurl)
+ g_free(fromurl);
+ if (tourl)
+ g_free(tourl);
+ if (url)
+ camel_url_free (url);
}
-struct _reconfig_data {
- FolderBrowser *fb;
- GtkProgress *progress;
- GtkWidget *frame;
- GtkWidget *apply;
- GtkWidget *cancel;
- GtkOptionMenu *optionlist;
+static void
+cleanup_reconfigure_folder (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ reconfigure_folder_input_t *input = (reconfigure_folder_input_t *) in_data;
+
+ if (camel_exception_is_set(ex)) {
+ GtkWidget *win = gtk_widget_get_ancestor((GtkWidget *)input->frame, GTK_TYPE_WINDOW);
+ gnome_error_dialog_parented ("If you can no longer open this mailbox, then\n"
+ "you may need to repair it manually.", GTK_WINDOW (win));
+ }
+
+ gtk_object_unref (GTK_OBJECT (input->fb));
+ g_free (input->newtype);
+}
+
+static const mail_operation_spec op_reconfigure_folder =
+{
+ describe_reconfigure_folder,
+ 0,
+ setup_reconfigure_folder,
+ do_reconfigure_folder,
+ cleanup_reconfigure_folder
};
static void
-reconfigure_clicked(GnomeDialog *d, int button, struct _reconfig_data *data)
+reconfigure_clicked(GnomeDialog *d, int button, reconfigure_folder_input_t *data)
{
if (button == 0) {
GtkMenu *menu;
int type;
char *types[] = { "mh", "mbox" };
- CamelException *ex;
-
- ex = camel_exception_new();
menu = (GtkMenu *)gtk_option_menu_get_menu(data->optionlist);
type = g_list_index(GTK_MENU_SHELL(menu)->children, gtk_menu_get_active(menu));
if (type < 0 || type > 1)
type = 1;
- gtk_progress_set_percentage(data->progress, 0.0);
gtk_widget_set_sensitive(data->frame, FALSE);
gtk_widget_set_sensitive(data->apply, FALSE);
gtk_widget_set_sensitive(data->cancel, FALSE);
- do_local_reconfigure_folder(data->fb, types[type], data->progress, ex);
- if (camel_exception_is_set(ex)) {
- GtkWidget *win = gtk_widget_get_ancestor((GtkWidget *)d, GTK_TYPE_WINDOW);
- char *error;
-
- error = g_strdup_printf("A failure occured:\n %s\n\n"
- "If you can no longer open this mailbox, then\n"
- "you may need to repair it manually.",
- camel_exception_get_description(ex));
- gnome_error_dialog_parented(error, GTK_WINDOW (win));
- g_free(error);
- }
- camel_exception_free(ex);
+ data->newtype = g_strdup (types[type]);
+ mail_operation_queue (&op_reconfigure_folder, data, TRUE);
}
- if (button != -1) {
+
+ if (button != -1)
gnome_dialog_close(d);
- }
}
void
@@ -379,33 +436,31 @@ local_reconfigure_folder(FolderBrowser *fb)
CamelStore *store;
GladeXML *gui;
GnomeDialog *gd;
- struct _reconfig_data *data;
+ reconfigure_folder_input_t *data;
if (fb->folder == NULL) {
g_warning("Trying to reconfigure nonexistant folder");
return;
}
- data = g_malloc0(sizeof(*data));
+ data = g_new (reconfigure_folder_input_t, 1);
store = camel_folder_get_parent_store(fb->folder);
gui = glade_xml_new(EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format");
gd = (GnomeDialog *)glade_xml_get_widget (gui, "dialog_format");
- data->progress = (GtkProgress *)glade_xml_get_widget (gui, "progress_format");
- gtk_progress_set_show_text(data->progress, TRUE);
data->frame = glade_xml_get_widget (gui, "frame_format");
data->apply = glade_xml_get_widget (gui, "apply_format");
data->cancel = glade_xml_get_widget (gui, "cancel_format");
data->optionlist = (GtkOptionMenu *)glade_xml_get_widget (gui, "option_format");
+ data->newtype = NULL;
data->fb = fb;
gtk_label_set_text((GtkLabel *)glade_xml_get_widget (gui, "label_format"),
((CamelService *)store)->url->protocol);
gtk_signal_connect((GtkObject *)gd, "clicked", reconfigure_clicked, data);
- gtk_object_set_data_full((GtkObject *)gd, "data", data, g_free);
gtk_widget_show((GtkWidget *)gd);
gtk_object_unref((GtkObject *)gui);
}
diff --git a/mail/mail-local.h b/mail/mail-local.h
index f24d3c7a2f..331832cfc8 100644
--- a/mail/mail-local.h
+++ b/mail/mail-local.h
@@ -1,3 +1,28 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* mail-local.h: Local mailbox support. */
+
+/*
+ * Author:
+ * Michael Zucchi <NotZed@helixcode.com>
+ *
+ * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
#ifndef _MAIL_LOCAL_H
#define _MAIL_LOCAL_H
@@ -5,7 +30,7 @@
#include "folder-browser.h"
/* mail-local.c */
-CamelFolder *local_uri_to_folder(const char *uri, CamelException *ex);
+CamelFolder *mail_tool_local_uri_to_folder(const char *uri, CamelException *ex);
void local_reconfigure_folder(FolderBrowser *fb);
#endif
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 77045cb79d..d235c6b2d9 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -2,9 +2,9 @@
/* mail-ops.c: callbacks for the mail toolbar/menus */
/*
- * Authors: Dan Winship <danw@helixcode.com>
- * Jeffrey Stedfast <fejj@helixcode.com>
- * Peter Williams <peterw@helixcode.com>
+ * Author :
+ * Dan Winship <danw@helixcode.com>
+ * Peter Williams <peterw@helixcode.com>
*
* Copyright 2000 Helix Code, Inc. (http://www.helixcode.com)
*
@@ -25,1115 +25,1863 @@
*/
#include <config.h>
-#include <ctype.h>
-#include <errno.h>
#include <gnome.h>
-#include <libgnomeprint/gnome-print-master.h>
-#include <libgnomeprint/gnome-print-master-preview.h>
#include "mail.h"
#include "mail-threads.h"
-#include "folder-browser.h"
+#include "mail-tools.h"
+#include "mail-ops.h"
#include "e-util/e-setup.h"
-#include "filter/filter-editor.h"
-#include "filter/filter-driver.h"
-#include "widgets/e-table/e-table.h"
-#include "mail-local.h"
+#include "composer/e-msg-composer.h"
-/* FIXME: is there another way to do this? */
-#include "Evolution.h"
-#include "evolution-storage.h"
+/* ** FETCH MAIL ********************************************************** */
-#include "evolution-shell-client.h"
-
-#ifndef HAVE_MKSTEMP
-#include <fcntl.h>
-#include <sys/stat.h>
-#endif
+typedef struct fetch_mail_input_s
+{
+ gchar *source_url;
+ gboolean keep_on_server;
+ CamelFolder *destination;
+ gpointer hook_func;
+ gpointer hook_data;
+}
+fetch_mail_input_t;
+
+static gchar *describe_fetch_mail (gpointer in_data, gboolean gerund);
+static void setup_fetch_mail (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_fetch_mail (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_fetch_mail (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_fetch_mail (gpointer in_data, gboolean gerund)
+{
+ fetch_mail_input_t *input = (fetch_mail_input_t *) in_data;
-struct post_send_data {
- CamelFolder *folder;
- const char *uid;
- guint32 flags;
-};
+ if (gerund)
+ return g_strdup_printf ("Fetching email from %s",
+ input->source_url);
+ else
+ return g_strdup_printf ("Fetch email from %s",
+ input->source_url);
+}
-typedef struct rfm_s {
- FolderBrowser *fb;
- MailConfigService *source;
-} rfm_t;
+static void
+setup_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ fetch_mail_input_t *input = (fetch_mail_input_t *) in_data;
-typedef struct rsm_s {
- EMsgComposer *composer;
- CamelTransport *transport;
- CamelMimeMessage *message;
- const char *subject;
- char *from;
- struct post_send_data *psd;
- gboolean ok;
-} rsm_t;
+ if (!input->source_url) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "You have no remote mail source configured "
+ "to fetch mail from.");
+ return;
+ }
-static void
-real_fetch_mail( gpointer user_data );
+ if (input->destination == NULL)
+ return;
-static void
-real_send_mail( gpointer user_data );
+ if (!CAMEL_IS_FOLDER (input->destination)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Bad folder passed to fetch_mail");
+ return;
+ }
-static void
-cleanup_send_mail( gpointer userdata );
+ camel_object_ref (CAMEL_OBJECT (input->destination));
+}
static void
-mail_exception_dialog (char *head, CamelException *ex, gpointer widget)
+do_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex)
{
- char *msg;
- GtkWindow *window =
- GTK_WINDOW (gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW));
+ fetch_mail_input_t *input;
+ CamelFolder *search_folder = NULL;
+
+ input = (fetch_mail_input_t *) in_data;
+
+ if (input->destination == NULL) {
+ input->destination = mail_tool_get_local_inbox (ex);
+
+ if (input->destination == NULL)
+ return;
+ }
- msg = g_strdup_printf ("%s:\n%s", head,
- camel_exception_get_description (ex));
- gnome_error_dialog_parented (msg, window);
- g_free (msg);
+ search_folder =
+ mail_tool_fetch_mail_into_searchable (input->source_url,
+ input->keep_on_server, ex);
+
+ if (search_folder == NULL) {
+ /* This happens with an IMAP source and on error */
+ camel_object_unref (CAMEL_OBJECT (input->destination));
+ input->destination = NULL;
+ return;
+ }
+
+ mail_tool_filter_contents_into (search_folder, input->destination,
+ input->hook_func, input->hook_data,
+ ex);
+ camel_object_unref (CAMEL_OBJECT (search_folder));
}
-#ifdef USE_BROKEN_THREADS
static void
-async_mail_exception_dialog (char *head, CamelException *ex, gpointer unused )
+cleanup_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex)
{
- mail_op_error( "%s: %s", head, camel_exception_get_description( ex ) );
+ fetch_mail_input_t *input = (fetch_mail_input_t *) in_data;
+
+ g_free (input->source_url);
+ if (input->destination)
+ camel_object_unref (CAMEL_OBJECT (input->destination));
}
-#else
-#define async_mail_exception_dialog mail_exception_dialog
-#endif
-static gboolean
-check_configured (void)
+static const mail_operation_spec op_fetch_mail = {
+ describe_fetch_mail,
+ 0,
+ setup_fetch_mail,
+ do_fetch_mail,
+ cleanup_fetch_mail
+};
+
+void
+mail_do_fetch_mail (const gchar * source_url, gboolean keep_on_server,
+ CamelFolder * destination,
+ gpointer hook_func, gpointer hook_data)
{
- if (mail_config_is_configured ())
- return TRUE;
-
- mail_config_druid ();
+ fetch_mail_input_t *input;
- return mail_config_is_configured ();
+ input = g_new (fetch_mail_input_t, 1);
+ input->source_url = g_strdup (source_url);
+ input->keep_on_server = keep_on_server;
+ input->destination = destination;
+ input->hook_func = hook_func;
+ input->hook_data = hook_data;
+
+ mail_operation_queue (&op_fetch_mail, input, TRUE);
}
-static void
-select_first_unread (CamelFolder *folder, int type, gpointer data)
+/* ** SEND MAIL *********************************************************** */
+
+typedef struct send_mail_input_s
{
- FolderBrowser *fb = data;
- ETable *table = E_TABLE_SCROLLED (fb->message_list->etable)->table;
- int mrow;
+ gchar *xport_uri;
+ CamelMimeMessage *message;
+ gchar *from;
+
+ /* If done_folder != NULL, will add done_flags to
+ * the flags of the message done_uid in done_folder. */
- mrow = e_table_view_to_model_row (table, 0);
- message_list_select (fb->message_list, mrow, MESSAGE_LIST_SELECT_NEXT,
- 0, CAMEL_MESSAGE_SEEN);
+ CamelFolder *done_folder;
+ char *done_uid;
+ guint32 done_flags;
+
+ GtkWidget *composer;
}
+send_mail_input_t;
+
+static gchar *describe_send_mail (gpointer in_data, gboolean gerund);
+static void setup_send_mail (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_send_mail (gpointer in_data, gpointer op_data,
+
+ CamelException * ex);
+static void cleanup_send_mail (gpointer in_data, gpointer op_data,
+ CamelException * ex);
-static CamelFolder *
-filter_get_folder(FilterDriver *fd, const char *uri, void *data)
+static gchar *
+describe_send_mail (gpointer in_data, gboolean gerund)
{
- return mail_uri_to_folder(uri);
+ send_mail_input_t *input = (send_mail_input_t *) in_data;
+
+ if (gerund) {
+ if (input->message->subject && input->message->subject[0])
+ return g_strdup_printf ("Sending \"%s\"",
+ input->message->subject);
+ else
+ return
+ g_strdup
+ ("Sending a message without a subject");
+ } else {
+ if (input->message->subject && input->message->subject[0])
+ return g_strdup_printf ("Send \"%s\"",
+ input->message->subject);
+ else
+ return g_strdup ("Send a message without a subject");
+ }
}
static void
-fetch_remote_mail (CamelFolder *source, CamelFolder *dest,
- gboolean keep_on_server, FolderBrowser *fb,
- CamelException *ex)
+setup_send_mail (gpointer in_data, gpointer op_data, CamelException * ex)
{
- CamelUIDCache *cache;
- GPtrArray *uids;
- int i;
+ send_mail_input_t *input = (send_mail_input_t *) in_data;
- uids = camel_folder_get_uids (source);
- if (keep_on_server) {
- GPtrArray *new_uids;
- char *url, *p, *filename;
-
- url = camel_url_to_string (
- CAMEL_SERVICE (source->parent_store)->url, FALSE);
- for (p = url; *p; p++) {
- if (!isascii ((unsigned char)*p) ||
- strchr (" /'\"`&();|<>${}!", *p))
- *p = '_';
- }
- filename = g_strdup_printf ("%s/config/cache-%s",
- evolution_dir, url);
- g_free (url);
-
- cache = camel_uid_cache_new (filename);
- g_free (filename);
- if (cache) {
- new_uids = camel_uid_cache_get_new_uids (cache, uids);
- camel_folder_free_uids (source, uids);
- uids = new_uids;
- } else {
- async_mail_exception_dialog ("Could not read UID "
- "cache file. You may "
- "receive duplicate "
- "messages.", NULL, fb);
- }
- } else
- cache = NULL;
+ if (!input->xport_uri) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No transport URI specified for send_mail operation.");
+ return;
+ }
- printf ("got %d new messages in source\n", uids->len);
- for (i = 0; i < uids->len; i++) {
- CamelMimeMessage *msg;
+ if (!CAMEL_IS_MIME_MESSAGE (input->message)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No message specified for send_mail operation.");
+ return;
+ }
- msg = camel_folder_get_message (source, uids->pdata[i], ex);
- if (camel_exception_is_set (ex)) {
- async_mail_exception_dialog ("Unable to get message",
- ex, fb);
- goto done;
- }
+ if (input->from == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No from address specified for send_mail operation.");
+ return;
+ }
- /* Append with flags = 0 since this is a new message */
- camel_folder_append_message (dest, msg, 0, ex);
- if (camel_exception_is_set (ex)) {
- async_mail_exception_dialog ("Unable to write message",
- ex, fb);
- gtk_object_unref (GTK_OBJECT (msg));
- goto done;
- }
+ /* NOTE THE EARLY EXIT!! */
- if (!cache)
- camel_folder_delete_message (source, uids->pdata[i]);
- gtk_object_unref (GTK_OBJECT (msg));
+ if (input->done_folder == NULL) {
+ camel_object_ref (CAMEL_OBJECT (input->message));
+ gtk_object_ref (GTK_OBJECT (input->composer));
+ gtk_widget_hide (GTK_WIDGET (input->composer));
+ return;
}
- camel_folder_sync (source, TRUE, ex);
+ if (!CAMEL_IS_FOLDER (input->done_folder)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Bad done_folder specified for send_mail operation.");
+ return;
+ }
+
+ if (input->done_uid == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No done_uid specified for send_mail operation.");
+ return;
+ }
+
+ if (!GTK_IS_WIDGET (input->composer)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No composer specified for send_mail operation.");
+ return;
+ }
- done:
- if (cache) {
- camel_uid_cache_free_uids (uids);
- if (!camel_exception_is_set (ex))
- camel_uid_cache_save (cache);
- camel_uid_cache_destroy (cache);
- } else
- camel_folder_free_uids (source, uids);
+ camel_object_ref (CAMEL_OBJECT (input->message));
+ camel_object_ref (CAMEL_OBJECT (input->done_folder));
+ gtk_object_ref (GTK_OBJECT (input->composer));
+ gtk_widget_hide (GTK_WIDGET (input->composer));
}
-void
-real_fetch_mail (gpointer user_data)
-{
- rfm_t *info;
- FolderBrowser *fb = NULL;
- CamelException *ex;
- CamelStore *store = NULL, *dest_store = NULL;
- CamelFolder *folder = NULL, *dest_folder = NULL;
- char *url = NULL, *dest_url;
- FilterContext *fc = NULL;
- FilterDriver *driver = NULL;
- char *userrules, *systemrules;
- char *tmp_mbox = NULL, *source;
- guint handler_id = 0;
- struct stat st;
- gboolean keep;
-
- info = (rfm_t *) user_data;
- fb = info->fb;
- url = info->source->url;
- keep = info->source->keep_on_server;
-
- /* If using IMAP, don't do anything... */
- if (!strncmp (url, "imap:", 5))
+static void
+do_send_mail (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ send_mail_input_t *input = (send_mail_input_t *) in_data;
+ CamelTransport *xport;
+
+ mail_tool_camel_lock_up ();
+ camel_mime_message_set_from (input->message, input->from);
+
+ camel_medium_add_header (CAMEL_MEDIUM (input->message), "X-Mailer",
+ "Evolution (Developer Preview)");
+ camel_mime_message_set_date (input->message,
+ CAMEL_MESSAGE_DATE_CURRENT, 0);
+
+ xport = camel_session_get_transport (session, input->xport_uri, ex);
+ mail_tool_camel_lock_down ();
+ if (camel_exception_is_set (ex))
return;
- ex = camel_exception_new ();
+ mail_tool_send_via_transport (xport, CAMEL_MEDIUM (input->message),
+ ex);
- dest_url = g_strdup_printf ("mbox://%s/local/Inbox", evolution_dir);
- dest_store = camel_session_get_store (session, dest_url, ex);
- g_free (dest_url);
- if (!dest_store) {
- async_mail_exception_dialog ("Unable to get new mail", ex, fb);
- goto cleanup;
- }
-
- dest_folder = camel_store_get_folder (dest_store, "mbox", FALSE, ex);
- if (!dest_folder) {
- async_mail_exception_dialog ("Unable to get new mail", ex, fb);
- goto cleanup;
+ if (camel_exception_is_set (ex))
+ return;
+
+ if (input->done_folder) {
+ guint32 set;
+
+ mail_tool_camel_lock_up ();
+ set = camel_folder_get_message_flags (input->done_folder,
+ input->done_uid);
+ camel_folder_set_message_flags (input->done_folder,
+ input->done_uid,
+ input->done_flags, ~set);
+ mail_tool_camel_lock_down ();
}
+}
- tmp_mbox = g_strdup_printf ("%s/local/Inbox/movemail", evolution_dir);
+static void
+cleanup_send_mail (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ send_mail_input_t *input = (send_mail_input_t *) in_data;
- /* If fetching mail from an mbox store, safely copy it to a
- * temporary store first.
- */
- if (!strncmp (url, "mbox:", 5)) {
- int tmpfd;
+ camel_object_unref (CAMEL_OBJECT (input->message));
+ if (input->done_folder)
+ camel_object_unref (CAMEL_OBJECT (input->done_folder));
- tmpfd = open (tmp_mbox, O_RDWR | O_CREAT | O_APPEND, 0660);
+ g_free (input->from);
+ g_free (input->xport_uri);
+ g_free (input->done_uid);
- if (tmpfd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Couldn't create temporary "
- "mbox: %s", g_strerror (errno));
- async_mail_exception_dialog ("Unable to move mail", ex, fb );
- goto cleanup;
- }
- close (tmpfd);
-
- /* Skip over "mbox:" plus host part (if any) of url. */
- source = url + 5;
- if (!strncmp (source, "//", 2))
- source = strchr (source + 2, '/');
-
- camel_movemail (source, tmp_mbox, ex);
- if (camel_exception_is_set (ex)) {
- async_mail_exception_dialog ("Unable to move mail",
- ex, fb);
- goto cleanup;
- }
+ if (!camel_exception_is_set (ex))
+ gtk_widget_destroy (input->composer);
+ else
+ gtk_widget_show (input->composer);
+}
- if (stat (tmp_mbox, &st) == -1 || st.st_size == 0) {
- gnome_ok_dialog ("No new messages.");
- goto cleanup;
- }
+static const mail_operation_spec op_send_mail = {
+ describe_send_mail,
+ 0,
+ setup_send_mail,
+ do_send_mail,
+ cleanup_send_mail
+};
- folder = camel_store_get_folder (dest_store, "movemail",
- FALSE, ex);
- if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
- async_mail_exception_dialog ("Unable to move mail", ex, fb);
- goto cleanup;
- }
- } else {
- CamelFolder *sourcefolder;
-
- store = camel_session_get_store(session, url, ex);
- if (!store) {
- async_mail_exception_dialog("Unable to get new mail", ex, fb);
- goto cleanup;
- }
-
- camel_service_connect(CAMEL_SERVICE (store), ex);
- if (camel_exception_get_id(ex) != CAMEL_EXCEPTION_NONE) {
- if (camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL)
- async_mail_exception_dialog("Unable to get new mail", ex, fb);
- goto cleanup;
- }
+void
+mail_do_send_mail (const char *xport_uri,
+ CamelMimeMessage * message,
+ const char * from,
+ CamelFolder * done_folder,
+ const char *done_uid,
+ guint32 done_flags, GtkWidget * composer)
+{
+ send_mail_input_t *input;
+
+ input = g_new (send_mail_input_t, 1);
+ input->xport_uri = g_strdup (xport_uri);
+ input->message = message;
+ input->from = g_strdup (from);
+ input->done_folder = done_folder;
+ input->done_uid = g_strdup (done_uid);
+ input->done_flags = done_flags;
+ input->composer = composer;
+
+ mail_operation_queue (&op_send_mail, input, TRUE);
+}
- sourcefolder = camel_store_get_folder(store, "inbox", FALSE, ex);
- if (camel_exception_get_id(ex) != CAMEL_EXCEPTION_NONE) {
- async_mail_exception_dialog("Unable to get new mail", ex, fb);
- goto cleanup;
- }
+/* ** EXPUNGE FOLDER ****************************************************** */
- /* can we perform filtering on this source? */
- if (!(sourcefolder->has_summary_capability
- && sourcefolder->has_search_capability)) {
- folder = camel_store_get_folder (dest_store,
- "movemail", TRUE, ex);
- if (camel_exception_is_set (ex)) {
- async_mail_exception_dialog ("Unable to move mail", ex, fb);
- goto cleanup;
- }
-
- fetch_remote_mail (sourcefolder, folder, keep, fb, ex);
- gtk_object_unref (GTK_OBJECT (sourcefolder));
- if (camel_exception_is_set (ex))
- goto cleanup;
- } else {
- folder = sourcefolder;
- }
- }
+static gchar *describe_expunge_folder (gpointer in_data, gboolean gerund);
+static void setup_expunge_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_expunge_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_expunge_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_expunge_folder (gpointer in_data, gboolean gerund)
+{
+ CamelFolder *f = CAMEL_FOLDER (in_data);
- if (camel_folder_get_message_count (folder) == 0) {
- gnome_ok_dialog ("No new messages.");
- goto cleanup;
- } else if (camel_exception_is_set (ex)) {
- async_mail_exception_dialog ("Unable to get new mail", ex, fb);
- goto cleanup;
+ if (gerund)
+ return g_strdup_printf ("Expunging \"%s\"", f->full_name);
+ else
+ return g_strdup_printf ("Expunge \"%s\"", f->full_name);
+}
+
+static void
+setup_expunge_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ if (!CAMEL_IS_FOLDER (in_data)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder is selected to be expunged");
+ return;
}
- folder_browser_clear_search (fb);
+ camel_object_ref (CAMEL_OBJECT (in_data));
+}
- /* apply filtering rules to this inbox */
- fc = filter_context_new();
- userrules = g_strdup_printf("%s/filters.xml", evolution_dir);
- systemrules = g_strdup_printf("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
- rule_context_load((RuleContext *)fc, systemrules, userrules);
- g_free (userrules);
- g_free (systemrules);
+static void
+do_expunge_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ mail_tool_camel_lock_up ();
+ camel_folder_expunge (CAMEL_FOLDER (in_data), ex);
+ mail_tool_camel_lock_down ();
+}
- driver = filter_driver_new(fc, filter_get_folder, 0);
+static void
+cleanup_expunge_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ camel_object_unref (CAMEL_OBJECT (in_data));
+}
- /* Attach a handler to the destination folder to select the first unread
- * message iff it changes and iff it's the folder being viewed.
- */
- if (dest_folder == fb->folder)
- handler_id = gtk_signal_connect (GTK_OBJECT (dest_folder), "folder_changed",
- GTK_SIGNAL_FUNC (select_first_unread), fb);
+static const mail_operation_spec op_expunge_folder = {
+ describe_expunge_folder,
+ 0,
+ setup_expunge_folder,
+ do_expunge_folder,
+ cleanup_expunge_folder
+};
- if (filter_driver_run(driver, folder, dest_folder) == -1) {
- async_mail_exception_dialog ("Unable to get new mail", ex, fb);
- goto cleanup;
- }
+void
+mail_do_expunge_folder (CamelFolder * folder)
+{
+ mail_operation_queue (&op_expunge_folder, folder, FALSE);
+}
+
+/* ** REFILE MESSAGES ***************************************************** */
- if (dest_folder == fb->folder)
- gtk_signal_disconnect (GTK_OBJECT (dest_folder), handler_id);
+typedef struct refile_messages_input_s
+{
+ CamelFolder *source;
+ GPtrArray *uids;
+ gchar *dest_uri;
+}
+refile_messages_input_t;
+
+static gchar *describe_refile_messages (gpointer in_data, gboolean gerund);
+static void setup_refile_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_refile_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_refile_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_refile_messages (gpointer in_data, gboolean gerund)
+{
+ refile_messages_input_t *input = (refile_messages_input_t *) in_data;
- cleanup:
- if (stat (tmp_mbox, &st) == 0 && st.st_size == 0)
- unlink (tmp_mbox); /* FIXME: should use camel to do this */
- g_free (tmp_mbox);
+ if (gerund)
+ return
+ g_strdup_printf
+ ("Moving messages from \"%s\" into \"%s\"",
+ input->source->full_name, input->dest_uri);
+ else
+ return
+ g_strdup_printf
+ ("Move messages from \"%s\" into \"%s\"",
+ input->source->full_name, input->dest_uri);
+}
- if (driver)
- gtk_object_unref((GtkObject *)driver);
- if (fc)
- gtk_object_unref((GtkObject *)fc);
+static void
+setup_refile_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ refile_messages_input_t *input = (refile_messages_input_t *) in_data;
- if (folder) {
- camel_folder_sync (folder, TRUE, ex);
- gtk_object_unref (GTK_OBJECT (folder));
+ if (!CAMEL_IS_FOLDER (input->source)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No source folder to refile messages from specified.");
+ return;
}
- if (dest_folder) {
- camel_folder_sync (dest_folder, TRUE, ex);
- gtk_object_unref (GTK_OBJECT (dest_folder));
+ if (input->uids == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No messages to refile have been specified.");
+ return;
}
- if (store) {
- camel_service_disconnect (CAMEL_SERVICE (store), ex);
- gtk_object_unref (GTK_OBJECT (store));
+ if (input->dest_uri == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No URI to refile to has been specified.");
+ return;
}
- if (dest_store && dest_store != fb->folder->parent_store) {
- camel_service_disconnect (CAMEL_SERVICE (dest_store), ex);
- gtk_object_unref (GTK_OBJECT (dest_store));
+ camel_object_ref (CAMEL_OBJECT (input->source));
+}
+
+static void
+do_refile_messages (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ refile_messages_input_t *input = (refile_messages_input_t *) in_data;
+ CamelFolder *dest;
+ gint i;
+
+ dest = mail_tool_uri_to_folder (input->dest_uri, ex);
+ if (camel_exception_is_set (ex))
+ return;
+
+ mail_tool_camel_lock_up ();
+ for (i = 0; i < input->uids->len; i++) {
+ camel_folder_move_message_to (input->source,
+ input->uids->pdata[i], dest,
+ ex);
+ g_free (input->uids->pdata[i]);
+ if (camel_exception_is_set (ex))
+ break;
}
- camel_exception_free (ex);
+
+ camel_object_unref (CAMEL_OBJECT (dest));
+ mail_tool_camel_lock_down ();
}
+static void
+cleanup_refile_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ refile_messages_input_t *input = (refile_messages_input_t *) in_data;
+
+ camel_object_unref (CAMEL_OBJECT (input->source));
+ g_free (input->dest_uri);
+ g_ptr_array_free (input->uids, TRUE);
+}
+
+static const mail_operation_spec op_refile_messages = {
+ describe_refile_messages,
+ 0,
+ setup_refile_messages,
+ do_refile_messages,
+ cleanup_refile_messages
+};
+
void
-fetch_mail (GtkWidget *button, gpointer user_data)
+mail_do_refile_messages (CamelFolder * source, GPtrArray * uids,
+ gchar * dest_uri)
{
- MailConfigService *source;
- rfm_t *info;
+ refile_messages_input_t *input;
- if (!check_configured ())
- return;
+ input = g_new (refile_messages_input_t, 1);
+ input->source = source;
+ input->uids = uids;
+ input->dest_uri = g_strdup (dest_uri);
+
+ mail_operation_queue (&op_refile_messages, input, TRUE);
+}
+
+/* ** FLAG MESSAGES ******************************************************* */
- source = mail_config_get_default_source ();
- if (!source || !source->url) {
- GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data),
- GTK_TYPE_WINDOW);
+typedef struct flag_messages_input_s
+{
+ CamelFolder *source;
+ GPtrArray *uids;
+ gboolean invert;
+ guint32 mask;
+ guint32 set;
+}
+flag_messages_input_t;
+
+static gchar *describe_flag_messages (gpointer in_data, gboolean gerund);
+static void setup_flag_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_flag_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_flag_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_flag_messages (gpointer in_data, gboolean gerund)
+{
+ flag_messages_input_t *input = (flag_messages_input_t *) in_data;
+
+ /* FIXME: change based on flags being applied? */
- gnome_error_dialog_parented ("You have no remote mail source "
- "configured", GTK_WINDOW (win));
+ if (gerund)
+ return g_strdup_printf ("Marking messages in folder \"%s\"",
+ input->source->full_name);
+ else
+ return g_strdup_printf ("Mark messages in folder \"%s\"",
+ input->source->full_name);
+}
+
+static void
+setup_flag_messages (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ flag_messages_input_t *input = (flag_messages_input_t *) in_data;
+
+ if (!CAMEL_IS_FOLDER (input->source)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No source folder to flag messages from specified.");
return;
}
- /* This must be dynamically allocated so as not to be clobbered
- * when we return. Actually, making it static in the whole file
- * would probably work.
- */
+ if (input->uids == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No messages to flag have been specified.");
+ return;
+ }
- info = g_new (rfm_t, 1);
- info->fb = FOLDER_BROWSER (user_data);
- info->source = source;
+ camel_object_ref (CAMEL_OBJECT (input->source));
+}
-#ifdef USE_BROKEN_THREADS
- mail_operation_try (_("Fetching mail"), real_fetch_mail, NULL, info);
-#else
- real_fetch_mail (info);
-#endif
+static void
+do_flag_messages (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ flag_messages_input_t *input = (flag_messages_input_t *) in_data;
+ gint i;
+
+ for (i = 0; i < input->uids->len; i++) {
+ if (input->invert) {
+ const CamelMessageInfo *info;
+
+ mail_tool_camel_lock_up ();
+ info = camel_folder_get_message_info (input->source, input->uids->pdata[i]);
+ camel_folder_set_message_flags (input->source, input->uids->pdata[i],
+ input->mask, ~info->flags);
+ mail_tool_camel_lock_down ();
+ } else {
+ mail_tool_set_uid_flags (input->source, input->uids->pdata[i],
+ input->mask, input->set);
+ }
+
+ g_free (input->uids->pdata[i]);
+ }
}
-static gboolean
-ask_confirm_for_empty_subject (EMsgComposer *composer)
+static void
+cleanup_flag_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex)
{
- GtkWidget *message_box;
- int button;
+ flag_messages_input_t *input = (flag_messages_input_t *) in_data;
- message_box = gnome_message_box_new (_("This message has no subject.\nReally send?"),
- GNOME_MESSAGE_BOX_QUESTION,
- GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO,
- NULL);
+ camel_object_unref (CAMEL_OBJECT (input->source));
+ g_ptr_array_free (input->uids, TRUE);
+}
- button = gnome_dialog_run_and_close (GNOME_DIALOG (message_box));
+static const mail_operation_spec op_flag_messages = {
+ describe_flag_messages,
+ 0,
+ setup_flag_messages,
+ do_flag_messages,
+ cleanup_flag_messages
+};
+
+void
+mail_do_flag_messages (CamelFolder * source, GPtrArray * uids,
+ gboolean invert,
+ guint32 mask, guint32 set)
+{
+ flag_messages_input_t *input;
- if (button == 0)
- return TRUE;
+ input = g_new (flag_messages_input_t, 1);
+ input->source = source;
+ input->uids = uids;
+ input->invert = invert;
+ input->mask = mask;
+ input->set = set;
+
+ mail_operation_queue (&op_flag_messages, input, TRUE);
+}
+
+/* ** SCAN SUBFOLDERS ***************************************************** */
+
+typedef struct scan_subfolders_input_s
+{
+ gchar *source_uri;
+ gboolean add_INBOX;
+ EvolutionStorage *storage;
+}
+scan_subfolders_input_t;
+
+typedef struct scan_subfolders_folderinfo_s
+{
+ char *path;
+ char *uri;
+}
+scan_subfolders_folderinfo_t;
+
+typedef struct scan_subfolders_op_s
+{
+ GPtrArray *new_folders;
+}
+scan_subfolders_op_t;
+
+static gchar *describe_scan_subfolders (gpointer in_data, gboolean gerund);
+static void setup_scan_subfolders (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_scan_subfolders (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_scan_subfolders (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_scan_subfolders (gpointer in_data, gboolean gerund)
+{
+ scan_subfolders_input_t *input = (scan_subfolders_input_t *) in_data;
+
+ if (gerund)
+ return g_strdup_printf ("Scanning folders in \"%s\"",
+ input->source_uri);
else
- return FALSE;
+ return g_strdup_printf ("Scan folders in \"%s\"",
+ input->source_uri);
}
static void
-set_x_mailer_header (CamelMedium *medium)
+setup_scan_subfolders (gpointer in_data, gpointer op_data,
+ CamelException * ex)
{
- char *mailer_string;
+ scan_subfolders_input_t *input = (scan_subfolders_input_t *) in_data;
+ scan_subfolders_op_t *data = (scan_subfolders_op_t *) op_data;
- mailer_string = g_strdup_printf ("Evolution %s (Developer Preview)", VERSION);
+ if (!input->source_uri) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No source uri to scan subfolders from was provided.");
+ return;
+ }
- camel_medium_add_header (medium, "X-Mailer", mailer_string);
+ if (!EVOLUTION_IS_STORAGE (input->storage)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No storage to scan subfolders into was provided.");
+ return;
+ }
- g_free (mailer_string);
+ gtk_object_ref (GTK_OBJECT (input->storage));
+ data->new_folders = g_ptr_array_new ();
}
static void
-real_send_mail (gpointer user_data)
+do_scan_subfolders (gpointer in_data, gpointer op_data, CamelException * ex)
{
- rsm_t *info = (rsm_t *) user_data;
- EMsgComposer *composer = NULL;
- CamelTransport *transport = NULL;
- CamelException *ex = NULL;
- CamelMimeMessage *message = NULL;
- const char *subject = NULL;
- char *from = NULL;
- struct post_send_data *psd = NULL;
+ scan_subfolders_input_t *input = (scan_subfolders_input_t *) in_data;
+ scan_subfolders_op_t *data = (scan_subfolders_op_t *) op_data;
-#ifdef USE_BROKEN_THREADS
- mail_op_hide_progressbar ();
- mail_op_set_message ("Connecting to transport...");
-#endif
+ scan_subfolders_folderinfo_t *info;
+ GPtrArray *lsub;
+ CamelFolder *folder;
+ int i;
+ char *splice;
- ex = camel_exception_new ();
- composer = info->composer;
- transport = info->transport;
- message = info->message;
- subject = info->subject;
- from = info->from;
- psd = info->psd;
+ if (input->source_uri[strlen (input->source_uri) - 1] == '/')
+ splice = "";
+ else
+ splice = "/";
- set_x_mailer_header (CAMEL_MEDIUM (message));
+ folder = mail_tool_get_root_of_store (input->source_uri, ex);
+ if (camel_exception_is_set (ex))
+ return;
- camel_mime_message_set_from (message, from);
- camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0);
+ mail_tool_camel_lock_up ();
- camel_service_connect (CAMEL_SERVICE (transport), ex);
+ /* we need a way to set the namespace */
+ lsub = camel_folder_get_subfolder_names (folder);
-#ifdef USE_BROKEN_THREADS
- mail_op_set_message ("Connected. Sending...");
-#endif
+ mail_tool_camel_lock_down ();
- if (!camel_exception_is_set (ex))
- camel_transport_send (transport, CAMEL_MEDIUM (message), ex);
+ if (input->add_INBOX) {
+ info = g_new (scan_subfolders_folderinfo_t, 1);
+ info->path = g_strdup ("/INBOX");
+ info->uri =
+ g_strdup_printf ("%s%sINBOX", input->source_uri,
+ splice);
+ g_ptr_array_add (data->new_folders, info);
+ }
- if (!camel_exception_is_set (ex)) {
-#ifdef USE_BROKEN_THREADS
- mail_op_set_message ("Sent. Disconnecting...");
-#endif
- camel_service_disconnect (CAMEL_SERVICE (transport), ex);
+ for (i = 0; i < lsub->len; i++) {
+ info = g_new (scan_subfolders_folderinfo_t, 1);
+ info->path = g_strdup_printf ("/%s", (char *) lsub->pdata[i]);
+ info->uri =
+ g_strdup_printf ("%s%s%s", input->source_uri, splice,
+ info->path);
+ g_ptr_array_add (data->new_folders, info);
}
- if (camel_exception_is_set (ex)) {
- async_mail_exception_dialog ("Could not send message", ex, composer);
- info->ok = FALSE;
- } else {
- if (psd) {
- camel_folder_set_message_flags (psd->folder, psd->uid,
- psd->flags, psd->flags);
- }
- info->ok = TRUE;
+ camel_folder_free_subfolder_names (folder, lsub);
+ camel_object_unref (CAMEL_OBJECT (folder));
+}
+
+static void
+cleanup_scan_subfolders (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ scan_subfolders_input_t *input = (scan_subfolders_input_t *) in_data;
+ scan_subfolders_op_t *data = (scan_subfolders_op_t *) op_data;
+
+ int i;
+ for (i = 0; i < data->new_folders->len; i++) {
+ scan_subfolders_folderinfo_t *info;
+
+ info = data->new_folders->pdata[i];
+ evolution_storage_new_folder (input->storage,
+ info->path,
+ "mail",
+ info->uri, "(No description)");
+ g_free (info->path);
+ g_free (info->uri);
+ g_free (info);
}
- camel_exception_free (ex);
+ g_ptr_array_free (data->new_folders, TRUE);
+ gtk_object_unref (GTK_OBJECT (input->storage));
+ g_free (input->source_uri);
+}
+
+static const mail_operation_spec op_scan_subfolders = {
+ describe_scan_subfolders,
+ sizeof (scan_subfolders_op_t),
+ setup_scan_subfolders,
+ do_scan_subfolders,
+ cleanup_scan_subfolders
+};
+
+void
+mail_do_scan_subfolders (const gchar * source_uri, gboolean add_INBOX,
+ EvolutionStorage * storage)
+{
+ scan_subfolders_input_t *input;
+
+ input = g_new (scan_subfolders_input_t, 1);
+ input->source_uri = g_strdup (source_uri);
+ input->add_INBOX = add_INBOX;
+ input->storage = storage;
+
+ mail_operation_queue (&op_scan_subfolders, input, TRUE);
+}
+
+/* ** ATTACH MESSAGE ****************************************************** */
+
+typedef struct attach_message_input_s
+{
+ EMsgComposer *composer;
+ CamelFolder *folder;
+ gchar *uid;
+}
+attach_message_input_t;
+
+typedef struct attach_message_data_s
+{
+ CamelMimePart *part;
+}
+attach_message_data_t;
+
+static gchar *describe_attach_message (gpointer in_data, gboolean gerund);
+static void setup_attach_message (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_attach_message (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_attach_message (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_attach_message (gpointer in_data, gboolean gerund)
+{
+ attach_message_input_t *input = (attach_message_input_t *) in_data;
+
+ if (gerund)
+ return
+ g_strdup_printf
+ ("Attaching messages from folder \"%s\"",
+ input->folder->full_name);
+ else
+ return g_strdup_printf ("Attach messages from \"%s\"",
+ input->folder->full_name);
}
static void
-cleanup_send_mail (gpointer userdata)
+setup_attach_message (gpointer in_data, gpointer op_data, CamelException * ex)
{
- rsm_t *info = (rsm_t *) userdata;
-
- if (info->ok) {
- gtk_object_destroy (GTK_OBJECT (info->composer));
+ attach_message_input_t *input = (attach_message_input_t *) in_data;
+
+ if (!input->uid) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No UID specified to attach.");
+ return;
}
- gtk_object_unref (GTK_OBJECT (info->message));
- g_free (info);
+ if (!CAMEL_IS_FOLDER (input->folder)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder to fetch the message from specified.");
+ return;
+ }
+
+ if (!E_IS_MSG_COMPOSER (input->composer)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No message composer from specified.");
+ return;
+ }
+
+ camel_object_ref (CAMEL_OBJECT (input->folder));
+ gtk_object_ref (GTK_OBJECT (input->composer));
}
static void
-composer_send_cb (EMsgComposer *composer, gpointer data)
-{
- const MailConfigIdentity *id = NULL;
- static CamelTransport *transport = NULL;
- struct post_send_data *psd = data;
- rsm_t *info;
- static char *from = NULL;
- const char *subject;
- CamelException *ex;
+do_attach_message (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ attach_message_input_t *input = (attach_message_input_t *) in_data;
+ attach_message_data_t *data = (attach_message_data_t *) op_data;
+
CamelMimeMessage *message;
- char *name, *addr;
-
- ex = camel_exception_new ();
-
- id = mail_config_get_default_identity ();
-
- if (!check_configured() || !id) {
- GtkWidget *message;
-
- message = gnome_warning_dialog_parented (_("You need to configure an identity\n"
- "before you can send mail."),
- GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (composer),
- GTK_TYPE_WINDOW)));
- gnome_dialog_run_and_close (GNOME_DIALOG (message));
+ CamelMimePart *part;
+
+ mail_tool_camel_lock_up ();
+ message = camel_folder_get_message (input->folder, input->uid, ex);
+ if (!message) {
+ mail_tool_camel_lock_down ();
+ return;
+ }
+
+ part = mail_tool_make_message_attachment (message);
+ camel_object_unref (CAMEL_OBJECT (message));
+ mail_tool_camel_lock_down ();
+ if (!part)
+ return;
+
+ data->part = part;
+}
+
+static void
+cleanup_attach_message (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ attach_message_input_t *input = (attach_message_input_t *) in_data;
+ attach_message_data_t *data = (attach_message_data_t *) op_data;
+
+ e_msg_composer_attach (input->composer, data->part);
+ camel_object_unref (CAMEL_OBJECT (data->part));
+ camel_object_unref (CAMEL_OBJECT (input->folder));
+ gtk_object_unref (GTK_OBJECT (input->composer));
+ g_free (input->uid);
+}
+
+static const mail_operation_spec op_attach_message = {
+ describe_attach_message,
+ sizeof (attach_message_data_t),
+ setup_attach_message,
+ do_attach_message,
+ cleanup_attach_message
+};
+
+void
+mail_do_attach_message (CamelFolder * folder, const char *uid,
+ EMsgComposer * composer)
+{
+ attach_message_input_t *input;
+
+ input = g_new (attach_message_input_t, 1);
+ input->folder = folder;
+ input->uid = g_strdup (uid);
+ input->composer = composer;
+
+ mail_operation_queue (&op_attach_message, input, TRUE);
+}
+
+/* ** FORWARD MESSAGES **************************************************** */
+
+typedef struct forward_messages_input_s
+{
+ CamelMimeMessage *basis;
+ CamelFolder *source;
+ GPtrArray *uids;
+ EMsgComposer *composer;
+}
+forward_messages_input_t;
+
+typedef struct forward_messages_data_s
+{
+ gchar *subject;
+ GPtrArray *parts;
+}
+forward_messages_data_t;
+
+static gchar *describe_forward_messages (gpointer in_data, gboolean gerund);
+static void setup_forward_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_forward_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_forward_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_forward_messages (gpointer in_data, gboolean gerund)
+{
+ forward_messages_input_t *input =
+
+ (forward_messages_input_t *) in_data;
+
+ if (gerund) {
+ if (input->basis->subject)
+ return g_strdup_printf ("Forwarding messages \"%s\"",
+ input->basis->subject);
+ else
+ return
+ g_strdup_printf
+ ("Forwarding a message without a subject");
+ } else {
+ if (input->basis->subject)
+ return g_strdup_printf ("Forward message \"%s\"",
+ input->basis->subject);
+ else
+ return
+ g_strdup_printf
+ ("Forward a message without a subject");
+ }
+}
+
+static void
+setup_forward_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ forward_messages_input_t *input =
+
+ (forward_messages_input_t *) in_data;
+
+ if (!input->uids) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No UIDs specified to attach.");
+ return;
+ }
+
+ if (!CAMEL_IS_MIME_MESSAGE (input->basis)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No basic message to forward was specified.");
+ return;
+ }
+
+ if (!CAMEL_IS_FOLDER (input->source)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder to fetch the messages from specified.");
return;
}
-
- from = g_strdup (e_msg_composer_hdrs_get_from (E_MSG_COMPOSER_HDRS (composer->hdrs)));
- if (!from) {
- CamelInternetAddress *ciaddr;
-
- g_assert (id);
-
- name = id->name;
- g_assert (name);
-
- addr = id->address;
- g_assert (addr);
-
- ciaddr = camel_internet_address_new ();
- camel_internet_address_add (ciaddr, name, addr);
-
- from = camel_address_encode (CAMEL_ADDRESS (ciaddr));
+
+ if (!E_IS_MSG_COMPOSER (input->composer)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No message composer from specified.");
+ return;
}
-
- if (!transport) {
- MailConfigService *t;
- char *url;
-
- t = mail_config_get_transport ();
- url = t->url;
- g_assert (url);
-
- transport = camel_session_get_transport (session, url, ex);
- if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
- mail_exception_dialog ("Could not load mail transport",
- ex, composer);
- camel_exception_free (ex);
+
+ camel_object_ref (CAMEL_OBJECT (input->basis));
+ camel_object_ref (CAMEL_OBJECT (input->source));
+ gtk_object_ref (GTK_OBJECT (input->composer));
+}
+
+static void
+do_forward_messages (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ forward_messages_input_t *input =
+
+ (forward_messages_input_t *) in_data;
+ forward_messages_data_t *data = (forward_messages_data_t *) op_data;
+
+ CamelMimeMessage *message;
+ CamelMimePart *part;
+ int i;
+
+ data->parts = g_ptr_array_new ();
+
+ mail_tool_camel_lock_up ();
+ for (i = 0; i < input->uids->len; i++) {
+ message =
+ camel_folder_get_message (input->source,
+ input->uids->pdata[i], ex);
+ g_free (input->uids->pdata[i]);
+ if (!message) {
+ mail_tool_camel_lock_down ();
return;
}
- }
-
- message = e_msg_composer_get_message (composer);
-
- subject = camel_mime_message_get_subject (message);
- if (!subject || !*subject) {
- if (!ask_confirm_for_empty_subject (composer)) {
- gtk_object_unref (GTK_OBJECT (message));
+ part = mail_tool_make_message_attachment (message);
+ if (!part) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+ "Failed to generate mime part from "
+ "message while generating forwarded message.");
+ mail_tool_camel_lock_down ();
return;
}
+ camel_object_unref (CAMEL_OBJECT (message));
+ g_ptr_array_add (data->parts, part);
}
-
- info = g_new0 (rsm_t, 1);
- info->composer = composer;
- info->transport = transport;
- info->message = message;
- info->subject = subject;
- info->from = from;
- info->psd = psd;
-
-#ifdef USE_BROKEN_THREADS
- mail_operation_try ("Send Message", real_send_mail, cleanup_send_mail, info);
-#else
- real_send_mail (info);
- cleanup_send_mail (info);
-#endif
+
+ mail_tool_camel_lock_down ();
+
+ data->subject = mail_tool_generate_forward_subject (input->basis);
}
static void
-free_psd (GtkWidget *composer, gpointer user_data)
+cleanup_forward_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex)
{
- struct post_send_data *psd = user_data;
+ forward_messages_input_t *input =
- gtk_object_unref (GTK_OBJECT (psd->folder));
- g_free (psd);
-}
+ (forward_messages_input_t *) in_data;
+ forward_messages_data_t *data = (forward_messages_data_t *) op_data;
-static GtkWidget *
-create_msg_composer (const char *url)
-{
- MailConfigIdentity *id;
- gboolean send_html;
- gchar *sig_file = NULL;
- GtkWidget *composer_widget;
+ int i;
- id = mail_config_get_default_identity ();
- send_html = mail_config_send_html ();
-
- if (id) {
- sig_file = id->sig;
+ for (i = 0; i < data->parts->len; i++) {
+ e_msg_composer_attach (input->composer,
+ data->parts->pdata[i]);
+ camel_object_unref (CAMEL_OBJECT (data->parts->pdata[i]));
}
-
- if (url != NULL)
- composer_widget = e_msg_composer_new_from_url (url);
- else
- composer_widget = e_msg_composer_new_with_sig_file (sig_file);
+ camel_object_unref (CAMEL_OBJECT (input->source));
- e_msg_composer_set_send_html (E_MSG_COMPOSER (composer_widget),
- send_html);
+ e_msg_composer_set_headers (input->composer, NULL, NULL, NULL,
+ data->subject);
- return composer_widget;
+ gtk_object_unref (GTK_OBJECT (input->composer));
+ g_free (data->subject);
+ g_ptr_array_free (data->parts, TRUE);
+ g_ptr_array_free (input->uids, TRUE);
+ gtk_widget_show (GTK_WIDGET (input->composer));
}
+static const mail_operation_spec op_forward_messages = {
+ describe_forward_messages,
+ sizeof (forward_messages_data_t),
+ setup_forward_messages,
+ do_forward_messages,
+ cleanup_forward_messages
+};
+
void
-compose_msg (GtkWidget *widget, gpointer user_data)
+mail_do_forward_message (CamelMimeMessage * basis,
+ CamelFolder * source,
+ GPtrArray * uids, EMsgComposer * composer)
{
- GtkWidget *composer;
-
- if (!check_configured ())
- return;
-
- composer = create_msg_composer (NULL);
-
- gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (composer_send_cb), NULL);
- gtk_widget_show (composer);
+ forward_messages_input_t *input;
+
+ input = g_new (forward_messages_input_t, 1);
+ input->basis = basis;
+ input->source = source;
+ input->uids = uids;
+ input->composer = composer;
+
+ mail_operation_queue (&op_forward_messages, input, TRUE);
}
-/* Send according to a mailto (RFC 2368) URL. */
-void
-send_to_url (const char *url)
+/* ** LOAD FOLDER ********************************************************* */
+
+typedef struct load_folder_input_s
{
- GtkWidget *composer;
+ FolderBrowser *fb;
+ gchar *url;
+}
+load_folder_input_t;
+
+static gchar *describe_load_folder (gpointer in_data, gboolean gerund);
+static void setup_load_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_load_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_load_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_load_folder (gpointer in_data, gboolean gerund)
+{
+ load_folder_input_t *input = (load_folder_input_t *) in_data;
- if (!check_configured ())
+ if (gerund) {
+ return g_strdup_printf ("Loading \"%s\"", input->url);
+ } else {
+ return g_strdup_printf ("Load \"%s\"", input->url);
+ }
+}
+
+static void
+setup_load_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ load_folder_input_t *input = (load_folder_input_t *) in_data;
+
+ if (!IS_FOLDER_BROWSER (input->fb)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder browser specified to load into.");
return;
+ }
- composer = create_msg_composer (url);
+ if (!input->url) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No URL to load was specified.");
+ return;
+ }
+
+ gtk_object_ref (GTK_OBJECT (input->fb));
- gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (composer_send_cb), NULL);
- gtk_widget_show (composer);
-}
+ if (input->fb->uri)
+ g_free (input->fb->uri);
+
+ input->fb->uri = input->url;
+}
static void
-reply (FolderBrowser *fb, gboolean to_all)
+do_load_folder (gpointer in_data, gpointer op_data, CamelException * ex)
{
- EMsgComposer *composer;
- struct post_send_data *psd;
+ load_folder_input_t *input = (load_folder_input_t *) in_data;
+
+ CamelFolder *folder;
- if (!check_configured () || !fb->message_list->cursor_uid ||
- !fb->mail_display->current_message)
+ folder = mail_tool_uri_to_folder (input->url, ex);
+ if (!folder)
return;
- psd = g_new (struct post_send_data, 1);
- psd->folder = fb->folder;
- gtk_object_ref (GTK_OBJECT (psd->folder));
- psd->uid = fb->message_list->cursor_uid;
- psd->flags = CAMEL_MESSAGE_ANSWERED;
+ if (input->fb->folder) {
+ mail_tool_camel_lock_up ();
+ camel_object_unref (CAMEL_OBJECT (input->fb->folder));
+ mail_tool_camel_lock_down ();
+ }
- composer = mail_generate_reply (fb->mail_display->current_message, to_all);
+ input->fb->folder = folder;
+}
+
+static void
+cleanup_load_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ load_folder_input_t *input = (load_folder_input_t *) in_data;
+
+ gtk_widget_set_sensitive (GTK_WIDGET (input->fb->search_entry),
+ camel_folder_has_search_capability (input->
+ fb->
+ folder));
+ gtk_widget_set_sensitive (GTK_WIDGET (input->fb->search_menu),
+ camel_folder_has_search_capability (input->
+ fb->
+ folder));
- gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (composer_send_cb), psd);
- gtk_signal_connect (GTK_OBJECT (composer), "destroy",
- GTK_SIGNAL_FUNC (free_psd), psd);
+ message_list_set_folder (input->fb->message_list, input->fb->folder);
- gtk_widget_show (GTK_WIDGET (composer));
+ /*g_free (input->url); = fb->uri now */
}
+static const mail_operation_spec op_load_folder = {
+ describe_load_folder,
+ 0,
+ setup_load_folder,
+ do_load_folder,
+ cleanup_load_folder
+};
+
void
-reply_to_sender (GtkWidget *widget, gpointer user_data)
+mail_do_load_folder (FolderBrowser * fb, const char *url)
{
- reply (FOLDER_BROWSER (user_data), FALSE);
+ load_folder_input_t *input;
+
+ input = g_new (load_folder_input_t, 1);
+ input->fb = fb;
+ input->url = g_strdup (url);
+
+ mail_operation_queue (&op_load_folder, input, TRUE);
}
-void
-reply_to_all (GtkWidget *widget, gpointer user_data)
+/* ** CREATE FOLDER ******************************************************* */
+
+typedef struct create_folder_input_s
{
- reply (FOLDER_BROWSER (user_data), TRUE);
+ Evolution_ShellComponentListener listener;
+ char *uri;
+ char *type;
}
+create_folder_input_t;
-static void
-attach_msg (MessageList *ml, const char *uid, gpointer data)
+typedef struct create_folder_data_s
{
- EMsgComposer *composer = data;
- CamelMimeMessage *message;
- CamelMimePart *part;
- const char *subject;
- char *desc;
-
- message = camel_folder_get_message (ml->folder, uid, NULL);
- if (!message)
- return;
- subject = camel_mime_message_get_subject (message);
- if (subject)
- desc = g_strdup_printf ("Forwarded message - %s", subject);
- else
- desc = g_strdup ("Forwarded message");
-
- part = camel_mime_part_new ();
- camel_mime_part_set_disposition (part, "inline");
- camel_mime_part_set_description (part, desc);
- camel_medium_set_content_object (CAMEL_MEDIUM (part),
- CAMEL_DATA_WRAPPER (message));
- camel_mime_part_set_content_type (part, "message/rfc822");
-
- e_msg_composer_attach (composer, part);
-
- gtk_object_unref (GTK_OBJECT (part));
- gtk_object_unref (GTK_OBJECT (message));
- g_free (desc);
+ Evolution_ShellComponentListener_Result result;
+}
+create_folder_data_t;
+
+static gchar *describe_create_folder (gpointer in_data, gboolean gerund);
+static void setup_create_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_create_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_create_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_create_folder (gpointer in_data, gboolean gerund)
+{
+ create_folder_input_t *input = (create_folder_input_t *) in_data;
+
+ if (gerund) {
+ return g_strdup_printf ("Creating \"%s\"", input->uri);
+ } else {
+ return g_strdup_printf ("Create \"%s\"", input->uri);
+ }
}
-void
-forward_msg (GtkWidget *widget, gpointer user_data)
+static void
+setup_create_folder (gpointer in_data, gpointer op_data, CamelException * ex)
{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- EMsgComposer *composer;
- CamelMimeMessage *cursor_msg;
- const char *from, *subject;
- char *fwd_subj;
-
- cursor_msg = fb->mail_display->current_message;
- if (!check_configured () || !cursor_msg)
+ create_folder_input_t *input = (create_folder_input_t *) in_data;
+
+ if (input->listener == CORBA_OBJECT_NIL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Invalid listener passed to create_folder");
return;
+ }
- composer = E_MSG_COMPOSER (create_msg_composer (NULL));
- message_list_foreach (fb->message_list, attach_msg, composer);
+ if (input->uri == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Invalid url passed to create_folder");
+ return;
+ }
+
+ if (input->type == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No type passed to create_folder");
+ return;
+ }
+
+ /* FIXME: reference listener somehow? */
+}
- from = camel_mime_message_get_from (cursor_msg);
- subject = camel_mime_message_get_subject (cursor_msg);
- if (from) {
- if (subject && *subject) {
- fwd_subj = g_strdup_printf ("[%s] %s", from, subject);
+static void
+do_create_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ create_folder_input_t *input = (create_folder_input_t *) in_data;
+ create_folder_data_t *data = (create_folder_data_t *) op_data;
+
+ CamelFolder *folder;
+ gchar *camel_url;
+
+ if (strcmp (input->type, "mail") != 0)
+ data->result =
+ Evolution_ShellComponentListener_UNSUPPORTED_TYPE;
+ else {
+ camel_url = g_strdup_printf ("mbox://%s", input->uri);
+ folder = mail_tool_get_folder_from_urlname (camel_url,
+ "mbox", ex);
+ g_free (camel_url);
+
+ if (!camel_exception_is_set (ex)) {
+ camel_object_unref (CAMEL_OBJECT (folder));
+ data->result = Evolution_ShellComponentListener_OK;
} else {
- fwd_subj = g_strdup_printf ("[%s] (forwarded message)",
- from);
+ data->result =
+ Evolution_ShellComponentListener_INVALID_URI;
}
- } else {
- fwd_subj = NULL;
}
+}
+
+static void
+cleanup_create_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ create_folder_input_t *input = (create_folder_input_t *) in_data;
+ create_folder_data_t *data = (create_folder_data_t *) op_data;
+
+ CORBA_Environment ev;
- e_msg_composer_set_headers (composer, NULL, NULL, NULL, fwd_subj);
- g_free (fwd_subj);
+ CORBA_exception_init (&ev);
+ Evolution_ShellComponentListener_report_result (input->listener,
+ data->result, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION)
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+ "Exception while reporting result to shell "
+ "component listener.");
+ CORBA_exception_free (&ev);
- gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (composer_send_cb), NULL);
+ /* FIXME: unref listener somehow? */
- gtk_widget_show (GTK_WIDGET (composer));
+ g_free (input->uri);
+ g_free (input->type);
}
-struct move_data {
- CamelFolder *source, *dest;
- CamelException *ex;
+static const mail_operation_spec op_create_folder = {
+ describe_create_folder,
+ sizeof (create_folder_data_t),
+ setup_create_folder,
+ do_create_folder,
+ cleanup_create_folder
};
-static void
-real_move_msg (MessageList *ml, const char *uid, gpointer user_data)
+void
+mail_do_create_folder (const Evolution_ShellComponentListener listener,
+ const char *uri, const char *type)
{
- struct move_data *rfd = user_data;
+ create_folder_input_t *input;
- if (camel_exception_is_set (rfd->ex))
- return;
+ input = g_new (create_folder_input_t, 1);
+ input->listener = listener;
+ input->uri = g_strdup (uri);
+ input->type = g_strdup (type);
- camel_folder_move_message_to (rfd->source, uid, rfd->dest, rfd->ex);
+ mail_operation_queue (&op_create_folder, input, FALSE);
}
-void
-move_msg (GtkWidget *widget, gpointer user_data)
-{
- FolderBrowser *fb = user_data;
- MessageList *ml = fb->message_list;
- char *uri, *physical, *path;
- struct move_data rfd;
- const char *allowed_types[] = { "mail", NULL };
- extern EvolutionShellClient *global_shell_client;
- static char *last = NULL;
-
- if (!last)
- last = g_strdup ("");
-
- evolution_shell_client_user_select_folder (global_shell_client,
- _("Move message(s) to"),
- last, allowed_types, &uri, &physical);
- if (!uri)
- return;
+/* ** SYNC FOLDER ********************************************************* */
+
+static gchar *describe_sync_folder (gpointer in_data, gboolean gerund);
+static void setup_sync_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_sync_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_sync_folder (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_sync_folder (gpointer in_data, gboolean gerund)
+{
+ CamelFolder *f = CAMEL_FOLDER (in_data);
- path = strchr (uri, '/');
- if (path && strcmp (last, path) != 0) {
- g_free (last);
- last = g_strdup (path);
+ if (gerund) {
+ return g_strdup_printf ("Synchronizing \"%s\"", f->full_name);
+ } else {
+ return g_strdup_printf ("Synchronize \"%s\"", f->full_name);
}
- g_free (uri);
+}
- rfd.source = ml->folder;
- rfd.dest = mail_uri_to_folder (physical);
- g_free (physical);
- if (!rfd.dest)
+static void
+setup_sync_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ if (!CAMEL_IS_FOLDER (in_data)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder is selected to be synced");
return;
- rfd.ex = camel_exception_new ();
-
- message_list_foreach (ml, real_move_msg, &rfd);
- gtk_object_unref (GTK_OBJECT (rfd.dest));
-
- if (camel_exception_is_set (rfd.ex))
- mail_exception_dialog ("Could not move message", rfd.ex, fb);
- camel_exception_free (rfd.ex);
+ }
+
+ camel_object_ref (CAMEL_OBJECT (in_data));
+}
+
+static void
+do_sync_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ mail_tool_camel_lock_up ();
+ camel_folder_sync (CAMEL_FOLDER (in_data), FALSE, ex);
+ mail_tool_camel_lock_down ();
+}
+
+static void
+cleanup_sync_folder (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ camel_object_unref (CAMEL_OBJECT (in_data));
}
+static const mail_operation_spec op_sync_folder = {
+ describe_sync_folder,
+ 0,
+ setup_sync_folder,
+ do_sync_folder,
+ cleanup_sync_folder
+};
+
void
-mark_all_seen (BonoboUIHandler *uih, void *user_data, const char *path)
+mail_do_sync_folder (CamelFolder * folder)
{
- FolderBrowser *fb = FOLDER_BROWSER(user_data);
- MessageList *ml = fb->message_list;
- GPtrArray *uids;
- int i;
+ mail_operation_queue (&op_sync_folder, folder, FALSE);
+}
- uids = camel_folder_get_uids (ml->folder);
- for (i = 0; i < uids->len; i++) {
- camel_folder_set_message_flags (ml->folder, uids->pdata[i],
- CAMEL_MESSAGE_SEEN,
- CAMEL_MESSAGE_SEEN);
- }
+/* ** DISPLAY MESSAGE ***************************************************** */
+
+typedef struct display_message_input_s
+{
+ MessageList *ml;
+ gchar *uid;
+ gint (*timeout) (gpointer);
}
+display_message_input_t;
-static void
-real_edit_msg (MessageList *ml, const char *uid, gpointer user_data)
+typedef struct display_message_data_s
{
- CamelException *ex = user_data;
CamelMimeMessage *msg;
- GtkWidget *composer;
-
- if (camel_exception_is_set (ex))
- return;
-
- msg = camel_folder_get_message (ml->folder, uid, ex);
-
- composer = e_msg_composer_new_with_message (msg);
- gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (composer_send_cb), NULL);
- gtk_widget_show (composer);
+}
+display_message_data_t;
+
+static gchar *describe_display_message (gpointer in_data, gboolean gerund);
+static void setup_display_message (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_display_message (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_display_message (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_display_message (gpointer in_data, gboolean gerund)
+{
+ display_message_input_t *input = (display_message_input_t *) in_data;
+
+ if (gerund) {
+ if (input->uid)
+ return g_strdup_printf ("Displaying message UID \"%s\"",
+ input->uid);
+ else
+ return g_strdup ("Clearing message display");
+ } else {
+ if (input->uid)
+ return g_strdup_printf ("Display message UID \"%s\"",
+ input->uid);
+ else
+ return g_strdup ("Clear message dispaly");
+ }
}
-void
-edit_msg (GtkWidget *widget, gpointer user_data)
+static void
+setup_display_message (gpointer in_data, gpointer op_data,
+ CamelException * ex)
{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- MessageList *ml = fb->message_list;
- CamelException ex;
- extern CamelFolder *drafts_folder;
-
- camel_exception_init (&ex);
-
- if (fb->folder != drafts_folder) {
- camel_exception_setv (&ex, CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "FIXME: some error message about not being in the Drafts folder...");
- mail_exception_dialog ("Could not open message for editing", &ex, fb);
+ display_message_input_t *input = (display_message_input_t *) in_data;
+ display_message_data_t *data = (display_message_data_t *) op_data;
+
+ if (!IS_MESSAGE_LIST (input->ml)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "Invalid message list passed to display_message");
return;
}
-
- message_list_foreach (ml, real_edit_msg, &ex);
- if (camel_exception_is_set (&ex)) {
- mail_exception_dialog ("Could not open message for editing", &ex, fb);
- camel_exception_clear (&ex);
+
+ if (!input->timeout) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No timeout callback passed to display_message");
return;
}
-}
-void
-edit_message (BonoboUIHandler *uih, void *user_data, const char *path)
-{
- edit_msg (NULL, user_data);
+ data->msg = NULL;
+ gtk_object_ref (GTK_OBJECT (input->ml));
}
static void
-real_delete_msg (MessageList *ml, const char *uid, gpointer user_data)
+do_display_message (gpointer in_data, gpointer op_data, CamelException * ex)
{
- CamelException *ex = user_data;
- guint32 flags;
+ display_message_input_t *input = (display_message_input_t *) in_data;
+ display_message_data_t *data = (display_message_data_t *) op_data;
- if (camel_exception_is_set (ex))
+ if (input->uid == NULL) {
+ data->msg = NULL;
return;
+ }
- /* Toggle the deleted flag without touching other flags. */
- flags = camel_folder_get_message_flags (ml->folder, uid);
- camel_folder_set_message_flags (ml->folder, uid,
- CAMEL_MESSAGE_DELETED, ~flags);
+ data->msg = camel_folder_get_message (input->ml->folder,
+ input->uid, ex);
}
-void
-delete_msg (GtkWidget *button, gpointer user_data)
-{
- FolderBrowser *fb = user_data;
- MessageList *ml = fb->message_list;
- CamelException ex;
-
- camel_exception_init (&ex);
- message_list_foreach (ml, real_delete_msg, &ex);
- if (camel_exception_is_set (&ex)) {
- mail_exception_dialog ("Could not toggle deleted flag",
- &ex, fb);
- camel_exception_clear (&ex);
- return;
+static void
+cleanup_display_message (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ display_message_input_t *input = (display_message_input_t *) in_data;
+ display_message_data_t *data = (display_message_data_t *) op_data;
+
+ MailDisplay *md = input->ml->parent_folder_browser->mail_display;
+
+ if (data->msg == NULL) {
+ mail_display_set_message (md, NULL);
+ } else {
+ if (input->ml->seen_id)
+ gtk_timeout_remove (input->ml->seen_id);
+
+ mail_display_set_message (md, CAMEL_MEDIUM (data->msg));
+ camel_object_unref (CAMEL_OBJECT (data->msg));
+
+ input->ml->seen_id =
+ gtk_timeout_add (1500, input->timeout, input->ml);
}
+
+ if (input->uid)
+ g_free (input->uid);
+ gtk_object_unref (GTK_OBJECT (input->ml));
}
-static void real_expunge_folder (gpointer user_data)
-{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- CamelException ex;
+static const mail_operation_spec op_display_message = {
+ describe_display_message,
+ sizeof (display_message_data_t),
+ setup_display_message,
+ do_display_message,
+ cleanup_display_message
+};
- e_table_model_pre_change(fb->message_list->table_model);
+void
+mail_do_display_message (MessageList * ml, const char *uid,
+ gint (*timeout) (gpointer))
+{
+ display_message_input_t *input;
-#ifdef USE_BROKEN_THREADS
- mail_op_hide_progressbar ();
- mail_op_set_message ("Expunging %s...", fb->message_list->folder->full_name);
-#endif
+ input = g_new (display_message_input_t, 1);
+ input->ml = ml;
+ input->uid = g_strdup (uid);
+ input->timeout = timeout;
- camel_exception_init (&ex);
+ mail_operation_queue (&op_display_message, input, FALSE);
+}
- camel_folder_expunge (fb->message_list->folder, &ex);
+/* ** EDIT MESSAGES ******************************************************* */
- /* FIXME: is there a better way to force an update? */
- /* FIXME: Folder should raise a signal to say its contents has changed ... */
- e_table_model_changed (fb->message_list->table_model);
+typedef struct edit_messages_input_s {
+ CamelFolder *folder;
+ GPtrArray *uids;
+ GtkSignalFunc signal;
+} edit_messages_input_t;
+
+typedef struct edit_messages_data_s {
+ GPtrArray *messages;
+} edit_messages_data_t;
+
+static gchar *describe_edit_messages (gpointer in_data, gboolean gerund);
+static void setup_edit_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_edit_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_edit_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_edit_messages (gpointer in_data, gboolean gerund)
+{
+ edit_messages_input_t *input = (edit_messages_input_t *) in_data;
- if (camel_exception_get_id (&ex) != CAMEL_EXCEPTION_NONE) {
- async_mail_exception_dialog ("Unable to expunge deleted messages", &ex, fb);
- }
+ if (gerund)
+ return g_strdup_printf
+ ("Opening messages from folder \"%s\"",
+ input->folder->full_name);
+ else
+ return g_strdup_printf ("Open messages from \"%s\"",
+ input->folder->full_name);
}
-void
-expunge_folder (BonoboUIHandler *uih, void *user_data, const char *path)
+static void
+setup_edit_messages (gpointer in_data, gpointer op_data, CamelException * ex)
{
- FolderBrowser *fb = FOLDER_BROWSER(user_data);
+ edit_messages_input_t *input = (edit_messages_input_t *) in_data;
- if (fb->message_list->folder) {
-#ifdef USE_BROKEN_THREADS
- mail_operation_try ("Expunge Folder", real_expunge_folder, NULL, fb);
-#else
- real_expunge_folder (fb);
-#endif
+ if (!input->uids) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No UIDs specified to edit.");
+ return;
+ }
+
+ if (!CAMEL_IS_FOLDER (input->folder)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder to fetch the messages from specified.");
+ return;
}
+
+ camel_object_ref (CAMEL_OBJECT (input->folder));
}
static void
-filter_druid_clicked(GtkWidget *w, int button, FolderBrowser *fb)
+do_edit_messages (gpointer in_data, gpointer op_data, CamelException * ex)
{
- FilterContext *fc;
+ edit_messages_input_t *input = (edit_messages_input_t *) in_data;
+ edit_messages_data_t *data = (edit_messages_data_t *) op_data;
+
+ int i;
- if (button == 0) {
- char *user;
+ data->messages = g_ptr_array_new ();
- fc = gtk_object_get_data((GtkObject *)w, "context");
- user = g_strdup_printf("%s/filters.xml", evolution_dir);
- rule_context_save((RuleContext *)fc, user);
- g_free(user);
- }
-
- if (button != -1) {
- gnome_dialog_close((GnomeDialog *)w);
+ for (i = 0; i < input->uids->len; i++) {
+ CamelMimeMessage *message;
+
+ mail_tool_camel_lock_up ();
+ message = camel_folder_get_message (input->folder, input->uids->pdata[i], ex);
+ mail_tool_camel_lock_down ();
+
+ if (message)
+ g_ptr_array_add (data->messages, message);
+
+ g_free (input->uids->pdata[i]);
}
}
-void
-filter_edit (BonoboUIHandler *uih, void *user_data, const char *path)
+static void
+cleanup_edit_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex)
{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- FilterContext *fc;
- char *user, *system;
- GtkWidget *w;
+ edit_messages_input_t *input = (edit_messages_input_t *) in_data;
+ edit_messages_data_t *data = (edit_messages_data_t *) op_data;
+
+ int i;
+
+ for (i = 0; i < data->messages->len; i++) {
+ GtkWidget *composer;
+
+ composer = e_msg_composer_new_with_message (data->messages->pdata[i]);
+
+ if (input->signal)
+ gtk_signal_connect (GTK_OBJECT (composer), "send",
+ input->signal, NULL);
+
+ gtk_widget_show (composer);
+
+ camel_object_unref (CAMEL_OBJECT (data->messages->pdata[i]));
+ }
+
+ g_ptr_array_free (input->uids, TRUE);
+ g_ptr_array_free (data->messages, TRUE);
+ camel_object_unref (CAMEL_OBJECT (input->folder));
- fc = filter_context_new();
- user = g_strdup_printf("%s/filters.xml", evolution_dir);
- system = g_strdup_printf("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
- rule_context_load((RuleContext *)fc, system, user);
- g_free(user);
- g_free(system);
- w = filter_editor_construct(fc);
- gtk_object_set_data_full((GtkObject *)w, "context", fc, (GtkDestroyNotify)gtk_object_unref);
- gtk_signal_connect((GtkObject *)w, "clicked", filter_druid_clicked, fb);
- gtk_widget_show(w);
}
+static const mail_operation_spec op_edit_messages = {
+ describe_edit_messages,
+ sizeof (edit_messages_data_t),
+ setup_edit_messages,
+ do_edit_messages,
+ cleanup_edit_messages
+};
+
void
-vfolder_edit_vfolders (BonoboUIHandler *uih, void *user_data, const char *path)
+mail_do_edit_messages (CamelFolder * folder, GPtrArray *uids,
+ GtkSignalFunc signal)
{
- void vfolder_edit(void);
+ edit_messages_input_t *input;
+
+ input = g_new (edit_messages_input_t, 1);
+ input->folder = folder;
+ input->uids = uids;
+ input->signal = signal;
- vfolder_edit();
+ mail_operation_queue (&op_edit_messages, input, TRUE);
}
-void
-providers_config (BonoboUIHandler *uih, void *user_data, const char *path)
+/* ** SETUP DRAFTBOX ****************************************************** */
+
+static gchar *describe_setup_draftbox (gpointer in_data, gboolean gerund);
+static void noop_setup_draftbox (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_setup_draftbox (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_setup_draftbox (gpointer in_data, gboolean gerund)
{
- mail_config();
+ if (gerund)
+ return g_strdup_printf ("Loading Draftbox");
+ else
+ return g_strdup_printf ("Load Draftbox");
}
-void
-print_msg (GtkWidget *button, gpointer user_data)
+static void
+noop_setup_draftbox (gpointer in_data, gpointer op_data, CamelException * ex)
{
- FolderBrowser *fb = user_data;
- GnomePrintMaster *print_master;
- GnomePrintContext *print_context;
- GtkWidget *preview;
+}
- print_master = gnome_print_master_new ();
+static void
+do_setup_draftbox (gpointer in_data, gpointer op_data, CamelException * ex)
+{
+ extern CamelFolder *drafts_folder;
+ gchar *url;
- print_context = gnome_print_master_get_context (print_master);
- gtk_html_print (fb->mail_display->html, print_context);
+ url = g_strdup_printf ("mbox://%s/local/Drafts", evolution_dir);
+ drafts_folder = mail_tool_get_folder_from_urlname (url, "mbox", ex);
+ g_free (url);
+}
- preview = GTK_WIDGET (gnome_print_master_preview_new (
- print_master, "Mail Print Preview"));
- gtk_widget_show (preview);
+/*
+ *static void
+ *cleanup_setup_draftbox (gpointer in_data, gpointer op_data,
+ * CamelException * ex)
+ *{
+ *}
+ */
- gtk_object_unref (GTK_OBJECT (print_master));
-}
+static const mail_operation_spec op_setup_draftbox = {
+ describe_setup_draftbox,
+ 0,
+ noop_setup_draftbox,
+ do_setup_draftbox,
+ noop_setup_draftbox
+};
void
-configure_folder(BonoboUIHandler *uih, void *user_data, const char *path)
+mail_do_setup_draftbox (void)
{
- FolderBrowser *fb = FOLDER_BROWSER(user_data);
-
- local_reconfigure_folder(fb);
+ mail_operation_queue (&op_setup_draftbox, NULL, FALSE);
}
+/* ** VIEW MESSAGES ******************************************************* */
-struct view_msg_data {
+typedef struct view_messages_input_s {
+ CamelFolder *folder;
+ GPtrArray *uids;
FolderBrowser *fb;
- CamelException *ex;
-};
+} view_messages_input_t;
+
+typedef struct view_messages_data_s {
+ GPtrArray *messages;
+} view_messages_data_t;
+
+static gchar *describe_view_messages (gpointer in_data, gboolean gerund);
+static void setup_view_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void do_view_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+static void cleanup_view_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex);
+
+static gchar *
+describe_view_messages (gpointer in_data, gboolean gerund)
+{
+ view_messages_input_t *input = (view_messages_input_t *) in_data;
+
+ if (gerund)
+ return g_strdup_printf
+ ("Viewing messages from folder \"%s\"",
+ input->folder->full_name);
+ else
+ return g_strdup_printf ("View messages from \"%s\"",
+ input->folder->full_name);
+}
static void
-real_view_msg (MessageList *ml, const char *uid, gpointer user_data)
+setup_view_messages (gpointer in_data, gpointer op_data, CamelException * ex)
{
- struct view_msg_data *data = user_data;
- FolderBrowser *fb;
- CamelMimeMessage *msg;
- GtkWidget *view;
-
- if (camel_exception_is_set (data->ex))
+ view_messages_input_t *input = (view_messages_input_t *) in_data;
+
+ if (!input->uids) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No UIDs specified to view.");
return;
-
- msg = camel_folder_get_message (ml->folder, uid, data->ex);
-
- fb = FOLDER_BROWSER (folder_browser_new ());
- folder_browser_set_uri (fb, data->fb->uri);
-
- fb->message_list->cursor_uid = uid;
- fb->mail_display->current_message = msg;
-
- view = mail_view_create (fb);
-
- gtk_widget_show (view);
+ }
+
+ if (!CAMEL_IS_FOLDER (input->folder)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder to fetch the messages from specified.");
+ return;
+ }
+
+ if (!IS_FOLDER_BROWSER (input->fb)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No folder browser was specified.");
+ return;
+ }
+
+
+ camel_object_ref (CAMEL_OBJECT (input->folder));
+ gtk_object_ref (GTK_OBJECT (input->fb));
}
-void
-view_msg (GtkWidget *widget, gpointer user_data)
+static void
+do_view_messages (gpointer in_data, gpointer op_data, CamelException * ex)
{
- struct view_msg_data data;
- FolderBrowser *fb = user_data;
- FolderBrowser *folder_browser;
- CamelException ex;
- MessageList *ml;
-
- camel_exception_init (&ex);
-
- data.fb = fb;
- data.ex = &ex;
-
- ml = fb->message_list;
- message_list_foreach (ml, real_view_msg, &data);
- if (camel_exception_is_set (&ex)) {
- mail_exception_dialog ("Could not open message for viewing", &ex, fb);
- camel_exception_clear (&ex);
- return;
+ view_messages_input_t *input = (view_messages_input_t *) in_data;
+ view_messages_data_t *data = (view_messages_data_t *) op_data;
+
+ int i;
+
+ data->messages = g_ptr_array_new ();
+
+ for (i = 0; i < input->uids->len; i++) {
+ CamelMimeMessage *message;
+
+ mail_tool_camel_lock_up ();
+ message = camel_folder_get_message (input->folder, input->uids->pdata[i], ex);
+ mail_tool_camel_lock_down ();
+
+ g_ptr_array_add (data->messages, message);
}
}
+static void
+cleanup_view_messages (gpointer in_data, gpointer op_data,
+ CamelException * ex)
+{
+ view_messages_input_t *input = (view_messages_input_t *) in_data;
+ view_messages_data_t *data = (view_messages_data_t *) op_data;
+
+ int i;
+
+ for (i = 0; i < data->messages->len; i++) {
+ CamelMimeMessage *msg;
+ gchar *uid;
+ GtkWidget *view;
+
+ if (data->messages->pdata[i] == NULL)
+ continue;
+
+ msg = data->messages->pdata[i];
+ uid = input->uids->pdata[i];
+
+ view = mail_view_create (input->folder, uid, msg);
+ gtk_widget_show (view);
+
+ /*Owned by the mail_display now*/
+ camel_object_unref (CAMEL_OBJECT (data->messages->pdata[i]));
+ g_free (uid);
+ }
+
+ g_ptr_array_free (input->uids, TRUE);
+ g_ptr_array_free (data->messages, TRUE);
+ camel_object_unref (CAMEL_OBJECT (input->folder));
+ gtk_object_unref (GTK_OBJECT (input->fb));
+}
+
+static const mail_operation_spec op_view_messages = {
+ describe_view_messages,
+ sizeof (view_messages_data_t),
+ setup_view_messages,
+ do_view_messages,
+ cleanup_view_messages
+};
+
void
-view_message (BonoboUIHandler *uih, void *user_data, const char *path)
+mail_do_view_messages (CamelFolder * folder, GPtrArray *uids,
+ FolderBrowser *fb)
{
- view_msg (NULL, user_data);
+ view_messages_input_t *input;
+
+ input = g_new (view_messages_input_t, 1);
+ input->folder = folder;
+ input->uids = uids;
+ input->fb = fb;
+
+ mail_operation_queue (&op_view_messages, input, TRUE);
}
diff --git a/mail/mail-threads.c b/mail/mail-threads.c
index a5dbac2427..7f5e796a51 100644
--- a/mail/mail-threads.c
+++ b/mail/mail-threads.c
@@ -24,8 +24,6 @@
#include <config.h>
-#ifdef USE_BROKEN_THREADS
-
#include <string.h>
#include <glib.h>
#include "mail.h"
@@ -35,7 +33,7 @@
/* FIXME TODO: Do we need operations that don't get a progress window because
* they're quick, but we still want camel to be locked? We need some kind
- * of flag to mail_operation_try, but then we also need some kind of monitor
+ * of flag to mail_operation_queue, but then we also need some kind of monitor
* to open the window if it takes more than a second or something. That would
* probably entail another thread....
*/
@@ -44,37 +42,56 @@
* A function and its userdata
**/
-typedef struct closure_s {
- void (*callback)( gpointer );
- void (*cleanup)( gpointer );
- gpointer data;
-
- gchar *prettyname;
- /* gboolean gets_window; */
-} closure_t;
+typedef struct closure_s
+{
+ gpointer in_data;
+ gboolean free_in_data;
+ gpointer op_data;
+ const mail_operation_spec *spec;
+ CamelException *ex;
+ gchar *infinitive;
+ gchar *gerund;
+}
+closure_t;
/**
* A command issued through the compipe
**/
-typedef struct com_msg_s {
- enum com_msg_type_e { STARTING, PERCENTAGE, HIDE_PBAR, SHOW_PBAR, MESSAGE, PASSWORD, ERROR, FINISHED } type;
+typedef struct com_msg_s
+{
+ enum com_msg_type_e {
+ STARTING,
+ PERCENTAGE,
+ HIDE_PBAR,
+ SHOW_PBAR,
+ MESSAGE,
+ PASSWORD,
+ ERROR,
+ FINISHED
+ } type;
gfloat percentage;
gchar *message;
- void (*func)( gpointer );
- gpointer userdata;
+ closure_t *clur;
/* Password stuff */
gchar **reply;
gboolean secret;
gboolean *success;
-} com_msg_t;
+}
+com_msg_t;
+
+/**
+ * @dispatch_thread_started: gboolean that tells us whether
+ * the dispatch thread has been launched.
+ **/
+
+static gboolean dispatch_thread_started = FALSE;
/**
- * @mail_operation_in_progress: When true, there's
- * another thread executing a major ev-mail operation:
- * fetch_mail, etc.
+ * @queue_len : the number of operations pending
+ * and being executed.
*
* Because camel is not thread-safe we work
* with the restriction that more than one mailbox
@@ -82,7 +99,7 @@ typedef struct com_msg_s {
* concurrently check mail and move messages, etc.
**/
-static gboolean mail_operation_in_progress;
+static gint queue_len = 0;
/**
* @queue_window: The little window on the screen that
@@ -110,27 +127,22 @@ static GtkWidget *queue_window_progress = NULL;
static int progress_timeout_handle = -1;
/**
- * @op_queue: The list of operations the are scheduled
- * to proceed after the currently executing one. When
- * only one operation is going, this is NULL.
- **/
-
-static GSList *op_queue = NULL;
-
-/**
- * @compipe: The pipe through which the dispatcher communicates
+ * @main_compipe: The pipe through which the dispatcher communicates
* with the main thread for GTK+ calls
*
* @chan_reader: the GIOChannel that reads our pipe
*
- * @READER: the fd in our pipe that.... reads!
- * @WRITER: the fd in our pipe that.... writes!
+ * @MAIN_READER: the fd in our main pipe that.... reads!
+ * @MAIN_WRITER: the fd in our main pipe that.... writes!
*/
-#define READER compipe[0]
-#define WRITER compipe[1]
+#define MAIN_READER main_compipe[0]
+#define MAIN_WRITER main_compipe[1]
+#define DISPATCH_READER dispatch_compipe[0]
+#define DISPATCH_WRITER dispatch_compipe[1]
-static int compipe[2] = { -1, -1 };
+static int main_compipe[2] = { -1, -1 };
+static int dispatch_compipe[2] = { -1, -1 };
GIOChannel *chan_reader = NULL;
@@ -146,28 +158,50 @@ GIOChannel *chan_reader = NULL;
* the dispatch thread may proceed its operations.
*/
-G_LOCK_DEFINE_STATIC( modal_lock );
+G_LOCK_DEFINE_STATIC (modal_lock);
static GCond *modal_cond = NULL;
static gboolean modal_may_proceed = FALSE;
/**
+ * @ready_for_op: A lock that the main thread only releases
+ * when it is ready for the dispatch thread to do its thing
+ *
+ * @ready_cond: A condition for this ... condition
+ *
+ * @ready_may_proceed: a gboolean telling the dispatch thread
+ * when it may proceed.
+ **/
+
+G_LOCK_DEFINE_STATIC (ready_for_op);
+static GCond *ready_cond = NULL;
+static gboolean ready_may_proceed = FALSE;
+
+/**
* Static prototypes
**/
-static void create_queue_window( void );
-static void dispatch( closure_t *clur );
-static void *dispatch_func( void *data );
-static void check_compipe( void );
-static void check_cond( void );
-static gboolean read_msg( GIOChannel *source, GIOCondition condition, gpointer userdata );
-static void remove_next_pending( void );
-static void show_error( com_msg_t *msg );
-static void show_error_clicked( void );
-static void get_password( com_msg_t *msg );
-static void get_password_cb( gchar *string, gpointer data );
-static void get_password_clicked( GnomeDialog *dialog, gint button, gpointer user_data );
-static gboolean progress_timeout( gpointer data );
-static void timeout_toggle( gboolean active );
+static void create_queue_window (void);
+static void destroy_queue_window (void);
+static void *dispatch (void * data);
+static void check_dispatcher (void);
+static void check_compipes (void);
+static void check_cond (void);
+static gboolean read_msg (GIOChannel * source, GIOCondition condition,
+ gpointer userdata);
+static void remove_next_pending (void);
+static void show_error (com_msg_t * msg);
+static void show_error_clicked (GtkObject * obj);
+static void get_password (com_msg_t * msg);
+static void get_password_cb (gchar * string, gpointer data);
+static void get_password_clicked (GnomeDialog * dialog, gint button,
+
+ gpointer user_data);
+static gboolean progress_timeout (gpointer data);
+static void timeout_toggle (gboolean active);
+static gboolean display_timeout (gpointer data);
+static closure_t *new_closure (const mail_operation_spec * spec, gpointer input,
+ gboolean free_in_data);
+static void free_closure (closure_t *clur);
/* Pthread code */
/* FIXME: support other thread types!!!! */
@@ -190,17 +224,25 @@ static pthread_t dispatch_thread;
* enough.
*/
-#else /* defined USE_PTHREADS */
-choke on this: no thread type defined
+#elif defined( G_THREADS_IMPL_SOLARIS )
+
+#include <thread.h>
+
+static thread_t dispatch_thread;
+
+#else /* no supported thread impl */
+void
+f (void)
+{
+ Error_No_supported_thread_implementation_recognized ();
+ choke on this;
+}
#endif
/**
- * mail_operation_try:
- * @description: A user-friendly string describing the operation.
- * @callback: the function to call in another thread to start the operation
- * @cleanup: the function to call in the main thread when the callback is finished.
- * NULL is allowed.
- * @user_data: extra data passed to the callback
+ * mail_operation_queue:
+ * @spec: describes the operation to be performed
+ * @input: input data for the operation.
*
* Runs a mail operation asynchronously. If no other operation is running,
* we start another thread and call the callback in that thread. The function
@@ -215,66 +257,75 @@ choke on this: no thread type defined
**/
gboolean
-mail_operation_try( const gchar *description, void (*callback)( gpointer ),
- void (*cleanup)( gpointer ), gpointer user_data )
+mail_operation_queue (const mail_operation_spec * spec, gpointer input,
+ gboolean free_in_data)
{
closure_t *clur;
- g_assert( callback );
-
- clur = g_new( closure_t, 1 );
- clur->callback = callback;
- clur->cleanup = cleanup;
- clur->data = user_data;
- clur->prettyname = g_strdup( description );
-
- if( mail_operation_in_progress == FALSE ) {
- /* No operations are going on, none are pending. So
- * we check to see if we're initialized (create the
- * window and the pipes), and send off the operation
- * on its merry way.
- */
- mail_operation_in_progress = TRUE;
+ g_assert (spec);
+
+ clur = new_closure (spec, input, free_in_data);
+
+ if (spec->setup)
+ (spec->setup) (clur->in_data, clur->op_data, clur->ex);
+
+ if (camel_exception_is_set (clur->ex)) {
+ if (clur->ex->id != CAMEL_EXCEPTION_USER_CANCEL) {
+ GtkWidget *err_dialog;
+ gchar *msg;
+
+ msg =
+ g_strdup_printf
+ ("Error while preparing to %s:\n" "%s",
+ clur->infinitive,
+ camel_exception_get_description (clur->ex));
+ err_dialog = gnome_error_dialog (msg);
+ g_free (msg);
+ gnome_dialog_set_close (GNOME_DIALOG (err_dialog),
+ TRUE);
+ /*gnome_dialog_run_and_close (GNOME_DIALOG (err_dialog)); */
+ /*gtk_widget_destroy (err_dialog); */
+ gtk_widget_show (GTK_WIDGET (err_dialog));
+
+ g_warning ("Setup failed for `%s': %s",
+ clur->infinitive,
+ camel_exception_get_description (clur->
+ ex));
+ }
- check_compipe();
- create_queue_window();
- gtk_widget_show_all( queue_window );
- gnome_win_hints_set_layer( queue_window,
- WIN_LAYER_ONTOP );
- gnome_win_hints_set_state( queue_window,
- WIN_STATE_ARRANGE_IGNORE );
- gnome_win_hints_set_hints( queue_window,
- WIN_HINTS_SKIP_FOCUS |
- WIN_HINTS_SKIP_WINLIST |
- WIN_HINTS_SKIP_TASKBAR );
- gtk_widget_hide( queue_window_pending );
+ free_closure (clur);
+ return FALSE;
+ }
- dispatch( clur );
+ if (queue_len == 0) {
+ check_cond ();
+ check_compipes ();
+ check_dispatcher ();
+ create_queue_window ();
+ /*gtk_widget_show_all (queue_window); */
+ gtk_timeout_add (1000, display_timeout, NULL);
} else {
GtkWidget *label;
- /* Zut. We already have an operation running. Well,
- * queue ourselves up.
- *
- * Yes, g_slist_prepend is faster down here.. But we pop
- * operations off the beginning of the list later and
- * that's a lot faster.
+ /* We already have an operation running. Well,
+ * queue ourselves up. (visually)
*/
- op_queue = g_slist_append( op_queue, clur );
-
/* Show us in the pending window. */
- label = gtk_label_new( description );
- gtk_misc_set_alignment( GTK_MISC( label ), 1.0, 0.5 );
- gtk_box_pack_start( GTK_BOX( queue_window_pending ), label,
- FALSE, TRUE, 2 );
+ label = gtk_label_new (clur->infinitive);
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (queue_window_pending), label,
+ FALSE, TRUE, 2);
+ gtk_widget_show (label);
/* If we want the next op to be on the bottom, uncomment this */
/* 1 = first on list always (0-based) */
/* gtk_box_reorder_child( GTK_BOX( queue_window_pending ), label, 1 ); */
- gtk_widget_show_all( queue_window_pending );
+ gtk_widget_show (queue_window_pending);
}
+ write (DISPATCH_WRITER, clur, sizeof (closure_t));
+ queue_len++;
return TRUE;
}
@@ -286,13 +337,14 @@ mail_operation_try( const gchar *description, void (*callback)( gpointer ),
* Threadsafe for, nay, intended to be called by, the dispatching thread.
**/
-void mail_op_set_percentage( gfloat percentage )
+void
+mail_op_set_percentage (gfloat percentage)
{
com_msg_t msg;
msg.type = PERCENTAGE;
msg.percentage = percentage;
- write( WRITER, &msg, sizeof( msg ) );
+ write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
@@ -307,12 +359,13 @@ void mail_op_set_percentage( gfloat percentage )
* that, right?
*/
-void mail_op_hide_progressbar( void )
+void
+mail_op_hide_progressbar (void)
{
com_msg_t msg;
msg.type = HIDE_PBAR;
- write( WRITER, &msg, sizeof( msg ) );
+ write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
@@ -322,12 +375,13 @@ void mail_op_hide_progressbar( void )
* Threadsafe for, nay, intended to be called by, the dispatching thread.
**/
-void mail_op_show_progressbar( void )
+void
+mail_op_show_progressbar (void)
{
com_msg_t msg;
msg.type = SHOW_PBAR;
- write( WRITER, &msg, sizeof( msg ) );
+ write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
@@ -340,17 +394,18 @@ void mail_op_show_progressbar( void )
* Threadsafe for, nay, intended to be called by, the dispatching thread.
**/
-void mail_op_set_message( gchar *fmt, ... )
+void
+mail_op_set_message (gchar * fmt, ...)
{
com_msg_t msg;
va_list val;
- va_start( val, fmt );
+ va_start (val, fmt);
msg.type = MESSAGE;
- msg.message = g_strdup_vprintf( fmt, val );
- va_end( val );
+ msg.message = g_strdup_vprintf (fmt, val);
+ va_end (val);
- write( WRITER, &msg, sizeof( msg ) );
+ write (MAIN_WRITER, &msg, sizeof (msg));
}
/**
@@ -365,30 +420,31 @@ void mail_op_set_message( gchar *fmt, ... )
* message.
**/
-gboolean mail_op_get_password( gchar *prompt, gboolean secret, gchar **dest )
+gboolean
+mail_op_get_password (gchar * prompt, gboolean secret, gchar ** dest)
{
com_msg_t msg;
gboolean result;
- check_cond();
-
msg.type = PASSWORD;
msg.secret = secret;
msg.message = prompt;
msg.reply = dest;
msg.success = &result;
-
+
(*dest) = NULL;
- G_LOCK( modal_lock );
+ G_LOCK (modal_lock);
- write( WRITER, &msg, sizeof( msg ) );
+ write (MAIN_WRITER, &msg, sizeof (msg));
modal_may_proceed = FALSE;
- while( modal_may_proceed == FALSE )
- g_cond_wait( modal_cond, g_static_mutex_get_mutex( &G_LOCK_NAME( modal_lock ) ) );
+ while (modal_may_proceed == FALSE)
+ g_cond_wait (modal_cond,
+ g_static_mutex_get_mutex (&G_LOCK_NAME
+ (modal_lock)));
- G_UNLOCK( modal_lock );
+ G_UNLOCK (modal_lock);
return result;
}
@@ -402,27 +458,28 @@ gboolean mail_op_get_password( gchar *prompt, gboolean secret, gchar **dest )
* Threadsafe for, nay, intended to be called by, the dispatching thread.
**/
-void mail_op_error( gchar *fmt, ... )
+void
+mail_op_error (gchar * fmt, ...)
{
com_msg_t msg;
va_list val;
- check_cond();
-
- va_start( val, fmt );
+ va_start (val, fmt);
msg.type = ERROR;
- msg.message = g_strdup_vprintf( fmt, val );
- va_end( val );
+ msg.message = g_strdup_vprintf (fmt, val);
+ va_end (val);
- G_LOCK( modal_lock );
+ G_LOCK (modal_lock);
modal_may_proceed = FALSE;
- write( WRITER, &msg, sizeof( msg ) );
+ write (MAIN_WRITER, &msg, sizeof (msg));
- while( modal_may_proceed == FALSE )
- g_cond_wait( modal_cond, g_static_mutex_get_mutex( &G_LOCK_NAME( modal_lock ) ) );
+ while (modal_may_proceed == FALSE)
+ g_cond_wait (modal_cond,
+ g_static_mutex_get_mutex (&G_LOCK_NAME
+ (modal_lock)));
- G_UNLOCK( modal_lock );
+ G_UNLOCK (modal_lock);
}
/**
@@ -432,12 +489,13 @@ void mail_op_error( gchar *fmt, ... )
* to finish executing
*/
-void mail_operation_wait_for_finish( void )
+void
+mail_operation_wait_for_finish (void)
{
- while( mail_operation_in_progress ) {
- while( gtk_events_pending() )
- gtk_main_iteration();
- }
+ while (queue_len)
+ gtk_main_iteration ();
+ /* Sigh. Otherwise we deadlock upon exit. */
+ GDK_THREADS_LEAVE ();
}
/**
@@ -445,15 +503,82 @@ void mail_operation_wait_for_finish( void )
*
* Returns TRUE if operations are being executed asynchronously
* when called, FALSE if not.
- */
+ **/
+
+gboolean
+mail_operations_are_executing (void)
+{
+ return (queue_len > 0);
+}
+
+/**
+ * mail_operations_terminate:
+ *
+ * Let the operations finish then terminate the dispatch thread
+ **/
-gboolean mail_operations_are_executing( void )
+void
+mail_operations_terminate (void)
{
- return mail_operation_in_progress;
+ closure_t clur;
+
+ mail_operation_wait_for_finish();
+
+ memset (&clur, 0, sizeof (closure_t));
+ clur.spec = NULL;
+
+ write (DISPATCH_WRITER, &clur, sizeof (closure_t));
}
/* ** Static functions **************************************************** */
+static void check_dispatcher (void)
+{
+ int res;
+
+ if (dispatch_thread_started)
+ return;
+
+#if defined( G_THREADS_IMPL_POSIX )
+ res = pthread_create (&dispatch_thread, NULL,
+ (void *) &dispatch, NULL);
+#elif defined( G_THREADS_IMPL_SOLARIS )
+ res = thr_create (NULL, 0, (void *) &dispatch, NULL, 0, &dispatch_thread);
+#else /* no known impl */
+ Error_No_thread_create_implementation ();
+ choke on this;
+#endif
+ if (res != 0) {
+ g_warning ("Error launching dispatch thread!");
+ /* FIXME: more error handling */
+ } else
+ dispatch_thread_started = TRUE;
+}
+
+static void
+print_hide (GtkWidget * wid)
+{
+ g_message ("$$$ hide signal emitted");
+}
+
+static void
+print_unmap (GtkWidget * wid)
+{
+ g_message ("$$$ unmap signal emitted");
+}
+
+static void
+print_map (GtkWidget * wid)
+{
+ g_message ("$$$ map signal emitted");
+}
+
+static void
+print_show (GtkWidget * wid)
+{
+ g_message ("$$$ show signal emitted");
+}
+
/**
* create_queue_window:
*
@@ -462,72 +587,115 @@ gboolean mail_operations_are_executing( void )
*/
static void
-create_queue_window( void )
+queue_window_delete_event_cb (GtkWindow *window,
+ void *data)
+{
+ /* Do nothing. Just prevent GTK+ from destroying the window. */
+}
+
+static void
+create_queue_window (void)
{
GtkWidget *vbox;
GtkWidget *pending_vb, *pending_lb;
GtkWidget *progress_lb, *progress_bar;
/* Check to see if we've only hidden it */
- if( queue_window != NULL )
+ if (queue_window != NULL)
return;
- queue_window = gtk_window_new( GTK_WINDOW_DIALOG );
- gtk_container_set_border_width( GTK_CONTAINER( queue_window ), 8 );
+ queue_window = gtk_window_new (GTK_WINDOW_DIALOG);
+ gtk_container_set_border_width (GTK_CONTAINER (queue_window), 8);
- vbox = gtk_vbox_new( FALSE, 4 );
+ gtk_signal_connect (GTK_OBJECT (queue_window), "delete_event",
+ GTK_SIGNAL_FUNC (queue_window_delete_event_cb), NULL);
- pending_vb = gtk_vbox_new( FALSE, 2 );
+ vbox = gtk_vbox_new (FALSE, 4);
+
+ pending_vb = gtk_vbox_new (FALSE, 2);
queue_window_pending = pending_vb;
- pending_lb = gtk_label_new( _("Currently pending operations:") );
- gtk_misc_set_alignment( GTK_MISC( pending_lb ), 0.0, 0.0 );
- gtk_box_pack_start( GTK_BOX( pending_vb ), pending_lb,
- FALSE, TRUE, 0 );
+ pending_lb = gtk_label_new (_("Currently pending operations:"));
+ gtk_misc_set_alignment (GTK_MISC (pending_lb), 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (pending_vb), pending_lb, FALSE, TRUE, 0);
- gtk_box_pack_start( GTK_BOX( vbox ), pending_vb,
- TRUE, TRUE, 4 );
+ gtk_box_pack_start (GTK_BOX (vbox), pending_vb, TRUE, TRUE, 4);
/* FIXME: 'operation' is not the warmest cuddliest word. */
- progress_lb = gtk_label_new( "" );
+ progress_lb = gtk_label_new ("");
queue_window_message = progress_lb;
- gtk_box_pack_start( GTK_BOX( vbox ), progress_lb,
- FALSE, TRUE, 4 );
+ gtk_box_pack_start (GTK_BOX (vbox), progress_lb, FALSE, TRUE, 4);
- progress_bar = gtk_progress_bar_new();
+ progress_bar = gtk_progress_bar_new ();
queue_window_progress = progress_bar;
/* FIXME: is this fit for l10n? */
- gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR( progress_bar ),
- GTK_PROGRESS_LEFT_TO_RIGHT );
- gtk_progress_bar_set_bar_style( GTK_PROGRESS_BAR( progress_bar ),
- GTK_PROGRESS_CONTINUOUS );
- gtk_box_pack_start( GTK_BOX( vbox ), progress_bar,
- FALSE, TRUE, 4 );
+ gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (progress_bar),
+ GTK_PROGRESS_LEFT_TO_RIGHT);
+ gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (progress_bar),
+ GTK_PROGRESS_CONTINUOUS);
+ gtk_box_pack_start (GTK_BOX (vbox), progress_bar, FALSE, TRUE, 4);
+
+ gtk_container_add (GTK_CONTAINER (queue_window), vbox);
+
+ gtk_widget_show (GTK_WIDGET (progress_bar));
+ gtk_widget_show (GTK_WIDGET (progress_lb));
+ gtk_widget_show (GTK_WIDGET (pending_lb));
+ gtk_widget_show (GTK_WIDGET (pending_vb));
+ gtk_widget_show (GTK_WIDGET (vbox));
+
+ gtk_signal_connect (GTK_OBJECT (queue_window), "hide", print_hide,
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (queue_window), "unmap", print_unmap,
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (queue_window), "show", print_show,
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (queue_window), "map", print_map,
+ NULL);
+}
- gtk_container_add( GTK_CONTAINER( queue_window ), vbox );
+static void destroy_queue_window (void)
+{
+ g_return_if_fail (queue_window);
+
+ timeout_toggle (FALSE);
+ gtk_widget_destroy (queue_window);
+
+ queue_window = NULL;
+ queue_window_progress = NULL;
+ queue_window_pending = NULL;
+ queue_window_message = NULL;
}
/**
- * check_compipe:
+ * check_compipes:
*
* Check and see if our pipe has been opened and open
* it if necessary.
**/
-static void check_compipe( void )
+static void
+check_compipes (void)
{
- if( READER > 0 )
- return;
+ if (MAIN_READER < 0) {
+ if (pipe (main_compipe) < 0) {
+ g_warning ("Call to pipe(2) failed!");
- if( pipe( compipe ) < 0 ) {
- g_warning( "Call to pipe(2) failed!" );
+ /* FIXME: better error handling. How do we react? */
+ return;
+ }
- /* FIXME: better error handling. How do we react? */
- return;
+ chan_reader = g_io_channel_unix_new (MAIN_READER);
+ g_io_add_watch (chan_reader, G_IO_IN, read_msg, NULL);
}
- chan_reader = g_io_channel_unix_new( READER );
- g_io_add_watch( chan_reader, G_IO_IN, read_msg, NULL );
+ if (DISPATCH_READER < 0) {
+ if (pipe (dispatch_compipe) < 0) {
+ g_warning ("Call to pipe(2) failed!");
+
+ /* FIXME: better error handling. How do we react? */
+ return;
+ }
+ }
}
/**
@@ -536,62 +704,94 @@ static void check_compipe( void )
* See if our condition is initialized and do so if necessary
**/
-static void check_cond( void )
+static void
+check_cond (void)
{
- if( modal_cond == NULL )
- modal_cond = g_cond_new();
+ if (modal_cond == NULL)
+ modal_cond = g_cond_new ();
+
+ if (ready_cond == NULL)
+ ready_cond = g_cond_new ();
}
/**
* dispatch:
- * @clur: The function to execute and its userdata
+ * @clur: The operation to execute and its parameters
*
* Start a thread that executes the closure and exit
* it when done.
*/
-static void dispatch( closure_t *clur )
+static void *
+dispatch (void *unused)
{
- int res;
+ size_t len;
+ closure_t *clur;
+ com_msg_t msg;
- res = pthread_create( &dispatch_thread, NULL, (void *) &dispatch_func, clur );
+ /* Let the compipes be created */
+ sleep (1);
- if( res != 0 ) {
- g_warning( "Error launching dispatch thread!" );
- /* FIXME: more error handling */
- }
-}
+ while (1) {
+ clur = g_new (closure_t, 1);
+ len = read (DISPATCH_READER, clur, sizeof (closure_t));
-/**
- * dispatch_func:
- * @data: the closure to run
- *
- * Runs the closure and exits the thread.
- */
+ if (len <= 0)
+ break;
-static void *dispatch_func( void *data )
-{
- com_msg_t msg;
- closure_t *clur = (closure_t *) data;
+ if (len != sizeof (closure_t)) {
+ g_warning ("dispatcher: Didn't read full message!");
+ continue;
+ }
+
+ if (clur->spec == NULL)
+ break;
- msg.type = STARTING;
- msg.message = clur->prettyname;
- write( WRITER, &msg, sizeof( msg ) );
+ msg.type = STARTING;
+ msg.message = g_strdup (clur->gerund);
+ write (MAIN_WRITER, &msg, sizeof (msg));
- /*GDK_THREADS_ENTER ();*/
- (clur->callback)( clur->data );
- /*GDK_THREADS_LEAVE ();*/
+ mail_op_hide_progressbar ();
+
+ (clur->spec->callback) (clur->in_data, clur->op_data, clur->ex);
+
+ if (camel_exception_is_set (clur->ex)) {
+ if (clur->ex->id != CAMEL_EXCEPTION_USER_CANCEL) {
+ g_warning ("Callback failed for `%s': %s",
+ clur->infinitive,
+ camel_exception_get_description (clur->
+ ex));
+ mail_op_error ("Error while `%s':\n" "%s",
+ clur->gerund,
+ camel_exception_get_description (clur->
+ ex));
+ }
+ }
- msg.type = FINISHED;
- msg.func = clur->cleanup; /* NULL is ok */
- msg.userdata = clur->data;
- write( WRITER, &msg, sizeof( msg ) );
+ msg.type = FINISHED;
+ msg.clur = clur;
- g_free( clur->prettyname );
- g_free( data );
+ G_LOCK (ready_for_op);
+ write (MAIN_WRITER, &msg, sizeof (msg));
- pthread_exit( 0 );
- return NULL; /*NOTREACHED*/
+ ready_may_proceed = FALSE;
+ while (ready_may_proceed == FALSE)
+ g_cond_wait (ready_cond,
+ g_static_mutex_get_mutex (&G_LOCK_NAME
+ (ready_for_op)));
+ G_UNLOCK (ready_for_op);
+ }
+
+#ifdef G_THREADS_IMPL_POSIX
+ pthread_exit (0);
+#elif defined( G_THREADS_IMPL_SOLARIS )
+ thr_exit (NULL);
+#else /* no known impl */
+ Error_No_thread_exit_implemented ();
+ choke on this;
+#endif
+ return NULL;
+ /*NOTREACHED*/
}
/**
@@ -604,75 +804,82 @@ static void *dispatch_func( void *data )
* action.
**/
-static gboolean read_msg( GIOChannel *source, GIOCondition condition, gpointer userdata )
+static gboolean
+read_msg (GIOChannel * source, GIOCondition condition, gpointer userdata)
{
com_msg_t *msg;
- closure_t *clur;
- GSList *temp;
guint size;
- msg = g_new0( com_msg_t, 1 );
+ msg = g_new0 (com_msg_t, 1);
- g_io_channel_read( source, (gchar *) msg,
- sizeof( com_msg_t ) / sizeof( gchar ),
- &size );
+ g_io_channel_read (source, (gchar *) msg,
+ sizeof (com_msg_t) / sizeof (gchar), &size);
- if( size != sizeof( com_msg_t ) ) {
- g_warning( _("Incomplete message written on pipe!") );
+ if (size != sizeof (com_msg_t)) {
+ g_warning (_("Incomplete message written on pipe!"));
msg->type = ERROR;
- msg->message = g_strdup( _("Error reading commands from dispatching thread.") );
+ msg->message =
+ g_strdup (_
+ ("Error reading commands from dispatching thread."));
}
/* This is very important, though I'm not quite sure why
* it is as we are in the main thread right now.
*/
- GDK_THREADS_ENTER();
+ GDK_THREADS_ENTER ();
- switch( msg->type ) {
+ switch (msg->type) {
case STARTING:
- DEBUG (("*** Message -- STARTING\n"));
- gtk_label_set_text( GTK_LABEL( queue_window_message ), msg->message );
- gtk_progress_bar_update( GTK_PROGRESS_BAR( queue_window_progress ), 0.0 );
- g_free( msg );
+ DEBUG (("*** Message -- STARTING %s\n", msg->message));
+ gtk_label_set_text (GTK_LABEL (queue_window_message),
+ msg->message);
+ gtk_progress_bar_update (GTK_PROGRESS_BAR
+ (queue_window_progress), 0.0);
+ g_free (msg->message);
+ g_free (msg);
break;
case PERCENTAGE:
DEBUG (("*** Message -- PERCENTAGE\n"));
- gtk_progress_bar_update( GTK_PROGRESS_BAR( queue_window_progress ), msg->percentage );
- g_free( msg );
+ gtk_progress_bar_update (GTK_PROGRESS_BAR
+ (queue_window_progress),
+ msg->percentage);
+ g_free (msg);
break;
case HIDE_PBAR:
DEBUG (("*** Message -- HIDE_PBAR\n"));
- gtk_progress_set_activity_mode( GTK_PROGRESS( queue_window_progress ), TRUE );
- timeout_toggle( TRUE );
-
- g_free( msg );
+ gtk_progress_set_activity_mode (GTK_PROGRESS
+ (queue_window_progress),
+ TRUE);
+ timeout_toggle (TRUE);
+ g_free (msg);
break;
case SHOW_PBAR:
DEBUG (("*** Message -- SHOW_PBAR\n"));
- timeout_toggle( FALSE );
- gtk_progress_set_activity_mode( GTK_PROGRESS( queue_window_progress ), FALSE );
-
- g_free( msg );
+ timeout_toggle (FALSE);
+ gtk_progress_set_activity_mode (GTK_PROGRESS
+ (queue_window_progress),
+ FALSE);
+ g_free (msg);
break;
case MESSAGE:
DEBUG (("*** Message -- MESSAGE\n"));
- gtk_label_set_text( GTK_LABEL( queue_window_message ),
- msg->message );
- g_free( msg->message );
- g_free( msg );
+ gtk_label_set_text (GTK_LABEL (queue_window_message),
+ msg->message);
+ g_free (msg->message);
+ g_free (msg);
break;
case PASSWORD:
DEBUG (("*** Message -- PASSWORD\n"));
- g_assert( msg->reply );
- g_assert( msg->success );
- get_password( msg );
+ g_assert (msg->reply);
+ g_assert (msg->success);
+ get_password (msg);
/* don't free msg! done later */
break;
case ERROR:
DEBUG (("*** Message -- ERROR\n"));
- show_error( msg );
- g_free( msg );
+ show_error (msg);
+ g_free (msg);
break;
/* Don't fall through; dispatch_func does the FINISHED
@@ -680,40 +887,58 @@ static gboolean read_msg( GIOChannel *source, GIOCondition condition, gpointer u
*/
case FINISHED:
- DEBUG (("*** Message -- FINISH\n"));
- if( msg->func )
- (msg->func)( msg->userdata );
+ DEBUG (
+ ("*** Message -- FINISH %s\n",
+ msg->clur->gerund));
+
+ if (msg->clur->spec->cleanup)
+ (msg->clur->spec->cleanup) (msg->clur->in_data,
+ msg->clur->op_data,
+ msg->clur->ex);
+
+ G_LOCK (ready_for_op);
+ ready_may_proceed = TRUE;
+ g_cond_signal (ready_cond);
+ G_UNLOCK (ready_for_op);
+
+ if (camel_exception_is_set (msg->clur->ex) &&
+ msg->clur->ex->id != CAMEL_EXCEPTION_USER_CANCEL) {
+ g_warning ("Error on cleanup of `%s': %s",
+ msg->clur->infinitive,
+ camel_exception_get_description (msg->
+ clur->
+ ex));
+ }
- if( op_queue == NULL ) {
- g_print("\tNo more ops -- hide %p.\n", queue_window);
+ free_closure (msg->clur);
+ queue_len--;
+
+ if (queue_len == 0) {
+ g_print ("\tNo more ops -- hide %p.\n", queue_window);
/* All done! */
- gtk_widget_hide( queue_window );
- mail_operation_in_progress = FALSE;
+ /* gtk_widget_hide seems to have problems sometimes
+ * here... perhaps because we're in a gsource handler,
+ * not a GTK event handler? Anyway, we defer the hiding
+ * til an idle. */
+ /*gtk_idle_add (hide_queue_window, NULL);*/
+ /*gtk_widget_hide (queue_window); */
+ destroy_queue_window ();
} else {
- g_print("\tOperation left.\n");
-
- /* There's another operation left */
-
- /* Pop it off the front */
- clur = op_queue->data;
- temp = g_slist_next( op_queue );
- g_slist_free_1( op_queue );
- op_queue = temp;
+ g_print ("\tOperation(s) left.\n");
- /* Clear it out of the 'pending' vbox */
- remove_next_pending();
-
- /* Run run run little process */
- dispatch( clur );
+ /* There's another operation left :
+ * Clear it out of the 'pending' vbox
+ */
+ remove_next_pending ();
}
- g_free( msg );
+ g_free (msg);
break;
default:
- g_warning( _("Corrupted message from dispatching thread?") );
+ g_warning (_("Corrupted message from dispatching thread?"));
break;
}
- GDK_THREADS_LEAVE();
+ GDK_THREADS_LEAVE ();
return TRUE;
}
@@ -725,23 +950,30 @@ static gboolean read_msg( GIOChannel *source, GIOCondition condition, gpointer u
* 'pending' message.
**/
-static void remove_next_pending( void )
+static void
+remove_next_pending (void)
{
GList *children;
- children = gtk_container_children( GTK_CONTAINER( queue_window_pending ) );
+ children =
+ gtk_container_children (GTK_CONTAINER (queue_window_pending));
/* Skip past the header label */
- children = g_list_first( children );
- children = g_list_next( children );
+ children = g_list_first (children);
+ children = g_list_next (children);
+
+ if (!children) {
+ g_warning ("Mistake in queue window!");
+ return;
+ }
/* Nuke the one on top */
- gtk_container_remove( GTK_CONTAINER( queue_window_pending ),
- GTK_WIDGET( children->data ) );
+ gtk_container_remove (GTK_CONTAINER (queue_window_pending),
+ GTK_WIDGET (children->data));
/* Hide it? */
- if( g_list_next( children ) == NULL )
- gtk_widget_hide( queue_window_pending );
+ if (g_list_next (children) == NULL)
+ gtk_widget_hide (queue_window_pending);
}
/**
@@ -750,28 +982,36 @@ static void remove_next_pending( void )
* Show the error dialog and wait for user OK
**/
-static void show_error( com_msg_t *msg )
+static void
+show_error (com_msg_t * msg)
{
GtkWidget *err_dialog;
+ gchar *old_message;
+
+ err_dialog = gnome_error_dialog (msg->message);
+ gnome_dialog_set_close (GNOME_DIALOG (err_dialog), TRUE);
+ gtk_signal_connect (GTK_OBJECT (err_dialog), "clicked",
+ (GtkSignalFunc) show_error_clicked, NULL);
+ g_free (msg->message);
- err_dialog = gnome_error_dialog( msg->message );
- gnome_dialog_set_close( GNOME_DIALOG(err_dialog), TRUE );
- gtk_signal_connect( GTK_OBJECT( err_dialog ), "clicked", (GtkSignalFunc) show_error_clicked, NULL );
- g_free( msg->message );
+ /* Save the old message, but display a new one right now */
+ gtk_label_get (GTK_LABEL (queue_window_message), &old_message);
+ gtk_object_set_data (GTK_OBJECT (err_dialog), "old_message",
+ g_strdup (old_message));
+ gtk_label_set_text (GTK_LABEL (queue_window_message),
+ _("Waiting for user to close error dialog"));
- G_LOCK( modal_lock );
+ G_LOCK (modal_lock);
- timeout_toggle( FALSE );
+ timeout_toggle (FALSE);
modal_may_proceed = FALSE;
- gtk_widget_show( GTK_WIDGET( err_dialog ) );
- gnome_win_hints_set_layer( err_dialog,
- WIN_LAYER_ONTOP );
- gnome_win_hints_set_state( err_dialog,
- WIN_STATE_ARRANGE_IGNORE );
- gnome_win_hints_set_hints( err_dialog,
+ gtk_widget_show_all (GTK_WIDGET (err_dialog));
+ gnome_win_hints_set_layer (err_dialog, WIN_LAYER_ONTOP);
+ gnome_win_hints_set_state (err_dialog, WIN_STATE_ARRANGE_IGNORE);
+ gnome_win_hints_set_hints (err_dialog,
WIN_HINTS_SKIP_FOCUS |
WIN_HINTS_SKIP_WINLIST |
- WIN_HINTS_SKIP_TASKBAR );
+ WIN_HINTS_SKIP_TASKBAR);
}
/**
@@ -781,12 +1021,21 @@ static void show_error( com_msg_t *msg )
* the dispatch thread is allowed to continue.
**/
-static void show_error_clicked( void )
+static void
+show_error_clicked (GtkObject * obj)
{
+ gchar *old_message;
+
+ /* Restore the old message */
+ old_message = gtk_object_get_data (obj, "old_message");
+ gtk_label_set_text (GTK_LABEL (queue_window_message),
+ old_message);
+ g_free (old_message);
+
modal_may_proceed = TRUE;
- timeout_toggle( TRUE );
- g_cond_signal( modal_cond );
- G_UNLOCK( modal_lock );
+ timeout_toggle (TRUE);
+ g_cond_signal (modal_cond);
+ G_UNLOCK (modal_lock);
}
/**
@@ -795,66 +1044,81 @@ static void show_error_clicked( void )
* Ask for a password and put the answer in *(msg->reply)
**/
-static void get_password( com_msg_t *msg )
+static void
+get_password (com_msg_t * msg)
{
GtkWidget *dialog;
+ gchar *old_message;
+
+ dialog = gnome_request_dialog (msg->secret, msg->message, NULL,
+ 0, get_password_cb, msg, NULL);
+ gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE);
+ gtk_signal_connect (GTK_OBJECT (dialog), "clicked",
+ get_password_clicked, msg);
- dialog = gnome_request_dialog( msg->secret, msg->message, NULL,
- 0, get_password_cb, msg,
- NULL );
- gnome_dialog_set_close( GNOME_DIALOG(dialog), TRUE );
- gtk_signal_connect( GTK_OBJECT( dialog ), "clicked", get_password_clicked, msg );
+ /* Save the old message, but display a new one right now */
+ gtk_label_get (GTK_LABEL (queue_window_message), &old_message);
+ gtk_object_set_data (GTK_OBJECT (dialog), "old_message", g_strdup(old_message));
+ gtk_label_set_text (GTK_LABEL (queue_window_message),
+ _("Waiting for user to enter data"));
- G_LOCK( modal_lock );
+ G_LOCK (modal_lock);
modal_may_proceed = FALSE;
- if( dialog == NULL ) {
+ if (dialog == NULL) {
*(msg->success) = FALSE;
- *(msg->reply) = g_strdup( _("Could not create dialog box.") );
+ *(msg->reply) = g_strdup (_("Could not create dialog box."));
modal_may_proceed = TRUE;
- g_cond_signal( modal_cond );
- G_UNLOCK( modal_lock );
+ g_cond_signal (modal_cond);
+ G_UNLOCK (modal_lock);
} else {
*(msg->reply) = NULL;
- timeout_toggle( FALSE );
- gtk_widget_show( GTK_WIDGET( dialog ) );
- gnome_win_hints_set_layer( dialog,
- WIN_LAYER_ONTOP );
- gnome_win_hints_set_state( dialog,
- WIN_STATE_ARRANGE_IGNORE );
- gnome_win_hints_set_hints( dialog,
+ timeout_toggle (FALSE);
+ gtk_widget_show_all (GTK_WIDGET (dialog));
+ gnome_win_hints_set_layer (dialog, WIN_LAYER_ONTOP);
+ gnome_win_hints_set_state (dialog, WIN_STATE_ARRANGE_IGNORE);
+ gnome_win_hints_set_hints (dialog,
WIN_HINTS_SKIP_FOCUS |
WIN_HINTS_SKIP_WINLIST |
- WIN_HINTS_SKIP_TASKBAR );
+ WIN_HINTS_SKIP_TASKBAR);
}
}
-static void get_password_cb( gchar *string, gpointer data )
+static void
+get_password_cb (gchar * string, gpointer data)
{
com_msg_t *msg = (com_msg_t *) data;
- if (string)
- *(msg->reply) = g_strdup( string );
- else
- *(msg->reply) = NULL;
+ if (string)
+ *(msg->reply) = g_strdup (string);
+ else
+ *(msg->reply) = NULL;
}
-static void get_password_clicked( GnomeDialog *dialog, gint button, gpointer user_data )
+static void
+get_password_clicked (GnomeDialog * dialog, gint button, gpointer user_data)
{
com_msg_t *msg = (com_msg_t *) user_data;
+ gchar *old_message;
+
+ /* Restore the old message */
+ old_message = gtk_object_get_data (GTK_OBJECT (dialog), "old_message");
+ gtk_label_set_text (GTK_LABEL (queue_window_message),
+ old_message);
+ g_free (old_message);
- if( button == 1 || *(msg->reply) == NULL ) {
+ if (button == 1 || *(msg->reply) == NULL) {
*(msg->success) = FALSE;
- *(msg->reply) = g_strdup( _("User cancelled query.") );
+ *(msg->reply) = g_strdup (_("User cancelled query."));
} else
*(msg->success) = TRUE;
- g_free( msg );
+ g_free (msg);
modal_may_proceed = TRUE;
- timeout_toggle( TRUE );
- g_cond_signal( modal_cond );
- G_UNLOCK( modal_lock );
+ timeout_toggle (TRUE);
+ g_cond_signal (modal_cond);
+ G_UNLOCK (modal_lock);
}
/* NOT totally copied from gtk+/gtk/testgtk.c, really! */
@@ -865,8 +1129,14 @@ progress_timeout (gpointer data)
gfloat new_val;
GtkAdjustment *adj;
+ if (queue_window == NULL) {
+ gtk_timeout_remove (progress_timeout_handle);
+ progress_timeout_handle = -1;
+ return FALSE;
+ }
+
adj = GTK_PROGRESS (data)->adjustment;
-
+
new_val = adj->value + 1;
if (new_val > adj->upper)
new_val = adj->lower;
@@ -885,20 +1155,100 @@ progress_timeout (gpointer data)
**/
static void
-timeout_toggle( gboolean active )
+timeout_toggle (gboolean active)
{
- if( (GTK_PROGRESS( queue_window_progress ))->activity_mode == 0 )
+ if (!queue_window)
+ return;
+
+ if ((GTK_PROGRESS (queue_window_progress))->activity_mode == 0)
return;
- if( active ) {
- if( progress_timeout_handle < 0 )
- progress_timeout_handle = gtk_timeout_add( 80, progress_timeout, queue_window_progress );
+ if (active) {
+ /* We do this in case queue_window_progress gets reset */
+ if (progress_timeout_handle < 0) {
+ progress_timeout_handle =
+ gtk_timeout_add (80, progress_timeout,
+ queue_window_progress);
+ } else {
+ gtk_timeout_remove (progress_timeout_handle);
+ progress_timeout_handle =
+ gtk_timeout_add (80, progress_timeout,
+ queue_window_progress);
+ }
} else {
- if( progress_timeout_handle >= 0 ) {
- gtk_timeout_remove( progress_timeout_handle );
+ if (progress_timeout_handle >= 0) {
+ gtk_timeout_remove (progress_timeout_handle);
progress_timeout_handle = -1;
}
}
}
-#endif
+/* This can theoretically run into problems where if a short operation starts
+ * and finishes, then another short operation starts and finishes a second
+ * later, we will see the window prematurely. My response: oh noooooo!
+ *
+ * Solution: keep the timeout's handle and remove the timeout upon reception
+ * of FINISH, and zero out the handle in this function. Whatever.
+ */
+static gboolean
+display_timeout (gpointer data)
+{
+ if (queue_len > 0 && queue_window) {
+ gtk_widget_show (queue_window);
+ gnome_win_hints_set_layer (queue_window, WIN_LAYER_ONTOP);
+ gnome_win_hints_set_state (queue_window,
+ WIN_STATE_ARRANGE_IGNORE);
+ gnome_win_hints_set_hints (queue_window,
+ WIN_HINTS_SKIP_FOCUS |
+ WIN_HINTS_SKIP_WINLIST |
+ WIN_HINTS_SKIP_TASKBAR);
+
+ if (queue_len == 1)
+ gtk_widget_hide (queue_window_pending);
+ }
+
+ return FALSE;
+}
+
+static closure_t *
+new_closure (const mail_operation_spec * spec, gpointer input,
+ gboolean free_in_data)
+{
+ closure_t *clur;
+
+ clur = g_new0 (closure_t, 1);
+ clur->spec = spec;
+ clur->in_data = input;
+ clur->free_in_data = free_in_data;
+ clur->ex = camel_exception_new ();
+
+ clur->op_data = g_malloc (spec->datasize);
+
+ camel_exception_init (clur->ex);
+
+ clur->infinitive = (spec->describe) (input, FALSE);
+ clur->gerund = (spec->describe) (input, TRUE);
+
+ return clur;
+}
+
+static void
+free_closure (closure_t *clur)
+{
+ clur->spec = NULL;
+
+ if (clur->free_in_data)
+ g_free (clur->in_data);
+ clur->in_data = NULL;
+
+ g_free (clur->op_data);
+ clur->op_data = NULL;
+
+ camel_exception_free (clur->ex);
+ clur->ex = NULL;
+
+ g_free (clur->infinitive);
+ g_free (clur->gerund);
+
+ g_free (clur);
+}
diff --git a/mail/mail-threads.h b/mail/mail-threads.h
index e26acdbb14..1aeb486935 100644
--- a/mail/mail-threads.h
+++ b/mail/mail-threads.h
@@ -25,28 +25,44 @@
#ifndef _MAIL_THREADS_H_
#define _MAIL_THREADS_H_
-#ifdef USE_BROKEN_THREADS
+#include <camel/camel-exception.h>
+#include <stdlib.h> /*size_t */
+
+/* Returns a g_strdup'ed string that describes what's going to happen,
+ * tersely but specifically.
+ */
+typedef gchar *(*mail_op_describe_func) (gpointer /*input_data*/, gboolean /*gerund*/);
+typedef void (*mail_op_func) (gpointer, gpointer, CamelException *);
+
+typedef struct _mail_operation_spec
+{
+ mail_op_describe_func describe;
+ size_t datasize;
+ mail_op_func setup;
+ mail_op_func callback;
+ mail_op_func cleanup;
+}
+mail_operation_spec;
+
/* Schedule to operation to happen eventually */
-gboolean mail_operation_try( const gchar *description,
- void (*callback)( gpointer ),
- void (*cleanup)( gpointer ),
- gpointer user_data );
+gboolean mail_operation_queue (const mail_operation_spec * spec,
+ gpointer input, gboolean free_in_data);
/* User interface hooks for the other thread */
-void mail_op_set_percentage( gfloat percentage );
-void mail_op_hide_progressbar( void );
-void mail_op_show_progressbar( void );
-void mail_op_set_message( gchar *fmt, ... ) G_GNUC_PRINTF( 1, 2 );
-void mail_op_error( gchar *fmt, ... ) G_GNUC_PRINTF( 1, 2 );
-gboolean mail_op_get_password( gchar *prompt, gboolean secret, gchar **dest );
+void mail_op_set_percentage (gfloat percentage);
+void mail_op_hide_progressbar (void);
+void mail_op_show_progressbar (void);
+void
+mail_op_set_message (gchar * fmt, ...) G_GNUC_PRINTF (1, 2);
+void mail_op_error (gchar * fmt, ...) G_GNUC_PRINTF (1, 2);
+gboolean mail_op_get_password (gchar * prompt, gboolean secret,
+ gchar ** dest);
/* Wait for the async operations to finish */
-void mail_operation_wait_for_finish( void );
-
-gboolean mail_operations_are_executing( void );
-
-#endif /* defined USE_BROKEN_THREADS */
+void mail_operation_wait_for_finish (void);
+gboolean mail_operations_are_executing (void);
+void mail_operations_terminate (void);
#endif /* defined _MAIL_THREADS_H_ */
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index fab59ef991..1fc5b8b2e3 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -19,12 +19,12 @@
#include "evolution-shell-component.h"
#include "folder-browser.h"
#include "mail-vfolder.h"
+#include "mail-tools.h"
#include "mail-autofilter.h"
#include "camel/camel.h"
#include "filter/vfolder-context.h"
-#include "filter/vfolder-rule.h"
#include "filter/vfolder-editor.h"
#define d(x) x
@@ -171,19 +171,17 @@ vfolder_create_storage(EvolutionShellComponent *shell_component)
vfolder_refresh();
}
+/* THIS IS ANALOGOUS TO mail_tool_uri_to_folder. IT IS NOT ASYNCHRONOUS */
/* maps the shell's uri to the real vfolder uri and open the folder */
CamelFolder *
-vfolder_uri_to_folder(const char *uri)
+vfolder_uri_to_folder(const char *uri, CamelException *ex)
{
- CamelFolder *mail_uri_to_folder(const char *);
void camel_vee_folder_add_folder(CamelFolder *, CamelFolder *);
struct _vfolder_info *info;
char *storeuri, *foldername;
VfolderRule *rule;
- CamelStore *store = NULL;
CamelFolder *folder = NULL, *sourcefolder;
- CamelException *ex;
const char *sourceuri;
int sources;
@@ -202,23 +200,19 @@ vfolder_uri_to_folder(const char *uri)
storeuri = g_strdup_printf("vfolder:%s/vfolder/%s", evolution_dir, info->name);
foldername = g_strdup_printf("mbox?%s", info->query);
- ex = camel_exception_new ();
- store = camel_session_get_store (session, storeuri, ex);
- if (store == NULL)
- goto cleanup;
- folder = camel_store_get_folder (store, foldername, TRUE, ex);
- if (folder == NULL)
- goto cleanup;
+ folder = mail_tool_get_folder_from_urlname (storeuri, foldername, ex);
sourceuri = NULL;
sources = 0;
while ( (sourceuri = vfolder_rule_next_source(rule, sourceuri)) ) {
d(printf("adding vfolder source: %s\n", sourceuri));
- sourcefolder = mail_uri_to_folder(sourceuri);
+ sourcefolder = mail_tool_uri_to_folder (sourceuri, ex);
if (sourcefolder) {
sources++;
+ mail_tool_camel_lock_up ();
camel_vee_folder_add_folder(folder, sourcefolder);
+ mail_tool_camel_lock_down ();
}
}
/* if we didn't have any sources, just use Inbox as the default */
@@ -227,12 +221,15 @@ vfolder_uri_to_folder(const char *uri)
defaulturi = g_strdup_printf("file://%s/local/Inbox", evolution_dir);
d(printf("No sources configured/found, using default: %s\n", defaulturi));
- sourcefolder = mail_uri_to_folder(defaulturi);
+ sourcefolder = mail_tool_uri_to_folder (defaulturi, ex);
g_free(defaulturi);
- if (sourcefolder)
+ if (sourcefolder) {
+ mail_tool_camel_lock_up ();
camel_vee_folder_add_folder(folder, sourcefolder);
+ mail_tool_camel_lock_down ();
+ }
}
-cleanup:
+
g_free(foldername);
g_free(storeuri);
diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h
index 4e87276322..2ff19cc3ea 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -15,7 +15,7 @@
void vfolder_create_storage(EvolutionShellComponent *shell_component);
-CamelFolder *vfolder_uri_to_folder(const char *uri);
+CamelFolder *vfolder_uri_to_folder(const char *uri, CamelException *ex);
void vfolder_edit(void);
FilterPart *vfolder_create_part(const char *name);
void vfolder_gui_add_rule(VfolderRule *rule);
diff --git a/mail/mail-view.c b/mail/mail-view.c
index a98cc4d5ca..6c336a47f8 100644
--- a/mail/mail-view.c
+++ b/mail/mail-view.c
@@ -20,17 +20,111 @@
*
*/
-#include <mail.h>
-#include <camel.h>
+#include <config.h>
+#include "mail.h"
+#include "mail-ops.h"
+#include "camel/camel.h"
+
+typedef struct mail_view_data_s {
+ CamelFolder *source;
+ gchar *uid;
+ CamelMimeMessage *msg;
+ MailDisplay *md;
+} mail_view_data;
+
+static void
+mail_view_data_free (gpointer mvd)
+{
+ mail_view_data *data = (mail_view_data *) mvd;
+
+ if (data->uid)
+ g_free (data->uid);
+ if (data->msg)
+ camel_object_unref (CAMEL_OBJECT (data->msg));
+ if (data->source)
+ camel_object_unref (CAMEL_OBJECT (data->source));
+
+ g_free (data);
+}
+
+static mail_view_data *
+mail_view_data_new (CamelFolder *source, const gchar *uid, CamelMimeMessage *msg)
+{
+ mail_view_data *data;
+
+ data = g_new (mail_view_data, 1);
+ data->source = source;
+ camel_object_ref (CAMEL_OBJECT (data->source));
+ data->msg = msg;
+ camel_object_ref (CAMEL_OBJECT (data->msg));
+ data->uid = g_strdup (uid);
+
+ return data;
+}
static void
on_close (GtkWidget *menuitem, gpointer user_data)
{
- GtkWidget *view;
-
- view = gtk_widget_get_toplevel (menuitem);
-
- gtk_widget_destroy (view);
+ GtkWidget *view_window;
+
+ view_window = gtk_object_get_data (GTK_OBJECT (menuitem), "view-window");
+ g_return_if_fail (view_window);
+ gtk_widget_destroy (GTK_WIDGET (view_window));
+}
+
+static void
+view_reply_to_sender (GtkWidget *widget, gpointer user_data)
+{
+ mail_view_data *data = (mail_view_data *) user_data;
+
+ mail_reply (data->source, data->msg, data->uid, FALSE);
+}
+
+static void
+view_reply_to_all (GtkWidget *widget, gpointer user_data)
+{
+ mail_view_data *data = (mail_view_data *) user_data;
+
+ mail_reply (data->source, data->msg, data->uid, TRUE);
+}
+
+static void
+view_forward_msg (GtkWidget *widget, gpointer user_data)
+{
+ mail_view_data *data = (mail_view_data *) user_data;
+
+ GPtrArray *uids;
+ EMsgComposer *composer;
+
+ uids = g_ptr_array_new();
+ g_ptr_array_add (uids, g_strdup (data->uid));
+
+ composer = E_MSG_COMPOSER (e_msg_composer_new ());
+ gtk_signal_connect (GTK_OBJECT (composer), "send",
+ GTK_SIGNAL_FUNC (composer_send_cb), NULL);
+
+ mail_do_forward_message (data->msg, data->source, uids, composer);
+}
+
+static void
+view_print_msg (GtkWidget *widget, gpointer user_data)
+{
+ mail_view_data *data = (mail_view_data *) user_data;
+
+ mail_print_msg (data->md);
+}
+
+static void
+view_delete_msg (GtkWidget *button, gpointer user_data)
+{
+ mail_view_data *data = (mail_view_data *) user_data;
+
+ GPtrArray *uids;
+
+ uids = g_ptr_array_new();
+ g_ptr_array_add (uids, g_strdup (data->uid));
+ mail_do_flag_messages (data->source, uids, TRUE,
+ CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
}
static GnomeUIInfo mail_view_toolbar [] = {
@@ -39,18 +133,18 @@ static GnomeUIInfo mail_view_toolbar [] = {
save_msg, GNOME_STOCK_PIXMAP_SAVE),*/
GNOMEUIINFO_ITEM_STOCK (N_("Reply"), N_("Reply to the sender of this message"),
- reply_to_sender, GNOME_STOCK_PIXMAP_MAIL_RPL),
+ view_reply_to_sender, GNOME_STOCK_PIXMAP_MAIL_RPL),
GNOMEUIINFO_ITEM_STOCK (N_("Reply to All"), N_("Reply to all recipients of this message"),
- reply_to_all, GNOME_STOCK_PIXMAP_MAIL_RPL),
+ view_reply_to_all, GNOME_STOCK_PIXMAP_MAIL_RPL),
- GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Forward this message"), forward_msg, GNOME_STOCK_PIXMAP_MAIL_FWD),
+ GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Forward this message"), view_forward_msg, GNOME_STOCK_PIXMAP_MAIL_FWD),
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), print_msg, GNOME_STOCK_PIXMAP_PRINT),
+ GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), view_print_msg, GNOME_STOCK_PIXMAP_PRINT),
- GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete this message"), delete_msg, GNOME_STOCK_PIXMAP_TRASH),
+ GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete this message"), view_delete_msg, GNOME_STOCK_PIXMAP_TRASH),
/*GNOMEUIINFO_SEPARATOR,*/
@@ -82,16 +176,17 @@ static GnomeUIInfo mail_view_menubar[] =
};
GtkWidget *
-mail_view_create (FolderBrowser *folder_browser)
+mail_view_create (CamelFolder *source, const char *uid, CamelMimeMessage *msg)
{
- CamelMimeMessage *msg;
GtkWidget *window;
GtkWidget *toolbar;
GtkWidget *mail_display;
- char *subject;
GnomeDockItemBehavior behavior;
+ char *subject;
+ mail_view_data *data;
+
+ data = mail_view_data_new (source, uid, msg);
- msg = folder_browser->mail_display->current_message;
subject = (char *) camel_mime_message_get_subject (msg);
if (!subject)
subject = "";
@@ -102,26 +197,30 @@ mail_view_create (FolderBrowser *folder_browser)
gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar),
mail_view_toolbar,
- NULL, folder_browser);
+ NULL, data);
behavior = GNOME_DOCK_ITEM_BEH_NORMAL;
if (!gnome_preferences_get_toolbar_detachable ())
behavior |= GNOME_DOCK_ITEM_BEH_LOCKED;
- gnome_app_add_toolbar (GNOME_APP (window),
+ gnome_app_add_toolbar (GNOME_APP (window),
GTK_TOOLBAR (toolbar),
GNOME_APP_TOOLBAR_NAME,
behavior,
GNOME_DOCK_TOP, 1, 0, 0);
gnome_app_create_menus (GNOME_APP (window), mail_view_menubar);
-
+
+ gtk_object_set_data_full (GTK_OBJECT (window), "mvd", data,
+ mail_view_data_free);
+
gtk_widget_ref (mail_view_menubar[0].widget);
gtk_object_set_data_full (GTK_OBJECT (window), "file",
mail_view_menubar[0].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (file_menu[0].widget);
+ gtk_object_set_data (GTK_OBJECT (file_menu[0].widget), "view-window", window);
gtk_object_set_data_full (GTK_OBJECT (window), "close",
file_menu[0].widget,
(GtkDestroyNotify) gtk_widget_unref);
@@ -131,11 +230,14 @@ mail_view_create (FolderBrowser *folder_browser)
mail_view_menubar[1].widget,
(GtkDestroyNotify) gtk_widget_unref);
- mail_display = mail_display_new (folder_browser);
+ mail_display = mail_display_new ();
mail_display_set_message (MAIL_DISPLAY (mail_display), CAMEL_MEDIUM (msg));
gtk_widget_set_usize (mail_display, 600, 600);
-
+ data->md = MAIL_DISPLAY (mail_display);
gnome_app_set_contents (GNOME_APP (window), mail_display);
return window;
}
+
+
+
diff --git a/mail/mail.h b/mail/mail.h
index 3ff7422370..2bc829dc36 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -31,8 +31,8 @@
void folder_browser_factory_init (void);
BonoboControl *folder_browser_factory_new_control (const char *uri);
-/* folder-browser */
-CamelFolder *mail_uri_to_folder (const char *uri);
+/* mail-config */
+void mail_config_druid (void);
/* mail-crypto */
char *mail_crypto_openpgp_decrypt (const char *ciphertext,
@@ -60,7 +60,7 @@ char *mail_get_message_body (CamelDataWrapper *data, gboolean want_plain,
/* mail-identify */
char *mail_identify_mime_part (CamelMimePart *part);
-/* mail-ops */
+/* mail-callbacks */
void fetch_mail (GtkWidget *widget, gpointer user_data);
void compose_msg (GtkWidget *widget, gpointer user_data);
void send_to_url (const char *url);
@@ -83,8 +83,12 @@ void providers_config (BonoboUIHandler *uih, void *user_data, const char *path);
void configure_folder(BonoboUIHandler *uih, void *user_data, const char *path);
+void mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, gboolean to_all);
+void composer_send_cb (EMsgComposer *composer, gpointer data);
+void mail_print_msg (MailDisplay *md);
+
/* mail view */
-GtkWidget *mail_view_create (FolderBrowser *folder_browser);
+GtkWidget *mail_view_create (CamelFolder *source, const char *uid, CamelMimeMessage *msg);
/* session */
void session_init (void);
diff --git a/mail/main.c b/mail/main.c
index 8ad567da21..372abf8b8a 100644
--- a/mail/main.c
+++ b/mail/main.c
@@ -30,9 +30,7 @@ main (int argc, char *argv [])
bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
textdomain (PACKAGE);
-#ifdef USE_BROKEN_THREADS
g_thread_init( NULL );
-#endif
od_assert_using_oaf ();
gnome_init_with_popt_table ("evolution-mail-component", VERSION,
@@ -59,13 +57,9 @@ main (int argc, char *argv [])
mail_config_init ();
component_factory_init ();
-#ifdef USE_BROKEN_THREADS
GDK_THREADS_ENTER ();
-#endif
bonobo_main ();
-#ifdef USE_BROKEN_THREADS
GDK_THREADS_LEAVE ();
-#endif
mail_config_write_on_exit ();
diff --git a/mail/message-list.c b/mail/message-list.c
index cdec9b2339..51ca345953 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -9,6 +9,7 @@
*
* (C) 2000 Helix Code, Inc.
*/
+
#include <config.h>
#include <gnome.h>
#include <bonobo/bonobo-main.h>
@@ -19,15 +20,17 @@
#include <camel/camel-folder.h>
#include "message-list.h"
#include "message-thread.h"
+#include "mail-threads.h"
+#include "mail-tools.h"
+#include "mail-ops.h"
#include "mail-config.h"
+#include "mail-vfolder.h"
+#include "mail-autofilter.h"
#include "mail.h"
#include "Mail.h"
#include "widgets/e-table/e-table-header-item.h"
#include "widgets/e-table/e-table-item.h"
-#include "mail-vfolder.h"
-#include "mail-autofilter.h"
-
#include "art/mail-new.xpm"
#include "art/mail-read.xpm"
#include "art/mail-replied.xpm"
@@ -107,6 +110,44 @@ get_message_info (MessageList *message_list, int row)
return camel_folder_get_message_info (message_list->folder, uid);
}
+/* Gets the uid of the message displayed at a given view row */
+static const char *
+get_message_uid (MessageList *message_list, int row)
+{
+ ETreeModel *model = (ETreeModel *)message_list->table_model;
+ ETreePath *node;
+ const char *uid;
+
+ if (row >= e_table_model_row_count (message_list->table_model))
+ return NULL;
+
+ node = e_tree_model_node_at_row (model, row);
+ g_return_val_if_fail (node != NULL, NULL);
+ uid = e_tree_model_node_get_data (model, node);
+
+ if (strncmp (uid, "uid:", 4) != 0)
+ return NULL;
+ uid += 4;
+
+ return uid;
+}
+
+static gint
+mark_msg_seen (gpointer data)
+{
+ MessageList *ml = data;
+ GPtrArray *uids;
+
+ if (!ml->cursor_uid)
+ return FALSE;
+
+ uids = g_ptr_array_new ();
+ g_ptr_array_add (uids, g_strdup (ml->cursor_uid));
+ mail_do_flag_messages (ml->folder, uids, FALSE,
+ CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+ return FALSE;
+}
+
/**
* message_list_select:
* @message_list: a MessageList
@@ -138,66 +179,30 @@ message_list_select (MessageList *message_list, int base_row,
last = e_table_model_row_count (message_list->table_model);
vrow = e_table_model_to_view_row (ets->table, base_row);
+
+ /* We don't know whether to use < or > due to "direction" */
while (vrow != last) {
- vrow += direction;
mrow = e_table_view_to_model_row (ets->table, vrow);
info = get_message_info (message_list, mrow);
if (info && (info->flags & mask) == flags) {
e_table_scrolled_set_cursor_row (ets, mrow);
+ mail_do_display_message (message_list, info->uid, mark_msg_seen);
return;
}
+ vrow += direction;
}
mail_display_set_message (message_list->parent_folder_browser->mail_display, NULL);
}
-static gint
-mark_msg_seen (gpointer data)
-{
- MessageList *ml = data;
- guint32 flags;
-
- if (!ml->cursor_uid)
- return FALSE;
-
- flags = camel_folder_get_message_flags (ml->folder, ml->cursor_uid);
- camel_folder_set_message_flags (ml->folder, ml->cursor_uid,
- CAMEL_MESSAGE_SEEN,
- CAMEL_MESSAGE_SEEN);
- return FALSE;
-}
-
/* select a message and display it */
static void
select_msg (MessageList *message_list, gint row)
{
- CamelException ex;
- CamelMimeMessage *message;
- const CamelMessageInfo *msg_info;
- MailDisplay *md = message_list->parent_folder_browser->mail_display;
-
- camel_exception_init (&ex);
-
- msg_info = get_message_info (message_list, row);
- if (msg_info) {
- message = camel_folder_get_message (message_list->folder,
- msg_info->uid, &ex);
- if (camel_exception_get_id (&ex)) {
- printf ("Unable to get message: %s\n",
- ex.desc?ex.desc:"unknown_reason");
- return;
- }
-
- if (message_list->seen_id)
- gtk_timeout_remove (message_list->seen_id);
+ const char *uid;
- mail_display_set_message (md, CAMEL_MEDIUM (message));
- gtk_object_unref (GTK_OBJECT (message));
-
- message_list->seen_id =
- gtk_timeout_add (1500, mark_msg_seen, message_list);
- } else
- mail_display_set_message (md, NULL);
+ uid = get_message_uid (message_list, row);
+ mail_do_display_message (message_list, uid, mark_msg_seen);
}
@@ -317,6 +322,7 @@ ml_tree_set_value_at (ETreeModel *etm, ETreePath *path, int col,
MessageList *message_list = model_data;
const CamelMessageInfo *msg_info;
char *uid;
+ GPtrArray *uids;
if (col != COL_MESSAGE_STATUS)
return;
@@ -330,8 +336,11 @@ ml_tree_set_value_at (ETreeModel *etm, ETreePath *path, int col,
if (!msg_info)
return;
- camel_folder_set_message_flags (message_list->folder, msg_info->uid,
- CAMEL_MESSAGE_SEEN, ~msg_info->flags);
+ uids = g_ptr_array_new ();
+ g_ptr_array_add (uids, g_strdup (uid));
+ mail_do_flag_messages (message_list->folder, uids, TRUE,
+ CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+
if (message_list->seen_id) {
gtk_timeout_remove (message_list->seen_id);
message_list->seen_id = 0;
@@ -571,38 +580,40 @@ message_list_init (GtkObject *object)
{
MessageList *message_list = MESSAGE_LIST (object);
char *spec;
-
+
message_list->table_model = (ETableModel *)
e_tree_simple_new (ml_tree_icon_at, ml_tree_value_at,
ml_tree_set_value_at,
ml_tree_is_cell_editable,
message_list);
e_tree_model_root_node_set_visible ((ETreeModel *)message_list->table_model, FALSE);
-
+
message_list_init_renderers (message_list);
message_list_init_header (message_list);
-
+
/*
* The etable
*/
-
+
spec = message_list_get_layout (message_list);
message_list->etable = e_table_scrolled_new (
message_list->header_model, message_list->table_model, spec);
g_free (spec);
-
+
gtk_object_set(GTK_OBJECT(message_list->etable),
"cursor_mode", E_TABLE_CURSOR_LINE,
"drawfocus", FALSE,
"drawgrid", FALSE,
NULL);
-
- gtk_signal_connect (GTK_OBJECT (message_list->etable), "realize",
- GTK_SIGNAL_FUNC (select_row), message_list);
-
+
+ /*
+ *gtk_signal_connect (GTK_OBJECT (message_list->etable), "realize",
+ * GTK_SIGNAL_FUNC (select_row), message_list);
+ */
+
gtk_signal_connect (GTK_OBJECT (message_list->etable), "cursor_change",
- GTK_SIGNAL_FUNC (on_cursor_change_cmd), message_list);
-
+ GTK_SIGNAL_FUNC (on_cursor_change_cmd), message_list);
+
gtk_signal_connect (GTK_OBJECT (message_list->etable), "right_click",
GTK_SIGNAL_FUNC (on_right_click), message_list);
@@ -662,7 +673,7 @@ message_list_destroy (GtkObject *object)
g_source_remove(message_list->idle_id);
if (message_list->folder)
- gtk_object_unref (GTK_OBJECT (message_list->folder));
+ camel_object_unref (CAMEL_OBJECT (message_list->folder));
GTK_OBJECT_CLASS (message_list_parent_class)->destroy (object);
}
@@ -820,86 +831,29 @@ build_flat (MessageList *ml, ETreePath *parent, GPtrArray *uids)
}
}
-void
-message_list_regenerate (MessageList *message_list, const char *search)
-{
- ETreeModel *etm = E_TREE_MODEL (message_list->table_model);
- GPtrArray *uids;
- int row = 0;
-
- e_table_model_pre_change(message_list->table_model);
-
- if (message_list->search) {
- g_free (message_list->search);
- message_list->search = NULL;
- }
-
- if (message_list->uid_rowmap) {
- g_hash_table_foreach (message_list->uid_rowmap,
- free_key, NULL);
- g_hash_table_destroy (message_list->uid_rowmap);
- }
- message_list->uid_rowmap = g_hash_table_new (g_str_hash, g_str_equal);
-
- if (search && camel_folder_has_search_capability (message_list->folder)) {
- CamelException ex;
-
- camel_exception_init (&ex);
- uids = camel_folder_search_by_expression (message_list->folder,
- search, &ex);
- if (camel_exception_is_set (&ex)) {
- e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
- "Search failed: %s",
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- } else
- message_list->search = g_strdup (search);
- } else
- uids = camel_folder_get_uids (message_list->folder);
-
- /* FIXME: free the old tree data */
-
- /* Clear the old contents, build the new */
- if (message_list->tree_root)
- e_tree_model_node_remove(etm, message_list->tree_root);
- message_list->tree_root =
- e_tree_model_node_insert(etm, NULL, 0, message_list);
- e_tree_model_node_set_expanded (etm, message_list->tree_root, TRUE);
-
- if (mail_config_thread_list()) {
- struct _container *head;
-
- head = thread_messages (message_list->folder, uids);
- build_tree (message_list, message_list->tree_root, head, &row);
- thread_messages_free (head);
- } else
- build_flat (message_list, message_list->tree_root, uids);
-
- if (search) {
- camel_folder_search_free(message_list->folder, uids);
- } else {
- camel_folder_free_uids (message_list->folder, uids);
- }
-
- e_table_model_changed (message_list->table_model);
- select_msg (message_list, 0);
-}
-
static void
-folder_changed (CamelFolder *f, int type, MessageList *message_list)
+folder_changed (CamelObject *o, gpointer event_data, gpointer user_data)
{
- message_list_regenerate (message_list, message_list->search);
+ MessageList *message_list = MESSAGE_LIST (user_data);
+ GDK_THREADS_ENTER(); /* Very important!!!! */
+ mail_do_regenerate_messagelist (message_list, message_list->search);
+ GDK_THREADS_LEAVE(); /* Very important!!!! */
}
static void
-message_changed (CamelFolder *f, const char *uid, MessageList *message_list)
+message_changed (CamelObject *o, gpointer uid, gpointer user_data)
{
+ MessageList *message_list = MESSAGE_LIST (user_data);
int row;
+ GDK_THREADS_ENTER(); /* Very important!!!! */
+
row = GPOINTER_TO_INT (g_hash_table_lookup (message_list->uid_rowmap,
uid));
if (row != -1)
e_table_model_row_changed (message_list->table_model, row);
+
+ GDK_THREADS_LEAVE(); /* Very important!!!! */
}
void
@@ -916,18 +870,20 @@ message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder)
camel_exception_init (&ex);
if (message_list->folder)
- gtk_object_unref (GTK_OBJECT (message_list->folder));
+ camel_object_unref (CAMEL_OBJECT (message_list->folder));
message_list->folder = camel_folder;
- gtk_signal_connect(GTK_OBJECT (camel_folder), "folder_changed",
+ camel_object_hook_event(CAMEL_OBJECT (camel_folder), "folder_changed",
folder_changed, message_list);
- gtk_signal_connect(GTK_OBJECT (camel_folder), "message_changed",
+ camel_object_hook_event(CAMEL_OBJECT (camel_folder), "message_changed",
message_changed, message_list);
- gtk_object_ref (GTK_OBJECT (camel_folder));
+ camel_object_ref (CAMEL_OBJECT (camel_folder));
- folder_changed (camel_folder, 0, message_list);
+ /*gtk_idle_add (regen_message_list, message_list);*/
+ /*folder_changed (CAMEL_OBJECT (camel_folder), 0, message_list);*/
+ mail_do_regenerate_messagelist (message_list, message_list->search);
}
GtkWidget *
@@ -953,13 +909,13 @@ static void
on_cursor_change_cmd (ETableScrolled *table, int row, gpointer user_data)
{
MessageList *message_list;
- const CamelMessageInfo *info;
+ const char *uid;
message_list = MESSAGE_LIST (user_data);
message_list->cursor_row = row;
- info = get_message_info (message_list, row);
- message_list->cursor_uid = info ? info->uid : NULL;
+ uid = get_message_uid (message_list, row);
+ message_list->cursor_uid = uid; /*NULL ok*/
if (!message_list->idle_id) {
message_list->idle_id =
@@ -972,10 +928,13 @@ on_cursor_change_cmd (ETableScrolled *table, int row, gpointer user_data)
static gint
idle_select_row (gpointer user_data)
{
- ETableScrolled *ets = user_data;
- int mrow = e_table_view_to_model_row (ets->table, 0);
+ MessageList *ml = MESSAGE_LIST (user_data);
+ ETableScrolled *ets = E_TABLE_SCROLLED (ml->etable);
+ int mrow;
- e_table_scrolled_set_cursor_row (ets, mrow);
+ mrow = e_table_view_to_model_row (ets->table, 0);
+ message_list_select (ml, mrow, MESSAGE_LIST_SELECT_NEXT,
+ 0, CAMEL_MESSAGE_SEEN);
return FALSE;
}
@@ -984,7 +943,7 @@ select_row (ETableScrolled *table, gpointer user_data)
{
MessageList *message_list = user_data;
- gtk_idle_add (idle_select_row, message_list->etable);
+ gtk_idle_add (idle_select_row, message_list);
}
static void
@@ -1082,12 +1041,12 @@ static void
mlfe_callback (int row, gpointer user_data)
{
struct message_list_foreach_data *mlfe_data = user_data;
- const CamelMessageInfo *info;
+ const char *uid;
- info = get_message_info (mlfe_data->message_list, row);
- if (info) {
+ uid = get_message_uid (mlfe_data->message_list, row);
+ if (uid) {
mlfe_data->callback (mlfe_data->message_list,
- info->uid,
+ uid,
mlfe_data->user_data);
}
}
@@ -1111,6 +1070,142 @@ message_list_toggle_threads (BonoboUIHandler *uih, void *user_data,
const char *path)
{
MessageList *ml = user_data;
- mail_config_set_thread_list(bonobo_ui_handler_menu_get_toggle_state (uih, path));
- message_list_regenerate (ml, ml->search);
+
+ mail_config_set_thread_list (bonobo_ui_handler_menu_get_toggle_state (uih, path));
+ mail_do_regenerate_messagelist (ml, ml->search);
+}
+
+/* ** REGENERATE MESSAGELIST ********************************************** */
+
+typedef struct regenerate_messagelist_input_s {
+ MessageList *ml;
+ char *search;
+} regenerate_messagelist_input_t;
+
+typedef struct regenerate_messagelist_data_s {
+ GPtrArray *uids;
+} regenerate_messagelist_data_t;
+
+static gchar *describe_regenerate_messagelist (gpointer in_data, gboolean gerund);
+static void setup_regenerate_messagelist (gpointer in_data, gpointer op_data, CamelException *ex);
+static void do_regenerate_messagelist (gpointer in_data, gpointer op_data, CamelException *ex);
+static void cleanup_regenerate_messagelist (gpointer in_data, gpointer op_data, CamelException *ex);
+
+static gchar *describe_regenerate_messagelist (gpointer in_data, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Rebuilding message view");
+ else
+ return g_strdup ("Rebuild message view");
+}
+
+static void setup_regenerate_messagelist (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ regenerate_messagelist_input_t *input = (regenerate_messagelist_input_t *) in_data;
+
+ if (!IS_MESSAGE_LIST (input->ml)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No messagelist specified to regenerate");
+ return;
+ }
+
+ gtk_object_ref (GTK_OBJECT (input->ml));
+ e_table_model_pre_change (input->ml->table_model);
+}
+
+static void do_regenerate_messagelist (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ regenerate_messagelist_input_t *input = (regenerate_messagelist_input_t *) in_data;
+ regenerate_messagelist_data_t *data = (regenerate_messagelist_data_t *) op_data;
+
+ if (input->ml->search) {
+ g_free (input->ml->search);
+ input->ml->search = NULL;
+ }
+
+ if (input->ml->uid_rowmap) {
+ g_hash_table_foreach (input->ml->uid_rowmap,
+ free_key, NULL);
+ g_hash_table_destroy (input->ml->uid_rowmap);
+ }
+ input->ml->uid_rowmap = g_hash_table_new (g_str_hash, g_str_equal);
+
+ mail_tool_camel_lock_up();
+
+ if (input->search) {
+ data->uids = camel_folder_search_by_expression (input->ml->folder,
+ input->search, ex);
+ if (camel_exception_is_set (ex)) {
+ mail_tool_camel_lock_down();
+ return;
+ }
+
+ input->ml->search = g_strdup (input->search);
+ } else
+ data->uids = camel_folder_get_uids (input->ml->folder);
+
+ mail_tool_camel_lock_down();
+}
+
+static void cleanup_regenerate_messagelist (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ regenerate_messagelist_input_t *input = (regenerate_messagelist_input_t *) in_data;
+ regenerate_messagelist_data_t *data = (regenerate_messagelist_data_t *) op_data;
+
+ ETreeModel *etm;
+
+ etm = E_TREE_MODEL (input->ml->table_model);
+
+ /* FIXME: free the old tree data */
+
+ if (data->uids == NULL) { /*exception*/
+ gtk_object_unref (GTK_OBJECT (input->ml));
+ return;
+ }
+
+ /* Clear the old contents, build the new */
+ if (input->ml->tree_root)
+ e_tree_model_node_remove(etm, input->ml->tree_root);
+ input->ml->tree_root =
+ e_tree_model_node_insert(etm, NULL, 0, input->ml);
+ e_tree_model_node_set_expanded (etm, input->ml->tree_root, TRUE);
+
+ if (mail_config_thread_list()) {
+ mail_do_thread_messages (input->ml, data->uids,
+ (gboolean) !(input->search),
+ build_tree);
+ } else {
+ build_flat (input->ml, input->ml->tree_root, data->uids);
+
+ if (input->search) {
+ camel_folder_search_free (input->ml->folder, data->uids);
+ } else {
+ camel_folder_free_uids (input->ml->folder, data->uids);
+ }
+ }
+
+ e_table_model_changed (input->ml->table_model);
+ select_row (NULL, input->ml);
+ g_free (input->search);
+ gtk_object_unref (GTK_OBJECT (input->ml));
+}
+
+static const mail_operation_spec op_regenerate_messagelist =
+{
+ describe_regenerate_messagelist,
+ sizeof (regenerate_messagelist_data_t),
+ setup_regenerate_messagelist,
+ do_regenerate_messagelist,
+ cleanup_regenerate_messagelist
+};
+
+void mail_do_regenerate_messagelist (MessageList *list, const gchar *search)
+{
+ regenerate_messagelist_input_t *input;
+
+ input = g_new (regenerate_messagelist_input_t, 1);
+ input->ml = list;
+ input->search = g_strdup (search);
+
+ mail_operation_queue (&op_regenerate_messagelist, input, TRUE);
}
diff --git a/mail/message-list.h b/mail/message-list.h
index 443d92d7f4..4f9719f30b 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -99,7 +99,6 @@ GtkType message_list_get_type (void);
BonoboObject *message_list_new (FolderBrowser *parent_folder_browser);
void message_list_set_folder (MessageList *message_list,
CamelFolder *camel_folder);
-void message_list_regenerate (MessageList *message_list, const char *search);
GtkWidget *message_list_get_widget (MessageList *message_list);
void message_list_foreach (MessageList *message_list,
diff --git a/mail/message-thread.c b/mail/message-thread.c
index f199c27341..fa362f04ee 100644
--- a/mail/message-thread.c
+++ b/mail/message-thread.c
@@ -31,9 +31,15 @@
#include <ctype.h>
#include "message-thread.h"
+#include "mail-tools.h"
+#include "mail-threads.h"
#define d(x)
+static struct _container *thread_messages(CamelFolder *folder, GPtrArray *uids);
+static void thread_messages_free(struct _container *);
+
+/* for debug only */
int dump_tree(struct _container *c, int depth);
static void
@@ -331,7 +337,7 @@ dump_tree(struct _container *c, int depth)
return count;
}
-void thread_messages_free(struct _container *c)
+static void thread_messages_free(struct _container *c)
{
struct _container *n;
@@ -407,7 +413,7 @@ sort_thread(struct _container **cp)
*cp = head;
}
-struct _container *
+static struct _container *
thread_messages(CamelFolder *folder, GPtrArray *uids)
{
GHashTable *id_table, *no_id_table;
@@ -419,13 +425,20 @@ thread_messages(CamelFolder *folder, GPtrArray *uids)
no_id_table = g_hash_table_new(NULL, NULL);
for (i=0;i<uids->len;i++) {
const CamelMessageInfo *mi;
+ mail_tool_camel_lock_up ();
mi = camel_folder_get_message_info (folder, uids->pdata[i]);
+ mail_tool_camel_lock_down ();
if (mi == NULL) {
g_warning("Folder doesn't contain uid %s", (char *)uids->pdata[i]);
continue;
}
+ if (mi == NULL) {
+ g_warning("Folder doesn't contain uid %s", uids->pdata[i]);
+ continue;
+ }
+
if (mi->message_id) {
d(printf("doing : %s\n", mi->message_id));
c = g_hash_table_lookup(id_table, mi->message_id);
@@ -495,6 +508,116 @@ thread_messages(CamelFolder *folder, GPtrArray *uids)
return head;
}
+/* ** THREAD MESSAGES ***************************************************** */
+
+typedef struct thread_messages_input_s {
+ MessageList *ml;
+ GPtrArray *uids;
+ gboolean use_camel_uidfree;
+ void (*build) (MessageList *, ETreePath *,
+ struct _container *, int *);
+} thread_messages_input_t;
+
+typedef struct thread_messages_data_s {
+ struct _container *container;
+ int row;
+} thread_messages_data_t;
+
+static gchar *describe_thread_messages (gpointer in_data, gboolean gerund);
+static void setup_thread_messages (gpointer in_data, gpointer op_data, CamelException *ex);
+static void do_thread_messages (gpointer in_data, gpointer op_data, CamelException *ex);
+static void cleanup_thread_messages (gpointer in_data, gpointer op_data, CamelException *ex);
+
+static gchar *describe_thread_messages (gpointer in_data, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Threading message list");
+ else
+ return g_strdup ("Thread message list");
+}
+
+static void setup_thread_messages (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ thread_messages_input_t *input = (thread_messages_input_t *) in_data;
+
+ if (!IS_MESSAGE_LIST (input->ml)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No messagelist to thread was provided to thread_messages");
+ return;
+ }
+
+ if (!input->uids) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No uids were provided to thread_messages");
+ return;
+ }
+
+ if (!input->build) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No build callback provided to thread_messages");
+ return;
+ }
+
+ gtk_object_ref (GTK_OBJECT (input->ml));
+}
+
+static void do_thread_messages (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ thread_messages_input_t *input = (thread_messages_input_t *) in_data;
+ thread_messages_data_t *data = (thread_messages_data_t *) op_data;
+
+ data->container = thread_messages (input->ml->folder, input->uids);
+ data->row = 0;
+}
+
+static void cleanup_thread_messages (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ thread_messages_input_t *input = (thread_messages_input_t *) in_data;
+ thread_messages_data_t *data = (thread_messages_data_t *) op_data;
+
+ (input->build) (input->ml, input->ml->tree_root,
+ data->container, &(data->row));
+ thread_messages_free (data->container);
+
+ if (input->use_camel_uidfree) {
+ mail_tool_camel_lock_up ();
+ camel_folder_free_uids (input->ml->folder, input->uids);
+ mail_tool_camel_lock_down ();
+ } else {
+ g_strfreev ((char **)input->uids->pdata);
+ g_ptr_array_free (input->uids, FALSE);
+ }
+
+ gtk_object_unref (GTK_OBJECT (input->ml));
+}
+
+static const mail_operation_spec op_thread_messages =
+{
+ describe_thread_messages,
+ sizeof (thread_messages_data_t),
+ setup_thread_messages,
+ do_thread_messages,
+ cleanup_thread_messages
+};
+
+void mail_do_thread_messages (MessageList *ml, GPtrArray *uids,
+ gboolean use_camel_uidfree,
+ void (*build) (MessageList *, ETreePath *,
+ struct _container *, int *))
+{
+ thread_messages_input_t *input;
+
+ input = g_new (thread_messages_input_t, 1);
+ input->ml = ml;
+ input->uids = uids;
+ input->use_camel_uidfree = use_camel_uidfree;
+ input->build = build;
+
+ mail_operation_queue (&op_thread_messages, input, TRUE);
+}
+
+/* ************************************************************************ */
+
#ifdef STANDALONE
static char *
@@ -546,7 +669,7 @@ main (int argc, char**argv)
}
#endif
- summary = camel_folder_get_summary(folder, ex);
+ summary = camel_folder_get_summary(folder);
thread_messages((CamelMessageInfo **)summary->pdata, summary->len);
return 0;
diff --git a/mail/message-thread.h b/mail/message-thread.h
index d66baacbdd..46a7a36b03 100644
--- a/mail/message-thread.h
+++ b/mail/message-thread.h
@@ -1,6 +1,9 @@
#ifndef _MESSAGE_THREAD_H
#define _MESSAGE_THREAD_H
+#include <gnome.h>
+#include "message-list.h"
+
struct _container {
struct _container *next,
*parent,
@@ -11,11 +14,10 @@ struct _container {
int order; /* the order of this message in the folder */
};
-struct _container *thread_messages(CamelFolder *folder, GPtrArray *uids);
-void thread_messages_free(struct _container *);
-
-/* for debug only */
-int dump_tree(struct _container *c, int depth);
+void mail_do_thread_messages (MessageList *ml, GPtrArray *uids,
+ gboolean use_camel_uidfree,
+ void (*build) (MessageList *, ETreePath *,
+ struct _container *, int *));
#endif /* !_MESSAGE_THREAD_H */
diff --git a/mail/session.c b/mail/session.c
index 7eaefd390c..3c5d52abb0 100644
--- a/mail/session.c
+++ b/mail/session.c
@@ -20,9 +20,7 @@ GHashTable *passwords;
* we deadlock....
*/
-#ifdef USE_BROKEN_THREADS
#define ASYNC_AUTH_CALLBACK
-#endif
#ifndef ASYNC_AUTH_CALLBACK
static void
@@ -63,7 +61,7 @@ mail_request_dialog (const char *prompt, gboolean secret, const char *key)
ans == NULL)
return NULL;
#else
- if (!mail_op_get_password (data, secret, &ans))
+ if (!mail_op_get_password (prompt, secret, &ans))
return NULL;
#endif
@@ -115,13 +113,99 @@ auth_callback (CamelAuthCallbackMode mode, char *data, gboolean secret,
return ans;
}
+/* ******************** */
+
+typedef struct _timeout_data_s {
+ CamelTimeoutCallback cb;
+ gpointer camel_data;
+ gboolean result;
+} timeout_data_t;
+
+static gchar *
+describe_camel_timeout (gpointer in_data, gboolean gerund)
+{
+ /* FIXME this is so wrong */
+
+ if (gerund)
+ return g_strdup ("Keeping connection alive");
+ else
+ return g_strdup ("Keep connection alive");
+}
+
+static void
+noop_camel_timeout (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+}
+
+static void
+do_camel_timeout (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ timeout_data_t *td = (timeout_data_t *) in_data;
+
+ td->result = (td->cb) (td->camel_data);
+}
+
+static const mail_operation_spec spec_camel_timeout =
+{
+ describe_camel_timeout,
+ 0,
+ noop_camel_timeout,
+ do_camel_timeout,
+ noop_camel_timeout
+};
+
+static gboolean
+camel_timeout (gpointer data)
+{
+ timeout_data_t *td = (timeout_data_t *) data;
+
+ if (td->result == FALSE) {
+ g_free (td);
+ return FALSE;
+ }
+
+ mail_operation_queue (&spec_camel_timeout, td, FALSE);
+ return TRUE;
+}
+
+static guint
+register_callback (guint32 interval, CamelTimeoutCallback cb, gpointer camel_data)
+{
+ timeout_data_t *td;
+
+ /* We do this because otherwise the timeout can get called
+ * more often than the dispatch thread can get rid of it,
+ * leading to timeout calls piling up, and we don't have a
+ * good way to watch the return values. It's not cool.
+ */
+ g_return_val_if_fail (interval > 1000, 0);
+
+ td = g_new (timeout_data_t, 1);
+ td->result = TRUE;
+ td->cb = cb;
+ td->camel_data = camel_data;
+
+ return gtk_timeout_add_full (interval, camel_timeout, NULL,
+ td, g_free);
+}
+
+static gboolean
+remove_callback (guint handle)
+{
+ gtk_timeout_remove (handle);
+ return TRUE;
+}
+
+/* ******************** */
+
void
session_init (void)
{
e_setup_base_dir ();
camel_init ();
- session = camel_session_new (auth_callback);
+ session = camel_session_new (auth_callback, register_callback,
+ remove_callback);
}
static gboolean
diff --git a/mail/test-thread.c b/mail/test-thread.c
index b9fb5bb0b2..7a389605ec 100644
--- a/mail/test-thread.c
+++ b/mail/test-thread.c
@@ -8,30 +8,44 @@
#include <stdio.h>
#include "mail-threads.h"
-#ifdef ENABLE_BROKEN_THREADS
-
-static void op_1( gpointer userdata );
-static void op_2( gpointer userdata );
-static void op_3( gpointer userdata );
-static void op_4( gpointer userdata );
-static void op_5( gpointer userdata );
-static void done( gpointer userdata );
+static gchar *desc_1 (gpointer in, gboolean gerund);
+static void op_1( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_2 (gpointer in, gboolean gerund);
+static void op_2( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_3 (gpointer in, gboolean gerund);
+static void op_3( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_4 (gpointer in, gboolean gerund);
+static void op_4( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_5 (gpointer in, gboolean gerund);
+static void op_5( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_6 (gpointer in, gboolean gerund);
+static gchar *desc_7 (gpointer in, gboolean gerund);
+static gchar *desc_8 (gpointer in, gboolean gerund);
+static void done( gpointer in, gpointer op, CamelException *ex );
+static void exception( gpointer in, gpointer op, CamelException *ex );
static gboolean queue_ops( void );
+const mail_operation_spec spec1 = { desc_1, 0, NULL, op_1, done };
+const mail_operation_spec spec2 = { desc_2, 0, NULL, op_2, done };
+const mail_operation_spec spec3 = { desc_3, 0, NULL, op_3, done };
+const mail_operation_spec spec4 = { desc_4, 0, NULL, op_4, NULL };
+const mail_operation_spec spec5 = { desc_5, 0, NULL, op_5, done };
+const mail_operation_spec spec6 = { desc_6, 0, exception, op_4, NULL };
+const mail_operation_spec spec7 = { desc_7, 0, NULL, exception, NULL };
+const mail_operation_spec spec8 = { desc_8, 0, NULL, op_4, exception };
+
static gboolean queue_ops( void )
{
int i;
- gchar buf[32];
g_message( "Top of queue_ops" );
- mail_operation_try( "The Crawling Progress Bar of Doom", op_1, done, "op1 finished" );
- mail_operation_try( "The Mysterious Message Setter", op_2, done, "op2 finished" );
- mail_operation_try( "The Error Dialog of No Return", op_3, done, "op3 finished" );
+ mail_operation_queue( &spec1, "op1 finished", FALSE );
+ mail_operation_queue( &spec2, "op2 finished", FALSE );
+ mail_operation_queue( &spec3, "op3 finished", FALSE );
for( i = 0; i < 3; i++ ) {
- sprintf( buf, "Queue Filler %d", i );
- mail_operation_try( buf, op_4, NULL, GINT_TO_POINTER( i ) );
+ mail_operation_queue( &spec4, GINT_TO_POINTER( i ), FALSE );
}
g_message( "Waiting for finish..." );
@@ -39,20 +53,23 @@ static gboolean queue_ops( void )
g_message( "Ops done -- queue some more!" );
- mail_operation_try( "Progress Bar Redux", op_1, NULL, NULL );
+ mail_operation_queue( &spec1, "done a second time", FALSE );
g_message( "Waiting for finish again..." );
mail_operation_wait_for_finish();
g_message( "Ops done -- more, more!" );
- mail_operation_try( "Dastardly Password Stealer", op_5, NULL, NULL );
+ mail_operation_queue( &spec5, "passwords stolen", FALSE );
for( i = 0; i < 3; i++ ) {
- sprintf( buf, "Queue Filler %d", i );
- mail_operation_try( buf, op_4, NULL, GINT_TO_POINTER( i ) );
+ mail_operation_queue( &spec4, GINT_TO_POINTER( i ), FALSE );
}
+ mail_operation_queue( &spec6, NULL, FALSE );
+ mail_operation_queue( &spec7, NULL, FALSE );
+ mail_operation_queue( &spec8, NULL, FALSE );
+
g_message( "Waiting for finish AGAIN..." );
mail_operation_wait_for_finish();
g_message( "Ops done again. Exiting 0" );
@@ -60,7 +77,12 @@ static gboolean queue_ops( void )
return FALSE;
}
-static void op_1( gpointer userdata )
+static void exception( gpointer in, gpointer op, CamelException *ex )
+{
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, "I don't feel like it.");
+}
+
+static void op_1( gpointer in, gpointer op, CamelException *ex )
{
gfloat pct;
@@ -73,7 +95,7 @@ static void op_1( gpointer userdata )
}
}
-static void op_2( gpointer userdata )
+static void op_2( gpointer in, gpointer op, CamelException *ex )
{
int i;
@@ -87,7 +109,7 @@ static void op_2( gpointer userdata )
sleep( 1 );
}
-static void op_3( gpointer userdata )
+static void op_3( gpointer in, gpointer op, CamelException *ex )
{
gfloat pct;
@@ -103,14 +125,14 @@ static void op_3( gpointer userdata )
sleep( 1 );
}
-static void op_4( gpointer userdata )
+static void op_4( gpointer in, gpointer op, CamelException *ex )
{
mail_op_hide_progressbar();
- mail_op_set_message( "Filler # %d", GPOINTER_TO_INT( userdata ) );
+ mail_op_set_message( "Filler # %d", GPOINTER_TO_INT( in ) );
sleep( 1 );
}
-static void op_5( gpointer userdata )
+static void op_5( gpointer in, gpointer op, CamelException *ex )
{
gchar *pass;
gboolean ret;
@@ -128,26 +150,81 @@ static void op_5( gpointer userdata )
sleep( 1 );
}
-static void done( gpointer userdata )
+static void done( gpointer in, gpointer op, CamelException *ex )
{
- g_message( "Operation done: %s", (gchar *) userdata );
+ g_message( "Operation done: %s", (gchar *) in );
}
-int main( int argc, char **argv )
+static gchar *desc_1 (gpointer in, gboolean gerund)
{
- g_thread_init( NULL );
- gnome_init( "test-thread", "0.0", argc, argv );
- gtk_idle_add( (GtkFunction) queue_ops, NULL );
- gtk_main();
- return 0;
+ if (gerund)
+ return g_strdup ("Showing the Crawling Progress Bar of Doom");
+ else
+ return g_strdup ("Progress Bar");
+}
+
+static gchar *desc_2 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Exploring the Mysterious Message Setter");
+ else
+ return g_strdup ("Explore");
+}
+
+static gchar *desc_3 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Dare the Error Dialog of No Return");
+ else
+ return g_strdup ("Dare");
+}
+
+static gchar *desc_4 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup_printf ("Filling Queue Space -- %d", GPOINTER_TO_INT (in));
+ else
+ return g_strdup_printf ("Filler -- %d", GPOINTER_TO_INT (in));
+}
+
+static gchar *desc_5 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Stealing your Password");
+ else
+ return g_strdup ("The Dastardly Password Stealer");
+}
+
+static gchar *desc_6 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Setting exception on setup");
+ else
+ return g_strdup ("Exception on setup");
+}
+
+static gchar *desc_7 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Setting exception in process");
+ else
+ return g_strdup ("Exception coming soon");
+}
+
+static gchar *desc_8 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Setting exception in cleanup");
+ else
+ return g_strdup ("Exception in cleanup");
}
-#else
int main( int argc, char **argv )
{
- g_message( "Threads aren't enabled, so they cannot be tested." );
+ g_thread_init( NULL );
+ gnome_init( "test-thread", "0.0", argc, argv );
+ gtk_idle_add( (GtkFunction) queue_ops, NULL );
+ gtk_main();
return 0;
}
-
-#endif
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 56dd6665a4..f160418e7d 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -148,6 +148,17 @@
(e_shell_folder_title_bar_set_title): Set both `label' and
`button_label'.
+2000-07-21 Peter Williams <peterw@helixcode.com>
+
+ * evolution-shell-client.c (user_select_folder): Don't use
+ g_main_loop to block the caller; this will break when
+ threads are enabled and GDK_THREADS_ENTER deadlocks. Use
+ gtk_main / gtk_main_exit to enter and exit the main loop,
+ which handles the recursive case correctly.
+ (impl_FolderSelectionListener_selected): Same.
+ (impl_FolderSelectionListener_cancel): Same.
+ (struct _FolderSelectionListenerServant): No more main_loop member.
+
2000-07-21 Ettore Perazzoli <ettore@helixcode.com>
* e-shell-view.c (storage_set_view_box_button_release_event_cb):
diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c
index d4469990b0..4e4fd830b3 100644
--- a/shell/evolution-shell-client.c
+++ b/shell/evolution-shell-client.c
@@ -49,7 +49,6 @@ static gboolean FolderSelectionListener_vtables_initialized = FALSE;
struct _FolderSelectionListenerServant {
POA_Evolution_FolderSelectionListener servant;
- GMainLoop *main_loop;
char **uri_return;
char **physical_uri_return;
};
@@ -71,7 +70,7 @@ impl_FolderSelectionListener_selected (PortableServer_Servant servant,
if (listener_servant->physical_uri_return != NULL)
* (listener_servant->physical_uri_return) = g_strdup (physical_uri);
- g_main_quit (listener_servant->main_loop);
+ gtk_main_quit ();
}
static void
@@ -88,7 +87,7 @@ impl_FolderSelectionListener_cancel (PortableServer_Servant servant,
if (listener_servant->physical_uri_return != NULL)
* (listener_servant->physical_uri_return) = NULL;
- g_main_quit (listener_servant->main_loop);
+ gtk_main_quit ();
}
static void
@@ -109,7 +108,6 @@ init_FolderSelectionListener_vtables (void)
static Evolution_FolderSelectionListener
create_folder_selection_listener_interface (char **result,
- GMainLoop *main_loop,
char **uri_return,
char **physical_uri_return)
{
@@ -123,7 +121,6 @@ create_folder_selection_listener_interface (char **result,
servant = g_new0 (FolderSelectionListenerServant, 1);
servant->servant.vepv = &FolderSelectionListener_vepv;
- servant->main_loop = main_loop;
servant->uri_return = uri_return;
servant->physical_uri_return = physical_uri_return;
@@ -172,21 +169,17 @@ user_select_folder (EvolutionShellClient *shell_client,
{
Evolution_FolderSelectionListener listener_interface;
Evolution_Shell corba_shell;
- GMainLoop *main_loop;
CORBA_Environment ev;
Evolution_Shell_FolderTypeList corba_type_list;
int num_possible_types;
char *result;
result = NULL;
- main_loop = g_main_new (FALSE);
- listener_interface = create_folder_selection_listener_interface (&result, main_loop,
- uri_return, physical_uri_return);
- if (listener_interface == CORBA_OBJECT_NIL) {
- g_main_destroy (main_loop);
+ listener_interface = create_folder_selection_listener_interface (&result, uri_return,
+ physical_uri_return);
+ if (listener_interface == CORBA_OBJECT_NIL)
return;
- }
CORBA_exception_init (&ev);
@@ -213,7 +206,7 @@ user_select_folder (EvolutionShellClient *shell_client,
return;
}
- g_main_run (main_loop);
+ gtk_main();
CORBA_Object_release (listener_interface, &ev);