From 68a4fe903696822894def062d300155f2646cc14 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 22 Sep 2010 16:19:16 -0400 Subject: [PATCH] Rename blocking Camel methods. Rename blocking Camel methods by appending a "sync" suffix. e.g. camel_folder_get_message() becomes camel_folder_get_message_sync(). Several reasons: The asynchronous functions which are about to be added will take the old names, along with a corresponding "finish" function. Along with the GCancellable argument, the "sync" suffix makes it clear to clients that the function may block. Clients are encouraged to use the asynchronous functions instead, unless they know for certain the function will not block (e.g. writing to a CamelMemStream). The "sync" suffix makes it easy to grep for blocking Camel calls in Evolution and identify places where the main loop is being blocked. These are bugs, and they're still lurking in Evolution. --- camel/camel-cipher-context.c | 197 ++-- camel/camel-cipher-context.h | 25 +- camel/camel-data-wrapper.c | 318 +++--- camel/camel-data-wrapper.h | 34 +- camel/camel-disco-diary.c | 10 +- camel/camel-disco-folder.c | 177 ++-- camel/camel-disco-store.c | 79 +- camel/camel-filter-driver.c | 42 +- camel/camel-filter-search.c | 2 +- camel/camel-folder-search.c | 11 +- camel/camel-folder-summary.c | 4 +- camel/camel-folder.c | 264 ++--- camel/camel-folder.h | 172 ++-- camel/camel-gpg-context.c | 101 +- camel/camel-mime-message.c | 37 +- camel/camel-mime-part-utils.c | 6 +- camel/camel-mime-part.c | 59 +- camel/camel-mime-part.h | 19 +- camel/camel-multipart-signed.c | 28 +- camel/camel-multipart.c | 52 +- camel/camel-offline-folder.c | 33 +- camel/camel-offline-folder.h | 5 +- camel/camel-offline-store.c | 90 +- camel/camel-offline-store.h | 24 +- camel/camel-sasl-anonymous.c | 10 +- camel/camel-sasl-cram-md5.c | 10 +- camel/camel-sasl-digest-md5.c | 10 +- camel/camel-sasl-gssapi.c | 10 +- camel/camel-sasl-login.c | 10 +- camel/camel-sasl-ntlm.c | 10 +- camel/camel-sasl-plain.c | 10 +- camel/camel-sasl-popb4smtp.c | 10 +- camel/camel-sasl.c | 173 ++-- camel/camel-sasl.h | 19 +- camel/camel-search-private.c | 3 +- camel/camel-service.c | 334 +++---- camel/camel-service.h | 35 +- camel/camel-session.c | 3 +- camel/camel-smime-context.c | 68 +- camel/camel-store.c | 310 +++--- camel/camel-store.h | 164 ++-- camel/camel-transport.c | 20 +- camel/camel-transport.h | 4 +- camel/camel-vee-folder.c | 366 +++---- camel/camel-vee-store.c | 248 ++--- camel/camel-vtrash-folder.c | 32 +- camel/providers/groupwise/camel-groupwise-folder.c | 830 ++++++++-------- .../providers/groupwise/camel-groupwise-journal.c | 12 +- camel/providers/groupwise/camel-groupwise-store.c | 124 +-- .../groupwise/camel-groupwise-transport.c | 32 +- camel/providers/groupwise/camel-groupwise-utils.c | 10 +- camel/providers/imap/camel-imap-command.c | 19 +- camel/providers/imap/camel-imap-folder.c | 134 +-- camel/providers/imap/camel-imap-journal.c | 6 +- camel/providers/imap/camel-imap-message-cache.c | 3 +- camel/providers/imap/camel-imap-search.c | 2 +- camel/providers/imap/camel-imap-store.c | 273 +++--- camel/providers/imap/camel-imap-wrapper.c | 12 +- camel/providers/imapx/camel-imapx-folder.c | 465 ++++----- camel/providers/imapx/camel-imapx-server.c | 18 +- camel/providers/imapx/camel-imapx-store.c | 882 +++++++++-------- camel/providers/imapx/test-imapx.c | 8 +- camel/providers/local/camel-local-folder.c | 124 +-- camel/providers/local/camel-local-store.c | 114 +-- camel/providers/local/camel-local-summary.c | 4 +- camel/providers/local/camel-maildir-folder.c | 184 ++-- camel/providers/local/camel-maildir-store.c | 548 ++++++----- camel/providers/local/camel-mbox-folder.c | 203 ++-- camel/providers/local/camel-mbox-store.c | 1020 ++++++++++---------- camel/providers/local/camel-mh-folder.c | 50 +- camel/providers/local/camel-mh-store.c | 383 ++++---- camel/providers/local/camel-spool-store.c | 466 +++++---- camel/providers/nntp/camel-nntp-folder.c | 154 +-- camel/providers/nntp/camel-nntp-store.c | 78 +- camel/providers/pop3/camel-pop3-folder.c | 339 +++---- camel/providers/pop3/camel-pop3-store.c | 123 +-- .../providers/sendmail/camel-sendmail-transport.c | 16 +- camel/providers/smtp/camel-smtp-transport.c | 135 +-- docs/reference/camel/camel-sections.txt | 129 +-- .../reference/camel/tmpl/camel-cipher-context.sgml | 40 +- docs/reference/camel/tmpl/camel-data-wrapper.sgml | 36 +- docs/reference/camel/tmpl/camel-folder.sgml | 174 ++-- docs/reference/camel/tmpl/camel-mime-part.sgml | 2 +- .../reference/camel/tmpl/camel-offline-folder.sgml | 2 +- docs/reference/camel/tmpl/camel-offline-store.sgml | 11 +- docs/reference/camel/tmpl/camel-sasl.sgml | 40 +- docs/reference/camel/tmpl/camel-service.sgml | 28 +- docs/reference/camel/tmpl/camel-store.sgml | 194 ++-- docs/reference/camel/tmpl/camel-transport.sgml | 2 +- docs/reference/camel/tmpl/camel-unused.sgml | 435 +++++++++ 90 files changed, 5991 insertions(+), 5521 deletions(-) diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c index 60d3bca..3ffa355 100644 --- a/camel/camel-cipher-context.c +++ b/camel/camel-cipher-context.c @@ -150,13 +150,13 @@ cipher_id_to_hash (CamelCipherContext *context, } static gint -cipher_sign (CamelCipherContext *ctx, - const gchar *userid, - CamelCipherHash hash, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +cipher_sign_sync (CamelCipherContext *ctx, + const gchar *userid, + CamelCipherHash hash, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { g_set_error ( error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -166,10 +166,10 @@ cipher_sign (CamelCipherContext *ctx, } static CamelCipherValidity * -cipher_verify (CamelCipherContext *context, - CamelMimePart *sigpart, - GCancellable *cancellable, - GError **error) +cipher_verify_sync (CamelCipherContext *context, + CamelMimePart *sigpart, + GCancellable *cancellable, + GError **error) { g_set_error ( error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -179,13 +179,13 @@ cipher_verify (CamelCipherContext *context, } static gint -cipher_encrypt (CamelCipherContext *context, - const gchar *userid, - GPtrArray *recipients, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +cipher_encrypt_sync (CamelCipherContext *context, + const gchar *userid, + GPtrArray *recipients, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { g_set_error ( error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -195,11 +195,11 @@ cipher_encrypt (CamelCipherContext *context, } static CamelCipherValidity * -cipher_decrypt (CamelCipherContext *context, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +cipher_decrypt_sync (CamelCipherContext *context, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { g_set_error ( error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -209,10 +209,10 @@ cipher_decrypt (CamelCipherContext *context, } static gint -cipher_import_keys (CamelCipherContext *context, - CamelStream *istream, - GCancellable *cancellable, - GError **error) +cipher_import_keys_sync (CamelCipherContext *context, + CamelStream *istream, + GCancellable *cancellable, + GError **error) { g_set_error ( error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -222,11 +222,11 @@ cipher_import_keys (CamelCipherContext *context, } static gint -cipher_export_keys (CamelCipherContext *context, - GPtrArray *keys, - CamelStream *ostream, - GCancellable *cancellable, - GError **error) +cipher_export_keys_sync (CamelCipherContext *context, + GPtrArray *keys, + CamelStream *ostream, + GCancellable *cancellable, + GError **error) { g_set_error ( error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, @@ -250,12 +250,12 @@ camel_cipher_context_class_init (CamelCipherContextClass *class) class->hash_to_id = cipher_hash_to_id; class->id_to_hash = cipher_id_to_hash; - class->sign = cipher_sign; - class->verify = cipher_verify; - class->encrypt = cipher_encrypt; - class->decrypt = cipher_decrypt; - class->import_keys = cipher_import_keys; - class->export_keys = cipher_export_keys; + class->sign_sync = cipher_sign_sync; + class->verify_sync = cipher_verify_sync; + class->encrypt_sync = cipher_encrypt_sync; + class->decrypt_sync = cipher_decrypt_sync; + class->import_keys_sync = cipher_import_keys_sync; + class->export_keys_sync = cipher_export_keys_sync; g_object_class_install_property ( object_class, @@ -277,7 +277,7 @@ camel_cipher_context_init (CamelCipherContext *context) } /** - * camel_cipher_sign: + * camel_cipher_sign_sync: * @context: Cipher Context * @userid: private key to use to sign the stream * @hash: preferred Message-Integrity-Check hash algorithm @@ -286,19 +286,20 @@ camel_cipher_context_init (CamelCipherContext *context) * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL * - * Converts the (unsigned) part @ipart into a new self-contained mime part @opart. - * This may be a multipart/signed part, or a simple part for enveloped types. + * Converts the (unsigned) part @ipart into a new self-contained mime + * part @opart. This may be a multipart/signed part, or a simple part + * for enveloped types. * * Returns: 0 for success or -1 for failure. **/ gint -camel_cipher_sign (CamelCipherContext *context, - const gchar *userid, - CamelCipherHash hash, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +camel_cipher_sign_sync (CamelCipherContext *context, + const gchar *userid, + CamelCipherHash hash, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; gint retval; @@ -306,13 +307,13 @@ camel_cipher_sign (CamelCipherContext *context, g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1); class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context); - g_return_val_if_fail (class->sign != NULL, -1); + g_return_val_if_fail (class->sign_sync != NULL, -1); CIPHER_LOCK (context); - retval = class->sign ( + retval = class->sign_sync ( context, userid, hash, ipart, opart, cancellable, error); - CAMEL_CHECK_GERROR (context, sign, retval == 0, error); + CAMEL_CHECK_GERROR (context, sign_sync, retval == 0, error); CIPHER_UNLOCK (context); @@ -320,7 +321,7 @@ camel_cipher_sign (CamelCipherContext *context, } /** - * camel_cipher_verify: + * camel_cipher_verify_sync: * @context: Cipher Context * @ipart: part to verify * @cancellable: optional #GCancellable object, or %NULL @@ -336,10 +337,10 @@ camel_cipher_sign (CamelCipherContext *context, * execute at all. **/ CamelCipherValidity * -camel_cipher_verify (CamelCipherContext *context, - CamelMimePart *ipart, - GCancellable *cancellable, - GError **error) +camel_cipher_verify_sync (CamelCipherContext *context, + CamelMimePart *ipart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; CamelCipherValidity *valid; @@ -347,12 +348,12 @@ camel_cipher_verify (CamelCipherContext *context, g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), NULL); class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context); - g_return_val_if_fail (class->verify != NULL, NULL); + g_return_val_if_fail (class->verify_sync != NULL, NULL); CIPHER_LOCK (context); - valid = class->verify (context, ipart, cancellable, error); - CAMEL_CHECK_GERROR (context, verify, valid != NULL, error); + valid = class->verify_sync (context, ipart, cancellable, error); + CAMEL_CHECK_GERROR (context, verify_sync, valid != NULL, error); CIPHER_UNLOCK (context); @@ -360,7 +361,7 @@ camel_cipher_verify (CamelCipherContext *context, } /** - * camel_cipher_encrypt: + * camel_cipher_encrypt_sync: * @context: Cipher Context * @userid: key id (or email address) to use when signing, or NULL to not sign. * @recipients: an array of recipient key ids and/or email addresses @@ -375,13 +376,13 @@ camel_cipher_verify (CamelCipherContext *context, * Returns: 0 for success or -1 for failure. **/ gint -camel_cipher_encrypt (CamelCipherContext *context, - const gchar *userid, - GPtrArray *recipients, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +camel_cipher_encrypt_sync (CamelCipherContext *context, + const gchar *userid, + GPtrArray *recipients, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; gint retval; @@ -389,14 +390,14 @@ camel_cipher_encrypt (CamelCipherContext *context, g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1); class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context); - g_return_val_if_fail (class->encrypt != NULL, -1); + g_return_val_if_fail (class->encrypt_sync != NULL, -1); CIPHER_LOCK (context); - retval = class->encrypt ( + retval = class->encrypt_sync ( context, userid, recipients, ipart, opart, cancellable, error); - CAMEL_CHECK_GERROR (context, encrypt, retval == 0, error); + CAMEL_CHECK_GERROR (context, encrypt_sync, retval == 0, error); CIPHER_UNLOCK (context); @@ -404,7 +405,7 @@ camel_cipher_encrypt (CamelCipherContext *context, } /** - * camel_cipher_decrypt: + * camel_cipher_decrypt_sync: * @context: * @ipart: * @opart: @@ -416,11 +417,11 @@ camel_cipher_encrypt (CamelCipherContext *context, * Returns: A validity/encryption status. **/ CamelCipherValidity * -camel_cipher_decrypt (CamelCipherContext *context, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +camel_cipher_decrypt_sync (CamelCipherContext *context, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; CamelCipherValidity *valid; @@ -428,12 +429,13 @@ camel_cipher_decrypt (CamelCipherContext *context, g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), NULL); class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context); - g_return_val_if_fail (class->decrypt != NULL, NULL); + g_return_val_if_fail (class->decrypt_sync != NULL, NULL); CIPHER_LOCK (context); - valid = class->decrypt (context, ipart, opart, cancellable, error); - CAMEL_CHECK_GERROR (context, decrypt, valid != NULL, error); + valid = class->decrypt_sync ( + context, ipart, opart, cancellable, error); + CAMEL_CHECK_GERROR (context, decrypt_sync, valid != NULL, error); CIPHER_UNLOCK (context); @@ -441,7 +443,7 @@ camel_cipher_decrypt (CamelCipherContext *context, } /** - * camel_cipher_import_keys: + * camel_cipher_import_keys_sync: * @context: Cipher Context * @istream: input stream (containing keys) * @cancellable: optional #GCancellable object, or %NULL @@ -453,10 +455,10 @@ camel_cipher_decrypt (CamelCipherContext *context, * Returns: 0 on success or -1 on fail. **/ gint -camel_cipher_import_keys (CamelCipherContext *context, - CamelStream *istream, - GCancellable *cancellable, - GError **error) +camel_cipher_import_keys_sync (CamelCipherContext *context, + CamelStream *istream, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; gint retval; @@ -465,16 +467,17 @@ camel_cipher_import_keys (CamelCipherContext *context, g_return_val_if_fail (CAMEL_IS_STREAM (istream), -1); class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context); - g_return_val_if_fail (class->import_keys != NULL, -1); + g_return_val_if_fail (class->import_keys_sync != NULL, -1); - retval = class->import_keys (context, istream, cancellable, error); - CAMEL_CHECK_GERROR (context, import_keys, retval == 0, error); + retval = class->import_keys_sync ( + context, istream, cancellable, error); + CAMEL_CHECK_GERROR (context, import_keys_sync, retval == 0, error); return retval; } /** - * camel_cipher_export_keys: + * camel_cipher_export_keys_sync: * @context: Cipher Context * @keys: an array of key ids * @ostream: output stream @@ -487,11 +490,11 @@ camel_cipher_import_keys (CamelCipherContext *context, * Returns: 0 on success or -1 on fail. **/ gint -camel_cipher_export_keys (CamelCipherContext *context, - GPtrArray *keys, - CamelStream *ostream, - GCancellable *cancellable, - GError **error) +camel_cipher_export_keys_sync (CamelCipherContext *context, + GPtrArray *keys, + CamelStream *ostream, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; gint retval; @@ -501,11 +504,11 @@ camel_cipher_export_keys (CamelCipherContext *context, g_return_val_if_fail (keys != NULL, -1); class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context); - g_return_val_if_fail (class->export_keys != NULL, -1); + g_return_val_if_fail (class->export_keys_sync != NULL, -1); - retval = class->export_keys ( + retval = class->export_keys_sync ( context, keys, ostream, cancellable, error); - CAMEL_CHECK_GERROR (context, export_keys, retval == 0, error); + CAMEL_CHECK_GERROR (context, export_keys_sync, retval == 0, error); return retval; } @@ -864,7 +867,7 @@ camel_cipher_canonical_to_stream (CamelMimePart *part, camel_stream_filter_add (CAMEL_STREAM_FILTER (filter), canon); g_object_unref (canon); - if (camel_data_wrapper_write_to_stream ( + if (camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (part), filter, cancellable, error) != -1 && camel_stream_flush (filter, cancellable, error) != -1) res = 0; diff --git a/camel/camel-cipher-context.h b/camel/camel-cipher-context.h index 2e21efa..e3d231a 100644 --- a/camel/camel-cipher-context.h +++ b/camel/camel-cipher-context.h @@ -138,7 +138,8 @@ struct _CamelCipherContextClass { const gchar *id); const gchar * (*hash_to_id) (CamelCipherContext *context, CamelCipherHash hash); - gint (*sign) (CamelCipherContext *context, + + gint (*sign_sync) (CamelCipherContext *context, const gchar *userid, CamelCipherHash hash, CamelMimePart *ipart, @@ -146,11 +147,11 @@ struct _CamelCipherContextClass { GCancellable *cancellable, GError **error); CamelCipherValidity * - (*verify) (CamelCipherContext *context, + (*verify_sync) (CamelCipherContext *context, CamelMimePart *ipart, GCancellable *cancellable, GError **error); - gint (*encrypt) (CamelCipherContext *context, + gint (*encrypt_sync) (CamelCipherContext *context, const gchar *userid, GPtrArray *recipients, CamelMimePart *ipart, @@ -158,16 +159,16 @@ struct _CamelCipherContextClass { GCancellable *cancellable, GError **error); CamelCipherValidity * - (*decrypt) (CamelCipherContext *context, + (*decrypt_sync) (CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *opart, GCancellable *cancellable, GError **error); - gint (*import_keys) (CamelCipherContext *context, + gint (*import_keys_sync) (CamelCipherContext *context, CamelStream *istream, GCancellable *cancellable, GError **error); - gint (*export_keys) (CamelCipherContext *context, + gint (*export_keys_sync) (CamelCipherContext *context, GPtrArray *keys, CamelStream *ostream, GCancellable *cancellable, @@ -191,7 +192,7 @@ const gchar * camel_cipher_hash_to_id (CamelCipherContext *context, to the cipher, etc etc. */ /* cipher routines */ -gint camel_cipher_sign (CamelCipherContext *context, +gint camel_cipher_sign_sync (CamelCipherContext *context, const gchar *userid, CamelCipherHash hash, CamelMimePart *ipart, @@ -199,11 +200,11 @@ gint camel_cipher_sign (CamelCipherContext *context, GCancellable *cancellable, GError **error); CamelCipherValidity * - camel_cipher_verify (CamelCipherContext *context, + camel_cipher_verify_sync (CamelCipherContext *context, CamelMimePart *ipart, GCancellable *cancellable, GError **error); -gint camel_cipher_encrypt (CamelCipherContext *context, +gint camel_cipher_encrypt_sync (CamelCipherContext *context, const gchar *userid, GPtrArray *recipients, CamelMimePart *ipart, @@ -211,18 +212,18 @@ gint camel_cipher_encrypt (CamelCipherContext *context, GCancellable *cancellable, GError **error); CamelCipherValidity * - camel_cipher_decrypt (CamelCipherContext *context, + camel_cipher_decrypt_sync (CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *opart, GCancellable *cancellable, GError **error); /* key/certificate routines */ -gint camel_cipher_import_keys (CamelCipherContext *context, +gint camel_cipher_import_keys_sync (CamelCipherContext *context, CamelStream *istream, GCancellable *cancellable, GError **error); -gint camel_cipher_export_keys (CamelCipherContext *context, +gint camel_cipher_export_keys_sync (CamelCipherContext *context, GPtrArray *keys, CamelStream *ostream, GCancellable *cancellable, diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c index d35eb49..4969f78 100644 --- a/camel/camel-data-wrapper.c +++ b/camel/camel-data-wrapper.c @@ -76,11 +76,49 @@ data_wrapper_finalize (GObject *object) G_OBJECT_CLASS (camel_data_wrapper_parent_class)->finalize (object); } +static void +data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, + const gchar *mime_type) +{ + if (data_wrapper->mime_type) + camel_content_type_unref (data_wrapper->mime_type); + data_wrapper->mime_type = camel_content_type_decode (mime_type); +} + +static gchar * +data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper) +{ + return camel_content_type_simple (data_wrapper->mime_type); +} + +static CamelContentType * +data_wrapper_get_mime_type_field (CamelDataWrapper *data_wrapper) +{ + return data_wrapper->mime_type; +} + +static void +data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, + CamelContentType *mime_type) +{ + if (mime_type) + camel_content_type_ref (mime_type); + if (data_wrapper->mime_type) + camel_content_type_unref (data_wrapper->mime_type); + data_wrapper->mime_type = mime_type; +} + +static gboolean +data_wrapper_is_offline (CamelDataWrapper *data_wrapper) +{ + return data_wrapper->offline; +} + static gssize -data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +data_wrapper_write_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { gssize ret; @@ -106,10 +144,10 @@ data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, } static gssize -data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +data_wrapper_decode_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { CamelMimeFilter *filter; CamelStream *fstream; @@ -144,7 +182,7 @@ data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper, g_object_unref (filter); } - ret = camel_data_wrapper_write_to_stream ( + ret = camel_data_wrapper_write_to_stream_sync ( data_wrapper, fstream, cancellable, error); camel_stream_flush (fstream, NULL, NULL); @@ -153,43 +191,11 @@ data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper, return ret; } -static void -data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, - const gchar *mime_type) -{ - if (data_wrapper->mime_type) - camel_content_type_unref (data_wrapper->mime_type); - data_wrapper->mime_type = camel_content_type_decode (mime_type); -} - -static gchar * -data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper) -{ - return camel_content_type_simple (data_wrapper->mime_type); -} - -static CamelContentType * -data_wrapper_get_mime_type_field (CamelDataWrapper *data_wrapper) -{ - return data_wrapper->mime_type; -} - -static void -data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, - CamelContentType *mime_type) -{ - if (mime_type) - camel_content_type_ref (mime_type); - if (data_wrapper->mime_type) - camel_content_type_unref (data_wrapper->mime_type); - data_wrapper->mime_type = mime_type; -} - static gint -data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +data_wrapper_construct_from_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { if (data_wrapper->stream) g_object_unref (data_wrapper->stream); @@ -199,12 +205,6 @@ data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, return 0; } -static gboolean -data_wrapper_is_offline (CamelDataWrapper *data_wrapper) -{ - return data_wrapper->offline; -} - static void camel_data_wrapper_class_init (CamelDataWrapperClass *class) { @@ -216,14 +216,14 @@ camel_data_wrapper_class_init (CamelDataWrapperClass *class) object_class->dispose = data_wrapper_dispose; object_class->finalize = data_wrapper_finalize; - class->write_to_stream = data_wrapper_write_to_stream; - class->decode_to_stream = data_wrapper_decode_to_stream; class->set_mime_type = data_wrapper_set_mime_type; class->get_mime_type = data_wrapper_get_mime_type; class->get_mime_type_field = data_wrapper_get_mime_type_field; class->set_mime_type_field = data_wrapper_set_mime_type_field; - class->construct_from_stream = data_wrapper_construct_from_stream; class->is_offline = data_wrapper_is_offline; + class->write_to_stream_sync = data_wrapper_write_to_stream_sync; + class->decode_to_stream_sync = data_wrapper_decode_to_stream_sync; + class->construct_from_stream_sync = data_wrapper_construct_from_stream_sync; } static void @@ -253,111 +253,6 @@ camel_data_wrapper_new (void) } /** - * camel_data_wrapper_write_to_stream: - * @data_wrapper: a #CamelDataWrapper object - * @stream: a #CamelStream for output - * @cancellable: optional #GCancellable object, or %NULL - * @error: return location for a #GError, or %NULL - * - * Writes the content of @data_wrapper to @stream in a machine-independent - * format appropriate for the data. It should be possible to construct an - * equivalent data wrapper object later by passing this stream to - * #camel_data_wrapper_construct_from_stream. - * - * Returns: the number of bytes written, or %-1 on fail - **/ -gssize -camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) -{ - CamelDataWrapperClass *class; - gssize n_bytes; - - g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1); - g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1); - - class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper); - g_return_val_if_fail (class->write_to_stream != NULL, -1); - - n_bytes = class->write_to_stream ( - data_wrapper, stream, cancellable, error); - CAMEL_CHECK_GERROR ( - data_wrapper, write_to_stream, n_bytes >= 0, error); - - return n_bytes; -} - -/** - * camel_data_wrapper_decode_to_stream: - * @data_wrapper: a #CamelDataWrapper object - * @stream: a #CamelStream for decoded data to be written to - * @cancellable: optional #GCancellable object, or %NULL - * @error: return location for a #GError, or %NULL - * - * Writes the decoded data content to @stream. - * - * Returns: the number of bytes written, or %-1 on fail - **/ -gssize -camel_data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) -{ - CamelDataWrapperClass *class; - gssize n_bytes; - - g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1); - g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1); - - class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper); - g_return_val_if_fail (class->decode_to_stream != NULL, -1); - - n_bytes = class->decode_to_stream ( - data_wrapper, stream, cancellable, error); - CAMEL_CHECK_GERROR ( - data_wrapper, decode_to_stream, n_bytes >= 0, error); - - return n_bytes; -} - -/** - * camel_data_wrapper_construct_from_stream: - * @data_wrapper: a #CamelDataWrapper object - * @stream: an input #CamelStream - * @cancellable: optional #GCancellable object, or %NULL - * @error: return location for a #GError, or %NULL - * - * Constructs the content of @data_wrapper from the supplied @stream. - * - * Returns: %0 on success or %-1 on fail - **/ -gint -camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) -{ - CamelDataWrapperClass *class; - gint retval; - - g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1); - g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1); - - class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper); - g_return_val_if_fail (class->construct_from_stream != NULL, -1); - - retval = class->construct_from_stream ( - data_wrapper, stream, cancellable, error); - CAMEL_CHECK_GERROR ( - data_wrapper, construct_from_stream, retval == 0, error); - - return retval; -} - -/** * camel_data_wrapper_set_mime_type: * @data_wrapper: a #CamelDataWrapper object * @mime_type: a MIME type @@ -468,6 +363,111 @@ camel_data_wrapper_is_offline (CamelDataWrapper *data_wrapper) } /** + * camel_data_wrapper_write_to_stream_sync: + * @data_wrapper: a #CamelDataWrapper object + * @stream: a #CamelStream for output + * @cancellable: optional #GCancellable object, or %NULL + * @error: return location for a #GError, or %NULL + * + * Writes the content of @data_wrapper to @stream in a machine-independent + * format appropriate for the data. It should be possible to construct an + * equivalent data wrapper object later by passing this stream to + * #camel_data_wrapper_construct_from_stream. + * + * Returns: the number of bytes written, or %-1 on fail + **/ +gssize +camel_data_wrapper_write_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) +{ + CamelDataWrapperClass *class; + gssize n_bytes; + + g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1); + g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1); + + class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper); + g_return_val_if_fail (class->write_to_stream_sync != NULL, -1); + + n_bytes = class->write_to_stream_sync ( + data_wrapper, stream, cancellable, error); + CAMEL_CHECK_GERROR ( + data_wrapper, write_to_stream_sync, n_bytes >= 0, error); + + return n_bytes; +} + +/** + * camel_data_wrapper_decode_to_stream_sync: + * @data_wrapper: a #CamelDataWrapper object + * @stream: a #CamelStream for decoded data to be written to + * @cancellable: optional #GCancellable object, or %NULL + * @error: return location for a #GError, or %NULL + * + * Writes the decoded data content to @stream. + * + * Returns: the number of bytes written, or %-1 on fail + **/ +gssize +camel_data_wrapper_decode_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) +{ + CamelDataWrapperClass *class; + gssize n_bytes; + + g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1); + g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1); + + class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper); + g_return_val_if_fail (class->decode_to_stream_sync != NULL, -1); + + n_bytes = class->decode_to_stream_sync ( + data_wrapper, stream, cancellable, error); + CAMEL_CHECK_GERROR ( + data_wrapper, decode_to_stream_sync, n_bytes >= 0, error); + + return n_bytes; +} + +/** + * camel_data_wrapper_construct_from_stream_sync: + * @data_wrapper: a #CamelDataWrapper object + * @stream: an input #CamelStream + * @cancellable: optional #GCancellable object, or %NULL + * @error: return location for a #GError, or %NULL + * + * Constructs the content of @data_wrapper from the supplied @stream. + * + * Returns: %0 on success or %-1 on fail + **/ +gint +camel_data_wrapper_construct_from_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) +{ + CamelDataWrapperClass *class; + gint retval; + + g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1); + g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1); + + class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper); + g_return_val_if_fail (class->construct_from_stream_sync != NULL, -1); + + retval = class->construct_from_stream_sync ( + data_wrapper, stream, cancellable, error); + CAMEL_CHECK_GERROR ( + data_wrapper, construct_from_stream_sync, retval == 0, error); + + return retval; +} + +/** * camel_data_wrapper_lock: * @data_wrapper: a #CamelDataWrapper * @lock: lock type to lock diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h index bbfbeea..adde135 100644 --- a/camel/camel-data-wrapper.h +++ b/camel/camel-data-wrapper.h @@ -90,34 +90,26 @@ struct _CamelDataWrapperClass { (*get_mime_type_field) (CamelDataWrapper *data_wrapper); void (*set_mime_type_field) (CamelDataWrapper *data_wrapper, CamelContentType *mime_type_field); - gssize (*write_to_stream) (CamelDataWrapper *data_wrapper, + gboolean (*is_offline) (CamelDataWrapper *data_wrapper); + + gssize (*write_to_stream_sync) (CamelDataWrapper *data_wrapper, CamelStream *stream, GCancellable *cancellable, GError **error); - gssize (*decode_to_stream) (CamelDataWrapper *data_wrapper, + gssize (*decode_to_stream_sync)(CamelDataWrapper *data_wrapper, CamelStream *stream, GCancellable *cancellable, GError **error); - gint (*construct_from_stream)(CamelDataWrapper *data_wrapper, + gint (*construct_from_stream_sync) + (CamelDataWrapper *data_wrapper, CamelStream *stream, GCancellable *cancellable, GError **error); - gboolean (*is_offline) (CamelDataWrapper *data_wrapper); }; GType camel_data_wrapper_get_type (void); CamelDataWrapper * camel_data_wrapper_new (void); -gssize camel_data_wrapper_write_to_stream - (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error); -gssize camel_data_wrapper_decode_to_stream - (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error); void camel_data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, const gchar *mime_type); gchar * camel_data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper); @@ -127,12 +119,22 @@ CamelContentType * void camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type); -gint camel_data_wrapper_construct_from_stream +gboolean camel_data_wrapper_is_offline (CamelDataWrapper *data_wrapper); +gssize camel_data_wrapper_write_to_stream_sync + (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error); +gssize camel_data_wrapper_decode_to_stream_sync + (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error); +gint camel_data_wrapper_construct_from_stream_sync (CamelDataWrapper *data_wrapper, CamelStream *stream, GCancellable *cancellable, GError **error); -gboolean camel_data_wrapper_is_offline (CamelDataWrapper *data_wrapper); void camel_data_wrapper_lock (CamelDataWrapper *data_wrapper, CamelDataWrapperLock lock); void camel_data_wrapper_unlock (CamelDataWrapper *data_wrapper, diff --git a/camel/camel-disco-diary.c b/camel/camel-disco-diary.c index cddd2d9..530d386 100644 --- a/camel/camel-disco-diary.c +++ b/camel/camel-disco-diary.c @@ -250,7 +250,7 @@ diary_decode_folder (CamelDiscoDiary *diary, GError *error = NULL; gchar *msg; - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( CAMEL_STORE (diary->store), name, 0, cancellable, &error); if (folder) @@ -280,7 +280,7 @@ close_folder (gchar *name, GCancellable *cancellable) { g_free (name); - camel_folder_sync (folder, FALSE, cancellable, NULL); + camel_folder_synchronize_sync (folder, FALSE, cancellable, NULL); g_object_unref (folder); } @@ -346,7 +346,7 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, continue; } - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( folder, uid, cancellable, NULL); if (!message) { /* The message was appended and then deleted. */ @@ -355,7 +355,7 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, } info = camel_folder_get_message_info (folder, uid); - camel_folder_append_message ( + camel_folder_append_message_sync ( folder, message, info, &ret_uid, cancellable, &local_error); camel_folder_free_message_info (folder, info); @@ -389,7 +389,7 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, continue; } - camel_folder_transfer_messages_to ( + camel_folder_transfer_messages_to_sync ( source, uids, destination, &ret_uids, delete_originals, cancellable, &local_error); diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c index 336d692..6fd9009 100644 --- a/camel/camel-disco-folder.c +++ b/camel/camel-disco-folder.c @@ -56,11 +56,6 @@ enum { G_DEFINE_TYPE (CamelDiscoFolder, camel_disco_folder, CAMEL_TYPE_FOLDER) -/* Forward Declarations */ -static gboolean disco_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error); - static void cdf_sync_offline (CamelSession *session, CamelSessionThreadMsg *mm) { @@ -164,7 +159,8 @@ disco_folder_get_property (GObject *object, } static gboolean -disco_refresh_info (CamelFolder *folder, +disco_expunge_uids (CamelFolder *folder, + GPtrArray *uids, GCancellable *cancellable, GError **error) { @@ -172,52 +168,32 @@ disco_refresh_info (CamelFolder *folder, CamelStore *parent_store; gboolean success; - parent_store = camel_folder_get_parent_store (folder); - - if (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store)) != CAMEL_DISCO_STORE_ONLINE) + if (uids->len == 0) return TRUE; - disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder); - - success = disco_folder_class->refresh_info_online ( - folder, cancellable, error); - CAMEL_CHECK_GERROR (folder, refresh_info_online, success, error); - - return success; -} - -static gboolean -disco_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) -{ - CamelDiscoFolderClass *disco_folder_class; - CamelStore *parent_store; - gboolean success; - - if (expunge && !disco_expunge (folder, cancellable, error)) - return FALSE; - - camel_object_state_write (CAMEL_OBJECT (folder)); - parent_store = camel_folder_get_parent_store (folder); disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder); switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) { case CAMEL_DISCO_STORE_ONLINE: - success = disco_folder_class->sync_online (folder, error); - CAMEL_CHECK_GERROR (folder, sync_online, success, error); + success = disco_folder_class->expunge_uids_online ( + folder, uids, error); + CAMEL_CHECK_GERROR ( + folder, expunge_uids_online, success, error); return success; case CAMEL_DISCO_STORE_OFFLINE: - success = disco_folder_class->sync_offline (folder, error); - CAMEL_CHECK_GERROR (folder, sync_offline, success, error); + success = disco_folder_class->expunge_uids_offline ( + folder, uids, error); + CAMEL_CHECK_GERROR ( + folder, expunge_uids_offline, success, error); return success; case CAMEL_DISCO_STORE_RESYNCING: - success = disco_folder_class->sync_resyncing (folder, error); - CAMEL_CHECK_GERROR (folder, sync_resyncing, success, error); + success = disco_folder_class->expunge_uids_resyncing ( + folder, uids, error); + CAMEL_CHECK_GERROR ( + folder, expunge_uids_resyncing, success, error); return success; } @@ -225,41 +201,40 @@ disco_sync (CamelFolder *folder, } static gboolean -disco_expunge_uids (CamelFolder *folder, - GPtrArray *uids, - GCancellable *cancellable, - GError **error) +disco_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { CamelDiscoFolderClass *disco_folder_class; CamelStore *parent_store; gboolean success; - if (uids->len == 0) - return TRUE; - parent_store = camel_folder_get_parent_store (folder); disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder); switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) { case CAMEL_DISCO_STORE_ONLINE: - success = disco_folder_class->expunge_uids_online ( - folder, uids, error); - CAMEL_CHECK_GERROR ( - folder, expunge_uids_online, success, error); + success = disco_folder_class->append_online ( + folder, message, info, + appended_uid, cancellable, error); + CAMEL_CHECK_GERROR (folder, append_online, success, error); return success; case CAMEL_DISCO_STORE_OFFLINE: - success = disco_folder_class->expunge_uids_offline ( - folder, uids, error); - CAMEL_CHECK_GERROR ( - folder, expunge_uids_offline, success, error); + success = disco_folder_class->append_offline ( + folder, message, info, + appended_uid, cancellable, error); + CAMEL_CHECK_GERROR (folder, append_offline, success, error); return success; case CAMEL_DISCO_STORE_RESYNCING: - success = disco_folder_class->expunge_uids_resyncing ( - folder, uids, error); - CAMEL_CHECK_GERROR ( - folder, expunge_uids_resyncing, success, error); + success = disco_folder_class->append_resyncing ( + folder, message, info, + appended_uid, cancellable, error); + CAMEL_CHECK_GERROR (folder, append_resyncing, success, error); return success; } @@ -267,9 +242,9 @@ disco_expunge_uids (CamelFolder *folder, } static gboolean -disco_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error) +disco_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { GPtrArray *uids; gint i; @@ -297,40 +272,60 @@ disco_expunge (CamelFolder *folder, } static gboolean -disco_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +disco_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + CamelDiscoFolderClass *disco_folder_class; + CamelStore *parent_store; + gboolean success; + + parent_store = camel_folder_get_parent_store (folder); + + if (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store)) != CAMEL_DISCO_STORE_ONLINE) + return TRUE; + + disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder); + + success = disco_folder_class->refresh_info_online ( + folder, cancellable, error); + CAMEL_CHECK_GERROR (folder, refresh_info_online, success, error); + + return success; +} + +static gboolean +disco_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) { CamelDiscoFolderClass *disco_folder_class; CamelStore *parent_store; gboolean success; + if (expunge && !disco_expunge_sync (folder, cancellable, error)) + return FALSE; + + camel_object_state_write (CAMEL_OBJECT (folder)); + parent_store = camel_folder_get_parent_store (folder); disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder); switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) { case CAMEL_DISCO_STORE_ONLINE: - success = disco_folder_class->append_online ( - folder, message, info, - appended_uid, cancellable, error); - CAMEL_CHECK_GERROR (folder, append_online, success, error); + success = disco_folder_class->sync_online (folder, error); + CAMEL_CHECK_GERROR (folder, sync_online, success, error); return success; case CAMEL_DISCO_STORE_OFFLINE: - success = disco_folder_class->append_offline ( - folder, message, info, - appended_uid, cancellable, error); - CAMEL_CHECK_GERROR (folder, append_offline, success, error); + success = disco_folder_class->sync_offline (folder, error); + CAMEL_CHECK_GERROR (folder, sync_offline, success, error); return success; case CAMEL_DISCO_STORE_RESYNCING: - success = disco_folder_class->append_resyncing ( - folder, message, info, - appended_uid, cancellable, error); - CAMEL_CHECK_GERROR (folder, append_resyncing, success, error); + success = disco_folder_class->sync_resyncing (folder, error); + CAMEL_CHECK_GERROR (folder, sync_resyncing, success, error); return success; } @@ -338,13 +333,13 @@ disco_append_message (CamelFolder *folder, } static gboolean -disco_transfer_messages_to (CamelFolder *source, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) +disco_transfer_messages_to_sync (CamelFolder *source, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) { CamelDiscoFolderClass *disco_folder_class; CamelStore *parent_store; @@ -442,11 +437,11 @@ camel_disco_folder_class_init (CamelDiscoFolderClass *class) object_class->get_property = disco_folder_get_property; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->refresh_info = disco_refresh_info; - folder_class->sync = disco_sync; - folder_class->expunge = disco_expunge; - folder_class->append_message = disco_append_message; - folder_class->transfer_messages_to = disco_transfer_messages_to; + folder_class->append_message_sync = disco_append_message_sync; + folder_class->expunge_sync = disco_expunge_sync; + folder_class->refresh_info_sync = disco_refresh_info_sync; + folder_class->synchronize_sync = disco_synchronize_sync; + folder_class->transfer_messages_to_sync = disco_transfer_messages_to_sync; class->prepare_for_offline = disco_prepare_for_offline; class->refresh_info_online = disco_refresh_info_online; diff --git a/camel/camel-disco-store.c b/camel/camel-disco-store.c index 92fa78c..d43eead 100644 --- a/camel/camel-disco-store.c +++ b/camel/camel-disco-store.c @@ -59,10 +59,20 @@ disco_store_construct (CamelService *service, return TRUE; } +static void +disco_store_cancel_connect (CamelService *service) +{ + CamelDiscoStore *store = CAMEL_DISCO_STORE (service); + + /* Fall back */ + store->status = CAMEL_DISCO_STORE_OFFLINE; + CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->cancel_connect (service); +} + static gboolean -disco_store_connect (CamelService *service, - GCancellable *cancellable, - GError **error) +disco_store_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelDiscoStore *store = CAMEL_DISCO_STORE (service); CamelDiscoStoreStatus status; @@ -71,7 +81,7 @@ disco_store_connect (CamelService *service, status = camel_disco_store_status (store); if (status != CAMEL_DISCO_STORE_OFFLINE) { - if (!CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->connect (service, cancellable, error)) { + if (!CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->connect_sync (service, cancellable, error)) { status = camel_disco_store_status (store); if (status != CAMEL_DISCO_STORE_OFFLINE) return FALSE; @@ -104,9 +114,9 @@ disco_store_connect (CamelService *service, return FALSE; } - if (!camel_service_disconnect (service, TRUE, error)) + if (!camel_service_disconnect_sync (service, TRUE, error)) return FALSE; - return camel_service_connect (service, error); + return camel_service_connect_sync (service, error); case CAMEL_DISCO_STORE_OFFLINE: return CAMEL_DISCO_STORE_GET_CLASS (service)->connect_offline (service, cancellable, error); @@ -117,10 +127,10 @@ disco_store_connect (CamelService *service, } static gboolean -disco_store_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) +disco_store_disconnect_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) { CamelDiscoStore *store = CAMEL_DISCO_STORE (service); CamelDiscoStoreClass *class; @@ -144,25 +154,15 @@ disco_store_disconnect (CamelService *service, } return CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)-> - disconnect (service, clean, cancellable, error); -} - -static void -disco_store_cancel_connect (CamelService *service) -{ - CamelDiscoStore *store = CAMEL_DISCO_STORE (service); - - /* Fall back */ - store->status = CAMEL_DISCO_STORE_OFFLINE; - CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->cancel_connect (service); + disconnect_sync (service, clean, cancellable, error); } static CamelFolder * -disco_store_get_folder (CamelStore *store, - const gchar *name, - guint32 flags, - GCancellable *cancellable, - GError **error) +disco_store_get_folder_sync (CamelStore *store, + const gchar *name, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store); CamelDiscoStoreClass *class; @@ -197,11 +197,11 @@ disco_store_get_folder (CamelStore *store, } static CamelFolderInfo * -disco_store_get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +disco_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store); CamelDiscoStoreClass *class; @@ -286,17 +286,18 @@ disco_store_set_status (CamelDiscoStore *disco_store, } } - camel_store_sync ( + camel_store_synchronize_sync ( CAMEL_STORE (disco_store), FALSE, cancellable, NULL); } - if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), network_available, error)) + if (!camel_service_disconnect_sync ( + CAMEL_SERVICE (disco_store), network_available, error)) return FALSE; disco_store->status = status; - return camel_service_connect (CAMEL_SERVICE (disco_store), error); + return camel_service_connect_sync (CAMEL_SERVICE (disco_store), error); } static void @@ -307,13 +308,13 @@ camel_disco_store_class_init (CamelDiscoStoreClass *class) service_class = CAMEL_SERVICE_CLASS (class); service_class->construct = disco_store_construct; - service_class->connect = disco_store_connect; - service_class->disconnect = disco_store_disconnect; service_class->cancel_connect = disco_store_cancel_connect; + service_class->connect_sync = disco_store_connect_sync; + service_class->disconnect_sync = disco_store_disconnect_sync; store_class = CAMEL_STORE_CLASS (class); - store_class->get_folder = disco_store_get_folder; - store_class->get_folder_info = disco_store_get_folder_info; + store_class->get_folder_sync = disco_store_get_folder_sync; + store_class->get_folder_info_sync = disco_store_get_folder_info_sync; class->set_status = disco_store_set_status; } @@ -456,7 +457,7 @@ camel_disco_store_prepare_for_offline (CamelDiscoStore *disco_store, } } - camel_store_sync ( + camel_store_synchronize_sync ( CAMEL_STORE (disco_store), FALSE, cancellable, NULL); } diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index 5ba1eff..9a4a77c 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -466,7 +466,7 @@ do_forward_to (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFil /* make sure we have the message... */ if (p->message == NULL) { /* FIXME Pass a GCancellable */ - p->message = camel_folder_get_message ( + p->message = camel_folder_get_message_sync ( p->source, p->uid, NULL, &p->error); if (p->message == NULL) return NULL; @@ -505,21 +505,21 @@ do_copy (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri uids = g_ptr_array_new (); g_ptr_array_add (uids, (gchar *) p->uid); /* FIXME Pass a GCancellable */ - camel_folder_transfer_messages_to ( + camel_folder_transfer_messages_to_sync ( p->source, uids, outbox, NULL, FALSE, NULL, &p->error); g_ptr_array_free (uids, TRUE); } else { if (p->message == NULL) /* FIXME Pass a GCancellable */ - p->message = camel_folder_get_message ( + p->message = camel_folder_get_message_sync ( p->source, p->uid, NULL, &p->error); if (!p->message) continue; /* FIXME Pass a GCancellable */ - camel_folder_append_message ( + camel_folder_append_message_sync ( outbox, p->message, p->info, NULL, NULL, &p->error); } @@ -566,21 +566,21 @@ do_move (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri uids = g_ptr_array_new (); g_ptr_array_add (uids, (gchar *) p->uid); /* FIXME Pass a GCancellable */ - camel_folder_transfer_messages_to ( + camel_folder_transfer_messages_to_sync ( p->source, uids, outbox, NULL, last, NULL, &p->error); g_ptr_array_free (uids, TRUE); } else { if (p->message == NULL) /* FIXME Pass a GCancellable */ - p->message = camel_folder_get_message ( + p->message = camel_folder_get_message_sync ( p->source, p->uid, NULL, &p->error); if (!p->message) continue; /* FIXME Pass a GCancellable */ - camel_folder_append_message ( + camel_folder_append_message_sync ( outbox, p->message, p->info, NULL, NULL, &p->error); @@ -808,7 +808,7 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi /* make sure we have the message... */ if (p->message == NULL) { /* FIXME Pass a GCancellable */ - p->message = camel_folder_get_message ( + p->message = camel_folder_get_message_sync ( p->source, p->uid, NULL, &p->error); if (p->message == NULL) return -1; @@ -845,7 +845,8 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi g_ptr_array_free (args, TRUE); stream = camel_stream_fs_new_with_fd (pipe_to_child); - if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (p->message), stream, NULL, NULL) == -1) { + if (camel_data_wrapper_write_to_stream_sync ( + CAMEL_DATA_WRAPPER (p->message), stream, NULL, NULL) == -1) { g_object_unref (stream); close (pipe_from_child); goto wait; @@ -876,7 +877,8 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi g_object_unref (mem); message = camel_mime_message_new (); - if (camel_mime_part_construct_from_parser ((CamelMimePart *) message, parser, NULL, NULL) == -1) { + if (camel_mime_part_construct_from_parser_sync ( + (CamelMimePart *) message, parser, NULL, NULL) == -1) { gint err = camel_mime_parser_errno (parser); g_set_error ( &p->error, G_IO_ERROR, @@ -1061,7 +1063,7 @@ close_folder (gpointer key, gpointer value, gpointer data) if (folder != FOLDER_INVALID) { /* FIXME Pass a GCancellable */ - camel_folder_sync ( + camel_folder_synchronize_sync ( folder, FALSE, NULL, (p->error != NULL) ? NULL : &p->error); camel_folder_thaw (folder); @@ -1307,7 +1309,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, message = camel_mime_message_new (); mime_part = CAMEL_MIME_PART (message); - if (camel_mime_part_construct_from_parser ( + if (camel_mime_part_construct_from_parser_sync ( mime_part, mp, cancellable, error) == -1) { report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d"), i); g_object_unref (message); @@ -1347,7 +1349,8 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, if (p->defaultfolder) { report_status(driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder")); - camel_folder_sync (p->defaultfolder, FALSE, cancellable, NULL); + camel_folder_synchronize_sync ( + p->defaultfolder, FALSE, cancellable, NULL); } report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Complete")); @@ -1451,7 +1454,8 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, if (p->defaultfolder) { report_status (driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder")); - camel_folder_sync (p->defaultfolder, FALSE, cancellable, NULL); + camel_folder_synchronize_sync ( + p->defaultfolder, FALSE, cancellable, NULL); } if (i == uids->len) @@ -1489,7 +1493,7 @@ get_message_cb (gpointer data, GError **error) uid = camel_message_info_uid (p->info); /* FIXME Pass a GCancellable */ - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( p->source, uid, NULL, error); } @@ -1551,7 +1555,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, if (message) { g_object_ref (message); } else { - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( source, uid, cancellable, error); if (!message) return -1; @@ -1666,19 +1670,19 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, uids = g_ptr_array_new (); g_ptr_array_add (uids, (gchar *) p->uid); - camel_folder_transfer_messages_to ( + camel_folder_transfer_messages_to_sync ( p->source, uids, p->defaultfolder, NULL, FALSE, cancellable, &p->error); g_ptr_array_free (uids, TRUE); } else { if (p->message == NULL) { - p->message = camel_folder_get_message ( + p->message = camel_folder_get_message_sync ( source, uid, cancellable, error); if (!p->message) goto error; } - camel_folder_append_message ( + camel_folder_append_message_sync ( p->defaultfolder, p->message, p->info, NULL, cancellable, &p->error); } diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c index 279786d..1c17f5a 100644 --- a/camel/camel-filter-search.c +++ b/camel/camel-filter-search.c @@ -590,7 +590,7 @@ run_command (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMess message = camel_filter_search_get_message (fms, f); stream = camel_stream_fs_new_with_fd (pipe_to_child); - camel_data_wrapper_write_to_stream ( + camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (message), stream, NULL, NULL); camel_stream_flush (stream, NULL, NULL); g_object_unref (stream); diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c index e8061dd..399980e 100644 --- a/camel/camel-folder-search.c +++ b/camel/camel-folder-search.c @@ -1046,7 +1046,7 @@ get_current_message (CamelFolderSearch *search) return NULL; /* FIXME Pass a GCancellable */ - return camel_folder_get_message ( + return camel_folder_get_message_sync ( search->folder, search->current->uid, NULL, NULL); } @@ -1433,7 +1433,8 @@ match_words_1message (CamelDataWrapper *object, struct _camel_search_words *word stream = camel_stream_mem_new_with_byte_array (byte_array); /* FIXME: The match should be part of a stream op */ - camel_data_wrapper_decode_to_stream (containee, stream, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync ( + containee, stream, NULL, NULL); camel_stream_write (stream, "", 1, NULL, NULL); for (i=0;ilen;i++) { /* FIXME: This is horridly slow, and should use a real search algorithm */ @@ -1462,7 +1463,7 @@ match_words_message (CamelFolder *folder, CamelMimeMessage *msg; gint truth = FALSE; - msg = camel_folder_get_message (folder, uid, cancellable, error); + msg = camel_folder_get_message_sync (folder, uid, cancellable, error); if (msg) { mask = 0; truth = match_words_1message ((CamelDataWrapper *)msg, words, &mask); @@ -1622,7 +1623,7 @@ search_body_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, Came gchar *uid = g_ptr_array_index (v, i); /* FIXME Pass a GCancellable */ - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( search->folder, uid, NULL, NULL); if (message) { if (camel_search_message_body_contains ((CamelDataWrapper *) message, &pattern)) { @@ -1838,7 +1839,7 @@ search_message_location (struct _ESExp *f, gint argc, struct _ESExpResult **argv if (argc == 1 && argv[0]->type == ESEXP_RES_STRING) { if (argv[0]->value.string && search->folder && parent_store && camel_folder_get_full_name (search->folder)) { /* FIXME Pass a GCancellable */ - CamelFolderInfo *fi = camel_store_get_folder_info (parent_store, camel_folder_get_full_name (search->folder), 0, NULL, NULL); + CamelFolderInfo *fi = camel_store_get_folder_info_sync (parent_store, camel_folder_get_full_name (search->folder), 0, NULL, NULL); if (fi) { same = g_str_equal (fi->uri ? fi->uri : "", argv[0]->value.string); diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index 421f535..489d1c0 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -1635,7 +1635,7 @@ msg_update_preview (const gchar *uid, gpointer value, CamelFolder *folder) parent_store = camel_folder_get_parent_store (folder); /* FIXME Pass a GCancellable */ - msg = camel_folder_get_message (folder, uid, NULL, NULL); + msg = camel_folder_get_message_sync (folder, uid, NULL, NULL); if (msg != NULL) { if (camel_mime_message_build_preview ((CamelMimePart *)msg, (CamelMessageInfo *)info) && info->preview) camel_db_write_preview_record (parent_store->cdb_w, full_name, info->uid, info->preview, NULL); @@ -4043,7 +4043,7 @@ summary_build_content_info_message (CamelFolderSummary *s, CamelMessageInfo *msg CAMEL_STREAM_FILTER (p->filter_stream), p->filter_index); - camel_data_wrapper_decode_to_stream ( + camel_data_wrapper_decode_to_stream_sync ( containee, p->filter_stream, NULL, NULL); camel_stream_flush (p->filter_stream, NULL, NULL); diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 101b9c9..2863942 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -129,7 +129,7 @@ filter_filter (CamelSession *session, for (i = 0; i < m->junk->len; i ++) { /* FIXME Pass a GCancellable */ - CamelMimeMessage *msg = camel_folder_get_message ( + CamelMimeMessage *msg = camel_folder_get_message_sync ( m->folder, m->junk->pdata[i], NULL, NULL); gint pc = 100 * i / m->junk->len; @@ -152,7 +152,7 @@ filter_filter (CamelSession *session, m->notjunk->len), full_name); for (i = 0; i < m->notjunk->len; i ++) { /* FIXME Pass a GCancellable */ - CamelMimeMessage *msg = camel_folder_get_message ( + CamelMimeMessage *msg = camel_folder_get_message_sync ( m->folder, m->notjunk->pdata[i], NULL, NULL); gint pc = 100 * i / m->notjunk->len; @@ -275,7 +275,7 @@ folder_transfer_message_to (CamelFolder *source, /* Default implementation. */ - msg = camel_folder_get_message (source, uid, cancellable, error); + msg = camel_folder_get_message_sync (source, uid, cancellable, error); if (!msg) return; @@ -290,7 +290,7 @@ folder_transfer_message_to (CamelFolder *source, /* we don't want to retain the deleted flag */ camel_message_info_set_flags (info, CAMEL_MESSAGE_DELETED, 0); - camel_folder_append_message ( + camel_folder_append_message_sync ( dest, msg, info, transferred_uid, cancellable, &local_error); g_object_unref (msg); @@ -429,14 +429,6 @@ folder_finalize (GObject *object) G_OBJECT_CLASS (camel_folder_parent_class)->finalize (object); } -static gboolean -folder_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - return TRUE; -} - static gint folder_get_message_count (CamelFolder *folder) { @@ -678,61 +670,6 @@ folder_free_message_info (CamelFolder *folder, camel_message_info_free (info); } -static gboolean -folder_transfer_messages_to (CamelFolder *source, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) -{ - gchar **ret_uid = NULL; - gint i; - GError *local_error = NULL; - - if (transferred_uids) { - *transferred_uids = g_ptr_array_new (); - g_ptr_array_set_size (*transferred_uids, uids->len); - } - - if (delete_originals) - camel_operation_start ( - cancellable, _("Moving messages")); - else - camel_operation_start ( - cancellable, _("Copying messages")); - - if (uids->len > 1) { - camel_folder_freeze (dest); - if (delete_originals) - camel_folder_freeze (source); - } - - for (i = 0; i < uids->len && local_error == NULL; i++) { - if (transferred_uids) - ret_uid = (gchar **)&((*transferred_uids)->pdata[i]); - folder_transfer_message_to ( - source, uids->pdata[i], dest, ret_uid, - delete_originals, cancellable, &local_error); - camel_operation_progress ( - cancellable, i * 100 / uids->len); - } - - if (uids->len > 1) { - camel_folder_thaw (dest); - if (delete_originals) - camel_folder_thaw (source); - } - - camel_operation_end (cancellable); - - if (local_error != NULL) - g_propagate_error (error, local_error); - - return TRUE; -} - static void folder_delete (CamelFolder *folder) { @@ -806,6 +743,69 @@ folder_get_quota_info (CamelFolder *folder) return NULL; } +static gboolean +folder_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + return TRUE; +} + +static gboolean +folder_transfer_messages_to_sync (CamelFolder *source, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) +{ + gchar **ret_uid = NULL; + gint i; + GError *local_error = NULL; + + if (transferred_uids) { + *transferred_uids = g_ptr_array_new (); + g_ptr_array_set_size (*transferred_uids, uids->len); + } + + if (delete_originals) + camel_operation_start ( + cancellable, _("Moving messages")); + else + camel_operation_start ( + cancellable, _("Copying messages")); + + if (uids->len > 1) { + camel_folder_freeze (dest); + if (delete_originals) + camel_folder_freeze (source); + } + + for (i = 0; i < uids->len && local_error == NULL; i++) { + if (transferred_uids) + ret_uid = (gchar **)&((*transferred_uids)->pdata[i]); + folder_transfer_message_to ( + source, uids->pdata[i], dest, ret_uid, + delete_originals, cancellable, &local_error); + camel_operation_progress ( + cancellable, i * 100 / uids->len); + } + + if (uids->len > 1) { + camel_folder_thaw (dest); + if (delete_originals) + camel_folder_thaw (source); + } + + camel_operation_end (cancellable); + + if (local_error != NULL) + g_propagate_error (error, local_error); + + return TRUE; +} + /* Signal callback that stops emission when folder is frozen. */ static void folder_changed (CamelFolder *folder, @@ -907,7 +907,6 @@ camel_folder_class_init (CamelFolderClass *class) object_class->dispose = folder_dispose; object_class->finalize = folder_finalize; - class->refresh_info = folder_refresh_info; class->get_message_count = folder_get_message_count; class->get_permanent_flags = folder_get_permanent_flags; class->get_message_flags = folder_get_message_flags; @@ -927,13 +926,14 @@ camel_folder_class_init (CamelFolderClass *class) class->get_message_info = folder_get_message_info; class->ref_message_info = folder_ref_message_info; class->free_message_info = folder_free_message_info; - class->transfer_messages_to = folder_transfer_messages_to; class->delete = folder_delete; class->rename = folder_rename; class->freeze = folder_freeze; class->thaw = folder_thaw; class->is_frozen = folder_is_frozen; class->get_quota_info = folder_get_quota_info; + class->refresh_info_sync = folder_refresh_info_sync; + class->transfer_messages_to_sync = folder_transfer_messages_to_sync; class->changed = folder_changed; /** @@ -1112,7 +1112,7 @@ camel_folder_get_filename (CamelFolder *folder, } /** - * camel_folder_sync: + * camel_folder_synchronize_sync: * @folder: a #CamelFolder * @expunge: whether or not to expunge deleted messages * @cancellable: optional #GCancellable object, or %NULL @@ -1124,10 +1124,10 @@ camel_folder_get_filename (CamelFolder *folder, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_folder_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) +camel_folder_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) { CamelFolderClass *class; gboolean success = TRUE; @@ -1135,13 +1135,14 @@ camel_folder_sync (CamelFolder *folder, g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); class = CAMEL_FOLDER_GET_CLASS (folder); - g_return_val_if_fail (class->sync != NULL, FALSE); + g_return_val_if_fail (class->synchronize_sync != NULL, FALSE); camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK); if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED)) { - success = class->sync (folder, expunge, cancellable, error); - CAMEL_CHECK_GERROR (folder, sync, success, error); + success = class->synchronize_sync ( + folder, expunge, cancellable, error); + CAMEL_CHECK_GERROR (folder, synchronize_sync, success, error); } camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK); @@ -1150,7 +1151,7 @@ camel_folder_sync (CamelFolder *folder, } /** - * camel_folder_refresh_info: + * camel_folder_refresh_info_sync: * @folder: a #CamelFolder * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL @@ -1160,9 +1161,9 @@ camel_folder_sync (CamelFolder *folder, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_folder_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) +camel_folder_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { CamelFolderClass *class; gboolean success; @@ -1170,12 +1171,12 @@ camel_folder_refresh_info (CamelFolder *folder, g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); class = CAMEL_FOLDER_GET_CLASS (folder); - g_return_val_if_fail (class->refresh_info != NULL, FALSE); + g_return_val_if_fail (class->refresh_info_sync != NULL, FALSE); camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK); - success = class->refresh_info (folder, cancellable, error); - CAMEL_CHECK_GERROR (folder, refresh_info, success, error); + success = class->refresh_info_sync (folder, cancellable, error); + CAMEL_CHECK_GERROR (folder, refresh_info_sync, success, error); camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK); @@ -1315,7 +1316,7 @@ camel_folder_get_parent_store (CamelFolder *folder) } /** - * camel_folder_expunge: + * camel_folder_expunge_sync: * @folder: a #CamelFolder * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL @@ -1325,9 +1326,9 @@ camel_folder_get_parent_store (CamelFolder *folder) * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_folder_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error) +camel_folder_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { CamelFolderClass *class; gboolean success = TRUE; @@ -1335,13 +1336,13 @@ camel_folder_expunge (CamelFolder *folder, g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); class = CAMEL_FOLDER_GET_CLASS (folder); - g_return_val_if_fail (class->expunge != NULL, FALSE); + g_return_val_if_fail (class->expunge_sync != NULL, FALSE); camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK); if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED)) { - success = class->expunge (folder, cancellable, error); - CAMEL_CHECK_GERROR (folder, expunge, success, error); + success = class->expunge_sync (folder, cancellable, error); + CAMEL_CHECK_GERROR (folder, expunge_sync, success, error); } camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK); @@ -1403,7 +1404,7 @@ camel_folder_get_deleted_message_count (CamelFolder *folder) } /** - * camel_folder_append_message: + * camel_folder_append_message_sync: * @folder: a #CamelFolder * @message: a #CamelMimeMessage object * @info: a #CamelMessageInfo with additional flags/etc to set on @@ -1419,12 +1420,12 @@ camel_folder_get_deleted_message_count (CamelFolder *folder) * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_folder_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +camel_folder_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { CamelFolderClass *class; gboolean success; @@ -1433,13 +1434,13 @@ camel_folder_append_message (CamelFolder *folder, g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), FALSE); class = CAMEL_FOLDER_GET_CLASS (folder); - g_return_val_if_fail (class->append_message != NULL, FALSE); + g_return_val_if_fail (class->append_message_sync != NULL, FALSE); camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK); - success = class->append_message ( + success = class->append_message_sync ( folder, message, info, appended_uid, cancellable, error); - CAMEL_CHECK_GERROR (folder, append_message, success, error); + CAMEL_CHECK_GERROR (folder, append_message_sync, success, error); camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK); @@ -1749,7 +1750,7 @@ camel_folder_has_summary_capability (CamelFolder *folder) /* UIDs stuff */ /** - * camel_folder_get_message: + * camel_folder_get_message_sync: * @folder: a #CamelFolder * @uid: the UID * @cancellable: optional #GCancellable object, or %NULL @@ -1760,10 +1761,10 @@ camel_folder_has_summary_capability (CamelFolder *folder) * Returns: a #CamelMimeMessage corresponding to @uid **/ CamelMimeMessage * -camel_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +camel_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelFolderClass *class; CamelMimeMessage *ret; @@ -1772,15 +1773,15 @@ camel_folder_get_message (CamelFolder *folder, g_return_val_if_fail (uid != NULL, NULL); class = CAMEL_FOLDER_GET_CLASS (folder); - g_return_val_if_fail (class->get_message != NULL, NULL); + g_return_val_if_fail (class->get_message_sync != NULL, NULL); camel_operation_start ( cancellable, _("Retrieving message '%s'"), uid); camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK); - ret = class->get_message (folder, uid, cancellable, error); - CAMEL_CHECK_GERROR (folder, get_message, ret != NULL, error); + ret = class->get_message_sync (folder, uid, cancellable, error); + CAMEL_CHECK_GERROR (folder, get_message_sync, ret != NULL, error); camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK); @@ -1797,7 +1798,7 @@ camel_folder_get_message (CamelFolder *folder, } /** - * camel_folder_sync_message: + * camel_folder_synchronize_message_sync: * @folder: a #CamelFolder * @uid: the UID * @cancellable: optional #GCancellable object, or %NULL @@ -1811,10 +1812,10 @@ camel_folder_get_message (CamelFolder *folder, * Since: 2.26 **/ gboolean -camel_folder_sync_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +camel_folder_synchronize_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelFolderClass *class; gboolean success = FALSE; @@ -1823,20 +1824,23 @@ camel_folder_sync_message (CamelFolder *folder, g_return_val_if_fail (uid != NULL, FALSE); class = CAMEL_FOLDER_GET_CLASS (folder); - g_return_val_if_fail (class->get_message != NULL, FALSE); + g_return_val_if_fail (class->get_message_sync != NULL, FALSE); camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK); /* Use the sync_message method if the class implements it. */ - if (class->sync_message != NULL) { - success = class->sync_message ( + if (class->synchronize_message_sync != NULL) { + success = class->synchronize_message_sync ( folder, uid, cancellable, error); - CAMEL_CHECK_GERROR (folder, sync_message, success, error); + CAMEL_CHECK_GERROR ( + folder, synchronize_message_sync, success, error); } else { CamelMimeMessage *message; - message = class->get_message (folder, uid, cancellable, error); - CAMEL_CHECK_GERROR (folder, get_message, message != NULL, error); + message = class->get_message_sync ( + folder, uid, cancellable, error); + CAMEL_CHECK_GERROR ( + folder, get_message_sync, message != NULL, error); if (message != NULL) { g_object_unref (message); @@ -2167,7 +2171,7 @@ camel_folder_search_free (CamelFolder *folder, } /** - * camel_folder_transfer_messages_to: + * camel_folder_transfer_messages_to_sync: * @source: the source #CamelFolder object * @uids: message UIDs in @source * @dest: the destination #CamelFolder object @@ -2184,13 +2188,13 @@ camel_folder_search_free (CamelFolder *folder, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_folder_transfer_messages_to (CamelFolder *source, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) +camel_folder_transfer_messages_to_sync (CamelFolder *source, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) { CamelFolderClass *class; gboolean success; @@ -2211,11 +2215,11 @@ camel_folder_transfer_messages_to (CamelFolder *source, class = CAMEL_FOLDER_GET_CLASS (dest); else class = CAMEL_FOLDER_GET_CLASS (source); - success = class->transfer_messages_to ( + success = class->transfer_messages_to_sync ( source, uids, dest, transferred_uids, delete_originals, cancellable, error); } else - success = folder_transfer_messages_to ( + success = folder_transfer_messages_to_sync ( source, uids, dest, transferred_uids, delete_originals, cancellable, error); diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 1dff41a..652cba7 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -144,23 +144,7 @@ struct _CamelFolderClass { CamelObjectClass parent_class; /* Methods */ - gboolean (*refresh_info) (CamelFolder *folder, - GCancellable *cancellable, - GError **error); - gboolean (*sync) (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error); - gboolean (*expunge) (CamelFolder *folder, - GCancellable *cancellable, - GError **error); gint (*get_message_count) (CamelFolder *folder); - gboolean (*append_message) (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error); guint32 (*get_permanent_flags) (CamelFolder *folder); guint32 (*get_message_flags) (CamelFolder *folder, const gchar *uid); @@ -182,11 +166,6 @@ struct _CamelFolderClass { const gchar *uid, const gchar *name, const gchar *value); - CamelMimeMessage * - (*get_message) (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error); GPtrArray * (*get_uids) (CamelFolder *folder); void (*free_uids) (CamelFolder *folder, GPtrArray *array); @@ -215,13 +194,6 @@ struct _CamelFolderClass { CamelMessageInfo *info); void (*free_message_info) (CamelFolder *folder, CamelMessageInfo *info); - gboolean (*transfer_messages_to) (CamelFolder *source, - GPtrArray *uids, - CamelFolder *destination, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error); void (*delete) (CamelFolder *folder); void (*rename) (CamelFolder *folder, const gchar *newname); @@ -233,10 +205,6 @@ struct _CamelFolderClass { guint32 (*count_by_expression) (CamelFolder *folder, const gchar *expression, GError **error); - gboolean (*sync_message) (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error); GPtrArray * (*get_uncached_uids) (CamelFolder *folder, GPtrArray *uids, GError **error); @@ -244,6 +212,41 @@ struct _CamelFolderClass { const gchar *uid, GError **error); + gboolean (*append_message_sync) (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error); + gboolean (*expunge_sync) (CamelFolder *folder, + GCancellable *cancellable, + GError **error); + CamelMimeMessage * + (*get_message_sync) (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error); + gboolean (*refresh_info_sync) (CamelFolder *folder, + GCancellable *cancellable, + GError **error); + gboolean (*synchronize_sync) (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error); + gboolean (*synchronize_message_sync) + (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error); + gboolean (*transfer_messages_to_sync) + (CamelFolder *source, + GPtrArray *uids, + CamelFolder *destination, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error); + /* Signals */ void (*changed) (CamelFolder *folder, CamelFolderChangeInfo *info); @@ -254,25 +257,10 @@ struct _CamelFolderClass { GType camel_folder_get_type (void); GQuark camel_folder_error_quark (void) G_GNUC_CONST; -gboolean camel_folder_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error); -gboolean camel_folder_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error); void camel_folder_set_lock_async (CamelFolder *folder, gboolean skip_folder_lock); - struct _CamelStore * camel_folder_get_parent_store (CamelFolder *folder); - -/* delete operations */ -gboolean camel_folder_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error); - -/* folder name operations */ const gchar * camel_folder_get_name (CamelFolder *folder); void camel_folder_set_name (CamelFolder *folder, const gchar *name); @@ -282,79 +270,46 @@ void camel_folder_set_full_name (CamelFolder *folder, const gchar * camel_folder_get_description (CamelFolder *folder); void camel_folder_set_description (CamelFolder *folder, const gchar *description); - -/* various properties accessors */ guint32 camel_folder_get_permanent_flags (CamelFolder *folder); - #ifndef CAMEL_DISABLE_DEPRECATED guint32 camel_folder_get_message_flags (CamelFolder *folder, const gchar *uid); - gboolean camel_folder_set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set); - gboolean camel_folder_get_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name); - void camel_folder_set_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name, gboolean value); - const gchar * camel_folder_get_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name); - void camel_folder_set_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name, const gchar *value); #endif /* CAMEL_DISABLE_DEPRECATED */ - -/* message manipulation */ -gboolean camel_folder_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error); - -/* summary related operations */ gboolean camel_folder_has_summary_capability (CamelFolder *folder); - gint camel_folder_get_message_count (CamelFolder *folder); - #ifndef CAMEL_DISABLE_DEPRECATED gint camel_folder_get_unread_message_count (CamelFolder *folder); #endif - gint camel_folder_get_deleted_message_count (CamelFolder *folder); - GPtrArray * camel_folder_get_summary (CamelFolder *folder); void camel_folder_free_summary (CamelFolder *folder, GPtrArray *array); -/* uid based access operations */ -CamelMimeMessage * - camel_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error); -gboolean camel_folder_sync_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error); - #define camel_folder_delete_message(folder, uid) \ (camel_folder_set_message_flags ( \ folder, uid, \ @@ -372,8 +327,6 @@ gint camel_folder_cmp_uids (CamelFolder *folder, const gchar *uid2); void camel_folder_sort_uids (CamelFolder *folder, GPtrArray *uids); - -/* search api */ gboolean camel_folder_has_search_capability (CamelFolder *folder); GPtrArray * camel_folder_search_by_expression @@ -389,8 +342,6 @@ void camel_folder_search_free (CamelFolder *folder, guint32 camel_folder_count_by_expression (CamelFolder *folder, const gchar *expression, GError **error); - -/* summary info */ CamelMessageInfo * camel_folder_get_message_info (CamelFolder *folder, const gchar *uid); @@ -400,29 +351,15 @@ void camel_folder_free_message_info (CamelFolder *folder, void camel_folder_ref_message_info (CamelFolder *folder, CamelMessageInfo *info); #endif - -gboolean camel_folder_transfer_messages_to - (CamelFolder *source, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error); - void camel_folder_delete (CamelFolder *folder); void camel_folder_rename (CamelFolder *folder, const gchar *new); void camel_folder_changed (CamelFolder *folder, CamelFolderChangeInfo *changes); - -/* stop/restart getting events */ void camel_folder_freeze (CamelFolder *folder); void camel_folder_thaw (CamelFolder *folder); gboolean camel_folder_is_frozen (CamelFolder *folder); gint camel_folder_get_frozen_count (CamelFolder *folder); - -/* quota support */ CamelFolderQuotaInfo * camel_folder_get_quota_info (CamelFolder *folder); CamelFolderQuotaInfo * @@ -432,18 +369,50 @@ CamelFolderQuotaInfo * CamelFolderQuotaInfo * camel_folder_quota_info_clone (const CamelFolderQuotaInfo *info); void camel_folder_quota_info_free (CamelFolderQuotaInfo *info); - -/* For use by subclasses (for free_{uids,summary,subfolder_names}) */ void camel_folder_free_nop (CamelFolder *folder, GPtrArray *array); void camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array); void camel_folder_free_deep (CamelFolder *folder, GPtrArray *array); - gchar * camel_folder_get_filename (CamelFolder *folder, const gchar *uid, GError **error); +gboolean camel_folder_append_message_sync + (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error); +gboolean camel_folder_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error); +CamelMimeMessage * + camel_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error); +gboolean camel_folder_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error); +gboolean camel_folder_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error); +gboolean camel_folder_synchronize_message_sync + (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error); +gboolean camel_folder_transfer_messages_to_sync + (CamelFolder *source, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error); /* update functions for change info */ CamelFolderChangeInfo * @@ -482,6 +451,7 @@ void camel_folder_change_info_change_uid void camel_folder_change_info_recent_uid (CamelFolderChangeInfo *info, const gchar *uid); + void camel_folder_lock (CamelFolder *folder, CamelFolderLock lock); void camel_folder_unlock (CamelFolder *folder, diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 9f26313..a63257f 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -1366,7 +1366,7 @@ swrite (CamelMimePart *sigpart, /* TODO: This should probably just write the decoded message content out, not the part + headers */ ostream = camel_stream_fs_new_with_fd (fd); - ret = camel_data_wrapper_write_to_stream ( + ret = camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (sigpart), ostream, cancellable, error); if (ret != -1) { ret = camel_stream_flush (ostream, cancellable, error); @@ -1507,13 +1507,13 @@ gpg_id_to_hash (CamelCipherContext *context, } static gint -gpg_sign (CamelCipherContext *context, - const gchar *userid, - CamelCipherHash hash, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +gpg_sign_sync (CamelCipherContext *context, + const gchar *userid, + CamelCipherHash hash, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { struct _GpgCtx *gpg = NULL; CamelCipherContextClass *class; @@ -1592,7 +1592,8 @@ gpg_sign (CamelCipherContext *context, dw = camel_data_wrapper_new (); camel_stream_reset (ostream, NULL); - camel_data_wrapper_construct_from_stream (dw, ostream, NULL, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, ostream, NULL, NULL); sigpart = camel_mime_part_new (); ct = camel_content_type_new("application", "pgp-signature"); @@ -1629,10 +1630,10 @@ fail: } static CamelCipherValidity * -gpg_verify (CamelCipherContext *context, - CamelMimePart *ipart, - GCancellable *cancellable, - GError **error) +gpg_verify_sync (CamelCipherContext *context, + CamelMimePart *ipart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; CamelCipherValidity *validity; @@ -1688,7 +1689,7 @@ gpg_verify (CamelCipherContext *context, CamelDataWrapper *content; content = camel_medium_get_content ((CamelMedium *) ipart); istream = camel_stream_mem_new (); - camel_data_wrapper_decode_to_stream ( + camel_data_wrapper_decode_to_stream_sync ( content, istream, NULL, NULL); camel_stream_reset (istream, NULL); sigpart = NULL; @@ -1831,13 +1832,13 @@ gpg_verify (CamelCipherContext *context, } static gint -gpg_encrypt (CamelCipherContext *context, - const gchar *userid, - GPtrArray *recipients, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +gpg_encrypt_sync (CamelCipherContext *context, + const gchar *userid, + GPtrArray *recipients, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; CamelGpgContext *ctx = (CamelGpgContext *) context; @@ -1897,7 +1898,8 @@ gpg_encrypt (CamelCipherContext *context, res = 0; dw = camel_data_wrapper_new (); - camel_data_wrapper_construct_from_stream (dw, ostream, NULL, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, ostream, NULL, NULL); encpart = camel_mime_part_new (); ct = camel_content_type_new("application", "octet-stream"); @@ -1917,7 +1919,8 @@ gpg_encrypt (CamelCipherContext *context, verpart = camel_mime_part_new (); dw = camel_data_wrapper_new (); camel_data_wrapper_set_mime_type (dw, class->encrypt_protocol); - camel_data_wrapper_construct_from_stream (dw, vstream, NULL, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, vstream, NULL, NULL); g_object_unref (vstream); camel_medium_set_content ((CamelMedium *)verpart, dw); g_object_unref (dw); @@ -1947,11 +1950,11 @@ fail1: } static CamelCipherValidity * -gpg_decrypt (CamelCipherContext *context, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +gpg_decrypt_sync (CamelCipherContext *context, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { struct _GpgCtx *gpg; CamelCipherValidity *valid = NULL; @@ -2002,7 +2005,8 @@ gpg_decrypt (CamelCipherContext *context, } istream = camel_stream_mem_new (); - camel_data_wrapper_decode_to_stream (content, istream, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync ( + content, istream, NULL, NULL); camel_stream_reset (istream, NULL); ostream = camel_stream_mem_new (); @@ -2040,16 +2044,17 @@ gpg_decrypt (CamelCipherContext *context, CamelStream *null = camel_stream_null_new (); /* Multipart encrypted - parse a full mime part */ - rv = camel_data_wrapper_construct_from_stream ( + rv = camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (opart), ostream, NULL, error); dw = camel_medium_get_content ((CamelMedium *)opart); - if (!camel_data_wrapper_decode_to_stream (dw, null, cancellable, NULL)) { + if (!camel_data_wrapper_decode_to_stream_sync ( + dw, null, cancellable, NULL)) { /* nothing had been decoded from the stream, it doesn't contain any header, like Content-Type or such, thus write it as a message body */ - rv = camel_data_wrapper_construct_from_stream ( + rv = camel_data_wrapper_construct_from_stream_sync ( dw, ostream, NULL, error); } @@ -2058,7 +2063,7 @@ gpg_decrypt (CamelCipherContext *context, /* Inline signed - raw data (may not be a mime part) */ CamelDataWrapper *dw; dw = camel_data_wrapper_new (); - rv = camel_data_wrapper_construct_from_stream ( + rv = camel_data_wrapper_construct_from_stream_sync ( dw, ostream, NULL, error); camel_data_wrapper_set_mime_type(dw, "application/octet-stream"); camel_medium_set_content ((CamelMedium *)opart, dw); @@ -2099,10 +2104,10 @@ gpg_decrypt (CamelCipherContext *context, } static gint -gpg_import_keys (CamelCipherContext *context, - CamelStream *istream, - GCancellable *cancellable, - GError **error) +gpg_import_keys_sync (CamelCipherContext *context, + CamelStream *istream, + GCancellable *cancellable, + GError **error) { struct _GpgCtx *gpg; gint res = -1; @@ -2140,11 +2145,11 @@ fail: } static gint -gpg_export_keys (CamelCipherContext *context, - GPtrArray *keys, - CamelStream *ostream, - GCancellable *cancellable, - GError **error) +gpg_export_keys_sync (CamelCipherContext *context, + GPtrArray *keys, + CamelStream *ostream, + GCancellable *cancellable, + GError **error) { struct _GpgCtx *gpg; gint i; @@ -2205,12 +2210,12 @@ camel_gpg_context_class_init (CamelGpgContextClass *class) cipher_context_class->key_protocol = "application/pgp-keys"; cipher_context_class->hash_to_id = gpg_hash_to_id; cipher_context_class->id_to_hash = gpg_id_to_hash; - cipher_context_class->sign = gpg_sign; - cipher_context_class->verify = gpg_verify; - cipher_context_class->encrypt = gpg_encrypt; - cipher_context_class->decrypt = gpg_decrypt; - cipher_context_class->import_keys = gpg_import_keys; - cipher_context_class->export_keys = gpg_export_keys; + cipher_context_class->sign_sync = gpg_sign_sync; + cipher_context_class->verify_sync = gpg_verify_sync; + cipher_context_class->encrypt_sync = gpg_encrypt_sync; + cipher_context_class->decrypt_sync = gpg_decrypt_sync; + cipher_context_class->import_keys_sync = gpg_import_keys_sync; + cipher_context_class->export_keys_sync = gpg_export_keys_sync; g_object_class_install_property ( object_class, diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 3aefe96..ba97e3a 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -216,10 +216,10 @@ mime_message_finalize (GObject *object) } static gssize -mime_message_write_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +mime_message_write_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { CamelDataWrapperClass *data_wrapper_class; CamelMimeMessage *mm = CAMEL_MIME_MESSAGE (data_wrapper); @@ -244,10 +244,10 @@ mime_message_write_to_stream (CamelDataWrapper *data_wrapper, if (!camel_medium_get_header ((CamelMedium *)mm, "Mime-Version")) camel_medium_set_header ((CamelMedium *)mm, "Mime-Version", "1.0"); - /* Chain up to parent's write_to_stream() method. */ + /* Chain up to parent's write_to_stream_sync() method. */ data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS ( camel_mime_message_parent_class); - return data_wrapper_class->write_to_stream ( + return data_wrapper_class->write_to_stream_sync ( data_wrapper, stream, cancellable, error); } @@ -289,10 +289,10 @@ mime_message_remove_header (CamelMedium *medium, } static gint -mime_message_construct_from_parser (CamelMimePart *dw, - CamelMimeParser *mp, - GCancellable *cancellable, - GError **error) +mime_message_construct_from_parser_sync (CamelMimePart *dw, + CamelMimeParser *mp, + GCancellable *cancellable, + GError **error) { CamelMimePartClass *mime_part_class; gchar *buf; @@ -301,13 +301,9 @@ mime_message_construct_from_parser (CamelMimePart *dw, gint ret; gint err; - d(printf("constructing mime-message\n")); - - d(printf("mime_message::construct_from_parser()\n")); - /* let the mime-part construct the guts ... */ mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_message_parent_class); - ret = mime_part_class->construct_from_parser ( + ret = mime_part_class->construct_from_parser_sync ( dw, mp, cancellable, error); if (ret == -1) @@ -328,7 +324,6 @@ mime_message_construct_from_parser (CamelMimePart *dw, return -1; } - d(printf("mime_message::construct_from_parser() leaving\n")); err = camel_mime_parser_errno (mp); if (err != 0) { errno = err; @@ -356,8 +351,8 @@ camel_mime_message_class_init (CamelMimeMessageClass *class) object_class->finalize = mime_message_finalize; data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class); - data_wrapper_class->write_to_stream = mime_message_write_to_stream; - data_wrapper_class->decode_to_stream = mime_message_write_to_stream; + data_wrapper_class->write_to_stream_sync = mime_message_write_to_stream_sync; + data_wrapper_class->decode_to_stream_sync = mime_message_write_to_stream_sync; medium_class = CAMEL_MEDIUM_CLASS (class); medium_class->add_header = mime_message_add_header; @@ -365,7 +360,7 @@ camel_mime_message_class_init (CamelMimeMessageClass *class) medium_class->remove_header = mime_message_remove_header; mime_part_class = CAMEL_MIME_PART_CLASS (class); - mime_part_class->construct_from_parser = mime_message_construct_from_parser; + mime_part_class->construct_from_parser_sync = mime_message_construct_from_parser_sync; header_name_table = g_hash_table_new ( camel_strcase_hash, camel_strcase_equal); @@ -910,7 +905,7 @@ find_best_encoding (CamelMimePart *part, CamelBestencRequired required, CamelBes idb = camel_stream_filter_add ( CAMEL_STREAM_FILTER (filter), bestenc); d(printf("writing to checking stream\n")); - camel_data_wrapper_decode_to_stream (content, filter, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync (content, filter, NULL, NULL); camel_stream_filter_remove (CAMEL_STREAM_FILTER (filter), idb); if (idc != -1) { camel_stream_filter_remove (CAMEL_STREAM_FILTER (filter), idc); @@ -953,7 +948,7 @@ find_best_encoding (CamelMimePart *part, CamelBestencRequired required, CamelBes CAMEL_STREAM_FILTER (filter), bestenc); /* and write it to the new stream */ - camel_data_wrapper_write_to_stream ( + camel_data_wrapper_write_to_stream_sync ( content, filter, NULL, NULL); g_object_unref (charenc); diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 1cef03a..e9c7268 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -78,7 +78,7 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, d(printf("message part kept in memory!\n")); mem = camel_stream_mem_new_with_byte_array (buffer); - retval = camel_data_wrapper_construct_from_stream ( + retval = camel_data_wrapper_construct_from_stream_sync ( dw, mem, cancellable, error); g_object_unref (mem); @@ -123,7 +123,7 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, case CAMEL_MIME_PARSER_STATE_MESSAGE: d(printf("Creating message part\n")); content = (CamelDataWrapper *) camel_mime_message_new (); - success = (camel_mime_part_construct_from_parser ( + success = (camel_mime_part_construct_from_parser_sync ( (CamelMimePart *)content, mp, cancellable, error) == 0); break; case CAMEL_MIME_PARSER_STATE_MULTIPART: @@ -187,7 +187,7 @@ camel_mime_message_build_preview (CamelMimePart *msg, !camel_content_type_is (dw->mime_type, "text", "calendar")) { CamelStream *mstream, *bstream; mstream = camel_stream_mem_new (); - if (camel_data_wrapper_decode_to_stream (dw, mstream, NULL, NULL) > 0) { + if (camel_data_wrapper_decode_to_stream_sync (dw, mstream, NULL, NULL) > 0) { gchar *line = NULL; GString *str = g_string_new (NULL); diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index a65dafa..e4d7025 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -497,10 +497,10 @@ mime_part_set_content (CamelMedium *medium, } static gssize -mime_part_write_to_stream (CamelDataWrapper *dw, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +mime_part_write_to_stream_sync (CamelDataWrapper *dw, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { CamelMimePart *mp = CAMEL_MIME_PART (dw); CamelMedium *medium = CAMEL_MEDIUM (dw); @@ -639,10 +639,10 @@ mime_part_write_to_stream (CamelDataWrapper *dw, } if (reencode) - count = camel_data_wrapper_decode_to_stream ( + count = camel_data_wrapper_decode_to_stream_sync ( content, stream, cancellable, error); else - count = camel_data_wrapper_write_to_stream ( + count = camel_data_wrapper_write_to_stream_sync ( content, stream, cancellable, error); if (filter_stream) { @@ -672,10 +672,10 @@ mime_part_write_to_stream (CamelDataWrapper *dw, } static gint -mime_part_construct_from_stream (CamelDataWrapper *dw, - CamelStream *s, - GCancellable *cancellable, - GError **error) +mime_part_construct_from_stream_sync (CamelDataWrapper *dw, + CamelStream *s, + GCancellable *cancellable, + GError **error) { CamelMimeParser *mp; gint ret; @@ -686,7 +686,7 @@ mime_part_construct_from_stream (CamelDataWrapper *dw, if (camel_mime_parser_init_with_stream (mp, s, error) == -1) { ret = -1; } else { - ret = camel_mime_part_construct_from_parser ( + ret = camel_mime_part_construct_from_parser_sync ( CAMEL_MIME_PART (dw), mp, cancellable, error); } g_object_unref (mp); @@ -694,10 +694,10 @@ mime_part_construct_from_stream (CamelDataWrapper *dw, } static gint -mime_part_construct_from_parser (CamelMimePart *mime_part, - CamelMimeParser *mp, - GCancellable *cancellable, - GError **error) +mime_part_construct_from_parser_sync (CamelMimePart *mime_part, + CamelMimeParser *mp, + GCancellable *cancellable, + GError **error) { CamelDataWrapper *dw = (CamelDataWrapper *) mime_part; struct _camel_header_raw *headers; @@ -708,8 +708,6 @@ mime_part_construct_from_parser (CamelMimePart *mime_part, gboolean success; gboolean retval = 0; - d(printf("mime_part::construct_from_parser()\n")); - switch (camel_mime_parser_step (mp, &buf, &len)) { case CAMEL_MIME_PARSER_STATE_MESSAGE: /* set the default type of a message always */ @@ -743,7 +741,6 @@ mime_part_construct_from_parser (CamelMimePart *mime_part, g_warning("Invalid state encountered???: %u", camel_mime_parser_state(mp)); } - d(printf("mime_part::construct_from_parser() leaving\n")); err = camel_mime_parser_errno (mp); if (err != 0) { errno = err; @@ -781,10 +778,10 @@ camel_mime_part_class_init (CamelMimePartClass *class) medium_class->set_content = mime_part_set_content; data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class); - data_wrapper_class->write_to_stream = mime_part_write_to_stream; - data_wrapper_class->construct_from_stream = mime_part_construct_from_stream; + data_wrapper_class->write_to_stream_sync = mime_part_write_to_stream_sync; + data_wrapper_class->construct_from_stream_sync = mime_part_construct_from_stream_sync; - class->construct_from_parser = mime_part_construct_from_parser; + class->construct_from_parser_sync = mime_part_construct_from_parser_sync; g_object_class_install_property ( object_class, @@ -1273,7 +1270,7 @@ camel_mime_part_get_content_type (CamelMimePart *mime_part) } /** - * camel_mime_part_construct_from_parser: + * camel_mime_part_construct_from_parser_sync: * @mime_part: a #CamelMimePart object * @parser: a #CamelMimeParser object * @cancellable: optional #GCancellable object, or %NULL @@ -1284,10 +1281,10 @@ camel_mime_part_get_content_type (CamelMimePart *mime_part) * Returns: %0 on success or %-1 on fail **/ gint -camel_mime_part_construct_from_parser (CamelMimePart *mime_part, - CamelMimeParser *mp, - GCancellable *cancellable, - GError **error) +camel_mime_part_construct_from_parser_sync (CamelMimePart *mime_part, + CamelMimeParser *mp, + GCancellable *cancellable, + GError **error) { CamelMimePartClass *class; gint retval; @@ -1296,12 +1293,12 @@ camel_mime_part_construct_from_parser (CamelMimePart *mime_part, g_return_val_if_fail (CAMEL_IS_MIME_PARSER (mp), -1); class = CAMEL_MIME_PART_GET_CLASS (mime_part); - g_return_val_if_fail (class->construct_from_parser != NULL, -1); + g_return_val_if_fail (class->construct_from_parser_sync != NULL, -1); - retval = class->construct_from_parser ( + retval = class->construct_from_parser_sync ( mime_part, mp, cancellable, error); CAMEL_CHECK_GERROR ( - mime_part, construct_from_parser, retval == 0, error); + mime_part, construct_from_parser_sync, retval == 0, error); return retval; } @@ -1345,7 +1342,7 @@ camel_mime_part_set_content (CamelMimePart *mime_part, dw = camel_data_wrapper_new (); camel_data_wrapper_set_mime_type (dw, type); stream = camel_stream_mem_new_with_buffer (data, length); - camel_data_wrapper_construct_from_stream ( + camel_data_wrapper_construct_from_stream_sync ( dw, stream, NULL, NULL); g_object_unref (stream); camel_medium_set_content (medium, dw); @@ -1376,7 +1373,7 @@ camel_mime_part_get_content_size (CamelMimePart *mime_part) dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part)); null = camel_stream_null_new (); - camel_data_wrapper_decode_to_stream (dw, null, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync (dw, null, NULL, NULL); size = CAMEL_STREAM_NULL (null)->written; g_object_unref (null); diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h index 6259d19..748a31b 100644 --- a/camel/camel-mime-part.h +++ b/camel/camel-mime-part.h @@ -69,7 +69,7 @@ struct _CamelMimePart { struct _CamelMimePartClass { CamelMediumClass parent_class; - gint (*construct_from_parser) (CamelMimePart *mime_part, + gint (*construct_from_parser_sync) (CamelMimePart *mime_part, CamelMimeParser *parser, GCancellable *cancellable, GError **error); @@ -109,30 +109,23 @@ void camel_mime_part_set_content_languages GList *content_languages); const GList * camel_mime_part_get_content_languages (CamelMimePart *mime_part); - -/* FIXME: what about content-type parameters? what about major/minor parts? */ void camel_mime_part_set_content_type (CamelMimePart *mime_part, const gchar *content_type); CamelContentType * camel_mime_part_get_content_type (CamelMimePart *mime_part); - -/* construction */ -gint camel_mime_part_construct_from_parser - (CamelMimePart *mime_part, - CamelMimeParser *parser, - GCancellable *cancellable, - GError **error); - -/* utility functions */ void camel_mime_part_set_content (CamelMimePart *mime_part, const gchar *data, gint length, const gchar *type); - gsize camel_mime_part_get_content_size (CamelMimePart *mime_part); +gint camel_mime_part_construct_from_parser_sync + (CamelMimePart *mime_part, + CamelMimeParser *parser, + GCancellable *cancellable, + GError **error); G_END_DECLS diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c index f61c08c..21968fb 100644 --- a/camel/camel-multipart-signed.c +++ b/camel/camel-multipart-signed.c @@ -254,10 +254,10 @@ multipart_signed_set_mime_type_field (CamelDataWrapper *data_wrapper, } static gssize -multipart_signed_write_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +multipart_signed_write_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper; CamelMultipart *mp = (CamelMultipart *)mps; @@ -326,7 +326,7 @@ multipart_signed_write_to_stream (CamelDataWrapper *data_wrapper, total += count; /* signature */ - count = camel_data_wrapper_write_to_stream ( + count = camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (mps->signature), stream, cancellable, error); if (count == -1) @@ -360,10 +360,10 @@ file_error: } static gint -multipart_signed_construct_from_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +multipart_signed_construct_from_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper; CamelStream *mem = camel_stream_mem_new (); @@ -436,7 +436,7 @@ multipart_signed_get_part (CamelMultipart *multipart, } camel_stream_reset (stream, NULL); mps->content = camel_mime_part_new (); - camel_data_wrapper_construct_from_stream ( + camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (mps->content), stream, NULL, NULL); g_object_unref (stream); return mps->content; @@ -453,7 +453,7 @@ multipart_signed_get_part (CamelMultipart *multipart, stream = camel_seekable_substream_new ((CamelSeekableStream *)dw->stream, mps->start2, mps->end2); camel_stream_reset (stream, NULL); mps->signature = camel_mime_part_new (); - camel_data_wrapper_construct_from_stream ( + camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (mps->signature), stream, NULL, NULL); g_object_unref (stream); @@ -532,9 +532,9 @@ camel_multipart_signed_class_init (CamelMultipartSignedClass *class) data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class); data_wrapper_class->set_mime_type_field = multipart_signed_set_mime_type_field; - data_wrapper_class->write_to_stream = multipart_signed_write_to_stream; - data_wrapper_class->decode_to_stream = multipart_signed_write_to_stream; - data_wrapper_class->construct_from_stream = multipart_signed_construct_from_stream; + data_wrapper_class->write_to_stream_sync = multipart_signed_write_to_stream_sync; + data_wrapper_class->decode_to_stream_sync = multipart_signed_write_to_stream_sync; + data_wrapper_class->construct_from_stream_sync = multipart_signed_construct_from_stream_sync; multipart_class = CAMEL_MULTIPART_CLASS (class); multipart_class->add_part = multipart_signed_add_part; diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index cae7ea1..5d76f8c 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -64,12 +64,30 @@ multipart_finalize (GObject *object) G_OBJECT_CLASS (camel_multipart_parent_class)->finalize (object); } +static gboolean +multipart_is_offline (CamelDataWrapper *data_wrapper) +{ + CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); + GList *node; + CamelDataWrapper *part; + + if (CAMEL_DATA_WRAPPER_CLASS (camel_multipart_parent_class)->is_offline (data_wrapper)) + return TRUE; + for (node = multipart->parts; node; node = node->next) { + part = node->data; + if (camel_data_wrapper_is_offline (part)) + return TRUE; + } + + return FALSE; +} + /* this is MIME specific, doesn't belong here really */ static gssize -multipart_write_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +multipart_write_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); const gchar *boundary; @@ -108,7 +126,7 @@ multipart_write_to_stream (CamelDataWrapper *data_wrapper, goto file_error; total += count; - count = camel_data_wrapper_write_to_stream ( + count = camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (node->data), stream, cancellable, error); if (count == -1) @@ -144,24 +162,6 @@ file_error: return -1; } -static gboolean -multipart_is_offline (CamelDataWrapper *data_wrapper) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); - GList *node; - CamelDataWrapper *part; - - if (CAMEL_DATA_WRAPPER_CLASS (camel_multipart_parent_class)->is_offline (data_wrapper)) - return TRUE; - for (node = multipart->parts; node; node = node->next) { - part = node->data; - if (camel_data_wrapper_is_offline (part)) - return TRUE; - } - - return FALSE; -} - static void multipart_add_part (CamelMultipart *multipart, CamelMimePart *part) @@ -312,7 +312,7 @@ multipart_construct_from_parser (CamelMultipart *multipart, while (camel_mime_parser_step (mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) { camel_mime_parser_unstep (mp); bodypart = camel_mime_part_new (); - camel_mime_part_construct_from_parser ( + camel_mime_part_construct_from_parser_sync ( bodypart, mp, NULL, NULL); camel_multipart_add_part (multipart, bodypart); g_object_unref (bodypart); @@ -341,9 +341,9 @@ camel_multipart_class_init (CamelMultipartClass *class) object_class->finalize = multipart_finalize; data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class); - data_wrapper_class->write_to_stream = multipart_write_to_stream; - data_wrapper_class->decode_to_stream = multipart_write_to_stream; data_wrapper_class->is_offline = multipart_is_offline; + data_wrapper_class->write_to_stream_sync = multipart_write_to_stream_sync; + data_wrapper_class->decode_to_stream_sync = multipart_write_to_stream_sync; class->add_part = multipart_add_part; class->add_part_at = multipart_add_part_at; diff --git a/camel/camel-offline-folder.c b/camel/camel-offline-folder.c index af31836..73338f6 100644 --- a/camel/camel-offline-folder.c +++ b/camel/camel-offline-folder.c @@ -73,13 +73,13 @@ offline_downsync_sync (CamelSession *session, CamelSessionThreadMsg *mm) camel_operation_progress (mm->cancellable, pc); /* FIXME Pass a GCancellable */ - camel_folder_sync_message ( + camel_folder_synchronize_message_sync ( m->folder, m->changes->uid_added->pdata[i], NULL, &mm->error); } } else { /* FIXME Pass a GCancellable */ - camel_offline_folder_downsync ( + camel_offline_folder_downsync_sync ( (CamelOfflineFolder *) m->folder, "(match-all)", NULL, &mm->error); } @@ -165,10 +165,10 @@ offline_folder_get_property (GObject *object, } static gboolean -offline_folder_downsync (CamelOfflineFolder *offline, - const gchar *expression, - GCancellable *cancellable, - GError **error) +offline_folder_downsync_sync (CamelOfflineFolder *offline, + const gchar *expression, + GCancellable *cancellable, + GError **error) { CamelFolder *folder = (CamelFolder *) offline; GPtrArray *uids, *uncached_uids = NULL; @@ -197,7 +197,7 @@ offline_folder_downsync (CamelOfflineFolder *offline, goto done; for (i = 0; i < uncached_uids->len; i++) { - camel_folder_sync_message ( + camel_folder_synchronize_message_sync ( folder, uncached_uids->pdata[i], cancellable, NULL); camel_operation_progress ( cancellable, i * 100 / uncached_uids->len); @@ -223,7 +223,7 @@ camel_offline_folder_class_init (CamelOfflineFolderClass *class) object_class->set_property = offline_folder_set_property; object_class->get_property = offline_folder_get_property; - class->downsync = offline_folder_downsync; + class->downsync_sync = offline_folder_downsync_sync; g_object_class_install_property ( object_class, @@ -280,7 +280,7 @@ camel_offline_folder_set_offline_sync (CamelOfflineFolder *offline_folder, } /** - * camel_offline_folder_downsync: + * camel_offline_folder_downsync_sync: * @offline: a #CamelOfflineFolder object * @expression: search expression describing which set of messages * to downsync (%NULL for all) @@ -293,10 +293,10 @@ camel_offline_folder_set_offline_sync (CamelOfflineFolder *offline_folder, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_offline_folder_downsync (CamelOfflineFolder *offline, - const gchar *expression, - GCancellable *cancellable, - GError **error) +camel_offline_folder_downsync_sync (CamelOfflineFolder *offline, + const gchar *expression, + GCancellable *cancellable, + GError **error) { CamelOfflineFolderClass *class; gboolean success; @@ -304,10 +304,11 @@ camel_offline_folder_downsync (CamelOfflineFolder *offline, g_return_val_if_fail (CAMEL_IS_OFFLINE_FOLDER (offline), FALSE); class = CAMEL_OFFLINE_FOLDER_GET_CLASS (offline); - g_return_val_if_fail (class->downsync != NULL, FALSE); + g_return_val_if_fail (class->downsync_sync != NULL, FALSE); - success = class->downsync (offline, expression, cancellable, error); - CAMEL_CHECK_GERROR (offline, downsync, success, error); + success = class->downsync_sync ( + offline, expression, cancellable, error); + CAMEL_CHECK_GERROR (offline, downsync_sync, success, error); return success; } diff --git a/camel/camel-offline-folder.h b/camel/camel-offline-folder.h index b8868db..d3ca48c 100644 --- a/camel/camel-offline-folder.h +++ b/camel/camel-offline-folder.h @@ -62,7 +62,7 @@ struct _CamelOfflineFolder { struct _CamelOfflineFolderClass { CamelFolderClass parent_class; - gboolean (*downsync) (CamelOfflineFolder *folder, + gboolean (*downsync_sync) (CamelOfflineFolder *folder, const gchar *expression, GCancellable *cancellable, GError **error); @@ -74,7 +74,8 @@ gboolean camel_offline_folder_get_offline_sync void camel_offline_folder_set_offline_sync (CamelOfflineFolder *offline, gboolean offline_sync); -gboolean camel_offline_folder_downsync (CamelOfflineFolder *offline, +gboolean camel_offline_folder_downsync_sync + (CamelOfflineFolder *offline, const gchar *expression, GCancellable *cancellable, GError **error); diff --git a/camel/camel-offline-store.c b/camel/camel-offline-store.c index 168657b..b4cb6b2 100644 --- a/camel/camel-offline-store.c +++ b/camel/camel-offline-store.c @@ -31,6 +31,14 @@ #include "camel-offline-store.h" #include "camel-session.h" +#define CAMEL_OFFLINE_STORE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), CAMEL_TYPE_OFFLINE_STORE, CamelOfflineStorePrivate)) + +struct _CamelOfflineStorePrivate { + gboolean online; +}; + G_DEFINE_TYPE (CamelOfflineStore, camel_offline_store, CAMEL_TYPE_STORE) static gboolean @@ -48,9 +56,7 @@ offline_store_construct (CamelService *service, if (!service_class->construct (service, session, provider, url, error)) return FALSE; - store->state = camel_session_get_online (session) ? - CAMEL_OFFLINE_STORE_NETWORK_AVAIL : - CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL; + store->priv->online = camel_session_get_online (session); return TRUE; } @@ -60,6 +66,8 @@ camel_offline_store_class_init (CamelOfflineStoreClass *class) { CamelServiceClass *service_class; + g_type_class_add_private (class, sizeof (CamelOfflineStorePrivate)); + service_class = CAMEL_SERVICE_CLASS (class); service_class->construct = offline_store_construct; } @@ -67,52 +75,54 @@ camel_offline_store_class_init (CamelOfflineStoreClass *class) static void camel_offline_store_init (CamelOfflineStore *store) { - store->state = CAMEL_OFFLINE_STORE_NETWORK_AVAIL; + store->priv = CAMEL_OFFLINE_STORE_GET_PRIVATE (store); + store->priv->online = TRUE; } /** - * camel_offline_store_get_network_state: + * camel_offline_store_get_online: * @store: a #CamelOfflineStore object * @error: return location for a #GError, or %NULL * - * Return the network state either #CAMEL_OFFLINE_STORE_NETWORK_AVAIL - * or #CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL. + * Returns %TRUE if @store is online. * * Since: 2.24 **/ -gint -camel_offline_store_get_network_state (CamelOfflineStore *store, - GError **error) +gboolean +camel_offline_store_get_online (CamelOfflineStore *store) { - return store->state; + g_return_val_if_fail (CAMEL_IS_OFFLINE_STORE (store), 0); + + return store->priv->online; } /** - * camel_offline_store_set_network_state: + * camel_offline_store_set_online_sync: * @store: a #CamelOfflineStore object - * @state: the network state + * @online: %TRUE for online, %FALSE for offline * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL * - * Set the network state to either #CAMEL_OFFLINE_STORE_NETWORK_AVAIL - * or #CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL. + * Sets the online/offline state of @store according to @online. **/ gboolean -camel_offline_store_set_network_state (CamelOfflineStore *store, - gint state, - GCancellable *cancellable, - GError **error) +camel_offline_store_set_online_sync (CamelOfflineStore *store, + gboolean online, + GCancellable *cancellable, + GError **error) { CamelService *service = CAMEL_SERVICE (store); gboolean network_available; - if (store->state == state) + g_return_val_if_fail (CAMEL_IS_OFFLINE_STORE (store), FALSE); + + if (store->priv->online == online) return TRUE; network_available = camel_session_get_network_available (service->session); - if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) { + if (store->priv->online) { /* network available -> network unavailable */ if (network_available) { if (((CamelStore *) store)->folders) { @@ -128,7 +138,7 @@ camel_offline_store_set_network_state (CamelOfflineStore *store, if (G_TYPE_CHECK_INSTANCE_TYPE (folder, CAMEL_TYPE_OFFLINE_FOLDER) && (sync || camel_offline_folder_get_offline_sync (CAMEL_OFFLINE_FOLDER (folder)))) { - camel_offline_folder_downsync ( + camel_offline_folder_downsync_sync ( (CamelOfflineFolder *) folder, NULL, cancellable, NULL); } @@ -139,44 +149,46 @@ camel_offline_store_set_network_state (CamelOfflineStore *store, g_ptr_array_free (folders, TRUE); } - camel_store_sync ( + camel_store_synchronize_sync ( CAMEL_STORE (store), FALSE, cancellable, NULL); } - if (!camel_service_disconnect (CAMEL_SERVICE (store), network_available, error)) + if (!camel_service_disconnect_sync ( + CAMEL_SERVICE (store), network_available, error)) return FALSE; } else { - store->state = state; + store->priv->online = online; /* network unavailable -> network available */ - if (!camel_service_connect (CAMEL_SERVICE (store), error)) { - store->state = CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL; + if (!camel_service_connect_sync (CAMEL_SERVICE (store), error)) { + store->priv->online = FALSE; return FALSE; } } - store->state = state; + store->priv->online = online; return TRUE; } /** - * camel_offline_store_prepare_for_offline: + * camel_offline_store_prepare_for_offline_sync: * * Since: 2.22 **/ gboolean -camel_offline_store_prepare_for_offline (CamelOfflineStore *store, - GCancellable *cancellable, - GError **error) +camel_offline_store_prepare_for_offline_sync (CamelOfflineStore *store, + GCancellable *cancellable, + GError **error) { - CamelService *service = CAMEL_SERVICE (store); - gboolean network_available; + CamelService *service; + + g_return_val_if_fail (CAMEL_IS_OFFLINE_STORE (store), FALSE); - network_available = camel_session_get_network_available (service->session); + service = CAMEL_SERVICE (store); - if (network_available) { - if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) { + if (camel_session_get_network_available (service->session)) { + if (store->priv->online) { if (((CamelStore *) store)->folders) { GPtrArray *folders; CamelFolder *folder; @@ -190,7 +202,7 @@ camel_offline_store_prepare_for_offline (CamelOfflineStore *store, if (G_TYPE_CHECK_INSTANCE_TYPE (folder, CAMEL_TYPE_OFFLINE_FOLDER) && (sync || camel_offline_folder_get_offline_sync (CAMEL_OFFLINE_FOLDER (folder)))) { - camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, cancellable, NULL); + camel_offline_folder_downsync_sync ((CamelOfflineFolder *) folder, NULL, cancellable, NULL); } g_object_unref (folder); } @@ -198,7 +210,7 @@ camel_offline_store_prepare_for_offline (CamelOfflineStore *store, } } - camel_store_sync ( + camel_store_synchronize_sync ( CAMEL_STORE (store), FALSE, cancellable, NULL); } diff --git a/camel/camel-offline-store.h b/camel/camel-offline-store.h index 5d39870..82f139f 100644 --- a/camel/camel-offline-store.h +++ b/camel/camel-offline-store.h @@ -52,37 +52,25 @@ G_BEGIN_DECLS typedef struct _CamelOfflineStore CamelOfflineStore; typedef struct _CamelOfflineStoreClass CamelOfflineStoreClass; - -enum { - CAMEL_OFFLINE_STORE_NETWORK_AVAIL, - CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL -}; +typedef struct _CamelOfflineStorePrivate CamelOfflineStorePrivate; struct _CamelOfflineStore { CamelStore parent; - - gint state; + CamelOfflineStorePrivate *priv; }; struct _CamelOfflineStoreClass { CamelStoreClass parent_class; - - gboolean (*set_network_state) (CamelOfflineStore *store, - gint state, - GCancellable *cancellable, - GError **error); }; GType camel_offline_store_get_type (void); -gboolean camel_offline_store_set_network_state +gboolean camel_offline_store_get_online (CamelOfflineStore *store); +gboolean camel_offline_store_set_online_sync (CamelOfflineStore *store, - gint state, + gboolean online, GCancellable *cancellable, GError **error); -gint camel_offline_store_get_network_state - (CamelOfflineStore *store, - GError **error); -gboolean camel_offline_store_prepare_for_offline +gboolean camel_offline_store_prepare_for_offline_sync (CamelOfflineStore *store, GCancellable *cancellable, GError **error); diff --git a/camel/camel-sasl-anonymous.c b/camel/camel-sasl-anonymous.c index 06bd930..b075671 100644 --- a/camel/camel-sasl-anonymous.c +++ b/camel/camel-sasl-anonymous.c @@ -54,10 +54,10 @@ sasl_anonymous_finalize (GObject *object) } static GByteArray * -sasl_anonymous_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_anonymous_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { CamelSaslAnonymous *sasl_anon = CAMEL_SASL_ANONYMOUS (sasl); CamelInternetAddress *cia; @@ -125,7 +125,7 @@ camel_sasl_anonymous_class_init (CamelSaslAnonymousClass *class) object_class->finalize = sasl_anonymous_finalize; sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_anonymous_challenge; + sasl_class->challenge_sync = sasl_anonymous_challenge_sync; } static void diff --git a/camel/camel-sasl-cram-md5.c b/camel/camel-sasl-cram-md5.c index ed087e9..3ce6237 100644 --- a/camel/camel-sasl-cram-md5.c +++ b/camel/camel-sasl-cram-md5.c @@ -58,10 +58,10 @@ G_DEFINE_TYPE (CamelSaslCramMd5, camel_sasl_cram_md5, CAMEL_TYPE_SASL) */ static GByteArray * -sasl_cram_md5_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_cram_md5_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { CamelService *service; GChecksum *checksum; @@ -140,7 +140,7 @@ camel_sasl_cram_md5_class_init (CamelSaslCramMd5Class *class) g_type_class_add_private (class, sizeof (CamelSaslCramMd5Private)); sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_cram_md5_challenge; + sasl_class->challenge_sync = sasl_cram_md5_challenge_sync; } static void diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c index a90a52f..cdea81a 100644 --- a/camel/camel-sasl-digest-md5.c +++ b/camel/camel-sasl-digest-md5.c @@ -787,10 +787,10 @@ sasl_digest_md5_finalize (GObject *object) } static GByteArray * -sasl_digest_md5_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_digest_md5_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { CamelSaslDigestMd5 *sasl_digest = CAMEL_SASL_DIGEST_MD5 (sasl); struct _CamelSaslDigestMd5Private *priv = sasl_digest->priv; @@ -940,7 +940,7 @@ camel_sasl_digest_md5_class_init (CamelSaslDigestMd5Class *class) object_class->finalize = sasl_digest_md5_finalize; sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_digest_md5_challenge; + sasl_class->challenge_sync = sasl_digest_md5_challenge_sync; } static void diff --git a/camel/camel-sasl-gssapi.c b/camel/camel-sasl-gssapi.c index 8edaf00..5932ab7 100644 --- a/camel/camel-sasl-gssapi.c +++ b/camel/camel-sasl-gssapi.c @@ -241,10 +241,10 @@ send_dbus_message (gchar *name) /* END DBus stuff */ static GByteArray * -sasl_gssapi_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_gssapi_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { CamelSaslGssapiPrivate *priv; CamelService *service; @@ -425,7 +425,7 @@ camel_sasl_gssapi_class_init (CamelSaslGssapiClass *class) object_class->finalize = sasl_gssapi_finalize; sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_gssapi_challenge; + sasl_class->challenge_sync = sasl_gssapi_challenge_sync; } static void diff --git a/camel/camel-sasl-login.c b/camel/camel-sasl-login.c index 66554f8..8615ae3 100644 --- a/camel/camel-sasl-login.c +++ b/camel/camel-sasl-login.c @@ -57,10 +57,10 @@ struct _CamelSaslLoginPrivate { G_DEFINE_TYPE (CamelSaslLogin, camel_sasl_login, CAMEL_TYPE_SASL) static GByteArray * -sasl_login_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_login_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { CamelSaslLoginPrivate *priv; GByteArray *buf = NULL; @@ -108,7 +108,7 @@ camel_sasl_login_class_init (CamelSaslLoginClass *class) g_type_class_add_private (class, sizeof (CamelSaslLoginPrivate)); sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_login_challenge; + sasl_class->challenge_sync = sasl_login_challenge_sync; } static void diff --git a/camel/camel-sasl-ntlm.c b/camel/camel-sasl-ntlm.c index b59f551..6d00e6d 100644 --- a/camel/camel-sasl-ntlm.c +++ b/camel/camel-sasl-ntlm.c @@ -659,10 +659,10 @@ deskey (DES_KS k, guchar *key, gint decrypt) } static GByteArray * -sasl_ntlm_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_ntlm_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { CamelService *service; GByteArray *ret; @@ -730,7 +730,7 @@ camel_sasl_ntlm_class_init (CamelSaslNTLMClass *class) g_type_class_add_private (class, sizeof (CamelSaslNTLMPrivate)); sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_ntlm_challenge; + sasl_class->challenge_sync = sasl_ntlm_challenge_sync; } static void diff --git a/camel/camel-sasl-plain.c b/camel/camel-sasl-plain.c index 3d67209..39b6571 100644 --- a/camel/camel-sasl-plain.c +++ b/camel/camel-sasl-plain.c @@ -52,10 +52,10 @@ CamelServiceAuthType camel_sasl_plain_authtype = { G_DEFINE_TYPE (CamelSaslPlain, camel_sasl_plain, CAMEL_TYPE_SASL) static GByteArray * -sasl_plain_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_plain_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { GByteArray *buf = NULL; CamelService *service; @@ -85,7 +85,7 @@ camel_sasl_plain_class_init (CamelSaslPlainClass *class) g_type_class_add_private (class, sizeof (CamelSaslPlainPrivate)); sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_plain_challenge; + sasl_class->challenge_sync = sasl_plain_challenge_sync; } static void diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c index d91f366..8bfc5b0 100644 --- a/camel/camel-sasl-popb4smtp.c +++ b/camel/camel-sasl-popb4smtp.c @@ -64,10 +64,10 @@ static GStaticMutex lock = G_STATIC_MUTEX_INIT; G_DEFINE_TYPE (CamelSaslPOPB4SMTP, camel_sasl_popb4smtp, CAMEL_TYPE_SASL) static GByteArray * -sasl_popb4smtp_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) +sasl_popb4smtp_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) { gchar *popuri; CamelService *service; @@ -144,7 +144,7 @@ camel_sasl_popb4smtp_class_init (CamelSaslPOPB4SMTPClass *class) g_type_class_add_private (class, sizeof (CamelSaslPOPB4SMTPPrivate)); sasl_class = CAMEL_SASL_CLASS (class); - sasl_class->challenge = sasl_popb4smtp_challenge; + sasl_class->challenge_sync = sasl_popb4smtp_challenge_sync; poplast = g_hash_table_new (g_str_hash, g_str_equal); } diff --git a/camel/camel-sasl.c b/camel/camel-sasl.c index fe89e99..4966602 100644 --- a/camel/camel-sasl.c +++ b/camel/camel-sasl.c @@ -255,92 +255,6 @@ camel_sasl_init (CamelSasl *sasl) } /** - * camel_sasl_challenge: - * @sasl: a #CamelSasl object - * @token: a token, or %NULL - * @cancellable: optional #GCancellable object, or %NULL - * @error: return location for a #GError, or %NULL - * - * If @token is %NULL, generate the initial SASL message to send to - * the server. (This will be %NULL if the client doesn't initiate the - * exchange.) Otherwise, @token is a challenge from the server, and - * the return value is the response. - * - * Returns: the SASL response or %NULL. If an error occurred, @error will - * also be set. - **/ -GByteArray * -camel_sasl_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error) -{ - CamelSaslClass *class; - GByteArray *response; - - g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL); - - class = CAMEL_SASL_GET_CLASS (sasl); - g_return_val_if_fail (class->challenge != NULL, NULL); - - response = class->challenge (sasl, token, cancellable, error); - if (token) - CAMEL_CHECK_GERROR (sasl, challenge, response != NULL, error); - - return response; -} - -/** - * camel_sasl_challenge_base64: - * @sasl: a #CamelSasl object - * @token: a base64-encoded token - * @cancellable: optional #GCancellable object, or %NULL - * @error: return location for a #GError, or %NULL - * - * As with #camel_sasl_challenge, but the challenge @token and the - * response are both base64-encoded. - * - * Returns: the base64 encoded challenge string - **/ -gchar * -camel_sasl_challenge_base64 (CamelSasl *sasl, - const gchar *token, - GCancellable *cancellable, - GError **error) -{ - GByteArray *token_binary, *ret_binary; - gchar *ret; - - g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL); - - if (token && *token) { - guchar *data; - gsize length = 0; - - data = g_base64_decode (token, &length); - token_binary = g_byte_array_new (); - g_byte_array_append (token_binary, data, length); - g_free (data); - } else - token_binary = NULL; - - ret_binary = camel_sasl_challenge ( - sasl, token_binary, cancellable, error); - if (token_binary) - g_byte_array_free (token_binary, TRUE); - if (!ret_binary) - return NULL; - - if (ret_binary->len > 0) - ret = g_base64_encode (ret_binary->data, ret_binary->len); - else - ret = g_strdup (""); - g_byte_array_free (ret_binary, TRUE); - - return ret; -} - -/** * camel_sasl_new: * @service_name: the SASL service name * @mechanism: the SASL mechanism @@ -465,6 +379,93 @@ camel_sasl_get_service_name (CamelSasl *sasl) } /** + * camel_sasl_challenge_sync: + * @sasl: a #CamelSasl object + * @token: a token, or %NULL + * @cancellable: optional #GCancellable object, or %NULL + * @error: return location for a #GError, or %NULL + * + * If @token is %NULL, generate the initial SASL message to send to + * the server. (This will be %NULL if the client doesn't initiate the + * exchange.) Otherwise, @token is a challenge from the server, and + * the return value is the response. + * + * Returns: the SASL response or %NULL. If an error occurred, @error will + * also be set. + **/ +GByteArray * +camel_sasl_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error) +{ + CamelSaslClass *class; + GByteArray *response; + + g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL); + + class = CAMEL_SASL_GET_CLASS (sasl); + g_return_val_if_fail (class->challenge_sync != NULL, NULL); + + response = class->challenge_sync (sasl, token, cancellable, error); + if (token != NULL) + CAMEL_CHECK_GERROR ( + sasl, challenge_sync, response != NULL, error); + + return response; +} + +/** + * camel_sasl_challenge_base64_sync: + * @sasl: a #CamelSasl object + * @token: a base64-encoded token + * @cancellable: optional #GCancellable object, or %NULL + * @error: return location for a #GError, or %NULL + * + * As with #camel_sasl_challenge, but the challenge @token and the + * response are both base64-encoded. + * + * Returns: the base64 encoded challenge string + **/ +gchar * +camel_sasl_challenge_base64_sync (CamelSasl *sasl, + const gchar *token, + GCancellable *cancellable, + GError **error) +{ + GByteArray *token_binary, *ret_binary; + gchar *ret; + + g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL); + + if (token && *token) { + guchar *data; + gsize length = 0; + + data = g_base64_decode (token, &length); + token_binary = g_byte_array_new (); + g_byte_array_append (token_binary, data, length); + g_free (data); + } else + token_binary = NULL; + + ret_binary = camel_sasl_challenge_sync ( + sasl, token_binary, cancellable, error); + if (token_binary) + g_byte_array_free (token_binary, TRUE); + if (!ret_binary) + return NULL; + + if (ret_binary->len > 0) + ret = g_base64_encode (ret_binary->data, ret_binary->len); + else + ret = g_strdup (""); + g_byte_array_free (ret_binary, TRUE); + + return ret; +} + +/** * camel_sasl_authtype_list: * @include_plain: whether or not to include the PLAIN mechanism * diff --git a/camel/camel-sasl.h b/camel/camel-sasl.h index 01ff9d6..57dc1c8 100644 --- a/camel/camel-sasl.h +++ b/camel/camel-sasl.h @@ -63,21 +63,13 @@ struct _CamelSasl { struct _CamelSaslClass { CamelObjectClass parent_class; - GByteArray * (*challenge) (CamelSasl *sasl, + GByteArray * (*challenge_sync) (CamelSasl *sasl, GByteArray *token, GCancellable *cancellable, GError **error); }; GType camel_sasl_get_type (void); -GByteArray * camel_sasl_challenge (CamelSasl *sasl, - GByteArray *token, - GCancellable *cancellable, - GError **error); -gchar * camel_sasl_challenge_base64 (CamelSasl *sasl, - const gchar *token, - GCancellable *cancellable, - GError **error); CamelSasl * camel_sasl_new (const gchar *service_name, const gchar *mechanism, CamelService *service); @@ -87,6 +79,15 @@ void camel_sasl_set_authenticated (CamelSasl *sasl, const gchar * camel_sasl_get_mechanism (CamelSasl *sasl); CamelService * camel_sasl_get_service (CamelSasl *sasl); const gchar * camel_sasl_get_service_name (CamelSasl *sasl); +GByteArray * camel_sasl_challenge_sync (CamelSasl *sasl, + GByteArray *token, + GCancellable *cancellable, + GError **error); +gchar * camel_sasl_challenge_base64_sync + (CamelSasl *sasl, + const gchar *token, + GCancellable *cancellable, + GError **error); GList * camel_sasl_authtype_list (gboolean include_plain); CamelServiceAuthType * diff --git a/camel/camel-search-private.c b/camel/camel-search-private.c index 3058d35..32941d3 100644 --- a/camel/camel-search-private.c +++ b/camel/camel-search-private.c @@ -479,7 +479,8 @@ camel_search_message_body_contains (CamelDataWrapper *object, regex_t *pattern) byte_array = g_byte_array_new (); stream = camel_stream_mem_new_with_byte_array (byte_array); - camel_data_wrapper_write_to_stream (containee, stream, NULL, NULL); + camel_data_wrapper_write_to_stream_sync ( + containee, stream, NULL, NULL); camel_stream_write (stream, "", 1, NULL, NULL); truth = regexec (pattern, (gchar *) byte_array->data, 0, NULL, 0) == 0; g_object_unref (stream); diff --git a/camel/camel-service.c b/camel/camel-service.c index c385b04..48478df 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -59,7 +59,7 @@ service_finalize (GObject *object) CamelService *service = CAMEL_SERVICE (object); if (service->status == CAMEL_SERVICE_CONNECTED) - CAMEL_SERVICE_GET_CLASS (service)->disconnect ( + CAMEL_SERVICE_GET_CLASS (service)->disconnect_sync ( service, TRUE, NULL, NULL); if (service->url) @@ -117,41 +117,6 @@ fail: return FALSE; } -static gboolean -service_connect (CamelService *service, - GCancellable *cancellable, - GError **error) -{ - /* Things like the CamelMboxStore can validly - * not define a connect function. */ - return TRUE; -} - -static gboolean -service_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) -{ - /* We let people get away with not having a disconnect - * function -- CamelMboxStore, for example. */ - return TRUE; -} - -static void -service_cancel_connect (CamelService *service) -{ - g_cancellable_cancel (service->connect_op); -} - -static GList * -service_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) -{ - return NULL; -} - static gchar * service_get_name (CamelService *service, gboolean brief) @@ -207,6 +172,41 @@ service_get_path (CamelService *service) } static void +service_cancel_connect (CamelService *service) +{ + g_cancellable_cancel (service->connect_op); +} + +static gboolean +service_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) +{ + /* Things like the CamelMboxStore can validly + * not define a connect function. */ + return TRUE; +} + +static gboolean +service_disconnect_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) +{ + /* We let people get away with not having a disconnect + * function -- CamelMboxStore, for example. */ + return TRUE; +} + +static GList * +service_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) +{ + return NULL; +} + +static void camel_service_class_init (CamelServiceClass *class) { GObjectClass *object_class; @@ -217,12 +217,12 @@ camel_service_class_init (CamelServiceClass *class) object_class->finalize = service_finalize; class->construct = service_construct; - class->connect = service_connect; - class->disconnect = service_disconnect; - class->cancel_connect = service_cancel_connect; - class->query_auth_types = service_query_auth_types; class->get_name = service_get_name; class->get_path = service_get_path; + class->cancel_connect = service_cancel_connect; + class->connect_sync = service_connect_sync; + class->disconnect_sync = service_disconnect_sync; + class->query_auth_types_sync = service_query_auth_types_sync; } static void @@ -282,109 +282,6 @@ camel_service_construct (CamelService *service, } /** - * camel_service_connect: - * @service: a #CamelService object - * @error: return location for a #GError, or %NULL - * - * Connect to the service using the parameters it was initialized - * with. - * - * Returns: %TRUE if the connection is made or %FALSE otherwise - **/ -gboolean -camel_service_connect (CamelService *service, - GError **error) -{ - CamelServiceClass *class; - gboolean ret = FALSE; - - g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); - g_return_val_if_fail (service->session != NULL, FALSE); - g_return_val_if_fail (service->url != NULL, FALSE); - - class = CAMEL_SERVICE_GET_CLASS (service); - g_return_val_if_fail (class->connect != NULL, FALSE); - - camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - - if (service->status == CAMEL_SERVICE_CONNECTED) { - camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - return TRUE; - } - - /* Register a separate operation for connecting, so that - * the offline code can cancel it. */ - camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - service->connect_op = (GCancellable *) camel_operation_new (); - camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - - service->status = CAMEL_SERVICE_CONNECTING; - ret = class->connect (service, service->connect_op, error); - CAMEL_CHECK_GERROR (service, connect, ret, error); - service->status = ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED; - - camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - g_object_unref (service->connect_op); - service->connect_op = NULL; - camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - - camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - - return ret; -} - -/** - * camel_service_disconnect: - * @service: a #CamelService object - * @clean: whether or not to try to disconnect cleanly - * @error: return location for a #GError, or %NULL - * - * Disconnect from the service. If @clean is %FALSE, it should not - * try to do any synchronizing or other cleanup of the connection. - * - * Returns: %TRUE if the disconnect was successful or %FALSE otherwise - **/ -gboolean -camel_service_disconnect (CamelService *service, - gboolean clean, - GError **error) -{ - CamelServiceClass *class; - gboolean res = TRUE; - - g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); - - class = CAMEL_SERVICE_GET_CLASS (service); - g_return_val_if_fail (class->disconnect != NULL, FALSE); - - camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - - if (service->status != CAMEL_SERVICE_DISCONNECTED - && service->status != CAMEL_SERVICE_DISCONNECTING) { - camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - service->connect_op = (GCancellable *) camel_operation_new (); - camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - - service->status = CAMEL_SERVICE_DISCONNECTING; - res = class->disconnect ( - service, clean, service->connect_op, error); - CAMEL_CHECK_GERROR (service, disconnect, res, error); - service->status = CAMEL_SERVICE_DISCONNECTED; - - camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - g_object_unref (service->connect_op); - service->connect_op = NULL; - camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); - } - - camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - - service->status = CAMEL_SERVICE_DISCONNECTED; - - return res; -} - -/** * camel_service_cancel_connect: * @service: a #CamelService object * @@ -409,24 +306,6 @@ camel_service_cancel_connect (CamelService *service) } /** - * camel_service_get_url: - * @service: a #CamelService object - * - * Gets the URL representing @service. The returned URL must be - * freed when it is no longer needed. For security reasons, this - * routine does not return the password. - * - * Returns: the URL representing @service - **/ -gchar * -camel_service_get_url (CamelService *service) -{ - g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL); - - return camel_url_to_string (service->url, CAMEL_URL_HIDE_PASSWORD); -} - -/** * camel_service_get_name: * @service: a #CamelService object * @brief: whether or not to use a briefer form @@ -512,7 +391,128 @@ camel_service_get_provider (CamelService *service) } /** - * camel_service_query_auth_types: + * camel_service_get_url: + * @service: a #CamelService object + * + * Gets the URL representing @service. The returned URL must be + * freed when it is no longer needed. For security reasons, this + * routine does not return the password. + * + * Returns: the URL representing @service + **/ +gchar * +camel_service_get_url (CamelService *service) +{ + g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL); + + return camel_url_to_string (service->url, CAMEL_URL_HIDE_PASSWORD); +} + +/** + * camel_service_connect_sync: + * @service: a #CamelService object + * @error: return location for a #GError, or %NULL + * + * Connect to the service using the parameters it was initialized + * with. + * + * Returns: %TRUE if the connection is made or %FALSE otherwise + **/ +gboolean +camel_service_connect_sync (CamelService *service, + GError **error) +{ + CamelServiceClass *class; + gboolean ret = FALSE; + + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + g_return_val_if_fail (service->session != NULL, FALSE); + g_return_val_if_fail (service->url != NULL, FALSE); + + class = CAMEL_SERVICE_GET_CLASS (service); + g_return_val_if_fail (class->connect_sync != NULL, FALSE); + + camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); + + if (service->status == CAMEL_SERVICE_CONNECTED) { + camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); + return TRUE; + } + + /* Register a separate operation for connecting, so that + * the offline code can cancel it. */ + camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + service->connect_op = (GCancellable *) camel_operation_new (); + camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + + service->status = CAMEL_SERVICE_CONNECTING; + ret = class->connect_sync (service, service->connect_op, error); + CAMEL_CHECK_GERROR (service, connect_sync, ret, error); + service->status = ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED; + + camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + g_object_unref (service->connect_op); + service->connect_op = NULL; + camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + + camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); + + return ret; +} + +/** + * camel_service_disconnect_sync: + * @service: a #CamelService object + * @clean: whether or not to try to disconnect cleanly + * @error: return location for a #GError, or %NULL + * + * Disconnect from the service. If @clean is %FALSE, it should not + * try to do any synchronizing or other cleanup of the connection. + * + * Returns: %TRUE if the disconnect was successful or %FALSE otherwise + **/ +gboolean +camel_service_disconnect_sync (CamelService *service, + gboolean clean, + GError **error) +{ + CamelServiceClass *class; + gboolean res = TRUE; + + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + + class = CAMEL_SERVICE_GET_CLASS (service); + g_return_val_if_fail (class->disconnect_sync != NULL, FALSE); + + camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); + + if (service->status != CAMEL_SERVICE_DISCONNECTED + && service->status != CAMEL_SERVICE_DISCONNECTING) { + camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + service->connect_op = (GCancellable *) camel_operation_new (); + camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + + service->status = CAMEL_SERVICE_DISCONNECTING; + res = class->disconnect_sync ( + service, clean, service->connect_op, error); + CAMEL_CHECK_GERROR (service, disconnect_sync, res, error); + service->status = CAMEL_SERVICE_DISCONNECTED; + + camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + g_object_unref (service->connect_op); + service->connect_op = NULL; + camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK); + } + + camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); + + service->status = CAMEL_SERVICE_DISCONNECTED; + + return res; +} + +/** + * camel_service_query_auth_types_sync: * @service: a #CamelService object * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL @@ -525,9 +525,9 @@ camel_service_get_provider (CamelService *service) * must free the list with #g_list_free when it is done with it. **/ GList * -camel_service_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) +camel_service_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelServiceClass *class; GList *ret; @@ -535,12 +535,12 @@ camel_service_query_auth_types (CamelService *service, g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL); class = CAMEL_SERVICE_GET_CLASS (service); - g_return_val_if_fail (class->query_auth_types != NULL, NULL); + g_return_val_if_fail (class->query_auth_types_sync != NULL, NULL); /* Note that we get the connect lock here, which means the * callee must not call the connect functions itself. */ camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - ret = class->query_auth_types (service, cancellable, error); + ret = class->query_auth_types_sync (service, cancellable, error); camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); return ret; diff --git a/camel/camel-service.h b/camel/camel-service.h index c500bed..7eb673d 100644 --- a/camel/camel-service.h +++ b/camel/camel-service.h @@ -118,20 +118,22 @@ struct _CamelServiceClass { CamelProvider *provider, CamelURL *url, GError **error); - gboolean (*connect) (CamelService *service, + gchar * (*get_name) (CamelService *service, + gboolean brief); + gchar * (*get_path) (CamelService *service); + void (*cancel_connect) (CamelService *service); + + gboolean (*connect_sync) (CamelService *service, GCancellable *cancellable, GError **error); - gboolean (*disconnect) (CamelService *service, + gboolean (*disconnect_sync) (CamelService *service, gboolean clean, GCancellable *cancellable, GError **error); - void (*cancel_connect) (CamelService *service); - GList * (*query_auth_types) (CamelService *service, + GList * (*query_auth_types_sync) + (CamelService *service, GCancellable *cancellable, GError **error); - gchar * (*get_name) (CamelService *service, - gboolean brief); - gchar * (*get_path) (CamelService *service); }; /* query_auth_types returns a GList of these */ @@ -150,20 +152,21 @@ gboolean camel_service_construct (CamelService *service, CamelProvider *provider, CamelURL *url, GError **error); -gboolean camel_service_connect (CamelService *service, - GError **error); -gboolean camel_service_disconnect (CamelService *service, - gboolean clean, - GError **error); -void camel_service_cancel_connect (CamelService *service); -gchar * camel_service_get_url (CamelService *service); gchar * camel_service_get_name (CamelService *service, gboolean brief); gchar * camel_service_get_path (CamelService *service); +CamelProvider * camel_service_get_provider (CamelService *service); struct _CamelSession * camel_service_get_session (CamelService *service); -CamelProvider * camel_service_get_provider (CamelService *service); -GList * camel_service_query_auth_types (CamelService *service, +gchar * camel_service_get_url (CamelService *service); +void camel_service_cancel_connect (CamelService *service); +gboolean camel_service_connect_sync (CamelService *service, + GError **error); +gboolean camel_service_disconnect_sync (CamelService *service, + gboolean clean, + GError **error); +GList * camel_service_query_auth_types_sync + (CamelService *service, GCancellable *cancellable, GError **error); void camel_service_lock (CamelService *service, diff --git a/camel/camel-session.c b/camel/camel-session.c index abf297d..9d43d0d 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -522,8 +522,9 @@ camel_session_get_service_connected (CamelSession *session, if (svc == NULL) return NULL; + /* FIXME This blocks. Need to take a GCancellable. */ if (svc->status != CAMEL_SERVICE_CONNECTED) { - if (!camel_service_connect (svc, error)) { + if (!camel_service_connect_sync (svc, error)) { g_object_unref (svc); return NULL; } diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c index 98b0466..58e81d2 100644 --- a/camel/camel-smime-context.c +++ b/camel/camel-smime-context.c @@ -760,13 +760,13 @@ get_hash_from_oid (SECOidTag oidTag) } static gint -smime_context_sign (CamelCipherContext *context, - const gchar *userid, - CamelCipherHash hash, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +smime_context_sign_sync (CamelCipherContext *context, + const gchar *userid, + CamelCipherHash hash, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; gint res = -1; @@ -850,7 +850,8 @@ smime_context_sign (CamelCipherContext *context, dw = camel_data_wrapper_new (); camel_stream_reset (ostream, NULL); - camel_data_wrapper_construct_from_stream (dw, ostream, cancellable, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, ostream, cancellable, NULL); dw->encoding = CAMEL_TRANSFER_ENCODING_BINARY; if (((CamelSMIMEContext *)context)->priv->sign_mode == CAMEL_SMIME_SIGN_CLEARSIGN) { @@ -907,10 +908,10 @@ fail: } static CamelCipherValidity * -smime_context_verify (CamelCipherContext *context, - CamelMimePart *ipart, - GCancellable *cancellable, - GError **error) +smime_context_verify_sync (CamelCipherContext *context, + CamelMimePart *ipart, + GCancellable *cancellable, + GError **error) { CamelCipherContextClass *class; NSSCMSDecoderContext *dec; @@ -976,7 +977,7 @@ smime_context_verify (CamelCipherContext *context, NULL, NULL, /* password callback */ NULL, NULL); /* decrypt key callback */ - camel_data_wrapper_decode_to_stream ( + camel_data_wrapper_decode_to_stream_sync ( camel_medium_get_content ( CAMEL_MEDIUM (sigpart)), mem, cancellable, NULL); (void)NSS_CMSDecoder_Update (dec, (gchar *) buffer->data, buffer->len); @@ -998,13 +999,13 @@ fail: } static gint -smime_context_encrypt (CamelCipherContext *context, - const gchar *userid, - GPtrArray *recipients, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +smime_context_encrypt_sync (CamelCipherContext *context, + const gchar *userid, + GPtrArray *recipients, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { CamelSMIMEContextPrivate *p = ((CamelSMIMEContext *)context)->priv; /*NSSCMSRecipientInfo **recipient_infos;*/ @@ -1144,7 +1145,8 @@ smime_context_encrypt (CamelCipherContext *context, PORT_FreeArena (poolp, PR_FALSE); dw = camel_data_wrapper_new (); - camel_data_wrapper_construct_from_stream (dw, ostream, NULL, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, ostream, NULL, NULL); g_object_unref (ostream); dw->encoding = CAMEL_TRANSFER_ENCODING_BINARY; @@ -1183,11 +1185,11 @@ fail: } static CamelCipherValidity * -smime_context_decrypt (CamelCipherContext *context, - CamelMimePart *ipart, - CamelMimePart *opart, - GCancellable *cancellable, - GError **error) +smime_context_decrypt_sync (CamelCipherContext *context, + CamelMimePart *ipart, + CamelMimePart *opart, + GCancellable *cancellable, + GError **error) { NSSCMSDecoderContext *dec; NSSCMSMessage *cmsg; @@ -1205,7 +1207,7 @@ smime_context_decrypt (CamelCipherContext *context, /* FIXME: stream this to the decoder incrementally */ buffer = g_byte_array_new (); istream = camel_stream_mem_new_with_byte_array (buffer); - camel_data_wrapper_decode_to_stream ( + camel_data_wrapper_decode_to_stream_sync ( camel_medium_get_content (CAMEL_MEDIUM (ipart)), istream, NULL, NULL); camel_stream_reset (istream, NULL); @@ -1238,7 +1240,7 @@ smime_context_decrypt (CamelCipherContext *context, #endif camel_stream_reset (ostream, NULL); - camel_data_wrapper_construct_from_stream ( + camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (opart), ostream, NULL, NULL); if (NSS_CMSMessage_IsSigned (cmsg)) { @@ -1270,10 +1272,10 @@ camel_smime_context_class_init (CamelSMIMEContextClass *class) cipher_context_class->key_protocol = "application/x-pkcs7-signature"; cipher_context_class->hash_to_id = smime_context_hash_to_id; cipher_context_class->id_to_hash = smime_context_id_to_hash; - cipher_context_class->sign = smime_context_sign; - cipher_context_class->verify = smime_context_verify; - cipher_context_class->encrypt = smime_context_encrypt; - cipher_context_class->decrypt = smime_context_decrypt; + cipher_context_class->sign_sync = smime_context_sign_sync; + cipher_context_class->verify_sync = smime_context_verify_sync; + cipher_context_class->encrypt_sync = smime_context_encrypt_sync; + cipher_context_class->decrypt_sync = smime_context_decrypt_sync; } static void @@ -1350,7 +1352,7 @@ camel_smime_context_describe_part (CamelSMIMEContext *context, CamelMimePart *pa /* FIXME: stream this to the decoder incrementally */ buffer = g_byte_array_new (); istream = camel_stream_mem_new_with_byte_array (buffer); - camel_data_wrapper_decode_to_stream ( + camel_data_wrapper_decode_to_stream_sync ( camel_medium_get_content ((CamelMedium *)part), istream, NULL, NULL); camel_stream_reset (istream, NULL); diff --git a/camel/camel-store.c b/camel/camel-store.c index dfd598e..fa4997f 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -212,43 +212,51 @@ store_construct (CamelService *service, return TRUE; } +static gboolean +store_can_refresh_folder (CamelStore *store, + CamelFolderInfo *info, + GError **error) +{ + return ((info->flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX); +} + static CamelFolder * -store_get_inbox (CamelStore *store, - GCancellable *cancellable, - GError **error) +store_get_inbox_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; CamelFolder *folder; /* Assume the inbox's name is "inbox" and open with default flags. */ class = CAMEL_STORE_GET_CLASS (store); - folder = class->get_folder (store, "inbox", 0, cancellable, error); - CAMEL_CHECK_GERROR (store, get_folder, folder != NULL, error); + folder = class->get_folder_sync (store, "inbox", 0, cancellable, error); + CAMEL_CHECK_GERROR (store, get_folder_sync, folder != NULL, error); return folder; } static CamelFolder * -store_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) +store_get_junk_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { - return store_get_special (store, CAMEL_VTRASH_FOLDER_TRASH); + return store_get_special (store, CAMEL_VTRASH_FOLDER_JUNK); } static CamelFolder * -store_get_junk (CamelStore *store, - GCancellable *cancellable, - GError **error) +store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { - return store_get_special (store, CAMEL_VTRASH_FOLDER_JUNK); + return store_get_special (store, CAMEL_VTRASH_FOLDER_TRASH); } static gboolean -store_sync (CamelStore *store, - gint expunge, - GCancellable *cancellable, - GError **error) +store_synchronize_sync (CamelStore *store, + gboolean expunge, + GCancellable *cancellable, + GError **error) { GPtrArray *folders; CamelFolder *folder; @@ -267,7 +275,7 @@ store_sync (CamelStore *store, folder = folders->pdata[i]; if (!CAMEL_IS_VEE_FOLDER (folder) && local_error == NULL) { - camel_folder_sync ( + camel_folder_synchronize_sync ( folder, expunge, cancellable, &local_error); ignore_no_such_table_exception (&local_error); } else if (CAMEL_IS_VEE_FOLDER (folder)) @@ -286,21 +294,13 @@ store_sync (CamelStore *store, } static gboolean -store_noop (CamelStore *store, - GCancellable *cancellable, - GError **error) +store_noop_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { return TRUE; } -static gboolean -store_can_refresh_folder (CamelStore *store, - CamelFolderInfo *info, - GError **error) -{ - return ((info->flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX); -} - static void camel_store_class_init (CamelStoreClass *class) { @@ -318,12 +318,12 @@ camel_store_class_init (CamelStoreClass *class) class->hash_folder_name = g_str_hash; class->compare_folder_name = g_str_equal; - class->get_inbox = store_get_inbox; - class->get_trash = store_get_trash; - class->get_junk = store_get_junk; - class->sync = store_sync; - class->noop = store_noop; class->can_refresh_folder = store_can_refresh_folder; + class->get_inbox_folder_sync = store_get_inbox_folder_sync; + class->get_junk_folder_sync = store_get_junk_folder_sync; + class->get_trash_folder_sync = store_get_trash_folder_sync; + class->synchronize_sync = store_synchronize_sync; + class->noop_sync = store_noop_sync; signals[FOLDER_CREATED] = g_signal_new ( "folder-created", @@ -413,7 +413,7 @@ camel_store_error_quark (void) } /** - * camel_store_get_folder: + * camel_store_get_folder_sync: * @store: a #CamelStore object * @folder_name: name of the folder to get * @flags: folder flags (create, save body index, etc) @@ -425,11 +425,11 @@ camel_store_error_quark (void) * Returns: the folder corresponding to the path @folder_name or %NULL. **/ CamelFolder * -camel_store_get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) +camel_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; CamelFolder *folder = NULL; @@ -460,29 +460,29 @@ camel_store_get_folder (CamelStore *store, if (!folder) { if (flags & CAMEL_STORE_IS_MIGRATING) { - if ((store->flags & CAMEL_STORE_VTRASH) && strcmp (folder_name, CAMEL_VTRASH_NAME) == 0) { - if (store->folders) - camel_object_bag_abort (store->folders, folder_name); - return NULL; - } + if ((store->flags & CAMEL_STORE_VTRASH) && strcmp (folder_name, CAMEL_VTRASH_NAME) == 0) { + if (store->folders) + camel_object_bag_abort (store->folders, folder_name); + return NULL; + } - if ((store->flags & CAMEL_STORE_VJUNK) && strcmp (folder_name, CAMEL_VJUNK_NAME) == 0) { - if (store->folders) - camel_object_bag_abort (store->folders, folder_name); - return NULL; - } + if ((store->flags & CAMEL_STORE_VJUNK) && strcmp (folder_name, CAMEL_VJUNK_NAME) == 0) { + if (store->folders) + camel_object_bag_abort (store->folders, folder_name); + return NULL; + } } if ((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0) { - folder = class->get_trash (store, cancellable, error); - CAMEL_CHECK_GERROR (store, get_trash, folder != NULL, error); + folder = class->get_trash_folder_sync (store, cancellable, error); + CAMEL_CHECK_GERROR (store, get_trash_folder_sync, folder != NULL, error); } else if ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0) { - folder = class->get_junk (store, cancellable, error); - CAMEL_CHECK_GERROR (store, get_junk, folder != NULL, error); + folder = class->get_junk_folder_sync (store, cancellable, error); + CAMEL_CHECK_GERROR (store, get_junk_folder_sync, folder != NULL, error); } else { - folder = class->get_folder ( + folder = class->get_folder_sync ( store, folder_name, flags, cancellable, error); - CAMEL_CHECK_GERROR (store, get_folder, folder != NULL, error); + CAMEL_CHECK_GERROR (store, get_folder_sync, folder != NULL, error); if (folder) { CamelVeeFolder *vfolder; @@ -516,7 +516,7 @@ camel_store_get_folder (CamelStore *store, } /** - * camel_store_create_folder: + * camel_store_create_folder_sync: * @store: a #CamelStore object * @parent_name: name of the new folder's parent, or %NULL * @folder_name: name of the folder to create @@ -530,11 +530,11 @@ camel_store_get_folder (CamelStore *store, * free with #camel_store_free_folder_info, or %NULL. **/ CamelFolderInfo * -camel_store_create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +camel_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; CamelFolderInfo *fi; @@ -543,7 +543,7 @@ camel_store_create_folder (CamelStore *store, g_return_val_if_fail (folder_name != NULL, NULL); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->create_folder != NULL, NULL); + g_return_val_if_fail (class->create_folder_sync != NULL, NULL); if ((parent_name == NULL || parent_name[0] == 0) && (((store->flags & CAMEL_STORE_VTRASH) && strcmp (folder_name, CAMEL_VTRASH_NAME) == 0) @@ -558,9 +558,9 @@ camel_store_create_folder (CamelStore *store, camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK); - fi = class->create_folder ( + fi = class->create_folder_sync ( store, parent_name, folder_name, cancellable, error); - CAMEL_CHECK_GERROR (store, create_folder, fi != NULL, error); + CAMEL_CHECK_GERROR (store, create_folder_sync, fi != NULL, error); camel_store_unlock (store, CAMEL_STORE_FOLDER_LOCK); @@ -598,7 +598,7 @@ cs_delete_cached_folder (CamelStore *store, } /** - * camel_store_delete_folder: + * camel_store_delete_folder_sync: * @store: a #CamelStore object * @folder_name: name of the folder to delete * @cancellable: optional #GCancellable object, or %NULL @@ -609,10 +609,10 @@ cs_delete_cached_folder (CamelStore *store, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_store_delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +camel_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; gboolean success; @@ -622,7 +622,7 @@ camel_store_delete_folder (CamelStore *store, g_return_val_if_fail (folder_name != NULL, FALSE); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->delete_folder != NULL, FALSE); + g_return_val_if_fail (class->delete_folder_sync != NULL, FALSE); /* TODO: should probably be a parameter/bit on the storeinfo */ if (((store->flags & CAMEL_STORE_VTRASH) && strcmp (folder_name, CAMEL_VTRASH_NAME) == 0) @@ -637,9 +637,9 @@ camel_store_delete_folder (CamelStore *store, camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK); - success = class->delete_folder ( + success = class->delete_folder_sync ( store, folder_name, cancellable, &local_error); - CAMEL_CHECK_GERROR (store, delete_folder, success, &local_error); + CAMEL_CHECK_GERROR (store, delete_folder_sync, success, &local_error); /* ignore 'no such table' errors */ if (local_error != NULL && @@ -657,7 +657,7 @@ camel_store_delete_folder (CamelStore *store, } /** - * camel_store_rename_folder: + * camel_store_rename_folder_sync: * @store: a #CamelStore object * @old_namein: the current name of the folder * @new_name: the new name of the folder @@ -669,11 +669,11 @@ camel_store_delete_folder (CamelStore *store, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_store_rename_folder (CamelStore *store, - const gchar *old_namein, - const gchar *new_name, - GCancellable *cancellable, - GError **error) +camel_store_rename_folder_sync (CamelStore *store, + const gchar *old_namein, + const gchar *new_name, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; CamelFolder *folder; @@ -687,7 +687,7 @@ camel_store_rename_folder (CamelStore *store, g_return_val_if_fail (new_name != NULL, FALSE); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->rename_folder != NULL, FALSE); + g_return_val_if_fail (class->rename_folder_sync != NULL, FALSE); if (strcmp (old_namein, new_name) == 0) return TRUE; @@ -734,9 +734,9 @@ camel_store_rename_folder (CamelStore *store, } /* Now try the real rename (will emit renamed signal) */ - success = class->rename_folder ( + success = class->rename_folder_sync ( store, old_name, new_name, cancellable, error); - CAMEL_CHECK_GERROR (store, rename_folder, success, error); + CAMEL_CHECK_GERROR (store, rename_folder_sync, success, error); /* If it worked, update all open folders/unlock them */ if (folders) { @@ -764,7 +764,7 @@ camel_store_rename_folder (CamelStore *store, if (store->flags & CAMEL_STORE_SUBSCRIPTIONS) flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED; - folder_info = class->get_folder_info ( + folder_info = class->get_folder_info_sync ( store, new_name, flags, cancellable, error); CAMEL_CHECK_GERROR (store, get_folder_info, folder_info != NULL, error); @@ -899,7 +899,7 @@ camel_store_folder_unsubscribed (CamelStore *store, } /** - * camel_store_get_inbox: + * camel_store_get_inbox_folder_sync: * @store: a #CamelStore object * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL @@ -908,9 +908,9 @@ camel_store_folder_unsubscribed (CamelStore *store, * or %NULL if no such folder exists. **/ CamelFolder * -camel_store_get_inbox (CamelStore *store, - GCancellable *cancellable, - GError **error) +camel_store_get_inbox_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; CamelFolder *folder; @@ -918,12 +918,13 @@ camel_store_get_inbox (CamelStore *store, g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->get_inbox != NULL, NULL); + g_return_val_if_fail (class->get_inbox_folder_sync != NULL, NULL); camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK); - folder = class->get_inbox (store, cancellable, error); - CAMEL_CHECK_GERROR (store, get_inbox, folder != NULL, error); + folder = class->get_inbox_folder_sync (store, cancellable, error); + CAMEL_CHECK_GERROR ( + store, get_inbox_folder_sync, folder != NULL, error); camel_store_unlock (store, CAMEL_STORE_FOLDER_LOCK); @@ -931,73 +932,76 @@ camel_store_get_inbox (CamelStore *store, } /** - * camel_store_get_trash: + * camel_store_get_junk_folder_sync: * @store: a #CamelStore object * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL * - * Returns: the folder in the store into which trash is delivered, or + * Returns: the folder in the store into which junk is delivered, or * %NULL if no such folder exists. **/ CamelFolder * -camel_store_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) +camel_store_get_junk_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); - if ((store->flags & CAMEL_STORE_VTRASH) == 0) { + if ((store->flags & CAMEL_STORE_VJUNK) == 0) { CamelStoreClass *class; CamelFolder *folder; class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->get_trash != NULL, NULL); + g_return_val_if_fail (class->get_junk_folder_sync != NULL, NULL); - folder = class->get_trash (store, cancellable, error); - CAMEL_CHECK_GERROR (store, get_trash, folder != NULL, error); + folder = class->get_junk_folder_sync (store, cancellable, error); + CAMEL_CHECK_GERROR ( + store, get_junk_folder_sync, folder != NULL, error); return folder; } - return camel_store_get_folder ( - store, CAMEL_VTRASH_NAME, 0, cancellable, error); + return camel_store_get_folder_sync ( + store, CAMEL_VJUNK_NAME, 0, cancellable, error); } /** - * camel_store_get_junk: + * camel_store_get_trash_folder_sync: * @store: a #CamelStore object * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL * - * Returns: the folder in the store into which junk is delivered, or + * Returns: the folder in the store into which trash is delivered, or * %NULL if no such folder exists. **/ CamelFolder * -camel_store_get_junk (CamelStore *store, - GCancellable *cancellable, - GError **error) +camel_store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); - if ((store->flags & CAMEL_STORE_VJUNK) == 0) { + if ((store->flags & CAMEL_STORE_VTRASH) == 0) { CamelStoreClass *class; CamelFolder *folder; class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->get_junk != NULL, NULL); + g_return_val_if_fail (class->get_trash_folder_sync != NULL, NULL); - folder = class->get_junk (store, cancellable, error); - CAMEL_CHECK_GERROR (store, get_junk, folder != NULL, error); + folder = class->get_trash_folder_sync ( + store, cancellable, error); + CAMEL_CHECK_GERROR ( + store, get_trash_folder_sync, folder != NULL, error); return folder; } - return camel_store_get_folder ( - store, CAMEL_VJUNK_NAME, 0, cancellable, error); + return camel_store_get_folder_sync ( + store, CAMEL_VTRASH_NAME, 0, cancellable, error); } /** - * camel_store_sync: + * camel_store_synchronize_sync: * @store: a #CamelStore object * @expunge: %TRUE if an expunge should be done after sync or %FALSE otherwise * @cancellable: optional #GCancellable object, or %NULL @@ -1009,10 +1013,10 @@ camel_store_get_junk (CamelStore *store, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_store_sync (CamelStore *store, - gint expunge, - GCancellable *cancellable, - GError **error) +camel_store_synchronize_sync (CamelStore *store, + gboolean expunge, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; gboolean success; @@ -1020,10 +1024,10 @@ camel_store_sync (CamelStore *store, g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->sync != NULL, FALSE); + g_return_val_if_fail (class->synchronize_sync != NULL, FALSE); - success = class->sync (store, expunge, cancellable, error); - CAMEL_CHECK_GERROR (store, sync, success, error); + success = class->synchronize_sync (store, expunge, cancellable, error); + CAMEL_CHECK_GERROR (store, synchronize_sync, success, error); return success; } @@ -1109,7 +1113,7 @@ dump_fi (CamelFolderInfo *fi, gint depth) } /** - * camel_store_get_folder_info: + * camel_store_get_folder_info_sync: * @store: a #CamelStore object * @top: the name of the folder to start from * @flags: various CAMEL_STORE_FOLDER_INFO_* flags to control behavior @@ -1139,11 +1143,11 @@ dump_fi (CamelFolderInfo *fi, gint depth) * #camel_store_free_folder_info, or %NULL. **/ CamelFolderInfo * -camel_store_get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +camel_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; CamelFolderInfo *info; @@ -1151,11 +1155,13 @@ camel_store_get_folder_info (CamelStore *store, g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->get_folder_info != NULL, NULL); + g_return_val_if_fail (class->get_folder_info_sync != NULL, NULL); - info = class->get_folder_info (store, top, flags, cancellable, error); + info = class->get_folder_info_sync ( + store, top, flags, cancellable, error); if (!(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)) - CAMEL_CHECK_GERROR (store, get_folder_info, info != NULL, error); + CAMEL_CHECK_GERROR ( + store, get_folder_info_sync, info != NULL, error); if (info && (top == NULL || *top == '\0') && (flags & CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL) == 0) { if (info->uri && (store->flags & CAMEL_STORE_VTRASH)) @@ -1492,7 +1498,7 @@ camel_store_folder_is_subscribed (CamelStore *store, } /** - * camel_store_subscribe_folder: + * camel_store_subscribe_folder_sync: * @store: a #CamelStore object * @folder_name: full path of the folder * @cancellable: optional #GCancellable object, or %NULL @@ -1503,10 +1509,10 @@ camel_store_folder_is_subscribed (CamelStore *store, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_store_subscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +camel_store_subscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; gboolean success; @@ -1516,13 +1522,13 @@ camel_store_subscribe_folder (CamelStore *store, g_return_val_if_fail (store->flags & CAMEL_STORE_SUBSCRIPTIONS, FALSE); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->subscribe_folder != NULL, FALSE); + g_return_val_if_fail (class->subscribe_folder_sync != NULL, FALSE); camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK); - success = class->subscribe_folder ( + success = class->subscribe_folder_sync ( store, folder_name, cancellable, error); - CAMEL_CHECK_GERROR (store, subscribe_folder, success, error); + CAMEL_CHECK_GERROR (store, subscribe_folder_sync, success, error); camel_store_unlock (store, CAMEL_STORE_FOLDER_LOCK); @@ -1530,7 +1536,7 @@ camel_store_subscribe_folder (CamelStore *store, } /** - * camel_store_unsubscribe_folder: + * camel_store_unsubscribe_folder_sync: * @store: a #CamelStore object * @folder_name: full path of the folder * @cancellable: optional #GCancellable object, or %NULL @@ -1541,10 +1547,10 @@ camel_store_subscribe_folder (CamelStore *store, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_store_unsubscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +camel_store_unsubscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; gboolean success; @@ -1554,13 +1560,13 @@ camel_store_unsubscribe_folder (CamelStore *store, g_return_val_if_fail (store->flags & CAMEL_STORE_SUBSCRIPTIONS, FALSE); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->unsubscribe_folder != NULL, FALSE); + g_return_val_if_fail (class->unsubscribe_folder_sync != NULL, FALSE); camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK); - success = class->unsubscribe_folder ( + success = class->unsubscribe_folder_sync ( store, folder_name, cancellable, error); - CAMEL_CHECK_GERROR (store, unsubscribe_folder, success, error); + CAMEL_CHECK_GERROR (store, unsubscribe_folder_sync, success, error); if (success) cs_delete_cached_folder (store, folder_name); @@ -1571,7 +1577,7 @@ camel_store_unsubscribe_folder (CamelStore *store, } /** - * camel_store_noop: + * camel_store_noop_sync: * @store: a #CamelStore object * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL @@ -1581,9 +1587,9 @@ camel_store_unsubscribe_folder (CamelStore *store, * Returns: %TRUE on success, %FALSE on failure **/ gboolean -camel_store_noop (CamelStore *store, - GCancellable *cancellable, - GError **error) +camel_store_noop_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelStoreClass *class; gboolean success; @@ -1591,10 +1597,10 @@ camel_store_noop (CamelStore *store, g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE); class = CAMEL_STORE_GET_CLASS (store); - g_return_val_if_fail (class->noop != NULL, FALSE); + g_return_val_if_fail (class->noop_sync != NULL, FALSE); - success = class->noop (store, cancellable, error); - CAMEL_CHECK_GERROR (store, noop, success, error); + success = class->noop_sync (store, cancellable, error); + CAMEL_CHECK_GERROR (store, noop_sync, success, error); return success; } diff --git a/camel/camel-store.h b/camel/camel-store.h index 1d75b6a..641c6e1 100644 --- a/camel/camel-store.h +++ b/camel/camel-store.h @@ -221,62 +221,67 @@ struct _CamelStoreClass { GCompareFunc compare_folder_name; /* Methods */ - CamelFolder * (*get_folder) (CamelStore *store, + gboolean (*can_refresh_folder) (CamelStore *store, + CamelFolderInfo *info, + GError **error); + gboolean (*folder_is_subscribed) (CamelStore *store, + const gchar *folder_name); + void (*free_folder_info) (CamelStore *store, + CamelFolderInfo *fi); + + CamelFolder * (*get_folder_sync) (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); - CamelFolder * (*get_inbox) (CamelStore *store, + CamelFolderInfo * + (*get_folder_info_sync) (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error); + CamelFolder * (*get_inbox_folder_sync) + (CamelStore *store, GCancellable *cancellable, GError **error); - CamelFolder * (*get_trash) (CamelStore *store, + CamelFolder * (*get_junk_folder_sync) (CamelStore *store, GCancellable *cancellable, GError **error); - CamelFolder * (*get_junk) (CamelStore *store, + CamelFolder * (*get_trash_folder_sync) + (CamelStore *store, GCancellable *cancellable, GError **error); CamelFolderInfo * - (*create_folder) (CamelStore *store, + (*create_folder_sync) (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GCancellable *cancellable, GError **error); - gboolean (*delete_folder) (CamelStore *store, + gboolean (*delete_folder_sync) (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); - gboolean (*rename_folder) (CamelStore *store, + gboolean (*rename_folder_sync) (CamelStore *store, const gchar *old_name, const gchar *new_name, GCancellable *cancellable, GError **error); - gboolean (*sync) (CamelStore *store, - gint expunge, - GCancellable *cancellable, - GError **error); - CamelFolderInfo * - (*get_folder_info) (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error); - void (*free_folder_info) (CamelStore *store, - CamelFolderInfo *fi); - gboolean (*folder_is_subscribed) (CamelStore *store, - const gchar *folder_name); - gboolean (*subscribe_folder) (CamelStore *store, + gboolean (*subscribe_folder_sync) + (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); - gboolean (*unsubscribe_folder) (CamelStore *store, + gboolean (*unsubscribe_folder_sync) + (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); - gboolean (*noop) (CamelStore *store, + gboolean (*synchronize_sync) (CamelStore *store, + gboolean expunge, GCancellable *cancellable, GError **error); - gboolean (*can_refresh_folder) (CamelStore *store, - CamelFolderInfo *info, + gboolean (*noop_sync) (CamelStore *store, + GCancellable *cancellable, GError **error); /* Signals */ @@ -297,35 +302,6 @@ struct _CamelStoreClass { GType camel_store_get_type (void); GQuark camel_store_error_quark (void) G_GNUC_CONST; -CamelFolder * camel_store_get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error); -CamelFolder * camel_store_get_inbox (CamelStore *store, - GCancellable *cancellable, - GError **error); -CamelFolder * camel_store_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error); -CamelFolder * camel_store_get_junk (CamelStore *store, - GCancellable *cancellable, - GError **error); -CamelFolderInfo * - camel_store_create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error); -gboolean camel_store_delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error); -gboolean camel_store_rename_folder (CamelStore *store, - const gchar *old_namein, - const gchar *new_name, - GCancellable *cancellable, - GError **error); void camel_store_folder_created (CamelStore *store, CamelFolderInfo *info); void camel_store_folder_deleted (CamelStore *store, @@ -337,16 +313,6 @@ void camel_store_folder_subscribed (CamelStore *store, CamelFolderInfo *info); void camel_store_folder_unsubscribed (CamelStore *store, CamelFolderInfo *info); -gboolean camel_store_sync (CamelStore *store, - gint expunge, - GCancellable *cancellable, - GError **error); -CamelFolderInfo * - camel_store_get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error); void camel_store_free_folder_info (CamelStore *store, CamelFolderInfo *fi); void camel_store_free_folder_info_full @@ -370,17 +336,6 @@ gboolean camel_store_supports_subscriptions (CamelStore *store); gboolean camel_store_folder_is_subscribed (CamelStore *store, const gchar *folder_name); -gboolean camel_store_subscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error); -gboolean camel_store_unsubscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error); -gboolean camel_store_noop (CamelStore *store, - GCancellable *cancellable, - GError **error); gint camel_store_folder_uri_equal (CamelStore *store, const gchar *uri0, const gchar *uri1); @@ -392,6 +347,63 @@ void camel_store_lock (CamelStore *store, void camel_store_unlock (CamelStore *store, CamelStoreLock lock); +CamelFolder * camel_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error); +CamelFolderInfo * + camel_store_get_folder_info_sync + (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error); +CamelFolder * camel_store_get_inbox_folder_sync + (CamelStore *store, + GCancellable *cancellable, + GError **error); +CamelFolder * camel_store_get_trash_folder_sync + (CamelStore *store, + GCancellable *cancellable, + GError **error); +CamelFolder * camel_store_get_junk_folder_sync + (CamelStore *store, + GCancellable *cancellable, + GError **error); +CamelFolderInfo * + camel_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error); +gboolean camel_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error); +gboolean camel_store_rename_folder_sync (CamelStore *store, + const gchar *old_namein, + const gchar *new_name, + GCancellable *cancellable, + GError **error); +gboolean camel_store_subscribe_folder_sync + (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error); +gboolean camel_store_unsubscribe_folder_sync + (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error); +gboolean camel_store_synchronize_sync (CamelStore *store, + gboolean expunge, + GCancellable *cancellable, + GError **error); +gboolean camel_store_noop_sync (CamelStore *store, + GCancellable *cancellable, + GError **error); + G_END_DECLS #endif /* CAMEL_STORE_H */ diff --git a/camel/camel-transport.c b/camel/camel-transport.c index 1f9af07..24bdc7b 100644 --- a/camel/camel-transport.c +++ b/camel/camel-transport.c @@ -75,7 +75,7 @@ camel_transport_init (CamelTransport *transport) } /** - * camel_transport_send_to: + * camel_transport_send_to_sync: * @transport: a #CamelTransport object * @message: a #CamelMimeMessage to send * @from: a #CamelAddress to send from @@ -90,12 +90,12 @@ camel_transport_init (CamelTransport *transport) * Return %TRUE on success or %FALSE on fail **/ gboolean -camel_transport_send_to (CamelTransport *transport, - CamelMimeMessage *message, - CamelAddress *from, - CamelAddress *recipients, - GCancellable *cancellable, - GError **error) +camel_transport_send_to_sync (CamelTransport *transport, + CamelMimeMessage *message, + CamelAddress *from, + CamelAddress *recipients, + GCancellable *cancellable, + GError **error) { CamelTransportClass *class; gboolean success; @@ -106,13 +106,13 @@ camel_transport_send_to (CamelTransport *transport, g_return_val_if_fail (CAMEL_IS_ADDRESS (recipients), FALSE); class = CAMEL_TRANSPORT_GET_CLASS (transport); - g_return_val_if_fail (class->send_to != NULL, FALSE); + g_return_val_if_fail (class->send_to_sync != NULL, FALSE); camel_transport_lock (transport, CAMEL_TRANSPORT_SEND_LOCK); - success = class->send_to ( + success = class->send_to_sync ( transport, message, from, recipients, cancellable, error); - CAMEL_CHECK_GERROR (transport, send_to, success, error); + CAMEL_CHECK_GERROR (transport, send_to_sync, success, error); camel_transport_unlock (transport, CAMEL_TRANSPORT_SEND_LOCK); diff --git a/camel/camel-transport.h b/camel/camel-transport.h index 3456591..7a53961 100644 --- a/camel/camel-transport.h +++ b/camel/camel-transport.h @@ -76,7 +76,7 @@ struct _CamelTransport { struct _CamelTransportClass { CamelServiceClass parent_class; - gboolean (*send_to) (CamelTransport *transport, + gboolean (*send_to_sync) (CamelTransport *transport, CamelMimeMessage *message, CamelAddress *from, CamelAddress *recipients, @@ -85,7 +85,7 @@ struct _CamelTransportClass { }; GType camel_transport_get_type (void); -gboolean camel_transport_send_to (CamelTransport *transport, +gboolean camel_transport_send_to_sync (CamelTransport *transport, CamelMimeMessage *message, CamelAddress *from, CamelAddress *recipients, diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index 233ea1a..8585108 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -985,183 +985,6 @@ vee_folder_finalize (GObject *object) G_OBJECT_CLASS (camel_vee_folder_parent_class)->finalize (object); } -static gboolean -vee_folder_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - CamelVeeFolderPrivate *p = CAMEL_VEE_FOLDER_GET_PRIVATE (vf); - GList *node, *list; - gboolean success = TRUE; - - camel_vee_folder_lock (vf, CAMEL_VEE_FOLDER_CHANGED_LOCK); - list = p->folders_changed; - p->folders_changed = NULL; - camel_vee_folder_unlock (vf, CAMEL_VEE_FOLDER_CHANGED_LOCK); - - node = list; - while (node) { - CamelFolder *f = node->data; - - if (camel_vee_folder_rebuild_folder (vf, f, error) == -1) { - success = FALSE; - break; - } - - node = node->next; - } - - g_list_free (list); - - return success; -} - -static gboolean -vee_folder_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) -{ - CamelVeeFolder *vf = (CamelVeeFolder *)folder; - CamelVeeFolderPrivate *p = CAMEL_VEE_FOLDER_GET_PRIVATE (vf); - GList *node; - GError *local_error = NULL; - - if (((CamelVeeSummary *)folder->summary)->fake_visible_count) - folder->summary->visible_count = ((CamelVeeSummary *)folder->summary)->fake_visible_count; - ((CamelVeeSummary *)folder->summary)->fake_visible_count = 0; - - camel_vee_folder_lock (vf, CAMEL_VEE_FOLDER_SUBFOLDER_LOCK); - - node = p->folders; - while (node) { - CamelFolder *f = node->data; - - if (!camel_folder_sync (f, expunge, cancellable, &local_error)) { - if (strncmp (local_error->message, "no such table", 13) != 0) { - const gchar *desc; - - desc = camel_folder_get_description (f); - g_warning ("%s", local_error->message); - g_propagate_prefixed_error ( - error, local_error, - _("Error storing '%s': "), desc); - } else - g_clear_error (&local_error); - } - - /* auto update vfolders shouldn't need a rebuild */ -/* if ((vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0 */ -/* && camel_vee_folder_rebuild_folder (vf, f, ex) == -1) */ -/* break; */ - - node = node->next; - } - - if (vf->priv->unread_vfolder == 1) { - /* Cleanup Junk/Trash uids */ - CamelStore *parent_store; - const gchar *full_name; - GSList *del = NULL; - gint i, count; - - camel_folder_summary_prepare_fetch_all (folder->summary, NULL); - count = camel_folder_summary_count (folder->summary); - for (i=0; i < count; i++) { - CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (folder->summary, i); - if (mi->old_flags & CAMEL_MESSAGE_DELETED) { - del = g_slist_prepend (del, (gpointer) camel_pstring_strdup (((CamelMessageInfo *)mi)->uid)); - camel_folder_summary_remove_index_fast (folder->summary, i); - count--; - i--; - - } - camel_message_info_free (mi); - } - - full_name = camel_folder_get_full_name (folder); - parent_store = camel_folder_get_parent_store (folder); - camel_db_delete_vuids (parent_store->cdb_w, full_name, "", del, NULL); - g_slist_foreach (del, (GFunc) camel_pstring_free, NULL); - g_slist_free (del); - } - camel_vee_folder_unlock (vf, CAMEL_VEE_FOLDER_SUBFOLDER_LOCK); - - camel_object_state_write (CAMEL_OBJECT (vf)); - - return TRUE; -} - -static gboolean -vee_folder_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - /* Force it to rebuild the counts, when some folders were expunged. */ - ((CamelVeeSummary *) folder->summary)->force_counts = TRUE; - - return CAMEL_FOLDER_GET_CLASS (folder)-> - sync (folder, TRUE, cancellable, error); -} - -static CamelMimeMessage * -vee_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) -{ - CamelVeeMessageInfo *mi; - CamelMimeMessage *msg = NULL; - - mi = (CamelVeeMessageInfo *)camel_folder_summary_uid (folder->summary, uid); - if (mi) { - msg = camel_folder_get_message ( - mi->summary->folder, camel_message_info_uid (mi)+8, - cancellable, error); - camel_message_info_free ((CamelMessageInfo *)mi); - } else { - g_set_error ( - error, CAMEL_FOLDER_ERROR, - CAMEL_FOLDER_ERROR_INVALID_UID, - _("No such message %s in %s"), uid, - camel_folder_get_name (folder)); - } - - return msg; -} - -static gboolean -vee_folder_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) -{ - g_set_error ( - error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, - _("Cannot copy or move messages into a Virtual Folder")); - - return FALSE; -} - -static gboolean -vee_folder_transfer_messages_to (CamelFolder *folder, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) -{ - g_set_error ( - error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, - _("Cannot copy or move messages into a Virtual Folder")); - - return FALSE; -} - static GPtrArray * vee_folder_search_by_expression (CamelFolder *folder, const gchar *expression, @@ -1384,6 +1207,183 @@ vee_folder_thaw (CamelFolder *folder) CAMEL_FOLDER_CLASS (camel_vee_folder_parent_class)->thaw (folder); } +static gboolean +vee_folder_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) +{ + g_set_error ( + error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + _("Cannot copy or move messages into a Virtual Folder")); + + return FALSE; +} + +static gboolean +vee_folder_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + /* Force it to rebuild the counts, when some folders were expunged. */ + ((CamelVeeSummary *) folder->summary)->force_counts = TRUE; + + return CAMEL_FOLDER_GET_CLASS (folder)-> + synchronize_sync (folder, TRUE, cancellable, error); +} + +static CamelMimeMessage * +vee_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) +{ + CamelVeeMessageInfo *mi; + CamelMimeMessage *msg = NULL; + + mi = (CamelVeeMessageInfo *)camel_folder_summary_uid (folder->summary, uid); + if (mi) { + msg = camel_folder_get_message_sync ( + mi->summary->folder, camel_message_info_uid (mi)+8, + cancellable, error); + camel_message_info_free ((CamelMessageInfo *)mi); + } else { + g_set_error ( + error, CAMEL_FOLDER_ERROR, + CAMEL_FOLDER_ERROR_INVALID_UID, + _("No such message %s in %s"), uid, + camel_folder_get_name (folder)); + } + + return msg; +} + +static gboolean +vee_folder_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + CamelVeeFolder *vf = (CamelVeeFolder *)folder; + CamelVeeFolderPrivate *p = CAMEL_VEE_FOLDER_GET_PRIVATE (vf); + GList *node, *list; + gboolean success = TRUE; + + camel_vee_folder_lock (vf, CAMEL_VEE_FOLDER_CHANGED_LOCK); + list = p->folders_changed; + p->folders_changed = NULL; + camel_vee_folder_unlock (vf, CAMEL_VEE_FOLDER_CHANGED_LOCK); + + node = list; + while (node) { + CamelFolder *f = node->data; + + if (camel_vee_folder_rebuild_folder (vf, f, error) == -1) { + success = FALSE; + break; + } + + node = node->next; + } + + g_list_free (list); + + return success; +} + +static gboolean +vee_folder_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) +{ + CamelVeeFolder *vf = (CamelVeeFolder *)folder; + CamelVeeFolderPrivate *p = CAMEL_VEE_FOLDER_GET_PRIVATE (vf); + GList *node; + GError *local_error = NULL; + + if (((CamelVeeSummary *)folder->summary)->fake_visible_count) + folder->summary->visible_count = ((CamelVeeSummary *)folder->summary)->fake_visible_count; + ((CamelVeeSummary *)folder->summary)->fake_visible_count = 0; + + camel_vee_folder_lock (vf, CAMEL_VEE_FOLDER_SUBFOLDER_LOCK); + + node = p->folders; + while (node) { + CamelFolder *f = node->data; + + if (!camel_folder_synchronize_sync (f, expunge, cancellable, &local_error)) { + if (strncmp (local_error->message, "no such table", 13) != 0) { + const gchar *desc; + + desc = camel_folder_get_description (f); + g_warning ("%s", local_error->message); + g_propagate_prefixed_error ( + error, local_error, + _("Error storing '%s': "), desc); + } else + g_clear_error (&local_error); + } + + /* auto update vfolders shouldn't need a rebuild */ +/* if ((vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0 */ +/* && camel_vee_folder_rebuild_folder (vf, f, ex) == -1) */ +/* break; */ + + node = node->next; + } + + if (vf->priv->unread_vfolder == 1) { + /* Cleanup Junk/Trash uids */ + CamelStore *parent_store; + const gchar *full_name; + GSList *del = NULL; + gint i, count; + + camel_folder_summary_prepare_fetch_all (folder->summary, NULL); + count = camel_folder_summary_count (folder->summary); + for (i=0; i < count; i++) { + CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (folder->summary, i); + if (mi->old_flags & CAMEL_MESSAGE_DELETED) { + del = g_slist_prepend (del, (gpointer) camel_pstring_strdup (((CamelMessageInfo *)mi)->uid)); + camel_folder_summary_remove_index_fast (folder->summary, i); + count--; + i--; + + } + camel_message_info_free (mi); + } + + full_name = camel_folder_get_full_name (folder); + parent_store = camel_folder_get_parent_store (folder); + camel_db_delete_vuids (parent_store->cdb_w, full_name, "", del, NULL); + g_slist_foreach (del, (GFunc) camel_pstring_free, NULL); + g_slist_free (del); + } + camel_vee_folder_unlock (vf, CAMEL_VEE_FOLDER_SUBFOLDER_LOCK); + + camel_object_state_write (CAMEL_OBJECT (vf)); + + return TRUE; +} + +static gboolean +vee_folder_transfer_messages_to_sync (CamelFolder *folder, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) +{ + g_set_error ( + error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + _("Cannot copy or move messages into a Virtual Folder")); + + return FALSE; +} + static void vee_folder_set_expression (CamelVeeFolder *vee_folder, const gchar *query) @@ -1918,18 +1918,18 @@ camel_vee_folder_class_init (CamelVeeFolderClass *class) object_class->finalize = vee_folder_finalize; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->refresh_info = vee_folder_refresh_info; - folder_class->sync = vee_folder_sync; - folder_class->expunge = vee_folder_expunge; - folder_class->get_message = vee_folder_get_message; - folder_class->append_message = vee_folder_append_message; - folder_class->transfer_messages_to = vee_folder_transfer_messages_to; folder_class->search_by_expression = vee_folder_search_by_expression; folder_class->search_by_uids = vee_folder_search_by_uids; folder_class->count_by_expression = vee_folder_count_by_expression; folder_class->delete = vee_folder_delete; folder_class->freeze = vee_folder_freeze; folder_class->thaw = vee_folder_thaw; + folder_class->append_message_sync = vee_folder_append_message_sync; + folder_class->expunge_sync = vee_folder_expunge_sync; + folder_class->get_message_sync = vee_folder_get_message_sync; + folder_class->refresh_info_sync = vee_folder_refresh_info_sync; + folder_class->synchronize_sync = vee_folder_synchronize_sync; + folder_class->transfer_messages_to_sync = vee_folder_transfer_messages_to_sync; class->set_expression = vee_folder_set_expression; class->add_folder = vee_folder_add_folder; diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c index 6ccef77..fd04cee 100644 --- a/camel/camel-vee-store.c +++ b/camel/camel-vee-store.c @@ -154,11 +154,11 @@ vee_store_get_name (CamelService *service, } static CamelFolder * -vee_store_get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) +vee_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelVeeFolder *vf; CamelFolder *folder; @@ -196,113 +196,12 @@ vee_store_get_folder (CamelStore *store, return (CamelFolder *)vf; } -static gboolean -vee_store_rename_folder (CamelStore *store, - const gchar *old, - const gchar *new, - GCancellable *cancellable, - GError **error) -{ - CamelFolder *folder, *oldfolder; - gchar *p, *name; - - d (printf ("vee rename folder '%s' '%s'\n", old, new)); - - if (strcmp (old, CAMEL_UNMATCHED_NAME) == 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot rename folder: %s: Invalid operation"), old); - return FALSE; - } - - /* See if it exists, for vfolders, all folders are in the folders hash */ - oldfolder = camel_object_bag_get (store->folders, old); - if (oldfolder == NULL) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot rename folder: %s: No such folder"), old); - return FALSE; - } - - /* Check that new parents exist, if not, create dummy ones */ - name = alloca (strlen (new)+1); - strcpy (name, new); - p = name; - while ( (p = strchr (p, '/'))) { - *p = 0; - - folder = camel_object_bag_reserve (store->folders, name); - if (folder == NULL) { - /* create a dummy vFolder for this, makes get_folder_info simpler */ - folder = camel_vee_folder_new (store, name, ((CamelVeeFolder *)oldfolder)->flags); - camel_object_bag_add (store->folders, name, folder); - change_folder (store, name, CHANGE_ADD|CHANGE_NOSELECT, 0); - /* FIXME: this sort of leaks folder, nobody owns a ref to it but us */ - } else { - g_object_unref (folder); - } - *p++='/'; - } - - g_object_unref (oldfolder); - - return TRUE; -} - -static gboolean -vee_store_delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - CamelFolder *folder; - - if (strcmp (folder_name, CAMEL_UNMATCHED_NAME) == 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot delete folder: %s: Invalid operation"), - folder_name); - return FALSE; - } - - folder = camel_object_bag_get (store->folders, folder_name); - if (folder) { - CamelObject *object = CAMEL_OBJECT (folder); - const gchar *state_filename; - - state_filename = camel_object_get_state_filename (object); - if (state_filename != NULL) { - g_unlink (state_filename); - camel_object_set_state_filename (object, NULL); - } - - if ((((CamelVeeFolder *)folder)->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) { - /* what about now-empty parents? ignore? */ - change_folder (store, folder_name, CHANGE_DELETE, -1); - } - - g_object_unref (folder); - } else { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot delete folder: %s: No such folder"), - folder_name); - return FALSE; - } - - return TRUE; -} - static CamelFolderInfo * -vee_store_get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +vee_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelFolderInfo *info, *res = NULL, *tail; GPtrArray *folders; @@ -350,7 +249,7 @@ vee_store_get_folder_info (CamelStore *store, /* ensures unread is correct */ if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - camel_folder_refresh_info ( + camel_folder_refresh_info_sync ( (CamelFolder *)folder, cancellable, NULL); @@ -438,21 +337,122 @@ vee_store_get_folder_info (CamelStore *store, } static CamelFolder * -vee_store_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) +vee_store_get_junk_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { return NULL; } static CamelFolder * -vee_store_get_junk (CamelStore *store, - GCancellable *cancellable, - GError **error) +vee_store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { return NULL; } +static gboolean +vee_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + CamelFolder *folder; + + if (strcmp (folder_name, CAMEL_UNMATCHED_NAME) == 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot delete folder: %s: Invalid operation"), + folder_name); + return FALSE; + } + + folder = camel_object_bag_get (store->folders, folder_name); + if (folder) { + CamelObject *object = CAMEL_OBJECT (folder); + const gchar *state_filename; + + state_filename = camel_object_get_state_filename (object); + if (state_filename != NULL) { + g_unlink (state_filename); + camel_object_set_state_filename (object, NULL); + } + + if ((((CamelVeeFolder *)folder)->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) { + /* what about now-empty parents? ignore? */ + change_folder (store, folder_name, CHANGE_DELETE, -1); + } + + g_object_unref (folder); + } else { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot delete folder: %s: No such folder"), + folder_name); + return FALSE; + } + + return TRUE; +} + +static gboolean +vee_store_rename_folder_sync (CamelStore *store, + const gchar *old, + const gchar *new, + GCancellable *cancellable, + GError **error) +{ + CamelFolder *folder, *oldfolder; + gchar *p, *name; + + d (printf ("vee rename folder '%s' '%s'\n", old, new)); + + if (strcmp (old, CAMEL_UNMATCHED_NAME) == 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot rename folder: %s: Invalid operation"), old); + return FALSE; + } + + /* See if it exists, for vfolders, all folders are in the folders hash */ + oldfolder = camel_object_bag_get (store->folders, old); + if (oldfolder == NULL) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot rename folder: %s: No such folder"), old); + return FALSE; + } + + /* Check that new parents exist, if not, create dummy ones */ + name = alloca (strlen (new)+1); + strcpy (name, new); + p = name; + while ( (p = strchr (p, '/'))) { + *p = 0; + + folder = camel_object_bag_reserve (store->folders, name); + if (folder == NULL) { + /* create a dummy vFolder for this, makes get_folder_info simpler */ + folder = camel_vee_folder_new (store, name, ((CamelVeeFolder *)oldfolder)->flags); + camel_object_bag_add (store->folders, name, folder); + change_folder (store, name, CHANGE_ADD|CHANGE_NOSELECT, 0); + /* FIXME: this sort of leaks folder, nobody owns a ref to it but us */ + } else { + g_object_unref (folder); + } + *p++='/'; + } + + g_object_unref (oldfolder); + + return TRUE; +} + static void camel_vee_store_class_init (CamelVeeStoreClass *class) { @@ -468,13 +468,13 @@ camel_vee_store_class_init (CamelVeeStoreClass *class) service_class->get_name = vee_store_get_name; store_class = CAMEL_STORE_CLASS (class); - store_class->get_folder = vee_store_get_folder; - store_class->rename_folder = vee_store_rename_folder; - store_class->delete_folder = vee_store_delete_folder; - store_class->get_folder_info = vee_store_get_folder_info; store_class->free_folder_info = camel_store_free_folder_info_full; - store_class->get_trash = vee_store_get_trash; - store_class->get_junk = vee_store_get_junk; + store_class->get_folder_sync = vee_store_get_folder_sync; + store_class->get_folder_info_sync = vee_store_get_folder_info_sync; + store_class->get_junk_folder_sync = vee_store_get_junk_folder_sync; + store_class->get_trash_folder_sync = vee_store_get_trash_folder_sync; + store_class->delete_folder_sync = vee_store_delete_folder_sync; + store_class->rename_folder_sync = vee_store_rename_folder_sync; } static void diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c index b1f23c5..63fd5db 100644 --- a/camel/camel-vtrash-folder.c +++ b/camel/camel-vtrash-folder.c @@ -68,7 +68,7 @@ transfer_messages (CamelFolder *folder, { gint i; - camel_folder_transfer_messages_to ( + camel_folder_transfer_messages_to_sync ( md->folder, md->uids, md->dest, NULL, md->delete, md->cancellable, error); @@ -84,12 +84,12 @@ transfer_messages (CamelFolder *folder, } static gboolean -vtrash_folder_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +vtrash_folder_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { g_set_error ( error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s", @@ -99,13 +99,13 @@ vtrash_folder_append_message (CamelFolder *folder, } static gboolean -vtrash_folder_transfer_messages_to (CamelFolder *source, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) +vtrash_folder_transfer_messages_to_sync (CamelFolder *source, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) { CamelVeeMessageInfo *mi; gint i; @@ -193,8 +193,8 @@ camel_vtrash_folder_class_init (CamelVTrashFolderClass *class) CamelFolderClass *folder_class; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->append_message = vtrash_folder_append_message; - folder_class->transfer_messages_to = vtrash_folder_transfer_messages_to; + folder_class->append_message_sync = vtrash_folder_append_message_sync; + folder_class->transfer_messages_to_sync = vtrash_folder_transfer_messages_to_sync; } static void diff --git a/camel/providers/groupwise/camel-groupwise-folder.c b/camel/providers/groupwise/camel-groupwise-folder.c index 15e278f..53da6ce 100644 --- a/camel/providers/groupwise/camel-groupwise-folder.c +++ b/camel/providers/groupwise/camel-groupwise-folder.c @@ -77,7 +77,7 @@ struct _CamelGroupwiseFolderPrivate { extern gint camel_application_is_exiting; /*prototypes*/ -static gboolean groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, GPtrArray **transferred_uids, gboolean delete_originals, GCancellable *cancellable, GError **error); +static gboolean groupwise_transfer_messages_to_sync (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, GPtrArray **transferred_uids, gboolean delete_originals, GCancellable *cancellable, GError **error); void convert_to_calendar (EGwItem *item, gchar **str, gint *len); static void convert_to_task (EGwItem *item, gchar **str, gint *len); static void convert_to_note (EGwItem *item, gchar **str, gint *len); @@ -107,142 +107,6 @@ groupwise_get_filename (CamelFolder *folder, const gchar *uid, GError **error) return camel_data_cache_get_filename (gw_folder->cache, "cache", uid, error); } -/* Get a message from cache if available otherwise get it from server */ -static CamelMimeMessage * -groupwise_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) -{ - CamelMimeMessage *msg = NULL; - CamelGroupwiseFolder *gw_folder; - CamelGroupwiseStore *gw_store; - CamelGroupwiseMessageInfo *mi = NULL; - CamelStore *parent_store; - gchar *container_id; - EGwConnectionStatus status; - EGwConnection *cnc; - EGwItem *item; - CamelStream *stream, *cache_stream; - const gchar *full_name; - - full_name = camel_folder_get_full_name (folder); - parent_store = camel_folder_get_parent_store (folder); - - gw_folder = CAMEL_GROUPWISE_FOLDER (folder); - gw_store = CAMEL_GROUPWISE_STORE (parent_store); - - /* see if it is there in cache */ - - mi = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->summary, uid); - if (mi == NULL) { - g_set_error ( - error, CAMEL_FOLDER_ERROR, - CAMEL_FOLDER_ERROR_INVALID_UID, - _("Cannot get message: %s\n %s"), uid, _("No such message")); - return NULL; - } - cache_stream = camel_data_cache_get (gw_folder->cache, "cache", uid, NULL); - stream = camel_stream_mem_new (); - if (cache_stream) { - msg = camel_mime_message_new (); - camel_stream_reset (stream, NULL); - camel_stream_write_to_stream (cache_stream, stream, cancellable, NULL); - camel_stream_reset (stream, NULL); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream, cancellable, error) == -1) { - if (errno == EINTR) { - g_object_unref (msg); - g_object_unref (cache_stream); - g_object_unref (stream); - camel_message_info_free (&mi->info); - return NULL; - } else { - g_prefix_error ( - error, _("Cannot get message %s: "), uid); - g_object_unref (msg); - msg = NULL; - } - } - g_object_unref (cache_stream); - } - g_object_unref (stream); - - if (msg != NULL) { - camel_message_info_free (&mi->info); - return msg; - } - - if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("This message is not available in offline mode.")); - camel_message_info_free (&mi->info); - return NULL; - } - - /* Check if we are really offline */ - if (!camel_groupwise_store_connected (gw_store, cancellable, NULL)) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("This message is not available in offline mode.")); - camel_message_info_free (&mi->info); - return NULL; - } - - container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, full_name)); - - cnc = cnc_lookup (gw_store->priv); - - status = e_gw_connection_get_item (cnc, container_id, uid, GET_ITEM_VIEW_WITH_CACHE, &item); - if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION) - status = e_gw_connection_get_item (cnc, container_id, uid, GET_ITEM_VIEW_WITH_CACHE, &item); - if (status != E_GW_CONNECTION_STATUS_OK) { - g_free (container_id); - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_INVALID, - _("Could not get message")); - camel_message_info_free (&mi->info); - return NULL; - } - - msg = groupwise_folder_item_to_msg (folder, item, NULL); - if (!msg) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_INVALID, - _("Could not get message")); - g_free (container_id); - camel_message_info_free (&mi->info); - - return NULL; - } - - if (msg) { - camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Source", groupwise_base_url_lookup (gw_store->priv)); - mi->info.dirty = TRUE; - camel_folder_summary_touch (folder->summary); - } - - /* add to cache */ - CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock); - if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", uid, NULL))) { - if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream, cancellable, NULL) == -1 - || camel_stream_flush (cache_stream, cancellable, NULL) == -1) - camel_data_cache_remove (gw_folder->cache, "cache", uid, NULL); - g_object_unref (cache_stream); - } - - CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock); - - camel_message_info_free (&mi->info); - g_free (container_id); - g_object_unref (item); - return msg; -} - /* create a mime message out of an gwitem */ static void groupwise_set_mail_message_dates (CamelMimeMessage *msg, EGwItem *item) @@ -676,13 +540,15 @@ move_to_mailbox (CamelFolder *folder, uids = g_ptr_array_new (); g_ptr_array_add (uids, (gpointer) uid); - dest = camel_store_get_folder (parent_store, "Mailbox", 0, cancellable, error); + dest = camel_store_get_folder_sync ( + parent_store, "Mailbox", 0, cancellable, error); camel_message_info_set_flags ( info, CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_JUNK | CAMEL_MESSAGE_JUNK_LEARN | CAMEL_GW_MESSAGE_NOJUNK | CAMEL_GW_MESSAGE_JUNK, 0); if (dest) - groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, cancellable, error); + groupwise_transfer_messages_to_sync ( + folder, uids, dest, NULL, TRUE, cancellable, error); else g_warning ("No Mailbox folder found"); @@ -706,17 +572,21 @@ move_to_junk (CamelFolder *folder, uids = g_ptr_array_new (); g_ptr_array_add (uids, (gpointer) uid); - dest = camel_store_get_folder (parent_store, JUNK_FOLDER, 0, cancellable, error); + dest = camel_store_get_folder_sync ( + parent_store, JUNK_FOLDER, 0, cancellable, error); if (dest) - groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, cancellable, error); + groupwise_transfer_messages_to_sync ( + folder, uids, dest, NULL, TRUE, cancellable, error); else { fi = create_junk_folder (parent_store); - dest = camel_store_get_folder (parent_store, JUNK_FOLDER, 0, cancellable, error); + dest = camel_store_get_folder_sync ( + parent_store, JUNK_FOLDER, 0, cancellable, error); if (!dest) g_warning ("Could not get JunkFolder:Message not moved"); else - groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, cancellable, error); + groupwise_transfer_messages_to_sync ( + folder, uids, dest, NULL, TRUE, cancellable, error); } update_junk_list (parent_store, info, ADD_JUNK_ENTRY); } @@ -805,15 +675,6 @@ groupwise_set_message_flags (CamelFolder *folder, return res; } -static gboolean -groupwise_sync_all (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) -{ - return groupwise_sync (folder, expunge, NULL, cancellable, error); -} - /* This may need to be reorganized. */ static gboolean groupwise_sync (CamelFolder *folder, @@ -846,7 +707,7 @@ groupwise_sync (CamelFolder *folder, deleted_items = deleted_head = NULL; - if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (gw_store))) return groupwise_sync_summary (folder, error); camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK); @@ -1164,7 +1025,7 @@ update_update (CamelSession *session, m->cnc would have become invalid, as the store disconnect unrefs it. */ camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL || + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (gw_store)) || ((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) { goto end1; } @@ -1273,56 +1134,6 @@ static CamelSessionThreadOps update_ops = { update_free, }; -static gboolean -groupwise_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *) folder->summary; - CamelStoreInfo *si; - CamelGroupwiseStore *gw_store; - CamelStore *parent_store; - const gchar *full_name; - - full_name = camel_folder_get_full_name (folder); - parent_store = camel_folder_get_parent_store (folder); - - gw_store = CAMEL_GROUPWISE_STORE (parent_store); - - /* - * Checking for the summary->time_string here since the first the a - * user views a folder, the read cursor is in progress, and the getQM - * should not interfere with the process - */ - if (summary->time_string && (strlen (summary->time_string) > 0)) { - groupwise_refresh_folder (folder, cancellable, error); - si = camel_store_summary_path ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary, full_name); - if (si) { - guint32 unread, total; - - total = camel_folder_summary_count (folder->summary); - unread = folder->summary->unread_count; - - if (si->total != total || si->unread != unread) { - si->total = total; - si->unread = unread; - camel_store_summary_touch ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary); - } - camel_store_summary_info_free ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary, si); - } - /* camel_folder_summary_save_to_db (folder->summary, ex); */ - camel_store_summary_save ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary); - } else { - /* We probably could not get the messages the first time. (get_folder) failed???! - * so do a get_folder again. And hope that it works - */ - g_print("Reloading folder...something wrong with the summary....\n"); - gw_store_reload_folder (gw_store, folder, 0, cancellable, error); - } - - return TRUE; -} - static gint check_for_new_mails_count (CamelGroupwiseSummary *gw_summary, GSList *ids) { @@ -1443,9 +1254,9 @@ groupwise_refresh_folder (CamelFolder *folder, /* Sync-up the (un)read changes before getting updates, so that the getFolderList will reflect the most recent changes too */ - groupwise_sync_all (folder, FALSE, cancellable, error); + groupwise_sync (folder, FALSE, NULL, cancellable, error); - if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (gw_store))) { g_warning ("In offline mode. Cannot refresh!!!\n"); return; } @@ -1888,7 +1699,7 @@ gw_update_cache (CamelFolder *folder, CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock); if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", id, NULL))) { - if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) mail_msg, cache_stream, cancellable, NULL) == -1 || camel_stream_flush (cache_stream, cancellable, NULL) == -1) + if (camel_data_wrapper_write_to_stream_sync ((CamelDataWrapper *) mail_msg, cache_stream, cancellable, NULL) == -1 || camel_stream_flush (cache_stream, cancellable, NULL) == -1) camel_data_cache_remove (gw_folder->cache, "cache", id, NULL); g_object_unref (cache_stream); } @@ -2249,7 +2060,7 @@ groupwise_folder_item_to_msg ( CamelFolder *folder, msg = camel_mime_message_new (); if (has_mime_822 && body) { temp_stream = camel_stream_mem_new_with_buffer (body, body_len); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, temp_stream, NULL, error) == -1) { + if (camel_data_wrapper_construct_from_stream_sync ((CamelDataWrapper *) msg, temp_stream, NULL, error) == -1) { g_object_unref (msg); g_object_unref (temp_stream); msg = NULL; @@ -2518,13 +2329,79 @@ gw_update_all_items (CamelFolder *folder, camel_folder_free_summary (folder, summary); } +/* A function to compare uids, inspired by strcmp . +This code was used in some other provider also , imap4rev1 iirc */ +static gint +uid_compar (gconstpointer va, gconstpointer vb) +{ + const gchar **sa = (const gchar **)va, **sb = (const gchar **)vb; + gulong a, b; + + a = strtoul (*sa, NULL, 10); + b = strtoul (*sb, NULL, 10); + if (a < b) + return -1; + else if (a == b) + return 0; + else + return 1; +} + +static gint +groupwise_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2) +{ + g_return_val_if_fail (uid1 != NULL, 0); + g_return_val_if_fail (uid2 != NULL, 0); + + return strcmp (uid1, uid2); +} + +static void +groupwise_folder_dispose (GObject *object) +{ + CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (object); + + if (gw_folder->cache != NULL) { + g_object_unref (gw_folder->cache); + gw_folder->cache = NULL; + } + + if (gw_folder->search != NULL) { + g_object_unref (gw_folder->search); + gw_folder->search = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (camel_groupwise_folder_parent_class)->dispose (object); +} + +static void +groupwise_folder_constructed (GObject *object) +{ + CamelFolder *folder; + CamelStore *parent_store; + CamelURL *url; + const gchar *full_name; + gchar *description; + + folder = CAMEL_FOLDER (object); + full_name = camel_folder_get_full_name (folder); + parent_store = camel_folder_get_parent_store (folder); + url = CAMEL_SERVICE (parent_store)->url; + + description = g_strdup_printf ( + "%s@%s:%s", url->user, url->host, full_name); + camel_folder_set_description (folder, description); + g_free (description); +} + static gboolean -groupwise_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +groupwise_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { const gchar *container_id = NULL; CamelGroupwiseStore *gw_store; @@ -2558,7 +2435,7 @@ groupwise_append_message (CamelFolder *folder, gw_store = CAMEL_GROUPWISE_STORE (parent_store); offline = CAMEL_OFFLINE_STORE (parent_store); - if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (offline)) { camel_groupwise_journal_append ((CamelGroupwiseJournal *) ((CamelGroupwiseFolder *)folder)->journal, message, info, appended_uid, cancellable, error); return FALSE; } @@ -2618,33 +2495,325 @@ groupwise_append_message (CamelFolder *folder, return TRUE; } -/* A function to compare uids, inspired by strcmp . -This code was used in some other provider also , imap4rev1 iirc */ -static gint -uid_compar (gconstpointer va, gconstpointer vb) -{ - const gchar **sa = (const gchar **)va, **sb = (const gchar **)vb; - gulong a, b; +static gboolean +groupwise_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + CamelGroupwiseStore *gw_store; + CamelGroupwiseFolder *gw_folder; + CamelGroupwiseMessageInfo *ginfo; + CamelMessageInfo *info; + CamelStore *parent_store; + gchar *container_id; + EGwConnection *cnc; + EGwConnectionStatus status; + CamelFolderChangeInfo *changes; + gint i, max; + gboolean delete = FALSE; + GList *deleted_items, *deleted_head; + const gchar *full_name; - a = strtoul (*sa, NULL, 10); - b = strtoul (*sb, NULL, 10); - if (a < b) - return -1; - else if (a == b) - return 0; - else - return 1; + full_name = camel_folder_get_full_name (folder); + parent_store = camel_folder_get_parent_store (folder); + + gw_folder = CAMEL_GROUPWISE_FOLDER (folder); + gw_store = CAMEL_GROUPWISE_STORE (parent_store); + + deleted_items = deleted_head = NULL; + cnc = cnc_lookup (gw_store->priv); + if (!cnc) + return TRUE; + + if (!strcmp (full_name, "Trash")) { + camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + status = e_gw_connection_purge_deleted_items (cnc); + if (status == E_GW_CONNECTION_STATUS_OK) { + camel_folder_freeze (folder); + groupwise_summary_clear (folder->summary, TRUE); + camel_folder_thaw (folder); + } else + g_warning ("Could not Empty Trash\n"); + camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + return TRUE; + } + + changes = camel_folder_change_info_new (); + + container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, full_name)); + + camel_folder_summary_prepare_fetch_all (folder->summary, error); + max = camel_folder_summary_count (folder->summary); + for (i = 0; i < max; i++) { + info = camel_folder_summary_index (folder->summary, i); + ginfo = (CamelGroupwiseMessageInfo *) info; + if (ginfo && (ginfo->info.flags & CAMEL_MESSAGE_DELETED)) { + + if (deleted_items) + deleted_items = g_list_prepend (deleted_items, (gchar *)camel_message_info_uid (info)); + else { + g_list_free (deleted_head); + deleted_head = NULL; + deleted_head = deleted_items = g_list_prepend (deleted_items, (gchar *)camel_message_info_uid (info)); + } + if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) { + /* Read the FIXME below */ + camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + status = e_gw_connection_remove_items (cnc, container_id, deleted_items); + camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + if (status == E_GW_CONNECTION_STATUS_OK) { + gchar *uid; + while (deleted_items) { + uid = (gchar *)deleted_items->data; + CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock); + camel_folder_change_info_remove_uid (changes, uid); + camel_folder_summary_remove_uid (folder->summary, uid); + camel_data_cache_remove(gw_folder->cache, "cache", uid, NULL); + CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock); + deleted_items = g_list_next (deleted_items); + max -= GROUPWISE_BULK_DELETE_LIMIT; + i -= GROUPWISE_BULK_DELETE_LIMIT; + } + } + delete = TRUE; + } + } + camel_message_info_free (info); + } + + if (deleted_items) { + /* FIXME: Put these in a function and reuse it inside the above loop, here and in groupwise_sync*/ + camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + status = e_gw_connection_remove_items (cnc, container_id, deleted_items); + camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + if (status == E_GW_CONNECTION_STATUS_OK) { + gchar *uid; + while (deleted_items) { + uid = (gchar *)deleted_items->data; + CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock); + camel_folder_change_info_remove_uid (changes, uid); + camel_folder_summary_remove_uid (folder->summary, uid); + camel_data_cache_remove(gw_folder->cache, "cache", uid, NULL); + CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock); + deleted_items = g_list_next (deleted_items); + } + } + delete = TRUE; + g_list_free (deleted_head); + } + + if (delete) + camel_folder_changed (folder, changes); + + g_free (container_id); + camel_folder_change_info_free (changes); + + return TRUE; +} + +/* Get a message from cache if available otherwise get it from server */ +static CamelMimeMessage * +groupwise_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) +{ + CamelMimeMessage *msg = NULL; + CamelGroupwiseFolder *gw_folder; + CamelGroupwiseStore *gw_store; + CamelGroupwiseMessageInfo *mi = NULL; + CamelStore *parent_store; + gchar *container_id; + EGwConnectionStatus status; + EGwConnection *cnc; + EGwItem *item; + CamelStream *stream, *cache_stream; + const gchar *full_name; + + full_name = camel_folder_get_full_name (folder); + parent_store = camel_folder_get_parent_store (folder); + + gw_folder = CAMEL_GROUPWISE_FOLDER (folder); + gw_store = CAMEL_GROUPWISE_STORE (parent_store); + + /* see if it is there in cache */ + + mi = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->summary, uid); + if (mi == NULL) { + g_set_error ( + error, CAMEL_FOLDER_ERROR, + CAMEL_FOLDER_ERROR_INVALID_UID, + _("Cannot get message: %s\n %s"), uid, _("No such message")); + return NULL; + } + cache_stream = camel_data_cache_get (gw_folder->cache, "cache", uid, NULL); + stream = camel_stream_mem_new (); + if (cache_stream) { + msg = camel_mime_message_new (); + camel_stream_reset (stream, NULL); + camel_stream_write_to_stream (cache_stream, stream, cancellable, NULL); + camel_stream_reset (stream, NULL); + if (camel_data_wrapper_construct_from_stream_sync ((CamelDataWrapper *) msg, stream, cancellable, error) == -1) { + if (errno == EINTR) { + g_object_unref (msg); + g_object_unref (cache_stream); + g_object_unref (stream); + camel_message_info_free (&mi->info); + return NULL; + } else { + g_prefix_error ( + error, _("Cannot get message %s: "), uid); + g_object_unref (msg); + msg = NULL; + } + } + g_object_unref (cache_stream); + } + g_object_unref (stream); + + if (msg != NULL) { + camel_message_info_free (&mi->info); + return msg; + } + + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (gw_store))) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("This message is not available in offline mode.")); + camel_message_info_free (&mi->info); + return NULL; + } + + /* Check if we are really offline */ + if (!camel_groupwise_store_connected (gw_store, cancellable, NULL)) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("This message is not available in offline mode.")); + camel_message_info_free (&mi->info); + return NULL; + } + + container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, full_name)); + + cnc = cnc_lookup (gw_store->priv); + + status = e_gw_connection_get_item (cnc, container_id, uid, GET_ITEM_VIEW_WITH_CACHE, &item); + if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION) + status = e_gw_connection_get_item (cnc, container_id, uid, GET_ITEM_VIEW_WITH_CACHE, &item); + if (status != E_GW_CONNECTION_STATUS_OK) { + g_free (container_id); + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_INVALID, + _("Could not get message")); + camel_message_info_free (&mi->info); + return NULL; + } + + msg = groupwise_folder_item_to_msg (folder, item, NULL); + if (!msg) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_INVALID, + _("Could not get message")); + g_free (container_id); + camel_message_info_free (&mi->info); + + return NULL; + } + + if (msg) { + camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Source", groupwise_base_url_lookup (gw_store->priv)); + mi->info.dirty = TRUE; + camel_folder_summary_touch (folder->summary); + } + + /* add to cache */ + CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock); + if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", uid, NULL))) { + if (camel_data_wrapper_write_to_stream_sync ((CamelDataWrapper *) msg, cache_stream, cancellable, NULL) == -1 + || camel_stream_flush (cache_stream, cancellable, NULL) == -1) + camel_data_cache_remove (gw_folder->cache, "cache", uid, NULL); + g_object_unref (cache_stream); + } + + CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock); + + camel_message_info_free (&mi->info); + g_free (container_id); + g_object_unref (item); + return msg; } -/* move messages */ static gboolean -groupwise_transfer_messages_to (CamelFolder *source, - GPtrArray *uids, - CamelFolder *destination, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) +groupwise_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *) folder->summary; + CamelStoreInfo *si; + CamelGroupwiseStore *gw_store; + CamelStore *parent_store; + const gchar *full_name; + + full_name = camel_folder_get_full_name (folder); + parent_store = camel_folder_get_parent_store (folder); + + gw_store = CAMEL_GROUPWISE_STORE (parent_store); + + /* + * Checking for the summary->time_string here since the first the a + * user views a folder, the read cursor is in progress, and the getQM + * should not interfere with the process + */ + if (summary->time_string && (strlen (summary->time_string) > 0)) { + groupwise_refresh_folder (folder, cancellable, error); + si = camel_store_summary_path ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary, full_name); + if (si) { + guint32 unread, total; + + total = camel_folder_summary_count (folder->summary); + unread = folder->summary->unread_count; + + if (si->total != total || si->unread != unread) { + si->total = total; + si->unread = unread; + camel_store_summary_touch ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary); + } + camel_store_summary_info_free ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary, si); + } + /* camel_folder_summary_save_to_db (folder->summary, ex); */ + camel_store_summary_save ((CamelStoreSummary *)((CamelGroupwiseStore *)parent_store)->summary); + } else { + /* We probably could not get the messages the first time. (get_folder) failed???! + * so do a get_folder again. And hope that it works + */ + g_print("Reloading folder...something wrong with the summary....\n"); + gw_store_reload_folder (gw_store, folder, 0, cancellable, error); + } + + return TRUE; +} + +static gboolean +groupwise_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) +{ + return groupwise_sync (folder, expunge, NULL, cancellable, error); +} + +static gboolean +groupwise_transfer_messages_to_sync (CamelFolder *source, + GPtrArray *uids, + CamelFolder *destination, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) { gint count, index = 0; GList *item_ids = NULL; @@ -2669,7 +2838,8 @@ groupwise_transfer_messages_to (CamelFolder *source, gw_store = CAMEL_GROUPWISE_STORE (source_parent_store); offline = CAMEL_OFFLINE_STORE (destination_parent_store); - if (destination == camel_store_get_trash (source_parent_store, cancellable, NULL)) + if (destination == camel_store_get_trash_folder_sync ( + source_parent_store, cancellable, NULL)) destination_is_trash = TRUE; else destination_is_trash = FALSE; @@ -2694,7 +2864,7 @@ groupwise_transfer_messages_to (CamelFolder *source, camel_service_lock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); /* check for offline operation */ - if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (offline)) { CamelGroupwiseJournal *journal = (CamelGroupwiseJournal *) ((CamelGroupwiseFolder *) destination)->journal; CamelMimeMessage *message; GList *l; @@ -2710,7 +2880,7 @@ groupwise_transfer_messages_to (CamelFolder *source, if (!(info = camel_folder_summary_uid (source->summary, uids->pdata[i]))) continue; - if (!(message = groupwise_folder_get_message (source, camel_message_info_uid (info), cancellable, error))) + if (!(message = groupwise_folder_get_message_sync (source, camel_message_info_uid (info), cancellable, error))) break; success = camel_groupwise_journal_transfer (journal, (CamelGroupwiseFolder *)source, message, info, uids->pdata[i], NULL, cancellable, error); @@ -2843,7 +3013,7 @@ groupwise_transfer_messages_to (CamelFolder *source, /* Refresh the destination folder, if its not refreshed already */ if (gw_store->current_folder != destination ) - camel_folder_refresh_info (destination, cancellable, error); + camel_folder_refresh_info_sync (destination, cancellable, error); camel_folder_summary_touch (source->summary); camel_folder_summary_touch (destination->summary); @@ -2855,170 +3025,6 @@ groupwise_transfer_messages_to (CamelFolder *source, return TRUE; } -static gboolean -groupwise_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - CamelGroupwiseStore *gw_store; - CamelGroupwiseFolder *gw_folder; - CamelGroupwiseMessageInfo *ginfo; - CamelMessageInfo *info; - CamelStore *parent_store; - gchar *container_id; - EGwConnection *cnc; - EGwConnectionStatus status; - CamelFolderChangeInfo *changes; - gint i, max; - gboolean delete = FALSE; - GList *deleted_items, *deleted_head; - const gchar *full_name; - - full_name = camel_folder_get_full_name (folder); - parent_store = camel_folder_get_parent_store (folder); - - gw_folder = CAMEL_GROUPWISE_FOLDER (folder); - gw_store = CAMEL_GROUPWISE_STORE (parent_store); - - deleted_items = deleted_head = NULL; - cnc = cnc_lookup (gw_store->priv); - if (!cnc) - return TRUE; - - if (!strcmp (full_name, "Trash")) { - camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - status = e_gw_connection_purge_deleted_items (cnc); - if (status == E_GW_CONNECTION_STATUS_OK) { - camel_folder_freeze (folder); - groupwise_summary_clear (folder->summary, TRUE); - camel_folder_thaw (folder); - } else - g_warning ("Could not Empty Trash\n"); - camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - return TRUE; - } - - changes = camel_folder_change_info_new (); - - container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, full_name)); - - camel_folder_summary_prepare_fetch_all (folder->summary, error); - max = camel_folder_summary_count (folder->summary); - for (i = 0; i < max; i++) { - info = camel_folder_summary_index (folder->summary, i); - ginfo = (CamelGroupwiseMessageInfo *) info; - if (ginfo && (ginfo->info.flags & CAMEL_MESSAGE_DELETED)) { - - if (deleted_items) - deleted_items = g_list_prepend (deleted_items, (gchar *)camel_message_info_uid (info)); - else { - g_list_free (deleted_head); - deleted_head = NULL; - deleted_head = deleted_items = g_list_prepend (deleted_items, (gchar *)camel_message_info_uid (info)); - } - if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) { - /* Read the FIXME below */ - camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - status = e_gw_connection_remove_items (cnc, container_id, deleted_items); - camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - if (status == E_GW_CONNECTION_STATUS_OK) { - gchar *uid; - while (deleted_items) { - uid = (gchar *)deleted_items->data; - CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock); - camel_folder_change_info_remove_uid (changes, uid); - camel_folder_summary_remove_uid (folder->summary, uid); - camel_data_cache_remove(gw_folder->cache, "cache", uid, NULL); - CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock); - deleted_items = g_list_next (deleted_items); - max -= GROUPWISE_BULK_DELETE_LIMIT; - i -= GROUPWISE_BULK_DELETE_LIMIT; - } - } - delete = TRUE; - } - } - camel_message_info_free (info); - } - - if (deleted_items) { - /* FIXME: Put these in a function and reuse it inside the above loop, here and in groupwise_sync*/ - camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - status = e_gw_connection_remove_items (cnc, container_id, deleted_items); - camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - if (status == E_GW_CONNECTION_STATUS_OK) { - gchar *uid; - while (deleted_items) { - uid = (gchar *)deleted_items->data; - CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock); - camel_folder_change_info_remove_uid (changes, uid); - camel_folder_summary_remove_uid (folder->summary, uid); - camel_data_cache_remove(gw_folder->cache, "cache", uid, NULL); - CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock); - deleted_items = g_list_next (deleted_items); - } - } - delete = TRUE; - g_list_free (deleted_head); - } - - if (delete) - camel_folder_changed (folder, changes); - - g_free (container_id); - camel_folder_change_info_free (changes); - - return TRUE; -} - -static gint -groupwise_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2) -{ - g_return_val_if_fail (uid1 != NULL, 0); - g_return_val_if_fail (uid2 != NULL, 0); - - return strcmp (uid1, uid2); -} - -static void -groupwise_folder_dispose (GObject *object) -{ - CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (object); - - if (gw_folder->cache != NULL) { - g_object_unref (gw_folder->cache); - gw_folder->cache = NULL; - } - - if (gw_folder->search != NULL) { - g_object_unref (gw_folder->search); - gw_folder->search = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (camel_groupwise_folder_parent_class)->dispose (object); -} - -static void -groupwise_folder_constructed (GObject *object) -{ - CamelFolder *folder; - CamelStore *parent_store; - CamelURL *url; - const gchar *full_name; - gchar *description; - - folder = CAMEL_FOLDER (object); - full_name = camel_folder_get_full_name (folder); - parent_store = camel_folder_get_parent_store (folder); - url = CAMEL_SERVICE (parent_store)->url; - - description = g_strdup_printf ( - "%s@%s:%s", url->user, url->host, full_name); - camel_folder_set_description (folder, description); - g_free (description); -} - static void camel_groupwise_folder_class_init (CamelGroupwiseFolderClass *class) { @@ -3032,20 +3038,20 @@ camel_groupwise_folder_class_init (CamelGroupwiseFolderClass *class) object_class->constructed = groupwise_folder_constructed; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->get_message = groupwise_folder_get_message; folder_class->rename = groupwise_folder_rename; folder_class->search_by_expression = groupwise_folder_search_by_expression; folder_class->count_by_expression = groupwise_folder_count_by_expression; folder_class->cmp_uids = groupwise_cmp_uids; folder_class->search_by_uids = groupwise_folder_search_by_uids; folder_class->search_free = groupwise_folder_search_free; - folder_class->append_message = groupwise_append_message; - folder_class->refresh_info = groupwise_refresh_info; - folder_class->sync = groupwise_sync_all; folder_class->set_message_flags = groupwise_set_message_flags; - folder_class->expunge = groupwise_expunge; - folder_class->transfer_messages_to = groupwise_transfer_messages_to; folder_class->get_filename = groupwise_get_filename; + folder_class->append_message_sync = groupwise_append_message_sync; + folder_class->expunge_sync = groupwise_expunge_sync; + folder_class->get_message_sync = groupwise_folder_get_message_sync; + folder_class->refresh_info_sync = groupwise_refresh_info_sync; + folder_class->synchronize_sync = groupwise_synchronize_sync; + folder_class->transfer_messages_to_sync = groupwise_transfer_messages_to_sync; } static void diff --git a/camel/providers/groupwise/camel-groupwise-journal.c b/camel/providers/groupwise/camel-groupwise-journal.c index 07a2601..0927106 100644 --- a/camel/providers/groupwise/camel-groupwise-journal.c +++ b/camel/providers/groupwise/camel-groupwise-journal.c @@ -175,7 +175,7 @@ groupwise_entry_play_append (CamelOfflineJournal *journal, } message = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream, cancellable, error) == -1) { + if (camel_data_wrapper_construct_from_stream_sync ((CamelDataWrapper *) message, stream, cancellable, error) == -1) { g_object_unref (message); g_object_unref (stream); goto done; @@ -188,7 +188,8 @@ groupwise_entry_play_append (CamelOfflineJournal *journal, info = camel_message_info_new (NULL); } - success = camel_folder_append_message (folder, message, info, NULL, cancellable, error); + success = camel_folder_append_message_sync ( + folder, message, info, NULL, cancellable, error); camel_message_info_free (info); g_object_unref (message); @@ -223,11 +224,12 @@ groupwise_entry_play_transfer (CamelOfflineJournal *journal, } name = camel_groupwise_store_folder_lookup ((CamelGroupwiseStore *) parent_store, entry->source_container); - if (name && (src = camel_store_get_folder (parent_store, name, 0, cancellable, error))) { + if (name && (src = camel_store_get_folder_sync (parent_store, name, 0, cancellable, error))) { uids = g_ptr_array_sized_new (1); g_ptr_array_add (uids, entry->original_uid); - if (camel_folder_transfer_messages_to (src, uids, folder, &xuids, FALSE, cancellable, error)) { + if (camel_folder_transfer_messages_to_sync ( + src, uids, folder, &xuids, FALSE, cancellable, error)) { real = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->summary, xuids->pdata[0]); /* transfer all the system flags, user flags/tags, etc */ @@ -326,7 +328,7 @@ update_cache (CamelGroupwiseJournal *groupwise_journal, return FALSE; } - if (camel_data_wrapper_write_to_stream ( + if (camel_data_wrapper_write_to_stream_sync ( (CamelDataWrapper *) message, cache, cancellable, error) == -1 || camel_stream_flush (cache, cancellable, error) == -1) { g_prefix_error ( diff --git a/camel/providers/groupwise/camel-groupwise-store.c b/camel/providers/groupwise/camel-groupwise-store.c index 915f337..cdc8cd9 100644 --- a/camel/providers/groupwise/camel-groupwise-store.c +++ b/camel/providers/groupwise/camel-groupwise-store.c @@ -289,9 +289,9 @@ groupwise_store_set_current_folder (CamelGroupwiseStore *groupwise_store, CamelF } static gboolean -groupwise_connect (CamelService *service, - GCancellable *cancellable, - GError **error) +groupwise_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelGroupwiseStore *store = CAMEL_GROUPWISE_STORE (service); CamelGroupwiseStorePrivate *priv = store->priv; @@ -300,9 +300,6 @@ groupwise_connect (CamelService *service, d("in groupwise store connect\n"); -/* if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL || - (service->status == CAMEL_SERVICE_DISCONNECTED)) - return FALSE; */ if (service->status == CAMEL_SERVICE_DISCONNECTED) return FALSE; @@ -321,12 +318,13 @@ groupwise_connect (CamelService *service, if (!check_for_connection (service, cancellable, error) || !groupwise_auth_loop (service, cancellable, error)) { camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync (service, TRUE, NULL); return FALSE; } service->status = CAMEL_SERVICE_CONNECTED; - ((CamelOfflineStore *) store)->state = CAMEL_OFFLINE_STORE_NETWORK_AVAIL; + camel_offline_store_set_online_sync ( + CAMEL_OFFLINE_STORE (store), TRUE, cancellable, NULL); if (!e_gw_connection_get_version (priv->cnc)) { camel_session_alert_user (session, @@ -410,10 +408,10 @@ groupwise_disconnect_cleanup (CamelService *service, gboolean clean, GError **er #endif static gboolean -groupwise_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) +groupwise_disconnect_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) { CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service); @@ -434,9 +432,9 @@ groupwise_disconnect (CamelService *service, } static GList* -groupwise_store_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) +groupwise_store_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { GList *auth_types = NULL; @@ -573,11 +571,11 @@ groupwise_get_folder_from_disk (CamelStore *store, } static CamelFolder * -groupwise_get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) +groupwise_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (store); CamelGroupwiseStorePrivate *priv = gw_store->priv; @@ -617,7 +615,7 @@ groupwise_get_folder (CamelStore *store, } if (!E_IS_GW_CONNECTION ( priv->cnc)) { - if (!groupwise_connect (CAMEL_SERVICE (store), cancellable, error)) { + if (!groupwise_connect_sync (CAMEL_SERVICE (store), cancellable, error)) { camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK); return NULL; } @@ -763,7 +761,7 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, } if (!E_IS_GW_CONNECTION ( priv->cnc)) { - if (!groupwise_connect (CAMEL_SERVICE ((CamelStore*)gw_store), cancellable, error)) { + if (!groupwise_connect_sync (CAMEL_SERVICE ((CamelStore*)gw_store), cancellable, error)) { camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK); return FALSE; } @@ -965,7 +963,8 @@ convert_to_folder_info (CamelGroupwiseStore *store, if (store->current_folder && !strcmp (camel_folder_get_full_name (store->current_folder), fi->full_name) && type != E_GW_CONTAINER_TYPE_INBOX) { - CAMEL_FOLDER_GET_CLASS (store->current_folder)->refresh_info (store->current_folder, cancellable, error); + CAMEL_FOLDER_GET_CLASS (store->current_folder)-> + refresh_info_sync (store->current_folder, cancellable, error); } return fi; } @@ -1136,19 +1135,19 @@ groupwise_get_folder_info_offline (CamelStore *store, const gchar *top, } static CamelFolderInfo * -groupwise_get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +groupwise_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store); CamelFolderInfo *info = NULL; /* Do not call groupwise_store_connected function as it would internall call folders_sync to populate the hash table which is used for mapping container id */ - if (!(((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL - && camel_service_connect ((CamelService *)store, error))) + if (!(camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)) + && camel_service_connect_sync ((CamelService *)store, error))) goto offline; camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); @@ -1206,11 +1205,11 @@ create_junk_folder (CamelStore *store) } static CamelFolderInfo* -groupwise_create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +groupwise_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store); CamelGroupwiseStorePrivate *priv = groupwise_store->priv; @@ -1219,7 +1218,7 @@ groupwise_create_folder (CamelStore *store, gchar *child_container_id; gint status; - if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { g_set_error ( error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Cannot create GroupWise folders in offline mode.")); @@ -1249,7 +1248,7 @@ groupwise_create_folder (CamelStore *store, parent_id = ""; if (!E_IS_GW_CONNECTION ( priv->cnc)) { - if (!groupwise_connect (CAMEL_SERVICE (store), cancellable, error)) { + if (!groupwise_connect_sync (CAMEL_SERVICE (store), cancellable, error)) { return NULL; } } @@ -1272,10 +1271,10 @@ groupwise_create_folder (CamelStore *store, } static gboolean -groupwise_delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +groupwise_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store); CamelGroupwiseStorePrivate *priv = groupwise_store->priv; @@ -1311,11 +1310,11 @@ groupwise_delete_folder (CamelStore *store, } static gboolean -groupwise_rename_folder (CamelStore *store, - const gchar *old_name, - const gchar *new_name, - GCancellable *cancellable, - GError **error) +groupwise_store_rename_folder_sync (CamelStore *store, + const gchar *old_name, + const gchar *new_name, + GCancellable *cancellable, + GError **error) { CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store); CamelGroupwiseStorePrivate *priv = groupwise_store->priv; @@ -1426,13 +1425,14 @@ groupwise_base_url_lookup (CamelGroupwiseStorePrivate *priv) } static CamelFolder * -groupwise_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) +groupwise_store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelFolder *folder; - folder = camel_store_get_folder(store, "Trash", 0, cancellable, error); + folder = camel_store_get_folder_sync ( + store, "Trash", 0, cancellable, error); if (folder) { CamelObject *object = CAMEL_OBJECT (folder); gchar *state = g_build_filename((CAMEL_GROUPWISE_STORE(store))->priv->storage_path, "folders", "Trash", "cmeta", NULL); @@ -1466,8 +1466,8 @@ camel_groupwise_store_connected (CamelGroupwiseStore *store, GCancellable *cancellable, GError **error) { - if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL - && camel_service_connect ((CamelService *)store, error)) { + if (camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)) + && camel_service_connect_sync ((CamelService *)store, error)) { CamelGroupwiseStore *gw_store = (CamelGroupwiseStore *) store; CamelGroupwiseStorePrivate *priv = gw_store->priv; @@ -1572,22 +1572,22 @@ camel_groupwise_store_class_init (CamelGroupwiseStoreClass *class) service_class = CAMEL_SERVICE_CLASS (class); service_class->construct = groupwise_store_construct; - service_class->query_auth_types = groupwise_store_query_auth_types; service_class->get_name = groupwise_get_name; - service_class->connect = groupwise_connect; - service_class->disconnect = groupwise_disconnect; + service_class->connect_sync = groupwise_connect_sync; + service_class->disconnect_sync = groupwise_disconnect_sync; + service_class->query_auth_types_sync = groupwise_store_query_auth_types_sync; store_class = CAMEL_STORE_CLASS (class); store_class->hash_folder_name = groupwise_hash_folder_name; store_class->compare_folder_name = groupwise_compare_folder_name; - store_class->get_folder = groupwise_get_folder; - store_class->create_folder = groupwise_create_folder; - store_class->delete_folder = groupwise_delete_folder; - store_class->rename_folder = groupwise_rename_folder; - store_class->get_folder_info = groupwise_get_folder_info; - store_class->free_folder_info = camel_store_free_folder_info_full; - store_class->get_trash = groupwise_get_trash; store_class->can_refresh_folder = groupwise_can_refresh_folder; + store_class->free_folder_info = camel_store_free_folder_info_full; + store_class->get_folder_sync = groupwise_store_get_folder_sync; + store_class->get_folder_info_sync = groupwise_store_get_folder_info_sync; + store_class->get_trash_folder_sync = groupwise_store_get_trash_folder_sync; + store_class->create_folder_sync = groupwise_store_create_folder_sync; + store_class->delete_folder_sync = groupwise_store_delete_folder_sync; + store_class->rename_folder_sync = groupwise_store_rename_folder_sync; } static void diff --git a/camel/providers/groupwise/camel-groupwise-transport.c b/camel/providers/groupwise/camel-groupwise-transport.c index 99e621a..12caf78 100644 --- a/camel/providers/groupwise/camel-groupwise-transport.c +++ b/camel/providers/groupwise/camel-groupwise-transport.c @@ -38,14 +38,6 @@ G_DEFINE_TYPE (CamelGroupwiseTransport, camel_groupwise_transport, CAMEL_TYPE_TRANSPORT) -static gboolean -groupwise_transport_connect (CamelService *service, - GCancellable *cancellable, - GError **error) -{ - return TRUE; -} - static gchar * groupwise_transport_get_name (CamelService *service, gboolean brief) @@ -61,12 +53,20 @@ groupwise_transport_get_name (CamelService *service, } static gboolean -groupwise_send_to (CamelTransport *transport, - CamelMimeMessage *message, - CamelAddress *from, - CamelAddress *recipients, - GCancellable *cancellable, - GError **error) +groupwise_transport_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) +{ + return TRUE; +} + +static gboolean +groupwise_send_to_sync (CamelTransport *transport, + CamelMimeMessage *message, + CamelAddress *from, + CamelAddress *recipients, + GCancellable *cancellable, + GError **error) { CamelService *service; CamelStore *store = NULL; @@ -181,11 +181,11 @@ camel_groupwise_transport_class_init (CamelGroupwiseTransportClass *class) CamelTransportClass *transport_class; service_class = CAMEL_SERVICE_CLASS (class); - service_class->connect = groupwise_transport_connect; service_class->get_name = groupwise_transport_get_name; + service_class->connect_sync = groupwise_transport_connect_sync; transport_class = CAMEL_TRANSPORT_CLASS (class); - transport_class->send_to = groupwise_send_to; + transport_class->send_to_sync = groupwise_send_to_sync; } static void diff --git a/camel/providers/groupwise/camel-groupwise-utils.c b/camel/providers/groupwise/camel-groupwise-utils.c index c6bf0f6..f40129b 100644 --- a/camel/providers/groupwise/camel-groupwise-utils.c +++ b/camel/providers/groupwise/camel-groupwise-utils.c @@ -464,14 +464,14 @@ camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *me filtered_stream = g_object_ref (content); } - camel_data_wrapper_decode_to_stream (dw, filtered_stream, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync (dw, filtered_stream, NULL, NULL); camel_stream_flush (filtered_stream, NULL, NULL); g_object_unref (filtered_stream); camel_stream_write (content, "", 1, NULL, NULL); e_gw_item_set_message (item, (const gchar *)byte_array->data); } else { - camel_data_wrapper_decode_to_stream (dw, content, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync (dw, content, NULL, NULL); send_as_attachment (cnc, item, content, type, dw, NULL, NULL, &attach_list); } @@ -668,7 +668,7 @@ do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **at if (temp_part) { is_alternative = TRUE; temp_dw = camel_medium_get_content (CAMEL_MEDIUM (temp_part)); - camel_data_wrapper_write_to_stream (temp_dw, temp_content, NULL, NULL); + camel_data_wrapper_write_to_stream_sync (temp_dw, temp_content, NULL, NULL); filename = camel_mime_part_get_filename (temp_part); disposition = camel_mime_part_get_disposition (temp_part); cid = camel_mime_part_get_content_id (temp_part); @@ -699,7 +699,7 @@ do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **at filtered_stream = g_object_ref (content); } - camel_data_wrapper_decode_to_stream (dw, filtered_stream, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync (dw, filtered_stream, NULL, NULL); camel_stream_flush (filtered_stream, NULL, NULL); g_object_unref (filtered_stream); @@ -710,7 +710,7 @@ do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **at disposition = camel_mime_part_get_disposition (part); content_id = camel_mime_part_get_content_id (part); - camel_data_wrapper_decode_to_stream (dw, content, NULL, NULL); + camel_data_wrapper_decode_to_stream_sync (dw, content, NULL, NULL); send_as_attachment (cnc, item, content, type, dw, filename, content_id, attach_list); } diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index da91e7b..294f70f 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -259,7 +259,9 @@ imap_command_start (CamelImapStore *store, g_io_error_from_errno (errno), "%s", g_strerror (errno)); - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + camel_service_disconnect_sync ( + CAMEL_SERVICE (store), FALSE, NULL); + return FALSE; } @@ -310,8 +312,11 @@ camel_imap_command_continuation (CamelImapStore *store, if (camel_stream_write (store->ostream, cmd, cmdlen, cancellable, error) == -1 || camel_stream_write (store->ostream, "\r\n", 2, cancellable, error) == -1) { - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); - camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); + camel_service_disconnect_sync ( + CAMEL_SERVICE (store), FALSE, NULL); + camel_service_unlock ( + CAMEL_SERVICE (store), + CAMEL_SERVICE_REC_CONNECT_LOCK); return NULL; } @@ -360,7 +365,8 @@ camel_imap_command_response (CamelImapStore *store, err = g_strerror (104); /* Connection was lost, no more data to fetch */ - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + camel_service_disconnect_sync ( + CAMEL_SERVICE (store), FALSE, NULL); g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -538,7 +544,7 @@ imap_read_untagged (CamelImapStore *store, length - nread, cancellable, error); if (n == -1) { - camel_service_disconnect ( + camel_service_disconnect_sync ( CAMEL_SERVICE (store), FALSE, NULL); g_string_free (str, TRUE); goto lose; @@ -552,7 +558,8 @@ imap_read_untagged (CamelImapStore *store, error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, _("Server response ended too soon.")); - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + camel_service_disconnect_sync ( + CAMEL_SERVICE (store), FALSE, NULL); g_string_free (str, TRUE); goto lose; } diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index d1b1ca2..0f073a3 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -72,21 +72,21 @@ enum { extern gint camel_application_is_exiting; static gboolean imap_rescan (CamelFolder *folder, gint exists, GCancellable *cancellable, GError **error); -static gboolean imap_refresh_info (CamelFolder *folder, GCancellable *cancellable, GError **error); +static gboolean imap_refresh_info_sync (CamelFolder *folder, GCancellable *cancellable, GError **error); static gboolean imap_sync_offline (CamelFolder *folder, GError **error); -static gboolean imap_sync (CamelFolder *folder, gboolean expunge, GCancellable *cancellable, GError **error); +static gboolean imap_synchronize_sync (CamelFolder *folder, gboolean expunge, GCancellable *cancellable, GError **error); static gboolean imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, GCancellable *cancellable, GError **error); static gboolean imap_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, GCancellable *cancellable, GError **error); -static gboolean imap_expunge (CamelFolder *folder, GCancellable *cancellable, GError **error); +static gboolean imap_expunge_sync (CamelFolder *folder, GCancellable *cancellable, GError **error); /*static void imap_cache_message (CamelDiscoFolder *disco_folder, const gchar *uid, GError **error);*/ static void imap_rename (CamelFolder *folder, const gchar *new); static GPtrArray * imap_get_uncached_uids (CamelFolder *folder, GPtrArray * uids, GError **error); static gchar * imap_get_filename (CamelFolder *folder, const gchar *uid, GError **error); /* message manipulation */ -static CamelMimeMessage *imap_get_message (CamelFolder *folder, const gchar *uid, GCancellable *cancellable, +static CamelMimeMessage *imap_get_message_sync (CamelFolder *folder, const gchar *uid, GCancellable *cancellable, GError **error); -static gboolean imap_sync_message (CamelFolder *folder, const gchar *uid, GCancellable *cancellable, +static gboolean imap_synchronize_message_sync (CamelFolder *folder, const gchar *uid, GCancellable *cancellable, GError **error); static gboolean imap_append_online (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, @@ -258,7 +258,6 @@ camel_imap_folder_class_init (CamelImapFolderClass *class) object_class->constructed = imap_folder_constructed; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->get_message = imap_get_message; folder_class->rename = imap_rename; folder_class->search_by_expression = imap_search_by_expression; folder_class->count_by_expression = imap_count_by_expression; @@ -266,14 +265,15 @@ camel_imap_folder_class_init (CamelImapFolderClass *class) folder_class->search_free = imap_search_free; folder_class->thaw = imap_thaw; folder_class->get_quota_info = imap_get_quota_info; - folder_class->refresh_info = imap_refresh_info; - folder_class->expunge = imap_expunge; - folder_class->sync = imap_sync; - folder_class->append_message = imap_append_online; - folder_class->sync_message = imap_sync_message; - folder_class->transfer_messages_to = imap_transfer_online; folder_class->get_uncached_uids = imap_get_uncached_uids; folder_class->get_filename = imap_get_filename; + folder_class->append_message_sync = imap_append_online; + folder_class->expunge_sync = imap_expunge_sync; + folder_class->get_message_sync = imap_get_message_sync; + folder_class->refresh_info_sync = imap_refresh_info_sync; + folder_class->synchronize_sync = imap_synchronize_sync; + folder_class->synchronize_message_sync = imap_synchronize_message_sync; + folder_class->transfer_messages_to_sync = imap_transfer_online; g_object_class_install_property ( object_class, @@ -326,7 +326,7 @@ replay_offline_journal (CamelImapStore *imap_store, g_return_if_fail (imap_journal != NULL); /* do not replay when still in offline */ - if (CAMEL_OFFLINE_STORE (imap_store)->state != CAMEL_OFFLINE_STORE_NETWORK_AVAIL || !camel_imap_store_connected (imap_store, error)) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (imap_store)) || !camel_imap_store_connected (imap_store, error)) return; /* Check if the replay is already in progress as imap_sync would be called while expunge resync */ @@ -734,9 +734,9 @@ get_folder_status (CamelFolder *folder, } static gboolean -imap_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) +imap_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelImapStore *imap_store; @@ -750,7 +750,7 @@ imap_refresh_info (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); imap_store = CAMEL_IMAP_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (imap_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (imap_store))) return TRUE; if (camel_folder_is_frozen (folder)) { @@ -1495,10 +1495,10 @@ move_messages (CamelFolder *src_folder, } static gboolean -imap_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) +imap_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelImapStore *store; @@ -1516,9 +1516,9 @@ imap_sync (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); store = CAMEL_IMAP_STORE (parent_store); - if (folder->permanent_flags == 0 || CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (folder->permanent_flags == 0 || !camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { if (expunge) { - if (!imap_expunge (folder, cancellable, error)) + if (!imap_expunge_sync (folder, cancellable, error)) return FALSE; } return imap_sync_offline (folder, error); @@ -1544,7 +1544,7 @@ imap_sync (CamelFolder *folder, real_trash = folder; g_object_ref (real_trash); } else { - real_trash = camel_store_get_trash ( + real_trash = camel_store_get_trash_folder_sync ( parent_store, cancellable, NULL); if (!store->real_trash_path && real_trash) { @@ -1564,7 +1564,7 @@ imap_sync (CamelFolder *folder, /* syncing the junk, but cannot move messages to itself, thus do nothing */ real_junk = NULL; } else { - real_junk = camel_store_get_junk ( + real_junk = camel_store_get_junk_folder_sync ( parent_store, cancellable, NULL); if (!store->real_junk_path && real_junk) { @@ -1736,7 +1736,7 @@ imap_sync (CamelFolder *folder, g_object_unref (real_junk); if (expunge && local_error == NULL) - imap_expunge (folder, cancellable, &local_error); + imap_expunge_sync (folder, cancellable, &local_error); if (local_error != NULL) g_propagate_error (error, local_error); @@ -1835,8 +1835,11 @@ imap_expunge_uids_online (CamelFolder *folder, camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); if ((store->capabilities & IMAP_CAPABILITY_UIDPLUS) == 0) { - if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, cancellable, error)) { - camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); + if (!CAMEL_FOLDER_GET_CLASS (folder)->synchronize_sync ( + folder, 0, cancellable, error)) { + camel_service_unlock ( + CAMEL_SERVICE (store), + CAMEL_SERVICE_REC_CONNECT_LOCK); return FALSE; } } @@ -1906,9 +1909,9 @@ imap_expunge_uids_online (CamelFolder *folder, } static gboolean -imap_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error) +imap_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; GPtrArray *uids = NULL; @@ -1924,7 +1927,7 @@ imap_expunge (CamelFolder *folder, CamelFolder *trash; GError *local_error = NULL; - trash = camel_store_get_trash ( + trash = camel_store_get_trash_folder_sync ( parent_store, cancellable, &local_error); if (local_error == NULL && trash && (folder == trash || g_ascii_strcasecmp (full_name, camel_folder_get_full_name (trash)) == 0)) { @@ -1942,7 +1945,7 @@ imap_expunge (CamelFolder *folder, if (!uids) return TRUE; - if (CAMEL_OFFLINE_STORE (parent_store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) + if (camel_offline_store_get_online (CAMEL_OFFLINE_STORE (parent_store))) success = imap_expunge_uids_online ( folder, uids, cancellable, error); else @@ -1986,8 +1989,11 @@ camel_imap_expunge_uids_resyncing (CamelFolder *folder, camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); - if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, cancellable, error)) { - camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); + if (!CAMEL_FOLDER_GET_CLASS (folder)->synchronize_sync ( + folder, 0, cancellable, error)) { + camel_service_unlock ( + CAMEL_SERVICE (store), + CAMEL_SERVICE_REC_CONNECT_LOCK); return FALSE; } @@ -2141,7 +2147,7 @@ camel_imap_expunge_uids_only (CamelFolder *folder, g_return_val_if_fail (uids != NULL, FALSE); - if (CAMEL_OFFLINE_STORE (parent_store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) + if (camel_offline_store_get_online (CAMEL_OFFLINE_STORE (parent_store))) return camel_imap_expunge_uids_resyncing ( folder, uids, cancellable, error); else @@ -2259,7 +2265,7 @@ do_append (CamelFolder *folder, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); camel_stream_filter_add ( CAMEL_STREAM_FILTER (streamfilter), crlf_filter); - camel_data_wrapper_write_to_stream ( + camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (message), streamfilter, cancellable, NULL); g_object_unref (streamfilter); g_object_unref (crlf_filter); @@ -2350,7 +2356,7 @@ imap_append_online (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); store = CAMEL_IMAP_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { return imap_append_offline ( folder, message, info, appended_uid, error); } @@ -2382,7 +2388,7 @@ imap_append_online (CamelFolder *folder, camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); if (store->current_folder != folder || camel_folder_summary_count (folder->summary) == count) - success = imap_refresh_info (folder, cancellable, error); + success = imap_refresh_info_sync (folder, cancellable, error); camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); return success; @@ -2477,7 +2483,7 @@ imap_transfer_offline (CamelFolder *source, mi = camel_folder_summary_uid (source->summary, uid); g_return_val_if_fail (mi != NULL, FALSE); - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( source, uid, cancellable, NULL); if (message) { @@ -2611,7 +2617,7 @@ handle_copyuid_copy_user_tags (CamelImapResponse *response, /* refresh folder's summary first, we copied messages there on the server, but do not know about it in a local summary */ - if (!imap_refresh_info (destination, cancellable, NULL)) + if (!imap_refresh_info_sync (destination, cancellable, NULL)) goto lose; src = imap_uid_set_to_array (source->summary, srcset); @@ -2766,13 +2772,14 @@ imap_transfer_messages (CamelFolder *source, parent_store = camel_folder_get_parent_store (source); store = CAMEL_IMAP_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) return imap_transfer_offline ( source, uids, dest, transferred_uids, delete_originals, cancellable, error); /* Sync message flags if needed. */ - if (can_call_sync && !imap_sync (source, FALSE, cancellable, error)) + if (can_call_sync && !imap_synchronize_sync ( + source, FALSE, cancellable, error)) return FALSE; count = camel_folder_summary_count (dest->summary); @@ -2786,7 +2793,7 @@ imap_transfer_messages (CamelFolder *source, /* Make the destination notice its new messages */ if (store->current_folder != dest || camel_folder_summary_count (dest->summary) == count) - success = imap_refresh_info (dest, cancellable, error); + success = imap_refresh_info_sync (dest, cancellable, error); /* FIXME */ if (transferred_uids) @@ -2864,7 +2871,7 @@ camel_imap_transfer_resyncing (CamelFolder *source, !isdigit (*(guchar *)(uids->pdata[i])) && local_error == NULL) { uid = uids->pdata[i]; - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( source, uid, cancellable, NULL); if (!message) { /* Message must have been expunged */ @@ -3109,7 +3116,7 @@ get_content (CamelImapFolder *imap_folder, stream = camel_imap_folder_fetch_data (imap_folder, uid, spec, FALSE, cancellable, error); if (stream) { - ret = camel_data_wrapper_construct_from_stream ( + ret = camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (body_mp), stream, cancellable, error); g_object_unref (CAMEL_OBJECT (stream)); if (ret == -1) { @@ -3150,7 +3157,8 @@ get_content (CamelImapFolder *imap_folder, gint ret; part = camel_mime_part_new (); - ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream, cancellable, error); + ret = camel_data_wrapper_construct_from_stream_sync ( + CAMEL_DATA_WRAPPER (part), stream, cancellable, error); g_object_unref (CAMEL_OBJECT (stream)); if (ret == -1) { g_object_unref (CAMEL_OBJECT (part)); @@ -3254,7 +3262,7 @@ get_message (CamelImapFolder *imap_folder, return NULL; msg = camel_mime_message_new (); - ret = camel_data_wrapper_construct_from_stream ( + ret = camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (msg), stream, cancellable, error); g_object_unref (CAMEL_OBJECT (stream)); if (ret == -1) { @@ -3304,7 +3312,7 @@ get_message_simple (CamelImapFolder *imap_folder, } msg = camel_mime_message_new (); - ret = camel_data_wrapper_construct_from_stream ( + ret = camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (msg), stream, cancellable, error); g_object_unref (CAMEL_OBJECT (stream)); if (ret == -1) { @@ -3350,10 +3358,10 @@ imap_folder_summary_uid_or_error (CamelFolderSummary *summary, const gchar * uid } static CamelMimeMessage * -imap_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +imap_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); @@ -3532,16 +3540,16 @@ fail: } /** - * imap_sync_message + * imap_synchronize_message_sync * * Ensure that a message is cached locally, but don't retrieve the content if * it is already local. */ static gboolean -imap_sync_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +imap_synchronize_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); CamelImapMessageInfo *mi; @@ -3568,7 +3576,7 @@ imap_sync_message (CamelFolder *folder, g_object_unref (stream); return TRUE; } - msg = imap_get_message (folder, uid, cancellable, error); + msg = imap_get_message_sync (folder, uid, cancellable, error); if (msg != NULL) { g_object_unref (msg); success = TRUE; @@ -3722,7 +3730,7 @@ add_message_from_data (CamelFolder *folder, g_ptr_array_set_size (messages, seq - first + 1); msg = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ( + if (camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (msg), stream, cancellable, NULL) == -1) { g_object_unref (CAMEL_OBJECT (msg)); return; @@ -4258,12 +4266,12 @@ imap_thaw (CamelFolder *folder) if (camel_folder_is_frozen (folder)) return; - /* FIXME imap_refresh_info() may block, but camel_folder_thaw() + /* FIXME imap_refresh_info_sync() may block, but camel_folder_thaw() * is not supposed to block. Potential hang here. */ imap_folder = CAMEL_IMAP_FOLDER (folder); if (imap_folder->need_refresh) { imap_folder->need_refresh = FALSE; - imap_refresh_info (folder, NULL, NULL); + imap_refresh_info_sync (folder, NULL, NULL); } } @@ -4525,7 +4533,7 @@ imap_get_quota_info (CamelFolder *folder) parent_store = camel_folder_get_parent_store (folder); imap_store = CAMEL_IMAP_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (imap_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (imap_store))) return NULL; camel_service_lock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK); diff --git a/camel/providers/imap/camel-imap-journal.c b/camel/providers/imap/camel-imap-journal.c index f0dac00..cd6f74f 100644 --- a/camel/providers/imap/camel-imap-journal.c +++ b/camel/providers/imap/camel-imap-journal.c @@ -292,7 +292,7 @@ journal_decode_folder (CamelIMAPJournal *journal, parent_store = camel_folder_get_parent_store ( CAMEL_OFFLINE_JOURNAL (journal)->folder); - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( parent_store, name, 0, cancellable, &local_error); if (folder) g_hash_table_insert (journal->folders, (gchar *) name, folder); @@ -332,7 +332,7 @@ imap_entry_play (CamelOfflineJournal *journal, CamelMimeMessage *message; CamelMessageInfo *info; - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( journal->folder, imap_entry->append_uid, cancellable, error); if (!message) { @@ -458,7 +458,7 @@ close_folder (gchar *name, CamelFolder *folder) { g_free (name); - camel_folder_sync (folder, FALSE, NULL, NULL); + camel_folder_synchronize_sync (folder, FALSE, NULL, NULL); g_object_unref (folder); } diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c index 158064d..6aa09fc 100644 --- a/camel/providers/imap/camel-imap-message-cache.c +++ b/camel/providers/imap/camel-imap-message-cache.c @@ -447,7 +447,8 @@ camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache, if (!stream) return; - if (camel_data_wrapper_write_to_stream (wrapper, stream, NULL, NULL) == -1) { + if (camel_data_wrapper_write_to_stream_sync ( + wrapper, stream, NULL, NULL) == -1) { insert_abort (path, stream); } else { insert_finish (cache, uid, path, key, stream); diff --git a/camel/providers/imap/camel-imap-search.c b/camel/providers/imap/camel-imap-search.c index 1d9a9d5..6c5d252 100644 --- a/camel/providers/imap/camel-imap-search.c +++ b/camel/providers/imap/camel-imap-search.c @@ -444,7 +444,7 @@ imap_body_contains (struct _ESExp *f, gint argc, struct _ESExpResult **argv, Cam /* TODO: Cache offline searches too? */ /* If offline, search using the parent class, which can handle this manually */ - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) return CAMEL_FOLDER_SEARCH_CLASS (camel_imap_search_parent_class)->body_contains (f, argc, argv, s); /* optimise the match "" case - match everything */ diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index e852154..88dd65f 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -66,20 +66,18 @@ extern gint camel_verbose_debug; static gchar imap_tag_prefix = 'A'; -static gboolean imap_noop (CamelStore *store, GCancellable *cancellable, GError **error); -static CamelFolder *imap_get_junk(CamelStore *store, GCancellable *cancellable, GError **error); -static CamelFolder *imap_get_trash(CamelStore *store, GCancellable *cancellable, GError **error); +static gboolean imap_store_noop_sync (CamelStore *store, GCancellable *cancellable, GError **error); +static CamelFolder *imap_store_get_junk_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error); +static CamelFolder *imap_store_get_trash_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error); static guint hash_folder_name (gconstpointer key); static gint compare_folder_name (gconstpointer a, gconstpointer b); -static CamelFolderInfo *create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GCancellable *cancellable, GError **error); -static gboolean delete_folder (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); -static gboolean rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, GCancellable *cancellable, GError **error); +static CamelFolderInfo *imap_store_create_folder_sync (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GCancellable *cancellable, GError **error); +static gboolean imap_store_delete_folder_sync (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); +static gboolean imap_store_rename_folder_sync (CamelStore *store, const gchar *old_name, const gchar *new_name, GCancellable *cancellable, GError **error); static gboolean folder_is_subscribed (CamelStore *store, const gchar *folder_name); -static gboolean subscribe_folder (CamelStore *store, const gchar *folder_name, - GCancellable *cancellable, GError **error); -static gboolean unsubscribe_folder (CamelStore *store, const gchar *folder_name, - GCancellable *cancellable, GError **error); +static gboolean imap_store_subscribe_folder_sync (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); +static gboolean imap_store_unsubscribe_folder_sync (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); static gboolean get_folders_sync (CamelImapStore *imap_store, const gchar *pattern, GCancellable *cancellable, GError **error); @@ -89,8 +87,8 @@ static void imap_forget_folder (CamelImapStore *imap_store, const gchar *folder_ static void imap_set_server_level (CamelImapStore *store); static gboolean imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error); -static CamelFolder * get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); -static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); +static CamelFolder * imap_store_get_folder_sync (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); +static CamelFolderInfo * imap_store_get_folder_info_sync (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); static CamelFolder * get_folder_offline (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error); static CamelFolderInfo * get_folder_info_offline (CamelStore *store, const gchar *top, guint32 flags, GError **error); @@ -674,7 +672,7 @@ try_auth (CamelImapStore *store, if (!resp) goto lose; - sasl_resp = camel_sasl_challenge_base64 ( + sasl_resp = camel_sasl_challenge_base64_sync ( sasl, imap_next_word (resp), cancellable, error); g_free (resp); if (!sasl_resp) @@ -873,7 +871,7 @@ imap_store_finalize (GObject *object) CamelImapStore *imap_store = CAMEL_IMAP_STORE (object); /* This frees current_folder, folders, authtypes, streams, and namespace. */ - camel_service_disconnect (CAMEL_SERVICE (imap_store), TRUE, NULL); + camel_service_disconnect_sync (CAMEL_SERVICE (imap_store), TRUE, NULL); g_free (imap_store->base_url); g_free (imap_store->storage_path); @@ -990,47 +988,6 @@ imap_store_construct (CamelService *service, return TRUE; } -static GList * -imap_store_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) -{ - CamelImapStore *store = CAMEL_IMAP_STORE (service); - CamelServiceAuthType *authtype; - GList *sasl_types, *t, *next; - gboolean connected; - - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("You must be working online to complete this operation")); - return NULL; - } - - camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); - connected = store->istream != NULL && store->connected; - if (!connected) - connected = connect_to_server_wrapper ( - service, cancellable, error); - camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); - if (!connected) - return NULL; - - sasl_types = camel_sasl_authtype_list (FALSE); - for (t = sasl_types; t; t = next) { - authtype = t->data; - next = t->next; - - if (!g_hash_table_lookup (store->authtypes, authtype->authproto)) { - sasl_types = g_list_remove_link (sasl_types, t); - g_list_free_1 (t); - } - } - - return g_list_prepend (sasl_types, &camel_imap_password_authtype); -} - static gchar * imap_store_get_name (CamelService *service, gboolean brief) @@ -1046,9 +1003,9 @@ imap_store_get_name (CamelService *service, } static gboolean -imap_store_connect (CamelService *service, - GCancellable *cancellable, - GError **error) +imap_store_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelImapStore *store = CAMEL_IMAP_STORE (service); CamelImapResponse *response; @@ -1056,14 +1013,14 @@ imap_store_connect (CamelService *service, gsize len; GError *local_error = NULL; - if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) return TRUE; camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); if (!connect_to_server_wrapper (service, cancellable, error) || !imap_auth_loop (service, cancellable, error)) { camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync (service, TRUE, NULL); return FALSE; } @@ -1220,7 +1177,7 @@ done: camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); if (local_error != NULL) { - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync (service, TRUE, NULL); g_propagate_error (error, local_error); return FALSE; } @@ -1229,14 +1186,14 @@ done: } static gboolean -imap_store_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) +imap_store_disconnect_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) { CamelImapStore *store = CAMEL_IMAP_STORE (service); - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL && clean) { + if (camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)) && clean) { CamelImapResponse *response; response = camel_imap_command (store, NULL, NULL, NULL, "LOGOUT"); @@ -1276,6 +1233,47 @@ imap_store_disconnect (CamelService *service, return TRUE; } +static GList * +imap_store_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) +{ + CamelImapStore *store = CAMEL_IMAP_STORE (service); + CamelServiceAuthType *authtype; + GList *sasl_types, *t, *next; + gboolean connected; + + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("You must be working online to complete this operation")); + return NULL; + } + + camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); + connected = store->istream != NULL && store->connected; + if (!connected) + connected = connect_to_server_wrapper ( + service, cancellable, error); + camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); + if (!connected) + return NULL; + + sasl_types = camel_sasl_authtype_list (FALSE); + for (t = sasl_types; t; t = next) { + authtype = t->data; + next = t->next; + + if (!g_hash_table_lookup (store->authtypes, authtype->authproto)) { + sasl_types = g_list_remove_link (sasl_types, t); + g_list_free_1 (t); + } + } + + return g_list_prepend (sasl_types, &camel_imap_password_authtype); +} + static void camel_imap_store_class_init (CamelImapStoreClass *class) { @@ -1289,27 +1287,27 @@ camel_imap_store_class_init (CamelImapStoreClass *class) service_class = CAMEL_SERVICE_CLASS (class); service_class->construct = imap_store_construct; - service_class->query_auth_types = imap_store_query_auth_types; service_class->get_name = imap_store_get_name; - service_class->connect = imap_store_connect; - service_class->disconnect = imap_store_disconnect; + service_class->connect_sync = imap_store_connect_sync; + service_class->disconnect_sync = imap_store_disconnect_sync; + service_class->query_auth_types_sync = imap_store_query_auth_types_sync; store_class = CAMEL_STORE_CLASS (class); store_class->hash_folder_name = hash_folder_name; store_class->compare_folder_name = compare_folder_name; - store_class->get_folder = get_folder; - store_class->create_folder = create_folder; - store_class->delete_folder = delete_folder; - store_class->rename_folder = rename_folder; - store_class->get_folder_info = get_folder_info; - store_class->free_folder_info = camel_store_free_folder_info_full; - store_class->folder_is_subscribed = folder_is_subscribed; - store_class->subscribe_folder = subscribe_folder; - store_class->unsubscribe_folder = unsubscribe_folder; - store_class->noop = imap_noop; - store_class->get_trash = imap_get_trash; - store_class->get_junk = imap_get_junk; store_class->can_refresh_folder = imap_can_refresh_folder; + store_class->folder_is_subscribed = folder_is_subscribed; + store_class->free_folder_info = camel_store_free_folder_info_full; + store_class->get_folder_sync = imap_store_get_folder_sync; + store_class->get_folder_info_sync = imap_store_get_folder_info_sync; + store_class->get_junk_folder_sync = imap_store_get_junk_folder_sync; + store_class->get_trash_folder_sync = imap_store_get_trash_folder_sync; + store_class->create_folder_sync = imap_store_create_folder_sync; + store_class->delete_folder_sync = imap_store_delete_folder_sync; + store_class->rename_folder_sync = imap_store_rename_folder_sync; + store_class->subscribe_folder_sync = imap_store_subscribe_folder_sync; + store_class->unsubscribe_folder_sync = imap_store_unsubscribe_folder_sync; + store_class->noop_sync = imap_store_noop_sync; } static void @@ -1509,9 +1507,9 @@ imap_summary_is_dirty (CamelFolderSummary *summary) } static gboolean -imap_noop (CamelStore *store, - GCancellable *cancellable, - GError **error) +imap_store_noop_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = (CamelImapStore *) store; CamelImapResponse *response; @@ -1528,7 +1526,7 @@ imap_noop (CamelStore *store, current_folder = imap_store->current_folder; if (current_folder && imap_summary_is_dirty (current_folder->summary)) { /* let's sync the flags instead. NB: must avoid folder lock */ - success = CAMEL_FOLDER_GET_CLASS (current_folder)->sync ( + success = CAMEL_FOLDER_GET_CLASS (current_folder)->synchronize_sync ( current_folder, FALSE, cancellable, error); } else { response = camel_imap_command (imap_store, NULL, cancellable, error, "NOOP"); @@ -1544,15 +1542,15 @@ done: } static CamelFolder * -imap_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) +imap_store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelFolder *folder = NULL; CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); if (imap_store->real_trash_path && *imap_store->real_trash_path) { - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( store, imap_store->real_trash_path, 0, cancellable, NULL); if (!folder) { @@ -1566,7 +1564,7 @@ imap_get_trash (CamelStore *store, return folder; folder = CAMEL_STORE_CLASS (camel_imap_store_parent_class)-> - get_trash (store, cancellable, error); + get_trash_folder_sync (store, cancellable, error); if (folder) { CamelObject *object = CAMEL_OBJECT (folder); @@ -1582,15 +1580,15 @@ imap_get_trash (CamelStore *store, } static CamelFolder * -imap_get_junk (CamelStore *store, - GCancellable *cancellable, - GError **error) +imap_store_get_junk_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelFolder *folder = NULL; CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); if (imap_store->real_junk_path && *imap_store->real_junk_path) { - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( store, imap_store->real_junk_path, 0, cancellable, NULL); if (!folder) { @@ -1604,7 +1602,7 @@ imap_get_junk (CamelStore *store, return folder; folder = CAMEL_STORE_CLASS (camel_imap_store_parent_class)-> - get_junk (store, cancellable, error); + get_junk_folder_sync (store, cancellable, error); if (folder) { CamelObject *object = CAMEL_OBJECT (folder); @@ -1746,11 +1744,11 @@ get_folder_status (CamelImapStore *imap_store, const gchar *folder_name, const g } static CamelFolder * -get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) +imap_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelImapResponse *response; @@ -1766,7 +1764,7 @@ get_folder (CamelStore *store, g_clear_error (&local_error); - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -1893,7 +1891,7 @@ get_folder (CamelStore *store, } /* delete the old parent and recreate it */ - if (!delete_folder ( + if (!imap_store_delete_folder_sync ( store, parent_name, cancellable, error)) { camel_service_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK); g_free (parent_name); @@ -2011,10 +2009,10 @@ get_folder_offline (CamelStore *store, const gchar *folder_name, } static gboolean -delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +imap_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelImapResponse *response; @@ -2072,10 +2070,10 @@ manage_subscriptions (CamelStore *store, path = camel_store_info_path (imap_store->summary, si); if (strncmp (path, old_name, olen) == 0) { if (subscribe) - subscribe_folder ( + imap_store_subscribe_folder_sync ( store, path, cancellable, NULL); else - unsubscribe_folder ( + imap_store_unsubscribe_folder_sync ( store, path, cancellable, NULL); } camel_store_summary_info_free ((CamelStoreSummary *)imap_store->summary, si); @@ -2127,11 +2125,11 @@ rename_folder_info (CamelImapStore *imap_store, const gchar *old_name, const gch } static gboolean -rename_folder (CamelStore *store, - const gchar *old_name, - const gchar *new_name_in, - GCancellable *cancellable, - GError **error) +imap_store_rename_folder_sync (CamelStore *store, + const gchar *old_name, + const gchar *new_name_in, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelImapResponse *response; @@ -2225,11 +2223,11 @@ fail: } static CamelFolderInfo * -create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +imap_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); gchar *full_name, *resp, *thisone, *parent_real, *real_name; @@ -2239,7 +2237,7 @@ create_folder (CamelStore *store, gint i = 0, flags; const gchar *c; - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -2328,7 +2326,7 @@ create_folder (CamelStore *store, } /* delete the old parent and recreate it */ - if (!delete_folder (store, parent_name, cancellable, error)) + if (!imap_store_delete_folder_sync (store, parent_name, cancellable, error)) return NULL; /* add the dirsep to the end of parent_name */ @@ -2733,11 +2731,11 @@ static CamelSessionThreadOps refresh_ops = { }; static CamelFolderInfo * -get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +imap_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelFolderInfo *tree = NULL; @@ -2752,7 +2750,7 @@ get_folder_info (CamelStore *store, if (camel_debug("imap:folder_info")) printf("get folder info online\n"); - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { tree = get_folder_info_offline (store, top, flags, error); return tree; } @@ -2963,10 +2961,10 @@ folder_is_subscribed (CamelStore *store, /* Note: folder_name must match a folder as listed with get_folder_info() -> full_name */ static gboolean -subscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +imap_store_subscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelImapResponse *response; @@ -3019,10 +3017,10 @@ done: } static gboolean -unsubscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +imap_store_unsubscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelImapResponse *response; @@ -3085,8 +3083,8 @@ camel_imap_store_connected (CamelImapStore *store, GError **error) did connect anyway ... */ if (store->istream != NULL - || (((CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) - && camel_service_connect ((CamelService *)store, NULL) + || (((camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) + && camel_service_connect_sync ((CamelService *)store, NULL) && store->istream != NULL))) return TRUE; @@ -3141,7 +3139,8 @@ camel_imap_store_readline (CamelImapStore *store, g_prefix_error ( error, _("Server unexpectedly disconnected: ")); - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + camel_service_disconnect_sync ( + CAMEL_SERVICE (store), FALSE, NULL); g_byte_array_free (ba, TRUE); return -1; } diff --git a/camel/providers/imap/camel-imap-wrapper.c b/camel/providers/imap/camel-imap-wrapper.c index 099ac9b..f0218f2 100644 --- a/camel/providers/imap/camel-imap-wrapper.c +++ b/camel/providers/imap/camel-imap-wrapper.c @@ -90,10 +90,10 @@ imap_wrapper_finalize (GObject *object) } static gssize -imap_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *stream, - GCancellable *cancellable, - GError **error) +imap_wrapper_write_to_stream_sync (CamelDataWrapper *data_wrapper, + CamelStream *stream, + GCancellable *cancellable, + GError **error) { CamelImapWrapper *imap_wrapper = CAMEL_IMAP_WRAPPER (data_wrapper); @@ -126,7 +126,7 @@ imap_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock); return CAMEL_DATA_WRAPPER_CLASS (camel_imap_wrapper_parent_class)-> - write_to_stream (data_wrapper, stream, cancellable, error); + write_to_stream_sync (data_wrapper, stream, cancellable, error); } static void @@ -142,7 +142,7 @@ camel_imap_wrapper_class_init (CamelImapWrapperClass *class) object_class->finalize = imap_wrapper_finalize; data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class); - data_wrapper_class->write_to_stream = imap_wrapper_write_to_stream; + data_wrapper_class->write_to_stream_sync = imap_wrapper_write_to_stream_sync; } static void diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c index dcefdc9..bf5595a 100644 --- a/camel/providers/imapx/camel-imapx-folder.c +++ b/camel/providers/imapx/camel-imapx-folder.c @@ -146,10 +146,142 @@ imapx_folder_finalize (GObject *object) G_OBJECT_CLASS (camel_imapx_folder_parent_class)->finalize (object); } +gchar * +imapx_get_filename (CamelFolder *folder, const gchar *uid, GError **error) +{ + CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder; + + return camel_data_cache_get_filename (ifolder->cache, "cache", uid, error); +} + +/* Algorithm for selecting a folder: + + - If uidvalidity == old uidvalidity + and exsists == old exists + and recent == old recent + and unseen == old unseen + Assume our summary is correct + for each summary item + mark the summary item as 'old/not updated' + rof + fetch flags from 1:* + for each fetch response + info = summary[index] + if info.uid != uid + info = summary_by_uid[uid] + fi + if info == NULL + create new info @ index + fi + if got.flags + update flags + fi + if got.header + update based on header + mark as retrieved + else if got.body + update based on imap body + mark as retrieved + fi + + Async fetch response: + info = summary[index] + if info == null + if uid == null + force resync/select? + info = empty @ index + else if uid && info.uid != uid + force a resync? + return + fi + + if got.flags { + info.flags = flags + } + if got.header { + info.init (header) + info.empty = false + } + +info.state - 2 bit field in flags + 0 = empty, nothing set + 1 = uid & flags set + 2 = update required + 3 = up to date +*/ + +static void +imapx_search_free (CamelFolder *folder, GPtrArray *uids) +{ + CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); + + g_return_if_fail (ifolder->search); + + g_mutex_lock (ifolder->search_lock); + + camel_folder_search_free_result (ifolder->search, uids); + + g_mutex_unlock (ifolder->search_lock); +} + +static GPtrArray * +imapx_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error) +{ + CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); + GPtrArray *matches; + + if (uids->len == 0) + return g_ptr_array_new (); + + g_mutex_lock (ifolder->search_lock); + + camel_folder_search_set_folder (ifolder->search, folder); + matches = camel_folder_search_search (ifolder->search, expression, uids, error); + + g_mutex_unlock (ifolder->search_lock); + + return matches; +} + +static guint32 +imapx_count_by_expression (CamelFolder *folder, const gchar *expression, GError **error) +{ + CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); + guint32 matches; + + g_mutex_lock (ifolder->search_lock); + + camel_folder_search_set_folder (ifolder->search, folder); + matches = camel_folder_search_count (ifolder->search, expression, error); + + g_mutex_unlock (ifolder->search_lock); + + return matches; +} + +static GPtrArray * +imapx_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error) +{ + CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); + GPtrArray *matches; + + g_mutex_lock (ifolder->search_lock); + + camel_folder_search_set_folder (ifolder->search, folder); + matches = camel_folder_search_search (ifolder->search, expression, NULL, error); + + g_mutex_unlock (ifolder->search_lock); + + return matches; +} + static gboolean -imapx_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) +imapx_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelIMAPXStore *istore; @@ -159,7 +291,7 @@ imapx_refresh_info (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); istore = CAMEL_IMAPX_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -167,13 +299,13 @@ imapx_refresh_info (CamelFolder *folder, return FALSE; } - if (!camel_service_connect ((CamelService *)istore, error)) - return FALSE; + if (appended_uid) + *appended_uid = NULL; - server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (folder), cancellable, error); - if (server != NULL) { - success = camel_imapx_server_refresh_info (server, folder, cancellable, error); - camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (folder)); + server = camel_imapx_store_get_server (istore, NULL, cancellable, error); + if (server) { + success = camel_imapx_server_append_message ( + server, folder, message, info, cancellable, error); g_object_unref (server); } @@ -181,9 +313,9 @@ imapx_refresh_info (CamelFolder *folder, } static gboolean -imapx_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error) +imapx_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelIMAPXStore *istore; @@ -192,7 +324,7 @@ imapx_expunge (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); istore = CAMEL_IMAPX_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -211,50 +343,11 @@ imapx_expunge (CamelFolder *folder, return FALSE; } -static gboolean -imapx_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) -{ - CamelStore *parent_store; - CamelIMAPXStore *istore; - CamelIMAPXServer *server; - - parent_store = camel_folder_get_parent_store (folder); - istore = CAMEL_IMAPX_STORE (parent_store); - - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("You must be working online to complete this operation")); - return FALSE; - } - - server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (folder), cancellable, error); - if (!server) - return FALSE; - - camel_imapx_server_sync_changes (server, folder, cancellable NULL); - - /* Sync twice - make sure deleted flags are written out, - then sync again incase expunge changed anything */ - - if (expunge) - camel_imapx_server_expunge (server, folder, cancellable, NULL); - - camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (folder)); - g_object_unref (server); - - return TRUE; -} - static CamelMimeMessage * -imapx_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +imapx_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelMimeMessage *msg = NULL; CamelStream *stream = NULL; @@ -285,7 +378,7 @@ imapx_get_message (CamelFolder *folder, return NULL; } - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -306,7 +399,8 @@ imapx_get_message (CamelFolder *folder, msg = camel_mime_message_new (); g_mutex_lock (ifolder->stream_lock); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)msg, stream, cancellable, error) == -1) { + if (camel_data_wrapper_construct_from_stream_sync ( + (CamelDataWrapper *)msg, stream, cancellable, error) == -1) { g_object_unref (msg); msg = NULL; } @@ -318,20 +412,19 @@ imapx_get_message (CamelFolder *folder, } static gboolean -imapx_sync_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +imapx_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelIMAPXStore *istore; CamelIMAPXServer *server; - gboolean success; + gboolean success = FALSE; parent_store = camel_folder_get_parent_store (folder); istore = CAMEL_IMAPX_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -339,35 +432,33 @@ imapx_sync_message (CamelFolder *folder, return FALSE; } - server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (folder), cancellable, error); - if (server == NULL) + if (!camel_service_connect_sync ((CamelService *)istore, error)) return FALSE; - success = camel_imapx_server_sync_message (server, folder, uid, cancellable, error); - camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (folder)); - g_object_unref (server); + server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (folder), cancellable, error); + if (server != NULL) { + success = camel_imapx_server_refresh_info (server, folder, cancellable, error); + camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (folder)); + g_object_unref (server); + } return success; } static gboolean -imapx_transfer_messages_to (CamelFolder *source, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) +imapx_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelIMAPXStore *istore; CamelIMAPXServer *server; - gboolean success = FALSE; - parent_store = camel_folder_get_parent_store (source); + parent_store = camel_folder_get_parent_store (folder); istore = CAMEL_IMAPX_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -375,35 +466,39 @@ imapx_transfer_messages_to (CamelFolder *source, return FALSE; } - server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (source), cancellable, error); - if (server) { - success = camel_imapx_server_copy_message (server, source, dest, uids, delete_originals, cancellable, error); - camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (source)); - g_object_unref (server); - } + server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (folder), cancellable, error); + if (!server) + return FALSE; - imapx_refresh_info (dest, cancellable, NULL); + camel_imapx_server_sync_changes (server, folder, cancellable, NULL); - return success; + /* Sync twice - make sure deleted flags are written out, + then sync again incase expunge changed anything */ + + if (expunge) + camel_imapx_server_expunge (server, folder, cancellable, NULL); + + camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (folder)); + g_object_unref (server); + + return TRUE; } static gboolean -imapx_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +imapx_synchronize_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelIMAPXStore *istore; CamelIMAPXServer *server; - gboolean success = FALSE; + gboolean success; parent_store = camel_folder_get_parent_store (folder); istore = CAMEL_IMAPX_STORE (parent_store); - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, @@ -411,146 +506,52 @@ imapx_append_message (CamelFolder *folder, return FALSE; } - if (appended_uid) - *appended_uid = NULL; + server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (folder), cancellable, error); + if (server == NULL) + return FALSE; - server = camel_imapx_store_get_server (istore, NULL, cancellable, error); - if (server) { - success = camel_imapx_server_append_message ( - server, folder, message, info, cancellable, error); - g_object_unref (server); - } + success = camel_imapx_server_sync_message (server, folder, uid, cancellable, error); + camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (folder)); + g_object_unref (server); return success; } -gchar * -imapx_get_filename (CamelFolder *folder, const gchar *uid, GError **error) -{ - CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder; - - return camel_data_cache_get_filename (ifolder->cache, "cache", uid, error); -} - -/* Algorithm for selecting a folder: - - - If uidvalidity == old uidvalidity - and exsists == old exists - and recent == old recent - and unseen == old unseen - Assume our summary is correct - for each summary item - mark the summary item as 'old/not updated' - rof - fetch flags from 1:* - for each fetch response - info = summary[index] - if info.uid != uid - info = summary_by_uid[uid] - fi - if info == NULL - create new info @ index - fi - if got.flags - update flags - fi - if got.header - update based on header - mark as retrieved - else if got.body - update based on imap body - mark as retrieved - fi - - Async fetch response: - info = summary[index] - if info == null - if uid == null - force resync/select? - info = empty @ index - else if uid && info.uid != uid - force a resync? - return - fi - - if got.flags { - info.flags = flags - } - if got.header { - info.init (header) - info.empty = false - } - -info.state - 2 bit field in flags - 0 = empty, nothing set - 1 = uid & flags set - 2 = update required - 3 = up to date -*/ - -static void -imapx_search_free (CamelFolder *folder, GPtrArray *uids) -{ - CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); - - g_return_if_fail (ifolder->search); - - g_mutex_lock (ifolder->search_lock); - - camel_folder_search_free_result (ifolder->search, uids); - - g_mutex_unlock (ifolder->search_lock); -} - -static GPtrArray * -imapx_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error) -{ - CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); - GPtrArray *matches; - - if (uids->len == 0) - return g_ptr_array_new (); - - g_mutex_lock (ifolder->search_lock); - - camel_folder_search_set_folder (ifolder->search, folder); - matches = camel_folder_search_search (ifolder->search, expression, uids, error); - - g_mutex_unlock (ifolder->search_lock); - - return matches; -} - -static guint32 -imapx_count_by_expression (CamelFolder *folder, const gchar *expression, GError **error) +static gboolean +imapx_transfer_messages_to_sync (CamelFolder *source, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) { - CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); - guint32 matches; - - g_mutex_lock (ifolder->search_lock); - - camel_folder_search_set_folder (ifolder->search, folder); - matches = camel_folder_search_count (ifolder->search, expression, error); - - g_mutex_unlock (ifolder->search_lock); - - return matches; -} + CamelStore *parent_store; + CamelIMAPXStore *istore; + CamelIMAPXServer *server; + gboolean success = FALSE; -static GPtrArray * -imapx_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error) -{ - CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder); - GPtrArray *matches; + parent_store = camel_folder_get_parent_store (source); + istore = CAMEL_IMAPX_STORE (parent_store); - g_mutex_lock (ifolder->search_lock); + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("You must be working online to complete this operation")); + return FALSE; + } - camel_folder_search_set_folder (ifolder->search, folder); - matches = camel_folder_search_search (ifolder->search, expression, NULL, error); + server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (source), cancellable, error); + if (server) { + success = camel_imapx_server_copy_message (server, source, dest, uids, delete_originals, cancellable, error); + camel_imapx_store_op_done (istore, server, camel_folder_get_full_name (source)); + g_object_unref (server); + } - g_mutex_unlock (ifolder->search_lock); + imapx_refresh_info_sync (dest, cancellable, NULL); - return matches; + return success; } static void @@ -564,18 +565,18 @@ camel_imapx_folder_class_init (CamelIMAPXFolderClass *class) object_class->finalize = imapx_folder_finalize; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->refresh_info = imapx_refresh_info; - folder_class->sync = imapx_sync; folder_class->search_by_expression = imapx_search_by_expression; folder_class->search_by_uids = imapx_search_by_uids; folder_class->count_by_expression = imapx_count_by_expression; folder_class->search_free = imapx_search_free; - folder_class->expunge = imapx_expunge; - folder_class->get_message = imapx_get_message; - folder_class->sync_message = imapx_sync_message; - folder_class->append_message = imapx_append_message; - folder_class->transfer_messages_to = imapx_transfer_messages_to; folder_class->get_filename = imapx_get_filename; + folder_class->append_message_sync = imapx_append_message_sync; + folder_class->expunge_sync = imapx_expunge_sync; + folder_class->get_message_sync = imapx_get_message_sync; + folder_class->refresh_info_sync = imapx_refresh_info_sync; + folder_class->synchronize_sync = imapx_synchronize_sync; + folder_class->synchronize_message_sync = imapx_synchronize_message_sync; + folder_class->transfer_messages_to_sync = imapx_transfer_messages_to_sync; } static void diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c index 35dd739..f2bf917 100644 --- a/camel/providers/imapx/camel-imapx-server.c +++ b/camel/providers/imapx/camel-imapx-server.c @@ -460,7 +460,7 @@ imapx_command_add_part (CamelIMAPXCommand *ic, camel_imapx_command_part_t type, /* TODO: seekable streams we could just seek to the end and back */ null = (CamelStreamNull *)camel_stream_null_new (); if ( (type & CAMEL_IMAPX_COMMAND_MASK) == CAMEL_IMAPX_COMMAND_DATAWRAPPER) { - camel_data_wrapper_write_to_stream ((CamelDataWrapper *)ob, (CamelStream *)null, NULL, NULL); + camel_data_wrapper_write_to_stream_sync ((CamelDataWrapper *)ob, (CamelStream *)null, NULL, NULL); } else { camel_stream_reset ((CamelStream *)ob, NULL); camel_stream_write_to_stream ((CamelStream *)ob, (CamelStream *)null, NULL, NULL); @@ -1628,7 +1628,7 @@ imapx_untagged (CamelIMAPXServer *imap, path_name = camel_imapx_store_summary_full_to_path (s, sinfo->name, ns->sep); c(imap->tagprefix, "Got folder path '%s' for full '%s'\n", path_name, sinfo->name); if (path_name) { - ifolder = (gpointer)camel_store_get_folder (imap->store, path_name, 0, cancellable, error); + ifolder = (gpointer)camel_store_get_folder_sync (imap->store, path_name, 0, cancellable, error); g_free (path_name); } } @@ -1792,7 +1792,7 @@ imapx_continuation (CamelIMAPXServer *imap, switch (cp->type & CAMEL_IMAPX_COMMAND_MASK) { case CAMEL_IMAPX_COMMAND_DATAWRAPPER: c(imap->tagprefix, "writing data wrapper to literal\n"); - camel_data_wrapper_write_to_stream ((CamelDataWrapper *)cp->ob, (CamelStream *)imap->stream, cancellable, NULL); + camel_data_wrapper_write_to_stream_sync ((CamelDataWrapper *)cp->ob, (CamelStream *)imap->stream, cancellable, NULL); break; case CAMEL_IMAPX_COMMAND_STREAM: c(imap->tagprefix, "writing stream to literal\n"); @@ -1805,7 +1805,7 @@ imapx_continuation (CamelIMAPXServer *imap, if (camel_imapx_stream_text (imap->stream, &token, cancellable, error)) return -1; - resp = camel_sasl_challenge_base64 ( + resp = camel_sasl_challenge_base64_sync ( (CamelSasl *) cp->ob, (const gchar *) token, cancellable, error); g_free(token); @@ -2143,8 +2143,8 @@ imapx_command_idle_stop (CamelIMAPXServer *is, GError **error) "Unable to issue DONE"); c(is->tagprefix, "Failed to issue DONE to terminate IDLE\n"); is->state = IMAPX_SHUTDOWN; - if (is->op) - camel_operation_cancel(is->op); + if (is->cancellable) + camel_operation_cancel (CAMEL_OPERATION (is->cancellable)); is->parser_quit = TRUE; return FALSE; } @@ -4414,7 +4414,7 @@ imapx_job_delete_folder_start (CamelIMAPXServer *is, encoded_fname = imapx_encode_folder_name ((CamelIMAPXStore *) is->store, job->u.folder_name); - job->folder = camel_store_get_folder ( + job->folder = camel_store_get_folder_sync ( is->store, "INBOX", 0, job->cancellable, &job->error); /* make sure to-be-deleted folder is not selected by selecting INBOX for this operation */ @@ -4455,7 +4455,7 @@ imapx_job_rename_folder_start (CamelIMAPXServer *is, CamelIMAPXCommand *ic; gchar *en_ofname = NULL, *en_nfname = NULL; - job->folder = camel_store_get_folder ( + job->folder = camel_store_get_folder_sync ( is->store, "INBOX", 0, job->cancellable, &job->error); en_ofname = imapx_encode_folder_name ((CamelIMAPXStore *) is->store, job->u.rename_folder.ofolder_name); @@ -5285,7 +5285,7 @@ camel_imapx_server_append_message (CamelIMAPXServer *is, g_object_unref (stream); canon = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF); camel_stream_filter_add ((CamelStreamFilter *)filter, canon); - res = camel_data_wrapper_write_to_stream ( + res = camel_data_wrapper_write_to_stream_sync ( (CamelDataWrapper *)message, filter, cancellable, error); g_object_unref (canon); g_object_unref (filter); diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c index b29ebc2..e176f3f 100644 --- a/camel/providers/imapx/camel-imapx-store.c +++ b/camel/providers/imapx/camel-imapx-store.c @@ -126,7 +126,8 @@ imapx_store_finalize (GObject *object) /* force disconnect so we dont have it run later, after we've cleaned up some stuff */ /* SIGH */ - camel_service_disconnect ((CamelService *)imapx_store, TRUE, NULL); + camel_service_disconnect_sync ( + (CamelService *)imapx_store, TRUE, NULL); if (imapx_store->con_man) { g_object_unref (imapx_store->con_man); imapx_store->con_man = NULL; @@ -175,54 +176,6 @@ imapx_construct (CamelService *service, CamelSession *session, CamelProvider *pr return TRUE; } -extern CamelServiceAuthType camel_imapx_password_authtype; - -static GList * -imapx_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) -{ - CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (service); - CamelServiceAuthType *authtype; - GList *sasl_types, *t, *next; - gboolean connected; - CamelIMAPXServer *server; - - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("You must be working online to complete this operation")); - return NULL; - } - - camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - - server = camel_imapx_server_new ((CamelStore *)istore, service->url); - - connected = server->stream != NULL; - if (!connected) - connected = imapx_connect_to_server (server, cancellable, error); - camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - if (!connected) - return NULL; - - sasl_types = camel_sasl_authtype_list (FALSE); - for (t = sasl_types; t; t = next) { - authtype = t->data; - next = t->next; - - if (!g_hash_table_lookup (server->cinfo->auth_types, authtype->authproto)) { - sasl_types = g_list_remove_link (sasl_types, t); - g_list_free_1 (t); - } - } - - g_object_unref (server); - - return g_list_prepend (sasl_types, &camel_imapx_password_authtype); -} - static gchar * imapx_get_name (CamelService *service, gboolean brief) { @@ -264,9 +217,9 @@ camel_imapx_store_op_done (CamelIMAPXStore *istore, CamelIMAPXServer *server, co } static gboolean -imapx_connect (CamelService *service, - GCancellable *cancellable, - GError **error) +imapx_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelIMAPXStore *istore = (CamelIMAPXStore *)service; CamelIMAPXServer *server; @@ -281,16 +234,16 @@ imapx_connect (CamelService *service, } static gboolean -imapx_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) +imapx_disconnect_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) { CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (service); CamelServiceClass *service_class; service_class = CAMEL_SERVICE_CLASS (camel_imapx_store_parent_class); - if (!service_class->disconnect (service, clean, cancellable, error)) + if (!service_class->disconnect_sync (service, clean, cancellable, error)) return FALSE; camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); @@ -304,100 +257,52 @@ imapx_disconnect (CamelService *service, return TRUE; } -static CamelFolder * -imapx_get_junk (CamelStore *store, - GCancellable *cancellable, - GError **error) -{ - CamelFolder *folder; - CamelStoreClass *store_class; - - store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class); - folder = store_class->get_junk (store, cancellable, error); - - if (folder) { - CamelObject *object = CAMEL_OBJECT (folder); - gchar *state = g_build_filename(((CamelIMAPXStore *)store)->storage_path, "system", "Junk.cmeta", NULL); - - camel_object_set_state_filename (object, state); - g_free (state); - /* no defaults? */ - camel_object_state_read (object); - } - - return folder; -} +extern CamelServiceAuthType camel_imapx_password_authtype; -static CamelFolder * -imapx_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) +static GList * +imapx_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { - CamelFolder *folder; - CamelStoreClass *store_class; - - store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class); - folder = store_class->get_trash (store, cancellable, error); - - if (folder) { - CamelObject *object = CAMEL_OBJECT (folder); - gchar *state = g_build_filename(((CamelIMAPXStore *)store)->storage_path, "system", "Trash.cmeta", NULL); + CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (service); + CamelServiceAuthType *authtype; + GList *sasl_types, *t, *next; + gboolean connected; + CamelIMAPXServer *server; - camel_object_set_state_filename (object, state); - g_free (state); - /* no defaults? */ - camel_object_state_read (object); + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("You must be working online to complete this operation")); + return NULL; } - return folder; -} - -static gboolean -imapx_noop (CamelStore *store, - GCancellable *cancellable, - GError **error) -{ - CamelIMAPXStore *istore = (CamelIMAPXStore *) store; - GSList *servers = NULL, *l; - gboolean success = FALSE; + camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) - return TRUE; + server = camel_imapx_server_new ((CamelStore *)istore, service->url); - servers = camel_imapx_conn_manager_get_connections (istore->con_man); + connected = server->stream != NULL; + if (!connected) + connected = imapx_connect_to_server (server, cancellable, error); + camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); + if (!connected) + return NULL; - for (l = servers; l != NULL; l = g_slist_next (l)) { - CamelIMAPXServer *server = CAMEL_IMAPX_SERVER (l->data); + sasl_types = camel_sasl_authtype_list (FALSE); + for (t = sasl_types; t; t = next) { + authtype = t->data; + next = t->next; - /* we just return last noops value, technically not correct though */ - success = camel_imapx_server_noop (server, NULL, cancellable, error); - g_object_unref (server); + if (!g_hash_table_lookup (server->cinfo->auth_types, authtype->authproto)) { + sasl_types = g_list_remove_link (sasl_types, t); + g_list_free_1 (t); + } } - g_slist_free (servers); - - return success; -} - -static guint -imapx_hash_folder_name (gconstpointer key) -{ - if (g_ascii_strcasecmp (key, "INBOX") == 0) - return g_str_hash ("INBOX"); - else - return g_str_hash (key); -} - -static gint -imapx_compare_folder_name (gconstpointer a, gconstpointer b) -{ - gconstpointer aname = a, bname = b; + g_object_unref (server); - if (g_ascii_strcasecmp (a, "INBOX") == 0) - aname = "INBOX"; - if (g_ascii_strcasecmp (b, "INBOX") == 0) - bname = "INBOX"; - return g_str_equal (aname, bname); + return g_list_prepend (sasl_types, &camel_imapx_password_authtype); } static CamelFolder * @@ -440,27 +345,6 @@ get_folder_offline (CamelStore *store, const gchar *folder_name, return new_folder; } -static CamelFolder * -imapx_get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) -{ - CamelFolder *folder; - - folder = get_folder_offline (store, folder_name, flags, NULL); - if (folder == NULL) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("No such folder: %s"), folder_name); - return NULL; - } - - return folder; -} - /* folder_name is path name */ static CamelFolderInfo * imapx_build_folder_info (CamelIMAPXStore *imapx_store, const gchar *folder_name) @@ -640,7 +524,7 @@ imapx_subscribe_folder (CamelStore *store, CamelIMAPXServer *server; gboolean success; - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) return TRUE; server = camel_imapx_store_get_server (istore, NULL, cancellable, error); @@ -668,7 +552,7 @@ imapx_unsubscribe_folder (CamelStore *store, CamelIMAPXServer *server; gboolean success; - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) return TRUE; server = camel_imapx_store_get_server (istore, NULL, cancellable, error); @@ -685,26 +569,6 @@ imapx_unsubscribe_folder (CamelStore *store, return success; } -static gboolean -imapx_store_subscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - return imapx_subscribe_folder ( - store, folder_name, TRUE, cancellable, error); -} - -static gboolean -imapx_store_unsubscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - return imapx_unsubscribe_folder ( - store, folder_name, TRUE, cancellable, error); -} - static void imapx_delete_folder_from_cache (CamelIMAPXStore *istore, const gchar *folder_name) { @@ -744,39 +608,6 @@ imapx_delete_folder_from_cache (CamelIMAPXStore *istore, const gchar *folder_nam camel_folder_info_free (fi); } -static gboolean -imapx_delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - CamelIMAPXStore *istore = (CamelIMAPXStore *) store; - CamelIMAPXServer *server; - gboolean success; - - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("You must be working online to complete this operation")); - return FALSE; - } - /* Use INBOX connection as the implementation would try to select inbox to ensure - we are not selected on the folder being deleted */ - server = camel_imapx_store_get_server (istore, "INBOX", cancellable, error); - if (!server) - return FALSE; - - success = camel_imapx_server_delete_folder ( - server, folder_name, cancellable, error); - g_object_unref (server); - - if (success) - imapx_delete_folder_from_cache (istore, folder_name); - - return success; -} - static void rename_folder_info (CamelIMAPXStore *istore, const gchar *old_name, const gchar *new_name) { @@ -810,195 +641,40 @@ rename_folder_info (CamelIMAPXStore *istore, const gchar *old_name, const gchar } } -static gboolean -imapx_rename_folder (CamelStore *store, - const gchar *old, - const gchar *new, - GCancellable *cancellable, - GError **error) +static CamelFolderInfo * +get_folder_info_offline (CamelStore *store, const gchar *top, + guint32 flags, GError **error) { - CamelIMAPXStore *istore = (CamelIMAPXStore *) store; - CamelIMAPXServer *server; - gchar *oldpath, *newpath, *storage_path; - gboolean success = FALSE; + CamelIMAPXStore *imapx_store = CAMEL_IMAPX_STORE (store); + gboolean include_inbox = FALSE; + CamelFolderInfo *fi; + GPtrArray *folders; + gchar *pattern, *name; + gint i; - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("You must be working online to complete this operation")); - return FALSE; - } + /* FIXME: obey other flags */ - if (istore->rec_options & IMAPX_SUBSCRIPTIONS) - imapx_unsubscribe_folder (store, old, FALSE, cancellable, NULL); + folders = g_ptr_array_new (); - /* Use INBOX connection as the implementation would try to select inbox to ensure - we are not selected on the folder being renamed */ - server = camel_imapx_store_get_server(istore, "INBOX", cancellable, error); - if (server) { - success = camel_imapx_server_rename_folder ( - server, old, new, cancellable, error); - g_object_unref (server); + if (top == NULL || top[0] == '\0') { + include_inbox = TRUE; + top = ""; } - if (!success) { - imapx_subscribe_folder (store, old, FALSE, cancellable, NULL); - return FALSE; + /* get starting point */ + if (top[0] == 0) { + if (imapx_store->namespace && imapx_store->namespace[0]) { + name = g_strdup (imapx_store->summary->namespaces->personal->full_name); + top = imapx_store->summary->namespaces->personal->path; + } else + name = g_strdup(""); + } else { + name = camel_imapx_store_summary_full_from_path (imapx_store->summary, top); + if (name == NULL) + name = camel_imapx_store_summary_path_to_full (imapx_store->summary, top, imapx_store->dir_sep); } - /* rename summary, and handle broken server */ - rename_folder_info (istore, old, new); - - if (istore->rec_options & IMAPX_SUBSCRIPTIONS) - success = imapx_subscribe_folder ( - store, new, FALSE, cancellable, error); - - storage_path = g_strdup_printf("%s/folders", istore->storage_path); - oldpath = imapx_path_to_physical (storage_path, old); - newpath = imapx_path_to_physical (storage_path, new); - g_free (storage_path); - - /* So do we care if this didn't work? Its just a cache? */ - if (g_rename (oldpath, newpath) == -1) { - g_warning ("Could not rename message cache '%s' to '%s': %s: cache reset", - oldpath, newpath, g_strerror (errno)); - } - - g_free (oldpath); - g_free (newpath); - - return success; -} - -static CamelFolderInfo * -imapx_create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - CamelStoreInfo *si; - CamelIMAPXStoreNamespace *ns; - CamelIMAPXStore *istore = (CamelIMAPXStore *) store; - CamelIMAPXServer *server; - gchar *real_name, *full_name, *parent_real; - CamelFolderInfo *fi = NULL; - gchar dir_sep; - gboolean success; - - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("You must be working online to complete this operation")); - return NULL; - } - - server = camel_imapx_store_get_server (istore, NULL, cancellable, error); - if (!server) - return NULL; - - if (!parent_name) - parent_name = ""; - - ns = camel_imapx_store_summary_namespace_find_path (istore->summary, parent_name); - if (ns) - dir_sep = ns->sep; - else - dir_sep = '/'; - - if (strchr (folder_name, dir_sep)) { - g_set_error ( - error, CAMEL_FOLDER_ERROR, - CAMEL_FOLDER_ERROR_INVALID_PATH, - _("The folder name \"%s\" is invalid because it contains the character \"%c\""), - folder_name, dir_sep); - g_object_unref (server); - return NULL; - } - - parent_real = camel_imapx_store_summary_full_from_path (istore->summary, parent_name); - if (parent_real == NULL) { - g_set_error ( - error, CAMEL_FOLDER_ERROR, - CAMEL_FOLDER_ERROR_INVALID_STATE, - _("Unknown parent folder: %s"), parent_name); - g_object_unref (server); - return NULL; - } - - si = camel_store_summary_path ((CamelStoreSummary *)istore->summary, parent_name); - if (si && si->flags & CAMEL_STORE_INFO_FOLDER_NOINFERIORS) { - g_set_error ( - error, CAMEL_FOLDER_ERROR, - CAMEL_FOLDER_ERROR_INVALID_STATE, - _("The parent folder is not allowed to contain subfolders")); - g_object_unref (server); - return NULL; - } - - if (si) - camel_store_summary_info_free ((CamelStoreSummary *) istore->summary, si); - - real_name = camel_imapx_store_summary_path_to_full (istore->summary, folder_name, dir_sep); - full_name = imapx_concat (istore, parent_real, real_name); - g_free (real_name); - - success = camel_imapx_server_create_folder ( - server, full_name, cancellable, error); - g_object_unref (server); - - if (success) { - CamelIMAPXStoreInfo *si; - - si = camel_imapx_store_summary_add_from_full (istore->summary, full_name, dir_sep); - camel_store_summary_save ((CamelStoreSummary *)istore->summary); - fi = imapx_build_folder_info (istore, camel_store_info_path (istore->summary, si)); - fi->flags |= CAMEL_FOLDER_NOCHILDREN; - camel_store_folder_created (store, fi); - } - - g_free (full_name); - g_free (parent_real); - - return fi; -} - -static CamelFolderInfo * -get_folder_info_offline (CamelStore *store, const gchar *top, - guint32 flags, GError **error) -{ - CamelIMAPXStore *imapx_store = CAMEL_IMAPX_STORE (store); - gboolean include_inbox = FALSE; - CamelFolderInfo *fi; - GPtrArray *folders; - gchar *pattern, *name; - gint i; - - /* FIXME: obey other flags */ - - folders = g_ptr_array_new (); - - if (top == NULL || top[0] == '\0') { - include_inbox = TRUE; - top = ""; - } - - /* get starting point */ - if (top[0] == 0) { - if (imapx_store->namespace && imapx_store->namespace[0]) { - name = g_strdup (imapx_store->summary->namespaces->personal->full_name); - top = imapx_store->summary->namespaces->personal->path; - } else - name = g_strdup(""); - } else { - name = camel_imapx_store_summary_full_from_path (imapx_store->summary, top); - if (name == NULL) - name = camel_imapx_store_summary_path_to_full (imapx_store->summary, top, imapx_store->dir_sep); - } - - pattern = imapx_concat(imapx_store, name, "*"); + pattern = imapx_concat(imapx_store, name, "*"); /* folder_info_build will insert parent nodes as necessary and mark * them as noselect, which is information we actually don't have at @@ -1351,10 +1027,10 @@ imapx_refresh_finfo (CamelSession *session, CamelSessionThreadMsg *msg) struct _imapx_refresh_msg *m = (struct _imapx_refresh_msg *)msg; CamelIMAPXStore *istore = (CamelIMAPXStore *)m->store; - if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (istore))) return; - if (!camel_service_connect ((CamelService *)istore, &msg->error)) + if (!camel_service_connect_sync ((CamelService *)istore, &msg->error)) return; /* look in all namespaces */ @@ -1392,12 +1068,84 @@ discover_inbox (CamelStore *store, } } +static gboolean +imapx_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error) +{ + CamelStoreClass *store_class; + gboolean res; + GError *local_error = NULL; + + store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class); + + res = store_class->can_refresh_folder (store, info, &local_error) || + (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL) || + (camel_url_get_param (((CamelService *)store)->url, "check_lsub") != NULL && (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0); + + if (!res && local_error == NULL && CAMEL_IS_IMAPX_STORE (store)) { + CamelStoreInfo *si; + CamelStoreSummary *sm = CAMEL_STORE_SUMMARY (((CamelIMAPXStore *)(store))->summary); + + if (!sm) + return FALSE; + + si = camel_store_summary_path (sm, info->full_name); + if (si) { + res = (si->flags & CAMEL_STORE_INFO_FOLDER_CHECK_FOR_NEW) != 0 ? TRUE : FALSE; + + camel_store_summary_info_free (sm, si); + } + } + + if (local_error != NULL) + g_propagate_error (error, local_error); + + return res; +} + +static gboolean +imapx_folder_is_subscribed (CamelStore *store, + const gchar *folder_name) +{ + CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (store); + CamelStoreInfo *si; + gint is_subscribed = FALSE; + + si = camel_store_summary_path ((CamelStoreSummary *)istore->summary, folder_name); + if (si) { + is_subscribed = (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) != 0; + camel_store_summary_info_free ((CamelStoreSummary *)istore->summary, si); + } + + return is_subscribed; +} + +static CamelFolder * +imapx_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) +{ + CamelFolder *folder; + + folder = get_folder_offline (store, folder_name, flags, NULL); + if (folder == NULL) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("No such folder: %s"), folder_name); + return NULL; + } + + return folder; +} + static CamelFolderInfo * -imapx_get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +imapx_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelIMAPXStore *istore = (CamelIMAPXStore *)store; CamelFolderInfo * fi= NULL; @@ -1409,7 +1157,7 @@ imapx_get_folder_info (CamelStore *store, g_mutex_lock (istore->get_finfo_lock); - if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { fi = get_folder_info_offline (store, top, flags, error); g_mutex_unlock (istore->get_finfo_lock); @@ -1436,7 +1184,7 @@ imapx_get_folder_info (CamelStore *store, return fi; } - if (!camel_service_connect ((CamelService *)store, error)) { + if (!camel_service_connect_sync ((CamelService *)store, error)) { g_mutex_unlock (istore->get_finfo_lock); return NULL; } @@ -1480,55 +1228,287 @@ imapx_get_folder_info (CamelStore *store, return fi; } -static gboolean -imapx_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error) +static CamelFolder * +imapx_store_get_junk_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { + CamelFolder *folder; CamelStoreClass *store_class; - gboolean res; - GError *local_error = NULL; store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class); + folder = store_class->get_junk_folder_sync (store, cancellable, error); - res = store_class->can_refresh_folder (store, info, &local_error) || - (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL) || - (camel_url_get_param (((CamelService *)store)->url, "check_lsub") != NULL && (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0); + if (folder) { + CamelObject *object = CAMEL_OBJECT (folder); + gchar *state = g_build_filename(((CamelIMAPXStore *)store)->storage_path, "system", "Junk.cmeta", NULL); - if (!res && local_error == NULL && CAMEL_IS_IMAPX_STORE (store)) { - CamelStoreInfo *si; - CamelStoreSummary *sm = CAMEL_STORE_SUMMARY (((CamelIMAPXStore *)(store))->summary); + camel_object_set_state_filename (object, state); + g_free (state); + /* no defaults? */ + camel_object_state_read (object); + } - if (!sm) - return FALSE; + return folder; +} - si = camel_store_summary_path (sm, info->full_name); - if (si) { - res = (si->flags & CAMEL_STORE_INFO_FOLDER_CHECK_FOR_NEW) != 0 ? TRUE : FALSE; +static CamelFolder * +imapx_store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) +{ + CamelFolder *folder; + CamelStoreClass *store_class; - camel_store_summary_info_free (sm, si); - } + store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class); + folder = store_class->get_trash_folder_sync (store, cancellable, error); + + if (folder) { + CamelObject *object = CAMEL_OBJECT (folder); + gchar *state = g_build_filename(((CamelIMAPXStore *)store)->storage_path, "system", "Trash.cmeta", NULL); + + camel_object_set_state_filename (object, state); + g_free (state); + /* no defaults? */ + camel_object_state_read (object); } - if (local_error != NULL) - g_propagate_error (error, local_error); + return folder; +} - return res; +static CamelFolderInfo * +imapx_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + CamelStoreInfo *si; + CamelIMAPXStoreNamespace *ns; + CamelIMAPXStore *istore = (CamelIMAPXStore *) store; + CamelIMAPXServer *server; + gchar *real_name, *full_name, *parent_real; + CamelFolderInfo *fi = NULL; + gchar dir_sep; + gboolean success; + + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("You must be working online to complete this operation")); + return NULL; + } + + server = camel_imapx_store_get_server (istore, NULL, cancellable, error); + if (!server) + return NULL; + + if (!parent_name) + parent_name = ""; + + ns = camel_imapx_store_summary_namespace_find_path (istore->summary, parent_name); + if (ns) + dir_sep = ns->sep; + else + dir_sep = '/'; + + if (strchr (folder_name, dir_sep)) { + g_set_error ( + error, CAMEL_FOLDER_ERROR, + CAMEL_FOLDER_ERROR_INVALID_PATH, + _("The folder name \"%s\" is invalid because it contains the character \"%c\""), + folder_name, dir_sep); + g_object_unref (server); + return NULL; + } + + parent_real = camel_imapx_store_summary_full_from_path (istore->summary, parent_name); + if (parent_real == NULL) { + g_set_error ( + error, CAMEL_FOLDER_ERROR, + CAMEL_FOLDER_ERROR_INVALID_STATE, + _("Unknown parent folder: %s"), parent_name); + g_object_unref (server); + return NULL; + } + + si = camel_store_summary_path ((CamelStoreSummary *)istore->summary, parent_name); + if (si && si->flags & CAMEL_STORE_INFO_FOLDER_NOINFERIORS) { + g_set_error ( + error, CAMEL_FOLDER_ERROR, + CAMEL_FOLDER_ERROR_INVALID_STATE, + _("The parent folder is not allowed to contain subfolders")); + g_object_unref (server); + return NULL; + } + + if (si) + camel_store_summary_info_free ((CamelStoreSummary *) istore->summary, si); + + real_name = camel_imapx_store_summary_path_to_full (istore->summary, folder_name, dir_sep); + full_name = imapx_concat (istore, parent_real, real_name); + g_free (real_name); + + success = camel_imapx_server_create_folder ( + server, full_name, cancellable, error); + g_object_unref (server); + + if (success) { + CamelIMAPXStoreInfo *si; + + si = camel_imapx_store_summary_add_from_full (istore->summary, full_name, dir_sep); + camel_store_summary_save ((CamelStoreSummary *)istore->summary); + fi = imapx_build_folder_info (istore, camel_store_info_path (istore->summary, si)); + fi->flags |= CAMEL_FOLDER_NOCHILDREN; + camel_store_folder_created (store, fi); + } + + g_free (full_name); + g_free (parent_real); + + return fi; } static gboolean -imapx_folder_is_subscribed (CamelStore *store, - const gchar *folder_name) +imapx_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { - CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (store); - CamelStoreInfo *si; - gint is_subscribed = FALSE; + CamelIMAPXStore *istore = (CamelIMAPXStore *) store; + CamelIMAPXServer *server; + gboolean success; - si = camel_store_summary_path ((CamelStoreSummary *)istore->summary, folder_name); - if (si) { - is_subscribed = (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) != 0; - camel_store_summary_info_free ((CamelStoreSummary *)istore->summary, si); + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("You must be working online to complete this operation")); + return FALSE; } + /* Use INBOX connection as the implementation would try to select inbox to ensure + we are not selected on the folder being deleted */ + server = camel_imapx_store_get_server (istore, "INBOX", cancellable, error); + if (!server) + return FALSE; - return is_subscribed; + success = camel_imapx_server_delete_folder ( + server, folder_name, cancellable, error); + g_object_unref (server); + + if (success) + imapx_delete_folder_from_cache (istore, folder_name); + + return success; +} + +static gboolean +imapx_store_rename_folder_sync (CamelStore *store, + const gchar *old, + const gchar *new, + GCancellable *cancellable, + GError **error) +{ + CamelIMAPXStore *istore = (CamelIMAPXStore *) store; + CamelIMAPXServer *server; + gchar *oldpath, *newpath, *storage_path; + gboolean success = FALSE; + + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("You must be working online to complete this operation")); + return FALSE; + } + + if (istore->rec_options & IMAPX_SUBSCRIPTIONS) + imapx_unsubscribe_folder (store, old, FALSE, cancellable, NULL); + + /* Use INBOX connection as the implementation would try to select inbox to ensure + we are not selected on the folder being renamed */ + server = camel_imapx_store_get_server(istore, "INBOX", cancellable, error); + if (server) { + success = camel_imapx_server_rename_folder ( + server, old, new, cancellable, error); + g_object_unref (server); + } + + if (!success) { + imapx_subscribe_folder (store, old, FALSE, cancellable, NULL); + return FALSE; + } + + /* rename summary, and handle broken server */ + rename_folder_info (istore, old, new); + + if (istore->rec_options & IMAPX_SUBSCRIPTIONS) + success = imapx_subscribe_folder ( + store, new, FALSE, cancellable, error); + + storage_path = g_strdup_printf("%s/folders", istore->storage_path); + oldpath = imapx_path_to_physical (storage_path, old); + newpath = imapx_path_to_physical (storage_path, new); + g_free (storage_path); + + /* So do we care if this didn't work? Its just a cache? */ + if (g_rename (oldpath, newpath) == -1) { + g_warning ("Could not rename message cache '%s' to '%s': %s: cache reset", + oldpath, newpath, g_strerror (errno)); + } + + g_free (oldpath); + g_free (newpath); + + return success; +} + +static gboolean +imapx_store_subscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + return imapx_subscribe_folder ( + store, folder_name, TRUE, cancellable, error); +} + +static gboolean +imapx_store_unsubscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + return imapx_unsubscribe_folder ( + store, folder_name, TRUE, cancellable, error); +} + +static gboolean +imapx_store_noop_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) +{ + CamelIMAPXStore *istore = (CamelIMAPXStore *) store; + GSList *servers = NULL, *l; + gboolean success = FALSE; + + if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) + return TRUE; + + servers = camel_imapx_conn_manager_get_connections (istore->con_man); + + for (l = servers; l != NULL; l = g_slist_next (l)) { + CamelIMAPXServer *server = CAMEL_IMAPX_SERVER (l->data); + + /* we just return last noops value, technically not correct though */ + success = camel_imapx_server_noop (server, NULL, cancellable, error); + g_object_unref (server); + } + + g_slist_free (servers); + + return success; } static void @@ -1543,29 +1523,27 @@ camel_imapx_store_class_init (CamelIMAPXStoreClass *class) service_class = CAMEL_SERVICE_CLASS (class); service_class->construct = imapx_construct; - service_class->query_auth_types = imapx_query_auth_types; service_class->get_name = imapx_get_name; - service_class->connect = imapx_connect; - service_class->disconnect = imapx_disconnect; + service_class->connect_sync = imapx_connect_sync; + service_class->disconnect_sync = imapx_disconnect_sync; + service_class->query_auth_types_sync = imapx_query_auth_types_sync; store_class = CAMEL_STORE_CLASS (class); - store_class->get_trash = imapx_get_trash; - store_class->get_junk = imapx_get_junk; - store_class->noop = imapx_noop; - store_class->get_folder = imapx_get_folder; - store_class->hash_folder_name = imapx_hash_folder_name; - store_class->compare_folder_name = imapx_compare_folder_name; + store_class->hash_folder_name = imapx_name_hash; + store_class->compare_folder_name = imapx_name_equal; store_class->can_refresh_folder = imapx_can_refresh_folder; - store_class->create_folder = imapx_create_folder; - store_class->rename_folder = imapx_rename_folder; - store_class->delete_folder = imapx_delete_folder; - store_class->subscribe_folder = imapx_store_subscribe_folder; - store_class->unsubscribe_folder = imapx_store_unsubscribe_folder; - store_class->get_folder_info = imapx_get_folder_info; store_class->folder_is_subscribed = imapx_folder_is_subscribed; store_class->free_folder_info = camel_store_free_folder_info_full; - store_class->hash_folder_name = imapx_name_hash; - store_class->compare_folder_name = imapx_name_equal; + store_class->get_folder_sync = imapx_store_get_folder_sync; + store_class->get_folder_info_sync = imapx_store_get_folder_info_sync; + store_class->get_junk_folder_sync = imapx_store_get_junk_folder_sync; + store_class->get_trash_folder_sync = imapx_store_get_trash_folder_sync; + store_class->create_folder_sync = imapx_store_create_folder_sync; + store_class->delete_folder_sync = imapx_store_delete_folder_sync; + store_class->rename_folder_sync = imapx_store_rename_folder_sync; + store_class->subscribe_folder_sync = imapx_store_subscribe_folder_sync; + store_class->unsubscribe_folder_sync = imapx_store_unsubscribe_folder_sync; + store_class->noop_sync = imapx_store_noop_sync; } static void diff --git a/camel/providers/imapx/test-imapx.c b/camel/providers/imapx/test-imapx.c index 9c154ae..7f3d270 100644 --- a/camel/providers/imapx/test-imapx.c +++ b/camel/providers/imapx/test-imapx.c @@ -45,13 +45,13 @@ main (gint argc, gchar *argv[]) camel_session_construct (session, "/tmp/test-camel-imapx"); service = camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, NULL); - camel_service_connect (service, NULL); + camel_service_connect_sync (service, NULL); - camel_store_get_folder_info ( + camel_store_get_folder_info_sync ( CAMEL_STORE (service), "", 3, NULL, NULL); - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( CAMEL_STORE (service), "INBOX", 0, NULL, NULL); - camel_folder_refresh_info (folder, NULL, NULL); + camel_folder_refresh_info_sync (folder, NULL, NULL); while (1) { diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c index cab3a7b..4d921a6 100644 --- a/camel/providers/local/camel-local-folder.c +++ b/camel/providers/local/camel-local-folder.c @@ -216,65 +216,6 @@ local_folder_constructed (GObject *object) g_free (path); } -static gboolean -local_folder_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - CamelLocalFolder *lf = (CamelLocalFolder *)folder; - - if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, cancellable, error) == -1) - return FALSE; - - if (camel_folder_change_info_changed (lf->changes)) { - camel_folder_changed (folder, lf->changes); - camel_folder_change_info_clear (lf->changes); - } - - return TRUE; -} - -static gboolean -local_folder_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) -{ - CamelLocalFolder *lf = CAMEL_LOCAL_FOLDER (folder); - gboolean success; - - d(printf("local sync '%s' , expunge=%s\n", folder->full_name, expunge?"true":"false")); - - if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) - return FALSE; - - camel_object_state_write (CAMEL_OBJECT (lf)); - - /* if sync fails, we'll pass it up on exit through ex */ - success = (camel_local_summary_sync ( - (CamelLocalSummary *)folder->summary, - expunge, lf->changes, cancellable, error) == 0); - camel_local_folder_unlock (lf); - - if (camel_folder_change_info_changed (lf->changes)) { - camel_folder_changed (folder, lf->changes); - camel_folder_change_info_clear (lf->changes); - } - - return success; -} - -static gboolean -local_folder_expunge (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - /* Just do a sync with expunge, serves the same purpose */ - /* call the callback directly, to avoid locking problems */ - return CAMEL_FOLDER_GET_CLASS (folder)->sync ( - folder, TRUE, cancellable, error); -} - static GPtrArray * local_folder_search_by_expression (CamelFolder *folder, const gchar *expression, @@ -416,6 +357,65 @@ local_folder_get_uncached_uids (CamelFolder *folder, return g_ptr_array_new (); } +static gboolean +local_folder_expunge_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + /* Just do a sync with expunge, serves the same purpose */ + /* call the callback directly, to avoid locking problems */ + return CAMEL_FOLDER_GET_CLASS (folder)->synchronize_sync ( + folder, TRUE, cancellable, error); +} + +static gboolean +local_folder_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) +{ + CamelLocalFolder *lf = (CamelLocalFolder *)folder; + + if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, cancellable, error) == -1) + return FALSE; + + if (camel_folder_change_info_changed (lf->changes)) { + camel_folder_changed (folder, lf->changes); + camel_folder_change_info_clear (lf->changes); + } + + return TRUE; +} + +static gboolean +local_folder_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) +{ + CamelLocalFolder *lf = CAMEL_LOCAL_FOLDER (folder); + gboolean success; + + d(printf("local sync '%s' , expunge=%s\n", folder->full_name, expunge?"true":"false")); + + if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) + return FALSE; + + camel_object_state_write (CAMEL_OBJECT (lf)); + + /* if sync fails, we'll pass it up on exit through ex */ + success = (camel_local_summary_sync ( + (CamelLocalSummary *)folder->summary, + expunge, lf->changes, cancellable, error) == 0); + camel_local_folder_unlock (lf); + + if (camel_folder_change_info_changed (lf->changes)) { + camel_folder_changed (folder, lf->changes); + camel_folder_change_info_clear (lf->changes); + } + + return success; +} + static gint local_folder_lock (CamelLocalFolder *lf, CamelLockType type, @@ -446,9 +446,6 @@ camel_local_folder_class_init (CamelLocalFolderClass *class) object_class->constructed = local_folder_constructed; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->refresh_info = local_folder_refresh_info; - folder_class->sync = local_folder_sync; - folder_class->expunge = local_folder_expunge; folder_class->search_by_expression = local_folder_search_by_expression; folder_class->search_by_uids = local_folder_search_by_uids; folder_class->search_free = local_folder_search_free; @@ -456,6 +453,9 @@ camel_local_folder_class_init (CamelLocalFolderClass *class) folder_class->rename = local_folder_rename; folder_class->count_by_expression = local_folder_count_by_expression; folder_class->get_uncached_uids = local_folder_get_uncached_uids; + folder_class->expunge_sync = local_folder_expunge_sync; + folder_class->refresh_info_sync = local_folder_refresh_info_sync; + folder_class->synchronize_sync = local_folder_synchronize_sync; class->lock = local_folder_lock; class->unlock = local_folder_unlock; diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c index d3ef901..cff3340 100644 --- a/camel/providers/local/camel-local-store.c +++ b/camel/providers/local/camel-local-store.c @@ -38,15 +38,15 @@ #define d(x) static gboolean construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, GError **error); -static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); +static CamelFolder *local_store_get_folder_sync (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); static gchar *get_name (CamelService *service, gboolean brief); -static CamelFolder *local_get_inbox (CamelStore *store, GCancellable *cancellable, GError **error); -static CamelFolder *local_get_junk (CamelStore *store, GCancellable *cancellable, GError **error); -static CamelFolder *local_get_trash (CamelStore *store, GCancellable *cancellable, GError **error); -static CamelFolderInfo *get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); -static gboolean delete_folder (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); -static gboolean rename_folder (CamelStore *store, const gchar *old, const gchar *new, GCancellable *cancellable, GError **error); -static CamelFolderInfo *create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GCancellable *cancellable, GError **error); +static CamelFolder *local_store_get_inbox_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error); +static CamelFolder *local_store_get_junk_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error); +static CamelFolder *local_store_get_trash_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error); +static CamelFolderInfo *local_store_get_folder_info_sync (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); +static gboolean local_store_delete_folder_sync (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); +static gboolean local_store_rename_folder_sync (CamelStore *store, const gchar *old, const gchar *new, GCancellable *cancellable, GError **error); +static CamelFolderInfo *local_store_create_folder_sync (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GCancellable *cancellable, GError **error); static gboolean local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error); static gchar *local_get_full_path (CamelLocalStore *lf, const gchar *full_name); @@ -80,16 +80,16 @@ camel_local_store_class_init (CamelLocalStoreClass *class) service_class->get_name = get_name; store_class = CAMEL_STORE_CLASS (class); - store_class->get_folder = get_folder; - store_class->get_inbox = local_get_inbox; - store_class->get_trash = local_get_trash; - store_class->get_junk = local_get_junk; - store_class->get_folder_info = get_folder_info; - store_class->free_folder_info = camel_store_free_folder_info_full; - store_class->create_folder = create_folder; - store_class->delete_folder = delete_folder; - store_class->rename_folder = rename_folder; store_class->can_refresh_folder = local_can_refresh_folder; + store_class->free_folder_info = camel_store_free_folder_info_full; + store_class->get_folder_sync = local_store_get_folder_sync; + store_class->get_folder_info_sync = local_store_get_folder_info_sync; + store_class->get_inbox_folder_sync = local_store_get_inbox_folder_sync; + store_class->get_junk_folder_sync = local_store_get_junk_folder_sync; + store_class->get_trash_folder_sync = local_store_get_trash_folder_sync; + store_class->create_folder_sync = local_store_create_folder_sync; + store_class->delete_folder_sync = local_store_delete_folder_sync; + store_class->rename_folder_sync = local_store_rename_folder_sync; class->get_full_path = local_get_full_path; class->get_meta_path = local_get_meta_path; @@ -132,11 +132,11 @@ camel_local_store_get_toplevel_dir (CamelLocalStore *store) } static CamelFolder * -get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) +local_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) { gint len = strlen (((CamelLocalStore *)store)->toplevel_dir); gchar *path = g_alloca (len + 1); @@ -189,9 +189,9 @@ get_folder (CamelStore *store, } static CamelFolder * -local_get_inbox (CamelStore *store, - GCancellable *cancellable, - GError **error) +local_store_get_inbox_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { g_set_error ( error, CAMEL_STORE_ERROR, @@ -202,15 +202,15 @@ local_get_inbox (CamelStore *store, } static CamelFolder * -local_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) +local_store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelFolder *folder; - /* Chain up to parent's get_trash() method. */ + /* Chain up to parent's get_trash_folder_sync() method. */ folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)-> - get_trash (store, cancellable, error); + get_trash_folder_sync (store, cancellable, error); if (folder) { CamelObject *object = CAMEL_OBJECT (folder); @@ -226,15 +226,15 @@ local_get_trash (CamelStore *store, } static CamelFolder * -local_get_junk (CamelStore *store, - GCancellable *cancellable, - GError **error) +local_store_get_junk_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { CamelFolder *folder; - /* Chain up to parent's get_junk() method. */ + /* Chain up to parent's get_junk_folder_sync() method. */ folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)-> - get_junk (store, cancellable, error); + get_junk_folder_sync (store, cancellable, error); if (folder) { CamelObject *object = CAMEL_OBJECT (folder); @@ -261,11 +261,11 @@ get_name (CamelService *service, gboolean brief) } static CamelFolderInfo * -get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +local_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { /* FIXME: This is broken, but it corresponds to what was * there before. @@ -277,11 +277,11 @@ get_folder_info (CamelStore *store, } static CamelFolderInfo * -create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +local_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { gchar *path = ((CamelLocalStore *)store)->toplevel_dir; gchar *name; @@ -321,11 +321,11 @@ create_folder (CamelStore *store, else name = g_strdup_printf("%s", folder_name); - folder = CAMEL_STORE_GET_CLASS (store)->get_folder ( + folder = CAMEL_STORE_GET_CLASS (store)->get_folder_sync ( store, name, CAMEL_STORE_FOLDER_CREATE, cancellable, error); if (folder) { g_object_unref (folder); - info = CAMEL_STORE_GET_CLASS (store)->get_folder_info ( + info = CAMEL_STORE_GET_CLASS (store)->get_folder_info_sync ( store, name, 0, cancellable, error); } @@ -380,11 +380,11 @@ xrename (const gchar *oldp, /* default implementation, rename all */ static gboolean -rename_folder (CamelStore *store, - const gchar *old, - const gchar *new, - GCancellable *cancellable, - GError **error) +local_store_rename_folder_sync (CamelStore *store, + const gchar *old, + const gchar *new, + GCancellable *cancellable, + GError **error) { gchar *path = CAMEL_LOCAL_STORE (store)->toplevel_dir; CamelLocalFolder *folder = NULL; @@ -457,10 +457,10 @@ ibex_failed: /* default implementation, only delete metadata */ static gboolean -delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +local_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelFolderInfo *fi; CamelFolder *lf; @@ -483,7 +483,7 @@ delete_folder (CamelStore *store, g_free (str); str = NULL; - if ((lf = camel_store_get_folder (store, folder_name, 0, cancellable, NULL))) { + if ((lf = camel_store_get_folder_sync (store, folder_name, 0, cancellable, NULL))) { CamelObject *object = CAMEL_OBJECT (lf); const gchar *state_filename; diff --git a/camel/providers/local/camel-local-summary.c b/camel/providers/local/camel-local-summary.c index 3e13f9f..7ad10f8 100644 --- a/camel/providers/local/camel-local-summary.c +++ b/camel/providers/local/camel-local-summary.c @@ -530,7 +530,9 @@ local_summary_add (CamelLocalSummary *cls, if (mi->info.size == 0) { CamelStreamNull *sn = (CamelStreamNull *)camel_stream_null_new (); - camel_data_wrapper_write_to_stream ((CamelDataWrapper *)msg, (CamelStream *)sn, NULL, NULL); + camel_data_wrapper_write_to_stream_sync ( + (CamelDataWrapper *)msg, + (CamelStream *)sn, NULL, NULL); mi->info.size = sn->written; g_object_unref (sn); } diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c index 5281d5a..57f322f 100644 --- a/camel/providers/local/camel-maildir-folder.c +++ b/camel/providers/local/camel-maildir-folder.c @@ -43,13 +43,81 @@ G_DEFINE_TYPE (CamelMaildirFolder, camel_maildir_folder, CAMEL_TYPE_LOCAL_FOLDER) +static gint +maildir_folder_cmp_uids (CamelFolder *folder, + const gchar *uid1, + const gchar *uid2) +{ + CamelMessageInfo *a, *b; + time_t tma, tmb; + + g_return_val_if_fail (folder != NULL, 0); + g_return_val_if_fail (folder->summary != NULL, 0); + + a = camel_folder_summary_uid (folder->summary, uid1); + b = camel_folder_summary_uid (folder->summary, uid2); + + g_return_val_if_fail (a != NULL, 0); + g_return_val_if_fail (b != NULL, 0); + + tma = camel_message_info_date_received (a); + tmb = camel_message_info_date_received (b); + + camel_message_info_free (a); + camel_message_info_free (b); + + return tma < tmb ? -1 : tma == tmb ? 0 : 1; +} + +static void +maildir_folder_sort_uids (CamelFolder *folder, + GPtrArray *uids) +{ + g_return_if_fail (camel_maildir_folder_parent_class != NULL); + g_return_if_fail (folder != NULL); + + if (uids && uids->len > 1) + camel_folder_summary_prepare_fetch_all (folder->summary, NULL); + + /* Chain up to parent's sort_uids() method. */ + CAMEL_FOLDER_CLASS (camel_maildir_folder_parent_class)->sort_uids (folder, uids); +} + +static gchar * +maildir_folder_get_filename (CamelFolder *folder, + const gchar *uid, + GError **error) +{ + CamelLocalFolder *lf = (CamelLocalFolder *)folder; + CamelMaildirMessageInfo *mdi; + CamelMessageInfo *info; + gchar *res; + + /* get the message summary info */ + if ((info = camel_folder_summary_uid (folder->summary, uid)) == NULL) { + set_cannot_get_message_ex ( + error, CAMEL_FOLDER_ERROR_INVALID_UID, + uid, lf->folder_path, _("No such message")); + return NULL; + } + + mdi = (CamelMaildirMessageInfo *)info; + + /* what do we do if the message flags (and :info data) changes? filename mismatch - need to recheck I guess */ + res = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename (mdi)); + + camel_message_info_free (info); + + return res; +} + static gboolean -maildir_folder_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +maildir_folder_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { CamelLocalFolder *lf = (CamelLocalFolder *)folder; CamelStream *output_stream; @@ -85,7 +153,7 @@ maildir_folder_append_message (CamelFolder *folder, if (output_stream == NULL) goto fail_write; - if (camel_data_wrapper_write_to_stream ( + if (camel_data_wrapper_write_to_stream_sync ( (CamelDataWrapper *)message, output_stream, cancellable, error) == -1 || camel_stream_close (output_stream, cancellable, error) == -1) goto fail_write; @@ -143,10 +211,10 @@ maildir_folder_append_message (CamelFolder *folder, } static CamelMimeMessage * -maildir_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +maildir_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelLocalFolder *lf = (CamelLocalFolder *)folder; CamelStream *message_stream = NULL; @@ -185,7 +253,9 @@ maildir_folder_get_message (CamelFolder *folder, } message = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, message_stream, cancellable, error) == -1) { + if (camel_data_wrapper_construct_from_stream_sync ( + (CamelDataWrapper *)message, + message_stream, cancellable, error) == -1) { g_prefix_error ( error, _("Cannot get message %s from folder %s: "), uid, lf->folder_path); @@ -207,54 +277,14 @@ maildir_folder_get_message (CamelFolder *folder, return message; } -static gint -maildir_folder_cmp_uids (CamelFolder *folder, - const gchar *uid1, - const gchar *uid2) -{ - CamelMessageInfo *a, *b; - time_t tma, tmb; - - g_return_val_if_fail (folder != NULL, 0); - g_return_val_if_fail (folder->summary != NULL, 0); - - a = camel_folder_summary_uid (folder->summary, uid1); - b = camel_folder_summary_uid (folder->summary, uid2); - - g_return_val_if_fail (a != NULL, 0); - g_return_val_if_fail (b != NULL, 0); - - tma = camel_message_info_date_received (a); - tmb = camel_message_info_date_received (b); - - camel_message_info_free (a); - camel_message_info_free (b); - - return tma < tmb ? -1 : tma == tmb ? 0 : 1; -} - -static void -maildir_folder_sort_uids (CamelFolder *folder, - GPtrArray *uids) -{ - g_return_if_fail (camel_maildir_folder_parent_class != NULL); - g_return_if_fail (folder != NULL); - - if (uids && uids->len > 1) - camel_folder_summary_prepare_fetch_all (folder->summary, NULL); - - /* Chain up to parent's sort_uids() method. */ - CAMEL_FOLDER_CLASS (camel_maildir_folder_parent_class)->sort_uids (folder, uids); -} - static gboolean -maildir_folder_transfer_messages_to (CamelFolder *source, - GPtrArray *uids, - CamelFolder *dest, - GPtrArray **transferred_uids, - gboolean delete_originals, - GCancellable *cancellable, - GError **error) +maildir_folder_transfer_messages_to_sync (CamelFolder *source, + GPtrArray *uids, + CamelFolder *dest, + GPtrArray **transferred_uids, + gboolean delete_originals, + GCancellable *cancellable, + GError **error) { gboolean fallback = FALSE; @@ -325,7 +355,7 @@ maildir_folder_transfer_messages_to (CamelFolder *source, /* Chain up to parent's transfer_messages_to() method. */ folder_class = CAMEL_FOLDER_CLASS (camel_maildir_folder_parent_class); - return folder_class->transfer_messages_to ( + return folder_class->transfer_messages_to_sync ( source, uids, dest, transferred_uids, delete_originals, cancellable, error); } @@ -333,34 +363,6 @@ maildir_folder_transfer_messages_to (CamelFolder *source, return TRUE; } -static gchar * -maildir_folder_get_filename (CamelFolder *folder, - const gchar *uid, - GError **error) -{ - CamelLocalFolder *lf = (CamelLocalFolder *)folder; - CamelMaildirMessageInfo *mdi; - CamelMessageInfo *info; - gchar *res; - - /* get the message summary info */ - if ((info = camel_folder_summary_uid (folder->summary, uid)) == NULL) { - set_cannot_get_message_ex ( - error, CAMEL_FOLDER_ERROR_INVALID_UID, - uid, lf->folder_path, _("No such message")); - return NULL; - } - - mdi = (CamelMaildirMessageInfo *)info; - - /* what do we do if the message flags (and :info data) changes? filename mismatch - need to recheck I guess */ - res = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename (mdi)); - - camel_message_info_free (info); - - return res; -} - static CamelLocalSummary * maildir_folder_create_summary (CamelLocalFolder *lf, const gchar *path, @@ -378,12 +380,12 @@ camel_maildir_folder_class_init (CamelMaildirFolderClass *class) CamelLocalFolderClass *local_folder_class; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->append_message = maildir_folder_append_message; - folder_class->get_message = maildir_folder_get_message; folder_class->cmp_uids = maildir_folder_cmp_uids; folder_class->sort_uids = maildir_folder_sort_uids; - folder_class->transfer_messages_to = maildir_folder_transfer_messages_to; folder_class->get_filename = maildir_folder_get_filename; + folder_class->append_message_sync = maildir_folder_append_message_sync; + folder_class->get_message_sync = maildir_folder_get_message_sync; + folder_class->transfer_messages_to_sync = maildir_folder_transfer_messages_to_sync; local_folder_class = CAMEL_LOCAL_FOLDER_CLASS (class); local_folder_class->create_summary = maildir_folder_create_summary; diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c index 0ced756..f440850 100644 --- a/camel/providers/local/camel-maildir-store.c +++ b/camel/providers/local/camel-maildir-store.c @@ -39,39 +39,8 @@ #define d(x) -static CamelFolder *get_folder (CamelStore * store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); -static CamelFolder *get_inbox (CamelStore *store, GCancellable *cancellable, GError **error); -static gboolean delete_folder (CamelStore * store, const gchar *folder_name, GCancellable *cancellable, GError **error); -static gboolean maildir_rename_folder (CamelStore *store, const gchar *old, const gchar *new, GCancellable *cancellable, GError **error); - -static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); - -static gboolean maildir_compare_folder_name (gconstpointer a, gconstpointer b); -static guint maildir_hash_folder_name (gconstpointer a); - G_DEFINE_TYPE (CamelMaildirStore, camel_maildir_store, CAMEL_TYPE_LOCAL_STORE) -static void -camel_maildir_store_class_init (CamelMaildirStoreClass *class) -{ - CamelStoreClass *store_class; - - store_class = CAMEL_STORE_CLASS (class); - store_class->hash_folder_name = maildir_hash_folder_name; - store_class->compare_folder_name = maildir_compare_folder_name; - store_class->get_folder = get_folder; - store_class->get_inbox = get_inbox; - store_class->delete_folder = delete_folder; - store_class->rename_folder = maildir_rename_folder; - store_class->get_folder_info = get_folder_info; - store_class->free_folder_info = camel_store_free_folder_info_full; -} - -static void -camel_maildir_store_init (CamelMaildirStore *maildir_store) -{ -} - /* This fixes up some historical cruft of names starting with "./" */ static const gchar * md_canon_name (const gchar *a) @@ -86,245 +55,6 @@ md_canon_name (const gchar *a) return a; } -static guint -maildir_hash_folder_name (gconstpointer a) -{ - return g_str_hash (md_canon_name (a)); -} - -static gboolean -maildir_compare_folder_name (gconstpointer a, - gconstpointer b) -{ - return g_str_equal (md_canon_name (a), md_canon_name (b)); -} - -static CamelFolder * -get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) -{ - CamelStoreClass *store_class; - gchar *name, *tmp, *cur, *new; - struct stat st; - CamelFolder *folder = NULL; - - folder_name = md_canon_name (folder_name); - - /* Chain up to parent's get_folder() method. */ - store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class); - if (!store_class->get_folder (store, folder_name, flags, cancellable, error)) - return NULL; - - name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); - tmp = g_strdup_printf("%s/tmp", name); - cur = g_strdup_printf("%s/cur", name); - new = g_strdup_printf("%s/new", name); - - if (!strcmp(folder_name, ".")) { - /* special case "." (aka inbox), may need to be created */ - if (g_stat (tmp, &st) != 0 || !S_ISDIR (st.st_mode) - || g_stat (cur, &st) != 0 || !S_ISDIR (st.st_mode) - || g_stat (new, &st) != 0 || !S_ISDIR (st.st_mode)) { - if (mkdir (tmp, 0700) != 0 - || mkdir (cur, 0700) != 0 - || mkdir (new, 0700) != 0) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Cannot create folder '%s': %s"), - folder_name, g_strerror (errno)); - rmdir (tmp); - rmdir (cur); - rmdir (new); - goto fail; - } - } - folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error); - } else if (g_stat (name, &st) == -1) { - /* folder doesn't exist, see if we should create it */ - if (errno != ENOENT) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Cannot get folder '%s': %s"), - folder_name, g_strerror (errno)); - } else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot get folder '%s': folder does not exist."), - folder_name); - } else { - if (mkdir (name, 0700) != 0 - || mkdir (tmp, 0700) != 0 - || mkdir (cur, 0700) != 0 - || mkdir (new, 0700) != 0) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Cannot create folder '%s': %s"), - folder_name, g_strerror (errno)); - rmdir (tmp); - rmdir (cur); - rmdir (new); - rmdir (name); - } else { - folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error); - } - } - } else if (!S_ISDIR (st.st_mode) - || g_stat (tmp, &st) != 0 || !S_ISDIR (st.st_mode) - || g_stat (cur, &st) != 0 || !S_ISDIR (st.st_mode) - || g_stat (new, &st) != 0 || !S_ISDIR (st.st_mode)) { - /* folder exists, but not maildir */ - g_set_error ( - error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("Cannot get folder '%s': not a maildir directory."), - name); - } else if (flags & CAMEL_STORE_FOLDER_EXCL) { - g_set_error ( - error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("Cannot create folder '%s': folder exists."), - folder_name); - } else { - folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error); - } -fail: - g_free (name); - g_free (tmp); - g_free (cur); - g_free (new); - - return folder; -} - -static CamelFolder * -get_inbox (CamelStore *store, - GCancellable *cancellable, - GError **error) -{ - return camel_store_get_folder ( - store, ".", CAMEL_STORE_FOLDER_CREATE, cancellable, error); -} - -static gboolean -delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - gchar *name, *tmp, *cur, *new; - struct stat st; - gboolean success = TRUE; - - if (strcmp(folder_name, ".") == 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot delete folder: %s: Invalid operation"), - _("Inbox")); - return FALSE; - } - - name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); - - tmp = g_strdup_printf("%s/tmp", name); - cur = g_strdup_printf("%s/cur", name); - new = g_strdup_printf("%s/new", name); - - if (g_stat (name, &st) == -1 || !S_ISDIR (st.st_mode) - || g_stat (tmp, &st) == -1 || !S_ISDIR (st.st_mode) - || g_stat (cur, &st) == -1 || !S_ISDIR (st.st_mode) - || g_stat (new, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Could not delete folder '%s': %s"), - folder_name, errno ? g_strerror (errno) : - _("not a maildir directory")); - } else { - gint err = 0; - - /* remove subdirs first - will fail if not empty */ - if (rmdir (cur) == -1 || rmdir (new) == -1) { - err = errno; - } else { - DIR *dir; - struct dirent *d; - - /* for tmp (only), its contents is irrelevant */ - dir = opendir (tmp); - if (dir) { - while ((d=readdir (dir))) { - gchar *name = d->d_name, *file; - - if (!strcmp(name, ".") || !strcmp(name, "..")) - continue; - file = g_strdup_printf("%s/%s", tmp, name); - unlink (file); - g_free (file); - } - closedir (dir); - } - if (rmdir (tmp) == -1 || rmdir (name) == -1) - err = errno; - } - - if (err != 0) { - /* easier just to mkdir all (and let them fail), than remember what we got to */ - mkdir (name, 0700); - mkdir (cur, 0700); - mkdir (new, 0700); - mkdir (tmp, 0700); - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (err), - _("Could not delete folder '%s': %s"), - folder_name, g_strerror (err)); - } else { - CamelStoreClass *store_class; - - /* Chain up to parent's delete_folder() method. */ - store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class); - success = store_class->delete_folder ( - store, folder_name, cancellable, error); - } - } - - g_free (name); - g_free (tmp); - g_free (cur); - g_free (new); - - return success; -} - -static gboolean -maildir_rename_folder (CamelStore *store, - const gchar *old, - const gchar *new, - GCancellable *cancellable, - GError **error) -{ - CamelStoreClass *store_class; - - if (strcmp(old, ".") == 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot rename folder: %s: Invalid operation"), - _("Inbox")); - return FALSE; - } - - /* Chain up to parent's rename_folder() method. */ - store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class); - return store_class->rename_folder (store, old, new, cancellable, error); -} - static void fill_fi (CamelStore *store, CamelFolderInfo *fi, @@ -337,11 +67,12 @@ fill_fi (CamelStore *store, if (folder == NULL && (flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - folder = camel_store_get_folder (store, fi->full_name, 0, cancellable, NULL); + folder = camel_store_get_folder_sync ( + store, fi->full_name, 0, cancellable, NULL); if (folder) { if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - camel_folder_refresh_info (folder, cancellable, NULL); + camel_folder_refresh_info_sync (folder, cancellable, NULL); fi->unread = camel_folder_get_unread_message_count (folder); fi->total = camel_folder_get_message_count (folder); g_object_unref (folder); @@ -549,12 +280,128 @@ fail: return res; } +static guint +maildir_store_hash_folder_name (gconstpointer a) +{ + return g_str_hash (md_canon_name (a)); +} + +static gboolean +maildir_store_compare_folder_name (gconstpointer a, + gconstpointer b) +{ + return g_str_equal (md_canon_name (a), md_canon_name (b)); +} + +static CamelFolder * +maildir_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) +{ + CamelStoreClass *store_class; + gchar *name, *tmp, *cur, *new; + struct stat st; + CamelFolder *folder = NULL; + + folder_name = md_canon_name (folder_name); + + /* Chain up to parent's get_folder_sync() method. */ + store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class); + if (!store_class->get_folder_sync ( + store, folder_name, flags, cancellable, error)) + return NULL; + + name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); + tmp = g_strdup_printf("%s/tmp", name); + cur = g_strdup_printf("%s/cur", name); + new = g_strdup_printf("%s/new", name); + + if (!strcmp(folder_name, ".")) { + /* special case "." (aka inbox), may need to be created */ + if (g_stat (tmp, &st) != 0 || !S_ISDIR (st.st_mode) + || g_stat (cur, &st) != 0 || !S_ISDIR (st.st_mode) + || g_stat (new, &st) != 0 || !S_ISDIR (st.st_mode)) { + if (mkdir (tmp, 0700) != 0 + || mkdir (cur, 0700) != 0 + || mkdir (new, 0700) != 0) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Cannot create folder '%s': %s"), + folder_name, g_strerror (errno)); + rmdir (tmp); + rmdir (cur); + rmdir (new); + goto fail; + } + } + folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error); + } else if (g_stat (name, &st) == -1) { + /* folder doesn't exist, see if we should create it */ + if (errno != ENOENT) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Cannot get folder '%s': %s"), + folder_name, g_strerror (errno)); + } else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot get folder '%s': folder does not exist."), + folder_name); + } else { + if (mkdir (name, 0700) != 0 + || mkdir (tmp, 0700) != 0 + || mkdir (cur, 0700) != 0 + || mkdir (new, 0700) != 0) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Cannot create folder '%s': %s"), + folder_name, g_strerror (errno)); + rmdir (tmp); + rmdir (cur); + rmdir (new); + rmdir (name); + } else { + folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error); + } + } + } else if (!S_ISDIR (st.st_mode) + || g_stat (tmp, &st) != 0 || !S_ISDIR (st.st_mode) + || g_stat (cur, &st) != 0 || !S_ISDIR (st.st_mode) + || g_stat (new, &st) != 0 || !S_ISDIR (st.st_mode)) { + /* folder exists, but not maildir */ + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Cannot get folder '%s': not a maildir directory."), + name); + } else if (flags & CAMEL_STORE_FOLDER_EXCL) { + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Cannot create folder '%s': folder exists."), + folder_name); + } else { + folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error); + } +fail: + g_free (name); + g_free (tmp); + g_free (cur); + g_free (new); + + return folder; +} + static CamelFolderInfo * -get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +maildir_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelFolderInfo *fi = NULL; CamelLocalStore *local_store = (CamelLocalStore *)store; @@ -602,3 +449,150 @@ fail: return NULL; } + +static CamelFolder * +maildir_store_get_inbox_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) +{ + return camel_store_get_folder_sync ( + store, ".", CAMEL_STORE_FOLDER_CREATE, cancellable, error); +} + +static gboolean +maildir_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + gchar *name, *tmp, *cur, *new; + struct stat st; + gboolean success = TRUE; + + if (strcmp(folder_name, ".") == 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot delete folder: %s: Invalid operation"), + _("Inbox")); + return FALSE; + } + + name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); + + tmp = g_strdup_printf("%s/tmp", name); + cur = g_strdup_printf("%s/cur", name); + new = g_strdup_printf("%s/new", name); + + if (g_stat (name, &st) == -1 || !S_ISDIR (st.st_mode) + || g_stat (tmp, &st) == -1 || !S_ISDIR (st.st_mode) + || g_stat (cur, &st) == -1 || !S_ISDIR (st.st_mode) + || g_stat (new, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Could not delete folder '%s': %s"), + folder_name, errno ? g_strerror (errno) : + _("not a maildir directory")); + } else { + gint err = 0; + + /* remove subdirs first - will fail if not empty */ + if (rmdir (cur) == -1 || rmdir (new) == -1) { + err = errno; + } else { + DIR *dir; + struct dirent *d; + + /* for tmp (only), its contents is irrelevant */ + dir = opendir (tmp); + if (dir) { + while ((d=readdir (dir))) { + gchar *name = d->d_name, *file; + + if (!strcmp(name, ".") || !strcmp(name, "..")) + continue; + file = g_strdup_printf("%s/%s", tmp, name); + unlink (file); + g_free (file); + } + closedir (dir); + } + if (rmdir (tmp) == -1 || rmdir (name) == -1) + err = errno; + } + + if (err != 0) { + /* easier just to mkdir all (and let them fail), than remember what we got to */ + mkdir (name, 0700); + mkdir (cur, 0700); + mkdir (new, 0700); + mkdir (tmp, 0700); + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (err), + _("Could not delete folder '%s': %s"), + folder_name, g_strerror (err)); + } else { + CamelStoreClass *store_class; + + /* Chain up to parent's delete_folder_sync() method. */ + store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class); + success = store_class->delete_folder_sync ( + store, folder_name, cancellable, error); + } + } + + g_free (name); + g_free (tmp); + g_free (cur); + g_free (new); + + return success; +} + +static gboolean +maildir_store_rename_folder_sync (CamelStore *store, + const gchar *old, + const gchar *new, + GCancellable *cancellable, + GError **error) +{ + CamelStoreClass *store_class; + + if (strcmp(old, ".") == 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot rename folder: %s: Invalid operation"), + _("Inbox")); + return FALSE; + } + + /* Chain up to parent's rename_folder_sync() method. */ + store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class); + return store_class->rename_folder_sync ( + store, old, new, cancellable, error); +} + +static void +camel_maildir_store_class_init (CamelMaildirStoreClass *class) +{ + CamelStoreClass *store_class; + + store_class = CAMEL_STORE_CLASS (class); + store_class->hash_folder_name = maildir_store_hash_folder_name; + store_class->compare_folder_name = maildir_store_compare_folder_name; + store_class->free_folder_info = camel_store_free_folder_info_full; + store_class->get_folder_sync = maildir_store_get_folder_sync; + store_class->get_folder_info_sync = maildir_store_get_folder_info_sync; + store_class->get_inbox_folder_sync = maildir_store_get_inbox_sync; + store_class->delete_folder_sync = maildir_store_delete_folder_sync; + store_class->rename_folder_sync = maildir_store_rename_folder_sync; +} + +static void +camel_maildir_store_init (CamelMaildirStore *maildir_store) +{ +} + diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c index 774ab7e..32abf33 100644 --- a/camel/providers/local/camel-mbox-folder.c +++ b/camel/providers/local/camel-mbox-folder.c @@ -48,13 +48,100 @@ G_DEFINE_TYPE (CamelMboxFolder, camel_mbox_folder, CAMEL_TYPE_LOCAL_FOLDER) +static gint +mbox_folder_cmp_uids (CamelFolder *folder, + const gchar *uid1, + const gchar *uid2) +{ + CamelMboxMessageInfo *a, *b; + gint res; + + g_return_val_if_fail (folder != NULL, 0); + g_return_val_if_fail (folder->summary != NULL, 0); + + a = (CamelMboxMessageInfo *) camel_folder_summary_uid (folder->summary, uid1); + b = (CamelMboxMessageInfo *) camel_folder_summary_uid (folder->summary, uid2); + + g_return_val_if_fail (a != NULL, 0); + g_return_val_if_fail (b != NULL, 0); + + res = a->frompos < b->frompos ? -1 : a->frompos == b->frompos ? 0 : 1; + + camel_message_info_free ((CamelMessageInfo *)a); + camel_message_info_free ((CamelMessageInfo *)b); + + return res; +} + +static void +mbox_folder_sort_uids (CamelFolder *folder, + GPtrArray *uids) +{ + g_return_if_fail (camel_mbox_folder_parent_class != NULL); + g_return_if_fail (folder != NULL); + + if (uids && uids->len > 1) + camel_folder_summary_prepare_fetch_all (folder->summary, NULL); + + CAMEL_FOLDER_CLASS (camel_mbox_folder_parent_class)->sort_uids (folder, uids); +} + +static gchar * +mbox_folder_get_filename (CamelFolder *folder, + const gchar *uid, + GError **error) +{ + CamelLocalFolder *lf = (CamelLocalFolder *)folder; + CamelMboxMessageInfo *info; + goffset frompos; + gchar *filename = NULL; + + d(printf("Getting message %s\n", uid)); + + /* lock the folder first, burn if we can't, need write lock for summary check */ + if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) + return NULL; + + /* check for new messages always */ + if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, NULL, error) == -1) { + camel_local_folder_unlock (lf); + return NULL; + } + + /* get the message summary info */ + info = (CamelMboxMessageInfo *) camel_folder_summary_uid (folder->summary, uid); + + if (info == NULL) { + set_cannot_get_message_ex ( + error, CAMEL_FOLDER_ERROR_INVALID_UID, + uid, lf->folder_path, _("No such message")); + goto fail; + } + + if (info->frompos == -1) { + camel_message_info_free ((CamelMessageInfo *)info); + goto fail; + } + + frompos = info->frompos; + camel_message_info_free ((CamelMessageInfo *)info); + + filename = g_strdup_printf ("%s%s!%" PRId64, lf->folder_path, G_DIR_SEPARATOR_S, (gint64) frompos); + +fail: + /* and unlock now we're finished with it */ + camel_local_folder_unlock (lf); + + return filename; +} + static gboolean -mbox_folder_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +mbox_folder_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { CamelLocalFolder *lf = (CamelLocalFolder *)folder; CamelStream *output_stream = NULL, *filter_stream = NULL; @@ -121,7 +208,7 @@ mbox_folder_append_message (CamelFolder *folder, camel_stream_filter_add ((CamelStreamFilter *) filter_stream, filter_from); g_object_unref (filter_from); - if (camel_data_wrapper_write_to_stream ( + if (camel_data_wrapper_write_to_stream_sync ( (CamelDataWrapper *) message, filter_stream, cancellable, error) == -1 || camel_stream_write (filter_stream, "\n", 1, cancellable, error) == -1 || camel_stream_flush (filter_stream, cancellable, error) == -1) @@ -203,10 +290,10 @@ fail: } static CamelMimeMessage * -mbox_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +mbox_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelLocalFolder *lf = (CamelLocalFolder *)folder; CamelMimeMessage *message = NULL; @@ -293,7 +380,8 @@ retry: } message = camel_mime_message_new (); - if (camel_mime_part_construct_from_parser ((CamelMimePart *)message, parser, cancellable, error) == -1) { + if (camel_mime_part_construct_from_parser_sync ( + (CamelMimePart *)message, parser, cancellable, error) == -1) { g_prefix_error ( error, _("Cannot get message %s from folder %s: "), uid, lf->folder_path); @@ -320,93 +408,6 @@ fail: return message; } -static gint -mbox_folder_cmp_uids (CamelFolder *folder, - const gchar *uid1, - const gchar *uid2) -{ - CamelMboxMessageInfo *a, *b; - gint res; - - g_return_val_if_fail (folder != NULL, 0); - g_return_val_if_fail (folder->summary != NULL, 0); - - a = (CamelMboxMessageInfo *) camel_folder_summary_uid (folder->summary, uid1); - b = (CamelMboxMessageInfo *) camel_folder_summary_uid (folder->summary, uid2); - - g_return_val_if_fail (a != NULL, 0); - g_return_val_if_fail (b != NULL, 0); - - res = a->frompos < b->frompos ? -1 : a->frompos == b->frompos ? 0 : 1; - - camel_message_info_free ((CamelMessageInfo *)a); - camel_message_info_free ((CamelMessageInfo *)b); - - return res; -} - -static void -mbox_folder_sort_uids (CamelFolder *folder, - GPtrArray *uids) -{ - g_return_if_fail (camel_mbox_folder_parent_class != NULL); - g_return_if_fail (folder != NULL); - - if (uids && uids->len > 1) - camel_folder_summary_prepare_fetch_all (folder->summary, NULL); - - CAMEL_FOLDER_CLASS (camel_mbox_folder_parent_class)->sort_uids (folder, uids); -} - -static gchar * -mbox_folder_get_filename (CamelFolder *folder, - const gchar *uid, - GError **error) -{ - CamelLocalFolder *lf = (CamelLocalFolder *)folder; - CamelMboxMessageInfo *info; - goffset frompos; - gchar *filename = NULL; - - d(printf("Getting message %s\n", uid)); - - /* lock the folder first, burn if we can't, need write lock for summary check */ - if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) - return NULL; - - /* check for new messages always */ - if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, NULL, error) == -1) { - camel_local_folder_unlock (lf); - return NULL; - } - - /* get the message summary info */ - info = (CamelMboxMessageInfo *) camel_folder_summary_uid (folder->summary, uid); - - if (info == NULL) { - set_cannot_get_message_ex ( - error, CAMEL_FOLDER_ERROR_INVALID_UID, - uid, lf->folder_path, _("No such message")); - goto fail; - } - - if (info->frompos == -1) { - camel_message_info_free ((CamelMessageInfo *)info); - goto fail; - } - - frompos = info->frompos; - camel_message_info_free ((CamelMessageInfo *)info); - - filename = g_strdup_printf ("%s%s!%" PRId64, lf->folder_path, G_DIR_SEPARATOR_S, (gint64) frompos); - -fail: - /* and unlock now we're finished with it */ - camel_local_folder_unlock (lf); - - return filename; -} - static CamelLocalSummary * mbox_folder_create_summary (CamelLocalFolder *lf, const gchar *path, @@ -466,11 +467,11 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *class) CamelLocalFolderClass *local_folder_class; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->append_message = mbox_folder_append_message; - folder_class->get_message = mbox_folder_get_message; folder_class->cmp_uids = mbox_folder_cmp_uids; folder_class->sort_uids = mbox_folder_sort_uids; folder_class->get_filename = mbox_folder_get_filename; + folder_class->append_message_sync = mbox_folder_append_message_sync; + folder_class->get_message_sync = mbox_folder_get_message_sync; local_folder_class = CAMEL_LOCAL_FOLDER_CLASS (class); local_folder_class->create_summary = mbox_folder_create_summary; diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c index 9830155..cb4a35f 100644 --- a/camel/providers/local/camel-mbox-store.c +++ b/camel/providers/local/camel-mbox-store.c @@ -38,44 +38,40 @@ #define d(x) -static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); -static gboolean delete_folder (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); -static gboolean rename_folder (CamelStore *store, const gchar *old, const gchar *new, GCancellable *cancellable, GError **error); -static CamelFolderInfo *create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GCancellable *cancellable, GError **error); -static CamelFolderInfo *get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); -static gchar *mbox_get_meta_path (CamelLocalStore *ls, const gchar *full_name, const gchar *ext); -static gchar *mbox_get_full_path (CamelLocalStore *ls, const gchar *full_name); - G_DEFINE_TYPE (CamelMboxStore, camel_mbox_store, CAMEL_TYPE_LOCAL_STORE) -static void -camel_mbox_store_class_init (CamelMboxStoreClass *class) +static const gchar *extensions[] = { + ".msf", ".ev-summary", ".ev-summary-meta", ".ibex.index", ".ibex.index.data", ".cmeta", ".lock", ".db", ".journal" +}; + +/* used to find out where we've visited already */ +struct _inode { + dev_t dnode; + ino_t inode; +}; + +static guint +inode_hash (gconstpointer d) { - CamelStoreClass *store_class; - CamelLocalStoreClass *local_store_class; + const struct _inode *v = d; - store_class = CAMEL_STORE_CLASS (class); - store_class->get_folder = get_folder; - store_class->delete_folder = delete_folder; - store_class->rename_folder = rename_folder; - store_class->create_folder = create_folder; - store_class->get_folder_info = get_folder_info; - store_class->free_folder_info = camel_store_free_folder_info_full; + return v->inode ^ v->dnode; +} - local_store_class = CAMEL_LOCAL_STORE_CLASS (class); - local_store_class->get_full_path = mbox_get_full_path; - local_store_class->get_meta_path = mbox_get_meta_path; +static gboolean +inode_equal (gconstpointer a, gconstpointer b) +{ + const struct _inode *v1 = a, *v2 = b; + + return v1->inode == v2->inode && v1->dnode == v2->dnode; } static void -camel_mbox_store_init (CamelMboxStore *mbox_store) +inode_free (gpointer k, gpointer v, gpointer d) { + g_free (k); } -static const gchar *extensions[] = { - ".msf", ".ev-summary", ".ev-summary-meta", ".ibex.index", ".ibex.index.data", ".cmeta", ".lock", ".db", ".journal" -}; - static gboolean ignore_file (const gchar *filename, gboolean sbd) { @@ -98,20 +94,238 @@ ignore_file (const gchar *filename, gboolean sbd) return FALSE; } +/* NB: duplicated in maildir store */ +static void +fill_fi (CamelStore *store, + CamelFolderInfo *fi, + guint32 flags) +{ + CamelFolder *folder; + + fi->unread = -1; + fi->total = -1; + folder = camel_object_bag_get (store->folders, fi->full_name); + if (folder) { + if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) + camel_folder_refresh_info_sync (folder, NULL, NULL); + fi->unread = camel_folder_get_unread_message_count (folder); + fi->total = camel_folder_get_message_count (folder); + g_object_unref (folder); + } else { + gchar *path, *folderpath; + CamelMboxSummary *mbs; + + /* This should be fast enough not to have to test for INFO_FAST */ + path = camel_local_store_get_meta_path(store, fi->full_name, ".ev-summary"); + folderpath = camel_local_store_get_full_path (store, fi->full_name); + + mbs = (CamelMboxSummary *)camel_mbox_summary_new (NULL, path, folderpath, NULL); + /* FIXME[disk-summary] track exception */ + if (camel_folder_summary_header_load_from_db ((CamelFolderSummary *)mbs, store, fi->full_name, NULL) != -1) { + fi->unread = ((CamelFolderSummary *)mbs)->unread_count; + fi->total = ((CamelFolderSummary *)mbs)->saved_count; + } + + g_object_unref (mbs); + g_free (folderpath); + g_free (path); + } +} + +static CamelFolderInfo * +scan_dir (CamelStore *store, CamelURL *url, GHashTable *visited, CamelFolderInfo *parent, const gchar *root, + const gchar *name, guint32 flags, GError **error) +{ + CamelFolderInfo *folders, *tail, *fi; + GHashTable *folder_hash; + const gchar *dent; + GDir *dir; + + tail = folders = NULL; + + if (!(dir = g_dir_open (root, 0, NULL))) + return NULL; + + folder_hash = g_hash_table_new (g_str_hash, g_str_equal); + + /* FIXME: it would be better if we queue'd up the recursive + * scans till the end so that we can limit the number of + * directory descriptors open at any given time... */ + + while ((dent = g_dir_read_name (dir))) { + gchar *short_name, *full_name, *path, *ext; + struct stat st; + + if (dent[0] == '.') + continue; + + if (ignore_file (dent, FALSE)) + continue; + + path = g_strdup_printf("%s/%s", root, dent); + if (g_stat (path, &st) == -1) { + g_free (path); + continue; + } +#ifndef G_OS_WIN32 + if (S_ISDIR (st.st_mode)) { + struct _inode in = { st.st_dev, st.st_ino }; + + if (g_hash_table_lookup (visited, &in)) { + g_free (path); + continue; + } + } +#endif + short_name = g_strdup (dent); + if ((ext = strrchr(short_name, '.')) && !strcmp(ext, ".sbd")) + *ext = '\0'; + + if (name != NULL) + full_name = g_strdup_printf("%s/%s", name, short_name); + else + full_name = g_strdup (short_name); + + if ((fi = g_hash_table_lookup (folder_hash, short_name)) != NULL) { + g_free (short_name); + g_free (full_name); + + if (S_ISDIR (st.st_mode)) { + fi->flags =(fi->flags & ~CAMEL_FOLDER_NOCHILDREN) | CAMEL_FOLDER_CHILDREN; + } else { + fi->flags &= ~CAMEL_FOLDER_NOSELECT; + } + } else { + fi = camel_folder_info_new (); + fi->parent = parent; + + camel_url_set_fragment (url, full_name); + + fi->uri = camel_url_to_string (url, 0); + fi->name = short_name; + fi->full_name = full_name; + fi->unread = -1; + fi->total = -1; + + if (S_ISDIR (st.st_mode)) + fi->flags = CAMEL_FOLDER_NOSELECT; + else + fi->flags = CAMEL_FOLDER_NOCHILDREN; + + if (tail == NULL) + folders = fi; + else + tail->next = fi; + + tail = fi; + + g_hash_table_insert (folder_hash, fi->name, fi); + } + + if (!S_ISDIR (st.st_mode)) { + fill_fi (store, fi, flags); + } else if ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)) { + struct _inode in = { st.st_dev, st.st_ino }; + + if (g_hash_table_lookup (visited, &in) == NULL) { +#ifndef G_OS_WIN32 + struct _inode *inew = g_new (struct _inode, 1); + + *inew = in; + g_hash_table_insert (visited, inew, inew); +#endif + if ((fi->child = scan_dir (store, url, visited, fi, path, fi->full_name, flags, error))) + fi->flags |= CAMEL_FOLDER_CHILDREN; + else + fi->flags =(fi->flags & ~CAMEL_FOLDER_CHILDREN) | CAMEL_FOLDER_NOCHILDREN; + } + } + + g_free (path); + } + + g_dir_close (dir); + + g_hash_table_destroy (folder_hash); + + return folders; +} + +static gint +xrename (CamelStore *store, const gchar *old_name, const gchar *new_name, const gchar *ext, gboolean missingok) +{ + CamelLocalStore *ls = (CamelLocalStore *)store; + gchar *oldpath, *newpath; + struct stat st; + gint ret = -1; + gint err = 0; + + if (ext != NULL) { + oldpath = camel_local_store_get_meta_path (ls, old_name, ext); + newpath = camel_local_store_get_meta_path (ls, new_name, ext); + } else { + oldpath = camel_local_store_get_full_path (ls, old_name); + newpath = camel_local_store_get_full_path (ls, new_name); + } + + if (g_stat (oldpath, &st) == -1) { + if (missingok && errno == ENOENT) { + ret = 0; + } else { + err = errno; + ret = -1; + } +#ifndef G_OS_WIN32 + } else if (S_ISDIR (st.st_mode)) { + /* use rename for dirs */ + if (g_rename (oldpath, newpath) == 0 || g_stat (newpath, &st) == 0) { + ret = 0; + } else { + err = errno; + ret = -1; + } + } else if (link (oldpath, newpath) == 0 /* and link for files */ + ||(g_stat (newpath, &st) == 0 && st.st_nlink == 2)) { + if (unlink (oldpath) == 0) { + ret = 0; + } else { + err = errno; + unlink (newpath); + ret = -1; + } + } else { + err = errno; + ret = -1; +#else + } else if ((!g_file_test (newpath, G_FILE_TEST_EXISTS) || g_remove (newpath) == 0) && + g_rename (oldpath, newpath) == 0) { + ret = 0; + } else { + err = errno; + ret = -1; +#endif + } + + g_free (oldpath); + g_free (newpath); + + return ret; +} + static CamelFolder * -get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) +mbox_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelStoreClass *store_class; struct stat st; gchar *name; - /* Chain up to parent's get_folder() method. */ + /* Chain up to parent's get_folder_sync() method. */ store_class = CAMEL_STORE_CLASS (camel_mbox_store_parent_class); - if (!store_class->get_folder (store, folder_name, flags, cancellable, error)) + if (!store_class->get_folder_sync (store, folder_name, flags, cancellable, error)) return NULL; name = camel_local_store_get_full_path (store, folder_name); @@ -201,13 +415,188 @@ get_folder (CamelStore *store, return camel_mbox_folder_new (store, folder_name, flags, cancellable, error); } -static gboolean -delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +static CamelFolderInfo * +mbox_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { - CamelFolderInfo *fi; + GHashTable *visited; +#ifndef G_OS_WIN32 + struct _inode *inode; +#endif + gchar *path, *subdir; + CamelFolderInfo *fi; + gchar *basename; + struct stat st; + CamelURL *url; + + top = top ? top : ""; + path = camel_local_store_get_full_path (store, top); + + if (*top == '\0') { + /* requesting root dir scan */ + if (g_stat (path, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_free (path); + return NULL; + } + + visited = g_hash_table_new (inode_hash, inode_equal); +#ifndef G_OS_WIN32 + inode = g_malloc0 (sizeof (*inode)); + inode->dnode = st.st_dev; + inode->inode = st.st_ino; + + g_hash_table_insert (visited, inode, inode); +#endif + url = camel_url_copy (((CamelService *) store)->url); + fi = scan_dir (store, url, visited, NULL, path, NULL, flags, error); + g_hash_table_foreach (visited, inode_free, NULL); + g_hash_table_destroy (visited); + camel_url_free (url); + g_free (path); + + return fi; + } + + /* requesting scan of specific folder */ + if (g_stat (path, &st) == -1 || !S_ISREG (st.st_mode)) { + g_free (path); + return NULL; + } + + visited = g_hash_table_new (inode_hash, inode_equal); + + basename = g_path_get_basename (top); + + url = camel_url_copy (((CamelService *) store)->url); + camel_url_set_fragment (url, top); + + fi = camel_folder_info_new (); + fi->parent = NULL; + fi->uri = camel_url_to_string (url, 0); + fi->name = basename; + fi->full_name = g_strdup (top); + fi->unread = -1; + fi->total = -1; + + subdir = g_strdup_printf("%s.sbd", path); + if (g_stat (subdir, &st) == 0) { + if (S_ISDIR (st.st_mode)) + fi->child = scan_dir (store, url, visited, fi, subdir, top, flags, error); + else + fill_fi (store, fi, flags); + } else + fill_fi (store, fi, flags); + + camel_url_free (url); + + if (fi->child) + fi->flags |= CAMEL_FOLDER_CHILDREN; + else + fi->flags |= CAMEL_FOLDER_NOCHILDREN; + + g_free (subdir); + + g_hash_table_foreach (visited, inode_free, NULL); + g_hash_table_destroy (visited); + g_free (path); + + return fi; +} + +static CamelFolderInfo * +mbox_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + /* FIXME: this is almost an exact copy of CamelLocalStore::create_folder() except that we use + * different path schemes... need to find a way to share parent's code? */ + const gchar *toplevel_dir =((CamelLocalStore *) store)->toplevel_dir; + CamelFolderInfo *info = NULL; + gchar *path, *name, *dir; + CamelFolder *folder; + struct stat st; + + if (!g_path_is_absolute (toplevel_dir)) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Store root %s is not an absolute path"), + toplevel_dir); + return NULL; + } + + if (folder_name[0] == '.' || ignore_file (folder_name, TRUE)) { + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Cannot create a folder by this name.")); + return NULL; + } + + if (parent_name && *parent_name) + name = g_strdup_printf("%s/%s", parent_name, folder_name); + else + name = g_strdup (folder_name); + + path = camel_local_store_get_full_path (store, name); + + dir = g_path_get_dirname (path); + if (g_mkdir_with_parents (dir, 0777) == -1 && errno != EEXIST) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Cannot create directory '%s': %s."), + dir, g_strerror (errno)); + + g_free (path); + g_free (name); + g_free (dir); + + return NULL; + } + + g_free (dir); + + if (g_stat (path, &st) == 0 || errno != ENOENT) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Cannot create folder: %s: %s"), + path, errno ? g_strerror (errno) : + _("Folder already exists")); + + g_free (path); + g_free (name); + + return NULL; + } + + g_free (path); + + folder = CAMEL_STORE_GET_CLASS (store)->get_folder_sync ( + store, name, CAMEL_STORE_FOLDER_CREATE, cancellable, error); + if (folder) { + g_object_unref (folder); + info = CAMEL_STORE_GET_CLASS (store)->get_folder_info_sync ( + store, name, 0, cancellable, error); + } + + g_free (name); + + return info; +} + +static gboolean +mbox_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + CamelFolderInfo *fi; CamelFolder *lf; gchar *name, *path; struct stat st; @@ -315,7 +704,7 @@ delete_folder (CamelStore *store, g_free (path); path = NULL; - if ((lf = camel_store_get_folder (store, folder_name, 0, cancellable, NULL))) { + if ((lf = camel_store_get_folder_sync (store, folder_name, 0, cancellable, NULL))) { CamelObject *object = CAMEL_OBJECT (lf); const gchar *state_filename; @@ -357,211 +746,66 @@ delete_folder (CamelStore *store, return TRUE; } -static CamelFolderInfo * -create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +static gboolean +mbox_store_rename_folder_sync (CamelStore *store, + const gchar *old, + const gchar *new, + GCancellable *cancellable, + GError **error) { - /* FIXME: this is almost an exact copy of CamelLocalStore::create_folder() except that we use - * different path schemes... need to find a way to share parent's code? */ - const gchar *toplevel_dir =((CamelLocalStore *) store)->toplevel_dir; - CamelFolderInfo *info = NULL; - gchar *path, *name, *dir; - CamelFolder *folder; - struct stat st; - - if (!g_path_is_absolute (toplevel_dir)) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Store root %s is not an absolute path"), - toplevel_dir); - return NULL; - } + CamelLocalFolder *folder = NULL; + gchar *oldibex, *newibex, *newdir; + gint errnosav; - if (folder_name[0] == '.' || ignore_file (folder_name, TRUE)) { + if (new[0] == '.' || ignore_file (new, TRUE)) { g_set_error ( error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("Cannot create a folder by this name.")); - return NULL; + _("The new folder name is illegal.")); + return FALSE; } - if (parent_name && *parent_name) - name = g_strdup_printf("%s/%s", parent_name, folder_name); - else - name = g_strdup (folder_name); + /* try to rollback failures, has obvious races */ - path = camel_local_store_get_full_path (store, name); + oldibex = camel_local_store_get_meta_path(store, old, ".ibex"); + newibex = camel_local_store_get_meta_path(store, new, ".ibex"); - dir = g_path_get_dirname (path); - if (g_mkdir_with_parents (dir, 0777) == -1 && errno != EEXIST) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Cannot create directory '%s': %s."), - dir, g_strerror (errno)); + newdir = g_path_get_dirname (newibex); + if (g_mkdir_with_parents (newdir, 0700) == -1) { + if (errno != EEXIST) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Could not rename '%s': '%s': %s"), + old, new, g_strerror (errno)); + g_free (oldibex); + g_free (newibex); + g_free (newdir); - g_free (path); - g_free (name); - g_free (dir); + return FALSE; + } - return NULL; + g_free (newdir); + newdir = NULL; } - g_free (dir); - - if (g_stat (path, &st) == 0 || errno != ENOENT) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Cannot create folder: %s: %s"), - path, errno ? g_strerror (errno) : - _("Folder already exists")); - - g_free (path); - g_free (name); - - return NULL; + folder = camel_object_bag_get (store->folders, old); + if (folder && folder->index) { + if (camel_index_rename (folder->index, newibex) == -1 && errno != ENOENT) { + errnosav = errno; + goto ibex_failed; + } + } else { + /* TODO: camel_text_index_rename should find out if we have an active index itself? */ + if (camel_text_index_rename (oldibex, newibex) == -1 && errno != ENOENT) { + errnosav = errno; + goto ibex_failed; + } } - g_free (path); - - folder = CAMEL_STORE_GET_CLASS (store)->get_folder ( - store, name, CAMEL_STORE_FOLDER_CREATE, cancellable, error); - if (folder) { - g_object_unref (folder); - info = CAMEL_STORE_GET_CLASS (store)->get_folder_info ( - store, name, 0, cancellable, error); - } - - g_free (name); - - return info; -} - -static gint -xrename (CamelStore *store, const gchar *old_name, const gchar *new_name, const gchar *ext, gboolean missingok) -{ - CamelLocalStore *ls = (CamelLocalStore *)store; - gchar *oldpath, *newpath; - struct stat st; - gint ret = -1; - gint err = 0; - - if (ext != NULL) { - oldpath = camel_local_store_get_meta_path (ls, old_name, ext); - newpath = camel_local_store_get_meta_path (ls, new_name, ext); - } else { - oldpath = camel_local_store_get_full_path (ls, old_name); - newpath = camel_local_store_get_full_path (ls, new_name); - } - - if (g_stat (oldpath, &st) == -1) { - if (missingok && errno == ENOENT) { - ret = 0; - } else { - err = errno; - ret = -1; - } -#ifndef G_OS_WIN32 - } else if (S_ISDIR (st.st_mode)) { - /* use rename for dirs */ - if (g_rename (oldpath, newpath) == 0 || g_stat (newpath, &st) == 0) { - ret = 0; - } else { - err = errno; - ret = -1; - } - } else if (link (oldpath, newpath) == 0 /* and link for files */ - ||(g_stat (newpath, &st) == 0 && st.st_nlink == 2)) { - if (unlink (oldpath) == 0) { - ret = 0; - } else { - err = errno; - unlink (newpath); - ret = -1; - } - } else { - err = errno; - ret = -1; -#else - } else if ((!g_file_test (newpath, G_FILE_TEST_EXISTS) || g_remove (newpath) == 0) && - g_rename (oldpath, newpath) == 0) { - ret = 0; - } else { - err = errno; - ret = -1; -#endif - } - - g_free (oldpath); - g_free (newpath); - - return ret; -} - -static gboolean -rename_folder (CamelStore *store, - const gchar *old, - const gchar *new, - GCancellable *cancellable, - GError **error) -{ - CamelLocalFolder *folder = NULL; - gchar *oldibex, *newibex, *newdir; - gint errnosav; - - if (new[0] == '.' || ignore_file (new, TRUE)) { - g_set_error ( - error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("The new folder name is illegal.")); - return FALSE; - } - - /* try to rollback failures, has obvious races */ - - oldibex = camel_local_store_get_meta_path(store, old, ".ibex"); - newibex = camel_local_store_get_meta_path(store, new, ".ibex"); - - newdir = g_path_get_dirname (newibex); - if (g_mkdir_with_parents (newdir, 0700) == -1) { - if (errno != EEXIST) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Could not rename '%s': '%s': %s"), - old, new, g_strerror (errno)); - g_free (oldibex); - g_free (newibex); - g_free (newdir); - - return FALSE; - } - - g_free (newdir); - newdir = NULL; - } - - folder = camel_object_bag_get (store->folders, old); - if (folder && folder->index) { - if (camel_index_rename (folder->index, newibex) == -1 && errno != ENOENT) { - errnosav = errno; - goto ibex_failed; - } - } else { - /* TODO: camel_text_index_rename should find out if we have an active index itself? */ - if (camel_text_index_rename (oldibex, newibex) == -1 && errno != ENOENT) { - errnosav = errno; - goto ibex_failed; - } - } - - if (xrename(store, old, new, ".ev-summary", TRUE) == -1) { - errnosav = errno; - goto summary_failed; - } + if (xrename(store, old, new, ".ev-summary", TRUE) == -1) { + errnosav = errno; + goto summary_failed; + } if (xrename(store, old, new, ".ev-summary-meta", TRUE) == -1) { errnosav = errno; @@ -626,284 +870,9 @@ ibex_failed: return FALSE; } -/* used to find out where we've visited already */ -struct _inode { - dev_t dnode; - ino_t inode; -}; - -static guint -inode_hash (gconstpointer d) -{ - const struct _inode *v = d; - - return v->inode ^ v->dnode; -} - -static gboolean -inode_equal (gconstpointer a, gconstpointer b) -{ - const struct _inode *v1 = a, *v2 = b; - - return v1->inode == v2->inode && v1->dnode == v2->dnode; -} - -static void -inode_free (gpointer k, gpointer v, gpointer d) -{ - g_free (k); -} - -/* NB: duplicated in maildir store */ -static void -fill_fi (CamelStore *store, - CamelFolderInfo *fi, - guint32 flags) -{ - CamelFolder *folder; - - fi->unread = -1; - fi->total = -1; - folder = camel_object_bag_get (store->folders, fi->full_name); - if (folder) { - if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - camel_folder_refresh_info (folder, NULL, NULL); - fi->unread = camel_folder_get_unread_message_count (folder); - fi->total = camel_folder_get_message_count (folder); - g_object_unref (folder); - } else { - gchar *path, *folderpath; - CamelMboxSummary *mbs; - - /* This should be fast enough not to have to test for INFO_FAST */ - path = camel_local_store_get_meta_path(store, fi->full_name, ".ev-summary"); - folderpath = camel_local_store_get_full_path (store, fi->full_name); - - mbs = (CamelMboxSummary *)camel_mbox_summary_new (NULL, path, folderpath, NULL); - /* FIXME[disk-summary] track exception */ - if (camel_folder_summary_header_load_from_db ((CamelFolderSummary *)mbs, store, fi->full_name, NULL) != -1) { - fi->unread = ((CamelFolderSummary *)mbs)->unread_count; - fi->total = ((CamelFolderSummary *)mbs)->saved_count; - } - - g_object_unref (mbs); - g_free (folderpath); - g_free (path); - } -} - -static CamelFolderInfo * -scan_dir (CamelStore *store, CamelURL *url, GHashTable *visited, CamelFolderInfo *parent, const gchar *root, - const gchar *name, guint32 flags, GError **error) -{ - CamelFolderInfo *folders, *tail, *fi; - GHashTable *folder_hash; - const gchar *dent; - GDir *dir; - - tail = folders = NULL; - - if (!(dir = g_dir_open (root, 0, NULL))) - return NULL; - - folder_hash = g_hash_table_new (g_str_hash, g_str_equal); - - /* FIXME: it would be better if we queue'd up the recursive - * scans till the end so that we can limit the number of - * directory descriptors open at any given time... */ - - while ((dent = g_dir_read_name (dir))) { - gchar *short_name, *full_name, *path, *ext; - struct stat st; - - if (dent[0] == '.') - continue; - - if (ignore_file (dent, FALSE)) - continue; - - path = g_strdup_printf("%s/%s", root, dent); - if (g_stat (path, &st) == -1) { - g_free (path); - continue; - } -#ifndef G_OS_WIN32 - if (S_ISDIR (st.st_mode)) { - struct _inode in = { st.st_dev, st.st_ino }; - - if (g_hash_table_lookup (visited, &in)) { - g_free (path); - continue; - } - } -#endif - short_name = g_strdup (dent); - if ((ext = strrchr(short_name, '.')) && !strcmp(ext, ".sbd")) - *ext = '\0'; - - if (name != NULL) - full_name = g_strdup_printf("%s/%s", name, short_name); - else - full_name = g_strdup (short_name); - - if ((fi = g_hash_table_lookup (folder_hash, short_name)) != NULL) { - g_free (short_name); - g_free (full_name); - - if (S_ISDIR (st.st_mode)) { - fi->flags =(fi->flags & ~CAMEL_FOLDER_NOCHILDREN) | CAMEL_FOLDER_CHILDREN; - } else { - fi->flags &= ~CAMEL_FOLDER_NOSELECT; - } - } else { - fi = camel_folder_info_new (); - fi->parent = parent; - - camel_url_set_fragment (url, full_name); - - fi->uri = camel_url_to_string (url, 0); - fi->name = short_name; - fi->full_name = full_name; - fi->unread = -1; - fi->total = -1; - - if (S_ISDIR (st.st_mode)) - fi->flags = CAMEL_FOLDER_NOSELECT; - else - fi->flags = CAMEL_FOLDER_NOCHILDREN; - - if (tail == NULL) - folders = fi; - else - tail->next = fi; - - tail = fi; - - g_hash_table_insert (folder_hash, fi->name, fi); - } - - if (!S_ISDIR (st.st_mode)) { - fill_fi (store, fi, flags); - } else if ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)) { - struct _inode in = { st.st_dev, st.st_ino }; - - if (g_hash_table_lookup (visited, &in) == NULL) { -#ifndef G_OS_WIN32 - struct _inode *inew = g_new (struct _inode, 1); - - *inew = in; - g_hash_table_insert (visited, inew, inew); -#endif - if ((fi->child = scan_dir (store, url, visited, fi, path, fi->full_name, flags, error))) - fi->flags |= CAMEL_FOLDER_CHILDREN; - else - fi->flags =(fi->flags & ~CAMEL_FOLDER_CHILDREN) | CAMEL_FOLDER_NOCHILDREN; - } - } - - g_free (path); - } - - g_dir_close (dir); - - g_hash_table_destroy (folder_hash); - - return folders; -} - -static CamelFolderInfo * -get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) -{ - GHashTable *visited; -#ifndef G_OS_WIN32 - struct _inode *inode; -#endif - gchar *path, *subdir; - CamelFolderInfo *fi; - gchar *basename; - struct stat st; - CamelURL *url; - - top = top ? top : ""; - path = camel_local_store_get_full_path (store, top); - - if (*top == '\0') { - /* requesting root dir scan */ - if (g_stat (path, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_free (path); - return NULL; - } - - visited = g_hash_table_new (inode_hash, inode_equal); -#ifndef G_OS_WIN32 - inode = g_malloc0 (sizeof (*inode)); - inode->dnode = st.st_dev; - inode->inode = st.st_ino; - - g_hash_table_insert (visited, inode, inode); -#endif - url = camel_url_copy (((CamelService *) store)->url); - fi = scan_dir (store, url, visited, NULL, path, NULL, flags, error); - g_hash_table_foreach (visited, inode_free, NULL); - g_hash_table_destroy (visited); - camel_url_free (url); - g_free (path); - - return fi; - } - - /* requesting scan of specific folder */ - if (g_stat (path, &st) == -1 || !S_ISREG (st.st_mode)) { - g_free (path); - return NULL; - } - - visited = g_hash_table_new (inode_hash, inode_equal); - - basename = g_path_get_basename (top); - - url = camel_url_copy (((CamelService *) store)->url); - camel_url_set_fragment (url, top); - - fi = camel_folder_info_new (); - fi->parent = NULL; - fi->uri = camel_url_to_string (url, 0); - fi->name = basename; - fi->full_name = g_strdup (top); - fi->unread = -1; - fi->total = -1; - - subdir = g_strdup_printf("%s.sbd", path); - if (g_stat (subdir, &st) == 0) { - if (S_ISDIR (st.st_mode)) - fi->child = scan_dir (store, url, visited, fi, subdir, top, flags, error); - else - fill_fi (store, fi, flags); - } else - fill_fi (store, fi, flags); - - camel_url_free (url); - - if (fi->child) - fi->flags |= CAMEL_FOLDER_CHILDREN; - else - fi->flags |= CAMEL_FOLDER_NOCHILDREN; - - g_free (subdir); - - g_hash_table_foreach (visited, inode_free, NULL); - g_hash_table_destroy (visited); - g_free (path); - - return fi; -} - static gchar * -mbox_get_full_path (CamelLocalStore *ls, const gchar *full_name) +mbox_store_get_full_path (CamelLocalStore *ls, + const gchar *full_name) { const gchar *inptr = full_name; gint subdirs = 0; @@ -939,7 +908,9 @@ mbox_get_full_path (CamelLocalStore *ls, const gchar *full_name) } static gchar * -mbox_get_meta_path (CamelLocalStore *ls, const gchar *full_name, const gchar *ext) +mbox_store_get_meta_path (CamelLocalStore *ls, + const gchar *full_name, + const gchar *ext) { /*#define USE_HIDDEN_META_FILES*/ #ifdef USE_HIDDEN_META_FILES @@ -951,14 +922,39 @@ mbox_get_meta_path (CamelLocalStore *ls, const gchar *full_name, const gchar *ex else sprintf (name, ".%s%s", full_name, ext); - return mbox_get_full_path (ls, name); + return mbox_store_get_full_path (ls, name); #else gchar *full_path, *path; - full_path = mbox_get_full_path (ls, full_name); + full_path = mbox_store_get_full_path (ls, full_name); path = g_strdup_printf ("%s%s", full_path, ext); g_free (full_path); return path; #endif } + +static void +camel_mbox_store_class_init (CamelMboxStoreClass *class) +{ + CamelStoreClass *store_class; + CamelLocalStoreClass *local_store_class; + + store_class = CAMEL_STORE_CLASS (class); + store_class->free_folder_info = camel_store_free_folder_info_full; + store_class->get_folder_sync = mbox_store_get_folder_sync; + store_class->get_folder_info_sync = mbox_store_get_folder_info_sync; + store_class->create_folder_sync = mbox_store_create_folder_sync; + store_class->delete_folder_sync = mbox_store_delete_folder_sync; + store_class->rename_folder_sync = mbox_store_rename_folder_sync; + + local_store_class = CAMEL_LOCAL_STORE_CLASS (class); + local_store_class->get_full_path = mbox_store_get_full_path; + local_store_class->get_meta_path = mbox_store_get_meta_path; +} + +static void +camel_mbox_store_init (CamelMboxStore *mbox_store) +{ +} + diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c index 7b4cd1c..a005a13 100644 --- a/camel/providers/local/camel-mh-folder.c +++ b/camel/providers/local/camel-mh-folder.c @@ -42,13 +42,23 @@ G_DEFINE_TYPE (CamelMhFolder, camel_mh_folder, CAMEL_TYPE_LOCAL_FOLDER) +static gchar * +mh_folder_get_filename (CamelFolder *folder, + const gchar *uid, + GError **error) +{ + CamelLocalFolder *lf = (CamelLocalFolder *)folder; + + return g_strdup_printf("%s/%s", lf->folder_path, uid); +} + static gboolean -mh_folder_append_message (CamelFolder *folder, - CamelMimeMessage *message, - const CamelMessageInfo *info, - gchar **appended_uid, - GCancellable *cancellable, - GError **error) +mh_folder_append_message_sync (CamelFolder *folder, + CamelMimeMessage *message, + const CamelMessageInfo *info, + gchar **appended_uid, + GCancellable *cancellable, + GError **error) { CamelLocalFolder *lf = (CamelLocalFolder *)folder; CamelStream *output_stream; @@ -80,7 +90,7 @@ mh_folder_append_message (CamelFolder *folder, if (output_stream == NULL) goto fail_write; - if (camel_data_wrapper_write_to_stream ( + if (camel_data_wrapper_write_to_stream_sync ( (CamelDataWrapper *)message, output_stream, cancellable, error) == -1 || camel_stream_close (output_stream, cancellable, error) == -1) goto fail_write; @@ -123,10 +133,10 @@ mh_folder_append_message (CamelFolder *folder, } static CamelMimeMessage * -mh_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +mh_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelLocalFolder *lf = (CamelLocalFolder *)folder; CamelStream *message_stream = NULL; @@ -161,7 +171,9 @@ mh_folder_get_message (CamelFolder *folder, } message = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, message_stream, cancellable, error) == -1) { + if (camel_data_wrapper_construct_from_stream_sync ( + (CamelDataWrapper *)message, + message_stream, cancellable, error) == -1) { g_prefix_error ( error, _("Cannot get message %s from folder %s: "), name, lf->folder_path); @@ -184,16 +196,6 @@ mh_folder_get_message (CamelFolder *folder, return message; } -static gchar * -mh_folder_get_filename (CamelFolder *folder, - const gchar *uid, - GError **error) -{ - CamelLocalFolder *lf = (CamelLocalFolder *)folder; - - return g_strdup_printf("%s/%s", lf->folder_path, uid); -} - static CamelLocalSummary * mh_folder_create_summary (CamelLocalFolder *lf, const gchar *path, @@ -211,9 +213,9 @@ camel_mh_folder_class_init (CamelMhFolderClass *class) CamelLocalFolderClass *local_folder_class; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->append_message = mh_folder_append_message; - folder_class->get_message = mh_folder_get_message; folder_class->get_filename = mh_folder_get_filename; + folder_class->append_message_sync = mh_folder_append_message_sync; + folder_class->get_message_sync = mh_folder_get_message_sync; local_folder_class = CAMEL_LOCAL_FOLDER_CLASS (class); local_folder_class->create_summary = mh_folder_create_summary; diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c index a842bc2..3dac19e 100644 --- a/camel/providers/local/camel-mh-store.c +++ b/camel/providers/local/camel-mh-store.c @@ -38,58 +38,8 @@ #define d(x) -static gboolean construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, GError **error); -static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); -static CamelFolder *get_inbox (CamelStore *store, GCancellable *cancellable, GError **error); -static gboolean delete_folder (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); -static gboolean rename_folder (CamelStore *store, const gchar *old, const gchar *new, GCancellable *cancellable, GError **error); -static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); - G_DEFINE_TYPE (CamelMhStore, camel_mh_store, CAMEL_TYPE_LOCAL_STORE) -static void -camel_mh_store_class_init (CamelMhStoreClass *class) -{ - CamelServiceClass *service_class; - CamelStoreClass *store_class; - - service_class = CAMEL_SERVICE_CLASS (class); - service_class->construct = construct; - - store_class = CAMEL_STORE_CLASS (class); - store_class->get_folder = get_folder; - store_class->get_inbox = get_inbox; - store_class->delete_folder = delete_folder; - store_class->rename_folder = rename_folder; - store_class->get_folder_info = get_folder_info; -} - -static void -camel_mh_store_init (CamelMhStore *mh_store) -{ -} - -static gboolean -construct (CamelService *service, - CamelSession *session, - CamelProvider *provider, - CamelURL *url, - GError **error) -{ - CamelServiceClass *service_class; - CamelMhStore *mh_store = (CamelMhStore *)service; - - /* Chain up to parent's construct() method. */ - service_class = CAMEL_SERVICE_CLASS (camel_mh_store_parent_class); - if (!service_class->construct (service, session, provider, url, error)) - return FALSE; - - if (camel_url_get_param(url, "dotfolders")) - mh_store->flags |= CAMEL_MH_DOTFOLDERS; - - return TRUE; -} - enum { UPDATE_NONE, UPDATE_ADD, @@ -191,141 +141,6 @@ fail: g_object_unref (out); } -static CamelFolder * -get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) -{ - CamelStoreClass *store_class; - gchar *name; - struct stat st; - - /* Chain up to parent's get_folder() method. */ - store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class); - if (store_class->get_folder (store, folder_name, flags, cancellable, error) == NULL) - return NULL; - - name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); - - if (g_stat (name, &st) == -1) { - if (errno != ENOENT) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Cannot get folder '%s': %s"), - folder_name, g_strerror (errno)); - g_free (name); - return NULL; - } - if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot get folder '%s': folder does not exist."), - folder_name); - g_free (name); - return NULL; - } - - if (mkdir (name, 0777) != 0) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Could not create folder '%s': %s"), - folder_name, g_strerror (errno)); - g_free (name); - return NULL; - } - - /* add to .folders if we are supposed to */ - /* FIXME: throw exception on error */ - if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) - folders_update (((CamelLocalStore *)store)->toplevel_dir, UPDATE_ADD, folder_name, NULL, cancellable); - } else if (!S_ISDIR (st.st_mode)) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Cannot get folder '%s': not a directory."), - folder_name); - g_free (name); - return NULL; - } else if (flags & CAMEL_STORE_FOLDER_EXCL) { - g_set_error ( - error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("Cannot create folder '%s': folder exists."), - folder_name); - g_free (name); - return NULL; - } - - g_free (name); - - return camel_mh_folder_new (store, folder_name, flags, cancellable, error); -} - -static CamelFolder * -get_inbox (CamelStore *store, - GCancellable *cancellable, - GError **error) -{ - return get_folder (store, "inbox", 0, cancellable, error); -} - -static gboolean -delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - CamelStoreClass *store_class; - gchar *name; - - /* remove folder directory - will fail if not empty */ - name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); - if (rmdir (name) == -1) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Could not delete folder '%s': %s"), - folder_name, g_strerror (errno)); - g_free (name); - return FALSE; - } - g_free (name); - - /* remove from .folders if we are supposed to */ - if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) - folders_update (((CamelLocalStore *)store)->toplevel_dir, UPDATE_REMOVE, folder_name, NULL, cancellable); - - /* Chain up to parent's delete_folder() method. */ - store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class); - return store_class->delete_folder (store, folder_name, cancellable, error); -} - -static gboolean -rename_folder (CamelStore *store, - const gchar *old, - const gchar *new, - GCancellable *cancellable, - GError **error) -{ - CamelStoreClass *store_class; - - /* Chain up to parent's rename_folder() method. */ - store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class); - if (!store_class->rename_folder (store, old, new, cancellable, error)) - return FALSE; - - if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) { - /* yeah this is messy, but so is mh! */ - folders_update (((CamelLocalStore *)store)->toplevel_dir, UPDATE_RENAME, old, new, cancellable); - } - - return TRUE; -} - static void fill_fi (CamelStore *store, CamelFolderInfo *fi, @@ -338,11 +153,12 @@ fill_fi (CamelStore *store, if (folder == NULL && (flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - folder = camel_store_get_folder (store, fi->full_name, 0, cancellable, NULL); + folder = camel_store_get_folder_sync ( + store, fi->full_name, 0, cancellable, NULL); if (folder) { if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - camel_folder_refresh_info (folder, cancellable, NULL); + camel_folder_refresh_info_sync (folder, cancellable, NULL); fi->unread = camel_folder_get_unread_message_count (folder); fi->total = camel_folder_get_message_count (folder); g_object_unref (folder); @@ -595,12 +411,108 @@ inode_free (gpointer k, gpointer v, gpointer d) g_free (k); } +static gboolean +mh_folder_store_construct (CamelService *service, + CamelSession *session, + CamelProvider *provider, + CamelURL *url, + GError **error) +{ + CamelServiceClass *service_class; + CamelMhStore *mh_store = (CamelMhStore *)service; + + /* Chain up to parent's construct() method. */ + service_class = CAMEL_SERVICE_CLASS (camel_mh_store_parent_class); + if (!service_class->construct (service, session, provider, url, error)) + return FALSE; + + if (camel_url_get_param(url, "dotfolders")) + mh_store->flags |= CAMEL_MH_DOTFOLDERS; + + return TRUE; +} + +static CamelFolder * +mh_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) +{ + CamelStoreClass *store_class; + gchar *name; + struct stat st; + + /* Chain up to parent's get_folder() method. */ + store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class); + if (store_class->get_folder_sync ( + store, folder_name, flags, cancellable, error) == NULL) + return NULL; + + name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); + + if (g_stat (name, &st) == -1) { + if (errno != ENOENT) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Cannot get folder '%s': %s"), + folder_name, g_strerror (errno)); + g_free (name); + return NULL; + } + if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot get folder '%s': folder does not exist."), + folder_name); + g_free (name); + return NULL; + } + + if (mkdir (name, 0777) != 0) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Could not create folder '%s': %s"), + folder_name, g_strerror (errno)); + g_free (name); + return NULL; + } + + /* add to .folders if we are supposed to */ + /* FIXME: throw exception on error */ + if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) + folders_update (((CamelLocalStore *)store)->toplevel_dir, UPDATE_ADD, folder_name, NULL, cancellable); + } else if (!S_ISDIR (st.st_mode)) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Cannot get folder '%s': not a directory."), + folder_name); + g_free (name); + return NULL; + } else if (flags & CAMEL_STORE_FOLDER_EXCL) { + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Cannot create folder '%s': folder exists."), + folder_name); + g_free (name); + return NULL; + } + + g_free (name); + + return camel_mh_folder_new (store, folder_name, flags, cancellable, error); +} + static CamelFolderInfo * -get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +mh_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelFolderInfo *fi = NULL; CamelURL *url; @@ -639,3 +551,90 @@ get_folder_info (CamelStore *store, return fi; } + +static CamelFolder * +mh_store_get_inbox_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) +{ + return mh_store_get_folder_sync ( + store, "inbox", 0, cancellable, error); +} + +static gboolean +mh_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + CamelStoreClass *store_class; + gchar *name; + + /* remove folder directory - will fail if not empty */ + name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); + if (rmdir (name) == -1) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Could not delete folder '%s': %s"), + folder_name, g_strerror (errno)); + g_free (name); + return FALSE; + } + g_free (name); + + /* remove from .folders if we are supposed to */ + if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) + folders_update (((CamelLocalStore *)store)->toplevel_dir, UPDATE_REMOVE, folder_name, NULL, cancellable); + + /* Chain up to parent's delete_folder() method. */ + store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class); + return store_class->delete_folder_sync ( + store, folder_name, cancellable, error); +} + +static gboolean +mh_store_rename_folder_sync (CamelStore *store, + const gchar *old, + const gchar *new, + GCancellable *cancellable, + GError **error) +{ + CamelStoreClass *store_class; + + /* Chain up to parent's rename_folder() method. */ + store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class); + if (!store_class->rename_folder_sync ( + store, old, new, cancellable, error)) + return FALSE; + + if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) { + /* yeah this is messy, but so is mh! */ + folders_update (((CamelLocalStore *)store)->toplevel_dir, UPDATE_RENAME, old, new, cancellable); + } + + return TRUE; +} + +static void +camel_mh_store_class_init (CamelMhStoreClass *class) +{ + CamelServiceClass *service_class; + CamelStoreClass *store_class; + + service_class = CAMEL_SERVICE_CLASS (class); + service_class->construct = mh_folder_store_construct; + + store_class = CAMEL_STORE_CLASS (class); + store_class->get_folder_sync = mh_store_get_folder_sync; + store_class->get_folder_info_sync = mh_store_get_folder_info_sync; + store_class->get_inbox_folder_sync = mh_store_get_inbox_sync; + store_class->delete_folder_sync = mh_store_delete_folder_sync; + store_class->rename_folder_sync = mh_store_rename_folder_sync; +} + +static void +camel_mh_store_init (CamelMhStore *mh_store) +{ +} + diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c index 04f173f..7b6028a 100644 --- a/camel/providers/local/camel-spool-store.c +++ b/camel/providers/local/camel-spool-store.c @@ -40,235 +40,8 @@ #define d(x) -static gboolean construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, GError **error); -static CamelFolder *get_folder (CamelStore* store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error); -static gchar *get_name (CamelService *service, gboolean brief); -static CamelFolder *get_inbox (CamelStore *store, GCancellable *cancellable, GError **error); -static gboolean rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, GCancellable *cancellable, GError **error); -static CamelFolderInfo *get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GCancellable *cancellable, GError **error); -static void free_folder_info (CamelStore *store, CamelFolderInfo *fi); - -static gboolean delete_folder (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error); - -static gchar *spool_get_meta_path (CamelLocalStore *ls, const gchar *full_name, const gchar *ext); -static gchar *spool_get_full_path (CamelLocalStore *ls, const gchar *full_name); - G_DEFINE_TYPE (CamelSpoolStore, camel_spool_store, CAMEL_TYPE_MBOX_STORE) -static void -camel_spool_store_class_init (CamelSpoolStoreClass *class) -{ - CamelServiceClass *service_class; - CamelStoreClass *store_class; - CamelLocalStoreClass *local_store_class; - - service_class = CAMEL_SERVICE_CLASS (class); - service_class->construct = construct; - service_class->get_name = get_name; - - store_class = CAMEL_STORE_CLASS (class); - store_class->get_folder = get_folder; - store_class->get_inbox = get_inbox; - store_class->get_folder_info = get_folder_info; - store_class->free_folder_info = free_folder_info; - store_class->delete_folder = delete_folder; - store_class->rename_folder = rename_folder; - - local_store_class = CAMEL_LOCAL_STORE_CLASS (class); - local_store_class->get_full_path = spool_get_full_path; - local_store_class->get_meta_path = spool_get_meta_path; -} - -static void -camel_spool_store_init (CamelSpoolStore *spool_store) -{ -} - -static gboolean -construct (CamelService *service, - CamelSession *session, - CamelProvider *provider, - CamelURL *url, - GError **error) -{ - CamelServiceClass *service_class; - struct stat st; - - d(printf("constructing store of type %s '%s:%s'\n", - G_OBJECT_CLASS_NAME (((CamelObject *)service)->s.type), url->protocol, url->path)); - - /* Chain up to parent's construct() method. */ - service_class = CAMEL_SERVICE_CLASS (camel_spool_store_parent_class); - if (!service_class->construct (service, session, provider, url, error)) - return FALSE; - - if (service->url->path[0] != '/') { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Store root %s is not an absolute path"), - service->url->path); - return FALSE; - } - - if (g_stat (service->url->path, &st) == -1) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Spool '%s' cannot be opened: %s"), - service->url->path, g_strerror (errno)); - return FALSE; - } - - if (S_ISREG (st.st_mode)) - ((CamelSpoolStore *)service)->type = CAMEL_SPOOL_STORE_MBOX; - else if (S_ISDIR (st.st_mode)) - /* we could check here for slight variations */ - ((CamelSpoolStore *)service)->type = CAMEL_SPOOL_STORE_ELM; - else { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Spool '%s' is not a regular file or directory"), - service->url->path); - return FALSE; - } - - return TRUE; -} - -static CamelFolder * -get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) -{ - CamelFolder *folder = NULL; - struct stat st; - gchar *name; - - d(printf("opening folder %s on path %s\n", folder_name, path)); - - /* we only support an 'INBOX' in mbox mode */ - if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX) { - if (strcmp(folder_name, "INBOX") != 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Folder '%s/%s' does not exist."), - ((CamelService *)store)->url->path, folder_name); - } else { - folder = camel_spool_folder_new (store, folder_name, flags, cancellable, error); - } - } else { - name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); - if (g_stat (name, &st) == -1) { - if (errno != ENOENT) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Could not open folder '%s':\n%s"), - folder_name, g_strerror (errno)); - } else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Folder '%s' does not exist."), - folder_name); - } else { - if (creat (name, 0600) == -1) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Could not create folder '%s':\n%s"), - folder_name, g_strerror (errno)); - } else { - folder = camel_spool_folder_new (store, folder_name, flags, cancellable, error); - } - } - } else if (!S_ISREG (st.st_mode)) { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("'%s' is not a mailbox file."), name); - } else { - folder = camel_spool_folder_new (store, folder_name, flags, cancellable, error); - } - g_free (name); - } - - return folder; -} - -static CamelFolder * -get_inbox (CamelStore *store, - GCancellable *cancellable, - GError **error) -{ - if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX) - return get_folder (store, "INBOX", CAMEL_STORE_FOLDER_CREATE, cancellable, error); - else { - g_set_error ( - error, CAMEL_STORE_ERROR, - CAMEL_STORE_ERROR_NO_FOLDER, - _("Store does not support an INBOX")); - return NULL; - } -} - -static gchar * -get_name (CamelService *service, - gboolean brief) -{ - if (brief) - return g_strdup (service->url->path); - else - return g_strdup_printf (((CamelSpoolStore *)service)->type == CAMEL_SPOOL_STORE_MBOX? - _("Spool mail file %s"):_("Spool folder tree %s"), service->url->path); -} - -/* default implementation, rename all */ -static gboolean -rename_folder (CamelStore *store, - const gchar *old, - const gchar *new, - GCancellable *cancellable, - GError **error) -{ - g_set_error ( - error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("Spool folders cannot be renamed")); - - return FALSE; -} - -/* default implementation, only delete metadata */ -static gboolean -delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) -{ - g_set_error ( - error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("Spool folders cannot be deleted")); - - return FALSE; -} - -static void -free_folder_info (CamelStore *store, - CamelFolderInfo *fi) -{ - if (fi) { - g_free (fi->uri); - g_free (fi->name); - g_free (fi->full_name); - g_slice_free (CamelFolderInfo, fi); - } -} - /* partially copied from mbox */ static void spool_fill_fi (CamelStore *store, @@ -283,7 +56,7 @@ spool_fill_fi (CamelStore *store, folder = camel_object_bag_get (store->folders, fi->full_name); if (folder) { if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - camel_folder_refresh_info (folder, cancellable, NULL); + camel_folder_refresh_info_sync (folder, cancellable, NULL); fi->unread = camel_folder_get_unread_message_count (folder); fi->total = camel_folder_get_message_count (folder); g_object_unref (folder); @@ -520,12 +293,152 @@ get_folder_info_mbox (CamelStore *store, return fi; } +static gboolean +spool_store_construct (CamelService *service, + CamelSession *session, + CamelProvider *provider, + CamelURL *url, + GError **error) +{ + CamelServiceClass *service_class; + struct stat st; + + d(printf("constructing store of type %s '%s:%s'\n", + G_OBJECT_CLASS_NAME (((CamelObject *)service)->s.type), url->protocol, url->path)); + + /* Chain up to parent's construct() method. */ + service_class = CAMEL_SERVICE_CLASS (camel_spool_store_parent_class); + if (!service_class->construct (service, session, provider, url, error)) + return FALSE; + + if (service->url->path[0] != '/') { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Store root %s is not an absolute path"), + service->url->path); + return FALSE; + } + + if (g_stat (service->url->path, &st) == -1) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Spool '%s' cannot be opened: %s"), + service->url->path, g_strerror (errno)); + return FALSE; + } + + if (S_ISREG (st.st_mode)) + ((CamelSpoolStore *)service)->type = CAMEL_SPOOL_STORE_MBOX; + else if (S_ISDIR (st.st_mode)) + /* we could check here for slight variations */ + ((CamelSpoolStore *)service)->type = CAMEL_SPOOL_STORE_ELM; + else { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Spool '%s' is not a regular file or directory"), + service->url->path); + return FALSE; + } + + return TRUE; +} + +static gchar * +spool_store_get_name (CamelService *service, + gboolean brief) +{ + if (brief) + return g_strdup (service->url->path); + else + return g_strdup_printf (((CamelSpoolStore *)service)->type == CAMEL_SPOOL_STORE_MBOX? + _("Spool mail file %s"):_("Spool folder tree %s"), service->url->path); +} + +static void +spool_store_free_folder_info (CamelStore *store, + CamelFolderInfo *fi) +{ + if (fi) { + g_free (fi->uri); + g_free (fi->name); + g_free (fi->full_name); + g_slice_free (CamelFolderInfo, fi); + } +} + +static CamelFolder * +spool_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) +{ + CamelFolder *folder = NULL; + struct stat st; + gchar *name; + + d(printf("opening folder %s on path %s\n", folder_name, path)); + + /* we only support an 'INBOX' in mbox mode */ + if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX) { + if (strcmp(folder_name, "INBOX") != 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Folder '%s/%s' does not exist."), + ((CamelService *)store)->url->path, folder_name); + } else { + folder = camel_spool_folder_new (store, folder_name, flags, cancellable, error); + } + } else { + name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); + if (g_stat (name, &st) == -1) { + if (errno != ENOENT) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Could not open folder '%s':\n%s"), + folder_name, g_strerror (errno)); + } else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Folder '%s' does not exist."), + folder_name); + } else { + if (creat (name, 0600) == -1) { + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Could not create folder '%s':\n%s"), + folder_name, g_strerror (errno)); + } else { + folder = camel_spool_folder_new (store, folder_name, flags, cancellable, error); + } + } + } else if (!S_ISREG (st.st_mode)) { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("'%s' is not a mailbox file."), name); + } else { + folder = camel_spool_folder_new (store, folder_name, flags, cancellable, error); + } + g_free (name); + } + + return folder; +} + static CamelFolderInfo * -get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +spool_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX) return get_folder_info_mbox (store, top, flags, cancellable, error); @@ -533,9 +446,56 @@ get_folder_info (CamelStore *store, return get_folder_info_elm (store, top, flags, cancellable, error); } +static CamelFolder * +spool_store_get_inbox_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) +{ + if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX) + return spool_store_get_folder_sync ( + store, "INBOX", CAMEL_STORE_FOLDER_CREATE, + cancellable, error); + else { + g_set_error ( + error, CAMEL_STORE_ERROR, + CAMEL_STORE_ERROR_NO_FOLDER, + _("Store does not support an INBOX")); + return NULL; + } +} + +/* default implementation, only delete metadata */ +static gboolean +spool_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) +{ + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Spool folders cannot be deleted")); + + return FALSE; +} + +/* default implementation, rename all */ +static gboolean +spool_store_rename_folder_sync (CamelStore *store, + const gchar *old, + const gchar *new, + GCancellable *cancellable, + GError **error) +{ + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Spool folders cannot be renamed")); + + return FALSE; +} + static gchar * -spool_get_full_path (CamelLocalStore *ls, - const gchar *full_name) +spool_store_get_full_path (CamelLocalStore *ls, + const gchar *full_name) { if (((CamelSpoolStore *)ls)->type == CAMEL_SPOOL_STORE_MBOX) /* a trailing / is always present on toplevel_dir from CamelLocalStore */ @@ -545,9 +505,9 @@ spool_get_full_path (CamelLocalStore *ls, } static gchar * -spool_get_meta_path (CamelLocalStore *ls, - const gchar *full_name, - const gchar *ext) +spool_store_get_meta_path (CamelLocalStore *ls, + const gchar *full_name, + const gchar *ext) { gchar *root = camel_session_get_storage_path (((CamelService *)ls)->session, (CamelService *)ls, NULL); gchar *path, *key; @@ -563,3 +523,33 @@ spool_get_meta_path (CamelLocalStore *ls, return path; } + +static void +camel_spool_store_class_init (CamelSpoolStoreClass *class) +{ + CamelServiceClass *service_class; + CamelStoreClass *store_class; + CamelLocalStoreClass *local_store_class; + + service_class = CAMEL_SERVICE_CLASS (class); + service_class->construct = spool_store_construct; + service_class->get_name = spool_store_get_name; + + store_class = CAMEL_STORE_CLASS (class); + store_class->free_folder_info = spool_store_free_folder_info; + store_class->get_folder_sync = spool_store_get_folder_sync; + store_class->get_folder_info_sync = spool_store_get_folder_info_sync; + store_class->get_inbox_folder_sync = spool_store_get_inbox_folder_sync; + store_class->delete_folder_sync = spool_store_delete_folder_sync; + store_class->rename_folder_sync = spool_store_rename_folder_sync; + + local_store_class = CAMEL_LOCAL_STORE_CLASS (class); + local_store_class->get_full_path = spool_store_get_full_path; + local_store_class->get_meta_path = spool_store_get_meta_path; +} + +static void +camel_spool_store_init (CamelSpoolStore *spool_store) +{ +} + diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c index 14c1757..450b903 100644 --- a/camel/providers/nntp/camel-nntp-folder.c +++ b/camel/providers/nntp/camel-nntp-folder.c @@ -295,80 +295,6 @@ nntp_folder_cache_message (CamelDiscoFolder *disco_folder, return success; } -static CamelMimeMessage * -nntp_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) -{ - CamelStore *parent_store; - CamelMimeMessage *message = NULL; - CamelNNTPStore *nntp_store; - CamelFolderChangeInfo *changes; - CamelNNTPFolder *nntp_folder; - CamelStream *stream = NULL; - gchar *article, *msgid; - - parent_store = camel_folder_get_parent_store (folder); - - nntp_folder = CAMEL_NNTP_FOLDER (folder); - nntp_store = CAMEL_NNTP_STORE (parent_store); - - article = alloca (strlen (uid)+1); - strcpy (article, uid); - msgid = strchr (article, ','); - if (msgid == NULL) { - g_set_error ( - error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, - _("Internal error: UID in invalid format: %s"), uid); - return NULL; - } - *msgid++ = 0; - - camel_service_lock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - - /* Lookup in cache, NEWS is global messageid's so use a global cache path */ - stream = camel_data_cache_get (nntp_store->cache, "cache", msgid, NULL); - if (stream == NULL) { - if (camel_disco_store_status ((CamelDiscoStore *) nntp_store) == CAMEL_DISCO_STORE_OFFLINE) { - g_set_error ( - error, CAMEL_SERVICE_ERROR, - CAMEL_SERVICE_ERROR_UNAVAILABLE, - _("This message is not currently available")); - goto fail; - } - - stream = nntp_folder_download_message (nntp_folder, article, msgid, cancellable, error); - if (stream == NULL) - goto fail; - } - - message = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream, cancellable, error) == -1) { - g_prefix_error (error, _("Cannot get message %s: "), uid); - g_object_unref (message); - message = NULL; - } - - g_object_unref (stream); -fail: - if (camel_folder_change_info_changed (nntp_folder->changes)) { - changes = nntp_folder->changes; - nntp_folder->changes = camel_folder_change_info_new (); - } else { - changes = NULL; - } - - camel_service_unlock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK); - - if (changes) { - camel_folder_changed (folder, changes); - camel_folder_change_info_free (changes); - } - - return message; -} - static GPtrArray* nntp_folder_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error) { @@ -439,6 +365,80 @@ nntp_folder_search_free (CamelFolder *folder, GPtrArray *result) CAMEL_NNTP_FOLDER_UNLOCK (nntp_folder, search_lock); } +static CamelMimeMessage * +nntp_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) +{ + CamelStore *parent_store; + CamelMimeMessage *message = NULL; + CamelNNTPStore *nntp_store; + CamelFolderChangeInfo *changes; + CamelNNTPFolder *nntp_folder; + CamelStream *stream = NULL; + gchar *article, *msgid; + + parent_store = camel_folder_get_parent_store (folder); + + nntp_folder = CAMEL_NNTP_FOLDER (folder); + nntp_store = CAMEL_NNTP_STORE (parent_store); + + article = alloca (strlen (uid)+1); + strcpy (article, uid); + msgid = strchr (article, ','); + if (msgid == NULL) { + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Internal error: UID in invalid format: %s"), uid); + return NULL; + } + *msgid++ = 0; + + camel_service_lock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + + /* Lookup in cache, NEWS is global messageid's so use a global cache path */ + stream = camel_data_cache_get (nntp_store->cache, "cache", msgid, NULL); + if (stream == NULL) { + if (camel_disco_store_status ((CamelDiscoStore *) nntp_store) == CAMEL_DISCO_STORE_OFFLINE) { + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_UNAVAILABLE, + _("This message is not currently available")); + goto fail; + } + + stream = nntp_folder_download_message (nntp_folder, article, msgid, cancellable, error); + if (stream == NULL) + goto fail; + } + + message = camel_mime_message_new (); + if (camel_data_wrapper_construct_from_stream_sync ((CamelDataWrapper *) message, stream, cancellable, error) == -1) { + g_prefix_error (error, _("Cannot get message %s: "), uid); + g_object_unref (message); + message = NULL; + } + + g_object_unref (stream); +fail: + if (camel_folder_change_info_changed (nntp_folder->changes)) { + changes = nntp_folder->changes; + nntp_folder->changes = camel_folder_change_info_new (); + } else { + changes = NULL; + } + + camel_service_unlock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK); + + if (changes) { + camel_folder_changed (folder, changes); + camel_folder_change_info_free (changes); + } + + return message; +} + static gboolean nntp_folder_append_message_online (CamelFolder *folder, CamelMimeMessage *mime_message, @@ -518,7 +518,7 @@ nntp_folder_append_message_online (CamelFolder *folder, /* write the message */ if (camel_stream_write (stream, group, strlen (group), cancellable, error) == -1 - || camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (mime_message), filtered_stream, cancellable, error) == -1 + || camel_data_wrapper_write_to_stream_sync (CAMEL_DATA_WRAPPER (mime_message), filtered_stream, cancellable, error) == -1 || camel_stream_flush (filtered_stream, cancellable, error) == -1 || camel_stream_write (stream, "\r\n.\r\n", 5, cancellable, error) == -1 || (ret = camel_nntp_stream_line (nntp_store->stream, (guchar **)&line, &u, cancellable, error)) == -1) { @@ -590,12 +590,12 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *class) object_class->finalize = nntp_folder_finalize; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->get_message = nntp_folder_get_message; folder_class->search_by_expression = nntp_folder_search_by_expression; folder_class->count_by_expression = nntp_folder_count_by_expression; folder_class->search_by_uids = nntp_folder_search_by_uids; folder_class->search_free = nntp_folder_search_free; folder_class->get_filename = nntp_get_filename; + folder_class->get_message_sync = nntp_folder_get_message_sync; disco_folder_class = CAMEL_DISCO_FOLDER_CLASS (class); disco_folder_class->sync_online = nntp_folder_sync_online; @@ -671,7 +671,7 @@ camel_nntp_folder_new (CamelStore *parent, camel_store_summary_info_free ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, si); } - if (subscribed && !camel_folder_refresh_info ( + if (subscribed && !camel_folder_refresh_info_sync ( folder, cancellable, error)) { g_object_unref (folder); folder = NULL; diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index c3b5b22..db98c9a 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -140,7 +140,8 @@ nntp_store_dispose (GObject *object) /* Only run this the first time. */ if (nntp_store->summary != NULL) - camel_service_disconnect (CAMEL_SERVICE (object), TRUE, NULL); + camel_service_disconnect_sync ( + CAMEL_SERVICE (object), TRUE, NULL); if (nntp_store->summary != NULL) { camel_store_summary_save ( @@ -530,9 +531,9 @@ nntp_store_get_name (CamelService *service, gboolean brief) extern CamelServiceAuthType camel_nntp_password_authtype; static GList * -nntp_store_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) +nntp_store_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { return g_list_append (NULL, &camel_nntp_password_authtype); } @@ -742,7 +743,7 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, gchar *line; folder = (CamelNNTPFolder *) - camel_store_get_folder ( + camel_store_get_folder_sync ( (CamelStore *)store, si->path, 0, cancellable, NULL); if (folder) { @@ -1139,10 +1140,10 @@ nntp_store_folder_is_subscribed (CamelStore *store, const gchar *folder_name) } static gboolean -nntp_store_subscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +nntp_store_subscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store); CamelStoreInfo *si; @@ -1180,10 +1181,10 @@ nntp_store_subscribe_folder (CamelStore *store, } static gboolean -nntp_store_unsubscribe_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +nntp_store_unsubscribe_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store); CamelFolderInfo *fi; @@ -1222,11 +1223,11 @@ nntp_store_unsubscribe_folder (CamelStore *store, /* stubs for various folder operations we're not implementing */ static CamelFolderInfo * -nntp_create_folder (CamelStore *store, - const gchar *parent_name, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +nntp_store_create_folder_sync (CamelStore *store, + const gchar *parent_name, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { g_set_error ( error, CAMEL_FOLDER_ERROR, @@ -1238,11 +1239,11 @@ nntp_create_folder (CamelStore *store, } static gboolean -nntp_rename_folder (CamelStore *store, - const gchar *old_name, - const gchar *new_name_in, - GCancellable *cancellable, - GError **error) +nntp_store_rename_folder_sync (CamelStore *store, + const gchar *old_name, + const gchar *new_name_in, + GCancellable *cancellable, + GError **error) { g_set_error ( error, CAMEL_FOLDER_ERROR, @@ -1253,12 +1254,13 @@ nntp_rename_folder (CamelStore *store, } static gboolean -nntp_delete_folder (CamelStore *store, - const gchar *folder_name, - GCancellable *cancellable, - GError **error) +nntp_store_delete_folder_sync (CamelStore *store, + const gchar *folder_name, + GCancellable *cancellable, + GError **error) { - nntp_store_unsubscribe_folder (store, folder_name, cancellable, NULL); + nntp_store_unsubscribe_folder_sync ( + store, folder_name, cancellable, NULL); g_set_error ( error, CAMEL_FOLDER_ERROR, @@ -1350,18 +1352,18 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *class) service_class = CAMEL_SERVICE_CLASS (class); service_class->construct = nntp_construct; - service_class->query_auth_types = nntp_store_query_auth_types; service_class->get_name = nntp_store_get_name; + service_class->query_auth_types_sync = nntp_store_query_auth_types_sync; store_class = CAMEL_STORE_CLASS (class); + store_class->can_refresh_folder = nntp_can_refresh_folder; store_class->free_folder_info = camel_store_free_folder_info_full; store_class->folder_is_subscribed = nntp_store_folder_is_subscribed; - store_class->subscribe_folder = nntp_store_subscribe_folder; - store_class->unsubscribe_folder = nntp_store_unsubscribe_folder; - store_class->create_folder = nntp_create_folder; - store_class->delete_folder = nntp_delete_folder; - store_class->rename_folder = nntp_rename_folder; - store_class->can_refresh_folder = nntp_can_refresh_folder; + store_class->create_folder_sync = nntp_store_create_folder_sync; + store_class->delete_folder_sync = nntp_store_delete_folder_sync; + store_class->rename_folder_sync = nntp_store_rename_folder_sync; + store_class->subscribe_folder_sync = nntp_store_subscribe_folder_sync; + store_class->unsubscribe_folder_sync = nntp_store_unsubscribe_folder_sync; disco_store_class = CAMEL_DISCO_STORE_CLASS (class); disco_store_class->can_work_offline = nntp_can_work_offline; @@ -1560,7 +1562,7 @@ camel_nntp_command (CamelNNTPStore *store, retry++; if (store->stream == NULL - && !camel_service_connect (CAMEL_SERVICE (store), error)) + && !camel_service_connect_sync (CAMEL_SERVICE (store), error)) return -1; /* Check for unprocessed data, !*/ @@ -1610,11 +1612,11 @@ camel_nntp_command (CamelNNTPStore *store, case 400: /* service discontinued */ case 401: /* wrong client state - this should quit but this is what the old code did */ case 503: /* information not available - this should quit but this is what the old code did (?) */ - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + camel_service_disconnect_sync (CAMEL_SERVICE (store), FALSE, NULL); ret = -1; continue; case -1: /* i/o error */ - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + camel_service_disconnect_sync (CAMEL_SERVICE (store), FALSE, NULL); if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || retry >= 3) { g_propagate_error (error, local_error); return -1; diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c index c01e8eb..390fd77 100644 --- a/camel/providers/pop3/camel-pop3-folder.c +++ b/camel/providers/pop3/camel-pop3-folder.c @@ -230,151 +230,6 @@ pop3_folder_dispose (GObject *object) G_OBJECT_CLASS (camel_pop3_folder_parent_class)->dispose (object); } -static gboolean -pop3_folder_refresh_info (CamelFolder *folder, - GCancellable *cancellable, - GError **error) -{ - CamelStore *parent_store; - CamelPOP3Store *pop3_store; - CamelPOP3Folder *pop3_folder = (CamelPOP3Folder *) folder; - CamelPOP3Command *pcl, *pcu = NULL; - gboolean success = TRUE; - gint i; - - parent_store = camel_folder_get_parent_store (folder); - pop3_store = CAMEL_POP3_STORE (parent_store); - - camel_operation_start (cancellable, _("Retrieving POP summary")); - - pop3_folder->uids = g_ptr_array_new (); - pop3_folder->uids_uid = g_hash_table_new (g_str_hash, g_str_equal); - /* only used during setup */ - pop3_folder->uids_id = g_hash_table_new (NULL, NULL); - - pcl = camel_pop3_engine_command_new(pop3_store->engine, CAMEL_POP3_COMMAND_MULTI, cmd_list, folder, "LIST\r\n"); - if (pop3_store->engine->capa & CAMEL_POP3_CAP_UIDL) - pcu = camel_pop3_engine_command_new(pop3_store->engine, CAMEL_POP3_COMMAND_MULTI, cmd_uidl, folder, "UIDL\r\n"); - while ((i = camel_pop3_engine_iterate (pop3_store->engine, NULL)) > 0) - ; - - if (i == -1) { - if (errno == EINTR) - g_set_error ( - error, G_IO_ERROR, - G_IO_ERROR_CANCELLED, - _("Cancelled")); - else - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - _("Cannot get POP summary: %s"), - g_strerror (errno)); - success = FALSE; - } - - /* TODO: check every id has a uid & commands returned OK too? */ - - camel_pop3_engine_command_free (pop3_store->engine, pcl); - - if (pop3_store->engine->capa & CAMEL_POP3_CAP_UIDL) { - camel_pop3_engine_command_free (pop3_store->engine, pcu); - } else { - for (i=0;iuids->len;i++) { - CamelPOP3FolderInfo *fi = pop3_folder->uids->pdata[i]; - if (fi->cmd) { - camel_pop3_engine_command_free (pop3_store->engine, fi->cmd); - fi->cmd = NULL; - } - if (fi->uid) - g_hash_table_insert (pop3_folder->uids_uid, fi->uid, fi); - } - } - - /* dont need this anymore */ - g_hash_table_destroy (pop3_folder->uids_id); - - camel_operation_end (cancellable); - - return success; -} - -static gboolean -pop3_folder_sync (CamelFolder *folder, - gboolean expunge, - GCancellable *cancellable, - GError **error) -{ - CamelStore *parent_store; - CamelPOP3Folder *pop3_folder; - CamelPOP3Store *pop3_store; - gint i; - CamelPOP3FolderInfo *fi; - - parent_store = camel_folder_get_parent_store (folder); - - pop3_folder = CAMEL_POP3_FOLDER (folder); - pop3_store = CAMEL_POP3_STORE (parent_store); - - if (pop3_store->delete_after && !expunge) { - d(printf("%s(%d): pop3_store->delete_after = [%d], expunge=[%d]\n", - __FILE__, __LINE__, pop3_store->delete_after, expunge)); - camel_operation_start (cancellable, _("Expunging old messages")); - camel_pop3_delete_old ( - folder, pop3_store->delete_after, - cancellable, error); - } - - if (!expunge) { - return TRUE; - } - - camel_operation_start (cancellable, _("Expunging deleted messages")); - - for (i = 0; i < pop3_folder->uids->len; i++) { - fi = pop3_folder->uids->pdata[i]; - /* busy already? wait for that to finish first */ - if (fi->cmd) { - while (camel_pop3_engine_iterate (pop3_store->engine, fi->cmd) > 0) - ; - camel_pop3_engine_command_free (pop3_store->engine, fi->cmd); - fi->cmd = NULL; - } - - if (fi->flags & CAMEL_MESSAGE_DELETED) { - fi->cmd = camel_pop3_engine_command_new (pop3_store->engine, - 0, - NULL, - NULL, - "DELE %u\r\n", - fi->id); - - /* also remove from cache */ - if (pop3_store->cache && fi->uid) - camel_data_cache_remove(pop3_store->cache, "cache", fi->uid, NULL); - } - } - - for (i = 0; i < pop3_folder->uids->len; i++) { - fi = pop3_folder->uids->pdata[i]; - /* wait for delete commands to finish */ - if (fi->cmd) { - while (camel_pop3_engine_iterate (pop3_store->engine, fi->cmd) > 0) - ; - camel_pop3_engine_command_free (pop3_store->engine, fi->cmd); - fi->cmd = NULL; - } - camel_operation_progress ( - cancellable, (i+1) * 100 / pop3_folder->uids->len); - } - - camel_operation_end (cancellable); - - camel_pop3_store_expunge (pop3_store, error); - - return TRUE; -} - static gint pop3_folder_get_message_count (CamelFolder *folder) { @@ -427,11 +282,34 @@ pop3_folder_get_filename (CamelFolder *folder, pop3_store->cache, "cache", fi->uid, NULL); } +static gboolean +pop3_folder_set_message_flags (CamelFolder *folder, + const gchar *uid, + guint32 flags, + guint32 set) +{ + CamelPOP3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); + CamelPOP3FolderInfo *fi; + gboolean res = FALSE; + + fi = g_hash_table_lookup (pop3_folder->uids_uid, uid); + if (fi) { + guint32 new = (fi->flags & ~flags) | (set & flags); + + if (fi->flags != new) { + fi->flags = new; + res = TRUE; + } + } + + return res; +} + static CamelMimeMessage * -pop3_folder_get_message (CamelFolder *folder, - const gchar *uid, - GCancellable *cancellable, - GError **error) +pop3_folder_get_message_sync (CamelFolder *folder, + const gchar *uid, + GCancellable *cancellable, + GError **error) { CamelStore *parent_store; CamelMimeMessage *message = NULL; @@ -572,7 +450,7 @@ pop3_folder_get_message (CamelFolder *folder, } message = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ( + if (camel_data_wrapper_construct_from_stream_sync ( CAMEL_DATA_WRAPPER (message), stream, cancellable, error) == -1) { g_prefix_error (error, _("Cannot get message %s: "), uid); g_object_unref (message); @@ -587,26 +465,148 @@ fail: } static gboolean -pop3_folder_set_message_flags (CamelFolder *folder, - const gchar *uid, - guint32 flags, - guint32 set) +pop3_folder_refresh_info_sync (CamelFolder *folder, + GCancellable *cancellable, + GError **error) { - CamelPOP3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder); + CamelStore *parent_store; + CamelPOP3Store *pop3_store; + CamelPOP3Folder *pop3_folder = (CamelPOP3Folder *) folder; + CamelPOP3Command *pcl, *pcu = NULL; + gboolean success = TRUE; + gint i; + + parent_store = camel_folder_get_parent_store (folder); + pop3_store = CAMEL_POP3_STORE (parent_store); + + camel_operation_start (cancellable, _("Retrieving POP summary")); + + pop3_folder->uids = g_ptr_array_new (); + pop3_folder->uids_uid = g_hash_table_new (g_str_hash, g_str_equal); + /* only used during setup */ + pop3_folder->uids_id = g_hash_table_new (NULL, NULL); + + pcl = camel_pop3_engine_command_new(pop3_store->engine, CAMEL_POP3_COMMAND_MULTI, cmd_list, folder, "LIST\r\n"); + if (pop3_store->engine->capa & CAMEL_POP3_CAP_UIDL) + pcu = camel_pop3_engine_command_new(pop3_store->engine, CAMEL_POP3_COMMAND_MULTI, cmd_uidl, folder, "UIDL\r\n"); + while ((i = camel_pop3_engine_iterate (pop3_store->engine, NULL)) > 0) + ; + + if (i == -1) { + if (errno == EINTR) + g_set_error ( + error, G_IO_ERROR, + G_IO_ERROR_CANCELLED, + _("Cancelled")); + else + g_set_error ( + error, G_IO_ERROR, + g_io_error_from_errno (errno), + _("Cannot get POP summary: %s"), + g_strerror (errno)); + success = FALSE; + } + + /* TODO: check every id has a uid & commands returned OK too? */ + + camel_pop3_engine_command_free (pop3_store->engine, pcl); + + if (pop3_store->engine->capa & CAMEL_POP3_CAP_UIDL) { + camel_pop3_engine_command_free (pop3_store->engine, pcu); + } else { + for (i=0;iuids->len;i++) { + CamelPOP3FolderInfo *fi = pop3_folder->uids->pdata[i]; + if (fi->cmd) { + camel_pop3_engine_command_free (pop3_store->engine, fi->cmd); + fi->cmd = NULL; + } + if (fi->uid) + g_hash_table_insert (pop3_folder->uids_uid, fi->uid, fi); + } + } + + /* dont need this anymore */ + g_hash_table_destroy (pop3_folder->uids_id); + + camel_operation_end (cancellable); + + return success; +} + +static gboolean +pop3_folder_synchronize_sync (CamelFolder *folder, + gboolean expunge, + GCancellable *cancellable, + GError **error) +{ + CamelStore *parent_store; + CamelPOP3Folder *pop3_folder; + CamelPOP3Store *pop3_store; + gint i; CamelPOP3FolderInfo *fi; - gboolean res = FALSE; - fi = g_hash_table_lookup (pop3_folder->uids_uid, uid); - if (fi) { - guint32 new = (fi->flags & ~flags) | (set & flags); + parent_store = camel_folder_get_parent_store (folder); - if (fi->flags != new) { - fi->flags = new; - res = TRUE; + pop3_folder = CAMEL_POP3_FOLDER (folder); + pop3_store = CAMEL_POP3_STORE (parent_store); + + if (pop3_store->delete_after && !expunge) { + d(printf("%s(%d): pop3_store->delete_after = [%d], expunge=[%d]\n", + __FILE__, __LINE__, pop3_store->delete_after, expunge)); + camel_operation_start (cancellable, _("Expunging old messages")); + camel_pop3_delete_old ( + folder, pop3_store->delete_after, + cancellable, error); + } + + if (!expunge) { + return TRUE; + } + + camel_operation_start (cancellable, _("Expunging deleted messages")); + + for (i = 0; i < pop3_folder->uids->len; i++) { + fi = pop3_folder->uids->pdata[i]; + /* busy already? wait for that to finish first */ + if (fi->cmd) { + while (camel_pop3_engine_iterate (pop3_store->engine, fi->cmd) > 0) + ; + camel_pop3_engine_command_free (pop3_store->engine, fi->cmd); + fi->cmd = NULL; + } + + if (fi->flags & CAMEL_MESSAGE_DELETED) { + fi->cmd = camel_pop3_engine_command_new (pop3_store->engine, + 0, + NULL, + NULL, + "DELE %u\r\n", + fi->id); + + /* also remove from cache */ + if (pop3_store->cache && fi->uid) + camel_data_cache_remove(pop3_store->cache, "cache", fi->uid, NULL); } } - return res; + for (i = 0; i < pop3_folder->uids->len; i++) { + fi = pop3_folder->uids->pdata[i]; + /* wait for delete commands to finish */ + if (fi->cmd) { + while (camel_pop3_engine_iterate (pop3_store->engine, fi->cmd) > 0) + ; + camel_pop3_engine_command_free (pop3_store->engine, fi->cmd); + fi->cmd = NULL; + } + camel_operation_progress ( + cancellable, (i+1) * 100 / pop3_folder->uids->len); + } + + camel_operation_end (cancellable); + + camel_pop3_store_expunge (pop3_store, error); + + return TRUE; } static void @@ -619,14 +619,14 @@ camel_pop3_folder_class_init (CamelPOP3FolderClass *class) object_class->dispose = pop3_folder_dispose; folder_class = CAMEL_FOLDER_CLASS (class); - folder_class->refresh_info = pop3_folder_refresh_info; - folder_class->sync = pop3_folder_sync; folder_class->get_message_count = pop3_folder_get_message_count; folder_class->get_uids = pop3_folder_get_uids; folder_class->free_uids = camel_folder_free_shallow; folder_class->get_filename = pop3_folder_get_filename; - folder_class->get_message = pop3_folder_get_message; folder_class->set_message_flags = pop3_folder_set_message_flags; + folder_class->get_message_sync = pop3_folder_get_message_sync; + folder_class->refresh_info_sync = pop3_folder_refresh_info_sync; + folder_class->synchronize_sync = pop3_folder_synchronize_sync; } static void @@ -649,7 +649,7 @@ camel_pop3_folder_new (CamelStore *parent, "parent-store", parent, NULL); /* mt-ok, since we dont have the folder-lock for new() */ - if (!camel_folder_refresh_info (folder, cancellable, error)) { + if (!camel_folder_refresh_info_sync (folder, cancellable, error)) { g_object_unref (folder); folder = NULL; } @@ -681,7 +681,8 @@ pop3_get_message_time_from_cache (CamelFolder *folder, const gchar *uid, time_t CamelMimeMessage *message; message = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, stream, NULL, NULL) == -1) { + if (camel_data_wrapper_construct_from_stream_sync ( + (CamelDataWrapper *)message, stream, NULL, NULL) == -1) { g_warning (_("Cannot get message %s: %s"), uid, g_strerror (errno)); g_object_unref (message); message = NULL; @@ -728,7 +729,7 @@ camel_pop3_delete_old (CamelFolder *folder, d(printf("%s(%d): fi->uid=[%s]\n", __FILE__, __LINE__, fi->uid)); if (!pop3_get_message_time_from_cache (folder, fi->uid, &message_time)) { d(printf("could not get message time from cache, trying from pop3\n")); - message = pop3_folder_get_message ( + message = pop3_folder_get_message_sync ( folder, fi->uid, cancellable, error); if (message) { message_time = message->date + message->date_offset; diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index 39cc238..35510a9 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -158,7 +158,8 @@ connect_to_server (CamelService *service, } /* parent class connect initialization */ - if (CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class)->connect (service, cancellable, error) == FALSE) { + if (CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class)-> + connect_sync (service, cancellable, error) == FALSE) { g_object_unref (tcp_stream); return FALSE; } @@ -342,7 +343,7 @@ try_sasl (CamelPOP3Store *store, its a protocol error, so fail, and try reset the server */ if (strncmp((gchar *) line, "+ ", 2) != 0 || camel_sasl_get_authenticated(sasl) - || (resp = (guchar *) camel_sasl_challenge_base64(sasl, (const gchar *) line+2, cancellable, NULL)) == NULL) { + || (resp = (guchar *) camel_sasl_challenge_base64_sync (sasl, (const gchar *) line+2, cancellable, NULL)) == NULL) { camel_stream_printf((CamelStream *)stream, "*\r\n"); camel_pop3_stream_line (stream, &line, &len); g_set_error ( @@ -532,7 +533,7 @@ pop3_store_finalize (GObject *object) /* force disconnect so we dont have it run later, after we've cleaned up some stuff */ /* SIGH */ - camel_service_disconnect ((CamelService *)pop3_store, TRUE, NULL); + camel_service_disconnect_sync ((CamelService *)pop3_store, TRUE, NULL); if (pop3_store->engine) g_object_unref (pop3_store->engine); @@ -543,10 +544,25 @@ pop3_store_finalize (GObject *object) G_OBJECT_CLASS (camel_pop3_store_parent_class)->finalize (object); } +static gchar * +pop3_store_get_name (CamelService *service, + gboolean brief) +{ + if (brief) + return g_strdup_printf ( + _("POP3 server %s"), + service->url->host); + else + return g_strdup_printf ( + _("POP3 server for %s on %s"), + service->url->user, + service->url->host); +} + static gboolean -pop3_store_connect (CamelService *service, - GCancellable *cancellable, - GError **error) +pop3_store_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelPOP3Store *store = (CamelPOP3Store *)service; gboolean reprompt = FALSE; @@ -602,7 +618,7 @@ pop3_store_connect (CamelService *service, if (local_error != NULL) { g_propagate_error (error, local_error); - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync (service, TRUE, NULL); return FALSE; } @@ -615,10 +631,10 @@ pop3_store_connect (CamelService *service, } static gboolean -pop3_store_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) +pop3_store_disconnect_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) { CamelServiceClass *service_class; CamelPOP3Store *store = CAMEL_POP3_STORE (service); @@ -634,7 +650,7 @@ pop3_store_disconnect (CamelService *service, /* Chain up to parent's disconnect() method. */ service_class = CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class); - if (!service_class->disconnect (service, clean, cancellable, error)) + if (!service_class->disconnect_sync (service, clean, cancellable, error)) return FALSE; g_object_unref (store->engine); @@ -644,9 +660,9 @@ pop3_store_disconnect (CamelService *service, } static GList * -pop3_store_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) +pop3_store_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelServiceClass *service_class; CamelPOP3Store *store = CAMEL_POP3_STORE (service); @@ -655,7 +671,7 @@ pop3_store_query_auth_types (CamelService *service, /* Chain up to parent's query_auth_types() method. */ service_class = CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class); - types = service_class->query_auth_types ( + types = service_class->query_auth_types_sync ( service, cancellable, &local_error); if (local_error != NULL) { @@ -665,7 +681,7 @@ pop3_store_query_auth_types (CamelService *service, if (connect_to_server_wrapper (service, cancellable, NULL)) { types = g_list_concat (types, g_list_copy (store->engine->auth)); - pop3_store_disconnect (service, TRUE, cancellable, NULL); + pop3_store_disconnect_sync (service, TRUE, cancellable, NULL); } else { g_set_error ( error, CAMEL_SERVICE_ERROR, @@ -677,27 +693,21 @@ pop3_store_query_auth_types (CamelService *service, return types; } -static gchar * -pop3_store_get_name (CamelService *service, - gboolean brief) +static gboolean +pop3_store_can_refresh_folder (CamelStore *store, + CamelFolderInfo *info, + GError **error) { - if (brief) - return g_strdup_printf ( - _("POP3 server %s"), - service->url->host); - else - return g_strdup_printf ( - _("POP3 server for %s on %s"), - service->url->user, - service->url->host); + /* any pop3 folder can be refreshed */ + return TRUE; } static CamelFolder * -pop3_store_get_folder (CamelStore *store, - const gchar *folder_name, - guint32 flags, - GCancellable *cancellable, - GError **error) +pop3_store_get_folder_sync (CamelStore *store, + const gchar *folder_name, + guint32 flags, + GCancellable *cancellable, + GError **error) { if (g_ascii_strcasecmp (folder_name, "inbox") != 0) { g_set_error ( @@ -710,21 +720,12 @@ pop3_store_get_folder (CamelStore *store, return camel_pop3_folder_new (store, cancellable, error); } -static CamelFolder * -pop3_store_get_trash (CamelStore *store, - GCancellable *cancellable, - GError **error) -{ - /* no-op */ - return NULL; -} - static CamelFolderInfo * -pop3_store_get_folder_info (CamelStore *store, - const gchar *top, - guint32 flags, - GCancellable *cancellable, - GError **error) +pop3_store_get_folder_info_sync (CamelStore *store, + const gchar *top, + guint32 flags, + GCancellable *cancellable, + GError **error) { g_set_error ( error, CAMEL_STORE_ERROR, @@ -734,13 +735,13 @@ pop3_store_get_folder_info (CamelStore *store, return NULL; } -static gboolean -pop3_store_can_refresh_folder (CamelStore *store, - CamelFolderInfo *info, - GError **error) +static CamelFolder * +pop3_store_get_trash_folder_sync (CamelStore *store, + GCancellable *cancellable, + GError **error) { - /* any pop3 folder can be refreshed */ - return TRUE; + /* no-op */ + return NULL; } static void @@ -754,16 +755,16 @@ camel_pop3_store_class_init (CamelPOP3StoreClass *class) object_class->finalize = pop3_store_finalize; service_class = CAMEL_SERVICE_CLASS (class); - service_class->connect = pop3_store_connect; - service_class->disconnect = pop3_store_disconnect; - service_class->query_auth_types = pop3_store_query_auth_types; service_class->get_name = pop3_store_get_name; + service_class->connect_sync = pop3_store_connect_sync; + service_class->disconnect_sync = pop3_store_disconnect_sync; + service_class->query_auth_types_sync = pop3_store_query_auth_types_sync; store_class = CAMEL_STORE_CLASS (class); - store_class->get_folder = pop3_store_get_folder; - store_class->get_trash = pop3_store_get_trash; - store_class->get_folder_info = pop3_store_get_folder_info; store_class->can_refresh_folder = pop3_store_can_refresh_folder; + store_class->get_folder_sync = pop3_store_get_folder_sync; + store_class->get_folder_info_sync = pop3_store_get_folder_info_sync; + store_class->get_trash_folder_sync = pop3_store_get_trash_folder_sync; } static void @@ -794,6 +795,6 @@ camel_pop3_store_expunge (CamelPOP3Store *store, camel_pop3_engine_command_free (store->engine, pc); - camel_service_disconnect (CAMEL_SERVICE (store), FALSE, error); + camel_service_disconnect_sync (CAMEL_SERVICE (store), FALSE, error); } diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c index 5226bac..6600ac1 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ b/camel/providers/sendmail/camel-sendmail-transport.c @@ -52,12 +52,12 @@ sendmail_get_name (CamelService *service, } static gboolean -sendmail_send_to (CamelTransport *transport, - CamelMimeMessage *message, - CamelAddress *from, - CamelAddress *recipients, - GCancellable *cancellable, - GError **error) +sendmail_send_to_sync (CamelTransport *transport, + CamelMimeMessage *message, + CamelAddress *from, + CamelAddress *recipients, + GCancellable *cancellable, + GError **error) { struct _camel_header_raw *header, *savedbcc, *n, *tail; const gchar *from_addr, *addr, **argv; @@ -175,7 +175,7 @@ sendmail_send_to (CamelTransport *transport, g_object_unref (out); out = (CamelStream *) filter; - if (camel_data_wrapper_write_to_stream ( + if (camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (message), out, cancellable, error) == -1 || camel_stream_close (out, cancellable, error) == -1) { g_object_unref (CAMEL_OBJECT (out)); @@ -239,7 +239,7 @@ camel_sendmail_transport_class_init (CamelSendmailTransportClass *class) service_class->get_name = sendmail_get_name; transport_class = CAMEL_TRANSPORT_CLASS (class); - transport_class->send_to = sendmail_send_to; + transport_class->send_to_sync = sendmail_send_to_sync; } static void diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 09c4748..9f17160 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -55,10 +55,6 @@ extern gint camel_verbose_debug; #define SMTPS_PORT 465 /* support prototypes */ -static gboolean smtp_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error); static GHashTable * esmtp_get_authtypes (const guchar *buffer); static gboolean smtp_helo (CamelSmtpTransport *transport, GCancellable *cancellable, @@ -134,7 +130,7 @@ connect_to_server (CamelService *service, gchar *respbuf = NULL; if (!CAMEL_SERVICE_CLASS (camel_smtp_transport_parent_class)-> - connect (service, cancellable, error)) + connect_sync (service, cancellable, error)) return FALSE; /* set some smtp transport defaults */ @@ -219,7 +215,8 @@ connect_to_server (CamelService *service, transport->flags &= ~CAMEL_SMTP_TRANSPORT_IS_ESMTP; if (!smtp_helo (transport, cancellable, error)) { - camel_service_disconnect ((CamelService *) transport, TRUE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, TRUE, NULL); return FALSE; } @@ -292,7 +289,8 @@ connect_to_server (CamelService *service, /* We are supposed to re-EHLO after a successful STARTTLS to re-fetch any supported extensions. */ if (!smtp_helo (transport, cancellable, error)) { - camel_service_disconnect ((CamelService *) transport, TRUE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, TRUE, NULL); return FALSE; } @@ -351,10 +349,23 @@ authtypes_free (gpointer key, gpointer value, gpointer data) g_free (value); } +static gchar * +smtp_get_name (CamelService *service, gboolean brief) +{ + if (brief) + return g_strdup_printf ( + _("SMTP server %s"), + service->url->host); + else + return g_strdup_printf ( + _("SMTP mail delivery via %s"), + service->url->host); +} + static gboolean -smtp_connect (CamelService *service, - GCancellable *cancellable, - GError **error) +smtp_connect_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); gboolean has_authtypes; @@ -366,7 +377,7 @@ smtp_connect (CamelService *service, CamelSasl *sasl; sasl = camel_sasl_new ("smtp", "POPB4SMTP", service); - chal = camel_sasl_challenge (sasl, NULL, cancellable, error); + chal = camel_sasl_challenge_sync (sasl, NULL, cancellable, error); truth = camel_sasl_get_authenticated (sasl); if (chal) g_byte_array_free (chal, TRUE); @@ -397,7 +408,7 @@ smtp_connect (CamelService *service, _("SMTP server %s does not support " "requested authentication type %s."), service->url->host, service->url->authmech); - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync (service, TRUE, NULL); return FALSE; } @@ -408,7 +419,7 @@ smtp_connect (CamelService *service, CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE, _("No support for authentication type %s"), service->url->authmech); - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync (service, TRUE, NULL); return FALSE; } @@ -419,7 +430,8 @@ smtp_connect (CamelService *service, transport, authtype->authproto, cancellable, error); if (!authenticated) { - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync ( + service, TRUE, NULL); return FALSE; } } @@ -458,7 +470,8 @@ smtp_connect (CamelService *service, errbuf = NULL; if (!service->url->passwd) { - camel_service_disconnect (service, TRUE, NULL); + camel_service_disconnect_sync ( + service, TRUE, NULL); return FALSE; } } @@ -493,10 +506,10 @@ smtp_connect (CamelService *service, } static gboolean -smtp_disconnect (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) +smtp_disconnect_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) { CamelServiceClass *service_class; CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); @@ -512,7 +525,7 @@ smtp_disconnect (CamelService *service, /* Chain up to parent's disconnect() method. */ service_class = CAMEL_SERVICE_CLASS (camel_smtp_transport_parent_class); - if (!service_class->disconnect (service, clean, cancellable, error)) + if (!service_class->disconnect_sync (service, clean, cancellable, error)) return FALSE; if (transport->authtypes) { @@ -540,9 +553,9 @@ smtp_disconnect (CamelService *service, } static GList * -smtp_query_auth_types (CamelService *service, - GCancellable *cancellable, - GError **error) +smtp_query_auth_types_sync (CamelService *service, + GCancellable *cancellable, + GError **error) { CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); CamelServiceAuthType *authtype; @@ -552,7 +565,7 @@ smtp_query_auth_types (CamelService *service, return NULL; if (!transport->authtypes) { - smtp_disconnect (service, TRUE, cancellable, NULL); + smtp_disconnect_sync (service, TRUE, cancellable, NULL); return NULL; } @@ -567,31 +580,18 @@ smtp_query_auth_types (CamelService *service, } } - smtp_disconnect (service, TRUE, cancellable, NULL); + smtp_disconnect_sync (service, TRUE, cancellable, NULL); return types; } -static gchar * -smtp_get_name (CamelService *service, gboolean brief) -{ - if (brief) - return g_strdup_printf ( - _("SMTP server %s"), - service->url->host); - else - return g_strdup_printf ( - _("SMTP mail delivery via %s"), - service->url->host); -} - static gboolean -smtp_send_to (CamelTransport *transport, - CamelMimeMessage *message, - CamelAddress *from, - CamelAddress *recipients, - GCancellable *cancellable, - GError **error) +smtp_send_to_sync (CamelTransport *transport, + CamelMimeMessage *message, + CamelAddress *from, + CamelAddress *recipients, + GCancellable *cancellable, + GError **error) { CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT (transport); CamelInternetAddress *cia; @@ -678,13 +678,13 @@ camel_smtp_transport_class_init (CamelSmtpTransportClass *class) CamelServiceClass *service_class; service_class = CAMEL_SERVICE_CLASS (class); - service_class->connect = smtp_connect; - service_class->disconnect = smtp_disconnect; - service_class->query_auth_types = smtp_query_auth_types; service_class->get_name = smtp_get_name; + service_class->connect_sync = smtp_connect_sync; + service_class->disconnect_sync = smtp_disconnect_sync; + service_class->query_auth_types_sync = smtp_query_auth_types_sync; transport_class = CAMEL_TRANSPORT_CLASS (class); - transport_class->send_to = smtp_send_to; + transport_class->send_to_sync = smtp_send_to_sync; } static void @@ -1041,7 +1041,8 @@ smtp_helo (CamelSmtpTransport *transport, g_prefix_error (error, _("HELO command failed: ")); camel_operation_end (cancellable); - camel_service_disconnect ((CamelService *) transport, FALSE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, FALSE, NULL); return FALSE; } @@ -1141,7 +1142,7 @@ smtp_auth (CamelSmtpTransport *transport, return FALSE; } - challenge = camel_sasl_challenge_base64 ( + challenge = camel_sasl_challenge_base64_sync ( sasl, NULL, cancellable, error); if (challenge) { auth_challenge = TRUE; @@ -1192,7 +1193,7 @@ smtp_auth (CamelSmtpTransport *transport, /* eat whtspc */ for (challenge = respbuf + 4; isspace (*challenge); challenge++); - challenge = camel_sasl_challenge_base64 ( + challenge = camel_sasl_challenge_base64_sync ( sasl, challenge, cancellable, error); if (challenge == NULL) goto break_and_lose; @@ -1285,7 +1286,8 @@ smtp_mail (CamelSmtpTransport *transport, transport->ostream, cmdbuf, cancellable, error) == -1) { g_free (cmdbuf); g_prefix_error (error, _("MAIL FROM command failed: ")); - camel_service_disconnect ((CamelService *) transport, FALSE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, FALSE, NULL); return FALSE; } g_free (cmdbuf); @@ -1298,7 +1300,7 @@ smtp_mail (CamelSmtpTransport *transport, cancellable, error); if (respbuf == NULL) { g_prefix_error (error, _("MAIL FROM command failed: ")); - camel_service_disconnect ( + camel_service_disconnect_sync ( CAMEL_SERVICE (transport), FALSE, NULL); return FALSE; } @@ -1334,7 +1336,8 @@ smtp_rcpt (CamelSmtpTransport *transport, transport->ostream, cmdbuf, cancellable, error) == -1) { g_free (cmdbuf); g_prefix_error (error, _("RCPT TO command failed: ")); - camel_service_disconnect ((CamelService *) transport, FALSE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, FALSE, NULL); return FALSE; } @@ -1349,7 +1352,7 @@ smtp_rcpt (CamelSmtpTransport *transport, if (respbuf == NULL) { g_prefix_error ( error, _("RCPT TO <%s> failed: "), recipient); - camel_service_disconnect ( + camel_service_disconnect_sync ( CAMEL_SERVICE (transport), FALSE, NULL); return FALSE; } @@ -1400,7 +1403,8 @@ smtp_data (CamelSmtpTransport *transport, transport->ostream, cmdbuf, cancellable, error) == -1) { g_free (cmdbuf); g_prefix_error (error, _("DATA command failed: ")); - camel_service_disconnect ((CamelService *) transport, FALSE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, FALSE, NULL); return FALSE; } g_free (cmdbuf); @@ -1409,7 +1413,7 @@ smtp_data (CamelSmtpTransport *transport, CAMEL_STREAM_BUFFER (transport->istream), cancellable, error); if (respbuf == NULL) { g_prefix_error (error, _("DATA command failed: ")); - camel_service_disconnect ( + camel_service_disconnect_sync ( CAMEL_SERVICE (transport), FALSE, NULL); return FALSE; } @@ -1447,7 +1451,7 @@ smtp_data (CamelSmtpTransport *transport, /* find out how large the message is... */ null = CAMEL_STREAM_NULL (camel_stream_null_new ()); - camel_data_wrapper_write_to_stream ( + camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (null), NULL, NULL); @@ -1469,7 +1473,7 @@ smtp_data (CamelSmtpTransport *transport, g_object_unref (filter); /* write the message */ - ret = camel_data_wrapper_write_to_stream ( + ret = camel_data_wrapper_write_to_stream_sync ( CAMEL_DATA_WRAPPER (message), filtered_stream, cancellable, error); @@ -1481,7 +1485,8 @@ smtp_data (CamelSmtpTransport *transport, g_object_unref (filtered_stream); - camel_service_disconnect ((CamelService *) transport, FALSE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, FALSE, NULL); return FALSE; } @@ -1496,7 +1501,8 @@ smtp_data (CamelSmtpTransport *transport, transport->ostream, "\r\n.\r\n", 5, cancellable, error) == -1) { g_prefix_error (error, _("DATA command failed: ")); - camel_service_disconnect ((CamelService *) transport, FALSE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, FALSE, NULL); return FALSE; } @@ -1508,7 +1514,7 @@ smtp_data (CamelSmtpTransport *transport, cancellable, error); if (respbuf == NULL) { g_prefix_error (error, _("DATA command failed: ")); - camel_service_disconnect ( + camel_service_disconnect_sync ( CAMEL_SERVICE (transport), FALSE, NULL); return FALSE; } @@ -1541,7 +1547,8 @@ smtp_rset (CamelSmtpTransport *transport, transport->ostream, cmdbuf, cancellable, error) == -1) { g_free (cmdbuf); g_prefix_error (error, _("RSET command failed: ")); - camel_service_disconnect ((CamelService *) transport, FALSE, NULL); + camel_service_disconnect_sync ( + (CamelService *) transport, FALSE, NULL); return FALSE; } g_free (cmdbuf); @@ -1554,7 +1561,7 @@ smtp_rset (CamelSmtpTransport *transport, cancellable, error); if (respbuf == NULL) { g_prefix_error (error, _("RSET command failed: ")); - camel_service_disconnect ( + camel_service_disconnect_sync ( CAMEL_SERVICE (transport), FALSE, NULL); return FALSE; } diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt index 05afb38..0d18659 100644 --- a/docs/reference/camel/camel-sections.txt +++ b/docs/reference/camel/camel-sections.txt @@ -141,12 +141,12 @@ camel_cipher_context_new camel_cipher_context_get_session camel_cipher_id_to_hash camel_cipher_hash_to_id -camel_cipher_sign -camel_cipher_verify -camel_cipher_encrypt -camel_cipher_decrypt -camel_cipher_import_keys -camel_cipher_export_keys +camel_cipher_sign_sync +camel_cipher_verify_sync +camel_cipher_encrypt_sync +camel_cipher_decrypt_sync +camel_cipher_import_keys_sync +camel_cipher_export_keys_sync camel_cipher_validity_new camel_cipher_validity_init camel_cipher_validity_get_valid @@ -204,14 +204,14 @@ camel_data_cache_get_type CamelDataWrapper CamelDataWrapper camel_data_wrapper_new -camel_data_wrapper_write_to_stream -camel_data_wrapper_decode_to_stream camel_data_wrapper_set_mime_type camel_data_wrapper_get_mime_type camel_data_wrapper_get_mime_type_field camel_data_wrapper_set_mime_type_field -camel_data_wrapper_construct_from_stream camel_data_wrapper_is_offline +camel_data_wrapper_write_to_stream_sync +camel_data_wrapper_decode_to_stream_sync +camel_data_wrapper_construct_from_stream_sync CamelDataWrapperLock camel_data_wrapper_lock camel_data_wrapper_unlock @@ -416,11 +416,8 @@ CAMEL_FOLDER_HAS_BEEN_DELETED CAMEL_FOLDER_IS_TRASH CAMEL_FOLDER_IS_JUNK CAMEL_FOLDER_FILTER_JUNK -camel_folder_refresh_info -camel_folder_sync camel_folder_set_lock_async camel_folder_get_parent_store -camel_folder_expunge camel_folder_get_name camel_folder_set_name camel_folder_get_full_name @@ -434,15 +431,12 @@ camel_folder_get_message_user_flag camel_folder_set_message_user_flag camel_folder_get_message_user_tag camel_folder_set_message_user_tag -camel_folder_append_message camel_folder_has_summary_capability camel_folder_get_message_count camel_folder_get_unread_message_count camel_folder_get_deleted_message_count camel_folder_get_summary camel_folder_free_summary -camel_folder_get_message -camel_folder_sync_message camel_folder_delete_message camel_folder_get_uids camel_folder_free_uids @@ -457,7 +451,6 @@ camel_folder_count_by_expression camel_folder_get_message_info camel_folder_free_message_info camel_folder_ref_message_info -camel_folder_transfer_messages_to camel_folder_delete camel_folder_rename camel_folder_changed @@ -473,6 +466,13 @@ camel_folder_free_nop camel_folder_free_shallow camel_folder_free_deep camel_folder_get_filename +camel_folder_append_message_sync +camel_folder_expunge_sync +camel_folder_get_message_sync +camel_folder_refresh_info_sync +camel_folder_synchronize_sync +camel_folder_synchronize_message_sync +camel_folder_transfer_messages_to_sync camel_folder_change_info_new camel_folder_change_info_clear camel_folder_change_info_free @@ -1326,7 +1326,7 @@ camel_mime_part_set_content_languages camel_mime_part_get_content_languages camel_mime_part_set_content_type camel_mime_part_get_content_type -camel_mime_part_construct_from_parser +camel_mime_part_construct_from_parser_sync camel_mime_part_set_content camel_mime_part_get_content_size camel_mime_part_construct_content_from_parser @@ -1486,7 +1486,7 @@ camel_error_quark CamelOfflineFolder camel_offline_folder_get_offline_sync camel_offline_folder_set_offline_sync -camel_offline_folder_downsync +camel_offline_folder_downsync_sync CAMEL_OFFLINE_FOLDER CAMEL_IS_OFFLINE_FOLDER @@ -1525,9 +1525,9 @@ camel_offline_journal_get_type camel-offline-store CamelOfflineStore CamelOfflineStore -camel_offline_store_set_network_state -camel_offline_store_get_network_state -camel_offline_store_prepare_for_offline +camel_offline_store_get_online +camel_offline_store_set_online_sync +camel_offline_store_prepare_for_offline_sync CAMEL_OFFLINE_STORE CAMEL_IS_OFFLINE_STORE @@ -1537,6 +1537,7 @@ CAMEL_IS_OFFLINE_STORE_CLASS CAMEL_OFFLINE_STORE_GET_CLASS CamelOfflineStoreClass +CamelOfflineStorePrivate camel_offline_store_get_type @@ -1590,6 +1591,32 @@ camel_key_table_get_type
+camel-operation +CamelOperation +camel_operation_new +camel_operation_cancel +camel_operation_uncancel +camel_operation_cancel_check +camel_operation_cancel_fd +camel_operation_cancel_prfd +camel_operation_start +camel_operation_start_transient +camel_operation_progress +camel_operation_end + +CAMEL_OPERATION +CAMEL_IS_OPERATION +CAMEL_TYPE_OPERATION +CAMEL_OPERATION_CLASS +CAMEL_IS_OPERATION_CLASS +CAMEL_OPERATION_GET_CLASS +CamelOperationClass +camel_operation_get_type + +CamelOperationPrivate +
+ +
camel-provider CamelProvider CamelProviderType @@ -1805,14 +1832,14 @@ camel_sasl_popb4smtp_get_type camel-sasl CamelSasl CamelSasl -camel_sasl_challenge -camel_sasl_challenge_base64 camel_sasl_new camel_sasl_get_authenticated camel_sasl_set_authenticated camel_sasl_get_mechanism camel_sasl_get_service camel_sasl_get_service_name +camel_sasl_challenge_sync +camel_sasl_challenge_base64_sync camel_sasl_authtype_list camel_sasl_authtype @@ -1885,15 +1912,15 @@ CamelServiceError CamelServiceConnectionStatus CamelServiceAuthType camel_service_construct -camel_service_connect -camel_service_disconnect -camel_service_cancel_connect -camel_service_get_url camel_service_get_name camel_service_get_path -camel_service_get_session camel_service_get_provider -camel_service_query_auth_types +camel_service_get_session +camel_service_get_url +camel_service_cancel_connect +camel_service_connect_sync +camel_service_disconnect_sync +camel_service_query_auth_types_sync CamelServiceLock camel_service_lock camel_service_unlock @@ -2081,20 +2108,11 @@ CAMEL_STORE_FOLDER_INFO_RECURSIVE CAMEL_STORE_FOLDER_INFO_SUBSCRIBED CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST -camel_store_get_folder -camel_store_get_inbox -camel_store_get_trash -camel_store_get_junk -camel_store_create_folder -camel_store_delete_folder -camel_store_rename_folder camel_store_folder_created camel_store_folder_deleted camel_store_folder_renamed camel_store_folder_subscribed camel_store_folder_unsubscribed -camel_store_sync -camel_store_get_folder_info camel_store_free_folder_info camel_store_free_folder_info_full camel_store_free_folder_info_nop @@ -2104,14 +2122,23 @@ camel_folder_info_build camel_folder_info_clone camel_store_supports_subscriptions camel_store_folder_is_subscribed -camel_store_subscribe_folder -camel_store_unsubscribe_folder -camel_store_noop camel_store_folder_uri_equal camel_store_can_refresh_folder CamelStoreLock camel_store_lock camel_store_unlock +camel_store_get_folder_sync +camel_store_get_folder_info_sync +camel_store_get_inbox_folder_sync +camel_store_get_junk_folder_sync +camel_store_get_trash_folder_sync +camel_store_create_folder_sync +camel_store_delete_folder_sync +camel_store_rename_folder_sync +camel_store_subscribe_folder_sync +camel_store_unsubscribe_folder_sync +camel_store_synchronize_sync +camel_store_noop_sync CAMEL_STORE CAMEL_IS_STORE @@ -2432,7 +2459,7 @@ camel_text_index_name_get_type camel-transport CamelTransport CamelTransport -camel_transport_send_to +camel_transport_send_to_sync CamelTransportLock camel_transport_lock camel_transport_unlock @@ -2824,24 +2851,6 @@ camel_movemail
-camel-operation -CamelOperation -camel_operation_new -camel_operation_cancel -camel_operation_uncancel -camel_operation_register -camel_operation_unregister -camel_operation_cancel_check -camel_operation_cancel_fd -camel_operation_cancel_prfd -camel_operation_registered -camel_operation_start -camel_operation_start_transient -camel_operation_progress -camel_operation_end -
- -
camel-string-utils camel_strcase_equal camel_strcase_hash diff --git a/docs/reference/camel/tmpl/camel-cipher-context.sgml b/docs/reference/camel/tmpl/camel-cipher-context.sgml index 768a8a6..1068c8f 100644 --- a/docs/reference/camel/tmpl/camel-cipher-context.sgml +++ b/docs/reference/camel/tmpl/camel-cipher-context.sgml @@ -136,7 +136,7 @@ CamelCipherContext @Returns: - + @@ -151,7 +151,7 @@ CamelCipherContext @Returns: - + @@ -163,7 +163,7 @@ CamelCipherContext @Returns: - + @@ -178,7 +178,7 @@ CamelCipherContext @Returns: - + @@ -191,7 +191,7 @@ CamelCipherContext @Returns: - + @@ -203,7 +203,7 @@ CamelCipherContext @Returns: - + @@ -500,6 +500,34 @@ CamelCipherContext @gpointer cert_data: @gpointer cert_data: @gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: +@gpointer cert_data: @gpointer cert_data: diff --git a/docs/reference/camel/tmpl/camel-data-wrapper.sgml b/docs/reference/camel/tmpl/camel-data-wrapper.sgml index 499158e..a27a941 100644 --- a/docs/reference/camel/tmpl/camel-data-wrapper.sgml +++ b/docs/reference/camel/tmpl/camel-data-wrapper.sgml @@ -35,49 +35,43 @@ CamelDataWrapper @Returns: - + @data_wrapper: -@stream: -@cancellable: -@error: -@Returns: +@mime_type: - + @data_wrapper: -@stream: -@cancellable: -@error: @Returns: - + @data_wrapper: -@mime_type: +@Returns: - + @data_wrapper: -@Returns: +@mime_type: - + @@ -86,16 +80,19 @@ CamelDataWrapper @Returns: - + @data_wrapper: -@mime_type: +@stream: +@cancellable: +@error: +@Returns: - + @@ -107,12 +104,15 @@ CamelDataWrapper @Returns: - + @data_wrapper: +@stream: +@cancellable: +@error: @Returns: diff --git a/docs/reference/camel/tmpl/camel-folder.sgml b/docs/reference/camel/tmpl/camel-folder.sgml index e337f03..99b6483 100644 --- a/docs/reference/camel/tmpl/camel-folder.sgml +++ b/docs/reference/camel/tmpl/camel-folder.sgml @@ -160,29 +160,6 @@ CamelFolder - - - - - -@folder: -@cancellable: -@error: -@Returns: - - - - - - - -@folder: -@expunge: -@cancellable: -@error: -@Returns: - - @@ -201,17 +178,6 @@ CamelFolder @Returns: - - - - - -@folder: -@cancellable: -@error: -@Returns: - - @@ -341,20 +307,6 @@ CamelFolder @value: - - - - - -@folder: -@message: -@info: -@appended_uid: -@cancellable: -@error: -@Returns: - - @@ -409,30 +361,6 @@ CamelFolder @array: - - - - - -@folder: -@uid: -@cancellable: -@error: -@Returns: - - - - - - - -@folder: -@uid: -@cancellable: -@error: -@Returns: - - @@ -571,21 +499,6 @@ CamelFolder @info: - - - - - -@source: -@uids: -@dest: -@transferred_uids: -@delete_originals: -@cancellable: -@error: -@Returns: - - @@ -721,6 +634,93 @@ CamelFolder @Returns: + + + + + +@folder: +@message: +@info: +@appended_uid: +@cancellable: +@error: +@Returns: + + + + + + + +@folder: +@cancellable: +@error: +@Returns: + + + + + + + +@folder: +@uid: +@cancellable: +@error: +@Returns: + + + + + + + +@folder: +@cancellable: +@error: +@Returns: + + + + + + + +@folder: +@expunge: +@cancellable: +@error: +@Returns: + + + + + + + +@folder: +@uid: +@cancellable: +@error: +@Returns: + + + + + + + +@source: +@uids: +@dest: +@transferred_uids: +@delete_originals: +@cancellable: +@error: +@Returns: + + diff --git a/docs/reference/camel/tmpl/camel-mime-part.sgml b/docs/reference/camel/tmpl/camel-mime-part.sgml index 4083d8b..55cad4b 100644 --- a/docs/reference/camel/tmpl/camel-mime-part.sgml +++ b/docs/reference/camel/tmpl/camel-mime-part.sgml @@ -226,7 +226,7 @@ CamelMimePart @Returns: - + diff --git a/docs/reference/camel/tmpl/camel-offline-folder.sgml b/docs/reference/camel/tmpl/camel-offline-folder.sgml index 81ba68e..e84bfae 100644 --- a/docs/reference/camel/tmpl/camel-offline-folder.sgml +++ b/docs/reference/camel/tmpl/camel-offline-folder.sgml @@ -49,7 +49,7 @@ CamelOfflineFolder @offline_sync: - + diff --git a/docs/reference/camel/tmpl/camel-offline-store.sgml b/docs/reference/camel/tmpl/camel-offline-store.sgml index 592e59e..225100b 100644 --- a/docs/reference/camel/tmpl/camel-offline-store.sgml +++ b/docs/reference/camel/tmpl/camel-offline-store.sgml @@ -26,29 +26,28 @@ CamelOfflineStore - + @store: -@state: -@cancellable: -@error: @Returns: - + @store: +@online: +@cancellable: @error: @Returns: - + diff --git a/docs/reference/camel/tmpl/camel-sasl.sgml b/docs/reference/camel/tmpl/camel-sasl.sgml index a855001..9d4c81f 100644 --- a/docs/reference/camel/tmpl/camel-sasl.sgml +++ b/docs/reference/camel/tmpl/camel-sasl.sgml @@ -46,42 +46,36 @@ CamelSasl - + -@sasl: -@token: -@cancellable: -@error: +@service_name: +@mechanism: +@service: @Returns: - + @sasl: -@token: -@cancellable: -@error: @Returns: - + -@service_name: -@mechanism: -@service: -@Returns: +@sasl: +@authenticated: - + @@ -90,16 +84,16 @@ CamelSasl @Returns: - + @sasl: -@authenticated: +@Returns: - + @@ -108,21 +102,27 @@ CamelSasl @Returns: - + @sasl: +@token: +@cancellable: +@error: @Returns: - + @sasl: +@token: +@cancellable: +@error: @Returns: diff --git a/docs/reference/camel/tmpl/camel-service.sgml b/docs/reference/camel/tmpl/camel-service.sgml index 7120ef6..8f7f083 100644 --- a/docs/reference/camel/tmpl/camel-service.sgml +++ b/docs/reference/camel/tmpl/camel-service.sgml @@ -77,36 +77,35 @@ CamelService @Returns: - + @service: -@error: +@brief: @Returns: - + @service: -@clean: -@error: @Returns: - + @service: +@Returns: - + @@ -115,44 +114,45 @@ CamelService @Returns: - + @service: -@brief: @Returns: - + @service: -@Returns: - + @service: +@error: @Returns: - + @service: +@clean: +@error: @Returns: - + diff --git a/docs/reference/camel/tmpl/camel-store.sgml b/docs/reference/camel/tmpl/camel-store.sgml index f9b7aea..7976bfc 100644 --- a/docs/reference/camel/tmpl/camel-store.sgml +++ b/docs/reference/camel/tmpl/camel-store.sgml @@ -371,324 +371,324 @@ CamelStore - + @store: -@folder_name: -@flags: -@cancellable: -@error: -@Returns: +@info: - + @store: -@cancellable: -@error: -@Returns: +@info: - + @store: -@cancellable: -@error: -@Returns: +@old_name: +@info: - + @store: -@cancellable: -@error: -@Returns: +@info: - + @store: -@parent_name: -@folder_name: -@cancellable: -@error: -@Returns: +@info: - + @store: -@folder_name: -@cancellable: -@error: -@Returns: +@fi: - + @store: -@old_namein: -@new_name: -@cancellable: -@error: -@Returns: +@fi: - + @store: -@info: +@fi: - + -@store: -@info: +@void: +@Returns: - + -@store: -@old_name: -@info: +@fi: - + -@store: -@info: +@folders: +@namespace: +@separator: +@short_names: +@Returns: - + -@store: -@info: +@fi: +@Returns: - + @store: -@expunge: -@cancellable: -@error: @Returns: - + @store: -@top: -@flags: -@cancellable: -@error: +@folder_name: @Returns: - + @store: -@fi: +@uri0: +@uri1: +@Returns: - + @store: -@fi: +@info: +@error: +@Returns: - + -@store: -@fi: - +@CAMEL_STORE_FOLDER_LOCK: - + -@void: -@Returns: +@store: +@lock: - + -@fi: +@store: +@lock: - + -@folders: -@namespace: -@separator: -@short_names: +@store: +@folder_name: +@flags: +@cancellable: +@error: @Returns: - + -@fi: +@store: +@top: +@flags: +@cancellable: +@error: @Returns: - + @store: +@cancellable: +@error: @Returns: - + @store: -@folder_name: +@cancellable: +@error: @Returns: - + @store: -@folder_name: @cancellable: @error: @Returns: - + @store: +@parent_name: @folder_name: @cancellable: @error: @Returns: - + @store: +@folder_name: @cancellable: @error: @Returns: - + @store: -@uri0: -@uri1: +@old_namein: +@new_name: +@cancellable: +@error: @Returns: - + @store: -@info: +@folder_name: +@cancellable: @error: @Returns: - + -@CAMEL_STORE_FOLDER_LOCK: +@store: +@folder_name: +@cancellable: +@error: +@Returns: - + + @store: -@lock: +@expunge: +@cancellable: +@error: +@Returns: - + @store: -@lock: +@cancellable: +@error: +@Returns: diff --git a/docs/reference/camel/tmpl/camel-transport.sgml b/docs/reference/camel/tmpl/camel-transport.sgml index 9efc6e7..c6bd743 100644 --- a/docs/reference/camel/tmpl/camel-transport.sgml +++ b/docs/reference/camel/tmpl/camel-transport.sgml @@ -26,7 +26,7 @@ CamelTransport - + diff --git a/docs/reference/camel/tmpl/camel-unused.sgml b/docs/reference/camel/tmpl/camel-unused.sgml index fff8076..152229e 100644 --- a/docs/reference/camel/tmpl/camel-unused.sgml +++ b/docs/reference/camel/tmpl/camel-unused.sgml @@ -4510,6 +4510,80 @@ streams @context: @session: + + + + + +@context: +@ipart: +@opart: +@cancellable: +@error: +@Returns: + + + + + + +@context: +@userid: +@recipients: +@ipart: +@opart: +@cancellable: +@error: +@Returns: + + + + + + +@context: +@keys: +@ostream: +@cancellable: +@error: +@Returns: + + + + + + +@context: +@istream: +@cancellable: +@error: +@Returns: + + + + + + +@context: +@userid: +@hash: +@ipart: +@opart: +@cancellable: +@error: +@Returns: + + + + + + +@context: +@ipart: +@cancellable: +@error: +@Returns: + @@ -4531,6 +4605,39 @@ streams @ex: @Returns: + + + + + +@data_wrapper: +@stream: +@cancellable: +@error: +@Returns: + + + + + + +@data_wrapper: +@stream: +@cancellable: +@error: +@Returns: + + + + + + +@data_wrapper: +@stream: +@cancellable: +@error: +@Returns: + @@ -4679,6 +4786,19 @@ streams @n: @Returns: + + + + + +@folder: +@message: +@info: +@appended_uid: +@cancellable: +@error: +@Returns: + @@ -4689,6 +4809,37 @@ streams @full_name: @name: + + + + + +@folder: +@cancellable: +@error: +@Returns: + + + + + + +@folder: +@uid: +@cancellable: +@error: +@Returns: + + + + + + +@folder: +@cancellable: +@error: +@Returns: + @@ -4739,6 +4890,42 @@ streams @summary: @Returns: + + + + + +@folder: +@expunge: +@cancellable: +@error: +@Returns: + + + + + + +@folder: +@uid: +@cancellable: +@error: +@Returns: + + + + + + +@source: +@uids: +@dest: +@transferred_uids: +@delete_originals: +@cancellable: +@error: +@Returns: + @@ -6621,6 +6808,17 @@ streams @stream: @Returns: + + + + + +@mime_part: +@parser: +@cancellable: +@error: +@Returns: + @@ -7282,6 +7480,47 @@ streams @Param1: + + + + + +@offline: +@expression: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@error: +@Returns: + + + + + + +@store: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@state: +@cancellable: +@error: +@Returns: + @@ -7563,6 +7802,28 @@ streams @sasl: @Returns: + + + + + +@sasl: +@token: +@cancellable: +@error: +@Returns: + + + + + + +@sasl: +@token: +@cancellable: +@error: +@Returns: + @@ -7664,6 +7925,35 @@ streams @type: @words: + + + + + +@service: +@error: +@Returns: + + + + + + +@service: +@clean: +@error: +@Returns: + + + + + + +@service: +@cancellable: +@error: +@Returns: + @@ -7806,6 +8096,138 @@ streams @xevline: @Returns: + + + + + +@store: +@parent_name: +@folder_name: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@folder_name: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@folder_name: +@flags: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@top: +@flags: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@old_namein: +@new_name: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@folder_name: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@expunge: +@cancellable: +@error: +@Returns: + + + + + + +@store: +@folder_name: +@cancellable: +@error: +@Returns: + @@ -7935,6 +8357,19 @@ streams @Returns: + + + + + +@transport: +@message: +@from: +@recipients: +@cancellable: +@error: +@Returns: + -- 2.7.4