diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 2000-02-18 06:16:33 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 2000-02-18 06:16:33 +0800 |
commit | 39400a38c775a76faa342d519454d789e55bb90d (patch) | |
tree | 62b607d5e8edfc3b8f82253a39e0f58293ea6144 /camel | |
parent | 0996e4f1ac82ee9fe15be3367d90e0dffd21d936 (diff) | |
download | gsoc2013-evolution-39400a38c775a76faa342d519454d789e55bb90d.tar.gz gsoc2013-evolution-39400a38c775a76faa342d519454d789e55bb90d.tar.zst gsoc2013-evolution-39400a38c775a76faa342d519454d789e55bb90d.zip |
use camel_stream_reset instead of seek. The formatter should be able to
2000-02-17 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/camel-formatter.c (handle_text_plain):
(handle_text_html): use camel_stream_reset instead
of seek. The formatter should be able to work
with all streams, not only seekable streams.
In the case where some provider implementation
would not be able to provide a reset method
to their stream, implementors would have
to find a workaround.
* camel/camel-session.c (camel_session_new): use
(void) instean of () in function decl.
* camel/camel-folder.c: ifdef async operation
related code.
* camel/camel-seekable-stream.c (_seek): added a warning.
(_reset): default implementation of reset for seekable
stream.
* camel/camel-mime-message.h: set_received_date declaration fix.
cosmetic changes.
* camel/providers/mbox/camel-mbox-provider.c (camel_provider_module_init):
use (void) instead of ().
* camel/camel-stream.c (camel_stream_reset):
new method for CamelStream.
svn path=/trunk/; revision=1835
Diffstat (limited to 'camel')
-rw-r--r-- | camel/camel-folder-pt-proxy.c | 2 | ||||
-rw-r--r-- | camel/camel-folder.c | 21 | ||||
-rw-r--r-- | camel/camel-folder.h | 2 | ||||
-rw-r--r-- | camel/camel-formatter.c | 12 | ||||
-rw-r--r-- | camel/camel-medium.c | 3 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 1 | ||||
-rw-r--r-- | camel/camel-mime-message.h | 104 | ||||
-rw-r--r-- | camel/camel-seekable-stream.c | 21 | ||||
-rw-r--r-- | camel/camel-session.c | 2 | ||||
-rw-r--r-- | camel/camel-session.h | 2 | ||||
-rw-r--r-- | camel/camel-stream-fs.c | 2 | ||||
-rw-r--r-- | camel/camel-stream.c | 22 | ||||
-rw-r--r-- | camel/camel-stream.h | 4 | ||||
-rw-r--r-- | camel/providers/mbox/Makefile.am | 8 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-provider.c | 6 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-store.c | 1 |
16 files changed, 147 insertions, 66 deletions
diff --git a/camel/camel-folder-pt-proxy.c b/camel/camel-folder-pt-proxy.c index 27e89438c3..e2e25c9149 100644 --- a/camel/camel-folder-pt-proxy.c +++ b/camel/camel-folder-pt-proxy.c @@ -117,8 +117,10 @@ camel_folder_pt_proxy_class_init (CamelFolderPtProxyClass *camel_folder_pt_proxy camel_folder_class->init_with_store = _init_with_store; camel_folder_class->open = _open; camel_folder_class->close = _close; +#ifdef FOLDER_ASYNC_TEST camel_folder_class->open_async = _open_async; camel_folder_class->close_async = _close_async; +#endif camel_folder_class->set_name = _set_name; camel_folder_class->get_name = _get_name; camel_folder_class->can_hold_folders = _can_hold_folders; diff --git a/camel/camel-folder.c b/camel/camel-folder.c index d7366d51b4..fa0cde0245 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -49,6 +49,8 @@ static void _close (CamelFolder *folder, gboolean expunge, CamelException *ex); +#ifdef FOLDER_ASYNC_TEST + /* Async operations are not used for the moment */ static void _open_async (CamelFolder *folder, CamelFolderOpenMode mode, @@ -61,6 +63,7 @@ static void _close_async (CamelFolder *folder, gpointer user_data, CamelException *ex); +#endif static void _set_name (CamelFolder *folder, const gchar *name, @@ -132,9 +135,13 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) /* virtual method definition */ camel_folder_class->init_with_store = _init_with_store; camel_folder_class->open = _open; +#ifdef FOLDER_ASYNC_TEST camel_folder_class->open_async = _open_async; +#endif camel_folder_class->close = _close; +#ifdef FOLDER_ASYNC_TEST camel_folder_class->close_async = _close_async; +#endif camel_folder_class->set_name = _set_name; camel_folder_class->get_name = _get_name; camel_folder_class->get_full_name = _get_full_name; @@ -302,7 +309,7 @@ camel_folder_open (CamelFolder *folder, - +#ifdef FOLDER_ASYNC_TEST static void _open_async (CamelFolder *folder, @@ -317,6 +324,7 @@ _open_async (CamelFolder *folder, + /** * camel_folder_open: Open a folder * @folder: The folder object @@ -347,7 +355,7 @@ camel_folder_open_async (CamelFolder *folder, } - +#endif /* FOLDER_ASYNC_TEST */ @@ -392,6 +400,7 @@ camel_folder_close (CamelFolder *folder, +#ifdef FOLDER_ASYNC_TEST static void @@ -442,7 +451,7 @@ camel_folder_close_async (CamelFolder *folder, } - +#endif static void @@ -1686,6 +1695,10 @@ _get_message_uid_by_number (CamelFolder *folder, gint message_number, CamelExcep return NULL; } + +const gchar * +camel_folder_get_message_uid_by_number (CamelFolder *folder, gint message_number, CamelException *ex); + /** * camel_folder_get_message_uid_by_number: get the UID corresponding to a message number * @folder: Folder object @@ -1710,6 +1723,8 @@ camel_folder_get_message_uid_by_number (CamelFolder *folder, gint message_number /* if (!folder->has_uid_capability) return NULL; */ /* return CF_CLASS (folder)->get_message_uid_by_number (folder, message_number, ex); */ + + return NULL; } diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 2a7b0caced..e3c05307d8 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -60,8 +60,10 @@ typedef enum { FOLDER_OPEN_RW = 3 /* folder is read/write */ } CamelFolderOpenMode; + typedef void (*CamelFolderAsyncCallback) (); + struct _CamelFolder { GtkObject parent_object; diff --git a/camel/camel-formatter.c b/camel/camel-formatter.c index bcdb490faa..a0231419da 100644 --- a/camel/camel-formatter.c +++ b/camel/camel-formatter.c @@ -611,10 +611,7 @@ handle_text_plain (CamelFormatter *formatter, CamelDataWrapper *wrapper) /* get the output stream of the data wrapper */ wrapper_output_stream = camel_data_wrapper_get_output_stream (wrapper); - if (CAMEL_IS_SEEKABLE_STREAM (wrapper_output_stream)) - camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (wrapper_output_stream), - 0, - CAMEL_STREAM_SET); + camel_stream_reset (wrapper_output_stream); do { @@ -623,7 +620,7 @@ handle_text_plain (CamelFormatter *formatter, CamelDataWrapper *wrapper) nb_bytes_read = camel_stream_read (wrapper_output_stream, tmp_buffer, 4096); - printf ("after camel_stream_read, nb_bytes_read=%d\n", nb_bytes_read); + /* If there's any text, write it to the stream */ if (nb_bytes_read > 0) { @@ -667,10 +664,7 @@ handle_text_html (CamelFormatter *formatter, CamelDataWrapper *wrapper) /* get the output stream of the data wrapper */ wrapper_output_stream = camel_data_wrapper_get_output_stream (wrapper); - if (CAMEL_IS_SEEKABLE_STREAM (wrapper_output_stream)) - camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (wrapper_output_stream), - 0, - CAMEL_STREAM_SET); + camel_stream_reset (wrapper_output_stream); /* write the header */ camel_stream_write_string (formatter->priv->stream, diff --git a/camel/camel-medium.c b/camel/camel-medium.c index 95d00280e1..a381319063 100644 --- a/camel/camel-medium.c +++ b/camel/camel-medium.c @@ -196,8 +196,6 @@ static const gchar * _get_header (CamelMedium *medium, const gchar *header_name) { - gchar *old_header_name; - gchar *old_header_value; gchar *header_value; header_value = (gchar *)g_hash_table_lookup (medium->headers, header_name); @@ -235,7 +233,6 @@ camel_medium_get_content_object (CamelMedium *medium) static void _set_content_object (CamelMedium *medium, CamelDataWrapper *content) { - GMimeContentField *object_content_field; CAMEL_LOG_FULL_DEBUG ("Entering CamelMedium::set_content_object\n"); if (medium->content) { diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index ffb94a0fb3..8fe1764f96 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -627,7 +627,6 @@ static void _set_recipient_list_from_string (CamelMimeMessage *message, gchar *recipient_type, gchar *recipients_string) { GList *recipients_list; - GList *tmp; CAMEL_LOG_FULL_DEBUG ("CamelMimeMessage::_set_recipient_list_from_string parsing ##%s##\n", recipients_string); recipients_list = string_split ( diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h index 69cf840a62..9187e82ca4 100644 --- a/camel/camel-mime-message.h +++ b/camel/camel-mime-message.h @@ -87,23 +87,37 @@ typedef struct { CamelMimePartClass parent_class; /* Virtual methods */ - void (*set_received_date) (CamelMimeMessage *mime_message, gchar *received_date); - const gchar * (*get_received_date) (CamelMimeMessage *mime_message); - const gchar * (*get_sent_date) (CamelMimeMessage *mime_message); - void (*set_reply_to) (CamelMimeMessage *mime_message, const gchar *reply_to); - const gchar * (*get_reply_to) (CamelMimeMessage *mime_message); - void (*set_subject) (CamelMimeMessage *mime_message, const gchar *subject); - const gchar * (*get_subject) (CamelMimeMessage *mime_message); - void (*set_from) (CamelMimeMessage *mime_message, const gchar *from); - const gchar * (*get_from) (CamelMimeMessage *mime_message); - void (*add_recipient) (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); - void (*remove_recipient) (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); - const GList * (*get_recipients) (CamelMimeMessage *mime_message, const gchar *recipient_type); - void (*set_flag) (CamelMimeMessage *mime_message, const gchar *flag, gboolean value); - gboolean (*get_flag) (CamelMimeMessage *mime_message, const gchar *flag); - GList * (*get_flag_list) (CamelMimeMessage *mime_message); - void (*set_message_number)(CamelMimeMessage *mime_message, guint number); - guint (*get_message_number)(CamelMimeMessage *mime_message); + void (*set_received_date) (CamelMimeMessage *mime_message, + const gchar *received_date); + const gchar * (*get_received_date) (CamelMimeMessage *mime_message); + const gchar * (*get_sent_date) (CamelMimeMessage *mime_message); + void (*set_reply_to) (CamelMimeMessage *mime_message, + const gchar *reply_to); + const gchar * (*get_reply_to) (CamelMimeMessage *mime_message); + void (*set_subject) (CamelMimeMessage *mime_message, + const gchar *subject); + const gchar * (*get_subject) (CamelMimeMessage *mime_message); + void (*set_from) (CamelMimeMessage *mime_message, + const gchar *from); + const gchar * (*get_from) (CamelMimeMessage *mime_message); + void (*add_recipient) (CamelMimeMessage *mime_message, + const gchar *recipient_type, + const gchar *recipient); + void (*remove_recipient) (CamelMimeMessage *mime_message, + const gchar *recipient_type, + const gchar *recipient); + const GList * (*get_recipients) (CamelMimeMessage *mime_message, + const gchar *recipient_type); + void (*set_flag) (CamelMimeMessage *mime_message, + const gchar *flag, + gboolean value); + gboolean (*get_flag) (CamelMimeMessage *mime_message, + const gchar *flag); + GList * (*get_flag_list) (CamelMimeMessage *mime_message); + void (*set_message_number) (CamelMimeMessage *mime_message, + guint number); + guint (*get_message_number) (CamelMimeMessage *mime_message); + } CamelMimeMessageClass; @@ -113,28 +127,40 @@ GtkType camel_mime_message_get_type (void); /* public methods */ -CamelMimeMessage *camel_mime_message_new_with_session (CamelSession *session); - - -void camel_mime_message_set_received_date (CamelMimeMessage *mime_message, const gchar *received_date); -const gchar *camel_mime_message_get_received_date (CamelMimeMessage *mime_message); -const gchar *camel_mime_message_get_sent_date (CamelMimeMessage *mime_message); -void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, const gchar *reply_to); -const gchar *camel_mime_message_get_reply_to (CamelMimeMessage *mime_message); -void camel_mime_message_set_subject (CamelMimeMessage *mime_message, const gchar *subject); -const gchar *camel_mime_message_get_subject (CamelMimeMessage *mime_message); -void camel_mime_message_set_from (CamelMimeMessage *mime_message, const gchar *from); -const gchar *camel_mime_message_get_from (CamelMimeMessage *mime_message); - -void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -const GList *camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type); - -void camel_mime_message_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value); -gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, const gchar *flag); -GList *camel_mime_message_get_flag_list (CamelMimeMessage *mime_message); - -guint camel_mime_message_get_message_number (CamelMimeMessage *mime_message); +CamelMimeMessage * camel_mime_message_new_with_session (CamelSession *session); + + +void camel_mime_message_set_received_date (CamelMimeMessage *mime_message, + const gchar *received_date); +const gchar * camel_mime_message_get_received_date (CamelMimeMessage *mime_message); +const gchar * camel_mime_message_get_sent_date (CamelMimeMessage *mime_message); +void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, + const gchar *reply_to); +const gchar * camel_mime_message_get_reply_to (CamelMimeMessage *mime_message); +void camel_mime_message_set_subject (CamelMimeMessage *mime_message, + const gchar *subject); +const gchar * camel_mime_message_get_subject (CamelMimeMessage *mime_message); +void camel_mime_message_set_from (CamelMimeMessage *mime_message, + const gchar *from); +const gchar * camel_mime_message_get_from (CamelMimeMessage *mime_message); + +void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, + const gchar *recipient_type, + const gchar *recipient); +void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, + const gchar *recipient_type, + const gchar *recipient); +const GList * camel_mime_message_get_recipients (CamelMimeMessage *mime_message, + const gchar *recipient_type); + +void camel_mime_message_set_flag (CamelMimeMessage *mime_message, + const gchar *flag, + gboolean value); +gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, + const gchar *flag); +GList * camel_mime_message_get_flag_list (CamelMimeMessage *mime_message); + +guint camel_mime_message_get_message_number (CamelMimeMessage *mime_message); #ifdef __cplusplus } diff --git a/camel/camel-seekable-stream.c b/camel/camel-seekable-stream.c index 55bbbd611a..1afb02d442 100644 --- a/camel/camel-seekable-stream.c +++ b/camel/camel-seekable-stream.c @@ -35,19 +35,24 @@ static CamelStreamClass *parent_class=NULL; /* Returns the class for a CamelSeekableStream */ #define CSS_CLASS(so) CAMEL_SEEKABLE_STREAM_CLASS (GTK_OBJECT(so)->klass) -static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy); +static gint _seek (CamelSeekableStream *stream, + gint offset, + CamelStreamSeekPolicy policy); +static void _reset (CamelStream *stream); static void camel_seekable_stream_class_init (CamelSeekableStreamClass *camel_seekable_stream_class) { CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_seekable_stream_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_seekable_stream_class); parent_class = gtk_type_class (camel_stream_get_type ()); + /* seekable stream methods */ camel_seekable_stream_class->seek = _seek; + /* camel stream methods overload */ + camel_stream_class->reset = _reset; } GtkType @@ -82,6 +87,7 @@ _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy) { + g_warning ("CamelSeekableStream::seek called on default implementation \n"); return -1; } @@ -124,6 +130,17 @@ camel_seekable_stream_get_current_position (CamelSeekableStream *stream) +/* a default implementation of reset for seekable streams */ +static void +_reset (CamelStream *stream) +{ + CamelSeekableStream *seekable_stream; + + g_assert (stream); + seekable_stream = CAMEL_SEEKABLE_STREAM (stream); + + camel_seekable_stream_seek (seekable_stream, 0, CAMEL_STREAM_SET); +} diff --git a/camel/camel-session.c b/camel/camel-session.c index 923d60c629..97ee59a491 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -84,7 +84,7 @@ camel_session_get_type (void) CamelSession * -camel_session_new () +camel_session_new (void) { return gtk_type_new (CAMEL_SESSION_TYPE); } diff --git a/camel/camel-session.h b/camel/camel-session.h index bd7af5dc38..6642a20f43 100644 --- a/camel/camel-session.h +++ b/camel/camel-session.h @@ -74,7 +74,7 @@ typedef struct { GtkType camel_session_get_type (void); -CamelSession *camel_session_new (); +CamelSession *camel_session_new (void); void camel_session_set_provider (CamelSession *session, CamelProvider *provider); CamelStore *camel_session_get_store_for_protocol (CamelSession *session, const gchar *protocol); CamelStore *camel_session_get_store (CamelSession *session, const gchar *url_string); diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index d6ba5fba13..f2aab64910 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -247,6 +247,8 @@ _init_with_name (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode stream_fs->name = g_strdup (name); CSFS_CLASS (stream_fs)->init_with_fd (stream_fs, fd); + gtk_signal_emit_by_name (GTK_OBJECT (stream_fs), "data_available"); + } diff --git a/camel/camel-stream.c b/camel/camel-stream.c index bad7f6811c..a339b23e18 100644 --- a/camel/camel-stream.c +++ b/camel/camel-stream.c @@ -68,6 +68,7 @@ camel_stream_class_init (CamelStreamClass *camel_stream_class) camel_stream_class->available = NULL; camel_stream_class->eos = NULL; camel_stream_class->close = default_camel_close; + camel_stream_class->close = NULL; /* virtual method overload */ @@ -158,7 +159,7 @@ camel_stream_flush (CamelStream *stream) * camel_stream_available: * @stream: a CamelStream object * - * Return value: the number of bytes available. + * Return value: %TRUE if some data is available for reading, %FALSE otherwise **/ gboolean camel_stream_available (CamelStream *stream) @@ -197,6 +198,25 @@ camel_stream_close (CamelStream *stream) +/** + * camel_stream_reset: reset a stream + * @stream: the stream object + * + * Reset a stream, that is put it in a state + * where it can be read from the begining. + * All streams in camel are not seekable, + * but they must all be resettable. + * + **/ +void +camel_stream_reset (CamelStream *stream) +{ + CS_CLASS (stream)->reset (stream); +} + + + + /***************** Utility functions ********************/ /** diff --git a/camel/camel-stream.h b/camel/camel-stream.h index 0496e13d7f..738160306b 100644 --- a/camel/camel-stream.h +++ b/camel/camel-stream.h @@ -60,9 +60,10 @@ typedef struct { gint (*read) (CamelStream *stream, gchar *buffer, gint n); gint (*write) (CamelStream *stream, const gchar *buffer, gint n); void (*flush) (CamelStream *stream); - gint (*available) (CamelStream *stream); + gboolean (*available) (CamelStream *stream); gboolean (*eos) (CamelStream *stream); void (*close) (CamelStream *stream); + void (*reset) (CamelStream *stream); } CamelStreamClass; @@ -83,6 +84,7 @@ void camel_stream_flush (CamelStream *stream); gboolean camel_stream_available (CamelStream *stream); gboolean camel_stream_eos (CamelStream *stream); void camel_stream_close (CamelStream *stream); +void camel_stream_reset (CamelStream *stream); diff --git a/camel/providers/mbox/Makefile.am b/camel/providers/mbox/Makefile.am index 62cfeaba22..eca7233ae3 100644 --- a/camel/providers/mbox/Makefile.am +++ b/camel/providers/mbox/Makefile.am @@ -4,9 +4,10 @@ SUBDIRS = libcamelmboxincludedir = $(includedir)/camel -lib_LTLIBRARIES = libcamelmbox.la -#provider_LTLIBRARIES = libcamelmbox.la +providerdir = $(pkglibdir)/camel-providers/$(VERSION) + +provider_LTLIBRARIES = libcamelmbox.la INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ -I$(top_srcdir)/intl \ @@ -34,6 +35,7 @@ libcamelmboxinclude_HEADERS = \ libcamelmbox_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) #libcamelmbox_la_LIBADD = -L$(top_srcdir)/libibex -libex -libcamelmbox_la_LIBADD = $(top_srcdir)/libibex/libibex.la $(UNICODE_LIBS) +#libcamelmbox_la_LIBADD = $(top_srcdir)/libibex/libibex.la $(UNICODE_LIBS) +libcamelmbox_la_LIBADD = -L$(top_srcdir)/libibex -libex $(UNICODE_LIBS) EXTRA_DIST = diff --git a/camel/providers/mbox/camel-mbox-provider.c b/camel/providers/mbox/camel-mbox-provider.c index 873dca0954..a63d832d5d 100644 --- a/camel/providers/mbox/camel-mbox-provider.c +++ b/camel/providers/mbox/camel-mbox-provider.c @@ -39,7 +39,11 @@ static CamelProvider _mbox_provider = { }; CamelProvider * -camel_provider_module_init () +camel_provider_module_init (void); + + +CamelProvider * +camel_provider_module_init (void) { _mbox_provider.object_type = camel_mbox_store_get_type(); return &_mbox_provider; diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c index f8b3b62718..12923b1b5a 100644 --- a/camel/providers/mbox/camel-mbox-store.c +++ b/camel/providers/mbox/camel-mbox-store.c @@ -54,7 +54,6 @@ camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class) static void camel_mbox_store_init (gpointer object, gpointer klass) { - CamelMboxStore *mbox_store = CAMEL_MBOX_STORE (object); CamelStore *store = CAMEL_STORE (object); store->separator = '/'; |