[evolution-data-server/camel-gobject-do-not-rebase: 6/7] Replace CamelException with GError.
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/camel-gobject-do-not-rebase: 6/7] Replace CamelException with GError.
- Date: Sat, 28 Nov 2009 19:52:09 +0000 (UTC)
commit 41992d69aa9e1386b1bab2c90ee0457663811253
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Nov 22 18:42:33 2009 -0500
Replace CamelException with GError.
camel/Makefile.am | 3 -
camel/camel-cipher-context.c | 106 ++-
camel/camel-cipher-context.h | 25 +-
camel/camel-data-cache.c | 61 +-
camel/camel-data-cache.h | 28 +-
camel/camel-data-wrapper.c | 1 -
camel/camel-db.c | 564 +++++++++-----
camel/camel-db.h | 100 ++--
camel/camel-digest-folder.c | 87 ++-
camel/camel-digest-store.c | 67 +-
camel/camel-digest-summary.h | 1 -
camel/camel-disco-diary.c | 54 +-
camel/camel-disco-diary.h | 4 +-
camel/camel-disco-folder.c | 288 ++++----
camel/camel-disco-folder.h | 136 ++--
camel/camel-disco-store.c | 169 ++---
camel/camel-disco-store.h | 28 +-
camel/camel-exception-list.def | 37 -
camel/camel-exception.c | 260 -------
camel/camel-exception.h | 80 --
camel/camel-filter-driver.c | 210 ++++--
camel/camel-filter-driver.h | 10 +-
camel/camel-filter-search.c | 50 +-
camel/camel-filter-search.h | 4 +-
camel/camel-folder-search.c | 169 +++--
camel/camel-folder-search.h | 6 +-
camel/camel-folder-summary.c | 180 ++---
camel/camel-folder-summary.h | 14 +-
camel/camel-folder.c | 381 ++++-----
camel/camel-folder.h | 483 +++++++-----
camel/camel-gpg-context.c | 281 +++++---
camel/camel-http-stream.c | 1 -
camel/camel-index.h | 1 -
camel/camel-lock-client.c | 46 +-
camel/camel-lock-client.h | 4 +-
camel/camel-lock-helper.c | 12 -
camel/camel-lock.c | 108 ++--
camel/camel-lock.h | 10 +-
camel/camel-mime-part.c | 1 -
camel/camel-movemail.c | 113 ++--
camel/camel-movemail.h | 4 +-
camel/camel-multipart-signed.c | 11 +-
camel/camel-multipart-signed.h | 2 +-
camel/camel-multipart.c | 1 -
camel/camel-net-utils.c | 66 ++-
camel/camel-net-utils.h | 6 +-
camel/camel-object.c | 54 +-
camel/camel-object.h | 38 +-
camel/camel-offline-folder.c | 28 +-
camel/camel-offline-folder.h | 4 +-
camel/camel-offline-journal.c | 40 +-
camel/camel-offline-journal.h | 6 +-
camel/camel-offline-store.c | 47 +-
camel/camel-offline-store.h | 8 +-
camel/camel-process.c | 23 +-
camel/camel-process.h | 4 +-
camel/camel-provider.c | 70 +-
camel/camel-provider.h | 24 +-
camel/camel-sasl-anonymous.c | 32 +-
camel/camel-sasl-cram-md5.c | 2 +-
camel/camel-sasl-digest-md5.c | 42 +-
camel/camel-sasl-gssapi.c | 45 +-
camel/camel-sasl-login.c | 10 +-
camel/camel-sasl-ntlm.c | 2 +-
camel/camel-sasl-plain.c | 2 +-
camel/camel-sasl-popb4smtp.c | 18 +-
camel/camel-sasl.c | 14 +-
camel/camel-sasl.h | 7 +-
camel/camel-search-private.c | 15 +-
camel/camel-search-private.h | 2 +-
camel/camel-service.c | 92 ++-
camel/camel-service.h | 93 ++-
camel/camel-session.c | 91 +--
camel/camel-session.h | 28 +-
camel/camel-smime-context.c | 166 +++--
camel/camel-store.c | 341 +++++----
camel/camel-store.h | 218 +++---
camel/camel-text-index.h | 1 -
camel/camel-transport.c | 6 +-
camel/camel-transport.h | 4 +-
camel/camel-url.c | 13 +-
camel/camel-url.h | 4 +-
camel/camel-vee-folder.c | 210 +++---
camel/camel-vee-folder.h | 6 +-
camel/camel-vee-store.c | 63 +-
camel/camel-vee-summary.h | 1 -
camel/camel-vtrash-folder.c | 40 +-
camel/camel.h | 1 -
camel/providers/groupwise/camel-groupwise-folder.c | 270 ++++---
camel/providers/groupwise/camel-groupwise-folder.h | 4 +-
.../providers/groupwise/camel-groupwise-journal.c | 63 +-
.../providers/groupwise/camel-groupwise-journal.h | 4 +-
.../providers/groupwise/camel-groupwise-provider.c | 5 +-
camel/providers/groupwise/camel-groupwise-store.c | 241 ++++---
camel/providers/groupwise/camel-groupwise-store.h | 4 +-
.../providers/groupwise/camel-groupwise-summary.c | 10 +-
.../groupwise/camel-groupwise-transport.c | 52 +-
camel/providers/hula/camel-hula-provider.c | 2 +-
camel/providers/imap/camel-imap-command.c | 173 +++--
camel/providers/imap/camel-imap-command.h | 12 +-
camel/providers/imap/camel-imap-folder.c | 810 ++++++++++++--------
camel/providers/imap/camel-imap-folder.h | 24 +-
camel/providers/imap/camel-imap-journal.c | 25 +-
camel/providers/imap/camel-imap-message-cache.c | 113 ++--
camel/providers/imap/camel-imap-message-cache.h | 18 +-
camel/providers/imap/camel-imap-store.c | 646 +++++++++-------
camel/providers/imap/camel-imap-store.h | 4 +-
camel/providers/imap/camel-imap-summary.c | 15 +-
camel/providers/imap4/camel-imap4-command.h | 4 +-
camel/providers/imap4/camel-imap4-engine.c | 36 +-
camel/providers/imap4/camel-imap4-engine.h | 26 +-
camel/providers/imap4/camel-imap4-folder.c | 52 +-
camel/providers/imap4/camel-imap4-folder.h | 2 +-
camel/providers/imap4/camel-imap4-journal.c | 8 +-
camel/providers/imap4/camel-imap4-journal.h | 2 +-
camel/providers/imap4/camel-imap4-search.c | 2 +-
camel/providers/imap4/camel-imap4-store.c | 66 +-
camel/providers/imap4/camel-imap4-summary.c | 14 +-
camel/providers/imap4/camel-imap4-summary.h | 2 +-
camel/providers/imap4/camel-imap4-utils.c | 8 +-
camel/providers/imap4/camel-imap4-utils.h | 8 +-
camel/providers/imapx/camel-imapx-exception.c | 4 +-
camel/providers/imapx/camel-imapx-exception.h | 4 +-
camel/providers/imapx/camel-imapx-folder.c | 17 +-
camel/providers/imapx/camel-imapx-server.c | 38 +-
camel/providers/imapx/camel-imapx-server.h | 12 +-
camel/providers/imapx/camel-imapx-store.c | 27 +-
camel/providers/imapx/camel-imapx-stream.c | 16 +-
camel/providers/imapx/camel-imapx-stream.h | 16 +-
camel/providers/imapx/camel-imapx-summary.c | 4 +-
camel/providers/imapx/camel-imapx-summary.h | 1 -
camel/providers/imapx/camel-imapx-utils.c | 26 +-
camel/providers/imapx/camel-imapx-utils.h | 26 +-
camel/providers/imapx/camel-imapx-view-summary.c | 2 +-
camel/providers/imapx/camel-imapx-view-summary.h | 2 +-
camel/providers/imapx/test-imapx.c | 2 +-
camel/providers/local/camel-local-folder.c | 84 ++-
camel/providers/local/camel-local-folder.h | 6 +-
camel/providers/local/camel-local-store.c | 205 ++++--
camel/providers/local/camel-local-summary.c | 73 ++-
camel/providers/local/camel-local-summary.h | 16 +-
camel/providers/local/camel-maildir-folder.c | 180 +++--
camel/providers/local/camel-maildir-folder.h | 2 +-
camel/providers/local/camel-maildir-store.c | 201 ++++--
camel/providers/local/camel-maildir-summary.c | 54 +-
camel/providers/local/camel-mbox-folder.c | 145 ++--
camel/providers/local/camel-mbox-folder.h | 2 +-
camel/providers/local/camel-mbox-store.c | 258 ++++---
camel/providers/local/camel-mbox-summary.c | 217 ++++--
camel/providers/local/camel-mbox-summary.h | 6 +-
camel/providers/local/camel-mh-folder.c | 94 ++-
camel/providers/local/camel-mh-folder.h | 2 +-
camel/providers/local/camel-mh-store.c | 174 +++--
camel/providers/local/camel-mh-summary.c | 49 +-
camel/providers/local/camel-spool-folder.c | 39 +-
camel/providers/local/camel-spool-folder.h | 2 +-
camel/providers/local/camel-spool-store.c | 228 ++++--
camel/providers/local/camel-spool-summary.c | 130 ++--
camel/providers/local/camel-spool-summary.h | 8 +-
camel/providers/nntp/camel-nntp-auth.c | 2 +-
camel/providers/nntp/camel-nntp-auth.h | 2 +-
camel/providers/nntp/camel-nntp-folder.c | 252 ++++--
camel/providers/nntp/camel-nntp-folder.h | 4 +-
camel/providers/nntp/camel-nntp-grouplist.c | 10 +-
camel/providers/nntp/camel-nntp-grouplist.h | 6 +-
camel/providers/nntp/camel-nntp-store.c | 329 +++++----
camel/providers/nntp/camel-nntp-store.h | 8 +-
camel/providers/nntp/camel-nntp-summary.c | 47 +-
camel/providers/nntp/camel-nntp-summary.h | 2 +-
camel/providers/nntp/camel-nntp-utils.c | 6 +-
camel/providers/nntp/camel-nntp-utils.h | 2 +-
camel/providers/pop3/camel-pop3-folder.c | 110 ++-
camel/providers/pop3/camel-pop3-folder.h | 4 +-
camel/providers/pop3/camel-pop3-store.c | 274 +++++---
camel/providers/pop3/camel-pop3-store.h | 6 +-
.../providers/sendmail/camel-sendmail-transport.c | 66 +-
camel/providers/smtp/camel-smtp-transport.c | 444 ++++++++----
camel/tests/folder/test1.c | 1 -
camel/tests/folder/test10.c | 1 -
camel/tests/folder/test11.c | 1 -
camel/tests/folder/test2.c | 1 -
camel/tests/folder/test3.c | 1 -
camel/tests/folder/test4.c | 1 -
camel/tests/folder/test5.c | 1 -
camel/tests/folder/test6.c | 1 -
camel/tests/folder/test7.c | 1 -
camel/tests/folder/test8.c | 1 -
camel/tests/folder/test9.c | 1 -
camel/tests/lib/camel-test-provider.c | 1 -
camel/tests/lib/folders.c | 2 -
camel/tests/misc/split.c | 1 -
camel/tests/misc/url.c | 1 -
camel/tests/misc/utf7.c | 1 -
.../reference/camel/tmpl/camel-cipher-context.sgml | 12 +-
docs/reference/camel/tmpl/camel-data-cache.sgml | 14 +-
docs/reference/camel/tmpl/camel-db.sgml | 96 ++--
docs/reference/camel/tmpl/camel-disco-diary.sgml | 4 +-
docs/reference/camel/tmpl/camel-disco-folder.sgml | 9 +-
docs/reference/camel/tmpl/camel-disco-store.sgml | 6 +-
docs/reference/camel/tmpl/camel-exception.sgml | 109 ---
docs/reference/camel/tmpl/camel-filter-driver.sgml | 10 +-
docs/reference/camel/tmpl/camel-filter-search.sgml | 4 +-
docs/reference/camel/tmpl/camel-folder-search.sgml | 6 +-
.../reference/camel/tmpl/camel-folder-summary.sgml | 12 +-
docs/reference/camel/tmpl/camel-folder.sgml | 30 +-
.../camel/tmpl/camel-groupwise-folder.sgml | 4 +-
.../camel/tmpl/camel-groupwise-journal.sgml | 4 +-
.../camel/tmpl/camel-groupwise-store.sgml | 4 +-
docs/reference/camel/tmpl/camel-imap-command.sgml | 12 +-
docs/reference/camel/tmpl/camel-imap-folder.sgml | 19 +-
.../camel/tmpl/camel-imap-message-cache.sgml | 18 +-
docs/reference/camel/tmpl/camel-imap-store.sgml | 4 +-
docs/reference/camel/tmpl/camel-imap4-command.sgml | 4 +-
docs/reference/camel/tmpl/camel-imap4-engine.sgml | 26 +-
docs/reference/camel/tmpl/camel-imap4-folder.sgml | 2 +-
docs/reference/camel/tmpl/camel-imap4-journal.sgml | 2 +-
docs/reference/camel/tmpl/camel-imap4-summary.sgml | 2 +-
docs/reference/camel/tmpl/camel-imap4-utils.sgml | 8 +-
docs/reference/camel/tmpl/camel-local-folder.sgml | 4 +-
docs/reference/camel/tmpl/camel-local-summary.sgml | 8 +-
docs/reference/camel/tmpl/camel-lock-client.sgml | 2 +-
docs/reference/camel/tmpl/camel-lock.sgml | 8 +-
.../reference/camel/tmpl/camel-maildir-folder.sgml | 2 +-
docs/reference/camel/tmpl/camel-mbox-folder.sgml | 2 +-
docs/reference/camel/tmpl/camel-mbox-summary.sgml | 2 +-
docs/reference/camel/tmpl/camel-mh-folder.sgml | 2 +-
docs/reference/camel/tmpl/camel-movemail.sgml | 2 +-
.../camel/tmpl/camel-multipart-signed.sgml | 2 +-
docs/reference/camel/tmpl/camel-net-utils.sgml | 4 +-
docs/reference/camel/tmpl/camel-nntp-auth.sgml | 2 +-
docs/reference/camel/tmpl/camel-nntp-folder.sgml | 5 +-
.../reference/camel/tmpl/camel-nntp-grouplist.sgml | 6 +-
docs/reference/camel/tmpl/camel-nntp-store.sgml | 8 +-
docs/reference/camel/tmpl/camel-nntp-summary.sgml | 2 +-
docs/reference/camel/tmpl/camel-nntp-utils.sgml | 2 +-
docs/reference/camel/tmpl/camel-object.sgml | 12 +-
.../reference/camel/tmpl/camel-offline-folder.sgml | 2 +-
.../camel/tmpl/camel-offline-journal.sgml | 4 +-
docs/reference/camel/tmpl/camel-offline-store.sgml | 6 +-
docs/reference/camel/tmpl/camel-pop3-folder.sgml | 4 +-
docs/reference/camel/tmpl/camel-pop3-store.sgml | 6 +-
docs/reference/camel/tmpl/camel-process.sgml | 2 +-
docs/reference/camel/tmpl/camel-provider.sgml | 9 +-
docs/reference/camel/tmpl/camel-sasl.sgml | 4 +-
docs/reference/camel/tmpl/camel-service.sgml | 9 +-
docs/reference/camel/tmpl/camel-session.sgml | 16 +-
docs/reference/camel/tmpl/camel-spool-folder.sgml | 2 +-
docs/reference/camel/tmpl/camel-spool-summary.sgml | 8 +-
docs/reference/camel/tmpl/camel-store.sgml | 32 +-
docs/reference/camel/tmpl/camel-transport.sgml | 2 +-
docs/reference/camel/tmpl/camel-unused.sgml | 96 +++
docs/reference/camel/tmpl/camel-url.sgml | 2 +-
docs/reference/camel/tmpl/camel-vee-folder.sgml | 4 +-
253 files changed, 7657 insertions(+), 5923 deletions(-)
---
diff --git a/camel/Makefile.am b/camel/Makefile.am
index cc94c78..b57c652 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -174,7 +174,6 @@ libcamel_1_2_la_SOURCES = \
camel-data-wrapper.c \
camel-db.c \
camel-debug.c \
- camel-exception.c \
camel-file-utils.c \
camel-html-parser.c \
camel-iconv.c \
@@ -246,8 +245,6 @@ libcamelinclude_HEADERS = \
camel-data-wrapper.h \
camel-db.h \
camel-debug.h \
- camel-exception-list.def \
- camel-exception.h \
camel-file-utils.h \
camel-i18n.h \
camel-iconv.h \
diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c
index 83bbd7e..ce4265f 100644
--- a/camel/camel-cipher-context.c
+++ b/camel/camel-cipher-context.c
@@ -62,11 +62,17 @@ enum {
static gpointer parent_class;
static gint
-cipher_sign (CamelCipherContext *ctx, const gchar *userid, CamelCipherHash hash,
- struct _CamelMimePart *ipart, struct _CamelMimePart *opart, CamelException *ex)
+cipher_sign (CamelCipherContext *ctx,
+ const gchar *userid,
+ CamelCipherHash hash,
+ CamelMimePart *ipart,
+ CamelMimePart *opart,
+ GError **error)
{
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Signing is not supported by this cipher"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Signing is not supported by this cipher"));
+
return -1;
}
@@ -77,7 +83,7 @@ cipher_sign (CamelCipherContext *ctx, const gchar *userid, CamelCipherHash hash,
* @hash: preferred Message-Integrity-Check hash algorithm
* @ipart: Input part.
* @opart: output part.
- * @ex: exception
+ * @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.
@@ -90,7 +96,7 @@ camel_cipher_sign (CamelCipherContext *context,
CamelCipherHash hash,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
gint retval;
@@ -104,7 +110,7 @@ camel_cipher_sign (CamelCipherContext *context,
CIPHER_LOCK (context);
- retval = class->sign (context, userid, hash, ipart, opart, ex);
+ retval = class->sign (context, userid, hash, ipart, opart, error);
CIPHER_UNLOCK (context);
@@ -114,10 +120,14 @@ camel_cipher_sign (CamelCipherContext *context,
}
static CamelCipherValidity *
-cipher_verify (CamelCipherContext *context, struct _CamelMimePart *sigpart, CamelException *ex)
+cipher_verify (CamelCipherContext *context,
+ CamelMimePart *sigpart,
+ GError **error)
{
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Verifying is not supported by this cipher"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Verifying is not supported by this cipher"));
+
return NULL;
}
@@ -125,7 +135,7 @@ cipher_verify (CamelCipherContext *context, struct _CamelMimePart *sigpart, Came
* camel_cipher_verify:
* @context: Cipher Context
* @ipart: part to verify
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Verifies the signature. If @istream is a clearsigned stream,
* you should pass %NULL as the sigstream parameter. Otherwise
@@ -139,7 +149,7 @@ cipher_verify (CamelCipherContext *context, struct _CamelMimePart *sigpart, Came
CamelCipherValidity *
camel_cipher_verify (CamelCipherContext *context,
CamelMimePart *ipart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
CamelCipherValidity *valid;
@@ -153,7 +163,7 @@ camel_cipher_verify (CamelCipherContext *context,
CIPHER_LOCK (context);
- valid = class->verify (context, ipart, ex);
+ valid = class->verify (context, ipart, error);
CIPHER_UNLOCK (context);
@@ -163,11 +173,17 @@ camel_cipher_verify (CamelCipherContext *context,
}
static gint
-cipher_encrypt (CamelCipherContext *context, const gchar *userid, GPtrArray *recipients,
- struct _CamelMimePart *ipart, struct _CamelMimePart *opart, CamelException *ex)
+cipher_encrypt (CamelCipherContext *context,
+ const gchar *userid,
+ GPtrArray *recipients,
+ CamelMimePart *ipart,
+ CamelMimePart *opart,
+ GError **error)
{
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Encryption is not supported by this cipher"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Encryption is not supported by this cipher"));
+
return -1;
}
@@ -178,7 +194,7 @@ cipher_encrypt (CamelCipherContext *context, const gchar *userid, GPtrArray *rec
* @recipients: an array of recipient key ids and/or email addresses
* @ipart: cleartext input stream
* @opart: ciphertext output stream
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Encrypts (and optionally signs) the cleartext input stream and
* writes the resulting ciphertext to the output stream.
@@ -191,7 +207,7 @@ camel_cipher_encrypt (CamelCipherContext *context,
GPtrArray *recipients,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
gint retval;
@@ -205,7 +221,8 @@ camel_cipher_encrypt (CamelCipherContext *context,
CIPHER_LOCK (context);
- retval = class->encrypt (context, userid, recipients, ipart, opart, ex);
+ retval = class->encrypt (
+ context, userid, recipients, ipart, opart, error);
CIPHER_UNLOCK (context);
@@ -215,10 +232,15 @@ camel_cipher_encrypt (CamelCipherContext *context,
}
static CamelCipherValidity *
-cipher_decrypt (CamelCipherContext *context, struct _CamelMimePart *ipart, struct _CamelMimePart *opart, CamelException *ex)
+cipher_decrypt (CamelCipherContext *context,
+ CamelMimePart *ipart,
+ CamelMimePart *opart,
+ GError **error)
{
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Decryption is not supported by this cipher"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Decryption is not supported by this cipher"));
+
return NULL;
}
@@ -227,7 +249,7 @@ cipher_decrypt (CamelCipherContext *context, struct _CamelMimePart *ipart, struc
* @context:
* @ipart:
* @opart:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Decrypts @ipart into @opart.
*
@@ -237,7 +259,7 @@ CamelCipherValidity *
camel_cipher_decrypt (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
CamelCipherValidity *valid;
@@ -251,7 +273,7 @@ camel_cipher_decrypt (CamelCipherContext *context,
CIPHER_LOCK (context);
- valid = class->decrypt (context, ipart, opart, ex);
+ valid = class->decrypt (context, ipart, opart, error);
CIPHER_UNLOCK (context);
@@ -261,10 +283,13 @@ camel_cipher_decrypt (CamelCipherContext *context,
}
static gint
-cipher_import_keys (CamelCipherContext *context, struct _CamelStream *istream, CamelException *ex)
+cipher_import_keys (CamelCipherContext *context,
+ CamelStream *istream,
+ GError **error)
{
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("You may not import keys with this cipher"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("You may not import keys with this cipher"));
return -1;
}
@@ -273,7 +298,7 @@ cipher_import_keys (CamelCipherContext *context, struct _CamelStream *istream, C
* camel_cipher_import_keys:
* @context: Cipher Context
* @istream: input stream (containing keys)
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Imports a stream of keys/certificates contained within @istream
* into the key/certificate database controlled by @ctx.
@@ -283,7 +308,7 @@ cipher_import_keys (CamelCipherContext *context, struct _CamelStream *istream, C
gint
camel_cipher_import_keys (CamelCipherContext *context,
CamelStream *istream,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
@@ -293,15 +318,18 @@ camel_cipher_import_keys (CamelCipherContext *context,
class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context);
g_return_val_if_fail (class->import_keys != NULL, -1);
- return class->import_keys (context, istream, ex);
+ return class->import_keys (context, istream, error);
}
static gint
-cipher_export_keys (CamelCipherContext *context, GPtrArray *keys,
- struct _CamelStream *ostream, CamelException *ex)
+cipher_export_keys (CamelCipherContext *context,
+ GPtrArray *keys,
+ CamelStream *ostream,
+ GError **error)
{
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("You may not export keys with this cipher"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("You may not export keys with this cipher"));
return -1;
}
@@ -311,7 +339,7 @@ cipher_export_keys (CamelCipherContext *context, GPtrArray *keys,
* @context: Cipher Context
* @keys: an array of key ids
* @ostream: output stream
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Exports the keys/certificates in @keys to the stream @ostream from
* the key/certificate database controlled by @ctx.
@@ -322,7 +350,7 @@ gint
camel_cipher_export_keys (CamelCipherContext *context,
GPtrArray *keys,
CamelStream *ostream,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
@@ -333,7 +361,7 @@ camel_cipher_export_keys (CamelCipherContext *context,
class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context);
g_return_val_if_fail (class->export_keys != NULL, -1);
- return class->export_keys (context, keys, ostream, ex);
+ return class->export_keys (context, keys, ostream, error);
}
static CamelCipherHash
diff --git a/camel/camel-cipher-context.h b/camel/camel-cipher-context.h
index 8292fec..4679f79 100644
--- a/camel/camel-cipher-context.h
+++ b/camel/camel-cipher-context.h
@@ -27,7 +27,6 @@
#ifndef CAMEL_CIPHER_CONTEXT_H
#define CAMEL_CIPHER_CONTEXT_H
-#include <camel/camel-exception.h>
#include <camel/camel-list-utils.h>
#include <camel/camel-mime-part.h>
#include <camel/camel-object.h>
@@ -142,29 +141,29 @@ struct _CamelCipherContextClass {
CamelCipherHash hash,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex);
+ GError **error);
CamelCipherValidity *
(*verify) (CamelCipherContext *context,
CamelMimePart *ipart,
- CamelException *ex);
+ GError **error);
gint (*encrypt) (CamelCipherContext *context,
const gchar *userid,
GPtrArray *recipients,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex);
+ GError **error);
CamelCipherValidity *
(*decrypt) (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex);
+ GError **error);
gint (*import_keys) (CamelCipherContext *context,
CamelStream *istream,
- CamelException *ex);
+ GError **error);
gint (*export_keys) (CamelCipherContext *context,
GPtrArray *keys,
CamelStream *ostream,
- CamelException *ex);
+ GError **error);
};
GType camel_cipher_context_get_type (void);
@@ -183,19 +182,19 @@ const gchar * camel_cipher_hash_to_id (CamelCipherContext *context, CamelCi
/* cipher routines */
gint camel_cipher_sign (CamelCipherContext *context, const gchar *userid, CamelCipherHash hash,
- CamelMimePart *ipart, CamelMimePart *opart, CamelException *ex);
-CamelCipherValidity *camel_cipher_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *ex);
+ CamelMimePart *ipart, CamelMimePart *opart, GError **error);
+CamelCipherValidity *camel_cipher_verify (CamelCipherContext *context, CamelMimePart *ipart, GError **error);
gint camel_cipher_encrypt (CamelCipherContext *context, const gchar *userid,
GPtrArray *recipients, CamelMimePart *ipart, CamelMimePart *opart,
- CamelException *ex);
+ GError **error);
CamelCipherValidity *camel_cipher_decrypt (CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *opart,
- CamelException *ex);
+ GError **error);
/* key/certificate routines */
gint camel_cipher_import_keys (CamelCipherContext *context, CamelStream *istream,
- CamelException *ex);
+ GError **error);
gint camel_cipher_export_keys (CamelCipherContext *context, GPtrArray *keys,
- CamelStream *ostream, CamelException *ex);
+ CamelStream *ostream, GError **error);
/* CamelCipherValidity utility functions */
CamelCipherValidity *camel_cipher_validity_new (void);
diff --git a/camel/camel-data-cache.c b/camel/camel-data-cache.c
index 7d50bcc..f7dbcf2 100644
--- a/camel/camel-data-cache.c
+++ b/camel/camel-data-cache.c
@@ -38,7 +38,6 @@
#include <libedataserver/e-data-server-util.h>
#include "camel-data-cache.h"
-#include "camel-exception.h"
#include "camel-stream-fs.h"
#include "camel-stream-mem.h"
#include "camel-file-utils.h"
@@ -186,7 +185,7 @@ camel_data_cache_get_type (void)
/**
* camel_data_cache_new:
* @path: Base path of cache, subdirectories will be created here.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Create a new data cache.
*
@@ -195,13 +194,14 @@ camel_data_cache_get_type (void)
**/
CamelDataCache *
camel_data_cache_new (const gchar *path,
- CamelException *ex)
+ GError **error)
{
g_return_val_if_fail (path != NULL, NULL);
if (g_mkdir_with_parents (path, 0700) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unable to create cache path"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unable to create cache path"));
return NULL;
}
@@ -355,7 +355,7 @@ data_cache_path(CamelDataCache *cdc, gint create, const gchar *path, const gchar
* @cdc: A #CamelDataCache
* @path: Relative path of item to add.
* @key: Key of item to add.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Add a new item to the cache.
*
@@ -369,7 +369,10 @@ data_cache_path(CamelDataCache *cdc, gint create, const gchar *path, const gchar
* The caller must unref this when finished.
**/
CamelStream *
-camel_data_cache_add(CamelDataCache *cdc, const gchar *path, const gchar *key, CamelException *ex)
+camel_data_cache_add (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error)
{
gchar *real;
CamelStream *stream;
@@ -403,7 +406,7 @@ camel_data_cache_add(CamelDataCache *cdc, const gchar *path, const gchar *key, C
* @cdc: A #CamelDataCache
* @path: Path to the (sub) cache the item exists in.
* @key: Key for the cache item.
- * @ex:
+ * @error:
*
* Lookup an item in the cache. If the item exists, a stream
* is returned for the item. The stream may be shared by
@@ -413,7 +416,10 @@ camel_data_cache_add(CamelDataCache *cdc, const gchar *path, const gchar *key, C
* Return value: A cache item, or NULL if the cache item does not exist.
**/
CamelStream *
-camel_data_cache_get(CamelDataCache *cdc, const gchar *path, const gchar *key, CamelException *ex)
+camel_data_cache_get (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error)
{
gchar *real;
CamelStream *stream;
@@ -437,14 +443,17 @@ camel_data_cache_get(CamelDataCache *cdc, const gchar *path, const gchar *key, C
* @cdc: A #CamelDataCache
* @path: Path to the (sub) cache the item exists in.
* @key: Key for the cache item.
- * @ex:
+ * @error:
*
* Lookup the filename for an item in the cache
*
* Return value: The filename for a cache item
**/
gchar *
-camel_data_cache_get_filename (CamelDataCache *cdc, const gchar *path, const gchar *key, CamelException *ex)
+camel_data_cache_get_filename (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error)
{
gchar *real;
@@ -458,14 +467,17 @@ camel_data_cache_get_filename (CamelDataCache *cdc, const gchar *path, const gch
* @cdc: A #CamelDataCache
* @path:
* @key:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Remove/expire a cache item.
*
* Return value:
**/
gint
-camel_data_cache_remove(CamelDataCache *cdc, const gchar *path, const gchar *key, CamelException *ex)
+camel_data_cache_remove (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error)
{
CamelStream *stream;
gchar *real;
@@ -480,9 +492,11 @@ camel_data_cache_remove(CamelDataCache *cdc, const gchar *path, const gchar *key
/* maybe we were a mem stream */
if (g_unlink (real) == -1 && errno != ENOENT) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not remove cache entry: %s: %s"),
- real, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not remove cache entry: %s: %s"),
+ real, g_strerror (errno));
ret = -1;
} else {
ret = 0;
@@ -498,7 +512,7 @@ camel_data_cache_remove(CamelDataCache *cdc, const gchar *path, const gchar *key
* @cache:
* @old:
* @new:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Rename a cache path. All cache items accessed from the old path
* are accessible using the new path.
@@ -507,8 +521,11 @@ camel_data_cache_remove(CamelDataCache *cdc, const gchar *path, const gchar *key
*
* Return value: -1 on error.
**/
-gint camel_data_cache_rename(CamelDataCache *cache,
- const gchar *old, const gchar *new, CamelException *ex)
+gint
+camel_data_cache_rename (CamelDataCache *cache,
+ const gchar *old,
+ const gchar *new,
+ GError **error)
{
/* blah dont care yet */
return -1;
@@ -518,7 +535,7 @@ gint camel_data_cache_rename(CamelDataCache *cache,
* camel_data_cache_clear:
* @cache:
* @path: Path to clear, or NULL to clear all items in all paths.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Clear all items in a given cache path or all items in the cache.
*
@@ -527,7 +544,9 @@ gint camel_data_cache_rename(CamelDataCache *cache,
* Return value: -1 on error.
**/
gint
-camel_data_cache_clear(CamelDataCache *cache, const gchar *path, CamelException *ex)
+camel_data_cache_clear (CamelDataCache *cache,
+ const gchar *path,
+ GError **error)
{
/* nor for this? */
return -1;
diff --git a/camel/camel-data-cache.h b/camel/camel-data-cache.h
index cc10b1d..64a7f6b 100644
--- a/camel/camel-data-cache.h
+++ b/camel/camel-data-cache.h
@@ -28,7 +28,6 @@
#define CAMEL_DATA_CACHE_H
#include <camel/camel-stream.h>
-#include <camel/camel-exception.h>
/* Standard GObject macros */
#define CAMEL_TYPE_DATA_CACHE \
@@ -66,7 +65,7 @@ struct _CamelDataCacheClass {
GType camel_data_cache_get_type (void);
CamelDataCache *camel_data_cache_new (const gchar *path,
- CamelException *ex);
+ GError **error);
const gchar * camel_data_cache_get_path (CamelDataCache *cdc);
void camel_data_cache_set_path (CamelDataCache *cdc,
const gchar *path);
@@ -75,29 +74,32 @@ void camel_data_cache_set_expire_age (CamelDataCache *cdc,
void camel_data_cache_set_expire_access
(CamelDataCache *cdc,
time_t when);
-gint camel_data_cache_rename (CamelDataCache *cache,
- const gchar *old,
- const gchar *new,
- CamelException *ex);
CamelStream * camel_data_cache_add (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex);
+ GError **error);
CamelStream * camel_data_cache_get (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex);
+ GError **error);
gint camel_data_cache_remove (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex);
-gint camel_data_cache_clear (CamelDataCache *cache,
- const gchar *path,
- CamelException *ex);
+ GError **error);
gchar * camel_data_cache_get_filename (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex);
+ GError **error);
+
+#ifndef CAMEL_DISABLE_DEPRECATED
+gint camel_data_cache_rename (CamelDataCache *cache,
+ const gchar *old,
+ const gchar *new,
+ GError **error);
+gint camel_data_cache_clear (CamelDataCache *cache,
+ const gchar *path,
+ GError **error);
+#endif
G_END_DECLS
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index af28b2a..3da4195 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -27,7 +27,6 @@
#include <errno.h>
#include "camel-data-wrapper.h"
-#include "camel-exception.h"
#include "camel-mime-filter-basic.h"
#include "camel-mime-filter-crlf.h"
#include "camel-private.h"
diff --git a/camel/camel-db.c b/camel/camel-db.c
index 87aeced..aa7b109 100644
--- a/camel/camel-db.c
+++ b/camel/camel-db.c
@@ -34,6 +34,7 @@
#include <glib/gi18n-lib.h>
#include "camel-debug.h"
+#include "camel-object.h"
/* how long to wait before invoking sync on the file */
#define SYNC_TIMEOUT_SECONDS 5
@@ -355,10 +356,10 @@ struct _CamelDBPrivate {
static GStaticRecMutex trans_lock = G_STATIC_REC_MUTEX_INIT;
-static gint write_mir (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelException *ex, gboolean delete_old_record);
-
static gint
-cdb_sql_exec (sqlite3 *db, const gchar * stmt, CamelException *ex)
+cdb_sql_exec (sqlite3 *db,
+ const gchar *stmt,
+ GError **error)
{
gchar *errmsg = NULL;
gint ret = -1;
@@ -376,8 +377,9 @@ cdb_sql_exec (sqlite3 *db, const gchar * stmt, CamelException *ex)
if (ret != SQLITE_OK) {
d(g_print ("Error in SQL EXEC statement: %s [%s].\n", stmt, errmsg));
- if (ex)
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _(errmsg));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM, "%s", errmsg);
sqlite3_free (errmsg);
errmsg = NULL;
return -1;
@@ -392,7 +394,8 @@ cdb_sql_exec (sqlite3 *db, const gchar * stmt, CamelException *ex)
}
CamelDB *
-camel_db_open (const gchar *path, CamelException *ex)
+camel_db_open (const gchar *path,
+ GError **error)
{
static GOnce vfs_once = G_ONCE_INIT;
CamelDB *cdb;
@@ -409,12 +412,17 @@ camel_db_open (const gchar *path, CamelException *ex)
if (ret) {
if (!db) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Insufficient memory"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Insufficient memory"));
} else {
- const gchar *error;
- error = sqlite3_errmsg (db);
- d(g_print("Can't open database %s: %s\n", path, error));
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _(error));
+ const gchar *errmsg;
+ errmsg = sqlite3_errmsg (db);
+ d(g_print("Can't open database %s: %s\n", path, errmsg));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM, "%s", errmsg);
sqlite3_close(db);
}
return NULL;
@@ -451,9 +459,10 @@ camel_db_open (const gchar *path, CamelException *ex)
}
CamelDB *
-camel_db_clone (CamelDB *cdb, CamelException *ex)
+camel_db_clone (CamelDB *cdb,
+ GError **error)
{
- return camel_db_open(cdb->priv->file_name, ex);
+ return camel_db_open (cdb->priv->file_name, error);
}
void
@@ -486,24 +495,27 @@ camel_db_set_collate (CamelDB *cdb, const gchar *col, const gchar *collate, Came
/* Should this be really exposed ? */
gint
-camel_db_command (CamelDB *cdb, const gchar *stmt, CamelException *ex)
+camel_db_command (CamelDB *cdb,
+ const gchar *stmt,
+ GError **error)
{
- gint ret;
+ gint ret;
- if (!cdb)
- return TRUE;
- g_mutex_lock (cdb->lock);
+ if (!cdb)
+ return TRUE;
+ g_mutex_lock (cdb->lock);
- START(stmt);
- ret = cdb_sql_exec (cdb->db, stmt, ex);
- END;
- g_mutex_unlock (cdb->lock);
+ START(stmt);
+ ret = cdb_sql_exec (cdb->db, stmt, error);
+ END;
+ g_mutex_unlock (cdb->lock);
- return ret;
+ return ret;
}
gint
-camel_db_begin_transaction (CamelDB *cdb, CamelException *ex)
+camel_db_begin_transaction (CamelDB *cdb,
+ GError **error)
{
if (!cdb)
return -1;
@@ -513,17 +525,18 @@ camel_db_begin_transaction (CamelDB *cdb, CamelException *ex)
g_mutex_lock (cdb->lock);
STARTTS("BEGIN");
- return (cdb_sql_exec (cdb->db, "BEGIN", ex));
+ return (cdb_sql_exec (cdb->db, "BEGIN", error));
}
gint
-camel_db_end_transaction (CamelDB *cdb, CamelException *ex)
+camel_db_end_transaction (CamelDB *cdb,
+ GError **error)
{
gint ret;
if (!cdb)
return -1;
- ret = cdb_sql_exec (cdb->db, "COMMIT", ex);
+ ret = cdb_sql_exec (cdb->db, "COMMIT", error);
ENDTS;
g_mutex_unlock (cdb->lock);
if (g_getenv("SQLITE_TRANSLOCK"))
@@ -535,11 +548,12 @@ camel_db_end_transaction (CamelDB *cdb, CamelException *ex)
}
gint
-camel_db_abort_transaction (CamelDB *cdb, CamelException *ex)
+camel_db_abort_transaction (CamelDB *cdb,
+ GError **error)
{
gint ret;
- ret = cdb_sql_exec (cdb->db, "ROLLBACK", ex);
+ ret = cdb_sql_exec (cdb->db, "ROLLBACK", error);
g_mutex_unlock (cdb->lock);
if (g_getenv("SQLITE_TRANSLOCK"))
g_static_rec_mutex_unlock (&trans_lock);
@@ -549,16 +563,20 @@ camel_db_abort_transaction (CamelDB *cdb, CamelException *ex)
}
gint
-camel_db_add_to_transaction (CamelDB *cdb, const gchar *stmt, CamelException *ex)
+camel_db_add_to_transaction (CamelDB *cdb,
+ const gchar *stmt,
+ GError **error)
{
if (!cdb)
return -1;
- return (cdb_sql_exec (cdb->db, stmt, ex));
+ return (cdb_sql_exec (cdb->db, stmt, error));
}
gint
-camel_db_transaction_command (CamelDB *cdb, GSList *qry_list, CamelException *ex)
+camel_db_transaction_command (CamelDB *cdb,
+ GSList *qry_list,
+ GError **error)
{
gint ret;
const gchar *query;
@@ -568,19 +586,19 @@ camel_db_transaction_command (CamelDB *cdb, GSList *qry_list, CamelException *ex
g_mutex_lock (cdb->lock);
STARTTS("BEGIN");
- ret = cdb_sql_exec (cdb->db, "BEGIN", ex);
+ ret = cdb_sql_exec (cdb->db, "BEGIN", error);
if (ret)
goto end;
while (qry_list) {
query = qry_list->data;
- ret = cdb_sql_exec (cdb->db, query, ex);
+ ret = cdb_sql_exec (cdb->db, query, error);
if (ret)
goto end;
qry_list = g_slist_next (qry_list);
}
- ret = cdb_sql_exec (cdb->db, "COMMIT", ex);
+ ret = cdb_sql_exec (cdb->db, "COMMIT", error);
ENDTS;
end:
g_mutex_unlock (cdb->lock);
@@ -602,7 +620,10 @@ count_cb (gpointer data, gint argc, gchar **argv, gchar **azColName)
}
gint
-camel_db_count_message_info (CamelDB *cdb, const gchar *query, guint32 *count, CamelException *ex)
+camel_db_count_message_info (CamelDB *cdb,
+ const gchar *query,
+ guint32 *count,
+ GError **error)
{
gint ret = -1;
gchar *errmsg = NULL;
@@ -628,8 +649,9 @@ camel_db_count_message_info (CamelDB *cdb, const gchar *query, guint32 *count, C
if (ret != SQLITE_OK) {
d(g_print ("Error in SQL SELECT statement: %s [%s]\n", query, errmsg));
- if (ex)
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _(errmsg));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM, "%s", errmsg);
sqlite3_free (errmsg);
errmsg = NULL;
}
@@ -643,7 +665,10 @@ camel_db_count_message_info (CamelDB *cdb, const gchar *query, guint32 *count, C
}
gint
-camel_db_count_junk_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex)
+camel_db_count_junk_message_info (CamelDB *cdb,
+ const gchar *table_name,
+ guint32 *count,
+ GError **error)
{
gint ret;
gchar *query;
@@ -653,14 +678,17 @@ camel_db_count_junk_message_info (CamelDB *cdb, const gchar *table_name, guint32
query = sqlite3_mprintf ("SELECT COUNT (*) FROM %Q WHERE junk = 1", table_name);
- ret = camel_db_count_message_info (cdb, query, count, ex);
+ ret = camel_db_count_message_info (cdb, query, count, error);
sqlite3_free (query);
return ret;
}
gint
-camel_db_count_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex)
+camel_db_count_unread_message_info (CamelDB *cdb,
+ const gchar *table_name,
+ guint32 *count,
+ GError **error)
{
gint ret;
gchar *query;
@@ -670,14 +698,17 @@ camel_db_count_unread_message_info (CamelDB *cdb, const gchar *table_name, guint
query = sqlite3_mprintf ("SELECT COUNT (*) FROM %Q WHERE read = 0", table_name);
- ret = camel_db_count_message_info (cdb, query, count, ex);
+ ret = camel_db_count_message_info (cdb, query, count, error);
sqlite3_free (query);
return ret;
}
gint
-camel_db_count_visible_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex)
+camel_db_count_visible_unread_message_info (CamelDB *cdb,
+ const gchar *table_name,
+ guint32 *count,
+ GError **error)
{
gint ret;
gchar *query;
@@ -687,14 +718,17 @@ camel_db_count_visible_unread_message_info (CamelDB *cdb, const gchar *table_nam
query = sqlite3_mprintf ("SELECT COUNT (*) FROM %Q WHERE read = 0 AND junk = 0 AND deleted = 0", table_name);
- ret = camel_db_count_message_info (cdb, query, count, ex);
+ ret = camel_db_count_message_info (cdb, query, count, error);
sqlite3_free (query);
return ret;
}
gint
-camel_db_count_visible_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex)
+camel_db_count_visible_message_info (CamelDB *cdb,
+ const gchar *table_name,
+ guint32 *count,
+ GError **error)
{
gint ret;
gchar *query;
@@ -704,14 +738,17 @@ camel_db_count_visible_message_info (CamelDB *cdb, const gchar *table_name, guin
query = sqlite3_mprintf ("SELECT COUNT (*) FROM %Q WHERE junk = 0 AND deleted = 0", table_name);
- ret = camel_db_count_message_info (cdb, query, count, ex);
+ ret = camel_db_count_message_info (cdb, query, count, error);
sqlite3_free (query);
return ret;
}
gint
-camel_db_count_junk_not_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex)
+camel_db_count_junk_not_deleted_message_info (CamelDB *cdb,
+ const gchar *table_name,
+ guint32 *count,
+ GError **error)
{
gint ret;
gchar *query;
@@ -721,14 +758,17 @@ camel_db_count_junk_not_deleted_message_info (CamelDB *cdb, const gchar *table_n
query = sqlite3_mprintf ("SELECT COUNT (*) FROM %Q WHERE junk = 1 AND deleted = 0", table_name);
- ret = camel_db_count_message_info (cdb, query, count, ex);
+ ret = camel_db_count_message_info (cdb, query, count, error);
sqlite3_free (query);
return ret;
}
gint
-camel_db_count_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex)
+camel_db_count_deleted_message_info (CamelDB *cdb,
+ const gchar *table_name,
+ guint32 *count,
+ GError **error)
{
gint ret;
gchar *query;
@@ -738,14 +778,17 @@ camel_db_count_deleted_message_info (CamelDB *cdb, const gchar *table_name, guin
query = sqlite3_mprintf ("SELECT COUNT (*) FROM %Q WHERE deleted = 1", table_name);
- ret = camel_db_count_message_info (cdb, query, count, ex);
+ ret = camel_db_count_message_info (cdb, query, count, error);
sqlite3_free (query);
return ret;
}
gint
-camel_db_count_total_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex)
+camel_db_count_total_message_info (CamelDB *cdb,
+ const gchar *table_name,
+ guint32 *count,
+ GError **error)
{
gint ret;
@@ -756,14 +799,18 @@ camel_db_count_total_message_info (CamelDB *cdb, const gchar *table_name, guint3
query = sqlite3_mprintf ("SELECT COUNT (*) FROM %Q where read=0 or read=1", table_name);
- ret = camel_db_count_message_info (cdb, query, count, ex);
+ ret = camel_db_count_message_info (cdb, query, count, error);
sqlite3_free (query);
return ret;
}
gint
-camel_db_select (CamelDB *cdb, const gchar * stmt, CamelDBSelectCB callback, gpointer data, CamelException *ex)
+camel_db_select (CamelDB *cdb,
+ const gchar *stmt,
+ CamelDBSelectCB callback,
+ gpointer data,
+ GError **error)
{
gchar *errmsg = NULL;
/*int nrecs = 0;*/
@@ -793,8 +840,9 @@ camel_db_select (CamelDB *cdb, const gchar * stmt, CamelDBSelectCB callback, gpo
if (ret != SQLITE_OK) {
d(g_warning ("Error in select statement '%s' [%s].\n", stmt, errmsg));
- if (ex)
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, errmsg);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM, "%s", errmsg);
sqlite3_free (errmsg);
errmsg = NULL;
}
@@ -808,20 +856,22 @@ camel_db_select (CamelDB *cdb, const gchar * stmt, CamelDBSelectCB callback, gpo
}
gint
-camel_db_create_vfolder (CamelDB *db, const gchar *folder_name, CamelException *ex)
+camel_db_create_vfolder (CamelDB *db,
+ const gchar *folder_name,
+ GError **error)
{
gint ret;
gchar *table_creation_query, *safe_index;
table_creation_query = sqlite3_mprintf ("CREATE TABLE IF NOT EXISTS %Q ( vuid TEXT PRIMARY KEY)", folder_name);
- ret = camel_db_command (db, table_creation_query, ex);
+ ret = camel_db_command (db, table_creation_query, error);
sqlite3_free (table_creation_query);
safe_index = g_strdup_printf("VINDEX-%s", folder_name);
table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (vuid)", safe_index, folder_name);
- ret = camel_db_command (db, table_creation_query, ex);
+ ret = camel_db_command (db, table_creation_query, error);
sqlite3_free (table_creation_query);
g_free (safe_index);
@@ -831,29 +881,34 @@ camel_db_create_vfolder (CamelDB *db, const gchar *folder_name, CamelException *
}
gint
-camel_db_recreate_vfolder (CamelDB *db, const gchar *folder_name, CamelException *ex)
+camel_db_recreate_vfolder (CamelDB *db,
+ const gchar *folder_name,
+ GError **error)
{
gint ret;
gchar *table_query;
table_query = sqlite3_mprintf ("DROP TABLE %Q", folder_name);
- ret = camel_db_command (db, table_query, ex);
+ ret = camel_db_command (db, table_query, error);
sqlite3_free (table_query);
- return camel_db_create_vfolder (db, folder_name, ex);
+ return camel_db_create_vfolder (db, folder_name, error);
}
gint
-camel_db_delete_uid_from_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid, CamelException *ex)
+camel_db_delete_uid_from_vfolder (CamelDB *db,
+ gchar *folder_name,
+ gchar *vuid,
+ GError **error)
{
gchar *del_query;
gint ret;
del_query = sqlite3_mprintf ("DELETE FROM %Q WHERE vuid = %Q", folder_name, vuid);
- ret = camel_db_command (db, del_query, ex);
+ ret = camel_db_command (db, del_query, error);
sqlite3_free (del_query);
CAMEL_DB_RELEASE_SQLITE_MEMORY;
@@ -861,14 +916,17 @@ camel_db_delete_uid_from_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid,
}
gint
-camel_db_delete_uid_from_vfolder_transaction (CamelDB *db, const gchar *folder_name, const gchar *vuid, CamelException *ex)
+camel_db_delete_uid_from_vfolder_transaction (CamelDB *db,
+ const gchar *folder_name,
+ const gchar *vuid,
+ GError **error)
{
gchar *del_query;
gint ret;
del_query = sqlite3_mprintf ("DELETE FROM %Q WHERE vuid = %Q", folder_name, vuid);
- ret = camel_db_add_to_transaction (db, del_query, ex);
+ ret = camel_db_add_to_transaction (db, del_query, error);
sqlite3_free (del_query);
@@ -896,7 +954,13 @@ read_uids_flags_callback (gpointer ref, gint ncol, gchar ** cols, gchar ** name)
}
gint
-camel_db_get_folder_uids_flags (CamelDB *db, const gchar *folder_name, const gchar *sort_by, const gchar *collate, GPtrArray *summary, GHashTable *table, CamelException *ex)
+camel_db_get_folder_uids_flags (CamelDB *db,
+ const gchar *folder_name,
+ const gchar *sort_by,
+ const gchar *collate,
+ GPtrArray *summary,
+ GHashTable *table,
+ GError **error)
{
GPtrArray *uids = summary;
GPtrArray *flags = g_ptr_array_new ();
@@ -910,7 +974,7 @@ camel_db_get_folder_uids_flags (CamelDB *db, const gchar *folder_name, const gch
sel_query = sqlite3_mprintf("SELECT uid,flags FROM %Q%s%s%s%s", folder_name, sort_by ? " order by " : "", sort_by ? sort_by: "", (sort_by && collate) ? " collate " : "", (sort_by && collate) ? collate : "");
- ret = camel_db_select (db, sel_query, read_uids_flags_callback, &data, ex);
+ ret = camel_db_select (db, sel_query, read_uids_flags_callback, &data, error);
sqlite3_free (sel_query);
for (i=0; i<uids->len; i++) {
@@ -940,21 +1004,28 @@ read_uids_callback (gpointer ref, gint ncol, gchar ** cols, gchar ** name)
}
gint
-camel_db_get_folder_uids (CamelDB *db, const gchar *folder_name, const gchar *sort_by, const gchar *collate, GPtrArray *array, CamelException *ex)
+camel_db_get_folder_uids (CamelDB *db,
+ const gchar *folder_name,
+ const gchar *sort_by,
+ const gchar *collate,
+ GPtrArray *array,
+ GError **error)
{
gchar *sel_query;
gint ret;
sel_query = sqlite3_mprintf("SELECT uid FROM %Q%s%s%s%s", folder_name, sort_by ? " order by " : "", sort_by ? sort_by: "", (sort_by && collate) ? " collate " : "", (sort_by && collate) ? collate : "");
- ret = camel_db_select (db, sel_query, read_uids_callback, array, ex);
+ ret = camel_db_select (db, sel_query, read_uids_callback, array, error);
sqlite3_free (sel_query);
return ret;
}
GPtrArray *
-camel_db_get_folder_junk_uids (CamelDB *db, gchar *folder_name, CamelException *ex)
+camel_db_get_folder_junk_uids (CamelDB *db,
+ gchar *folder_name,
+ GError **error)
{
gchar *sel_query;
gint ret;
@@ -962,7 +1033,7 @@ camel_db_get_folder_junk_uids (CamelDB *db, gchar *folder_name, CamelException *
sel_query = sqlite3_mprintf("SELECT uid FROM %Q where junk=1", folder_name);
- ret = camel_db_select (db, sel_query, read_uids_callback, array, ex);
+ ret = camel_db_select (db, sel_query, read_uids_callback, array, error);
sqlite3_free (sel_query);
@@ -974,7 +1045,9 @@ camel_db_get_folder_junk_uids (CamelDB *db, gchar *folder_name, CamelException *
}
GPtrArray *
-camel_db_get_folder_deleted_uids (CamelDB *db, gchar *folder_name, CamelException *ex)
+camel_db_get_folder_deleted_uids (CamelDB *db,
+ gchar *folder_name,
+ GError **error)
{
gchar *sel_query;
gint ret;
@@ -982,7 +1055,7 @@ camel_db_get_folder_deleted_uids (CamelDB *db, gchar *folder_name, CamelExceptio
sel_query = sqlite3_mprintf("SELECT uid FROM %Q where deleted=1", folder_name);
- ret = camel_db_select (db, sel_query, read_uids_callback, array, ex);
+ ret = camel_db_select (db, sel_query, read_uids_callback, array, error);
sqlite3_free (sel_query);
if (!array->len || ret != 0) {
@@ -1014,7 +1087,9 @@ read_preview_callback (gpointer ref, gint ncol, gchar ** cols, gchar ** name)
}
GHashTable *
-camel_db_get_folder_preview (CamelDB *db, gchar *folder_name, CamelException *ex)
+camel_db_get_folder_preview (CamelDB *db,
+ gchar *folder_name,
+ GError **error)
{
gchar *sel_query;
gint ret;
@@ -1022,7 +1097,7 @@ camel_db_get_folder_preview (CamelDB *db, gchar *folder_name, CamelException *ex
sel_query = sqlite3_mprintf("SELECT uid, preview FROM '%s_preview'", folder_name);
- ret = camel_db_select (db, sel_query, read_preview_callback, hash, ex);
+ ret = camel_db_select (db, sel_query, read_preview_callback, hash, error);
sqlite3_free (sel_query);
if (!g_hash_table_size (hash) || ret != 0) {
@@ -1034,14 +1109,18 @@ camel_db_get_folder_preview (CamelDB *db, gchar *folder_name, CamelException *ex
}
gint
-camel_db_write_preview_record (CamelDB *db, gchar *folder_name, const gchar *uid, const gchar *msg, CamelException *ex)
+camel_db_write_preview_record (CamelDB *db,
+ gchar *folder_name,
+ const gchar *uid,
+ const gchar *msg,
+ GError **error)
{
gchar *query;
gint ret;
query = sqlite3_mprintf("INSERT OR REPLACE INTO '%s_preview' VALUES(%Q,%Q)", folder_name, uid, msg);
- ret = camel_db_add_to_transaction (db, query, ex);
+ ret = camel_db_add_to_transaction (db, query, error);
sqlite3_free (query);
return ret;
@@ -1067,7 +1146,10 @@ read_vuids_callback (gpointer ref, gint ncol, gchar ** cols, gchar ** name)
}
GPtrArray *
-camel_db_get_vuids_from_vfolder (CamelDB *db, gchar *folder_name, gchar *filter, CamelException *ex)
+camel_db_get_vuids_from_vfolder (CamelDB *db,
+ gchar *folder_name,
+ gchar *filter,
+ GError **error)
{
gchar *sel_query;
gchar *cond = NULL;
@@ -1084,7 +1166,7 @@ camel_db_get_vuids_from_vfolder (CamelDB *db, gchar *folder_name, gchar *filter,
/* FIXME[disk-summary] No The caller should parse the ex in case
* of NULL returns */
array = g_ptr_array_new ();
- camel_db_select (db, sel_query, read_vuids_callback, array, ex);
+ camel_db_select (db, sel_query, read_vuids_callback, array, error);
sqlite3_free (sel_query);
/* We make sure to return NULL if we don't get anything. Be good to your caller */
if (!array->len) {
@@ -1096,14 +1178,17 @@ camel_db_get_vuids_from_vfolder (CamelDB *db, gchar *folder_name, gchar *filter,
}
gint
-camel_db_add_to_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid, CamelException *ex)
+camel_db_add_to_vfolder (CamelDB *db,
+ gchar *folder_name,
+ gchar *vuid,
+ GError **error)
{
gchar *ins_query;
gint ret;
ins_query = sqlite3_mprintf ("INSERT INTO %Q VALUES (%Q)", folder_name, vuid);
- ret = camel_db_command (db, ins_query, ex);
+ ret = camel_db_command (db, ins_query, error);
sqlite3_free (ins_query);
CAMEL_DB_RELEASE_SQLITE_MEMORY;
@@ -1111,14 +1196,17 @@ camel_db_add_to_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid, CamelExce
}
gint
-camel_db_add_to_vfolder_transaction (CamelDB *db, gchar *folder_name, gchar *vuid, CamelException *ex)
+camel_db_add_to_vfolder_transaction (CamelDB *db,
+ gchar *folder_name,
+ gchar *vuid,
+ GError **error)
{
gchar *ins_query;
gint ret;
ins_query = sqlite3_mprintf ("INSERT INTO %Q VALUES (%Q)", folder_name, vuid);
- ret = camel_db_add_to_transaction (db, ins_query, ex);
+ ret = camel_db_add_to_transaction (db, ins_query, error);
sqlite3_free (ins_query);
@@ -1126,65 +1214,68 @@ camel_db_add_to_vfolder_transaction (CamelDB *db, gchar *folder_name, gchar *vui
}
gint
-camel_db_create_folders_table (CamelDB *cdb, CamelException *ex)
+camel_db_create_folders_table (CamelDB *cdb,
+ GError **error)
{
const gchar *query = "CREATE TABLE IF NOT EXISTS folders ( folder_name TEXT PRIMARY KEY, version REAL, flags INTEGER, nextuid INTEGER, time NUMERIC, saved_count INTEGER, unread_count INTEGER, deleted_count INTEGER, junk_count INTEGER, visible_count INTEGER, jnd_count INTEGER, bdata TEXT )";
CAMEL_DB_RELEASE_SQLITE_MEMORY;
- return ((camel_db_command (cdb, query, ex)));
+ return ((camel_db_command (cdb, query, error)));
}
static gint
-camel_db_create_message_info_table (CamelDB *cdb, const gchar *folder_name, CamelException *ex)
+camel_db_create_message_info_table (CamelDB *cdb,
+ const gchar *folder_name,
+ GError **error)
{
gint ret;
gchar *table_creation_query, *safe_index;
/* README: It is possible to compress all system flags into a single column and use just as userflags but that makes querying for other applications difficult an d bloats the parsing code. Instead, it is better to bloat the tables. Sqlite should have some optimizations for sparse columns etc. */
table_creation_query = sqlite3_mprintf ("CREATE TABLE IF NOT EXISTS %Q ( uid TEXT PRIMARY KEY , flags INTEGER , msg_type INTEGER , read INTEGER , deleted INTEGER , replied INTEGER , important INTEGER , junk INTEGER , attachment INTEGER , dirty INTEGER , size INTEGER , dsent NUMERIC , dreceived NUMERIC , subject TEXT , mail_from TEXT , mail_to TEXT , mail_cc TEXT , mlist TEXT , followup_flag TEXT , followup_completed_on TEXT , followup_due_by TEXT , part TEXT , labels TEXT , usertags TEXT , cinfo TEXT , bdata TEXT, created TEXT, modified TEXT)", folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
table_creation_query = sqlite3_mprintf ("CREATE TABLE IF NOT EXISTS '%s_bodystructure' ( uid TEXT PRIMARY KEY , bodystructure TEXT )", folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
/* Create message preview table. */
table_creation_query = sqlite3_mprintf ("CREATE TABLE IF NOT EXISTS '%s_preview' ( uid TEXT PRIMARY KEY , preview TEXT)", folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
/* FIXME: sqlize folder_name before you create the index */
safe_index = g_strdup_printf("SINDEX-%s", folder_name);
table_creation_query = sqlite3_mprintf ("DROP INDEX IF EXISTS %Q", safe_index);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
g_free (safe_index);
sqlite3_free (table_creation_query);
/* INDEX on preview */
safe_index = g_strdup_printf("SINDEX-%s-preview", folder_name);
table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON '%s_preview' (uid, preview)", safe_index, folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
g_free (safe_index);
sqlite3_free (table_creation_query);
/* Index on deleted*/
safe_index = g_strdup_printf("DELINDEX-%s", folder_name);
table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (deleted)", safe_index, folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
g_free (safe_index);
sqlite3_free (table_creation_query);
/* Index on Junk*/
safe_index = g_strdup_printf("JUNKINDEX-%s", folder_name);
table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (junk)", safe_index, folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
g_free (safe_index);
sqlite3_free (table_creation_query);
/* Index on unread*/
safe_index = g_strdup_printf("READINDEX-%s", folder_name);
table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (read)", safe_index, folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
g_free (safe_index);
sqlite3_free (table_creation_query);
@@ -1192,7 +1283,10 @@ camel_db_create_message_info_table (CamelDB *cdb, const gchar *folder_name, Came
}
static gint
-camel_db_migrate_folder_prepare (CamelDB *cdb, const gchar *folder_name, gint version, CamelException *ex)
+camel_db_migrate_folder_prepare (CamelDB *cdb,
+ const gchar *folder_name,
+ gint version,
+ GError **error)
{
gint ret = 0;
gchar *table_creation_query;
@@ -1208,23 +1302,23 @@ camel_db_migrate_folder_prepare (CamelDB *cdb, const gchar *folder_name, gint ve
* */
table_creation_query = sqlite3_mprintf ("DROP TABLE IF EXISTS 'mem.%q'", folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
table_creation_query = sqlite3_mprintf ("CREATE TEMP TABLE IF NOT EXISTS 'mem.%q' ( uid TEXT PRIMARY KEY , flags INTEGER , msg_type INTEGER , read INTEGER , deleted INTEGER , replied INTEGER , important INTEGER , junk INTEGER , attachment INTEGER , dirty INTEGER , size INTEGER , dsent NUMERIC , dreceived NUMERIC , subject TEXT , mail_from TEXT , mail_to TEXT , mail_cc TEXT , mlist TEXT , followup_flag TEXT , followup_completed_on TEXT , followup_due_by TEXT , part TEXT , labels TEXT , usertags TEXT , cinfo TEXT , bdata TEXT, created TEXT, modified TEXT )", folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
table_creation_query = sqlite3_mprintf ("INSERT INTO 'mem.%q' SELECT uid , flags , msg_type , read , deleted , replied , important , junk , attachment , msg_security , size , dsent , dreceived , subject , mail_from , mail_to , mail_cc , mlist , followup_flag , followup_completed_on , followup_due_by , part , labels , usertags , cinfo , bdata , strftime(\"%%s\", 'now'), strftime(\"%%s\", 'now') FROM %Q", folder_name, folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
table_creation_query = sqlite3_mprintf ("DROP TABLE IF EXISTS %Q", folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
- ret = camel_db_create_message_info_table (cdb, folder_name, ex);
- camel_exception_clear (ex);
+ ret = camel_db_create_message_info_table (cdb, folder_name, error);
+ g_clear_error (error);
}
/* Add later version migrations here */
@@ -1233,7 +1327,10 @@ camel_db_migrate_folder_prepare (CamelDB *cdb, const gchar *folder_name, gint ve
}
static gint
-camel_db_migrate_folder_recreate (CamelDB *cdb, const gchar *folder_name, gint version, CamelException *ex)
+camel_db_migrate_folder_recreate (CamelDB *cdb,
+ const gchar *folder_name,
+ gint version,
+ GError **error)
{
gint ret = 0;
gchar *table_creation_query;
@@ -1242,11 +1339,11 @@ camel_db_migrate_folder_recreate (CamelDB *cdb, const gchar *folder_name, gint v
if (version < 2) {
table_creation_query = sqlite3_mprintf ("INSERT INTO %Q SELECT uid , flags , msg_type , read , deleted , replied , important , junk , attachment , dirty , size , dsent , dreceived , subject , mail_from , mail_to , mail_cc , mlist , followup_flag , followup_completed_on , followup_due_by , part , labels , usertags , cinfo , bdata, created, modified FROM 'mem.%q'", folder_name, folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
table_creation_query = sqlite3_mprintf ("DROP TABLE 'mem.%q'", folder_name);
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
}
@@ -1256,7 +1353,10 @@ camel_db_migrate_folder_recreate (CamelDB *cdb, const gchar *folder_name, gint v
}
gint
-camel_db_reset_folder_version (CamelDB *cdb, const gchar *folder_name, gint reset_version, CamelException *ex)
+camel_db_reset_folder_version (CamelDB *cdb,
+ const gchar *folder_name,
+ gint reset_version,
+ GError **error)
{
gint ret = 0;
gchar *version_creation_query;
@@ -1268,9 +1368,9 @@ camel_db_reset_folder_version (CamelDB *cdb, const gchar *folder_name, gint rese
version_insert_query = sqlite3_mprintf ("INSERT INTO '%q_version' VALUES ('%d')", folder_name, reset_version);
- ret = camel_db_add_to_transaction (cdb, drop_folder_query, ex);
- ret = camel_db_add_to_transaction (cdb, version_creation_query, ex);
- ret = camel_db_add_to_transaction (cdb, version_insert_query, ex);
+ ret = camel_db_add_to_transaction (cdb, drop_folder_query, error);
+ ret = camel_db_add_to_transaction (cdb, version_creation_query, error);
+ ret = camel_db_add_to_transaction (cdb, version_insert_query, error);
sqlite3_free (drop_folder_query);
sqlite3_free (version_creation_query);
@@ -1280,7 +1380,10 @@ camel_db_reset_folder_version (CamelDB *cdb, const gchar *folder_name, gint rese
}
static gint
-camel_db_write_folder_version (CamelDB *cdb, const gchar *folder_name, gint old_version, CamelException *ex)
+camel_db_write_folder_version (CamelDB *cdb,
+ const gchar *folder_name,
+ gint old_version,
+ GError **error)
{
gint ret = 0;
gchar *version_creation_query;
@@ -1293,8 +1396,8 @@ camel_db_write_folder_version (CamelDB *cdb, const gchar *folder_name, gint old_
else
version_insert_query = sqlite3_mprintf ("UPDATE '%q_version' SET version='2'", folder_name);
- ret = camel_db_add_to_transaction (cdb, version_creation_query, ex);
- ret = camel_db_add_to_transaction (cdb, version_insert_query, ex);
+ ret = camel_db_add_to_transaction (cdb, version_creation_query, error);
+ ret = camel_db_add_to_transaction (cdb, version_insert_query, error);
sqlite3_free (version_creation_query);
sqlite3_free (version_insert_query);
@@ -1303,7 +1406,9 @@ camel_db_write_folder_version (CamelDB *cdb, const gchar *folder_name, gint old_
}
static gint
-camel_db_get_folder_version (CamelDB *cdb, const gchar *folder_name, CamelException *ex)
+camel_db_get_folder_version (CamelDB *cdb,
+ const gchar *folder_name,
+ GError **error)
{
gint version = -1, ret;
gchar *query;
@@ -1326,42 +1431,36 @@ camel_db_get_folder_version (CamelDB *cdb, const gchar *folder_name, CamelExcept
}
gint
-camel_db_prepare_message_info_table (CamelDB *cdb, const gchar *folder_name, CamelException *ex)
+camel_db_prepare_message_info_table (CamelDB *cdb,
+ const gchar *folder_name,
+ GError **error)
{
gint ret, current_version;
/* Make sure we have the table already */
- ret = camel_db_create_message_info_table (cdb, folder_name, ex);
+ ret = camel_db_create_message_info_table (cdb, folder_name, error);
/* Migration stage zero: version fetch */
- current_version = camel_db_get_folder_version (cdb, folder_name, ex);
+ current_version = camel_db_get_folder_version (cdb, folder_name, error);
/* Migration stage one: storing the old data if necessary */
- ret = camel_db_migrate_folder_prepare (cdb, folder_name, current_version, ex);
+ ret = camel_db_migrate_folder_prepare (cdb, folder_name, current_version, error);
/* Migration stage two: rewriting the old data if necessary */
- ret = camel_db_migrate_folder_recreate (cdb, folder_name, current_version, ex);
+ ret = camel_db_migrate_folder_recreate (cdb, folder_name, current_version, error);
/* Final step: (over)write the current version label */
- ret = camel_db_write_folder_version (cdb, folder_name, current_version, ex);
+ ret = camel_db_write_folder_version (cdb, folder_name, current_version, error);
return ret;
}
-gint
-camel_db_write_fresh_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelException *ex)
-{
- return write_mir (cdb, folder_name, record, ex, FALSE);
-}
-
-gint
-camel_db_write_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelException *ex)
-{
- return write_mir (cdb, folder_name, record, ex, TRUE);
-}
-
static gint
-write_mir (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelException *ex, gboolean delete_old_record)
+write_mir (CamelDB *cdb,
+ const gchar *folder_name,
+ CamelMIRecord *record,
+ GError **error,
+ gboolean delete_old_record)
{
gint ret;
/*char *del_query;*/
@@ -1395,7 +1494,7 @@ write_mir (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelE
/* if (delete_old_record)
ret = camel_db_add_to_transaction (cdb, del_query, ex); */
- ret = camel_db_add_to_transaction (cdb, ins_query, ex);
+ ret = camel_db_add_to_transaction (cdb, ins_query, error);
#endif
@@ -1406,7 +1505,7 @@ write_mir (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelE
if (ret == 0) {
ins_query = sqlite3_mprintf ("INSERT OR REPLACE INTO '%s_bodystructure' VALUES (%Q, %Q )",
folder_name, record->uid, record->bodystructure);
- ret = camel_db_add_to_transaction (cdb, ins_query, ex);
+ ret = camel_db_add_to_transaction (cdb, ins_query, error);
sqlite3_free (ins_query);
}
@@ -1414,7 +1513,27 @@ write_mir (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelE
}
gint
-camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, CamelException *ex)
+camel_db_write_fresh_message_info_record (CamelDB *cdb,
+ const gchar *folder_name,
+ CamelMIRecord *record,
+ GError **error)
+{
+ return write_mir (cdb, folder_name, record, error, FALSE);
+}
+
+gint
+camel_db_write_message_info_record (CamelDB *cdb,
+ const gchar *folder_name,
+ CamelMIRecord *record,
+ GError **error)
+{
+ return write_mir (cdb, folder_name, record, error, TRUE);
+}
+
+gint
+camel_db_write_folder_info_record (CamelDB *cdb,
+ CamelFIRecord *record,
+ GError **error)
{
gint ret;
@@ -1437,8 +1556,8 @@ camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, CamelExc
g_free (upd_query);
#else
- ret = camel_db_add_to_transaction (cdb, del_query, ex);
- ret = camel_db_add_to_transaction (cdb, ins_query, ex);
+ ret = camel_db_add_to_transaction (cdb, del_query, error);
+ ret = camel_db_add_to_transaction (cdb, ins_query, error);
#endif
@@ -1502,57 +1621,71 @@ read_fir_callback (gpointer ref, gint ncol, gchar ** cols, gchar ** name)
}
gint
-camel_db_read_folder_info_record (CamelDB *cdb, const gchar *folder_name, CamelFIRecord **record, CamelException *ex)
+camel_db_read_folder_info_record (CamelDB *cdb,
+ const gchar *folder_name,
+ CamelFIRecord **record,
+ GError **error)
{
gchar *query;
gint ret;
query = sqlite3_mprintf ("SELECT * FROM folders WHERE folder_name = %Q", folder_name);
- ret = camel_db_select (cdb, query, read_fir_callback, record, ex);
+ ret = camel_db_select (cdb, query, read_fir_callback, record, error);
sqlite3_free (query);
return (ret);
}
gint
-camel_db_read_message_info_record_with_uid (CamelDB *cdb, const gchar *folder_name, const gchar *uid, gpointer p, CamelDBSelectCB read_mir_callback, CamelException *ex)
+camel_db_read_message_info_record_with_uid (CamelDB *cdb,
+ const gchar *folder_name,
+ const gchar *uid,
+ gpointer p,
+ CamelDBSelectCB read_mir_callback,
+ GError **error)
{
gchar *query;
gint ret;
query = sqlite3_mprintf ("SELECT uid, flags, size, dsent, dreceived, subject, mail_from, mail_to, mail_cc, mlist, part, labels, usertags, cinfo, bdata FROM %Q WHERE uid = %Q", folder_name, uid);
- ret = camel_db_select (cdb, query, read_mir_callback, p, ex);
+ ret = camel_db_select (cdb, query, read_mir_callback, p, error);
sqlite3_free (query);
return (ret);
}
gint
-camel_db_read_message_info_records (CamelDB *cdb, const gchar *folder_name, gpointer p, CamelDBSelectCB read_mir_callback, CamelException *ex)
+camel_db_read_message_info_records (CamelDB *cdb,
+ const gchar *folder_name,
+ gpointer p,
+ CamelDBSelectCB read_mir_callback,
+ GError **error)
{
gchar *query;
gint ret;
query = sqlite3_mprintf ("SELECT uid, flags, size, dsent, dreceived, subject, mail_from, mail_to, mail_cc, mlist, part, labels, usertags, cinfo, bdata FROM %Q ", folder_name);
- ret = camel_db_select (cdb, query, read_mir_callback, p, ex);
+ ret = camel_db_select (cdb, query, read_mir_callback, p, error);
sqlite3_free (query);
return (ret);
}
static gint
-camel_db_create_deleted_table (CamelDB *cdb, CamelException *ex)
+camel_db_create_deleted_table (CamelDB *cdb,
+ GError **error)
{
gint ret;
gchar *table_creation_query;
table_creation_query = sqlite3_mprintf ("CREATE TABLE IF NOT EXISTS Deletes (id INTEGER primary key AUTOINCREMENT not null, uid TEXT, time TEXT, mailbox TEXT)");
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, error);
sqlite3_free (table_creation_query);
return ret;
}
static gint
-camel_db_trim_deleted_table (CamelDB *cdb, CamelException *ex)
+camel_db_trim_deleted_table (CamelDB *cdb,
+ GError **error)
{
gint ret = 0;
@@ -1564,37 +1697,45 @@ camel_db_trim_deleted_table (CamelDB *cdb, CamelException *ex)
}
gint
-camel_db_delete_uid (CamelDB *cdb, const gchar *folder, const gchar *uid, CamelException *ex)
+camel_db_delete_uid (CamelDB *cdb,
+ const gchar *folder,
+ const gchar *uid,
+ GError **error)
{
gchar *tab;
gint ret;
- camel_db_begin_transaction (cdb, ex);
+ camel_db_begin_transaction (cdb, error);
- ret = camel_db_create_deleted_table (cdb, ex);
+ ret = camel_db_create_deleted_table (cdb, error);
tab = sqlite3_mprintf ("INSERT OR REPLACE INTO Deletes (uid, mailbox, time) SELECT uid, %Q, strftime(\"%%s\", 'now') FROM %Q WHERE uid = %Q", folder, folder, uid);
- ret = camel_db_add_to_transaction (cdb, tab, ex);
+ ret = camel_db_add_to_transaction (cdb, tab, error);
sqlite3_free (tab);
- ret = camel_db_trim_deleted_table (cdb, ex);
+ ret = camel_db_trim_deleted_table (cdb, error);
tab = sqlite3_mprintf ("DELETE FROM '%s_bodystructure' WHERE uid = %Q", folder, uid);
- ret = camel_db_add_to_transaction (cdb, tab, ex);
+ ret = camel_db_add_to_transaction (cdb, tab, error);
sqlite3_free (tab);
tab = sqlite3_mprintf ("DELETE FROM %Q WHERE uid = %Q", folder, uid);
- ret = camel_db_add_to_transaction (cdb, tab, ex);
+ ret = camel_db_add_to_transaction (cdb, tab, error);
sqlite3_free (tab);
- ret = camel_db_end_transaction (cdb, ex);
+ ret = camel_db_end_transaction (cdb, error);
CAMEL_DB_RELEASE_SQLITE_MEMORY;
return ret;
}
static gint
-cdb_delete_ids (CamelDB *cdb, const gchar * folder_name, GSList *uids, const gchar *uid_prefix, const gchar *field, CamelException *ex)
+cdb_delete_ids (CamelDB *cdb,
+ const gchar *folder_name,
+ GSList *uids,
+ const gchar *uid_prefix,
+ const gchar *field,
+ GError **error)
{
gchar *tmp;
gint ret;
@@ -1607,10 +1748,10 @@ cdb_delete_ids (CamelDB *cdb, const gchar * folder_name, GSList *uids, const gch
if (strcmp (field, "vuid") != 0)
ins_str = g_string_new ("INSERT OR REPLACE INTO Deletes (uid, mailbox, time) SELECT uid, ");
- camel_db_begin_transaction (cdb, ex);
+ camel_db_begin_transaction (cdb, error);
if (ins_str)
- ret = camel_db_create_deleted_table (cdb, ex);
+ ret = camel_db_create_deleted_table (cdb, error);
if (ins_str) {
tab = sqlite3_mprintf ("%Q, strftime(\"%%s\", 'now') FROM %Q WHERE %s IN (", folder_name, folder_name, field);
@@ -1647,13 +1788,13 @@ cdb_delete_ids (CamelDB *cdb, const gchar * folder_name, GSList *uids, const gch
g_string_append (str, ")");
if (ins_str) {
g_string_append (ins_str, ")");
- ret = camel_db_add_to_transaction (cdb, ins_str->str, ex);
- ret = camel_db_trim_deleted_table (cdb, ex);
+ ret = camel_db_add_to_transaction (cdb, ins_str->str, error);
+ ret = camel_db_trim_deleted_table (cdb, error);
}
- ret = camel_db_add_to_transaction (cdb, str->str, ex);
+ ret = camel_db_add_to_transaction (cdb, str->str, error);
- ret = camel_db_end_transaction (cdb, ex);
+ ret = camel_db_end_transaction (cdb, error);
CAMEL_DB_RELEASE_SQLITE_MEMORY;
@@ -1665,22 +1806,31 @@ cdb_delete_ids (CamelDB *cdb, const gchar * folder_name, GSList *uids, const gch
}
gint
-camel_db_delete_uids (CamelDB *cdb, const gchar * folder_name, GSList *uids, CamelException *ex)
+camel_db_delete_uids (CamelDB *cdb,
+ const gchar *folder_name,
+ GSList *uids,
+ GError **error)
{
if (!uids || !uids->data)
return 0;
- return cdb_delete_ids (cdb, folder_name, uids, "", "uid", ex);
+ return cdb_delete_ids (cdb, folder_name, uids, "", "uid", error);
}
gint
-camel_db_delete_vuids (CamelDB *cdb, const gchar * folder_name, const gchar *hash, GSList *uids, CamelException *ex)
+camel_db_delete_vuids (CamelDB *cdb,
+ const gchar *folder_name,
+ const gchar *hash,
+ GSList *uids,
+ GError **error)
{
- return cdb_delete_ids (cdb, folder_name, uids, hash, "vuid", ex);
+ return cdb_delete_ids (cdb, folder_name, uids, hash, "vuid", error);
}
gint
-camel_db_clear_folder_summary (CamelDB *cdb, gchar *folder, CamelException *ex)
+camel_db_clear_folder_summary (CamelDB *cdb,
+ gchar *folder,
+ GError **error)
{
gint ret;
@@ -1693,21 +1843,21 @@ camel_db_clear_folder_summary (CamelDB *cdb, gchar *folder, CamelException *ex)
msginfo_del = sqlite3_mprintf ("DELETE FROM %Q ", folder);
bstruct_del = sqlite3_mprintf ("DELETE FROM '%s_bodystructure' ", folder);
- camel_db_begin_transaction (cdb, ex);
+ camel_db_begin_transaction (cdb, error);
- ret = camel_db_create_deleted_table (cdb, ex);
+ ret = camel_db_create_deleted_table (cdb, error);
tab = sqlite3_mprintf ("INSERT OR REPLACE INTO Deletes (uid, mailbox, time) SELECT uid, %Q, strftime(\"%%s\", 'now') FROM %Q", folder, folder);
- ret = camel_db_add_to_transaction (cdb, tab, ex);
+ ret = camel_db_add_to_transaction (cdb, tab, error);
sqlite3_free (tab);
- ret = camel_db_trim_deleted_table (cdb, ex);
+ ret = camel_db_trim_deleted_table (cdb, error);
- camel_db_add_to_transaction (cdb, msginfo_del, ex);
- camel_db_add_to_transaction (cdb, folders_del, ex);
- camel_db_add_to_transaction (cdb, bstruct_del, ex);
+ camel_db_add_to_transaction (cdb, msginfo_del, error);
+ camel_db_add_to_transaction (cdb, folders_del, error);
+ camel_db_add_to_transaction (cdb, bstruct_del, error);
- ret = camel_db_end_transaction (cdb, ex);
+ ret = camel_db_end_transaction (cdb, error);
sqlite3_free (folders_del);
sqlite3_free (msginfo_del);
@@ -1717,73 +1867,78 @@ camel_db_clear_folder_summary (CamelDB *cdb, gchar *folder, CamelException *ex)
}
gint
-camel_db_delete_folder (CamelDB *cdb, const gchar *folder, CamelException *ex)
+camel_db_delete_folder (CamelDB *cdb,
+ const gchar *folder,
+ GError **error)
{
gint ret;
gchar *del;
gchar *tab;
- camel_db_begin_transaction (cdb, ex);
+ camel_db_begin_transaction (cdb, error);
- ret = camel_db_create_deleted_table (cdb, ex);
+ ret = camel_db_create_deleted_table (cdb, error);
tab = sqlite3_mprintf ("INSERT OR REPLACE INTO Deletes (uid, mailbox, time) SELECT uid, %Q, strftime(\"%%s\", 'now') FROM %Q", folder, folder);
- ret = camel_db_add_to_transaction (cdb, tab, ex);
+ ret = camel_db_add_to_transaction (cdb, tab, error);
sqlite3_free (tab);
- ret = camel_db_trim_deleted_table (cdb, ex);
+ ret = camel_db_trim_deleted_table (cdb, error);
del = sqlite3_mprintf ("DELETE FROM folders WHERE folder_name = %Q", folder);
- ret = camel_db_add_to_transaction (cdb, del, ex);
+ ret = camel_db_add_to_transaction (cdb, del, error);
sqlite3_free (del);
del = sqlite3_mprintf ("DROP TABLE %Q ", folder);
- ret = camel_db_add_to_transaction (cdb, del, ex);
+ ret = camel_db_add_to_transaction (cdb, del, error);
sqlite3_free (del);
del = sqlite3_mprintf ("DROP TABLE '%s_bodystructure' ", folder);
- ret = camel_db_add_to_transaction (cdb, del, ex);
+ ret = camel_db_add_to_transaction (cdb, del, error);
sqlite3_free (del);
- ret = camel_db_end_transaction (cdb, ex);
+ ret = camel_db_end_transaction (cdb, error);
CAMEL_DB_RELEASE_SQLITE_MEMORY;
return ret;
}
gint
-camel_db_rename_folder (CamelDB *cdb, const gchar *old_folder, const gchar *new_folder, CamelException *ex)
+camel_db_rename_folder (CamelDB *cdb,
+ const gchar *old_folder,
+ const gchar *new_folder,
+ GError **error)
{
gint ret;
gchar *cmd, *tab;
- camel_db_begin_transaction (cdb, ex);
+ camel_db_begin_transaction (cdb, error);
- ret = camel_db_create_deleted_table (cdb, ex);
+ ret = camel_db_create_deleted_table (cdb, error);
tab = sqlite3_mprintf ("INSERT OR REPLACE INTO Deletes (uid, mailbox, time) SELECT uid, %Q, strftime(\"%%s\", 'now') FROM %Q", old_folder, old_folder);
- ret = camel_db_add_to_transaction (cdb, tab, ex);
+ ret = camel_db_add_to_transaction (cdb, tab, error);
sqlite3_free (tab);
- ret = camel_db_trim_deleted_table (cdb, ex);
+ ret = camel_db_trim_deleted_table (cdb, error);
cmd = sqlite3_mprintf ("ALTER TABLE %Q RENAME TO %Q", old_folder, new_folder);
- ret = camel_db_add_to_transaction (cdb, cmd, ex);
+ ret = camel_db_add_to_transaction (cdb, cmd, error);
sqlite3_free (cmd);
cmd = sqlite3_mprintf ("ALTER TABLE '%q_version' RENAME TO '%q_version'", old_folder, new_folder);
- ret = camel_db_add_to_transaction (cdb, cmd, ex);
+ ret = camel_db_add_to_transaction (cdb, cmd, error);
sqlite3_free (cmd);
cmd = sqlite3_mprintf ("UPDATE %Q SET modified=strftime(\"%%s\", 'now'), created=strftime(\"%%s\", 'now')", new_folder);
- ret = camel_db_add_to_transaction (cdb, cmd, ex);
+ ret = camel_db_add_to_transaction (cdb, cmd, error);
sqlite3_free (cmd);
cmd = sqlite3_mprintf ("UPDATE folders SET folder_name = %Q WHERE folder_name = %Q", new_folder, old_folder);
- ret = camel_db_add_to_transaction (cdb, cmd, ex);
+ ret = camel_db_add_to_transaction (cdb, cmd, error);
sqlite3_free (cmd);
- ret = camel_db_end_transaction (cdb, ex);
+ ret = camel_db_end_transaction (cdb, error);
CAMEL_DB_RELEASE_SQLITE_MEMORY;
return ret;
@@ -1875,28 +2030,32 @@ camel_db_get_column_name (const gchar *raw_name)
}
gint
-camel_db_migrate_vfolders_to_14 (CamelDB *cdb, const gchar *folder, CamelException *ex)
+camel_db_migrate_vfolders_to_14 (CamelDB *cdb,
+ const gchar *folder,
+ GError **error)
{
gchar *cmd = sqlite3_mprintf ("ALTER TABLE %Q ADD COLUMN flags INTEGER", folder);
gint ret;
- ret = camel_db_command (cdb, cmd, ex);
+ ret = camel_db_command (cdb, cmd, error);
sqlite3_free (cmd);
CAMEL_DB_RELEASE_SQLITE_MEMORY;
return ret;
}
-gint camel_db_start_in_memory_transactions (CamelDB *cdb, CamelException *ex)
+gint
+camel_db_start_in_memory_transactions (CamelDB *cdb,
+ GError **error)
{
gint ret;
gchar *cmd = sqlite3_mprintf ("ATTACH DATABASE ':memory:' AS %s", CAMEL_DB_IN_MEMORY_DB);
- ret = camel_db_command (cdb, cmd, ex);
+ ret = camel_db_command (cdb, cmd, error);
sqlite3_free (cmd);
cmd = sqlite3_mprintf ("CREATE TEMPORARY TABLE %Q ( uid TEXT PRIMARY KEY , flags INTEGER , msg_type INTEGER , read INTEGER , deleted INTEGER , replied INTEGER , important INTEGER , junk INTEGER , attachment INTEGER , dirty INTEGER , size INTEGER , dsent NUMERIC , dreceived NUMERIC , subject TEXT , mail_from TEXT , mail_to TEXT , mail_cc TEXT , mlist TEXT , followup_flag TEXT , followup_completed_on TEXT , followup_due_by TEXT , part TEXT , labels TEXT , usertags TEXT , cinfo TEXT , bdata TEXT )", CAMEL_DB_IN_MEMORY_TABLE);
- ret = camel_db_command (cdb, cmd, ex);
+ ret = camel_db_command (cdb, cmd, error);
if (ret != 0 )
abort ();
sqlite3_free (cmd);
@@ -1904,20 +2063,23 @@ gint camel_db_start_in_memory_transactions (CamelDB *cdb, CamelException *ex)
return ret;
}
-gint camel_db_flush_in_memory_transactions (CamelDB *cdb, const gchar * folder_name, CamelException *ex)
+gint
+camel_db_flush_in_memory_transactions (CamelDB *cdb,
+ const gchar *folder_name,
+ GError **error)
{
gint ret;
gchar *cmd = sqlite3_mprintf ("INSERT INTO %Q SELECT * FROM %Q", folder_name, CAMEL_DB_IN_MEMORY_TABLE);
- ret = camel_db_command (cdb, cmd, ex);
+ ret = camel_db_command (cdb, cmd, error);
sqlite3_free (cmd);
cmd = sqlite3_mprintf ("DROP TABLE %Q", CAMEL_DB_IN_MEMORY_TABLE);
- ret = camel_db_command (cdb, cmd, ex);
+ ret = camel_db_command (cdb, cmd, error);
sqlite3_free (cmd);
cmd = sqlite3_mprintf ("DETACH %Q", CAMEL_DB_IN_MEMORY_DB);
- ret = camel_db_command (cdb, cmd, ex);
+ ret = camel_db_command (cdb, cmd, error);
sqlite3_free (cmd);
return ret;
diff --git a/camel/camel-db.h b/camel/camel-db.h
index 885cff7..1ca50b3 100644
--- a/camel/camel-db.h
+++ b/camel/camel-db.h
@@ -17,8 +17,6 @@
#define CAMEL_DB_IN_MEMORY_DB "EVO_IN_meM_hAnDlE"
#define CAMEL_DB_IN_MEMORY_TABLE_LIMIT 100000
-#include "camel-exception.h"
-
typedef struct _CamelDBPrivate CamelDBPrivate;
typedef gint(*CamelDBCollate)(gpointer ,int,gconstpointer ,int,gconstpointer );
@@ -110,64 +108,64 @@ typedef struct _CamelFIRecord {
typedef struct _CamelDB CamelDB;
typedef gint (*CamelDBSelectCB) (gpointer data, gint ncol, gchar **colvalues, gchar **colnames);
-CamelDB * camel_db_open (const gchar *path, CamelException *ex);
-CamelDB * camel_db_clone (CamelDB *cdb, CamelException *ex);
+CamelDB * camel_db_open (const gchar *path, GError **error);
+CamelDB * camel_db_clone (CamelDB *cdb, GError **error);
void camel_db_close (CamelDB *cdb);
-gint camel_db_command (CamelDB *cdb, const gchar *stmt, CamelException *ex);
+gint camel_db_command (CamelDB *cdb, const gchar *stmt, GError **error);
-gint camel_db_transaction_command (CamelDB *cdb, GSList *qry_list, CamelException *ex);
+gint camel_db_transaction_command (CamelDB *cdb, GSList *qry_list, GError **error);
-gint camel_db_begin_transaction (CamelDB *cdb, CamelException *ex);
-gint camel_db_add_to_transaction (CamelDB *cdb, const gchar *query, CamelException *ex);
-gint camel_db_end_transaction (CamelDB *cdb, CamelException *ex);
-gint camel_db_abort_transaction (CamelDB *cdb, CamelException *ex);
-gint camel_db_clear_folder_summary (CamelDB *cdb, gchar *folder, CamelException *ex);
-gint camel_db_rename_folder (CamelDB *cdb, const gchar *old_folder, const gchar *new_folder, CamelException *ex);
+gint camel_db_begin_transaction (CamelDB *cdb, GError **error);
+gint camel_db_add_to_transaction (CamelDB *cdb, const gchar *query, GError **error);
+gint camel_db_end_transaction (CamelDB *cdb, GError **error);
+gint camel_db_abort_transaction (CamelDB *cdb, GError **error);
+gint camel_db_clear_folder_summary (CamelDB *cdb, gchar *folder, GError **error);
+gint camel_db_rename_folder (CamelDB *cdb, const gchar *old_folder, const gchar *new_folder, GError **error);
-gint camel_db_delete_folder (CamelDB *cdb, const gchar *folder, CamelException *ex);
-gint camel_db_delete_uid (CamelDB *cdb, const gchar *folder, const gchar *uid, CamelException *ex);
-/*int camel_db_delete_uids (CamelDB *cdb, CamelException *ex, gint nargs, ... );*/
-gint camel_db_delete_uids (CamelDB *cdb, const gchar * folder_name, GSList *uids, CamelException *ex);
-gint camel_db_delete_vuids (CamelDB *cdb, const gchar * folder_name, const gchar *shash, GSList *uids, CamelException *ex);
+gint camel_db_delete_folder (CamelDB *cdb, const gchar *folder, GError **error);
+gint camel_db_delete_uid (CamelDB *cdb, const gchar *folder, const gchar *uid, GError **error);
+/*int camel_db_delete_uids (CamelDB *cdb, GError **error, gint nargs, ... );*/
+gint camel_db_delete_uids (CamelDB *cdb, const gchar * folder_name, GSList *uids, GError **error);
+gint camel_db_delete_vuids (CamelDB *cdb, const gchar * folder_name, const gchar *shash, GSList *uids, GError **error);
-gint camel_db_create_folders_table (CamelDB *cdb, CamelException *ex);
-gint camel_db_select (CamelDB *cdb, const gchar * stmt, CamelDBSelectCB callback, gpointer data, CamelException *ex);
+gint camel_db_create_folders_table (CamelDB *cdb, GError **error);
+gint camel_db_select (CamelDB *cdb, const gchar * stmt, CamelDBSelectCB callback, gpointer data, GError **error);
-gint camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, CamelException *ex);
-gint camel_db_read_folder_info_record (CamelDB *cdb, const gchar *folder_name, CamelFIRecord **record, CamelException *ex);
+gint camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, GError **error);
+gint camel_db_read_folder_info_record (CamelDB *cdb, const gchar *folder_name, CamelFIRecord **record, GError **error);
-gint camel_db_prepare_message_info_table (CamelDB *cdb, const gchar *folder_name, CamelException *ex);
+gint camel_db_prepare_message_info_table (CamelDB *cdb, const gchar *folder_name, GError **error);
-gint camel_db_write_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelException *ex);
-gint camel_db_write_fresh_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, CamelException *ex);
-gint camel_db_read_message_info_records (CamelDB *cdb, const gchar *folder_name, gpointer p, CamelDBSelectCB read_mir_callback, CamelException *ex);
-gint camel_db_read_message_info_record_with_uid (CamelDB *cdb, const gchar *folder_name, const gchar *uid, gpointer p, CamelDBSelectCB read_mir_callback, CamelException *ex);
+gint camel_db_write_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, GError **error);
+gint camel_db_write_fresh_message_info_record (CamelDB *cdb, const gchar *folder_name, CamelMIRecord *record, GError **error);
+gint camel_db_read_message_info_records (CamelDB *cdb, const gchar *folder_name, gpointer p, CamelDBSelectCB read_mir_callback, GError **error);
+gint camel_db_read_message_info_record_with_uid (CamelDB *cdb, const gchar *folder_name, const gchar *uid, gpointer p, CamelDBSelectCB read_mir_callback, GError **error);
-gint camel_db_count_junk_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex);
-gint camel_db_count_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex);
-gint camel_db_count_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex);
-gint camel_db_count_total_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex);
+gint camel_db_count_junk_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
+gint camel_db_count_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
+gint camel_db_count_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
+gint camel_db_count_total_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
-gint camel_db_count_visible_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex);
-gint camel_db_count_visible_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex);
+gint camel_db_count_visible_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
+gint camel_db_count_visible_unread_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
-gint camel_db_count_junk_not_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, CamelException *ex);
-gint camel_db_count_message_info (CamelDB *cdb, const gchar *query, guint32 *count, CamelException *ex);
+gint camel_db_count_junk_not_deleted_message_info (CamelDB *cdb, const gchar *table_name, guint32 *count, GError **error);
+gint camel_db_count_message_info (CamelDB *cdb, const gchar *query, guint32 *count, GError **error);
void camel_db_camel_mir_free (CamelMIRecord *record);
-gint camel_db_create_vfolder (CamelDB *db, const gchar *folder_name, CamelException *ex);
-gint camel_db_recreate_vfolder (CamelDB *db, const gchar *folder_name, CamelException *ex);
-gint camel_db_delete_uid_from_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid, CamelException *ex);
-gint camel_db_delete_uid_from_vfolder_transaction (CamelDB *db, const gchar *folder_name, const gchar *vuid, CamelException *ex);
-GPtrArray * camel_db_get_vuids_from_vfolder (CamelDB *db, gchar *folder_name, gchar *filter, CamelException *ex);
-gint camel_db_add_to_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid, CamelException *ex);
-gint camel_db_add_to_vfolder_transaction (CamelDB *db, gchar *folder_name, gchar *vuid, CamelException *ex);
+gint camel_db_create_vfolder (CamelDB *db, const gchar *folder_name, GError **error);
+gint camel_db_recreate_vfolder (CamelDB *db, const gchar *folder_name, GError **error);
+gint camel_db_delete_uid_from_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid, GError **error);
+gint camel_db_delete_uid_from_vfolder_transaction (CamelDB *db, const gchar *folder_name, const gchar *vuid, GError **error);
+GPtrArray * camel_db_get_vuids_from_vfolder (CamelDB *db, gchar *folder_name, gchar *filter, GError **error);
+gint camel_db_add_to_vfolder (CamelDB *db, gchar *folder_name, gchar *vuid, GError **error);
+gint camel_db_add_to_vfolder_transaction (CamelDB *db, gchar *folder_name, gchar *vuid, GError **error);
-gint camel_db_get_folder_uids (CamelDB *db, const gchar *folder_name, const gchar *sort_by, const gchar *collate, GPtrArray *array, CamelException *ex);
-gint camel_db_get_folder_uids_flags (CamelDB *db, const gchar *folder_name, const gchar *sort_by, const gchar *collate, GPtrArray *summary, GHashTable *table, CamelException *ex);
+gint camel_db_get_folder_uids (CamelDB *db, const gchar *folder_name, const gchar *sort_by, const gchar *collate, GPtrArray *array, GError **error);
+gint camel_db_get_folder_uids_flags (CamelDB *db, const gchar *folder_name, const gchar *sort_by, const gchar *collate, GPtrArray *summary, GHashTable *table, GError **error);
-GPtrArray * camel_db_get_folder_junk_uids (CamelDB *db, gchar *folder_name, CamelException *ex);
-GPtrArray * camel_db_get_folder_deleted_uids (CamelDB *db, gchar *folder_name, CamelException *ex);
+GPtrArray * camel_db_get_folder_junk_uids (CamelDB *db, gchar *folder_name, GError **error);
+GPtrArray * camel_db_get_folder_deleted_uids (CamelDB *db, gchar *folder_name, GError **error);
gchar * camel_db_sqlize_string (const gchar *string);
void camel_db_free_sqlized_string (gchar *string);
@@ -175,16 +173,16 @@ void camel_db_free_sqlized_string (gchar *string);
gchar * camel_db_get_column_name (const gchar *raw_name);
gint camel_db_set_collate (CamelDB *cdb, const gchar *col, const gchar *collate, CamelDBCollate func);
/* Migration APIS */
-gint camel_db_migrate_vfolders_to_14(CamelDB *cdb, const gchar *folder, CamelException *ex);
+gint camel_db_migrate_vfolders_to_14(CamelDB *cdb, const gchar *folder, GError **error);
-gint camel_db_start_in_memory_transactions (CamelDB *cdb, CamelException *ex);
-gint camel_db_flush_in_memory_transactions (CamelDB *cdb, const gchar * folder_name, CamelException *ex);
+gint camel_db_start_in_memory_transactions (CamelDB *cdb, GError **error);
+gint camel_db_flush_in_memory_transactions (CamelDB *cdb, const gchar * folder_name, GError **error);
GHashTable *
-camel_db_get_folder_preview (CamelDB *db, gchar *folder_name, CamelException *ex);
-gint camel_db_write_preview_record (CamelDB *db, gchar *folder_name, const gchar *uid, const gchar *msg, CamelException *ex);
+camel_db_get_folder_preview (CamelDB *db, gchar *folder_name, GError **error);
+gint camel_db_write_preview_record (CamelDB *db, gchar *folder_name, const gchar *uid, const gchar *msg, GError **error);
gint
-camel_db_reset_folder_version (CamelDB *cdb, const gchar *folder_name, gint reset_version, CamelException *ex);
+camel_db_reset_folder_version (CamelDB *cdb, const gchar *folder_name, gint reset_version, GError **error);
#endif
diff --git a/camel/camel-digest-folder.c b/camel/camel-digest-folder.c
index 158f8b9..0bbc38c 100644
--- a/camel/camel-digest-folder.c
+++ b/camel/camel-digest-folder.c
@@ -26,7 +26,6 @@
#include "camel-digest-folder.h"
#include "camel-digest-summary.h"
-#include "camel-exception.h"
#include "camel-folder-search.h"
#include "camel-mime-message.h"
#include "camel-multipart.h"
@@ -49,25 +48,25 @@ struct _CamelDigestFolderPrivate {
static gpointer parent_class;
-static void digest_refresh_info (CamelFolder *folder, CamelException *ex);
-static void digest_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
+static gboolean digest_refresh_info (CamelFolder *folder, GError **error);
+static gboolean digest_sync (CamelFolder *folder, gboolean expunge, GError **error);
static const gchar *digest_get_full_name (CamelFolder *folder);
-static void digest_expunge (CamelFolder *folder, CamelException *ex);
+static gboolean digest_expunge (CamelFolder *folder, GError **error);
/* message manipulation */
static CamelMimeMessage *digest_get_message (CamelFolder *folder, const gchar *uid,
- CamelException *ex);
-static void digest_append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex);
-static void digest_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
+ GError **error);
+static gboolean digest_append_message (CamelFolder *folder, CamelMimeMessage *message,
+ const CamelMessageInfo *info, gchar **appended_uid, GError **error);
+static gboolean digest_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex);
+ gboolean delete_originals, GError **error);
static GPtrArray *digest_search_by_expression (CamelFolder *folder, const gchar *expression,
- CamelException *ex);
+ GError **error);
static GPtrArray *digest_search_by_uids (CamelFolder *folder, const gchar *expression,
- GPtrArray *uids, CamelException *ex);
+ GPtrArray *uids, GError **error);
static void digest_search_free (CamelFolder *folder, GPtrArray *result);
@@ -263,22 +262,26 @@ camel_digest_folder_new (CamelStore *parent_store, CamelMimeMessage *message)
return folder;
}
-static void
-digest_refresh_info (CamelFolder *folder, CamelException *ex)
+static gboolean
+digest_refresh_info (CamelFolder *folder,
+ GError **error)
{
-
+ return TRUE;
}
-static void
-digest_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+static gboolean
+digest_sync (CamelFolder *folder,
+ gboolean expunge,
+ GError **error)
{
- /* no-op */
+ return TRUE;
}
-static void
-digest_expunge (CamelFolder *folder, CamelException *ex)
+static gboolean
+digest_expunge (CamelFolder *folder,
+ GError **error)
{
- /* no-op */
+ return TRUE;
}
static const gchar *
@@ -287,28 +290,37 @@ digest_get_full_name (CamelFolder *folder)
return folder->full_name;
}
-static void
-digest_append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+static gboolean
+digest_append_message (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
- /* no-op */
if (appended_uid)
*appended_uid = NULL;
+
+ return TRUE;
}
-static void
-digest_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
- CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+static gboolean
+digest_transfer_messages_to (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error)
{
- /* no-op */
if (transferred_uids)
*transferred_uids = NULL;
+
+ return TRUE;
}
static CamelMimeMessage *
-digest_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+digest_get_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelDigestFolder *digest = CAMEL_DIGEST_FOLDER (folder);
CamelDataWrapper *wrapper;
@@ -340,7 +352,9 @@ digest_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
static GPtrArray *
-digest_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+digest_search_by_expression (CamelFolder *folder,
+ const gchar *expression,
+ GError **error)
{
CamelDigestFolder *df = (CamelDigestFolder *) folder;
GPtrArray *matches;
@@ -351,7 +365,7 @@ digest_search_by_expression (CamelFolder *folder, const gchar *expression, Camel
df->priv->search = camel_folder_search_new ();
camel_folder_search_set_folder (df->priv->search, folder);
- matches = camel_folder_search_search(df->priv->search, expression, NULL, ex);
+ matches = camel_folder_search_search(df->priv->search, expression, NULL, error);
CAMEL_DIGEST_FOLDER_UNLOCK (folder, search_lock);
@@ -359,7 +373,10 @@ digest_search_by_expression (CamelFolder *folder, const gchar *expression, Camel
}
static GPtrArray *
-digest_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+digest_search_by_uids (CamelFolder *folder,
+ const gchar *expression,
+ GPtrArray *uids,
+ GError **error)
{
CamelDigestFolder *df = (CamelDigestFolder *) folder;
GPtrArray *matches;
@@ -373,7 +390,7 @@ digest_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *
df->priv->search = camel_folder_search_new ();
camel_folder_search_set_folder (df->priv->search, folder);
- matches = camel_folder_search_search(df->priv->search, expression, uids, ex);
+ matches = camel_folder_search_search(df->priv->search, expression, uids, error);
CAMEL_DIGEST_FOLDER_UNLOCK (folder, search_lock);
diff --git a/camel/camel-digest-store.c b/camel/camel-digest-store.c
index b39092c..5d80545 100644
--- a/camel/camel-digest-store.c
+++ b/camel/camel-digest-store.c
@@ -28,36 +28,28 @@
#include "camel-digest-folder.h"
#include "camel-digest-store.h"
-#include "camel-exception.h"
#include "camel-private.h"
#define d(x)
-static CamelFolder *digest_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex);
-static void digest_delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
-static void digest_rename_folder (CamelStore *store, const gchar *old, const gchar *new, CamelException *ex);
-static CamelFolder *digest_get_trash (CamelStore *store, CamelException *ex);
-static CamelFolder *digest_get_junk (CamelStore *store, CamelException *ex);
+static CamelFolder *digest_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error);
+static gboolean digest_delete_folder (CamelStore *store, const gchar *folder_name, GError **error);
+static gboolean digest_rename_folder (CamelStore *store, const gchar *old, const gchar *new, GError **error);
+static CamelFolder *digest_get_trash (CamelStore *store, GError **error);
+static CamelFolder *digest_get_junk (CamelStore *store, GError **error);
-static CamelFolderInfo *digest_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
+static CamelFolderInfo *digest_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error);
-static gint digest_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
-static gint digest_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
static gpointer parent_class;
static void
digest_store_class_init (CamelDigestStoreClass *class)
{
- CamelObjectClass *camel_object_class;
CamelStoreClass *store_class;
parent_class = g_type_class_peek_parent (class);
- camel_object_class = CAMEL_OBJECT_CLASS (class);
- camel_object_class->setv = digest_setv;
- camel_object_class->getv = digest_getv;
-
store_class = CAMEL_STORE_CLASS (class);
store_class->get_folder = digest_get_folder;
store_class->rename_folder = digest_rename_folder;
@@ -96,20 +88,6 @@ camel_digest_store_get_type (void)
return type;
}
-static gint
-digest_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
-{
- /* CamelDigestStore doesn't currently have anything to set */
- return CAMEL_OBJECT_CLASS (parent_class)->setv (object, ex, args);
-}
-
-static gint
-digest_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
-{
- /* CamelDigestStore doesn't currently have anything to get */
- return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
-}
-
/**
* camel_digest_store_new:
* @url:
@@ -135,37 +113,50 @@ camel_digest_store_new (const gchar *url)
}
static CamelFolder *
-digest_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+digest_get_folder (CamelStore *store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error)
{
return NULL;
}
static CamelFolder *
-digest_get_trash (CamelStore *store, CamelException *ex)
+digest_get_trash (CamelStore *store,
+ GError **error)
{
return NULL;
}
static CamelFolder *
-digest_get_junk (CamelStore *store, CamelException *ex)
+digest_get_junk (CamelStore *store,
+ GError **error)
{
return NULL;
}
static CamelFolderInfo *
-digest_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+digest_get_folder_info (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
return NULL;
}
-static void
-digest_delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+static gboolean
+digest_delete_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error)
{
-
+ return TRUE;
}
-static void
-digest_rename_folder (CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+static gboolean
+digest_rename_folder (CamelStore *store,
+ const gchar *old,
+ const gchar *new,
+ GError **error)
{
-
+ return TRUE;
}
diff --git a/camel/camel-digest-summary.h b/camel/camel-digest-summary.h
index 1b45bd4..cc88229 100644
--- a/camel/camel-digest-summary.h
+++ b/camel/camel-digest-summary.h
@@ -31,7 +31,6 @@
#include <camel/camel-folder-summary.h>
#include <camel/camel-folder.h>
-#include <camel/camel-exception.h>
/* Standard GObject macros */
#define CAMEL_TYPE_DIGEST_SUMMARY \
diff --git a/camel/camel-disco-diary.c b/camel/camel-disco-diary.c
index 1ddffa9..31c7597 100644
--- a/camel/camel-disco-diary.c
+++ b/camel/camel-disco-diary.c
@@ -35,7 +35,6 @@
#include "camel-disco-diary.h"
#include "camel-disco-folder.h"
#include "camel-disco-store.h"
-#include "camel-exception.h"
#include "camel-file-utils.h"
#include "camel-folder.h"
#include "camel-operation.h"
@@ -259,21 +258,24 @@ diary_decode_folder (CamelDiscoDiary *diary)
return NULL;
folder = g_hash_table_lookup (diary->folders, name);
if (!folder) {
- CamelException ex;
+ GError *error = NULL;
gchar *msg;
- camel_exception_init (&ex);
- folder = camel_store_get_folder (CAMEL_STORE (diary->store),
- name, 0, &ex);
+ folder = camel_store_get_folder (
+ CAMEL_STORE (diary->store), name, 0, &error);
if (folder)
g_hash_table_insert (diary->folders, name, folder);
else {
- msg = g_strdup_printf (_("Could not open '%s':\n%s\nChanges made to this folder will not be resynchronized."),
- name, camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- camel_session_alert_user (camel_service_get_session (CAMEL_SERVICE (diary->store)),
- CAMEL_SESSION_ALERT_WARNING,
- msg, FALSE);
+ msg = g_strdup_printf (
+ _("Could not open '%s':\n%s\n"
+ "Changes made to this folder "
+ "will not be resynchronized."),
+ name, error->message);
+ g_error_free (error);
+ camel_session_alert_user (
+ camel_service_get_session (CAMEL_SERVICE (diary->store)),
+ CAMEL_SESSION_ALERT_WARNING,
+ msg, FALSE);
g_free (msg);
g_free (name);
}
@@ -291,11 +293,13 @@ close_folder (gpointer name, gpointer folder, gpointer data)
}
void
-camel_disco_diary_replay (CamelDiscoDiary *diary, CamelException *ex)
+camel_disco_diary_replay (CamelDiscoDiary *diary,
+ GError **error)
{
guint32 action;
off_t size;
gdouble pc;
+ GError *local_error = NULL;
d(printf("disco diary replay\n"));
@@ -305,7 +309,7 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, CamelException *ex)
rewind (diary->file);
camel_operation_start (NULL, _("Resynchronizing with server"));
- while (!camel_exception_is_set (ex)) {
+ while (local_error == NULL) {
pc = ftell (diary->file) / size;
camel_operation_progress (NULL, pc * 100);
@@ -326,7 +330,8 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, CamelException *ex)
goto lose;
if (folder)
- camel_disco_folder_expunge_uids (folder, uids, ex);
+ camel_disco_folder_expunge_uids (
+ folder, uids, &local_error);
free_uids (uids);
break;
}
@@ -355,7 +360,8 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, CamelException *ex)
}
info = camel_folder_get_message_info (folder, uid);
- camel_folder_append_message (folder, message, info, &ret_uid, ex);
+ camel_folder_append_message (
+ folder, message, info, &ret_uid, &local_error);
camel_folder_free_message_info (folder, info);
if (ret_uid) {
@@ -387,7 +393,9 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, CamelException *ex)
continue;
}
- camel_folder_transfer_messages_to (source, uids, destination, &ret_uids, delete_originals, ex);
+ camel_folder_transfer_messages_to (
+ source, uids, destination, &ret_uids,
+ delete_originals, &local_error);
if (ret_uids) {
for (i = 0; i < uids->len; i++) {
@@ -415,10 +423,14 @@ camel_disco_diary_replay (CamelDiscoDiary *diary, CamelException *ex)
/* Truncate the log */
ftruncate (fileno (diary->file), 0);
+
+ g_propagate_error (error, local_error);
}
CamelDiscoDiary *
-camel_disco_diary_new (CamelDiscoStore *store, const gchar *filename, CamelException *ex)
+camel_disco_diary_new (CamelDiscoStore *store,
+ const gchar *filename,
+ GError **error)
{
CamelDiscoDiary *diary;
@@ -445,9 +457,11 @@ camel_disco_diary_new (CamelDiscoStore *store, const gchar *filename, CamelExcep
diary->file = g_fopen (filename, "a+b");
if (!diary->file) {
g_object_unref (diary);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not open journal file: %s",
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "Could not open journal file: %s",
+ g_strerror (errno));
return NULL;
}
diff --git a/camel/camel-disco-diary.h b/camel/camel-disco-diary.h
index f32f120..3ca470d 100644
--- a/camel/camel-disco-diary.h
+++ b/camel/camel-disco-diary.h
@@ -91,7 +91,7 @@ struct _CamelDiscoDiaryClass {
/* public methods */
CamelDiscoDiary *camel_disco_diary_new (CamelDiscoStore *store,
const gchar *filename,
- CamelException *ex);
+ GError **error);
gboolean camel_disco_diary_empty (CamelDiscoDiary *diary);
@@ -99,7 +99,7 @@ void camel_disco_diary_log (CamelDiscoDiary *diary,
CamelDiscoDiaryAction action,
...);
void camel_disco_diary_replay (CamelDiscoDiary *diary,
- CamelException *ex);
+ GError **error);
/* Temporary->Permanent UID map stuff */
void camel_disco_diary_uidmap_add (CamelDiscoDiary *diary,
diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c
index 4d40bb9..d2a3d43 100644
--- a/camel/camel-disco-folder.c
+++ b/camel/camel-disco-folder.c
@@ -29,7 +29,6 @@
#include "camel-disco-folder.h"
#include "camel-disco-store.h"
-#include "camel-exception.h"
#include "camel-session.h"
static gpointer parent_class;
@@ -39,27 +38,25 @@ static CamelProperty disco_property_list[] = {
{ CAMEL_DISCO_FOLDER_OFFLINE_SYNC, "offline_sync", N_("Copy folder content locally for offline operation") },
};
-static gint disco_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args);
-static gint disco_setv(CamelObject *object, CamelException *ex, CamelArgV *args);
+static gint disco_getv(CamelObject *object, GError **error, CamelArgGetV *args);
+static gint disco_setv(CamelObject *object, GError **error, CamelArgV *args);
-static void disco_refresh_info (CamelFolder *folder, CamelException *ex);
-static void disco_refresh_info_online (CamelFolder *folder, CamelException *ex);
-static void disco_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static void disco_expunge (CamelFolder *folder, CamelException *ex);
+static gboolean disco_refresh_info (CamelFolder *folder, GError **error);
+static gboolean disco_refresh_info_online (CamelFolder *folder, GError **error);
+static gboolean disco_sync (CamelFolder *folder, gboolean expunge, GError **error);
+static gboolean disco_expunge (CamelFolder *folder, GError **error);
-static void disco_append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex);
-static void disco_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
+static gboolean disco_append_message (CamelFolder *folder, CamelMimeMessage *message,
+ const CamelMessageInfo *info, gchar **appended_uid, GError **error);
+static gboolean disco_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
CamelFolder *destination,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
-static void disco_cache_message (CamelDiscoFolder *disco_folder,
- const gchar *uid, CamelException *ex);
-static void disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
+static gboolean disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
const gchar *expression,
- CamelException *ex);
+ GError **error);
struct _cdf_sync_msg {
CamelSessionThreadMsg msg;
@@ -83,12 +80,12 @@ cdf_sync_offline(CamelSession *session, CamelSessionThreadMsg *mm)
camel_operation_progress(NULL, pc);
camel_disco_folder_cache_message((CamelDiscoFolder *)m->folder,
m->changes->uid_added->pdata[i],
- &mm->ex);
+ &mm->error);
}
} else {
camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)m->folder,
"(match-all)",
- &mm->ex);
+ &mm->error);
}
camel_operation_end(NULL);
@@ -147,7 +144,6 @@ disco_folder_class_init (CamelDiscoFolderClass *class)
folder_class->append_message = disco_append_message;
folder_class->transfer_messages_to = disco_transfer_messages_to;
- class->cache_message = disco_cache_message;
class->prepare_for_offline = disco_prepare_for_offline;
class->refresh_info_online = disco_refresh_info_online;
@@ -186,7 +182,9 @@ camel_disco_folder_get_type (void)
}
static gint
-disco_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+disco_getv (CamelObject *object,
+ GError **error,
+ CamelArgGetV *args)
{
gint i, count=0;
guint32 tag;
@@ -203,7 +201,7 @@ disco_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
props.argc = 1;
props.argv[0] = *arg;
- ((CamelObjectClass *)parent_class)->getv(object, ex, &props);
+ ((CamelObjectClass *)parent_class)->getv(object, error, &props);
*arg->ca_ptr = g_slist_concat(*arg->ca_ptr, g_slist_copy(disco_folder_properties));
break; }
/* disco args */
@@ -219,13 +217,15 @@ disco_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
}
if (count)
- return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->getv(object, error, args);
return 0;
}
static gint
-disco_setv(CamelObject *object, CamelException *ex, CamelArgV *args)
+disco_setv (CamelObject *object,
+ GError **error,
+ CamelArgV *args)
{
gint save = 0;
gint i;
@@ -253,96 +253,97 @@ disco_setv(CamelObject *object, CamelException *ex, CamelArgV *args)
if (save)
camel_object_state_write(object);
- return ((CamelObjectClass *)parent_class)->setv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->setv(object, error, args);
}
-static void
-disco_refresh_info_online(CamelFolder *folder, CamelException *ex)
+static gboolean
+disco_refresh_info_online (CamelFolder *folder,
+ GError **error)
{
- /* NOOP */;
+ return TRUE;
}
-static void
-disco_refresh_info (CamelFolder *folder, CamelException *ex)
+static gboolean
+disco_refresh_info (CamelFolder *folder,
+ GError **error)
{
+ CamelDiscoFolderClass *disco_folder_class;
+
if (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store)) != CAMEL_DISCO_STORE_ONLINE)
- return;
- CAMEL_DISCO_FOLDER_GET_CLASS (folder)->refresh_info_online (folder, ex);
+ return TRUE;
+
+ disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder);
+
+ return disco_folder_class->refresh_info_online (folder, error);
}
-static void
-disco_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+static gboolean
+disco_sync (CamelFolder *folder,
+ gboolean expunge,
+ GError **error)
{
- void (*sync)(CamelFolder *, CamelException *) = NULL;
+ CamelDiscoFolderClass *disco_folder_class;
- if (expunge) {
- disco_expunge (folder, ex);
- if (camel_exception_is_set (ex))
- return;
- }
+ if (expunge && !disco_expunge (folder, error))
+ return FALSE;
camel_object_state_write(folder);
+ disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder);
+
switch (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store))) {
case CAMEL_DISCO_STORE_ONLINE:
- sync = CAMEL_DISCO_FOLDER_GET_CLASS (folder)->sync_online;
- break;
+ return disco_folder_class->sync_online (folder, error);
case CAMEL_DISCO_STORE_OFFLINE:
- sync = CAMEL_DISCO_FOLDER_GET_CLASS (folder)->sync_offline;
- break;
+ return disco_folder_class->sync_offline (folder, error);
case CAMEL_DISCO_STORE_RESYNCING:
- sync = CAMEL_DISCO_FOLDER_GET_CLASS (folder)->sync_resyncing;
- break;
+ return disco_folder_class->sync_resyncing (folder, error);
}
- if (sync) {
- sync(folder, ex);
- } else {
- g_warning("Class '%s' doesn't implement CamelDiscoFolder:sync methods",
- G_OBJECT_TYPE_NAME (folder));
- }
+ g_return_val_if_reached (FALSE);
}
-static void
-disco_expunge_uids (CamelFolder *folder, GPtrArray *uids, CamelException *ex)
+static gboolean
+disco_expunge_uids (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
{
CamelDiscoStore *disco = CAMEL_DISCO_STORE (folder->parent_store);
- void (*expunge_uids)(CamelFolder *, GPtrArray *, CamelException *) = NULL;
+ CamelDiscoFolderClass *disco_folder_class;
if (uids->len == 0)
- return;
+ return TRUE;
+
+ disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder);
switch (camel_disco_store_status (disco)) {
case CAMEL_DISCO_STORE_ONLINE:
- expunge_uids = CAMEL_DISCO_FOLDER_GET_CLASS (folder)->expunge_uids_online;
- break;
+ return disco_folder_class->expunge_uids_online (
+ folder, uids, error);
case CAMEL_DISCO_STORE_OFFLINE:
- expunge_uids = CAMEL_DISCO_FOLDER_GET_CLASS (folder)->expunge_uids_offline;
- break;
+ return disco_folder_class->expunge_uids_offline (
+ folder, uids, error);
case CAMEL_DISCO_STORE_RESYNCING:
- expunge_uids = CAMEL_DISCO_FOLDER_GET_CLASS (folder)->expunge_uids_resyncing;
- break;
+ return disco_folder_class->expunge_uids_resyncing (
+ folder, uids, error);
}
- if (expunge_uids) {
- expunge_uids(folder, uids, ex);
- } else {
- g_warning("Class '%s' doesn't implement CamelDiscoFolder:expunge_uids methods",
- G_OBJECT_TYPE_NAME (folder));
- }
+ g_return_val_if_reached (FALSE);
}
-static void
-disco_expunge (CamelFolder *folder, CamelException *ex)
+static gboolean
+disco_expunge (CamelFolder *folder,
+ GError **error)
{
GPtrArray *uids;
gint i;
guint count;
CamelMessageInfo *info;
+ gboolean success;
uids = g_ptr_array_new ();
count = camel_folder_summary_count (folder->summary);
@@ -353,136 +354,156 @@ disco_expunge (CamelFolder *folder, CamelException *ex)
camel_message_info_free(info);
}
- disco_expunge_uids (folder, uids, ex);
+ success = disco_expunge_uids (folder, uids, error);
for (i = 0; i < uids->len; i++)
g_free (uids->pdata[i]);
g_ptr_array_free (uids, TRUE);
+
+ return success;
}
-static void
-disco_append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+static gboolean
+disco_append_message (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelDiscoStore *disco = CAMEL_DISCO_STORE (folder->parent_store);
+ CamelDiscoFolderClass *disco_folder_class;
+
+ disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder);
switch (camel_disco_store_status (disco)) {
case CAMEL_DISCO_STORE_ONLINE:
- CAMEL_DISCO_FOLDER_GET_CLASS (folder)->append_online (folder, message, info,
- appended_uid, ex);
- break;
+ return disco_folder_class->append_online (
+ folder, message, info, appended_uid, error);
case CAMEL_DISCO_STORE_OFFLINE:
- CAMEL_DISCO_FOLDER_GET_CLASS (folder)->append_offline (folder, message, info,
- appended_uid, ex);
- break;
+ return disco_folder_class->append_offline (
+ folder, message, info, appended_uid, error);
case CAMEL_DISCO_STORE_RESYNCING:
- CAMEL_DISCO_FOLDER_GET_CLASS (folder)->append_resyncing (folder, message, info,
- appended_uid, ex);
- break;
+ return disco_folder_class->append_resyncing (
+ folder, message, info, appended_uid, error);
}
+
+ g_return_val_if_reached (FALSE);
}
-static void
-disco_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
- CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+static gboolean
+disco_transfer_messages_to (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error)
{
CamelDiscoStore *disco = CAMEL_DISCO_STORE (source->parent_store);
+ CamelDiscoFolderClass *disco_folder_class;
+
+ disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (source);
switch (camel_disco_store_status (disco)) {
case CAMEL_DISCO_STORE_ONLINE:
- CAMEL_DISCO_FOLDER_GET_CLASS (source)->transfer_online (source, uids,
- dest, transferred_uids,
- delete_originals, ex);
- break;
+ return disco_folder_class->transfer_online (
+ source, uids, dest, transferred_uids,
+ delete_originals, error);
case CAMEL_DISCO_STORE_OFFLINE:
- CAMEL_DISCO_FOLDER_GET_CLASS (source)->transfer_offline (source, uids,
- dest, transferred_uids,
- delete_originals, ex);
- break;
+ return disco_folder_class->transfer_offline (
+ source, uids, dest, transferred_uids,
+ delete_originals, error);
case CAMEL_DISCO_STORE_RESYNCING:
- CAMEL_DISCO_FOLDER_GET_CLASS (source)->transfer_resyncing (source, uids,
- dest, transferred_uids,
- delete_originals, ex);
- break;
+ return disco_folder_class->transfer_resyncing (
+ source, uids, dest, transferred_uids,
+ delete_originals, error);
}
+
+ g_return_val_if_reached (FALSE);
}
/**
* camel_disco_folder_expunge_uids:
* @folder: a (disconnectable) folder
* @uids: array of UIDs to expunge
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This expunges the messages in @uids from @folder. It should take
* whatever steps are needed to avoid expunging any other messages,
* although in some cases it may not be possible to avoid expunging
* messages that are marked deleted by another client at the same time
* as the expunge_uids call is running.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
-camel_disco_folder_expunge_uids (CamelFolder *folder, GPtrArray *uids,
- CamelException *ex)
+gboolean
+camel_disco_folder_expunge_uids (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
{
- disco_expunge_uids (folder, uids, ex);
-}
+ g_return_val_if_fail (CAMEL_IS_DISCO_FOLDER (folder), FALSE);
+ g_return_val_if_fail (uids != NULL, FALSE);
-static void
-disco_cache_message (CamelDiscoFolder *disco_folder, const gchar *uid,
- CamelException *ex)
-{
- g_warning ("CamelDiscoFolder::cache_message not implemented for '%s'",
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (disco_folder)));
+ return disco_expunge_uids (folder, uids, error);
}
/**
* camel_disco_folder_cache_message:
* @disco_folder: the folder
* @uid: the UID of the message to cache
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* Requests that @disco_folder cache message @uid to disk.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_disco_folder_cache_message (CamelDiscoFolder *disco_folder,
- const gchar *uid, CamelException *ex)
+ const gchar *uid,
+ GError **error)
{
- CAMEL_DISCO_FOLDER_GET_CLASS (disco_folder)->cache_message (disco_folder, uid, ex);
+ CamelDiscoFolderClass *class;
+
+ g_return_val_if_fail (CAMEL_IS_DISCO_FOLDER (disco_folder), FALSE);
+ g_return_val_if_fail (uid != NULL, FALSE);
+
+ class = CAMEL_DISCO_FOLDER_GET_CLASS (disco_folder);
+ g_return_val_if_fail (class->cache_message != NULL, FALSE);
+
+ return class->cache_message (disco_folder, uid, error);
}
-static void
+static gboolean
disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
- const gchar *expression,
- CamelException *ex)
+ const gchar *expression,
+ GError **error)
{
CamelFolder *folder = CAMEL_FOLDER (disco_folder);
GPtrArray *uids;
gint i;
+ gboolean success = TRUE;
camel_operation_start(NULL, _("Preparing folder '%s' for offline"), folder->full_name);
if (expression)
- uids = camel_folder_search_by_expression (folder, expression, ex);
+ uids = camel_folder_search_by_expression (folder, expression, error);
else
uids = camel_folder_get_uids (folder);
if (!uids) {
camel_operation_end(NULL);
- return;
+ return FALSE;
}
- for (i = 0; i < uids->len; i++) {
+ for (i = 0; i < uids->len && success; i++) {
gint pc = i * 100 / uids->len;
- camel_disco_folder_cache_message (disco_folder, uids->pdata[i], ex);
camel_operation_progress(NULL, pc);
- if (camel_exception_is_set (ex))
- break;
+ success = camel_disco_folder_cache_message (
+ disco_folder, uids->pdata[i], error);
}
if (expression)
@@ -491,6 +512,8 @@ disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
camel_folder_free_uids (folder, uids);
camel_operation_end(NULL);
+
+ return success;
}
/**
@@ -498,18 +521,25 @@ disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
* @disco_folder: the folder
* @expression: an expression describing messages to synchronize, or %NULL
* if all messages should be sync'ed.
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This prepares @disco_folder for offline operation, by downloading
* the bodies of all messages described by @expression (using the
* same syntax as camel_folder_search_by_expression() ).
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_disco_folder_prepare_for_offline (CamelDiscoFolder *disco_folder,
- const gchar *expression,
- CamelException *ex)
+ const gchar *expression,
+ GError **error)
{
- g_return_if_fail (CAMEL_IS_DISCO_FOLDER (disco_folder));
+ CamelDiscoFolderClass *class;
+
+ g_return_val_if_fail (CAMEL_IS_DISCO_FOLDER (disco_folder), FALSE);
+
+ class = CAMEL_DISCO_FOLDER_GET_CLASS (disco_folder);
+ g_return_val_if_fail (class->prepare_for_offline != NULL, FALSE);
- CAMEL_DISCO_FOLDER_GET_CLASS (disco_folder)->prepare_for_offline (disco_folder, expression, ex);
+ return class->prepare_for_offline (disco_folder, expression, error);
}
diff --git a/camel/camel-disco-folder.h b/camel/camel-disco-folder.h
index edea120..fe17e8a 100644
--- a/camel/camel-disco-folder.h
+++ b/camel/camel-disco-folder.h
@@ -74,73 +74,79 @@ struct _CamelDiscoFolder {
struct _CamelDiscoFolderClass {
CamelFolderClass parent_class;
- void (*refresh_info_online) (CamelFolder *folder, CamelException *ex);
-
- void (*sync_online) (CamelFolder *folder, CamelException *ex);
- void (*sync_offline) (CamelFolder *folder, CamelException *ex);
- void (*sync_resyncing) (CamelFolder *folder, CamelException *ex);
-
- void (*expunge_uids_online) (CamelFolder *folder, GPtrArray *uids,
- CamelException *ex);
- void (*expunge_uids_offline) (CamelFolder *folder, GPtrArray *uids,
- CamelException *ex);
- void (*expunge_uids_resyncing) (CamelFolder *folder, GPtrArray *uids,
- CamelException *ex);
-
- void (*append_online) (CamelFolder *folder,
- CamelMimeMessage *message,
- const CamelMessageInfo *info,
- gchar **appended_uid,
- CamelException *ex);
- void (*append_offline) (CamelFolder *folder,
- CamelMimeMessage *message,
- const CamelMessageInfo *info,
- gchar **appended_uid,
- CamelException *ex);
- void (*append_resyncing) (CamelFolder *folder,
- CamelMimeMessage *message,
- const CamelMessageInfo *info,
- gchar **appended_uid,
- CamelException *ex);
-
- void (*transfer_online) (CamelFolder *source, GPtrArray *uids,
- CamelFolder *destination,
- GPtrArray **transferred_uids,
- gboolean delete_originals,
- CamelException *ex);
- void (*transfer_offline) (CamelFolder *source, GPtrArray *uids,
- CamelFolder *destination,
- GPtrArray **transferred_uids,
- gboolean delete_originals,
- CamelException *ex);
- void (*transfer_resyncing) (CamelFolder *source, GPtrArray *uids,
- CamelFolder *destination,
- GPtrArray **transferred_uids,
- gboolean delete_originals,
- CamelException *ex);
-
- void (*cache_message) (CamelDiscoFolder *disco_folder,
- const gchar *uid, CamelException *ex);
- void (*prepare_for_offline) (CamelDiscoFolder *disco_folder,
- const gchar *expression,
- CamelException *ex);
-
- void (*update_uid) (CamelFolder *folder, const gchar *old_uid,
- const gchar *new_uid);
+ gboolean (*refresh_info_online) (CamelFolder *folder,
+ GError **error);
+ gboolean (*sync_online) (CamelFolder *folder,
+ GError **error);
+ gboolean (*sync_offline) (CamelFolder *folder,
+ GError **error);
+ gboolean (*sync_resyncing) (CamelFolder *folder,
+ GError **error);
+ gboolean (*expunge_uids_online) (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error);
+ gboolean (*expunge_uids_offline) (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error);
+ gboolean (*expunge_uids_resyncing)
+ (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error);
+ gboolean (*append_online) (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error);
+ gboolean (*append_offline) (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error);
+ gboolean (*append_resyncing) (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error);
+ gboolean (*transfer_online) (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *destination,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error);
+ gboolean (*transfer_offline) (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *destination,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error);
+ gboolean (*transfer_resyncing) (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *destination,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error);
+ gboolean (*cache_message) (CamelDiscoFolder *disco_folder,
+ const gchar *uid,
+ GError **error);
+ gboolean (*prepare_for_offline) (CamelDiscoFolder *disco_folder,
+ const gchar *expression,
+ GError **error);
+ void (*update_uid) (CamelFolder *folder,
+ const gchar *old_uid,
+ const gchar *new_uid);
};
-/* public methods */
-void camel_disco_folder_expunge_uids (CamelFolder *folder, GPtrArray *uids,
- CamelException *ex);
-
-void camel_disco_folder_cache_message (CamelDiscoFolder *disco_folder,
- const gchar *uid,
- CamelException *ex);
-void camel_disco_folder_prepare_for_offline (CamelDiscoFolder *disco_folder,
- const gchar *expression,
- CamelException *ex);
-
-GType camel_disco_folder_get_type (void);
+GType camel_disco_folder_get_type (void);
+gboolean camel_disco_folder_expunge_uids (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error);
+gboolean camel_disco_folder_cache_message(CamelDiscoFolder *disco_folder,
+ const gchar *uid,
+ GError **error);
+gboolean camel_disco_folder_prepare_for_offline
+ (CamelDiscoFolder *disco_folder,
+ const gchar *expression,
+ GError **error);
G_END_DECLS
diff --git a/camel/camel-disco-store.c b/camel/camel-disco-store.c
index eafefcb..4877a2c 100644
--- a/camel/camel-disco-store.c
+++ b/camel/camel-disco-store.c
@@ -31,45 +31,37 @@
#include "camel-disco-diary.h"
#include "camel-disco-folder.h"
#include "camel-disco-store.h"
-#include "camel-exception.h"
#include "camel-session.h"
#define d(x)
static gpointer parent_class;
-static void disco_construct (CamelService *service, CamelSession *session,
+static gboolean disco_construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex);
-static gboolean disco_connect (CamelService *service, CamelException *ex);
+ GError **error);
+static gboolean disco_connect (CamelService *service, GError **error);
static void disco_cancel_connect (CamelService *service);
-static gboolean disco_disconnect (CamelService *service, gboolean clean, CamelException *ex);
+static gboolean disco_disconnect (CamelService *service, gboolean clean, GError **error);
static CamelFolder *disco_get_folder (CamelStore *store, const gchar *name,
- guint32 flags, CamelException *ex);
+ guint32 flags, GError **error);
static CamelFolderInfo *disco_get_folder_info (CamelStore *store,
const gchar *top, guint32 flags,
- CamelException *ex);
+ GError **error);
static void set_status (CamelDiscoStore *disco_store,
CamelDiscoStoreStatus status,
- CamelException *ex);
+ GError **error);
static gboolean can_work_offline (CamelDiscoStore *disco_store);
-static gint disco_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
-static gint disco_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
static void
disco_store_class_init (CamelDiscoStoreClass *class)
{
- CamelObjectClass *camel_object_class;
CamelServiceClass *service_class;
CamelStoreClass *store_class;
parent_class = g_type_class_peek_parent (class);
- camel_object_class = CAMEL_OBJECT_CLASS (class);
- camel_object_class->setv = disco_setv;
- camel_object_class->getv = disco_getv;
-
service_class = CAMEL_SERVICE_CLASS (class);
service_class->construct = disco_construct;
service_class->connect = disco_connect;
@@ -102,56 +94,50 @@ camel_disco_store_get_type (void)
return type;
}
-static gint
-disco_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
-{
- /* CamelDiscoStore doesn't currently have anything to set */
- return CAMEL_OBJECT_CLASS (parent_class)->setv (object, ex, args);
-}
-
-static gint
-disco_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
-{
- /* CamelDiscoStore doesn't currently have anything to get */
- return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
-}
-
-static void
-disco_construct (CamelService *service, CamelSession *session,
- CamelProvider *provider, CamelURL *url,
- CamelException *ex)
+static gboolean
+disco_construct (CamelService *service,
+ CamelSession *session,
+ CamelProvider *provider,
+ CamelURL *url,
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelDiscoStore *disco = CAMEL_DISCO_STORE (service);
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ /* Chain up to parent's construct() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
disco->status = camel_session_is_online (session) ?
CAMEL_DISCO_STORE_ONLINE : CAMEL_DISCO_STORE_OFFLINE;
+
+ return TRUE;
}
static gboolean
-disco_connect (CamelService *service, CamelException *ex)
+disco_connect (CamelService *service,
+ GError **error)
{
CamelDiscoStore *store = CAMEL_DISCO_STORE (service);
CamelDiscoStoreStatus status;
struct _CamelDiscoDiary *diary;
+ GError *local_error = NULL;
status = camel_disco_store_status (store);
if (status != CAMEL_DISCO_STORE_OFFLINE) {
- if (!CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex)) {
+ if (!CAMEL_SERVICE_CLASS (parent_class)->connect (service, error)) {
status = camel_disco_store_status (store);
if (status != CAMEL_DISCO_STORE_OFFLINE)
return FALSE;
- camel_exception_clear (ex);
+ g_clear_error (error);
}
}
switch (status) {
case CAMEL_DISCO_STORE_ONLINE:
case CAMEL_DISCO_STORE_RESYNCING:
- if (!CAMEL_DISCO_STORE_GET_CLASS (service)->connect_online (service, ex))
+ if (!CAMEL_DISCO_STORE_GET_CLASS (service)->connect_online (service, error))
return FALSE;
if (!store->diary)
@@ -166,18 +152,20 @@ disco_connect (CamelService *service, CamelException *ex)
store->status = CAMEL_DISCO_STORE_RESYNCING;
diary = store->diary;
g_object_ref (diary);
- camel_disco_diary_replay(diary, ex);
+ camel_disco_diary_replay(diary, &local_error);
g_object_unref (diary);
store->status = CAMEL_DISCO_STORE_ONLINE;
- if (camel_exception_is_set (ex))
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
- if (!camel_service_disconnect (service, TRUE, ex))
+ if (!camel_service_disconnect (service, TRUE, error))
return FALSE;
- return camel_service_connect (service, ex);
+ return camel_service_connect (service, error);
case CAMEL_DISCO_STORE_OFFLINE:
- return CAMEL_DISCO_STORE_GET_CLASS (service)->connect_offline (service, ex);
+ return CAMEL_DISCO_STORE_GET_CLASS (service)->connect_offline (service, error);
}
g_assert_not_reached ();
@@ -195,42 +183,46 @@ disco_cancel_connect (CamelService *service)
}
static gboolean
-disco_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+disco_disconnect (CamelService *service,
+ gboolean clean,
+ GError **error)
{
CamelDiscoStore *store = CAMEL_DISCO_STORE (service);
switch (camel_disco_store_status (store)) {
case CAMEL_DISCO_STORE_ONLINE:
case CAMEL_DISCO_STORE_RESYNCING:
- if (!CAMEL_DISCO_STORE_GET_CLASS (service)->disconnect_online (service, clean, ex))
+ if (!CAMEL_DISCO_STORE_GET_CLASS (service)->disconnect_online (service, clean, error))
return FALSE;
break;
case CAMEL_DISCO_STORE_OFFLINE:
- if (!CAMEL_DISCO_STORE_GET_CLASS (service)->disconnect_offline (service, clean, ex))
+ if (!CAMEL_DISCO_STORE_GET_CLASS (service)->disconnect_offline (service, clean, error))
return FALSE;
break;
}
- return CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex);
+ return CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, error);
}
static CamelFolder *
-disco_get_folder (CamelStore *store, const gchar *name,
- guint32 flags, CamelException *ex)
+disco_get_folder (CamelStore *store,
+ const gchar *name,
+ guint32 flags,
+ GError **error)
{
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store);
switch (camel_disco_store_status (disco_store)) {
case CAMEL_DISCO_STORE_ONLINE:
- return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_online (store, name, flags, ex);
+ return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_online (store, name, flags, error);
case CAMEL_DISCO_STORE_OFFLINE:
- return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_offline (store, name, flags, ex);
+ return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_offline (store, name, flags, error);
case CAMEL_DISCO_STORE_RESYNCING:
- return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_resyncing (store, name, flags, ex);
+ return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_resyncing (store, name, flags, error);
}
g_assert_not_reached ();
@@ -238,27 +230,29 @@ disco_get_folder (CamelStore *store, const gchar *name,
}
static CamelFolderInfo *
-disco_get_folder_info (CamelStore *store, const gchar *top,
- guint32 flags, CamelException *ex)
+disco_get_folder_info (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store);
switch (camel_disco_store_status (disco_store)) {
case CAMEL_DISCO_STORE_ONLINE:
- return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_online (store, top, flags, ex);
+ return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_online (store, top, flags, error);
case CAMEL_DISCO_STORE_OFFLINE:
/* Can't edit subscriptions while offline */
if ((store->flags & CAMEL_STORE_SUBSCRIPTIONS) &&
!(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)) {
- camel_disco_store_check_online (disco_store, ex);
+ camel_disco_store_check_online (disco_store, error);
return NULL;
}
- return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_offline (store, top, flags, ex);
+ return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_offline (store, top, flags, error);
case CAMEL_DISCO_STORE_RESYNCING:
- return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_resyncing (store, top, flags, ex);
+ return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_resyncing (store, top, flags, error);
}
g_assert_not_reached ();
@@ -286,16 +280,16 @@ camel_disco_store_status (CamelDiscoStore *store)
}
static void
-set_status(CamelDiscoStore *disco_store, CamelDiscoStoreStatus status, CamelException *ex)
+set_status (CamelDiscoStore *disco_store,
+ CamelDiscoStoreStatus status,
+ GError **error)
{
- CamelException x;
CamelService *service = CAMEL_SERVICE (disco_store);
gboolean network_state = camel_session_get_network_state (service->session);
if (disco_store->status == status)
return;
- camel_exception_init(&x);
/* Sync the folder fully if we've been told to sync online for this store or this folder
and we're going offline */
@@ -314,8 +308,7 @@ set_status(CamelDiscoStore *disco_store, CamelDiscoStoreStatus status, CamelExce
folder = folders->pdata[i];
if (G_TYPE_CHECK_INSTANCE_TYPE(folder, CAMEL_TYPE_DISCO_FOLDER)
&& (sync || ((CamelDiscoFolder *)folder)->offline_sync)) {
- camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "", &x);
- camel_exception_clear(&x);
+ camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "", NULL);
}
g_object_unref (folder);
}
@@ -323,34 +316,33 @@ set_status(CamelDiscoStore *disco_store, CamelDiscoStoreStatus status, CamelExce
}
}
- camel_store_sync(CAMEL_STORE (disco_store), FALSE, &x);
- camel_exception_clear(&x);
+ camel_store_sync(CAMEL_STORE (disco_store), FALSE, NULL);
}
- if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), network_state, ex))
+ if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), network_state, error))
return;
disco_store->status = status;
- camel_service_connect (CAMEL_SERVICE (disco_store), ex);
+ camel_service_connect (CAMEL_SERVICE (disco_store), error);
}
/**
* camel_disco_store_set_status:
* @store: a disconnectable store
* @status: the new status
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* Sets @store to @status. If an error occurrs and the status cannot
* be set to @status, @ex will be set.
**/
void
camel_disco_store_set_status (CamelDiscoStore *store,
- CamelDiscoStoreStatus status,
- CamelException *ex)
+ CamelDiscoStoreStatus status,
+ GError **error)
{
d(printf("disco store set status: %s\n", status == CAMEL_DISCO_STORE_ONLINE?"online":"offline"));
- CAMEL_DISCO_STORE_GET_CLASS (store)->set_status (store, status, ex);
+ CAMEL_DISCO_STORE_GET_CLASS (store)->set_status (store, status, error);
}
static gboolean
@@ -377,7 +369,7 @@ camel_disco_store_can_work_offline (CamelDiscoStore *store)
/**
* camel_disco_store_check_online:
* @store: a disconnectable store
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This checks that @store is online, and sets @ex if it is not. This
* can be used as a simple way to set a generic error message in @ex
@@ -386,26 +378,27 @@ camel_disco_store_can_work_offline (CamelDiscoStore *store)
* Return value: whether or not @store is online.
**/
gboolean
-camel_disco_store_check_online (CamelDiscoStore *store, CamelException *ex)
+camel_disco_store_check_online (CamelDiscoStore *store,
+ GError **error)
{
- if (camel_disco_store_status (store) != CAMEL_DISCO_STORE_ONLINE) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You must be working online to "
- "complete this operation"));
- return FALSE;
- }
+ if (camel_disco_store_status (store) == CAMEL_DISCO_STORE_ONLINE)
+ return TRUE;
- return TRUE;
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
+
+ return FALSE;
}
void
-camel_disco_store_prepare_for_offline(CamelDiscoStore *disco_store, CamelException *ex)
+camel_disco_store_prepare_for_offline (CamelDiscoStore *disco_store,
+ GError **error)
{
- CamelException x;
CamelService *service = CAMEL_SERVICE (disco_store);
gboolean network_state = camel_session_get_network_state (service->session);
- camel_exception_init(&x);
/* Sync the folder fully if we've been told to sync online for this store or this folder */
if (network_state) {
@@ -422,8 +415,7 @@ camel_disco_store_prepare_for_offline(CamelDiscoStore *disco_store, CamelExcepti
folder = folders->pdata[i];
if (G_TYPE_CHECK_INSTANCE_TYPE(folder, CAMEL_TYPE_DISCO_FOLDER)
&& (sync || ((CamelDiscoFolder *)folder)->offline_sync)) {
- camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "(match-all)", &x);
- camel_exception_clear(&x);
+ camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "(match-all)", NULL);
}
g_object_unref (folder);
}
@@ -431,8 +423,7 @@ camel_disco_store_prepare_for_offline(CamelDiscoStore *disco_store, CamelExcepti
}
}
- camel_store_sync(CAMEL_STORE (disco_store), FALSE, &x);
- camel_exception_clear(&x);
+ camel_store_sync(CAMEL_STORE (disco_store), FALSE, NULL);
}
}
diff --git a/camel/camel-disco-store.h b/camel/camel-disco-store.h
index 66ebc2a..dc5e7a1 100644
--- a/camel/camel-disco-store.h
+++ b/camel/camel-disco-store.h
@@ -80,44 +80,44 @@ struct _CamelDiscoStoreClass {
void (*set_status) (CamelDiscoStore *,
CamelDiscoStoreStatus,
- CamelException *);
+ GError **error);
gboolean (*can_work_offline) (CamelDiscoStore *);
gboolean (*connect_online) (CamelService *,
- CamelException *);
+ GError **error);
gboolean (*connect_offline) (CamelService *,
- CamelException *);
+ GError **error);
gboolean (*disconnect_online) (CamelService *, gboolean,
- CamelException *);
+ GError **error);
gboolean (*disconnect_offline) (CamelService *, gboolean,
- CamelException *);
+ GError **error);
CamelFolder * (*get_folder_online) (CamelStore *store,
const gchar *name,
guint32 flags,
- CamelException *ex);
+ GError **error);
CamelFolder * (*get_folder_offline) (CamelStore *store,
const gchar *name,
guint32 flags,
- CamelException *ex);
+ GError **error);
CamelFolder * (*get_folder_resyncing) (CamelStore *store,
const gchar *name,
guint32 flags,
- CamelException *ex);
+ GError **error);
CamelFolderInfo * (*get_folder_info_online) (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex);
+ GError **error);
CamelFolderInfo * (*get_folder_info_offline) (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex);
+ GError **error);
CamelFolderInfo * (*get_folder_info_resyncing) (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex);
+ GError **error);
};
GType camel_disco_store_get_type (void);
@@ -126,12 +126,12 @@ GType camel_disco_store_get_type (void);
CamelDiscoStoreStatus camel_disco_store_status (CamelDiscoStore *store);
void camel_disco_store_set_status (CamelDiscoStore *store,
CamelDiscoStoreStatus status,
- CamelException *ex);
+ GError **error);
gboolean camel_disco_store_can_work_offline (CamelDiscoStore *store);
/* Convenience functions */
-gboolean camel_disco_store_check_online (CamelDiscoStore *store, CamelException *ex);
-void camel_disco_store_prepare_for_offline(CamelDiscoStore *store, CamelException *ex);
+gboolean camel_disco_store_check_online (CamelDiscoStore *store, GError **error);
+void camel_disco_store_prepare_for_offline(CamelDiscoStore *store, GError **error);
G_END_DECLS
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index aeddc10..a2fc9a9 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -122,7 +122,7 @@ struct _CamelFilterDriverPrivate {
CamelDList rules; /* list of _filter_rule structs */
- CamelException *ex;
+ GError *error;
/* evaluator */
ESExp *eval;
@@ -485,12 +485,12 @@ do_forward_to (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFil
/* make sure we have the message... */
if (p->message == NULL) {
- if (!(p->message = camel_folder_get_message (p->source, p->uid, p->ex)))
+ if (!(p->message = camel_folder_get_message (p->source, p->uid, &p->error)))
return NULL;
}
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Forward message to '%s'", argv[0]->value.string);
- camel_session_forward_to (p->session, p->source, p->message, argv[0]->value.string, p->ex);
+ camel_session_forward_to (p->session, p->source, p->message, argv[0]->value.string, &p->error);
return NULL;
}
@@ -521,19 +521,19 @@ do_copy (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gchar *) p->uid);
- camel_folder_transfer_messages_to (p->source, uids, outbox, NULL, FALSE, p->ex);
+ camel_folder_transfer_messages_to (p->source, uids, outbox, NULL, FALSE, &p->error);
g_ptr_array_free (uids, TRUE);
} else {
if (p->message == NULL)
- p->message = camel_folder_get_message (p->source, p->uid, p->ex);
+ p->message = camel_folder_get_message (p->source, p->uid, &p->error);
if (!p->message)
continue;
- camel_folder_append_message (outbox, p->message, p->info, NULL, p->ex);
+ camel_folder_append_message (outbox, p->message, p->info, NULL, &p->error);
}
- if (!camel_exception_is_set (p->ex))
+ if (p->error == NULL)
p->copied = TRUE;
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Copy to folder %s",
@@ -574,18 +574,23 @@ do_move (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gchar *) p->uid);
- camel_folder_transfer_messages_to (p->source, uids, outbox, NULL, last, p->ex);
+ camel_folder_transfer_messages_to (
+ p->source, uids, outbox, NULL,
+ last, &p->error);
g_ptr_array_free (uids, TRUE);
} else {
if (p->message == NULL)
- p->message = camel_folder_get_message (p->source, p->uid, p->ex);
+ p->message = camel_folder_get_message (
+ p->source, p->uid, &p->error);
if (!p->message)
continue;
- camel_folder_append_message (outbox, p->message, p->info, NULL, p->ex);
+ camel_folder_append_message (
+ outbox, p->message, p->info,
+ NULL, &p->error);
- if (!camel_exception_is_set(p->ex) && last) {
+ if (p->error == NULL && last) {
if (p->source && p->uid && camel_folder_has_summary_capability (p->source))
camel_folder_set_message_flags(p->source, p->uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, ~0);
else
@@ -593,7 +598,7 @@ do_move (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri
}
}
- if (!camel_exception_is_set (p->ex)) {
+ if (p->error == NULL) {
p->moved = TRUE;
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Move to folder %s", folder);
}
@@ -794,7 +799,7 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi
/* make sure we have the message... */
if (p->message == NULL) {
- if (!(p->message = camel_folder_get_message (p->source, p->uid, p->ex)))
+ if (!(p->message = camel_folder_get_message (p->source, p->uid, &p->error)))
return -1;
}
@@ -818,9 +823,10 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi
&error)) {
g_ptr_array_free (args, TRUE);
- camel_exception_setv (p->ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to create child process '%s': %s"),
- argv[0]->value.string, error->message);
+ g_set_error (
+ &p->error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to create child process '%s': %s"),
+ argv[0]->value.string, error->message);
g_error_free (error);
return -1;
}
@@ -860,10 +866,11 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi
message = camel_mime_message_new ();
if (camel_mime_part_construct_from_parser ((CamelMimePart *) message, parser) == -1) {
- camel_exception_setv (p->ex, CAMEL_EXCEPTION_SYSTEM,
- _("Invalid message stream received from %s: %s"),
- argv[0]->value.string,
- g_strerror (camel_mime_parser_errno (parser)));
+ g_set_error (
+ &p->error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Invalid message stream received from %s: %s"),
+ argv[0]->value.string,
+ g_strerror (camel_mime_parser_errno (parser)));
g_object_unref (message);
message = NULL;
} else {
@@ -1015,13 +1022,9 @@ open_folder (CamelFilterDriver *driver, const gchar *folder_url)
in duplicate mails, just mail going to inbox. Otherwise,
we want to know about exceptions and abort processing */
if (p->defaultfolder) {
- CamelException ex;
-
- camel_exception_init (&ex);
- camelfolder = p->get_folder (driver, folder_url, p->data, &ex);
- camel_exception_clear (&ex);
+ camelfolder = p->get_folder (driver, folder_url, p->data, NULL);
} else {
- camelfolder = p->get_folder (driver, folder_url, p->data, p->ex);
+ camelfolder = p->get_folder (driver, folder_url, p->data, &p->error);
}
if (camelfolder) {
@@ -1045,7 +1048,7 @@ close_folder (gpointer key, gpointer value, gpointer data)
g_free (key);
if (folder != FOLDER_INVALID) {
- camel_folder_sync (folder, FALSE, camel_exception_is_set(p->ex)?NULL : p->ex);
+ camel_folder_sync (folder, FALSE, (p->error != NULL) ? NULL : &p->error);
camel_folder_thaw (folder);
g_object_unref (folder);
}
@@ -1130,33 +1133,36 @@ camel_filter_driver_log (CamelFilterDriver *driver, enum filter_log_t status, co
struct _run_only_once {
CamelFilterDriver *driver;
- CamelException *ex;
+ GError *error;
};
static gboolean
run_only_once (gpointer key, gchar *action, struct _run_only_once *data)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (data->driver);
- CamelException *ex = data->ex;
ESExpResult *r;
d(printf ("evaluating: %s\n\n", action));
e_sexp_input_text (p->eval, action, strlen (action));
if (e_sexp_parse (p->eval) == -1) {
- if (!camel_exception_is_set (ex))
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Error parsing filter: %s: %s"),
- e_sexp_error (p->eval), action);
+ if (data->error == NULL)
+ g_set_error (
+ &data->error,
+ CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error parsing filter: %s: %s"),
+ e_sexp_error (p->eval), action);
goto done;
}
r = e_sexp_eval (p->eval);
if (r == NULL) {
- if (!camel_exception_is_set (ex))
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Error executing filter: %s: %s"),
- e_sexp_error (p->eval), action);
+ if (data->error == NULL)
+ g_set_error (
+ &data->error,
+ CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error executing filter: %s: %s"),
+ e_sexp_error (p->eval), action);
goto done;
}
@@ -1173,12 +1179,13 @@ run_only_once (gpointer key, gchar *action, struct _run_only_once *data)
/**
* camel_filter_driver_flush:
* @driver:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Flush all of the only-once filter actions.
**/
void
-camel_filter_driver_flush (CamelFilterDriver *driver, CamelException *ex)
+camel_filter_driver_flush (CamelFilterDriver *driver,
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
struct _run_only_once data;
@@ -1187,9 +1194,11 @@ camel_filter_driver_flush (CamelFilterDriver *driver, CamelException *ex)
return;
data.driver = driver;
- data.ex = ex;
+ data.error = NULL;
g_hash_table_foreach_remove (p->only_once, (GHRFunc) run_only_once, &data);
+
+ g_propagate_error (error, data.error);
}
static gint
@@ -1216,7 +1225,7 @@ decode_flags_from_xev(const gchar *xev, CamelMessageInfoBase *mi)
* @driver: CamelFilterDriver
* @mbox: mbox filename to be filtered
* @original_source_url:
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Filters an mbox file based on rules defined in the FilterDriver
* object. Is more efficient as it doesn't need to open the folder
@@ -1227,7 +1236,10 @@ decode_flags_from_xev(const gchar *xev, CamelMessageInfoBase *mi)
*
**/
gint
-camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, const gchar *original_source_url, CamelException *ex)
+camel_filter_driver_filter_mbox (CamelFilterDriver *driver,
+ const gchar *mbox,
+ const gchar *original_source_url,
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
CamelMimeParser *mp = NULL;
@@ -1241,7 +1253,9 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
fd = g_open (mbox, O_RDONLY|O_BINARY, 0);
if (fd == -1) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unable to open spool folder"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unable to open spool folder"));
goto fail;
}
/* to get the filesize */
@@ -1250,7 +1264,9 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
mp = camel_mime_parser_new ();
camel_mime_parser_scan_from (mp, TRUE);
if (camel_mime_parser_init_with_fd (mp, fd) == -1) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unable to process spool folder"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unable to process spool folder"));
goto fail;
}
fd = -1;
@@ -1264,6 +1280,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
GQueue *header_queue;
gint pc = 0;
const gchar *xev;
+ GError *local_error = NULL;
if (st.st_size > 0)
pc = (gint)(100.0 * ((double)camel_mime_parser_tell (mp) / (double)st.st_size));
@@ -1274,7 +1291,12 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
mime_part = CAMEL_MIME_PART (message);
if (camel_mime_part_construct_from_parser (mime_part, mp) == -1) {
- camel_exception_set (ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM, _("Cannot open message"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ (errno == EINTR) ?
+ CAMEL_ERROR_USER_CANCEL :
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot open message"));
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d"), i);
g_object_unref (message);
goto fail;
@@ -1290,12 +1312,17 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
((CamelMessageInfoBase *)info)->size = camel_mime_parser_tell(mp) - last;
last = camel_mime_parser_tell(mp);
- status = camel_filter_driver_filter_message (driver, message, info, NULL, NULL, source_url,
- original_source_url ? original_source_url : source_url, ex);
+ status = camel_filter_driver_filter_message (
+ driver, message, info, NULL, NULL, source_url,
+ original_source_url ? original_source_url : source_url,
+ &local_error);
g_object_unref (message);
- if (camel_exception_is_set (ex) || status == -1) {
- report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d"), i);
+ if (local_error != NULL || status == -1) {
+ report_status (
+ driver, CAMEL_FILTER_STATUS_END, 100,
+ _("Failed on message %d"), i);
camel_message_info_free (info);
+ g_propagate_error (error, local_error);
goto fail;
}
@@ -1309,7 +1336,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
if (p->defaultfolder) {
report_status(driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder"));
- camel_folder_sync(p->defaultfolder, FALSE, camel_exception_is_set (ex) ? NULL : ex);
+ camel_folder_sync(p->defaultfolder, FALSE, NULL);
}
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Complete"));
@@ -1332,7 +1359,7 @@ fail:
* @cache: UID cache (needed for POP folders)
* @uids: message uids to be filtered or NULL (as a shortcut to filter all messages)
* @remove: TRUE to mark filtered messages as deleted
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Filters a folder based on rules defined in the FilterDriver
* object.
@@ -1342,8 +1369,12 @@ fail:
*
**/
gint
-camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder, CamelUIDCache *cache,
- GPtrArray *uids, gboolean remove, CamelException *ex)
+camel_filter_driver_filter_folder (CamelFilterDriver *driver,
+ CamelFolder *folder,
+ CamelUIDCache *cache,
+ GPtrArray *uids,
+ gboolean remove,
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
gboolean freeuids = FALSE;
@@ -1367,6 +1398,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
for (i = 0; i < uids->len; i++) {
gint pc = (100 * i)/uids->len;
+ GError *local_error = NULL;
report_status (driver, CAMEL_FILTER_STATUS_START, pc, _("Getting message %d of %d"), i+1,
uids->len);
@@ -1376,15 +1408,19 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
else
info = NULL;
- status = camel_filter_driver_filter_message (driver, NULL, info, uids->pdata[i],
- folder, source_url, source_url, ex);
+ status = camel_filter_driver_filter_message (
+ driver, NULL, info, uids->pdata[i],
+ folder, source_url, source_url, &local_error);
if (camel_folder_has_summary_capability (folder))
camel_folder_free_message_info (folder, info);
- if (camel_exception_is_set (ex) || status == -1) {
- report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed at message %d of %d"),
- i+1, uids->len);
+ if (local_error != NULL || status == -1) {
+ report_status (
+ driver, CAMEL_FILTER_STATUS_END, 100,
+ _("Failed at message %d of %d"),
+ i+1, uids->len);
+ g_propagate_error (error, local_error);
status = -1;
break;
}
@@ -1399,7 +1435,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
if (p->defaultfolder) {
report_status (driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder"));
- camel_folder_sync (p->defaultfolder, FALSE, camel_exception_is_set (ex) ? NULL : ex);
+ camel_folder_sync (p->defaultfolder, FALSE, NULL);
}
if (i == uids->len)
@@ -1419,7 +1455,7 @@ struct _get_message {
};
static CamelMimeMessage *
-get_message_cb (gpointer data, CamelException *ex)
+get_message_cb (gpointer data, GError **error)
{
struct _get_message *msgdata = data;
struct _CamelFilterDriverPrivate *p = msgdata->p;
@@ -1437,7 +1473,7 @@ get_message_cb (gpointer data, CamelException *ex)
else
uid = camel_message_info_uid (p->info);
- message = camel_folder_get_message (p->source, uid, ex);
+ message = camel_folder_get_message (p->source, uid, error);
}
if (source_url && message && camel_mime_message_get_source (message) == NULL)
@@ -1455,7 +1491,7 @@ get_message_cb (gpointer data, CamelException *ex)
* @source: source folder or NULL
* @source_url: url of source folder or NULL
* @original_source_url: url of original source folder (pre-movemail) or NULL
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Filters a message based on rules defined in the FilterDriver
* object. If the source folder (@source) and the uid (@uid) are
@@ -1468,11 +1504,14 @@ get_message_cb (gpointer data, CamelException *ex)
*
**/
gint
-camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
- CamelMessageInfo *info, const gchar *uid,
- CamelFolder *source, const gchar *source_url,
- const gchar *original_source_url,
- CamelException *ex)
+camel_filter_driver_filter_message (CamelFilterDriver *driver,
+ CamelMimeMessage *message,
+ CamelMessageInfo *info,
+ const gchar *uid,
+ CamelFolder *source,
+ const gchar *source_url,
+ const gchar *original_source_url,
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
CamelMimePart *mime_part;
@@ -1494,7 +1533,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
if (message) {
g_object_ref (message);
} else {
- message = camel_folder_get_message (source, uid, ex);
+ message = camel_folder_get_message (source, uid, error);
if (!message)
return -1;
}
@@ -1513,7 +1552,6 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
g_object_ref (message);
}
- p->ex = ex;
p->terminated = FALSE;
p->deleted = FALSE;
p->copied = FALSE;
@@ -1536,9 +1574,10 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
data.p = p;
data.source_url = original_source_url;
- result = camel_filter_search_match (p->session, get_message_cb, &data, p->info,
- original_source_url ? original_source_url : source_url,
- node->match, p->ex);
+ result = camel_filter_search_match (
+ p->session, get_message_cb, &data, p->info,
+ original_source_url ? original_source_url : source_url,
+ node->match, &p->error);
switch (result) {
case CAMEL_SEARCH_ERROR:
@@ -1554,17 +1593,21 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
/* perform necessary filtering actions */
e_sexp_input_text (p->eval, node->action, strlen (node->action));
if (e_sexp_parse (p->eval) == -1) {
- camel_exception_setv (ex, 1, _("Error parsing filter: %s: %s"),
- e_sexp_error (p->eval), node->action);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error parsing filter: %s: %s"),
+ e_sexp_error (p->eval), node->action);
goto error;
}
r = e_sexp_eval (p->eval);
- if (camel_exception_is_set(p->ex))
+ if (p->error != NULL)
goto error;
if (r == NULL) {
- camel_exception_setv (ex, 1, _("Error executing filter: %s: %s"),
- e_sexp_error (p->eval), node->action);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error executing filter: %s: %s"),
+ e_sexp_error (p->eval), node->action);
goto error;
}
e_sexp_result_free (p->eval, r);
@@ -1599,16 +1642,20 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gchar *) p->uid);
- camel_folder_transfer_messages_to (p->source, uids, p->defaultfolder, NULL, FALSE, p->ex);
+ camel_folder_transfer_messages_to (
+ p->source, uids, p->defaultfolder,
+ NULL, FALSE, &p->error);
g_ptr_array_free (uids, TRUE);
} else {
if (p->message == NULL) {
- p->message = camel_folder_get_message (source, uid, ex);
+ p->message = camel_folder_get_message (source, uid, error);
if (!p->message)
goto error;
}
- camel_folder_append_message (p->defaultfolder, p->message, p->info, NULL, p->ex);
+ camel_folder_append_message (
+ p->defaultfolder, p->message,
+ p->info, NULL, &p->error);
}
}
@@ -1630,5 +1677,8 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
if (freeinfo)
camel_message_info_free (info);
+ g_propagate_error (error, p->error);
+ p->error = NULL;
+
return -1;
}
diff --git a/camel/camel-filter-driver.h b/camel/camel-filter-driver.h
index a5a5dcc..18933c6 100644
--- a/camel/camel-filter-driver.h
+++ b/camel/camel-filter-driver.h
@@ -77,7 +77,7 @@ enum camel_filter_status_t {
};
typedef CamelFolder * (*CamelFilterGetFolderFunc) (CamelFilterDriver *driver, const gchar *uri,
- gpointer data, CamelException *ex);
+ gpointer data, GError **error);
/* report status */
typedef void (CamelFilterStatusFunc) (CamelFilterDriver *driver, enum camel_filter_status_t status,
gint pc, const gchar *desc, gpointer data);
@@ -106,18 +106,18 @@ gint camel_filter_driver_remove_rule_by_name (CamelFilterDriver *d, const gcha
/*void camel_filter_driver_set_global(CamelFilterDriver *, const gchar *name, const gchar *value);*/
-void camel_filter_driver_flush (CamelFilterDriver *driver, CamelException *ex);
+void camel_filter_driver_flush (CamelFilterDriver *driver, GError **error);
gint camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
CamelMessageInfo *info, const gchar *uid,
CamelFolder *source, const gchar *source_url,
- const gchar *original_source_url, CamelException *ex);
+ const gchar *original_source_url, GError **error);
gint camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox,
- const gchar *original_source_url, CamelException *ex);
+ const gchar *original_source_url, GError **error);
gint camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder, CamelUIDCache *cache,
- GPtrArray *uids, gboolean remove, CamelException *ex);
+ GPtrArray *uids, gboolean remove, GError **error);
#if 0
/* generate the search query/action string for a filter option */
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 4775e2f..5eeea2a 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -46,7 +46,6 @@
#include <libedataserver/e-sexp.h>
#include "camel-debug.h"
-#include "camel-exception.h"
#include "camel-filter-search.h"
#include "camel-iconv.h"
#include "camel-mime-message.h"
@@ -68,7 +67,7 @@ typedef struct {
CamelMimeMessage *message;
CamelMessageInfo *info;
const gchar *source;
- CamelException *ex;
+ GError **error;
} FilterMessageSearch;
/* ESExp callbacks */
@@ -130,7 +129,7 @@ camel_filter_search_get_message (FilterMessageSearch *fms, struct _ESExp *sexp)
if (fms->message)
return fms->message;
- fms->message = fms->get_message (fms->get_message_data, fms->ex);
+ fms->message = fms->get_message (fms->get_message_data, fms->error);
if (fms->message == NULL)
e_sexp_fatal_error (sexp, _("Failed to retrieve message"));
@@ -276,7 +275,7 @@ header_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMes
if (argc > 1 && argv[0]->type == ESEXP_RES_STRING
&& (contents = camel_medium_get_header (CAMEL_MEDIUM (message), argv[0]->value.string))
- && camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc-1, argv+1, fms->ex) == 0) {
+ && camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc-1, argv+1, fms->error) == 0) {
r->value.bool = regexec (&pattern, contents, 0, NULL, 0) == 0;
regfree (&pattern);
} else
@@ -333,7 +332,7 @@ header_full_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, Filt
gchar *contents;
if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_NEWLINE,
- argc, argv, fms->ex) == 0) {
+ argc, argv, fms->error) == 0) {
message = camel_filter_search_get_message (fms, f);
contents = get_full_header (message);
r->value.bool = regexec (&pattern, contents, 0, NULL, 0) == 0;
@@ -367,7 +366,7 @@ body_contains (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMe
CamelMimeMessage *message;
regex_t pattern;
- if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_ICASE, argc, argv, fms->ex) == 0) {
+ if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_ICASE, argc, argv, fms->error) == 0) {
message = camel_filter_search_get_message (fms, f);
r->value.bool = camel_search_message_body_contains ((CamelDataWrapper *) message, &pattern);
regfree (&pattern);
@@ -385,7 +384,7 @@ body_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMessa
regex_t pattern;
if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_NEWLINE,
- argc, argv, fms->ex) == 0) {
+ argc, argv, fms->error) == 0) {
message = camel_filter_search_get_message (fms, f);
r->value.bool = camel_search_message_body_contains ((CamelDataWrapper *) message, &pattern);
regfree (&pattern);
@@ -602,9 +601,10 @@ run_command (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMess
&error)) {
g_ptr_array_free (args, TRUE);
- camel_exception_setv (fms->ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to create child process '%s': %s"),
- argv[0]->value.string, error->message);
+ g_set_error (
+ fms->error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to create child process '%s': %s"),
+ argv[0]->value.string, error->message);
g_error_free (error);
return -1;
}
@@ -721,16 +721,19 @@ junk_test (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMessag
* @info:
* @source:
* @expression:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Returns: one of CAMEL_SEARCH_MATCHED, CAMEL_SEARCH_NOMATCH, or
* CAMEL_SEARCH_ERROR.
**/
gint
camel_filter_search_match (CamelSession *session,
- CamelFilterSearchGetMessageFunc get_message, gpointer data,
- CamelMessageInfo *info, const gchar *source,
- const gchar *expression, CamelException *ex)
+ CamelFilterSearchGetMessageFunc get_message,
+ gpointer data,
+ CamelMessageInfo *info,
+ const gchar *source,
+ const gchar *expression,
+ GError **error)
{
FilterMessageSearch fms;
ESExp *sexp;
@@ -744,7 +747,7 @@ camel_filter_search_match (CamelSession *session,
fms.message = NULL;
fms.info = info;
fms.source = source;
- fms.ex = ex;
+ fms.error = error;
sexp = e_sexp_new ();
@@ -757,18 +760,21 @@ camel_filter_search_match (CamelSession *session,
e_sexp_input_text (sexp, expression, strlen (expression));
if (e_sexp_parse (sexp) == -1) {
- if (!camel_exception_is_set (ex))
- /* A filter search is a search through your filters, ie. your filters is the corpus being searched thru. */
- camel_exception_setv (ex, 1, _("Error executing filter search: %s: %s"),
- e_sexp_error (sexp), expression);
+ /* A filter search is a search through your filters,
+ * ie. your filters is the corpus being searched thru. */
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error executing filter search: %s: %s"),
+ e_sexp_error (sexp), expression);
goto error;
}
result = e_sexp_eval (sexp);
if (result == NULL) {
- if (!camel_exception_is_set (ex))
- camel_exception_setv (ex, 1, _("Error executing filter search: %s: %s"),
- e_sexp_error (sexp), expression);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error executing filter search: %s: %s"),
+ e_sexp_error (sexp), expression);
goto error;
}
diff --git a/camel/camel-filter-search.h b/camel/camel-filter-search.h
index a14cd1f..0b86806 100644
--- a/camel/camel-filter-search.h
+++ b/camel/camel-filter-search.h
@@ -41,12 +41,12 @@ enum {
CAMEL_SEARCH_MATCHED = 1
};
-typedef CamelMimeMessage * (*CamelFilterSearchGetMessageFunc) (gpointer data, CamelException *ex);
+typedef CamelMimeMessage * (*CamelFilterSearchGetMessageFunc) (gpointer data, GError **error);
gint camel_filter_search_match (struct _CamelSession *session,
CamelFilterSearchGetMessageFunc get_message, gpointer data,
CamelMessageInfo *info, const gchar *source,
- const gchar *expression, CamelException *ex);
+ const gchar *expression, GError **error);
G_END_DECLS
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index 5093fc1..128a4cd 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -37,7 +37,6 @@
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-folder-search.h"
#include "camel-folder-thread.h"
#include "camel-iconv.h"
@@ -63,7 +62,7 @@
((obj), CAMEL_TYPE_FOLDER_SEARCH, CamelFolderSearchPrivate))
struct _CamelFolderSearchPrivate {
- CamelException *ex;
+ GError **error;
CamelFolderThread *threads;
GHashTable *threads_hash;
@@ -328,7 +327,7 @@ camel_folder_search_set_body_index(CamelFolderSearch *search, CamelIndex *index)
* camel_folder_search_execute_expression:
* @search:
* @expr:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Execute the search expression @expr, returning an array of
* all matches as a GPtrArray of uid's of matching messages.
@@ -343,7 +342,9 @@ camel_folder_search_set_body_index(CamelFolderSearch *search, CamelIndex *index)
* This must only be freed by camel_folder_search_free_result.
**/
GPtrArray *
-camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *expr, CamelException *ex)
+camel_folder_search_execute_expression (CamelFolderSearch *search,
+ const gchar *expr,
+ GError **error)
{
ESExpResult *r;
GPtrArray *matches;
@@ -351,14 +352,17 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *e
GHashTable *results;
CamelFolderSearchPrivate *p = search->priv;
- p->ex = ex;
+ p->error = error;
/* only re-parse if the search has changed */
if (search->last_search == NULL
|| strcmp(search->last_search, expr)) {
e_sexp_input_text(search->sexp, expr, strlen(expr));
if (e_sexp_parse(search->sexp) == -1) {
- camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot parse search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
return NULL;
}
@@ -367,8 +371,10 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *e
}
r = e_sexp_eval(search->sexp);
if (r == NULL) {
- if (!camel_exception_is_set(ex))
- camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error executing search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
return NULL;
}
@@ -423,7 +429,7 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *e
* @search:
* @expr:
* @uids: to search against, NULL for all uid's.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Run a search. Search must have had Folder already set on it, and
* it must implement summaries.
@@ -432,7 +438,9 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *e
**/
guint32
-camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelException *ex)
+camel_folder_search_count (CamelFolderSearch *search,
+ const gchar *expr,
+ GError **error)
{
ESExpResult *r;
GPtrArray *summary_set;
@@ -446,7 +454,7 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
g_assert(search->folder);
- p->ex = ex;
+ p->error = error;
/* We route body-contains search and thread based search through memory and not via db. */
if (strstr((const gchar *) expr, "body-contains") || strstr((const gchar *) expr, "match-threads")) {
@@ -460,7 +468,10 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
|| strcmp(search->last_search, expr)) {
e_sexp_input_text(search->sexp, expr, strlen(expr));
if (e_sexp_parse(search->sexp) == -1) {
- camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot parse search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
goto fail;
}
@@ -469,8 +480,10 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
}
r = e_sexp_eval(search->sexp);
if (r == NULL) {
- if (!camel_exception_is_set(ex))
- camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error executing search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
goto fail;
}
@@ -496,8 +509,10 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
e_sexp_result_free(search->sexp, r);
} else {
+ GError *local_error = NULL;
+
/* Sync the db, so that we search the db for changes */
- camel_folder_summary_save_to_db (search->folder->summary, ex);
+ camel_folder_summary_save_to_db (search->folder->summary, error);
dd(printf ("sexp is : [%s]\n", expr));
if (g_getenv("SQL_SEARCH_OLD"))
@@ -511,16 +526,17 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
dd(printf("Equivalent sql %s\n", tmp));
cdb = (CamelDB *) (search->folder->parent_store->cdb_r);
- camel_db_count_message_info (cdb, tmp, &count, ex);
- if (ex && camel_exception_is_set(ex)) {
- const gchar *exception = camel_exception_get_description (ex);
- if (strncmp(exception, "no such table", 13) == 0) {
- d(g_warning ("Error during searching %s: %s\n", tmp, exception));
- camel_exception_clear (ex); /* Suppress no such table */
+ camel_db_count_message_info (cdb, tmp, &count, &local_error);
+ if (local_error != NULL) {
+ const gchar *message = local_error->message;
+ if (strncmp(message, "no such table", 13) == 0) {
+ d(g_warning ("Error during searching %s: %s\n", tmp, message));
+ /* Suppress no such table */
+ g_clear_error (&local_error);
}
+ g_propagate_error (error, local_error);
}
g_free (tmp);
-
}
fail:
@@ -568,7 +584,7 @@ do_search_in_memory (const gchar *expr)
* @search:
* @expr:
* @uids: to search against, NULL for all uid's.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Run a search. Search must have had Folder already set on it, and
* it must implement summaries.
@@ -576,7 +592,10 @@ do_search_in_memory (const gchar *expr)
* Return value:
**/
GPtrArray *
-camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArray *uids, CamelException *ex)
+camel_folder_search_search (CamelFolderSearch *search,
+ const gchar *expr,
+ GPtrArray *uids,
+ GError **error)
{
ESExpResult *r;
GPtrArray *matches = NULL, *summary_set;
@@ -589,7 +608,7 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
g_assert(search->folder);
- p->ex = ex;
+ p->error = error;
/* We route body-contains / thread based search and uid search through memory and not via db. */
if (uids || do_search_in_memory (expr)) {
@@ -615,7 +634,10 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
|| strcmp(search->last_search, expr)) {
e_sexp_input_text(search->sexp, expr, strlen(expr));
if (e_sexp_parse(search->sexp) == -1) {
- camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot parse search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
goto fail;
}
@@ -624,8 +646,10 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
}
r = e_sexp_eval(search->sexp);
if (r == NULL) {
- if (!camel_exception_is_set(ex))
- camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error executing search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
goto fail;
}
@@ -653,8 +677,10 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
e_sexp_result_free(search->sexp, r);
} else {
+ GError *local_error = NULL;
+
/* Sync the db, so that we search the db for changes */
- camel_folder_summary_save_to_db (search->folder->summary, ex);
+ camel_folder_summary_save_to_db (search->folder->summary, error);
dd(printf ("sexp is : [%s]\n", expr));
if (g_getenv("SQL_SEARCH_OLD"))
@@ -669,13 +695,17 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
matches = g_ptr_array_new();
cdb = (CamelDB *) (search->folder->parent_store->cdb_r);
- camel_db_select (cdb, tmp, (CamelDBSelectCB) read_uid_callback, matches, ex);
- if (ex && camel_exception_is_set(ex)) {
- const gchar *exception = camel_exception_get_description (ex);
- if (strncmp(exception, "no such table", 13) == 0) {
- d(g_warning ("Error during searching %s: %s\n", tmp, exception));
- camel_exception_clear (ex); /* Suppress no such table */
+ camel_db_select (
+ cdb, tmp, (CamelDBSelectCB)
+ read_uid_callback, matches, &local_error);
+ if (local_error != NULL) {
+ const gchar *message = local_error->message;
+ if (strncmp(message, "no such table", 13) == 0) {
+ d(g_warning ("Error during searching %s: %s\n", tmp, message));
+ /* Suppress no such table */
+ g_clear_error (&local_error);
}
+ g_propagate_error (error, local_error);
}
g_free (tmp);
@@ -841,7 +871,8 @@ search_match_all(struct _ESExp *f, gint argc, struct _ESExpTerm **argv, CamelFol
v = search->summary_set?search->summary_set:search->summary;
if (v->len > g_hash_table_size (search->folder->summary->loaded_infos) && !CAMEL_IS_VEE_FOLDER (search->folder)) {
- camel_folder_summary_reload_from_db (search->folder->summary, search->priv->ex);
+ camel_folder_summary_reload_from_db (
+ search->folder->summary, search->priv->error);
}
for (i=0;i<v->len;i++) {
@@ -1019,18 +1050,11 @@ search_match_threads(struct _ESExp *f, gint argc, struct _ESExpTerm **argv, Came
static CamelMimeMessage *
get_current_message (CamelFolderSearch *search)
{
- CamelException x = CAMEL_EXCEPTION_INITIALISER;
- CamelMimeMessage *res;
-
if (!search || !search->folder || !search->current)
return NULL;
- res = camel_folder_get_message (search->folder, search->current->uid, &x);
-
- if (!res)
- camel_exception_clear (&x);
-
- return res;
+ return camel_folder_get_message (
+ search->folder, search->current->uid, NULL);
}
static ESExpResult *
@@ -1240,7 +1264,7 @@ search_header_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, Ca
if (argc > 1 && argv[0]->type == ESEXP_RES_STRING
&& (contents = camel_medium_get_header (CAMEL_MEDIUM (msg), argv[0]->value.string))
- && camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc-1, argv+1, search->priv->ex) == 0) {
+ && camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc-1, argv+1, search->priv->error) == 0) {
r->value.bool = regexec (&pattern, contents, 0, NULL, 0) == 0;
regfree (&pattern);
} else
@@ -1303,7 +1327,7 @@ search_header_full_regex (struct _ESExp *f, gint argc, struct _ESExpResult **arg
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
- if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_NEWLINE, argc, argv, search->priv->ex) == 0) {
+ if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_NEWLINE, argc, argv, search->priv->error) == 0) {
gchar *contents;
contents = get_full_header (msg);
@@ -1345,7 +1369,10 @@ htand(gchar *key, gint value, struct IterData *iter_data)
}
static gint
-match_message_index(CamelIndex *idx, const gchar *uid, const gchar *match, CamelException *ex)
+match_message_index (CamelIndex *idx,
+ const gchar *uid,
+ const gchar *match,
+ GError **error)
{
CamelIndexCursor *wc, *nc;
const gchar *word, *name;
@@ -1382,7 +1409,9 @@ or
/* returns messages which contain all words listed in words */
static GPtrArray *
-match_words_index(CamelFolderSearch *search, struct _camel_search_words *words, CamelException *ex)
+match_words_index (CamelFolderSearch *search,
+ struct _camel_search_words *words,
+ GError **error)
{
GPtrArray *result = g_ptr_array_new();
GHashTable *ht = g_hash_table_new(g_str_hash, g_str_equal);
@@ -1474,28 +1503,29 @@ match_words_1message (CamelDataWrapper *object, struct _camel_search_words *word
}
static gboolean
-match_words_message(CamelFolder *folder, const gchar *uid, struct _camel_search_words *words, CamelException *ex)
+match_words_message (CamelFolder *folder,
+ const gchar *uid,
+ struct _camel_search_words *words,
+ GError **error)
{
guint32 mask;
CamelMimeMessage *msg;
- CamelException x = CAMEL_EXCEPTION_INITIALISER;
- gint truth;
+ gint truth = FALSE;
- msg = camel_folder_get_message(folder, uid, &x);
+ msg = camel_folder_get_message(folder, uid, NULL);
if (msg) {
mask = 0;
truth = match_words_1message((CamelDataWrapper *)msg, words, &mask);
g_object_unref (msg);
- } else {
- camel_exception_clear(&x);
- truth = FALSE;
}
return truth;
}
static GPtrArray *
-match_words_messages(CamelFolderSearch *search, struct _camel_search_words *words, CamelException *ex)
+match_words_messages (CamelFolderSearch *search,
+ struct _camel_search_words *words,
+ GError **error)
{
gint i;
GPtrArray *matches = g_ptr_array_new();
@@ -1505,13 +1535,13 @@ match_words_messages(CamelFolderSearch *search, struct _camel_search_words *word
struct _camel_search_words *simple;
simple = camel_search_words_simple(words);
- indexed = match_words_index(search, simple, ex);
+ indexed = match_words_index(search, simple, error);
camel_search_words_free(simple);
for (i=0;i<indexed->len;i++) {
const gchar *uid = g_ptr_array_index(indexed, i);
- if (match_words_message(search->folder, uid, words, ex))
+ if (match_words_message(search->folder, uid, words, error))
g_ptr_array_add(matches, (gchar *)uid);
}
@@ -1522,7 +1552,7 @@ match_words_messages(CamelFolderSearch *search, struct _camel_search_words *word
for (i=0;i<v->len;i++) {
gchar *uid = g_ptr_array_index(v, i);
- if (match_words_message(search->folder, uid, words, ex))
+ if (match_words_message(search->folder, uid, words, error))
g_ptr_array_add(matches, (gchar *)uid);
}
}
@@ -1534,7 +1564,7 @@ static ESExpResult *
search_body_contains(struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFolderSearch *search)
{
gint i, j;
- CamelException *ex = search->priv->ex;
+ GError **error = search->priv->error;
struct _camel_search_words *words;
ESExpResult *r;
struct IterData lambdafoo;
@@ -1551,10 +1581,10 @@ search_body_contains(struct _ESExp *f, gint argc, struct _ESExpResult **argv, Ca
truth = TRUE;
if ((words->type & CAMEL_SEARCH_WORD_COMPLEX) == 0 && search->body_index) {
for (j=0;j<words->len && truth;j++)
- truth = match_message_index(search->body_index, camel_message_info_uid(search->current), words->words[j]->word, ex);
+ truth = match_message_index(search->body_index, camel_message_info_uid(search->current), words->words[j]->word, error);
} else {
/* TODO: cache current message incase of multiple body search terms */
- truth = match_words_message(search->folder, camel_message_info_uid(search->current), words, ex);
+ truth = match_words_message(search->folder, camel_message_info_uid(search->current), words, error);
}
camel_search_words_free(words);
}
@@ -1582,9 +1612,9 @@ search_body_contains(struct _ESExp *f, gint argc, struct _ESExpResult **argv, Ca
if (argv[i]->type == ESEXP_RES_STRING) {
words = camel_search_words_split((const guchar *) argv[i]->value.string);
if ((words->type & CAMEL_SEARCH_WORD_COMPLEX) == 0 && search->body_index) {
- matches = match_words_index(search, words, ex);
+ matches = match_words_index(search, words, error);
} else {
- matches = match_words_messages(search, words, ex);
+ matches = match_words_messages(search, words, error);
}
for (j=0;j<matches->len;j++) {
g_hash_table_insert(ht, matches->pdata[j], matches->pdata[j]);
@@ -1613,7 +1643,7 @@ search_body_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, Came
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
- if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_NEWLINE, argc, argv, search->priv->ex) == 0) {
+ if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_NEWLINE, argc, argv, search->priv->error) == 0) {
r->value.bool = camel_search_message_body_contains ((CamelDataWrapper *) msg, &pattern);
regfree (&pattern);
} else
@@ -1626,24 +1656,21 @@ search_body_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, Came
r = e_sexp_result_new(f, ESEXP_RES_ARRAY_PTR);
r->value.ptrarray = g_ptr_array_new ();
- if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_NEWLINE, argc, argv, search->priv->ex) == 0) {
+ if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_NEWLINE, argc, argv, search->priv->error) == 0) {
gint i;
GPtrArray *v = search->summary_set?search->summary_set:search->summary;
- CamelException x = CAMEL_EXCEPTION_INITIALISER;
CamelMimeMessage *message;
for (i = 0; i < v->len; i++) {
gchar *uid = g_ptr_array_index(v, i);
- message = camel_folder_get_message (search->folder, uid, &x);
+ message = camel_folder_get_message (search->folder, uid, NULL);
if (message) {
if (camel_search_message_body_contains ((CamelDataWrapper *) message, &pattern)) {
g_ptr_array_add (r->value.ptrarray, uid);
}
g_object_unref (message);
- } else {
- camel_exception_clear (&x);
}
}
diff --git a/camel/camel-folder-search.h b/camel/camel-folder-search.h
index d8d5c7d..5eea9ac 100644
--- a/camel/camel-folder-search.h
+++ b/camel/camel-folder-search.h
@@ -158,10 +158,10 @@ void camel_folder_search_set_folder(CamelFolderSearch *search, CamelFolder *fold
void camel_folder_search_set_summary(CamelFolderSearch *search, GPtrArray *summary);
void camel_folder_search_set_body_index(CamelFolderSearch *search, CamelIndex *index);
/* this interface is deprecated */
-GPtrArray *camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *expr, CamelException *ex);
+GPtrArray *camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *expr, GError **error);
-GPtrArray *camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArray *uids, CamelException *ex);
-guint32 camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelException *ex);
+GPtrArray *camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArray *uids, GError **error);
+guint32 camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, GError **error);
void camel_folder_search_free_result(CamelFolderSearch *search, GPtrArray *);
G_END_DECLS
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 3aea9fb..b733036 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -130,7 +130,7 @@ static CamelMessageContentInfo * content_info_load(CamelFolderSummary *, FILE *)
static gint content_info_save(CamelFolderSummary *, FILE *, CamelMessageContentInfo *);
static void content_info_free(CamelFolderSummary *, CamelMessageContentInfo *);
-static gint save_message_infos_to_db (CamelFolderSummary *s, gboolean fresh_mir, CamelException *ex);
+static gint save_message_infos_to_db (CamelFolderSummary *s, gboolean fresh_mir, GError **error);
static gint camel_read_mir_callback (gpointer ref, gint ncol, gchar ** cols, gchar ** name);
static gchar *next_uid_string(CamelFolderSummary *s);
@@ -276,7 +276,8 @@ summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *record)
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s,
+ GError **error)
{
CamelFIRecord * record = g_new0 (CamelFIRecord, 1);
CamelDB *db;
@@ -1263,12 +1264,10 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid)
if (!info) {
CamelDB *cdb;
- CamelException ex;
gchar *folder_name;
struct _db_pass_data data;
d(printf ("\ncamel_folder_summary_uid called \n"));
- camel_exception_init (&ex);
s->flags &= ~CAMEL_SUMMARY_DIRTY;
folder_name = s->folder->full_name;
@@ -1281,11 +1280,11 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid)
data.double_ref = TRUE;
data.add = FALSE;
- ret = camel_db_read_message_info_record_with_uid (cdb, folder_name, uid, &data, camel_read_mir_callback, &ex);
- if (ret != 0) {
- camel_exception_clear (&ex);
+ ret = camel_db_read_message_info_record_with_uid (
+ cdb, folder_name, uid, &data,
+ camel_read_mir_callback, NULL);
+ if (ret != 0)
return NULL;
- }
CAMEL_SUMMARY_LOCK(s, summary_lock);
CAMEL_SUMMARY_LOCK(s, ref_lock);
@@ -1293,15 +1292,6 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid)
/* We would have double reffed at camel_read_mir_callback */
info = g_hash_table_lookup (s->loaded_infos, uid);
- if (!info) {
- gchar *errmsg = g_strdup_printf ("no uid [%s] exists", uid);
-
- /* Makes no sense now as the exception is local as of now. FIXME: Pass exception from caller */
- camel_exception_set (&ex, CAMEL_EXCEPTION_SYSTEM, _(errmsg));
- d(g_warning ("No uid[%s] exists in %s\n", uid, folder_name));
- camel_exception_clear (&ex);
- g_free (errmsg);
- }
} else
info->refcount++;
@@ -1538,12 +1528,9 @@ remove_cache (CamelSession *session, CamelSessionThreadMsg *msg)
{
struct _folder_summary_free_msg *m = (struct _folder_summary_free_msg *)msg;
CamelFolderSummary *s = m->summary;
- CamelException ex;
CAMEL_DB_RELEASE_SQLITE_MEMORY;
- camel_exception_init (&ex);
- camel_folder_sync (s->folder, FALSE, &ex);
- camel_exception_clear (&ex);
+ camel_folder_sync (s->folder, FALSE, NULL);
if (time(NULL) - s->cache_load_time < SUMMARY_CACHE_DROP)
return;
@@ -1611,7 +1598,7 @@ struct _preview_update_msg {
CamelSessionThreadMsg msg;
CamelFolder *folder;
- CamelException ex;
+ GError **error;
};
static void
@@ -1619,17 +1606,12 @@ msg_update_preview (const gchar *uid, gpointer value, CamelFolder *folder)
{
CamelMessageInfoBase *info = (CamelMessageInfoBase *)camel_folder_summary_uid (folder->summary, uid);
CamelMimeMessage *msg;
- CamelException ex;
- camel_exception_init(&ex);
- msg = camel_folder_get_message (folder, uid, &ex);
- if (camel_exception_is_set(&ex))
- g_warning ("Error fetching message: %s", camel_exception_get_description(&ex));
- else {
+ msg = camel_folder_get_message (folder, uid, NULL);
+ if (msg != NULL) {
if (camel_mime_message_build_preview ((CamelMimePart *)msg, (CamelMessageInfo *)info) && info->preview)
camel_db_write_preview_record (folder->parent_store->cdb_w, folder->full_name, info->uid, info->preview, NULL);
}
- camel_exception_clear(&ex);
camel_message_info_free(info);
}
@@ -1701,7 +1683,8 @@ static CamelSessionThreadOps preview_update_ops = {
/* end */
gint
-camel_folder_summary_reload_from_db (CamelFolderSummary *s, CamelException *ex)
+camel_folder_summary_reload_from_db (CamelFolderSummary *s,
+ GError **error)
{
CamelDB *cdb;
gchar *folder_name;
@@ -1731,7 +1714,7 @@ camel_folder_summary_reload_from_db (CamelFolderSummary *s, CamelException *ex)
m = camel_session_thread_msg_new(((CamelService *)s->folder->parent_store)->session, &preview_update_ops, sizeof(*m));
m->folder = s->folder;
- camel_exception_init(&m->ex);
+ m->error = NULL;
camel_session_thread_queue(((CamelService *)s->folder->parent_store)->session, &m->msg, 0);
}
@@ -1751,12 +1734,14 @@ camel_folder_summary_add_preview (CamelFolderSummary *s, CamelMessageInfo *info)
* @s: #CamelFolderSummary object
* @at_least: How many infos already loaded are considered fine to not reload all of them.
* Use -1 to force reload of all of them if not in memory yet.
- * @ex: #CamelException object.
+ * @error: return location for a #GError, or %NULL
*
* Loads all infos into memory, if they are not yet.
**/
void
-camel_folder_summary_ensure_infos_loaded (CamelFolderSummary *s, gint at_least, CamelException *ex)
+camel_folder_summary_ensure_infos_loaded (CamelFolderSummary *s,
+ gint at_least,
+ GError **error)
{
guint loaded, known;
@@ -1765,9 +1750,8 @@ camel_folder_summary_ensure_infos_loaded (CamelFolderSummary *s, gint at_least,
loaded = camel_folder_summary_cache_size (s);
known = camel_folder_summary_count (s);
- if ((at_least == -1 && known != loaded) || at_least > loaded) {
- camel_folder_summary_reload_from_db (s, ex);
- }
+ if ((at_least == -1 && known != loaded) || at_least > loaded)
+ camel_folder_summary_reload_from_db (s, error);
}
#if 0
@@ -1792,19 +1776,20 @@ camel_folder_summary_get_flag_cache (CamelFolderSummary *summary)
}
gint
-camel_folder_summary_load_from_db (CamelFolderSummary *s, CamelException *ex)
+camel_folder_summary_load_from_db (CamelFolderSummary *s,
+ GError **error)
{
CamelDB *cdb;
gchar *folder_name;
gint ret = 0;
- CamelException ex2;
struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s);
+ GError *local_error = NULL;
/* struct _db_pass_data data; */
d(printf ("\ncamel_folder_summary_load_from_db called \n"));
s->flags &= ~CAMEL_SUMMARY_DIRTY;
- ret = camel_folder_summary_header_load_from_db (s, s->folder->parent_store, s->folder->full_name, ex);
+ ret = camel_folder_summary_header_load_from_db (s, s->folder->parent_store, s->folder->full_name, error);
if (ret)
return ret;
@@ -1812,19 +1797,16 @@ camel_folder_summary_load_from_db (CamelFolderSummary *s, CamelException *ex)
folder_name = s->folder->full_name;
cdb = s->folder->parent_store->cdb_r;
- camel_exception_init (&ex2);
+ ret = camel_db_get_folder_uids_flags (
+ cdb, folder_name, s->sort_by, s->collate,
+ s->uids, p->flag_cache, &local_error);
- ret = camel_db_get_folder_uids_flags (cdb, folder_name, s->sort_by, s->collate, s->uids, p->flag_cache, &ex2);
-
- if (camel_exception_is_set (&ex2) && camel_exception_get_description (&ex2) &&
- strstr (camel_exception_get_description (&ex2), "no such table") != NULL) {
+ if (local_error != NULL && local_error->message != NULL &&
+ strstr (local_error->message, "no such table") != NULL) {
/* create table the first time it is accessed and missing */
- ret = camel_db_prepare_message_info_table (cdb, folder_name, ex);
- } else if (ex) {
- camel_exception_xfer (ex, &ex2);
- }
-
- camel_exception_clear (&ex2);
+ ret = camel_db_prepare_message_info_table (cdb, folder_name, error);
+ } else if (local_error != NULL)
+ g_propagate_error (error, local_error);
/* camel_folder_summary_dump (s); */
@@ -1832,7 +1814,7 @@ camel_folder_summary_load_from_db (CamelFolderSummary *s, CamelException *ex)
data.summary = s;
data.add = TRUE;
data.double_ref = FALSE;
- ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer) &data, camel_read_mir_callback, ex);
+ ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer) &data, camel_read_mir_callback, error);
#endif
return ret == 0 ? 0 : -1;
@@ -2043,14 +2025,12 @@ camel_folder_summary_migrate_infos(CamelFolderSummary *s)
gint ret = 0;
CamelDB *cdb = s->folder->parent_store->cdb_w;
CamelFIRecord *record;
- CamelException ex;
/* Kick off the gc thread cycle. */
if (s->timeout_handle)
g_source_remove (s->timeout_handle);
s->timeout_handle = 0;
- camel_exception_init (&ex);
d(g_print ("\ncamel_folder_summary_load from FLAT FILE called \n"));
if (s->summary_path == NULL) {
@@ -2099,20 +2079,20 @@ camel_folder_summary_migrate_infos(CamelFolderSummary *s)
if (fclose (in) != 0)
return -1;
- record = CAMEL_FOLDER_SUMMARY_GET_CLASS (s)->summary_header_to_db (s, &ex);
+ record = CAMEL_FOLDER_SUMMARY_GET_CLASS (s)->summary_header_to_db (s, NULL);
if (!record) {
return -1;
}
- ret = save_message_infos_to_db (s, TRUE, &ex);
+ ret = save_message_infos_to_db (s, TRUE, NULL);
if (ret != 0) {
return -1;
}
- camel_db_begin_transaction (cdb, &ex);
- ret = camel_db_write_folder_info_record (cdb, record, &ex);
- camel_db_end_transaction (cdb, &ex);
+ camel_db_begin_transaction (cdb, NULL);
+ ret = camel_db_write_folder_info_record (cdb, record, NULL);
+ camel_db_end_transaction (cdb, NULL);
g_free (record->bdata);
g_free (record);
@@ -2182,7 +2162,7 @@ perform_content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentI
#endif
typedef struct {
- CamelException *ex;
+ GError **error;
gboolean migration;
gint progress;
} SaveToDBArgs;
@@ -2191,7 +2171,7 @@ static void
save_to_db_cb (gpointer key, gpointer value, gpointer data)
{
SaveToDBArgs *args = (SaveToDBArgs *) data;
- CamelException *ex = args->ex;
+ GError **error = args->error;
CamelMessageInfoBase *mi = (CamelMessageInfoBase *)value;
CamelFolderSummary *s = (CamelFolderSummary *)mi->summary;
gchar *folder_name = s->folder->full_name;
@@ -2213,20 +2193,20 @@ save_to_db_cb (gpointer key, gpointer value, gpointer data)
}
if (!args->migration) {
- if (camel_db_write_message_info_record (cdb, folder_name, mir, ex) != 0) {
+ if (camel_db_write_message_info_record (cdb, folder_name, mir, error) != 0) {
camel_db_camel_mir_free (mir);
return;
}
} else {
- if (camel_db_write_fresh_message_info_record (cdb, CAMEL_DB_IN_MEMORY_TABLE, mir, ex) != 0) {
+ if (camel_db_write_fresh_message_info_record (cdb, CAMEL_DB_IN_MEMORY_TABLE, mir, error) != 0) {
camel_db_camel_mir_free (mir);
return;
}
if (args->progress > CAMEL_DB_IN_MEMORY_TABLE_LIMIT) {
g_print ("BULK INsert limit reached \n");
- camel_db_flush_in_memory_transactions (cdb, folder_name, ex);
- camel_db_start_in_memory_transactions (cdb, ex);
+ camel_db_flush_in_memory_transactions (cdb, folder_name, error);
+ camel_db_start_in_memory_transactions (cdb, error);
args->progress = 0;
} else {
args->progress ++;
@@ -2242,18 +2222,20 @@ save_to_db_cb (gpointer key, gpointer value, gpointer data)
}
static gint
-save_message_infos_to_db (CamelFolderSummary *s, gboolean fresh_mirs, CamelException *ex)
+save_message_infos_to_db (CamelFolderSummary *s,
+ gboolean fresh_mirs,
+ GError **error)
{
CamelDB *cdb = s->folder->parent_store->cdb_w;
gchar *folder_name;
SaveToDBArgs args;
- args.ex = ex;
+ args.error = error;
args.migration = fresh_mirs;
args.progress = 0;
folder_name = s->folder->full_name;
- if (camel_db_prepare_message_info_table (cdb, folder_name, ex) != 0) {
+ if (camel_db_prepare_message_info_table (cdb, folder_name, error) != 0) {
return -1;
}
CAMEL_SUMMARY_LOCK(s, summary_lock);
@@ -2273,7 +2255,8 @@ msg_save_preview (const gchar *uid, gpointer value, CamelFolder *folder)
}
gint
-camel_folder_summary_save_to_db (CamelFolderSummary *s, CamelException *ex)
+camel_folder_summary_save_to_db (CamelFolderSummary *s,
+ GError **error)
{
CamelDB *cdb = s->folder->parent_store->cdb_w;
CamelFIRecord *record;
@@ -2296,63 +2279,67 @@ camel_folder_summary_save_to_db (CamelFolderSummary *s, CamelException *ex)
count = cfs_count_dirty(s);
if (!count)
- return camel_folder_summary_header_save_to_db (s, ex);
+ return camel_folder_summary_header_save_to_db (s, error);
dd(printf("Saving %d/%d dirty records of %s\n", count, g_hash_table_size (s->loaded_infos), s->folder->full_name));
- camel_db_begin_transaction (cdb, ex);
+ camel_db_begin_transaction (cdb, NULL);
- ret = save_message_infos_to_db (s, FALSE, ex);
+ ret = save_message_infos_to_db (s, FALSE, error);
if (ret != 0) {
- camel_db_abort_transaction (cdb, ex);
+ camel_db_abort_transaction (cdb, NULL);
/* Failed, so lets reset the flag */
s->flags |= CAMEL_SUMMARY_DIRTY;
return -1;
}
- if (ex && camel_exception_is_set (ex) && strstr (camel_exception_get_description (ex), "26 columns but 28 values") != NULL) {
+ /* XXX So... if an error is set, how do we even reach this point
+ * given the above error check? Oye vey is logic is nasty. */
+ if (error != NULL && *error != NULL &&
+ strstr ((*error)->message, "26 columns but 28 values") != NULL) {
/* This is an error is previous migration. Let remigrate this folder alone. */
- camel_db_abort_transaction (cdb, ex);
- camel_db_reset_folder_version (cdb, s->folder->full_name, 0, ex);
+ camel_db_abort_transaction (cdb, NULL);
+ camel_db_reset_folder_version (cdb, s->folder->full_name, 0, NULL);
g_warning ("Fixing up a broken summary migration on %s\n", s->folder->full_name);
/* Begin everything again. */
- camel_db_begin_transaction (cdb, ex);
+ camel_db_begin_transaction (cdb, NULL);
- ret = save_message_infos_to_db (s, FALSE, ex);
+ ret = save_message_infos_to_db (s, FALSE, error);
if (ret != 0) {
- camel_db_abort_transaction (cdb, ex);
+ camel_db_abort_transaction (cdb, NULL);
/* Failed, so lets reset the flag */
s->flags |= CAMEL_SUMMARY_DIRTY;
return -1;
}
}
- camel_db_end_transaction (cdb, ex);
+ camel_db_end_transaction (cdb, NULL);
- record = CAMEL_FOLDER_SUMMARY_GET_CLASS (s)->summary_header_to_db (s, ex);
+ record = CAMEL_FOLDER_SUMMARY_GET_CLASS (s)->summary_header_to_db (s, error);
if (!record) {
s->flags |= CAMEL_SUMMARY_DIRTY;
return -1;
}
- camel_db_begin_transaction (cdb, ex);
- ret = camel_db_write_folder_info_record (cdb, record, ex);
+ camel_db_begin_transaction (cdb, NULL);
+ ret = camel_db_write_folder_info_record (cdb, record, error);
g_free (record->bdata);
g_free (record);
if (ret != 0) {
- camel_db_abort_transaction (cdb, ex);
+ camel_db_abort_transaction (cdb, NULL);
s->flags |= CAMEL_SUMMARY_DIRTY;
return -1;
}
- camel_db_end_transaction (cdb, ex);
+ camel_db_end_transaction (cdb, NULL);
return ret;
}
gint
-camel_folder_summary_header_save_to_db (CamelFolderSummary *s, CamelException *ex)
+camel_folder_summary_header_save_to_db (CamelFolderSummary *s,
+ GError **error)
{
CamelDB *cdb = s->folder->parent_store->cdb_w;
CamelFIRecord *record;
@@ -2360,22 +2347,22 @@ camel_folder_summary_header_save_to_db (CamelFolderSummary *s, CamelException *e
d(printf ("\ncamel_folder_summary_header_save_to_db called \n"));
- record = CAMEL_FOLDER_SUMMARY_GET_CLASS (s)->summary_header_to_db (s, ex);
+ record = CAMEL_FOLDER_SUMMARY_GET_CLASS (s)->summary_header_to_db (s, error);
if (!record) {
return -1;
}
- camel_db_begin_transaction (cdb, ex);
- ret = camel_db_write_folder_info_record (cdb, record, ex);
+ camel_db_begin_transaction (cdb, NULL);
+ ret = camel_db_write_folder_info_record (cdb, record, error);
g_free (record->bdata);
g_free (record);
if (ret != 0) {
- camel_db_abort_transaction (cdb, ex);
+ camel_db_abort_transaction (cdb, NULL);
return -1;
}
- camel_db_end_transaction (cdb, ex);
+ camel_db_end_transaction (cdb, NULL);
return ret;
}
@@ -2523,7 +2510,10 @@ exception:
}
gint
-camel_folder_summary_header_load_from_db (CamelFolderSummary *s, CamelStore *store, const gchar *folder_name, CamelException *ex)
+camel_folder_summary_header_load_from_db (CamelFolderSummary *s,
+ CamelStore *store,
+ const gchar *folder_name,
+ GError **error)
{
CamelDB *cdb;
CamelFIRecord *record;
@@ -2535,7 +2525,7 @@ camel_folder_summary_header_load_from_db (CamelFolderSummary *s, CamelStore *sto
cdb = store->cdb_r;
record = g_new0 (CamelFIRecord, 1);
- camel_db_read_folder_info_record (cdb, folder_name, &record, ex);
+ camel_db_read_folder_info_record (cdb, folder_name, &record, error);
if (record) {
if (CAMEL_FOLDER_SUMMARY_GET_CLASS (s)->summary_header_from_db (s, record) == -1)
@@ -3250,7 +3240,6 @@ camel_folder_summary_remove_range (CamelFolderSummary *s, gint start, gint end)
gint i;
CamelDB *cdb;
- CamelException ex; /* May be this should come from the caller */
gchar *folder_name;
GSList *uids = NULL;
@@ -3268,7 +3257,6 @@ camel_folder_summary_remove_range (CamelFolderSummary *s, gint start, gint end)
g_hash_table_remove (s->loaded_infos, uid);
}
}
- camel_exception_init (&ex);
folder_name = s->folder->full_name;
cdb = s->folder->parent_store->cdb_w;
@@ -3277,7 +3265,7 @@ camel_folder_summary_remove_range (CamelFolderSummary *s, gint start, gint end)
* Add should add to db and del should del to db. Sync only
* the changes at interval and remove those full sync on
* folder switch */
- camel_db_delete_uids (cdb, folder_name, uids, &ex);
+ camel_db_delete_uids (cdb, folder_name, uids, NULL);
g_slist_foreach (uids, (GFunc) camel_pstring_free, NULL);
g_slist_free (uids);
@@ -3288,8 +3276,6 @@ camel_folder_summary_remove_range (CamelFolderSummary *s, gint start, gint end)
s->flags |= CAMEL_SUMMARY_DIRTY;
CAMEL_SUMMARY_UNLOCK(s, summary_lock);
-
- camel_exception_clear (&ex);
} else {
CAMEL_SUMMARY_UNLOCK(s, summary_lock);
}
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index 530b990..e35a046 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -289,7 +289,7 @@ struct _CamelFolderSummaryClass {
/* Load/Save folder summary from DB*/
gint (*summary_header_from_db)(CamelFolderSummary *, struct _CamelFIRecord *);
- struct _CamelFIRecord * (*summary_header_to_db)(CamelFolderSummary *, CamelException *ex);
+ struct _CamelFIRecord * (*summary_header_to_db)(CamelFolderSummary *, GError **error);
CamelMessageInfo * (*message_info_from_db) (CamelFolderSummary *, struct _CamelMIRecord*);
struct _CamelMIRecord * (*message_info_to_db) (CamelFolderSummary *, CamelMessageInfo *);
CamelMessageContentInfo * (*content_info_from_db) (CamelFolderSummary *, struct _CamelMIRecord *);
@@ -364,13 +364,13 @@ gint camel_folder_summary_load(CamelFolderSummary *summary);
gint camel_folder_summary_save(CamelFolderSummary *summary);
/* load/save the full summary from/to the db */
-gint camel_folder_summary_save_to_db (CamelFolderSummary *s, CamelException *ex);
-gint camel_folder_summary_load_from_db (CamelFolderSummary *s, CamelException *ex);
+gint camel_folder_summary_save_to_db (CamelFolderSummary *s, GError **error);
+gint camel_folder_summary_load_from_db (CamelFolderSummary *s, GError **error);
/* only load the header */
gint camel_folder_summary_header_load(CamelFolderSummary *summary);
-gint camel_folder_summary_header_load_from_db (CamelFolderSummary *s, struct _CamelStore *store, const gchar *folder_name, CamelException *ex);
-gint camel_folder_summary_header_save_to_db (CamelFolderSummary *s, CamelException *ex);
+gint camel_folder_summary_header_load_from_db (CamelFolderSummary *s, struct _CamelStore *store, const gchar *folder_name, GError **error);
+gint camel_folder_summary_header_save_to_db (CamelFolderSummary *s, GError **error);
/* set the dirty bit on the summary */
void camel_folder_summary_touch(CamelFolderSummary *summary);
@@ -386,9 +386,9 @@ GPtrArray * camel_folder_summary_get_changed (CamelFolderSummary *s);
/* Gets the size of loaded mi's */
gint camel_folder_summary_cache_size (CamelFolderSummary *s);
/* reload the summary at any required point if required */
-gint camel_folder_summary_reload_from_db (CamelFolderSummary *s, CamelException *ex);
+gint camel_folder_summary_reload_from_db (CamelFolderSummary *s, GError **error);
/* ensures all CamelMessagesInfos loaded in memory */
-void camel_folder_summary_ensure_infos_loaded (CamelFolderSummary *s, gint at_least, CamelException *ex);
+void camel_folder_summary_ensure_infos_loaded (CamelFolderSummary *s, gint at_least, GError **error);
/* insert mi to summary */
void camel_folder_summary_insert (CamelFolderSummary *s, CamelMessageInfo *info, gboolean load);
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 72433e3..8a346a4 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -34,7 +34,6 @@
#include "camel-db.h"
#include "camel-debug.h"
-#include "camel-exception.h"
#include "camel-filter-driver.h"
#include "camel-folder.h"
#include "camel-mime-message.h"
@@ -54,10 +53,7 @@
static gpointer parent_class;
-static void refresh_info (CamelFolder *folder, CamelException *ex);
-
-static void folder_sync (CamelFolder *folder, gboolean expunge,
- CamelException *ex);
+static gboolean refresh_info (CamelFolder *folder, GError **error);
static const gchar *get_name (CamelFolder *folder);
static const gchar *get_full_name (CamelFolder *folder);
@@ -73,17 +69,11 @@ static void set_message_user_tag (CamelFolder *folder, const gchar *uid, const g
static gint get_message_count (CamelFolder *folder);
-static void expunge (CamelFolder *folder,
- CamelException *ex);
-static gint folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static gint folder_getv (CamelObject *object, GError **error, CamelArgGetV *args);
static void folder_free (CamelObject *o, guint32 tag, gpointer val);
-static void append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex);
-
static GPtrArray *get_uids (CamelFolder *folder);
-static GPtrArray *get_uncached_uids (CamelFolder *, GPtrArray * uids, CamelException *);
+static GPtrArray *get_uncached_uids (CamelFolder *, GPtrArray * uids, GError **);
static void free_uids (CamelFolder *folder,
GPtrArray *array);
static gint cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2);
@@ -93,20 +83,14 @@ static GPtrArray *get_summary (CamelFolder *folder);
static void free_summary (CamelFolder *folder,
GPtrArray *array);
-static CamelMimeMessage *get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
-
static CamelMessageInfo *get_message_info (CamelFolder *folder, const gchar *uid);
static void free_message_info (CamelFolder *folder, CamelMessageInfo *info);
static void ref_message_info (CamelFolder *folder, CamelMessageInfo *info);
-static GPtrArray *search_by_expression (CamelFolder *folder, const gchar *exp, CamelException *ex);
-static guint32 count_by_expression (CamelFolder *folder, const gchar *exp, CamelException *ex);
-
-static GPtrArray *search_by_uids (CamelFolder *folder, const gchar *exp, GPtrArray *uids, CamelException *ex);
static void search_free (CamelFolder * folder, GPtrArray *result);
-static void transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest,
- GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
+static gboolean transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest,
+ GPtrArray **transferred_uids, gboolean delete_originals, GError **error);
static void delete (CamelFolder *folder);
static void folder_rename (CamelFolder *folder, const gchar *new);
@@ -118,10 +102,6 @@ static gboolean is_frozen (CamelFolder *folder);
static gboolean folder_changed (CamelObject *object,
gpointer event_data);
-static gchar * get_filename (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex);
-
static CamelFolderQuotaInfo *get_quota_info (CamelFolder *folder);
static void
@@ -185,14 +165,11 @@ folder_class_init (CamelFolderClass *class)
camel_object_class->getv = folder_getv;
camel_object_class->free = folder_free;
- class->sync = folder_sync;
class->refresh_info = refresh_info;
class->get_name = get_name;
class->get_full_name = get_full_name;
class->get_parent_store = get_parent_store;
- class->expunge = expunge;
class->get_message_count = get_message_count;
- class->append_message = append_message;
class->get_permanent_flags = get_permanent_flags;
class->get_message_flags = get_message_flags;
class->set_message_flags = set_message_flags;
@@ -200,7 +177,6 @@ folder_class_init (CamelFolderClass *class)
class->set_message_user_flag = set_message_user_flag;
class->get_message_user_tag = get_message_user_tag;
class->set_message_user_tag = set_message_user_tag;
- class->get_message = get_message;
class->get_uids = get_uids;
class->get_uncached_uids = get_uncached_uids;
class->free_uids = free_uids;
@@ -208,9 +184,6 @@ folder_class_init (CamelFolderClass *class)
class->sort_uids = sort_uids;
class->get_summary = get_summary;
class->free_summary = free_summary;
- class->search_by_expression = search_by_expression;
- class->count_by_expression = count_by_expression;
- class->search_by_uids = search_by_uids;
class->search_free = search_free;
class->get_message_info = get_message_info;
class->ref_message_info = ref_message_info;
@@ -223,7 +196,6 @@ folder_class_init (CamelFolderClass *class)
class->thaw = thaw;
class->is_frozen = is_frozen;
class->get_quota_info = get_quota_info;
- class->get_filename = get_filename;
camel_object_class_add_event (
camel_object_class, "folder_changed", folder_changed);
@@ -263,18 +235,23 @@ camel_folder_get_type (void)
return type;
}
-static gchar *
-get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+GQuark
+camel_folder_error_quark (void)
{
- w (g_warning ("CamelFolder::get_filename not implemented for '%s'",
- camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
- return g_strdup ("/dev/null");
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0)) {
+ const gchar *string = "camel-folder-error-quark";
+ quark = g_quark_from_static_string (string);
+ }
+
+ return quark;
}
gchar *
camel_folder_get_filename (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
@@ -283,7 +260,7 @@ camel_folder_get_filename (CamelFolder *folder,
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->get_filename != NULL, NULL);
- return class->get_filename (folder, uid, ex);
+ return class->get_filename (folder, uid, error);
}
/**
@@ -312,75 +289,81 @@ camel_folder_construct (CamelFolder *folder, CamelStore *parent_store,
folder->full_name = g_strdup (full_name);
}
-static void
-folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
-{
- w (g_warning ("CamelFolder::sync not implemented for '%s'",
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder))));
-}
-
/**
* camel_folder_sync:
* @folder: a #CamelFolder object
* @expunge: whether or not to expunge deleted messages
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Sync changes made to a folder to its backing store, possibly
* expunging deleted messages as well.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_folder_sync (CamelFolder *folder,
gboolean expunge,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ gboolean success = TRUE;
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
class = CAMEL_FOLDER_GET_CLASS (folder);
- g_return_if_fail (class->sync != NULL);
+ g_return_val_if_fail (class->sync != NULL, FALSE);
CAMEL_FOLDER_REC_LOCK (folder, lock);
if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
- class->sync (folder, expunge, ex);
+ success = class->sync (folder, expunge, error);
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+
+ return success;
}
-static void
-refresh_info (CamelFolder *folder, CamelException *ex)
+static gboolean
+refresh_info (CamelFolder *folder,
+ GError **error)
{
- /* No op */
+ return TRUE;
}
/**
* camel_folder_refresh_info:
* @folder: a #CamelFolder object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Updates a folder's summary to be in sync with its backing store.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_folder_refresh_info (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ gboolean success;
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
class = CAMEL_FOLDER_GET_CLASS (folder);
- g_return_if_fail (class->refresh_info != NULL);
+ g_return_val_if_fail (class->refresh_info != NULL, FALSE);
CAMEL_FOLDER_REC_LOCK (folder, lock);
- class->refresh_info (folder, ex);
+ success = class->refresh_info (folder, error);
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+
+ return success;
}
static gint
-folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
+folder_getv (CamelObject *object,
+ GError **error,
+ CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
gint i;
@@ -521,7 +504,7 @@ folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
- return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
+ return CAMEL_OBJECT_CLASS (parent_class)->getv (object, error, args);
}
static void
@@ -629,37 +612,35 @@ camel_folder_get_parent_store (CamelFolder *folder)
return class->get_parent_store (folder);
}
-static void
-expunge (CamelFolder *folder, CamelException *ex)
-{
- w (g_warning ("CamelFolder::expunge not implemented for '%s'",
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder))));
-}
-
/**
* camel_folder_expunge:
* @folder: a #CamelFolder object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Delete messages which have been marked as "DELETED"
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_folder_expunge (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ gboolean success = TRUE;
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
class = CAMEL_FOLDER_GET_CLASS (folder);
- g_return_if_fail (class->expunge != NULL);
+ g_return_val_if_fail (class->expunge != NULL, FALSE);
CAMEL_FOLDER_REC_LOCK (folder, lock);
if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
- class->expunge (folder, ex);
+ success = class->expunge (folder, error);
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+
+ return success;
}
static gint
@@ -729,22 +710,6 @@ camel_folder_get_deleted_message_count (CamelFolder *folder)
return count;
}
-static void
-append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
-{
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("Unsupported operation: append message: for %s"),
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder)));
-
- w (g_warning ("CamelFolder::append_message not implemented for '%s'",
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder))));
-
- return;
-
-}
-
/**
* camel_folder_append_message:
* @folder: a #CamelFolder object
@@ -753,30 +718,36 @@ append_message (CamelFolder *folder, CamelMimeMessage *message,
* new message, or %NULL
* @appended_uid: if non-%NULL, the UID of the appended message will
* be returned here, if it is known.
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Append @message to @folder. Only the flag and tag data from @info
* are used. If @info is %NULL, no flags or tags will be set.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_folder_append_message (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ gboolean success;
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
class = CAMEL_FOLDER_GET_CLASS (folder);
- g_return_if_fail (class->append_message != NULL);
+ g_return_val_if_fail (class->append_message != NULL, FALSE);
CAMEL_FOLDER_REC_LOCK (folder, lock);
- class->append_message (folder, message, info, appended_uid, ex);
+ success = class->append_message (
+ folder, message, info, appended_uid, error);
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+
+ return success;
}
static guint32
@@ -1213,27 +1184,20 @@ camel_folder_has_summary_capability (CamelFolder *folder)
/* UIDs stuff */
-static CamelMimeMessage *
-get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
- w (g_warning ("CamelFolder::get_message not implemented for '%s'",
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder))));
-
- return NULL;
-}
-
/**
* camel_folder_get_message:
* @folder: a #CamelFolder object
* @uid: the UID
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Get a message from its UID in the folder.
*
* Returns: a #CamelMimeMessage corresponding to @uid
**/
CamelMimeMessage *
-camel_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+camel_folder_get_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelMimeMessage *ret;
@@ -1241,7 +1205,7 @@ camel_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException
CAMEL_FOLDER_REC_LOCK (folder, lock);
- ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message (folder, uid, ex);
+ ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message (folder, uid, error);
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
@@ -1258,21 +1222,22 @@ camel_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException
* camel_folder_sync_message:
* @folder: a #CamelFolder object
* @uid: the UID
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Ensure that a message identified by UID has been synced in the folder (so
* that camel_folder_get_message on it later will work in offline mode).
*
- * Returns: void.
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_folder_sync_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ gboolean success = FALSE;
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
class = CAMEL_FOLDER_GET_CLASS (folder);
@@ -1280,15 +1245,19 @@ camel_folder_sync_message (CamelFolder *folder,
/* Use the sync_message method if the class implements it. */
if (class->sync_message != NULL)
- class->sync_message (folder, uid, ex);
+ success = class->sync_message (folder, uid, error);
else {
CamelMimeMessage *message;
- message = class->get_message (folder, uid, ex);
- if (message != NULL)
- g_object_unref (message);
+ message = class->get_message (folder, uid, error);
+ if (message != NULL) {
+ g_object_unref (message);
+ success = TRUE;
+ }
}
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+
+ return success;
}
static GPtrArray *
@@ -1360,7 +1329,9 @@ camel_folder_free_uids (CamelFolder *folder,
* Default: return the uids we are given.
*/
static GPtrArray *
-get_uncached_uids (CamelFolder *folder, GPtrArray * uids, CamelException *ex)
+get_uncached_uids (CamelFolder *folder,
+ GPtrArray * uids,
+ GError **error)
{
GPtrArray *result;
gint i;
@@ -1386,7 +1357,7 @@ get_uncached_uids (CamelFolder *folder, GPtrArray * uids, CamelException *ex)
GPtrArray *
camel_folder_get_uncached_uids (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
@@ -1396,7 +1367,7 @@ camel_folder_get_uncached_uids (CamelFolder *folder,
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->get_uncached_uids != NULL, NULL);
- return class->get_uncached_uids (folder, uids, ex);
+ return class->get_uncached_uids (folder, uids, error);
}
static gint
@@ -1552,25 +1523,11 @@ camel_folder_has_search_capability (CamelFolder *folder)
return folder->folder_flags & CAMEL_FOLDER_HAS_SEARCH_CAPABILITY;
}
-static GPtrArray *
-search_by_expression (CamelFolder *folder, const gchar *expression,
- CamelException *ex)
-{
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("Unsupported operation: search by expression: for %s"),
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder)));
-
- w (g_warning ("CamelFolder::search_by_expression not implemented for "
- "'%s'", G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder))));
-
- return NULL;
-}
-
/**
* camel_folder_search_by_expression:
* @folder: a #CamelFolder object
* @expr: a search expression
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Searches the folder for messages matching the given search expression.
*
@@ -1580,7 +1537,7 @@ search_by_expression (CamelFolder *folder, const gchar *expression,
GPtrArray *
camel_folder_search_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
@@ -1592,28 +1549,14 @@ camel_folder_search_by_expression (CamelFolder *folder,
/* NOTE: that it is upto the callee to lock */
- return class->search_by_expression (folder, expression, ex);
-}
-
-static guint32
-count_by_expression (CamelFolder *folder, const gchar *expression,
- CamelException *ex)
-{
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("Unsupported operation: count by expression: for %s"),
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder)));
-
- w (g_warning ("CamelFolder::count_by_expression not implemented for "
- "'%s'", G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder))));
-
- return 0;
+ return class->search_by_expression (folder, expression, error);
}
/**
* camel_folder_count_by_expression:
* @folder: a #CamelFolder object
* @expr: a search expression
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Searches the folder for count of messages matching the given search expression.
*
@@ -1622,7 +1565,7 @@ count_by_expression (CamelFolder *folder, const gchar *expression,
guint32
camel_folder_count_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
@@ -1634,20 +1577,7 @@ camel_folder_count_by_expression (CamelFolder *folder,
/* NOTE: that it is upto the callee to lock */
- return class->count_by_expression (folder, expression, ex);
-}
-
-static GPtrArray *
-search_by_uids (CamelFolder *folder, const gchar *exp, GPtrArray *uids, CamelException *ex)
-{
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("Unsupported operation: search by UIDs: for %s"),
- G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder)));
-
- w (g_warning ("CamelFolder::search_by_expression not implemented for "
- "'%s'", G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (folder))));
-
- return NULL;
+ return class->count_by_expression (folder, expression, error);
}
/**
@@ -1655,7 +1585,7 @@ search_by_uids (CamelFolder *folder, const gchar *exp, GPtrArray *uids, CamelExc
* @folder: a #CamelFolder object
* @expr: search expression
* @uids: array of uid's to match against.
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Search a subset of uid's for an expression match.
*
@@ -1666,7 +1596,7 @@ GPtrArray *
camel_folder_search_by_uids (CamelFolder *folder,
const gchar *expr,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
@@ -1678,7 +1608,7 @@ camel_folder_search_by_uids (CamelFolder *folder,
/* NOTE: that it is upto the callee to lock */
- return class->search_by_uids (folder, expr, uids, ex);
+ return class->search_by_uids (folder, expr, uids, error);
}
static void
@@ -1717,16 +1647,20 @@ camel_folder_search_free (CamelFolder *folder,
}
static void
-transfer_message_to (CamelFolder *source, const gchar *uid, CamelFolder *dest,
- gchar **transferred_uid, gboolean delete_original,
- CamelException *ex)
+transfer_message_to (CamelFolder *source,
+ const gchar *uid,
+ CamelFolder *dest,
+ gchar **transferred_uid,
+ gboolean delete_original,
+ GError **error)
{
CamelMimeMessage *msg;
CamelMessageInfo *minfo, *info;
+ GError *local_error = NULL;
/* Default implementation. */
- msg = camel_folder_get_message (source, uid, ex);
+ msg = camel_folder_get_message (source, uid, error);
if (!msg)
return;
@@ -1747,44 +1681,57 @@ transfer_message_to (CamelFolder *source, const gchar *uid, CamelFolder *dest,
/* we don't want to retain the deleted flag */
camel_message_info_set_flags (info, CAMEL_MESSAGE_DELETED, 0);
- camel_folder_append_message (dest, msg, info, transferred_uid, ex);
+ camel_folder_append_message (
+ dest, msg, info, transferred_uid, &local_error);
g_object_unref (msg);
- if (delete_original && !camel_exception_is_set (ex))
- camel_folder_set_message_flags (source, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, ~0);
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
+ else if (delete_original)
+ camel_folder_set_message_flags (
+ source, uid, CAMEL_MESSAGE_DELETED |
+ CAMEL_MESSAGE_SEEN, ~0);
camel_message_info_free (info);
}
-static void
-transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex)
+static gboolean
+transfer_messages_to (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error)
{
- CamelException local;
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);
}
- camel_exception_init (&local);
- if (ex == NULL)
- ex = &local;
-
- camel_operation_start (NULL, delete_originals ? _("Moving messages") : _("Copying messages"));
+ if (delete_originals)
+ camel_operation_start (NULL, _("Moving messages"));
+ else
+ camel_operation_start (NULL, _("Copying messages"));
if (uids->len > 1) {
camel_folder_freeze (dest);
if (delete_originals)
camel_folder_freeze (source);
}
- for (i = 0; i < uids->len && !camel_exception_is_set (ex); i++) {
+
+ for (i = 0; i < uids->len && local_error != NULL; i++) {
if (transferred_uids)
ret_uid = (gchar **)&((*transferred_uids)->pdata[i]);
- transfer_message_to (source, uids->pdata[i], dest, ret_uid, delete_originals, ex);
+ transfer_message_to (
+ source, uids->pdata[i], dest, ret_uid,
+ delete_originals, &local_error);
camel_operation_progress (NULL, i * 100 / uids->len);
}
+
if (uids->len > 1) {
camel_folder_thaw (dest);
if (delete_originals)
@@ -1792,7 +1739,11 @@ transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, G
}
camel_operation_end (NULL);
- camel_exception_clear (&local);
+
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
+
+ return TRUE;
}
/**
@@ -1803,29 +1754,32 @@ transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, G
* @transferred_uids: if non-%NULL, the UIDs of the resulting messages
* in @dest will be stored here, if known.
* @delete_originals: whether or not to delete the original messages
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This copies or moves messages from one folder to another. If the
* @source and @dest folders have the same parent_store, this may be
* more efficient than using #camel_folder_append_message.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_folder_transfer_messages_to (CamelFolder *source,
GPtrArray *uids,
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ gboolean success;
- g_return_if_fail (CAMEL_IS_FOLDER (source));
- g_return_if_fail (uids != NULL);
- g_return_if_fail (CAMEL_IS_FOLDER (dest));
+ g_return_val_if_fail (CAMEL_IS_FOLDER (source), FALSE);
+ g_return_val_if_fail (uids != NULL, FALSE);
+ g_return_val_if_fail (CAMEL_IS_FOLDER (dest), FALSE);
if (source == dest || uids->len == 0) {
/* source and destination folders are the same, or no work to do, do nothing. */
- return;
+ return TRUE;
}
if (source->parent_store == dest->parent_store) {
@@ -1836,13 +1790,15 @@ camel_folder_transfer_messages_to (CamelFolder *source,
class = CAMEL_FOLDER_GET_CLASS (dest);
else
class = CAMEL_FOLDER_GET_CLASS (source);
- class->transfer_messages_to (
+ success = class->transfer_messages_to (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
} else
- transfer_messages_to (
+ success = transfer_messages_to (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
+
+ return success;
}
static void
@@ -2142,7 +2098,7 @@ struct _folder_filter_msg {
GPtrArray *notjunk;
CamelFolder *folder;
CamelFilterDriver *driver;
- CamelException ex;
+ GError *error;
};
static void
@@ -2153,8 +2109,8 @@ filter_filter (CamelSession *session, CamelSessionThreadMsg *tmsg)
gint i, status = 0;
CamelURL *uri;
gchar *source_url;
- CamelException ex;
CamelJunkPlugin *csp = ((CamelService *)m->folder->parent_store)->session->junk_plugin;
+ GError *local_error = NULL;
if (m->junk) {
camel_operation_start (NULL, _("Learning junk"));
@@ -2220,15 +2176,18 @@ filter_filter (CamelSession *session, CamelSessionThreadMsg *tmsg)
continue;
}
- status = camel_filter_driver_filter_message (m->driver, NULL, info, uid, m->folder, source_url, source_url, &m->ex);
+ status = camel_filter_driver_filter_message (m->driver, NULL, info, uid, m->folder, source_url, source_url, &local_error);
camel_folder_free_message_info (m->folder, info);
}
- camel_exception_init (&ex);
- camel_filter_driver_flush (m->driver, &ex);
- if (!camel_exception_is_set (&m->ex))
- camel_exception_xfer (&m->ex, &ex);
+ if (local_error == NULL)
+ camel_filter_driver_flush (m->driver, &local_error);
+ else
+ camel_filter_driver_flush (m->driver, NULL);
+
+ if (local_error != NULL)
+ g_propagate_error (&m->error, local_error);
g_free (source_url);
@@ -2250,7 +2209,7 @@ filter_free (CamelSession *session, CamelSessionThreadMsg *msg)
if (m->notjunk)
camel_folder_free_deep (m->folder, m->notjunk);
- camel_folder_summary_save_to_db (m->folder->summary, &m->ex);
+ camel_folder_summary_save_to_db (m->folder->summary, &m->error);
camel_folder_thaw (m->folder);
g_object_unref (m->folder);
}
@@ -2356,7 +2315,7 @@ folder_changed (CamelObject *obj, gpointer event_data)
camel_folder_change_info_cat (folder->priv->changed_frozen, changed);
CAMEL_FOLDER_UNLOCK (folder, change_lock);
msg->driver = driver;
- camel_exception_init (&msg->ex);
+ msg->error = NULL;
camel_session_thread_queue (session, &msg->msg, 0);
return FALSE;
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index cfcf9d5..3756863 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -51,6 +51,9 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_FOLDER, CamelFolderClass))
+#define CAMEL_FOLDER_ERROR \
+ (camel_folder_error_quark ())
+
G_BEGIN_DECLS
struct _CamelStore;
@@ -62,6 +65,17 @@ typedef struct _CamelFolder CamelFolder;
typedef struct _CamelFolderClass CamelFolderClass;
typedef struct _CamelFolderPrivate CamelFolderPrivate;
+typedef enum {
+ CAMEL_FOLDER_ERROR_INVALID,
+ CAMEL_FOLDER_ERROR_INVALID_STATE,
+ CAMEL_FOLDER_ERROR_NON_EMPTY,
+ CAMEL_FOLDER_ERROR_NON_UID,
+ CAMEL_FOLDER_ERROR_INSUFFICIENT_PERMISSION,
+ CAMEL_FOLDER_ERROR_INVALID_PATH,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ CAMEL_FOLDER_ERROR_SUMMARY_INVALID
+} CamelFolderError;
+
enum {
CAMEL_FOLDER_ARG_FIRST = CAMEL_ARG_FIRST + 0x1000,
CAMEL_FOLDER_ARG_NAME = CAMEL_FOLDER_ARG_FIRST,
@@ -148,259 +162,320 @@ struct _CamelFolder {
struct _CamelFolderClass {
CamelObjectClass parent_class;
- /* Virtual methods */
- void (*refresh_info) (CamelFolder *folder, CamelException *ex);
-
- void (*sync) (CamelFolder *folder, gboolean expunge,
- CamelException *ex);
-
- const gchar * (*get_name) (CamelFolder *folder);
- const gchar * (*get_full_name) (CamelFolder *folder);
-
- struct _CamelStore * (*get_parent_store) (CamelFolder *folder);
-
- void (*expunge) (CamelFolder *folder,
- CamelException *ex);
-
- gint (*get_message_count) (CamelFolder *folder);
-
- void (*append_message) (CamelFolder *folder,
- CamelMimeMessage *message,
- const CamelMessageInfo *info,
- gchar **appended_uid,
- CamelException *ex);
-
- guint32 (*get_permanent_flags) (CamelFolder *folder);
- guint32 (*get_message_flags) (CamelFolder *folder,
- const gchar *uid);
- gboolean (*set_message_flags) (CamelFolder *folder,
- const gchar *uid,
- guint32 flags, guint32 set);
-
- gboolean (*get_message_user_flag) (CamelFolder *folder,
- const gchar *uid,
- const gchar *name);
- void (*set_message_user_flag) (CamelFolder *folder,
- const gchar *uid,
- const gchar *name,
- gboolean value);
-
- const gchar * (*get_message_user_tag) (CamelFolder *folder,
- const gchar *uid,
- const gchar *name);
- void (*set_message_user_tag) (CamelFolder *folder,
- const gchar *uid,
- const gchar *name,
- const gchar *value);
-
- CamelMimeMessage * (*get_message) (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex);
-
- GPtrArray * (*get_uids) (CamelFolder *folder);
- void (*free_uids) (CamelFolder *folder,
- GPtrArray *array);
-
- gint (* cmp_uids) (CamelFolder *folder, const gchar *uid1, const gchar *uid2);
- void (* sort_uids) (CamelFolder *folder, GPtrArray *uids);
-
- GPtrArray * (*get_summary) (CamelFolder *folder);
- void (*free_summary) (CamelFolder *folder,
- GPtrArray *summary);
-
- gboolean (*has_search_capability) (CamelFolder *folder);
-
- GPtrArray * (*search_by_expression) (CamelFolder *, const gchar *, CamelException *);
- GPtrArray * (*search_by_uids) (CamelFolder *, const gchar *, GPtrArray *uids, CamelException *);
-
- void (*search_free) (CamelFolder *folder, GPtrArray *result);
-
- CamelMessageInfo * (*get_message_info) (CamelFolder *, const gchar *uid);
- void (*ref_message_info) (CamelFolder *, CamelMessageInfo *);
- void (*free_message_info) (CamelFolder *, CamelMessageInfo *);
-
- void (*transfer_messages_to) (CamelFolder *source,
- GPtrArray *uids,
- CamelFolder *destination,
- GPtrArray **transferred_uids,
- gboolean delete_originals,
- CamelException *ex);
-
- void (*delete) (CamelFolder *folder);
- void (*rename) (CamelFolder *folder, const gchar *newname);
-
- void (*freeze) (CamelFolder *folder);
- void (*thaw) (CamelFolder *folder);
- gboolean (*is_frozen) (CamelFolder *folder);
-
- CamelFolderQuotaInfo * (*get_quota_info) (CamelFolder *folder);
- guint32 (*count_by_expression) (CamelFolder *, const gchar *, CamelException *);
- void (*sync_message) (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex);
- GPtrArray * (*get_uncached_uids)(CamelFolder *, GPtrArray * uids, CamelException *);
- gchar * (*get_filename) (CamelFolder *, const gchar *uid, CamelException *);
+ gboolean (*refresh_info) (CamelFolder *folder,
+ GError **error);
+ gboolean (*sync) (CamelFolder *folder,
+ gboolean expunge,
+ GError **error);
+ const gchar * (*get_name) (CamelFolder *folder);
+ const gchar * (*get_full_name) (CamelFolder *folder);
+ struct _CamelStore *
+ (*get_parent_store) (CamelFolder *folder);
+ gboolean (*expunge) (CamelFolder *folder,
+ GError **error);
+ gint (*get_message_count) (CamelFolder *folder);
+ gboolean (*append_message) (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error);
+ guint32 (*get_permanent_flags) (CamelFolder *folder);
+ guint32 (*get_message_flags) (CamelFolder *folder,
+ const gchar *uid);
+ gboolean (*set_message_flags) (CamelFolder *folder,
+ const gchar *uid,
+ guint32 flags, guint32 set);
+ gboolean (*get_message_user_flag)(CamelFolder *folder,
+ const gchar *uid,
+ const gchar *name);
+ void (*set_message_user_flag)(CamelFolder *folder,
+ const gchar *uid,
+ const gchar *name,
+ gboolean value);
+ const gchar * (*get_message_user_tag) (CamelFolder *folder,
+ const gchar *uid,
+ const gchar *name);
+ void (*set_message_user_tag) (CamelFolder *folder,
+ const gchar *uid,
+ const gchar *name,
+ const gchar *value);
+ CamelMimeMessage *
+ (*get_message) (CamelFolder *folder,
+ const gchar *uid,
+ GError **error);
+ GPtrArray * (*get_uids) (CamelFolder *folder);
+ void (*free_uids) (CamelFolder *folder,
+ GPtrArray *array);
+ gint (*cmp_uids) (CamelFolder *folder,
+ const gchar *uid1,
+ const gchar *uid2);
+ void (*sort_uids) (CamelFolder *folder,
+ GPtrArray *uids);
+ GPtrArray * (*get_summary) (CamelFolder *folder);
+ void (*free_summary) (CamelFolder *folder,
+ GPtrArray *summary);
+ gboolean (*has_search_capability)(CamelFolder *folder);
+ GPtrArray * (*search_by_expression) (CamelFolder *folder,
+ const gchar *expression,
+ GError **error);
+ GPtrArray * (*search_by_uids) (CamelFolder *folder,
+ const gchar *expression,
+ GPtrArray *uids,
+ GError **error);
+ void (*search_free) (CamelFolder *folder,
+ GPtrArray *result);
+ CamelMessageInfo *
+ (*get_message_info) (CamelFolder *folder,
+ const gchar *uid);
+ void (*ref_message_info) (CamelFolder *folder,
+ 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,
+ GError **error);
+ void (*delete) (CamelFolder *folder);
+ void (*rename) (CamelFolder *folder,
+ const gchar *newname);
+ void (*freeze) (CamelFolder *folder);
+ void (*thaw) (CamelFolder *folder);
+ gboolean (*is_frozen) (CamelFolder *folder);
+ CamelFolderQuotaInfo *
+ (*get_quota_info) (CamelFolder *folder);
+ guint32 (*count_by_expression) (CamelFolder *folder,
+ const gchar *expression,
+ GError **error);
+ gboolean (*sync_message) (CamelFolder *folder,
+ const gchar *uid,
+ GError **error);
+ GPtrArray * (*get_uncached_uids) (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error);
+ gchar * (*get_filename) (CamelFolder *folder,
+ const gchar *uid,
+ GError **error);
};
-GType camel_folder_get_type (void);
+GType camel_folder_get_type (void);
+GQuark camel_folder_error_quark (void) G_GNUC_CONST;
/* public methods */
-void camel_folder_construct (CamelFolder *folder,
- struct _CamelStore *parent_store,
- const gchar *full_name,
- const gchar *name);
+void camel_folder_construct (CamelFolder *folder,
+ struct _CamelStore *parent_store,
+ const gchar *full_name,
+ const gchar *name);
-void camel_folder_refresh_info (CamelFolder *folder,
- CamelException *ex);
-void camel_folder_sync (CamelFolder *folder,
- gboolean expunge,
- CamelException *ex);
+gboolean camel_folder_refresh_info (CamelFolder *folder,
+ GError **error);
+gboolean camel_folder_sync (CamelFolder *folder,
+ gboolean expunge,
+ GError **error);
-struct _CamelStore * camel_folder_get_parent_store (CamelFolder *folder);
+struct _CamelStore *
+ camel_folder_get_parent_store (CamelFolder *folder);
/* delete operations */
-void camel_folder_expunge (CamelFolder *folder,
- CamelException *ex);
+gboolean camel_folder_expunge (CamelFolder *folder,
+ GError **error);
/* folder name operations */
-const gchar * camel_folder_get_name (CamelFolder *folder);
-const gchar * camel_folder_get_full_name (CamelFolder *folder);
+const gchar * camel_folder_get_name (CamelFolder *folder);
+const gchar * camel_folder_get_full_name (CamelFolder *folder);
/* various properties accessors */
-guint32 camel_folder_get_permanent_flags (CamelFolder *folder);
+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);
+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 */
-void camel_folder_append_message (CamelFolder *folder,
- CamelMimeMessage *message,
- const CamelMessageInfo *info,
- gchar **appended_uid,
- CamelException *ex);
+gboolean camel_folder_append_message (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error);
/* summary related operations */
-gboolean camel_folder_has_summary_capability (CamelFolder *folder);
+gboolean camel_folder_has_summary_capability
+ (CamelFolder *folder);
-gint camel_folder_get_message_count (CamelFolder *folder);
+gint camel_folder_get_message_count (CamelFolder *folder);
#ifndef CAMEL_DISABLE_DEPRECATED
-gint camel_folder_get_unread_message_count (CamelFolder *folder);
+gint camel_folder_get_unread_message_count
+ (CamelFolder *folder);
#endif
-gint camel_folder_get_deleted_message_count (CamelFolder *folder);
+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);
+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,
- CamelException *ex);
-void camel_folder_sync_message (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex);
+CamelMimeMessage *
+ camel_folder_get_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error);
+gboolean camel_folder_sync_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error);
+
#define camel_folder_delete_message(folder, uid) \
- camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN)
-
-GPtrArray * camel_folder_get_uids (CamelFolder *folder);
-void camel_folder_free_uids (CamelFolder *folder,
- GPtrArray *array);
-GPtrArray * camel_folder_get_uncached_uids (CamelFolder *,
- GPtrArray * uids,
- CamelException *);
-gint camel_folder_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2);
-void camel_folder_sort_uids (CamelFolder *folder,
- GPtrArray *uids);
+ (camel_folder_set_message_flags \
+ (folder, uid, CAMEL_MESSAGE_DELETED | \
+ CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN))
+
+GPtrArray * camel_folder_get_uids (CamelFolder *folder);
+void camel_folder_free_uids (CamelFolder *folder,
+ GPtrArray *array);
+GPtrArray * camel_folder_get_uncached_uids (CamelFolder *,
+ GPtrArray * uids,
+ GError **error);
+gint camel_folder_cmp_uids (CamelFolder *folder,
+ const gchar *uid1,
+ 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 (CamelFolder *folder, const gchar *expr, CamelException *ex);
-GPtrArray * camel_folder_search_by_uids (CamelFolder *folder, const gchar *expr, GPtrArray *uids, CamelException *ex);
-void camel_folder_search_free (CamelFolder *folder, GPtrArray *result);
-guint32 camel_folder_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex);
+gboolean camel_folder_has_search_capability
+ (CamelFolder *folder);
+GPtrArray * camel_folder_search_by_expression
+ (CamelFolder *folder,
+ const gchar *expr,
+ GError **error);
+GPtrArray * camel_folder_search_by_uids (CamelFolder *folder,
+ const gchar *expr,
+ GPtrArray *uids,
+ GError **error);
+void camel_folder_search_free (CamelFolder *folder,
+ GPtrArray *result);
+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);
-void camel_folder_free_message_info (CamelFolder *folder, CamelMessageInfo *info);
+CamelMessageInfo *
+ camel_folder_get_message_info (CamelFolder *folder,
+ const gchar *uid);
+void camel_folder_free_message_info (CamelFolder *folder,
+ CamelMessageInfo *info);
#ifndef CAMEL_DISABLE_DEPRECATED
-void camel_folder_ref_message_info (CamelFolder *folder, CamelMessageInfo *info);
+void camel_folder_ref_message_info (CamelFolder *folder,
+ CamelMessageInfo *info);
#endif
-void camel_folder_transfer_messages_to (CamelFolder *source,
- GPtrArray *uids,
- CamelFolder *dest,
- GPtrArray **transferred_uids,
- gboolean delete_originals,
- CamelException *ex);
+gboolean camel_folder_transfer_messages_to
+ (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error);
-void camel_folder_delete (CamelFolder *folder);
-void camel_folder_rename (CamelFolder *folder, const gchar *new);
+void camel_folder_delete (CamelFolder *folder);
+void camel_folder_rename (CamelFolder *folder,
+ const gchar *new);
/* stop/restart getting events */
-void camel_folder_freeze (CamelFolder *folder);
-void camel_folder_thaw (CamelFolder *folder);
-gboolean camel_folder_is_frozen (CamelFolder *folder);
+void camel_folder_freeze (CamelFolder *folder);
+void camel_folder_thaw (CamelFolder *folder);
+gboolean camel_folder_is_frozen (CamelFolder *folder);
/* quota support */
-CamelFolderQuotaInfo *camel_folder_get_quota_info (CamelFolder *folder);
-
-CamelFolderQuotaInfo *camel_folder_quota_info_new (const gchar *name, guint64 used, guint64 total);
-CamelFolderQuotaInfo *camel_folder_quota_info_clone (const CamelFolderQuotaInfo *info);
-void camel_folder_quota_info_free (CamelFolderQuotaInfo *info);
+CamelFolderQuotaInfo *
+ camel_folder_get_quota_info (CamelFolder *folder);
+CamelFolderQuotaInfo *
+ camel_folder_quota_info_new (const gchar *name,
+ guint64 used,
+ guint64 total);
+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);
+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, CamelException *ex);
+gchar * camel_folder_get_filename (CamelFolder *folder,
+ const gchar *uid,
+ GError **error);
/* update functions for change info */
-CamelFolderChangeInfo * camel_folder_change_info_new (void);
-void camel_folder_change_info_clear (CamelFolderChangeInfo *info);
-void camel_folder_change_info_free (CamelFolderChangeInfo *info);
-gboolean camel_folder_change_info_changed (CamelFolderChangeInfo *info);
+CamelFolderChangeInfo *
+ camel_folder_change_info_new (void);
+void camel_folder_change_info_clear (CamelFolderChangeInfo *info);
+void camel_folder_change_info_free (CamelFolderChangeInfo *info);
+gboolean camel_folder_change_info_changed(CamelFolderChangeInfo *info);
/* for building diff's automatically */
-void camel_folder_change_info_add_source (CamelFolderChangeInfo *info, const gchar *uid);
-void camel_folder_change_info_add_source_list(CamelFolderChangeInfo *info, const GPtrArray *list);
-void camel_folder_change_info_add_update (CamelFolderChangeInfo *info, const gchar *uid);
-void camel_folder_change_info_add_update_list(CamelFolderChangeInfo *info, const GPtrArray *list);
-void camel_folder_change_info_build_diff (CamelFolderChangeInfo *info);
+void camel_folder_change_info_add_source
+ (CamelFolderChangeInfo *info,
+ const gchar *uid);
+void camel_folder_change_info_add_source_list
+ (CamelFolderChangeInfo *info,
+ const GPtrArray *list);
+void camel_folder_change_info_add_update
+ (CamelFolderChangeInfo *info,
+ const gchar *uid);
+void camel_folder_change_info_add_update_list
+ (CamelFolderChangeInfo *info,
+ const GPtrArray *list);
+void camel_folder_change_info_build_diff
+ (CamelFolderChangeInfo *info);
/* for manipulating diff's directly */
-void camel_folder_change_info_cat (CamelFolderChangeInfo *info, CamelFolderChangeInfo *src);
-void camel_folder_change_info_add_uid (CamelFolderChangeInfo *info, const gchar *uid);
-void camel_folder_change_info_remove_uid (CamelFolderChangeInfo *info, const gchar *uid);
-void camel_folder_change_info_change_uid (CamelFolderChangeInfo *info, const gchar *uid);
-void camel_folder_change_info_recent_uid (CamelFolderChangeInfo *info, const gchar *uid);
+void camel_folder_change_info_cat (CamelFolderChangeInfo *info,
+ CamelFolderChangeInfo *src);
+void camel_folder_change_info_add_uid(CamelFolderChangeInfo *info,
+ const gchar *uid);
+void camel_folder_change_info_remove_uid
+ (CamelFolderChangeInfo *info,
+ const gchar *uid);
+void camel_folder_change_info_change_uid
+ (CamelFolderChangeInfo *info,
+ const gchar *uid);
+void camel_folder_change_info_recent_uid
+ (CamelFolderChangeInfo *info,
+ const gchar *uid);
G_END_DECLS
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index db16735..28f404f 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -697,7 +697,8 @@ next_token (const gchar *in, gchar **token)
}
static gint
-gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
+gpg_ctx_parse_status (struct _GpgCtx *gpg,
+ GError **error)
{
register guchar *inptr;
const guchar *status;
@@ -723,11 +724,15 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
if (strncmp ((const gchar *) status, "[GNUPG:] ", 9) != 0) {
gchar *message;
- message = g_locale_to_utf8((const gchar *) status, -1, NULL, NULL, NULL);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unexpected GnuPG status message encountered:\n\n%s"),
- message);
+
+ message = g_locale_to_utf8 (
+ (const gchar *) status, -1, NULL, NULL, NULL);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unexpected GnuPG status message encountered:\n\n%s"),
+ message);
g_free(message);
+
return -1;
}
@@ -739,8 +744,9 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
status += 12;
status = (const guchar *) next_token ((gchar *) status, &hint);
if (!hint) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to parse gpg userid hint."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to parse gpg userid hint."));
return -1;
}
@@ -763,8 +769,9 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
status = (const guchar *) next_token ((gchar *) status, &userid);
if (!userid) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to parse gpg passphrase request."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to parse gpg passphrase request."));
return -1;
}
@@ -777,8 +784,9 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
status = (const guchar *) next_token ((gchar *) status, &userid);
if (!userid) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to parse gpg passphrase request."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to parse gpg passphrase request."));
return -1;
}
@@ -788,6 +796,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
const gchar *name = NULL;
gchar *prompt, *passwd;
guint32 flags;
+ GError *local_error = NULL;
status += 11;
@@ -806,14 +815,16 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
"user: \"%s\""), name);
} else {
next_token ((gchar *) status, &prompt);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unexpected request from GnuPG for '%s'"), prompt);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unexpected request from GnuPG for '%s'"),
+ prompt);
g_free (prompt);
return -1;
}
flags = CAMEL_SESSION_PASSWORD_SECRET | CAMEL_SESSION_PASSPHRASE;
- if ((passwd = camel_session_get_password (gpg->session, NULL, NULL, prompt, gpg->need_id, flags, ex))) {
+ if ((passwd = camel_session_get_password (gpg->session, NULL, NULL, prompt, gpg->need_id, flags, &local_error))) {
if (!gpg->utf8) {
gchar *opasswd = passwd;
@@ -831,8 +842,13 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
gpg->send_passwd = TRUE;
} else {
- if (!camel_exception_is_set (ex))
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled."));
+ if (local_error == NULL)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Canceled."));
+ g_propagate_error (error, local_error);
+
return -1;
}
@@ -842,21 +858,27 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
} else if (!strncmp ((gchar *) status, "BAD_PASSPHRASE", 14)) {
gpg->bad_passwds++;
- camel_session_forget_password (gpg->session, NULL, NULL, gpg->need_id, ex);
+ camel_session_forget_password (gpg->session, NULL, NULL, gpg->need_id, error);
if (gpg->bad_passwds == 3) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Failed to unlock secret key: 3 bad passphrases given."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Failed to unlock secret key: "
+ "3 bad passphrases given."));
return -1;
}
} else if (!strncmp ((const gchar *) status, "UNEXPECTED ", 11)) {
/* this is an error */
gchar *message;
- message = g_locale_to_utf8((const gchar *) status+11, -1, NULL, NULL, NULL);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unexpected response from GnuPG: %s"),
- message);
- g_free(message);
+
+ message = g_locale_to_utf8 (
+ (const gchar *) status+11, -1, NULL, NULL, NULL);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unexpected response from GnuPG: %s"), message);
+ g_free (message);
+
return -1;
} else if (!strncmp ((gchar *) status, "NODATA", 6)) {
/* this is an error */
@@ -916,8 +938,9 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
} else if (!strncmp ((gchar *) status, "END_ENCRYPTION", 14)) {
/* nothing to do, but we know the end is near? */
} else if (!strncmp ((gchar *) status, "NO_RECP", 7)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to encrypt: No valid recipients specified."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to encrypt: No valid recipients specified."));
return -1;
}
break;
@@ -995,7 +1018,8 @@ gpg_ctx_op_cancel (struct _GpgCtx *gpg)
#endif
static gint
-gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
+gpg_ctx_op_step (struct _GpgCtx *gpg,
+ GError **error)
{
#ifndef G_OS_WIN32
GPollFD polls[6];
@@ -1041,8 +1065,11 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
goto exception;
if ((polls[5].revents & G_IO_IN) && camel_operation_cancel_check(NULL)) {
- camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled."));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL, _("Canceled."));
gpg_ctx_op_cancel(gpg);
+
return -1;
}
@@ -1068,7 +1095,7 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
if (nread > 0) {
status_backup (gpg, buffer, nread);
- if (gpg_ctx_parse_status (gpg, ex) == -1)
+ if (gpg_ctx_parse_status (gpg, error) == -1)
return -1;
} else {
gpg->complete = TRUE;
@@ -1187,7 +1214,10 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
exception:
/* always called on an i/o error */
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to execute gpg: %s"), g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to execute gpg: %s"), g_strerror (errno));
gpg_ctx_op_cancel(gpg);
#endif
return -1;
@@ -1263,7 +1293,12 @@ gpg_ctx_op_wait (struct _GpgCtx *gpg)
}
static gint
-gpg_sign (CamelCipherContext *context, const gchar *userid, CamelCipherHash hash, CamelMimePart *ipart, CamelMimePart *opart, CamelException *ex)
+gpg_sign (CamelCipherContext *context,
+ const gchar *userid,
+ CamelCipherHash hash,
+ CamelMimePart *ipart,
+ CamelMimePart *opart,
+ GError **error)
{
struct _GpgCtx *gpg = NULL;
CamelCipherContextClass *class;
@@ -1282,8 +1317,11 @@ gpg_sign (CamelCipherContext *context, const gchar *userid, CamelCipherHash hash
istream = camel_stream_mem_new();
if (camel_cipher_canonical_to_stream(ipart, CAMEL_MIME_FILTER_CANON_STRIP|CAMEL_MIME_FILTER_CANON_CRLF|CAMEL_MIME_FILTER_CANON_FROM,
istream) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not generate signing data: %s"), g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not generate signing data: %s"),
+ g_strerror (errno));
goto fail;
}
@@ -1314,13 +1352,16 @@ gpg_sign (CamelCipherContext *context, const gchar *userid, CamelCipherHash hash
gpg_ctx_set_ostream (gpg, ostream);
if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg: %s"), g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to execute gpg: %s"),
+ g_strerror (errno));
goto fail;
}
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1)
+ if (gpg_ctx_op_step (gpg, error) == -1)
goto fail;
}
@@ -1328,9 +1369,11 @@ gpg_sign (CamelCipherContext *context, const gchar *userid, CamelCipherHash hash
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- diagnostics && *diagnostics ? diagnostics :
- _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
+ (diagnostics != NULL && *diagnostics != '\0') ?
+ diagnostics : _("Failed to execute gpg."));
+
goto fail;
}
@@ -1409,7 +1452,9 @@ swrite (CamelMimePart *sigpart)
}
static CamelCipherValidity *
-gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *ex)
+gpg_verify (CamelCipherContext *context,
+ CamelMimePart *ipart,
+ GError **error)
{
CamelCipherContextClass *class;
CamelCipherValidity *validity;
@@ -1437,20 +1482,26 @@ gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *e
if (!CAMEL_IS_MULTIPART_SIGNED(mps)
|| tmp == NULL
|| g_ascii_strcasecmp(tmp, class->sign_protocol) != 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
return NULL;
}
if (!(istream = camel_multipart_signed_get_content_stream ((CamelMultipartSigned *) mps, NULL))) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
return NULL;
}
if (!(sigpart = camel_multipart_get_part (mps, CAMEL_MULTIPART_SIGNED_SIGNATURE))) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
g_object_unref (istream);
return NULL;
}
@@ -1464,8 +1515,10 @@ gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *e
sigpart = NULL;
} else {
/* Invalid Mimetype */
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
return NULL;
}
@@ -1503,9 +1556,11 @@ gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *e
if (sigpart) {
sigfile = swrite (sigpart);
if (sigfile == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: could not create temp file: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "could not create temp file: %s"),
+ g_strerror (errno));
goto exception;
}
}
@@ -1533,13 +1588,14 @@ gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *e
gpg_ctx_set_istream (gpg, canon_stream);
if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to execute gpg."));
goto exception;
}
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1)
+ if (gpg_ctx_op_step (gpg, error) == -1)
goto exception;
}
@@ -1548,9 +1604,10 @@ gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *e
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- diagnostics && *diagnostics ? diagnostics :
- _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
+ (diagnostics != NULL && *diagnostics != '\0') ?
+ diagnostics : _("Failed to execute gpg."));
goto exception;
}
@@ -1597,7 +1654,12 @@ gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *e
}
static gint
-gpg_encrypt (CamelCipherContext *context, const gchar *userid, GPtrArray *recipients, struct _CamelMimePart *ipart, struct _CamelMimePart *opart, CamelException *ex)
+gpg_encrypt (CamelCipherContext *context,
+ const gchar *userid,
+ GPtrArray *recipients,
+ CamelMimePart *ipart,
+ CamelMimePart *opart,
+ GError **error)
{
CamelCipherContextClass *class;
CamelGpgContext *ctx = (CamelGpgContext *) context;
@@ -1614,8 +1676,10 @@ gpg_encrypt (CamelCipherContext *context, const gchar *userid, GPtrArray *recipi
ostream = camel_stream_mem_new();
istream = camel_stream_mem_new();
if (camel_cipher_canonical_to_stream(ipart, CAMEL_MIME_FILTER_CANON_CRLF, istream) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not generate encrypting data: %s"), g_strerror(errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not generate encrypting data: %s"),
+ g_strerror (errno));
goto fail1;
}
@@ -1632,13 +1696,15 @@ gpg_encrypt (CamelCipherContext *context, const gchar *userid, GPtrArray *recipi
}
if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to execute gpg."));
goto fail;
}
/* FIXME: move tihs to a common routine */
while (!gpg_ctx_op_complete(gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1)
+ if (gpg_ctx_op_step (gpg, error) == -1)
goto fail;
}
@@ -1646,8 +1712,10 @@ gpg_encrypt (CamelCipherContext *context, const gchar *userid, GPtrArray *recipi
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- diagnostics && *diagnostics ? diagnostics : _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
+ (diagnostics != NULL && *diagnostics != '\0') ?
+ diagnostics : _("Failed to execute gpg."));
goto fail;
}
@@ -1705,7 +1773,10 @@ fail1:
}
static CamelCipherValidity *
-gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *opart, CamelException *ex)
+gpg_decrypt (CamelCipherContext *context,
+ CamelMimePart *ipart,
+ CamelMimePart *opart,
+ GError **error)
{
struct _GpgCtx *gpg;
CamelCipherValidity *valid = NULL;
@@ -1717,16 +1788,18 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
gint rv;
if (!ipart) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot decrypt message: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot decrypt message: Incorrect message format"));
return NULL;
}
content = camel_medium_get_content ((CamelMedium *)ipart);
if (!content) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot decrypt message: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot decrypt message: Incorrect message format"));
return NULL;
}
@@ -1735,7 +1808,10 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
if (camel_content_type_is(ct, "multipart", "encrypted")) {
mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) ipart);
if (!(encrypted = camel_multipart_get_part (mp, CAMEL_MULTIPART_ENCRYPTED_CONTENT))) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to decrypt MIME part: protocol error"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to decrypt MIME part: "
+ "protocol error"));
return NULL;
}
@@ -1744,8 +1820,9 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
content = camel_medium_get_content ((CamelMedium *) ipart);
} else {
/* Invalid Mimetype */
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot decrypt message: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot decrypt message: Incorrect message format"));
return NULL;
}
@@ -1762,13 +1839,14 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
gpg_ctx_set_ostream (gpg, ostream);
if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to execute gpg."));
goto fail;
}
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1)
+ if (gpg_ctx_op_step (gpg, error) == -1)
goto fail;
}
@@ -1776,9 +1854,10 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- diagnostics && *diagnostics ? diagnostics :
- _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
+ (diagnostics != NULL && *diagnostics != '\0') ?
+ diagnostics : _("Failed to execute gpg."));
goto fail;
}
@@ -1831,8 +1910,9 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
}
}
} else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unable to parse message content"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unable to parse message content"));
}
fail:
@@ -1844,7 +1924,9 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op
}
static gint
-gpg_import_keys (CamelCipherContext *context, CamelStream *istream, CamelException *ex)
+gpg_import_keys (CamelCipherContext *context,
+ CamelStream *istream,
+ GError **error)
{
struct _GpgCtx *gpg;
gint res = -1;
@@ -1854,14 +1936,15 @@ gpg_import_keys (CamelCipherContext *context, CamelStream *istream, CamelExcepti
gpg_ctx_set_istream (gpg, istream);
if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg: %s"),
- errno ? g_strerror (errno) : _("Unknown"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to execute gpg: %s"),
+ errno ? g_strerror (errno) : _("Unknown"));
goto fail;
}
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1)
+ if (gpg_ctx_op_step (gpg, error) == -1)
goto fail;
}
@@ -1869,9 +1952,10 @@ gpg_import_keys (CamelCipherContext *context, CamelStream *istream, CamelExcepti
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- diagnostics && *diagnostics ? diagnostics :
- _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
+ (diagnostics != NULL && *diagnostics != '\0') ?
+ diagnostics : _("Failed to execute gpg."));
goto fail;
}
@@ -1883,7 +1967,10 @@ fail:
}
static gint
-gpg_export_keys (CamelCipherContext *context, GPtrArray *keys, CamelStream *ostream, CamelException *ex)
+gpg_export_keys (CamelCipherContext *context,
+ GPtrArray *keys,
+ CamelStream *ostream,
+ GError **error)
{
struct _GpgCtx *gpg;
gint i;
@@ -1899,14 +1986,15 @@ gpg_export_keys (CamelCipherContext *context, GPtrArray *keys, CamelStream *ostr
}
if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg: %s"),
- errno ? g_strerror (errno) : _("Unknown"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to execute gpg: %s"),
+ errno ? g_strerror (errno) : _("Unknown"));
goto fail;
}
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1)
+ if (gpg_ctx_op_step (gpg, error) == -1)
goto fail;
}
@@ -1914,9 +2002,10 @@ gpg_export_keys (CamelCipherContext *context, GPtrArray *keys, CamelStream *ostr
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- diagnostics && *diagnostics ? diagnostics :
- _("Failed to execute gpg."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
+ (diagnostics != NULL && *diagnostics != '\0') ?
+ diagnostics : _("Failed to execute gpg."));
goto fail;
}
diff --git a/camel/camel-http-stream.c b/camel/camel-http-stream.c
index 329b488..493c434 100644
--- a/camel/camel-http-stream.c
+++ b/camel/camel-http-stream.c
@@ -30,7 +30,6 @@
#include <stdlib.h>
#include <string.h>
-#include "camel-exception.h"
#include "camel-http-stream.h"
#include "camel-mime-utils.h"
#include "camel-net-utils.h"
diff --git a/camel/camel-index.h b/camel/camel-index.h
index 78c6995..69535a9 100644
--- a/camel/camel-index.h
+++ b/camel/camel-index.h
@@ -25,7 +25,6 @@
#ifndef CAMEL_INDEX_H
#define CAMEL_INDEX_H
-#include <camel/camel-exception.h>
#include <camel/camel-object.h>
/* Standard GObject macros */
diff --git a/camel/camel-lock-client.c b/camel/camel-lock-client.c
index 0b5693e..1622b97 100644
--- a/camel/camel-lock-client.c
+++ b/camel/camel-lock-client.c
@@ -34,7 +34,6 @@
#include <sys/types.h>
#include <sys/wait.h>
-#include "camel-exception.h"
#include "camel-lock-client.h"
#include "camel-lock-helper.h"
@@ -90,7 +89,8 @@ static gint write_n(gint fd, gpointer buffer, gint inlen)
return inlen;
}
-static gint lock_helper_init(CamelException *ex)
+static gint
+lock_helper_init (GError **error)
{
gint i;
@@ -100,9 +100,11 @@ static gint lock_helper_init(CamelException *ex)
lock_stdout_pipe[1] = -1;
if (pipe(lock_stdin_pipe) == -1
|| pipe(lock_stdout_pipe) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot build locking helper pipe: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot build locking helper pipe: %s"),
+ g_strerror (errno));
if (lock_stdin_pipe[0] != -1)
close(lock_stdin_pipe[0]);
if (lock_stdin_pipe[1] != -1)
@@ -122,9 +124,11 @@ static gint lock_helper_init(CamelException *ex)
close(lock_stdin_pipe[1]);
close(lock_stdout_pipe[0]);
close(lock_stdout_pipe[1]);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot fork locking helper: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot fork locking helper: %s"),
+ g_strerror (errno));
return -1;
case 0:
close(STDIN_FILENO);
@@ -152,7 +156,9 @@ static gint lock_helper_init(CamelException *ex)
return 0;
}
-gint camel_lock_helper_lock(const gchar *path, CamelException *ex)
+gint
+camel_lock_helper_lock (const gchar *path,
+ GError **error)
{
struct _CamelLockHelperMsg *msg;
gint len = strlen(path);
@@ -162,7 +168,7 @@ gint camel_lock_helper_lock(const gchar *path, CamelException *ex)
LOCK();
if (lock_helper_pid == -1) {
- if (lock_helper_init(ex) == -1) {
+ if (lock_helper_init(error) == -1) {
UNLOCK();
return -1;
}
@@ -199,8 +205,11 @@ again:
|| msg->seq > lock_sequence) {
res = CAMEL_LOCK_HELPER_STATUS_PROTOCOL;
d(printf("lock child protocol error\n"));
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not lock '%s': protocol error with lock-helper"), path);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Could not lock '%s': protocol "
+ "error with lock-helper"), path);
goto fail;
}
} while (msg->seq < lock_sequence);
@@ -212,8 +221,10 @@ again:
res = msg->data;
break;
default:
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not lock '%s'"), path);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Could not lock '%s'"), path);
d(printf("locking failed ! status = %d\n", msg->id));
break;
}
@@ -222,8 +233,11 @@ again:
retry--;
goto again;
} else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not lock '%s': protocol error with lock-helper"), path);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Could not lock '%s': protocol "
+ "error with lock-helper"), path);
}
fail:
diff --git a/camel/camel-lock-client.h b/camel/camel-lock-client.h
index 642d7f6..76fd986 100644
--- a/camel/camel-lock-client.h
+++ b/camel/camel-lock-client.h
@@ -28,11 +28,11 @@
#ifndef CAMEL_LOCK_CLIENT_H
#define CAMEL_LOCK_CLIENT_H
-#include <camel/camel-exception.h>
+#include <camel/camel.h>
G_BEGIN_DECLS
-gint camel_lock_helper_lock(const gchar *path , CamelException *ex);
+gint camel_lock_helper_lock(const gchar *path , GError **error);
gint camel_lock_helper_unlock(gint lockid);
G_END_DECLS
diff --git a/camel/camel-lock-helper.c b/camel/camel-lock-helper.c
index a250bb2..61c27c3 100644
--- a/camel/camel-lock-helper.c
+++ b/camel/camel-lock-helper.c
@@ -98,18 +98,6 @@ static gint write_n(gint fd, gpointer buffer, gint inlen)
return inlen;
}
-void
-camel_exception_setv (CamelException *ex, ExceptionId id, const gchar *format, ...)
-{
- ;
-}
-
-void
-camel_exception_clear (CamelException *exception)
-{
- ;
-}
-
gchar *gettext (const gchar *msgid);
gchar *
diff --git a/camel/camel-lock.c b/camel/camel-lock.c
index 9da38fe..016af8c 100644
--- a/camel/camel-lock.c
+++ b/camel/camel-lock.c
@@ -64,7 +64,7 @@
/**
* camel_lock_dot:
* @path:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Create an exclusive lock using .lock semantics.
* All locks are equivalent to write locks (exclusive).
@@ -72,7 +72,8 @@
* Return value: -1 on error, sets @ex appropriately.
**/
gint
-camel_lock_dot(const gchar *path, CamelException *ex)
+camel_lock_dot (const gchar *path,
+ GError **error)
{
#ifdef USE_DOT
gchar *locktmp, *lock;
@@ -98,9 +99,11 @@ camel_lock_dot(const gchar *path, CamelException *ex)
sprintf(locktmp, "%sXXXXXX", path);
fdtmp = g_mkstemp(locktmp);
if (fdtmp == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create lock file for %s: %s"),
- path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not create lock file for %s: %s"),
+ path, g_strerror (errno));
return -1;
}
close(fdtmp);
@@ -140,7 +143,10 @@ camel_lock_dot(const gchar *path, CamelException *ex)
d(printf("failed to get lock after %d retries\n", retry));
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Timed out trying to get lock file on %s. Try again later."), path);
+ g_set_error (
+ error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Timed out trying to get lock file on %s. "
+ "Try again later."), path);
return -1;
#else /* ! USE_DOT */
return 0;
@@ -170,7 +176,7 @@ camel_unlock_dot(const gchar *path)
* camel_lock_fcntl:
* @fd:
* @type:
- * @ex:
+ * @error:
*
* Create a lock using fcntl(2).
*
@@ -180,7 +186,9 @@ camel_unlock_dot(const gchar *path)
* Return value: -1 on error.
**/
gint
-camel_lock_fcntl(gint fd, CamelLockType type, CamelException *ex)
+camel_lock_fcntl (gint fd,
+ CamelLockType type,
+ GError **error)
{
#ifdef USE_FCNTL
struct flock lock;
@@ -194,9 +202,11 @@ camel_lock_fcntl(gint fd, CamelLockType type, CamelException *ex)
we assume the filesystem doesn't support fcntl() locking */
/* this is somewhat system-dependent */
if (errno != EINVAL && errno != ENOLCK) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to get lock using fcntl(2): %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to get lock using fcntl(2): %s"),
+ g_strerror (errno));
return -1;
} else {
static gint failed = 0;
@@ -234,7 +244,7 @@ camel_unlock_fcntl(gint fd)
* camel_lock_flock:
* @fd:
* @type:
- * @ex:
+ * @error:
*
* Create a lock using flock(2).
*
@@ -244,7 +254,9 @@ camel_unlock_fcntl(gint fd)
* Return value: -1 on error.
**/
gint
-camel_lock_flock(gint fd, CamelLockType type, CamelException *ex)
+camel_lock_flock (gint fd,
+ CamelLockType type,
+ GError **error)
{
#ifdef USE_FLOCK
gint op;
@@ -257,9 +269,11 @@ camel_lock_flock(gint fd, CamelLockType type, CamelException *ex)
op = LOCK_EX|LOCK_NB;
if (flock(fd, op) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to get lock using flock(2): %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to get lock using flock(2): %s"),
+ g_strerror (errno));
return -1;
}
#endif
@@ -287,7 +301,7 @@ camel_unlock_flock(gint fd)
* @path: Path to the file to lock (used for .locking only).
* @fd: Open file descriptor of the right type to lock.
* @type: Type of lock, CAMEL_LOCK_READ or CAMEL_LOCK_WRITE.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Attempt to lock a folder, multiple attempts will be made using all
* locking strategies available.
@@ -295,7 +309,10 @@ camel_unlock_flock(gint fd)
* Return value: -1 on error, @ex will describe the locking system that failed.
**/
gint
-camel_lock_folder(const gchar *path, gint fd, CamelLockType type, CamelException *ex)
+camel_lock_folder (const gchar *path,
+ gint fd,
+ CamelLockType type,
+ GError **error)
{
gint retry = 0;
@@ -303,9 +320,9 @@ camel_lock_folder(const gchar *path, gint fd, CamelLockType type, CamelException
if (retry > 0)
g_usleep(CAMEL_LOCK_DELAY*1000000);
- if (camel_lock_fcntl(fd, type, ex) == 0) {
- if (camel_lock_flock(fd, type, ex) == 0) {
- if (camel_lock_dot(path, ex) == 0)
+ if (camel_lock_fcntl(fd, type, error) == 0) {
+ if (camel_lock_flock(fd, type, error) == 0) {
+ if (camel_lock_dot(path, error) == 0)
return 0;
camel_unlock_flock(fd);
}
@@ -335,24 +352,23 @@ camel_unlock_folder(const gchar *path, gint fd)
#if 0
gint main(gint argc, gchar **argv)
{
- CamelException *ex;
+ GError *error = NULL;
gint fd1, fd2;
- ex = camel_exception_new();
-
#if 0
- if (camel_lock_dot("mylock", ex) == 0) {
- if (camel_lock_dot("mylock", ex) == 0) {
+ if (camel_lock_dot("mylock", &error) == 0) {
+ if (camel_lock_dot("mylock", &error) == 0) {
printf("Got lock twice?\n");
} else {
- printf("failed to get lock 2: %s\n", camel_exception_get_description(ex));
+ printf("failed to get lock 2: %s\n", error->message);
}
camel_unlock_dot("mylock");
} else {
- printf("failed to get lock 1: %s\n", camel_exception_get_description(ex));
+ printf("failed to get lock 1: %s\n", error->message);
}
- camel_exception_clear(ex);
+ if (error != NULL)
+ g_clear_error (&error);
#endif
fd1 = open("mylock", O_RDWR);
@@ -367,49 +383,53 @@ gint main(gint argc, gchar **argv)
return 1;
}
- if (camel_lock_fcntl(fd1, CAMEL_LOCK_WRITE, ex) == 0) {
+ if (camel_lock_fcntl(fd1, CAMEL_LOCK_WRITE, &error) == 0) {
printf("got fcntl write lock once\n");
g_usleep(5000000);
- if (camel_lock_fcntl(fd2, CAMEL_LOCK_WRITE, ex) == 0) {
+ if (camel_lock_fcntl(fd2, CAMEL_LOCK_WRITE, &error) == 0) {
printf("got fcntl write lock twice!\n");
} else {
- printf("failed to get write lock: %s\n", camel_exception_get_description(ex));
+ printf("failed to get write lock: %s\n", error->message);
}
- camel_exception_clear(ex);
+ if (error != NULL)
+ g_clear_error (&error);
- if (camel_lock_fcntl(fd2, CAMEL_LOCK_READ, ex) == 0) {
+ if (camel_lock_fcntl(fd2, CAMEL_LOCK_READ, &error) == 0) {
printf("got fcntl read lock as well?\n");
camel_unlock_fcntl(fd2);
} else {
- printf("failed to get read lock: %s\n", camel_exception_get_description(ex));
+ printf("failed to get read lock: %s\n", error->message);
}
- camel_exception_clear(ex);
+ if (error != NULL)
+ g_clear_error (&error);
camel_unlock_fcntl(fd1);
} else {
- printf("failed to get write lock at all: %s\n", camel_exception_get_description(ex));
+ printf("failed to get write lock at all: %s\n", error->message);
}
- if (camel_lock_fcntl(fd1, CAMEL_LOCK_READ, ex) == 0) {
+ if (camel_lock_fcntl(fd1, CAMEL_LOCK_READ, &error) == 0) {
printf("got fcntl read lock once\n");
g_usleep(5000000);
- if (camel_lock_fcntl(fd2, CAMEL_LOCK_WRITE, ex) == 0) {
+ if (camel_lock_fcntl(fd2, CAMEL_LOCK_WRITE, &error) == 0) {
printf("got fcntl write lock too?!\n");
} else {
- printf("failed to get write lock: %s\n", camel_exception_get_description(ex));
+ printf("failed to get write lock: %s\n", error->message);
}
- camel_exception_clear(ex);
+ if (error != NULL)
+ g_clear_error (&error);
- if (camel_lock_fcntl(fd2, CAMEL_LOCK_READ, ex) == 0) {
+ if (camel_lock_fcntl(fd2, CAMEL_LOCK_READ, &error) == 0) {
printf("got fcntl read lock twice\n");
camel_unlock_fcntl(fd2);
} else {
- printf("failed to get read lock: %s\n", camel_exception_get_description(ex));
+ printf("failed to get read lock: %s\n", error->message);
}
- camel_exception_clear(ex);
+ if (error != NULL)
+ g_clear_error (&error);
camel_unlock_fcntl(fd1);
}
diff --git a/camel/camel-lock.h b/camel/camel-lock.h
index e5260d6..bc663b8 100644
--- a/camel/camel-lock.h
+++ b/camel/camel-lock.h
@@ -26,7 +26,7 @@
#ifndef CAMEL_LOCK_H
#define CAMEL_LOCK_H
-#include <camel/camel-exception.h>
+#include <glib.h>
/* for .lock locking, retry, delay and stale counts */
#define CAMEL_LOCK_DOT_RETRY (5) /* number of times to retry lock */
@@ -45,16 +45,16 @@ typedef enum {
} CamelLockType;
/* specific locking strategies */
-gint camel_lock_dot(const gchar *path, CamelException *ex);
-gint camel_lock_fcntl(gint fd, CamelLockType type, CamelException *ex);
-gint camel_lock_flock(gint fd, CamelLockType type, CamelException *ex);
+gint camel_lock_dot(const gchar *path, GError **error);
+gint camel_lock_fcntl(gint fd, CamelLockType type, GError **error);
+gint camel_lock_flock(gint fd, CamelLockType type, GError **error);
void camel_unlock_dot(const gchar *path);
void camel_unlock_fcntl(gint fd);
void camel_unlock_flock(gint fd);
/* lock a folder in a standard way */
-gint camel_lock_folder(const gchar *path, gint fd, CamelLockType type, CamelException *ex);
+gint camel_lock_folder(const gchar *path, gint fd, CamelLockType type, GError **error);
void camel_unlock_folder(const gchar *path, gint fd);
G_END_DECLS
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index dfc8a17..a0e0060 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -33,7 +33,6 @@
#include <string.h>
#include "camel-charset-map.h"
-#include "camel-exception.h"
#include "camel-iconv.h"
#include "camel-mime-filter-basic.h"
#include "camel-mime-filter-charset.h"
diff --git a/camel/camel-movemail.c b/camel/camel-movemail.c
index e048e05..b87b31d 100644
--- a/camel/camel-movemail.c
+++ b/camel/camel-movemail.c
@@ -43,7 +43,6 @@
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-lock-client.h"
#include "camel-mime-filter-from.h"
#include "camel-mime-filter.h"
@@ -56,15 +55,15 @@
#include <sys/wait.h>
static void movemail_external (const gchar *source, const gchar *dest,
- CamelException *ex);
+ GError **error);
#endif
#ifdef HAVE_BROKEN_SPOOL
static gint camel_movemail_copy_filter(gint fromfd, gint tofd, off_t start, gsize bytes, CamelMimeFilter *filter);
-static gint camel_movemail_solaris (gint oldsfd, gint dfd, CamelException *ex);
+static gint camel_movemail_solaris (gint oldsfd, gint dfd, GError **error);
#else
/* these could probably be exposed as a utility? (but only mbox needs it) */
-static gint camel_movemail_copy_file(gint sfd, gint dfd, CamelException *ex);
+static gint camel_movemail_copy_file(gint sfd, gint dfd, GError **error);
#endif
#if 0
@@ -75,7 +74,7 @@ static gint camel_movemail_copy(gint fromfd, gint tofd, off_t start, gsize bytes
* camel_movemail:
* @source: source file
* @dest: destination file
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This copies an mbox file from a shared directory with multiple
* readers and writers into a private (presumably Camel-controlled)
@@ -85,7 +84,9 @@ static gint camel_movemail_copy(gint fromfd, gint tofd, off_t start, gsize bytes
* Return Value: Returns -1 on error.
**/
gint
-camel_movemail(const gchar *source, const gchar *dest, CamelException *ex)
+camel_movemail (const gchar *source,
+ const gchar *dest,
+ GError **error)
{
gint lockid = -1;
gint res = -1;
@@ -100,11 +101,11 @@ camel_movemail(const gchar *source, const gchar *dest, CamelException *ex)
* called a fraction earlier.)
*/
if (stat (source, &st) == -1) {
- if (errno != ENOENT) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not check mail file %s: %s"),
- source, g_strerror (errno));
- }
+ if (errno != ENOENT)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not check mail file %s: %s"),
+ source, g_strerror (errno));
return -1;
}
@@ -114,24 +115,25 @@ camel_movemail(const gchar *source, const gchar *dest, CamelException *ex)
/* open files */
sfd = open (source, O_RDWR);
if (sfd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open mail file %s: %s"),
- source, g_strerror (errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not open mail file %s: %s"),
+ source, g_strerror (errno));
return -1;
}
dfd = open (dest, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
if (dfd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open temporary mail "
- "file %s: %s"), dest,
- g_strerror (errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not open temporary mail "
+ "file %s: %s"), dest, g_strerror (errno));
close (sfd);
return -1;
}
/* lock our source mailbox */
- lockid = camel_lock_helper_lock(source, ex);
+ lockid = camel_lock_helper_lock(source, error);
if (lockid == -1) {
close(sfd);
close(dfd);
@@ -141,7 +143,7 @@ camel_movemail(const gchar *source, const gchar *dest, CamelException *ex)
#ifdef HAVE_BROKEN_SPOOL
res = camel_movemail_solaris(sfd, dfd, ex);
#else
- res = camel_movemail_copy_file(sfd, dfd, ex);
+ res = camel_movemail_copy_file(sfd, dfd, error);
#endif
/* If no errors occurred copying the data, and we successfully
@@ -151,9 +153,10 @@ camel_movemail(const gchar *source, const gchar *dest, CamelException *ex)
if (close (dfd) == 0) {
ftruncate (sfd, 0);
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to store mail in temp file %s: %s"),
- dest, g_strerror (errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to store mail in temp file %s: %s"),
+ dest, g_strerror (errno));
res = -1;
}
} else
@@ -167,7 +170,9 @@ camel_movemail(const gchar *source, const gchar *dest, CamelException *ex)
#ifdef MOVEMAIL_PATH
static void
-movemail_external (const gchar *source, const gchar *dest, CamelException *ex)
+movemail_external (const gchar *source,
+ const gchar *dest,
+ GError **error)
{
sigset_t mask, omask;
pid_t pid;
@@ -181,9 +186,10 @@ movemail_external (const gchar *source, const gchar *dest, CamelException *ex)
if (pipe (fd) == -1) {
sigprocmask (SIG_SETMASK, &omask, NULL);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create pipe: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not create pipe: %s"),
+ g_strerror (errno));
return;
}
@@ -193,9 +199,9 @@ movemail_external (const gchar *source, const gchar *dest, CamelException *ex)
close (fd[0]);
close (fd[1]);
sigprocmask (SIG_SETMASK, &omask, NULL);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not fork: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not fork: %s"), g_strerror (errno));
return;
case 0:
@@ -231,9 +237,10 @@ movemail_external (const gchar *source, const gchar *dest, CamelException *ex)
sigprocmask (SIG_SETMASK, &omask, NULL);
if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Movemail program failed: %s"),
- output ? output : _("(Unknown error)"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Movemail program failed: %s"),
+ output ? output : _("(Unknown error)"));
}
g_free (output);
}
@@ -241,7 +248,9 @@ movemail_external (const gchar *source, const gchar *dest, CamelException *ex)
#ifndef HAVE_BROKEN_SPOOL
static gint
-camel_movemail_copy_file(gint sfd, gint dfd, CamelException *ex)
+camel_movemail_copy_file (gint sfd,
+ gint dfd,
+ GError **error)
{
gint nread, nwrote;
gchar buf[4096];
@@ -255,9 +264,11 @@ camel_movemail_copy_file(gint sfd, gint dfd, CamelException *ex)
else if (nread == -1) {
if (errno == EINTR)
continue;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Error reading mail file: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Error reading mail file: %s"),
+ g_strerror (errno));
return -1;
}
@@ -266,9 +277,11 @@ camel_movemail_copy_file(gint sfd, gint dfd, CamelException *ex)
if (nwrote == -1) {
if (errno == EINTR)
continue; /* continues inner loop */
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Error writing mail temp file: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Error writing mail temp file: %s"),
+ g_strerror (errno));
return -1;
}
written += nwrote;
@@ -446,7 +459,9 @@ solaris_header_write(gint fd, struct _camel_header_raw *header)
we must convert it to a real mbox format. Thankfully this is
mostly pretty easy */
static gint
-camel_movemail_solaris (gint oldsfd, gint dfd, CamelException *ex)
+camel_movemail_solaris (gint oldsfd,
+ gint dfd,
+ GError **error)
{
CamelMimeParser *mp;
gchar *buffer;
@@ -459,9 +474,11 @@ camel_movemail_solaris (gint oldsfd, gint dfd, CamelException *ex)
/* need to dup as the mime parser will close on finish */
sfd = dup(oldsfd);
if (sfd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Error copying mail temp file: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Error copying mail temp file: %s"),
+ g_strerror (errno));
return -1;
}
@@ -526,9 +543,11 @@ camel_movemail_solaris (gint oldsfd, gint dfd, CamelException *ex)
fail:
g_free(from);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Error copying mail temp file: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Error copying mail temp file: %s"),
+ g_strerror (errno));
g_object_unref (mp);
g_object_unref (ffrom);
diff --git a/camel/camel-movemail.h b/camel/camel-movemail.h
index 2923274..2d26f74 100644
--- a/camel/camel-movemail.h
+++ b/camel/camel-movemail.h
@@ -29,11 +29,11 @@
#ifndef CAMEL_MOVEMAIL_H
#define CAMEL_MOVEMAIL_H
-#include <camel/camel-exception.h>
+#include <glib.h>
G_BEGIN_DECLS
-gint camel_movemail (const gchar *source, const gchar *dest, CamelException *ex);
+gint camel_movemail (const gchar *source, const gchar *dest, GError **error);
G_END_DECLS
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index 77512b6..3c3e52c 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -36,7 +36,6 @@
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-mime-filter-canon.h"
#include "camel-mime-filter-crlf.h"
#include "camel-mime-message.h"
@@ -586,7 +585,7 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
/**
* camel_multipart_signed_get_content_stream:
* @mps: a #CamlMultipartSigned object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Get the raw signed content stream of the multipart/signed MIME part
* suitable for use with verification of the signature.
@@ -594,7 +593,8 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
* Returns: the signed content stream
**/
CamelStream *
-camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelException *ex)
+camel_multipart_signed_get_content_stream (CamelMultipartSigned *mps,
+ GError **error)
{
CamelStream *constream;
@@ -608,7 +608,10 @@ camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelExcept
CamelMimeFilter *canon_filter;
if (mps->start1 == -1 && parse_content(mps) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("parse error"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("parse error"));
return NULL;
}
diff --git a/camel/camel-multipart-signed.h b/camel/camel-multipart-signed.h
index 20b1054..b118274 100644
--- a/camel/camel-multipart-signed.h
+++ b/camel/camel-multipart-signed.h
@@ -104,7 +104,7 @@ GType camel_multipart_signed_get_type (void);
/* public methods */
CamelMultipartSigned *camel_multipart_signed_new (void);
-CamelStream *camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelException *ex);
+CamelStream *camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, GError **error);
G_END_DECLS
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c
index f90fc32..dbf03e7 100644
--- a/camel/camel-multipart.c
+++ b/camel/camel-multipart.c
@@ -31,7 +31,6 @@
#include <time.h> /* for time */
#include <unistd.h> /* for getpid */
-#include "camel-exception.h"
#include "camel-mime-part.h"
#include "camel-multipart.h"
#include "camel-stream-mem.h"
diff --git a/camel/camel-net-utils.c b/camel/camel-net-utils.c
index dc64948..9e77d08 100644
--- a/camel/camel-net-utils.c
+++ b/camel/camel-net-utils.c
@@ -31,7 +31,6 @@
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-msgport.h"
#include "camel-net-utils.h"
#ifdef G_OS_WIN32
@@ -39,6 +38,8 @@
#endif
#include "camel-operation.h"
+#include "camel-object.h"
+
#define d(x)
/* These are GNU extensions */
@@ -443,7 +444,10 @@ cs_freeinfo(struct _addrinfo_msg *msg)
/* returns -1 if we didn't wait for reply from thread */
static gint
-cs_waitinfo(gpointer (worker)(gpointer), struct _addrinfo_msg *msg, const gchar *error, CamelException *ex)
+cs_waitinfo (gpointer (worker)(gpointer),
+ struct _addrinfo_msg *msg,
+ const gchar *errmsg,
+ GError **error)
{
CamelMsgPort *reply_port;
pthread_t id;
@@ -491,15 +495,21 @@ cs_waitinfo(gpointer (worker)(gpointer), struct _addrinfo_msg *msg, const gchar
#endif
) {
if (status == -1)
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s", error,
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "%s: %s", errmsg,
#ifndef G_OS_WIN32
- g_strerror(errno)
+ g_strerror (errno)
#else
- g_win32_error_message (WSAGetLastError ())
+ g_win32_error_message (WSAGetLastError ())
#endif
- );
+ );
else
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Canceled"));
/* We cancel so if the thread impl is decent it causes immediate exit.
We detach so we dont need to wait for it to exit if it isn't.
@@ -518,7 +528,10 @@ cs_waitinfo(gpointer (worker)(gpointer), struct _addrinfo_msg *msg, const gchar
d(printf("child done\n"));
}
} else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error, _("cannot create thread"), g_strerror(err));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ "%s: %s: %s", errmsg, _("cannot create thread"),
+ g_strerror (err));
}
camel_msgport_destroy(reply_port);
@@ -660,7 +673,10 @@ cs_getaddrinfo(gpointer data)
#endif /* NEED_ADDRINFO */
struct addrinfo *
-camel_getaddrinfo(const gchar *name, const gchar *service, const struct addrinfo *hints, CamelException *ex)
+camel_getaddrinfo (const gchar *name,
+ const gchar *service,
+ const struct addrinfo *hints,
+ GError **error)
{
struct _addrinfo_msg *msg;
struct addrinfo *res = NULL;
@@ -670,7 +686,10 @@ camel_getaddrinfo(const gchar *name, const gchar *service, const struct addrinfo
g_return_val_if_fail(name != NULL, NULL);
if (camel_operation_cancel_check(NULL)) {
- camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Canceled"));
return NULL;
}
@@ -696,10 +715,12 @@ camel_getaddrinfo(const gchar *name, const gchar *service, const struct addrinfo
msg->hostbuflen = 1024;
msg->hostbufmem = g_malloc(msg->hostbuflen);
#endif
- if (cs_waitinfo(cs_getaddrinfo, msg, _("Host lookup failed"), ex) == 0) {
+ if (cs_waitinfo(cs_getaddrinfo, msg, _("Host lookup failed"), error) == 0) {
if (msg->result != 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: %s: %s"),
- name, gai_strerror (msg->result));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Host lookup failed: %s: %s"),
+ name, gai_strerror (msg->result));
}
cs_freeinfo(msg);
@@ -796,13 +817,21 @@ cs_getnameinfo(gpointer data)
#endif
gint
-camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, gchar **host, gchar **serv, gint flags, CamelException *ex)
+camel_getnameinfo (const struct sockaddr *sa,
+ socklen_t salen,
+ gchar **host,
+ gchar **serv,
+ gint flags,
+ GError **error)
{
struct _addrinfo_msg *msg;
gint result;
if (camel_operation_cancel_check(NULL)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Canceled"));
return -1;
}
@@ -826,11 +855,12 @@ camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, gchar **host, gcha
msg->hostbuflen = 1024;
msg->hostbufmem = g_malloc(msg->hostbuflen);
#endif
- cs_waitinfo(cs_getnameinfo, msg, _("Name lookup failed"), ex);
+ cs_waitinfo(cs_getnameinfo, msg, _("Name lookup failed"), error);
if ((result = msg->result) != 0)
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Name lookup failed: %s"),
- gai_strerror (result));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Name lookup failed: %s"), gai_strerror (result));
else {
if (host)
*host = g_strdup(msg->host);
diff --git a/camel/camel-net-utils.h b/camel/camel-net-utils.h
index 85e2469..9dfb228 100644
--- a/camel/camel-net-utils.h
+++ b/camel/camel-net-utils.h
@@ -41,8 +41,6 @@
G_BEGIN_DECLS
-struct _CamelException;
-
#ifndef _WIN32
#ifdef NEED_ADDRINFO
/* Some of this is copied from GNU's netdb.h
@@ -92,10 +90,10 @@ struct addrinfo {
#endif
struct addrinfo *camel_getaddrinfo(const gchar *name, const gchar *service,
- const struct addrinfo *hints, struct _CamelException *ex);
+ const struct addrinfo *hints, struct _GError **error);
void camel_freeaddrinfo(struct addrinfo *host);
gint camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, gchar **host, gchar **serv,
- gint flags, struct _CamelException *ex);
+ gint flags, struct _GError **error);
G_END_DECLS
diff --git a/camel/camel-object.c b/camel/camel-object.c
index 61d6675..f2d7ea2 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -143,7 +143,9 @@ hooks_free(CamelHookList *hooks)
/* CamelObject base methods */
static gint
-cobject_getv(CamelObject *o, CamelException *ex, CamelArgGetV *args)
+cobject_getv (CamelObject *o,
+ GError **error,
+ CamelArgGetV *args)
{
CamelObjectClass *class;
gint i;
@@ -179,7 +181,9 @@ cobject_getv(CamelObject *o, CamelException *ex, CamelArgGetV *args)
}
static gint
-cobject_setv(CamelObject *o, CamelException *ex, CamelArgV *args)
+cobject_setv (CamelObject *o,
+ GError **error,
+ CamelArgV *args)
{
gint i;
guint32 tag;
@@ -557,6 +561,19 @@ camel_object_get_type(void)
return type;
}
+GQuark
+camel_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0)) {
+ const gchar *string = "camel-error-quark";
+ quark = g_quark_from_static_string (string);
+ }
+
+ return quark;
+}
+
static CamelHookPair *
co_find_pair (CamelObjectClass *class,
const gchar *name)
@@ -888,7 +905,7 @@ trigger:
/* get/set arg methods */
gint
camel_object_set (gpointer vo,
- CamelException *ex, ...)
+ GError **error, ...)
{
CamelObjectClass *class;
CamelArgV args;
@@ -897,15 +914,15 @@ camel_object_set (gpointer vo,
g_return_val_if_fail(CAMEL_IS_OBJECT(o), -1);
- camel_argv_start(&args, ex);
+ camel_argv_start(&args, error);
class = CAMEL_OBJECT_GET_CLASS (o);
g_return_val_if_fail (class->setv != NULL, -1);
while (camel_argv_build(&args) && ret == 0)
- ret = class->setv(o, ex, &args);
+ ret = class->setv(o, error, &args);
if (ret == 0)
- ret = class->setv(o, ex, &args);
+ ret = class->setv(o, error, &args);
camel_argv_end(&args);
@@ -914,7 +931,7 @@ camel_object_set (gpointer vo,
gint
camel_object_setv (gpointer vo,
- CamelException *ex,
+ GError **error,
CamelArgV *args)
{
CamelObjectClass *class;
@@ -924,12 +941,12 @@ camel_object_setv (gpointer vo,
class = CAMEL_OBJECT_GET_CLASS (vo);
g_return_val_if_fail (class->setv != NULL, -1);
- return class->setv (vo, ex, args);
+ return class->setv (vo, error, args);
}
gint
camel_object_get (gpointer vo,
- CamelException *ex,
+ GError **error,
...)
{
CamelObjectClass *class;
@@ -939,15 +956,15 @@ camel_object_get (gpointer vo,
g_return_val_if_fail(CAMEL_IS_OBJECT(o), -1);
- camel_argv_start(&args, ex);
+ camel_argv_start(&args, error);
class = CAMEL_OBJECT_GET_CLASS (o);
g_return_val_if_fail (class->getv != NULL, -1);
while (camel_arggetv_build(&args) && ret == 0)
- ret = class->getv(o, ex, &args);
+ ret = class->getv(o, error, &args);
if (ret == 0)
- ret = class->getv(o, ex, &args);
+ ret = class->getv(o, error, &args);
camel_argv_end(&args);
@@ -956,7 +973,7 @@ camel_object_get (gpointer vo,
gpointer
camel_object_get_ptr (gpointer vo,
- CamelException *ex,
+ GError **error,
gint tag)
{
CamelObjectClass *class;
@@ -978,7 +995,7 @@ camel_object_get_ptr (gpointer vo,
class = CAMEL_OBJECT_GET_CLASS (o);
g_return_val_if_fail (class->getv != NULL, NULL);
- ret = class->getv(o, ex, &args);
+ ret = class->getv(o, error, &args);
if (ret != 0)
return NULL;
else
@@ -987,7 +1004,8 @@ camel_object_get_ptr (gpointer vo,
gint
camel_object_get_int (gpointer vo,
- CamelException *ex, gint tag)
+ GError **error,
+ gint tag)
{
CamelObjectClass *class;
CamelObject *o = vo;
@@ -1007,7 +1025,7 @@ camel_object_get_int (gpointer vo,
class = CAMEL_OBJECT_GET_CLASS (o);
g_return_val_if_fail (class->getv != NULL, 0);
- ret = class->getv(o, ex, &args);
+ ret = class->getv(o, error, &args);
if (ret != 0)
return 0;
else
@@ -1016,7 +1034,7 @@ camel_object_get_int (gpointer vo,
gint
camel_object_getv (gpointer vo,
- CamelException *ex,
+ GError **error,
CamelArgGetV *args)
{
CamelObjectClass *class;
@@ -1026,7 +1044,7 @@ camel_object_getv (gpointer vo,
class = CAMEL_OBJECT_GET_CLASS (vo);
g_return_val_if_fail (class->getv != NULL, -1);
- return class->getv (vo, ex, args);
+ return class->getv (vo, error, args);
}
/* NB: If this doesn't return NULL, then you must unget_hooks when done */
diff --git a/camel/camel-object.h b/camel/camel-object.h
index 61bc261..cccb381 100644
--- a/camel/camel-object.h
+++ b/camel/camel-object.h
@@ -37,7 +37,6 @@
#include <pthread.h>
#include <camel/camel-arg.h>
-#include <camel/camel-exception.h>
/* The CamelObjectBag API was originally defined in this header,
* so include it here for backward-compatibility. */
@@ -62,6 +61,9 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_OBJECT, CamelObjectClass))
+#define CAMEL_ERROR \
+ (camel_error_quark ())
+
G_BEGIN_DECLS
typedef struct _CamelObjectClass CamelObjectClass;
@@ -72,6 +74,11 @@ typedef struct _CamelObjectMeta CamelObjectMeta;
typedef gboolean (*CamelObjectEventPrepFunc) (CamelObject *, gpointer);
typedef void (*CamelObjectEventHookFunc) (CamelObject *, gpointer, gpointer);
+typedef enum {
+ CAMEL_ERROR_SYSTEM,
+ CAMEL_ERROR_USER_CANCEL
+} CamelError;
+
/* camel object args. */
enum {
/* Get a description of the object. */
@@ -94,7 +101,7 @@ enum {
/* returned by get::CAMEL_OBJECT_METADATA */
struct _CamelObjectMeta {
- struct _CamelObjectMeta *next;
+ CamelObjectMeta *next;
gchar *value;
gchar name[1]; /* allocated as part of structure */
@@ -116,24 +123,25 @@ struct _CamelObjectClass {
/* root-class fields follow, type system above */
/* get/set interface */
- gint (*setv)(struct _CamelObject *, struct _CamelException *ex, CamelArgV *args);
- gint (*getv)(struct _CamelObject *, struct _CamelException *ex, CamelArgGetV *args);
+ gint (*setv)(CamelObject *, GError **error, CamelArgV *args);
+ gint (*getv)(CamelObject *, GError **error, CamelArgGetV *args);
/* we only free 1 at a time, and only pointer types, obviously */
- void (*free)(struct _CamelObject *, guint32 tag, gpointer ptr);
+ void (*free)(CamelObject *, guint32 tag, gpointer ptr);
/* get/set meta-data interface */
- gchar *(*meta_get)(struct _CamelObject *, const gchar * name);
- gboolean (*meta_set)(struct _CamelObject *, const gchar * name, const gchar *value);
+ gchar *(*meta_get)(CamelObject *, const gchar * name);
+ gboolean (*meta_set)(CamelObject *, const gchar * name, const gchar *value);
/* persistence stuff */
- gint (*state_read)(struct _CamelObject *, FILE *fp);
- gint (*state_write)(struct _CamelObject *, FILE *fp);
+ gint (*state_read)(CamelObject *, FILE *fp);
+ gint (*state_write)(CamelObject *, FILE *fp);
};
/* object class methods (types == classes now) */
void camel_object_class_add_event (CamelObjectClass *klass, const gchar *name, CamelObjectEventPrepFunc prep);
GType camel_object_get_type (void);
+GQuark camel_error_quark (void) G_GNUC_CONST;
/* hooks */
CamelObjectHookID camel_object_hook_event(gpointer obj, const gchar *name, CamelObjectEventHookFunc hook, gpointer data);
@@ -142,14 +150,14 @@ void camel_object_unhook_event(gpointer obj, const gchar *name, CamelObjectEvent
void camel_object_trigger_event(gpointer obj, const gchar *name, gpointer event_data);
/* get/set methods */
-gint camel_object_set(gpointer obj, struct _CamelException *ex, ...);
-gint camel_object_setv(gpointer obj, struct _CamelException *ex, CamelArgV *);
-gint camel_object_get(gpointer obj, struct _CamelException *ex, ...);
-gint camel_object_getv(gpointer obj, struct _CamelException *ex, CamelArgGetV *);
+gint camel_object_set(gpointer obj, GError **error, ...);
+gint camel_object_setv(gpointer obj, GError **error, CamelArgV *);
+gint camel_object_get(gpointer obj, GError **error, ...);
+gint camel_object_getv(gpointer obj, GError **error, CamelArgGetV *);
/* not very efficient one-time calls */
-gpointer camel_object_get_ptr(gpointer vo, CamelException *ex, gint tag);
-gint camel_object_get_int(gpointer vo, CamelException *ex, gint tag);
+gpointer camel_object_get_ptr(gpointer vo, GError **error, gint tag);
+gint camel_object_get_int(gpointer vo, GError **error, gint tag);
/* meta-data for user-specific data */
gchar *camel_object_meta_get(gpointer vo, const gchar * name);
diff --git a/camel/camel-offline-folder.c b/camel/camel-offline-folder.c
index 066d424..e85772d 100644
--- a/camel/camel-offline-folder.c
+++ b/camel/camel-offline-folder.c
@@ -60,11 +60,11 @@ offline_downsync_sync (CamelSession *session, CamelSessionThreadMsg *mm)
gint pc = i * 100 / m->changes->uid_added->len;
camel_operation_progress (NULL, pc);
- if ((message = camel_folder_get_message (m->folder, m->changes->uid_added->pdata[i], &mm->ex)))
+ if ((message = camel_folder_get_message (m->folder, m->changes->uid_added->pdata[i], &mm->error)))
g_object_unref (message);
}
} else {
- camel_offline_folder_downsync ((CamelOfflineFolder *) m->folder, "(match-all)", &mm->ex);
+ camel_offline_folder_downsync ((CamelOfflineFolder *) m->folder, "(match-all)", &mm->error);
}
camel_operation_end (NULL);
@@ -108,7 +108,7 @@ offline_folder_changed (CamelFolder *folder, CamelFolderChangeInfo *changes, gpo
static gint
offline_folder_getv (CamelObject *object,
- CamelException *ex,
+ GError **error,
CamelArgGetV *args)
{
CamelArgGetV props;
@@ -125,7 +125,7 @@ offline_folder_getv (CamelObject *object,
case CAMEL_FOLDER_ARG_PROPERTIES:
props.argc = 1;
props.argv[0] = *arg;
- ((CamelObjectClass *) parent_class)->getv (object, ex, &props);
+ ((CamelObjectClass *) parent_class)->getv (object, error, &props);
*arg->ca_ptr = g_slist_concat (*arg->ca_ptr, g_slist_copy (offline_folder_props));
break;
case CAMEL_OFFLINE_FOLDER_ARG_SYNC_OFFLINE:
@@ -140,14 +140,14 @@ offline_folder_getv (CamelObject *object,
}
if (count)
- return ((CamelObjectClass *) parent_class)->getv (object, ex, args);
+ return ((CamelObjectClass *) parent_class)->getv (object, error, args);
return 0;
}
static gint
offline_folder_setv (CamelObject *object,
- CamelException *ex,
+ GError **error,
CamelArgV *args)
{
CamelOfflineFolder *folder = (CamelOfflineFolder *) object;
@@ -177,13 +177,13 @@ offline_folder_setv (CamelObject *object,
if (save)
camel_object_state_write (object);
- return ((CamelObjectClass *) parent_class)->setv (object, ex, args);
+ return ((CamelObjectClass *) parent_class)->setv (object, error, args);
}
static void
offline_folder_downsync (CamelOfflineFolder *offline,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder = (CamelFolder *) offline;
GPtrArray *uids, *uncached_uids = NULL;
@@ -192,13 +192,13 @@ offline_folder_downsync (CamelOfflineFolder *offline,
camel_operation_start (NULL, _("Syncing messages in folder '%s' to disk"), folder->full_name);
if (expression)
- uids = camel_folder_search_by_expression (folder, expression, ex);
+ uids = camel_folder_search_by_expression (folder, expression, error);
else
uids = camel_folder_get_uids (folder);
if (!uids)
goto done;
- uncached_uids = camel_folder_get_uncached_uids(folder, uids, ex);
+ uncached_uids = camel_folder_get_uncached_uids(folder, uids, error);
if (uids) {
if (expression)
camel_folder_search_free (folder, uids);
@@ -211,7 +211,7 @@ offline_folder_downsync (CamelOfflineFolder *offline,
for (i = 0; i < uncached_uids->len; i++) {
gint pc = i * 100 / uncached_uids->len;
- camel_folder_sync_message (folder, uncached_uids->pdata[i], ex);
+ camel_folder_sync_message (folder, uncached_uids->pdata[i], error);
camel_operation_progress (NULL, pc);
}
@@ -275,7 +275,7 @@ camel_offline_folder_get_type (void)
* camel_offline_folder_downsync:
* @offline: a #CamelOfflineFolder object
* @expression: search expression describing which set of messages to downsync (%NULL for all)
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Syncs messages in @offline described by the search @expression to
* the local machine for offline availability.
@@ -283,7 +283,7 @@ camel_offline_folder_get_type (void)
void
camel_offline_folder_downsync (CamelOfflineFolder *offline,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelOfflineFolderClass *class;
@@ -292,5 +292,5 @@ camel_offline_folder_downsync (CamelOfflineFolder *offline,
class = CAMEL_OFFLINE_FOLDER_GET_CLASS (offline);
g_return_if_fail (class->downsync != NULL);
- class->downsync (offline, expression, ex);
+ class->downsync (offline, expression, error);
}
diff --git a/camel/camel-offline-folder.h b/camel/camel-offline-folder.h
index ea9d9e6..be8bc64 100644
--- a/camel/camel-offline-folder.h
+++ b/camel/camel-offline-folder.h
@@ -71,12 +71,12 @@ struct _CamelOfflineFolder {
struct _CamelOfflineFolderClass {
CamelFolderClass parent_class;
- void (* downsync) (CamelOfflineFolder *folder, const gchar *expression, CamelException *ex);
+ void (* downsync) (CamelOfflineFolder *folder, const gchar *expression, GError **error);
};
GType camel_offline_folder_get_type (void);
-void camel_offline_folder_downsync (CamelOfflineFolder *offline, const gchar *expression, CamelException *ex);
+void camel_offline_folder_downsync (CamelOfflineFolder *offline, const gchar *expression, GError **error);
G_END_DECLS
diff --git a/camel/camel-offline-journal.c b/camel/camel-offline-journal.c
index 85a0996..376715b 100644
--- a/camel/camel-offline-journal.c
+++ b/camel/camel-offline-journal.c
@@ -143,23 +143,26 @@ camel_offline_journal_set_filename (CamelOfflineJournal *journal, const gchar *f
/**
* camel_offline_journal_write:
* @journal: a #CamelOfflineJournal object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Save the journal to disk.
*
* Returns: %0 on success or %-1 on fail
**/
gint
-camel_offline_journal_write (CamelOfflineJournal *journal, CamelException *ex)
+camel_offline_journal_write (CamelOfflineJournal *journal,
+ GError **error)
{
CamelDListNode *entry;
FILE *fp;
gint fd;
if ((fd = g_open (journal->filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot write offline journal for folder '%s': %s"),
- journal->folder->full_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot write offline journal for folder '%s': %s"),
+ journal->folder->full_name, g_strerror (errno));
return -1;
}
@@ -180,9 +183,11 @@ camel_offline_journal_write (CamelOfflineJournal *journal, CamelException *ex)
exception:
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot write offline journal for folder '%s': %s"),
- journal->folder->full_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot write offline journal for folder '%s': %s"),
+ journal->folder->full_name, g_strerror (errno));
fclose (fp);
@@ -192,28 +197,29 @@ camel_offline_journal_write (CamelOfflineJournal *journal, CamelException *ex)
/**
* camel_offline_journal_replay:
* @journal: a #CamelOfflineJournal object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Replay all entries in the journal.
*
* Returns: %0 on success (no entry failed to replay) or %-1 on fail
**/
gint
-camel_offline_journal_replay (CamelOfflineJournal *journal, CamelException *ex)
+camel_offline_journal_replay (CamelOfflineJournal *journal,
+ GError **error)
{
CamelDListNode *entry, *next;
- CamelException lex;
+ GError *local_error = NULL;
gint failed = 0;
- camel_exception_init (&lex);
-
entry = journal->queue.head;
while (entry->next) {
next = entry->next;
- if (CAMEL_OFFLINE_JOURNAL_GET_CLASS (journal)->entry_play (journal, entry, &lex) == -1) {
- if (failed == 0)
- camel_exception_xfer (ex, &lex);
- camel_exception_clear (&lex);
+ if (CAMEL_OFFLINE_JOURNAL_GET_CLASS (journal)->entry_play (journal, entry, &local_error) == -1) {
+ if (failed == 0) {
+ g_propagate_error (error, local_error);
+ local_error = NULL;
+ }
+ g_clear_error (&local_error);
failed++;
} else {
camel_dlist_remove (entry);
diff --git a/camel/camel-offline-journal.h b/camel/camel-offline-journal.h
index ec21026..f280449 100644
--- a/camel/camel-offline-journal.h
+++ b/camel/camel-offline-journal.h
@@ -76,7 +76,7 @@ struct _CamelOfflineJournalClass {
CamelDListNode * (* entry_load) (CamelOfflineJournal *journal, FILE *in);
gint (* entry_write) (CamelOfflineJournal *journal, CamelDListNode *entry, FILE *out);
- gint (* entry_play) (CamelOfflineJournal *journal, CamelDListNode *entry, CamelException *ex);
+ gint (* entry_play) (CamelOfflineJournal *journal, CamelDListNode *entry, GError **error);
};
GType camel_offline_journal_get_type (void);
@@ -84,8 +84,8 @@ GType camel_offline_journal_get_type (void);
void camel_offline_journal_construct (CamelOfflineJournal *journal, struct _CamelFolder *folder, const gchar *filename);
void camel_offline_journal_set_filename (CamelOfflineJournal *journal, const gchar *filename);
-gint camel_offline_journal_write (CamelOfflineJournal *journal, CamelException *ex);
-gint camel_offline_journal_replay (CamelOfflineJournal *journal, CamelException *ex);
+gint camel_offline_journal_write (CamelOfflineJournal *journal, GError **error);
+gint camel_offline_journal_replay (CamelOfflineJournal *journal, GError **error);
G_END_DECLS
diff --git a/camel/camel-offline-store.c b/camel/camel-offline-store.c
index eb7c0e1..32a9920 100644
--- a/camel/camel-offline-store.c
+++ b/camel/camel-offline-store.c
@@ -33,26 +33,26 @@
static gpointer parent_class;
-static void
+static gboolean
offline_store_construct (CamelService *service,
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelOfflineStore *store = CAMEL_OFFLINE_STORE (service);
CamelServiceClass *service_class;
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (parent_class);
- service_class->construct (service, session, provider, url, ex);
-
- if (camel_exception_is_set (ex))
- return;
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
store->state = camel_session_is_online (session) ?
CAMEL_OFFLINE_STORE_NETWORK_AVAIL :
CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL;
+
+ return TRUE;
}
static void
@@ -93,13 +93,14 @@ camel_offline_store_get_type (void)
/**
* camel_offline_store_get_network_state:
* @store: a #CamelOfflineStore object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Return the network state either #CAMEL_OFFLINE_STORE_NETWORK_AVAIL
* or #CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL.
**/
gint
-camel_offline_store_get_network_state (CamelOfflineStore *store, CamelException *ex)
+camel_offline_store_get_network_state (CamelOfflineStore *store,
+ GError **error)
{
return store->state;
}
@@ -108,22 +109,22 @@ camel_offline_store_get_network_state (CamelOfflineStore *store, CamelException
* camel_offline_store_set_network_state:
* @store: a #CamelOfflineStore object
* @state: the network state
- * @ex: a #CamelException
+ * @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.
**/
void
-camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, CamelException *ex)
+camel_offline_store_set_network_state (CamelOfflineStore *store,
+ gint state,
+ GError **error)
{
- CamelException lex;
CamelService *service = CAMEL_SERVICE (store);
gboolean network_state = camel_session_get_network_state (service->session);
if (store->state == state)
return;
- camel_exception_init (&lex);
if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
/* network available -> network unavailable */
if (network_state) {
@@ -140,8 +141,7 @@ camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, Cam
if (G_TYPE_CHECK_INSTANCE_TYPE (folder, CAMEL_TYPE_OFFLINE_FOLDER)
&& (sync || ((CamelOfflineFolder *) folder)->sync_offline)) {
- camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex);
- camel_exception_clear (&lex);
+ camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, NULL);
}
g_object_unref (folder);
@@ -150,16 +150,15 @@ camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, Cam
g_ptr_array_free (folders, TRUE);
}
- camel_store_sync (CAMEL_STORE (store), FALSE, &lex);
- camel_exception_clear (&lex);
+ camel_store_sync (CAMEL_STORE (store), FALSE, NULL);
}
- if (!camel_service_disconnect (CAMEL_SERVICE (store), network_state, ex))
+ if (!camel_service_disconnect (CAMEL_SERVICE (store), network_state, error))
return;
} else {
store->state = state;
/* network unavailable -> network available */
- if (!camel_service_connect (CAMEL_SERVICE (store), ex)) {
+ if (!camel_service_connect (CAMEL_SERVICE (store), error)) {
store->state = CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL;
return;
}
@@ -169,13 +168,12 @@ camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, Cam
}
void
-camel_offline_store_prepare_for_offline (CamelOfflineStore *store, CamelException *ex)
+camel_offline_store_prepare_for_offline (CamelOfflineStore *store,
+ GError **error)
{
- CamelException lex;
CamelService *service = CAMEL_SERVICE (store);
gboolean network_state = camel_session_get_network_state (service->session);
- camel_exception_init (&lex);
if (network_state) {
if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
if (((CamelStore *) store)->folders) {
@@ -191,8 +189,7 @@ camel_offline_store_prepare_for_offline (CamelOfflineStore *store, CamelExceptio
if (G_TYPE_CHECK_INSTANCE_TYPE (folder, CAMEL_TYPE_OFFLINE_FOLDER)
&& (sync || ((CamelOfflineFolder *) folder)->sync_offline)) {
- camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex);
- camel_exception_clear (&lex);
+ camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, NULL);
}
g_object_unref (folder);
}
@@ -200,8 +197,6 @@ camel_offline_store_prepare_for_offline (CamelOfflineStore *store, CamelExceptio
}
}
- camel_store_sync (CAMEL_STORE (store), FALSE, &lex);
- camel_exception_clear (&lex);
-
+ camel_store_sync (CAMEL_STORE (store), FALSE, NULL);
}
}
diff --git a/camel/camel-offline-store.h b/camel/camel-offline-store.h
index 4cde7c4..636ef77 100644
--- a/camel/camel-offline-store.h
+++ b/camel/camel-offline-store.h
@@ -71,15 +71,15 @@ struct _CamelOfflineStore {
struct _CamelOfflineStoreClass {
CamelStoreClass parent_class;
- void (* set_network_state) (CamelOfflineStore *store, gint state, CamelException *ex);
+ void (* set_network_state) (CamelOfflineStore *store, gint state, GError **error);
};
GType camel_offline_store_get_type (void);
-void camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, CamelException *ex);
-gint camel_offline_store_get_network_state (CamelOfflineStore *store, CamelException *ex);
+void camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, GError **error);
+gint camel_offline_store_get_network_state (CamelOfflineStore *store, GError **error);
-void camel_offline_store_prepare_for_offline (CamelOfflineStore *store, CamelException *ex);
+void camel_offline_store_prepare_for_offline (CamelOfflineStore *store, GError **error);
G_END_DECLS
diff --git a/camel/camel-process.c b/camel/camel-process.c
index cfc767a..3b15a30 100644
--- a/camel/camel-process.c
+++ b/camel/camel-process.c
@@ -31,7 +31,12 @@
#include "camel-process.h"
pid_t
-camel_process_fork (const gchar *path, gchar **argv, gint *infd, gint *outfd, gint *errfd, CamelException *ex)
+camel_process_fork (const gchar *path,
+ gchar **argv,
+ gint *infd,
+ gint *outfd,
+ gint *errfd,
+ GError **error)
{
gint errnosav, fd[6], i;
pid_t pid;
@@ -42,9 +47,11 @@ camel_process_fork (const gchar *path, gchar **argv, gint *infd, gint *outfd, gi
for (i = 0; i < 6; i += 2) {
if (pipe (fd + i) == -1) {
errnosav = errno;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to create pipe to '%s': %s"),
- argv[0], g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to create pipe to '%s': %s"),
+ argv[0], g_strerror (errno));
for (i = 0; i < 6; i++) {
if (fd[i] == -1)
@@ -84,9 +91,11 @@ camel_process_fork (const gchar *path, gchar **argv, gint *infd, gint *outfd, gi
execv (path, argv);
_exit (255);
} else if (pid == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to create child process '%s': %s"),
- argv[0], g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to create child process '%s': %s"),
+ argv[0], g_strerror (errno));
for (i = 0; i < 6; i++)
close (fd[i]);
return -1;
diff --git a/camel/camel-process.h b/camel/camel-process.h
index adfff35..21ce9ad 100644
--- a/camel/camel-process.h
+++ b/camel/camel-process.h
@@ -31,11 +31,11 @@
#include <sys/types.h>
-#include <camel/camel-exception.h>
+#include <glib.h>
G_BEGIN_DECLS
-pid_t camel_process_fork (const gchar *path, gchar **argv, gint *infd, gint *outfd, gint *errfd, CamelException *ex);
+pid_t camel_process_fork (const gchar *path, gchar **argv, gint *infd, gint *outfd, gint *errfd, GError **error);
gint camel_process_wait (pid_t pid);
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 83f49eb..f785003 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -38,7 +38,6 @@
#include <glib/gstdio.h>
#include <gmodule.h>
-#include "camel-exception.h"
#include "camel-private.h"
#include "camel-provider.h"
#include "camel-string-utils.h"
@@ -164,14 +163,17 @@ camel_provider_init (void)
/**
* camel_provider_load:
* @path: the path to a shared library
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* Loads the provider at @path, and calls its initialization function,
* passing @session as an argument. The provider should then register
* itself with @session.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
-camel_provider_load(const gchar *path, CamelException *ex)
+gboolean
+camel_provider_load (const gchar *path,
+ GError **error)
{
GModule *module;
CamelProvider *(*provider_module_init) (void);
@@ -179,31 +181,35 @@ camel_provider_load(const gchar *path, CamelException *ex)
pthread_once(&setup_once, provider_setup);
if (!g_module_supported ()) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load %s: Module loading "
- "not supported on this system."),
- path);
- return;
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not load %s: Module loading "
+ "not supported on this system."), path);
+ return FALSE;
}
module = g_module_open (path, G_MODULE_BIND_LAZY);
- if (!module) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load %s: %s"),
- path, g_module_error ());
- return;
+ if (module == NULL) {
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not load %s: %s"),
+ path, g_module_error ());
+ return FALSE;
}
if (!g_module_symbol (module, "camel_provider_module_init",
(gpointer *)&provider_module_init)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load %s: No initialization "
- "code in module."), path);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not load %s: No initialization "
+ "code in module."), path);
g_module_close (module);
- return;
+ return FALSE;
}
provider_module_init ();
+
+ return TRUE;
}
/**
@@ -335,15 +341,16 @@ camel_provider_list(gboolean load)
/**
* camel_provider_get:
* @url_string: the URL for the service whose provider you want
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This returns the CamelProvider that would be used to handle
* @url_string, loading it in from disk if necessary.
*
- * Return value: the provider, or %NULL, in which case @ex will be set.
+ * Return value: the provider, or %NULL, in which case @error will be set.
**/
CamelProvider *
-camel_provider_get(const gchar *url_string, CamelException *ex)
+camel_provider_get (const gchar *url_string,
+ GError **error)
{
CamelProvider *provider = NULL;
gchar *protocol;
@@ -366,17 +373,18 @@ camel_provider_get(const gchar *url_string, CamelException *ex)
m = g_hash_table_lookup(module_table, protocol);
if (m && !m->loaded) {
m->loaded = 1;
- camel_provider_load(m->path, ex);
- if (camel_exception_is_set (ex))
+ if (!camel_provider_load (m->path, error))
goto fail;
}
provider = g_hash_table_lookup(provider_table, protocol);
}
if (provider == NULL)
- camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- _("No provider available for protocol '%s'"),
- protocol);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ _("No provider available for protocol '%s'"),
+ protocol);
fail:
UNLOCK();
@@ -388,7 +396,7 @@ fail:
* @provider: camel provider
* @url: a #CamelURL
* @auto_detected: output hash table of auto-detected values
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* After filling in the standard Username/Hostname/Port/Path settings
* (which must be set in @url), if the provider supports it, you
@@ -405,13 +413,15 @@ fail:
* Returns: 0 on success or -1 on fail.
**/
gint
-camel_provider_auto_detect (CamelProvider *provider, CamelURL *url,
- GHashTable **auto_detected, CamelException *ex)
+camel_provider_auto_detect (CamelProvider *provider,
+ CamelURL *url,
+ GHashTable **auto_detected,
+ GError **error)
{
g_return_val_if_fail (provider != NULL, -1);
if (provider->auto_detect) {
- return provider->auto_detect (url, auto_detected, ex);
+ return provider->auto_detect (url, auto_detected, error);
} else {
*auto_detected = NULL;
return 0;
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index 6e556a6..d4e0d11 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -32,7 +32,6 @@
#define CAMEL_PROVIDER_H
#include <camel/camel-object.h>
-#include <camel/camel-exception.h>
#include <camel/camel-url.h>
#define CAMEL_PROVIDER(obj) ((CamelProvider *)(obj))
@@ -144,7 +143,7 @@ typedef struct {
#define CAMEL_PROVIDER_CONF_DEFAULT_HOSTNAME { CAMEL_PROVIDER_CONF_LABEL, "hostname", NULL, N_("_Host:"), NULL }
#define CAMEL_PROVIDER_CONF_DEFAULT_PATH { CAMEL_PROVIDER_CONF_ENTRY, "path", NULL, N_("_Path:"), "" }
-typedef gint (*CamelProviderAutoDetectFunc) (CamelURL *url, GHashTable **auto_detected, CamelException *ex);
+typedef gint (*CamelProviderAutoDetectFunc) (CamelURL *url, GHashTable **auto_detected, GError **error);
typedef struct {
/* Provider name used in CamelURLs. */
@@ -221,18 +220,21 @@ struct _CamelProviderModule {
guint loaded:1;
};
-void camel_provider_init(void);
-
-void camel_provider_load(const gchar *path, CamelException *ex);
-void camel_provider_register(CamelProvider *provider);
-GList *camel_provider_list(gboolean load);
-CamelProvider *camel_provider_get(const gchar *url_string, CamelException *ex);
+void camel_provider_init (void);
+gboolean camel_provider_load (const gchar *path,
+ GError **error);
+void camel_provider_register (CamelProvider *provider);
+GList * camel_provider_list (gboolean load);
+CamelProvider * camel_provider_get (const gchar *url_string,
+ GError **error);
/* This is defined by each module, not by camel-provider.c. */
-void camel_provider_module_init(void);
+void camel_provider_module_init (void);
-gint camel_provider_auto_detect (CamelProvider *provider, CamelURL *url,
- GHashTable **auto_detected, CamelException *ex);
+gint camel_provider_auto_detect (CamelProvider *provider,
+ CamelURL *url,
+ GHashTable **auto_detected,
+ GError **error);
G_END_DECLS
diff --git a/camel/camel-sasl-anonymous.c b/camel/camel-sasl-anonymous.c
index 72f960d..72b66c6 100644
--- a/camel/camel-sasl-anonymous.c
+++ b/camel/camel-sasl-anonymous.c
@@ -45,15 +45,17 @@ static gpointer parent_class;
static GByteArray *
sasl_anonymous_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslAnonymous *sasl_anon = CAMEL_SASL_ANONYMOUS (sasl);
CamelInternetAddress *cia;
GByteArray *ret = NULL;
if (token) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Authentication failed."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Authentication failed."));
return NULL;
}
@@ -61,9 +63,11 @@ sasl_anonymous_challenge (CamelSasl *sasl,
case CAMEL_SASL_ANON_TRACE_EMAIL:
cia = camel_internet_address_new ();
if (camel_internet_address_add (cia, NULL, sasl_anon->trace_info) != 1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Invalid email address trace information:\n%s"),
- sasl_anon->trace_info);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Invalid email address trace information:\n%s"),
+ sasl_anon->trace_info);
g_object_unref (cia);
return NULL;
}
@@ -73,9 +77,11 @@ sasl_anonymous_challenge (CamelSasl *sasl,
break;
case CAMEL_SASL_ANON_TRACE_OPAQUE:
if (strchr (sasl_anon->trace_info, '@')) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Invalid opaque trace information:\n%s"),
- sasl_anon->trace_info);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Invalid opaque trace information:\n%s"),
+ sasl_anon->trace_info);
return NULL;
}
ret = g_byte_array_new ();
@@ -85,9 +91,11 @@ sasl_anonymous_challenge (CamelSasl *sasl,
ret = g_byte_array_new ();
break;
default:
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Invalid trace information:\n%s"),
- sasl_anon->trace_info);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Invalid trace information:\n%s"),
+ sasl_anon->trace_info);
return NULL;
}
diff --git a/camel/camel-sasl-cram-md5.c b/camel/camel-sasl-cram-md5.c
index cb43fb1..3f643e7 100644
--- a/camel/camel-sasl-cram-md5.c
+++ b/camel/camel-sasl-cram-md5.c
@@ -60,7 +60,7 @@ static gpointer parent_class;
static GByteArray *
sasl_cram_md5_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelService *service;
GChecksum *checksum;
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index 5eab30d..344fde1 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -782,7 +782,7 @@ sasl_digest_md5_finalize (GObject *object)
static GByteArray *
sasl_digest_md5_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslDigestMd5 *sasl_digest = CAMEL_SASL_DIGEST_MD5 (sasl);
struct _CamelSaslDigestMd5Private *priv = sasl_digest->priv;
@@ -807,8 +807,10 @@ sasl_digest_md5_challenge (CamelSasl *sasl,
switch (priv->state) {
case STATE_AUTH:
if (token->len > 2048) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server challenge too long (>2048 octets)"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Server challenge too long (>2048 octets)"));
return NULL;
}
@@ -816,15 +818,19 @@ sasl_digest_md5_challenge (CamelSasl *sasl,
priv->challenge = parse_server_challenge (tokens, &abort);
g_free (tokens);
if (!priv->challenge || abort) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server challenge invalid\n"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Server challenge invalid\n"));
return NULL;
}
if (priv->challenge->qop == QOP_INVALID) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server challenge contained invalid "
- "\"Quality of Protection\" token"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Server challenge contained invalid "
+ "\"Quality of Protection\" token"));
return NULL;
}
@@ -852,8 +858,11 @@ sasl_digest_md5_challenge (CamelSasl *sasl,
if (!tokens || !*tokens) {
g_free (tokens);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server response did not contain authorization data"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Server response did not contain "
+ "authorization data"));
return NULL;
}
@@ -870,8 +879,11 @@ sasl_digest_md5_challenge (CamelSasl *sasl,
if (!rspauth->value) {
g_free (rspauth->name);
g_free (rspauth);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server response contained incomplete authorization data"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Server response contained incomplete "
+ "authorization data"));
return NULL;
}
@@ -880,8 +892,10 @@ sasl_digest_md5_challenge (CamelSasl *sasl,
g_free (rspauth->name);
g_free (rspauth->value);
g_free (rspauth);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server response does not match"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Server response does not match"));
camel_sasl_set_authenticated (sasl, TRUE);
return NULL;
diff --git a/camel/camel-sasl-gssapi.c b/camel/camel-sasl-gssapi.c
index efcd2a0..e1a1691 100644
--- a/camel/camel-sasl-gssapi.c
+++ b/camel/camel-sasl-gssapi.c
@@ -95,7 +95,9 @@ struct _CamelSaslGssapiPrivate {
static gpointer parent_class;
static void
-gssapi_set_exception (OM_uint32 major, OM_uint32 minor, CamelException *ex)
+gssapi_set_exception (OM_uint32 major,
+ OM_uint32 minor,
+ GError **error)
{
const gchar *str;
@@ -145,7 +147,10 @@ gssapi_set_exception (OM_uint32 major, OM_uint32 minor, CamelException *ex)
str = _("Bad authentication response from server.");
}
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, str);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ "%s", str);
}
static void
@@ -168,7 +173,7 @@ sasl_gssapi_finalize (GObject *object)
static GByteArray *
sasl_gssapi_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslGssapiPrivate *priv;
CamelService *service;
@@ -192,7 +197,7 @@ sasl_gssapi_challenge (CamelSasl *sasl,
case GSSAPI_STATE_INIT:
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
- ai = camel_getaddrinfo(service->url->host?service->url->host:"localhost", NULL, &hints, ex);
+ ai = camel_getaddrinfo(service->url->host?service->url->host:"localhost", NULL, &hints, error);
if (ai == NULL)
return NULL;
@@ -205,7 +210,7 @@ sasl_gssapi_challenge (CamelSasl *sasl,
g_free (str);
if (major != GSS_S_COMPLETE) {
- gssapi_set_exception (major, minor, ex);
+ gssapi_set_exception (major, minor, error);
return NULL;
}
@@ -215,8 +220,10 @@ sasl_gssapi_challenge (CamelSasl *sasl,
break;
case GSSAPI_STATE_CONTINUE_NEEDED:
if (token == NULL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Bad authentication response from server."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Bad authentication response from server."));
return NULL;
}
@@ -239,7 +246,7 @@ sasl_gssapi_challenge (CamelSasl *sasl,
priv->state = GSSAPI_STATE_CONTINUE_NEEDED;
break;
default:
- gssapi_set_exception (major, minor, ex);
+ gssapi_set_exception (major, minor, error);
return NULL;
}
@@ -251,8 +258,10 @@ sasl_gssapi_challenge (CamelSasl *sasl,
break;
case GSSAPI_STATE_COMPLETE:
if (token == NULL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Bad authentication response from server."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Bad authentication response from server."));
return NULL;
}
@@ -261,13 +270,15 @@ sasl_gssapi_challenge (CamelSasl *sasl,
major = gss_unwrap (&minor, priv->ctx, &inbuf, &outbuf, &conf_state, &qop);
if (major != GSS_S_COMPLETE) {
- gssapi_set_exception (major, minor, ex);
+ gssapi_set_exception (major, minor, error);
return NULL;
}
if (outbuf.length < 4) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Bad authentication response from server."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Bad authentication response from server."));
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
#endif
@@ -276,8 +287,10 @@ sasl_gssapi_challenge (CamelSasl *sasl,
/* check that our desired security layer is supported */
if ((((guchar *) outbuf.value)[0] & DESIRED_SECURITY_LAYER) != DESIRED_SECURITY_LAYER) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Unsupported security layer."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Unsupported security layer."));
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
#endif
@@ -296,7 +309,7 @@ sasl_gssapi_challenge (CamelSasl *sasl,
major = gss_wrap (&minor, priv->ctx, FALSE, qop, &inbuf, &conf_state, &outbuf);
if (major != GSS_S_COMPLETE) {
- gssapi_set_exception (major, minor, ex);
+ gssapi_set_exception (major, minor, error);
g_free (str);
return NULL;
}
diff --git a/camel/camel-sasl-login.c b/camel/camel-sasl-login.c
index bfd8c4f..fc26faf 100644
--- a/camel/camel-sasl-login.c
+++ b/camel/camel-sasl-login.c
@@ -59,7 +59,7 @@ static gpointer parent_class;
static GByteArray *
sasl_login_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslLoginPrivate *priv;
GByteArray *buf = NULL;
@@ -88,10 +88,10 @@ sasl_login_challenge (CamelSasl *sasl,
camel_sasl_set_authenticated (sasl, TRUE);
break;
default:
- if (!camel_exception_is_set (ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Unknown authentication state."));
- }
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Unknown authentication state."));
}
priv->state++;
diff --git a/camel/camel-sasl-ntlm.c b/camel/camel-sasl-ntlm.c
index 27a2d03..1d5829b 100644
--- a/camel/camel-sasl-ntlm.c
+++ b/camel/camel-sasl-ntlm.c
@@ -661,7 +661,7 @@ deskey (DES_KS k, guchar *key, gint decrypt)
static GByteArray *
sasl_ntlm_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelService *service;
GByteArray *ret;
diff --git a/camel/camel-sasl-plain.c b/camel/camel-sasl-plain.c
index 7571ad4..e282264 100644
--- a/camel/camel-sasl-plain.c
+++ b/camel/camel-sasl-plain.c
@@ -54,7 +54,7 @@ static gpointer parent_class;
static GByteArray *
sasl_plain_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
GByteArray *buf = NULL;
CamelService *service;
diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c
index 2e870ca..2bff5ce 100644
--- a/camel/camel-sasl-popb4smtp.c
+++ b/camel/camel-sasl-popb4smtp.c
@@ -67,7 +67,7 @@ static gpointer parent_class;
static GByteArray *
sasl_popb4smtp_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
gchar *popuri;
CamelService *service;
@@ -79,15 +79,23 @@ sasl_popb4smtp_challenge (CamelSasl *sasl,
session = service->session;
camel_sasl_set_authenticated (sasl, FALSE);
- popuri = camel_session_get_password (session, service, NULL, _("POP Source URI"), "popb4smtp_uri", 0, ex);
+ popuri = camel_session_get_password (
+ session, service, NULL, _("POP Source URI"),
+ "popb4smtp_uri", 0, error);
if (popuri == NULL) {
- camel_exception_setv(ex, 1, _("POP Before SMTP auth using an unknown transport"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("POP Before SMTP auth using an unknown transport"));
return NULL;
}
if (g_ascii_strncasecmp(popuri, "pop:", 4) != 0) {
- camel_exception_setv(ex, 1, _("POP Before SMTP auth using a non-pop source"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("POP Before SMTP auth using a non-pop source"));
return NULL;
}
@@ -111,7 +119,7 @@ sasl_popb4smtp_challenge (CamelSasl *sasl,
}
/* connect to pop session */
- store = camel_session_get_store(session, popuri, ex);
+ store = camel_session_get_store(session, popuri, error);
if (store) {
camel_sasl_set_authenticated (sasl, TRUE);
g_object_unref (store);
diff --git a/camel/camel-sasl.c b/camel/camel-sasl.c
index 48b117c..224496f 100644
--- a/camel/camel-sasl.c
+++ b/camel/camel-sasl.c
@@ -276,7 +276,7 @@ camel_sasl_get_type (void)
* camel_sasl_challenge:
* @sasl: a #CamelSasl object
* @token: a token, or %NULL
- * @ex: a #CamelException
+ * @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
@@ -289,7 +289,7 @@ camel_sasl_get_type (void)
GByteArray *
camel_sasl_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslClass *class;
@@ -298,14 +298,14 @@ camel_sasl_challenge (CamelSasl *sasl,
class = CAMEL_SASL_GET_CLASS (sasl);
g_return_val_if_fail (class->challenge != NULL, NULL);
- return class->challenge (sasl, token, ex);
+ return class->challenge (sasl, token, error);
}
/**
* camel_sasl_challenge_base64:
* @sasl: a #CamelSasl object
* @token: a base64-encoded token
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* As with #camel_sasl_challenge, but the challenge @token and the
* response are both base64-encoded.
@@ -313,7 +313,9 @@ camel_sasl_challenge (CamelSasl *sasl,
* Returns: the base64 encoded challenge string
**/
gchar *
-camel_sasl_challenge_base64 (CamelSasl *sasl, const gchar *token, CamelException *ex)
+camel_sasl_challenge_base64 (CamelSasl *sasl,
+ const gchar *token,
+ GError **error)
{
GByteArray *token_binary, *ret_binary;
gchar *ret;
@@ -331,7 +333,7 @@ camel_sasl_challenge_base64 (CamelSasl *sasl, const gchar *token, CamelException
} else
token_binary = NULL;
- ret_binary = camel_sasl_challenge (sasl, token_binary, ex);
+ ret_binary = camel_sasl_challenge (sasl, token_binary, error);
if (token_binary)
g_byte_array_free (token_binary, TRUE);
if (!ret_binary)
diff --git a/camel/camel-sasl.h b/camel/camel-sasl.h
index 4eca4c2..3d47b51 100644
--- a/camel/camel-sasl.h
+++ b/camel/camel-sasl.h
@@ -28,7 +28,6 @@
#define CAMEL_SASL_H
#include <camel/camel-object.h>
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
/* Standard GObject macros */
@@ -66,14 +65,14 @@ struct _CamelSaslClass {
GByteArray * (*challenge) (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex);
+ GError **error);
};
GType camel_sasl_get_type (void);
/* public methods */
-GByteArray *camel_sasl_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex);
-gchar *camel_sasl_challenge_base64 (CamelSasl *sasl, const gchar *token, CamelException *ex);
+GByteArray *camel_sasl_challenge (CamelSasl *sasl, GByteArray *token, GError **error);
+gchar *camel_sasl_challenge_base64 (CamelSasl *sasl, const gchar *token, GError **error);
/* utility functions */
CamelSasl * camel_sasl_new (const gchar *service_name,
diff --git a/camel/camel-search-private.c b/camel/camel-search-private.c
index 582cc24..da3efc0 100644
--- a/camel/camel-search-private.c
+++ b/camel/camel-search-private.c
@@ -37,7 +37,6 @@
#include <libedataserver/e-sexp.h>
-#include "camel-exception.h"
#include "camel-mime-message.h"
#include "camel-multipart.h"
#include "camel-search-private.h"
@@ -54,8 +53,11 @@
A small issue is that case-insenstivity wont work entirely correct for utf8 strings. */
gint
-camel_search_build_match_regex (regex_t *pattern, camel_search_flags_t type, gint argc,
- struct _ESExpResult **argv, CamelException *ex)
+camel_search_build_match_regex (regex_t *pattern,
+ camel_search_flags_t type,
+ gint argc,
+ struct _ESExpResult **argv,
+ GError **error)
{
GString *match = g_string_new("");
gint c, i, count=0, err;
@@ -107,9 +109,10 @@ camel_search_build_match_regex (regex_t *pattern, camel_search_flags_t type, gin
gchar *buffer = g_malloc0 (len + 1);
regerror (err, pattern, buffer, len);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Regular expression compilation failed: %s: %s"),
- match->str, buffer);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Regular expression compilation failed: %s: %s"),
+ match->str, buffer);
regfree (pattern);
}
diff --git a/camel/camel-search-private.h b/camel/camel-search-private.h
index 17e9a6c..ae52f45 100644
--- a/camel/camel-search-private.h
+++ b/camel/camel-search-private.h
@@ -57,7 +57,7 @@ typedef enum {
} camel_search_t;
/* builds a regex that represents a string search */
-gint camel_search_build_match_regex(regex_t *pattern, camel_search_flags_t type, gint argc, struct _ESExpResult **argv, CamelException *ex);
+gint camel_search_build_match_regex(regex_t *pattern, camel_search_flags_t type, gint argc, struct _ESExpResult **argv, GError **error);
gboolean camel_search_message_body_contains(CamelDataWrapper *object, regex_t *pattern);
gboolean camel_search_header_match(const gchar *value, const gchar *match, camel_search_match_t how, camel_search_t type, const gchar *default_charset);
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 5708d59..5686dc8 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -35,7 +35,6 @@
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-operation.h"
#include "camel-private.h"
#include "camel-service.h"
@@ -55,17 +54,8 @@ service_finalize (GObject *object)
{
CamelService *service = CAMEL_SERVICE (object);
- if (service->status == CAMEL_SERVICE_CONNECTED) {
- CamelException ex;
-
- camel_exception_init (&ex);
- CAMEL_SERVICE_GET_CLASS (service)->disconnect (service, TRUE, &ex);
- if (camel_exception_is_set (&ex)) {
- w(g_warning ("service_finalize: silent disconnect failure: %s",
- camel_exception_get_description (&ex)));
- }
- camel_exception_clear (&ex);
- }
+ if (service->status == CAMEL_SERVICE_CONNECTED)
+ CAMEL_SERVICE_GET_CLASS (service)->disconnect (service, TRUE, NULL);
if (service->url)
camel_url_free (service->url);
@@ -82,7 +72,7 @@ service_finalize (GObject *object)
static gint
service_setv (CamelObject *object,
- CamelException *ex,
+ GError **error,
CamelArgV *args)
{
CamelService *service = (CamelService *) object;
@@ -141,17 +131,17 @@ service_setv (CamelObject *object,
/* FIXME: what if we are in the process of connecting? */
if (reconnect && service->status == CAMEL_SERVICE_CONNECTED) {
/* reconnect the service using the new URL */
- if (camel_service_disconnect (service, TRUE, ex))
- camel_service_connect (service, ex);
+ if (camel_service_disconnect (service, TRUE, error))
+ camel_service_connect (service, error);
}
/* Chain up to parent's setv() method. */
- return CAMEL_OBJECT_CLASS (parent_class)->setv (object, ex, args);
+ return CAMEL_OBJECT_CLASS (parent_class)->setv (object, error, args);
}
static gint
service_getv (CamelObject *object,
- CamelException *ex,
+ GError **error,
CamelArgGetV *args)
{
CamelService *service = (CamelService *) object;
@@ -195,15 +185,15 @@ service_getv (CamelObject *object,
}
/* Chain up to parent's getv() method. */
- return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
+ return CAMEL_OBJECT_CLASS (parent_class)->getv (object, error, args);
}
-static void
+static gboolean
service_construct (CamelService *service,
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
gchar *err, *url_string;
@@ -228,17 +218,22 @@ service_construct (CamelService *service,
service->status = CAMEL_SERVICE_DISCONNECTED;
- return;
+ return TRUE;
fail:
url_string = camel_url_to_string(url, CAMEL_URL_HIDE_PASSWORD);
- camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, err, url_string);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ err, url_string);
g_free(url_string);
+
+ return FALSE;
}
static gboolean
service_connect (CamelService *service,
- CamelException *ex)
+ GError **error)
{
/* Things like the CamelMboxStore can validly
* not define a connect function. */
@@ -248,7 +243,7 @@ service_connect (CamelService *service,
static gboolean
service_disconnect (CamelService *service,
gboolean clean,
- CamelException *ex)
+ GError **error)
{
/* We let people get away with not having a disconnect
* function -- CamelMboxStore, for example. */
@@ -263,7 +258,7 @@ service_cancel_connect (CamelService *service)
static GList *
service_query_auth_types (CamelService *service,
- CamelException *ex)
+ GError **error)
{
return NULL;
}
@@ -374,38 +369,53 @@ camel_service_get_type (void)
return type;
}
+GQuark
+camel_service_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0)) {
+ const gchar *string = "camel-service-error-quark";
+ quark = g_quark_from_static_string (string);
+ }
+
+ return quark;
+}
+
/**
* camel_service_construct:
* @service: a #CamelService object
* @session: the #CamelSession for @service
* @provider: the #CamelProvider associated with @service
* @url: the default URL for the service (may be %NULL)
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Constructs a #CamelService initialized with the given parameters.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_service_construct (CamelService *service,
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
- g_return_if_fail (CAMEL_IS_SERVICE (service));
- g_return_if_fail (CAMEL_IS_SESSION (session));
+ g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE);
class = CAMEL_SERVICE_GET_CLASS (service);
- g_return_if_fail (class->construct != NULL);
+ g_return_val_if_fail (class->construct != NULL, FALSE);
- class->construct (service, session, provider, url, ex);
+ return class->construct (service, session, provider, url, error);
}
/**
* camel_service_connect:
* @service: a #CamelService object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Connect to the service using the parameters it was initialized
* with.
@@ -414,7 +424,7 @@ camel_service_construct (CamelService *service,
**/
gboolean
camel_service_connect (CamelService *service,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
gboolean ret = FALSE;
@@ -448,7 +458,7 @@ camel_service_connect (CamelService *service,
CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
service->status = CAMEL_SERVICE_CONNECTING;
- ret = class->connect (service, ex);
+ ret = class->connect (service, error);
service->status = ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED;
CAMEL_SERVICE_LOCK (service, connect_op_lock);
@@ -470,7 +480,7 @@ camel_service_connect (CamelService *service,
* camel_service_disconnect:
* @service: a #CamelService object
* @clean: whether or not to try to disconnect cleanly
- * @ex: a #CamelException
+ * @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.
@@ -480,7 +490,7 @@ camel_service_connect (CamelService *service,
gboolean
camel_service_disconnect (CamelService *service,
gboolean clean,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
gboolean res = TRUE;
@@ -505,7 +515,7 @@ camel_service_disconnect (CamelService *service,
CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
service->status = CAMEL_SERVICE_DISCONNECTING;
- res = class->disconnect (service, clean, ex);
+ res = class->disconnect (service, clean, error);
service->status = CAMEL_SERVICE_DISCONNECTED;
CAMEL_SERVICE_LOCK (service, connect_op_lock);
@@ -653,7 +663,7 @@ camel_service_get_provider (CamelService *service)
/**
* camel_service_query_auth_types:
* @service: a #CamelService object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This is used by the mail source wizard to get the list of
* authentication types supported by the protocol, and information
@@ -664,7 +674,7 @@ camel_service_get_provider (CamelService *service)
**/
GList *
camel_service_query_auth_types (CamelService *service,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
GList *ret;
@@ -677,7 +687,7 @@ camel_service_query_auth_types (CamelService *service,
/* Note that we get the connect lock here, which means the
* callee must not call the connect functions itself. */
CAMEL_SERVICE_REC_LOCK (service, connect_lock);
- ret = class->query_auth_types (service, ex);
+ ret = class->query_auth_types (service, error);
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
return ret;
diff --git a/camel/camel-service.h b/camel/camel-service.h
index 2f112d9..60eaf07 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -53,6 +53,9 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_SERVICE, CamelServiceClass))
+#define CAMEL_SERVICE_ERROR \
+ (camel_service_error_quark ())
+
G_BEGIN_DECLS
struct _CamelSession;
@@ -61,6 +64,14 @@ typedef struct _CamelService CamelService;
typedef struct _CamelServiceClass CamelServiceClass;
typedef struct _CamelServicePrivate CamelServicePrivate;
+typedef enum {
+ CAMEL_SERVICE_ERROR_INVALID,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ CAMEL_SERVICE_ERROR_NOT_CONNECTED
+} CamelServiceError;
+
enum {
CAMEL_SERVICE_ARG_FIRST = CAMEL_ARG_FIRST + 100,
CAMEL_SERVICE_ARG_USERNAME,
@@ -97,25 +108,25 @@ struct _CamelService {
struct _CamelServiceClass {
CamelObjectClass parent_class;
- void (*construct) (CamelService *service,
- struct _CamelSession *session,
- CamelProvider *provider,
- CamelURL *url,
- CamelException *ex);
-
- gboolean (*connect) (CamelService *service,
- CamelException *ex);
- gboolean (*disconnect) (CamelService *service,
- gboolean clean,
- CamelException *ex);
- void (*cancel_connect) (CamelService *service);
-
- GList * (*query_auth_types) (CamelService *service,
- CamelException *ex);
-
- gchar * (*get_name) (CamelService *service,
- gboolean brief);
- gchar * (*get_path) (CamelService *service);
+ gboolean (*construct) (CamelService *service,
+ struct _CamelSession *session,
+ CamelProvider *provider,
+ CamelURL *url,
+ GError **error);
+
+ gboolean (*connect) (CamelService *service,
+ GError **error);
+ gboolean (*disconnect) (CamelService *service,
+ gboolean clean,
+ GError **error);
+ void (*cancel_connect) (CamelService *service);
+
+ GList * (*query_auth_types) (CamelService *service,
+ GError **error);
+
+ gchar * (*get_name) (CamelService *service,
+ gboolean brief);
+ gchar * (*get_path) (CamelService *service);
};
/* query_auth_types returns a GList of these */
@@ -127,28 +138,28 @@ typedef struct {
gboolean need_password; /* needs a password to authenticate */
} CamelServiceAuthType;
-/* public methods */
-void camel_service_construct (CamelService *service,
- struct _CamelSession *session,
- CamelProvider *provider,
- CamelURL *url,
- CamelException *ex);
-gboolean camel_service_connect (CamelService *service,
- CamelException *ex);
-gboolean camel_service_disconnect (CamelService *service,
- gboolean clean,
- CamelException *ex);
-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);
-struct _CamelSession * camel_service_get_session (CamelService *service);
-CamelProvider * camel_service_get_provider (CamelService *service);
-GList * camel_service_query_auth_types (CamelService *service,
- CamelException *ex);
-
-GType camel_service_get_type (void);
+GType camel_service_get_type (void);
+GQuark camel_service_error_quark (void) G_GNUC_CONST;
+gboolean camel_service_construct (CamelService *service,
+ struct _CamelSession *session,
+ 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);
+struct _CamelSession *
+ camel_service_get_session (CamelService *service);
+CamelProvider * camel_service_get_provider (CamelService *service);
+GList * camel_service_query_auth_types (CamelService *service,
+ GError **error);
G_END_DECLS
diff --git a/camel/camel-session.c b/camel/camel-session.c
index adad849..35b1d71 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -39,7 +39,6 @@
#include <libedataserver/e-data-server-util.h>
-#include "camel-exception.h"
#include "camel-file-utils.h"
#include "camel-private.h"
#include "camel-session.h"
@@ -105,24 +104,25 @@ static CamelService *
session_get_service (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex)
+ GError **error)
{
CamelURL *url;
CamelProvider *provider;
CamelService *service;
- CamelException internal_ex;
- url = camel_url_new (url_string, ex);
+ url = camel_url_new (url_string, error);
if (!url)
return NULL;
/* We need to look up the provider so we can then lookup
the service in the provider's cache */
- provider = camel_provider_get(url->protocol, ex);
+ provider = camel_provider_get(url->protocol, error);
if (provider && !provider->object_types[type]) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- _("No provider available for protocol '%s'"),
- url->protocol);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ _("No provider available for protocol '%s'"),
+ url->protocol);
provider = NULL;
}
@@ -141,10 +141,7 @@ session_get_service (CamelSession *session,
service = camel_object_bag_reserve(provider->service_cache[type], url);
if (service == NULL) {
service = g_object_new (provider->object_types[type], NULL);
- camel_exception_init (&internal_ex);
- camel_service_construct (service, session, provider, url, &internal_ex);
- if (camel_exception_is_set (&internal_ex)) {
- camel_exception_xfer (ex, &internal_ex);
+ if (!camel_service_construct (service, session, provider, url, error)) {
g_object_unref (service);
service = NULL;
camel_object_bag_abort(provider->service_cache[type], url);
@@ -161,7 +158,7 @@ session_get_service (CamelSession *session,
static gchar *
session_get_storage_path (CamelSession *session,
CamelService *service,
- CamelException *ex)
+ GError **error)
{
gchar *path, *p;
@@ -177,9 +174,11 @@ session_get_storage_path (CamelSession *session,
return path;
if (g_mkdir_with_parents (path, S_IRWXU) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create directory %s:\n%s"),
- path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not create directory %s:\n%s"),
+ path, g_strerror (errno));
g_free (path);
return NULL;
}
@@ -199,7 +198,6 @@ session_thread_msg_new (CamelSession *session,
m->session = session;
g_object_ref (session);
m->op = camel_operation_new(cs_thread_status, m);
- camel_exception_init(&m->ex);
CAMEL_SESSION_LOCK(session, thread_lock);
m->id = session->priv->thread_id++;
g_hash_table_insert(session->priv->thread_active, GINT_TO_POINTER(m->id), m);
@@ -227,7 +225,7 @@ session_thread_msg_free (CamelSession *session,
msg->ops->free(session, msg);
if (msg->op)
camel_operation_unref(msg->op);
- camel_exception_clear(&msg->ex);
+ g_clear_error (&msg->error);
g_object_unref (msg->session);
g_free(msg);
}
@@ -297,20 +295,6 @@ session_thread_status (CamelSession *session,
}
static void
-session_forward_to (CamelSession *session,
- CamelFolder *folder,
- CamelMimeMessage *message,
- const gchar *address,
- CamelException *ex)
-{
- if (ex)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Camel session doesn't support "
- "forwarding of a message."));
-}
-
-static void
session_class_init (CamelSessionClass *class)
{
GObjectClass *object_class;
@@ -329,7 +313,6 @@ session_class_init (CamelSessionClass *class)
class->thread_queue = session_thread_queue;
class->thread_wait = session_thread_wait;
class->thread_status = session_thread_status;
- class->forward_to = session_forward_to;
camel_object_class = CAMEL_OBJECT_CLASS (class);
camel_object_class_add_event (camel_object_class, "online", NULL);
@@ -390,7 +373,7 @@ camel_session_construct (CamelSession *session, const gchar *storage_path)
* @type: the provider type (#CAMEL_PROVIDER_STORE or
* #CAMEL_PROVIDER_TRANSPORT) to get, since some URLs may be able
* to specify either type.
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This resolves a #CamelURL into a #CamelService, including loading the
* provider library for that service if it has not already been loaded.
@@ -406,7 +389,7 @@ CamelService *
camel_session_get_service (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
CamelService *service;
@@ -418,7 +401,7 @@ camel_session_get_service (CamelSession *session,
g_return_val_if_fail (class->get_service != NULL, NULL);
CAMEL_SESSION_LOCK (session, lock);
- service = class->get_service (session, url_string, type, ex);
+ service = class->get_service (session, url_string, type, error);
CAMEL_SESSION_UNLOCK (session, lock);
return service;
@@ -429,7 +412,7 @@ camel_session_get_service (CamelSession *session,
* @session: a #CamelSession object
* @url_string: a #CamelURL describing the service to get
* @type: the provider type
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This works like #camel_session_get_service, but also ensures that
* the returned service will have been successfully connected (via
@@ -441,16 +424,16 @@ CamelService *
camel_session_get_service_connected (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex)
+ GError **error)
{
CamelService *svc;
- svc = camel_session_get_service (session, url_string, type, ex);
+ svc = camel_session_get_service (session, url_string, type, error);
if (svc == NULL)
return NULL;
if (svc->status != CAMEL_SERVICE_CONNECTED) {
- if (camel_service_connect (svc, ex) == FALSE) {
+ if (!camel_service_connect (svc, error)) {
g_object_unref (svc);
return NULL;
}
@@ -463,7 +446,7 @@ camel_session_get_service_connected (CamelSession *session,
* camel_session_get_storage_path:
* @session: a #CamelSession object
* @service: a #CamelService
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This returns the path to a directory which the service can use for
* its own purposes. Data stored there will remain between Evolution
@@ -477,7 +460,7 @@ camel_session_get_service_connected (CamelSession *session,
gchar *
camel_session_get_storage_path (CamelSession *session,
CamelService *service,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
@@ -487,7 +470,7 @@ camel_session_get_storage_path (CamelSession *session,
class = CAMEL_SESSION_GET_CLASS (session);
g_return_val_if_fail (class->get_storage_path != NULL, NULL);
- return class->get_storage_path (session, service, ex);
+ return class->get_storage_path (session, service, error);
}
/**
@@ -500,7 +483,7 @@ camel_session_get_storage_path (CamelSession *session,
* @flags: #CAMEL_SESSION_PASSWORD_REPROMPT, the prompt should force a reprompt
* #CAMEL_SESSION_PASSWORD_SECRET, whether the password is secret
* #CAMEL_SESSION_PASSWORD_STATIC, the password is remembered externally
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This function is used by a #CamelService to ask the application and
* the user for a password or other authentication data.
@@ -529,7 +512,7 @@ camel_session_get_password (CamelSession *session,
const gchar *prompt,
const gchar *item,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
@@ -541,7 +524,7 @@ camel_session_get_password (CamelSession *session,
g_return_val_if_fail (class->get_password != NULL, NULL);
return class->get_password (
- session, service, domain, prompt, item, flags, ex);
+ session, service, domain, prompt, item, flags, error);
}
/**
@@ -549,7 +532,7 @@ camel_session_get_password (CamelSession *session,
* @session: a #CamelSession object
* @service: the #CamelService rejecting the password
* @item: an identifier, unique within this service, for the information
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This function is used by a #CamelService to tell the application
* that the authentication information it provided via
@@ -565,7 +548,7 @@ camel_session_forget_password (CamelSession *session,
CamelService *service,
const gchar *domain,
const gchar *item,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
@@ -575,7 +558,7 @@ camel_session_forget_password (CamelSession *session,
class = CAMEL_SESSION_GET_CLASS (session);
g_return_if_fail (class->forget_password);
- class->forget_password (session, service, domain, item, ex);
+ class->forget_password (session, service, domain, item, error);
}
/**
@@ -698,14 +681,14 @@ camel_session_set_online (CamelSession *session, gboolean online)
* camel_session_get_filter_driver:
* @session: a #CamelSession object
* @type: the type of filter (eg, "incoming")
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Returns: a filter driver, loaded with applicable rules
**/
CamelFilterDriver *
camel_session_get_filter_driver (CamelSession *session,
const gchar *type,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
@@ -715,7 +698,7 @@ camel_session_get_filter_driver (CamelSession *session,
class = CAMEL_SESSION_GET_CLASS (session);
g_return_val_if_fail (class->get_filter_driver != NULL, NULL);
- return class->get_filter_driver (session, type, ex);
+ return class->get_filter_driver (session, type, error);
}
/**
@@ -917,7 +900,7 @@ camel_session_forward_to (CamelSession *session,
CamelFolder *folder,
CamelMimeMessage *message,
const gchar *address,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
@@ -929,5 +912,5 @@ camel_session_forward_to (CamelSession *session,
class = CAMEL_SESSION_GET_CLASS (session);
g_return_if_fail (class->forward_to != NULL);
- class->forward_to (session, folder, message, address, ex);
+ class->forward_to (session, folder, message, address, error);
}
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 215ef39..90dc412 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -97,10 +97,10 @@ struct _CamelSessionClass {
CamelService * (*get_service) (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex);
+ GError **error);
gchar * (*get_storage_path) (CamelSession *session,
CamelService *service,
- CamelException *ex);
+ GError **error);
gchar * (*get_password) (CamelSession *session,
CamelService *service,
@@ -108,12 +108,12 @@ struct _CamelSessionClass {
const gchar *prompt,
const gchar *item,
guint32 flags,
- CamelException *ex);
+ GError **error);
void (*forget_password) (CamelSession *session,
CamelService *service,
const gchar *domain,
const gchar *item,
- CamelException *ex);
+ GError **error);
gboolean (*alert_user) (CamelSession *session,
CamelSessionAlertType type,
const gchar *prompt,
@@ -121,7 +121,7 @@ struct _CamelSessionClass {
CamelFilterDriver * (*get_filter_driver) (CamelSession *session,
const gchar *type,
- CamelException *ex);
+ GError **error);
/* mechanism for creating and maintaining multiple threads of control */
gpointer (*thread_msg_new) (CamelSession *session,
@@ -144,7 +144,7 @@ struct _CamelSessionClass {
struct _CamelFolder *folder,
struct _CamelMimeMessage *message,
const gchar *address,
- CamelException *ex);
+ GError **error);
};
GType camel_session_get_type (void);
@@ -155,11 +155,11 @@ void camel_session_construct (CamelSession *session,
CamelService * camel_session_get_service (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex);
+ GError **error);
CamelService * camel_session_get_service_connected (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex);
+ GError **error);
#define camel_session_get_store(session, url_string, ex) \
((CamelStore *) camel_session_get_service_connected \
@@ -170,7 +170,7 @@ CamelService * camel_session_get_service_connected (CamelSession *session,
gchar * camel_session_get_storage_path (CamelSession *session,
CamelService *service,
- CamelException *ex);
+ GError **error);
gchar * camel_session_get_password (CamelSession *session,
CamelService *service,
@@ -178,12 +178,12 @@ gchar * camel_session_get_password (CamelSession *session,
const gchar *prompt,
const gchar *item,
guint32 flags,
- CamelException *ex);
+ GError **error);
void camel_session_forget_password (CamelSession *session,
CamelService *service,
const gchar *domain,
const gchar *item,
- CamelException *ex);
+ GError **error);
gboolean camel_session_alert_user (CamelSession *session,
CamelSessionAlertType type,
const gchar *prompt,
@@ -200,7 +200,7 @@ void camel_session_set_online (CamelSession *session,
CamelFilterDriver *camel_session_get_filter_driver (CamelSession *session,
const gchar *type,
- CamelException *ex);
+ GError **error);
gboolean camel_session_check_junk (CamelSession *session);
void camel_session_set_check_junk (CamelSession *session,
@@ -216,7 +216,7 @@ struct _CamelSessionThreadMsg {
gint id;
- CamelException ex;
+ GError *error;
CamelSessionThreadOps *ops;
struct _CamelOperation *op;
CamelSession *session;
@@ -250,7 +250,7 @@ void camel_session_forward_to (CamelSession *session,
struct _CamelFolder *folder,
struct _CamelMimeMessage *message,
const gchar *address,
- CamelException *ex);
+ GError **error);
G_END_DECLS
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index 62342c1..621d246 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -48,7 +48,6 @@
#include <glib/gi18n-lib.h>
#include "camel-data-wrapper.h"
-#include "camel-exception.h"
#include "camel-mime-filter-basic.h"
#include "camel-mime-filter-canon.h"
#include "camel-mime-part.h"
@@ -279,7 +278,8 @@ nss_error_to_string (glong errorcode)
}
static void
-set_nss_error (CamelException *ex, const gchar *def_error)
+set_nss_error (GError **error,
+ const gchar *def_error)
{
glong err_code;
@@ -288,7 +288,10 @@ set_nss_error (CamelException *ex, const gchar *def_error)
err_code = PORT_GetError ();
if (!err_code) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, def_error);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ "%s", def_error);
} else {
const gchar *err_str;
@@ -296,12 +299,19 @@ set_nss_error (CamelException *ex, const gchar *def_error)
if (!err_str)
err_str = "Uknown error.";
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "%s (%d) - %s", err_str, (gint) err_code, def_error);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ "%s (%d) - %s", err_str, (gint) err_code, def_error);
}
}
static NSSCMSMessage *
-sm_signing_cmsmessage (CamelSMIMEContext *context, const gchar *nick, SECOidTag hash, gint detached, CamelException *ex)
+sm_signing_cmsmessage (CamelSMIMEContext *context,
+ const gchar *nick,
+ SECOidTag hash,
+ gint detached,
+ GError **error)
{
CamelSMIMEContextPrivate *p = context->priv;
NSSCMSMessage *cmsg = NULL;
@@ -315,49 +325,51 @@ sm_signing_cmsmessage (CamelSMIMEContext *context, const gchar *nick, SECOidTag
certUsageEmailSigner,
PR_FALSE,
NULL)) == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot find certificate for '%s'"), nick);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot find certificate for '%s'"), nick);
return NULL;
}
cmsg = NSS_CMSMessage_Create (NULL); /* create a message on its own pool */
if (cmsg == NULL) {
- set_nss_error (ex, _("Cannot create CMS message"));
+ set_nss_error (error, _("Cannot create CMS message"));
goto fail;
}
if ((sigd = NSS_CMSSignedData_Create (cmsg)) == NULL) {
- set_nss_error (ex, _("Cannot create CMS signed data"));
+ set_nss_error (error, _("Cannot create CMS signed data"));
goto fail;
}
cinfo = NSS_CMSMessage_GetContentInfo (cmsg);
if (NSS_CMSContentInfo_SetContent_SignedData (cmsg, cinfo, sigd) != SECSuccess) {
- set_nss_error (ex, _("Cannot attach CMS signed data"));
+ set_nss_error (error, _("Cannot attach CMS signed data"));
goto fail;
}
/* if !detatched, the contentinfo will alloc a data item for us */
cinfo = NSS_CMSSignedData_GetContentInfo (sigd);
if (NSS_CMSContentInfo_SetContent_Data (cmsg, cinfo, NULL, detached) != SECSuccess) {
- set_nss_error (ex, _("Cannot attach CMS data"));
+ set_nss_error (error, _("Cannot attach CMS data"));
goto fail;
}
signerinfo = NSS_CMSSignerInfo_Create (cmsg, cert, hash);
if (signerinfo == NULL) {
- set_nss_error (ex, _("Cannot create CMS Signer information"));
+ set_nss_error (error, _("Cannot create CMS Signer information"));
goto fail;
}
/* we want the cert chain included for this one */
if (NSS_CMSSignerInfo_IncludeCerts (signerinfo, NSSCMSCM_CertChain, certUsageEmailSigner) != SECSuccess) {
- set_nss_error (ex, _("Cannot find certificate chain"));
+ set_nss_error (error, _("Cannot find certificate chain"));
goto fail;
}
/* SMIME RFC says signing time should always be added */
if (NSS_CMSSignerInfo_AddSigningTime (signerinfo, PR_Now ()) != SECSuccess) {
- set_nss_error (ex, _("Cannot add CMS Signing time"));
+ set_nss_error (error, _("Cannot add CMS Signing time"));
goto fail;
}
@@ -379,7 +391,10 @@ sm_signing_cmsmessage (CamelSMIMEContext *context, const gchar *nick, SECOidTag
p->certdb,
p->encrypt_key,
certUsageEmailRecipient, PR_FALSE, NULL)) == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Encryption certificate for '%s' does not exist"), p->encrypt_key);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Encryption certificate for '%s' does not exist"),
+ p->encrypt_key);
goto fail;
}
enccert = ekpcert;
@@ -391,30 +406,32 @@ sm_signing_cmsmessage (CamelSMIMEContext *context, const gchar *nick, SECOidTag
if ((ekpcert = CERT_FindUserCertByUsage (
p->certdb, (gchar *)nick,
certUsageEmailRecipient, PR_FALSE, NULL)) == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Encryption certificate for '%s' does not exist"), nick);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Encryption certificate for '%s' does not exist"), nick);
goto fail;
}
enccert = ekpcert;
}
if (NSS_CMSSignerInfo_AddSMIMEEncKeyPrefs (signerinfo, enccert, p->certdb) != SECSuccess) {
- set_nss_error (ex, _("Cannot add SMIMEEncKeyPrefs attribute"));
+ set_nss_error (error, _("Cannot add SMIMEEncKeyPrefs attribute"));
goto fail;
}
if (NSS_CMSSignerInfo_AddMSSMIMEEncKeyPrefs (signerinfo, enccert, p->certdb) != SECSuccess) {
- set_nss_error (ex, _("Cannot add MS SMIMEEncKeyPrefs attribute"));
+ set_nss_error (error, _("Cannot add MS SMIMEEncKeyPrefs attribute"));
goto fail;
}
if (ekpcert != NULL && NSS_CMSSignedData_AddCertificate (sigd, ekpcert) != SECSuccess) {
- set_nss_error (ex, _("Cannot add encryption certificate"));
+ set_nss_error (error, _("Cannot add encryption certificate"));
goto fail;
}
}
if (NSS_CMSSignedData_AddSignerInfo (sigd, signerinfo) != SECSuccess) {
- set_nss_error (ex, _("Cannot add CMS Signer information"));
+ set_nss_error (error, _("Cannot add CMS Signer information"));
goto fail;
}
@@ -469,7 +486,10 @@ sm_status_description (NSSCMSVerificationStatus status)
}
static CamelCipherValidity *
-sm_verify_cmsg (CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *extstream, CamelException *ex)
+sm_verify_cmsg (CamelCipherContext *context,
+ NSSCMSMessage *cmsg,
+ CamelStream *extstream,
+ GError **error)
{
CamelSMIMEContextPrivate *p = ((CamelSMIMEContext *)context)->priv;
NSSCMSSignedData *sigd = NULL;
@@ -503,17 +523,17 @@ sm_verify_cmsg (CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *e
case SEC_OID_PKCS7_SIGNED_DATA:
sigd = (NSSCMSSignedData *)NSS_CMSContentInfo_GetContent (cinfo);
if (sigd == NULL) {
- set_nss_error (ex, _("No signed data in signature"));
+ set_nss_error (error, _("No signed data in signature"));
goto fail;
}
if (extstream == NULL) {
- set_nss_error (ex, _("Digests missing from enveloped data"));
+ set_nss_error (error, _("Digests missing from enveloped data"));
goto fail;
}
if ((poolp = PORT_NewArena (1024)) == NULL) {
- set_nss_error (ex, g_strerror (ENOMEM));
+ set_nss_error (error, g_strerror (ENOMEM));
goto fail;
}
@@ -521,7 +541,7 @@ sm_verify_cmsg (CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *e
digcx = NSS_CMSDigestContext_StartMultiple (digestalgs);
if (digcx == NULL) {
- set_nss_error (ex, _("Cannot calculate digests"));
+ set_nss_error (error, _("Cannot calculate digests"));
goto fail;
}
@@ -532,18 +552,18 @@ sm_verify_cmsg (CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *e
g_object_unref (mem);
if (NSS_CMSDigestContext_FinishMultiple (digcx, poolp, &digests) != SECSuccess) {
- set_nss_error (ex, _("Cannot calculate digests"));
+ set_nss_error (error, _("Cannot calculate digests"));
goto fail;
}
for (which_digest = 0; digests[which_digest] != NULL; which_digest++) {
SECOidData *digest_alg = SECOID_FindOID (&digestalgs[which_digest]->algorithm);
if (digest_alg == NULL) {
- set_nss_error (ex, _("Cannot set message digests"));
+ set_nss_error (error, _("Cannot set message digests"));
goto fail;
}
if (NSS_CMSSignedData_SetDigestValue (sigd, digest_alg->offset, digests[which_digest]) != SECSuccess) {
- set_nss_error (ex, _("Cannot set message digests"));
+ set_nss_error (error, _("Cannot set message digests"));
goto fail;
}
}
@@ -553,12 +573,12 @@ sm_verify_cmsg (CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *e
/* import all certificates present */
if (NSS_CMSSignedData_ImportCerts (sigd, p->certdb, certUsageEmailSigner, PR_TRUE) != SECSuccess) {
- set_nss_error (ex, _("Certificate import failed"));
+ set_nss_error (error, _("Certificate import failed"));
goto fail;
}
if (NSS_CMSSignedData_ImportCerts (sigd, p->certdb, certUsageEmailRecipient, PR_TRUE) != SECSuccess) {
- set_nss_error (ex, _("Certificate import failed"));
+ set_nss_error (error, _("Certificate import failed"));
goto fail;
}
@@ -575,7 +595,7 @@ sm_verify_cmsg (CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *e
}
} else {
if (!NSS_CMSSignedData_HasDigests (sigd)) {
- set_nss_error (ex, _("Cannot find signature digests"));
+ set_nss_error (error, _("Cannot find signature digests"));
goto fail;
}
@@ -668,7 +688,7 @@ smime_context_sign (CamelCipherContext *context,
CamelCipherHash hash,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
gint res = -1;
@@ -693,8 +713,9 @@ smime_context_sign (CamelCipherContext *context,
break;
}
- cmsg = sm_signing_cmsmessage ((CamelSMIMEContext *)context, userid, sechash,
- ((CamelSMIMEContext *)context)->priv->sign_mode == CAMEL_SMIME_SIGN_CLEARSIGN, ex);
+ cmsg = sm_signing_cmsmessage (
+ (CamelSMIMEContext *)context, userid, sechash,
+ ((CamelSMIMEContext *)context)->priv->sign_mode == CAMEL_SMIME_SIGN_CLEARSIGN, error);
if (cmsg == NULL)
return -1;
@@ -708,8 +729,11 @@ smime_context_sign (CamelCipherContext *context,
CAMEL_MIME_FILTER_CANON_STRIP
|CAMEL_MIME_FILTER_CANON_CRLF
|CAMEL_MIME_FILTER_CANON_FROM, istream) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not generate signing data: %s"), g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not generate signing data: %s"),
+ g_strerror (errno));
goto fail;
}
@@ -720,18 +744,18 @@ smime_context_sign (CamelCipherContext *context,
NULL, NULL, /* decrypt key callback */
NULL, NULL ); /* detached digests */
if (!enc) {
- set_nss_error (ex, _("Cannot create encoder context"));
+ set_nss_error (error, _("Cannot create encoder context"));
goto fail;
}
if (NSS_CMSEncoder_Update (enc, (gchar *) buffer->data, buffer->len) != SECSuccess) {
NSS_CMSEncoder_Cancel (enc);
- set_nss_error (ex, _("Failed to add data to CMS encoder"));
+ set_nss_error (error, _("Failed to add data to CMS encoder"));
goto fail;
}
if (NSS_CMSEncoder_Finish (enc) != SECSuccess) {
- set_nss_error (ex, _("Failed to encode data"));
+ set_nss_error (error, _("Failed to encode data"));
goto fail;
}
@@ -798,7 +822,7 @@ fail:
static CamelCipherValidity *
smime_context_verify (CamelCipherContext *context,
CamelMimePart *ipart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
NSSCMSDecoderContext *dec;
@@ -829,26 +853,33 @@ smime_context_verify (CamelCipherContext *context,
|| tmp == NULL
|| (g_ascii_strcasecmp (tmp, class->sign_protocol) != 0
&& g_ascii_strcasecmp (tmp, "application/pkcs7-signature") != 0)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
goto fail;
}
- constream = camel_multipart_signed_get_content_stream ((CamelMultipartSigned *)mps, ex);
+ constream = camel_multipart_signed_get_content_stream (
+ (CamelMultipartSigned *)mps, error);
if (constream == NULL)
goto fail;
sigpart = camel_multipart_get_part (mps, CAMEL_MULTIPART_SIGNED_SIGNATURE);
if (sigpart == NULL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
goto fail;
}
} else if (camel_content_type_is (ct, "application", "x-pkcs7-mime")) {
sigpart = ipart;
} else {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: Incorrect message format"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
goto fail;
}
@@ -861,11 +892,11 @@ smime_context_verify (CamelCipherContext *context,
(void)NSS_CMSDecoder_Update (dec, (gchar *) buffer->data, buffer->len);
cmsg = NSS_CMSDecoder_Finish (dec);
if (cmsg == NULL) {
- set_nss_error (ex, _("Decoder failed"));
+ set_nss_error (error, _("Decoder failed"));
goto fail;
}
- valid = sm_verify_cmsg (context, cmsg, constream, ex);
+ valid = sm_verify_cmsg (context, cmsg, constream, error);
NSS_CMSMessage_Destroy (cmsg);
fail:
@@ -882,7 +913,7 @@ smime_context_encrypt (CamelCipherContext *context,
GPtrArray *recipients,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelSMIMEContextPrivate *p = ((CamelSMIMEContext *)context)->priv;
/*NSSCMSRecipientInfo **recipient_infos;*/
@@ -905,28 +936,31 @@ smime_context_encrypt (CamelCipherContext *context,
poolp = PORT_NewArena (1024);
if (poolp == NULL) {
- set_nss_error (ex, g_strerror (ENOMEM));
+ set_nss_error (error, g_strerror (ENOMEM));
return -1;
}
/* Lookup all recipients certs, for later working */
recipient_certs = (CERTCertificate **)PORT_ArenaZAlloc (poolp, sizeof (*recipient_certs[0])*(recipients->len + 1));
if (recipient_certs == NULL) {
- set_nss_error (ex, g_strerror (ENOMEM));
+ set_nss_error (error, g_strerror (ENOMEM));
goto fail;
}
for (i=0;i<recipients->len;i++) {
recipient_certs[i] = CERT_FindCertByNicknameOrEmailAddr (p->certdb, recipients->pdata[i]);
if (recipient_certs[i] == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot find certificate for '%s'"), recipients->pdata[i]);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot find certificate for '%s'"),
+ (gchar *) recipients->pdata[i]);
goto fail;
}
}
/* Find a common algorithm, probably 3DES anyway ... */
if (NSS_SMIMEUtil_FindBulkAlgForRecipients (recipient_certs, &bulkalgtag, &bulkkeysize) != SECSuccess) {
- set_nss_error (ex, _("Cannot find common bulk encryption algorithm"));
+ set_nss_error (error, _("Cannot find common bulk encryption algorithm"));
goto fail;
}
@@ -934,7 +968,7 @@ smime_context_encrypt (CamelCipherContext *context,
type = PK11_AlgtagToMechanism (bulkalgtag);
slot = PK11_GetBestSlot (type, context);
if (slot == NULL) {
- set_nss_error (ex, _("Cannot allocate slot for encryption bulk key"));
+ set_nss_error (error, _("Cannot allocate slot for encryption bulk key"));
goto fail;
}
@@ -945,25 +979,25 @@ smime_context_encrypt (CamelCipherContext *context,
/* msg->envelopedData->data */
cmsg = NSS_CMSMessage_Create (NULL);
if (cmsg == NULL) {
- set_nss_error (ex, _("Cannot create CMS Message"));
+ set_nss_error (error, _("Cannot create CMS Message"));
goto fail;
}
envd = NSS_CMSEnvelopedData_Create (cmsg, bulkalgtag, bulkkeysize);
if (envd == NULL) {
- set_nss_error (ex, _("Cannot create CMS Enveloped data"));
+ set_nss_error (error, _("Cannot create CMS Enveloped data"));
goto fail;
}
cinfo = NSS_CMSMessage_GetContentInfo (cmsg);
if (NSS_CMSContentInfo_SetContent_EnvelopedData (cmsg, cinfo, envd) != SECSuccess) {
- set_nss_error (ex, _("Cannot attach CMS Enveloped data"));
+ set_nss_error (error, _("Cannot attach CMS Enveloped data"));
goto fail;
}
cinfo = NSS_CMSEnvelopedData_GetContentInfo (envd);
if (NSS_CMSContentInfo_SetContent_Data (cmsg, cinfo, NULL, PR_FALSE) != SECSuccess) {
- set_nss_error (ex, _("Cannot attach CMS data object"));
+ set_nss_error (error, _("Cannot attach CMS data object"));
goto fail;
}
@@ -972,12 +1006,12 @@ smime_context_encrypt (CamelCipherContext *context,
NSSCMSRecipientInfo *ri = NSS_CMSRecipientInfo_Create (cmsg, recipient_certs[i]);
if (ri == NULL) {
- set_nss_error (ex, _("Cannot create CMS Recipient information"));
+ set_nss_error (error, _("Cannot create CMS Recipient information"));
goto fail;
}
if (NSS_CMSEnvelopedData_AddRecipient (envd, ri) != SECSuccess) {
- set_nss_error (ex, _("Cannot add CMS Recipient information"));
+ set_nss_error (error, _("Cannot add CMS Recipient information"));
goto fail;
}
}
@@ -991,7 +1025,7 @@ smime_context_encrypt (CamelCipherContext *context,
sm_decrypt_key, bulkkey,
NULL, NULL);
if (enc == NULL) {
- set_nss_error (ex, _("Cannot create encoder context"));
+ set_nss_error (error, _("Cannot create encoder context"));
goto fail;
}
@@ -1003,13 +1037,13 @@ smime_context_encrypt (CamelCipherContext *context,
if (NSS_CMSEncoder_Update (enc, (gchar *) buffer->data, buffer->len) != SECSuccess) {
NSS_CMSEncoder_Cancel (enc);
g_object_unref (mem);
- set_nss_error (ex, _("Failed to add data to encoder"));
+ set_nss_error (error, _("Failed to add data to encoder"));
goto fail;
}
g_object_unref (mem);
if (NSS_CMSEncoder_Finish (enc) != SECSuccess) {
- set_nss_error (ex, _("Failed to encode data"));
+ set_nss_error (error, _("Failed to encode data"));
goto fail;
}
@@ -1062,7 +1096,7 @@ static CamelCipherValidity *
smime_context_decrypt (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
NSSCMSDecoderContext *dec;
NSSCMSMessage *cmsg;
@@ -1097,7 +1131,7 @@ smime_context_decrypt (CamelCipherContext *context,
g_object_unref (istream);
if (cmsg == NULL) {
- set_nss_error (ex, _("Decoder failed"));
+ set_nss_error (error, _("Decoder failed"));
goto fail;
}
@@ -1115,7 +1149,7 @@ smime_context_decrypt (CamelCipherContext *context,
if (NSS_CMSMessage_IsSigned (cmsg)) {
camel_stream_reset (ostream);
- valid = sm_verify_cmsg (context, cmsg, ostream, ex);
+ valid = sm_verify_cmsg (context, cmsg, ostream, error);
} else {
valid = camel_cipher_validity_new ();
valid->encrypt.description = g_strdup (_("Encrypted content"));
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 66ce274..b3e9bd8 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -35,7 +35,6 @@
#include "camel-db.h"
#include "camel-debug.h"
-#include "camel-exception.h"
#include "camel-folder.h"
#include "camel-private.h"
#include "camel-session.h"
@@ -56,10 +55,13 @@ static gpointer parent_class;
* Clears the exception 'ex' when it's the 'no such table' exception.
**/
static void
-ignore_no_such_table_exception (CamelException *ex)
+ignore_no_such_table_exception (GError **error)
{
- if (ex && camel_exception_is_set (ex) && g_ascii_strncasecmp (camel_exception_get_description (ex), "no such table", 13) == 0)
- camel_exception_clear (ex);
+ if (error == NULL || *error == NULL)
+ return;
+
+ if (g_ascii_strncasecmp ((*error)->message, "no such table", 13) == 0)
+ g_clear_error (error);
}
static CamelFolder *
@@ -106,24 +108,26 @@ store_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static void
+static gboolean
store_construct (CamelService *service,
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelStore *store = CAMEL_STORE(service);
gchar *store_db_path, *store_path = NULL;
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ /* Chain up to parent's construct() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
store_db_path = g_build_filename (service->url->path, CAMEL_DB_FILE, NULL);
if (!service->url->path || strlen (store_db_path) < 2) {
- store_path = camel_session_get_storage_path (session, service, ex);
+ store_path = camel_session_get_storage_path (session, service, error);
g_free (store_db_path);
store_db_path = g_build_filename (store_path, CAMEL_DB_FILE, NULL);
@@ -137,113 +141,118 @@ store_construct (CamelService *service,
g_free (store_path);
/* This is for reading from the store */
- store->cdb_r = camel_db_open (store_db_path, ex);
+ store->cdb_r = camel_db_open (store_db_path, NULL);
if (camel_debug("sqlite"))
printf("store_db_path %s\n", store_db_path);
- if (camel_exception_is_set (ex)) {
+ if (store->cdb_r == NULL) {
gchar *store_path;
if (camel_debug("sqlite"))
g_print ("Failure for store_db_path : [%s]\n", store_db_path);
g_free (store_db_path);
- store_path = camel_session_get_storage_path (session, service, ex);
+ store_path = camel_session_get_storage_path (session, service, NULL);
store_db_path = g_build_filename (store_path, CAMEL_DB_FILE, NULL);
g_free (store_path);
- camel_exception_clear(ex);
- store->cdb_r = camel_db_open (store_db_path, ex);
- if (camel_exception_is_set (ex)) {
+
+ store->cdb_r = camel_db_open (store_db_path, NULL);
+ if (store->cdb_r == NULL) {
g_print("Retry with %s failed\n", store_db_path);
g_free(store_db_path);
- camel_exception_clear(ex);
- return;
+ return FALSE;
}
}
g_free (store_db_path);
- if (camel_db_create_folders_table (store->cdb_r, ex))
+ if (camel_db_create_folders_table (store->cdb_r, error)) {
g_warning ("something went wrong terribly during db creation \n");
- else {
- d(printf ("folders table successfully created \n"));
+ return FALSE;
}
- if (camel_exception_is_set (ex))
- return;
/* This is for writing to the store */
- store->cdb_w = camel_db_clone (store->cdb_r, ex);
+ store->cdb_w = camel_db_clone (store->cdb_r, error);
if (camel_url_get_param(url, "filter"))
store->flags |= CAMEL_STORE_FILTER_INBOX;
+
+ return TRUE;
}
static CamelFolder *
store_get_inbox (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
/* Assume the inbox's name is "inbox" and open with default flags. */
class = CAMEL_STORE_GET_CLASS (store);
- return class->get_folder (store, "inbox", 0, ex);
+ return class->get_folder (store, "inbox", 0, error);
}
static CamelFolder *
store_get_trash (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
return store_get_special (store, CAMEL_VTRASH_FOLDER_TRASH);
}
static CamelFolder *
store_get_junk (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
return store_get_special (store, CAMEL_VTRASH_FOLDER_JUNK);
}
-static void
+static gboolean
store_sync (CamelStore *store,
gint expunge,
- CamelException *ex)
+ GError **error)
{
GPtrArray *folders;
CamelFolder *folder;
- CamelException x;
+ gboolean success = TRUE;
gint i;
+ GError *local_error = NULL;
if (store->folders == NULL)
- return;
+ return TRUE;
/* We don't sync any vFolders, that is used to update certain
* vfolder queries mainly, and we're really only interested in
* storing/expunging the physical mails. */
- camel_exception_init(&x);
folders = camel_object_bag_list(store->folders);
for (i=0;i<folders->len;i++) {
folder = folders->pdata[i];
if (!CAMEL_IS_VEE_FOLDER(folder)
- && !camel_exception_is_set(&x)) {
- camel_folder_sync(folder, expunge, &x);
- ignore_no_such_table_exception (&x);
+ && local_error == NULL) {
+ camel_folder_sync(folder, expunge, &local_error);
+ ignore_no_such_table_exception (&local_error);
} else if (CAMEL_IS_VEE_FOLDER(folder))
camel_vee_folder_sync_headers(folder, NULL); /* Literally don't care of vfolder exceptions */
g_object_unref (folder);
}
- camel_exception_xfer(ex, &x);
- g_ptr_array_free(folders, TRUE);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ success = FALSE;
+ }
+
+ g_ptr_array_free (folders, TRUE);
+
+ return FALSE;
}
-static void
+static gboolean
store_noop (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
- /* no-op */
+ return TRUE;
}
static gboolean
store_can_refresh_folder (CamelStore *store,
CamelFolderInfo *info,
- CamelException *ex)
+ GError **error)
{
return ((info->flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX);
}
@@ -320,19 +329,35 @@ camel_store_get_type (void)
return type;
}
+GQuark
+camel_store_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0)) {
+ const gchar *string = "camel-store-error-quark";
+ quark = g_quark_from_static_string (string);
+ }
+
+ return quark;
+}
+
/**
* camel_store_get_folder:
* @store: a #CamelStore object
* @folder_name: name of the folder to get
* @flags: folder flags (create, save body index, etc)
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Get a specific folder object from the store by name.
*
* Returns: the folder corresponding to the path @folder_name or %NULL.
**/
CamelFolder *
-camel_store_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+camel_store_get_folder (CamelStore *store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error)
{
CamelFolder *folder = NULL;
@@ -347,9 +372,10 @@ camel_store_get_folder (CamelStore *store, const gchar *folder_name, guint32 fla
/* Try cache first. */
folder = camel_object_bag_reserve(store->folders, folder_name);
if (folder && (flags & CAMEL_STORE_FOLDER_EXCL)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': folder exists"),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot create folder '%s': folder exists"),
+ folder_name);
camel_object_bag_abort (store->folders, folder_name);
g_object_unref (folder);
return NULL;
@@ -373,11 +399,11 @@ camel_store_get_folder (CamelStore *store, const gchar *folder_name, guint32 fla
}
if ((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0) {
- folder = CAMEL_STORE_GET_CLASS(store)->get_trash(store, ex);
+ folder = CAMEL_STORE_GET_CLASS(store)->get_trash(store, error);
} else if ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0) {
- folder = CAMEL_STORE_GET_CLASS(store)->get_junk(store, ex);
+ folder = CAMEL_STORE_GET_CLASS(store)->get_junk(store, error);
} else {
- folder = CAMEL_STORE_GET_CLASS (store)->get_folder(store, folder_name, flags, ex);
+ folder = CAMEL_STORE_GET_CLASS (store)->get_folder(store, folder_name, flags, error);
if (folder) {
CamelVeeFolder *vfolder;
@@ -406,16 +432,6 @@ camel_store_get_folder (CamelStore *store, const gchar *folder_name, guint32 fla
camel_object_trigger_event(store, "folder_opened", folder);
}
- if (camel_debug_start(":store")) {
- gchar *u = camel_url_to_string(((CamelService *)store)->url, CAMEL_URL_HIDE_PASSWORD);
-
- printf("CamelStore('%s'):get_folder('%s', %u) = %p\n", u, folder_name, flags, (gpointer) folder);
- if (ex && ex->id)
- printf(" failed: '%s'\n", ex->desc);
- g_free(u);
- camel_debug_end();
- }
-
return folder;
}
@@ -424,7 +440,7 @@ camel_store_get_folder (CamelStore *store, const gchar *folder_name, guint32 fla
* @store: a #CamelStore object
* @parent_name: name of the new folder's parent, or %NULL
* @folder_name: name of the folder to create
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Creates a new folder as a child of an existing folder.
* @parent_name can be %NULL to create a new top-level folder.
@@ -436,7 +452,7 @@ CamelFolderInfo *
camel_store_create_folder (CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolderInfo *fi;
@@ -447,8 +463,11 @@ camel_store_create_folder (CamelStore *store,
if ((parent_name == NULL || parent_name[0] == 0)
&& (((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0)
|| ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0))) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_INVALID,
- _("Cannot create folder: %s: folder exists"), folder_name);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
+ _("Cannot create folder: %s: folder exists"),
+ folder_name);
return NULL;
}
@@ -456,7 +475,7 @@ camel_store_create_folder (CamelStore *store,
g_return_val_if_fail (class->create_folder != NULL, NULL);
CAMEL_STORE_LOCK(store, folder_lock);
- fi = class->create_folder (store, parent_name, folder_name, ex);
+ fi = class->create_folder (store, parent_name, folder_name, error);
CAMEL_STORE_UNLOCK(store, folder_lock);
return fi;
@@ -495,51 +514,55 @@ cs_delete_cached_folder(CamelStore *store, const gchar *folder_name)
* camel_store_delete_folder:
* @store: a #CamelStore object
* @folder_name: name of the folder to delete
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Deletes the named folder. The folder must be empty.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_store_delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
- CamelException local;
+ gboolean success;
+ GError *local_error = NULL;
- g_return_if_fail (CAMEL_IS_STORE (store));
- g_return_if_fail (folder_name != NULL);
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+ g_return_val_if_fail (folder_name != 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)
|| ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot delete folder: %s: Invalid operation"), folder_name);
- return;
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Cannot delete folder: %s: Invalid operation"),
+ folder_name);
+ return FALSE;
}
class = CAMEL_STORE_GET_CLASS (store);
- g_return_if_fail (class->delete_folder != NULL);
-
- camel_exception_init(&local);
+ g_return_val_if_fail (class->delete_folder != NULL, FALSE);
CAMEL_STORE_LOCK(store, folder_lock);
- class->delete_folder(store, folder_name, &local);
+ success = class->delete_folder (store, folder_name, &local_error);
/* ignore 'no such table' errors */
- if (camel_exception_is_set (&local) && camel_exception_get_description (&local) &&
- g_ascii_strncasecmp (camel_exception_get_description (&local), "no such table", 13) == 0)
- camel_exception_clear (&local);
+ if (local_error != NULL &&
+ g_ascii_strncasecmp (local_error->message, "no such table", 13) == 0)
+ g_clear_error (&local_error);
- if (!camel_exception_is_set(&local))
+ if (local_error == NULL)
cs_delete_cached_folder(store, folder_name);
- else {
- camel_exception_xfer(ex, &local);
- printf("excep: %s\n", camel_exception_get_description (ex));
- }
+ else
+ g_propagate_error (error, local_error);
CAMEL_STORE_UNLOCK(store, folder_lock);
+
+ return success;
}
/**
@@ -547,36 +570,44 @@ camel_store_delete_folder (CamelStore *store,
* @store: a #CamelStore object
* @old_namein: the current name of the folder
* @new_name: the new name of the folder
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Rename a named folder to a new name.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_store_rename_folder (CamelStore *store,
const gchar *old_namein,
const gchar *new_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolder *folder;
gint i, oldlen, namelen;
GPtrArray *folders = NULL;
gchar *old_name;
+ gboolean success;
- d(printf("store rename folder %s '%s' '%s'\n", ((CamelService *)store)->url->protocol, old_name, new_name));
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+ g_return_val_if_fail (old_namein != NULL, FALSE);
+ g_return_val_if_fail (new_name != NULL, FALSE);
if (strcmp(old_namein, new_name) == 0)
- return;
+ return TRUE;
if (((store->flags & CAMEL_STORE_VTRASH) && strcmp(old_namein, CAMEL_VTRASH_NAME) == 0)
|| ((store->flags & CAMEL_STORE_VJUNK) && strcmp(old_namein, CAMEL_VJUNK_NAME) == 0)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot rename folder: %s: Invalid operation"), old_namein);
- return;
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Cannot rename folder: %s: Invalid operation"),
+ old_namein);
+ return FALSE;
}
class = CAMEL_STORE_GET_CLASS (store);
- g_return_if_fail (class->rename_folder != NULL);
+ g_return_val_if_fail (class->rename_folder != NULL, FALSE);
/* need to save this, since old_namein might be folder->full_name, which could go away */
old_name = g_strdup(old_namein);
@@ -607,11 +638,11 @@ camel_store_rename_folder (CamelStore *store,
}
/* Now try the real rename (will emit renamed event) */
- class->rename_folder (store, old_name, new_name, ex);
+ success = class->rename_folder (store, old_name, new_name, error);
/* If it worked, update all open folders/unlock them */
if (folders) {
- if (!camel_exception_is_set(ex)) {
+ if (success) {
guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE;
CamelRenameInfo reninfo;
@@ -634,7 +665,7 @@ camel_store_rename_folder (CamelStore *store,
flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
reninfo.old_base = (gchar *)old_name;
- reninfo.new = class->get_folder_info(store, new_name, flags, ex);
+ reninfo.new = class->get_folder_info(store, new_name, flags, error);
if (reninfo.new != NULL) {
camel_object_trigger_event (store, "folder_renamed", &reninfo);
class->free_folder_info(store, reninfo.new);
@@ -653,19 +684,21 @@ camel_store_rename_folder (CamelStore *store,
g_ptr_array_free(folders, TRUE);
g_free(old_name);
+
+ return TRUE;
}
/**
* camel_store_get_inbox:
* @store: a #CamelStore object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Returns: the folder in the store into which new mail is delivered,
* or %NULL if no such folder exists.
**/
CamelFolder *
camel_store_get_inbox (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolder *folder;
@@ -676,7 +709,7 @@ camel_store_get_inbox (CamelStore *store,
g_return_val_if_fail (class->get_inbox != NULL, NULL);
CAMEL_STORE_LOCK(store, folder_lock);
- folder = class->get_inbox (store, ex);
+ folder = class->get_inbox (store, error);
CAMEL_STORE_UNLOCK(store, folder_lock);
return folder;
@@ -685,14 +718,14 @@ camel_store_get_inbox (CamelStore *store,
/**
* camel_store_get_trash:
* @store: a #CamelStore object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Returns: the folder in the store into which trash is delivered, or
* %NULL if no such folder exists.
**/
CamelFolder *
camel_store_get_trash (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
@@ -702,22 +735,23 @@ camel_store_get_trash (CamelStore *store,
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->get_trash != NULL, NULL);
- return class->get_trash (store, ex);
+ return class->get_trash (store, error);
}
- return camel_store_get_folder (store, CAMEL_VTRASH_NAME, 0, ex);
+ return camel_store_get_folder (store, CAMEL_VTRASH_NAME, 0, error);
}
/**
* camel_store_get_junk:
* @store: a #CamelStore object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Returns: the folder in the store into which junk is delivered, or
* %NULL if no such folder exists.
**/
CamelFolder *
-camel_store_get_junk (CamelStore *store, CamelException *ex)
+camel_store_get_junk (CamelStore *store,
+ GError **error)
{
g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
@@ -727,34 +761,36 @@ camel_store_get_junk (CamelStore *store, CamelException *ex)
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->get_junk != NULL, NULL);
- return class->get_junk (store, ex);
+ return class->get_junk (store, error);
}
- return camel_store_get_folder (store, CAMEL_VJUNK_NAME, 0, ex);
+ return camel_store_get_folder (store, CAMEL_VJUNK_NAME, 0, error);
}
/**
* camel_store_sync:
* @store: a #CamelStore object
* @expunge: %TRUE if an expunge should be done after sync or %FALSE otherwise
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Syncs any changes that have been made to the store object and its
* folders with the real store.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_store_sync (CamelStore *store,
gint expunge,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
- g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
class = CAMEL_STORE_GET_CLASS (store);
- g_return_if_fail (class->sync != NULL);
+ g_return_val_if_fail (class->sync != NULL, FALSE);
- class->sync (store, expunge, ex);
+ return class->sync (store, expunge, error);
}
static void
@@ -837,7 +873,7 @@ dump_fi(CamelFolderInfo *fi, gint depth)
* @store: a #CamelStore object
* @top: the name of the folder to start from
* @flags: various CAMEL_STORE_FOLDER_INFO_* flags to control behavior
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* This fetches information about the folder structure of @store,
* starting with @top, and returns a tree of CamelFolderInfo
@@ -865,7 +901,7 @@ CamelFolderInfo *
camel_store_get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolderInfo *info;
@@ -875,7 +911,7 @@ camel_store_get_folder_info (CamelStore *store,
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->get_folder_info != NULL, NULL);
- info = class->get_folder_info (store, top, flags, ex);
+ info = class->get_folder_info (store, top, flags, error);
if (info && (top == NULL || *top == '\0') && (flags & CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL) == 0) {
if (info->uri && (store->flags & CAMEL_STORE_VTRASH))
@@ -1203,85 +1239,92 @@ camel_store_folder_subscribed (CamelStore *store,
* camel_store_subscribe_folder:
* @store: a #CamelStore object
* @folder_name: full path of the folder
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Subscribe to the folder described by @folder_name.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_store_subscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
+ gboolean success;
- g_return_if_fail (CAMEL_IS_STORE (store));
- g_return_if_fail (folder_name != NULL);
- g_return_if_fail (store->flags & CAMEL_STORE_SUBSCRIPTIONS);
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+ g_return_val_if_fail (folder_name != NULL, FALSE);
+ g_return_val_if_fail (store->flags & CAMEL_STORE_SUBSCRIPTIONS, FALSE);
class = CAMEL_STORE_GET_CLASS (store);
- g_return_if_fail (class->subscribe_folder != NULL);
+ g_return_val_if_fail (class->subscribe_folder != NULL, FALSE);
CAMEL_STORE_LOCK (store, folder_lock);
- class->subscribe_folder (store, folder_name, ex);
+ success = class->subscribe_folder (store, folder_name, error);
CAMEL_STORE_UNLOCK (store, folder_lock);
+
+ return success;
}
/**
* camel_store_unsubscribe_folder:
* @store: a #CamelStore object
* @folder_name: full path of the folder
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Unsubscribe from the folder described by @folder_name.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_store_unsubscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
- CamelException local;
+ gboolean success;
- g_return_if_fail (CAMEL_IS_STORE (store));
- g_return_if_fail (folder_name != NULL);
- g_return_if_fail (store->flags & CAMEL_STORE_SUBSCRIPTIONS);
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+ g_return_val_if_fail (folder_name != NULL, FALSE);
+ g_return_val_if_fail (store->flags & CAMEL_STORE_SUBSCRIPTIONS, FALSE);
class = CAMEL_STORE_GET_CLASS (store);
- g_return_if_fail (class->unsubscribe_folder != NULL);
-
- camel_exception_init (&local);
+ g_return_val_if_fail (class->unsubscribe_folder != NULL, FALSE);
CAMEL_STORE_LOCK (store, folder_lock);
- class->unsubscribe_folder (store, folder_name, ex);
+ success = class->unsubscribe_folder (store, folder_name, error);
- if (!camel_exception_is_set (&local))
+ if (success)
cs_delete_cached_folder (store, folder_name);
- else
- camel_exception_xfer (ex, &local);
CAMEL_STORE_UNLOCK (store, folder_lock);
+
+ return success;
}
/**
* camel_store_noop:
* @store: a #CamelStore object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Pings @store so that its connection doesn't timeout.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
**/
-void
+gboolean
camel_store_noop (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
- g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
class = CAMEL_STORE_GET_CLASS (store);
- g_return_if_fail (class->noop != NULL);
+ g_return_val_if_fail (class->noop != NULL, FALSE);
- class->noop (store, ex);
+ return class->noop (store, error);
}
/**
@@ -1346,7 +1389,7 @@ camel_store_folder_uri_equal (CamelStore *store,
* camel_store_can_refresh_folder
* @store: a #CamelStore
* @info: a #CamelFolderInfo
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Returns if this folder (param info) should be checked for new mail or not.
* It should not look into sub infos (info->child) or next infos, it should
@@ -1358,7 +1401,7 @@ camel_store_folder_uri_equal (CamelStore *store,
gboolean
camel_store_can_refresh_folder (CamelStore *store,
CamelFolderInfo *info,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
@@ -1368,5 +1411,5 @@ camel_store_can_refresh_folder (CamelStore *store,
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->can_refresh_folder != NULL, FALSE);
- return class->can_refresh_folder (store, info, ex);
+ return class->can_refresh_folder (store, info, error);
}
diff --git a/camel/camel-store.h b/camel/camel-store.h
index 3f8453f..06c9c2e 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -57,8 +57,16 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_STORE, CamelStoreClass))
+#define CAMEL_STORE_ERROR \
+ (camel_store_error_quark ())
+
G_BEGIN_DECLS
+typedef enum {
+ CAMEL_STORE_ERROR_INVALID,
+ CAMEL_STORE_ERROR_NO_FOLDER
+} CamelStoreError;
+
enum {
CAMEL_STORE_ARG_FIRST = CAMEL_SERVICE_ARG_FIRST + 100
};
@@ -180,126 +188,126 @@ struct _CamelStore {
struct _CamelStoreClass {
CamelServiceClass parent_class;
- GHashFunc hash_folder_name;
- GCompareFunc compare_folder_name;
-
- CamelFolder * (*get_folder) (CamelStore *store,
- const gchar *folder_name,
- guint32 flags,
- CamelException *ex);
-
- CamelFolder * (*get_inbox) (CamelStore *store, CamelException *ex);
- CamelFolder * (*get_trash) (CamelStore *store, CamelException *ex);
- CamelFolder * (*get_junk) (CamelStore *store, CamelException *ex);
-
- CamelFolderInfo *(*create_folder) (CamelStore *store,
- const gchar *parent_name,
- const gchar *folder_name,
- CamelException *ex);
- void (*delete_folder) (CamelStore *store,
- const gchar *folder_name,
- CamelException *ex);
- void (*rename_folder) (CamelStore *store,
- const gchar *old_name,
- const gchar *new_name,
- CamelException *ex);
-
- void (*sync) (CamelStore *store, gint expunge, CamelException *ex);
-
- CamelFolderInfo *(*get_folder_info) (CamelStore *store,
- const gchar *top,
- guint32 flags,
- CamelException *ex);
- void (*free_folder_info) (CamelStore *store,
- CamelFolderInfo *fi);
-
- gboolean (*folder_subscribed) (CamelStore *store,
- const gchar *folder_name);
- void (*subscribe_folder) (CamelStore *store,
- const gchar *folder_name,
- CamelException *ex);
- void (*unsubscribe_folder) (CamelStore *store,
- const gchar *folder_name,
- CamelException *ex);
- void (*noop) (CamelStore *store,
- CamelException *ex);
-
- gboolean (*can_refresh_folder) (CamelStore *store,
- CamelFolderInfo *info,
- CamelException *ex);
-};
+ GHashFunc hash_folder_name;
+ GCompareFunc compare_folder_name;
-GType camel_store_get_type (void);
+ CamelFolder * (*get_folder) (CamelStore *store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error);
+ CamelFolder * (*get_inbox) (CamelStore *store,
+ GError **error);
+ CamelFolder * (*get_trash) (CamelStore *store,
+ GError **error);
+ CamelFolder * (*get_junk) (CamelStore *store,
+ GError **error);
+ CamelFolderInfo *
+ (*create_folder) (CamelStore *store,
+ const gchar *parent_name,
+ const gchar *folder_name,
+ GError **error);
+ gboolean (*delete_folder) (CamelStore *store,
+ const gchar *folder_name,
+ GError **error);
+ gboolean (*rename_folder) (CamelStore *store,
+ const gchar *old_name,
+ const gchar *new_name,
+ GError **error);
+ gboolean (*sync) (CamelStore *store,
+ gint expunge,
+ GError **error);
+ CamelFolderInfo *
+ (*get_folder_info) (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error);
+ void (*free_folder_info) (CamelStore *store,
+ CamelFolderInfo *fi);
+ gboolean (*folder_subscribed) (CamelStore *store,
+ const gchar *folder_name);
+ gboolean (*subscribe_folder) (CamelStore *store,
+ const gchar *folder_name,
+ GError **error);
+ gboolean (*unsubscribe_folder) (CamelStore *store,
+ const gchar *folder_name,
+ GError **error);
+ gboolean (*noop) (CamelStore *store,
+ GError **error);
+ gboolean (*can_refresh_folder) (CamelStore *store,
+ CamelFolderInfo *info,
+ GError **error);
+};
-/* public methods */
-CamelFolder * camel_store_get_folder (CamelStore *store,
+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,
- CamelException *ex);
-CamelFolder * camel_store_get_inbox (CamelStore *store,
- CamelException *ex);
-CamelFolder * camel_store_get_trash (CamelStore *store,
- CamelException *ex);
-CamelFolder * camel_store_get_junk (CamelStore *store,
- CamelException *ex);
-
-CamelFolderInfo *camel_store_create_folder (CamelStore *store,
+ GError **error);
+CamelFolder * camel_store_get_inbox (CamelStore *store,
+ GError **error);
+CamelFolder * camel_store_get_trash (CamelStore *store,
+ GError **error);
+CamelFolder * camel_store_get_junk (CamelStore *store,
+ GError **error);
+CamelFolderInfo *
+ camel_store_create_folder (CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
- CamelException *ex);
-void camel_store_delete_folder (CamelStore *store,
+ GError **error);
+gboolean camel_store_delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex);
-void camel_store_rename_folder (CamelStore *store,
+ GError **error);
+gboolean camel_store_rename_folder (CamelStore *store,
const gchar *old_namein,
const gchar *new_name,
- CamelException *ex);
-
-void camel_store_sync (CamelStore *store, gint expunge, CamelException *ex);
-
-CamelFolderInfo *camel_store_get_folder_info (CamelStore *store,
+ GError **error);
+gboolean camel_store_sync (CamelStore *store,
+ gint expunge,
+ GError **error);
+CamelFolderInfo *
+ camel_store_get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex);
-void camel_store_free_folder_info (CamelStore *store,
+ GError **error);
+void camel_store_free_folder_info (CamelStore *store,
CamelFolderInfo *fi);
+void camel_store_free_folder_info_full
+ (CamelStore *store,
+ CamelFolderInfo *fi);
+void camel_store_free_folder_info_nop(CamelStore *store,
+ CamelFolderInfo *fi);
+CamelFolderInfo *
+ camel_folder_info_new (void);
+void camel_folder_info_free (CamelFolderInfo *fi);
+CamelFolderInfo *
+ camel_folder_info_clone (CamelFolderInfo *fi);
+gboolean camel_store_supports_subscriptions
+ (CamelStore *store);
+gboolean camel_store_folder_subscribed (CamelStore *store,
+ const gchar *folder_name);
+gboolean camel_store_subscribe_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error);
+gboolean camel_store_unsubscribe_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error);
+gboolean camel_store_noop (CamelStore *store,
+ GError **error);
+gint camel_store_folder_uri_equal (CamelStore *store,
+ const gchar *uri0,
+ const gchar *uri1);
+gboolean camel_store_can_refresh_folder (CamelStore *store,
+ CamelFolderInfo *info,
+ GError **error);
-void camel_store_free_folder_info_full (CamelStore *store,
- CamelFolderInfo *fi);
-void camel_store_free_folder_info_nop (CamelStore *store,
- CamelFolderInfo *fi);
-
-CamelFolderInfo *camel_folder_info_new (void);
-void camel_folder_info_free (CamelFolderInfo *fi);
#ifndef CAMEL_DISABLE_DEPRECATED
-CamelFolderInfo *camel_folder_info_build (GPtrArray *folders,
- const gchar *namespace,
- gchar separator,
- gboolean short_names);
+CamelFolderInfo *
+ camel_folder_info_build (GPtrArray *folders,
+ const gchar *namespace,
+ gchar separator,
+ gboolean short_names);
#endif /* CAMEL_DISABLE_DEPRECATED */
-CamelFolderInfo *camel_folder_info_clone (CamelFolderInfo *fi);
-
-gboolean camel_store_supports_subscriptions (CamelStore *store);
-
-gboolean camel_store_folder_subscribed (CamelStore *store,
- const gchar *folder_name);
-void camel_store_subscribe_folder (CamelStore *store,
- const gchar *folder_name,
- CamelException *ex);
-void camel_store_unsubscribe_folder (CamelStore *store,
- const gchar *folder_name,
- CamelException *ex);
-
-void camel_store_noop (CamelStore *store,
- CamelException *ex);
-
-gint camel_store_folder_uri_equal (CamelStore *store,
- const gchar *uri0,
- const gchar *uri1);
-
-gboolean camel_store_can_refresh_folder (CamelStore *store,
- CamelFolderInfo *info,
- CamelException *ex);
G_END_DECLS
diff --git a/camel/camel-text-index.h b/camel/camel-text-index.h
index 48c5c6a..75da888 100644
--- a/camel/camel-text-index.h
+++ b/camel/camel-text-index.h
@@ -26,7 +26,6 @@
#ifndef CAMEL_TEXT_INDEX_H
#define CAMEL_TEXT_INDEX_H
-#include <camel/camel-exception.h>
#include <camel/camel-object.h>
#include "camel-index.h"
diff --git a/camel/camel-transport.c b/camel/camel-transport.c
index 986fd8d..2a6c4b6 100644
--- a/camel/camel-transport.c
+++ b/camel/camel-transport.c
@@ -95,7 +95,7 @@ camel_transport_get_type (void)
* @message: a #CamelMimeMessage to send
* @from: a #CamelAddress to send from
* @recipients: a #CamelAddress containing all recipients
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Sends the message to the given recipients, regardless of the contents
* of @message. If the message contains a "Bcc" header, the transport
@@ -108,7 +108,7 @@ camel_transport_send_to (CamelTransport *transport,
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex)
+ GError **error)
{
CamelTransportClass *class;
gboolean sent;
@@ -122,7 +122,7 @@ camel_transport_send_to (CamelTransport *transport,
g_return_val_if_fail (class->send_to != NULL, FALSE);
CAMEL_TRANSPORT_LOCK (transport, send_lock);
- sent = class->send_to (transport, message, from, recipients, ex);
+ sent = class->send_to (transport, message, from, recipients, error);
CAMEL_TRANSPORT_UNLOCK (transport, send_lock);
return sent;
diff --git a/camel/camel-transport.h b/camel/camel-transport.h
index 3656287..6aae022 100644
--- a/camel/camel-transport.h
+++ b/camel/camel-transport.h
@@ -74,7 +74,7 @@ struct _CamelTransportClass {
gboolean (*send_to) (CamelTransport *transport,
CamelMimeMessage *message,
CamelAddress *from, CamelAddress *recipients,
- CamelException *ex);
+ GError **error);
};
/* public methods */
@@ -82,7 +82,7 @@ gboolean camel_transport_send_to (CamelTransport *transport,
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex);
+ GError **error);
GType camel_transport_get_type (void);
diff --git a/camel/camel-url.c b/camel/camel-url.c
index 96399a8..cee3f0c 100644
--- a/camel/camel-url.c
+++ b/camel/camel-url.c
@@ -34,9 +34,9 @@
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-mime-utils.h"
#include "camel-object.h"
+#include "camel-service.h"
#include "camel-string-utils.h"
#include "camel-url.h"
@@ -290,14 +290,15 @@ copy_param (GQuark key_id, gpointer data, gpointer user_data)
/**
* camel_url_new:
* @url_string: a URL string
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Parses an absolute URL.
*
* Returns: a #CamelURL if it can be parsed, or %NULL otherwise
**/
CamelURL *
-camel_url_new (const gchar *url_string, CamelException *ex)
+camel_url_new (const gchar *url_string,
+ GError **error)
{
CamelURL *url;
@@ -308,9 +309,9 @@ camel_url_new (const gchar *url_string, CamelException *ex)
if (!url->protocol) {
camel_url_free (url);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- _("Could not parse URL '%s'"),
- url_string);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not parse URL '%s'"), url_string);
return NULL;
}
return url;
diff --git a/camel/camel-url.h b/camel/camel-url.h
index d326bdb..bbd571e 100644
--- a/camel/camel-url.h
+++ b/camel/camel-url.h
@@ -30,7 +30,7 @@
#ifndef CAMEL_URL_H
#define CAMEL_URL_H
-#include <camel/camel-exception.h>
+#include <glib.h>
G_BEGIN_DECLS
@@ -55,7 +55,7 @@ typedef struct _CamelURL {
#define CAMEL_URL_HIDE_ALL (CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH)
CamelURL *camel_url_new_with_base (CamelURL *base, const gchar *url_string);
-CamelURL *camel_url_new (const gchar *url_string, CamelException *ex);
+CamelURL *camel_url_new (const gchar *url_string, GError **error);
gchar *camel_url_to_string (CamelURL *url, guint32 flags);
void camel_url_free (CamelURL *url);
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index 6e85435..d93a211 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -30,7 +30,6 @@
#include "camel-db.h"
#include "camel-debug.h"
-#include "camel-exception.h"
#include "camel-folder-search.h"
#include "camel-mime-message.h"
#include "camel-private.h"
@@ -115,9 +114,7 @@ folder_changed_add_uid (CamelFolder *sub, const gchar *uid, const gchar hash[8],
vuid = camel_message_info_uid (vinfo);
if (use_db) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
- camel_db_add_to_vfolder_transaction (folder->parent_store->cdb_w, folder->full_name, (gchar *)vuid, &ex);
- camel_exception_clear (&ex);
+ camel_db_add_to_vfolder_transaction (folder->parent_store->cdb_w, folder->full_name, (gchar *)vuid, NULL);
}
camel_folder_change_info_add_uid (vf->changes, vuid);
if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL) {
@@ -129,12 +126,10 @@ folder_changed_add_uid (CamelFolder *sub, const gchar *uid, const gchar hash[8],
}
vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info ((CamelFolder *)folder_unmatched, vuid);
if (vinfo) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
camel_folder_change_info_remove_uid (folder_unmatched->changes, vuid);
- camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, ((CamelFolder *)folder_unmatched)->full_name, vuid, &ex);
+ camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, ((CamelFolder *)folder_unmatched)->full_name, vuid, NULL);
camel_folder_summary_remove_uid_fast (((CamelFolder *)folder_unmatched)->summary, vuid);
camel_folder_free_message_info ((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
- camel_exception_clear (&ex);
}
}
}
@@ -155,12 +150,10 @@ folder_changed_remove_uid (CamelFolder *sub, const gchar *uid, const gchar hash[
strcpy (vuid+8, uid);
camel_folder_change_info_remove_uid (vf->changes, vuid);
- if (use_db) {
- /* FIXME[disk-summary] Handle exception */
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
- camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, folder->full_name, vuid, &ex);
- camel_exception_clear (&ex);
- }
+ if (use_db)
+ camel_db_delete_uid_from_vfolder_transaction (
+ folder->parent_store->cdb_w,
+ folder->full_name, vuid, NULL);
camel_folder_summary_remove_uid_fast (folder->summary, vuid);
if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL) {
@@ -187,12 +180,10 @@ folder_changed_remove_uid (CamelFolder *sub, const gchar *uid, const gchar hash[
vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info ((CamelFolder *)folder_unmatched, vuid);
if (vinfo) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
camel_folder_change_info_remove_uid (folder_unmatched->changes, vuid);
- camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, ((CamelFolder *)folder_unmatched)->full_name, vuid, &ex);
+ camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, ((CamelFolder *)folder_unmatched)->full_name, vuid, NULL);
camel_folder_summary_remove_uid_fast (((CamelFolder *)folder_unmatched)->summary, vuid);
camel_folder_free_message_info ((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
- camel_exception_clear (&ex);
}
}
}
@@ -278,10 +269,8 @@ folder_changed_change (CamelSession *session, CamelSessionThreadMsg *msg)
/* Find newly added that match */
if (changes->uid_added->len > 0) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
dd (printf (" Searching for added matches '%s'\n", vf->expression));
- matches_added = camel_folder_search_by_uids (sub, vf->expression, changes->uid_added, &ex);
- camel_exception_clear (&ex);
+ matches_added = camel_folder_search_by_uids (sub, vf->expression, changes->uid_added, NULL);
}
/* TODO:
@@ -291,7 +280,6 @@ folder_changed_change (CamelSession *session, CamelSessionThreadMsg *msg)
/* Search for changed items that newly match, but only if we dont have them */
changed = changes->uid_changed;
if (changed->len > 0) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
dd (printf (" Searching for changed matches '%s'\n", vf->expression));
if ((vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0) {
@@ -317,11 +305,9 @@ folder_changed_change (CamelSession *session, CamelSessionThreadMsg *msg)
}
if (changed->len)
- matches_changed = camel_folder_search_by_uids (sub, vf->expression, changed, &ex);
- camel_exception_clear (&ex);
+ matches_changed = camel_folder_search_by_uids (sub, vf->expression, changed, NULL);
if (always_changed && always_changed->len)
- present = camel_folder_search_by_uids (sub, vf->expression, always_changed, &ex);
- camel_exception_clear (&ex);
+ present = camel_folder_search_by_uids (sub, vf->expression, always_changed, NULL);
}
CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
@@ -599,7 +585,7 @@ static CamelSessionThreadOps folder_changed_ops = {
static gint
vee_folder_rebuild_folder (CamelVeeFolder *vee_folder,
CamelFolder *source,
- CamelException *ex);
+ GError **error);
static void
unmatched_check_uid (gchar *uidin, gpointer value, struct _update_data *u)
@@ -617,12 +603,10 @@ unmatched_check_uid (gchar *uidin, gpointer value, struct _update_data *u)
} else {
CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_uid (((CamelFolder *)u->folder_unmatched)->summary, uid);
if (mi) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
- camel_db_delete_uid_from_vfolder_transaction (((CamelFolder *)u->folder_unmatched)->parent_store->cdb_w, ((CamelFolder *)u->folder_unmatched)->full_name, uid, &ex);
+ camel_db_delete_uid_from_vfolder_transaction (((CamelFolder *)u->folder_unmatched)->parent_store->cdb_w, ((CamelFolder *)u->folder_unmatched)->full_name, uid, NULL);
camel_folder_summary_remove_uid_fast (((CamelFolder *)u->folder_unmatched)->summary, uid);
camel_folder_change_info_remove_uid (u->folder_unmatched->changes, uid);
camel_message_info_free ((CamelMessageInfo *)mi);
- camel_exception_clear (&ex);
}
}
}
@@ -641,9 +625,7 @@ folder_added_uid (gchar *uidin, gpointer value, struct _update_data *u)
/* FIXME[disk-summary] Make all these as transactions, just
* testing atm */
if (u->rebuilt && !u->correlating) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
- camel_db_add_to_vfolder_transaction (((CamelFolder *) u->vee_folder)->parent_store->cdb_w, ((CamelFolder *) u->vee_folder)->full_name, (gchar *) camel_message_info_uid (mi), &ex);
- camel_exception_clear (&ex);
+ camel_db_add_to_vfolder_transaction (((CamelFolder *) u->vee_folder)->parent_store->cdb_w, ((CamelFolder *) u->vee_folder)->full_name, (gchar *) camel_message_info_uid (mi), NULL);
}
if (!CAMEL_IS_VEE_FOLDER (u->source) && u->unmatched_uids != NULL) {
if (g_hash_table_lookup_extended (u->unmatched_uids, camel_message_info_uid (mi), (gpointer *)&oldkey, &oldval)) {
@@ -659,7 +641,7 @@ folder_added_uid (gchar *uidin, gpointer value, struct _update_data *u)
static gint
count_result (CamelFolderSummary *summary,
const gchar *query,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder = summary->folder;
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
@@ -671,7 +653,7 @@ count_result (CamelFolderSummary *summary,
node = p->folders;
while (node) {
CamelFolder *f = node->data;
- count += camel_folder_count_by_expression (f, expr, ex);
+ count += camel_folder_count_by_expression (f, expr, error);
node = node->next;
}
@@ -680,7 +662,8 @@ count_result (CamelFolderSummary *summary,
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s,
+ GError **error)
{
CamelFIRecord * record = g_new0 (CamelFIRecord, 1);
CamelDB *db;
@@ -722,11 +705,11 @@ summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
record->jnd_count = s->junk_not_deleted_count;
} else {
/* Either first time, or by force we search the count */
- s->junk_count = count_result (s, "(match-all (system-flag \"junk\"))", ex);
- s->deleted_count = count_result (s, "(match-all (system-flag \"deleted\"))", ex);
- s->unread_count = count_result (s, "(match-all (not (system-flag \"Seen\")))", ex);
- s->visible_count = count_result (s, "(match-all (and (not (system-flag \"deleted\")) (not (system-flag \"junk\"))))", ex);
- s->junk_not_deleted_count = count_result (s, "(match-all (and (not (system-flag \"deleted\")) (system-flag \"junk\")))", ex);
+ s->junk_count = count_result (s, "(match-all (system-flag \"junk\"))", NULL);
+ s->deleted_count = count_result (s, "(match-all (system-flag \"deleted\"))", NULL);
+ s->unread_count = count_result (s, "(match-all (not (system-flag \"Seen\")))", NULL);
+ s->visible_count = count_result (s, "(match-all (and (not (system-flag \"deleted\")) (not (system-flag \"junk\"))))", NULL);
+ s->junk_not_deleted_count = count_result (s, "(match-all (and (not (system-flag \"deleted\")) (system-flag \"junk\")))", NULL);
record->junk_count = s->junk_count;
record->deleted_count = s->deleted_count;
@@ -998,11 +981,9 @@ vee_folder_finalize (GObject *object)
/* Save the counts to DB */
if (!vf->deleted) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
record = summary_header_to_db (((CamelFolder *)vf)->summary, NULL);
- camel_db_write_folder_info_record (((CamelFolder *) vf)->parent_store->cdb_w, record, &ex);
+ camel_db_write_folder_info_record (((CamelFolder *) vf)->parent_store->cdb_w, record, NULL);
g_free (record);
- camel_exception_clear (&ex);
}
/* This may invoke sub-classes with partially destroyed state, they must deal with this */
@@ -1039,7 +1020,7 @@ vee_folder_finalize (GObject *object)
/* This entire code will be useless, since we sync the counts always. */
static gint
vee_folder_getv (CamelObject *object,
- CamelException *ex,
+ GError **error,
CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
@@ -1134,16 +1115,17 @@ vee_folder_getv (CamelObject *object,
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
- return ((CamelObjectClass *)parent_class)->getv (object, ex, args);
+ return ((CamelObjectClass *)parent_class)->getv (object, error, args);
}
-static void
+static gboolean
vee_folder_refresh_info (CamelFolder *folder,
- CamelException *ex)
+ 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, changed_lock);
list = p->folders_changed;
@@ -1154,23 +1136,28 @@ vee_folder_refresh_info (CamelFolder *folder,
while (node) {
CamelFolder *f = node->data;
- if (camel_vee_folder_rebuild_folder (vf, f, ex) == -1)
+ if (camel_vee_folder_rebuild_folder (vf, f, error) == -1) {
+ success = FALSE;
break;
+ }
node = node->next;
}
g_list_free (list);
+
+ return success;
}
-static void
+static gboolean
vee_folder_sync (CamelFolder *folder,
gboolean expunge,
- CamelException *ex)
+ 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;
@@ -1182,15 +1169,18 @@ vee_folder_sync (CamelFolder *folder,
while (node) {
CamelFolder *f = node->data;
- camel_folder_sync (f, expunge, ex);
- if (camel_exception_is_set (ex) && strncmp (camel_exception_get_description (ex), "no such table", 13)) {
- const gchar *desc;
-
- camel_object_get (f, NULL, CAMEL_OBJECT_DESCRIPTION, &desc, NULL);
- camel_exception_setv (ex, ex->id, _("Error storing '%s': %s"), desc, ex->desc);
- g_warning ("%s", camel_exception_get_description (ex));
- } else
- camel_exception_clear (ex);
+ if (!camel_folder_sync (f, expunge, &local_error)) {
+ if (strncmp (local_error->message, "no such table", 13) != 0) {
+ const gchar *desc;
+
+ camel_object_get (f, NULL, CAMEL_OBJECT_DESCRIPTION, &desc, NULL);
+ 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 */
@@ -1235,74 +1225,83 @@ vee_folder_sync (CamelFolder *folder,
}
camel_message_info_free (mi);
}
- camel_db_delete_vuids (folder->parent_store->cdb_w, folder->full_name, "", del, ex);
+ camel_db_delete_vuids (folder->parent_store->cdb_w, folder->full_name, "", del, NULL);
g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
g_slist_free (del);
}
CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
camel_object_state_write (vf);
+
+ return TRUE;
}
-static void
+static gboolean
vee_folder_expunge (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
/* Force it to rebuild the counts, when some folders were expunged. */
((CamelVeeSummary *) folder->summary)->force_counts = TRUE;
- CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, TRUE, ex);
+
+ return CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, TRUE, error);
}
static CamelMimeMessage *
vee_folder_get_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ 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, ex);
+ msg = camel_folder_get_message (mi->summary->folder, camel_message_info_uid (mi)+8, error);
camel_message_info_free ((CamelMessageInfo *)mi);
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("No such message %s in %s"), uid,
- folder->name);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("No such message %s in %s"), uid,
+ folder->name);
}
return msg;
}
-static void
+static gboolean
vee_folder_append_message (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
_("Cannot copy or move messages into a Virtual Folder"));
+
+ return FALSE;
}
-static void
+static gboolean
vee_folder_transfer_messages_to (CamelFolder *folder,
GPtrArray *uids,
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
_("Cannot copy or move messages into a Virtual Folder"));
+
+ return FALSE;
}
static GPtrArray *
vee_folder_search_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
GList *node;
GPtrArray *matches, *result = g_ptr_array_new ();
@@ -1326,10 +1325,7 @@ vee_folder_search_by_expression (CamelFolder *folder,
/* make sure we only search each folder once - for unmatched folder to work right */
if (g_hash_table_lookup (searched, f) == NULL) {
camel_vee_folder_hash_folder (f, hash);
- matches = camel_folder_search_by_expression (f, expr, ex);
- if (camel_exception_is_set (ex) && strncmp (camel_exception_get_description (ex), "no such table", 13)) {
- camel_exception_clear (ex);
- }
+ matches = camel_folder_search_by_expression (f, expr, NULL);
if (matches) {
for (i = 0; i < matches->len; i++) {
gchar *uid = matches->pdata[i], *vuid;
@@ -1358,7 +1354,7 @@ static GPtrArray *
vee_folder_search_by_uids (CamelFolder *folder,
const gchar *expression,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
GList *node;
GPtrArray *matches, *result = g_ptr_array_new ();
@@ -1390,7 +1386,7 @@ vee_folder_search_by_uids (CamelFolder *folder,
g_ptr_array_add (folder_uids, uid+8);
}
if (folder_uids->len > 0) {
- matches = camel_folder_search_by_uids (f, expr, folder_uids, ex);
+ matches = camel_folder_search_by_uids (f, expr, folder_uids, error);
if (matches) {
for (i = 0; i < matches->len; i++) {
gchar *uid = matches->pdata[i], *vuid;
@@ -1402,8 +1398,6 @@ vee_folder_search_by_uids (CamelFolder *folder,
g_free (vuid);
}
camel_folder_search_free (f, matches);
- } else {
- g_warning ("Search failed: %s", camel_exception_get_description (ex));
}
}
g_hash_table_insert (searched, f, f);
@@ -1423,7 +1417,7 @@ vee_folder_search_by_uids (CamelFolder *folder,
static guint32
vee_folder_count_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
GList *node;
gchar *expr;
@@ -1444,7 +1438,7 @@ vee_folder_count_by_expression (CamelFolder *folder,
/* make sure we only search each folder once - for unmatched folder to work right */
if (g_hash_table_lookup (searched, f) == NULL) {
- count += camel_folder_count_by_expression (f, expr, ex);
+ count += camel_folder_count_by_expression (f, expr, NULL);
g_hash_table_insert (searched, f, f);
}
node = g_list_next (node);
@@ -1532,7 +1526,6 @@ vee_folder_set_expression (CamelVeeFolder *vee_folder,
{
CamelVeeFolderPrivate *p = CAMEL_VEE_FOLDER_GET_PRIVATE (vee_folder);
GList *node;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CAMEL_VEE_FOLDER_LOCK (vee_folder, subfolder_lock);
@@ -1547,8 +1540,7 @@ vee_folder_set_expression (CamelVeeFolder *vee_folder,
if (vee_folder->expression) {
CamelFolderSummary *s = ((CamelFolder *)vee_folder)->summary;
camel_folder_summary_clear (s);
- camel_db_recreate_vfolder (((CamelFolder *) vee_folder)->parent_store->cdb_w, ((CamelFolder *) vee_folder)->full_name, &ex);
- camel_exception_clear (&ex);
+ camel_db_recreate_vfolder (((CamelFolder *) vee_folder)->parent_store->cdb_w, ((CamelFolder *) vee_folder)->full_name, NULL);
s->junk_count = 0;
s->deleted_count = 0;
s->unread_count = 0;
@@ -1564,16 +1556,12 @@ vee_folder_set_expression (CamelVeeFolder *vee_folder,
while (node) {
CamelFolder *f = node->data;
- if (camel_vee_folder_rebuild_folder (vee_folder, f, &ex) == -1)
+ if (camel_vee_folder_rebuild_folder (vee_folder, f, NULL) == -1)
break;
- camel_exception_clear (&ex);
-
node = node->next;
}
- camel_exception_clear (&ex);
-
CAMEL_VEE_FOLDER_LOCK (vee_folder, changed_lock);
g_list_free (p->folders_changed);
p->folders_changed = NULL;
@@ -1586,11 +1574,7 @@ static void
vee_folder_add_folder (CamelVeeFolder *vee_folder,
CamelFolder *sub)
{
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-
- vee_folder_rebuild_folder (vee_folder, sub, &ex);
-
- camel_exception_clear (&ex);
+ vee_folder_rebuild_folder (vee_folder, sub, NULL);
}
static void
@@ -1613,7 +1597,7 @@ vee_folder_remove_folder (CamelVeeFolder *vee_folder,
static gint
vee_folder_rebuild_folder (CamelVeeFolder *vee_folder,
CamelFolder *source,
- CamelException *ex)
+ GError **error)
{
GPtrArray *match, *all;
GHashTable *allhash, *matchhash, *fullhash;
@@ -1653,7 +1637,7 @@ vee_folder_rebuild_folder (CamelVeeFolder *vee_folder,
/* We take this to mean the results have not been cached.
* XXX: It will also trigger if the result set is empty. */
match == NULL) {
- match = camel_folder_search_by_expression (source, vee_folder->expression, ex);
+ match = camel_folder_search_by_expression (source, vee_folder->expression, error);
if (match == NULL) /* Search failed */
return 0;
rebuilded = TRUE;
@@ -1802,11 +1786,10 @@ vee_folder_rebuild_folder (CamelVeeFolder *vee_folder,
/* Del the unwanted things from the summary, we don't hold any locks now. */
if (del_list) {
- if (!correlating) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
- camel_db_delete_vuids (folder->parent_store->cdb_w, folder->full_name, shash, del_list, &ex);
- camel_exception_clear (&ex);
- }
+ if (!correlating)
+ camel_db_delete_vuids (
+ folder->parent_store->cdb_w,
+ folder->full_name, shash, del_list, NULL);
((CamelVeeSummary *)folder->summary)->force_counts = TRUE;
g_slist_foreach (del_list, (GFunc) camel_pstring_free, NULL);
g_slist_free (del_list);
@@ -2172,14 +2155,16 @@ camel_vee_folder_remove_folder (CamelVeeFolder *vf, CamelFolder *sub)
* camel_vee_folder_rebuild_folder:
* @vf: Virtual Folder object
* @sub: source CamelFolder to add to @vf
- * @ex: Exception.
+ * @error: return location for a #GError, or %NULL
*
* Rebuild the folder @sub, if it should be.
**/
gint
-camel_vee_folder_rebuild_folder (CamelVeeFolder *vf, CamelFolder *sub, CamelException *ex)
+camel_vee_folder_rebuild_folder (CamelVeeFolder *vf,
+ CamelFolder *sub,
+ GError **error)
{
- return CAMEL_VEE_FOLDER_GET_CLASS (vf)->rebuild_folder (vf, sub, ex);
+ return CAMEL_VEE_FOLDER_GET_CLASS (vf)->rebuild_folder (vf, sub, error);
}
static void
@@ -2322,15 +2307,16 @@ camel_vee_folder_unmask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *s
}
void
-camel_vee_folder_sync_headers (CamelFolder *vf, CamelException *ex)
+camel_vee_folder_sync_headers (CamelFolder *vf,
+ GError **error)
{
CamelFIRecord * record;
time_t start, end;
/* Save the counts to DB */
start = time (NULL);
- record = summary_header_to_db (vf->summary, ex);
- camel_db_write_folder_info_record (vf->parent_store->cdb_w, record, ex);
+ record = summary_header_to_db (vf->summary, error);
+ camel_db_write_folder_info_record (vf->parent_store->cdb_w, record, error);
end = time (NULL);
dd (printf ("Sync for vfolder '%s': %ld secs\n", vf->full_name, end-start));
diff --git a/camel/camel-vee-folder.h b/camel/camel-vee-folder.h
index 84b1054..e325f40 100644
--- a/camel/camel-vee-folder.h
+++ b/camel/camel-vee-folder.h
@@ -83,7 +83,7 @@ struct _CamelVeeFolderClass {
void (*add_folder)(CamelVeeFolder *, CamelFolder *);
void (*remove_folder)(CamelVeeFolder *, CamelFolder *);
- gint (*rebuild_folder)(CamelVeeFolder *, CamelFolder *, CamelException *);
+ gint (*rebuild_folder)(CamelVeeFolder *, CamelFolder *, GError **error);
void (*set_expression)(CamelVeeFolder *, const gchar *);
@@ -104,14 +104,14 @@ CamelFolder *camel_vee_folder_get_location(CamelVeeFolder *vf, const struct _Cam
void camel_vee_folder_add_folder (CamelVeeFolder *vf, CamelFolder *sub);
void camel_vee_folder_remove_folder (CamelVeeFolder *vf, CamelFolder *sub);
void camel_vee_folder_set_folders (CamelVeeFolder *vf, GList *folders);
-gint camel_vee_folder_rebuild_folder(CamelVeeFolder *vf, CamelFolder *sub, CamelException *ex);
+gint camel_vee_folder_rebuild_folder(CamelVeeFolder *vf, CamelFolder *sub, GError **error);
void camel_vee_folder_set_expression (CamelVeeFolder *vf, const gchar *expr);
void camel_vee_folder_mask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub);
void camel_vee_folder_unmask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub);
void camel_vee_folder_hash_folder (CamelFolder *folder, gchar buffer[8]);
-void camel_vee_folder_sync_headers (CamelFolder *vf, CamelException *ex);
+void camel_vee_folder_sync_headers (CamelFolder *vf, GError **error);
G_END_DECLS
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 42b1d9e..81a66ce 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -28,7 +28,6 @@
#include <glib/gstdio.h>
#include "camel-db.h"
-#include "camel-exception.h"
#include "camel-private.h"
#include "camel-session.h"
#include "camel-vee-folder.h"
@@ -106,12 +105,12 @@ vee_store_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static void
+static gboolean
vee_store_construct (CamelService *service,
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
CamelStore *store;
@@ -122,7 +121,8 @@ vee_store_construct (CamelService *service,
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (parent_class);
- service_class->construct (service, session, provider, url, ex);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
/* Set up unmatched folder */
#ifndef VEE_UNMATCHED_ENABLE
@@ -131,13 +131,15 @@ vee_store_construct (CamelService *service,
camel_vee_folder_construct (vee_store->folder_unmatched, store, CAMEL_UNMATCHED_NAME, _("Unmatched"), CAMEL_STORE_FOLDER_PRIVATE);
camel_db_create_vfolder (store->cdb_r, _("Unmatched"), NULL);
#endif
+
+ return TRUE;
}
static CamelFolder *
vee_store_get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelVeeFolder *vf;
CamelFolder *folder;
@@ -171,11 +173,11 @@ vee_store_get_folder (CamelStore *store,
return (CamelFolder *)vf;
}
-static void
+static gboolean
vee_store_rename_folder (CamelStore *store,
const gchar *old,
const gchar *new,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder, *oldfolder;
gchar *p, *name;
@@ -183,17 +185,21 @@ vee_store_rename_folder (CamelStore *store,
d (printf ("vee rename folder '%s' '%s'\n", old, new));
if (strcmp (old, CAMEL_UNMATCHED_NAME) == 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot rename folder: %s: Invalid operation"), old);
- return;
+ 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) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot rename folder: %s: No such folder"), old);
- return;
+ 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 */
@@ -217,19 +223,24 @@ vee_store_rename_folder (CamelStore *store,
}
g_object_unref (oldfolder);
+
+ return TRUE;
}
-static void
+static gboolean
vee_store_delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
if (strcmp (folder_name, CAMEL_UNMATCHED_NAME) == 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot delete folder: %s: Invalid operation"), folder_name);
- return;
+ 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);
@@ -250,16 +261,22 @@ vee_store_delete_folder (CamelStore *store,
g_object_unref (folder);
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot delete folder: %s: No such folder"), folder_name);
+ 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,
- CamelException *ex)
+ GError **error)
{
CamelFolderInfo *info, *res = NULL, *tail;
GPtrArray *folders;
@@ -390,14 +407,14 @@ vee_store_get_folder_info (CamelStore *store,
static CamelFolder *
vee_store_get_trash (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
return NULL;
}
static CamelFolder *
vee_store_get_junk (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
return NULL;
}
diff --git a/camel/camel-vee-summary.h b/camel/camel-vee-summary.h
index d84cf29..1bbd7a0 100644
--- a/camel/camel-vee-summary.h
+++ b/camel/camel-vee-summary.h
@@ -28,7 +28,6 @@
#define CAMEL_VEE_SUMMARY_H
#include <camel/camel-folder-summary.h>
-#include <camel/camel-exception.h>
/* Standard GObject macros */
#define CAMEL_TYPE_VEE_SUMMARY \
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c
index d45cbed..0cef36c 100644
--- a/camel/camel-vtrash-folder.c
+++ b/camel/camel-vtrash-folder.c
@@ -30,7 +30,6 @@
#include <glib/gi18n-lib.h>
#include "camel-db.h"
-#include "camel-exception.h"
#include "camel-mime-message.h"
#include "camel-private.h"
#include "camel-store.h"
@@ -66,12 +65,14 @@ struct _transfer_data {
static gpointer parent_class;
static void
-transfer_messages(CamelFolder *folder, struct _transfer_data *md, CamelException *ex)
+transfer_messages (CamelFolder *folder,
+ struct _transfer_data *md,
+ GError **error)
{
gint i;
- if (!camel_exception_is_set (ex))
- camel_folder_transfer_messages_to(md->folder, md->uids, md->dest, NULL, md->delete, ex);
+ camel_folder_transfer_messages_to (
+ md->folder, md->uids, md->dest, NULL, md->delete, error);
for (i=0;i<md->uids->len;i++)
g_free(md->uids->pdata[i]);
@@ -83,7 +84,7 @@ transfer_messages(CamelFolder *folder, struct _transfer_data *md, CamelException
/* This entire code will be useless, since we sync the counts always. */
static gint
vtrash_folder_getv (CamelObject *object,
- CamelException *ex,
+ GError **error,
CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
@@ -167,28 +168,30 @@ vtrash_folder_getv (CamelObject *object,
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
- return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
+ return CAMEL_OBJECT_CLASS (parent_class)->getv (object, error, args);
}
-static void
+static gboolean
vtrash_folder_append_message (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM, "%s",
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
_(vdata[((CamelVTrashFolder *)folder)->type].error_copy));
+
+ return FALSE;
}
-static void
+static gboolean
vtrash_folder_transfer_messages_to (CamelFolder *source,
GPtrArray *uids,
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
CamelVeeMessageInfo *mi;
gint i;
@@ -208,15 +211,16 @@ vtrash_folder_transfer_messages_to (CamelFolder *source,
if (CAMEL_IS_VTRASH_FOLDER (dest)) {
/* Copy to trash is meaningless. */
if (!delete_originals) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s",
- _(vdata[((CamelVTrashFolder *)dest)->type].error_copy));
- return;
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM, "%s",
+ _(vdata[((CamelVTrashFolder *)dest)->type].error_copy));
+ return FALSE;
}
/* Move to trash is the same as setting the message flag */
for (i = 0; i < uids->len; i++)
camel_folder_set_message_flags(source, uids->pdata[i], ((CamelVTrashFolder *)dest)->bit, ~0);
- return;
+ return TRUE;
}
/* Moving/Copying from the trash to the original folder = undelete.
@@ -257,9 +261,11 @@ vtrash_folder_transfer_messages_to (CamelFolder *source,
}
if (batch) {
- g_hash_table_foreach(batch, (GHFunc)transfer_messages, ex);
+ g_hash_table_foreach(batch, (GHFunc)transfer_messages, error);
g_hash_table_destroy(batch);
}
+
+ return TRUE;
}
static void
diff --git a/camel/camel.h b/camel/camel.h
index 6247ead..34aa9af 100644
--- a/camel/camel.h
+++ b/camel/camel.h
@@ -42,7 +42,6 @@
#include <camel/camel-disco-diary.h>
#include <camel/camel-disco-folder.h>
#include <camel/camel-disco-store.h>
-#include <camel/camel-exception.h>
#include <camel/camel-file-utils.h>
#include <camel/camel-filter-driver.h>
#include <camel/camel-filter-search.h>
diff --git a/camel/providers/groupwise/camel-groupwise-folder.c b/camel/providers/groupwise/camel-groupwise-folder.c
index b1177ce..c5e30f4 100644
--- a/camel/providers/groupwise/camel-groupwise-folder.c
+++ b/camel/providers/groupwise/camel-groupwise-folder.c
@@ -83,20 +83,20 @@ struct _CamelGroupwiseFolderPrivate {
extern gint camel_application_is_exiting;
/*prototypes*/
-static void groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
-static gint gw_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static gboolean groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, GPtrArray **transferred_uids, gboolean delete_originals, GError **error);
+static gint gw_getv (CamelObject *object, GError **error, CamelArgGetV *args);
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);
-static void gw_update_all_items ( CamelFolder *folder, GList *item_list, CamelException *ex);
+static void gw_update_all_items ( CamelFolder *folder, GList *item_list, GError **error);
static void groupwise_populate_details_from_item (CamelMimeMessage *msg, EGwItem *item);
static void groupwise_populate_msg_body_from_item (EGwConnection *cnc, CamelMultipart *multipart, EGwItem *item, gchar *body);
static void groupwise_msg_set_recipient_list (CamelMimeMessage *msg, EGwItem *item);
-static void gw_update_cache ( CamelFolder *folder, GList *item_list, CamelException *ex, gboolean uid_flag);
-static CamelMimeMessage *groupwise_folder_item_to_msg ( CamelFolder *folder, EGwItem *item, CamelException *ex );
-static gchar * groupwise_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static void gw_update_cache ( CamelFolder *folder, GList *item_list, GError **error, gboolean uid_flag);
+static CamelMimeMessage *groupwise_folder_item_to_msg ( CamelFolder *folder, EGwItem *item, GError **error );
+static gchar * groupwise_get_filename (CamelFolder *folder, const gchar *uid, GError **error);
static const gchar *get_from_from_org (EGwItemOrganizer *org);
-static void groupwise_refresh_folder(CamelFolder *folder, CamelException *ex);
+static void groupwise_refresh_folder(CamelFolder *folder, GError **error);
#define d(x)
@@ -104,16 +104,16 @@ static const gchar * GET_ITEM_VIEW_WITH_CACHE = "peek default recipient threadin
static const gchar * GET_ITEM_VIEW_WITHOUT_CACHE = "peek default recipient threading hasAttachment subject status priority startDate created delivered size recurrenceKey";
static gchar *
-groupwise_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+groupwise_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
- return camel_data_cache_get_filename (gw_folder->cache, "cache", uid, ex);
+ 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, CamelException *ex )
+groupwise_folder_get_message( CamelFolder *folder, const gchar *uid, GError **error )
{
CamelMimeMessage *msg = NULL;
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
@@ -130,11 +130,13 @@ groupwise_folder_get_message( CamelFolder *folder, const gchar *uid, CamelExcept
mi = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->summary, uid);
if (mi == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message: %s\n %s"), uid, _("No such message"));
+ 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, ex);
+ cache_stream = camel_data_cache_get (gw_folder->cache, "cache", uid, error);
stream = camel_stream_mem_new ();
if (cache_stream) {
msg = camel_mime_message_new ();
@@ -143,15 +145,21 @@ groupwise_folder_get_message( CamelFolder *folder, const gchar *uid, CamelExcept
camel_stream_reset (stream);
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream) == -1) {
if (errno == EINTR) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
g_object_unref (msg);
g_object_unref (cache_stream);
g_object_unref (stream);
camel_message_info_free (&mi->info);
return NULL;
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"),
- uid, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get message %s: %s"),
+ uid, g_strerror (errno));
g_object_unref (msg);
msg = NULL;
}
@@ -166,16 +174,20 @@ groupwise_folder_get_message( CamelFolder *folder, const gchar *uid, CamelExcept
}
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not available in offline mode."));
+ 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, ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not available in offline mode."));
+ if (!camel_groupwise_store_connected (gw_store, error)) {
+ 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;
}
@@ -189,14 +201,20 @@ groupwise_folder_get_message( CamelFolder *folder, const gchar *uid, CamelExcept
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);
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
+ 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, ex);
+ msg = groupwise_folder_item_to_msg (folder, item, error);
if (!msg) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
+ 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);
@@ -474,35 +492,35 @@ groupwise_folder_rename (CamelFolder *folder, const gchar *new)
}
static GPtrArray *
-groupwise_folder_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+groupwise_folder_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
GPtrArray *matches;
CAMEL_GROUPWISE_FOLDER_LOCK(gw_folder, search_lock);
camel_folder_search_set_folder (gw_folder->search, folder);
- matches = camel_folder_search_search(gw_folder->search, expression, NULL, ex);
+ matches = camel_folder_search_search(gw_folder->search, expression, NULL, error);
CAMEL_GROUPWISE_FOLDER_UNLOCK(gw_folder, search_lock);
return matches;
}
static guint32
-groupwise_folder_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+groupwise_folder_count_by_expression (CamelFolder *folder, const gchar *expression, GError **error)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
guint32 matches;
CAMEL_GROUPWISE_FOLDER_LOCK(gw_folder, search_lock);
camel_folder_search_set_folder (gw_folder->search, folder);
- matches = camel_folder_search_count (gw_folder->search, expression, ex);
+ matches = camel_folder_search_count (gw_folder->search, expression, error);
CAMEL_GROUPWISE_FOLDER_UNLOCK(gw_folder, search_lock);
return matches;
}
static GPtrArray *
-groupwise_folder_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+groupwise_folder_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
GPtrArray *matches;
@@ -513,7 +531,7 @@ groupwise_folder_search_by_uids(CamelFolder *folder, const gchar *expression, GP
CAMEL_GROUPWISE_FOLDER_LOCK(gw_folder, search_lock);
camel_folder_search_set_folder(gw_folder->search, folder);
- matches = camel_folder_search_search(gw_folder->search, expression, uids, ex);
+ matches = camel_folder_search_search(gw_folder->search, expression, uids, error);
CAMEL_GROUPWISE_FOLDER_UNLOCK(gw_folder, search_lock);
@@ -606,7 +624,7 @@ error:
}
static void
-move_to_mailbox (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
+move_to_mailbox (CamelFolder *folder, CamelMessageInfo *info, GError **error)
{
CamelFolder *dest;
GPtrArray *uids;
@@ -615,10 +633,10 @@ move_to_mailbox (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gpointer) uid);
- dest = camel_store_get_folder (folder->parent_store, "Mailbox", 0, ex);
+ dest = camel_store_get_folder (folder->parent_store, "Mailbox", 0, 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, ex);
+ groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, error);
else
g_warning ("No Mailbox folder found");
@@ -626,7 +644,7 @@ move_to_mailbox (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex
}
static void
-move_to_junk (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
+move_to_junk (CamelFolder *folder, CamelMessageInfo *info, GError **error)
{
CamelFolder *dest;
CamelFolderInfo *fi;
@@ -636,29 +654,31 @@ move_to_junk (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gpointer) uid);
- dest = camel_store_get_folder (folder->parent_store, JUNK_FOLDER, 0, ex);
+ dest = camel_store_get_folder (folder->parent_store, JUNK_FOLDER, 0, error);
if (dest)
- groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, ex);
+ groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, error);
else {
fi = create_junk_folder (folder->parent_store);
- dest = camel_store_get_folder (folder->parent_store, JUNK_FOLDER, 0, ex);
+ dest = camel_store_get_folder (folder->parent_store, JUNK_FOLDER, 0, error);
if (!dest)
g_warning ("Could not get JunkFolder:Message not moved");
else
- groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, ex);
+ groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, error);
}
update_junk_list (folder->parent_store, info, ADD_JUNK_ENTRY);
}
/********************* back to folder functions*************************/
-static void
-groupwise_sync_summary (CamelFolder *folder, CamelException *ex)
+static gboolean
+groupwise_sync_summary (CamelFolder *folder, GError **error)
{
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
camel_store_summary_touch ((CamelStoreSummary *)((CamelGroupwiseStore *)folder->parent_store)->summary);
camel_store_summary_save ((CamelStoreSummary *)((CamelGroupwiseStore *)folder->parent_store)->summary);
+
+ return TRUE;
}
/* This may need to be reorganized. */
@@ -687,8 +707,8 @@ sync_flags (CamelFolder *folder, GList *uids)
}
/* This may need to be reorganized. */
-static void
-groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+static gboolean
+groupwise_sync (CamelFolder *folder, gboolean expunge, GError **error)
{
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
@@ -701,6 +721,7 @@ groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
EGwConnectionStatus status;
EGwConnection *cnc;
gint count, i;
+ gboolean success;
GList *deleted_items, *deleted_head;
@@ -708,23 +729,21 @@ groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
- groupwise_sync_summary (folder, ex);
- return;
+ return groupwise_sync_summary (folder, error);
}
cnc = cnc_lookup (priv);
container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name);
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- if (!camel_groupwise_store_connected (gw_store, ex)) {
+ if (!camel_groupwise_store_connected (gw_store, NULL)) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
- camel_exception_clear (ex);
- return;
+ return TRUE;
}
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
if (folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED)
- return;
+ return TRUE;
count = camel_folder_summary_count (folder->summary);
CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
@@ -745,7 +764,7 @@ groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
if ((flags & CAMEL_MESSAGE_JUNK) && strcmp(camel_folder_get_name(folder), JUNK_FOLDER)) {
/*marked a message junk*/
- move_to_junk (folder, info, ex);
+ move_to_junk (folder, info, error);
camel_folder_summary_remove_uid (folder->summary, camel_message_info_uid(info));
camel_data_cache_remove (gw_folder->cache, "cache", camel_message_info_uid(info), NULL);
continue;
@@ -753,7 +772,7 @@ groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
if ((flags & CAMEL_GW_MESSAGE_NOJUNK) && !strcmp(camel_folder_get_name(folder), JUNK_FOLDER)) {
/*message was marked as junk, now unjunk*/
- move_to_mailbox (folder, info, ex);
+ move_to_mailbox (folder, info, error);
camel_folder_summary_remove_uid (folder->summary, camel_message_info_uid(info));
camel_data_cache_remove (gw_folder->cache, "cache", camel_message_info_uid(info), NULL);
continue;
@@ -906,12 +925,14 @@ groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- groupwise_sync_summary (folder, ex);
+ success = groupwise_sync_summary (folder, error);
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+
+ return success;
}
CamelFolder *
-camel_gw_folder_new(CamelStore *store, const gchar *folder_name, const gchar *folder_dir, CamelException *ex)
+camel_gw_folder_new(CamelStore *store, const gchar *folder_name, const gchar *folder_dir, GError **error)
{
CamelFolder *folder;
CamelGroupwiseFolder *gw_folder;
@@ -933,9 +954,9 @@ camel_gw_folder_new(CamelStore *store, const gchar *folder_name, const gchar *fo
g_free(summary_file);
if (!folder->summary) {
g_object_unref (CAMEL_OBJECT (folder));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load summary for %s"),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not load summary for %s"), folder_name);
return NULL;
}
@@ -945,7 +966,7 @@ camel_gw_folder_new(CamelStore *store, const gchar *folder_name, const gchar *fo
g_free(state_file);
camel_object_state_read(folder);
- gw_folder->cache = camel_data_cache_new (folder_dir, ex);
+ gw_folder->cache = camel_data_cache_new (folder_dir, error);
if (!gw_folder->cache) {
g_object_unref (folder);
return NULL;
@@ -988,7 +1009,7 @@ update_update (CamelSession *session, CamelSessionThreadMsg *msg)
{
struct _folder_update_msg *m = (struct _folder_update_msg *)msg;
EGwConnectionStatus status;
- CamelException *ex = NULL;
+ GError **error = NULL;
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (m->folder->parent_store);
GList *item_list, *items_full_list = NULL, *last_element=NULL;
@@ -1075,7 +1096,7 @@ update_update (CamelSession *session, CamelSessionThreadMsg *msg)
}*/
g_print ("\nNumber of items in the folder: %d \n", g_list_length(items_full_list));
- gw_update_all_items (m->folder, items_full_list, ex);
+ gw_update_all_items (m->folder, items_full_list, error);
camel_operation_end (NULL);
return;
@@ -1108,8 +1129,8 @@ static CamelSessionThreadOps update_ops = {
update_free,
};
-static void
-groupwise_refresh_info(CamelFolder *folder, CamelException *ex)
+static gboolean
+groupwise_refresh_info(CamelFolder *folder, GError **error)
{
CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *) folder->summary;
CamelStoreInfo *si;
@@ -1120,7 +1141,7 @@ groupwise_refresh_info(CamelFolder *folder, CamelException *ex)
* should not interfere with the process
*/
if (summary->time_string && (strlen (summary->time_string) > 0)) {
- groupwise_refresh_folder(folder, ex);
+ groupwise_refresh_folder(folder, error);
si = camel_store_summary_path ((CamelStoreSummary *)((CamelGroupwiseStore *)folder->parent_store)->summary, folder->full_name);
if (si) {
guint32 unread, total;
@@ -1139,8 +1160,10 @@ groupwise_refresh_info(CamelFolder *folder, CamelException *ex)
* 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, ex);
+ gw_store_reload_folder (gw_store, folder, 0, error);
}
+
+ return TRUE;
}
static gint
@@ -1214,7 +1237,7 @@ get_merge_lists_new_count (CamelGroupwiseSummary *summary, GSList *new, GSList *
}
static void
-update_summary_string (CamelFolder *folder, const gchar *time_string, CamelException *ex)
+update_summary_string (CamelFolder *folder, const gchar *time_string, GError **error)
{
CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *) folder->summary;
@@ -1223,11 +1246,11 @@ update_summary_string (CamelFolder *folder, const gchar *time_string, CamelExcep
((CamelGroupwiseSummary *) folder->summary)->time_string = g_strdup (time_string);
camel_folder_summary_touch (folder->summary);
- groupwise_sync_summary (folder, ex);
+ groupwise_sync_summary (folder, error);
}
static void
-groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
+groupwise_refresh_folder(CamelFolder *folder, GError **error)
{
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
@@ -1272,7 +1295,7 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- if (!camel_groupwise_store_connected (gw_store, ex))
+ if (!camel_groupwise_store_connected (gw_store, error))
goto end1;
if (!strcmp (folder->full_name, "Trash")) {
@@ -1321,7 +1344,10 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
"peek id",
&new_sync_time, "New", NULL, source, -1, &new_items);
if (status != E_GW_CONNECTION_STATUS_OK) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Authentication failed"));
goto end2;
}
@@ -1336,7 +1362,10 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
"peek id",
&modified_sync_time, "Modified", NULL, source, -1, &modified_items);
if (status != E_GW_CONNECTION_STATUS_OK) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Authentication failed"));
goto end3;
}
@@ -1373,10 +1402,10 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
g_object_unref (container);
if (list)
- gw_update_cache (folder, list, ex, FALSE);
+ gw_update_cache (folder, list, error, FALSE);
/* update the new_sync_time to summary */
- update_summary_string (folder, new_sync_time, ex);
+ update_summary_string (folder, new_sync_time, error);
}
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
@@ -1478,7 +1507,7 @@ groupwise_folder_set_threading_data (CamelGroupwiseMessageInfo *mi, EGwItem *ite
/* Update the GroupWise cache with the list of items passed. should happen in thread. */
static void
-gw_update_cache (CamelFolder *folder, GList *list, CamelException *ex, gboolean uid_flag)
+gw_update_cache (CamelFolder *folder, GList *list, GError **error, gboolean uid_flag)
{
CamelGroupwiseMessageInfo *mi = NULL;
CamelMessageInfo *pmi = NULL;
@@ -1682,11 +1711,11 @@ gw_update_cache (CamelFolder *folder, GList *list, CamelException *ex, gboolean
if (folder_needs_caching) {
/******************** Begine Caching ************************/
/* add to cache if its a new message*/
- t_cache_stream = camel_data_cache_get (gw_folder->cache, "cache", id, ex);
+ t_cache_stream = camel_data_cache_get (gw_folder->cache, "cache", id, error);
if (t_cache_stream) {
g_object_unref (t_cache_stream);
- mail_msg = groupwise_folder_item_to_msg (folder, item, ex);
+ mail_msg = groupwise_folder_item_to_msg (folder, item, error);
if (mail_msg)
camel_medium_set_header (CAMEL_MEDIUM (mail_msg), "X-Evolution-Source", groupwise_base_url_lookup (priv));
@@ -1747,7 +1776,7 @@ get_from_from_org (EGwItemOrganizer *org)
/* Update summary, if there is none existing, create one */
void
-gw_update_summary ( CamelFolder *folder, GList *list,CamelException *ex)
+gw_update_summary ( CamelFolder *folder, GList *list,GError **error)
{
CamelGroupwiseMessageInfo *mi = NULL;
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
@@ -1915,7 +1944,7 @@ gw_update_summary ( CamelFolder *folder, GList *list,CamelException *ex)
static CamelMimeMessage *
groupwise_folder_item_to_msg( CamelFolder *folder,
EGwItem *item,
- CamelException *ex )
+ GError **error )
{
CamelMimeMessage *msg = NULL;
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE(folder->parent_store);
@@ -1960,7 +1989,10 @@ groupwise_folder_item_to_msg( CamelFolder *folder,
(const gchar **)&attachment, &len);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not get attachment\n");
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Could not get message"));
return NULL;
}
if (attachment && attachment[0] && (len !=0) ) {
@@ -2011,7 +2043,10 @@ groupwise_folder_item_to_msg( CamelFolder *folder,
(const gchar **)&attachment, &len);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not get attachment\n");
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Could not get message"));
return NULL;
}
body = g_strdup (attachment);
@@ -2121,7 +2156,7 @@ groupwise_folder_item_to_msg( CamelFolder *folder,
g_warning ("Could not get attachment\n");
continue;
}
- temp_msg = groupwise_folder_item_to_msg(folder, temp_item, ex);
+ temp_msg = groupwise_folder_item_to_msg(folder, temp_item, error);
if (temp_msg) {
CamelContentType *ct = camel_content_type_new("message", "rfc822");
part = camel_mime_part_new ();
@@ -2239,7 +2274,7 @@ end:
}
static void
-gw_update_all_items (CamelFolder *folder, GList *item_list, CamelException *ex)
+gw_update_all_items (CamelFolder *folder, GList *item_list, GError **error)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
GPtrArray *summary = NULL;
@@ -2280,7 +2315,7 @@ gw_update_all_items (CamelFolder *folder, GList *item_list, CamelException *ex)
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- gw_update_cache (folder, item_list, ex, TRUE);
+ gw_update_cache (folder, item_list, error, TRUE);
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
g_list_foreach (item_list, (GFunc)g_free, NULL);
@@ -2290,10 +2325,10 @@ gw_update_all_items (CamelFolder *folder, GList *item_list, CamelException *ex)
camel_folder_free_summary (folder, summary);
}
-static void
+static gboolean
groupwise_append_message (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
const gchar *container_id = NULL;
CamelGroupwiseStore *gw_store= CAMEL_GROUPWISE_STORE(folder->parent_store);
@@ -2311,14 +2346,16 @@ groupwise_append_message (CamelFolder *folder, CamelMimeMessage *message,
is_ok = TRUE;
if (!is_ok) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot append message to folder '%s': %s"),
- folder->full_name, e_gw_connection_get_error_message (status));
- return;
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot append message to folder '%s': %s"),
+ folder->full_name, e_gw_connection_get_error_message (status));
+ return FALSE;
}
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_groupwise_journal_append ((CamelGroupwiseJournal *) ((CamelGroupwiseFolder *)folder)->journal, message, info, appended_uid, ex);
- return;
+ camel_groupwise_journal_append ((CamelGroupwiseJournal *) ((CamelGroupwiseFolder *)folder)->journal, message, info, appended_uid, error);
+ return FALSE;
}
cnc = cnc_lookup (priv);
@@ -2342,32 +2379,38 @@ groupwise_append_message (CamelFolder *folder, CamelMimeMessage *message,
status = e_gw_connection_create_item (cnc, item, &id);
if (status != E_GW_CONNECTION_STATUS_OK) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create message: %s"),
- e_gw_connection_get_error_message (status));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot create message: %s"),
+ e_gw_connection_get_error_message (status));
if (appended_uid)
*appended_uid = NULL;
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
- return;
+ return FALSE;
}
status = e_gw_connection_add_item (cnc, container_id, id);
g_message ("Adding %s to %s", id, container_id);
if (status != E_GW_CONNECTION_STATUS_OK) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot append message to folder '%s': %s"),
- folder->full_name, e_gw_connection_get_error_message (status));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot append message to folder '%s': %s"),
+ folder->full_name, e_gw_connection_get_error_message (status));
if (appended_uid)
*appended_uid = NULL;
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
- return;
+ return FALSE;
}
if (appended_uid)
*appended_uid = g_strdup (id);
g_free (id);
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
+
+ return TRUE;
}
/* A function to compare uids, inspired by strcmp .
@@ -2389,10 +2432,10 @@ uid_compar (gconstpointer va, gconstpointer vb)
}
/* move messages */
-static void
+static gboolean
groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
CamelFolder *destination, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+ gboolean delete_originals, GError **error)
{
gint count, index = 0;
GList *item_ids = NULL;
@@ -2441,23 +2484,28 @@ groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
for (l = item_ids, i = 0; l; l = l->next, i++) {
CamelMessageInfo *info;
+ GError *local_error = NULL;
if (!(info = camel_folder_summary_uid (source->summary, uids->pdata[i])))
continue;
- if (!(message = groupwise_folder_get_message (source, camel_message_info_uid (info), ex)))
+ if (!(message = groupwise_folder_get_message (source, camel_message_info_uid (info), error)))
break;
- camel_groupwise_journal_transfer (journal, (CamelGroupwiseFolder *)source, message, info, uids->pdata[i], NULL, ex);
+ camel_groupwise_journal_transfer (journal, (CamelGroupwiseFolder *)source, message, info, uids->pdata[i], NULL, &local_error);
g_object_unref (message);
- if (camel_exception_is_set (ex))
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
break;
+ }
if (delete_originals) {
if ( !strcmp(source->full_name, SENT) ) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not available in offline mode."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("This message is not available in offline mode."));
} else {
camel_folder_summary_remove_uid (source->summary, uids->pdata[i]);
@@ -2467,7 +2515,7 @@ groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
}
CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
- return;
+ return TRUE;
}
cnc = cnc_lookup (priv);
@@ -2580,7 +2628,7 @@ groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
/* Refresh the destination folder, if its not refreshed already */
if (gw_store->current_folder != destination )
- camel_folder_refresh_info (destination, ex);
+ camel_folder_refresh_info (destination, error);
camel_folder_summary_touch (source->summary);
camel_folder_summary_touch (destination->summary);
@@ -2588,10 +2636,12 @@ groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
groupwise_store_set_current_folder (gw_store, source);
CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
+
+ return TRUE;
}
-static void
-groupwise_expunge (CamelFolder *folder, CamelException *ex)
+static gboolean
+groupwise_expunge (CamelFolder *folder, GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE(folder->parent_store);
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
@@ -2609,7 +2659,7 @@ groupwise_expunge (CamelFolder *folder, CamelException *ex)
deleted_items = deleted_head = NULL;
cnc = cnc_lookup (priv);
if (!cnc)
- return;
+ return TRUE;
if (!strcmp (folder->full_name, "Trash")) {
CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
@@ -2621,7 +2671,7 @@ groupwise_expunge (CamelFolder *folder, CamelException *ex)
} else
g_warning ("Could not Empty Trash\n");
CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
- return;
+ return TRUE;
}
changes = camel_folder_change_info_new ();
@@ -2692,6 +2742,8 @@ groupwise_expunge (CamelFolder *folder, CamelException *ex)
g_free (container_id);
camel_folder_change_info_free (changes);
+
+ return TRUE;
}
static gint
@@ -2793,7 +2845,7 @@ camel_groupwise_folder_get_type (void)
}
static gint
-gw_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
+gw_getv (CamelObject *object, GError **error, CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
gint i, count = 0;
@@ -2823,7 +2875,7 @@ gw_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
}
if (count)
- return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->getv(object, error, args);
return 0;
diff --git a/camel/providers/groupwise/camel-groupwise-folder.h b/camel/providers/groupwise/camel-groupwise-folder.h
index 937818e..2b86ac7 100644
--- a/camel/providers/groupwise/camel-groupwise-folder.h
+++ b/camel/providers/groupwise/camel-groupwise-folder.h
@@ -81,8 +81,8 @@ struct _CamelGroupwiseFolderClass {
GType camel_groupwise_folder_get_type (void);
/* implemented */
-CamelFolder * camel_gw_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *folder_name, CamelException *ex);
-void gw_update_summary ( CamelFolder *folder, GList *item_list,CamelException *ex);
+CamelFolder * camel_gw_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *folder_name, GError **error);
+void gw_update_summary ( CamelFolder *folder, GList *item_list,GError **error);
G_END_DECLS
diff --git a/camel/providers/groupwise/camel-groupwise-journal.c b/camel/providers/groupwise/camel-groupwise-journal.c
index cab0760..0aff116 100644
--- a/camel/providers/groupwise/camel-groupwise-journal.c
+++ b/camel/providers/groupwise/camel-groupwise-journal.c
@@ -44,7 +44,7 @@
static void groupwise_entry_free (CamelOfflineJournal *journal, CamelDListNode *entry);
static CamelDListNode *groupwise_entry_load (CamelOfflineJournal *journal, FILE *in);
static gint groupwise_entry_write (CamelOfflineJournal *journal, CamelDListNode *entry, FILE *out);
-static gint groupwise_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelException *ex);
+static gint groupwise_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, GError **error);
static gpointer parent_class;
@@ -171,17 +171,17 @@ gw_message_info_dup_to (CamelMessageInfoBase *dest, CamelMessageInfoBase *src)
}
static gint
-groupwise_entry_play_append (CamelOfflineJournal *journal, CamelGroupwiseJournalEntry *entry, CamelException *ex)
+groupwise_entry_play_append (CamelOfflineJournal *journal, CamelGroupwiseJournalEntry *entry, GError **error)
{
CamelGroupwiseFolder *gw_folder = (CamelGroupwiseFolder *) journal->folder;
CamelFolder *folder = journal->folder;
CamelMimeMessage *message;
CamelMessageInfo *info;
CamelStream *stream;
- CamelException lex;
+ gboolean success;
/* if the message isn't in the cache, the user went behind our backs so "not our problem" */
- if (!gw_folder->cache || !(stream = camel_data_cache_get (gw_folder->cache, "cache", entry->uid, ex)))
+ if (!gw_folder->cache || !(stream = camel_data_cache_get (gw_folder->cache, "cache", entry->uid, error)))
goto done;
message = camel_mime_message_new ();
@@ -198,15 +198,12 @@ groupwise_entry_play_append (CamelOfflineJournal *journal, CamelGroupwiseJournal
info = camel_message_info_new (NULL);
}
- camel_exception_init (&lex);
- camel_folder_append_message (folder, message, info, NULL, &lex);
+ success = camel_folder_append_message (folder, message, info, NULL, error);
camel_message_info_free (info);
g_object_unref (message);
- if (camel_exception_is_set (&lex)) {
- camel_exception_xfer (ex, &lex);
+ if (!success)
return -1;
- }
done:
@@ -217,14 +214,13 @@ groupwise_entry_play_append (CamelOfflineJournal *journal, CamelGroupwiseJournal
}
static gint
-groupwise_entry_play_transfer (CamelOfflineJournal *journal, CamelGroupwiseJournalEntry *entry, CamelException *ex)
+groupwise_entry_play_transfer (CamelOfflineJournal *journal, CamelGroupwiseJournalEntry *entry, GError **error)
{
CamelGroupwiseFolder *gw_folder = (CamelGroupwiseFolder *) journal->folder;
CamelFolder *folder = journal->folder;
CamelGroupwiseMessageInfo *real;
CamelMessageInfoBase *info;
GPtrArray *xuids, *uids;
- CamelException lex;
CamelFolder *src;
const gchar *name;
@@ -234,20 +230,17 @@ groupwise_entry_play_transfer (CamelOfflineJournal *journal, CamelGroupwiseJourn
}
name = camel_groupwise_store_folder_lookup ((CamelGroupwiseStore *) folder->parent_store, entry->source_container);
- if (name && (src = camel_store_get_folder (folder->parent_store, name, 0, ex))) {
+ if (name && (src = camel_store_get_folder (folder->parent_store, name, 0, error))) {
uids = g_ptr_array_sized_new (1);
g_ptr_array_add (uids, entry->original_uid);
- camel_exception_init (&lex);
- camel_folder_transfer_messages_to (src, uids, folder, &xuids, FALSE, &lex);
- if (!camel_exception_is_set (&lex)) {
+ if (camel_folder_transfer_messages_to (src, uids, folder, &xuids, FALSE, error)) {
real = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->summary, xuids->pdata[0]);
/* transfer all the system flags, user flags/tags, etc */
gw_message_info_dup_to ((CamelMessageInfoBase *) real, (CamelMessageInfoBase *) info);
camel_message_info_free (real);
} else {
- camel_exception_xfer (ex, &lex);
goto exception;
}
@@ -255,8 +248,10 @@ groupwise_entry_play_transfer (CamelOfflineJournal *journal, CamelGroupwiseJourn
g_ptr_array_free (uids, TRUE);
g_object_unref (src);
} else if (!name) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get folder container %s"),
- entry->source_container);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot get folder container %s"),
+ entry->source_container);
goto exception;
}
@@ -275,15 +270,15 @@ groupwise_entry_play_transfer (CamelOfflineJournal *journal, CamelGroupwiseJourn
}
static gint
-groupwise_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelException *ex)
+groupwise_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, GError **error)
{
CamelGroupwiseJournalEntry *groupwise_entry = (CamelGroupwiseJournalEntry *) entry;
switch (groupwise_entry->type) {
case CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND:
- return groupwise_entry_play_append (journal, groupwise_entry, ex);
+ return groupwise_entry_play_append (journal, groupwise_entry, error);
case CAMEL_GROUPWISE_JOURNAL_ENTRY_TRANSFER:
- return groupwise_entry_play_transfer (journal, groupwise_entry, ex);
+ return groupwise_entry_play_transfer (journal, groupwise_entry, error);
default:
g_assert_not_reached ();
return -1;
@@ -305,7 +300,7 @@ camel_groupwise_journal_new (CamelGroupwiseFolder *folder, const gchar *filename
static gboolean
update_cache (CamelGroupwiseJournal *groupwise_journal, CamelMimeMessage *message,
- const CamelMessageInfo *mi, gchar **updated_uid, CamelException *ex)
+ const CamelMessageInfo *mi, gchar **updated_uid, GError **error)
{
CamelOfflineJournal *journal = (CamelOfflineJournal *) groupwise_journal;
CamelGroupwiseFolder *groupwise_folder = (CamelGroupwiseFolder *) journal->folder;
@@ -316,15 +311,17 @@ update_cache (CamelGroupwiseJournal *groupwise_journal, CamelMimeMessage *messag
gchar *uid;
if (groupwise_folder->cache == NULL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message in offline mode: cache unavailable"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot append message in offline mode: cache unavailable"));
return FALSE;
}
nextuid = camel_folder_summary_next_uid (folder->summary);
uid = g_strdup_printf ("-%u", nextuid);
- if (!(cache = camel_data_cache_add (groupwise_folder->cache, "cache", uid, ex))) {
+ if (!(cache = camel_data_cache_add (groupwise_folder->cache, "cache", uid, error))) {
folder->summary->nextuid--;
g_free (uid);
return FALSE;
@@ -332,9 +329,11 @@ update_cache (CamelGroupwiseJournal *groupwise_journal, CamelMimeMessage *messag
if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) message, cache) == -1
|| camel_stream_flush (cache) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message in offline mode: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot append message in offline mode: %s"),
+ g_strerror (errno));
camel_data_cache_remove (groupwise_folder->cache, "cache", uid, NULL);
folder->summary->nextuid--;
g_object_unref (cache);
@@ -362,13 +361,13 @@ update_cache (CamelGroupwiseJournal *groupwise_journal, CamelMimeMessage *messag
void
camel_groupwise_journal_append (CamelGroupwiseJournal *groupwise_journal, CamelMimeMessage *message,
- const CamelMessageInfo *mi, gchar **appended_uid, CamelException *ex)
+ const CamelMessageInfo *mi, gchar **appended_uid, GError **error)
{
CamelOfflineJournal *journal = (CamelOfflineJournal *) groupwise_journal;
CamelGroupwiseJournalEntry *entry;
gchar *uid;
- if (!update_cache (groupwise_journal, message, mi, &uid, ex))
+ if (!update_cache (groupwise_journal, message, mi, &uid, error))
return;
entry = g_new (CamelGroupwiseJournalEntry, 1);
@@ -385,14 +384,14 @@ void
camel_groupwise_journal_transfer (CamelGroupwiseJournal *groupwise_journal, CamelGroupwiseFolder *source_folder,
CamelMimeMessage *message, const CamelMessageInfo *mi,
const gchar *original_uid, gchar **transferred_uid,
- CamelException *ex)
+ GError **error)
{
CamelOfflineJournal *journal = (CamelOfflineJournal *) groupwise_journal;
CamelGroupwiseStore *gw_store= CAMEL_GROUPWISE_STORE(journal->folder->parent_store);
CamelGroupwiseJournalEntry *entry;
gchar *uid;
- if (!update_cache (groupwise_journal, message, mi, &uid, ex))
+ if (!update_cache (groupwise_journal, message, mi, &uid, error))
return;
entry = g_new (CamelGroupwiseJournalEntry, 1);
diff --git a/camel/providers/groupwise/camel-groupwise-journal.h b/camel/providers/groupwise/camel-groupwise-journal.h
index d6246ea..c0fb5ec 100644
--- a/camel/providers/groupwise/camel-groupwise-journal.h
+++ b/camel/providers/groupwise/camel-groupwise-journal.h
@@ -84,9 +84,9 @@ CamelOfflineJournal *camel_groupwise_journal_new (struct _CamelGroupwiseFolder *
/* interfaces for adding a journal entry */
void camel_groupwise_journal_append (CamelGroupwiseJournal *journal, CamelMimeMessage *message, const CamelMessageInfo *mi,
- gchar **appended_uid, CamelException *ex);
+ gchar **appended_uid, GError **error);
void camel_groupwise_journal_transfer (CamelGroupwiseJournal *journal, CamelGroupwiseFolder *source_folder, CamelMimeMessage *message,
- const CamelMessageInfo *mi, const gchar *orginal_uid, gchar **transferred_uid, CamelException *ex);
+ const CamelMessageInfo *mi, const gchar *orginal_uid, gchar **transferred_uid, GError **error);
G_END_DECLS
diff --git a/camel/providers/groupwise/camel-groupwise-provider.c b/camel/providers/groupwise/camel-groupwise-provider.c
index 41b5dfa..4792e7e 100644
--- a/camel/providers/groupwise/camel-groupwise-provider.c
+++ b/camel/providers/groupwise/camel-groupwise-provider.c
@@ -106,7 +106,7 @@ CamelServiceAuthType camel_groupwise_password_authtype = {
static gint
groupwise_auto_detect_cb (CamelURL *url, GHashTable **auto_detected,
- CamelException *ex)
+ GError **error)
{
*auto_detected = g_hash_table_new (g_str_hash, g_str_equal);
@@ -120,11 +120,10 @@ void
camel_provider_module_init(void)
{
CamelProvider *imap_provider = NULL;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
gboolean use_imap = g_getenv ("USE_IMAP") != NULL;
if (use_imap)
- imap_provider = camel_provider_get("imap://", &ex);
+ imap_provider = camel_provider_get("imap://", NULL);
groupwise_provider.url_hash = groupwise_url_hash;
groupwise_provider.url_equal = groupwise_url_equal;
diff --git a/camel/providers/groupwise/camel-groupwise-store.c b/camel/providers/groupwise/camel-groupwise-store.c
index ac624e4..86270ab 100644
--- a/camel/providers/groupwise/camel-groupwise-store.c
+++ b/camel/providers/groupwise/camel-groupwise-store.c
@@ -74,15 +74,16 @@ struct _CamelGroupwiseStorePrivate {
static gpointer parent_class;
extern CamelServiceAuthType camel_groupwise_password_authtype; /*for the query_auth_types function*/
-static CamelFolderInfo *convert_to_folder_info (CamelGroupwiseStore *store, EGwContainer *container, const gchar *url, CamelException *ex);
-static void groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex);
+static CamelFolderInfo *convert_to_folder_info (CamelGroupwiseStore *store, EGwContainer *container, const gchar *url, GError **error);
+static gboolean groupwise_folders_sync (CamelGroupwiseStore *store, GError **error);
static gint match_path(const gchar *path, const gchar *name);
-static void
+static gboolean
groupwise_store_construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex)
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
CamelStore *store = CAMEL_STORE (service);
const gchar *property_value;
@@ -91,13 +92,16 @@ groupwise_store_construct (CamelService *service, CamelSession *session,
d(printf ("\nin groupwise store constrcut\n"));
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ /* Chain up to parent's construct() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
if (!(url->host || url->user)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID,
- _("Host or user not available in url"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Host or user not available in url"));
}
/*XXX: The number 3 assigned to the list_loaded variable denotes
@@ -108,9 +112,9 @@ groupwise_store_construct (CamelService *service, CamelSession *session,
groupwise_store->list_loaded = 3;
/*storage path*/
- priv->storage_path = camel_session_get_storage_path (session, service, ex);
+ priv->storage_path = camel_session_get_storage_path (session, service, error);
if (!priv->storage_path)
- return;
+ return FALSE;
/*store summary*/
path = g_alloca (strlen (priv->storage_path) + 32);
@@ -152,6 +156,8 @@ groupwise_store_construct (CamelService *service, CamelSession *session,
store->flags &= ~CAMEL_STORE_VJUNK;
store->flags &= ~CAMEL_STORE_VTRASH;
+
+ return TRUE;
}
static guint
@@ -169,7 +175,7 @@ groupwise_compare_folder_name (gconstpointer a, gconstpointer b)
}
static gboolean
-groupwise_auth_loop (CamelService *service, CamelException *ex)
+groupwise_auth_loop (CamelService *service, GError **error)
{
CamelSession *session = camel_service_get_session (service);
CamelStore *store = CAMEL_STORE (service);
@@ -194,12 +200,14 @@ groupwise_auth_loop (CamelService *service, CamelException *ex)
"GroupWise", service->url->user, service->url->host);
service->url->passwd =
camel_session_get_password (session, service, "Groupwise",
- prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
+ prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, error);
g_free (prompt);
if (!service->url->passwd) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("You did not enter a password."));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("You did not enter a password."));
return FALSE;
}
}
@@ -213,12 +221,17 @@ groupwise_auth_loop (CamelService *service, CamelException *ex)
if (!E_IS_GW_CONNECTION(priv->cnc)) {
if (errors.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD) {
/* We need to un-cache the password before prompting again */
- camel_session_forget_password (session, service, "Groupwise", "password", ex);
+ camel_session_forget_password (session, service, "Groupwise", "password", error);
g_free (service->url->passwd);
service->url->passwd = NULL;
- camel_exception_clear (ex);
+ g_clear_error (error);
} else {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, errors.description ? errors.description : _("You must be working online to complete this operation"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ "%s", errors.description ?
+ errors.description :
+ _("You must be working online to complete this operation"));
return FALSE;
}
} else
@@ -230,22 +243,27 @@ groupwise_auth_loop (CamelService *service, CamelException *ex)
}
static gboolean
-check_for_connection (CamelService *service, CamelException *ex)
+check_for_connection (CamelService *service, GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
struct addrinfo hints, *ai;
+ GError *local_error = NULL;
memset (&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(priv->server_name, "groupwise", &hints, ex);
- if (ai == NULL && priv->port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
- camel_exception_clear (ex);
- ai = camel_getaddrinfo(priv->server_name, priv->port, &hints, ex);
+ ai = camel_getaddrinfo(priv->server_name, "groupwise", &hints, &local_error);
+ if (ai == NULL && priv->port != NULL &&
+ !g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL)) {
+ g_clear_error (&local_error);
+ ai = camel_getaddrinfo(priv->server_name, priv->port, &hints, &local_error);
}
- if (ai == NULL)
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
camel_freeaddrinfo (ai);
@@ -274,7 +292,7 @@ groupwise_store_set_current_folder (CamelGroupwiseStore *groupwise_store, CamelF
}
static gboolean
-groupwise_connect (CamelService *service, CamelException *ex)
+groupwise_connect (CamelService *service, GError **error)
{
CamelGroupwiseStore *store = CAMEL_GROUPWISE_STORE (service);
CamelGroupwiseStorePrivate *priv = store->priv;
@@ -292,7 +310,7 @@ groupwise_connect (CamelService *service, CamelException *ex)
if (!priv) {
store->priv = g_new0 (CamelGroupwiseStorePrivate, 1);
priv = store->priv;
- camel_service_construct (service, service->session, service->provider, service->url, ex);
+ camel_service_construct (service, service->session, service->provider, service->url, error);
}
CAMEL_SERVICE_REC_LOCK (service, connect_lock);
@@ -302,7 +320,7 @@ groupwise_connect (CamelService *service, CamelException *ex)
return TRUE;
}
- if (!check_for_connection (service, ex) || !groupwise_auth_loop (service, ex)) {
+ if (!check_for_connection (service, error) || !groupwise_auth_loop (service, error)) {
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
@@ -339,7 +357,7 @@ groupwise_connect (CamelService *service, CamelException *ex)
}
#if 0
static void
-groupwise_disconnect_cleanup (CamelService *service, gboolean clean, CamelException *ex)
+groupwise_disconnect_cleanup (CamelService *service, gboolean clean, GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
@@ -394,7 +412,7 @@ groupwise_disconnect_cleanup (CamelService *service, gboolean clean, CamelExcept
#endif
static gboolean
-groupwise_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+groupwise_disconnect (CamelService *service, gboolean clean, GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
@@ -415,7 +433,7 @@ groupwise_disconnect (CamelService *service, gboolean clean, CamelException *ex)
}
static GList*
-groupwise_store_query_auth_types (CamelService *service, CamelException *ex)
+groupwise_store_query_auth_types (CamelService *service, GError **error)
{
GList *auth_types = NULL;
@@ -488,7 +506,7 @@ groupwise_build_folder_info(CamelGroupwiseStore *gw_store, const gchar *parent_n
}
static void
-groupwise_forget_folder (CamelGroupwiseStore *gw_store, const gchar *folder_name, CamelException *ex)
+groupwise_forget_folder (CamelGroupwiseStore *gw_store, const gchar *folder_name, GError **error)
{
CamelGroupwiseStorePrivate *priv = gw_store->priv;
gchar *state_file;
@@ -522,7 +540,7 @@ groupwise_forget_folder (CamelGroupwiseStore *gw_store, const gchar *folder_name
}
static CamelFolder *
-groupwise_get_folder_from_disk (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+groupwise_get_folder_from_disk (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = gw_store->priv;
@@ -534,19 +552,21 @@ groupwise_get_folder_from_disk (CamelStore *store, const gchar *folder_name, gui
g_free(storage_path);
if (!folder_dir || g_access (folder_dir, F_OK) != 0) {
g_free (folder_dir);
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("No such folder %s"), folder_name);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("No such folder %s"), folder_name);
return NULL;
}
- folder = camel_gw_folder_new (store, folder_name, folder_dir, ex);
+ folder = camel_gw_folder_new (store, folder_name, folder_dir, error);
g_free (folder_dir);
return folder;
}
static CamelFolder *
-groupwise_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+groupwise_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = gw_store->priv;
@@ -561,25 +581,25 @@ groupwise_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags
CamelStoreInfo *si = NULL;
guint total = 0;
- folder = groupwise_get_folder_from_disk (store, folder_name, flags, ex);
+ folder = groupwise_get_folder_from_disk (store, folder_name, flags, error);
if (folder) {
groupwise_store_set_current_folder (gw_store, folder);
return folder;
}
- camel_exception_clear (ex);
+ g_clear_error (error);
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
groupwise_store_set_current_folder (gw_store, NULL);
- if (!camel_groupwise_store_connected (gw_store, ex)) {
+ if (!camel_groupwise_store_connected (gw_store, error)) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
return NULL;
}
if (!E_IS_GW_CONNECTION( priv->cnc)) {
- if (!groupwise_connect (CAMEL_SERVICE(store), ex)) {
+ if (!groupwise_connect (CAMEL_SERVICE(store), error)) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
return NULL;
}
@@ -590,10 +610,13 @@ groupwise_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags
storage_path = g_strdup_printf("%s/folders", priv->storage_path);
folder_dir = e_path_to_physical (storage_path, folder_name);
g_free(storage_path);
- folder = camel_gw_folder_new (store, folder_name, folder_dir, ex);
+ folder = camel_gw_folder_new (store, folder_name, folder_dir, error);
if (!folder) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Authentication failed"));
g_free (folder_dir);
g_free (container_id);
return NULL;
@@ -663,7 +686,7 @@ groupwise_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags
camel_operation_progress (NULL, (100*count)/total);
}
- gw_update_summary (folder, list, ex);
+ gw_update_summary (folder, list, error);
/* For shared-folders created by the user, we don't get the total number of messages,
in the getFolderList call. So, we need to wait until an empty list is returned in the
@@ -687,7 +710,7 @@ groupwise_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags
summary->time_string = g_strdup (e_gw_connection_get_server_time (priv->cnc));
}
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
groupwise_store_set_current_folder (gw_store, folder);
@@ -698,7 +721,7 @@ groupwise_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags
}
void
-gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guint32 flags, CamelException *ex)
+gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guint32 flags, GError **error)
{
CamelGroupwiseStorePrivate *priv = gw_store->priv;
CamelGroupwiseSummary *summary;
@@ -711,17 +734,15 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guin
CamelStoreInfo *si = NULL;
guint total = 0;
- camel_exception_clear (ex);
-
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- if (!camel_groupwise_store_connected (gw_store, ex)) {
+ if (!camel_groupwise_store_connected (gw_store, error)) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
return;
}
if (!E_IS_GW_CONNECTION( priv->cnc)) {
- if (!groupwise_connect (CAMEL_SERVICE((CamelStore*)gw_store), ex)) {
+ if (!groupwise_connect (CAMEL_SERVICE((CamelStore*)gw_store), error)) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
return;
}
@@ -737,7 +758,7 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guin
summary = (CamelGroupwiseSummary *) folder->summary;
camel_folder_summary_clear (folder->summary);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
summary_count = camel_folder_summary_count (folder->summary);
if (!summary_count || !summary->time_string) {
@@ -767,8 +788,11 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guin
if (status != E_GW_CONNECTION_STATUS_OK) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
- camel_folder_summary_save_to_db (folder->summary, ex);
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Authentication failed"));
camel_operation_end (NULL);
g_free (container_id);
return;
@@ -786,7 +810,7 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guin
camel_operation_progress (NULL, (100*count)/total);
}
- gw_update_summary (folder, list, ex);
+ gw_update_summary (folder, list, error);
/* For shared-folders created by the user, we don't get the total number of messages,
in the getFolderList call. So, we need to wait until an empty list is returned in the
@@ -811,7 +835,7 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guin
summary->time_string = g_strdup (e_gw_connection_get_server_time (priv->cnc));
}
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
groupwise_store_set_current_folder (gw_store, NULL);
@@ -821,7 +845,7 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guin
}
static CamelFolderInfo *
-convert_to_folder_info (CamelGroupwiseStore *store, EGwContainer *container, const gchar *url, CamelException *ex)
+convert_to_folder_info (CamelGroupwiseStore *store, EGwContainer *container, const gchar *url, GError **error)
{
const gchar *name = NULL, *id = NULL, *parent = NULL;
gchar *par_name = NULL;
@@ -917,7 +941,7 @@ convert_to_folder_info (CamelGroupwiseStore *store, EGwContainer *container, con
if (store->current_folder
&& !strcmp (store->current_folder->full_name, fi->full_name)
&& type != E_GW_CONTAINER_TYPE_INBOX) {
- CAMEL_FOLDER_GET_CLASS (store->current_folder)->refresh_info (store->current_folder, ex);
+ CAMEL_FOLDER_GET_CLASS (store->current_folder)->refresh_info (store->current_folder, error);
}
return fi;
}
@@ -929,8 +953,8 @@ get_folders_free (gpointer k, gpointer v, gpointer d)
camel_folder_info_free (fi);
}
-static void
-groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex)
+static gboolean
+groupwise_folders_sync (CamelGroupwiseStore *store, GError **error)
{
CamelGroupwiseStorePrivate *priv = store->priv;
gint status;
@@ -944,7 +968,7 @@ groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex)
if (!priv->cnc && ((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
if (((CamelService *)store)->status == CAMEL_SERVICE_DISCONNECTED) {
((CamelService *)store)->status = CAMEL_SERVICE_CONNECTING;
- groupwise_connect ((CamelService *)store, ex);
+ groupwise_connect ((CamelService *)store, error);
}
}
@@ -953,7 +977,7 @@ groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex)
status = e_gw_connection_get_container_list (priv->cnc, "folders", &folder_list);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not get folder list..\n");
- return;
+ return TRUE;
}
temp_list = folder_list;
@@ -1003,7 +1027,7 @@ groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex)
if ( (type == E_GW_CONTAINER_TYPE_CALENDAR) || (type == E_GW_CONTAINER_TYPE_CONTACTS) )
continue;
- info = convert_to_folder_info (store, E_GW_CONTAINER (folder_list->data), (const gchar *)url, ex);
+ info = convert_to_folder_info (store, E_GW_CONTAINER (folder_list->data), (const gchar *)url, error);
if (info) {
hfi = g_hash_table_lookup (present, info->full_name);
if (hfi == NULL)
@@ -1038,11 +1062,13 @@ groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex)
g_hash_table_foreach (present, get_folders_free, NULL);
g_hash_table_destroy (present);
+
+ return TRUE;
}
static CamelFolderInfo *
groupwise_get_folder_info_offline (CamelStore *store, const gchar *top,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelFolderInfo *fi;
@@ -1095,7 +1121,7 @@ struct _store_refresh_msg {
CamelSessionThreadMsg msg;
CamelStore *store;
- CamelException ex;
+ GError *error;
};
#if 0
@@ -1135,7 +1161,7 @@ static CamelSessionThreadOps store_refresh_ops = {
/*** Thread stuff ends ***/
static CamelFolderInfo *
-groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
@@ -1161,14 +1187,17 @@ groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, C
* is used as is here.
*/
if (camel_store_summary_count ((CamelStoreSummary *)groupwise_store->summary) == 0) {
+ GError *local_error = NULL;
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
if (groupwise_store->list_loaded == 3) {
- groupwise_folders_sync (groupwise_store, ex);
+ groupwise_folders_sync (groupwise_store, &local_error);
groupwise_store->list_loaded -= 1;
}
- if (camel_exception_is_set (ex)) {
+ if (local_error != NULL) {
camel_store_summary_save ((CamelStoreSummary *) groupwise_store->summary);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ g_propagate_error (error, local_error);
return NULL;
}
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
@@ -1183,18 +1212,17 @@ groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, C
}
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
- if ((groupwise_store->list_loaded == 1) && check_for_connection((CamelService *)store, ex)) {
+ if ((groupwise_store->list_loaded == 1) && check_for_connection((CamelService *)store, error)) {
if (!priv->cnc) {
- if (groupwise_connect ((CamelService *)store, ex)) {
+ if (groupwise_connect ((CamelService *)store, error)) {
g_warning ("Could connect!!!\n");
} else
g_warning ("Could not connect..failure connecting\n");
}
- if (camel_groupwise_store_connected (groupwise_store, ex)) {
+ if (camel_groupwise_store_connected (groupwise_store, error)) {
if (groupwise_store->current_folder)
- CAMEL_FOLDER_GET_CLASS (groupwise_store->current_folder)->sync (groupwise_store->current_folder, FALSE, ex);
- groupwise_folders_sync (groupwise_store, ex);
- if (camel_exception_is_set (ex)) {
+ CAMEL_FOLDER_GET_CLASS (groupwise_store->current_folder)->sync (groupwise_store->current_folder, FALSE, error);
+ if (!groupwise_folders_sync (groupwise_store, error)) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return NULL;
}
@@ -1206,7 +1234,7 @@ groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, C
/*camel_exception_clear (ex);*/
end_r:
- info = groupwise_get_folder_info_offline (store, top, flags, ex);
+ info = groupwise_get_folder_info_offline (store, top, flags, error);
return info;
}
@@ -1251,7 +1279,7 @@ static CamelFolderInfo*
groupwise_create_folder(CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
@@ -1261,21 +1289,28 @@ groupwise_create_folder(CamelStore *store,
gint status;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create GroupWise folders in offline mode."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot create GroupWise folders in offline mode."));
return NULL;
}
if (parent_name == NULL) {
parent_name = "";
if (groupwise_is_system_folder (folder_name)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, NULL);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ NULL /* XXX Um, hello? Error message? */);
return NULL;
}
}
if (parent_name && (strlen(parent_name) > 0) ) {
if (strcmp (parent_name, "Cabinet") && groupwise_is_system_folder (parent_name)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE, _("The parent folder is not allowed to contain subfolders"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("The parent folder is not allowed to contain subfolders"));
return NULL;
}
parent_id = g_hash_table_lookup (priv->name_hash, parent_name);
@@ -1283,7 +1318,7 @@ groupwise_create_folder(CamelStore *store,
parent_id = "";
if (!E_IS_GW_CONNECTION( priv->cnc)) {
- if (!groupwise_connect (CAMEL_SERVICE(store), ex)) {
+ if (!groupwise_connect (CAMEL_SERVICE(store), error)) {
return NULL;
}
}
@@ -1305,10 +1340,10 @@ groupwise_create_folder(CamelStore *store,
return root;
}
-static void
+static gboolean
groupwise_delete_folder(CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
@@ -1317,9 +1352,9 @@ groupwise_delete_folder(CamelStore *store,
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
- if (!camel_groupwise_store_connected (groupwise_store, ex)) {
+ if (!camel_groupwise_store_connected (groupwise_store, error)) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return FALSE;
}
container = g_hash_table_lookup (priv->name_hash, folder_name);
@@ -1331,7 +1366,7 @@ groupwise_delete_folder(CamelStore *store,
if (status == E_GW_CONNECTION_STATUS_OK) {
groupwise_store_set_current_folder (groupwise_store, NULL);
- groupwise_forget_folder(groupwise_store,folder_name,ex);
+ groupwise_forget_folder(groupwise_store,folder_name,error);
g_hash_table_remove (priv->id_hash, container);
g_hash_table_remove (priv->name_hash, folder_name);
@@ -1339,13 +1374,15 @@ groupwise_delete_folder(CamelStore *store,
g_hash_table_remove (priv->parent_hash, container);
}
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+
+ return TRUE;
}
-static void
+static gboolean
groupwise_rename_folder(CamelStore *store,
const gchar *old_name,
const gchar *new_name,
- CamelException *ex)
+ GError **error)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
@@ -1354,16 +1391,18 @@ groupwise_rename_folder(CamelStore *store,
gchar *temp_new = NULL;
if (groupwise_is_system_folder (old_name)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename GroupWise folder '%s' to '%s'"),
- old_name, new_name);
- return;
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot rename GroupWise folder '%s' to '%s'"),
+ old_name, new_name);
+ return FALSE;
}
CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
- if (!camel_groupwise_store_connected (groupwise_store, ex)) {
+ if (!camel_groupwise_store_connected (groupwise_store, error)) {
CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
- return;
+ return FALSE;
}
groupwise_store_set_current_folder (groupwise_store, NULL);
@@ -1377,10 +1416,12 @@ groupwise_rename_folder(CamelStore *store,
if (!container_id || e_gw_connection_rename_folder (priv->cnc, container_id , temp_new) != E_GW_CONNECTION_STATUS_OK)
{
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename GroupWise folder '%s' to '%s'"),
- old_name, new_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot rename GroupWise folder '%s' to '%s'"),
+ old_name, new_name);
CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
- return;
+ return FALSE;
}
g_hash_table_replace (priv->id_hash, g_strdup(container_id), g_strdup(temp_new));
@@ -1403,6 +1444,8 @@ groupwise_rename_folder(CamelStore *store,
g_free (oldpath);
g_free (newpath);
CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+
+ return TRUE;
}
gchar *
@@ -1450,9 +1493,9 @@ groupwise_base_url_lookup (CamelGroupwiseStorePrivate *priv)
}
static CamelFolder *
-groupwise_get_trash (CamelStore *store, CamelException *ex)
+groupwise_get_trash (CamelStore *store, GError **error)
{
- CamelFolder *folder = camel_store_get_folder(store, "Trash", 0, ex);
+ CamelFolder *folder = camel_store_get_folder(store, "Trash", 0, error);
if (folder) {
gchar *state = g_build_filename((CAMEL_GROUPWISE_STORE(store))->priv->storage_path, "folders", "Trash", "cmeta", NULL);
@@ -1466,11 +1509,11 @@ groupwise_get_trash (CamelStore *store, CamelException *ex)
}
static gboolean
-groupwise_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+groupwise_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
{
gboolean res;
- res = CAMEL_STORE_CLASS(parent_class)->can_refresh_folder (store, info, ex) ||
+ res = CAMEL_STORE_CLASS(parent_class)->can_refresh_folder (store, info, error) ||
(camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL);
return res;
@@ -1481,10 +1524,10 @@ groupwise_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelExc
* online. Based on an equivalient function in IMAP
*/
gboolean
-camel_groupwise_store_connected (CamelGroupwiseStore *store, CamelException *ex)
+camel_groupwise_store_connected (CamelGroupwiseStore *store, GError **error)
{
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
- && camel_service_connect ((CamelService *)store, ex)) {
+ && camel_service_connect ((CamelService *)store, error)) {
return TRUE;
}
/*Not online, so return FALSE*/
diff --git a/camel/providers/groupwise/camel-groupwise-store.h b/camel/providers/groupwise/camel-groupwise-store.h
index da6793f..5c2b4e4 100644
--- a/camel/providers/groupwise/camel-groupwise-store.h
+++ b/camel/providers/groupwise/camel-groupwise-store.h
@@ -87,8 +87,8 @@ EGwConnection *cnc_lookup (CamelGroupwiseStorePrivate *priv);
gchar *storage_path_lookup (CamelGroupwiseStorePrivate *priv);
const gchar *groupwise_base_url_lookup (CamelGroupwiseStorePrivate *priv);
CamelFolderInfo * create_junk_folder (CamelStore *store);
-gboolean camel_groupwise_store_connected (CamelGroupwiseStore *store, CamelException *ex);
-void gw_store_reload_folder (CamelGroupwiseStore *store, CamelFolder *folder, guint32 flags, CamelException *ex);
+gboolean camel_groupwise_store_connected (CamelGroupwiseStore *store, GError **error);
+void gw_store_reload_folder (CamelGroupwiseStore *store, CamelFolder *folder, guint32 flags, GError **error);
void groupwise_store_set_current_folder (CamelGroupwiseStore *groupwise_store, CamelFolder *folder);
G_END_DECLS
diff --git a/camel/providers/groupwise/camel-groupwise-summary.c b/camel/providers/groupwise/camel-groupwise-summary.c
index cadad35..29a006b 100644
--- a/camel/providers/groupwise/camel-groupwise-summary.c
+++ b/camel/providers/groupwise/camel-groupwise-summary.c
@@ -55,7 +55,7 @@ static gint gw_content_info_save (CamelFolderSummary *s, FILE *out, CamelMessage
static gboolean gw_info_set_flags(CamelMessageInfo *info, guint32 flags, guint32 set);
static gint summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *mir);
-static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, CamelException *ex);
+static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, GError **error);
static CamelMIRecord * message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info);
static CamelMessageInfo * message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
static gint content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir);
@@ -147,7 +147,6 @@ camel_groupwise_summary_get_type (void)
CamelFolderSummary *
camel_groupwise_summary_new (struct _CamelFolder *folder, const gchar *filename)
{
- CamelException ex;
CamelFolderSummary *summary;
summary = g_object_new (CAMEL_TYPE_GROUPWISE_SUMMARY, NULL);
@@ -155,8 +154,7 @@ camel_groupwise_summary_new (struct _CamelFolder *folder, const gchar *filename)
camel_folder_summary_set_build_content (summary, TRUE);
camel_folder_summary_set_filename (summary, filename);
- camel_exception_init (&ex);
- if (camel_folder_summary_load_from_db (summary, &ex) == -1) {
+ if (camel_folder_summary_load_from_db (summary, NULL) == -1) {
camel_folder_summary_clear_db (summary);
}
@@ -205,12 +203,12 @@ gw_summary_header_load (CamelFolderSummary *s, FILE *in)
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s, GError **error)
{
CamelGroupwiseSummary *ims = CAMEL_GROUPWISE_SUMMARY(s);
struct _CamelFIRecord *fir;
- fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, ex);
+ fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, error);
if (!fir)
return NULL;
diff --git a/camel/providers/groupwise/camel-groupwise-transport.c b/camel/providers/groupwise/camel-groupwise-transport.c
index 1c85b1f..42cdb23 100644
--- a/camel/providers/groupwise/camel-groupwise-transport.c
+++ b/camel/providers/groupwise/camel-groupwise-transport.c
@@ -40,13 +40,13 @@ static gboolean groupwise_send_to (CamelTransport *transport,
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex);
+ GError **error);
static gpointer parent_class;
static gboolean
groupwise_transport_connect (CamelService *service,
- CamelException *ex)
+ GError **error)
{
return TRUE;
}
@@ -65,29 +65,12 @@ groupwise_transport_get_name (CamelService *service,
service->url->host);
}
-static void
-groupwise_transport_construct (CamelService *service,
- CamelSession *session,
- CamelProvider *provider,
- CamelURL *url,
- CamelException *ex)
-{
- CamelServiceClass *service_class;
-
- /* Chain up to parent's construct() method. */
- service_class = CAMEL_SERVICE_CLASS (parent_class);
- service_class->construct (service, session, provider, url, ex);
-
- if (camel_exception_is_set (ex))
- return;
-}
-
static gboolean
groupwise_send_to (CamelTransport *transport,
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex)
+ GError **error)
{
CamelService *service;
CamelStore *store = NULL;
@@ -102,7 +85,10 @@ groupwise_send_to (CamelTransport *transport,
EGwItemLinkInfo *info = NULL;
if (!transport) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Authentication failed"));
return FALSE;
}
@@ -115,11 +101,14 @@ groupwise_send_to (CamelTransport *transport,
camel_operation_start (NULL, _("Sending Message") );
/*camel groupwise store and cnc*/
- store = camel_session_get_store (service->session, url, ex );
+ store = camel_session_get_store (service->session, url, error);
g_free (url);
if (!store) {
g_warning ("ERROR: Could not get a pointer to the store");
- camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("Cannot get folder: Invalid operation on this store"));
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
+ _("Cannot get folder: Invalid operation on this store"));
return FALSE;
}
groupwise_store = CAMEL_GROUPWISE_STORE (store);
@@ -129,7 +118,10 @@ groupwise_send_to (CamelTransport *transport,
if (!cnc) {
g_warning ("||| Eh!!! Failure |||\n");
camel_operation_end (NULL);
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Authentication failed"));
return FALSE;
}
@@ -160,9 +152,16 @@ groupwise_send_to (CamelTransport *transport,
/* FIXME: 58652 should be changed with an enum.*/
if (status == 58652)
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("You have exceeded this account's storage limit. Your messages are queued in your Outbox. Resend by pressing Send/Receive after deleting/archiving some of your mail.\n"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You have exceeded this account's storage limit. Your messages are queued in your Outbox. Resend by pressing Send/Receive after deleting/archiving some of your mail.\n"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,_("Could not send message: %s"),_("Unknown error"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not send message: %s"),
+ _("Unknown error"));
status = 0;
return FALSE;
}
@@ -190,7 +189,6 @@ groupwise_transport_class_init (CamelGroupwiseTransportClass *class)
service_class = CAMEL_SERVICE_CLASS (class);
service_class->connect = groupwise_transport_connect;
service_class->get_name = groupwise_transport_get_name;
- service_class->construct = groupwise_transport_construct;
transport_class = CAMEL_TRANSPORT_CLASS (class);
transport_class->send_to = groupwise_send_to;
diff --git a/camel/providers/hula/camel-hula-provider.c b/camel/providers/hula/camel-hula-provider.c
index aaa453a..4056b50 100644
--- a/camel/providers/hula/camel-hula-provider.c
+++ b/camel/providers/hula/camel-hula-provider.c
@@ -95,7 +95,7 @@ CamelServiceAuthType camel_hula_password_authtype = {
static gint
hula_auto_detect_cb (CamelURL *url, GHashTable **auto_detected,
- CamelException *ex)
+ GError **error)
{
*auto_detected = g_hash_table_new (g_str_hash, g_str_equal);
diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c
index 39eec71..ccb14fd 100644
--- a/camel/providers/imap/camel-imap-command.c
+++ b/camel/providers/imap/camel-imap-command.c
@@ -44,11 +44,11 @@
#include "camel-imap-utils.h"
static gboolean imap_command_start (CamelImapStore *store, CamelFolder *folder,
- const gchar *cmd, CamelException *ex);
+ const gchar *cmd, GError **error);
static CamelImapResponse *imap_read_response (CamelImapStore *store,
- CamelException *ex);
+ GError **error);
static gchar *imap_read_untagged (CamelImapStore *store, gchar *line,
- CamelException *ex);
+ GError **error);
static gchar *imap_command_strdup_vprintf (CamelImapStore *store,
const gchar *fmt, va_list ap);
static gchar *imap_command_strdup_printf (CamelImapStore *store,
@@ -82,8 +82,10 @@ static gchar *imap_command_strdup_printf (CamelImapStore *store,
* response, which the caller must free with camel_imap_response_free().
**/
CamelImapResponse *
-camel_imap_command (CamelImapStore *store, CamelFolder *folder,
- CamelException *ex, const gchar *fmt, ...)
+camel_imap_command (CamelImapStore *store,
+ CamelFolder *folder,
+ GError **error,
+ const gchar *fmt, ...)
{
va_list ap;
gchar *cmd;
@@ -102,14 +104,14 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder,
cmd = imap_command_strdup_printf (store, "SELECT %F", folder->full_name);
}
- if (!imap_command_start (store, folder, cmd, ex)) {
+ if (!imap_command_start (store, folder, cmd, error)) {
g_free (cmd);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return NULL;
}
g_free (cmd);
- return imap_read_response (store, ex);
+ return imap_read_response (store, error);
}
/**
@@ -147,8 +149,10 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder,
* an error occurred (in which case @ex will be set).
**/
gboolean
-camel_imap_command_start (CamelImapStore *store, CamelFolder *folder,
- CamelException *ex, const gchar *fmt, ...)
+camel_imap_command_start (CamelImapStore *store,
+ CamelFolder *folder,
+ GError **error,
+ const gchar *fmt, ...)
{
va_list ap;
gchar *cmd;
@@ -159,7 +163,7 @@ camel_imap_command_start (CamelImapStore *store, CamelFolder *folder,
va_end (ap);
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
- ok = imap_command_start (store, folder, cmd, ex);
+ ok = imap_command_start (store, folder, cmd, error);
g_free (cmd);
if (!ok)
@@ -168,34 +172,43 @@ camel_imap_command_start (CamelImapStore *store, CamelFolder *folder,
}
static gboolean
-imap_command_start (CamelImapStore *store, CamelFolder *folder,
- const gchar *cmd, CamelException *ex)
+imap_command_start (CamelImapStore *store,
+ CamelFolder *folder,
+ const gchar *cmd,
+ GError **error)
{
gssize nwritten;
if (!store->ostream) {
- camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("No output stream"));
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
+ _("No output stream"));
return FALSE;
}
if (!store->istream) {
- camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("No input stream"));
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
+ _("No input stream"));
return FALSE;
}
/* Check for current folder */
if (folder && folder != store->current_folder) {
CamelImapResponse *response;
- CamelException internal_ex;
+ GError *local_error = NULL;
- response = camel_imap_command (store, folder, ex, NULL);
+ response = camel_imap_command (store, folder, error, NULL);
if (!response)
return FALSE;
- camel_exception_init (&internal_ex);
- camel_imap_folder_selected (folder, response, &internal_ex);
+
+ camel_imap_folder_selected (folder, response, &local_error);
camel_imap_response_free (store, response);
- if (camel_exception_is_set (&internal_ex)) {
- camel_exception_xfer (ex, &internal_ex);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
}
}
@@ -221,11 +234,15 @@ imap_command_start (CamelImapStore *store, CamelFolder *folder,
if (nwritten == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Operation cancelled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Operation cancelled"));
else
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "%s", g_strerror (errno));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
return FALSE;
@@ -251,36 +268,48 @@ imap_command_start (CamelImapStore *store, CamelFolder *folder,
* connect_lock will be released.
**/
CamelImapResponse *
-camel_imap_command_continuation (CamelImapStore *store, const gchar *cmd,
- gsize cmdlen, CamelException *ex)
+camel_imap_command_continuation (CamelImapStore *store,
+ const gchar *cmd,
+ gsize cmdlen,
+ GError **error)
{
- if (!camel_imap_store_connected (store, ex))
+ if (!camel_imap_store_connected (store, error))
return NULL;
if (!store->ostream) {
- camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("No output stream"));
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
+ _("No output stream"));
return NULL;
}
if (!store->istream) {
- camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("No input stream"));
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
+ _("No input stream"));
return NULL;
}
if (camel_stream_write (store->ostream, cmd, cmdlen) == -1 ||
camel_stream_write (store->ostream, "\r\n", 2) == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Operation cancelled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Operation cancelled"));
else
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "%s", g_strerror (errno));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return NULL;
}
- return imap_read_response (store, ex);
+ return imap_read_response (store, error);
}
/**
@@ -300,12 +329,12 @@ camel_imap_command_continuation (CamelImapStore *store, const gchar *cmd,
**/
CamelImapResponseType
camel_imap_command_response (CamelImapStore *store, gchar **response,
- CamelException *ex)
+ GError **error)
{
CamelImapResponseType type;
gchar *respbuf;
- if (camel_imap_store_readline (store, &respbuf, ex) < 0) {
+ if (camel_imap_store_readline (store, &respbuf, error) < 0) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return CAMEL_IMAP_RESPONSE_ERROR;
}
@@ -323,9 +352,10 @@ camel_imap_command_response (CamelImapStore *store, gchar **response,
/* Connection was lost, no more data to fetch */
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Server unexpectedly disconnected: %s"),
- err);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Server unexpectedly disconnected: %s"), err);
store->connected = FALSE;
g_free (respbuf);
respbuf = NULL;
@@ -335,7 +365,7 @@ camel_imap_command_response (CamelImapStore *store, gchar **response,
/* Read the rest of the response. */
type = CAMEL_IMAP_RESPONSE_UNTAGGED;
- respbuf = imap_read_untagged (store, respbuf, ex);
+ respbuf = imap_read_untagged (store, respbuf, error);
if (!respbuf)
type = CAMEL_IMAP_RESPONSE_ERROR;
else if (!g_ascii_strncasecmp (respbuf, "* OK [ALERT]", 12)
@@ -369,7 +399,7 @@ camel_imap_command_response (CamelImapStore *store, gchar **response,
}
static CamelImapResponse *
-imap_read_response (CamelImapStore *store, CamelException *ex)
+imap_read_response (CamelImapStore *store, GError **error)
{
CamelImapResponse *response;
CamelImapResponseType type;
@@ -389,7 +419,7 @@ imap_read_response (CamelImapStore *store, CamelException *ex)
} */
response->untagged = g_ptr_array_new ();
- while ((type = camel_imap_command_response (store, &respbuf, ex))
+ while ((type = camel_imap_command_response (store, &respbuf, error))
== CAMEL_IMAP_RESPONSE_UNTAGGED)
g_ptr_array_add (response->untagged, respbuf);
@@ -413,9 +443,11 @@ imap_read_response (CamelImapStore *store, CamelException *ex)
if (!p || (g_ascii_strncasecmp(p, " NO", 3) != 0 && g_ascii_strncasecmp(p, " BAD", 4)) ) {
g_warning ("Unexpected response from IMAP server: %s",
respbuf);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Unexpected response from IMAP "
- "server: %s"), respbuf);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Unexpected response from IMAP server: %s"),
+ respbuf);
camel_imap_response_free_without_processing (store, response);
return NULL;
}
@@ -423,9 +455,11 @@ imap_read_response (CamelImapStore *store, CamelException *ex)
p += 3;
if (!*p++)
p = NULL;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_INVALID,
- _("IMAP command failed: %s"),
- p ? p : _("Unknown error"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("IMAP command failed: %s"),
+ (p != NULL) ? p : _("Unknown error"));
camel_imap_response_free_without_processing (store, response);
return NULL;
}
@@ -435,7 +469,7 @@ imap_read_response (CamelImapStore *store, CamelException *ex)
* of literals.
*/
static gchar *
-imap_read_untagged (CamelImapStore *store, gchar *line, CamelException *ex)
+imap_read_untagged (CamelImapStore *store, gchar *line, GError **error)
{
gint fulllen, ldigits, nread, n, i, sexp = 0;
guint length;
@@ -484,11 +518,15 @@ imap_read_untagged (CamelImapStore *store, gchar *line, CamelException *ex)
do {
if ((n = camel_stream_read (store->istream, str->str + nread + 1, length - nread)) == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Operation cancelled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Operation cancelled"));
else
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- g_strerror (errno));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ "%s", g_strerror (errno));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
g_string_free (str, TRUE);
goto lose;
@@ -498,8 +536,10 @@ imap_read_untagged (CamelImapStore *store, gchar *line, CamelException *ex)
} while (n > 0 && nread < length);
if (nread < length) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Server response ended too soon."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Server response ended too soon."));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
g_string_free (str, TRUE);
goto lose;
@@ -553,7 +593,7 @@ imap_read_untagged (CamelImapStore *store, gchar *line, CamelException *ex)
/* Read the next line. */
do {
- if (camel_imap_store_readline (store, &line, ex) < 0)
+ if (camel_imap_store_readline (store, &line, error) < 0)
goto lose;
/* MAJOR HACK ALERT, gropuwise sometimes sends an extra blank line after literals, check that here
@@ -681,7 +721,7 @@ gchar *
camel_imap_response_extract (CamelImapStore *store,
CamelImapResponse *response,
const gchar *type,
- CamelException *ex)
+ GError **error)
{
gint len = strlen (type), i;
gchar *resp;
@@ -704,9 +744,11 @@ camel_imap_response_extract (CamelImapStore *store,
g_ptr_array_remove_index (response->untagged, i);
} else {
resp = NULL;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("IMAP server response did not contain "
- "%s information"), type);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("IMAP server response did not "
+ "contain %s information"), type);
}
camel_imap_response_free (store, response);
@@ -729,7 +771,7 @@ camel_imap_response_extract (CamelImapStore *store,
gchar *
camel_imap_response_extract_continuation (CamelImapStore *store,
CamelImapResponse *response,
- CamelException *ex)
+ GError **error)
{
gchar *status;
@@ -740,9 +782,12 @@ camel_imap_response_extract_continuation (CamelImapStore *store,
return status;
}
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Unexpected OK response from IMAP server: %s"),
- response->status);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Unexpected OK response from IMAP server: %s"),
+ response->status);
+
camel_imap_response_free (store, response);
return NULL;
}
diff --git a/camel/providers/imap/camel-imap-command.h b/camel/providers/imap/camel-imap-command.h
index fc330a2..76b8f3d 100644
--- a/camel/providers/imap/camel-imap-command.h
+++ b/camel/providers/imap/camel-imap-command.h
@@ -47,12 +47,12 @@ struct _CamelImapResponse {
CamelImapResponse *camel_imap_command (CamelImapStore *store,
CamelFolder *folder,
- CamelException *ex,
+ GError **error,
const gchar *fmt, ...);
CamelImapResponse *camel_imap_command_continuation (CamelImapStore *store,
const gchar *cmd,
gsize cmdlen,
- CamelException *ex);
+ GError **error);
void camel_imap_response_free (CamelImapStore *store,
CamelImapResponse *response);
@@ -61,18 +61,18 @@ void camel_imap_response_free_without_processing (CamelImapStore *store,
gchar *camel_imap_response_extract (CamelImapStore *store,
CamelImapResponse *response,
const gchar *type,
- CamelException *ex);
+ GError **error);
gchar *camel_imap_response_extract_continuation (CamelImapStore *store,
CamelImapResponse *response,
- CamelException *ex);
+ GError **error);
gboolean camel_imap_command_start (CamelImapStore *store,
CamelFolder *folder,
- CamelException *ex,
+ GError **error,
const gchar *fmt, ...);
CamelImapResponseType camel_imap_command_response (CamelImapStore *store,
gchar **response,
- CamelException *ex);
+ GError **error);
G_END_DECLS
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index d821273..35c1e7a 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -71,46 +71,46 @@ static CamelProperty imap_property_list[] = {
{ CAMEL_IMAP_FOLDER_CHECK_FOLDER, "check_folder", N_("Always check for new mail in this folder") },
};
-static gint imap_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
-static gint imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
-
-static void imap_rescan (CamelFolder *folder, gint exists, CamelException *ex);
-static void imap_refresh_info (CamelFolder *folder, CamelException *ex);
-static void imap_sync_offline (CamelFolder *folder, CamelException *ex);
-static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static void imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, CamelException *ex);
-static void imap_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, CamelException *ex);
-static void imap_expunge (CamelFolder *folder, CamelException *ex);
-/*static void imap_cache_message (CamelDiscoFolder *disco_folder, const gchar *uid, CamelException *ex);*/
+static gint imap_getv (CamelObject *object, GError **error, CamelArgGetV *args);
+static gint imap_setv (CamelObject *object, GError **error, CamelArgV *args);
+
+static gboolean imap_rescan (CamelFolder *folder, gint exists, GError **error);
+static gboolean imap_refresh_info (CamelFolder *folder, GError **error);
+static gboolean imap_sync_offline (CamelFolder *folder, GError **error);
+static gboolean imap_sync (CamelFolder *folder, gboolean expunge, GError **error);
+static gboolean imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, GError **error);
+static gboolean imap_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, GError **error);
+static gboolean imap_expunge (CamelFolder *folder, 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, CamelException *ex);
-static gchar * imap_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
+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,
- CamelException *ex);
-static void imap_sync_message (CamelFolder *folder, const gchar *uid,
- CamelException *ex);
-static void imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
+ GError **error);
+static gboolean imap_sync_message (CamelFolder *folder, const gchar *uid,
+ GError **error);
+static gboolean imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex);
-static void imap_append_offline (CamelFolder *folder, CamelMimeMessage *message,
+ GError **error);
+static gboolean imap_append_offline (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex);
+ GError **error);
-static void imap_transfer_online (CamelFolder *source, GPtrArray *uids,
+static gboolean imap_transfer_online (CamelFolder *source, GPtrArray *uids,
CamelFolder *dest, GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
-static void imap_transfer_offline (CamelFolder *source, GPtrArray *uids,
+ GError **error);
+static gboolean imap_transfer_offline (CamelFolder *source, GPtrArray *uids,
CamelFolder *dest, GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
/* searching */
-static GPtrArray *imap_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex);
-static guint32 imap_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex);
-static GPtrArray *imap_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex);
+static GPtrArray *imap_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error);
+static guint32 imap_count_by_expression (CamelFolder *folder, const gchar *expression, GError **error);
+static GPtrArray *imap_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error);
static void imap_search_free (CamelFolder *folder, GPtrArray *uids);
static void imap_thaw (CamelFolder *folder);
@@ -124,7 +124,7 @@ static GData *parse_fetch_response (CamelImapFolder *imap_folder, gchar *msg_att
static CamelImapMessageInfo * imap_folder_summary_uid_or_error(
CamelFolderSummary *summary,
const gchar * uid,
- CamelException *ex);
+ GError **error);
#ifdef G_OS_WIN32
/* The strtok() in Microsoft's C library is MT-safe (but still uses
@@ -266,7 +266,7 @@ camel_imap_folder_get_type (void)
}
static void
-replay_offline_journal (CamelImapStore *imap_store, CamelImapFolder *imap_folder, CamelException *ex)
+replay_offline_journal (CamelImapStore *imap_store, CamelImapFolder *imap_folder, GError **error)
{
CamelIMAPJournal *imap_journal;
@@ -278,16 +278,16 @@ replay_offline_journal (CamelImapStore *imap_store, CamelImapFolder *imap_folder
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, ex))
+ if (CAMEL_OFFLINE_STORE (imap_store)->state != CAMEL_OFFLINE_STORE_NETWORK_AVAIL || !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 */
if (!imap_journal->rp_in_progress) {
imap_journal->rp_in_progress++;
- camel_offline_journal_replay (imap_folder->journal, ex);
+ camel_offline_journal_replay (imap_folder->journal, error);
camel_imap_journal_close_folders (imap_journal);
- camel_offline_journal_write (imap_folder->journal, ex);
+ camel_offline_journal_write (imap_folder->journal, error);
imap_journal->rp_in_progress--;
g_return_if_fail (imap_journal->rp_in_progress >= 0);
@@ -296,7 +296,7 @@ replay_offline_journal (CamelImapStore *imap_store, CamelImapFolder *imap_folder
CamelFolder *
camel_imap_folder_new (CamelStore *parent, const gchar *folder_name,
- const gchar *folder_dir, CamelException *ex)
+ const gchar *folder_dir, GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (parent);
CamelFolder *folder;
@@ -305,9 +305,11 @@ camel_imap_folder_new (CamelStore *parent, const gchar *folder_name,
gchar *summary_file, *state_file, *path;
if (g_mkdir_with_parents (folder_dir, S_IRWXU) != 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create directory %s: %s"),
- folder_dir, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not create directory %s: %s"),
+ folder_dir, g_strerror (errno));
return NULL;
}
@@ -324,9 +326,9 @@ camel_imap_folder_new (CamelStore *parent, const gchar *folder_name,
g_free (summary_file);
if (!folder->summary) {
g_object_unref (CAMEL_OBJECT (folder));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load summary for %s"),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not load summary for %s"), folder_name);
return NULL;
}
@@ -341,7 +343,7 @@ camel_imap_folder_new (CamelStore *parent, const gchar *folder_name,
g_free(state_file);
camel_object_state_read(folder);
- imap_folder->cache = camel_imap_message_cache_new (folder_dir, folder->summary, ex);
+ imap_folder->cache = camel_imap_message_cache_new (folder_dir, folder->summary, error);
if (!imap_folder->cache) {
g_object_unref (CAMEL_OBJECT (folder));
return NULL;
@@ -366,9 +368,10 @@ camel_imap_folder_new (CamelStore *parent, const gchar *folder_name,
}
/* Called with the store's connect_lock locked */
-void
-camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response,
- CamelException *ex)
+gboolean
+camel_imap_folder_selected (CamelFolder *folder,
+ CamelImapResponse *response,
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapSummary *imap_summary = CAMEL_IMAP_SUMMARY (folder->summary);
@@ -435,8 +438,7 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response,
camel_imap_message_cache_clear (imap_folder->cache);
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
imap_folder->need_rescan = FALSE;
- camel_imap_folder_changed (folder, exists, NULL, ex);
- return;
+ return camel_imap_folder_changed (folder, exists, NULL, error);
}
/* If we've lost messages, we have to rescan everything */
@@ -453,9 +455,9 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response,
* is selected, and we don't want camel_imap_command
* to worry about it.)
*/
- response = camel_imap_command (store, NULL, ex, "FETCH %d UID", count);
+ response = camel_imap_command (store, NULL, error, "FETCH %d UID", count);
if (!response)
- return;
+ return FALSE;
uid = 0;
for (i = 0; i < response->untagged->len; i++) {
resp = response->untagged->pdata[i];
@@ -486,30 +488,32 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response,
}
/* Now rescan if we need to */
- if (imap_folder->need_rescan) {
- imap_rescan (folder, exists, ex);
- return;
- }
+ if (imap_folder->need_rescan)
+ return imap_rescan (folder, exists, error);
/* If we don't need to rescan completely, but new messages
* have been added, find out about them.
*/
if (exists > count)
- camel_imap_folder_changed (folder, exists, NULL, ex);
+ camel_imap_folder_changed (folder, exists, NULL, error);
/* And we're done. */
+
+ return TRUE;
}
static gchar *
-imap_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+imap_get_filename (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelImapFolder *imap_folder = (CamelImapFolder*) folder;
- return camel_imap_message_cache_get_filename (imap_folder->cache, uid, "", ex);
+ return camel_imap_message_cache_get_filename (imap_folder->cache, uid, "", error);
}
static gint
-imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+imap_getv(CamelObject *object, GError **error, CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
gint i, count=0;
@@ -528,7 +532,7 @@ imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
props.argc = 1;
props.argv[0] = *arg;
- ((CamelObjectClass *)parent_class)->getv(object, ex, &props);
+ ((CamelObjectClass *)parent_class)->getv(object, error, &props);
for (i = 0; i < G_N_ELEMENTS (imap_property_list); i++)
*arg->ca_ptr = g_slist_append (*arg->ca_ptr, &imap_property_list[i]);
@@ -557,13 +561,13 @@ imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
}
if (count)
- return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->getv(object, error, args);
return 0;
}
static gint
-imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
+imap_setv (CamelObject *object, GError **error, CamelArgV *args)
{
gint save = 0;
gint i;
@@ -610,7 +614,7 @@ imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
if (save)
camel_object_state_write (object);
- return ((CamelObjectClass *)parent_class)->setv (object, ex, args);
+ return ((CamelObjectClass *)parent_class)->setv (object, error, args);
}
static void
@@ -644,7 +648,7 @@ imap_rename (CamelFolder *folder, const gchar *new)
/* called with connect_lock locked */
static gboolean
-get_folder_status (CamelFolder *folder, guint32 *total, guint32 *unread, CamelException *ex)
+get_folder_status (CamelFolder *folder, guint32 *total, guint32 *unread, GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapResponse *response;
@@ -652,7 +656,7 @@ get_folder_status (CamelFolder *folder, guint32 *total, guint32 *unread, CamelEx
g_return_val_if_fail (folder != NULL, FALSE);
- response = camel_imap_command (imap_store, folder, ex, "STATUS %F (MESSAGES UNSEEN)", folder->full_name);
+ response = camel_imap_command (imap_store, folder, error, "STATUS %F (MESSAGES UNSEEN)", folder->full_name);
if (response) {
gint i;
@@ -714,21 +718,23 @@ get_folder_status (CamelFolder *folder, guint32 *total, guint32 *unread, CamelEx
return res;
}
-static void
-imap_refresh_info (CamelFolder *folder, CamelException *ex)
+static gboolean
+imap_refresh_info (CamelFolder *folder,
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapResponse *response;
CamelStoreInfo *si;
gint check_rescan = -1;
+ GError *local_error = NULL;
if (CAMEL_OFFLINE_STORE (imap_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
- return;
+ return TRUE;
if (camel_folder_is_frozen (folder)) {
imap_folder->need_refresh = TRUE;
- return;
+ return TRUE;
}
/* If the folder isn't selected, select it (which will force
@@ -738,17 +744,17 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex)
* should do it. */
CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
- if (camel_application_is_exiting || !camel_imap_store_connected(imap_store, ex))
+ if (camel_application_is_exiting || !camel_imap_store_connected(imap_store, error))
goto done;
/* try to store local changes first, as the summary contains new local messages */
- replay_offline_journal (imap_store, imap_folder, ex);
+ replay_offline_journal (imap_store, imap_folder, &local_error);
if (imap_store->current_folder != folder
|| g_ascii_strcasecmp(folder->full_name, "INBOX") == 0) {
- response = camel_imap_command (imap_store, folder, ex, NULL);
+ response = camel_imap_command (imap_store, folder, &local_error, NULL);
if (response) {
- camel_imap_folder_selected (folder, response, ex);
+ camel_imap_folder_selected (folder, response, &local_error);
camel_imap_response_free (imap_store, response);
}
} else if (imap_folder->need_rescan) {
@@ -756,18 +762,18 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex)
* a NOOP to give the server a chance to tell us about new
* messages.
*/
- imap_rescan (folder, camel_folder_summary_count (folder->summary), ex);
+ imap_rescan (folder, camel_folder_summary_count (folder->summary), &local_error);
check_rescan = 0;
} else {
#if 0
/* on some servers need to CHECKpoint INBOX to recieve new messages?? */
/* rfc2060 suggests this, but havent seen a server that requires it */
if (g_ascii_strcasecmp(folder->full_name, "INBOX") == 0) {
- response = camel_imap_command (imap_store, folder, ex, "CHECK");
+ response = camel_imap_command (imap_store, folder, &local_error, "CHECK");
camel_imap_response_free (imap_store, response);
}
#endif
- response = camel_imap_command (imap_store, folder, ex, "NOOP");
+ response = camel_imap_command (imap_store, folder, &local_error, "NOOP");
camel_imap_response_free (imap_store, response);
}
@@ -786,7 +792,7 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex)
camel_store_summary_info_free((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary, si);
}
- if (check_rescan && !camel_application_is_exiting && !camel_exception_is_set (ex)) {
+ if (check_rescan && !camel_application_is_exiting && local_error == NULL) {
if (check_rescan == -1) {
guint32 total, unread = 0, server_total = 0, server_unread = 0;
@@ -794,7 +800,7 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex)
/* Check whether there are changes in total/unread messages in the folders
and if so, then rescan whole summary */
- if (get_folder_status (folder, &server_total, &server_unread, ex)) {
+ if (get_folder_status (folder, &server_total, &server_unread, &local_error)) {
camel_object_get (folder, NULL, CAMEL_FOLDER_TOTAL, &total, CAMEL_FOLDER_UNREAD, &unread, NULL);
if (total != server_total || unread != server_unread)
@@ -803,13 +809,20 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex)
}
if (check_rescan)
- imap_rescan (folder, camel_folder_summary_count (folder->summary), ex);
+ imap_rescan (folder, camel_folder_summary_count (folder->summary), &local_error);
}
done:
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
camel_store_summary_save ((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
static void
@@ -890,8 +903,8 @@ merge_custom_flags (CamelMessageInfo *mi, const gchar *custom_flags)
}
/* Called with the store's connect_lock locked */
-static void
-imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
+static gboolean
+imap_rescan (CamelFolder *folder, gint exists, GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
@@ -909,17 +922,18 @@ imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
GArray *removed;
gboolean ok;
CamelFolderChangeInfo *changes = NULL;
+ gboolean success;
if (camel_application_is_exiting)
- return;
+ return TRUE;
imap_folder->need_rescan = FALSE;
summary_len = camel_folder_summary_count (folder->summary);
if (summary_len == 0) {
if (exists)
- camel_imap_folder_changed (folder, exists, NULL, ex);
- return;
+ return camel_imap_folder_changed (folder, exists, NULL, error);
+ return TRUE;
}
/* Check UIDs and flags of all messages we already know of. */
@@ -928,21 +942,21 @@ imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
if (!uid) {
camel_operation_end (NULL);
- return;
+ return TRUE;
}
- ok = camel_imap_command_start (store, folder, ex,
- "UID FETCH 1:%s (FLAGS)",
- uid);
+ ok = camel_imap_command_start (
+ store, folder, error,
+ "UID FETCH 1:%s (FLAGS)", uid);
g_free (uid);
if (!ok) {
camel_operation_end (NULL);
- return;
+ return FALSE;
}
new = g_malloc0 (summary_len * sizeof (*new));
summary_got = 0;
- while ((type = camel_imap_command_response (store, &resp, ex)) == CAMEL_IMAP_RESPONSE_UNTAGGED && !camel_application_is_exiting) {
+ while ((type = camel_imap_command_response (store, &resp, error)) == CAMEL_IMAP_RESPONSE_UNTAGGED && !camel_application_is_exiting) {
GData *data;
gchar *uid;
guint32 flags;
@@ -972,7 +986,7 @@ imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
camel_operation_end (NULL);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
g_free(new);
- return;
+ return TRUE;
}
camel_operation_end (NULL);
if (type == CAMEL_IMAP_RESPONSE_ERROR || camel_application_is_exiting) {
@@ -985,7 +999,7 @@ imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
if (type != CAMEL_IMAP_RESPONSE_ERROR && type != CAMEL_IMAP_RESPONSE_TAGGED)
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return TRUE;
}
/* Free the final tagged response */
@@ -1001,7 +1015,7 @@ imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
removed = g_array_new (FALSE, FALSE, sizeof (gint));
if (summary_len - camel_folder_summary_cache_size (folder->summary) > 50)
- camel_folder_summary_reload_from_db (folder->summary, ex);
+ camel_folder_summary_reload_from_db (folder->summary, error);
for (i = 0, j = 0; i < summary_len && new[j].uid; i++) {
gboolean changed = FALSE;
@@ -1194,9 +1208,12 @@ imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
j = seq - del;
g_array_append_val (removed, j);
}
+
/* And finally update the summary. */
- camel_imap_folder_changed (folder, exists, removed, ex);
+ success = camel_imap_folder_changed (folder, exists, removed, error);
g_array_free (removed, TRUE);
+
+ return success;
}
static const gchar *
@@ -1365,8 +1382,9 @@ get_matching (CamelFolder *folder, guint32 flags, guint32 mask, CamelMessageInfo
#undef close_range
}
-static void
-imap_sync_offline (CamelFolder *folder, CamelException *ex)
+static gboolean
+imap_sync_offline (CamelFolder *folder,
+ GError **error)
{
if (folder->summary && (folder->summary->flags & CAMEL_SUMMARY_DIRTY) != 0) {
CamelStoreInfo *si;
@@ -1384,17 +1402,22 @@ imap_sync_offline (CamelFolder *folder, CamelException *ex)
}
}
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, error);
camel_store_summary_save((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary);
+
+ return TRUE;
}
-static void
-imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+static gboolean
+imap_sync (CamelFolder *folder,
+ gboolean expunge,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapMessageInfo *info;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- CamelException local_ex;
+ gboolean success;
+ GError *local_error = NULL;
GPtrArray *matches, *summary;
gchar *set, *flaglist, *uid;
@@ -1402,19 +1425,16 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
if (folder->permanent_flags == 0 || CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
if (expunge) {
- imap_expunge (folder, ex);
- if (camel_exception_is_set (ex))
- return;
+ if (!imap_expunge (folder, error))
+ return FALSE;
}
- imap_sync_offline (folder, ex);
- return;
+ return imap_sync_offline (folder, error);
}
- camel_exception_init (&local_ex);
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
/* write local changes first */
- replay_offline_journal (store, imap_folder, ex);
+ replay_offline_journal (store, imap_folder, NULL);
/* Find a message with changed flags, find all of the other
* messages like it, sync them as a group, mark them as
@@ -1455,7 +1475,7 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
/* Make sure we're connected before issuing commands */
- if (!camel_imap_store_connected(store, ex)) {
+ if (!camel_imap_store_connected(store, NULL)) {
g_free(set);
break;
}
@@ -1478,7 +1498,7 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
g_free (flaglist);
flaglist = strdup ("(\\Seen)");
- response = camel_imap_command (store, folder, &local_ex,
+ response = camel_imap_command (store, folder, &local_error,
"UID STORE %s +FLAGS.SILENT %s",
set, flaglist);
if (response)
@@ -1492,8 +1512,8 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
camel_message_info_free (info);
/* Note: to 'unset' flags, use -FLAGS.SILENT (<flag list>) */
- if (!camel_exception_is_set (&local_ex)) {
- response = camel_imap_command (store, folder, &local_ex,
+ if (local_error == NULL) {
+ response = camel_imap_command (store, folder, &local_error,
"UID STORE %s %sFLAGS.SILENT %s",
set, unset ? "-" : "", flaglist);
}
@@ -1504,7 +1524,7 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
if (response)
camel_imap_response_free (store, response);
- if (!camel_exception_is_set (&local_ex)) {
+ if (local_error == NULL) {
for (j = 0; j < matches->len; j++) {
info = matches->pdata[j];
info->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
@@ -1526,9 +1546,9 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
/* check for an exception */
- if (camel_exception_is_set (&local_ex)) {
- camel_exception_xfer (ex, &local_ex);
- return;
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
}
/* Re-lock the connect_lock */
@@ -1536,15 +1556,17 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
if (expunge)
- imap_expunge (folder, ex);
+ imap_expunge (folder, NULL);
g_ptr_array_foreach (summary, (GFunc) camel_pstring_free, NULL);
g_ptr_array_free (summary, TRUE);
/* Save the summary */
- imap_sync_offline (folder, ex);
+ success = imap_sync_offline (folder, error);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+
+ return success;
}
static gint
@@ -1563,8 +1585,10 @@ uid_compar (gconstpointer va, gconstpointer vb)
return 1;
}
-static void
-imap_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, CamelException *ex)
+static gboolean
+imap_expunge_uids_offline (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
{
CamelFolderChangeInfo *changes;
GSList *list = NULL;
@@ -1582,19 +1606,23 @@ imap_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, CamelException
* the cached data may be useful in replaying a COPY later.
*/
}
- camel_db_delete_uids (folder->parent_store->cdb_w, folder->full_name, list, ex);
+ camel_db_delete_uids (folder->parent_store->cdb_w, folder->full_name, list, NULL);
g_slist_free(list);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
camel_imap_journal_log (CAMEL_IMAP_FOLDER (folder)->journal,
CAMEL_IMAP_JOURNAL_ENTRY_EXPUNGE, uids);
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
camel_folder_change_info_free (changes);
+
+ return TRUE;
}
-static void
-imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, CamelException *ex)
+static gboolean
+imap_expunge_uids_online (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapResponse *response;
@@ -1608,10 +1636,9 @@ imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, CamelException *
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
if ((store->capabilities & IMAP_CAPABILITY_UIDPLUS) == 0) {
- CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, ex);
- if (camel_exception_is_set(ex)) {
+ if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, error)) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return FALSE;
}
}
@@ -1619,24 +1646,26 @@ imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, CamelException *
while (uid < uids->len) {
set = imap_uid_array_to_set (folder->summary, uids, uid, UID_SET_LIMIT, &uid);
- response = camel_imap_command (store, folder, ex,
+ response = camel_imap_command (store, folder, error,
"UID STORE %s +FLAGS.SILENT (\\Deleted)",
set);
if (response)
camel_imap_response_free (store, response);
- if (camel_exception_is_set (ex)) {
+ else {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
g_free (set);
- return;
+ return FALSE;
}
if (!full_expunge) {
- response = camel_imap_command (store, folder, ex,
+ GError *local_error = NULL;
+
+ response = camel_imap_command (store, folder, &local_error,
"UID EXPUNGE %s", set);
- if (camel_exception_is_set (ex)) {
- g_debug (G_STRLOC ": 'UID EXPUNGE %s' failed: %s (0x%x)", set, camel_exception_get_description (ex), camel_exception_get_id (ex));
- camel_exception_clear (ex);
+ if (local_error != NULL) {
+ g_debug (G_STRLOC ": 'UID EXPUNGE %s' failed: %s (0x%x)", set, local_error->message, local_error->code);
+ g_clear_error (&local_error);
/* UID EXPUNGE failed, something is broken on the server probably,
thus fall back to the full expunge. It's not so good, especially
@@ -1648,7 +1677,7 @@ imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, CamelException *
}
if (full_expunge)
- response = camel_imap_command (store, folder, ex, "EXPUNGE");
+ response = camel_imap_command (store, folder, NULL, "EXPUNGE");
if (response)
camel_imap_response_free (store, response);
@@ -1667,35 +1696,43 @@ imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, CamelException *
* the cached data may be useful in replaying a COPY later.
*/
}
- camel_db_delete_uids (folder->parent_store->cdb_w, folder->full_name, list, ex);
+ camel_db_delete_uids (folder->parent_store->cdb_w, folder->full_name, list, NULL);
g_slist_free (list);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
camel_folder_change_info_free (changes);
+
+ return TRUE;
}
-static void
-imap_expunge (CamelFolder *folder, CamelException *ex)
+static gboolean
+imap_expunge (CamelFolder *folder,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
GPtrArray *uids;
+ gboolean success;
- camel_folder_summary_save_to_db (folder->summary, ex);
- uids = camel_db_get_folder_deleted_uids (folder->parent_store->cdb_r, folder->full_name, ex);
+ camel_folder_summary_save_to_db (folder->summary, error);
+ uids = camel_db_get_folder_deleted_uids (folder->parent_store->cdb_r, folder->full_name, error);
if (!uids)
- return;
+ return TRUE;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL)
- imap_expunge_uids_online (folder, uids, ex);
+ success = imap_expunge_uids_online (folder, uids, error);
else
- imap_expunge_uids_offline (folder, uids, ex);
+ success = imap_expunge_uids_offline (folder, uids, error);
g_ptr_array_foreach (uids, (GFunc) camel_pstring_free, NULL);
g_ptr_array_free (uids, TRUE);
+
+ return success;
}
-void
-imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelException *ex)
+gboolean
+imap_expunge_uids_resyncing (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
@@ -1704,12 +1741,10 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
gchar *result;
if (imap_folder->read_only)
- return;
+ return TRUE;
- if (store->capabilities & IMAP_CAPABILITY_UIDPLUS) {
- imap_expunge_uids_online (folder, uids, ex);
- return;
- }
+ if (store->capabilities & IMAP_CAPABILITY_UIDPLUS)
+ return imap_expunge_uids_online (folder, uids, error);
/* If we don't have UID EXPUNGE we need to avoid expunging any
* of the wrong messages. So we search for deleted messages,
@@ -1719,21 +1754,20 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
- CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, ex);
- if (camel_exception_is_set(ex)) {
+ if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, error)) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return FALSE;
}
- response = camel_imap_command (store, folder, ex, "UID SEARCH DELETED");
+ response = camel_imap_command (store, folder, error, "UID SEARCH DELETED");
if (!response) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return FALSE;
}
- result = camel_imap_response_extract (store, response, "SEARCH", ex);
+ result = camel_imap_response_extract (store, response, "SEARCH", error);
if (!result) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return FALSE;
}
if (result[8] == ' ') {
@@ -1784,7 +1818,7 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
while (uid < keep_uids->len) {
uidset = imap_uid_array_to_set (folder->summary, keep_uids, uid, UID_SET_LIMIT, &uid);
- response = camel_imap_command (store, folder, ex,
+ response = camel_imap_command (store, folder, error,
"UID STORE %s -FLAGS.SILENT (\\Deleted)",
uidset);
@@ -1794,7 +1828,7 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
g_ptr_array_free (keep_uids, TRUE);
g_ptr_array_free (mark_uids, TRUE);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return FALSE;
}
camel_imap_response_free (store, response);
}
@@ -1808,7 +1842,7 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
while (uid < mark_uids->len) {
uidset = imap_uid_array_to_set (folder->summary, mark_uids, uid, UID_SET_LIMIT, &uid);
- response = camel_imap_command (store, folder, ex,
+ response = camel_imap_command (store, folder, error,
"UID STORE %s +FLAGS.SILENT (\\Deleted)",
uidset);
@@ -1818,7 +1852,7 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
g_ptr_array_free (keep_uids, TRUE);
g_ptr_array_free (mark_uids, TRUE);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- return;
+ return FALSE;
}
camel_imap_response_free (store, response);
}
@@ -1828,7 +1862,7 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
}
/* Do the actual expunging */
- response = camel_imap_command (store, folder, ex, "EXPUNGE");
+ response = camel_imap_command (store, folder, error, "EXPUNGE");
if (response)
camel_imap_response_free (store, response);
@@ -1840,9 +1874,7 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
while (uid < keep_uids->len) {
uidset = imap_uid_array_to_set (folder->summary, keep_uids, uid, UID_SET_LIMIT, &uid);
- /* Don't pass ex if it's already been set */
- response = camel_imap_command (store, folder,
- camel_exception_is_set (ex) ? NULL : ex,
+ response = camel_imap_command (store, folder, NULL,
"UID STORE %s +FLAGS.SILENT (\\Deleted)",
uidset);
@@ -1858,6 +1890,8 @@ imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelExceptio
g_free (result);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+
+ return TRUE;
}
static gchar *
@@ -1877,10 +1911,12 @@ get_temp_uid (void)
return res;
}
-static void
-imap_append_offline (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+static gboolean
+imap_append_offline (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelImapMessageCache *cache = CAMEL_IMAP_FOLDER (folder)->cache;
CamelFolderChangeInfo *changes;
@@ -1891,7 +1927,7 @@ imap_append_offline (CamelFolder *folder, CamelMimeMessage *message,
camel_imap_summary_add_offline (folder->summary, uid, message, info);
CAMEL_IMAP_FOLDER_REC_LOCK (folder, cache_lock);
camel_imap_message_cache_insert_wrapper (cache, uid, "",
- CAMEL_DATA_WRAPPER (message), ex);
+ CAMEL_DATA_WRAPPER (message), error);
CAMEL_IMAP_FOLDER_REC_UNLOCK (folder, cache_lock);
changes = camel_folder_change_info_new ();
@@ -1906,6 +1942,8 @@ imap_append_offline (CamelFolder *folder, CamelMimeMessage *message,
*appended_uid = uid;
else
g_free (uid);
+
+ return TRUE;
}
static void
@@ -1930,9 +1968,11 @@ imap_folder_uid_in_ignore_recent (CamelImapFolder *imap_folder, const gchar *uid
}
static CamelImapResponse *
-do_append (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **uid,
- CamelException *ex)
+do_append (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **uid,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapResponse *response, *response2;
@@ -1942,6 +1982,7 @@ do_append (CamelFolder *folder, CamelMimeMessage *message,
GByteArray *ba;
gchar *flagstr, *end;
guint32 flags = 0;
+ GError *local_error = NULL;
/* encode any 8bit parts so we avoid sending embedded nul-chars and such */
camel_mime_message_encode_8bit_parts (message);
@@ -1975,14 +2016,15 @@ retry:
else
flagstr = NULL;
- response = camel_imap_command (store, NULL, ex, "APPEND %F%s%s {%d}",
+ response = camel_imap_command (store, NULL, &local_error,
+ "APPEND %F%s%s {%d}",
folder->full_name, flagstr ? " " : "",
flagstr ? flagstr : "", ba->len);
g_free (flagstr);
if (!response) {
- if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_SERVICE_INVALID && !store->nocustomappend) {
- camel_exception_clear(ex);
+ if (g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_INVALID) && !store->nocustomappend) {
+ g_clear_error (&local_error);
store->nocustomappend = 1;
goto retry;
}
@@ -1991,8 +2033,11 @@ retry:
}
if (*response->status != '+') {
- if (!camel_exception_is_set (ex))
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Unexpected response status '%s' after APPEND command"), response->status);
+ if (local_error == NULL)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unexpected response status '%s' after APPEND command"),
+ response->status);
camel_imap_response_free (store, response);
g_byte_array_free (ba, TRUE);
@@ -2000,14 +2045,16 @@ retry:
}
/* send the rest of our data - the mime message */
- response2 = camel_imap_command_continuation (store, (const gchar *) ba->data, ba->len, ex);
+ response2 = camel_imap_command_continuation (store, (const gchar *) ba->data, ba->len, &local_error);
g_byte_array_free (ba, TRUE);
/* free it only after message is sent. This may cause more FETCHes. */
camel_imap_response_free (store, response);
if (!response2) {
- if (!camel_exception_is_set (ex))
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("No response on continuation after APPEND command"));
+ if (local_error == NULL)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("No response on continuation after APPEND command"));
return response2;
}
@@ -2033,28 +2080,27 @@ retry:
return response2;
}
-static void
-imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+static gboolean
+imap_append_online (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapResponse *response;
+ gboolean success = TRUE;
gchar *uid;
gint count;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- imap_append_offline (folder, message, info, appended_uid, ex);
- return;
+ return imap_append_offline (folder, message, info, appended_uid, error);
}
count = camel_folder_summary_count (folder->summary);
- response = do_append (folder, message, info, &uid, ex);
- if (!response) {
- if (!camel_exception_is_set (ex))
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unknown error occurred during APPEND command!"));
- return;
- }
+ response = do_append (folder, message, info, &uid, error);
+ if (!response)
+ return FALSE;
if (uid) {
/* Cache first, since freeing response may trigger a
@@ -2063,7 +2109,7 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
CAMEL_IMAP_FOLDER_REC_LOCK (folder, cache_lock);
camel_imap_message_cache_insert_wrapper (
CAMEL_IMAP_FOLDER (folder)->cache, uid,
- "", CAMEL_DATA_WRAPPER (message), ex);
+ "", CAMEL_DATA_WRAPPER (message), NULL);
CAMEL_IMAP_FOLDER_REC_UNLOCK (folder, cache_lock);
if (appended_uid)
*appended_uid = uid;
@@ -2078,22 +2124,26 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
if (store->current_folder != folder ||
camel_folder_summary_count (folder->summary) == count)
- imap_refresh_info (folder, ex);
+ success = imap_refresh_info (folder, error);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+
+ return success;
}
-void
-imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+gboolean
+imap_append_resyncing (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapResponse *response;
gchar *uid;
- response = do_append (folder, message, info, &uid, ex);
+ response = do_append (folder, message, info, &uid, error);
if (!response)
- return;
+ return FALSE;
if (uid) {
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
@@ -2101,7 +2151,7 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message,
CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
camel_imap_message_cache_copy (imap_folder->cache, olduid,
- imap_folder->cache, uid, ex);
+ imap_folder->cache, uid, NULL);
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
if (appended_uid)
@@ -2112,12 +2162,17 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message,
*appended_uid = NULL;
camel_imap_response_free (store, response);
+
+ return TRUE;
}
-static void
-imap_transfer_offline (CamelFolder *source, GPtrArray *uids,
- CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+static gboolean
+imap_transfer_offline (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store);
CamelImapMessageCache *sc = CAMEL_IMAP_FOLDER (source)->cache;
@@ -2127,6 +2182,7 @@ imap_transfer_offline (CamelFolder *source, GPtrArray *uids,
CamelMessageInfo *mi;
gchar *uid, *destuid;
gint i;
+ GError *local_error = NULL;
/* We grab the store's command lock first, and then grab the
* source and destination cache_locks. This way we can't
@@ -2145,13 +2201,13 @@ imap_transfer_offline (CamelFolder *source, GPtrArray *uids,
changes = camel_folder_change_info_new ();
- for (i = 0; i < uids->len && !camel_exception_is_set (ex); i++) {
+ for (i = 0; i < uids->len && local_error == NULL; i++) {
uid = uids->pdata[i];
destuid = get_temp_uid ();
mi = camel_folder_summary_uid (source->summary, uid);
- g_return_if_fail (mi != NULL);
+ g_return_val_if_fail (mi != NULL, FALSE);
message = camel_folder_get_message (source, uid, NULL);
@@ -2161,7 +2217,7 @@ imap_transfer_offline (CamelFolder *source, GPtrArray *uids,
} else
camel_imap_summary_add_offline_uncached (dest->summary, destuid, mi);
- camel_imap_message_cache_copy (sc, uid, dc, destuid, ex);
+ camel_imap_message_cache_copy (sc, uid, dc, destuid, &local_error);
camel_message_info_free(mi);
camel_folder_change_info_add_uid (changes, destuid);
@@ -2170,18 +2226,24 @@ imap_transfer_offline (CamelFolder *source, GPtrArray *uids,
else
g_free (destuid);
- if (delete_originals && !camel_exception_is_set (ex))
+ if (delete_originals && local_error == NULL)
camel_folder_delete_message (source, uid);
}
+ g_clear_error (&local_error);
+
CAMEL_IMAP_FOLDER_REC_UNLOCK (dest, cache_lock);
CAMEL_IMAP_FOLDER_REC_UNLOCK (source, cache_lock);
camel_object_trigger_event (CAMEL_OBJECT (dest), "folder_changed", changes);
camel_folder_change_info_free (changes);
- camel_imap_journal_log (CAMEL_IMAP_FOLDER (source)->journal, CAMEL_IMAP_JOURNAL_ENTRY_TRANSFER, dest,
- uids, delete_originals, ex);
+ camel_imap_journal_log (
+ CAMEL_IMAP_FOLDER (source)->journal,
+ CAMEL_IMAP_JOURNAL_ENTRY_TRANSFER,
+ dest, uids, delete_originals, error);
+
+ return TRUE;
}
static void
@@ -2243,12 +2305,14 @@ handle_copyuid (CamelImapResponse *response, CamelFolder *source,
}
static void
-handle_copyuid_copy_user_tags (CamelImapResponse *response, CamelFolder *source, CamelFolder *destination)
+handle_copyuid_copy_user_tags (CamelImapResponse *response,
+ CamelFolder *source,
+ CamelFolder *destination)
{
gchar *validity, *srcset, *destset;
GPtrArray *src, *dest;
gint i;
- CamelException ex;
+ GError *local_error = NULL;
validity = camel_strstrcase (response->status, "[COPYUID ");
if (!validity)
@@ -2269,16 +2333,14 @@ handle_copyuid_copy_user_tags (CamelImapResponse *response, CamelFolder *source,
camel_imap_response_free (CAMEL_IMAP_STORE (destination->parent_store),
camel_imap_command (CAMEL_IMAP_STORE (destination->parent_store), destination, NULL, "NOOP"));
- camel_exception_init (&ex);
/* refresh folder's summary first, we copied messages there on the server,
but do not know about it in a local summary */
- imap_refresh_info (destination, &ex);
- if (camel_exception_is_set (&ex)) {
- g_warning ("destination folder refresh failed, error: %s", ex.desc);
- camel_exception_clear (&ex);
+ imap_refresh_info (destination, &local_error);
+ if (local_error != NULL) {
+ g_warning ("destination folder refresh failed, error: %s", local_error->message);
+ g_clear_error (&local_error);
goto lose;
}
- camel_exception_clear (&ex);
src = imap_uid_set_to_array (source->summary, srcset);
dest = imap_uid_set_to_array (destination->summary, destset);
@@ -2353,25 +2415,35 @@ any_has_user_tag (CamelFolder *source, gchar *uidset)
return FALSE;
}
-static void
-do_copy (CamelFolder *source, GPtrArray *uids,
- CamelFolder *destination, gint delete_originals, CamelException *ex)
+static gboolean
+do_copy (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *destination,
+ gint delete_originals,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store);
CamelImapResponse *response;
gchar *uidset;
gint uid = 0, last=0, i;
+ GError *local_error = NULL;
- while (uid < uids->len && !camel_exception_is_set (ex)) {
+ while (uid < uids->len && local_error == NULL) {
uidset = imap_uid_array_to_set (source->summary, uids, uid, UID_SET_LIMIT, &uid);
/* use XGWMOVE only when none of the moving messages has set any user tag */
if ((store->capabilities & IMAP_CAPABILITY_XGWMOVE) != 0 && delete_originals && !any_has_user_tag (source, uidset)) {
- response = camel_imap_command (store, source, ex, "UID XGWMOVE %s %F", uidset, destination->full_name);
+ response = camel_imap_command (
+ store, source, &local_error,
+ "UID XGWMOVE %s %F", uidset,
+ destination->full_name);
/* returns only 'A00012 OK UID XGWMOVE completed' '* 2 XGWMOVE' so nothing useful */
camel_imap_response_free (store, response);
} else {
- response = camel_imap_command (store, source, ex, "UID COPY %s %F", uidset, destination->full_name);
+ response = camel_imap_command (
+ store, source, &local_error,
+ "UID COPY %s %F", uidset,
+ destination->full_name);
if (response && (store->capabilities & IMAP_CAPABILITY_UIDPLUS))
handle_copyuid (response, source, destination);
if (response)
@@ -2379,62 +2451,77 @@ do_copy (CamelFolder *source, GPtrArray *uids,
camel_imap_response_free (store, response);
}
- if (!camel_exception_is_set(ex) && delete_originals) {
+ if (local_error == NULL && delete_originals) {
for (i=last;i<uid;i++)
camel_folder_delete_message(source, uids->pdata[i]);
last = uid;
}
g_free (uidset);
}
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
-static void
-imap_transfer_online (CamelFolder *source, GPtrArray *uids,
- CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+static gboolean
+imap_transfer_online (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store);
+ gboolean success = TRUE;
gint count;
- if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- imap_transfer_offline (source, uids, dest, transferred_uids, delete_originals, ex);
- return;
- }
+ if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+ return imap_transfer_offline (
+ source, uids, dest, transferred_uids,
+ delete_originals, error);
/* Sync message flags if needed. */
- imap_sync (source, FALSE, ex);
- if (camel_exception_is_set (ex))
- return;
+ if (!imap_sync (source, FALSE, error))
+ return FALSE;
count = camel_folder_summary_count (dest->summary);
qsort (uids->pdata, uids->len, sizeof (gpointer), uid_compar);
/* Now copy the messages */
- do_copy(source, uids, dest, delete_originals, ex);
- if (camel_exception_is_set (ex))
- return;
+ if (!do_copy(source, uids, dest, delete_originals, error))
+ return FALSE;
/* Make the destination notice its new messages */
if (store->current_folder != dest ||
camel_folder_summary_count (dest->summary) == count)
- imap_refresh_info (dest, ex);
+ success = imap_refresh_info (dest, error);
/* FIXME */
if (transferred_uids)
*transferred_uids = NULL;
+
+ return success;
}
-void
-imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids,
- CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+gboolean
+imap_transfer_resyncing (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error)
{
GPtrArray *realuids;
gint first, i;
const gchar *uid;
CamelMimeMessage *message;
CamelMessageInfo *info;
+ GError *local_error = NULL;
qsort (uids->pdata, uids->len, sizeof (gpointer), uid_compar);
@@ -2447,7 +2534,7 @@ imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids,
realuids = g_ptr_array_new ();
i = 0;
- while (i < uids->len && !camel_exception_is_set (ex)) {
+ while (i < uids->len && local_error == NULL) {
/* Skip past real UIDs */
for (first = i; i < uids->len; i++) {
uid = uids->pdata[i];
@@ -2462,16 +2549,16 @@ imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids,
/* If we saw any real UIDs, do a COPY */
if (i != first) {
- do_copy (source, realuids, dest, delete_originals, ex);
+ do_copy (source, realuids, dest, delete_originals, &local_error);
g_ptr_array_set_size (realuids, 0);
- if (i == uids->len || camel_exception_is_set (ex))
+ if (i == uids->len || local_error != NULL)
break;
}
/* Deal with fake UIDs */
while (i < uids->len &&
!isdigit (*(guchar *)(uids->pdata[i])) &&
- !camel_exception_is_set (ex)) {
+ local_error == NULL) {
uid = uids->pdata[i];
message = camel_folder_get_message (source, uid, NULL);
if (!message) {
@@ -2480,12 +2567,12 @@ imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids,
continue;
}
info = camel_folder_get_message_info (source, uid);
- g_return_if_fail (info != NULL);
+ g_return_val_if_fail (info != NULL, FALSE);
- imap_append_online (dest, message, info, NULL, ex);
+ imap_append_online (dest, message, info, NULL, &local_error);
camel_folder_free_message_info (source, info);
g_object_unref (CAMEL_OBJECT (message));
- if (delete_originals && !camel_exception_is_set (ex))
+ if (delete_originals && local_error == NULL)
camel_folder_delete_message (source, uid);
i++;
}
@@ -2496,10 +2583,19 @@ imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids,
/* FIXME */
if (transferred_uids)
*transferred_uids = NULL;
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
static GPtrArray *
-imap_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+imap_search_by_expression (CamelFolder *folder,
+ const gchar *expression,
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *matches;
@@ -2510,7 +2606,7 @@ imap_search_by_expression (CamelFolder *folder, const gchar *expression, CamelEx
CAMEL_IMAP_FOLDER_LOCK(folder, search_lock);
camel_folder_search_set_folder (imap_folder->search, folder);
- matches = camel_folder_search_search(imap_folder->search, expression, NULL, ex);
+ matches = camel_folder_search_search(imap_folder->search, expression, NULL, error);
CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock);
@@ -2518,7 +2614,9 @@ imap_search_by_expression (CamelFolder *folder, const gchar *expression, CamelEx
}
static guint32
-imap_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+imap_count_by_expression (CamelFolder *folder,
+ const gchar *expression,
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
guint32 matches;
@@ -2529,14 +2627,18 @@ imap_count_by_expression (CamelFolder *folder, const gchar *expression, CamelExc
CAMEL_IMAP_FOLDER_LOCK(folder, search_lock);
camel_folder_search_set_folder (imap_folder->search, folder);
- matches = camel_folder_search_count(imap_folder->search, expression, ex);
+ matches = camel_folder_search_count(imap_folder->search, expression, error);
CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock);
return matches;
}
+
static GPtrArray *
-imap_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+imap_search_by_uids (CamelFolder *folder,
+ const gchar *expression,
+ GPtrArray *uids,
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER(folder);
GPtrArray *matches;
@@ -2547,7 +2649,7 @@ imap_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uid
CAMEL_IMAP_FOLDER_LOCK(folder, search_lock);
camel_folder_search_set_folder(imap_folder->search, folder);
- matches = camel_folder_search_search(imap_folder->search, expression, uids, ex);
+ matches = camel_folder_search_search(imap_folder->search, expression, uids, error);
CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock);
@@ -2571,7 +2673,7 @@ imap_search_free (CamelFolder *folder, GPtrArray *uids)
static CamelMimeMessage *get_message (CamelImapFolder *imap_folder,
const gchar *uid,
CamelMessageContentInfo *ci,
- CamelException *ex);
+ GError **error);
struct _part_spec_stack {
struct _part_spec_stack *parent;
@@ -2663,7 +2765,7 @@ static CamelDataWrapper *
get_content (CamelImapFolder *imap_folder, const gchar *uid,
CamelMimePart *part, CamelMessageContentInfo *ci,
gint frommsg,
- CamelException *ex)
+ GError **error)
{
CamelDataWrapper *content = NULL;
CamelStream *stream;
@@ -2694,7 +2796,7 @@ get_content (CamelImapFolder *imap_folder, const gchar *uid,
strcpy(spec, part_spec);
g_free(part_spec);
- stream = camel_imap_folder_fetch_data (imap_folder, uid, spec, FALSE, ex);
+ stream = camel_imap_folder_fetch_data (imap_folder, uid, spec, FALSE, error);
if (stream) {
ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (body_mp), stream);
g_object_unref (CAMEL_OBJECT (stream));
@@ -2731,7 +2833,8 @@ get_content (CamelImapFolder *imap_folder, const gchar *uid,
num = 1;
while (ci) {
sprintf (child_spec + speclen, "%d.MIME", num++);
- stream = camel_imap_folder_fetch_data (imap_folder, uid, child_spec, FALSE, ex);
+ stream = camel_imap_folder_fetch_data (
+ imap_folder, uid, child_spec, FALSE, error);
if (stream) {
gint ret;
@@ -2745,7 +2848,7 @@ get_content (CamelImapFolder *imap_folder, const gchar *uid,
return NULL;
}
- content = get_content (imap_folder, uid, part, ci, FALSE, ex);
+ content = get_content (imap_folder, uid, part, ci, FALSE, error);
}
if (!stream || !content) {
@@ -2787,7 +2890,7 @@ get_content (CamelImapFolder *imap_folder, const gchar *uid,
return (CamelDataWrapper *) body_mp;
} else if (camel_content_type_is (ci->type, "message", "rfc822")) {
- content = (CamelDataWrapper *) get_message (imap_folder, uid, ci->childs, ex);
+ content = (CamelDataWrapper *) get_message (imap_folder, uid, ci->childs, error);
g_free (part_spec);
return content;
} else {
@@ -2811,7 +2914,7 @@ get_content (CamelImapFolder *imap_folder, const gchar *uid,
static CamelMimeMessage *
get_message (CamelImapFolder *imap_folder, const gchar *uid,
CamelMessageContentInfo *ci,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (CAMEL_FOLDER (imap_folder)->parent_store);
CamelDataWrapper *content;
@@ -2825,7 +2928,7 @@ get_message (CamelImapFolder *imap_folder, const gchar *uid,
section_text = g_strdup_printf ("%s%s%s", part_spec, *part_spec ? "." : "",
store->server_level >= IMAP_LEVEL_IMAP4REV1 ? "HEADER" : "0");
- stream = camel_imap_folder_fetch_data (imap_folder, uid, section_text, FALSE, ex);
+ stream = camel_imap_folder_fetch_data (imap_folder, uid, section_text, FALSE, error);
g_free (section_text);
g_free(part_spec);
if (!stream)
@@ -2839,7 +2942,7 @@ get_message (CamelImapFolder *imap_folder, const gchar *uid,
return NULL;
}
- content = get_content (imap_folder, uid, CAMEL_MIME_PART (msg), ci, TRUE, ex);
+ content = get_content (imap_folder, uid, CAMEL_MIME_PART (msg), ci, TRUE, error);
if (!content) {
g_object_unref (CAMEL_OBJECT (msg));
return NULL;
@@ -2865,14 +2968,14 @@ get_message (CamelImapFolder *imap_folder, const gchar *uid,
static CamelMimeMessage *
get_message_simple (CamelImapFolder *imap_folder, const gchar *uid,
- CamelStream *stream, CamelException *ex)
+ CamelStream *stream, GError **error)
{
CamelMimeMessage *msg;
gint ret;
if (!stream) {
stream = camel_imap_folder_fetch_data (imap_folder, uid, "",
- FALSE, ex);
+ FALSE, error);
if (!stream)
return NULL;
}
@@ -2882,9 +2985,11 @@ get_message_simple (CamelImapFolder *imap_folder, const gchar *uid,
stream);
g_object_unref (CAMEL_OBJECT (stream));
if (ret == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Unable to retrieve message: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Unable to retrieve message: %s"),
+ g_strerror (errno));
g_object_unref (CAMEL_OBJECT (msg));
return NULL;
}
@@ -2911,13 +3016,14 @@ content_info_incomplete (CamelMessageContentInfo *ci)
}
static CamelImapMessageInfo *
-imap_folder_summary_uid_or_error(CamelFolderSummary *summary, const gchar * uid, CamelException *ex)
+imap_folder_summary_uid_or_error(CamelFolderSummary *summary, const gchar * uid, GError **error)
{
CamelImapMessageInfo *mi;
mi = (CamelImapMessageInfo *)camel_folder_summary_uid (summary, uid);
if (mi == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
_("Cannot get message with message ID %s: %s"),
uid, _("No such message available."));
}
@@ -2925,7 +3031,9 @@ imap_folder_summary_uid_or_error(CamelFolderSummary *summary, const gchar * uid,
}
static CamelMimeMessage *
-imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+imap_get_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
@@ -2933,15 +3041,16 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
CamelMimeMessage *msg = NULL;
CamelStream *stream = NULL;
gint retry;
+ GError *local_error = NULL;
- mi = imap_folder_summary_uid_or_error(folder->summary, uid, ex);
+ mi = imap_folder_summary_uid_or_error(folder->summary, uid, error);
if (!mi)
return NULL;
/* If its cached in full, just get it as is, this is only a shortcut,
since we get stuff from the cache anyway. It affects a busted connection though. */
if ( (stream = camel_imap_folder_fetch_data(imap_folder, uid, "", TRUE, NULL))
- && (msg = get_message_simple(imap_folder, uid, stream, ex)))
+ && (msg = get_message_simple(imap_folder, uid, stream, error)))
goto done;
/* All this mess is so we silently retry a fetch if we fail with
@@ -2949,7 +3058,7 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
retry = 0;
do {
retry++;
- camel_exception_clear(ex);
+ g_clear_error (&local_error);
/* If the message is small or only 1 part, or server doesn't do 4v1 (properly) fetch it in one piece. */
if (store->server_level < IMAP_LEVEL_IMAP4REV1
@@ -2957,7 +3066,7 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
|| mi->info.size < IMAP_SMALL_BODY_SIZE
|| (!content_info_incomplete(mi->info.content) && !mi->info.content->childs)) {
CamelMessageInfoBase *info = (CamelMessageInfoBase *) camel_folder_summary_uid (folder->summary, uid);
- msg = get_message_simple (imap_folder, uid, NULL, ex);
+ msg = get_message_simple (imap_folder, uid, NULL, &local_error);
if (info && !info->preview && msg && camel_folder_summary_get_need_preview(folder->summary)) {
if (camel_mime_message_build_preview ((CamelMimePart *)msg, (CamelMessageInfo *)info) && info->preview)
camel_folder_summary_add_preview (folder->summary, (CamelMessageInfo *)info);
@@ -2977,14 +3086,16 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
gint i;
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
- if (!camel_imap_store_connected(store, ex)) {
+ if (!camel_imap_store_connected(store, NULL)) {
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not currently available"));
+ g_set_error (
+ &local_error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("This message is not currently available"));
goto fail;
}
- response = camel_imap_command (store, folder, ex, "UID FETCH %s BODY", uid);
+ response = camel_imap_command (store, folder, &local_error, "UID FETCH %s BODY", uid);
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
if (response) {
@@ -3013,7 +3124,7 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
camel_imap_response_free (store, response);
} else {
- camel_exception_clear(ex);
+ g_clear_error (&local_error);
}
}
@@ -3030,9 +3141,9 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
* let the mailer's "bad MIME" code handle it.
*/
if (content_info_incomplete (mi->info.content))
- msg = get_message_simple (imap_folder, uid, NULL, ex);
+ msg = get_message_simple (imap_folder, uid, NULL, &local_error);
else
- msg = get_message (imap_folder, uid, mi->info.content, ex);
+ msg = get_message (imap_folder, uid, mi->info.content, &local_error);
if (msg && camel_folder_summary_get_need_preview(folder->summary)) {
CamelMessageInfoBase *info = (CamelMessageInfoBase *) camel_folder_summary_uid (folder->summary, uid);
if (info && !info->preview) {
@@ -3045,7 +3156,10 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
} while (msg == NULL
&& retry < 2
- && camel_exception_get_id(ex) == CAMEL_EXCEPTION_SERVICE_UNAVAILABLE);
+ && g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE));
+
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
done:
if (msg) {
@@ -3091,20 +3205,23 @@ fail:
* Ensure that a message is cached locally, but don't retrieve the content if
* it is already local.
*/
-static void
-imap_sync_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+static gboolean
+imap_sync_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapMessageInfo *mi;
CamelMimeMessage *msg = NULL;
CamelStream *stream = NULL;
+ gboolean success = FALSE;
- mi = imap_folder_summary_uid_or_error(folder->summary, uid, ex);
+ mi = imap_folder_summary_uid_or_error(folder->summary, uid, error);
if (!mi)
/* No such UID - is this duplicate work? The sync process selects
* UIDs to start with.
*/
- return;
+ return FALSE;
camel_message_info_free(&mi->info);
/* If we can get a stream, assume its fully cached. This may be false
@@ -3116,17 +3233,21 @@ imap_sync_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
since we get stuff from the cache anyway. It affects a busted connection though. */
if ((stream = camel_imap_folder_fetch_data(imap_folder, uid, "", TRUE, NULL))) {
g_object_unref (stream);
- return;
+ return TRUE;
}
- msg = imap_get_message(folder, uid, ex);
- if (msg)
+ msg = imap_get_message(folder, uid, error);
+ if (msg != NULL) {
g_object_unref (msg);
+ success = TRUE;
+ }
+
+ return success;
}
/* FIXME Remove it after confirming
static void
imap_cache_message (CamelDiscoFolder *disco_folder, const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (disco_folder);
CamelStream *stream;
@@ -3366,10 +3487,11 @@ update_summary (CamelFolderSummary *summary, CamelMessageInfoBase *info)
auto-generated? */
#define MAILING_LIST_HEADERS "X-MAILING-LIST X-LOOP LIST-ID LIST-POST MAILING-LIST ORIGINATOR X-LIST SENDER RETURN-PATH X-BEENTHERE "
-static void
-imap_update_summary (CamelFolder *folder, gint exists,
- CamelFolderChangeInfo *changes,
- CamelException *ex)
+static gboolean
+imap_update_summary (CamelFolder *folder,
+ gint exists,
+ CamelFolderChangeInfo *changes,
+ GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
@@ -3426,11 +3548,11 @@ imap_update_summary (CamelFolder *folder, gint exists,
uidval = 0;
got = 0;
- if (!camel_imap_command_start (store, folder, ex,
+ if (!camel_imap_command_start (store, folder, error,
"UID FETCH %d:* (FLAGS RFC822.SIZE INTERNALDATE BODYSTRUCTURE BODY.PEEK[%s])",
uidval + 1, header_spec->str)) {
g_string_free (header_spec, TRUE);
- return;
+ return FALSE;
}
camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
@@ -3441,7 +3563,7 @@ imap_update_summary (CamelFolder *folder, gint exists,
fetch_data = g_ptr_array_new ();
messages = g_ptr_array_new ();
ct = exists - seq;
- while ((type = camel_imap_command_response (store, &resp, ex)) ==
+ while ((type = camel_imap_command_response (store, &resp, error)) ==
CAMEL_IMAP_RESPONSE_UNTAGGED && !camel_application_is_exiting) {
data = parse_fetch_response (imap_folder, resp);
g_free (resp);
@@ -3512,7 +3634,7 @@ imap_update_summary (CamelFolder *folder, gint exists,
while (uid < needheaders->len && !camel_application_is_exiting) {
uidset = imap_uid_array_to_set (folder->summary, needheaders, uid, UID_SET_LIMIT, &uid);
- if (!camel_imap_command_start (store, folder, ex,
+ if (!camel_imap_command_start (store, folder, error,
"UID FETCH %s BODYSTRUCTURE BODY.PEEK[%s]",
uidset, header_spec->str)) {
g_ptr_array_free (needheaders, TRUE);
@@ -3523,7 +3645,7 @@ imap_update_summary (CamelFolder *folder, gint exists,
}
g_free (uidset);
- while ((type = camel_imap_command_response (store, &resp, ex))
+ while ((type = camel_imap_command_response (store, &resp, error))
== CAMEL_IMAP_RESPONSE_UNTAGGED && !camel_application_is_exiting) {
data = parse_fetch_response (imap_folder, resp);
g_free (resp);
@@ -3634,17 +3756,21 @@ imap_update_summary (CamelFolder *folder, gint exists,
mi = messages->pdata[i];
if (!mi) {
g_warning ("No information for message %d", i + first);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Incomplete server response: no information provided for message %d"),
- i + first);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Incomplete server response: "
+ "no information provided for message %d"),
+ i + first);
break;
}
uid = (gchar *)camel_message_info_uid(mi);
if (uid[0] == 0) {
g_warning("Server provided no uid: message %d", i + first);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Incomplete server response: no UID provided for message %d"),
- i + first);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Incomplete server response: "
+ "no UID provided for message %d"),
+ i + first);
break;
}
@@ -3689,7 +3815,7 @@ imap_update_summary (CamelFolder *folder, gint exists,
imap_folder->priv->ignore_recent = NULL;
}
- return;
+ return TRUE;
lose:
if (fetch_data) {
@@ -3711,17 +3837,20 @@ imap_update_summary (CamelFolder *folder, gint exists,
g_hash_table_unref (imap_folder->priv->ignore_recent);
imap_folder->priv->ignore_recent = NULL;
}
+
+ return FALSE;
}
/* Called with the store's connect_lock locked */
-void
+gboolean
camel_imap_folder_changed (CamelFolder *folder, gint exists,
- GArray *expunged, CamelException *ex)
+ GArray *expunged, GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelFolderChangeInfo *changes;
gint len;
gchar *uid;
+ gboolean success = TRUE;
changes = camel_folder_change_info_new ();
if (expunged) {
@@ -3746,20 +3875,22 @@ camel_imap_folder_changed (CamelFolder *folder, gint exists,
}
/* Delete all in one transaction */
- camel_db_delete_uids (folder->parent_store->cdb_w, folder->full_name, deleted, ex);
+ camel_db_delete_uids (folder->parent_store->cdb_w, folder->full_name, deleted, NULL);
g_slist_foreach (deleted, (GFunc) g_free, NULL);
g_slist_free (deleted);
}
len = camel_folder_summary_count (folder->summary);
if (exists > len && !camel_application_is_exiting)
- imap_update_summary (folder, exists, changes, ex);
+ success = imap_update_summary (folder, exists, changes, error);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
if (camel_folder_change_info_changed (changes))
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
camel_folder_change_info_free (changes);
+
+ return success;
}
static void
@@ -3781,7 +3912,7 @@ imap_thaw (CamelFolder *folder)
CamelStream *
camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const gchar *uid,
const gchar *section_text, gboolean cache_only,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder = CAMEL_FOLDER (imap_folder);
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
@@ -3802,38 +3933,41 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const gchar *uid,
* an inefficiency, and bad luck.
*/
CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
- stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text, ex);
+ stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text, error);
if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) {
- camel_exception_clear (ex);
- stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", ex);
+ g_clear_error (error);
+ stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", error);
}
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
if (stream || cache_only)
return stream;
- camel_exception_clear(ex);
+ g_clear_error (error);
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
- if (!camel_imap_store_connected(store, ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not currently available"));
+ if (!camel_imap_store_connected(store, error)) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("This message is not currently available"));
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return NULL;
}
- camel_exception_clear (ex);
+ g_clear_error (error);
if (store->server_level < IMAP_LEVEL_IMAP4REV1 && !*section_text) {
- response = camel_imap_command (store, folder, ex,
- "UID FETCH %s RFC822.PEEK",
- uid);
+ response = camel_imap_command (
+ store, folder, error,
+ "UID FETCH %s RFC822.PEEK", uid);
} else {
- response = camel_imap_command (store, folder, ex,
- "UID FETCH %s BODY.PEEK[%s]",
- uid, section_text);
+ response = camel_imap_command (
+ store, folder, error,
+ "UID FETCH %s BODY.PEEK[%s]", uid,
+ section_text);
}
/* We won't need the connect_lock again after this. */
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
@@ -3856,8 +3990,10 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const gchar *uid,
camel_imap_response_free (store, response);
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
if (!stream) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not find message body in FETCH response."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not find message body in FETCH response."));
} else {
g_object_ref (CAMEL_OBJECT (stream));
g_datalist_clear (&fetch_data);
@@ -4112,14 +4248,20 @@ done:
* Scan for messages that are local and return the rest.
*/
static GPtrArray *
-imap_get_uncached_uids (CamelFolder *folder, GPtrArray * uids, CamelException *ex)
+imap_get_uncached_uids (CamelFolder *folder,
+ GPtrArray * uids,
+ GError **error)
{
GPtrArray *result;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
- result = camel_imap_message_cache_filter_cached (imap_folder->cache, uids, ex);
+
+ result = camel_imap_message_cache_filter_cached (
+ imap_folder->cache, uids, error);
+
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
+
return result;
}
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index 963aba5..1218b62 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -90,30 +90,30 @@ struct _CamelImapFolderClass {
CamelFolder *camel_imap_folder_new (CamelStore *parent,
const gchar *folder_name,
const gchar *folder_dir,
- CamelException *ex);
+ GError **error);
-void camel_imap_folder_selected (CamelFolder *folder,
+gboolean camel_imap_folder_selected (CamelFolder *folder,
CamelImapResponse *response,
- CamelException *ex);
+ GError **error);
-void camel_imap_folder_changed (CamelFolder *folder, gint exists,
- GArray *expunged, CamelException *ex);
+gboolean camel_imap_folder_changed (CamelFolder *folder, gint exists,
+ GArray *expunged, GError **error);
CamelStream *camel_imap_folder_fetch_data (CamelImapFolder *imap_folder,
const gchar *uid,
const gchar *section_text,
gboolean cache_only,
- CamelException *ex);
-void
+ GError **error);
+gboolean
imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex);
-void
+ GError **error);
+gboolean
imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids,
CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex);
-void
-imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelException *ex);
+ gboolean delete_originals, GError **error);
+gboolean
+imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, GError **error);
GType camel_imap_folder_get_type (void);
diff --git a/camel/providers/imap/camel-imap-journal.c b/camel/providers/imap/camel-imap-journal.c
index 716723e..38d21c0 100644
--- a/camel/providers/imap/camel-imap-journal.c
+++ b/camel/providers/imap/camel-imap-journal.c
@@ -44,7 +44,7 @@
static void imap_entry_free (CamelOfflineJournal *journal, CamelDListNode *entry);
static CamelDListNode *imap_entry_load (CamelOfflineJournal *journal, FILE *in);
static gint imap_entry_write (CamelOfflineJournal *journal, CamelDListNode *entry, FILE *out);
-static gint imap_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelException *ex);
+static gint imap_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, GError **error);
static void unref_folder (gpointer key, gpointer value, gpointer data);
static void free_uids (GPtrArray *array);
static void close_folder (gpointer name, gpointer folder, gpointer data);
@@ -305,18 +305,17 @@ journal_decode_folder (CamelIMAPJournal *journal, const gchar *name)
folder = offline->folder;
}
if (!folder) {
- CamelException ex;
+ GError *local_error = NULL;
gchar *msg;
- camel_exception_init (&ex);
folder = camel_store_get_folder (CAMEL_STORE (CAMEL_OFFLINE_JOURNAL (journal)->folder->parent_store),
- name, 0, &ex);
+ name, 0, &local_error);
if (folder)
g_hash_table_insert (journal->folders, (gchar *) name, folder);
else {
msg = g_strdup_printf (_("Could not open '%s':\n%s\nChanges made to this folder will not be resynchronized."),
- name, camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
+ name, local_error->message);
+ g_clear_error (&local_error);
camel_session_alert_user (camel_service_get_session (CAMEL_SERVICE (CAMEL_OFFLINE_JOURNAL (journal)->folder->parent_store)),
CAMEL_SESSION_ALERT_WARNING,
msg, FALSE);
@@ -328,7 +327,7 @@ journal_decode_folder (CamelIMAPJournal *journal, const gchar *name)
}
static gint
-imap_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelException *ex)
+imap_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, GError **error)
{
CamelIMAPJournalEntry *imap_entry = (CamelIMAPJournalEntry *) entry;
@@ -336,7 +335,7 @@ imap_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelExcep
switch (imap_entry->type) {
case CAMEL_IMAP_JOURNAL_ENTRY_EXPUNGE:
- imap_expunge_uids_resyncing (journal->folder, imap_entry->uids, ex);
+ imap_expunge_uids_resyncing (journal->folder, imap_entry->uids, error);
return 0;
case CAMEL_IMAP_JOURNAL_ENTRY_APPEND:
{
@@ -349,7 +348,7 @@ imap_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelExcep
return -1;
info = camel_folder_get_message_info (journal->folder, imap_entry->append_uid);
- imap_append_resyncing (journal->folder, message, info, &ret_uid, ex);
+ imap_append_resyncing (journal->folder, message, info, &ret_uid, error);
camel_folder_free_message_info (journal->folder, info);
if (ret_uid) {
@@ -371,13 +370,9 @@ imap_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelExcep
return -1;
}
- camel_exception_clear (ex);
- imap_transfer_resyncing (journal->folder, imap_entry->uids, destination, &ret_uids, imap_entry->move, ex);
-
- if (camel_exception_is_set (ex)) {
- d(g_print ("Exception set: %s \n", camel_exception_get_description (ex)));
+ g_clear_error (error);
+ if (!imap_transfer_resyncing (journal->folder, imap_entry->uids, destination, &ret_uids, imap_entry->move, error))
return -1;
- }
if (ret_uids) {
for (i = 0; i < imap_entry->uids->len; i++) {
diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c
index 35f9f60..c714c7d 100644
--- a/camel/providers/imap/camel-imap-message-cache.c
+++ b/camel/providers/imap/camel-imap-message-cache.c
@@ -169,7 +169,7 @@ cache_put (CamelImapMessageCache *cache, const gchar *uid, const gchar *key,
* camel_imap_message_cache_new:
* @path: directory to use for storage
* @summary: CamelFolderSummary for the folder we are caching
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* Return value: a new CamelImapMessageCache object using @path for
* storage. If cache files already exist in @path, then any that do not
@@ -178,23 +178,20 @@ cache_put (CamelImapMessageCache *cache, const gchar *uid, const gchar *key,
* expensive, but the parts hash is immediately usable.
**/
CamelImapMessageCache *
-camel_imap_message_cache_new (const gchar *path, CamelFolderSummary *summary,
- CamelException *ex)
+camel_imap_message_cache_new (const gchar *path,
+ CamelFolderSummary *summary,
+ GError **error)
{
CamelImapMessageCache *cache;
GDir *dir;
const gchar *dname;
gchar *uid, *p;
GPtrArray *deletes;
- GError *error = NULL;
GHashTable *shash;
- dir = g_dir_open (path, 0, &error);
+ dir = g_dir_open (path, 0, error);
if (!dir) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open cache directory: %s"),
- error->message);
- g_error_free (error);
+ g_prefix_error (error, _("Could not open cache directory: "));
return NULL;
}
@@ -239,25 +236,22 @@ camel_imap_message_cache_new (const gchar *path, CamelFolderSummary *summary,
/**
* camel_imap_message_cache_delete:
* @path: directory to use for storage
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* All the files under this directory would be deleted
**/
gboolean
-camel_imap_message_cache_delete (const gchar *path, CamelException *ex)
+camel_imap_message_cache_delete (const gchar *path,
+ GError **error)
{
GDir *dir;
const gchar *dname;
- GError *error = NULL;
GPtrArray *deletes;
- dir = g_dir_open (path, 0, &error);
+ dir = g_dir_open (path, 0, error);
if (!dir) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open cache directory: %s"),
- error->message);
- g_error_free (error);
+ g_prefix_error (error, _("Could not open cache directory: "));
return FALSE;
}
@@ -318,7 +312,7 @@ stream_finalize (CamelObject *stream, gpointer event_data, gpointer user_data)
static CamelStream *
insert_setup (CamelImapMessageCache *cache, const gchar *uid, const gchar *part_spec,
- gchar **path, gchar **key, CamelException *ex)
+ gchar **path, gchar **key, GError **error)
{
CamelStream *stream;
gint fd;
@@ -340,9 +334,11 @@ insert_setup (CamelImapMessageCache *cache, const gchar *uid, const gchar *part_
fd = g_open (*path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to cache message %s: %s"),
- uid, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to cache message %s: %s"),
+ uid, g_strerror (errno));
g_free (*path);
return NULL;
}
@@ -385,21 +381,26 @@ insert_finish (CamelImapMessageCache *cache, const gchar *uid, gchar *path,
* caller must unref.
**/
CamelStream *
-camel_imap_message_cache_insert (CamelImapMessageCache *cache, const gchar *uid,
- const gchar *part_spec, const gchar *data,
- gint len, CamelException *ex)
+camel_imap_message_cache_insert (CamelImapMessageCache *cache,
+ const gchar *uid,
+ const gchar *part_spec,
+ const gchar *data,
+ gint len,
+ GError **error)
{
gchar *path, *key;
CamelStream *stream;
- stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
+ stream = insert_setup (cache, uid, part_spec, &path, &key, error);
if (!stream)
return NULL;
if (camel_stream_write (stream, data, len) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to cache message %s: %s"),
- uid, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to cache message %s: %s"),
+ uid, g_strerror (errno));
return insert_abort (path, stream);
}
@@ -417,20 +418,24 @@ camel_imap_message_cache_insert (CamelImapMessageCache *cache, const gchar *uid,
**/
void
camel_imap_message_cache_insert_stream (CamelImapMessageCache *cache,
- const gchar *uid, const gchar *part_spec,
- CamelStream *data_stream, CamelException *ex)
+ const gchar *uid,
+ const gchar *part_spec,
+ CamelStream *data_stream,
+ GError **error)
{
gchar *path, *key;
CamelStream *stream;
- stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
+ stream = insert_setup (cache, uid, part_spec, &path, &key, error);
if (!stream)
return;
if (camel_stream_write_to_stream (data_stream, stream) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to cache message %s: %s"),
- uid, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to cache message %s: %s"),
+ uid, g_strerror (errno));
insert_abort (path, stream);
} else {
insert_finish (cache, uid, path, key, stream);
@@ -449,20 +454,24 @@ camel_imap_message_cache_insert_stream (CamelImapMessageCache *cache,
**/
void
camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache,
- const gchar *uid, const gchar *part_spec,
- CamelDataWrapper *wrapper, CamelException *ex)
+ const gchar *uid,
+ const gchar *part_spec,
+ CamelDataWrapper *wrapper,
+ GError **error)
{
gchar *path, *key;
CamelStream *stream;
- stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
+ stream = insert_setup (cache, uid, part_spec, &path, &key, error);
if (!stream)
return;
if (camel_data_wrapper_write_to_stream (wrapper, stream) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to cache message %s: %s"),
- uid, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to cache message %s: %s"),
+ uid, g_strerror (errno));
insert_abort (path, stream);
} else {
insert_finish (cache, uid, path, key, stream);
@@ -475,7 +484,7 @@ camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache,
* @cache: the cache
* @uid: the UID of the data to get
* @part_spec: the part_spec of the data to get
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Return value: the filename of a cache item
**/
@@ -483,7 +492,7 @@ gchar *
camel_imap_message_cache_get_filename (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
- CamelException *ex)
+ GError **error)
{
gchar *path;
@@ -505,14 +514,14 @@ camel_imap_message_cache_get_filename (CamelImapMessageCache *cache,
* @cache: the cache
* @uid: the UID of the data to get
* @part_spec: the part_spec of the data to get
- * @ex: exception
+ * @error: return location for a #GError, or %NULL
*
* Return value: a CamelStream containing the cached data (which the
* caller must unref), or %NULL if that data is not cached.
**/
CamelStream *
camel_imap_message_cache_get (CamelImapMessageCache *cache, const gchar *uid,
- const gchar *part_spec, CamelException *ex)
+ const gchar *part_spec, GError **error)
{
CamelStream *stream;
gchar *path, *key;
@@ -540,9 +549,11 @@ camel_imap_message_cache_get (CamelImapMessageCache *cache, const gchar *uid,
if (stream) {
cache_put (cache, uid, key, stream);
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to cache %s: %s"),
- part_spec, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to cache %s: %s"),
+ part_spec, g_strerror (errno));
}
g_free (path);
@@ -629,7 +640,7 @@ camel_imap_message_cache_copy (CamelImapMessageCache *source,
const gchar *source_uid,
CamelImapMessageCache *dest,
const gchar *dest_uid,
- CamelException *ex)
+ GError **error)
{
GPtrArray *subparts;
CamelStream *stream;
@@ -645,8 +656,8 @@ camel_imap_message_cache_copy (CamelImapMessageCache *source,
if (!part++)
continue;
- if ((stream = camel_imap_message_cache_get (source, source_uid, part, ex))) {
- camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream, ex);
+ if ((stream = camel_imap_message_cache_get (source, source_uid, part, error))) {
+ camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream, error);
g_object_unref (CAMEL_OBJECT (stream));
}
}
@@ -682,7 +693,7 @@ _match_part(gpointer part_name, gpointer user_data)
* needed.
*/
GPtrArray *
-camel_imap_message_cache_filter_cached(CamelImapMessageCache *cache, GPtrArray *uids, CamelException *ex)
+camel_imap_message_cache_filter_cached(CamelImapMessageCache *cache, GPtrArray *uids, GError **error)
{
GPtrArray *result, *parts_list;
gint i;
diff --git a/camel/providers/imap/camel-imap-message-cache.h b/camel/providers/imap/camel-imap-message-cache.h
index 640c388..659dda5 100644
--- a/camel/providers/imap/camel-imap-message-cache.h
+++ b/camel/providers/imap/camel-imap-message-cache.h
@@ -73,7 +73,7 @@ struct _CamelImapMessageCacheClass {
/* public methods */
CamelImapMessageCache *camel_imap_message_cache_new (const gchar *path,
CamelFolderSummary *summary,
- CamelException *ex);
+ GError **error);
void camel_imap_message_cache_set_path (CamelImapMessageCache *cache,
const gchar *path);
@@ -85,27 +85,27 @@ CamelStream *camel_imap_message_cache_insert (CamelImapMessageCache *cache,
const gchar *part_spec,
const gchar *data,
gint len,
- CamelException *ex);
+ GError **error);
void camel_imap_message_cache_insert_stream (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
CamelStream *data_stream,
- CamelException *ex);
+ GError **error);
void camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
CamelDataWrapper *wrapper,
- CamelException *ex);
+ GError **error);
CamelStream *camel_imap_message_cache_get (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
- CamelException *ex);
+ GError **error);
gchar * camel_imap_message_cache_get_filename (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
- CamelException *ex);
+ GError **error);
void camel_imap_message_cache_remove (CamelImapMessageCache *cache,
const gchar *uid);
@@ -116,12 +116,12 @@ void camel_imap_message_cache_copy (CamelImapMessageCache *source,
const gchar *source_uid,
CamelImapMessageCache *dest,
const gchar *dest_uid,
- CamelException *ex);
+ GError **error);
gboolean camel_imap_message_cache_delete (const gchar *path,
- CamelException *ex);
+ GError **error);
GPtrArray * camel_imap_message_cache_filter_cached(CamelImapMessageCache *,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
GType camel_imap_message_cache_get_type (void);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 52dde05..e0d83c9 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -63,45 +63,45 @@ static gpointer parent_class;
static gchar imap_tag_prefix = 'A';
-static void construct (CamelService *service, CamelSession *session,
+static gboolean construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex);
+ GError **error);
-static gint imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
-static gint imap_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static gint imap_setv (CamelObject *object, GError **error, CamelArgV *args);
+static gint imap_getv (CamelObject *object, GError **error, CamelArgGetV *args);
static gchar *imap_get_name (CamelService *service, gboolean brief);
-static void imap_noop (CamelStore *store, CamelException *ex);
-static CamelFolder *imap_get_junk(CamelStore *store, CamelException *ex);
-static CamelFolder *imap_get_trash(CamelStore *store, CamelException *ex);
-static GList *query_auth_types (CamelService *service, CamelException *ex);
+static gboolean imap_noop (CamelStore *store, GError **error);
+static CamelFolder *imap_get_junk(CamelStore *store, GError **error);
+static CamelFolder *imap_get_trash(CamelStore *store, GError **error);
+static GList *query_auth_types (CamelService *service, 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, CamelException *ex);
-static void delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
-static void rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, CamelException *ex);
+static CamelFolderInfo *create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GError **error);
+static gboolean delete_folder (CamelStore *store, const gchar *folder_name, GError **error);
+static gboolean rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, GError **error);
static gboolean folder_subscribed (CamelStore *store, const gchar *folder_name);
-static void subscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex);
-static void unsubscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex);
+static gboolean subscribe_folder (CamelStore *store, const gchar *folder_name,
+ GError **error);
+static gboolean unsubscribe_folder (CamelStore *store, const gchar *folder_name,
+ GError **error);
-static void get_folders_sync(CamelImapStore *imap_store, const gchar *pattern, CamelException *ex);
+static gboolean get_folders_sync(CamelImapStore *imap_store, const gchar *pattern, GError **error);
-static void imap_folder_effectively_unsubscribed(CamelImapStore *imap_store, const gchar *folder_name, CamelException *ex);
-static gboolean imap_check_folder_still_extant (CamelImapStore *imap_store, const gchar *full_name, CamelException *ex);
-static void imap_forget_folder(CamelImapStore *imap_store, const gchar *folder_name, CamelException *ex);
+static gboolean imap_folder_effectively_unsubscribed(CamelImapStore *imap_store, const gchar *folder_name, GError **error);
+static gboolean imap_check_folder_still_extant (CamelImapStore *imap_store, const gchar *full_name, GError **error);
+static void imap_forget_folder(CamelImapStore *imap_store, const gchar *folder_name, GError **error);
static void imap_set_server_level (CamelImapStore *store);
-static gboolean imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
-static gboolean imap_connect (CamelService *service, CamelException *ex);
-static gboolean imap_disconnect (CamelService *service, gboolean clean, CamelException *ex);
-static CamelFolder * get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex);
-static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
-static CamelFolder * get_folder_offline (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex);
-static CamelFolderInfo * get_folder_info_offline (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
+static gboolean imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error);
+static gboolean imap_connect (CamelService *service, GError **error);
+static gboolean imap_disconnect (CamelService *service, gboolean clean, GError **error);
+static CamelFolder * get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error);
+static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, 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);
static gboolean
free_key (gpointer key, gpointer value, gpointer user_data)
@@ -222,23 +222,25 @@ camel_imap_store_get_type (void)
return type;
}
-static void
+static gboolean
construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex)
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelImapStore *imap_store = CAMEL_IMAP_STORE (service);
CamelStore *store = CAMEL_STORE (service);
gchar *tmp;
CamelURL *summary_url;
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ /* Chain up to parent's construct() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
- imap_store->storage_path = camel_session_get_storage_path (session, service, ex);
+ imap_store->storage_path = camel_session_get_storage_path (session, service, error);
if (!imap_store->storage_path)
- return;
+ return FALSE;
/* FIXME */
imap_store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
@@ -297,10 +299,12 @@ construct (CamelService *service, CamelSession *session,
imap_store->capabilities = is->capabilities;
imap_set_server_level(imap_store);
}
+
+ return TRUE;
}
static gint
-imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
+imap_setv (CamelObject *object, GError **error, CamelArgV *args)
{
CamelImapStore *store = (CamelImapStore *) object;
guint32 tag, flags;
@@ -370,11 +374,11 @@ imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
we need to do it here... or, better yet, somehow chain it
up to CamelService's setv implementation. */
- return CAMEL_OBJECT_CLASS (parent_class)->setv (object, ex, args);
+ return CAMEL_OBJECT_CLASS (parent_class)->setv (object, error, args);
}
static gint
-imap_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
+imap_getv (CamelObject *object, GError **error, CamelArgGetV *args)
{
CamelImapStore *store = (CamelImapStore *) object;
guint32 tag;
@@ -416,7 +420,7 @@ imap_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
}
}
- return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
+ return CAMEL_OBJECT_CLASS (parent_class)->getv (object, error, args);
}
static gchar *
@@ -482,7 +486,7 @@ parse_capability(CamelImapStore *store, gchar *capa)
}
static gboolean
-imap_get_capability (CamelService *service, CamelException *ex)
+imap_get_capability (CamelService *service, GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelImapResponse *response;
@@ -492,10 +496,10 @@ imap_get_capability (CamelService *service, CamelException *ex)
/* We assume we have utf8 capable search until a failed search tells us otherwise */
store->capabilities = IMAP_CAPABILITY_utf8_search;
store->authtypes = g_hash_table_new (g_str_hash, g_str_equal);
- response = camel_imap_command (store, NULL, ex, "CAPABILITY");
+ response = camel_imap_command (store, NULL, error, "CAPABILITY");
if (!response)
return FALSE;
- result = camel_imap_response_extract (store, response, "CAPABILITY ", ex);
+ result = camel_imap_response_extract (store, response, "CAPABILITY ", error);
if (!result)
return FALSE;
@@ -536,7 +540,7 @@ enum {
#endif
static gboolean
-connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
+connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, GError **error)
{
CamelImapStore *store = (CamelImapStore *) service;
CamelImapResponse *response;
@@ -565,13 +569,15 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection cancelled"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ _("Connection cancelled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to %s: %s"),
- service->url->host,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not connect to %s: %s"),
+ service->url->host, g_strerror (errno));
g_object_unref (tcp_stream);
@@ -596,7 +602,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
camel_tcp_stream_setsockopt((CamelTcpStream *)tcp_stream, &sockopt);
/* Read the greeting, if any, and deal with PREAUTH */
- if (camel_imap_store_readline (store, &buf, ex) < 0) {
+ if (camel_imap_store_readline (store, &buf, error) < 0) {
if (store->istream) {
g_object_unref (store->istream);
store->istream = NULL;
@@ -646,7 +652,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
g_free (buf);
/* get the imap server capabilities */
- if (!imap_get_capability (service, ex)) {
+ if (!imap_get_capability (service, error)) {
if (store->istream) {
g_object_unref (store->istream);
store->istream = NULL;
@@ -676,14 +682,15 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
clean_quit = FALSE;
if (!(store->capabilities & IMAP_CAPABILITY_STARTTLS)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("STARTTLS not supported"));
goto exception;
}
- response = camel_imap_command (store, NULL, ex, "STARTTLS");
+ response = camel_imap_command (store, NULL, error, "STARTTLS");
if (!response) {
g_object_unref (store->istream);
g_object_unref (store->ostream);
@@ -695,21 +702,23 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
/* Okay, now toggle SSL/TLS mode */
if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to IMAP server %s in secure mode: %s"),
- service->url->host, _("SSL negotiations failed"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to connect to IMAP server %s in secure mode: %s"),
+ service->url->host, _("SSL negotiations failed"));
goto exception;
}
#else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to IMAP server %s in secure mode: %s"),
- service->url->host, _("SSL is not available in this build"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to connect to IMAP server %s in secure mode: %s"),
+ service->url->host, _("SSL is not available in this build"));
goto exception;
#endif /* HAVE_SSL */
/* rfc2595, section 4 states that after a successful STLS
command, the client MUST discard prior CAPA responses */
- if (!imap_get_capability (service, ex)) {
+ if (!imap_get_capability (service, error)) {
if (store->istream) {
g_object_unref (store->istream);
store->istream = NULL;
@@ -727,7 +736,8 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
if (store->capabilities & IMAP_CAPABILITY_LOGINDISABLED ) {
clean_quit = TRUE;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("Unknown error"));
goto exception;
@@ -739,7 +749,7 @@ exception:
if (clean_quit && store->connected) {
/* try to disconnect cleanly */
- response = camel_imap_command (store, NULL, ex, "LOGOUT");
+ response = camel_imap_command (store, NULL, error, "LOGOUT");
if (response)
camel_imap_response_free_without_processing (store, response);
}
@@ -764,7 +774,7 @@ exception:
/* Using custom commands to connect to IMAP servers is not supported on Win32 */
static gboolean
-connect_to_server_process (CamelService *service, const gchar *cmd, CamelException *ex)
+connect_to_server_process (CamelService *service, const gchar *cmd, GError **error)
{
CamelImapStore *store = (CamelImapStore *) service;
CamelStream *cmd_stream;
@@ -847,12 +857,16 @@ connect_to_server_process (CamelService *service, const gchar *cmd, CamelExcepti
if (ret == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection cancelled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Connection cancelled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect with command \"%s\": %s"),
- full_cmd, g_strerror (errno));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not connect with command \"%s\": %s"),
+ full_cmd, g_strerror (errno));
g_object_unref (cmd_stream);
g_free (full_cmd);
@@ -868,7 +882,7 @@ connect_to_server_process (CamelService *service, const gchar *cmd, CamelExcepti
store->command = 0;
/* Read the greeting, if any, and deal with PREAUTH */
- if (camel_imap_store_readline (store, &buf, ex) < 0) {
+ if (camel_imap_store_readline (store, &buf, error) < 0) {
if (store->istream) {
g_object_unref (store->istream);
store->istream = NULL;
@@ -888,7 +902,7 @@ connect_to_server_process (CamelService *service, const gchar *cmd, CamelExcepti
g_free (buf);
/* get the imap server capabilities */
- if (!imap_get_capability (service, ex)) {
+ if (!imap_get_capability (service, error)) {
if (store->istream) {
g_object_unref (store->istream);
store->istream = NULL;
@@ -923,20 +937,21 @@ static struct {
};
static gboolean
-connect_to_server_wrapper (CamelService *service, CamelException *ex)
+connect_to_server_wrapper (CamelService *service, GError **error)
{
const gchar *ssl_mode;
struct addrinfo hints, *ai;
gint mode, ret, i;
const gchar *serv;
const gchar *port;
+ GError *local_error = NULL;
#ifndef G_OS_WIN32
const gchar *command;
if (camel_url_get_param(service->url, "use_command")
&& (command = camel_url_get_param(service->url, "command")))
- return connect_to_server_process(service, command, ex);
+ return connect_to_server_process(service, command, error);
#endif
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
@@ -961,16 +976,19 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
- if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
- camel_exception_clear (ex);
- ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, &local_error);
+ if (ai == NULL && port != NULL &&
+ !g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL)) {
+ g_clear_error (&local_error);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, &local_error);
}
- if (ai == NULL)
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
- ret = connect_to_server (service, ai, mode, ex);
+ ret = connect_to_server (service, ai, mode, error);
camel_freeaddrinfo (ai);
@@ -980,7 +998,7 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
extern CamelServiceAuthType camel_imap_password_authtype;
static GList *
-query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types (CamelService *service, GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelServiceAuthType *authtype;
@@ -988,15 +1006,17 @@ query_auth_types (CamelService *service, CamelException *ex)
gboolean connected;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You must be working online to complete this operation"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
return NULL;
}
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
connected = store->istream != NULL && store->connected;
if (!connected)
- connected = connect_to_server_wrapper (service, ex);
+ connected = connect_to_server_wrapper (service, error);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
if (!connected)
return NULL;
@@ -1055,9 +1075,10 @@ imap_build_folder_info(CamelImapStore *imap_store, const gchar *folder_name)
return fi;
}
-static void
-imap_folder_effectively_unsubscribed(CamelImapStore *imap_store,
- const gchar *folder_name, CamelException *ex)
+static gboolean
+imap_folder_effectively_unsubscribed (CamelImapStore *imap_store,
+ const gchar *folder_name,
+ GError **error)
{
CamelFolderInfo *fi;
CamelStoreInfo *si;
@@ -1076,17 +1097,19 @@ imap_folder_effectively_unsubscribed(CamelImapStore *imap_store,
/* we don't need to emit a "folder_unsubscribed" signal
if we are in the process of renaming folders, so we
are done here... */
- return;
+ return TRUE;
}
fi = imap_build_folder_info(imap_store, folder_name);
camel_object_trigger_event (CAMEL_OBJECT (imap_store), "folder_unsubscribed", fi);
camel_folder_info_free (fi);
+
+ return TRUE;
}
static void
-imap_forget_folder (CamelImapStore *imap_store, const gchar *folder_name, CamelException *ex)
+imap_forget_folder (CamelImapStore *imap_store, const gchar *folder_name, GError **error)
{
gchar *state_file;
gchar *journal_file;
@@ -1117,8 +1140,8 @@ imap_forget_folder (CamelImapStore *imap_store, const gchar *folder_name, CamelE
g_unlink (state_file);
g_free (state_file);
- camel_db_delete_folder (((CamelStore *)imap_store)->cdb_w, folder_name, ex);
- camel_imap_message_cache_delete (folder_dir, ex);
+ camel_db_delete_folder (((CamelStore *)imap_store)->cdb_w, folder_name, NULL);
+ camel_imap_message_cache_delete (folder_dir, NULL);
state_file = g_strdup_printf("%s/subfolders", folder_dir);
g_rmdir(state_file);
@@ -1139,11 +1162,11 @@ imap_forget_folder (CamelImapStore *imap_store, const gchar *folder_name, CamelE
static gboolean
imap_check_folder_still_extant (CamelImapStore *imap_store, const gchar *full_name,
- CamelException *ex)
+ GError **error)
{
CamelImapResponse *response;
- response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %F",
+ response = camel_imap_command (imap_store, NULL, error, "LIST \"\" %F",
full_name);
if (response) {
@@ -1169,7 +1192,7 @@ imap_check_folder_still_extant (CamelImapStore *imap_store, const gchar *full_na
or remove it from camel_folder_refresh_info, and use another locking mechanism */
/* also see get_folder_info_online() for the same hack repeated */
static void
-imap_store_refresh_folders (CamelImapStore *store, CamelException *ex)
+imap_store_refresh_folders (CamelImapStore *store, GError **error)
{
GPtrArray *folders;
gint i;
@@ -1210,29 +1233,29 @@ imap_store_refresh_folders (CamelImapStore *store, CamelException *ex)
#endif
static gboolean
-try_auth (CamelImapStore *store, const gchar *mech, CamelException *ex)
+try_auth (CamelImapStore *store, const gchar *mech, GError **error)
{
CamelSasl *sasl;
CamelImapResponse *response;
gchar *resp;
gchar *sasl_resp;
- response = camel_imap_command (store, NULL, ex, "AUTHENTICATE %s", mech);
+ response = camel_imap_command (store, NULL, error, "AUTHENTICATE %s", mech);
if (!response)
return FALSE;
sasl = camel_sasl_new ("imap", mech, CAMEL_SERVICE (store));
while (!camel_sasl_get_authenticated (sasl)) {
- resp = camel_imap_response_extract_continuation (store, response, ex);
+ resp = camel_imap_response_extract_continuation (store, response, error);
if (!resp)
goto lose;
- sasl_resp = camel_sasl_challenge_base64 (sasl, imap_next_word (resp), ex);
+ sasl_resp = camel_sasl_challenge_base64 (sasl, imap_next_word (resp), error);
g_free (resp);
- if (!sasl_resp || camel_exception_is_set (ex))
+ if (!sasl_resp)
goto break_and_lose;
- response = camel_imap_command_continuation (store, sasl_resp, strlen (sasl_resp), ex);
+ response = camel_imap_command_continuation (store, sasl_resp, strlen (sasl_resp), error);
g_free (sasl_resp);
if (!response)
goto lose;
@@ -1258,18 +1281,13 @@ try_auth (CamelImapStore *store, const gchar *mech, CamelException *ex)
camel_imap_response_free (store, response);
lose:
- if (!camel_exception_is_set (ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Bad authentication response from server."));
- }
-
g_object_unref (sasl);
return FALSE;
}
static gboolean
-imap_auth_loop (CamelService *service, CamelException *ex)
+imap_auth_loop (CamelService *service, GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelSession *session = camel_service_get_session (service);
@@ -1290,7 +1308,9 @@ imap_auth_loop (CamelService *service, CamelException *ex)
if (service->url->authmech) {
if (!g_hash_table_lookup (store->authtypes, service->url->authmech)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("IMAP server %s does not support requested "
"authentication type %s"),
service->url->host,
@@ -1300,23 +1320,27 @@ imap_auth_loop (CamelService *service, CamelException *ex)
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("No support for authentication type %s"),
- service->url->authmech);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("No support for authentication type %s"),
+ service->url->authmech);
return FALSE;
}
if (!authtype->need_password) {
- authenticated = try_auth (store, authtype->authproto, ex);
+ authenticated = try_auth (store, authtype->authproto, error);
if (!authenticated)
return FALSE;
}
}
while (!authenticated) {
+ GError *local_error = NULL;
+
if (errbuf) {
/* We need to un-cache the password before prompting again */
- camel_session_forget_password (session, service, auth_domain, "password", ex);
+ camel_session_forget_password (session, service, auth_domain, "password", error);
g_free (service->url->passwd);
service->url->passwd = NULL;
}
@@ -1335,7 +1359,7 @@ imap_auth_loop (CamelService *service, CamelException *ex)
service->url->passwd = camel_session_get_password (
session, service, auth_domain, full_prompt,
- "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
+ "password", CAMEL_SESSION_PASSWORD_SECRET, NULL);
g_free (base_prompt);
g_free (full_prompt);
@@ -1343,7 +1367,9 @@ imap_auth_loop (CamelService *service, CamelException *ex)
errbuf = NULL;
if (!service->url->passwd) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
_("You did not enter a password."));
return FALSE;
}
@@ -1352,14 +1378,14 @@ imap_auth_loop (CamelService *service, CamelException *ex)
if (!store->connected) {
/* Some servers (eg, courier) will disconnect on
* a bad password. So reconnect here. */
- if (!connect_to_server_wrapper (service, ex))
+ if (!connect_to_server_wrapper (service, error))
return FALSE;
}
if (authtype)
- authenticated = try_auth (store, authtype->authproto, ex);
+ authenticated = try_auth (store, authtype->authproto, &local_error);
else {
- response = camel_imap_command (store, NULL, ex,
+ response = camel_imap_command (store, NULL, &local_error,
"LOGIN %S %S",
service->url->user,
service->url->passwd);
@@ -1369,15 +1395,16 @@ imap_auth_loop (CamelService *service, CamelException *ex)
}
}
if (!authenticated) {
- d(printf("EXCEP %d %d %d\n", camel_exception_get_id(ex), CAMEL_EXCEPTION_USER_CANCEL, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE));
- if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL ||
- camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_UNAVAILABLE)
+ if (g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL) ||
+ g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE)) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
errbuf = g_markup_printf_escaped (
_("Unable to authenticate to IMAP server.\n%s\n\n"),
- camel_exception_get_description (ex));
- camel_exception_clear (ex);
+ local_error->message);
+ g_clear_error (&local_error);
}
}
@@ -1385,19 +1412,20 @@ imap_auth_loop (CamelService *service, CamelException *ex)
}
static gboolean
-imap_connect (CamelService *service, CamelException *ex)
+imap_connect (CamelService *service, GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelImapResponse *response;
gchar *result, *name;
gsize len;
+ GError *local_error = NULL;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
- if (!connect_to_server_wrapper (service, ex) ||
- !imap_auth_loop (service, ex)) {
+ if (!connect_to_server_wrapper (service, error) ||
+ !imap_auth_loop (service, error)) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
@@ -1407,11 +1435,11 @@ imap_connect (CamelService *service, CamelException *ex)
if (store->capabilities & IMAP_CAPABILITY_NAMESPACE) {
struct _namespaces *namespaces;
- response = camel_imap_command (store, NULL, ex, "NAMESPACE");
+ response = camel_imap_command (store, NULL, &local_error, "NAMESPACE");
if (!response)
goto done;
- result = camel_imap_response_extract (store, response, "NAMESPACE", ex);
+ result = camel_imap_response_extract (store, response, "NAMESPACE", &local_error);
if (!result)
goto done;
@@ -1491,7 +1519,7 @@ imap_connect (CamelService *service, CamelException *ex)
/* This idiom means "tell me the hierarchy separator
* for the given path, even if that path doesn't exist.
*/
- response = camel_imap_command (store, NULL, ex,
+ response = camel_imap_command (store, NULL, &local_error,
"LIST %G \"\"",
use_namespace);
} else {
@@ -1499,7 +1527,7 @@ imap_connect (CamelService *service, CamelException *ex)
* to "tell me about this folder", which will fail if
* the folder doesn't exist (eg, if namespace is "").
*/
- response = camel_imap_command (store, NULL, ex,
+ response = camel_imap_command (store, NULL, &local_error,
"LIST \"\" %G",
use_namespace);
}
@@ -1529,22 +1557,21 @@ imap_connect (CamelService *service, CamelException *ex)
CamelStoreInfo *si;
/* look in all namespaces */
- get_folders_sync (store, NULL, ex);
- if (camel_exception_is_set(ex))
+ if (!get_folders_sync (store, NULL, &local_error))
goto done;
/* Make sure INBOX is present/subscribed */
si = camel_store_summary_path((CamelStoreSummary *)store->summary, "INBOX");
if (si == NULL || (si->flags & CAMEL_FOLDER_SUBSCRIBED) == 0) {
- response = camel_imap_command (store, NULL, ex, "SUBSCRIBE INBOX");
+ response = camel_imap_command (store, NULL, &local_error, "SUBSCRIBE INBOX");
if (response != NULL) {
camel_imap_response_free (store, response);
}
if (si)
camel_store_summary_info_free((CamelStoreSummary *)store->summary, si);
- if (camel_exception_is_set(ex))
+ if (local_error != NULL)
goto done;
- get_folders_sync(store, "INBOX", ex);
+ get_folders_sync(store, "INBOX", NULL);
}
store->refresh_stamp = time(NULL);
@@ -1556,14 +1583,17 @@ done:
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- if (camel_exception_is_set (ex))
+ if (local_error != NULL) {
camel_service_disconnect (service, TRUE, NULL);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
- return !camel_exception_is_set (ex);
+ return TRUE;
}
static gboolean
-imap_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+imap_disconnect (CamelService *service, gboolean clean, GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
@@ -1626,35 +1656,43 @@ imap_summary_is_dirty (CamelFolderSummary *summary)
return FALSE;
}
-static void
-imap_noop (CamelStore *store, CamelException *ex)
+static gboolean
+imap_noop (CamelStore *store,
+ GError **error)
{
CamelImapStore *imap_store = (CamelImapStore *) store;
CamelImapResponse *response;
CamelFolder *current_folder;
+ gboolean success = TRUE;
CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
- if (!camel_imap_store_connected(imap_store, ex))
+ if (!camel_imap_store_connected(imap_store, error)) {
+ success = FALSE;
goto done;
+ }
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 */
- CAMEL_FOLDER_GET_CLASS (current_folder)->sync (current_folder, FALSE, ex);
+ success = CAMEL_FOLDER_GET_CLASS (current_folder)->sync (current_folder, FALSE, error);
} else {
- response = camel_imap_command (imap_store, NULL, ex, "NOOP");
+ response = camel_imap_command (imap_store, NULL, error, "NOOP");
if (response)
camel_imap_response_free (imap_store, response);
+ else
+ success = FALSE;
}
done:
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+
+ return success;
}
static CamelFolder *
-imap_get_trash(CamelStore *store, CamelException *ex)
+imap_get_trash(CamelStore *store, GError **error)
{
- CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_trash(store, ex);
+ CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_trash(store, error);
if (folder) {
gchar *state = g_build_filename(((CamelImapStore *)store)->storage_path, "system", "Trash.cmeta", NULL);
@@ -1669,9 +1707,9 @@ imap_get_trash(CamelStore *store, CamelException *ex)
}
static CamelFolder *
-imap_get_junk(CamelStore *store, CamelException *ex)
+imap_get_junk(CamelStore *store, GError **error)
{
- CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_junk(store, ex);
+ CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_junk(store, error);
if (folder) {
gchar *state = g_build_filename(((CamelImapStore *)store)->storage_path, "system", "Junk.cmeta", NULL);
@@ -1740,14 +1778,10 @@ get_folder_status (CamelImapStore *imap_store, const gchar *folder_name, const g
type);
if (!response) {
- CamelException ex;
-
- camel_exception_init (&ex);
- if (imap_check_folder_still_extant (imap_store, folder_name, &ex) == FALSE) {
- imap_folder_effectively_unsubscribed (imap_store, folder_name, &ex);
- imap_forget_folder (imap_store, folder_name, &ex);
+ if (imap_check_folder_still_extant (imap_store, folder_name, NULL) == FALSE) {
+ imap_folder_effectively_unsubscribed (imap_store, folder_name, NULL);
+ imap_forget_folder (imap_store, folder_name, NULL);
}
- camel_exception_clear (&ex);
return NULL;
}
@@ -1816,30 +1850,31 @@ get_folder_status (CamelImapStore *imap_store, const gchar *folder_name, const g
}
static CamelFolder *
-get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
CamelFolder *new_folder;
gchar *folder_dir, *storage_path;
+ GError *local_error = NULL;
/* Try to get it locally first, if it is, then the client will
force a select when necessary */
- new_folder = get_folder_offline(store, folder_name, flags, ex);
+ new_folder = get_folder_offline(store, folder_name, flags, error);
if (new_folder)
return new_folder;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You must be working online to complete this operation"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
return NULL;
}
- camel_exception_clear(ex);
-
CAMEL_SERVICE_REC_LOCK(imap_store, connect_lock);
- if (!camel_imap_store_connected(imap_store, ex)) {
+ if (!camel_imap_store_connected(imap_store, error)) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
return NULL;
}
@@ -1852,22 +1887,25 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
imap_store->current_folder = NULL;
}
- response = camel_imap_command (imap_store, NULL, ex, "SELECT %F", folder_name);
+ response = camel_imap_command (imap_store, NULL, &local_error, "SELECT %F", folder_name);
if (!response) {
gchar *folder_real, *parent_name, *parent_real;
const gchar *c;
- if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL) {
+ if (g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL)) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ g_propagate_error (error, local_error);
return NULL;
}
- camel_exception_clear (ex);
+ g_clear_error (&local_error);
if (!(flags & CAMEL_STORE_FOLDER_CREATE)) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("No such folder %s"), folder_name);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("No such folder %s"), folder_name);
return NULL;
}
@@ -1878,9 +1916,11 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
if (*c != '\0') {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
- _("The folder name \"%s\" is invalid because it contains the character \"%c\""),
- folder_name, *c);
+ 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, *c);
return NULL;
}
@@ -1897,7 +1937,7 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
gint flags;
gint i;
- if (!(response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %G", parent_real))) {
+ if (!(response = camel_imap_command (imap_store, NULL, error, "LIST \"\" %G", parent_real))) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
g_free (parent_name);
g_free (parent_real);
@@ -1925,8 +1965,8 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
if (need_convert) {
struct imap_status_item *items, *item;
guint32 messages = 0;
- CamelException lex;
gchar *name;
+ GError *local_error = NULL;
item = items = get_folder_status (imap_store, parent_name, "MESSAGES");
while (item != NULL) {
@@ -1941,8 +1981,10 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
imap_status_item_free (items);
if (messages > 0) {
- camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
- _("The parent folder is not allowed to contain subfolders"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_STATE,
+ _("The parent folder is not allowed to contain subfolders"));
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
g_free (parent_name);
g_free (parent_real);
@@ -1950,11 +1992,10 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
}
/* delete the old parent and recreate it */
- camel_exception_init (&lex);
- delete_folder (store, parent_name, &lex);
- if (camel_exception_is_set (&lex)) {
+ delete_folder (store, parent_name, &local_error);
+ if (local_error != NULL) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
- camel_exception_xfer (ex, &lex);
+ g_propagate_error (error, local_error);
g_free (parent_name);
g_free (parent_real);
return NULL;
@@ -1962,7 +2003,7 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
/* add the dirsep to the end of parent_name */
name = g_strdup_printf ("%s%c", parent_real, imap_store->dir_sep);
- response = camel_imap_command (imap_store, NULL, ex, "CREATE %G",
+ response = camel_imap_command (imap_store, NULL, error, "CREATE %G",
name);
g_free (name);
@@ -1981,7 +2022,7 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
g_free (parent_name);
folder_real = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, imap_store->dir_sep);
- response = camel_imap_command (imap_store, NULL, ex, "CREATE %G", folder_real);
+ response = camel_imap_command (imap_store, NULL, error, "CREATE %G", folder_real);
if (response) {
camel_imap_store_summary_add_from_full(imap_store->summary, folder_real, imap_store->dir_sep);
@@ -1995,9 +2036,10 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
return NULL;
}
} else if (flags & CAMEL_STORE_FOLDER_EXCL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': folder exists."),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot create folder '%s': folder exists."),
+ folder_name);
camel_imap_response_free_without_processing (imap_store, response);
@@ -2009,18 +2051,13 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
storage_path = g_strdup_printf("%s/folders", imap_store->storage_path);
folder_dir = imap_path_to_physical (storage_path, folder_name);
g_free(storage_path);
- new_folder = camel_imap_folder_new (store, folder_name, folder_dir, ex);
+ new_folder = camel_imap_folder_new (store, folder_name, folder_dir, error);
g_free (folder_dir);
if (new_folder) {
- CamelException local_ex;
-
imap_store->current_folder = new_folder;
g_object_ref (new_folder);
- camel_exception_init (&local_ex);
- camel_imap_folder_selected (new_folder, response, &local_ex);
+ if (!camel_imap_folder_selected (new_folder, response, error)) {
- if (camel_exception_is_set (&local_ex)) {
- camel_exception_xfer (ex, &local_ex);
g_object_unref (imap_store->current_folder);
imap_store->current_folder = NULL;
g_object_unref (new_folder);
@@ -2036,7 +2073,7 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
static CamelFolder *
get_folder_offline (CamelStore *store, const gchar *folder_name,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelFolder *new_folder = NULL;
@@ -2059,33 +2096,42 @@ get_folder_offline (CamelStore *store, const gchar *folder_name,
storage_path = g_strdup_printf("%s/folders", imap_store->storage_path);
folder_dir = imap_path_to_physical (storage_path, folder_name);
g_free(storage_path);
- new_folder = camel_imap_folder_new (store, folder_name, folder_dir, ex);
+ new_folder = camel_imap_folder_new (store, folder_name, folder_dir, error);
g_free(folder_dir);
camel_store_summary_info_free((CamelStoreSummary *)imap_store->summary, si);
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("No such folder %s"), folder_name);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("No such folder %s"), folder_name);
}
return new_folder;
}
-static void
-delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+static gboolean
+delete_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
+ gboolean success = TRUE;
CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
- if (!camel_imap_store_connected(imap_store, ex))
+ if (!camel_imap_store_connected(imap_store, error)) {
+ success = FALSE;
goto fail;
+ }
/* make sure this folder isn't currently SELECTed */
- response = camel_imap_command (imap_store, NULL, ex, "SELECT INBOX");
- if (!response)
+ response = camel_imap_command (imap_store, NULL, error, "SELECT INBOX");
+ if (!response) {
+ success = FALSE;
goto fail;
+ }
camel_imap_response_free_without_processing (imap_store, response);
if (imap_store->current_folder)
@@ -2093,13 +2139,15 @@ delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
/* no need to actually create a CamelFolder for INBOX */
imap_store->current_folder = NULL;
- response = camel_imap_command(imap_store, NULL, ex, "DELETE %F", folder_name);
+ response = camel_imap_command(imap_store, NULL, error, "DELETE %F", folder_name);
if (response) {
camel_imap_response_free (imap_store, response);
- imap_forget_folder (imap_store, folder_name, ex);
+ imap_forget_folder (imap_store, folder_name, error);
}
fail:
CAMEL_SERVICE_REC_UNLOCK(imap_store, connect_lock);
+
+ return success;
}
static void
@@ -2170,24 +2218,32 @@ rename_folder_info (CamelImapStore *imap_store, const gchar *old_name, const gch
}
}
-static void
-rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name_in, CamelException *ex)
+static gboolean
+rename_folder (CamelStore *store,
+ const gchar *old_name,
+ const gchar *new_name_in,
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
gchar *oldpath, *newpath, *storage_path;
+ gboolean success = TRUE;
CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
- if (!camel_imap_store_connected(imap_store, ex))
+ if (!camel_imap_store_connected(imap_store, error)) {
+ success = FALSE;
goto fail;
+ }
/* make sure this folder isn't currently SELECTed - it's
actually possible to rename INBOX but if you do another
INBOX will immediately be created by the server */
- response = camel_imap_command (imap_store, NULL, ex, "SELECT INBOX");
- if (!response)
+ response = camel_imap_command (imap_store, NULL, error, "SELECT INBOX");
+ if (!response) {
+ success = FALSE;
goto fail;
+ }
camel_imap_response_free_without_processing (imap_store, response);
if (imap_store->current_folder)
@@ -2199,10 +2255,11 @@ rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name_i
if (imap_store->parameters & IMAP_PARAM_SUBSCRIPTIONS)
manage_subscriptions(store, old_name, FALSE);
- response = camel_imap_command (imap_store, NULL, ex, "RENAME %F %F", old_name, new_name_in);
+ response = camel_imap_command (imap_store, NULL, error, "RENAME %F %F", old_name, new_name_in);
if (!response) {
if (imap_store->parameters & IMAP_PARAM_SUBSCRIPTIONS)
manage_subscriptions(store, old_name, TRUE);
+ success = FALSE;
goto fail;
}
@@ -2230,24 +2287,27 @@ rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name_i
fail:
imap_store->renaming = FALSE;
CAMEL_SERVICE_REC_UNLOCK(imap_store, connect_lock);
+
+ return success;
}
static CamelFolderInfo *
create_folder (CamelStore *store, const gchar *parent_name,
- const gchar *folder_name, CamelException *ex)
+ const gchar *folder_name, GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
gchar *full_name, *resp, *thisone, *parent_real, *real_name;
CamelImapResponse *response;
- CamelException internal_ex;
CamelFolderInfo *root = NULL;
gboolean need_convert;
gint i = 0, flags;
const gchar *c;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You must be working online to complete this operation"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
return NULL;
}
@@ -2259,9 +2319,11 @@ create_folder (CamelStore *store, const gchar *parent_name,
c++;
if (*c != '\0') {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
- _("The folder name \"%s\" is invalid because it contains the character \"%c\""),
- folder_name, *c);
+ 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, *c);
return NULL;
}
@@ -2270,13 +2332,15 @@ create_folder (CamelStore *store, const gchar *parent_name,
/* FIXME: use storesummary directly */
parent_real = camel_imap_store_summary_full_from_path(imap_store->summary, parent_name);
if (parent_real == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
- _("Unknown parent folder: %s"), parent_name);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_STATE,
+ _("Unknown parent folder: %s"), parent_name);
return NULL;
}
need_convert = FALSE;
- response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %G",
+ response = camel_imap_command (imap_store, NULL, error, "LIST \"\" %G",
parent_real);
if (!response) /* whoa, this is bad */ {
g_free(parent_real);
@@ -2300,8 +2364,6 @@ create_folder (CamelStore *store, const gchar *parent_name,
camel_imap_response_free (imap_store, response);
- camel_exception_init (&internal_ex);
-
/* if not, check if we can delete it and recreate it */
if (need_convert) {
struct imap_status_item *items, *item;
@@ -2321,22 +2383,21 @@ create_folder (CamelStore *store, const gchar *parent_name,
imap_status_item_free (items);
if (messages > 0) {
- camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
- _("The parent folder is not allowed to contain subfolders"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_STATE,
+ _("The parent folder is not allowed to contain subfolders"));
g_free(parent_real);
return NULL;
}
/* delete the old parent and recreate it */
- delete_folder (store, parent_name, &internal_ex);
- if (camel_exception_is_set (&internal_ex)) {
- camel_exception_xfer (ex, &internal_ex);
+ if (!delete_folder (store, parent_name, error))
return NULL;
- }
/* add the dirsep to the end of parent_name */
name = g_strdup_printf ("%s%c", parent_real, imap_store->dir_sep);
- response = camel_imap_command (imap_store, NULL, ex, "CREATE %G",
+ response = camel_imap_command (imap_store, NULL, error, "CREATE %G",
name);
g_free (name);
@@ -2353,7 +2414,7 @@ create_folder (CamelStore *store, const gchar *parent_name,
real_name = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, imap_store->dir_sep);
full_name = imap_concat (imap_store, parent_real, real_name);
g_free(real_name);
- response = camel_imap_command (imap_store, NULL, ex, "CREATE %G", full_name);
+ response = camel_imap_command (imap_store, NULL, error, "CREATE %G", full_name);
if (response) {
CamelImapStoreInfo *si;
@@ -2506,8 +2567,8 @@ get_folders_free(gpointer k, gpointer v, gpointer d)
camel_folder_info_free(v);
}
-static void
-get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, CamelException *ex)
+static gboolean
+get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, GError **error)
{
CamelImapResponse *response;
CamelFolderInfo *fi, *hfi;
@@ -2517,6 +2578,7 @@ get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, CamelExcept
CamelStoreInfo *si;
const gchar *pattern = ppattern;
CamelImapStoreNamespace *ns;
+ gboolean success = TRUE;
/* We do a LIST followed by LSUB, and merge the results. LSUB may not be a strict
subset of LIST for some servers, so we can't use either or separately */
@@ -2537,11 +2599,13 @@ get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, CamelExcept
}
for (j = 0; j < 2; j++) {
- response = camel_imap_command (imap_store, NULL, ex,
+ response = camel_imap_command (imap_store, NULL, error,
"%s \"\" %G", j==1 ? "LSUB" : "LIST",
pattern);
- if (!response)
+ if (!response) {
+ success = FALSE;
goto fail;
+ }
for (i = 0; i < response->untagged->len; i++) {
list = response->untagged->pdata[i];
@@ -2606,14 +2670,10 @@ get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, CamelExcept
gchar *dup_folder_name = g_strdup (camel_store_info_path (imap_store->summary, si));
if (dup_folder_name) {
- CamelException eex;
-
- camel_exception_init (&eex);
- imap_folder_effectively_unsubscribed (imap_store, dup_folder_name, &eex);
- imap_forget_folder (imap_store, dup_folder_name, &eex);
+ imap_folder_effectively_unsubscribed (imap_store, dup_folder_name, NULL);
+ imap_forget_folder (imap_store, dup_folder_name, NULL);
g_free (dup_folder_name);
- camel_exception_clear (&eex);
} else {
camel_store_summary_remove ((CamelStoreSummary *)imap_store->summary, si);
}
@@ -2627,6 +2687,8 @@ get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, CamelExcept
fail:
g_hash_table_foreach(present, get_folders_free, NULL);
g_hash_table_destroy(present);
+
+ return success;
}
#if 0
@@ -2681,7 +2743,7 @@ struct _refresh_msg {
CamelSessionThreadMsg msg;
CamelStore *store;
- CamelException ex;
+ GError *error;
};
static void
@@ -2691,11 +2753,11 @@ refresh_refresh(CamelSession *session, CamelSessionThreadMsg *msg)
CAMEL_SERVICE_REC_LOCK(m->store, connect_lock);
- if (!camel_imap_store_connected((CamelImapStore *)m->store, &m->ex))
+ if (!camel_imap_store_connected((CamelImapStore *)m->store, &m->error))
goto done;
/* look in all namespaces */
- get_folders_sync((CamelImapStore *)m->store, NULL, &m->ex);
+ get_folders_sync((CamelImapStore *)m->store, NULL, &m->error);
camel_store_summary_save((CamelStoreSummary *)((CamelImapStore *)m->store)->summary);
done:
CAMEL_SERVICE_REC_UNLOCK(m->store, connect_lock);
@@ -2707,7 +2769,7 @@ refresh_free(CamelSession *session, CamelSessionThreadMsg *msg)
struct _refresh_msg *m = (struct _refresh_msg *)msg;
g_object_unref (m->store);
- camel_exception_clear(&m->ex);
+ g_clear_error (&m->error);
}
static CamelSessionThreadOps refresh_ops = {
@@ -2716,7 +2778,10 @@ static CamelSessionThreadOps refresh_ops = {
};
static CamelFolderInfo *
-get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+get_folder_info (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelFolderInfo *tree = NULL;
@@ -2732,7 +2797,7 @@ get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelExcept
printf("get folder info online\n");
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- tree = get_folder_info_offline (store, top, flags, ex);
+ tree = get_folder_info_offline (store, top, flags, error);
return tree;
}
@@ -2754,7 +2819,6 @@ get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelExcept
m = camel_session_thread_msg_new(((CamelService *)store)->session, &refresh_ops, sizeof(*m));
m->store = store;
g_object_ref (store);
- camel_exception_init(&m->ex);
camel_session_thread_queue(((CamelService *)store)->session, &m->msg, 0);
}
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
@@ -2766,7 +2830,7 @@ get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelExcept
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
- if (!camel_imap_store_connected((CamelImapStore *)store, ex))
+ if (!camel_imap_store_connected((CamelImapStore *)store, error))
goto fail;
if (top[0] == 0) {
@@ -2788,20 +2852,19 @@ get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelExcept
}
ns = camel_imap_store_summary_get_main_namespace (imap_store->summary);
- get_folders_sync(imap_store, pattern, ex);
- if (camel_exception_is_set(ex))
+ if (!get_folders_sync (imap_store, pattern, error))
goto fail;
if (pattern[0] != '*' && ns) {
pattern[i] = ns->sep;
pattern[i+1] = (flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)?'*':'%';
pattern[i+2] = 0;
- get_folders_sync(imap_store, pattern, ex);
+ get_folders_sync(imap_store, pattern, NULL);
}
camel_store_summary_save((CamelStoreSummary *)imap_store->summary);
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
}
- tree = get_folder_info_offline(store, top, flags, ex);
+ tree = get_folder_info_offline(store, top, flags, error);
return tree;
fail:
@@ -2811,7 +2874,7 @@ fail:
static CamelFolderInfo *
get_folder_info_offline (CamelStore *store, const gchar *top,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
gboolean include_inbox = FALSE;
@@ -2930,24 +2993,31 @@ folder_subscribed (CamelStore *store, const gchar *folder_name)
}
/* Note: folder_name must match a folder as listed with get_folder_info() -> full_name */
-static void
-subscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex)
+static gboolean
+subscribe_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
CamelFolderInfo *fi;
CamelStoreInfo *si;
+ gboolean success = TRUE;
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
- if (!camel_imap_store_connected (imap_store, ex))
+ if (!camel_imap_store_connected (imap_store, error)) {
+ success = FALSE;
goto done;
+ }
- response = camel_imap_command (imap_store, NULL, ex,
+ response = camel_imap_command (imap_store, NULL, error,
"SUBSCRIBE %F", folder_name);
- if (!response)
+ if (!response) {
+ success = FALSE;
goto done;
+ }
+
camel_imap_response_free (imap_store, response);
si = camel_store_summary_path((CamelStoreSummary *)imap_store->summary, folder_name);
@@ -2974,29 +3044,41 @@ subscribe_folder (CamelStore *store, const gchar *folder_name,
camel_folder_info_free (fi);
done:
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+
+ return success;
}
-static void
-unsubscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex)
+static gboolean
+unsubscribe_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
+ gboolean success = TRUE;
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
- if (!camel_imap_store_connected (imap_store, ex))
+ if (!camel_imap_store_connected (imap_store, error)) {
+ success = FALSE;
goto done;
+ }
- response = camel_imap_command (imap_store, NULL, ex,
+ response = camel_imap_command (imap_store, NULL, error,
"UNSUBSCRIBE %F", folder_name);
- if (!response)
+ if (!response) {
+ success = FALSE;
goto done;
+ }
+
camel_imap_response_free (imap_store, response);
- imap_folder_effectively_unsubscribed (imap_store, folder_name, ex);
+ success = imap_folder_effectively_unsubscribed (imap_store, folder_name, error);
+
done:
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+
+ return success;
}
#if 0
@@ -3023,8 +3105,10 @@ folder_flags_have_changed (CamelFolder *folder)
/* Use this whenever you need to ensure you're both connected and
online. */
gboolean
-camel_imap_store_connected (CamelImapStore *store, CamelException *ex)
+camel_imap_store_connected (CamelImapStore *store, GError **error)
{
+ GError *local_error = NULL;
+
/* This looks stupid ... because it is.
camel-service-connect will return OK if we connect in 'offline mode',
@@ -3033,19 +3117,23 @@ camel_imap_store_connected (CamelImapStore *store, CamelException *ex)
if (store->istream != NULL
|| (((CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL)
- && camel_service_connect((CamelService *)store, ex)
+ && camel_service_connect((CamelService *)store, &local_error)
&& store->istream != NULL)))
return TRUE;
- if (!camel_exception_is_set(ex))
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You must be working online to complete this operation"));
+ if (local_error != NULL)
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
+
+ g_propagate_error (error, local_error);
return FALSE;
}
gssize
-camel_imap_store_readline (CamelImapStore *store, gchar **dest, CamelException *ex)
+camel_imap_store_readline (CamelImapStore *store, gchar **dest, GError **error)
{
CamelStreamBuffer *stream;
gchar linebuf[1024] = {0};
@@ -3062,7 +3150,7 @@ camel_imap_store_readline (CamelImapStore *store, gchar **dest, CamelException *
* meaning if we reconnect, so always set an exception.
*/
- if (!camel_imap_store_connected (store, ex))
+ if (!camel_imap_store_connected (store, error))
return -1;
stream = CAMEL_STREAM_BUFFER (store->istream);
@@ -3076,13 +3164,21 @@ camel_imap_store_readline (CamelImapStore *store, gchar **dest, CamelException *
if (nread <= 0) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Operation cancelled"));
else if (errno == 0)
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("Server unexpectedly disconnected"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Server unexpectedly disconnected"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Server unexpectedly disconnected: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Server unexpectedly disconnected: %s"),
+ g_strerror (errno));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
g_byte_array_free (ba, TRUE);
@@ -3110,15 +3206,18 @@ camel_imap_store_readline (CamelImapStore *store, gchar **dest, CamelException *
}
static gboolean
-imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+imap_can_refresh_folder (CamelStore *store,
+ CamelFolderInfo *info,
+ GError **error)
{
+ GError *local_error = NULL;
gboolean res;
- res = CAMEL_STORE_CLASS(parent_class)->can_refresh_folder (store, info, ex) ||
+ res = CAMEL_STORE_CLASS(parent_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 && !camel_exception_is_set (ex) && CAMEL_IS_IMAP_STORE (store)) {
+ if (!res && local_error == NULL && CAMEL_IS_IMAP_STORE (store)) {
CamelStoreInfo *si;
CamelStoreSummary *sm = CAMEL_STORE_SUMMARY (((CamelImapStore *)(store))->summary);
@@ -3133,5 +3232,8 @@ imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelExceptio
}
}
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
+
return res;
}
diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h
index e24c244..6102ff6 100644
--- a/camel/providers/imap/camel-imap-store.h
+++ b/camel/providers/imap/camel-imap-store.h
@@ -168,9 +168,9 @@ struct _CamelImapStoreClass {
GType camel_imap_store_get_type (void);
-gboolean camel_imap_store_connected (CamelImapStore *store, CamelException *ex);
+gboolean camel_imap_store_connected (CamelImapStore *store, GError **error);
-gssize camel_imap_store_readline (CamelImapStore *store, gchar **dest, CamelException *ex);
+gssize camel_imap_store_readline (CamelImapStore *store, gchar **dest, GError **error);
G_END_DECLS
diff --git a/camel/providers/imap/camel-imap-summary.c b/camel/providers/imap/camel-imap-summary.c
index efeeadf..6382fa5 100644
--- a/camel/providers/imap/camel-imap-summary.c
+++ b/camel/providers/imap/camel-imap-summary.c
@@ -51,7 +51,7 @@ static gint content_info_save (CamelFolderSummary *s, FILE *out,
CamelMessageContentInfo *info);
static gint summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *mir);
-static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, CamelException *ex);
+static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, GError **error);
static CamelMIRecord * message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info);
static CamelMessageInfo * message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
static gint content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir);
@@ -180,8 +180,7 @@ CamelFolderSummary *
camel_imap_summary_new (struct _CamelFolder *folder, const gchar *filename)
{
CamelFolderSummary *summary;
- CamelException ex;
- camel_exception_init (&ex);
+ GError *local_error = NULL;
summary = g_object_new (CAMEL_TYPE_IMAP_SUMMARY, NULL);
summary->folder = folder;
@@ -195,13 +194,13 @@ camel_imap_summary_new (struct _CamelFolder *folder, const gchar *filename)
camel_folder_summary_set_build_content (summary, TRUE);
camel_folder_summary_set_filename (summary, filename);
- if (camel_folder_summary_load_from_db (summary, &ex) == -1) {
+ if (camel_folder_summary_load_from_db (summary, &local_error) == -1) {
/* FIXME: Isn't this dangerous ? We clear the summary
if it cannot be loaded, for some random reason.
We need to pass the ex and find out why it is not loaded etc. ? */
camel_folder_summary_clear_db (summary);
- g_message ("Unable to load summary: %s\n", camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
+ g_message ("Unable to load summary: %s\n", local_error->message);
+ g_clear_error (&local_error);
}
g_ptr_array_sort (summary->uids, (GCompareFunc) uid_compare);
@@ -274,12 +273,12 @@ summary_header_load (CamelFolderSummary *s, FILE *in)
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s, GError **error)
{
CamelImapSummary *ims = CAMEL_IMAP_SUMMARY(s);
struct _CamelFIRecord *fir;
- fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, ex);
+ fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, error);
if (!fir)
return NULL;
fir->bdata = g_strdup_printf ("%d %u", CAMEL_IMAP_SUMMARY_VERSION, ims->validity);
diff --git a/camel/providers/imap4/camel-imap4-command.h b/camel/providers/imap4/camel-imap4-command.h
index 318dfb0..87a5650 100644
--- a/camel/providers/imap4/camel-imap4-command.h
+++ b/camel/providers/imap4/camel-imap4-command.h
@@ -37,13 +37,13 @@ typedef struct _CamelIMAP4Literal CamelIMAP4Literal;
typedef gint (* CamelIMAP4PlusCallback) (struct _CamelIMAP4Engine *engine,
CamelIMAP4Command *ic,
const guchar *linebuf,
- gsize linelen, CamelException *ex);
+ gsize linelen, GError **error);
typedef gint (* CamelIMAP4UntaggedCallback) (struct _CamelIMAP4Engine *engine,
CamelIMAP4Command *ic,
guint32 index,
struct _camel_imap4_token_t *token,
- CamelException *ex);
+ GError **error);
typedef void (* CamelIMAP4CommandReset) (CamelIMAP4Command *ic, gpointer user_data);
diff --git a/camel/providers/imap4/camel-imap4-engine.c b/camel/providers/imap4/camel-imap4-engine.c
index bda04e8..dfb818b 100644
--- a/camel/providers/imap4/camel-imap4-engine.c
+++ b/camel/providers/imap4/camel-imap4-engine.c
@@ -43,7 +43,7 @@ static void camel_imap4_engine_init (CamelIMAP4Engine *engine, CamelIMAP4EngineC
static void imap4_engine_finalize (CamelObject *object);
static gint parse_xgwextensions (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index,
- camel_imap4_token_t *token, CamelException *ex);
+ camel_imap4_token_t *token, GError **error);
static gpointer parent_class;
@@ -179,7 +179,7 @@ camel_imap4_engine_new (CamelService *service, CamelIMAP4ReconnectFunc reconnect
* Note: on error, @stream will be unref'd.
**/
gint
-camel_imap4_engine_take_stream (CamelIMAP4Engine *engine, CamelStream *stream, CamelException *ex)
+camel_imap4_engine_take_stream (CamelIMAP4Engine *engine, CamelStream *stream, GError **error)
{
camel_imap4_token_t token;
gint code;
@@ -256,7 +256,7 @@ camel_imap4_engine_disconnect (CamelIMAP4Engine *engine)
* Returns: %0 on success or %-1 on fail.
**/
gint
-camel_imap4_engine_capability (CamelIMAP4Engine *engine, CamelException *ex)
+camel_imap4_engine_capability (CamelIMAP4Engine *engine, GError **error)
{
CamelIMAP4Command *ic;
gint id, retval = 0;
@@ -302,7 +302,7 @@ camel_imap4_engine_capability (CamelIMAP4Engine *engine, CamelException *ex)
* Returns: 0 on success or -1 on fail.
**/
gint
-camel_imap4_engine_namespace (CamelIMAP4Engine *engine, CamelException *ex)
+camel_imap4_engine_namespace (CamelIMAP4Engine *engine, GError **error)
{
camel_imap4_list_t *list;
GPtrArray *array = NULL;
@@ -372,7 +372,7 @@ camel_imap4_engine_namespace (CamelIMAP4Engine *engine, CamelException *ex)
* Returns: 0 on success or -1 on fail.
**/
gint
-camel_imap4_engine_select_folder (CamelIMAP4Engine *engine, CamelFolder *folder, CamelException *ex)
+camel_imap4_engine_select_folder (CamelIMAP4Engine *engine, CamelFolder *folder, GError **error)
{
CamelIMAP4RespCode *resp;
CamelIMAP4Command *ic;
@@ -484,7 +484,7 @@ static struct {
};
static gint
-parse_xgwextensions (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
+parse_xgwextensions (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, GError **error)
{
gint i;
@@ -523,7 +523,7 @@ auth_free (gpointer key, gpointer value, gpointer user_data)
}
static gint
-engine_parse_capability (CamelIMAP4Engine *engine, gint sentinel, CamelException *ex)
+engine_parse_capability (CamelIMAP4Engine *engine, gint sentinel, GError **error)
{
camel_imap4_token_t token;
gint i;
@@ -576,7 +576,7 @@ engine_parse_capability (CamelIMAP4Engine *engine, gint sentinel, CamelException
}
static gint
-engine_parse_flags_list (CamelIMAP4Engine *engine, CamelIMAP4RespCode *resp, gint perm, CamelException *ex)
+engine_parse_flags_list (CamelIMAP4Engine *engine, CamelIMAP4RespCode *resp, gint perm, GError **error)
{
guint32 flags = 0;
@@ -606,7 +606,7 @@ engine_parse_flags_list (CamelIMAP4Engine *engine, CamelIMAP4RespCode *resp, gin
}
static gint
-engine_parse_flags (CamelIMAP4Engine *engine, CamelException *ex)
+engine_parse_flags (CamelIMAP4Engine *engine, GError **error)
{
camel_imap4_token_t token;
@@ -626,7 +626,7 @@ engine_parse_flags (CamelIMAP4Engine *engine, CamelException *ex)
}
static gint
-engine_parse_namespace (CamelIMAP4Engine *engine, CamelException *ex)
+engine_parse_namespace (CamelIMAP4Engine *engine, GError **error)
{
CamelIMAP4Namespace *namespaces[3], *node, *tail;
camel_imap4_token_t token;
@@ -804,7 +804,7 @@ static struct {
* Returns: 0 on success or -1 on fail.
**/
gint
-camel_imap4_engine_parse_resp_code (CamelIMAP4Engine *engine, CamelException *ex)
+camel_imap4_engine_parse_resp_code (CamelIMAP4Engine *engine, GError **error)
{
CamelIMAP4RespCode *resp = NULL;
camel_imap4_resp_code_t code;
@@ -1071,7 +1071,7 @@ camel_imap4_engine_parse_resp_code (CamelIMAP4Engine *engine, CamelException *ex
* CAMEL_IMAP4_UNTAGGED_[OK,NO,BAD,PREAUTH,HANDLED] on success
**/
gint
-camel_imap4_engine_handle_untagged_1 (CamelIMAP4Engine *engine, camel_imap4_token_t *token, CamelException *ex)
+camel_imap4_engine_handle_untagged_1 (CamelIMAP4Engine *engine, camel_imap4_token_t *token, GError **error)
{
gint code = CAMEL_IMAP4_UNTAGGED_HANDLED;
CamelIMAP4Command *ic = engine->current;
@@ -1229,7 +1229,7 @@ camel_imap4_engine_handle_untagged_1 (CamelIMAP4Engine *engine, camel_imap4_toke
* Handle a stream of untagged responses.
**/
void
-camel_imap4_engine_handle_untagged (CamelIMAP4Engine *engine, CamelException *ex)
+camel_imap4_engine_handle_untagged (CamelIMAP4Engine *engine, GError **error)
{
camel_imap4_token_t token;
@@ -1536,7 +1536,7 @@ camel_imap4_engine_dequeue (CamelIMAP4Engine *engine, CamelIMAP4Command *ic)
* Returns: %0 on success or %-1 on fail.
**/
gint
-camel_imap4_engine_next_token (CamelIMAP4Engine *engine, camel_imap4_token_t *token, CamelException *ex)
+camel_imap4_engine_next_token (CamelIMAP4Engine *engine, camel_imap4_token_t *token, GError **error)
{
if (camel_imap4_stream_next_token (engine->istream, token) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -1561,7 +1561,7 @@ camel_imap4_engine_next_token (CamelIMAP4Engine *engine, camel_imap4_token_t *to
* Returns: 0 on success or -1 on fail
**/
gint
-camel_imap4_engine_eat_line (CamelIMAP4Engine *engine, CamelException *ex)
+camel_imap4_engine_eat_line (CamelIMAP4Engine *engine, GError **error)
{
camel_imap4_token_t token;
guchar *literal;
@@ -1605,7 +1605,7 @@ camel_imap4_engine_eat_line (CamelIMAP4Engine *engine, CamelException *ex)
* Returns: 0 on success or -1 on fail
**/
gint
-camel_imap4_engine_line (CamelIMAP4Engine *engine, guchar **line, gsize *len, CamelException *ex)
+camel_imap4_engine_line (CamelIMAP4Engine *engine, guchar **line, gsize *len, GError **error)
{
GByteArray *linebuf = NULL;
guchar *buf;
@@ -1660,7 +1660,7 @@ camel_imap4_engine_line (CamelIMAP4Engine *engine, guchar **line, gsize *len, Ca
* Returns: 0 on success or -1 on fail.
**/
gint
-camel_imap4_engine_literal (CamelIMAP4Engine *engine, guchar **literal, gsize *len, CamelException *ex)
+camel_imap4_engine_literal (CamelIMAP4Engine *engine, guchar **literal, gsize *len, GError **error)
{
GByteArray *literalbuf = NULL;
guchar *buf;
@@ -1713,7 +1713,7 @@ camel_imap4_engine_literal (CamelIMAP4Engine *engine, guchar **literal, gsize *l
* Returns: 0 on success or -1 on fail.
**/
gint
-camel_imap4_engine_nstring (CamelIMAP4Engine *engine, guchar **nstring, CamelException *ex)
+camel_imap4_engine_nstring (CamelIMAP4Engine *engine, guchar **nstring, GError **error)
{
camel_imap4_token_t token;
gsize n;
diff --git a/camel/providers/imap4/camel-imap4-engine.h b/camel/providers/imap4/camel-imap4-engine.h
index 01287a8..a334186 100644
--- a/camel/providers/imap4/camel-imap4-engine.h
+++ b/camel/providers/imap4/camel-imap4-engine.h
@@ -155,7 +155,7 @@ enum {
CAMEL_IMAP4_ENGINE_MAXLEN_TOKEN
};
-typedef gboolean (* CamelIMAP4ReconnectFunc) (CamelIMAP4Engine *engine, CamelException *ex);
+typedef gboolean (* CamelIMAP4ReconnectFunc) (CamelIMAP4Engine *engine, GError **error);
struct _CamelIMAP4Engine {
CamelObject parent;
@@ -201,14 +201,14 @@ GType camel_imap4_engine_get_type (void);
CamelIMAP4Engine *camel_imap4_engine_new (CamelService *service, CamelIMAP4ReconnectFunc reconnect);
/* returns 0 on success or -1 on error */
-gint camel_imap4_engine_take_stream (CamelIMAP4Engine *engine, CamelStream *stream, CamelException *ex);
+gint camel_imap4_engine_take_stream (CamelIMAP4Engine *engine, CamelStream *stream, GError **error);
void camel_imap4_engine_disconnect (CamelIMAP4Engine *engine);
-gint camel_imap4_engine_capability (CamelIMAP4Engine *engine, CamelException *ex);
-gint camel_imap4_engine_namespace (CamelIMAP4Engine *engine, CamelException *ex);
+gint camel_imap4_engine_capability (CamelIMAP4Engine *engine, GError **error);
+gint camel_imap4_engine_namespace (CamelIMAP4Engine *engine, GError **error);
-gint camel_imap4_engine_select_folder (CamelIMAP4Engine *engine, CamelFolder *folder, CamelException *ex);
+gint camel_imap4_engine_select_folder (CamelIMAP4Engine *engine, CamelFolder *folder, GError **error);
struct _CamelIMAP4Command *camel_imap4_engine_queue (CamelIMAP4Engine *engine, CamelFolder *folder,
const gchar *format, ...);
@@ -220,18 +220,18 @@ void camel_imap4_engine_dequeue (CamelIMAP4Engine *engine, struct _CamelIMAP4Com
gint camel_imap4_engine_iterate (CamelIMAP4Engine *engine);
/* untagged response utility functions */
-gint camel_imap4_engine_handle_untagged_1 (CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token, CamelException *ex);
-void camel_imap4_engine_handle_untagged (CamelIMAP4Engine *engine, CamelException *ex);
+gint camel_imap4_engine_handle_untagged_1 (CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token, GError **error);
+void camel_imap4_engine_handle_untagged (CamelIMAP4Engine *engine, GError **error);
/* stream wrapper utility functions */
-gint camel_imap4_engine_next_token (CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token, CamelException *ex);
-gint camel_imap4_engine_line (CamelIMAP4Engine *engine, guchar **line, gsize *len, CamelException *ex);
-gint camel_imap4_engine_literal (CamelIMAP4Engine *engine, guchar **literal, gsize *len, CamelException *ex);
-gint camel_imap4_engine_nstring (CamelIMAP4Engine *engine, guchar **nstring, CamelException *ex);
-gint camel_imap4_engine_eat_line (CamelIMAP4Engine *engine, CamelException *ex);
+gint camel_imap4_engine_next_token (CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token, GError **error);
+gint camel_imap4_engine_line (CamelIMAP4Engine *engine, guchar **line, gsize *len, GError **error);
+gint camel_imap4_engine_literal (CamelIMAP4Engine *engine, guchar **literal, gsize *len, GError **error);
+gint camel_imap4_engine_nstring (CamelIMAP4Engine *engine, guchar **nstring, GError **error);
+gint camel_imap4_engine_eat_line (CamelIMAP4Engine *engine, GError **error);
/* response code stuff */
-gint camel_imap4_engine_parse_resp_code (CamelIMAP4Engine *engine, CamelException *ex);
+gint camel_imap4_engine_parse_resp_code (CamelIMAP4Engine *engine, GError **error);
void camel_imap4_resp_code_free (CamelIMAP4RespCode *rcode);
G_END_DECLS
diff --git a/camel/providers/imap4/camel-imap4-folder.c b/camel/providers/imap4/camel-imap4-folder.c
index 518268a..30af417 100644
--- a/camel/providers/imap4/camel-imap4-folder.c
+++ b/camel/providers/imap4/camel-imap4-folder.c
@@ -54,21 +54,21 @@ static void camel_imap4_folder_class_init (CamelIMAP4FolderClass *class);
static void camel_imap4_folder_init (CamelIMAP4Folder *folder, CamelIMAP4FolderClass *class);
static void imap4_folder_finalize (CamelObject *object);
-static gint imap4_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
-static gint imap4_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
+static gint imap4_getv (CamelObject *object, GError **error, CamelArgGetV *args);
+static gint imap4_setv (CamelObject *object, GError **error, CamelArgV *args);
-static void imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static void imap4_refresh_info (CamelFolder *folder, CamelException *ex);
-static void imap4_expunge (CamelFolder *folder, CamelException *ex);
-static CamelMimeMessage *imap4_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static void imap4_sync (CamelFolder *folder, gboolean expunge, GError **error);
+static void imap4_refresh_info (CamelFolder *folder, GError **error);
+static void imap4_expunge (CamelFolder *folder, GError **error);
+static CamelMimeMessage *imap4_get_message (CamelFolder *folder, const gchar *uid, GError **error);
static void imap4_append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex);
+ const CamelMessageInfo *info, gchar **appended_uid, GError **error);
static void imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
- GPtrArray **transferred_uids, gboolean move, CamelException *ex);
-static GPtrArray *imap4_search_by_expression (CamelFolder *folder, const gchar *expr, CamelException *ex);
-static GPtrArray *imap4_search_by_uids (CamelFolder *folder, const gchar *expr, GPtrArray *uids, CamelException *ex);
+ GPtrArray **transferred_uids, gboolean move, GError **error);
+static GPtrArray *imap4_search_by_expression (CamelFolder *folder, const gchar *expr, GError **error);
+static GPtrArray *imap4_search_by_uids (CamelFolder *folder, const gchar *expr, GPtrArray *uids, GError **error);
static void imap4_search_free (CamelFolder *folder, GPtrArray *uids);
-static gchar * imap4_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static gchar * imap4_get_filename (CamelFolder *folder, const gchar *uid, GError **error);
static gpointer parent_class;
@@ -160,7 +160,7 @@ imap4_folder_finalize (CamelObject *object)
}
static gchar *
-imap4_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+imap4_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) folder;
@@ -168,7 +168,7 @@ imap4_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
static gint
-imap4_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
+imap4_getv (CamelObject *object, GError **error, CamelArgGetV *args)
{
CamelIMAP4Folder *folder = (CamelIMAP4Folder *) object;
CamelArgGetV props;
@@ -212,7 +212,7 @@ imap4_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
}
static gint
-imap4_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
+imap4_setv (CamelObject *object, GError **error, CamelArgV *args)
{
CamelIMAP4Folder *folder = (CamelIMAP4Folder *) object;
CamelDataCache *cache = folder->cache;
@@ -328,7 +328,7 @@ imap4_store_build_filename (gpointer store, const gchar *full_name)
}
CamelFolder *
-camel_imap4_folder_new (CamelStore *store, const gchar *full_name, CamelException *ex)
+camel_imap4_folder_new (CamelStore *store, const gchar *full_name, GError **error)
{
CamelIMAP4Folder *imap4_folder;
gchar *utf7_name, *name, *p;
@@ -445,7 +445,7 @@ static struct {
};
static gint
-imap4_sync_flag (CamelFolder *folder, GPtrArray *infos, gchar onoff, const gchar *flag, CamelException *ex)
+imap4_sync_flag (CamelFolder *folder, GPtrArray *infos, gchar onoff, const gchar *flag, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
CamelIMAP4Command *ic;
@@ -494,7 +494,7 @@ imap4_sync_flag (CamelFolder *folder, GPtrArray *infos, gchar onoff, const gchar
}
static gint
-imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
+imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, GError **error)
{
CamelIMAP4MessageInfo *iinfo;
GPtrArray *on_set, *off_set;
@@ -554,7 +554,7 @@ imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
}
static void
-imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+imap4_sync (CamelFolder *folder, gboolean expunge, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
CamelOfflineStore *offline = (CamelOfflineStore *) folder->parent_store;
@@ -641,13 +641,13 @@ imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
static void
-imap4_expunge (CamelFolder *folder, CamelException *ex)
+imap4_expunge (CamelFolder *folder, GError **error)
{
imap4_sync (folder, TRUE, ex);
}
static void
-imap4_refresh_info (CamelFolder *folder, CamelException *ex)
+imap4_refresh_info (CamelFolder *folder, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
CamelOfflineStore *offline = (CamelOfflineStore *) folder->parent_store;
@@ -687,7 +687,7 @@ imap4_refresh_info (CamelFolder *folder, CamelException *ex)
}
static gint
-untagged_fetch (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
+untagged_fetch (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, GError **error)
{
CamelFolderSummary *summary = ((CamelFolder *) engine->folder)->summary;
CamelStream *fstream, *stream = ic->user_data;
@@ -784,7 +784,7 @@ untagged_fetch (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index,
}
static CamelMimeMessage *
-imap4_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+imap4_get_message (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
CamelOfflineStore *offline = (CamelOfflineStore *) folder->parent_store;
@@ -907,7 +907,7 @@ static gchar *tm_months[] = {
static void
imap4_append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
+ const CamelMessageInfo *info, gchar **appended_uid, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
CamelOfflineStore *offline = (CamelOfflineStore *) folder->parent_store;
@@ -1080,7 +1080,7 @@ info_uid_sort (const CamelMessageInfo **info0, const CamelMessageInfo **info1)
static void
imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
- GPtrArray **transferred_uids, gboolean move, CamelException *ex)
+ GPtrArray **transferred_uids, gboolean move, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) src->parent_store)->engine;
CamelOfflineStore *offline = (CamelOfflineStore *) src->parent_store;
@@ -1216,7 +1216,7 @@ imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest
}
static GPtrArray *
-imap4_search_by_expression (CamelFolder *folder, const gchar *expr, CamelException *ex)
+imap4_search_by_expression (CamelFolder *folder, const gchar *expr, GError **error)
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) folder;
GPtrArray *matches;
@@ -1232,7 +1232,7 @@ imap4_search_by_expression (CamelFolder *folder, const gchar *expr, CamelExcepti
}
static GPtrArray *
-imap4_search_by_uids (CamelFolder *folder, const gchar *expr, GPtrArray *uids, CamelException *ex)
+imap4_search_by_uids (CamelFolder *folder, const gchar *expr, GPtrArray *uids, GError **error)
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) folder;
GPtrArray *matches;
diff --git a/camel/providers/imap4/camel-imap4-folder.h b/camel/providers/imap4/camel-imap4-folder.h
index abd0230..9a24036 100644
--- a/camel/providers/imap4/camel-imap4-folder.h
+++ b/camel/providers/imap4/camel-imap4-folder.h
@@ -85,7 +85,7 @@ struct _CamelIMAP4FolderClass {
GType camel_imap4_folder_get_type (void);
-CamelFolder *camel_imap4_folder_new (CamelStore *store, const gchar *full_name, CamelException *ex);
+CamelFolder *camel_imap4_folder_new (CamelStore *store, const gchar *full_name, GError **error);
const gchar *camel_imap4_folder_utf7_name (CamelIMAP4Folder *folder);
diff --git a/camel/providers/imap4/camel-imap4-journal.c b/camel/providers/imap4/camel-imap4-journal.c
index fdec918..79bfc08 100644
--- a/camel/providers/imap4/camel-imap4-journal.c
+++ b/camel/providers/imap4/camel-imap4-journal.c
@@ -46,7 +46,7 @@ static void imap4_journal_finalize (CamelObject *object);
static void imap4_entry_free (CamelOfflineJournal *journal, CamelDListNode *entry);
static CamelDListNode *imap4_entry_load (CamelOfflineJournal *journal, FILE *in);
static gint imap4_entry_write (CamelOfflineJournal *journal, CamelDListNode *entry, FILE *out);
-static gint imap4_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelException *ex);
+static gint imap4_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, GError **error);
static gpointer parent_class;
@@ -180,7 +180,7 @@ imap4_message_info_dup_to (CamelMessageInfoBase *dest, CamelMessageInfoBase *src
}
static gint
-imap4_entry_play_append (CamelOfflineJournal *journal, CamelIMAP4JournalEntry *entry, CamelException *ex)
+imap4_entry_play_append (CamelOfflineJournal *journal, CamelIMAP4JournalEntry *entry, GError **error)
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) journal->folder;
CamelFolder *folder = journal->folder;
@@ -250,7 +250,7 @@ imap4_entry_play_append (CamelOfflineJournal *journal, CamelIMAP4JournalEntry *e
}
static gint
-imap4_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, CamelException *ex)
+imap4_entry_play (CamelOfflineJournal *journal, CamelDListNode *entry, GError **error)
{
CamelIMAP4JournalEntry *imap4_entry = (CamelIMAP4JournalEntry *) entry;
@@ -290,7 +290,7 @@ camel_imap4_journal_readd_failed (CamelIMAP4Journal *journal)
void
camel_imap4_journal_append (CamelIMAP4Journal *imap4_journal, CamelMimeMessage *message,
- const CamelMessageInfo *mi, gchar **appended_uid, CamelException *ex)
+ const CamelMessageInfo *mi, gchar **appended_uid, GError **error)
{
CamelOfflineJournal *journal = (CamelOfflineJournal *) imap4_journal;
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) journal->folder;
diff --git a/camel/providers/imap4/camel-imap4-journal.h b/camel/providers/imap4/camel-imap4-journal.h
index 80765bf..3b6c378 100644
--- a/camel/providers/imap4/camel-imap4-journal.h
+++ b/camel/providers/imap4/camel-imap4-journal.h
@@ -85,7 +85,7 @@ void camel_imap4_journal_readd_failed (CamelIMAP4Journal *journal);
/* interfaces for adding a journal entry */
void camel_imap4_journal_append (CamelIMAP4Journal *journal, CamelMimeMessage *message, const CamelMessageInfo *mi,
- gchar **appended_uid, CamelException *ex);
+ gchar **appended_uid, GError **error);
G_END_DECLS
diff --git a/camel/providers/imap4/camel-imap4-search.c b/camel/providers/imap4/camel-imap4-search.c
index 7375cdc..9504afc 100644
--- a/camel/providers/imap4/camel-imap4-search.c
+++ b/camel/providers/imap4/camel-imap4-search.c
@@ -95,7 +95,7 @@ camel_imap4_search_new (CamelIMAP4Engine *engine, const gchar *cachedir)
}
static gint
-untagged_search (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
+untagged_search (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, GError **error)
{
CamelFolderSummary *summary = ((CamelFolder *) engine->folder)->summary;
GPtrArray *matches = ic->user_data;
diff --git a/camel/providers/imap4/camel-imap4-store.c b/camel/providers/imap4/camel-imap4-store.c
index ecb04b9..f2ee621 100644
--- a/camel/providers/imap4/camel-imap4-store.c
+++ b/camel/providers/imap4/camel-imap4-store.c
@@ -48,24 +48,24 @@ static void imap4_store_finalize (CamelObject *object);
/* service methods */
static void imap4_construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex);
+ GError **error);
static gchar *imap4_get_name (CamelService *service, gboolean brief);
-static gboolean imap4_connect (CamelService *service, CamelException *ex);
-static gboolean imap4_reconnect (CamelIMAP4Engine *engine, CamelException *ex);
-static gboolean imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex);
-static GList *imap4_query_auth_types (CamelService *service, CamelException *ex);
+static gboolean imap4_connect (CamelService *service, GError **error);
+static gboolean imap4_reconnect (CamelIMAP4Engine *engine, GError **error);
+static gboolean imap4_disconnect (CamelService *service, gboolean clean, GError **error);
+static GList *imap4_query_auth_types (CamelService *service, GError **error);
/* store methods */
-static CamelFolder *imap4_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex);
-static CamelFolderInfo *imap4_create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex);
-static void imap4_delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
-static void imap4_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, CamelException *ex);
-static CamelFolderInfo *imap4_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
+static CamelFolder *imap4_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error);
+static CamelFolderInfo *imap4_create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GError **error);
+static void imap4_delete_folder (CamelStore *store, const gchar *folder_name, GError **error);
+static void imap4_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, GError **error);
+static CamelFolderInfo *imap4_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error);
static void imap4_free_folder_info (CamelStore *store, CamelFolderInfo *fi);
-static void imap4_subscribe_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
-static void imap4_unsubscribe_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
+static void imap4_subscribe_folder (CamelStore *store, const gchar *folder_name, GError **error);
+static void imap4_unsubscribe_folder (CamelStore *store, const gchar *folder_name, GError **error);
static gboolean imap4_folder_subscribed (CamelStore *store, const gchar *folder_name);
-static void imap4_noop (CamelStore *store, CamelException *ex);
+static void imap4_noop (CamelStore *store, GError **error);
static gpointer parent_class;
@@ -163,7 +163,7 @@ imap4_store_finalize (CamelObject *object)
}
static void
-imap4_construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+imap4_construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, GError **error)
{
CamelIMAP4Store *store = (CamelIMAP4Store *) service;
gchar *buf;
@@ -215,7 +215,7 @@ enum {
#endif
static gboolean
-connect_to_server (CamelIMAP4Engine *engine, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
+connect_to_server (CamelIMAP4Engine *engine, struct addrinfo *ai, gint ssl_mode, GError **error)
{
CamelService *service = engine->service;
CamelSockOptData sockopt;
@@ -342,7 +342,7 @@ static struct {
};
static gboolean
-connect_to_server_wrapper (CamelIMAP4Engine *engine, CamelException *ex)
+connect_to_server_wrapper (CamelIMAP4Engine *engine, GError **error)
{
CamelService *service = engine->service;
struct addrinfo *ai, hints;
@@ -390,7 +390,7 @@ connect_to_server_wrapper (CamelIMAP4Engine *engine, CamelException *ex)
}
static gint
-sasl_auth (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, const guchar *linebuf, gsize linelen, CamelException *ex)
+sasl_auth (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, const guchar *linebuf, gsize linelen, GError **error)
{
/* Perform a single challenge iteration */
CamelSasl *sasl = ic->user_data;
@@ -428,7 +428,7 @@ sasl_auth (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, const guchar *linebu
}
static gint
-imap4_try_authenticate (CamelIMAP4Engine *engine, gboolean reprompt, const gchar *errmsg, CamelException *ex)
+imap4_try_authenticate (CamelIMAP4Engine *engine, gboolean reprompt, const gchar *errmsg, GError **error)
{
CamelService *service = engine->service;
CamelSession *session = service->session;
@@ -506,7 +506,7 @@ imap4_try_authenticate (CamelIMAP4Engine *engine, gboolean reprompt, const gchar
}
static gboolean
-imap4_reconnect (CamelIMAP4Engine *engine, CamelException *ex)
+imap4_reconnect (CamelIMAP4Engine *engine, GError **error)
{
CamelService *service = engine->service;
gboolean reprompt = FALSE;
@@ -553,7 +553,7 @@ imap4_reconnect (CamelIMAP4Engine *engine, CamelException *ex)
}
static gboolean
-imap4_connect (CamelService *service, CamelException *ex)
+imap4_connect (CamelService *service, GError **error)
{
CamelIMAP4Store *store = (CamelIMAP4Store *) service;
gboolean retval;
@@ -572,7 +572,7 @@ imap4_connect (CamelService *service, CamelException *ex)
}
static gboolean
-imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+imap4_disconnect (CamelService *service, gboolean clean, GError **error)
{
CamelIMAP4Store *store = (CamelIMAP4Store *) service;
CamelIMAP4Command *ic;
@@ -597,7 +597,7 @@ imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex)
extern CamelServiceAuthType camel_imap4_password_authtype;
static GList *
-imap4_query_auth_types (CamelService *service, CamelException *ex)
+imap4_query_auth_types (CamelService *service, GError **error)
{
CamelIMAP4Store *store = (CamelIMAP4Store *) service;
CamelServiceAuthType *authtype;
@@ -668,7 +668,7 @@ imap4_folder_utf7_name (CamelStore *store, const gchar *folder_name, gchar wildc
}
static CamelFolder *
-imap4_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+imap4_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelFolder *folder = NULL;
@@ -765,7 +765,7 @@ imap4_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, Ca
}
static gboolean
-imap4_folder_can_contain_folders (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imap4_folder_can_contain_folders (CamelStore *store, const gchar *folder_name, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
guint32 flags = CAMEL_FOLDER_NOINFERIORS;
@@ -836,7 +836,7 @@ imap4_folder_can_contain_folders (CamelStore *store, const gchar *folder_name, C
}
static CamelFolderInfo *
-imap4_folder_create (CamelStore *store, const gchar *folder_name, const gchar *subfolder_hint, CamelException *ex)
+imap4_folder_create (CamelStore *store, const gchar *folder_name, const gchar *subfolder_hint, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelFolderInfo *fi = NULL;
@@ -906,7 +906,7 @@ imap4_folder_create (CamelStore *store, const gchar *folder_name, const gchar *s
}
static gboolean
-imap4_folder_recreate (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imap4_folder_recreate (CamelStore *store, const gchar *folder_name, GError **error)
{
CamelFolderInfo *fi = NULL;
gchar hint[2];
@@ -928,7 +928,7 @@ imap4_folder_recreate (CamelStore *store, const gchar *folder_name, CamelExcepti
}
static CamelFolderInfo *
-imap4_create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex)
+imap4_create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GError **error)
{
CamelFolderInfo *fi = NULL;
const gchar *c;
@@ -982,7 +982,7 @@ imap4_create_folder (CamelStore *store, const gchar *parent_name, const gchar *f
}
static void
-imap4_delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imap4_delete_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelFolder *selected = (CamelFolder *) engine->folder;
@@ -1077,7 +1077,7 @@ imap4_delete_folder (CamelStore *store, const gchar *folder_name, CamelException
}
static void
-imap4_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, CamelException *ex)
+imap4_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
gchar *old_uname, *new_uname;
@@ -1409,7 +1409,7 @@ imap4_build_folder_info (CamelStore *store, const gchar *top, guint32 flags, GPt
}
static CamelFolderInfo *
-imap4_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+imap4_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelIMAP4Command *ic, *ic0 = NULL, *ic1 = NULL;
@@ -1609,7 +1609,7 @@ imap4_folder_subscribed (CamelStore *store, const gchar *folder_name)
}
static void
-imap4_subscribe_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imap4_subscribe_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelIMAP4Command *ic;
@@ -1681,7 +1681,7 @@ imap4_subscribe_folder (CamelStore *store, const gchar *folder_name, CamelExcept
}
static void
-imap4_unsubscribe_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imap4_unsubscribe_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelIMAP4Command *ic;
@@ -1753,7 +1753,7 @@ imap4_unsubscribe_folder (CamelStore *store, const gchar *folder_name, CamelExce
}
static void
-imap4_noop (CamelStore *store, CamelException *ex)
+imap4_noop (CamelStore *store, GError **error)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelFolder *folder = (CamelFolder *) engine->folder;
diff --git a/camel/providers/imap4/camel-imap4-summary.c b/camel/providers/imap4/camel-imap4-summary.c
index 5d9035f..51e6e45 100644
--- a/camel/providers/imap4/camel-imap4-summary.c
+++ b/camel/providers/imap4/camel-imap4-summary.c
@@ -189,7 +189,7 @@ imap4_header_save (CamelFolderSummary *summary, FILE *fout)
}
static gint
-envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, CamelException *ex)
+envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, GError **error)
{
gchar *addr, *name = NULL, *user = NULL;
struct _camel_header_address *cia;
@@ -292,7 +292,7 @@ envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, CamelExceptio
}
static gint
-envelope_decode_addresses (CamelIMAP4Engine *engine, gchar **addrlist, CamelException *ex)
+envelope_decode_addresses (CamelIMAP4Engine *engine, gchar **addrlist, GError **error)
{
camel_imap4_token_t token;
GString *addrs;
@@ -338,7 +338,7 @@ envelope_decode_addresses (CamelIMAP4Engine *engine, gchar **addrlist, CamelExce
}
static gint
-envelope_decode_date (CamelIMAP4Engine *engine, time_t *date, CamelException *ex)
+envelope_decode_date (CamelIMAP4Engine *engine, time_t *date, GError **error)
{
guchar *literal = NULL;
camel_imap4_token_t token;
@@ -377,7 +377,7 @@ envelope_decode_date (CamelIMAP4Engine *engine, time_t *date, CamelException *ex
}
static gint
-envelope_decode_nstring (CamelIMAP4Engine *engine, gchar **nstring, gboolean rfc2047, CamelException *ex)
+envelope_decode_nstring (CamelIMAP4Engine *engine, gchar **nstring, gboolean rfc2047, GError **error)
{
camel_imap4_token_t token;
guchar *literal;
@@ -469,7 +469,7 @@ decode_references (const gchar *refstr, const gchar *irtstr)
}
static gint
-decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_token_t *token, CamelException *ex)
+decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_token_t *token, GError **error)
{
CamelIMAP4MessageInfo *iinfo = (CamelIMAP4MessageInfo *) info;
gchar *nstring, *msgid;
@@ -893,7 +893,7 @@ imap4_fetch_all_update (struct imap4_fetch_all_t *fetch)
}
static gint
-untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
+untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, GError **error)
{
struct imap4_fetch_all_t *fetch = ic->user_data;
CamelFolderSummary *summary = fetch->summary;
@@ -1541,7 +1541,7 @@ info_uid_sort (const CamelMessageInfo **info0, const CamelMessageInfo **info1)
#endif
gint
-camel_imap4_summary_flush_updates (CamelFolderSummary *summary, CamelException *ex)
+camel_imap4_summary_flush_updates (CamelFolderSummary *summary, GError **error)
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) summary->folder;
CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
diff --git a/camel/providers/imap4/camel-imap4-summary.h b/camel/providers/imap4/camel-imap4-summary.h
index ed40485..3afb9f7 100644
--- a/camel/providers/imap4/camel-imap4-summary.h
+++ b/camel/providers/imap4/camel-imap4-summary.h
@@ -102,7 +102,7 @@ void camel_imap4_summary_set_uidvalidity (CamelFolderSummary *summary, guint32 u
void camel_imap4_summary_expunge (CamelFolderSummary *summary, gint seqid);
-gint camel_imap4_summary_flush_updates (CamelFolderSummary *summary, CamelException *ex);
+gint camel_imap4_summary_flush_updates (CamelFolderSummary *summary, GError **error);
G_END_DECLS
diff --git a/camel/providers/imap4/camel-imap4-utils.c b/camel/providers/imap4/camel-imap4-utils.c
index 5669e66..c5bda23 100644
--- a/camel/providers/imap4/camel-imap4-utils.c
+++ b/camel/providers/imap4/camel-imap4-utils.c
@@ -415,7 +415,7 @@ camel_imap4_get_uid_set (CamelIMAP4Engine *engine, CamelFolderSummary *summary,
}
void
-camel_imap4_utils_set_unexpected_token_error (CamelException *ex, CamelIMAP4Engine *engine, camel_imap4_token_t *token)
+camel_imap4_utils_set_unexpected_token_error (GError **error, CamelIMAP4Engine *engine, camel_imap4_token_t *token)
{
GString *errmsg;
@@ -476,7 +476,7 @@ static struct {
};
gint
-camel_imap4_parse_flags_list (CamelIMAP4Engine *engine, guint32 *flags, CamelException *ex)
+camel_imap4_parse_flags_list (CamelIMAP4Engine *engine, guint32 *flags, GError **error)
{
camel_imap4_token_t token;
guint32 new = 0;
@@ -534,7 +534,7 @@ static struct {
};
gint
-camel_imap4_untagged_list (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
+camel_imap4_untagged_list (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, GError **error)
{
GPtrArray *array = ic->user_data;
camel_imap4_list_t *list;
@@ -661,7 +661,7 @@ camel_imap4_status_free (camel_imap4_status_t *status)
}
gint
-camel_imap4_untagged_status (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
+camel_imap4_untagged_status (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, GError **error)
{
camel_imap4_status_attr_t *attr, *tail, *list = NULL;
GPtrArray *array = ic->user_data;
diff --git a/camel/providers/imap4/camel-imap4-utils.h b/camel/providers/imap4/camel-imap4-utils.h
index 41bfea5..a348b26 100644
--- a/camel/providers/imap4/camel-imap4-utils.h
+++ b/camel/providers/imap4/camel-imap4-utils.h
@@ -55,9 +55,9 @@ gchar camel_imap4_get_path_delim (struct _CamelIMAP4StoreSummary *s, const gchar
gint camel_imap4_get_uid_set (struct _CamelIMAP4Engine *engine, struct _CamelFolderSummary *summary, GPtrArray *infos, gint cur, gsize linelen, gchar **set);
-void camel_imap4_utils_set_unexpected_token_error (CamelException *ex, struct _CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token);
+void camel_imap4_utils_set_unexpected_token_error (GError **error, struct _CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token);
-gint camel_imap4_parse_flags_list (struct _CamelIMAP4Engine *engine, guint32 *flags, CamelException *ex);
+gint camel_imap4_parse_flags_list (struct _CamelIMAP4Engine *engine, guint32 *flags, GError **error);
/* Note: make sure these don't clash with any bit flags in camel-store.h */
#define CAMEL_IMAP4_FOLDER_MARKED (1 << 17)
@@ -70,7 +70,7 @@ typedef struct {
} camel_imap4_list_t;
gint camel_imap4_untagged_list (struct _CamelIMAP4Engine *engine, struct _CamelIMAP4Command *ic,
- guint32 index, struct _camel_imap4_token_t *token, CamelException *ex);
+ guint32 index, struct _camel_imap4_token_t *token, GError **error);
enum {
CAMEL_IMAP4_STATUS_UNKNOWN,
@@ -95,7 +95,7 @@ typedef struct {
void camel_imap4_status_free (camel_imap4_status_t *status);
gint camel_imap4_untagged_status (struct _CamelIMAP4Engine *engine, struct _CamelIMAP4Command *ic,
- guint32 index, struct _camel_imap4_token_t *token, CamelException *ex);
+ guint32 index, struct _camel_imap4_token_t *token, GError **error);
G_END_DECLS
diff --git a/camel/providers/imapx/camel-imapx-exception.c b/camel/providers/imapx/camel-imapx-exception.c
index e031baf..699e6a5 100644
--- a/camel/providers/imapx/camel-imapx-exception.c
+++ b/camel/providers/imapx/camel-imapx-exception.c
@@ -30,7 +30,7 @@ camel_exception_try(struct _CamelExceptionEnv *env)
}
void
-camel_exception_throw_ex(CamelException *ex)
+camel_exception_throw_ex(GError **error)
{
struct _CamelExceptionEnv *env;
@@ -52,7 +52,7 @@ camel_exception_throw_ex(CamelException *ex)
void
camel_exception_throw(gint id, gchar *fmt, ...)
{
- CamelException *ex;
+ GError **error;
va_list ap;
ex = camel_exception_new();
diff --git a/camel/providers/imapx/camel-imapx-exception.h b/camel/providers/imapx/camel-imapx-exception.h
index dcaff91..1e08d0b 100644
--- a/camel/providers/imapx/camel-imapx-exception.h
+++ b/camel/providers/imapx/camel-imapx-exception.h
@@ -11,7 +11,7 @@
struct _CamelExceptionEnv {
struct _CamelExceptionEnv *parent;
- CamelException *ex;
+ GError **error;
jmp_buf env;
};
@@ -29,7 +29,7 @@ void camel_exception_done(struct _CamelExceptionEnv *env);
void camel_exception_drop(struct _CamelExceptionEnv *env);
/* user functions */
-void camel_exception_throw_ex(CamelException *ex) __attribute__ ((noreturn));
+void camel_exception_throw_ex(GError **error) __attribute__ ((noreturn));
void camel_exception_throw(gint id, gchar *fmt, ...) __attribute__ ((noreturn));
#endif
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 4549414..0ff98a6 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -27,7 +27,6 @@
#include <errno.h>
-#include "camel/camel-exception.h"
#include "camel/camel-stream-mem.h"
#include "camel/camel-stream-filter.h"
#include "camel/camel-mime-message.h"
@@ -72,29 +71,29 @@ camel_imapx_folder_new(CamelStore *store, const gchar *path, const gchar *raw)
#if 0
/* experimental interfaces */
void
-camel_imapx_folder_open(CamelIMAPXFolder *folder, CamelException *ex)
+camel_imapx_folder_open(CamelIMAPXFolder *folder, GError **error)
{
/* */
}
void
-camel_imapx_folder_delete(CamelIMAPXFolder *folder, CamelException *ex)
+camel_imapx_folder_delete(CamelIMAPXFolder *folder, GError **error)
{
}
void
-camel_imapx_folder_rename(CamelIMAPXFolder *folder, const gchar *new, CamelException *ex)
+camel_imapx_folder_rename(CamelIMAPXFolder *folder, const gchar *new, GError **error)
{
}
void
-camel_imapx_folder_close(CamelIMAPXFolder *folder, CamelException *ex)
+camel_imapx_folder_close(CamelIMAPXFolder *folder, GError **error)
{
}
#endif
static void
-imapx_refresh_info (CamelFolder *folder, CamelException *ex)
+imapx_refresh_info (CamelFolder *folder, GError **error)
{
CamelIMAPXStore *is = (CamelIMAPXStore *)folder->parent_store;
@@ -104,7 +103,7 @@ imapx_refresh_info (CamelFolder *folder, CamelException *ex)
}
static void
-imapx_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+imapx_sync (CamelFolder *folder, gboolean expunge, GError **error)
{
CamelIMAPXStore *is = (CamelIMAPXStore *)folder->parent_store;
@@ -120,7 +119,7 @@ imapx_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
static CamelMimeMessage *
-imapx_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+imapx_get_message (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelMimeMessage *msg = NULL;
CamelStream *stream;
@@ -145,7 +144,7 @@ imapx_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
static void
-imapx_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
+imapx_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, GError **error)
{
CamelIMAPXStore *is = (CamelIMAPXStore *)folder->parent_store;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 435fc73..93e21c6 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -166,7 +166,7 @@ typedef struct _CamelIMAPXJob CamelIMAPXJob;
struct _CamelIMAPXJob {
CamelMsg msg;
- CamelException *ex;
+ GError **error;
void (*start)(CamelIMAPXServer *is, struct _CamelIMAPXJob *job);
@@ -229,7 +229,7 @@ enum {
#define SSL_PORT_FLAGS (CAMEL_TCP_STREAM_SSL_ENABLE_SSL2 | CAMEL_TCP_STREAM_SSL_ENABLE_SSL3)
#define STARTTLS_FLAGS (CAMEL_TCP_STREAM_SSL_ENABLE_TLS)
-static void imapx_select(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex);
+static void imapx_select(CamelIMAPXServer *is, CamelFolder *folder, GError **error);
/*
this creates a uid (or sequence number) set directly into a command,
@@ -711,7 +711,7 @@ imapx_command_start(CamelIMAPXServer *imap, CamelIMAPXCommand *ic)
/* must have QUEUE lock */
static void
-imapx_command_start_next(CamelIMAPXServer *imap, CamelException *ex)
+imapx_command_start_next(CamelIMAPXServer *imap, GError **error)
{
CamelIMAPXCommand *ic, *nc;
gint count = 0;
@@ -937,7 +937,7 @@ imapx_expunged(CamelIMAPXServer *imap)
/* handle any untagged responses */
static gint
-imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
+imapx_untagged(CamelIMAPXServer *imap, GError **error)
{
guint id, len;
guchar *token, *p, c;
@@ -1156,7 +1156,7 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
/* handle any continuation requests
either data continuations, or auth continuation */
static gint
-imapx_continuation(CamelIMAPXServer *imap, CamelException *ex)
+imapx_continuation(CamelIMAPXServer *imap, GError **error)
{
CamelIMAPXCommand *ic, *newliteral = NULL;
CamelIMAPXCommandPart *cp;
@@ -1256,7 +1256,7 @@ imapx_continuation(CamelIMAPXServer *imap, CamelException *ex)
/* handle a completion line */
static gint
-imapx_completion(CamelIMAPXServer *imap, guchar *token, gint len, CamelException *ex)
+imapx_completion(CamelIMAPXServer *imap, guchar *token, gint len, GError **error)
{
CamelIMAPXCommand * volatile ic;
guint tag;
@@ -1311,7 +1311,7 @@ imapx_completion(CamelIMAPXServer *imap, guchar *token, gint len, CamelException
}
static void
-imapx_step(CamelIMAPXServer *is, CamelException *ex)
+imapx_step(CamelIMAPXServer *is, GError **error)
/* throws IO,PARSE exception */
{
guint len;
@@ -1333,7 +1333,7 @@ imapx_step(CamelIMAPXServer *is, CamelException *ex)
/* Used to run 1 command synchronously,
use for capa, login, and selecting only. */
static void
-imapx_command_run(CamelIMAPXServer *is, CamelIMAPXCommand *ic, CamelException *ex)
+imapx_command_run(CamelIMAPXServer *is, CamelIMAPXCommand *ic, GError **error)
/* throws IO,PARSE exception */
{
camel_imapx_command_close(ic);
@@ -1409,7 +1409,7 @@ imapx_select_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
}
static void
-imapx_select(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+imapx_select(CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
CamelIMAPXCommand *ic;
@@ -1461,7 +1461,7 @@ imapx_select(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
}
static void
-imapx_connect(CamelIMAPXServer *is, gint ssl_mode, gint try_starttls, CamelException *ex)
+imapx_connect(CamelIMAPXServer *is, gint ssl_mode, gint try_starttls, GError **error)
/* throws IO exception */
{
CamelStream * tcp_stream = NULL;
@@ -1542,7 +1542,7 @@ imapx_connect(CamelIMAPXServer *is, gint ssl_mode, gint try_starttls, CamelExcep
}
static void
-imapx_reconnect(CamelIMAPXServer *is, CamelException *ex)
+imapx_reconnect(CamelIMAPXServer *is, GError **error)
{
CamelSasl *sasl;
CamelIMAPXCommand *ic;
@@ -1808,7 +1808,7 @@ imapx_refresh_info_cmp(gconstpointer ap, gconstpointer bp)
/* skips over non-server uids (pending appends) */
static const CamelMessageInfo *
-imapx_iterator_next(CamelIterator *iter, CamelException *ex)
+imapx_iterator_next(CamelIterator *iter, GError **error)
{
const CamelMessageInfo *iterinfo;
@@ -2410,7 +2410,7 @@ imapx_run_job(CamelIMAPXServer *is, CamelIMAPXJob *job)
}
static CamelStream *
-imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, gint pri, CamelException *ex)
+imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, gint pri, GError **error)
{
CamelStream *stream;
CamelIMAPXJob *job;
@@ -2482,13 +2482,13 @@ imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar
}
CamelStream *
-camel_imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, CamelException *ex)
+camel_imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, GError **error)
{
return imapx_server_get_message(is, folder, uid, 100, ex);
}
void
-camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *mi, CamelException *ex)
+camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *mi, GError **error)
{
gchar *uid = NULL, *tmp = NULL, *new = NULL;
CamelStream *stream, *filter;
@@ -2615,7 +2615,7 @@ getmsgs(gpointer d)
}
void
-camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
CamelIMAPXJob *job;
@@ -2664,7 +2664,7 @@ imapx_sync_free_user(GArray *user_set)
}
void
-camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, GPtrArray *infos, CamelException *ex)
+camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, GPtrArray *infos, GError **error)
{
guint i, on_orset, off_orset;
GArray *on_user = NULL, *off_user = NULL;
@@ -2772,7 +2772,7 @@ camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, GPtrA
/* expunge-uids? */
void
-camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
CamelIMAPXJob *job;
@@ -2829,7 +2829,7 @@ imapx_list_cmp(gconstpointer ap, gconstpointer bp)
}
GPtrArray *
-camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, CamelException *ex)
+camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, GError **error)
{
CamelIMAPXJob *job;
GPtrArray *folders;
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index a8e5f24..3b3649c 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -96,13 +96,13 @@ CamelIMAPXServer *camel_imapx_server_new(struct _CamelStore *store, struct _Came
void camel_imapx_server_connect(CamelIMAPXServer *is, gint state);
-GPtrArray *camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, CamelException *ex);
+GPtrArray *camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, GError **error);
-void camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, struct _CamelException *ex);
-void camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, GPtrArray *infos, CamelException *ex);
-void camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex);
+void camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, struct _GError **error);
+void camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, GPtrArray *infos, GError **error);
+void camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, GError **error);
-CamelStream *camel_imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, struct _CamelException *ex);
-void camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, struct _CamelMimeMessage *message, const struct _CamelMessageInfo *mi, CamelException *ex);
+CamelStream *camel_imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, struct _GError **error);
+void camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, struct _CamelMimeMessage *message, const struct _CamelMessageInfo *mi, GError **error);
#endif /* ! _CAMEL_IMAPX_SERVER_H */
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index c2a3304..0d0d670 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -39,7 +39,6 @@
#include "camel/camel-stream-buffer.h"
#include "camel/camel-session.h"
-#include "camel/camel-exception.h"
#include "camel/camel-url.h"
#include "camel/camel-sasl.h"
#include "camel/camel-data-cache.h"
@@ -84,7 +83,7 @@ imapx_name_equal(gconstpointer a, gconstpointer b)
return g_str_equal(aname, bname);
}
-static void imap_construct(CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+static void imap_construct(CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, GError **error)
{
gchar *base, *summary;
CamelIMAPXStore *store = (CamelIMAPXStore *)service;
@@ -108,7 +107,7 @@ extern CamelServiceAuthType camel_imapx_password_authtype;
extern CamelServiceAuthType camel_imapx_apop_authtype;
static GList *
-imap_query_auth_types (CamelService *service, CamelException *ex)
+imap_query_auth_types (CamelService *service, GError **error)
{
/*CamelIMAPXStore *store = CAMEL_IMAPX_STORE (service);*/
GList *types = NULL;
@@ -175,7 +174,7 @@ store_get_login(struct _CamelIMAPXDriver *driver, gchar **login, gchar **pass, C
#endif
static gboolean
-imap_connect (CamelService *service, CamelException *ex)
+imap_connect (CamelService *service, GError **error)
{
CamelIMAPXStore *store = (CamelIMAPXStore *)service;
@@ -189,7 +188,7 @@ imap_connect (CamelService *service, CamelException *ex)
}
static gboolean
-imap_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+imap_disconnect (CamelService *service, gboolean clean, GError **error)
{
CamelIMAPXStore *store = CAMEL_IMAPX_STORE (service);
@@ -202,7 +201,7 @@ imap_disconnect (CamelService *service, gboolean clean, CamelException *ex)
}
static CamelFolder *
-imap_get_trash (CamelStore *store, CamelException *ex)
+imap_get_trash (CamelStore *store, GError **error)
{
/* no-op */
return NULL;
@@ -210,7 +209,7 @@ imap_get_trash (CamelStore *store, CamelException *ex)
static CamelFolder *
get_folder_offline (CamelStore *store, const gchar *folder_name,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
CamelIMAPXStore *imapx_store = CAMEL_IMAPX_STORE (store);
CamelFolder *new_folder = NULL;
@@ -247,7 +246,7 @@ get_folder_offline (CamelStore *store, const gchar *folder_name,
}
static CamelFolder *
-imap_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+imap_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *)store;
CamelFolder *folder;
@@ -262,7 +261,7 @@ imap_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, Cam
}
static CamelFolder *
-imap_get_inbox(CamelStore *store, CamelException *ex)
+imap_get_inbox(CamelStore *store, GError **error)
{
camel_exception_setv(ex, 1, "get_inbox::unimplemented");
@@ -508,7 +507,7 @@ imap_match_pattern(gchar dir_sep, const gchar *pattern, const gchar *name)
static CamelFolderInfo *
get_folder_info_offline (CamelStore *store, const gchar *top,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
CamelIMAPXStore *imapx_store = CAMEL_IMAPX_STORE (store);
gboolean include_inbox = FALSE;
@@ -609,7 +608,7 @@ get_folder_info_offline (CamelStore *store, const gchar *top,
}
static CamelFolderInfo *
-imap_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+imap_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *)store;
CamelFolderInfo * fi= NULL;
@@ -652,19 +651,19 @@ imap_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelEx
}
static void
-imap_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+imap_delete_folder(CamelStore *store, const gchar *folder_name, GError **error)
{
camel_exception_setv(ex, 1, "delete_folder::unimplemented");
}
static void
-imap_rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+imap_rename_folder(CamelStore *store, const gchar *old, const gchar *new, GError **error)
{
camel_exception_setv(ex, 1, "rename_folder::unimplemented");
}
static CamelFolderInfo *
-imap_create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex)
+imap_create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, GError **error)
{
camel_exception_setv(ex, 1, "create_folder::unimplemented");
return NULL;
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index 0abe7ce..4f6f7b5 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -254,7 +254,7 @@ skip_ws(CamelIMAPXStream *is, guchar *pp, guchar *pe)
/* FIXME: these should probably handle it themselves,
and get rid of the token interface? */
gint
-camel_imapx_stream_atom(CamelIMAPXStream *is, guchar **data, guint *lenp, CamelException *ex)
+camel_imapx_stream_atom(CamelIMAPXStream *is, guchar **data, guint *lenp, GError **error)
{
guchar *p, c;
@@ -277,7 +277,7 @@ camel_imapx_stream_atom(CamelIMAPXStream *is, guchar **data, guint *lenp, CamelE
/* gets an atom, a quoted_string, or a literal */
gint
-camel_imapx_stream_astring(CamelIMAPXStream *is, guchar **data, CamelException *ex)
+camel_imapx_stream_astring(CamelIMAPXStream *is, guchar **data, GError **error)
{
guchar *p, *start;
guint len, inlen;
@@ -318,7 +318,7 @@ camel_imapx_stream_astring(CamelIMAPXStream *is, guchar **data, CamelException *
/* check for NIL or (small) quoted_string or literal */
gint
-camel_imapx_stream_nstring(CamelIMAPXStream *is, guchar **data, CamelException *ex)
+camel_imapx_stream_nstring(CamelIMAPXStream *is, guchar **data, GError **error)
{
guchar *p, *start;
guint len, inlen;
@@ -362,7 +362,7 @@ camel_imapx_stream_nstring(CamelIMAPXStream *is, guchar **data, CamelException *
/* parse an nstring as a stream */
gint
-camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, CamelException *ex)
+camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, GError **error)
/* throws IO,PARSE exception */
{
guchar *token;
@@ -404,7 +404,7 @@ camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, Ca
}
guint32
-camel_imapx_stream_number(CamelIMAPXStream *is, CamelException *ex)
+camel_imapx_stream_number(CamelIMAPXStream *is, GError **error)
{
guchar *token;
guint len;
@@ -418,7 +418,7 @@ camel_imapx_stream_number(CamelIMAPXStream *is, CamelException *ex)
}
gint
-camel_imapx_stream_text(CamelIMAPXStream *is, guchar **text, CamelException *ex)
+camel_imapx_stream_text(CamelIMAPXStream *is, guchar **text, GError **error)
{
GByteArray *build = g_byte_array_new();
guchar *token;
@@ -460,7 +460,7 @@ camel_imapx_stream_text(CamelIMAPXStream *is, guchar **text, CamelException *ex)
/* Get one token from the imap stream */
camel_imapx_token_t
/* throws IO,PARSE exception */
-camel_imapx_stream_token(CamelIMAPXStream *is, guchar **data, guint *len, CamelException *ex)
+camel_imapx_stream_token(CamelIMAPXStream *is, guchar **data, guint *len, GError **error)
{
register guchar c, *p, *o, *oe;
guchar *e;
@@ -703,7 +703,7 @@ gint camel_imapx_stream_getl(CamelIMAPXStream *is, guchar **start, guint *len)
/* skip the rest of the line of tokens */
gint
-camel_imapx_stream_skip(CamelIMAPXStream *is, CamelException *ex)
+camel_imapx_stream_skip(CamelIMAPXStream *is, GError **error)
{
gint tok;
guchar *token;
diff --git a/camel/providers/imapx/camel-imapx-stream.h b/camel/providers/imapx/camel-imapx-stream.h
index a98ff6d..f7177ef 100644
--- a/camel/providers/imapx/camel-imapx-stream.h
+++ b/camel/providers/imapx/camel-imapx-stream.h
@@ -66,7 +66,7 @@ CamelStream *camel_imapx_stream_new (CamelStream *source);
gint camel_imapx_stream_buffered (CamelIMAPXStream *is);
-camel_imapx_token_t camel_imapx_stream_token (CamelIMAPXStream *is, guchar **start, guint *len, CamelException *ex); /* throws IO,PARSE exception */
+camel_imapx_token_t camel_imapx_stream_token (CamelIMAPXStream *is, guchar **start, guint *len, GError **error); /* throws IO,PARSE exception */
void camel_imapx_stream_ungettoken (CamelIMAPXStream *is, camel_imapx_token_t tok, guchar *token, guint len);
void camel_imapx_stream_set_literal (CamelIMAPXStream *is, guint literal);
@@ -76,20 +76,20 @@ gint camel_imapx_stream_getl (CamelIMAPXStream *is, guchar **start, guint *le
/* all throw IO,PARSE exceptions */
/* gets an atom, upper-cases */
-gint camel_imapx_stream_atom (CamelIMAPXStream *is, guchar **start, guint *len, CamelException *ex);
+gint camel_imapx_stream_atom (CamelIMAPXStream *is, guchar **start, guint *len, GError **error);
/* gets an atom or string */
-gint camel_imapx_stream_astring (CamelIMAPXStream *is, guchar **start, CamelException *ex);
+gint camel_imapx_stream_astring (CamelIMAPXStream *is, guchar **start, GError **error);
/* gets a NIL or a string, start==NULL if NIL */
-gint camel_imapx_stream_nstring (CamelIMAPXStream *is, guchar **start, CamelException *ex);
+gint camel_imapx_stream_nstring (CamelIMAPXStream *is, guchar **start, GError **error);
/* gets a NIL or string into a stream, stream==NULL if NIL */
-gint camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, CamelException *ex);
+gint camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, GError **error);
/* gets 'text' */
-gint camel_imapx_stream_text (CamelIMAPXStream *is, guchar **text, CamelException *ex);
+gint camel_imapx_stream_text (CamelIMAPXStream *is, guchar **text, GError **error);
/* gets a 'number' */
-guint32 camel_imapx_stream_number(CamelIMAPXStream *is, CamelException *ex);
+guint32 camel_imapx_stream_number(CamelIMAPXStream *is, GError **error);
/* skips the rest of a line, including literals, etc */
-gint camel_imapx_stream_skip(CamelIMAPXStream *is, CamelException *ex);
+gint camel_imapx_stream_skip(CamelIMAPXStream *is, GError **error);
#endif /* ! _CAMEL_IMAPX_STREAM_H */
diff --git a/camel/providers/imapx/camel-imapx-summary.c b/camel/providers/imapx/camel-imapx-summary.c
index a69ff36..0d3c1be 100644
--- a/camel/providers/imapx/camel-imapx-summary.c
+++ b/camel/providers/imapx/camel-imapx-summary.c
@@ -57,7 +57,7 @@ static gint content_info_save (CamelFolderSummary *s, FILE *out,
CamelMessageContentInfo *info);
static gint summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *mir);
-static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, CamelException *ex);
+static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, GError **error);
static CamelMIRecord * message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info);
static CamelMessageInfo * message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
static gint content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir);
@@ -285,7 +285,7 @@ summary_header_load (CamelFolderSummary *s, FILE *in)
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s, GError **error)
{
CamelIMAPXSummary *ims = CAMEL_IMAPX_SUMMARY(s);
struct _CamelFIRecord *fir;
diff --git a/camel/providers/imapx/camel-imapx-summary.h b/camel/providers/imapx/camel-imapx-summary.h
index 06f5b29..1891d69 100644
--- a/camel/providers/imapx/camel-imapx-summary.h
+++ b/camel/providers/imapx/camel-imapx-summary.h
@@ -25,7 +25,6 @@
//#include "camel-imap-types.h"
#include <camel/camel-folder-summary.h>
-#include <camel/camel-exception.h>
#define CAMEL_IMAPX_SUMMARY(obj) CAMEL_CHECK_CAST (obj, camel_imapx_summary_get_type (), CamelIMAPXSummary)
#define CAMEL_IMAPX_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_imapx_summary_get_type (), CamelIMAPXSummaryClass)
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 7aee53e..78b0c4a 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -56,7 +56,7 @@ static struct {
shoudl this be part of imapx-driver? */
/* mabye this should be a stream op? */
void
-imap_parse_flags(CamelIMAPXStream *stream, guint32 *flagsp, CamelFlag **user_flagsp, CamelException *ex)
+imap_parse_flags(CamelIMAPXStream *stream, guint32 *flagsp, CamelFlag **user_flagsp, GError **error)
/* throws IO,PARSE exception */
{
gint tok, i;
@@ -152,7 +152,7 @@ struct {
};
struct _capability_info *
-imap_parse_capability(CamelIMAPXStream *stream, CamelException *ex)
+imap_parse_capability(CamelIMAPXStream *stream, GError **error)
{
gint tok, len, i;
guchar *token, *p, c, *temp;
@@ -203,7 +203,7 @@ void imap_free_capability(struct _capability_info *cinfo)
}
struct _CamelIMAPXNamespaceList *
-imap_parse_namespace_list (CamelIMAPXStream *stream, CamelException *ex)
+imap_parse_namespace_list (CamelIMAPXStream *stream, GError **error)
{
CamelIMAPXStoreNamespace *namespaces[3], *node, *tail;
CamelIMAPXNamespaceList *nsl = NULL;
@@ -443,7 +443,7 @@ imap_free_body(struct _CamelMessageContentInfo *cinfo)
}
void
-imap_parse_param_list(CamelIMAPXStream *is, struct _camel_header_param **plist, CamelException *ex)
+imap_parse_param_list(CamelIMAPXStream *is, struct _camel_header_param **plist, GError **error)
{
gint tok, len;
guchar *token, *param;
@@ -469,7 +469,7 @@ imap_parse_param_list(CamelIMAPXStream *is, struct _camel_header_param **plist,
}
struct _CamelContentDisposition *
-imap_parse_ext_optional(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_ext_optional(CamelIMAPXStream *is, GError **error)
{
gint tok, len;
guchar *token;
@@ -555,7 +555,7 @@ imap_parse_ext_optional(CamelIMAPXStream *is, CamelException *ex)
}
struct _CamelMessageContentInfo *
-imap_parse_body_fields(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_body_fields(CamelIMAPXStream *is, GError **error)
{
guchar *token, *type;
struct _CamelMessageContentInfo *cinfo;
@@ -613,7 +613,7 @@ error:
}
struct _camel_header_address *
-imap_parse_address_list(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_address_list(CamelIMAPXStream *is, GError **error)
/* throws PARSE,IO exception */
{
gint tok, len;
@@ -690,7 +690,7 @@ imap_parse_address_list(CamelIMAPXStream *is, CamelException *ex)
}
struct _CamelMessageInfo *
-imap_parse_envelope(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_envelope(CamelIMAPXStream *is, GError **error)
{
gint tok, len;
guchar *token;
@@ -800,7 +800,7 @@ imap_parse_envelope(CamelIMAPXStream *is, CamelException *ex)
}
struct _CamelMessageContentInfo *
-imap_parse_body(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_body(CamelIMAPXStream *is, GError **error)
{
gint tok, len;
guchar *token;
@@ -955,7 +955,7 @@ imap_parse_body(CamelIMAPXStream *is, CamelException *ex)
}
gchar *
-imap_parse_section(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_section(CamelIMAPXStream *is, GError **error)
{
gint tok, len;
guchar *token;
@@ -1098,7 +1098,7 @@ imap_dump_fetch(struct _fetch_info *finfo)
}
struct _fetch_info *
-imap_parse_fetch(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_fetch(CamelIMAPXStream *is, GError **error)
{
gint tok, len;
guchar *token, *p, c;
@@ -1201,7 +1201,7 @@ imap_parse_fetch(CamelIMAPXStream *is, CamelException *ex)
/* rfc 2060 section 7.1 Status Responses */
/* shoudl this start after [ or before the [? token_unget anyone? */
struct _status_info *
-imap_parse_status(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_status(CamelIMAPXStream *is, GError **error)
{
gint tok, len;
guchar *token;
@@ -1340,7 +1340,7 @@ static struct {
};
struct _list_info *
-imap_parse_list(CamelIMAPXStream *is, CamelException *ex)
+imap_parse_list(CamelIMAPXStream *is, GError **error)
/* throws io, parse */
{
gint tok, len, i;
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index fc7c633..73af905 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -57,7 +57,7 @@ enum {
/* ********************************************************************** */
-void imap_parse_flags(struct _CamelIMAPXStream *stream, guint32 *flagsp, struct _CamelFlag **user_flagsp, CamelException *ex);
+void imap_parse_flags(struct _CamelIMAPXStream *stream, guint32 *flagsp, struct _CamelFlag **user_flagsp, GError **error);
void imap_write_flags(CamelStream *stream, guint32 flags, struct _CamelFlag *user_flags);
/* ********************************************************************** */
@@ -76,16 +76,16 @@ struct _capability_info {
/* auth stuff here */
};
-struct _capability_info *imap_parse_capability(struct _CamelIMAPXStream *stream, CamelException *ex);
+struct _capability_info *imap_parse_capability(struct _CamelIMAPXStream *stream, GError **error);
void imap_free_capability(struct _capability_info *);
-void imap_parse_param_list(struct _CamelIMAPXStream *is, struct _camel_header_param **plist, CamelException *ex) /* IO,PARSE */;
-struct _CamelContentDisposition *imap_parse_ext_optional(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-struct _CamelMessageContentInfo *imap_parse_body_fields(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-struct _camel_header_address *imap_parse_address_list(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-struct _CamelMessageInfo *imap_parse_envelope(struct _CamelIMAPXStream *is, CamelException *ex) /* IO, PARSE */;
-struct _CamelMessageContentInfo *imap_parse_body(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-gchar *imap_parse_section(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
+void imap_parse_param_list(struct _CamelIMAPXStream *is, struct _camel_header_param **plist, GError **error) /* IO,PARSE */;
+struct _CamelContentDisposition *imap_parse_ext_optional(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+struct _CamelMessageContentInfo *imap_parse_body_fields(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+struct _camel_header_address *imap_parse_address_list(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+struct _CamelMessageInfo *imap_parse_envelope(struct _CamelIMAPXStream *is, GError **error) /* IO, PARSE */;
+struct _CamelMessageContentInfo *imap_parse_body(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+gchar *imap_parse_section(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
void imap_free_body(struct _CamelMessageContentInfo *cinfo);
/* ********************************************************************** */
@@ -119,7 +119,7 @@ struct _fetch_info {
#define FETCH_SECTION (1<<9)
#define FETCH_UID (1<<10)
-struct _fetch_info *imap_parse_fetch(struct _CamelIMAPXStream *is, CamelException *ex);
+struct _fetch_info *imap_parse_fetch(struct _CamelIMAPXStream *is, GError **error);
void imap_free_fetch(struct _fetch_info *finfo);
void imap_dump_fetch(struct _fetch_info *finfo);
@@ -146,7 +146,7 @@ struct _status_info {
gchar *text;
};
-struct _status_info *imap_parse_status(struct _CamelIMAPXStream *is, CamelException *ex);
+struct _status_info *imap_parse_status(struct _CamelIMAPXStream *is, GError **error);
struct _status_info *imap_copy_status(struct _status_info *sinfo);
void imap_free_status(struct _status_info *sinfo);
@@ -160,7 +160,7 @@ struct _list_info {
gchar *name;
};
-struct _list_info *imap_parse_list(struct _CamelIMAPXStream *is, CamelException *ex);
+struct _list_info *imap_parse_list(struct _CamelIMAPXStream *is, GError **error);
gchar *imapx_list_get_path(struct _list_info *li);
void imap_free_list(struct _list_info *linfo);
@@ -194,7 +194,7 @@ gchar *imapx_path_to_physical (const gchar *prefix, const gchar *vpath);
gchar *imapx_concat (CamelIMAPXStore *imap_store, const gchar *prefix, const gchar *suffix);
void camel_imapx_namespace_list_clear (struct _CamelIMAPXNamespaceList *nsl);
-struct _CamelIMAPXNamespaceList * imap_parse_namespace_list (struct _CamelIMAPXStream *stream, CamelException *ex);
+struct _CamelIMAPXNamespaceList * imap_parse_namespace_list (struct _CamelIMAPXStream *stream, GError **error);
struct _CamelIMAPXNamespaceList *camel_imapx_namespace_list_copy (const struct _CamelIMAPXNamespaceList *nsl);
#endif
diff --git a/camel/providers/imapx/camel-imapx-view-summary.c b/camel/providers/imapx/camel-imapx-view-summary.c
index 109700c..904a5fb 100644
--- a/camel/providers/imapx/camel-imapx-view-summary.c
+++ b/camel/providers/imapx/camel-imapx-view-summary.c
@@ -47,7 +47,7 @@ static CamelViewSummaryDiskClass *cmvs_parent;
* Return value: A new CamelIMAPXViewSummary widget.
**/
CamelIMAPXViewSummary *
-camel_imapx_view_summary_new(const gchar *base, CamelException *ex)
+camel_imapx_view_summary_new(const gchar *base, GError **error)
{
return (CamelIMAPXViewSummary *)camel_view_summary_disk_construct(camel_object_new(camel_imapx_view_summary_get_type()), base, ex);
}
diff --git a/camel/providers/imapx/camel-imapx-view-summary.h b/camel/providers/imapx/camel-imapx-view-summary.h
index 5c30bbd..1392866 100644
--- a/camel/providers/imapx/camel-imapx-view-summary.h
+++ b/camel/providers/imapx/camel-imapx-view-summary.h
@@ -53,7 +53,7 @@ struct _CamelIMAPXViewSummaryClass {
};
CamelType camel_imapx_view_summary_get_type (void);
-CamelIMAPXViewSummary *camel_imapx_view_summary_new (const gchar *base, CamelException *ex);
+CamelIMAPXViewSummary *camel_imapx_view_summary_new (const gchar *base, GError **error);
/* called on root view */
guint32 camel_imapx_view_next_uid(CamelIMAPXView *view);
diff --git a/camel/providers/imapx/test-imapx.c b/camel/providers/imapx/test-imapx.c
index 80b8ea7..4ea1d6f 100644
--- a/camel/providers/imapx/test-imapx.c
+++ b/camel/providers/imapx/test-imapx.c
@@ -8,7 +8,7 @@ gint
main (gint argc, gchar *argv [])
{
CamelSession *session;
- CamelException *ex;
+ GError **error;
gchar *uri = NULL;
CamelService *service;
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index d1568af..a4a4772 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -60,22 +60,22 @@
static gpointer parent_class;
static GSList *local_folder_properties;
-static gint local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args);
-static gint local_setv(CamelObject *object, CamelException *ex, CamelArgV *args);
+static gint local_getv(CamelObject *object, GError **error, CamelArgGetV *args);
+static gint local_setv(CamelObject *object, GError **error, CamelArgV *args);
-static gint local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
+static gint local_lock(CamelLocalFolder *lf, CamelLockType type, GError **error);
static void local_unlock(CamelLocalFolder *lf);
-static void local_refresh_info(CamelFolder *folder, CamelException *ex);
+static gboolean local_refresh_info(CamelFolder *folder, GError **error);
-static void local_sync(CamelFolder *folder, gboolean expunge, CamelException *ex);
-static void local_expunge(CamelFolder *folder, CamelException *ex);
+static gboolean local_sync(CamelFolder *folder, gboolean expunge, GError **error);
+static gboolean local_expunge(CamelFolder *folder, GError **error);
-static GPtrArray *local_search_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex);
-static guint32 local_count_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex);
-static GPtrArray *local_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex);
+static GPtrArray *local_search_by_expression(CamelFolder *folder, const gchar *expression, GError **error);
+static guint32 local_count_by_expression(CamelFolder *folder, const gchar *expression, GError **error);
+static GPtrArray *local_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error);
static void local_search_free(CamelFolder *folder, GPtrArray * result);
-static GPtrArray * local_get_uncached_uids (CamelFolder *folder, GPtrArray * uids, CamelException *ex);
+static GPtrArray * local_get_uncached_uids (CamelFolder *folder, GPtrArray * uids, GError **error);
static void local_delete(CamelFolder *folder);
static void local_rename(CamelFolder *folder, const gchar *newname);
@@ -219,7 +219,7 @@ camel_local_folder_get_type (void)
}
CamelLocalFolder *
-camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex)
+camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, const gchar *full_name, guint32 flags, GError **error)
{
CamelFolderInfo *fi;
CamelFolder *folder;
@@ -307,9 +307,9 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con
folder->summary = (CamelFolderSummary *)CAMEL_LOCAL_FOLDER_GET_CLASS(lf)->create_summary(lf, lf->summary_path, lf->folder_path, lf->index);
if (!(flags & CAMEL_STORE_IS_MIGRATING) && camel_local_summary_load((CamelLocalSummary *)folder->summary, forceindex, NULL) == -1) {
/* ? */
- if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, ex) == 0) {
+ if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, error) == 0) {
/* we sync here so that any hard work setting up the folder isn't lost */
- if (camel_local_summary_sync((CamelLocalSummary *)folder->summary, FALSE, lf->changes, ex) == -1) {
+ if (camel_local_summary_sync((CamelLocalSummary *)folder->summary, FALSE, lf->changes, error) == -1) {
g_object_unref (CAMEL_OBJECT (folder));
g_free(name);
return NULL;
@@ -351,13 +351,13 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con
/* lock the folder, may be called repeatedly (with matching unlock calls),
with type the same or less than the first call */
-gint camel_local_folder_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
+gint camel_local_folder_lock(CamelLocalFolder *lf, CamelLockType type, GError **error)
{
if (lf->locked > 0) {
/* lets be anal here - its important the code knows what its doing */
g_assert(lf->locktype == type || lf->locktype == CAMEL_LOCK_WRITE);
} else {
- if (CAMEL_LOCAL_FOLDER_GET_CLASS(lf)->lock(lf, type, ex) == -1)
+ if (CAMEL_LOCAL_FOLDER_GET_CLASS(lf)->lock(lf, type, error) == -1)
return -1;
lf->locktype = type;
}
@@ -379,7 +379,7 @@ gint camel_local_folder_unlock(CamelLocalFolder *lf)
}
static gint
-local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+local_getv(CamelObject *object, GError **error, CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
gint i;
@@ -429,7 +429,7 @@ local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
props.argc = 1;
props.argv[0] = *arg;
- ((CamelObjectClass *)parent_class)->getv(object, ex, &props);
+ ((CamelObjectClass *)parent_class)->getv(object, error, &props);
*arg->ca_ptr = g_slist_concat(*arg->ca_ptr, g_slist_copy(local_folder_properties));
break; }
@@ -446,11 +446,11 @@ local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
- return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->getv(object, error, args);
}
static gint
-local_setv(CamelObject *object, CamelException *ex, CamelArgV *args)
+local_setv(CamelObject *object, GError **error, CamelArgV *args)
{
gint i;
guint32 tag;
@@ -477,11 +477,11 @@ local_setv(CamelObject *object, CamelException *ex, CamelArgV *args)
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
- return ((CamelObjectClass *)parent_class)->setv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->setv(object, error, args);
}
static gint
-local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
+local_lock(CamelLocalFolder *lf, CamelLockType type, GError **error)
{
return 0;
}
@@ -493,13 +493,13 @@ local_unlock(CamelLocalFolder *lf)
}
/* for auto-check to work */
-static void
-local_refresh_info(CamelFolder *folder, CamelException *ex)
+static gboolean
+local_refresh_info(CamelFolder *folder, GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
- if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1) {
- return;
+ if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, error) == -1) {
+ return FALSE;
}
CAMEL_FOLDER_REC_UNLOCK(folder, lock);
@@ -508,46 +508,50 @@ local_refresh_info(CamelFolder *folder, CamelException *ex)
camel_folder_change_info_clear(lf->changes);
}
+ return TRUE;
+
}
static GPtrArray *
-local_get_uncached_uids (CamelFolder *folder, GPtrArray * uids, CamelException *ex)
+local_get_uncached_uids (CamelFolder *folder, GPtrArray * uids, GError **error)
{
GPtrArray *result = g_ptr_array_new ();
/* By default, we would have everything local. No need to fetch from anywhere. */
return result;
}
-static void
-local_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
+static gboolean
+local_sync(CamelFolder *folder, gboolean expunge, GError **error)
{
CamelLocalFolder *lf = CAMEL_LOCAL_FOLDER(folder);
d(printf("local sync '%s' , expunge=%s\n", folder->full_name, expunge?"true":"false"));
- if (camel_local_folder_lock(lf, CAMEL_LOCK_WRITE, ex) == -1)
- return;
+ if (camel_local_folder_lock(lf, CAMEL_LOCK_WRITE, error) == -1)
+ return FALSE;
camel_object_state_write(lf);
/* if sync fails, we'll pass it up on exit through ex */
- camel_local_summary_sync((CamelLocalSummary *)folder->summary, expunge, lf->changes, ex);
+ camel_local_summary_sync((CamelLocalSummary *)folder->summary, expunge, lf->changes, error);
camel_local_folder_unlock(lf);
if (camel_folder_change_info_changed(lf->changes)) {
camel_object_trigger_event(CAMEL_OBJECT(folder), "folder_changed", lf->changes);
camel_folder_change_info_clear(lf->changes);
}
+
+ return TRUE;
}
-static void
-local_expunge(CamelFolder *folder, CamelException *ex)
+static gboolean
+local_expunge(CamelFolder *folder, GError **error)
{
d(printf("expunge\n"));
/* Just do a sync with expunge, serves the same purpose */
/* call the callback directly, to avoid locking problems */
- CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, TRUE, ex);
+ return CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, TRUE, error);
}
static void
@@ -592,7 +596,7 @@ local_rename(CamelFolder *folder, const gchar *newname)
}
static GPtrArray *
-local_search_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex)
+local_search_by_expression(CamelFolder *folder, const gchar *expression, GError **error)
{
CamelLocalFolder *local_folder = CAMEL_LOCAL_FOLDER(folder);
GPtrArray *matches;
@@ -604,7 +608,7 @@ local_search_by_expression(CamelFolder *folder, const gchar *expression, CamelEx
camel_folder_search_set_folder(local_folder->search, folder);
camel_folder_search_set_body_index(local_folder->search, local_folder->index);
- matches = camel_folder_search_search(local_folder->search, expression, NULL, ex);
+ matches = camel_folder_search_search(local_folder->search, expression, NULL, error);
CAMEL_LOCAL_FOLDER_UNLOCK(folder, search_lock);
@@ -612,7 +616,7 @@ local_search_by_expression(CamelFolder *folder, const gchar *expression, CamelEx
}
static guint32
-local_count_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex)
+local_count_by_expression(CamelFolder *folder, const gchar *expression, GError **error)
{
CamelLocalFolder *local_folder = CAMEL_LOCAL_FOLDER(folder);
gint matches;
@@ -624,7 +628,7 @@ local_count_by_expression(CamelFolder *folder, const gchar *expression, CamelExc
camel_folder_search_set_folder(local_folder->search, folder);
camel_folder_search_set_body_index(local_folder->search, local_folder->index);
- matches = camel_folder_search_count (local_folder->search, expression, ex);
+ matches = camel_folder_search_count (local_folder->search, expression, error);
CAMEL_LOCAL_FOLDER_UNLOCK(folder, search_lock);
@@ -632,7 +636,7 @@ local_count_by_expression(CamelFolder *folder, const gchar *expression, CamelExc
}
static GPtrArray *
-local_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+local_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error)
{
CamelLocalFolder *local_folder = CAMEL_LOCAL_FOLDER(folder);
GPtrArray *matches;
@@ -647,7 +651,7 @@ local_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *ui
camel_folder_search_set_folder(local_folder->search, folder);
camel_folder_search_set_body_index(local_folder->search, local_folder->index);
- matches = camel_folder_search_search(local_folder->search, expression, uids, ex);
+ matches = camel_folder_search_search(local_folder->search, expression, uids, error);
CAMEL_LOCAL_FOLDER_UNLOCK(folder, search_lock);
diff --git a/camel/providers/local/camel-local-folder.h b/camel/providers/local/camel-local-folder.h
index 5395a21..0e9010d 100644
--- a/camel/providers/local/camel-local-folder.h
+++ b/camel/providers/local/camel-local-folder.h
@@ -89,7 +89,7 @@ struct _CamelLocalFolderClass {
CamelLocalSummary *(*create_summary)(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index);
/* Lock the folder for my operations */
- gint (*lock)(CamelLocalFolder *, CamelLockType type, CamelException *ex);
+ gint (*lock)(CamelLocalFolder *, CamelLockType type, GError **error);
/* Unlock the folder for my operations */
void (*unlock)(CamelLocalFolder *);
@@ -98,13 +98,13 @@ struct _CamelLocalFolderClass {
/* public methods */
/* flags are taken from CAMEL_STORE_FOLDER_* flags */
CamelLocalFolder *camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store,
- const gchar *full_name, guint32 flags, CamelException *ex);
+ const gchar *full_name, guint32 flags, GError **error);
GType camel_local_folder_get_type(void);
/* Lock the folder for internal use. May be called repeatedly */
/* UNIMPLEMENTED */
-gint camel_local_folder_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
+gint camel_local_folder_lock(CamelLocalFolder *lf, CamelLockType type, GError **error);
gint camel_local_folder_unlock(CamelLocalFolder *lf);
G_END_DECLS
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index faa79a6..1f44efd 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -39,17 +39,17 @@
#define d(x)
-static void construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex);
-static CamelFolder *get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelException * ex);
+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, GError **error);
static gchar *get_name(CamelService *service, gboolean brief);
-static CamelFolder *local_get_inbox (CamelStore *store, CamelException *ex);
-static CamelFolder *local_get_junk(CamelStore *store, CamelException *ex);
-static CamelFolder *local_get_trash(CamelStore *store, CamelException *ex);
-static CamelFolderInfo *get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
-static void delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex);
-static void rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex);
-static CamelFolderInfo *create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex);
-static gboolean local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
+static CamelFolder *local_get_inbox (CamelStore *store, GError **error);
+static CamelFolder *local_get_junk(CamelStore *store, GError **error);
+static CamelFolder *local_get_trash(CamelStore *store, GError **error);
+static CamelFolderInfo *get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error);
+static gboolean delete_folder(CamelStore *store, const gchar *folder_name, GError **error);
+static gboolean rename_folder(CamelStore *store, const gchar *old, const gchar *new, GError **error);
+static CamelFolderInfo *create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, 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);
static gchar *local_get_meta_path(CamelLocalStore *lf, const gchar *full_name, const gchar *ext);
@@ -117,21 +117,29 @@ camel_local_store_get_type (void)
return type;
}
-static void
-construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+static gboolean
+construct (CamelService *service,
+ CamelSession *session,
+ CamelProvider *provider,
+ CamelURL *url,
+ GError **error)
{
CamelLocalStore *local_store = CAMEL_LOCAL_STORE (service);
+ CamelServiceClass *service_class;
gint len;
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ /* Chain up to parent's construct() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
len = strlen (service->url->path);
if (!G_IS_DIR_SEPARATOR (service->url->path[len - 1]))
local_store->toplevel_dir = g_strdup_printf ("%s/", service->url->path);
else
local_store->toplevel_dir = g_strdup (service->url->path);
+
+ return TRUE;
}
const gchar *
@@ -141,7 +149,7 @@ camel_local_store_get_toplevel_dir (CamelLocalStore *store)
}
static CamelFolder *
-get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelException * ex)
+get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, GError **error)
{
gint len = strlen(((CamelLocalStore *)store)->toplevel_dir);
gchar *path = g_alloca(len + 1);
@@ -152,15 +160,19 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
path[len-1] = '\0';
if (!g_path_is_absolute(path)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Store root %s is not an absolute path"), path);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Store root %s is not an absolute path"), path);
return NULL;
}
if (g_stat(path, &st) == 0) {
if (!S_ISDIR(st.st_mode)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Store root %s is not a regular directory"), path);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Store root %s is not a regular directory"), path);
return NULL;
}
return (CamelFolder *) 0xdeadbeef;
@@ -168,17 +180,21 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
if (errno != ENOENT
|| (flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder: %s: %s"),
- path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get folder: %s: %s"),
+ path, g_strerror (errno));
return NULL;
}
/* need to create the dir heirarchy */
if (g_mkdir_with_parents (path, 0777) == -1 && errno != EEXIST) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder: %s: %s"),
- path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get folder: %s: %s"),
+ path, g_strerror (errno));
return NULL;
}
@@ -186,17 +202,24 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
}
static CamelFolder *
-local_get_inbox(CamelStore *store, CamelException *ex)
+local_get_inbox(CamelStore *store, GError **error)
{
- camel_exception_set(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Local stores do not have an inbox"));
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Local stores do not have an inbox"));
+
return NULL;
}
static CamelFolder *
-local_get_trash(CamelStore *store, CamelException *ex)
+local_get_trash (CamelStore *store,
+ GError **error)
{
- CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_trash(store, ex);
+ CamelFolder *folder;
+
+ /* Chain up to parent's get_trash() method. */
+ folder = CAMEL_STORE_CLASS (parent_class)->get_trash (store, error);
if (folder) {
gchar *state = camel_local_store_get_meta_path(store, CAMEL_VTRASH_NAME, ".cmeta");
@@ -211,9 +234,13 @@ local_get_trash(CamelStore *store, CamelException *ex)
}
static CamelFolder *
-local_get_junk(CamelStore *store, CamelException *ex)
+local_get_junk (CamelStore *store,
+ GError **error)
{
- CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_junk(store, ex);
+ CamelFolder *folder;
+
+ /* Chain up to parent's get_junk() method. */
+ folder = CAMEL_STORE_CLASS (parent_class)->get_junk (store, error);
if (folder) {
gchar *state = camel_local_store_get_meta_path(store, CAMEL_VJUNK_NAME, ".cmeta");
@@ -240,7 +267,7 @@ get_name (CamelService *service, gboolean brief)
static CamelFolderInfo *
get_folder_info (CamelStore *store, const gchar *top,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
/* FIXME: This is broken, but it corresponds to what was
* there before.
@@ -252,7 +279,10 @@ get_folder_info (CamelStore *store, const gchar *top,
}
static CamelFolderInfo *
-create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex)
+create_folder (CamelStore *store,
+ const gchar *parent_name,
+ const gchar *folder_name,
+ GError **error)
{
gchar *path = ((CamelLocalStore *)store)->toplevel_dir;
gchar *name;
@@ -263,8 +293,10 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
/* This is a pretty hacky version of create folder, but should basically work */
if (!g_path_is_absolute(path)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Store root %s is not an absolute path"), path);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Store root %s is not an absolute path"), path);
return NULL;
}
@@ -274,9 +306,11 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
name = g_strdup_printf("%s/%s", path, folder_name);
if (g_stat(name, &st) == 0 || errno != ENOENT) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder: %s: %s"),
- name, g_strerror (errno));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Cannot get folder: %s: %s"),
+ name, g_strerror (errno));
g_free(name);
return NULL;
}
@@ -288,10 +322,12 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
else
name = g_strdup_printf("%s", folder_name);
- folder = CAMEL_STORE_GET_CLASS (store)->get_folder (store, name, CAMEL_STORE_FOLDER_CREATE, ex);
+ folder = CAMEL_STORE_GET_CLASS (store)->get_folder (
+ store, name, CAMEL_STORE_FOLDER_CREATE, error);
if (folder) {
g_object_unref (folder);
- info = CAMEL_STORE_GET_CLASS (store)->get_folder_info (store, name, 0, ex);
+ info = CAMEL_STORE_GET_CLASS (store)->get_folder_info (
+ store, name, 0, error);
/* get_folder(CREATE) will emit a folder_created event for us */
/*if (info)
@@ -303,7 +339,13 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
return info;
}
-static gint xrename(const gchar *oldp, const gchar *newp, const gchar *prefix, const gchar *suffix, gint missingok, CamelException *ex)
+static gint
+xrename (const gchar *oldp,
+ const gchar *newp,
+ const gchar *prefix,
+ const gchar *suffix,
+ gint missingok,
+ GError **error)
{
struct stat st;
gchar *old = g_strconcat(prefix, oldp, suffix, NULL);
@@ -329,9 +371,11 @@ static gint xrename(const gchar *oldp, const gchar *newp, const gchar *prefix, c
}
if (ret == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not rename folder %s to %s: %s"),
- old, new, g_strerror (err));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (err),
+ _("Could not rename folder %s to %s: %s"),
+ old, new, g_strerror (err));
}
g_free(old);
@@ -340,8 +384,11 @@ static gint xrename(const gchar *oldp, const gchar *newp, const gchar *prefix, c
}
/* default implementation, rename all */
-static void
-rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+static gboolean
+rename_folder(CamelStore *store,
+ const gchar *old,
+ const gchar *new,
+ GError **error)
{
gchar *path = CAMEL_LOCAL_STORE (store)->toplevel_dir;
CamelLocalFolder *folder = NULL;
@@ -362,16 +409,16 @@ rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelExcept
goto ibex_failed;
}
- if (xrename(old, new, path, ".ev-summary", TRUE, ex))
+ if (xrename(old, new, path, ".ev-summary", TRUE, error))
goto summary_failed;
- if (xrename(old, new, path, ".ev-summary-meta", TRUE, ex))
+ if (xrename(old, new, path, ".ev-summary-meta", TRUE, error))
goto summary_failed;
- if (xrename(old, new, path, ".cmeta", TRUE, ex))
+ if (xrename(old, new, path, ".cmeta", TRUE, error))
goto cmeta_failed;
- if (xrename(old, new, path, "", FALSE, ex))
+ if (xrename(old, new, path, "", FALSE, error))
goto base_failed;
g_free(newibex);
@@ -380,16 +427,16 @@ rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelExcept
if (folder)
g_object_unref (folder);
- return;
+ return TRUE;
/* The (f)utility of this recovery effort is quesitonable */
base_failed:
- xrename(new, old, path, ".cmeta", TRUE, ex);
+ xrename(new, old, path, ".cmeta", TRUE, NULL);
cmeta_failed:
- xrename(new, old, path, ".ev-summary", TRUE, ex);
- xrename(new, old, path, ".ev-summary-meta", TRUE, ex);
+ xrename(new, old, path, ".ev-summary", TRUE, NULL);
+ xrename(new, old, path, ".ev-summary-meta", TRUE, NULL);
summary_failed:
if (folder) {
if (folder->index)
@@ -397,23 +444,28 @@ summary_failed:
} else
camel_text_index_rename(newibex, oldibex);
ibex_failed:
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not rename '%s': %s"),
- old, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not rename '%s': %s"),
+ old, g_strerror (errno));
g_free(newibex);
g_free(oldibex);
if (folder)
g_object_unref (folder);
+
+ return FALSE;
}
/* default implementation, only delete metadata */
-static void
-delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+static gboolean
+delete_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error)
{
CamelFolderInfo *fi;
- CamelException lex;
CamelFolder *lf;
gchar *name;
gchar *str;
@@ -422,35 +474,36 @@ delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
str = g_strdup_printf("%s.ibex", name);
if (camel_text_index_remove(str) == -1 && errno != ENOENT) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder index file '%s': %s"),
- str, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder index file '%s': %s"),
+ str, g_strerror (errno));
g_free(str);
g_free (name);
- return;
+ return FALSE;
}
g_free(str);
str = NULL;
- camel_exception_init (&lex);
- if ((lf = camel_store_get_folder (store, folder_name, 0, &lex))) {
+ if ((lf = camel_store_get_folder (store, folder_name, 0, NULL))) {
camel_object_get (lf, NULL, CAMEL_OBJECT_STATE_FILE, &str, NULL);
camel_object_set (lf, NULL, CAMEL_OBJECT_STATE_FILE, NULL, NULL);
g_object_unref (lf);
- } else {
- camel_exception_clear (&lex);
}
if (str == NULL)
str = g_strdup_printf ("%s.cmeta", name);
if (g_unlink (str) == -1 && errno != ENOENT) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder meta file '%s': %s"),
- str, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder meta file '%s': %s"),
+ str, g_strerror (errno));
g_free (name);
g_free (str);
- return;
+ return FALSE;
}
g_free (str);
@@ -466,6 +519,8 @@ delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
camel_object_trigger_event (store, "folder_deleted", fi);
camel_folder_info_free (fi);
+
+ return TRUE;
}
static gchar *
@@ -481,7 +536,7 @@ local_get_meta_path(CamelLocalStore *ls, const gchar *full_name, const gchar *ex
}
static gboolean
-local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
{
/* any local folder can be refreshed */
return TRUE;
diff --git a/camel/providers/local/camel-local-summary.c b/camel/providers/local/camel-local-summary.c
index 33444e8..20cd62b 100644
--- a/camel/providers/local/camel-local-summary.c
+++ b/camel/providers/local/camel-local-summary.c
@@ -43,7 +43,7 @@
#define EXTRACT_FIRST_DIGIT(val) val=strtoul (part, &part, 10);
-static CamelFIRecord * summary_header_to_db (CamelFolderSummary *, CamelException *ex);
+static CamelFIRecord * summary_header_to_db (CamelFolderSummary *, GError **error);
static gint summary_header_from_db (CamelFolderSummary *, CamelFIRecord *);
static gint summary_header_load (CamelFolderSummary *, FILE *);
@@ -54,10 +54,10 @@ static CamelMessageInfo * message_info_new_from_header (CamelFolderSummary *, GQ
static gint local_summary_decode_x_evolution(CamelLocalSummary *cls, const gchar *xev, CamelLocalMessageInfo *mi);
static gchar *local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *mi);
-static gint local_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex);
-static gint local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-static gint local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-static CamelMessageInfo *local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);
+static gint local_summary_load(CamelLocalSummary *cls, gint forceindex, GError **error);
+static gint local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, GError **error);
+static gint local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
+static CamelMessageInfo *local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, GError **error);
static gint local_summary_need_index(void);
static gpointer parent_class;
@@ -164,15 +164,15 @@ camel_local_summary_construct(CamelLocalSummary *new, const gchar *filename, con
}
static gint
-local_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex)
+local_summary_load(CamelLocalSummary *cls, gint forceindex, GError **error)
{
d(g_print ("\nlocal_summary_load called \n"));
- return camel_folder_summary_load_from_db ((CamelFolderSummary *)cls, ex);
+ return camel_folder_summary_load_from_db ((CamelFolderSummary *)cls, error);
}
/* load/check the summary */
gint
-camel_local_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex)
+camel_local_summary_load(CamelLocalSummary *cls, gint forceindex, GError **error)
{
CamelLocalSummaryClass *class;
@@ -181,7 +181,7 @@ camel_local_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException
class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
if ((forceindex && class->need_index())
- || class->load(cls, forceindex, ex) == -1) {
+ || class->load(cls, forceindex, error) == -1) {
w(g_warning("Could not load summary: flags may be reset"));
camel_folder_summary_clear((CamelFolderSummary *)cls);
return -1;
@@ -288,11 +288,15 @@ do_stat_mi(CamelLocalSummary *cls, struct _stat_info *info, CamelMessageInfo *mi
#endif
gint
-camel_local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+camel_local_summary_check (CamelLocalSummary *cls,
+ CamelFolderChangeInfo *changeinfo,
+ GError **error)
{
+ CamelLocalSummaryClass *local_summary_class;
gint ret;
- ret = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls)->check (cls, changeinfo, ex);
+ local_summary_class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
+ ret = local_summary_class->check (cls, changeinfo, error);
#ifdef DOSTATS
if (ret != -1) {
@@ -319,15 +323,30 @@ camel_local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changei
}
gint
-camel_local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+camel_local_summary_sync (CamelLocalSummary *cls,
+ gboolean expunge,
+ CamelFolderChangeInfo *changeinfo,
+ GError **error)
{
- return CAMEL_LOCAL_SUMMARY_GET_CLASS (cls)->sync (cls, expunge, changeinfo, ex);
+ CamelLocalSummaryClass *local_summary_class;
+
+ local_summary_class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
+
+ return local_summary_class->sync (cls, expunge, changeinfo, error);
}
CamelMessageInfo *
-camel_local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, CamelException *ex)
+camel_local_summary_add (CamelLocalSummary *cls,
+ CamelMimeMessage *msg,
+ const CamelMessageInfo *info,
+ CamelFolderChangeInfo *ci,
+ GError **error)
{
- return CAMEL_LOCAL_SUMMARY_GET_CLASS (cls)->add (cls, msg, info, ci, ex);
+ CamelLocalSummaryClass *local_summary_class;
+
+ local_summary_class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
+
+ return local_summary_class->add (cls, msg, info, ci, error);
}
/**
@@ -429,18 +448,21 @@ camel_local_summary_write_headers(gint fd, GQueue *header_queue, const gchar *xe
}
static gint
-local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, GError **error)
{
/* FIXME: sync index here ? */
return 0;
}
static gint
-local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+local_summary_sync (CamelLocalSummary *cls,
+ gboolean expunge,
+ CamelFolderChangeInfo *changeinfo,
+ GError **error)
{
gint ret = 0;
- ret = camel_folder_summary_save_to_db ((CamelFolderSummary *)cls, ex);
+ ret = camel_folder_summary_save_to_db ((CamelFolderSummary *)cls, error);
if (ret == -1) {
g_warning ("Could not save summary for local providers");
return -1;
@@ -492,7 +514,7 @@ update_summary (CamelFolderSummary *summary, CamelMessageInfoBase *info, CamelMe
}
static CamelMessageInfo *
-local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, CamelException *ex)
+local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, GError **error)
{
CamelLocalMessageInfo *mi;
CamelFolderSummary *s = (CamelFolderSummary *)cls;
@@ -539,8 +561,9 @@ local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMess
camel_folder_change_info_add_uid(ci, camel_message_info_uid(mi));
} else {
d(printf("Failed!\n"));
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unable to add message to summary: unknown reason"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unable to add message to summary: unknown reason"));
}
return (CamelMessageInfo *)mi;
}
@@ -708,11 +731,15 @@ summary_header_load(CamelFolderSummary *s, FILE *in)
}
static struct _CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s, GError **error)
{
+ CamelFolderSummaryClass *folder_summary_class;
struct _CamelFIRecord *fir;
- fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, ex);
+ /* Chain up to parent's summary_header_to_db() method. */
+ folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (parent_class);
+ fir = folder_summary_class->summary_header_to_db (s, error);
+
if (fir)
fir->bdata = g_strdup_printf ("%d", CAMEL_LOCAL_SUMMARY_VERSION);
diff --git a/camel/providers/local/camel-local-summary.h b/camel/providers/local/camel-local-summary.h
index fca613a..9528ccc 100644
--- a/camel/providers/local/camel-local-summary.h
+++ b/camel/providers/local/camel-local-summary.h
@@ -75,10 +75,10 @@ struct _CamelLocalSummary {
struct _CamelLocalSummaryClass {
CamelFolderSummaryClass parent_class;
- gint (*load)(CamelLocalSummary *cls, gint forceindex, CamelException *ex);
- gint (*check)(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex);
- gint (*sync)(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
- CamelMessageInfo *(*add)(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);
+ gint (*load)(CamelLocalSummary *cls, gint forceindex, GError **error);
+ gint (*check)(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, GError **error);
+ gint (*sync)(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
+ CamelMessageInfo *(*add)(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, GError **error);
gchar *(*encode_x_evolution)(CamelLocalSummary *cls, const CamelLocalMessageInfo *info);
gint (*decode_x_evolution)(CamelLocalSummary *cls, const gchar *xev, CamelLocalMessageInfo *info);
@@ -89,13 +89,13 @@ GType camel_local_summary_get_type (void);
void camel_local_summary_construct (CamelLocalSummary *new, const gchar *filename, const gchar *local_name, CamelIndex *index);
/* load/check the summary */
-gint camel_local_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex);
+gint camel_local_summary_load(CamelLocalSummary *cls, gint forceindex, GError **error);
/* check for new/removed messages */
-gint camel_local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *, CamelException *ex);
+gint camel_local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *, GError **error);
/* perform a folder sync or expunge, if needed */
-gint camel_local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *, CamelException *ex);
+gint camel_local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *, GError **error);
/* add a new message to the summary */
-CamelMessageInfo *camel_local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);
+CamelMessageInfo *camel_local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, GError **error);
/* force the next check to be a full check/rebuild */
void camel_local_summary_check_force(CamelLocalSummary *cls);
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index 105ea2d..fe5f826 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -45,15 +45,17 @@ static gpointer parent_class;
static CamelLocalSummary *maildir_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index);
-static void maildir_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, gchar **appended_uid, CamelException * ex);
-static CamelMimeMessage *maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex);
-static gchar * maildir_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static gboolean maildir_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, gchar **appended_uid, GError **error);
+static CamelMimeMessage *maildir_get_message(CamelFolder * folder, const gchar * uid, GError **error);
+static gchar * maildir_get_filename (CamelFolder *folder, const gchar *uid, GError **error);
static gint maildir_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2);
static void maildir_sort_uids (CamelFolder *folder, GPtrArray *uids);
-static void maildir_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
+static gboolean maildir_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, GError **error);
static gint
-maildir_folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+maildir_folder_getv (CamelObject *object,
+ GError **error,
+ CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
gint i;
@@ -78,7 +80,7 @@ maildir_folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
- return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->getv(object, error, args);
}
static void
@@ -124,7 +126,10 @@ camel_maildir_folder_get_type (void)
}
CamelFolder *
-camel_maildir_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex)
+camel_maildir_folder_new (CamelStore *parent_store,
+ const gchar *full_name,
+ guint32 flags,
+ GError **error)
{
CamelFolder *folder;
@@ -136,35 +141,48 @@ camel_maildir_folder_new(CamelStore *parent_store, const gchar *full_name, guint
&& strcmp(full_name, ".") == 0)
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
- folder = (CamelFolder *)camel_local_folder_construct((CamelLocalFolder *)folder,
- parent_store, full_name, flags, ex);
+ folder = (CamelFolder *) camel_local_folder_construct (
+ CAMEL_LOCAL_FOLDER (folder),
+ parent_store, full_name, flags, error);
return folder;
}
-static CamelLocalSummary *maildir_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index)
+static CamelLocalSummary *
+maildir_create_summary (CamelLocalFolder *lf,
+ const gchar *path,
+ const gchar *folder,
+ CamelIndex *index)
{
- return (CamelLocalSummary *)camel_maildir_summary_new((CamelFolder *)lf, path, folder, index);
+ return (CamelLocalSummary *) camel_maildir_summary_new (
+ CAMEL_FOLDER (lf), path, folder, index);
}
-static void
-maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
+static gboolean
+maildir_append_message (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *output_stream;
CamelMessageInfo *mi;
CamelMaildirMessageInfo *mdi;
gchar *name, *dest = NULL;
+ gboolean success = TRUE;
d(printf("Appending message\n"));
/* If we can't lock, don't do anything */
- if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
- return;
+ if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1)
+ return FALSE;
/* add it to the summary/assign the uid, etc */
- mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
- if (camel_exception_is_set (ex))
+ mi = camel_local_summary_add (
+ CAMEL_LOCAL_SUMMARY (folder->summary),
+ message, info, lf->changes, error);
+ if (mi == NULL)
goto check_changed;
if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
@@ -207,12 +225,16 @@ maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const Ca
camel_message_info_uid (mi));
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Maildir append message canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Maildir append message canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to maildir folder: %s: %s"),
- name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot append message to maildir folder: %s: %s"),
+ name, g_strerror (errno));
if (output_stream) {
g_object_unref (CAMEL_OBJECT (output_stream));
@@ -222,6 +244,8 @@ maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const Ca
g_free (name);
g_free (dest);
+ success = FALSE;
+
check_changed:
camel_local_folder_unlock (lf);
@@ -229,10 +253,14 @@ maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const Ca
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", lf->changes);
camel_folder_change_info_clear (lf->changes);
}
+
+ return success;
}
static gchar *
-maildir_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+maildir_get_filename (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelMaildirMessageInfo *mdi;
@@ -240,9 +268,11 @@ maildir_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
/* get the message summary info */
if ((info = camel_folder_summary_uid(folder->summary, uid)) == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, _("No such message"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("No such message"));
return NULL;
}
@@ -253,7 +283,9 @@ maildir_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
static CamelMimeMessage *
-maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)
+maildir_get_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *message_stream = NULL;
@@ -264,14 +296,16 @@ maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex
d(printf("getting message: %s\n", uid));
- if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
+ if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1)
return NULL;
/* get the message summary info */
if ((info = camel_folder_summary_uid(folder->summary, uid)) == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, _("No such message"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("No such message"));
goto fail;
}
@@ -283,17 +317,28 @@ maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex
camel_message_info_free(info);
if ((message_stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0)) == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, g_strerror(errno));
goto fail;
}
message = camel_mime_message_new();
if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream) == -1) {
- camel_exception_setv(ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, _("Invalid message contents"));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("Invalid message contents"));
+ else
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("Invalid message contents"));
g_object_unref (message);
message = NULL;
@@ -313,7 +358,9 @@ maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex
}
static gint
-maildir_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2)
+maildir_cmp_uids (CamelFolder *folder,
+ const gchar *uid1,
+ const gchar *uid2)
{
CamelMessageInfo *a, *b;
time_t tma, tmb;
@@ -334,29 +381,27 @@ maildir_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2)
}
static void
-maildir_sort_uids (CamelFolder *folder, GPtrArray *uids)
+maildir_sort_uids (CamelFolder *folder,
+ GPtrArray *uids)
{
g_return_if_fail (parent_class != NULL);
g_return_if_fail (folder != NULL);
- if (uids && uids->len > 1) {
- CamelException ex;
-
- camel_exception_init (&ex);
-
- camel_folder_summary_ensure_infos_loaded (folder->summary, uids->len, &ex);
-
- if (camel_exception_is_set (&ex))
- g_warning ("%s: %s", G_STRFUNC, camel_exception_get_description (&ex));
-
- camel_exception_clear (&ex);
- }
+ if (uids && uids->len > 1)
+ camel_folder_summary_ensure_infos_loaded (
+ folder->summary, uids->len, NULL);
+ /* Chain up to parent's sort_uids() method. */
CAMEL_FOLDER_CLASS (parent_class)->sort_uids (folder, uids);
}
-static void
-maildir_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex)
+static gboolean
+maildir_transfer_messages_to (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ GError **error)
{
gboolean fallback = FALSE;
@@ -377,10 +422,12 @@ maildir_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder
CamelMessageInfo *info;
if ((info = camel_folder_summary_uid (source->summary, uid)) == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, _("No such message"));
- return;
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("No such message"));
+ return FALSE;
}
mdi = (CamelMaildirMessageInfo *) info;
@@ -396,8 +443,10 @@ maildir_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder
i = uids->len + 1;
fallback = TRUE;
} else {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot transfer message to destination folder"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot transfer message to destination folder"));
break;
}
} else {
@@ -416,6 +465,15 @@ maildir_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder
} else
fallback = TRUE;
- if (fallback)
- ((CamelFolderClass *)parent_class)->transfer_messages_to (source, uids, dest, transferred_uids, delete_originals, ex);
+ if (fallback) {
+ CamelFolderClass *folder_class;
+
+ /* Chain up to parent's transfer_messages_to() method. */
+ folder_class = CAMEL_FOLDER_CLASS (parent_class);
+ return folder_class->transfer_messages_to (
+ source, uids, dest, transferred_uids,
+ delete_originals, error);
+ }
+
+ return TRUE;
}
diff --git a/camel/providers/local/camel-maildir-folder.h b/camel/providers/local/camel-maildir-folder.h
index 2165756..d52b545 100644
--- a/camel/providers/local/camel-maildir-folder.h
+++ b/camel/providers/local/camel-maildir-folder.h
@@ -58,7 +58,7 @@ struct _CamelMaildirFolderClass {
};
/* public methods */
-CamelFolder *camel_maildir_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex);
+CamelFolder *camel_maildir_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, GError **error);
GType camel_maildir_folder_get_type(void);
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 66e4cde..6c42804 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -40,12 +40,12 @@
static gpointer parent_class;
-static CamelFolder *get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelException * ex);
-static CamelFolder *get_inbox (CamelStore *store, CamelException *ex);
-static void delete_folder(CamelStore * store, const gchar *folder_name, CamelException * ex);
-static void maildir_rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex);
+static CamelFolder *get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, GError **error);
+static CamelFolder *get_inbox (CamelStore *store, GError **error);
+static gboolean delete_folder(CamelStore * store, const gchar *folder_name, GError **error);
+static gboolean maildir_rename_folder(CamelStore *store, const gchar *old, const gchar *new, GError **error);
-static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
+static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error);
static gboolean maildir_compare_folder_name(gconstpointer a, gconstpointer b);
static guint maildir_hash_folder_name(gconstpointer a);
@@ -88,7 +88,7 @@ camel_maildir_store_get_type (void)
/* This fixes up some historical cruft of names starting with "./" */
static const gchar *
-md_canon_name(const gchar *a)
+md_canon_name (const gchar *a)
{
if (a != NULL) {
if (a[0] == '/')
@@ -96,29 +96,39 @@ md_canon_name(const gchar *a)
if (a[0] == '.' && a[1] == '/')
a+=2;
}
+
return a;
}
-static guint maildir_hash_folder_name(gconstpointer a)
+static guint
+maildir_hash_folder_name (gconstpointer a)
{
- return g_str_hash(md_canon_name(a));
+ return g_str_hash (md_canon_name(a));
}
-static gboolean maildir_compare_folder_name(gconstpointer a, gconstpointer b)
+static gboolean
+maildir_compare_folder_name (gconstpointer a,
+ gconstpointer b)
{
- return g_str_equal(md_canon_name(a), md_canon_name(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, CamelException * ex)
+get_folder (CamelStore * store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error)
{
+ CamelStoreClass *store_class;
gchar *name, *tmp, *cur, *new;
struct stat st;
CamelFolder *folder = NULL;
folder_name = md_canon_name(folder_name);
- if (!((CamelStoreClass *)parent_class)->get_folder(store, folder_name, flags, ex))
+ /* Chain up to parent's get_folder() method. */
+ store_class = CAMEL_STORE_CLASS (parent_class);
+ if (!store_class->get_folder (store, folder_name, flags, error))
return NULL;
name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
@@ -134,40 +144,48 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
if (mkdir(tmp, 0700) != 0
|| mkdir(cur, 0700) != 0
|| mkdir(new, 0700) != 0) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': %s"),
- folder_name, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_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, ex);
+ folder = camel_maildir_folder_new(store, folder_name, flags, error);
} else if (stat(name, &st) == -1) {
/* folder doesn't exist, see if we should create it */
if (errno != ENOENT) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get folder '%s': %s"),
+ folder_name, g_strerror (errno));
} else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder '%s': folder does not exist."),
- folder_name);
+ 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) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_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, ex);
+ folder = camel_maildir_folder_new(store, folder_name, flags, error);
}
}
} else if (!S_ISDIR(st.st_mode)
@@ -175,14 +193,19 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
|| stat(cur, &st) != 0 || !S_ISDIR(st.st_mode)
|| stat(new, &st) != 0 || !S_ISDIR(st.st_mode)) {
/* folder exists, but not maildir */
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get folder '%s': not a maildir directory."), name);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot get folder '%s': not a maildir directory."),
+ name);
} else if (flags & CAMEL_STORE_FOLDER_EXCL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': folder exists."),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot create folder '%s': folder exists."),
+ folder_name);
} else {
- folder = camel_maildir_folder_new(store, folder_name, flags, ex);
+ folder = camel_maildir_folder_new(store, folder_name, flags, error);
}
fail:
g_free(name);
@@ -194,20 +217,29 @@ fail:
}
static CamelFolder *
-get_inbox (CamelStore *store, CamelException *ex)
+get_inbox (CamelStore *store,
+ GError **error)
{
- return camel_store_get_folder(store, ".", CAMEL_STORE_FOLDER_CREATE, ex);
+ return camel_store_get_folder (
+ store, ".", CAMEL_STORE_FOLDER_CREATE, error);
}
-static void delete_folder(CamelStore * store, const gchar *folder_name, CamelException * ex)
+static gboolean
+delete_folder (CamelStore * store,
+ const gchar *folder_name,
+ GError **error)
{
gchar *name, *tmp, *cur, *new;
struct stat st;
+ gboolean success = TRUE;
if (strcmp(folder_name, ".") == 0) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot delete folder: %s: Invalid operation"), _("Inbox"));
- return;
+ 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);
@@ -220,10 +252,12 @@ static void delete_folder(CamelStore * store, const gchar *folder_name, CamelExc
|| stat(tmp, &st) == -1 || !S_ISDIR(st.st_mode)
|| stat(cur, &st) == -1 || !S_ISDIR(st.st_mode)
|| stat(new, &st) == -1 || !S_ISDIR(st.st_mode)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder '%s': %s"),
- folder_name, errno ? g_strerror (errno) :
- _("not a maildir directory"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Could not delete folder '%s': %s"),
+ folder_name, errno ? g_strerror (errno) :
+ _("not a maildir directory"));
} else {
gint err = 0;
@@ -258,12 +292,18 @@ static void delete_folder(CamelStore * store, const gchar *folder_name, CamelExc
mkdir(cur, 0700);
mkdir(new, 0700);
mkdir(tmp, 0700);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder '%s': %s"),
- folder_name, g_strerror (err));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (err),
+ _("Could not delete folder '%s': %s"),
+ folder_name, g_strerror (err));
} else {
- /* and remove metadata */
- ((CamelStoreClass *)parent_class)->delete_folder(store, folder_name, ex);
+ CamelStoreClass *store_class;
+
+ /* Chain up to parent's delete_folder() method. */
+ store_class = CAMEL_STORE_CLASS (parent_class);
+ success = store_class->delete_folder (
+ store, folder_name, error);
}
}
@@ -271,22 +311,36 @@ static void delete_folder(CamelStore * store, const gchar *folder_name, CamelExc
g_free(tmp);
g_free(cur);
g_free(new);
+
+ return success;
}
-static void
-maildir_rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+static gboolean
+maildir_rename_folder (CamelStore *store,
+ const gchar *old,
+ const gchar *new,
+ GError **error)
{
+ CamelStoreClass *store_class;
+
if (strcmp(old, ".") == 0) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot rename folder: %s: Invalid operation"), _("Inbox"));
- return;
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Cannot rename folder: %s: Invalid operation"),
+ _("Inbox"));
+ return FALSE;
}
- ((CamelStoreClass *)parent_class)->rename_folder(store, old, new, ex);
+ /* Chain up to parent's rename_folder() method. */
+ store_class = CAMEL_STORE_CLASS (parent_class);
+ return store_class->rename_folder (store, old, new, error);
}
static void
-fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
+fill_fi (CamelStore *store,
+ CamelFolderInfo *fi,
+ guint32 flags)
{
CamelFolder *folder;
@@ -332,26 +386,34 @@ struct _scan_node {
ino_t inode;
};
-static guint scan_hash(gconstpointer d)
+static guint
+scan_hash (gconstpointer d)
{
const struct _scan_node *v = d;
return v->inode ^ v->dnode;
}
-static gboolean scan_equal(gconstpointer a, gconstpointer b)
+static gboolean
+scan_equal (gconstpointer a, gconstpointer b)
{
const struct _scan_node *v1 = a, *v2 = b;
return v1->inode == v2->inode && v1->dnode == v2->dnode;
}
-static void scan_free(gpointer k, gpointer v, gpointer d)
+static void
+scan_free (gpointer k, gpointer v, gpointer d)
{
g_free(k);
}
-static CamelFolderInfo *scan_fi(CamelStore *store, guint32 flags, CamelURL *url, const gchar *full, const gchar *name)
+static CamelFolderInfo *
+scan_fi (CamelStore *store,
+ guint32 flags,
+ CamelURL *url,
+ const gchar *full,
+ const gchar *name)
{
CamelFolderInfo *fi;
gchar *tmp, *cur, *new;
@@ -391,7 +453,11 @@ static CamelFolderInfo *scan_fi(CamelStore *store, guint32 flags, CamelURL *url,
}
static gint
-scan_dirs(CamelStore *store, guint32 flags, CamelFolderInfo *topfi, CamelURL *url, CamelException *ex)
+scan_dirs (CamelStore *store,
+ guint32 flags,
+ CamelFolderInfo *topfi,
+ CamelURL *url,
+ GError **error)
{
CamelDList queue = CAMEL_DLIST_INITIALISER(queue);
struct _scan_node *sn;
@@ -426,9 +492,11 @@ scan_dirs(CamelStore *store, guint32 flags, CamelFolderInfo *topfi, CamelURL *ur
dir = opendir(name);
if (dir == NULL) {
g_free(name);
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not scan folder '%s': %s"),
- root, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not scan folder '%s': %s"),
+ root, g_strerror (errno));
goto fail;
}
@@ -491,7 +559,10 @@ fail:
}
static CamelFolderInfo *
-get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+get_folder_info (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
CamelFolderInfo *fi = NULL;
CamelLocalStore *local_store = (CamelLocalStore *)store;
@@ -505,7 +576,7 @@ get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelExcept
/* create a dummy "." parent inbox, use to scan, then put back at the top level */
fi = scan_fi(store, flags, url, ".", _("Inbox"));
- if (scan_dirs(store, flags, fi, url, ex) == -1)
+ if (scan_dirs(store, flags, fi, url, error) == -1)
goto fail;
fi->next = fi->child;
scan = fi->child;
@@ -523,7 +594,7 @@ get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelExcept
const gchar *name = strrchr(top, '/');
fi = scan_fi(store, flags, url, top, name?name+1:top);
- if (scan_dirs(store, flags, fi, url, ex) == -1)
+ if (scan_dirs(store, flags, fi, url, error) == -1)
goto fail;
}
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c
index efe92d3..1da4a5a 100644
--- a/camel/providers/local/camel-maildir-summary.c
+++ b/camel/providers/local/camel-maildir-summary.c
@@ -52,10 +52,10 @@ static CamelMessageInfo *message_info_load(CamelFolderSummary *s, FILE *in);
static CamelMessageInfo *message_info_new_from_header(CamelFolderSummary *, GQueue *header_queue);
static void message_info_free(CamelFolderSummary *, CamelMessageInfo *mi);
-static gint maildir_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex);
-static gint maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-static gint maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-static CamelMessageInfo *maildir_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);
+static gint maildir_summary_load(CamelLocalSummary *cls, gint forceindex, GError **error);
+static gint maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, GError **error);
+static gint maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
+static CamelMessageInfo *maildir_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, GError **error);
static gchar *maildir_summary_next_uid_string(CamelFolderSummary *s);
static gint maildir_summary_decode_x_evolution(CamelLocalSummary *cls, const gchar *xev, CamelLocalMessageInfo *mi);
@@ -265,11 +265,19 @@ static gchar *maildir_summary_encode_x_evolution(CamelLocalSummary *cls, const C
both 'new' and 'add' will try and set the filename, this is not ideal ...
*/
static CamelMessageInfo *
-maildir_summary_add (CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *changes, CamelException *ex)
+maildir_summary_add (CamelLocalSummary *cls,
+ CamelMimeMessage *msg,
+ const CamelMessageInfo *info,
+ CamelFolderChangeInfo *changes,
+ GError **error)
{
+ CamelLocalSummaryClass *local_summary_class;
CamelMaildirMessageInfo *mi;
- mi = (CamelMaildirMessageInfo *)((CamelLocalSummaryClass *) parent_class)->add(cls, msg, info, changes, ex);
+ /* Chain up to parent's add() method. */
+ local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (parent_class);
+ mi = (CamelMaildirMessageInfo *) local_summary_class->add (
+ cls, msg, info, changes, error);
if (mi) {
if (info) {
camel_maildir_info_set_filename(mi, camel_maildir_summary_info_to_name(mi));
@@ -420,8 +428,12 @@ message_info_load(CamelFolderSummary *s, FILE *in)
return mi;
}
-static gint maildir_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex)
+static gint
+maildir_summary_load (CamelLocalSummary *cls,
+ gint forceindex,
+ GError **error)
{
+ CamelLocalSummaryClass *local_summary_class;
gchar *cur;
DIR *dir;
struct dirent *d;
@@ -436,7 +448,9 @@ static gint maildir_summary_load(CamelLocalSummary *cls, gint forceindex, CamelE
dir = opendir(cur);
if (dir == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
_("Cannot open maildir directory path: %s: %s"),
cls->folder_path, g_strerror (errno));
g_free(cur);
@@ -466,7 +480,9 @@ static gint maildir_summary_load(CamelLocalSummary *cls, gint forceindex, CamelE
closedir(dir);
g_free(cur);
- ret = ((CamelLocalSummaryClass *) parent_class)->load(cls, forceindex, ex);
+ /* Chain up to parent's load() method. */
+ local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (parent_class);
+ ret = local_summary_class->load (cls, forceindex, error);
g_hash_table_destroy(mds->priv->load_map);
mds->priv->load_map = NULL;
@@ -527,7 +543,7 @@ remove_summary(gchar *key, CamelMessageInfo *info, struct _remove_data *rd)
}
static gint
-maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, CamelException *ex)
+maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, GError **error)
{
DIR *dir;
struct dirent *d;
@@ -555,7 +571,9 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca
no longer exist */
dir = opendir(cur);
if (dir == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
_("Cannot open maildir directory path: %s: %s"),
cls->folder_path, g_strerror (errno));
g_free(cur);
@@ -569,7 +587,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca
left = g_hash_table_new(g_str_hash, g_str_equal);
count = camel_folder_summary_count (s);
if (count != camel_folder_summary_cache_size (s)) {
- camel_folder_summary_reload_from_db (s, ex);
+ camel_folder_summary_reload_from_db (s, NULL);
count = camel_folder_summary_count (s);
}
forceindex = count == 0;
@@ -716,8 +734,12 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca
/* sync the summary with the ondisk files. */
static gint
-maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changes, CamelException *ex)
+maildir_summary_sync (CamelLocalSummary *cls,
+ gboolean expunge,
+ CamelFolderChangeInfo *changes,
+ GError **error)
{
+ CamelLocalSummaryClass *local_summary_class;
gint count, i;
CamelMessageInfo *info;
CamelMaildirMessageInfo *mdi;
@@ -726,7 +748,7 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange
d(printf("summary_sync(expunge=%s)\n", expunge?"true":"false"));
- if (camel_local_summary_check(cls, changes, ex) == -1)
+ if (camel_local_summary_check(cls, changes, error) == -1)
return -1;
camel_operation_start(NULL, _("Storing folder"));
@@ -786,6 +808,8 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange
camel_operation_end(NULL);
- return ((CamelLocalSummaryClass *)parent_class)->sync(cls, expunge, changes, ex);
+ /* Chain up to parent's sync() method. */
+ local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (parent_class);
+ return local_summary_class->sync (cls, expunge, changes, error);
}
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 149114c..fdcd87b 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -48,13 +48,13 @@
static gpointer parent_class;
-static gint mbox_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
+static gint mbox_lock(CamelLocalFolder *lf, CamelLockType type, GError **error);
static void mbox_unlock(CamelLocalFolder *lf);
-static void mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const CamelMessageInfo * info, gchar **appended_uid, CamelException *ex);
-static CamelMimeMessage *mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex);
+static gboolean mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const CamelMessageInfo * info, gchar **appended_uid, GError **error);
+static CamelMimeMessage *mbox_get_message(CamelFolder *folder, const gchar * uid, GError **error);
static CamelLocalSummary *mbox_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index);
-static gchar * mbox_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static gchar * mbox_get_filename (CamelFolder *folder, const gchar *uid, GError **error);
static gint mbox_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2);
static void mbox_sort_uids (CamelFolder *folder, GPtrArray *uids);
@@ -104,7 +104,7 @@ camel_mbox_folder_get_type (void)
}
CamelFolder *
-camel_mbox_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex)
+camel_mbox_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, GError **error)
{
CamelFolder *folder;
@@ -112,7 +112,7 @@ camel_mbox_folder_new(CamelStore *parent_store, const gchar *full_name, guint32
folder = g_object_new (CAMEL_TYPE_MBOX_FOLDER, NULL);
folder = (CamelFolder *)camel_local_folder_construct((CamelLocalFolder *)folder,
- parent_store, full_name, flags, ex);
+ parent_store, full_name, flags, error);
return folder;
}
@@ -122,7 +122,7 @@ static CamelLocalSummary *mbox_create_summary(CamelLocalFolder *lf, const gchar
return (CamelLocalSummary *)camel_mbox_summary_new((CamelFolder *)lf, path, folder, index);
}
-static gint mbox_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
+static gint mbox_lock(CamelLocalFolder *lf, CamelLockType type, GError **error)
{
#ifndef G_OS_WIN32
CamelMboxFolder *mf = (CamelMboxFolder *)lf;
@@ -132,13 +132,15 @@ static gint mbox_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *
mf->lockfd = open(lf->folder_path, O_RDWR|O_LARGEFILE, 0);
if (mf->lockfd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder lock on %s: %s"),
- lf->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot create folder lock on %s: %s"),
+ lf->folder_path, g_strerror (errno));
return -1;
}
- if (camel_lock_folder(lf->folder_path, mf->lockfd, type, ex) == -1) {
+ if (camel_lock_folder(lf->folder_path, mf->lockfd, type, error) == -1) {
close(mf->lockfd);
mf->lockfd = -1;
return -1;
@@ -159,8 +161,12 @@ static void mbox_unlock(CamelLocalFolder *lf)
#endif
}
-static void
-mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const CamelMessageInfo * info, gchar **appended_uid, CamelException *ex)
+static gboolean
+mbox_append_message (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *output_stream = NULL, *filter_stream = NULL;
@@ -174,18 +180,18 @@ mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const Camel
gchar *xev;
#endif
/* If we can't lock, dont do anything */
- if (camel_local_folder_lock(lf, CAMEL_LOCK_WRITE, ex) == -1)
- return;
+ if (camel_local_folder_lock(lf, CAMEL_LOCK_WRITE, error) == -1)
+ return FALSE;
d(printf("Appending message\n"));
/* first, check the summary is correct (updates folder_size too) */
- retval = camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, ex);
+ retval = camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, error);
if (retval == -1)
goto fail;
/* add it to the summary/assign the uid, etc */
- mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
+ mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, error);
if (mi == NULL)
goto fail;
@@ -196,9 +202,11 @@ mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const Camel
output_stream = camel_stream_fs_new_with_name(lf->folder_path, O_WRONLY | O_APPEND | O_LARGEFILE, 0666);
if (output_stream == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot open mailbox: %s: %s\n"),
- lf->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot open mailbox: %s: %s\n"),
+ lf->folder_path, g_strerror (errno));
goto fail;
}
@@ -258,16 +266,20 @@ mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const Camel
if (appended_uid)
*appended_uid = g_strdup(camel_message_info_uid(mi));
- return;
+ return TRUE;
fail_write:
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Mail append canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Mail append canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to mbox file: %s: %s"),
- lf->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot append message to mbox file: %s: %s"),
+ lf->folder_path, g_strerror (errno));
if (output_stream) {
gint fd;
@@ -305,10 +317,12 @@ fail:
camel_object_trigger_event((CamelObject *)folder, "folder_changed", lf->changes);
camel_folder_change_info_clear(lf->changes);
}
+
+ return FALSE;
}
static gchar *
-mbox_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+mbox_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelMboxMessageInfo *info;
@@ -318,11 +332,11 @@ mbox_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
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, ex) == -1)
+ 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, ex) == -1) {
+ if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, error) == -1) {
camel_local_folder_unlock(lf);
return NULL;
}
@@ -331,9 +345,11 @@ mbox_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
info = (CamelMboxMessageInfo *) camel_folder_summary_uid(folder->summary, uid);
if (info == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, _("No such message"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("No such message"));
goto fail;
}
@@ -355,7 +371,7 @@ fail:
}
static CamelMimeMessage *
-mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex)
+mbox_get_message(CamelFolder *folder, const gchar * uid, GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelMimeMessage *message = NULL;
@@ -368,11 +384,11 @@ mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex)
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, ex) == -1)
+ 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, ex) == -1) {
+ if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, error) == -1) {
camel_local_folder_unlock(lf);
return NULL;
}
@@ -382,9 +398,11 @@ retry:
info = (CamelMboxMessageInfo *) camel_folder_summary_uid(folder->summary, uid);
if (info == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, _("No such message"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("No such message"));
goto fail;
}
@@ -403,9 +421,11 @@ retry:
fd = g_open(lf->folder_path, O_LARGEFILE | O_RDONLY | O_BINARY, 0);
if (fd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message: %s from folder %s\n %s"),
- uid, lf->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, g_strerror (errno));
goto fail;
}
@@ -429,22 +449,36 @@ retry:
if (!retried) {
retried = TRUE;
camel_local_summary_check_force((CamelLocalSummary *)folder->summary);
- retval = camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, ex);
+ retval = camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, error);
if (retval != -1)
goto retry;
}
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("Cannot get message: %s from folder %s\n %s"), uid, lf->folder_path,
- _("The folder appears to be irrecoverably corrupted."));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path,
+ _("The folder appears to be irrecoverably corrupted."));
goto fail;
}
message = camel_mime_message_new();
if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser) == -1) {
- camel_exception_setv(ex, errno==EINTR?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message: %s from folder %s\n %s"), uid, lf->folder_path,
- _("Message construction failed."));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path,
+ _("Message construction failed."));
+ else
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path,
+ _("Message construction failed."));
g_object_unref (message);
message = NULL;
goto fail;
@@ -491,18 +525,9 @@ mbox_sort_uids (CamelFolder *folder, GPtrArray *uids)
g_return_if_fail (parent_class != NULL);
g_return_if_fail (folder != NULL);
- if (uids && uids->len > 1) {
- CamelException ex;
-
- camel_exception_init (&ex);
-
- camel_folder_summary_ensure_infos_loaded (folder->summary, uids->len, &ex);
-
- if (camel_exception_is_set (&ex))
- g_warning ("%s: %s", G_STRFUNC, camel_exception_get_description (&ex));
-
- camel_exception_clear (&ex);
- }
+ if (uids && uids->len > 1)
+ camel_folder_summary_ensure_infos_loaded (
+ folder->summary, uids->len, NULL);
CAMEL_FOLDER_CLASS (parent_class)->sort_uids (folder, uids);
}
diff --git a/camel/providers/local/camel-mbox-folder.h b/camel/providers/local/camel-mbox-folder.h
index 89b03b7..02d3cf8 100644
--- a/camel/providers/local/camel-mbox-folder.h
+++ b/camel/providers/local/camel-mbox-folder.h
@@ -61,7 +61,7 @@ struct _CamelMboxFolderClass {
/* public methods */
/* flags are taken from CAMEL_STORE_FOLDER_* flags */
-CamelFolder *camel_mbox_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex);
+CamelFolder *camel_mbox_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, GError **error);
GType camel_mbox_folder_get_type(void);
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 03b6f8c..0923b1b 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -42,11 +42,11 @@
static gpointer parent_class;
-static CamelFolder *get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex);
-static void delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex);
-static void rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex);
-static CamelFolderInfo *create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex);
-static CamelFolderInfo *get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
+static CamelFolder *get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, GError **error);
+static gboolean delete_folder(CamelStore *store, const gchar *folder_name, GError **error);
+static gboolean rename_folder(CamelStore *store, const gchar *old, const gchar *new, GError **error);
+static CamelFolderInfo *create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, GError **error);
+static CamelFolderInfo *get_folder_info(CamelStore *store, const gchar *top, guint32 flags, 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);
@@ -116,12 +116,18 @@ ignore_file(const gchar *filename, gboolean sbd)
}
static CamelFolder *
-get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+get_folder (CamelStore *store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error)
{
+ CamelStoreClass *store_class;
struct stat st;
gchar *name;
- if (!((CamelStoreClass *) parent_class)->get_folder(store, folder_name, flags, ex))
+ /* Chain up to parent's get_folder() method. */
+ store_class = CAMEL_STORE_CLASS (parent_class);
+ if (!store_class->get_folder (store, folder_name, flags, error))
return NULL;
name = camel_local_store_get_full_path(store, folder_name);
@@ -132,17 +138,21 @@ get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelExce
gint fd;
if (errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_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) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder '%s': folder does not exist."),
- folder_name);
+ 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;
}
@@ -151,8 +161,10 @@ get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelExce
basename = g_path_get_basename (folder_name);
if (basename[0] == '.' || ignore_file (basename, TRUE)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create a folder by this name."));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot create a folder by this name."));
g_free (name);
g_free (basename);
return NULL;
@@ -161,9 +173,11 @@ get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelExce
dirname = g_path_get_dirname(name);
if (g_mkdir_with_parents(dirname, 0777) == -1 && errno != EEXIST) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot create folder '%s': %s"),
+ folder_name, g_strerror (errno));
g_free(dirname);
g_free(name);
return NULL;
@@ -173,9 +187,11 @@ get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelExce
fd = g_open(name, O_LARGEFILE | O_WRONLY | O_CREAT | O_APPEND | O_BINARY, 0666);
if (fd == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot create folder '%s': %s"),
+ folder_name, g_strerror (errno));
g_free(name);
return NULL;
}
@@ -183,28 +199,31 @@ get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelExce
g_free(name);
close(fd);
} else if (!S_ISREG(st.st_mode)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get folder '%s': not a regular file."),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot get folder '%s': not a regular file."),
+ folder_name);
g_free(name);
return NULL;
} else if (flags & CAMEL_STORE_FOLDER_EXCL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': folder exists."),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot create folder '%s': folder exists."),
+ folder_name);
g_free (name);
return NULL;
} else
g_free(name);
- return camel_mbox_folder_new(store, folder_name, flags, ex);
+ return camel_mbox_folder_new(store, folder_name, flags, error);
}
-static void
-delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+static gboolean
+delete_folder(CamelStore *store, const gchar *folder_name, GError **error)
{
CamelFolderInfo *fi;
- CamelException lex;
CamelFolder *lf;
gchar *name, *path;
struct stat st;
@@ -213,45 +232,55 @@ delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
path = g_strdup_printf("%s.sbd", name);
if (g_rmdir(path) == -1 && errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder '%s':\n%s"),
- folder_name, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder '%s':\n%s"),
+ folder_name, g_strerror (errno));
g_free(path);
g_free(name);
- return;
+ return FALSE;
}
g_free(path);
if (g_stat(name, &st) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder '%s':\n%s"),
- folder_name, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder '%s':\n%s"),
+ folder_name, g_strerror (errno));
g_free(name);
- return;
+ return FALSE;
}
if (!S_ISREG(st.st_mode)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("'%s' is not a regular file."), name);
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("'%s' is not a regular file."), name);
g_free(name);
- return;
+ return FALSE;
}
if (st.st_size != 0) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_NON_EMPTY,
- _("Folder '%s' is not empty. Not deleted."),
- folder_name);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_NON_EMPTY,
+ _("Folder '%s' is not empty. Not deleted."),
+ folder_name);
g_free(name);
- return;
+ return FALSE;
}
if (g_unlink(name) == -1 && errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder '%s':\n%s"),
- name, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder '%s':\n%s"),
+ name, g_strerror (errno));
g_free(name);
- return;
+ return FALSE;
}
/* FIXME: we have to do our own meta cleanup here rather than
@@ -261,61 +290,66 @@ delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
* paths itself */
path = camel_local_store_get_meta_path(store, folder_name, ".ev-summary");
if (g_unlink(path) == -1 && errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder summary file '%s': %s"),
- path, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder summary file '%s': %s"),
+ path, g_strerror(errno));
g_free(path);
g_free(name);
- return;
+ return FALSE;
}
g_free(path);
path = camel_local_store_get_meta_path(store, folder_name, ".ev-summary-meta");
if (g_unlink(path) == -1 && errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder summary file '%s': %s"),
- path, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder summary file '%s': %s"),
+ path, g_strerror (errno));
g_free(path);
g_free(name);
- return;
+ return FALSE;
}
g_free(path);
path = camel_local_store_get_meta_path(store, folder_name, ".ibex");
if (camel_text_index_remove(path) == -1 && errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder index file '%s': %s"),
- path, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder index file '%s': %s"),
+ path, g_strerror(errno));
g_free(path);
g_free(name);
- return;
+ return FALSE;
}
g_free(path);
path = NULL;
- camel_exception_init(&lex);
- if ((lf = camel_store_get_folder(store, folder_name, 0, &lex))) {
+ if ((lf = camel_store_get_folder(store, folder_name, 0, NULL))) {
camel_object_get(lf, NULL, CAMEL_OBJECT_STATE_FILE, &path, NULL);
camel_object_set(lf, NULL, CAMEL_OBJECT_STATE_FILE, NULL, NULL);
g_object_unref (lf);
- } else {
- camel_exception_clear(&lex);
}
if (path == NULL)
path = camel_local_store_get_meta_path(store, folder_name, ".cmeta");
if (g_unlink(path) == -1 && errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder meta file '%s': %s"),
- path, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder meta file '%s': %s"),
+ path, g_strerror (errno));
g_free(path);
g_free(name);
- return;
+ return FALSE;
}
g_free(path);
@@ -330,10 +364,12 @@ delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
camel_object_trigger_event(store, "folder_deleted", fi);
camel_folder_info_free(fi);
+
+ return TRUE;
}
static CamelFolderInfo *
-create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex)
+create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, 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? */
@@ -344,14 +380,19 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
struct stat st;
if (!g_path_is_absolute(toplevel_dir)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Store root %s is not an absolute path"), 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)) {
- camel_exception_set(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create a folder by this name."));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot create a folder by this name."));
return NULL;
}
@@ -364,8 +405,11 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
dir = g_path_get_dirname(path);
if (g_mkdir_with_parents(dir, 0777) == -1 && errno != EEXIST) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create directory '%s': %s."),
- dir, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot create directory '%s': %s."),
+ dir, g_strerror (errno));
g_free(path);
g_free(name);
@@ -377,10 +421,12 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
g_free(dir);
if (g_stat(path, &st) == 0 || errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot create folder: %s: %s"),
- path, errno ? g_strerror(errno) :
- _("Folder already exists"));
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Cannot create folder: %s: %s"),
+ path, errno ? g_strerror (errno) :
+ _("Folder already exists"));
g_free(path);
g_free(name);
@@ -390,10 +436,12 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
g_free(path);
- folder = CAMEL_STORE_GET_CLASS (store)->get_folder (store, name, CAMEL_STORE_FOLDER_CREATE, ex);
+ folder = CAMEL_STORE_GET_CLASS (store)->get_folder (
+ store, name, CAMEL_STORE_FOLDER_CREATE, error);
if (folder) {
g_object_unref (folder);
- info = CAMEL_STORE_GET_CLASS (store)->get_folder_info (store, name, 0, ex);
+ info = CAMEL_STORE_GET_CLASS (store)->get_folder_info (
+ store, name, 0, error);
}
g_free(name);
@@ -462,17 +510,19 @@ xrename(CamelStore *store, const gchar *old_name, const gchar *new_name, const g
return ret;
}
-static void
-rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+static gboolean
+rename_folder(CamelStore *store, const gchar *old, const gchar *new, GError **error)
{
CamelLocalFolder *folder = NULL;
gchar *oldibex, *newibex, *newdir;
gint errnosav;
if (new[0] == '.' || ignore_file(new, TRUE)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("The new folder name is illegal."));
- return;
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("The new folder name is illegal."));
+ return FALSE;
}
/* try to rollback failures, has obvious races */
@@ -483,14 +533,16 @@ rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelExcept
newdir = g_path_get_dirname(newibex);
if (g_mkdir_with_parents(newdir, 0777) == -1) {
if (errno != EEXIST) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not rename '%s': '%s': %s"),
- old, new, g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_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;
+ return FALSE;
}
g_free(newdir);
@@ -542,7 +594,7 @@ rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelExcept
if (folder)
g_object_unref (folder);
- return;
+ return TRUE;
base_failed:
xrename(store, new, old, ".sbd", TRUE);
@@ -564,15 +616,19 @@ ibex_failed:
g_free(newdir);
}
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not rename '%s' to %s: %s"),
- old, new, g_strerror(errnosav));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errnosav),
+ _("Could not rename '%s' to %s: %s"),
+ old, new, g_strerror (errnosav));
g_free(newibex);
g_free(oldibex);
if (folder)
g_object_unref (folder);
+
+ return FALSE;
}
/* used to find out where we've visited already */
@@ -641,7 +697,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
static CamelFolderInfo *
scan_dir(CamelStore *store, CamelURL *url, GHashTable *visited, CamelFolderInfo *parent, const gchar *root,
- const gchar *name, guint32 flags, CamelException *ex)
+ const gchar *name, guint32 flags, GError **error)
{
CamelFolderInfo *folders, *tail, *fi;
GHashTable *folder_hash;
@@ -741,7 +797,7 @@ scan_dir(CamelStore *store, CamelURL *url, GHashTable *visited, CamelFolderInfo
*inew = in;
g_hash_table_insert(visited, inew, inew);
#endif
- if ((fi->child = scan_dir (store, url, visited, fi, path, fi->full_name, flags, ex)))
+ 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;
@@ -759,7 +815,7 @@ scan_dir(CamelStore *store, CamelURL *url, GHashTable *visited, CamelFolderInfo
}
static CamelFolderInfo *
-get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+get_folder_info(CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
GHashTable *visited;
#ifndef G_OS_WIN32
@@ -790,7 +846,7 @@ get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelExcepti
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, ex);
+ 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);
@@ -823,7 +879,7 @@ get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelExcepti
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, ex);
+ fi->child = scan_dir (store, url, visited, fi, subdir, top, flags, error);
else
fill_fi(store, fi, flags);
} else
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index a6ec6ac..1ef6c1a 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -46,7 +46,7 @@
#define EXTRACT_DIGIT(val) part++; val=strtoul (part, &part, 10);
#define EXTRACT_FIRST_DIGIT(val) val=strtoul (part, &part, 10);
-static CamelFIRecord * summary_header_to_db (CamelFolderSummary *, CamelException *ex);
+static CamelFIRecord * summary_header_to_db (CamelFolderSummary *, GError **error);
static gint summary_header_from_db (CamelFolderSummary *, CamelFIRecord *);
static CamelMessageInfo * message_info_from_db(CamelFolderSummary *s, CamelMIRecord *record);
static CamelMIRecord * message_info_to_db(CamelFolderSummary *s, CamelMessageInfo *info);
@@ -63,14 +63,14 @@ static gint meta_message_info_save(CamelFolderSummary *s, FILE *out_meta, FIL
static gchar *mbox_summary_encode_x_evolution (CamelLocalSummary *cls, const CamelLocalMessageInfo *mi);
-static gint mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-static gint mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
+static gint mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, GError **error);
+static gint mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
#ifdef STATUS_PINE
-static CamelMessageInfo *mbox_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, CamelException *ex);
+static CamelMessageInfo *mbox_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, GError **error);
#endif
-static gint mbox_summary_sync_quick(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-static gint mbox_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
+static gint mbox_summary_sync_quick(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
+static gint mbox_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
#ifdef STATUS_PINE
/* Which status flags are stored in each separate header */
@@ -282,13 +282,17 @@ summary_header_load(CamelFolderSummary *s, FILE *in)
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s, GError **error)
{
+ CamelFolderSummaryClass *folder_summary_class;
CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(s);
struct _CamelFIRecord *fir;
gchar *tmp;
- fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, ex);
+ /* Chain up to parent's summary_header_to_db() method. */
+ folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (parent_class);
+ fir = folder_summary_class->summary_header_to_db (s, error);
+
if (fir) {
tmp = fir->bdata;
fir->bdata = g_strdup_printf ("%s %d %d", tmp ? tmp : "", CAMEL_MBOX_SUMMARY_VERSION, (gint) mbs->folder_size);
@@ -489,7 +493,7 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
/* like summary_rebuild, but also do changeinfo stuff (if supplied) */
static gint
-summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *changeinfo, GError **error)
{
gint i, count;
CamelFolderSummary *s = (CamelFolderSummary *)cls;
@@ -511,9 +515,11 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan
fd = g_open(cls->folder_path, O_LARGEFILE | O_RDONLY | O_BINARY, 0);
if (fd == -1) {
d(printf("%s failed to open: %s\n", cls->folder_path, g_strerror (errno)));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open folder: %s: %s"),
- cls->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not open folder: %s: %s"),
+ cls->folder_path, g_strerror (errno));
camel_operation_end(NULL);
return -1;
}
@@ -543,7 +549,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan
from the old end, so everything must be treated as new */
count = camel_folder_summary_count(s);
if (count != camel_folder_summary_cache_size(s)) /* It makes sense to load summary, if it isn't there. */
- camel_folder_summary_reload_from_db (s, ex);
+ camel_folder_summary_reload_from_db (s, NULL);
for (i=0;i<count;i++) {
mi = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i);
if (offset == 0)
@@ -562,8 +568,11 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan
info = camel_folder_summary_add_from_parser(s, mp);
if (info == NULL) {
- camel_exception_setv(ex, 1, _("Fatal mail parser error near position %ld in folder %s"),
- camel_mime_parser_tell(mp), cls->folder_path);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Fatal mail parser error near position %ld in folder %s"),
+ camel_mime_parser_tell(mp), cls->folder_path);
ok = -1;
break;
}
@@ -604,7 +613,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan
}
/* Delete all in one transaction */
- camel_db_delete_uids (s->folder->parent_store->cdb_w, s->folder->full_name, del, ex);
+ camel_db_delete_uids (s->folder->parent_store->cdb_w, s->folder->full_name, del, NULL);
g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
g_slist_free (del);
@@ -625,7 +634,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan
}
static gint
-mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, CamelException *ex)
+mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, GError **error)
{
CamelMboxSummary *mbs = (CamelMboxSummary *)cls;
CamelFolderSummary *s = (CamelFolderSummary *)cls;
@@ -638,9 +647,11 @@ mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Camel
/* check if the summary is up-to-date */
if (g_stat(cls->folder_path, &st) == -1) {
camel_folder_summary_clear(s);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot check folder: %s: %s"),
- cls->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot check folder: %s: %s"),
+ cls->folder_path, g_strerror (errno));
return -1;
}
@@ -668,10 +679,10 @@ mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Camel
if (mbs->folder_size < st.st_size) {
/* this will automatically rescan from 0 if there is a problem */
d(printf("folder grew, attempting to rebuild from %d\n", mbs->folder_size));
- ret = summary_update(cls, mbs->folder_size, changes, ex);
+ ret = summary_update(cls, mbs->folder_size, changes, error);
} else {
d(printf("folder shrank! rebuilding from start\n"));
- ret = summary_update(cls, 0, changes, ex);
+ ret = summary_update(cls, 0, changes, error);
}
} else {
d(printf("Folder unchanged, do nothing\n"));
@@ -693,7 +704,7 @@ mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Camel
/* perform a full sync */
static gint
-mbox_summary_sync_full(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+mbox_summary_sync_full(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error)
{
CamelLocalSummary *cls = (CamelLocalSummary *)mbs;
gint fd = -1, fdout = -1;
@@ -706,9 +717,11 @@ mbox_summary_sync_full(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChang
fd = g_open(cls->folder_path, O_LARGEFILE | O_RDONLY | O_BINARY, 0);
if (fd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open file: %s: %s"),
- cls->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not open file: %s: %s"),
+ cls->folder_path, g_strerror (errno));
camel_operation_end(NULL);
return -1;
}
@@ -718,31 +731,37 @@ mbox_summary_sync_full(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChang
d(printf("Writing temporary file to %s\n", tmpname));
fdout = g_open(tmpname, O_LARGEFILE|O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600);
if (fdout == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot open temporary mailbox: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot open temporary mailbox: %s"),
+ g_strerror (errno));
goto error;
}
- if (camel_mbox_summary_sync_mbox((CamelMboxSummary *)cls, flags, changeinfo, fd, fdout, ex) == -1)
+ if (camel_mbox_summary_sync_mbox((CamelMboxSummary *)cls, flags, changeinfo, fd, fdout, error) == -1)
goto error;
d(printf("Closing folders\n"));
if (close(fd) == -1) {
g_warning("Cannot close source folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not close source folder %s: %s"),
- cls->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not close source folder %s: %s"),
+ cls->folder_path, g_strerror (errno));
fd = -1;
goto error;
}
if (close(fdout) == -1) {
g_warning("Cannot close temporary folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not close temporary folder: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not close temporary folder: %s"),
+ g_strerror (errno));
fdout = -1;
goto error;
}
@@ -755,9 +774,11 @@ mbox_summary_sync_full(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChang
#endif
if (g_rename(tmpname, cls->folder_path) == -1) {
g_warning("Cannot rename folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not rename folder: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not rename folder: %s"),
+ g_strerror (errno));
goto error;
}
tmpname = NULL;
@@ -806,7 +827,7 @@ cms_sort_frompos (gpointer a, gpointer b, gpointer data)
/* perform a quick sync - only system flags have changed */
static gint
-mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error)
{
CamelLocalSummary *cls = (CamelLocalSummary *)mbs;
CamelFolderSummary *s = (CamelFolderSummary *)mbs;
@@ -826,9 +847,11 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan
fd = g_open(cls->folder_path, O_LARGEFILE|O_RDWR|O_BINARY, 0);
if (fd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open file: %s: %s"),
- cls->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not open file: %s: %s"),
+ cls->folder_path, g_strerror (errno));
camel_operation_end(NULL);
return -1;
@@ -837,9 +860,11 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan
/* need to dup since mime parser closes its fd once it is finalized */
pfd = dup(fd);
if (pfd == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not store folder: %s"),
- g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not store folder: %s"),
+ g_strerror (errno));
close(fd);
return -1;
}
@@ -876,16 +901,20 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan
if (camel_mime_parser_step(mp, NULL, NULL) != CAMEL_MIME_PARSER_STATE_FROM) {
g_warning("Expected a From line here, didn't get it");
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Summary and folder mismatch, even after a sync"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Summary and folder mismatch, even after a sync"));
goto error;
}
if (camel_mime_parser_tell_start_from(mp) != info->frompos) {
g_warning("Didn't get the next message where I expected (%d) got %d instead",
(gint)info->frompos, (gint)camel_mime_parser_tell_start_from(mp));
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Summary and folder mismatch, even after a sync"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Summary and folder mismatch, even after a sync"));
goto error;
}
@@ -935,9 +964,11 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan
if (close(fd) == -1) {
g_warning ("Cannot close source folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not close source folder %s: %s"),
- cls->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not close source folder %s: %s"),
+ cls->folder_path, g_strerror (errno));
fd = -1;
goto error;
}
@@ -965,7 +996,7 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan
}
static gint
-mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error)
{
struct stat st;
CamelMboxSummary *mbs = (CamelMboxSummary *)cls;
@@ -976,7 +1007,7 @@ mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInf
GPtrArray *summary = NULL;
/* first, sync ourselves up, just to make sure */
- if (camel_local_summary_check(cls, changeinfo, ex) == -1)
+ if (camel_local_summary_check(cls, changeinfo, error) == -1)
return -1;
/* Sync only the changes */
@@ -999,7 +1030,7 @@ mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInf
if (quick && expunge) {
guint32 dcount =0;
- if (camel_db_count_deleted_message_info (s->folder->parent_store->cdb_w, s->folder->full_name, &dcount, ex) == -1)
+ if (camel_db_count_deleted_message_info (s->folder->parent_store->cdb_w, s->folder->full_name, &dcount, error) == -1)
return -1;
if (dcount)
quick = FALSE;
@@ -1009,10 +1040,10 @@ mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInf
ret = -1;
if (quick) {
if (work) {
- ret = CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_quick (mbs, expunge, changeinfo, ex);
+ ret = CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_quick (mbs, expunge, changeinfo, error);
if (ret == -1) {
g_warning("failed a quick-sync, trying a full sync");
- camel_exception_clear(ex);
+ g_clear_error (error);
}
} else {
ret = 0;
@@ -1020,13 +1051,15 @@ mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInf
}
if (ret == -1)
- ret = CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_full (mbs, expunge, changeinfo, ex);
+ ret = CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_full (mbs, expunge, changeinfo, error);
if (ret == -1)
return -1;
if (g_stat(cls->folder_path, &st) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unknown error: %s"), g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Unknown error: %s"), g_strerror (errno));
return -1;
}
@@ -1036,11 +1069,11 @@ mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInf
camel_folder_summary_touch(s);
}
- return CAMEL_LOCAL_SUMMARY_CLASS (parent_class)->sync(cls, expunge, changeinfo, ex);
+ return CAMEL_LOCAL_SUMMARY_CLASS (parent_class)->sync(cls, expunge, changeinfo, error);
}
gint
-camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderChangeInfo *changeinfo, gint fd, gint fdout, CamelException *ex)
+camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderChangeInfo *changeinfo, gint fd, gint fdout, GError **error)
{
CamelMboxSummary *mbs = (CamelMboxSummary *)cls;
CamelFolderSummary *s = (CamelFolderSummary *)mbs;
@@ -1062,9 +1095,11 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
/* need to dup this because the mime-parser owns the fd after we give it to it */
fd = dup(fd);
if (fd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not store folder: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not store folder: %s"),
+ g_strerror (errno));
return -1;
}
@@ -1092,16 +1127,20 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
if (camel_mime_parser_step(mp, &buffer, &len) != CAMEL_MIME_PARSER_STATE_FROM) {
g_warning("Expected a From line here, didn't get it %d", (gint)camel_mime_parser_tell(mp));
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Summary and folder mismatch, even after a sync"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Summary and folder mismatch, even after a sync"));
goto error;
}
if (camel_mime_parser_tell_start_from(mp) != info->frompos) {
g_warning("Didn't get the next message where I expected (%d) got %d instead",
(gint)info->frompos, (gint)camel_mime_parser_tell_start_from(mp));
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Summary and folder mismatch, even after a sync"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Summary and folder mismatch, even after a sync"));
goto error;
}
@@ -1168,9 +1207,11 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
#endif
if (len == -1) {
d(printf("Error writing to temporary mailbox\n"));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Writing to temporary mailbox failed: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Writing to temporary mailbox failed: %s"),
+ g_strerror (errno));
goto error;
}
info->info.info.flags &= 0xffff;
@@ -1185,18 +1226,22 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
while (camel_mime_parser_step(mp, &buffer, &len) == CAMEL_MIME_PARSER_STATE_PRE_FROM) {
/*d(printf("copying mbox contents to temporary: '%.*s'\n", len, buffer));*/
if (write(fdout, buffer, len) != len) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Writing to temporary mailbox failed: %s: %s"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Writing to temporary mailbox failed: %s: %s"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno));
goto error;
}
}
if (write(fdout, "\n", 1) != 1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Writing to temporary mailbox failed: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Writing to temporary mailbox failed: %s"),
+ g_strerror (errno));
goto error;
}
@@ -1207,7 +1252,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
info = NULL;
}
}
- camel_db_delete_uids (s->folder->parent_store->cdb_w, s->folder->full_name, del, ex);
+ camel_db_delete_uids (s->folder->parent_store->cdb_w, s->folder->full_name, del, NULL);
g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
g_slist_free (del);
@@ -1235,7 +1280,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
}
if (touched)
- camel_folder_summary_header_save_to_db (s, ex);
+ camel_folder_summary_header_save_to_db (s, NULL);
return 0;
error:
@@ -1251,11 +1296,15 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
#ifdef STATUS_PINE
static CamelMessageInfo *
-mbox_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, CamelException *ex)
+mbox_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, GError **error)
{
+ CamelLocalSummaryClass *local_summary_class;
CamelMboxMessageInfo *mi;
- mi = (CamelMboxMessageInfo *)CAMEL_LOCAL_SUMMARY_CLASS (parent_class)->add(cls, msg, info, ci, ex);
+ /* Chain up to parent's add() method. */
+ local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (parent_class);
+ mi = (CamelMboxMessageInfo *) local_summary_class->add (
+ cls, msg, info, ci, error);
if (mi && ((CamelMboxSummary *)cls)->xstatus) {
gchar status[8];
diff --git a/camel/providers/local/camel-mbox-summary.h b/camel/providers/local/camel-mbox-summary.h
index 5b4f95c..d917b39 100644
--- a/camel/providers/local/camel-mbox-summary.h
+++ b/camel/providers/local/camel-mbox-summary.h
@@ -75,9 +75,9 @@ struct _CamelMboxSummaryClass {
CamelLocalSummaryClass parent_class;
/* sync in-place */
- gint (*sync_quick)(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
+ gint (*sync_quick)(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
/* sync requires copy */
- gint (*sync_full)(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
+ gint (*sync_full)(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
};
GType camel_mbox_summary_get_type (void);
@@ -87,7 +87,7 @@ CamelMboxSummary *camel_mbox_summary_new (struct _CamelFolder *, const gcha
void camel_mbox_summary_xstatus(CamelMboxSummary *mbs, gint state);
/* build a new mbox from an existing mbox storing summary information */
-gint camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderChangeInfo *changeinfo, gint fd, gint fdout, CamelException *ex);
+gint camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderChangeInfo *changeinfo, gint fd, gint fdout, GError **error);
G_END_DECLS
diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c
index 361f596..5129d8d 100644
--- a/camel/providers/local/camel-mh-folder.c
+++ b/camel/providers/local/camel-mh-folder.c
@@ -43,9 +43,9 @@ static gpointer parent_class;
static CamelLocalSummary *mh_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index);
-static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, gchar **appended_uid, CamelException * ex);
-static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex);
-static gchar * mh_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static gboolean mh_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, gchar **appended_uid, GError **error);
+static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, GError **error);
+static gchar * mh_get_filename (CamelFolder *folder, const gchar *uid, GError **error);
static void
mh_folder_class_init (CamelObjectClass *class)
@@ -83,26 +83,39 @@ camel_mh_folder_get_type (void)
}
CamelFolder *
-camel_mh_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex)
+camel_mh_folder_new (CamelStore *parent_store,
+ const gchar *full_name,
+ guint32 flags,
+ GError **error)
{
CamelFolder *folder;
d(printf("Creating mh folder: %s\n", full_name));
folder = g_object_new (CAMEL_TYPE_MH_FOLDER, NULL);
- folder = (CamelFolder *)camel_local_folder_construct((CamelLocalFolder *)folder,
- parent_store, full_name, flags, ex);
+ folder = (CamelFolder *) camel_local_folder_construct (
+ CAMEL_LOCAL_FOLDER (folder),
+ parent_store, full_name, flags, error);
return folder;
}
-static CamelLocalSummary *mh_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index)
+static CamelLocalSummary *
+mh_create_summary (CamelLocalFolder *lf,
+ const gchar *path,
+ const gchar *folder,
+ CamelIndex *index)
{
- return (CamelLocalSummary *)camel_mh_summary_new((CamelFolder *)lf, path, folder, index);
+ return (CamelLocalSummary *) camel_mh_summary_new (
+ CAMEL_FOLDER (lf), path, folder, index);
}
-static void
-mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
+static gboolean
+mh_append_message (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *output_stream;
@@ -114,12 +127,12 @@ mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMe
d(printf("Appending message\n"));
/* If we can't lock, don't do anything */
- if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
- return;
+ if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1)
+ return FALSE;
/* add it to the summary/assign the uid, etc */
- mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
- if (camel_exception_is_set (ex))
+ mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, error);
+ if (mi == NULL)
goto check_changed;
if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
@@ -154,12 +167,16 @@ mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMe
camel_message_info_uid (mi));
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("MH append message canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("MH append message canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to mh folder: %s: %s"),
- name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot append message to mh folder: %s: %s"),
+ name, g_strerror (errno));
if (output_stream) {
g_object_unref (CAMEL_OBJECT (output_stream));
@@ -175,16 +192,24 @@ mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMe
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", lf->changes);
camel_folder_change_info_clear (lf->changes);
}
+
+ return TRUE;
}
-static gchar * mh_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+static gchar *
+mh_get_filename (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
return g_strdup_printf("%s/%s", lf->folder_path, uid);
}
-static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)
+static CamelMimeMessage *
+mh_get_message (CamelFolder *folder,
+ const gchar *uid,
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *message_stream = NULL;
@@ -194,14 +219,16 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid,
d(printf("getting message: %s\n", uid));
- if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
+ if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1)
return NULL;
/* get the message summary info */
if ((info = camel_folder_summary_uid(folder->summary, uid)) == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message: %s from folder %s\n %s"), uid, lf->folder_path,
- _("No such message"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message: %s from folder %s\n %s"),
+ uid, lf->folder_path, _("No such message"));
goto fail;
}
@@ -210,17 +237,22 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid,
name = g_strdup_printf("%s/%s", lf->folder_path, uid);
if ((message_stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0)) == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message: %s from folder %s\n %s"), name, lf->folder_path,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get message: %s from folder %s\n %s"),
+ name, lf->folder_path, g_strerror (errno));
goto fail;
}
message = camel_mime_message_new();
if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message: %s from folder %s\n %s"), name, lf->folder_path,
- _("Message construction failed."));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot get message: %s from folder %s\n %s"),
+ name, lf->folder_path,
+ _("Message construction failed."));
g_object_unref (message);
message = NULL;
diff --git a/camel/providers/local/camel-mh-folder.h b/camel/providers/local/camel-mh-folder.h
index 9857a3e..264f36c 100644
--- a/camel/providers/local/camel-mh-folder.h
+++ b/camel/providers/local/camel-mh-folder.h
@@ -57,7 +57,7 @@ struct _CamelMhFolderClass {
};
/* public methods */
-CamelFolder *camel_mh_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex);
+CamelFolder *camel_mh_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, GError **error);
GType camel_mh_folder_get_type(void);
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index 5741ac2..f0d16dc 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -39,12 +39,12 @@ static gpointer parent_class;
#define d(x)
-static void construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex);
-static CamelFolder *get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelException * ex);
-static CamelFolder *get_inbox (CamelStore *store, CamelException *ex);
-static void delete_folder(CamelStore * store, const gchar *folder_name, CamelException * ex);
-static void rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex);
-static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
+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, GError **error);
+static CamelFolder *get_inbox (CamelStore *store, GError **error);
+static gboolean delete_folder(CamelStore * store, const gchar *folder_name, GError **error);
+static gboolean rename_folder(CamelStore *store, const gchar *old, const gchar *new, GError **error);
+static CamelFolderInfo * get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error);
static void
mh_store_class_init (CamelObjectClass *class)
@@ -83,17 +83,25 @@ camel_mh_store_get_type (void)
return type;
}
-static void
-construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+static gboolean
+construct (CamelService *service,
+ CamelSession *session,
+ CamelProvider *provider,
+ CamelURL *url,
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelMhStore *mh_store = (CamelMhStore *)service;
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ /* Chain up to parent's construct() method. */
+ service_class = CAMEL_SERVICE_CLASS (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 {
@@ -105,7 +113,10 @@ enum {
/* update the .folders file if it exists, or create it if it doesn't */
static void
-folders_update(const gchar *root, gint mode, const gchar *folder, const gchar *new)
+folders_update (const gchar *root,
+ gint mode,
+ const gchar *folder,
+ const gchar *new)
{
gchar *tmp, *tmpnew, *line = NULL;
CamelStream *stream, *in = NULL, *out = NULL;
@@ -193,36 +204,48 @@ fail:
}
static CamelFolder *
-get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelException * ex)
+get_folder (CamelStore *store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error)
{
+ CamelStoreClass *store_class;
gchar *name;
struct stat st;
- if (!((CamelStoreClass *)parent_class)->get_folder(store, folder_name, flags, ex))
+ /* Chain up to parent's get_folder() method. */
+ store_class = CAMEL_STORE_CLASS (parent_class);
+ if (store_class->get_folder (store, folder_name, flags, error) == NULL)
return NULL;
name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
if (stat(name, &st) == -1) {
if (errno != ENOENT) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_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) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder '%s': folder does not exist."),
- folder_name);
+ 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) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not create folder '%s': %s"),
+ folder_name, g_strerror (errno));
g_free (name);
return NULL;
}
@@ -232,40 +255,53 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS)
folders_update(((CamelLocalStore *)store)->toplevel_dir, UPDATE_ADD, folder_name, NULL);
} else if (!S_ISDIR(st.st_mode)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder '%s': not a directory."), folder_name);
+ 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) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder '%s': folder exists."), folder_name);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("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, ex);
+ return camel_mh_folder_new(store, folder_name, flags, error);
}
static CamelFolder *
-get_inbox (CamelStore *store, CamelException *ex)
+get_inbox (CamelStore *store,
+ GError **error)
{
- return get_folder (store, "inbox", 0, ex);
+ return get_folder (store, "inbox", 0, error);
}
-static void delete_folder(CamelStore * store, const gchar *folder_name, CamelException * ex)
+static gboolean
+delete_folder (CamelStore *store,
+ const gchar *folder_name,
+ 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) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not delete folder '%s': %s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not delete folder '%s': %s"),
+ folder_name, g_strerror (errno));
g_free(name);
- return;
+ return FALSE;
}
g_free(name);
@@ -273,31 +309,36 @@ static void delete_folder(CamelStore * store, const gchar *folder_name, CamelExc
if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS)
folders_update(((CamelLocalStore *)store)->toplevel_dir, UPDATE_REMOVE, folder_name, NULL);
- /* and remove metadata */
- ((CamelStoreClass *)parent_class)->delete_folder(store, folder_name, ex);
+ /* Chain up to parent's delete_folder() method. */
+ store_class = CAMEL_STORE_CLASS (parent_class);
+ return store_class->delete_folder (store, folder_name, error);
}
-static void
-rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+static gboolean
+rename_folder (CamelStore *store,
+ const gchar *old,
+ const gchar *new,
+ GError **error)
{
- CamelException e;
+ CamelStoreClass *store_class;
- camel_exception_init(&e);
- ((CamelStoreClass *)parent_class)->rename_folder(store, old, new, &e);
- if (camel_exception_is_set(&e)) {
- camel_exception_xfer(ex, &e);
- return;
- }
- camel_exception_clear(&e);
+ /* Chain up to parent's rename_folder() method. */
+ store_class = CAMEL_STORE_CLASS (parent_class);
+ if (!store_class->rename_folder (store, old, new, 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);
}
+
+ return TRUE;
}
static void
-fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
+fill_fi (CamelStore *store,
+ CamelFolderInfo *fi,
+ guint32 flags)
{
CamelFolder *folder;
@@ -339,7 +380,11 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
}
static CamelFolderInfo *
-folder_info_new (CamelStore *store, CamelURL *url, const gchar *root, const gchar *path, guint32 flags)
+folder_info_new (CamelStore *store,
+ CamelURL *url,
+ const gchar *root,
+ const gchar *path,
+ guint32 flags)
{
/* FIXME: need to set fi->flags = CAMEL_FOLDER_NOSELECT (and possibly others) when appropriate */
CamelFolderInfo *fi;
@@ -370,8 +415,14 @@ struct _inode {
/* Scan path, under root, for directories to add folders for. Both
* root and path should have a trailing "/" if they aren't empty. */
static void
-recursive_scan (CamelStore *store, CamelURL *url, CamelFolderInfo **fip, CamelFolderInfo *parent,
- GHashTable *visited, const gchar *root, const gchar *path, guint32 flags)
+recursive_scan (CamelStore *store,
+ CamelURL *url,
+ CamelFolderInfo **fip,
+ CamelFolderInfo *parent,
+ GHashTable *visited,
+ const gchar *root,
+ const gchar *path,
+ guint32 flags)
{
gchar *fullpath, *tmp;
DIR *dp;
@@ -441,7 +492,12 @@ recursive_scan (CamelStore *store, CamelURL *url, CamelFolderInfo **fip, CamelFo
/* scan a .folders file */
static void
-folders_scan(CamelStore *store, CamelURL *url, const gchar *root, const gchar *top, CamelFolderInfo **fip, guint32 flags)
+folders_scan (CamelStore *store,
+ CamelURL *url,
+ const gchar *root,
+ const gchar *top,
+ CamelFolderInfo **fip,
+ guint32 flags)
{
CamelFolderInfo *fi;
gchar line[512], *path, *tmp;
@@ -522,27 +578,33 @@ folders_scan(CamelStore *store, CamelURL *url, const gchar *root, const gchar *t
}
/* FIXME: move to camel-local, this is shared with maildir code */
-static guint inode_hash(gconstpointer d)
+static guint
+inode_hash (gconstpointer d)
{
const struct _inode *v = d;
return v->inode ^ v->dnode;
}
-static gboolean inode_equal(gconstpointer a, gconstpointer b)
+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)
+static void
+inode_free (gpointer k, gpointer v, gpointer d)
{
g_free(k);
}
static CamelFolderInfo *
-get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+get_folder_info (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
CamelFolderInfo *fi = NULL;
CamelURL *url;
diff --git a/camel/providers/local/camel-mh-summary.c b/camel/providers/local/camel-mh-summary.c
index a8f4f97..4000765 100644
--- a/camel/providers/local/camel-mh-summary.c
+++ b/camel/providers/local/camel-mh-summary.c
@@ -47,9 +47,9 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), CAMEL_TYPE_MH_SUMMARY, CamelMhSummaryPrivate))
-static gint mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-static gint mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
-/*static gint mh_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);*/
+static gint mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, GError **error);
+static gint mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
+/*static gint mh_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, CamelMessageInfo *info, CamelFolderChangeInfo *, GError **error);*/
static gchar *mh_summary_next_uid_string(CamelFolderSummary *s);
@@ -66,6 +66,7 @@ mh_summary_class_init (CamelMhSummaryClass *class)
CamelLocalSummaryClass *local_summary_class;
parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (CamelMhSummaryPrivate));
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
folder_summary_class->next_uid_string = mh_summary_next_uid_string;
@@ -114,7 +115,11 @@ camel_mh_summary_get_type (void)
*
* Return value: A new #CamelMhSummary object.
**/
-CamelMhSummary *camel_mh_summary_new(struct _CamelFolder *folder, const gchar *filename, const gchar *mhdir, CamelIndex *index)
+CamelMhSummary *
+camel_mh_summary_new (CamelFolder *folder,
+ const gchar *filename,
+ const gchar *mhdir,
+ CamelIndex *index)
{
CamelMhSummary *o;
@@ -130,7 +135,8 @@ CamelMhSummary *camel_mh_summary_new(struct _CamelFolder *folder, const gchar *f
return o;
}
-static gchar *mh_summary_next_uid_string(CamelFolderSummary *s)
+static gchar *
+mh_summary_next_uid_string (CamelFolderSummary *s)
{
CamelMhSummary *mhs = (CamelMhSummary *)s;
CamelLocalSummary *cls = (CamelLocalSummary *)s;
@@ -165,7 +171,10 @@ static gchar *mh_summary_next_uid_string(CamelFolderSummary *s)
return uidstr;
}
-static gint camel_mh_summary_add(CamelLocalSummary *cls, const gchar *name, gint forceindex)
+static gint
+camel_mh_summary_add (CamelLocalSummary *cls,
+ const gchar *name,
+ gint forceindex)
{
CamelMhSummary *mhs = (CamelMhSummary *)cls;
gchar *filename = g_strdup_printf("%s/%s", cls->folder_path, name);
@@ -199,7 +208,9 @@ static gint camel_mh_summary_add(CamelLocalSummary *cls, const gchar *name, gint
}
static void
-remove_summary(gchar *key, CamelMessageInfo *info, CamelLocalSummary *cls)
+remove_summary (gchar *key,
+ CamelMessageInfo *info,
+ CamelLocalSummary *cls)
{
d(printf("removing message %s from summary\n", key));
if (cls->index)
@@ -209,7 +220,9 @@ remove_summary(gchar *key, CamelMessageInfo *info, CamelLocalSummary *cls)
}
static gint
-mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+mh_summary_check (CamelLocalSummary *cls,
+ CamelFolderChangeInfo *changeinfo,
+ GError **error)
{
DIR *dir;
struct dirent *d;
@@ -228,9 +241,11 @@ mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, Came
no longer exist */
dir = opendir(cls->folder_path);
if (dir == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot open MH directory path: %s: %s"),
- cls->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot open MH directory path: %s: %s"),
+ cls->folder_path, g_strerror (errno));
return -1;
}
@@ -287,8 +302,12 @@ mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, Came
/* sync the summary file with the ondisk files */
static gint
-mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changes, CamelException *ex)
+mh_summary_sync (CamelLocalSummary *cls,
+ gboolean expunge,
+ CamelFolderChangeInfo *changes,
+ GError **error)
{
+ CamelLocalSummaryClass *local_summary_class;
gint count, i;
CamelLocalMessageInfo *info;
gchar *name;
@@ -298,7 +317,7 @@ mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo
/* we could probably get away without this ... but why not use it, esp if we're going to
be doing any significant io already */
- if (camel_local_summary_check(cls, changes, ex) == -1)
+ if (camel_local_summary_check(cls, changes, error) == -1)
return -1;
/* FIXME: need to update/honour .mh_sequences or whatever it is */
@@ -327,5 +346,7 @@ mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo
camel_message_info_free(info);
}
- return ((CamelLocalSummaryClass *)parent_class)->sync(cls, expunge, changes, ex);
+ /* Chain up to parent's sync() method. */
+ local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (parent_class);
+ return local_summary_class->sync (cls, expunge, changes, error);
}
diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c
index 2e11f92..210e35c 100644
--- a/camel/providers/local/camel-spool-folder.c
+++ b/camel/providers/local/camel-spool-folder.c
@@ -44,7 +44,7 @@ static gpointer parent_class;
static CamelLocalSummary *spool_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index);
-static gint spool_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
+static gint spool_lock(CamelLocalFolder *lf, CamelLockType type, GError **error);
static void spool_unlock(CamelLocalFolder *lf);
static void
@@ -85,7 +85,10 @@ camel_spool_folder_get_type (void)
}
CamelFolder *
-camel_spool_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex)
+camel_spool_folder_new (CamelStore *parent_store,
+ const gchar *full_name,
+ guint32 flags,
+ GError **error)
{
CamelFolder *folder;
@@ -98,7 +101,7 @@ camel_spool_folder_new(CamelStore *parent_store, const gchar *full_name, guint32
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
flags &= ~CAMEL_STORE_FOLDER_BODY_INDEX;
- folder = (CamelFolder *)camel_local_folder_construct((CamelLocalFolder *)folder, parent_store, full_name, flags, ex);
+ folder = (CamelFolder *)camel_local_folder_construct((CamelLocalFolder *)folder, parent_store, full_name, flags, error);
if (folder) {
if (camel_url_get_param(((CamelService *)parent_store)->url, "xstatus"))
camel_mbox_summary_xstatus((CamelMboxSummary *)folder->summary, TRUE);
@@ -108,13 +111,19 @@ camel_spool_folder_new(CamelStore *parent_store, const gchar *full_name, guint32
}
static CamelLocalSummary *
-spool_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index)
+spool_create_summary (CamelLocalFolder *lf,
+ const gchar *path,
+ const gchar *folder,
+ CamelIndex *index)
{
- return (CamelLocalSummary *)camel_spool_summary_new((CamelFolder *)lf, folder);
+ return (CamelLocalSummary *) camel_spool_summary_new (
+ CAMEL_FOLDER (lf), folder);
}
static gint
-spool_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
+spool_lock (CamelLocalFolder *lf,
+ CamelLockType type,
+ GError **error)
{
gint retry = 0;
CamelMboxFolder *mf = (CamelMboxFolder *)lf;
@@ -122,9 +131,11 @@ spool_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
mf->lockfd = open(lf->folder_path, O_RDWR|O_LARGEFILE, 0);
if (mf->lockfd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot create folder lock on %s: %s"),
- lf->folder_path, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot create folder lock on %s: %s"),
+ lf->folder_path, g_strerror (errno));
return -1;
}
@@ -132,11 +143,11 @@ spool_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
if (retry > 0)
sleep(CAMEL_LOCK_DELAY);
- camel_exception_clear(ex);
+ g_clear_error (error);
- if (camel_lock_fcntl(mf->lockfd, type, ex) == 0) {
- if (camel_lock_flock(mf->lockfd, type, ex) == 0) {
- if ((sf->lockid = camel_lock_helper_lock(lf->folder_path, ex)) != -1)
+ if (camel_lock_fcntl(mf->lockfd, type, error) == 0) {
+ if (camel_lock_flock(mf->lockfd, type, error) == 0) {
+ if ((sf->lockid = camel_lock_helper_lock(lf->folder_path, error)) != -1)
return 0;
camel_unlock_flock(mf->lockfd);
}
@@ -152,7 +163,7 @@ spool_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
}
static void
-spool_unlock(CamelLocalFolder *lf)
+spool_unlock (CamelLocalFolder *lf)
{
CamelMboxFolder *mf = (CamelMboxFolder *)lf;
CamelSpoolFolder *sf = (CamelSpoolFolder *)lf;
diff --git a/camel/providers/local/camel-spool-folder.h b/camel/providers/local/camel-spool-folder.h
index 1e7d2a4..ec237f8 100644
--- a/camel/providers/local/camel-spool-folder.h
+++ b/camel/providers/local/camel-spool-folder.h
@@ -65,7 +65,7 @@ struct _CamelSpoolFolderClass {
GType camel_spool_folder_get_type(void);
-CamelFolder *camel_spool_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, CamelException *ex);
+CamelFolder *camel_spool_folder_new(CamelStore *parent_store, const gchar *full_name, guint32 flags, GError **error);
G_END_DECLS
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index 04a8806..29f43d2 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -45,15 +45,15 @@
#define d(x)
-static void construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex);
-static CamelFolder *get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelException * ex);
+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, GError **error);
static gchar *get_name(CamelService *service, gboolean brief);
-static CamelFolder *get_inbox (CamelStore *store, CamelException *ex);
-static void rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_name, CamelException *ex);
-static CamelFolderInfo *get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
+static CamelFolder *get_inbox (CamelStore *store, GError **error);
+static gboolean rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_name, GError **error);
+static CamelFolderInfo *get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error);
static void free_folder_info (CamelStore *store, CamelFolderInfo *fi);
-static void delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex);
+static gboolean delete_folder(CamelStore *store, const gchar *folder_name, 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);
@@ -104,29 +104,40 @@ camel_spool_store_get_type (void)
return type;
}
-static void
-construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+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));
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ /* Chain up to parent's construct() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
if (service->url->path[0] != '/') {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Store root %s is not an absolute path"), service->url->path);
- return;
+ 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 (stat(service->url->path, &st) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Spool '%s' cannot be opened: %s"),
- service->url->path, g_strerror (errno));
- return;
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Spool '%s' cannot be opened: %s"),
+ service->url->path, g_strerror (errno));
+ return FALSE;
}
if (S_ISREG(st.st_mode))
@@ -135,15 +146,22 @@ construct (CamelService *service, CamelSession *session, CamelProvider *provider
/* we could check here for slight variations */
((CamelSpoolStore *)service)->type = CAMEL_SPOOL_STORE_ELM;
else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Spool '%s' is not a regular file or directory"),
- service->url->path);
- return;
+ 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, CamelException * ex)
+get_folder (CamelStore *store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error)
{
CamelFolder *folder = NULL;
struct stat st;
@@ -154,37 +172,47 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
/* we only support an 'INBOX' in mbox mode */
if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX) {
if (strcmp(folder_name, "INBOX") != 0) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Folder '%s/%s' does not exist."),
- ((CamelService *)store)->url->path, folder_name);
+ 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, ex);
+ folder = camel_spool_folder_new(store, folder_name, flags, error);
}
} else {
name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
if (stat(name, &st) == -1) {
if (errno != ENOENT) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open folder '%s':\n%s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not open folder '%s':\n%s"),
+ folder_name, g_strerror (errno));
} else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Folder '%s' does not exist."),
- folder_name);
+ 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) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create folder '%s':\n%s"),
- folder_name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_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, ex);
+ folder = camel_spool_folder_new(store, folder_name, flags, error);
}
}
} else if (!S_ISREG(st.st_mode)) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("'%s' is not a mailbox file."), name);
+ 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, ex);
+ folder = camel_spool_folder_new(store, folder_name, flags, error);
}
g_free(name);
}
@@ -193,19 +221,23 @@ get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelExc
}
static CamelFolder *
-get_inbox(CamelStore *store, CamelException *ex)
+get_inbox (CamelStore *store,
+ GError **error)
{
if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX)
- return get_folder (store, "INBOX", CAMEL_STORE_FOLDER_CREATE, ex);
+ return get_folder (store, "INBOX", CAMEL_STORE_FOLDER_CREATE, error);
else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Store does not support an INBOX"));
+ 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)
+get_name (CamelService *service,
+ gboolean brief)
{
if (brief)
return g_strdup(service->url->path);
@@ -215,22 +247,35 @@ get_name (CamelService *service, gboolean brief)
}
/* default implementation, rename all */
-static void
-rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+static gboolean
+rename_folder (CamelStore *store,
+ const gchar *old,
+ const gchar *new,
+ GError **error)
{
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Spool folders cannot be renamed"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Spool folders cannot be renamed"));
+
+ return FALSE;
}
/* default implementation, only delete metadata */
-static void
-delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+static gboolean
+delete_folder (CamelStore *store,
+ const gchar *folder_name,
+ GError **error)
{
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Spool folders cannot be deleted"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Spool folders cannot be deleted"));
+
+ return FALSE;
}
-static void free_folder_info (CamelStore *store, CamelFolderInfo *fi)
+static void
+free_folder_info (CamelStore *store,
+ CamelFolderInfo *fi)
{
if (fi) {
g_free(fi->uri);
@@ -242,7 +287,9 @@ static void free_folder_info (CamelStore *store, CamelFolderInfo *fi)
/* partially copied from mbox */
static void
-spool_fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
+spool_fill_fi (CamelStore *store,
+ CamelFolderInfo *fi,
+ guint32 flags)
{
CamelFolder *folder;
@@ -259,7 +306,11 @@ spool_fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
}
static CamelFolderInfo *
-spool_new_fi(CamelStore *store, CamelFolderInfo *parent, CamelFolderInfo **fip, const gchar *full, guint32 flags)
+spool_new_fi (CamelStore *store,
+ CamelFolderInfo *parent,
+ CamelFolderInfo **fip,
+ const gchar *full,
+ guint32 flags)
{
CamelFolderInfo *fi;
const gchar *name;
@@ -298,7 +349,15 @@ struct _inode {
};
/* returns number of records found at or below this level */
-static gint scan_dir(CamelStore *store, GHashTable *visited, gchar *root, const gchar *path, guint32 flags, CamelFolderInfo *parent, CamelFolderInfo **fip, CamelException *ex)
+static gint
+scan_dir (CamelStore *store,
+ GHashTable *visited,
+ gchar *root,
+ const gchar *path,
+ guint32 flags,
+ CamelFolderInfo *parent,
+ CamelFolderInfo **fip,
+ GError **error)
{
DIR *dir;
struct dirent *d;
@@ -319,9 +378,11 @@ static gint scan_dir(CamelStore *store, GHashTable *visited, gchar *root, const
name = root;
if (stat(name, &st) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not scan folder '%s': %s"),
- name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not scan folder '%s': %s"),
+ name, g_strerror (errno));
} else if (S_ISREG(st.st_mode)) {
/* incase we start scanning from a file. messy duplication :-/ */
if (path) {
@@ -333,9 +394,11 @@ static gint scan_dir(CamelStore *store, GHashTable *visited, gchar *root, const
dir = opendir(name);
if (dir == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not scan folder '%s': %s"),
- name, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not scan folder '%s': %s"),
+ name, g_strerror (errno));
return -1;
}
@@ -389,7 +452,7 @@ static gint scan_dir(CamelStore *store, GHashTable *visited, gchar *root, const
*inew = in;
g_hash_table_insert(visited, inew, inew);
- if (scan_dir(store, visited, root, fname, flags, parent, fip, ex) == -1) {
+ if (scan_dir(store, visited, root, fname, flags, parent, fip, error) == -1) {
g_free(tmp);
g_free(fname);
closedir(dir);
@@ -407,34 +470,40 @@ static gint scan_dir(CamelStore *store, GHashTable *visited, gchar *root, const
return 0;
}
-static guint inode_hash(gconstpointer d)
+static guint
+inode_hash (gconstpointer d)
{
const struct _inode *v = d;
return v->inode ^ v->dnode;
}
-static gboolean inode_equal(gconstpointer a, gconstpointer b)
+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)
+static void
+inode_free (gpointer k, gpointer v, gpointer d)
{
g_free(k);
}
static CamelFolderInfo *
-get_folder_info_elm(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+get_folder_info_elm (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
CamelFolderInfo *fi = NULL;
GHashTable *visited;
visited = g_hash_table_new(inode_hash, inode_equal);
- if (scan_dir(store, visited, ((CamelService *)store)->url->path, top, flags, NULL, &fi, ex) == -1 && fi != NULL) {
+ if (scan_dir(store, visited, ((CamelService *)store)->url->path, top, flags, NULL, &fi, error) == -1 && fi != NULL) {
camel_store_free_folder_info_full(store, fi);
fi = NULL;
}
@@ -446,7 +515,10 @@ get_folder_info_elm(CamelStore *store, const gchar *top, guint32 flags, CamelExc
}
static CamelFolderInfo *
-get_folder_info_mbox(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+get_folder_info_mbox (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
CamelFolderInfo *fi = NULL, *fip = NULL;
@@ -461,16 +533,20 @@ get_folder_info_mbox(CamelStore *store, const gchar *top, guint32 flags, CamelEx
}
static CamelFolderInfo *
-get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+get_folder_info (CamelStore *store,
+ const gchar *top,
+ guint32 flags,
+ GError **error)
{
if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX)
- return get_folder_info_mbox(store, top, flags, ex);
+ return get_folder_info_mbox (store, top, flags, error);
else
- return get_folder_info_elm(store, top, flags, ex);
+ return get_folder_info_elm (store, top, flags, error);
}
static gchar *
-spool_get_full_path(CamelLocalStore *ls, const gchar *full_name)
+spool_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 */
@@ -480,7 +556,9 @@ spool_get_full_path(CamelLocalStore *ls, const gchar *full_name)
}
static gchar *
-spool_get_meta_path(CamelLocalStore *ls, const gchar *full_name, const gchar *ext)
+spool_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;
diff --git a/camel/providers/local/camel-spool-summary.c b/camel/providers/local/camel-spool-summary.c
index 92fa7df..19ab96d 100644
--- a/camel/providers/local/camel-spool-summary.c
+++ b/camel/providers/local/camel-spool-summary.c
@@ -42,10 +42,10 @@
#define CAMEL_SPOOL_SUMMARY_VERSION (0x400)
-static gint spool_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex);
-static gint spool_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex);
+static gint spool_summary_load(CamelLocalSummary *cls, gint forceindex, GError **error);
+static gint spool_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, GError **error);
-static gint spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
+static gint spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, GError **error);
static gint spool_summary_need_index(void);
static gpointer parent_class;
@@ -99,7 +99,8 @@ camel_spool_summary_get_type(void)
}
CamelSpoolSummary *
-camel_spool_summary_new(struct _CamelFolder *folder, const gchar *mbox_name)
+camel_spool_summary_new (CamelFolder *folder,
+ const gchar *mbox_name)
{
CamelSpoolSummary *new;
@@ -116,7 +117,9 @@ camel_spool_summary_new(struct _CamelFolder *folder, const gchar *mbox_name)
}
static gint
-spool_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex)
+spool_summary_load (CamelLocalSummary *cls,
+ gint forceindex,
+ GError **error)
{
g_warning("spool summary - not loading anything\n");
return 0;
@@ -124,7 +127,10 @@ spool_summary_load(CamelLocalSummary *cls, gint forceindex, CamelException *ex)
/* perform a full sync */
static gint
-spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+spool_summary_sync_full (CamelMboxSummary *cls,
+ gboolean expunge,
+ CamelFolderChangeInfo *changeinfo,
+ GError **error)
{
gint fd = -1, fdout = -1;
gchar tmpname[64] = { '\0' };
@@ -140,10 +146,12 @@ spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChan
fd = open(((CamelLocalSummary *)cls)->folder_path, O_RDWR|O_LARGEFILE);
if (fd == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not open file: %s: %s"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not open file: %s: %s"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno));
camel_operation_end(NULL);
return -1;
}
@@ -153,42 +161,50 @@ spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChan
d(printf("Writing tmp file to %s\n", tmpname));
if (fdout == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot open temporary mailbox: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot open temporary mailbox: %s"),
+ g_strerror (errno));
goto error;
}
- if (camel_mbox_summary_sync_mbox((CamelMboxSummary *)cls, flags, changeinfo, fd, fdout, ex) == -1)
+ if (camel_mbox_summary_sync_mbox((CamelMboxSummary *)cls, flags, changeinfo, fd, fdout, error) == -1)
goto error;
/* sync out content */
if (fsync(fdout) == -1) {
g_warning("Cannot sync temporary folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not sync temporary folder %s: %s"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not sync temporary folder %s: %s"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno));
goto error;
}
/* see if we can write this much to the spool file */
if (fstat(fd, &st) == -1) {
g_warning("Cannot sync temporary folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not sync temporary folder %s: %s"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not sync temporary folder %s: %s"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno));
goto error;
}
spoollen = st.st_size;
if (fstat(fdout, &st) == -1) {
g_warning("Cannot sync temporary folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not sync temporary folder %s: %s"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not sync temporary folder %s: %s"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno));
goto error;
}
outlen = st.st_size;
@@ -201,10 +217,12 @@ spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChan
|| lseek(fd, 0, SEEK_SET) == -1
|| lseek(fdout, 0, SEEK_SET) == -1)) {
g_warning("Cannot sync spool folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not sync spool folder %s: %s"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not sync spool folder %s: %s"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno));
/* incase we ran out of room, remove any trailing space first */
ftruncate(fd, spoollen);
goto error;
@@ -231,11 +249,13 @@ spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChan
}
if (size == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not sync spool folder %s: %s\n"
- "Folder may be corrupt, copy saved in '%s'"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno), tmpname);
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not sync spool folder %s: %s\n"
+ "Folder may be corrupt, copy saved in '%s'"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno), tmpname);
/* so we dont delete it */
tmpname[0] = '\0';
g_free(buffer);
@@ -248,22 +268,26 @@ spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChan
d(printf("Closing folders\n"));
if (ftruncate(fd, outlen) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not sync spool folder %s: %s\n"
- "Folder may be corrupt, copy saved in '%s'"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno), tmpname);
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not sync spool folder %s: %s\n"
+ "Folder may be corrupt, copy saved in '%s'"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno), tmpname);
tmpname[0] = '\0';
goto error;
}
if (close(fd) == -1) {
g_warning("Cannot close source folder: %s", g_strerror (errno));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not sync spool folder %s: %s\n"
- "Folder may be corrupt, copy saved in '%s'"),
- ((CamelLocalSummary *)cls)->folder_path,
- g_strerror (errno), tmpname);
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not sync spool folder %s: %s\n"
+ "Folder may be corrupt, copy saved in '%s'"),
+ ((CamelLocalSummary *)cls)->folder_path,
+ g_strerror (errno), tmpname);
tmpname[0] = '\0';
fd = -1;
goto error;
@@ -293,13 +317,15 @@ spool_summary_sync_full(CamelMboxSummary *cls, gboolean expunge, CamelFolderChan
}
static gint
-spool_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex)
+spool_summary_check (CamelLocalSummary *cls,
+ CamelFolderChangeInfo *changeinfo,
+ GError **error)
{
gint i, work, count;
struct stat st;
CamelFolderSummary *s = (CamelFolderSummary *)cls;
- if (CAMEL_LOCAL_SUMMARY_CLASS (parent_class)->check(cls, changeinfo, ex) == -1)
+ if (CAMEL_LOCAL_SUMMARY_CLASS (parent_class)->check(cls, changeinfo, error) == -1)
return -1;
/* check to see if we need to copy/update the file; missing xev headers prompt this */
@@ -315,13 +341,15 @@ spool_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, C
/* if we do, then write out the headers using sync_full, etc */
if (work) {
d(printf("Have to add new headers, re-syncing from the start to accomplish this\n"));
- if (CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_full (CAMEL_MBOX_SUMMARY (cls), FALSE, changeinfo, ex) == -1)
+ if (CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_full (CAMEL_MBOX_SUMMARY (cls), FALSE, changeinfo, error) == -1)
return -1;
if (stat(cls->folder_path, &st) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unknown error: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Unknown error: %s"),
+ g_strerror (errno));
return -1;
}
diff --git a/camel/providers/local/camel-spool-summary.h b/camel/providers/local/camel-spool-summary.h
index 653600a..391512e 100644
--- a/camel/providers/local/camel-spool-summary.h
+++ b/camel/providers/local/camel-spool-summary.h
@@ -65,13 +65,13 @@ void camel_spool_summary_construct (CamelSpoolSummary *new, const gchar *filenam
CamelSpoolSummary *camel_spool_summary_new(struct _CamelFolder *, const gchar *filename);
/* load/check the summary */
-gint camel_spool_summary_load(CamelSpoolSummary *cls, gint forceindex, CamelException *ex);
+gint camel_spool_summary_load(CamelSpoolSummary *cls, gint forceindex, GError **error);
/* check for new/removed messages */
-gint camel_spool_summary_check(CamelSpoolSummary *cls, CamelFolderChangeInfo *, CamelException *ex);
+gint camel_spool_summary_check(CamelSpoolSummary *cls, CamelFolderChangeInfo *, GError **error);
/* perform a folder sync or expunge, if needed */
-gint camel_spool_summary_sync(CamelSpoolSummary *cls, gboolean expunge, CamelFolderChangeInfo *, CamelException *ex);
+gint camel_spool_summary_sync(CamelSpoolSummary *cls, gboolean expunge, CamelFolderChangeInfo *, GError **error);
/* add a new message to the summary */
-CamelMessageInfo *camel_spool_summary_add(CamelSpoolSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);
+CamelMessageInfo *camel_spool_summary_add(CamelSpoolSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, GError **error);
/* generate an X-Evolution header line */
gchar *camel_spool_summary_encode_x_evolution(CamelSpoolSummary *cls, const CamelMessageInfo *info);
diff --git a/camel/providers/nntp/camel-nntp-auth.c b/camel/providers/nntp/camel-nntp-auth.c
index c11321c..51e7907 100644
--- a/camel/providers/nntp/camel-nntp-auth.c
+++ b/camel/providers/nntp/camel-nntp-auth.c
@@ -31,7 +31,7 @@
#include "camel-nntp-resp-codes.h"
gint
-camel_nntp_auth_authenticate (CamelNNTPStore *store, CamelException *ex)
+camel_nntp_auth_authenticate (CamelNNTPStore *store, GError **error)
{
CamelService *service = CAMEL_SERVICE (store);
CamelSession *session = camel_service_get_session (service);
diff --git a/camel/providers/nntp/camel-nntp-auth.h b/camel/providers/nntp/camel-nntp-auth.h
index c74869a..28b614f 100644
--- a/camel/providers/nntp/camel-nntp-auth.h
+++ b/camel/providers/nntp/camel-nntp-auth.h
@@ -29,7 +29,7 @@
G_BEGIN_DECLS
-gint camel_nntp_auth_authenticate (CamelNNTPStore *store, CamelException *ex);
+gint camel_nntp_auth_authenticate (CamelNNTPStore *store, GError **error);
G_END_DECLS
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 8dca275..1998f91 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -53,12 +53,9 @@ static void
nntp_folder_finalize (GObject *object)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (object);
- CamelException ex;
-
- camel_exception_init (&ex);
camel_folder_summary_save_to_db (
- CAMEL_FOLDER (nntp_folder)->summary, &ex);
+ CAMEL_FOLDER (nntp_folder)->summary, NULL);
g_mutex_free (nntp_folder->priv->search_lock);
g_mutex_free (nntp_folder->priv->cache_lock);
@@ -67,28 +64,34 @@ nntp_folder_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-void
-camel_nntp_folder_selected(CamelNNTPFolder *folder, gchar *line, CamelException *ex)
+gboolean
+camel_nntp_folder_selected (CamelNNTPFolder *folder,
+ gchar *line,
+ GError **error)
{
- camel_nntp_summary_check((CamelNNTPSummary *)((CamelFolder *)folder)->summary,
- (CamelNNTPStore *)((CamelFolder *)folder)->parent_store,
- line, folder->changes, ex);
+ return camel_nntp_summary_check (
+ (CamelNNTPSummary *)((CamelFolder *)folder)->summary,
+ (CamelNNTPStore *)((CamelFolder *)folder)->parent_store,
+ line, folder->changes, error);
}
-static void
-nntp_folder_refresh_info_online (CamelFolder *folder, CamelException *ex)
+static gboolean
+nntp_folder_refresh_info_online (CamelFolder *folder,
+ GError **error)
{
CamelNNTPStore *nntp_store;
CamelFolderChangeInfo *changes = NULL;
CamelNNTPFolder *nntp_folder;
gchar *line;
+ gboolean success;
nntp_store = (CamelNNTPStore *) folder->parent_store;
nntp_folder = (CamelNNTPFolder *) folder;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
- camel_nntp_command(nntp_store, ex, nntp_folder, &line, NULL);
+ success = camel_nntp_command (
+ nntp_store, error, nntp_folder, &line, NULL);
if (camel_folder_change_info_changed(nntp_folder->changes)) {
changes = nntp_folder->changes;
@@ -101,26 +104,36 @@ nntp_folder_refresh_info_online (CamelFolder *folder, CamelException *ex)
camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
}
+
+ return success;
}
-static void
-nntp_folder_sync_online (CamelFolder *folder, CamelException *ex)
+static gboolean
+nntp_folder_sync_online (CamelFolder *folder, GError **error)
{
+ gboolean success;
+
CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ success = camel_folder_summary_save_to_db (folder->summary, error);
CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
+
+ return success;
}
-static void
-nntp_folder_sync_offline (CamelFolder *folder, CamelException *ex)
+static gboolean
+nntp_folder_sync_offline (CamelFolder *folder, GError **error)
{
+ gboolean success;
+
CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ success = camel_folder_summary_save_to_db (folder->summary, error);
CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
+
+ return success;
}
static gchar *
-nntp_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+nntp_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelNNTPStore *nntp_store = (CamelNNTPStore *) folder->parent_store;
gchar *article, *msgid;
@@ -129,24 +142,25 @@ nntp_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
strcpy(article, uid);
msgid = strchr (article, ',');
if (msgid == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Internal error: UID in invalid format: %s"), uid);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Internal error: UID in invalid format: %s"), uid);
return NULL;
}
*msgid++ = 0;
- return camel_data_cache_get_filename (nntp_store->cache, "cache", msgid, ex);
+ return camel_data_cache_get_filename (nntp_store->cache, "cache", msgid, error);
}
static CamelStream *
-nntp_folder_download_message (CamelNNTPFolder *nntp_folder, const gchar *id, const gchar *msgid, CamelException *ex)
+nntp_folder_download_message (CamelNNTPFolder *nntp_folder, const gchar *id, const gchar *msgid, GError **error)
{
CamelNNTPStore *nntp_store = (CamelNNTPStore *) ((CamelFolder *) nntp_folder)->parent_store;
CamelStream *stream = NULL;
gint ret;
gchar *line;
- ret = camel_nntp_command (nntp_store, ex, nntp_folder, &line, "article %s", id);
+ ret = camel_nntp_command (nntp_store, error, nntp_folder, &line, "article %s", id);
if (ret == 220) {
stream = camel_data_cache_add (nntp_store->cache, "cache", msgid, NULL);
if (stream) {
@@ -159,50 +173,71 @@ nntp_folder_download_message (CamelNNTPFolder *nntp_folder, const gchar *id, con
g_object_ref (stream);
}
} else if (ret == 423 || ret == 430) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, _("Cannot get message %s: %s"), msgid, line);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message %s: %s"), msgid, line);
} else if (ret != -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), msgid, line);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot get message %s: %s"), msgid, line);
}
return stream;
fail:
if (errno == EINTR)
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), msgid, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get message %s: %s"),
+ msgid, g_strerror (errno));
return NULL;
}
-static void
-nntp_folder_cache_message (CamelDiscoFolder *disco_folder, const gchar *uid, CamelException *ex)
+static gboolean
+nntp_folder_cache_message (CamelDiscoFolder *disco_folder,
+ const gchar *uid,
+ GError **error)
{
CamelNNTPStore *nntp_store = (CamelNNTPStore *)((CamelFolder *) disco_folder)->parent_store;
CamelStream *stream;
gchar *article, *msgid;
+ gboolean success = TRUE;
article = alloca(strlen(uid)+1);
strcpy(article, uid);
msgid = strchr(article, ',');
if (!msgid) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Internal error: UID in invalid format: %s"), uid);
- return;
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Internal error: UID in invalid format: %s"), uid);
+ return FALSE;
}
*msgid++ = 0;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
- stream = nntp_folder_download_message ((CamelNNTPFolder *) disco_folder, article, msgid, ex);
+ stream = nntp_folder_download_message (
+ (CamelNNTPFolder *) disco_folder, article, msgid, error);
if (stream)
g_object_unref (stream);
+ else
+ success = FALSE;
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+
+ return success;
}
static CamelMimeMessage *
-nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+nntp_folder_get_message (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelMimeMessage *message = NULL;
CamelNNTPStore *nntp_store;
@@ -218,8 +253,9 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
strcpy(article, uid);
msgid = strchr (article, ',');
if (msgid == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Internal error: UID in invalid format: %s"), uid);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Internal error: UID in invalid format: %s"), uid);
return NULL;
}
*msgid++ = 0;
@@ -230,12 +266,14 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
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) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not currently available"));
+ 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, ex);
+ stream = nntp_folder_download_message (nntp_folder, article, msgid, error);
if (stream == NULL)
goto fail;
}
@@ -243,9 +281,16 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
message = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
if (errno == EINTR)
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), uid, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Cannot get message %s: %s"),
+ uid, g_strerror (errno));
g_object_unref (message);
message = NULL;
}
@@ -270,7 +315,7 @@ fail:
}
static GPtrArray*
-nntp_folder_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+nntp_folder_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
GPtrArray *matches;
@@ -281,7 +326,7 @@ nntp_folder_search_by_expression (CamelFolder *folder, const gchar *expression,
nntp_folder->search = camel_folder_search_new ();
camel_folder_search_set_folder (nntp_folder->search, folder);
- matches = camel_folder_search_search(nntp_folder->search, expression, NULL, ex);
+ matches = camel_folder_search_search(nntp_folder->search, expression, NULL, error);
CAMEL_NNTP_FOLDER_UNLOCK(nntp_folder, search_lock);
@@ -289,7 +334,7 @@ nntp_folder_search_by_expression (CamelFolder *folder, const gchar *expression,
}
static guint32
-nntp_folder_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+nntp_folder_count_by_expression (CamelFolder *folder, const gchar *expression, GError **error)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
guint32 count;
@@ -300,7 +345,7 @@ nntp_folder_count_by_expression (CamelFolder *folder, const gchar *expression, C
nntp_folder->search = camel_folder_search_new ();
camel_folder_search_set_folder (nntp_folder->search, folder);
- count = camel_folder_search_count(nntp_folder->search, expression, ex);
+ count = camel_folder_search_count(nntp_folder->search, expression, error);
CAMEL_NNTP_FOLDER_UNLOCK(nntp_folder, search_lock);
@@ -308,7 +353,7 @@ nntp_folder_count_by_expression (CamelFolder *folder, const gchar *expression, C
}
static GPtrArray *
-nntp_folder_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+nntp_folder_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error)
{
CamelNNTPFolder *nntp_folder = (CamelNNTPFolder *) folder;
GPtrArray *matches;
@@ -322,7 +367,7 @@ nntp_folder_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrAr
nntp_folder->search = camel_folder_search_new ();
camel_folder_search_set_folder (nntp_folder->search, folder);
- matches = camel_folder_search_search(nntp_folder->search, expression, uids, ex);
+ matches = camel_folder_search_search(nntp_folder->search, expression, uids, error);
CAMEL_NNTP_FOLDER_UNLOCK(folder, search_lock);
@@ -339,10 +384,12 @@ nntp_folder_search_free (CamelFolder *folder, GPtrArray *result)
CAMEL_NNTP_FOLDER_UNLOCK(nntp_folder, search_lock);
}
-static void
-nntp_folder_append_message_online (CamelFolder *folder, CamelMimeMessage *mime_message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+static gboolean
+nntp_folder_append_message_online (CamelFolder *folder,
+ CamelMimeMessage *mime_message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
CamelNNTPStore *nntp_store = (CamelNNTPStore *) folder->parent_store;
CamelStream *stream = (CamelStream*)nntp_store->stream;
@@ -354,20 +401,27 @@ nntp_folder_append_message_online (CamelFolder *folder, CamelMimeMessage *mime_m
gint ret;
guint u;
gchar *group, *line;
+ gboolean success = TRUE;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
/* send 'POST' command */
- ret = camel_nntp_command (nntp_store, ex, NULL, &line, "post");
+ ret = camel_nntp_command (nntp_store, error, NULL, &line, "post");
if (ret != 340) {
- if (ret == 440)
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- _("Posting failed: %s"), line);
- else if (ret != -1)
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Posting failed: %s"), line);
+ if (ret == 440) {
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INSUFFICIENT_PERMISSION,
+ _("Posting failed: %s"), line);
+ success = FALSE;
+ } else if (ret != -1) {
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Posting failed: %s"), line);
+ success = FALSE;
+ }
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
- return;
+ return success;
}
/* the 'Newsgroups: ' header */
@@ -393,12 +447,25 @@ nntp_folder_append_message_online (CamelFolder *folder, CamelMimeMessage *mime_m
|| camel_stream_flush (filtered_stream) == -1
|| camel_stream_write (stream, "\r\n.\r\n", 5) == -1
|| (ret = camel_nntp_stream_line (nntp_store->stream, (guchar **)&line, &u)) == -1) {
- if (errno == EINTR)
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
- else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Posting failed: %s"), g_strerror (errno));
+ if (errno == EINTR) {
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
+ success = FALSE;
+ } else {
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Posting failed: %s"),
+ g_strerror (errno));
+ success = FALSE;
+ }
} else if (atoi(line) != 240) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Posting failed: %s"), line);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Posting failed: %s"), line);
+ success = FALSE;
}
g_object_unref (filtered_stream);
@@ -407,26 +474,42 @@ nntp_folder_append_message_online (CamelFolder *folder, CamelMimeMessage *mime_m
camel_header_raw_append_queue (header_queue, &save_queue);
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+
+ return success;
}
-static void
-nntp_folder_append_message_offline (CamelFolder *folder, CamelMimeMessage *mime_message,
- const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+static gboolean
+nntp_folder_append_message_offline (CamelFolder *folder,
+ CamelMimeMessage *mime_message,
+ const CamelMessageInfo *info,
+ gchar **appended_uid,
+ GError **error)
{
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You cannot post NNTP messages while working offline!"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You cannot post NNTP messages while working offline!"));
+
+ return FALSE;
}
/* I do not know what to do this exactly. Looking at the IMAP implementation for this, it
seems to assume the message is copied to a folder on the same store. In that case, an
NNTP implementation doesn't seem to make any sense. */
-static void
-nntp_folder_transfer_message (CamelFolder *source, GPtrArray *uids, CamelFolder *dest,
- GPtrArray **transferred_uids, gboolean delete_orig, CamelException *ex)
+static gboolean
+nntp_folder_transfer_message (CamelFolder *source,
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_orig,
+ GError **error)
{
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You cannot copy messages from a NNTP folder!"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You cannot copy messages from a NNTP folder!"));
+
+ return FALSE;
}
static void
@@ -495,7 +578,9 @@ camel_nntp_folder_get_type (void)
}
CamelFolder *
-camel_nntp_folder_new (CamelStore *parent, const gchar *folder_name, CamelException *ex)
+camel_nntp_folder_new (CamelStore *parent,
+ const gchar *folder_name,
+ GError **error)
{
CamelFolder *folder;
CamelNNTPFolder *nntp_folder;
@@ -505,7 +590,7 @@ camel_nntp_folder_new (CamelStore *parent, const gchar *folder_name, CamelExcept
gboolean subscribed = TRUE;
service = (CamelService *) parent;
- root = camel_session_get_storage_path (service->session, service, ex);
+ root = camel_session_get_storage_path (service->session, service, error);
if (root == NULL)
return NULL;
@@ -530,7 +615,7 @@ camel_nntp_folder_new (CamelStore *parent, const gchar *folder_name, CamelExcept
folder->summary = (CamelFolderSummary *) camel_nntp_summary_new (folder, root);
g_free(root);
- camel_folder_summary_load_from_db (folder->summary, ex);
+ camel_folder_summary_load_from_db (folder->summary, NULL);
si = camel_store_summary_path ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, folder_name);
if (si) {
@@ -538,12 +623,9 @@ camel_nntp_folder_new (CamelStore *parent, const gchar *folder_name, CamelExcept
camel_store_summary_info_free ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, si);
}
- if (subscribed) {
- camel_folder_refresh_info(folder, ex);
- if (camel_exception_is_set(ex)) {
- g_object_unref (folder);
- folder = NULL;
- }
+ if (subscribed && !camel_folder_refresh_info (folder, error)) {
+ g_object_unref (folder);
+ folder = NULL;
}
return folder;
diff --git a/camel/providers/nntp/camel-nntp-folder.h b/camel/providers/nntp/camel-nntp-folder.h
index 8f3c23b..79613bf 100644
--- a/camel/providers/nntp/camel-nntp-folder.h
+++ b/camel/providers/nntp/camel-nntp-folder.h
@@ -68,9 +68,9 @@ struct _CamelNNTPFolderClass {
GType camel_nntp_folder_get_type (void);
-CamelFolder *camel_nntp_folder_new (CamelStore *parent, const gchar *folder_name, CamelException *ex);
+CamelFolder *camel_nntp_folder_new (CamelStore *parent, const gchar *folder_name, GError **error);
-void camel_nntp_folder_selected(CamelNNTPFolder *folder, gchar *line, CamelException *ex);
+gboolean camel_nntp_folder_selected(CamelNNTPFolder *folder, gchar *line, GError **error);
G_END_DECLS
diff --git a/camel/providers/nntp/camel-nntp-grouplist.c b/camel/providers/nntp/camel-nntp-grouplist.c
index 062cca3..637d8ae 100644
--- a/camel/providers/nntp/camel-nntp-grouplist.c
+++ b/camel/providers/nntp/camel-nntp-grouplist.c
@@ -34,7 +34,7 @@
#include "camel-nntp-resp-codes.h"
static CamelNNTPGroupList *
-camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, CamelException *ex)
+camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, GError **error)
{
gint status;
gboolean done = FALSE;
@@ -83,7 +83,7 @@ camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, CamelException *ex)
}
static CamelNNTPGroupList*
-camel_nntp_get_grouplist_from_file (CamelNNTPStore *store, CamelException *ex)
+camel_nntp_get_grouplist_from_file (CamelNNTPStore *store, GError **error)
{
gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store));
gchar *grouplist_file = g_strdup_printf ("%s/grouplist", root_dir);
@@ -145,7 +145,7 @@ save_entry (CamelNNTPGroupListEntry *entry, FILE *fp)
}
void
-camel_nntp_grouplist_save (CamelNNTPGroupList *group_list, CamelException *ex)
+camel_nntp_grouplist_save (CamelNNTPGroupList *group_list, GError **error)
{
FILE *fp;
gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(group_list->store));
@@ -188,7 +188,7 @@ camel_nntp_grouplist_free (CamelNNTPGroupList *group_list)
}
CamelNNTPGroupList*
-camel_nntp_grouplist_fetch (CamelNNTPStore *store, CamelException *ex)
+camel_nntp_grouplist_fetch (CamelNNTPStore *store, GError **error)
{
CamelNNTPGroupList *list;
@@ -215,7 +215,7 @@ camel_nntp_grouplist_fetch (CamelNNTPStore *store, CamelException *ex)
}
gint
-camel_nntp_grouplist_update (CamelNNTPGroupList *group_list, CamelException *ex)
+camel_nntp_grouplist_update (CamelNNTPGroupList *group_list, GError **error)
{
return 0;
}
diff --git a/camel/providers/nntp/camel-nntp-grouplist.h b/camel/providers/nntp/camel-nntp-grouplist.h
index b1e5997..8499015 100644
--- a/camel/providers/nntp/camel-nntp-grouplist.h
+++ b/camel/providers/nntp/camel-nntp-grouplist.h
@@ -45,9 +45,9 @@ struct CamelNNTPGroupList {
typedef struct CamelNNTPGroupList _CamelNNTPGroupList;
typedef struct CamelNNTPGroupListEntry _CamelNNTPGroupListEntry;
-struct CamelNNTPGroupList* camel_nntp_grouplist_fetch (CamelNNTPStore *store, CamelException *ex);
-gint camel_nntp_grouplist_update (struct CamelNNTPGroupList *group_list, CamelException *ex);
-void camel_nntp_grouplist_save (struct CamelNNTPGroupList *group_list, CamelException *ex);
+struct CamelNNTPGroupList* camel_nntp_grouplist_fetch (CamelNNTPStore *store, GError **error);
+gint camel_nntp_grouplist_update (struct CamelNNTPGroupList *group_list, GError **error);
+void camel_nntp_grouplist_save (struct CamelNNTPGroupList *group_list, GError **error);
void camel_nntp_grouplist_free (struct CamelNNTPGroupList *group_list);
G_END_DECLS
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index eff8fac..fc7a221 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -57,7 +57,7 @@
static gpointer parent_class;
-static gint camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex);
+static gint camel_nntp_try_authenticate (CamelNNTPStore *store, GError **error);
static void
nntp_store_dispose (GObject *object)
@@ -139,7 +139,7 @@ static struct {
};
static gint
-xover_setup(CamelNNTPStore *store, CamelException *ex)
+xover_setup(CamelNNTPStore *store, GError **error)
{
gint ret, i;
gchar *line;
@@ -151,7 +151,7 @@ xover_setup(CamelNNTPStore *store, CamelException *ex)
if (store->xover || getenv("CAMEL_NNTP_DISABLE_XOVER") != NULL)
return 0;
- ret = camel_nntp_raw_command_auth(store, ex, &line, "list overview.fmt");
+ ret = camel_nntp_raw_command_auth(store, error, &line, "list overview.fmt");
if (ret == -1) {
return -1;
} else if (ret != 215)
@@ -202,7 +202,7 @@ enum {
#endif
static gboolean
-connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
+connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, GError **error)
{
CamelNNTPStore *store = (CamelNNTPStore *) service;
CamelDiscoStore *disco_store = (CamelDiscoStore*) service;
@@ -222,9 +222,11 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
}
#else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to %s: %s"),
- service->url->host, _("SSL unavailable"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not connect to %s: %s"),
+ service->url->host, _("SSL unavailable"));
goto fail;
#endif /* HAVE_SSL */
@@ -234,13 +236,16 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Connection canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to %s: %s"),
- service->url->host,
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not connect to %s: %s"),
+ service->url->host, g_strerror (errno));
g_object_unref (tcp_stream);
@@ -253,12 +258,16 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
/* Read the greeting, if any. */
if (camel_nntp_stream_line (store->stream, &buf, &len) == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Connection canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not read greeting from %s: %s"),
- service->url->host, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not read greeting from %s: %s"),
+ service->url->host, g_strerror (errno));
g_object_unref (store->stream);
store->stream = NULL;
@@ -268,9 +277,10 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
len = strtoul ((gchar *) buf, (gchar **) &buf, 10);
if (len != 200 && len != 201) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("NNTP server %s returned error code %d: %s"),
- service->url->host, len, buf);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("NNTP server %s returned error code %d: %s"),
+ service->url->host, len, buf);
g_object_unref (store->stream);
store->stream = NULL;
@@ -281,20 +291,20 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
/* if we have username, try it here */
if (service->url->user != NULL
&& service->url->user[0]
- && camel_nntp_try_authenticate(store, ex) != NNTP_AUTH_ACCEPTED)
+ && camel_nntp_try_authenticate(store, error) != NNTP_AUTH_ACCEPTED)
goto fail;
/* set 'reader' mode & ignore return code, also ping the server, inn goes offline very quickly otherwise */
- if (camel_nntp_raw_command_auth (store, ex, (gchar **) &buf, "mode reader") == -1
- || camel_nntp_raw_command_auth (store, ex, (gchar **) &buf, "date") == -1)
+ if (camel_nntp_raw_command_auth (store, error, (gchar **) &buf, "mode reader") == -1
+ || camel_nntp_raw_command_auth (store, error, (gchar **) &buf, "date") == -1)
goto fail;
- if (xover_setup(store, ex) == -1)
+ if (xover_setup(store, error) == -1)
goto fail;
if (!disco_store->diary) {
path = g_build_filename (store->storage_path, ".ev-journal", NULL);
- disco_store->diary = camel_disco_diary_new (disco_store, path, ex);
+ disco_store->diary = camel_disco_diary_new (disco_store, path, error);
g_free (path);
}
@@ -322,13 +332,14 @@ static struct {
};
static gboolean
-nntp_connect_online (CamelService *service, CamelException *ex)
+nntp_connect_online (CamelService *service, GError **error)
{
struct addrinfo hints, *ai;
const gchar *ssl_mode;
gint mode, ret, i;
gchar *serv;
const gchar *port;
+ GError *local_error = NULL;
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
@@ -352,15 +363,19 @@ nntp_connect_online (CamelService *service, CamelException *ex)
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
- if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
- camel_exception_clear (ex);
- ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, &local_error);
+ if (ai == NULL && port != NULL &&
+ g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL)) {
+ g_clear_error (&local_error);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, &local_error);
}
- if (ai == NULL)
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
- ret = connect_to_server (service, ai, mode, ex);
+ ret = connect_to_server (service, ai, mode, error);
camel_freeaddrinfo (ai);
@@ -368,7 +383,7 @@ nntp_connect_online (CamelService *service, CamelException *ex)
}
static gboolean
-nntp_connect_offline (CamelService *service, CamelException *ex)
+nntp_connect_offline (CamelService *service, GError **error)
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(service);
CamelDiscoStore *disco_store = (CamelDiscoStore *) nntp_store;
@@ -379,7 +394,7 @@ nntp_connect_offline (CamelService *service, CamelException *ex)
/* setup store-wide cache */
if (nntp_store->cache == NULL) {
- nntp_store->cache = camel_data_cache_new (nntp_store->storage_path, ex);
+ nntp_store->cache = camel_data_cache_new (nntp_store->storage_path, error);
if (nntp_store->cache == NULL)
return FALSE;
@@ -392,7 +407,7 @@ nntp_connect_offline (CamelService *service, CamelException *ex)
return TRUE;
path = g_build_filename (nntp_store->storage_path, ".ev-journal", NULL);
- disco_store->diary = camel_disco_diary_new (disco_store, path, ex);
+ disco_store->diary = camel_disco_diary_new (disco_store, path, error);
g_free (path);
if (!disco_store->diary)
@@ -402,7 +417,7 @@ nntp_connect_offline (CamelService *service, CamelException *ex)
}
static gboolean
-nntp_disconnect_online (CamelService *service, gboolean clean, CamelException *ex)
+nntp_disconnect_online (CamelService *service, gboolean clean, GError **error)
{
CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
CamelServiceClass *service_class;
@@ -412,13 +427,11 @@ nntp_disconnect_online (CamelService *service, gboolean clean, CamelException *e
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
- if (clean) {
- camel_nntp_raw_command (store, ex, &line, "quit");
- camel_exception_clear(ex);
- }
+ if (clean)
+ camel_nntp_raw_command (store, NULL, &line, "quit");
/* Chain up to parent's disconnect() method. */
- if (!service_class->disconnect (service, clean, ex)) {
+ if (!service_class->disconnect (service, clean, error)) {
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
return FALSE;
}
@@ -434,15 +447,14 @@ nntp_disconnect_online (CamelService *service, gboolean clean, CamelException *e
}
static gboolean
-nntp_disconnect_offline (CamelService *service, gboolean clean, CamelException *ex)
+nntp_disconnect_offline (CamelService *service, gboolean clean, GError **error)
{
CamelDiscoStore *disco = CAMEL_DISCO_STORE(service);
CamelServiceClass *service_class;
- service_class = CAMEL_SERVICE_CLASS (parent_class);
-
/* Chain up to parent's disconnect() method. */
- if (!service_class->disconnect (service, clean, ex))
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->disconnect (service, clean, error))
return FALSE;
if (disco->diary) {
@@ -466,20 +478,20 @@ nntp_store_get_name (CamelService *service, gboolean brief)
extern CamelServiceAuthType camel_nntp_password_authtype;
static GList *
-nntp_store_query_auth_types (CamelService *service, CamelException *ex)
+nntp_store_query_auth_types (CamelService *service, GError **error)
{
return g_list_append (NULL, &camel_nntp_password_authtype);
}
static CamelFolder *
-nntp_get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+nntp_get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
CamelFolder *folder;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
- folder = camel_nntp_folder_new(store, folder_name, ex);
+ folder = camel_nntp_folder_new(store, folder_name, error);
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
@@ -641,7 +653,7 @@ nntp_store_info_update(CamelNNTPStore *store, gchar *line)
}
static CamelFolderInfo *
-nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const gchar *top, guint flags, CamelException *ex)
+nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const gchar *top, guint flags, GError **error)
{
gint i;
CamelStoreInfo *si;
@@ -662,12 +674,12 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const gchar *top,
CamelNNTPFolder *folder;
gchar *line;
- folder = (CamelNNTPFolder *)camel_store_get_folder((CamelStore *)store, si->path, 0, ex);
+ folder = (CamelNNTPFolder *)camel_store_get_folder((CamelStore *)store, si->path, 0, error);
if (folder) {
CamelFolderChangeInfo *changes = NULL;
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
- camel_nntp_command(store, ex, folder, &line, NULL);
+ camel_nntp_command(store, error, folder, &line, NULL);
if (camel_folder_change_info_changed(folder->changes)) {
changes = folder->changes;
folder->changes = camel_folder_change_info_new();
@@ -679,7 +691,7 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const gchar *top,
}
g_object_unref (folder);
}
- camel_exception_clear(ex);
+ g_clear_error (error);
}
fi = nntp_folder_info_from_store_info (store, store->do_short_folder_notation, si);
fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN | CAMEL_FOLDER_SYSTEM;
@@ -699,7 +711,7 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const gchar *top,
* get folder info, using the information in our StoreSummary
*/
static CamelFolderInfo *
-nntp_store_get_cached_folder_info (CamelNNTPStore *store, const gchar *orig_top, guint flags, CamelException *ex)
+nntp_store_get_cached_folder_info (CamelNNTPStore *store, const gchar *orig_top, guint flags, GError **error)
{
gint i;
gint subscribed_or_flag = (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) ? 0 : 1,
@@ -779,10 +791,10 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store, const gchar *orig_top,
/* retrieves the date from the NNTP server */
static gboolean
-nntp_get_date(CamelNNTPStore *nntp_store, CamelException *ex)
+nntp_get_date(CamelNNTPStore *nntp_store, GError **error)
{
guchar *line;
- gint ret = camel_nntp_command(nntp_store, ex, NULL, (gchar **)&line, "date");
+ gint ret = camel_nntp_command(nntp_store, error, NULL, (gchar **)&line, "date");
gchar *ptr;
nntp_store->summary->last_newslist[0] = 0;
@@ -816,7 +828,7 @@ store_info_sort (gconstpointer a, gconstpointer b)
}
static CamelFolderInfo *
-nntp_store_get_folder_info_all(CamelNNTPStore *nntp_store, const gchar *top, guint32 flags, gboolean online, CamelException *ex)
+nntp_store_get_folder_info_all(CamelNNTPStore *nntp_store, const gchar *top, guint32 flags, gboolean online, GError **error)
{
CamelNNTPStoreSummary *summary = nntp_store->summary;
CamelNNTPStoreInfo *si;
@@ -843,7 +855,7 @@ nntp_store_get_folder_info_all(CamelNNTPStore *nntp_store, const gchar *top, gui
if (!nntp_get_date (nntp_store, NULL))
goto do_complete_list_nodate;
- ret = camel_nntp_command (nntp_store, ex, NULL, (gchar **) &line, "newgroups %s", date);
+ ret = camel_nntp_command (nntp_store, error, NULL, (gchar **) &line, "newgroups %s", date);
if (ret == -1)
goto error;
else if (ret != 231) {
@@ -863,12 +875,14 @@ nntp_store_get_folder_info_all(CamelNNTPStore *nntp_store, const gchar *top, gui
/* at first, we do a DATE to find out the last load occasion */
nntp_get_date (nntp_store, NULL);
do_complete_list_nodate:
- ret = camel_nntp_command (nntp_store, ex, NULL, (gchar **)&line, "list");
+ ret = camel_nntp_command (nntp_store, error, NULL, (gchar **)&line, "list");
if (ret == -1)
goto error;
else if (ret != 215) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_INVALID,
- _("Error retrieving newsgroups:\n\n%s"), line);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Error retrieving newsgroups:\n\n%s"), line);
goto error;
}
@@ -893,7 +907,7 @@ nntp_store_get_folder_info_all(CamelNNTPStore *nntp_store, const gchar *top, gui
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
}
- fi = nntp_store_get_cached_folder_info (nntp_store, top, flags, ex);
+ fi = nntp_store_get_cached_folder_info (nntp_store, top, flags, error);
error:
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
@@ -901,7 +915,7 @@ nntp_store_get_folder_info_all(CamelNNTPStore *nntp_store, const gchar *top, gui
}
static CamelFolderInfo *
-nntp_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, gboolean online, CamelException *ex)
+nntp_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, gboolean online, GError **error)
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
CamelFolderInfo *first = NULL;
@@ -914,23 +928,23 @@ nntp_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, gboole
top?top:""));
if (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)
- first = nntp_store_get_subscribed_folder_info (nntp_store, top, flags, ex);
+ first = nntp_store_get_subscribed_folder_info (nntp_store, top, flags, error);
else
- first = nntp_store_get_folder_info_all (nntp_store, top, flags, online, ex);
+ first = nntp_store_get_folder_info_all (nntp_store, top, flags, online, error);
return first;
}
static CamelFolderInfo *
-nntp_get_folder_info_online (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+nntp_get_folder_info_online (CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
- return nntp_get_folder_info (store, top, flags, TRUE, ex);
+ return nntp_get_folder_info (store, top, flags, TRUE, error);
}
static CamelFolderInfo *
-nntp_get_folder_info_offline(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+nntp_get_folder_info_offline(CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
- return nntp_get_folder_info (store, top, flags, FALSE, ex);
+ return nntp_get_folder_info (store, top, flags, FALSE, error);
}
static gboolean
@@ -949,21 +963,26 @@ nntp_store_folder_subscribed (CamelStore *store, const gchar *folder_name)
return truth;
}
-static void
+static gboolean
nntp_store_subscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
CamelStoreInfo *si;
CamelFolderInfo *fi;
+ gboolean success = TRUE;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
si = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
if (!si) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("You cannot subscribe to this newsgroup:\n\n"
- "No such newsgroup. The selected item is a probably a parent folder."));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("You cannot subscribe to this newsgroup:\n\n"
+ "No such newsgroup. The selected item is a "
+ "probably a parent folder."));
+ success = FALSE;
} else {
if (!(si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED)) {
si->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
@@ -974,28 +993,35 @@ nntp_store_subscribe_folder (CamelStore *store, const gchar *folder_name,
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
camel_object_trigger_event ((CamelObject *) nntp_store, "folder_subscribed", fi);
camel_folder_info_free (fi);
- return;
+ return TRUE;
}
}
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+
+ return success;
}
-static void
+static gboolean
nntp_store_unsubscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
CamelFolderInfo *fi;
CamelStoreInfo *fitem;
+ gboolean success = TRUE;
+
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
fitem = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
if (!fitem) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("You cannot unsubscribe to this newsgroup:\n\n"
- "newsgroup does not exist!"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("You cannot unsubscribe to this newsgroup:\n\n"
+ "newsgroup does not exist!"));
+ success = FALSE;
} else {
if (fitem->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) {
fitem->flags &= ~CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
@@ -1005,66 +1031,82 @@ nntp_store_unsubscribe_folder (CamelStore *store, const gchar *folder_name,
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
camel_object_trigger_event ((CamelObject *) nntp_store, "folder_unsubscribed", fi);
camel_folder_info_free (fi);
- return;
+ return TRUE;
}
}
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+
+ return success;
}
/* stubs for various folder operations we're not implementing */
static CamelFolderInfo *
nntp_create_folder (CamelStore *store, const gchar *parent_name,
- const gchar *folder_name, CamelException *ex)
+ const gchar *folder_name, GError **error)
{
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("You cannot create a folder in a News store: subscribe instead."));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("You cannot create a folder in a News store: "
+ "subscribe instead."));
+
return NULL;
}
-static void
-nntp_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name_in, CamelException *ex)
+static gboolean
+nntp_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name_in, GError **error)
{
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("You cannot rename a folder in a News store."));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("You cannot rename a folder in a News store."));
+
+ return FALSE;
}
-static void
-nntp_delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+static gboolean
+nntp_delete_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
- nntp_store_unsubscribe_folder (store, folder_name, ex);
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("You cannot remove a folder in a News store: unsubscribe instead."));
- return;
+ nntp_store_unsubscribe_folder (store, folder_name, NULL);
+
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("You cannot remove a folder in a News store: "
+ "unsubscribe instead."));
+
+ return FALSE;
}
static gboolean
-nntp_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+nntp_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
{
/* any nntp folder can be refreshed */
return TRUE;
}
/* construction function in which we set some basic store properties */
-static void
+static gboolean
nntp_construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex)
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(service);
CamelURL *summary_url;
gchar *tmp;
/* construct the parent first */
- CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
- if (camel_exception_is_set (ex))
- return;
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->construct (service, session, provider, url, error))
+ return FALSE;
/* find out the storage path, base url */
- nntp_store->storage_path = camel_session_get_storage_path (session, service, ex);
+ nntp_store->storage_path = camel_session_get_storage_path (session, service, error);
if (!nntp_store->storage_path)
- return;
+ return FALSE;
/* FIXME */
nntp_store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
@@ -1092,13 +1134,15 @@ nntp_construct (CamelService *service, CamelSession *session,
nntp_store->folder_hierarchy_relative = FALSE;
/* setup store-wide cache */
- nntp_store->cache = camel_data_cache_new(nntp_store->storage_path, ex);
+ nntp_store->cache = camel_data_cache_new(nntp_store->storage_path, error);
if (nntp_store->cache == NULL)
- return;
+ return FALSE;
/* Default cache expiry - 2 weeks old, or not visited in 5 days */
camel_data_cache_set_expire_age(nntp_store->cache, 60*60*24*14);
camel_data_cache_set_expire_access(nntp_store->cache, 60*60*24*5);
+
+ return TRUE;
}
static void
@@ -1176,16 +1220,18 @@ camel_nntp_store_get_type (void)
}
static gint
-camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex)
+camel_nntp_try_authenticate (CamelNNTPStore *store, GError **error)
{
CamelService *service = (CamelService *) store;
CamelSession *session = camel_service_get_session (service);
gint ret;
gchar *line = NULL;
+ GError *local_error = NULL;
if (!service->url->user) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_INVALID_PARAM,
- _("Authentication requested but no username provided"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Authentication requested but no username provided"));
return -1;
}
@@ -1208,7 +1254,7 @@ camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex)
service->url->passwd =
camel_session_get_password (session, service, NULL,
- prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
+ prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, error);
g_free(prompt);
g_free(base);
@@ -1217,18 +1263,18 @@ camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex)
}
/* now, send auth info (currently, only authinfo user/pass is supported) */
- ret = camel_nntp_raw_command(store, ex, &line, "authinfo user %s", service->url->user);
+ ret = camel_nntp_raw_command(store, &local_error, &line, "authinfo user %s", service->url->user);
if (ret == NNTP_AUTH_CONTINUE)
- ret = camel_nntp_raw_command(store, ex, &line, "authinfo pass %s", service->url->passwd);
+ ret = camel_nntp_raw_command(store, &local_error, &line, "authinfo pass %s", service->url->passwd);
if (ret != NNTP_AUTH_ACCEPTED) {
if (ret != -1) {
- if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL ||
- camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_UNAVAILABLE)
+ if (g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL) ||
+ g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE))
return ret;
/* Need to forget the password here since we have no context on it */
- camel_session_forget_password(session, service, NULL, "password", ex);
+ camel_session_forget_password(session, service, NULL, "password", error);
g_free (service->url->passwd);
service->url->passwd = NULL;
goto retry;
@@ -1241,7 +1287,7 @@ camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex)
/* Enter owning lock */
gint
-camel_nntp_raw_commandv (CamelNNTPStore *store, CamelException *ex, gchar **line, const gchar *fmt, va_list ap)
+camel_nntp_raw_commandv (CamelNNTPStore *store, GError **error, gchar **line, const gchar *fmt, va_list ap)
{
GByteArray *buffer;
const guchar *p, *ps;
@@ -1320,20 +1366,27 @@ camel_nntp_raw_commandv (CamelNNTPStore *store, CamelException *ex, gchar **line
ioerror:
if (errno == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled."));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Canceled."));
else
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("NNTP Command failed: %s"), g_strerror(errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("NNTP Command failed: %s"),
+ g_strerror(errno));
return -1;
}
gint
-camel_nntp_raw_command(CamelNNTPStore *store, CamelException *ex, gchar **line, const gchar *fmt, ...)
+camel_nntp_raw_command(CamelNNTPStore *store, GError **error, gchar **line, const gchar *fmt, ...)
{
gint ret;
va_list ap;
va_start(ap, fmt);
- ret = camel_nntp_raw_commandv(store, ex, line, fmt, ap);
+ ret = camel_nntp_raw_commandv(store, error, line, fmt, ap);
va_end(ap);
return ret;
@@ -1341,7 +1394,7 @@ camel_nntp_raw_command(CamelNNTPStore *store, CamelException *ex, gchar **line,
/* use this where you also need auth to be handled, i.e. most cases where you'd try raw command */
gint
-camel_nntp_raw_command_auth(CamelNNTPStore *store, CamelException *ex, gchar **line, const gchar *fmt, ...)
+camel_nntp_raw_command_auth(CamelNNTPStore *store, GError **error, gchar **line, const gchar *fmt, ...)
{
gint ret, retry, go;
va_list ap;
@@ -1353,11 +1406,11 @@ camel_nntp_raw_command_auth(CamelNNTPStore *store, CamelException *ex, gchar **l
retry++;
va_start(ap, fmt);
- ret = camel_nntp_raw_commandv(store, ex, line, fmt, ap);
+ ret = camel_nntp_raw_commandv(store, error, line, fmt, ap);
va_end(ap);
if (ret == NNTP_AUTH_REQUIRED) {
- if (camel_nntp_try_authenticate(store, ex) != NNTP_AUTH_ACCEPTED)
+ if (camel_nntp_try_authenticate(store, error) != NNTP_AUTH_ACCEPTED)
return -1;
go = TRUE;
}
@@ -1367,7 +1420,7 @@ camel_nntp_raw_command_auth(CamelNNTPStore *store, CamelException *ex, gchar **l
}
gint
-camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder *folder, gchar **line, const gchar *fmt, ...)
+camel_nntp_command (CamelNNTPStore *store, GError **error, CamelNNTPFolder *folder, gchar **line, const gchar *fmt, ...)
{
const guchar *p;
va_list ap;
@@ -1375,17 +1428,21 @@ camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder *
guint u;
if (((CamelDiscoStore *)store)->status == CAMEL_DISCO_STORE_OFFLINE) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
- _("Not connected."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_NOT_CONNECTED,
+ _("Not connected."));
return -1;
}
retry = 0;
do {
+ GError *local_error = NULL;
+
retry ++;
if (store->stream == NULL
- && !camel_service_connect (CAMEL_SERVICE (store), ex))
+ && !camel_service_connect (CAMEL_SERVICE (store), error))
return -1;
/* Check for unprocessed data, ! */
@@ -1398,12 +1455,11 @@ camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder *
if (folder != NULL
&& (store->current_folder == NULL || strcmp(store->current_folder, ((CamelFolder *)folder)->full_name) != 0)) {
- ret = camel_nntp_raw_command_auth(store, ex, line, "group %s", ((CamelFolder *)folder)->full_name);
+ ret = camel_nntp_raw_command_auth(store, error, line, "group %s", ((CamelFolder *)folder)->full_name);
if (ret == 211) {
g_free(store->current_folder);
store->current_folder = g_strdup(((CamelFolder *)folder)->full_name);
- camel_nntp_folder_selected(folder, *line, ex);
- if (camel_exception_is_set(ex)) {
+ if (!camel_nntp_folder_selected(folder, *line, error)) {
ret = -1;
goto error;
}
@@ -1417,19 +1473,22 @@ camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder *
return 0;
va_start(ap, fmt);
- ret = camel_nntp_raw_commandv(store, ex, line, fmt, ap);
+ ret = camel_nntp_raw_commandv(store, &local_error, line, fmt, ap);
va_end(ap);
error:
switch (ret) {
case NNTP_AUTH_REQUIRED:
- if (camel_nntp_try_authenticate(store, ex) != NNTP_AUTH_ACCEPTED)
+ if (camel_nntp_try_authenticate(store, error) != NNTP_AUTH_ACCEPTED)
return -1;
retry--;
ret = -1;
continue;
case 411: /* no such group */
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("No such folder: %s"), line);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("No such folder: %s"),
+ (gchar *) line);
return -1;
case 400: /* service discontinued */
case 401: /* wrong client state - this should quit but this is what the old code did */
@@ -1439,9 +1498,11 @@ camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder *
continue;
case -1: /* i/o error */
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
- if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL || retry >= 3)
+ if (g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL) || retry >= 3) {
+ g_propagate_error (error, local_error);
return -1;
- camel_exception_clear(ex);
+ }
+ g_clear_error (&local_error);
break;
}
} while (ret == -1 && retry < 3);
diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h
index 1a07a95..71b05e2 100644
--- a/camel/providers/nntp/camel-nntp-store.h
+++ b/camel/providers/nntp/camel-nntp-store.h
@@ -109,10 +109,10 @@ struct _CamelNNTPStoreClass {
GType camel_nntp_store_get_type (void);
-gint camel_nntp_raw_commandv (CamelNNTPStore *store, struct _CamelException *ex, gchar **line, const gchar *fmt, va_list ap);
-gint camel_nntp_raw_command(CamelNNTPStore *store, struct _CamelException *ex, gchar **line, const gchar *fmt, ...);
-gint camel_nntp_raw_command_auth(CamelNNTPStore *store, struct _CamelException *ex, gchar **line, const gchar *fmt, ...);
-gint camel_nntp_command (CamelNNTPStore *store, struct _CamelException *ex, struct _CamelNNTPFolder *folder, gchar **line, const gchar *fmt, ...);
+gint camel_nntp_raw_commandv (CamelNNTPStore *store, struct _GError **error, gchar **line, const gchar *fmt, va_list ap);
+gint camel_nntp_raw_command(CamelNNTPStore *store, struct _GError **error, gchar **line, const gchar *fmt, ...);
+gint camel_nntp_raw_command_auth(CamelNNTPStore *store, struct _GError **error, gchar **line, const gchar *fmt, ...);
+gint camel_nntp_command (CamelNNTPStore *store, struct _GError **error, struct _CamelNNTPFolder *folder, gchar **line, const gchar *fmt, ...);
G_END_DECLS
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index e29a17f..dd90088 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -62,7 +62,7 @@ static CamelMessageInfo * message_info_new_from_header (CamelFolderSummary *, GQ
static gint summary_header_load (CamelFolderSummary *, FILE *);
static gint summary_header_save (CamelFolderSummary *, FILE *);
static gint summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *mir);
-static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, CamelException *ex);
+static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, GError **error);
static gpointer parent_class;
@@ -208,12 +208,12 @@ summary_header_load (CamelFolderSummary *s, FILE *in)
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s, GError **error)
{
CamelNNTPSummary *cns = CAMEL_NNTP_SUMMARY (s);
struct _CamelFIRecord *fir;
- fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, ex);
+ fir = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_to_db (s, error);
if (!fir)
return NULL;
fir->bdata = g_strdup_printf ("%d %d %d", CAMEL_NNTP_SUMMARY_VERSION, cns->high, cns->low);
@@ -239,7 +239,7 @@ summary_header_save (CamelFolderSummary *s, FILE *out)
/* Note: This will be called from camel_nntp_command, so only use camel_nntp_raw_command */
static gint
-add_range_xover (CamelNNTPSummary *cns, CamelNNTPStore *store, guint high, guint low, CamelFolderChangeInfo *changes, CamelException *ex)
+add_range_xover (CamelNNTPSummary *cns, CamelNNTPStore *store, guint high, guint low, CamelFolderChangeInfo *changes, GError **error)
{
CamelFolderSummary *s;
CamelMessageInfoBase *mi;
@@ -256,12 +256,13 @@ add_range_xover (CamelNNTPSummary *cns, CamelNNTPStore *store, guint high, guint
camel_operation_start (NULL, _("%s: Scanning new messages"), ((CamelService *)store)->url->host);
- ret = camel_nntp_raw_command_auth (store, ex, &line, "xover %r", low, high);
+ ret = camel_nntp_raw_command_auth (store, error, &line, "xover %r", low, high);
if (ret != 224) {
camel_operation_end (NULL);
if (ret != -1)
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unexpected server response from xover: %s"), line);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unexpected server response from xover: %s"), line);
return -1;
}
@@ -340,7 +341,7 @@ add_range_xover (CamelNNTPSummary *cns, CamelNNTPStore *store, guint high, guint
/* Note: This will be called from camel_nntp_command, so only use camel_nntp_raw_command */
static gint
-add_range_head (CamelNNTPSummary *cns, CamelNNTPStore *store, guint high, guint low, CamelFolderChangeInfo *changes, CamelException *ex)
+add_range_head (CamelNNTPSummary *cns, CamelNNTPStore *store, guint high, guint low, CamelFolderChangeInfo *changes, GError **error)
{
CamelFolderSummary *s;
gint ret = -1;
@@ -363,14 +364,17 @@ add_range_head (CamelNNTPSummary *cns, CamelNNTPStore *store, guint high, guint
for (i=low;i<high+1;i++) {
camel_operation_progress (NULL, (count * 100) / total);
count++;
- ret = camel_nntp_raw_command_auth (store, ex, &line, "head %u", i);
+ ret = camel_nntp_raw_command_auth (store, error, &line, "head %u", i);
/* unknown article, ignore */
if (ret == 423)
continue;
else if (ret == -1)
goto ioerror;
else if (ret != 221) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Unexpected server response from head: %s"), line);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Unexpected server response from head: %s"),
+ line);
goto ioerror;
}
line += 3;
@@ -406,9 +410,16 @@ error:
if (ret == -1) {
if (errno == EINTR)
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Use cancel"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User cancel"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Operation failed: %s"), g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Operation failed: %s"),
+ g_strerror (errno));
}
ioerror:
@@ -428,7 +439,7 @@ ioerror:
/* Assumes we have the stream */
/* Note: This will be called from camel_nntp_command, so only use camel_nntp_raw_command */
gint
-camel_nntp_summary_check (CamelNNTPSummary *cns, CamelNNTPStore *store, gchar *line, CamelFolderChangeInfo *changes, CamelException *ex)
+camel_nntp_summary_check (CamelNNTPSummary *cns, CamelNNTPStore *store, gchar *line, CamelFolderChangeInfo *changes, GError **error)
{
CamelFolderSummary *s;
gint ret = 0, i;
@@ -493,7 +504,7 @@ camel_nntp_summary_check (CamelNNTPSummary *cns, CamelNNTPStore *store, gchar *l
cns->low = f;
}
- camel_db_delete_uids (s->folder->parent_store->cdb_w, s->folder->full_name, del, ex);
+ camel_db_delete_uids (s->folder->parent_store->cdb_w, s->folder->full_name, del, NULL);
g_slist_foreach (del, (GFunc) g_free, NULL);
g_slist_free (del);
@@ -502,15 +513,15 @@ camel_nntp_summary_check (CamelNNTPSummary *cns, CamelNNTPStore *store, gchar *l
cns->high = f-1;
if (store->xover) {
- ret = add_range_xover (cns, store, l, cns->high+1, changes, ex);
+ ret = add_range_xover (cns, store, l, cns->high+1, changes, error);
} else {
- ret = add_range_head (cns, store, l, cns->high+1, changes, ex);
+ ret = add_range_head (cns, store, l, cns->high+1, changes, error);
}
}
/* TODO: not from here */
camel_folder_summary_touch (s);
- camel_folder_summary_save_to_db (s, ex);
+ camel_folder_summary_save_to_db (s, NULL);
update:
/* update store summary if we have it */
@@ -519,7 +530,7 @@ update:
guint32 unread = 0;
count = camel_folder_summary_count (s);
- camel_db_count_unread_message_info (s->folder->parent_store->cdb_r, s->folder->full_name, &unread, ex);
+ camel_db_count_unread_message_info (s->folder->parent_store->cdb_r, s->folder->full_name, &unread, NULL);
if (si->info.unread != unread
|| si->info.total != count
diff --git a/camel/providers/nntp/camel-nntp-summary.h b/camel/providers/nntp/camel-nntp-summary.h
index 59ef66b..bf4a4df 100644
--- a/camel/providers/nntp/camel-nntp-summary.h
+++ b/camel/providers/nntp/camel-nntp-summary.h
@@ -68,7 +68,7 @@ struct _CamelNNTPSummaryClass {
GType camel_nntp_summary_get_type (void);
CamelNNTPSummary *camel_nntp_summary_new(struct _CamelFolder *folder, const gchar *path);
-gint camel_nntp_summary_check(CamelNNTPSummary *cns, struct _CamelNNTPStore *store, gchar *line, struct _CamelFolderChangeInfo *changes, struct _CamelException *ex);
+gint camel_nntp_summary_check(CamelNNTPSummary *cns, struct _CamelNNTPStore *store, gchar *line, struct _CamelFolderChangeInfo *changes, struct _GError **error);
G_END_DECLS
diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c
index 3a307de..1c18f0c 100644
--- a/camel/providers/nntp/camel-nntp-utils.c
+++ b/camel/providers/nntp/camel-nntp-utils.c
@@ -31,7 +31,7 @@
static void
get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
- gint first_message, gint last_message, CamelException *ex)
+ gint first_message, gint last_message, GError **error)
{
gint status;
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
@@ -127,7 +127,7 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
#if 0
static GArray*
get_HEAD_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
- gint first_message, gint last_message, CamelException *ex)
+ gint first_message, gint last_message, GError **error)
{
gint i;
gint status;
@@ -246,7 +246,7 @@ uid_num (CamelFolderSummary *summary, gint index)
void
camel_nntp_get_headers (CamelStore *store,
CamelNNTPFolder *nntp_folder,
- CamelException *ex)
+ GError **error)
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
CamelFolder *folder = CAMEL_FOLDER (nntp_folder);
diff --git a/camel/providers/nntp/camel-nntp-utils.h b/camel/providers/nntp/camel-nntp-utils.h
index 986b3a5..494481e 100644
--- a/camel/providers/nntp/camel-nntp-utils.h
+++ b/camel/providers/nntp/camel-nntp-utils.h
@@ -27,7 +27,7 @@
G_BEGIN_DECLS
-void camel_nntp_get_headers (CamelStore *store, CamelNNTPFolder *nntp_folder, CamelException *ex);
+void camel_nntp_get_headers (CamelStore *store, CamelNNTPFolder *nntp_folder, GError **error);
G_END_DECLS
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 51c6c50..eb9b5d9 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -40,13 +40,13 @@
static gpointer parent_class;
-static void pop3_refresh_info (CamelFolder *folder, CamelException *ex);
-static void pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
+static gboolean pop3_refresh_info (CamelFolder *folder, GError **error);
+static gboolean pop3_sync (CamelFolder *folder, gboolean expunge, GError **error);
static gint pop3_get_message_count (CamelFolder *folder);
static GPtrArray *pop3_get_uids (CamelFolder *folder);
-static CamelMimeMessage *pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static CamelMimeMessage *pop3_get_message (CamelFolder *folder, const gchar *uid, GError **error);
static gboolean pop3_set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set);
-static gchar * pop3_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
+static gchar * pop3_get_filename (CamelFolder *folder, const gchar *uid, GError **error);
static void
pop3_folder_finalize (GObject *object)
@@ -117,7 +117,7 @@ camel_pop3_folder_get_type (void)
}
CamelFolder *
-camel_pop3_folder_new (CamelStore *parent, CamelException *ex)
+camel_pop3_folder_new (CamelStore *parent, GError **error)
{
CamelFolder *folder;
@@ -127,9 +127,8 @@ camel_pop3_folder_new (CamelStore *parent, CamelException *ex)
camel_folder_construct (folder, parent, "inbox", "inbox");
/* mt-ok, since we dont have the folder-lock for new() */
- camel_folder_refresh_info (folder, ex);/* mt-ok */
- if (camel_exception_is_set (ex)) {
- g_object_unref (CAMEL_OBJECT (folder));
+ if (!camel_folder_refresh_info (folder, error)) { /* mt-ok */
+ g_object_unref (folder);
folder = NULL;
}
@@ -248,12 +247,13 @@ cmd_uidl(CamelPOP3Engine *pe, CamelPOP3Stream *stream, gpointer data)
} while (ret>0);
}
-static void
-pop3_refresh_info (CamelFolder *folder, CamelException *ex)
+static gboolean
+pop3_refresh_info (CamelFolder *folder, GError **error)
{
CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store);
CamelPOP3Folder *pop3_folder = (CamelPOP3Folder *) folder;
CamelPOP3Command *pcl, *pcu = NULL;
+ gboolean success = TRUE;
gint i;
camel_operation_start (NULL, _("Retrieving POP summary"));
@@ -271,11 +271,17 @@ pop3_refresh_info (CamelFolder *folder, CamelException *ex)
if (i == -1) {
if (errno == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get POP summary: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_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? */
@@ -300,11 +306,14 @@ pop3_refresh_info (CamelFolder *folder, CamelException *ex)
g_hash_table_destroy(pop3_folder->uids_id);
camel_operation_end (NULL);
- return;
+
+ return success;
}
-static void
-pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+static gboolean
+pop3_sync (CamelFolder *folder,
+ gboolean expunge,
+ GError **error)
{
CamelPOP3Folder *pop3_folder;
CamelPOP3Store *pop3_store;
@@ -318,11 +327,11 @@ pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
d(printf("%s(%d): pop3_store->delete_after = [%d], expunge=[%d]\n",
__FILE__, __LINE__, pop3_store->delete_after, expunge));
camel_operation_start(NULL, _("Expunging old messages"));
- camel_pop3_delete_old(folder, pop3_store->delete_after,ex);
+ camel_pop3_delete_old(folder, pop3_store->delete_after, error);
}
if (!expunge) {
- return;
+ return TRUE;
}
camel_operation_start(NULL, _("Expunging deleted messages"));
@@ -365,7 +374,9 @@ pop3_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
camel_operation_end(NULL);
- camel_pop3_store_expunge (pop3_store, ex);
+ camel_pop3_store_expunge (pop3_store, error);
+
+ return TRUE;
}
static gboolean
@@ -411,7 +422,9 @@ pop3_get_message_time_from_cache (CamelFolder *folder, const gchar *uid, time_t
}
gint
-camel_pop3_delete_old(CamelFolder *folder, gint days_to_delete, CamelException *ex)
+camel_pop3_delete_old (CamelFolder *folder,
+ gint days_to_delete,
+ GError **error)
{
CamelPOP3Folder *pop3_folder;
CamelPOP3FolderInfo *fi;
@@ -475,7 +488,7 @@ camel_pop3_delete_old(CamelFolder *folder, gint days_to_delete, CamelException *
camel_operation_end(NULL);
- camel_pop3_store_expunge (pop3_store, ex);
+ camel_pop3_store_expunge (pop3_store, error);
return 0;
}
@@ -524,7 +537,7 @@ done:
}
static gchar *
-pop3_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+pop3_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelPOP3Folder *pop3_folder = (CamelPOP3Folder *)folder;
CamelPOP3Store *pop3_store = (CamelPOP3Store *)((CamelFolder *)pop3_folder)->parent_store;
@@ -532,8 +545,10 @@ pop3_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
fi = g_hash_table_lookup(pop3_folder->uids_uid, uid);
if (fi == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("No message with UID %s"), uid);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("No message with UID %s"), uid);
return NULL;
}
@@ -541,7 +556,7 @@ pop3_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
static CamelMimeMessage *
-pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+pop3_get_message (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelMimeMessage *message = NULL;
CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store);
@@ -554,8 +569,10 @@ pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
fi = g_hash_table_lookup(pop3_folder->uids_uid, uid);
if (fi == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("No message with UID %s"), uid);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("No message with UID %s"), uid);
return NULL;
}
@@ -581,11 +598,16 @@ pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
if (fi->err != 0) {
if (fi->err == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message %s: %s"),
- uid, g_strerror (fi->err));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Cannot get message %s: %s"),
+ uid, g_strerror (fi->err));
goto fail;
}
}
@@ -642,17 +664,24 @@ pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
/* Check to see we have safely written flag set */
if (fi->err != 0) {
if (fi->err == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
_("Cannot get message %s: %s"),
uid, g_strerror (fi->err));
goto done;
}
if (camel_stream_read(stream, buffer, 1) != 1 || buffer[0] != '#') {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message %s: %s"), uid, _("Unknown reason"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot get message %s: %s"),
+ uid, _("Unknown reason"));
goto done;
}
}
@@ -660,9 +689,14 @@ pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
message = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, stream) == -1) {
if (errno == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("User canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
_("Cannot get message %s: %s"),
uid, g_strerror (errno));
g_object_unref (message);
diff --git a/camel/providers/pop3/camel-pop3-folder.h b/camel/providers/pop3/camel-pop3-folder.h
index e40fe76..aba32a6 100644
--- a/camel/providers/pop3/camel-pop3-folder.h
+++ b/camel/providers/pop3/camel-pop3-folder.h
@@ -77,11 +77,11 @@ struct _CamelPOP3FolderClass {
};
/* public methods */
-CamelFolder *camel_pop3_folder_new (CamelStore *parent, CamelException *ex);
+CamelFolder *camel_pop3_folder_new (CamelStore *parent, GError **error);
GType camel_pop3_folder_get_type (void);
-gint camel_pop3_delete_old(CamelFolder *folder, gint days_to_delete, CamelException *ex);
+gint camel_pop3_delete_old(CamelFolder *folder, gint days_to_delete, GError **error);
G_END_DECLS
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 2dcd356..af8601b 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -46,16 +46,16 @@
static gpointer parent_class;
-static gboolean pop3_connect (CamelService *service, CamelException *ex);
-static gboolean pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex);
-static GList *query_auth_types (CamelService *service, CamelException *ex);
+static gboolean pop3_connect (CamelService *service, GError **error);
+static gboolean pop3_disconnect (CamelService *service, gboolean clean, GError **error);
+static GList *query_auth_types (CamelService *service, GError **error);
static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name,
- guint32 flags, CamelException *ex);
+ guint32 flags, GError **error);
-static CamelFolder *get_trash (CamelStore *store, CamelException *ex);
+static CamelFolder *get_trash (CamelStore *store, GError **error);
-static gboolean pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
+static gboolean pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error);
static void
pop3_store_finalize (GObject *object)
@@ -129,7 +129,10 @@ enum {
#endif
static gboolean
-connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
+connect_to_server (CamelService *service,
+ struct addrinfo *ai,
+ gint ssl_mode,
+ GError **error)
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
CamelStream *tcp_stream;
@@ -147,9 +150,11 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
}
#else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to %s: %s"),
- service->url->host, _("SSL unavailable"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not connect to %s: %s"),
+ service->url->host, _("SSL unavailable"));
return FALSE;
#endif /* HAVE_SSL */
@@ -158,10 +163,14 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
_("Connection canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host,
g_strerror (errno));
@@ -172,7 +181,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
}
/* parent class connect initialization */
- if (CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex) == FALSE) {
+ if (CAMEL_SERVICE_CLASS (parent_class)->connect (service, error) == FALSE) {
g_object_unref (tcp_stream);
return FALSE;
}
@@ -184,7 +193,8 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
store->delete_after = atoi(delete_days);
if (!(store->engine = camel_pop3_engine_new (tcp_stream, flags))) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
_("Failed to read a valid greeting from POP server %s"),
service->url->host);
g_object_unref (tcp_stream);
@@ -201,7 +211,8 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
clean_quit = FALSE;
if (!(store->engine->capa & CAMEL_POP3_CAP_STLS)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
_("Failed to connect to POP server %s in secure mode: %s"),
service->url->host, _("STLS not supported by server"));
goto stls_exception;
@@ -215,7 +226,8 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
camel_pop3_engine_command_free (store->engine, pc);
if (ret == FALSE) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
_("Failed to connect to POP server %s in secure mode: %s"),
service->url->host, store->engine->line);
goto stls_exception;
@@ -225,9 +237,10 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
ret = camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream));
if (ret == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to POP server %s in secure mode: %s"),
- service->url->host, _("TLS negotiations failed"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to connect to POP server %s in secure mode: %s"),
+ service->url->host, _("TLS negotiations failed"));
goto stls_exception;
}
#else
@@ -275,13 +288,15 @@ static struct {
};
static gboolean
-connect_to_server_wrapper (CamelService *service, CamelException *ex)
+connect_to_server_wrapper (CamelService *service,
+ GError **error)
{
struct addrinfo hints, *ai;
const gchar *ssl_mode;
gint mode, ret, i;
gchar *serv;
const gchar *port;
+ GError *local_error = NULL;
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
@@ -305,16 +320,19 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
- if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
- camel_exception_clear (ex);
- ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, &local_error);
+ if (ai == NULL && port != NULL &&
+ !g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL)) {
+ g_clear_error (&local_error);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, &local_error);
}
- if (ai == NULL)
+ if (ai == NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
- ret = connect_to_server (service, ai, mode, ex);
+ ret = connect_to_server (service, ai, mode, error);
camel_freeaddrinfo (ai);
@@ -325,22 +343,32 @@ extern CamelServiceAuthType camel_pop3_password_authtype;
extern CamelServiceAuthType camel_pop3_apop_authtype;
static GList *
-query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types (CamelService *service,
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
GList *types = NULL;
+ GError *local_error = NULL;
+
+ /* Chain up to parent's query_auth_types() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ types = service_class->query_auth_types (service, &local_error);
- types = CAMEL_SERVICE_CLASS (parent_class)->query_auth_types (service, ex);
- if (camel_exception_is_set (ex))
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return NULL;
+ }
if (connect_to_server_wrapper (service, NULL)) {
types = g_list_concat(types, g_list_copy(store->engine->auth));
pop3_disconnect (service, TRUE, NULL);
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to POP server %s"),
- service->url->host);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not connect to POP server %s"),
+ service->url->host);
}
return types;
@@ -356,7 +384,7 @@ query_auth_types (CamelService *service, CamelException *ex)
* reconnect.
**/
void
-camel_pop3_store_expunge (CamelPOP3Store *store, CamelException *ex)
+camel_pop3_store_expunge (CamelPOP3Store *store, GError **error)
{
CamelPOP3Command *pc;
@@ -365,11 +393,13 @@ camel_pop3_store_expunge (CamelPOP3Store *store, CamelException *ex)
;
camel_pop3_engine_command_free(store->engine, pc);
- camel_service_disconnect (CAMEL_SERVICE (store), FALSE, ex);
+ camel_service_disconnect (CAMEL_SERVICE (store), FALSE, error);
}
static gint
-try_sasl(CamelPOP3Store *store, const gchar *mech, CamelException *ex)
+try_sasl (CamelPOP3Store *store,
+ const gchar *mech,
+ GError **error)
{
CamelPOP3Stream *stream = store->engine->stream;
guchar *line, *resp;
@@ -379,10 +409,12 @@ try_sasl(CamelPOP3Store *store, const gchar *mech, CamelException *ex)
sasl = camel_sasl_new("pop", mech, (CamelService *)store);
if (sasl == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- _("Unable to connect to POP server %s: "
- "No support for requested authentication mechanism."),
- CAMEL_SERVICE (store)->url->host);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ _("Unable to connect to POP server %s: "
+ "No support for requested authentication mechanism."),
+ CAMEL_SERVICE (store)->url->host);
return -1;
}
@@ -395,21 +427,26 @@ try_sasl(CamelPOP3Store *store, const gchar *mech, CamelException *ex)
if (strncmp((gchar *) line, "+OK", 3) == 0)
break;
if (strncmp((gchar *) line, "-ERR", 4) == 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("SASL '%s' Login failed for POP server %s: %s"),
- mech, CAMEL_SERVICE (store)->url->host, line);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("SASL '%s' Login failed for POP server %s: %s"),
+ mech, CAMEL_SERVICE (store)->url->host, line);
goto done;
}
/* If we dont get continuation, or the sasl object's run out of work, or we dont get a challenge,
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, ex)) == NULL) {
+ || (resp = (guchar *) camel_sasl_challenge_base64(sasl, (const gchar *) line+2, error)) == NULL) {
camel_stream_printf((CamelStream *)stream, "*\r\n");
camel_pop3_stream_line(stream, &line, &len);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Cannot login to POP server %s: SASL Protocol error"),
- CAMEL_SERVICE (store)->url->host);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Cannot login to POP server %s: "
+ "SASL Protocol error"),
+ CAMEL_SERVICE (store)->url->host);
goto done;
}
@@ -424,11 +461,14 @@ try_sasl(CamelPOP3Store *store, const gchar *mech, CamelException *ex)
ioerror:
if (errno == EINTR) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL, _("Canceled"));
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to authenticate on POP server %s: %s"),
- CAMEL_SERVICE (store)->url->host, g_strerror (errno));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to authenticate on POP server %s: %s"),
+ CAMEL_SERVICE (store)->url->host, g_strerror (errno));
}
done:
g_object_unref (sasl);
@@ -436,7 +476,10 @@ try_sasl(CamelPOP3Store *store, const gchar *mech, CamelException *ex)
}
static gint
-pop3_try_authenticate (CamelService *service, gboolean reprompt, const gchar *errmsg, CamelException *ex)
+pop3_try_authenticate (CamelService *service,
+ gboolean reprompt,
+ const gchar *errmsg,
+ GError **error)
{
CamelPOP3Store *store = (CamelPOP3Store *)service;
CamelPOP3Command *pcu = NULL, *pcp = NULL;
@@ -464,7 +507,7 @@ pop3_try_authenticate (CamelService *service, gboolean reprompt, const gchar *er
service->url->passwd = camel_session_get_password (
camel_service_get_session (service), service,
- NULL, full_prompt, "password", flags, ex);
+ NULL, full_prompt, "password", flags, error);
g_free (base_prompt);
g_free (full_prompt);
@@ -485,9 +528,13 @@ pop3_try_authenticate (CamelService *service, gboolean reprompt, const gchar *er
if (!isascii((gint)*d)) {
/* README for Translators: The string APOP should not be translated */
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- _("Unable to connect to POP server %s: Invalid APOP ID received. Impersonation attack suspected. Please contact your admin."),
- CAMEL_SERVICE (store)->url->host);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ _("Unable to connect to POP server %s: "
+ "Invalid APOP ID received. Impersonation "
+ "attack suspected. Please contact your admin."),
+ CAMEL_SERVICE (store)->url->host);
return 0;
}
@@ -508,14 +555,16 @@ pop3_try_authenticate (CamelService *service, gboolean reprompt, const gchar *er
while (l) {
auth = l->data;
if (strcmp(auth->authproto, service->url->authmech) == 0)
- return try_sasl (store, service->url->authmech, ex);
+ return try_sasl (store, service->url->authmech, error);
l = l->next;
}
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- _("Unable to connect to POP server %s: "
- "No support for requested authentication mechanism."),
- CAMEL_SERVICE (store)->url->host);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ _("Unable to connect to POP server %s: "
+ "No support for requested authentication mechanism."),
+ CAMEL_SERVICE (store)->url->host);
return 0;
}
@@ -524,26 +573,38 @@ pop3_try_authenticate (CamelService *service, gboolean reprompt, const gchar *er
if (status == -1) {
if (errno == EINTR) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL, _("Canceled"));
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unable to connect to POP server %s.\n"
- "Error sending password: %s"),
- CAMEL_SERVICE (store)->url->host,
- errno ? g_strerror (errno) : _("Unknown error"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_SYSTEM,
+ _("Unable to connect to POP server %s.\n"
+ "Error sending password: %s"),
+ CAMEL_SERVICE (store)->url->host, errno ?
+ g_strerror (errno) : _("Unknown error"));
}
} else if (pcu && pcu->state != CAMEL_POP3_COMMAND_OK) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Unable to connect to POP server %s.\n"
- "Error sending username: %s"),
- CAMEL_SERVICE (store)->url->host,
- store->engine->line ? (gchar *)store->engine->line : _("Unknown error"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Unable to connect to POP server %s.\n"
+ "Error sending username: %s"),
+ CAMEL_SERVICE (store)->url->host,
+ store->engine->line ?
+ (gchar *)store->engine->line :
+ _("Unknown error"));
} else if (pcp->state != CAMEL_POP3_COMMAND_OK) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Unable to connect to POP server %s.\n"
- "Error sending password: %s"),
- CAMEL_SERVICE (store)->url->host,
- store->engine->line ? (gchar *)store->engine->line : _("Unknown error"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Unable to connect to POP server %s.\n"
+ "Error sending password: %s"),
+ CAMEL_SERVICE (store)->url->host,
+ store->engine->line ?
+ (gchar *)store->engine->line :
+ _("Unknown error"));
}
camel_pop3_engine_command_free (store->engine, pcp);
@@ -555,22 +616,24 @@ pop3_try_authenticate (CamelService *service, gboolean reprompt, const gchar *er
}
static gboolean
-pop3_connect (CamelService *service, CamelException *ex)
+pop3_connect (CamelService *service,
+ GError **error)
{
CamelPOP3Store *store = (CamelPOP3Store *)service;
gboolean reprompt = FALSE;
CamelSession *session;
gchar *errbuf = NULL;
gint status;
+ GError *local_error = NULL;
session = camel_service_get_session (service);
if (store->cache == NULL) {
gchar *root;
- root = camel_session_get_storage_path (session, service, ex);
+ root = camel_session_get_storage_path (session, service, error);
if (root) {
- store->cache = camel_data_cache_new(root, ex);
+ store->cache = camel_data_cache_new (root, error);
g_free(root);
if (store->cache) {
/* Default cache expiry - 1 week or not visited in a day */
@@ -580,23 +643,26 @@ pop3_connect (CamelService *service, CamelException *ex)
}
}
- if (!connect_to_server_wrapper (service, ex))
+ if (!connect_to_server_wrapper (service, error))
return FALSE;
while (1) {
- status = pop3_try_authenticate (service, reprompt, errbuf, ex);
+ status = pop3_try_authenticate (
+ service, reprompt, errbuf, &local_error);
g_free (errbuf);
errbuf = NULL;
- /* we only re-prompt if we failed to authenticate, any other error and we just abort */
- if (status == 0 && camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE) {
- gchar *tmp = camel_utf8_make_valid (camel_exception_get_description (ex));
+ /* we only re-prompt if we failed to authenticate,
+ * any other error and we just abort */
+ if (g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE)) {
+ gchar *tmp = camel_utf8_make_valid (local_error->message);
errbuf = g_markup_printf_escaped ("%s\n\n", tmp);
g_free (tmp);
- camel_exception_clear (ex);
- camel_session_forget_password (session, service, NULL, "password", ex);
- camel_exception_clear (ex);
+ g_clear_error (&local_error);
+
+ camel_session_forget_password (
+ session, service, NULL, "password", NULL);
g_free (service->url->passwd);
service->url->passwd = NULL;
@@ -607,12 +673,14 @@ pop3_connect (CamelService *service, CamelException *ex)
g_free (errbuf);
- if (status == -1 || camel_exception_is_set(ex)) {
- camel_service_disconnect(service, TRUE, ex);
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ camel_service_disconnect(service, TRUE, NULL);
return FALSE;
}
- /* Now that we are in the TRANSACTION state, try regetting the capabilities */
+ /* Now that we are in the TRANSACTION state,
+ * try regetting the capabilities */
store->engine->state = CAMEL_POP3_ENGINE_TRANSACTION;
camel_pop3_engine_reget_capabilities (store->engine);
@@ -620,8 +688,11 @@ pop3_connect (CamelService *service, CamelException *ex)
}
static gboolean
-pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+pop3_disconnect (CamelService *service,
+ gboolean clean,
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
if (clean) {
@@ -633,7 +704,9 @@ pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex)
camel_pop3_engine_command_free(store->engine, pc);
}
- if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex))
+ /* Chain up to parent's disconnect() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->disconnect (service, clean, error))
return FALSE;
g_object_unref (store->engine);
@@ -643,26 +716,31 @@ pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex)
}
static CamelFolder *
-get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+get_folder (CamelStore *store,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **error)
{
if (g_ascii_strcasecmp (folder_name, "inbox") != 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
- _("No such folder '%s'."), folder_name);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("No such folder '%s'."), folder_name);
return NULL;
}
- return camel_pop3_folder_new (store, ex);
+ return camel_pop3_folder_new (store, error);
}
static CamelFolder *
-get_trash (CamelStore *store, CamelException *ex)
+get_trash (CamelStore *store, GError **error)
{
/* no-op */
return NULL;
}
static gboolean
-pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
{
/* any pop3 folder can be refreshed */
return TRUE;
diff --git a/camel/providers/pop3/camel-pop3-store.h b/camel/providers/pop3/camel-pop3-store.h
index 31440d3..3b27aef 100644
--- a/camel/providers/pop3/camel-pop3-store.h
+++ b/camel/providers/pop3/camel-pop3-store.h
@@ -71,12 +71,12 @@ struct _CamelPOP3StoreClass {
GType camel_pop3_store_get_type (void);
/* public methods */
-void camel_pop3_store_expunge (CamelPOP3Store *store, CamelException *ex);
+void camel_pop3_store_expunge (CamelPOP3Store *store, GError **error);
/* support functions */
enum { CAMEL_POP3_OK, CAMEL_POP3_ERR, CAMEL_POP3_FAIL };
-gint camel_pop3_command (CamelPOP3Store *store, gchar **ret, CamelException *ex, gchar *fmt, ...);
-gchar *camel_pop3_command_get_additional_data (CamelPOP3Store *store, gint total, CamelException *ex);
+gint camel_pop3_command (CamelPOP3Store *store, gchar **ret, GError **error, gchar *fmt, ...);
+gchar *camel_pop3_command_get_additional_data (CamelPOP3Store *store, gint total, GError **error);
G_END_DECLS
diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c
index 94c59a2..9eb98c0 100644
--- a/camel/providers/sendmail/camel-sendmail-transport.c
+++ b/camel/providers/sendmail/camel-sendmail-transport.c
@@ -42,7 +42,7 @@ static gchar *get_name (CamelService *service, gboolean brief);
static gboolean sendmail_send_to (CamelTransport *transport,
CamelMimeMessage *message,
CamelAddress *from, CamelAddress *recipients,
- CamelException *ex);
+ GError **error);
static void
sendmail_transport_class_init (CamelSendmailTransportClass *class)
@@ -76,9 +76,11 @@ camel_sendmail_transport_get_type (void)
}
static gboolean
-sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message,
- CamelAddress *from, CamelAddress *recipients,
- CamelException *ex)
+sendmail_send_to (CamelTransport *transport,
+ CamelMimeMessage *message,
+ CamelAddress *from,
+ CamelAddress *recipients,
+ GError **error)
{
const gchar *from_addr, *addr, **argv;
gint i, len, fd[2], nullfd, wstat;
@@ -104,8 +106,9 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message,
for (i = 0; i < len; i++) {
if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (recipients), i, NULL, &addr)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not parse recipient list"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not parse recipient list"));
g_free (argv);
return FALSE;
}
@@ -121,10 +124,11 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message,
camel_header_raw_extract (header_queue, &bcc_queue, "Bcc");
if (pipe (fd) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create pipe to sendmail: "
- "%s: mail not sent"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not create pipe to sendmail: %s: "
+ "mail not sent"), g_strerror (errno));
/* restore the bcc headers */
camel_header_raw_append_queue (header_queue, &bcc_queue);
@@ -142,10 +146,11 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message,
pid = fork ();
switch (pid) {
case -1:
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not fork sendmail: "
- "%s: mail not sent"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not fork sendmail: %s: "
+ "mail not sent"), g_strerror (errno));
close (fd[0]);
close (fd[1]);
sigprocmask (SIG_SETMASK, &omask, NULL);
@@ -184,9 +189,11 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message,
if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1
|| camel_stream_close (out) == -1) {
g_object_unref (CAMEL_OBJECT (out));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not send message: %s"),
- g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not send message: %s"),
+ g_strerror (errno));
/* Wait for sendmail to exit. */
while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR)
@@ -212,22 +219,23 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message,
camel_header_raw_append_queue (header_queue, &bcc_queue);
if (!WIFEXITED (wstat)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("sendmail exited with signal %s: "
- "mail not sent."),
- g_strsignal (WTERMSIG (wstat)));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("sendmail exited with signal %s: mail not sent."),
+ g_strsignal (WTERMSIG (wstat)));
return FALSE;
} else if (WEXITSTATUS (wstat) != 0) {
if (WEXITSTATUS (wstat) == 255) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not execute %s: "
- "mail not sent."),
- SENDMAIL_PATH);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Could not execute %s: mail not sent."),
+ SENDMAIL_PATH);
} else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("sendmail exited with status "
- "%d: mail not sent."),
- WEXITSTATUS (wstat));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("sendmail exited with status %d: "
+ "mail not sent."),
+ WEXITSTATUS (wstat));
}
return FALSE;
}
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 9af0f2c..ff9ed7c 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -49,26 +49,26 @@
/* camel smtp transport class prototypes */
static gboolean smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
- CamelAddress *from, CamelAddress *recipients, CamelException *ex);
+ CamelAddress *from, CamelAddress *recipients, GError **error);
/* support prototypes */
-static gboolean smtp_connect (CamelService *service, CamelException *ex);
-static gboolean smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex);
+static gboolean smtp_connect (CamelService *service, GError **error);
+static gboolean smtp_disconnect (CamelService *service, gboolean clean, GError **error);
static GHashTable *esmtp_get_authtypes (const guchar *buffer);
-static GList *query_auth_types (CamelService *service, CamelException *ex);
+static GList *query_auth_types (CamelService *service, GError **error);
static gchar *get_name (CamelService *service, gboolean brief);
-static gboolean smtp_helo (CamelSmtpTransport *transport, CamelException *ex);
-static gboolean smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex);
+static gboolean smtp_helo (CamelSmtpTransport *transport, GError **error);
+static gboolean smtp_auth (CamelSmtpTransport *transport, const gchar *mech, GError **error);
static gboolean smtp_mail (CamelSmtpTransport *transport, const gchar *sender,
- gboolean has_8bit_parts, CamelException *ex);
-static gboolean smtp_rcpt (CamelSmtpTransport *transport, const gchar *recipient, CamelException *ex);
-static gboolean smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelException *ex);
-static gboolean smtp_rset (CamelSmtpTransport *transport, CamelException *ex);
-static gboolean smtp_quit (CamelSmtpTransport *transport, CamelException *ex);
+ gboolean has_8bit_parts, GError **error);
+static gboolean smtp_rcpt (CamelSmtpTransport *transport, const gchar *recipient, GError **error);
+static gboolean smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, GError **error);
+static gboolean smtp_rset (CamelSmtpTransport *transport, GError **error);
+static gboolean smtp_quit (CamelSmtpTransport *transport, GError **error);
static void smtp_set_exception (CamelSmtpTransport *transport, gboolean disconnect, const gchar *respbuf,
- const gchar *message, CamelException *ex);
+ const gchar *message, GError **error);
static gpointer parent_class;
@@ -196,14 +196,17 @@ enum {
#endif
static gboolean
-connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
+connect_to_server (CamelService *service,
+ struct addrinfo *ai,
+ gint ssl_mode,
+ GError **error)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelStream *tcp_stream;
gchar *respbuf = NULL;
gint ret;
- if (!CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex))
+ if (!CAMEL_SERVICE_CLASS (parent_class)->connect (service, error))
return FALSE;
/* set some smtp transport defaults */
@@ -230,12 +233,16 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection canceled"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("Connection canceled"));
else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to %s: %s"),
- service->url->host, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Could not connect to %s: %s"),
+ service->url->host, g_strerror (errno));
g_object_unref (tcp_stream);
@@ -256,7 +263,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
if (!respbuf || strncmp (respbuf, "220", 3)) {
- smtp_set_exception (transport, FALSE, respbuf, _("Welcome response error"), ex);
+ smtp_set_exception (transport, FALSE, respbuf, _("Welcome response error"), error);
g_free (respbuf);
return FALSE;
}
@@ -265,15 +272,15 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
/* Try sending EHLO */
transport->flags |= CAMEL_SMTP_TRANSPORT_IS_ESMTP;
- if (!smtp_helo (transport, ex)) {
+ if (!smtp_helo (transport, error)) {
if (!transport->connected)
return FALSE;
/* Fall back to HELO */
- camel_exception_clear (ex);
+ g_clear_error (error);
transport->flags &= ~CAMEL_SMTP_TRANSPORT_IS_ESMTP;
- if (!smtp_helo (transport, ex)) {
+ if (!smtp_helo (transport, error)) {
camel_service_disconnect ((CamelService *) transport, TRUE, NULL);
return FALSE;
@@ -281,7 +288,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
}
/* clear any EHLO/HELO exception and assume that any SMTP errors encountered were non-fatal */
- camel_exception_clear (ex);
+ g_clear_error (error);
if (ssl_mode != MODE_TLS) {
/* we're done */
@@ -290,18 +297,28 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
#ifdef HAVE_SSL
if (!(transport->flags & CAMEL_SMTP_TRANSPORT_STARTTLS)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to SMTP server %s in secure mode: %s"),
- service->url->host, _("STARTTLS not supported"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to connect to SMTP server %s in secure mode: %s"),
+ service->url->host, _("STARTTLS not supported"));
goto exception_cleanup;
}
d(fprintf (stderr, "sending : STARTTLS\r\n"));
if (camel_stream_write (tcp_stream, "STARTTLS\r\n", 10) == -1) {
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("STARTTLS command failed: %s"),
- g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("STARTTLS command failed: %s"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("STARTTLS command failed: %s"),
+ g_strerror (errno));
goto exception_cleanup;
}
@@ -315,7 +332,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "220", 3)) {
- smtp_set_exception (transport, FALSE, respbuf, _("STARTTLS command failed"), ex);
+ smtp_set_exception (transport, FALSE, respbuf, _("STARTTLS command failed"), error);
g_free (respbuf);
goto exception_cleanup;
}
@@ -323,21 +340,24 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, Ca
/* Okay, now toggle SSL/TLS mode */
if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to SMTP server %s in secure mode: %s"),
- service->url->host, g_strerror (errno));
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("Failed to connect to SMTP server %s in secure mode: %s"),
+ service->url->host, g_strerror (errno));
goto exception_cleanup;
}
#else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to SMTP server %s in secure mode: %s"),
- service->url->host, _("SSL is not available in this build"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Failed to connect to SMTP server %s in secure mode: %s"),
+ service->url->host, _("SSL is not available in this build"));
goto exception_cleanup;
#endif /* HAVE_SSL */
/* We are supposed to re-EHLO after a successful STARTTLS to
re-fetch any supported extensions. */
- if (!smtp_helo (transport, ex)) {
+ if (!smtp_helo (transport, error)) {
camel_service_disconnect ((CamelService *) transport, TRUE, NULL);
return FALSE;
@@ -371,13 +391,15 @@ static struct {
};
static gboolean
-connect_to_server_wrapper (CamelService *service, CamelException *ex)
+connect_to_server_wrapper (CamelService *service,
+ GError **error)
{
struct addrinfo hints, *ai;
const gchar *ssl_mode;
gint mode, ret, i;
gchar *serv;
const gchar *port;
+ GError *local_error = NULL;
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
@@ -401,16 +423,19 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
- if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
- camel_exception_clear (ex);
- ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, error);
+ if (ai == NULL && port != NULL &&
+ !g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL)) {
+ g_clear_error (&local_error);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, &local_error);
}
- if (ai == NULL)
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
- ret = connect_to_server (service, ai, mode, ex);
+ ret = connect_to_server (service, ai, mode, error);
camel_freeaddrinfo (ai);
@@ -418,7 +443,7 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
}
static gboolean
-smtp_connect (CamelService *service, CamelException *ex)
+smtp_connect (CamelService *service, GError **error)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
gboolean has_authtypes;
@@ -430,7 +455,7 @@ smtp_connect (CamelService *service, CamelException *ex)
CamelSasl *sasl;
sasl = camel_sasl_new ("smtp", "POPB4SMTP", service);
- chal = camel_sasl_challenge (sasl, NULL, ex);
+ chal = camel_sasl_challenge (sasl, NULL, error);
truth = camel_sasl_get_authenticated (sasl);
if (chal)
g_byte_array_free (chal, TRUE);
@@ -439,10 +464,10 @@ smtp_connect (CamelService *service, CamelException *ex)
if (!truth)
return FALSE;
- return connect_to_server_wrapper (service, ex);
+ return connect_to_server_wrapper (service, error);
}
- if (!connect_to_server_wrapper (service, ex))
+ if (!connect_to_server_wrapper (service, error))
return FALSE;
/* check to see if AUTH is required, if so...then AUTH ourselves */
@@ -455,19 +480,23 @@ smtp_connect (CamelService *service, CamelException *ex)
gchar *errbuf = NULL;
if (!g_hash_table_lookup (transport->authtypes, service->url->authmech)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("SMTP server %s does not support requested "
- "authentication type %s."),
- service->url->host, service->url->authmech);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("SMTP server %s does not support "
+ "requested authentication type %s."),
+ service->url->host, service->url->authmech);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("No support for authentication type %s"),
- service->url->authmech);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("No support for authentication type %s"),
+ service->url->authmech);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
@@ -475,7 +504,8 @@ smtp_connect (CamelService *service, CamelException *ex)
if (!authtype->need_password) {
/* authentication mechanism doesn't need a password,
so if it fails there's nothing we can do */
- authenticated = smtp_auth (transport, authtype->authproto, ex);
+ authenticated = smtp_auth (
+ transport, authtype->authproto, error);
if (!authenticated) {
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
@@ -486,6 +516,8 @@ smtp_connect (CamelService *service, CamelException *ex)
/* keep trying to login until either we succeed or the user cancels */
while (!authenticated) {
+ GError *local_error = NULL;
+
if (errbuf) {
/* We need to un-cache the password before prompting again */
camel_session_forget_password (session, service, NULL, "password", NULL);
@@ -507,7 +539,7 @@ smtp_connect (CamelService *service, CamelException *ex)
service->url->passwd = camel_session_get_password (
session, service, NULL, full_prompt,
- "password", password_flags, ex);
+ "password", password_flags, error);
g_free (base_prompt);
g_free (full_prompt);
@@ -520,17 +552,18 @@ smtp_connect (CamelService *service, CamelException *ex)
}
}
- authenticated = smtp_auth (transport, authtype->authproto, ex);
+ authenticated = smtp_auth (
+ transport, authtype->authproto, &local_error);
if (!authenticated) {
- if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL ||
- camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_UNAVAILABLE)
+ if (g_error_matches (local_error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL) ||
+ g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE))
return FALSE;
errbuf = g_markup_printf_escaped (
_("Unable to authenticate "
"to SMTP server.\n%s\n\n"),
- camel_exception_get_description (ex));
- camel_exception_clear (ex);
+ local_error->message);
+ g_clear_error (&local_error);
g_free (service->url->passwd);
service->url->passwd = NULL;
@@ -554,8 +587,11 @@ authtypes_free (gpointer key, gpointer value, gpointer data)
}
static gboolean
-smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+smtp_disconnect (CamelService *service,
+ gboolean clean,
+ GError **error)
{
+ CamelServiceClass *service_class;
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
/*if (!service->connected)
@@ -564,10 +600,12 @@ smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex)
if (transport->connected && clean) {
/* send the QUIT command to the SMTP server */
- smtp_quit (transport, ex);
+ smtp_quit (transport, NULL);
}
- if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex))
+ /* Chain up to parent's disconnect() method. */
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ if (!service_class->disconnect (service, clean, error))
return FALSE;
if (transport->authtypes) {
@@ -631,13 +669,13 @@ esmtp_get_authtypes (const guchar *buffer)
}
static GList *
-query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types (CamelService *service, GError **error)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelServiceAuthType *authtype;
GList *types, *t, *next;
- if (!connect_to_server_wrapper (service, ex))
+ if (!connect_to_server_wrapper (service, error))
return NULL;
types = g_list_copy (service->provider->authtypes);
@@ -670,7 +708,7 @@ get_name (CamelService *service, gboolean brief)
static gboolean
smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
CamelAddress *from, CamelAddress *recipients,
- CamelException *ex)
+ GError **error)
{
CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT (transport);
const CamelInternetAddress *cia;
@@ -679,14 +717,17 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
gint i, len;
if (!smtp_transport->connected) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
- _("Cannot send message: service not connected."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_NOT_CONNECTED,
+ _("Cannot send message: service not connected."));
return FALSE;
}
if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &addr)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot send message: sender address not valid."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot send message: sender address not valid."));
return FALSE;
}
@@ -697,15 +738,16 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
/* rfc1652 (8BITMIME) requires that you notify the ESMTP daemon that
you'll be sending an 8bit mime message at "MAIL FROM:" time. */
- if (!smtp_mail (smtp_transport, addr, has_8bit_parts, ex)) {
+ if (!smtp_mail (smtp_transport, addr, has_8bit_parts, error)) {
camel_operation_end (NULL);
return FALSE;
}
len = camel_address_length (recipients);
if (len == 0) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot send message: no recipients defined."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot send message: no recipients defined."));
camel_operation_end (NULL);
return FALSE;
}
@@ -715,14 +757,16 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
gchar *enc;
if (!camel_internet_address_get (cia, i, NULL, &addr)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot send message: one or more invalid recipients"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Cannot send message: "
+ "one or more invalid recipients"));
camel_operation_end (NULL);
return FALSE;
}
enc = camel_internet_address_encode_address(NULL, NULL, addr);
- if (!smtp_rcpt (smtp_transport, enc, ex)) {
+ if (!smtp_rcpt (smtp_transport, enc, error)) {
g_free(enc);
camel_operation_end (NULL);
return FALSE;
@@ -730,14 +774,13 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
g_free(enc);
}
- if (!smtp_data (smtp_transport, message, ex)) {
+ if (!smtp_data (smtp_transport, message, error)) {
camel_operation_end (NULL);
return FALSE;
}
/* reset the service for our next transfer session */
- if (!smtp_rset (smtp_transport, ex))
- camel_exception_clear (ex);
+ smtp_rset (smtp_transport, NULL);
camel_operation_end (NULL);
@@ -850,18 +893,28 @@ convert_to_local (GString *str)
}
static void
-smtp_set_exception (CamelSmtpTransport *transport, gboolean disconnect, const gchar *respbuf, const gchar *message, CamelException *ex)
+smtp_set_exception (CamelSmtpTransport *transport,
+ gboolean disconnect,
+ const gchar *respbuf,
+ const gchar *message,
+ GError **error)
{
const gchar *token, *rbuf = respbuf;
gchar *buffer = NULL;
GString *string;
- gint error;
+ gint errnum;
if (!respbuf) {
fake_status_code:
- error = respbuf ? atoi (respbuf) : 0;
- camel_exception_setv (ex, error == 0 && errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- "%s: %s", message, smtp_error_string (error));
+ errnum = respbuf ? atoi (respbuf) : 0;
+ if (errnum == 0 && errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ "%s: %s", message, smtp_error_string (errnum));
+ else
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ "%s: %s", message, smtp_error_string (errnum));
} else {
string = g_string_new ("");
do {
@@ -899,8 +952,9 @@ smtp_set_exception (CamelSmtpTransport *transport, gboolean disconnect, const gc
goto fake_status_code;
}
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "%s: %s", message, string->str);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ "%s: %s", message, string->str);
g_string_free (string, TRUE);
} else {
@@ -909,8 +963,9 @@ smtp_set_exception (CamelSmtpTransport *transport, gboolean disconnect, const gc
if (!buffer)
goto fake_status_code;
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "%s: %s", message, buffer);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ "%s: %s", message, buffer);
g_free (buffer);
}
@@ -926,7 +981,7 @@ smtp_set_exception (CamelSmtpTransport *transport, gboolean disconnect, const gc
}
static gboolean
-smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
+smtp_helo (CamelSmtpTransport *transport, GError **error)
{
gchar *name = NULL, *cmdbuf = NULL, *respbuf = NULL;
const gchar *token, *numeric = NULL;
@@ -969,8 +1024,18 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
d(fprintf (stderr, "sending : %s", cmdbuf));
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("HELO command failed: %s"), g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("HELO command failed: %s"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("HELO command failed: %s"),
+ g_strerror (errno));
camel_operation_end (NULL);
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
@@ -987,7 +1052,7 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) {
- smtp_set_exception (transport, FALSE, respbuf, _("HELO command failed"), ex);
+ smtp_set_exception (transport, FALSE, respbuf, _("HELO command failed"), error);
camel_operation_end (NULL);
g_free (respbuf);
@@ -1044,7 +1109,9 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
}
static gboolean
-smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
+smtp_auth (CamelSmtpTransport *transport,
+ const gchar *mech,
+ GError **error)
{
CamelService *service;
gchar *cmdbuf, *respbuf = NULL, *challenge;
@@ -1058,12 +1125,13 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
sasl = camel_sasl_new ("smtp", mech, service);
if (!sasl) {
camel_operation_end (NULL);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Error creating SASL authentication object."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
+ _("Error creating SASL authentication object."));
return FALSE;
}
- challenge = camel_sasl_challenge_base64 (sasl, NULL, ex);
+ challenge = camel_sasl_challenge_base64 (sasl, NULL, error);
if (challenge) {
auth_challenge = TRUE;
cmdbuf = g_strdup_printf ("AUTH %s %s\r\n", mech, challenge);
@@ -1075,8 +1143,17 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
d(fprintf (stderr, "sending : %s", cmdbuf));
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("AUTH command failed: %s"), g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ _("AUTH command failed: %s"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("AUTH command failed: %s"),
+ g_strerror (errno));
goto lose;
}
g_free (cmdbuf);
@@ -1086,14 +1163,24 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
while (!camel_sasl_get_authenticated (sasl)) {
if (!respbuf) {
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("AUTH command failed: %s"), g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("AUTH command failed: %s"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("AUTH command failed: %s"),
+ g_strerror (errno));
goto lose;
}
/* the server challenge/response should follow a 334 code */
if (strncmp (respbuf, "334", 3) != 0) {
- smtp_set_exception (transport, FALSE, respbuf, _("AUTH command failed"), ex);
+ smtp_set_exception (transport, FALSE, respbuf, _("AUTH command failed"), error);
goto lose;
}
@@ -1109,7 +1196,7 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
/* eat whtspc */
for (challenge = respbuf + 4; isspace (*challenge); challenge++);
- challenge = camel_sasl_challenge_base64 (sasl, challenge, ex);
+ challenge = camel_sasl_challenge_base64 (sasl, challenge, error);
if (challenge == NULL)
goto break_and_lose;
@@ -1120,6 +1207,10 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
g_free (challenge);
d(fprintf (stderr, "sending : %s", cmdbuf));
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Bad authentication response from server."));
g_free (cmdbuf);
goto lose;
}
@@ -1130,8 +1221,13 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
}
- if (respbuf == NULL)
+ if (respbuf == NULL) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Bad authentication response from server."));
goto lose;
+ }
/* Work around broken SASL implementations. */
if (auth_challenge && strncmp (respbuf, "334", 3) == 0)
@@ -1145,8 +1241,13 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
}
/* Catch any other errors. */
- if (strncmp (respbuf, "235", 3) != 0)
+ if (strncmp (respbuf, "235", 3) != 0) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Bad authentication response from server."));
goto lose;
+ }
g_object_unref (sasl);
camel_operation_end (NULL);
@@ -1161,11 +1262,6 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
lose:
- if (!camel_exception_is_set (ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Bad authentication response from server.\n"));
- }
-
g_object_unref (sasl);
camel_operation_end (NULL);
@@ -1175,7 +1271,7 @@ smtp_auth (CamelSmtpTransport *transport, const gchar *mech, CamelException *ex)
}
static gboolean
-smtp_mail (CamelSmtpTransport *transport, const gchar *sender, gboolean has_8bit_parts, CamelException *ex)
+smtp_mail (CamelSmtpTransport *transport, const gchar *sender, gboolean has_8bit_parts, GError **error)
{
/* we gotta tell the smtp server who we are. (our email addy) */
gchar *cmdbuf, *respbuf = NULL;
@@ -1189,9 +1285,17 @@ smtp_mail (CamelSmtpTransport *transport, const gchar *sender, gboolean has_8bit
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("MAIL FROM command failed: %s: mail not sent"),
- g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ _("MAIL FROM command failed: %s: mail not sent"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("MAIL FROM command failed: %s: mail not sent"),
+ g_strerror (errno));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
@@ -1207,7 +1311,7 @@ smtp_mail (CamelSmtpTransport *transport, const gchar *sender, gboolean has_8bit
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) {
- smtp_set_exception (transport, TRUE, respbuf, _("MAIL FROM command failed"), ex);
+ smtp_set_exception (transport, TRUE, respbuf, _("MAIL FROM command failed"), error);
g_free (respbuf);
return FALSE;
}
@@ -1218,7 +1322,7 @@ smtp_mail (CamelSmtpTransport *transport, const gchar *sender, gboolean has_8bit
}
static gboolean
-smtp_rcpt (CamelSmtpTransport *transport, const gchar *recipient, CamelException *ex)
+smtp_rcpt (CamelSmtpTransport *transport, const gchar *recipient, GError **error)
{
/* we gotta tell the smtp server who we are going to be sending
* our email to */
@@ -1230,9 +1334,17 @@ smtp_rcpt (CamelSmtpTransport *transport, const gchar *recipient, CamelException
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("RCPT TO command failed: %s: mail not sent"),
- g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ _("RCPT TO command failed: %s: mail not sent"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("RCPT TO command failed: %s: mail not sent"),
+ g_strerror (errno));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
@@ -1251,7 +1363,7 @@ smtp_rcpt (CamelSmtpTransport *transport, const gchar *recipient, CamelException
gchar *message;
message = g_strdup_printf (_("RCPT TO <%s> failed"), recipient);
- smtp_set_exception (transport, TRUE, respbuf, message, ex);
+ smtp_set_exception (transport, TRUE, respbuf, message, error);
g_free (message);
g_free (respbuf);
return FALSE;
@@ -1263,7 +1375,7 @@ smtp_rcpt (CamelSmtpTransport *transport, const gchar *recipient, CamelException
}
static gboolean
-smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelException *ex)
+smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, GError **error)
{
CamelBestencEncoding enctype = CAMEL_BESTENC_8BIT;
CamelStream *filtered_stream;
@@ -1291,9 +1403,17 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("DATA command failed: %s: mail not sent"),
- g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ _("DATA command failed: %s: mail not sent"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("DATA command failed: %s: mail not sent"),
+ g_strerror (errno));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
@@ -1309,7 +1429,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
/* we should have gotten instructions on how to use the DATA command:
* 354 Enter mail, end with "." on a line by itself
*/
- smtp_set_exception (transport, TRUE, respbuf, _("DATA command failed"), ex);
+ smtp_set_exception (transport, TRUE, respbuf, _("DATA command failed"), error);
g_free (respbuf);
return FALSE;
}
@@ -1352,9 +1472,17 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
camel_header_raw_append_queue (header_queue, &bcc_queue);
if (ret == -1) {
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("DATA command failed: %s: mail not sent"),
- g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ _("DATA command failed: %s: mail not sent"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("DATA command failed: %s: mail not sent"),
+ g_strerror (errno));
g_object_unref (filtered_stream);
@@ -1371,9 +1499,17 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
d(fprintf (stderr, "sending : \\r\\n.\\r\\n\n"));
if (camel_stream_write (transport->ostream, "\r\n.\r\n", 5) == -1) {
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("DATA command failed: %s: mail not sent"),
- g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_USER_CANCEL,
+ _("DATA command failed: %s: mail not sent"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("DATA command failed: %s: mail not sent"),
+ g_strerror (errno));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
@@ -1388,7 +1524,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) {
- smtp_set_exception (transport, TRUE, respbuf, _("DATA command failed"), ex);
+ smtp_set_exception (transport, TRUE, respbuf, _("DATA command failed"), error);
g_free (respbuf);
return FALSE;
}
@@ -1399,7 +1535,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
}
static gboolean
-smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
+smtp_rset (CamelSmtpTransport *transport, GError **error)
{
/* we are going to reset the smtp server (just to be nice) */
gchar *cmdbuf, *respbuf = NULL;
@@ -1410,8 +1546,18 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("RSET command failed: %s"), g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("RSET command failed: %s"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("RSET command failed: %s"),
+ g_strerror (errno));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
@@ -1427,7 +1573,9 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) {
- smtp_set_exception (transport, TRUE, respbuf, _("RSET command failed"), ex);
+ smtp_set_exception (
+ transport, TRUE, respbuf,
+ _("RSET command failed"), error);
g_free (respbuf);
return FALSE;
}
@@ -1438,7 +1586,7 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
}
static gboolean
-smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
+smtp_quit (CamelSmtpTransport *transport, GError **error)
{
/* we are going to reset the smtp server (just to be nice) */
gchar *cmdbuf, *respbuf = NULL;
@@ -1449,8 +1597,18 @@ smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("QUIT command failed: %s"), g_strerror (errno));
+ if (errno == EINTR)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_USER_CANCEL,
+ _("QUIT command failed: %s"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ _("QUIT command failed: %s"),
+ g_strerror (errno));
return FALSE;
}
@@ -1464,7 +1622,9 @@ smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "221", 3)) {
- smtp_set_exception (transport, FALSE, respbuf, _("QUIT command failed"), ex);
+ smtp_set_exception (
+ transport, FALSE, respbuf,
+ _("QUIT command failed"), error);
g_free (respbuf);
return FALSE;
}
diff --git a/camel/tests/folder/test1.c b/camel/tests/folder/test1.c
index 29a37ad..af9ee01 100644
--- a/camel/tests/folder/test1.c
+++ b/camel/tests/folder/test1.c
@@ -5,7 +5,6 @@
#include "folders.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test10.c b/camel/tests/folder/test10.c
index 175dc30..24f185b 100644
--- a/camel/tests/folder/test10.c
+++ b/camel/tests/folder/test10.c
@@ -9,7 +9,6 @@
#include "messages.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test11.c b/camel/tests/folder/test11.c
index fe20aaf..ab775a8 100644
--- a/camel/tests/folder/test11.c
+++ b/camel/tests/folder/test11.c
@@ -8,7 +8,6 @@
#include "camel-test-provider.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test2.c b/camel/tests/folder/test2.c
index a7c07cc..849ced1 100644
--- a/camel/tests/folder/test2.c
+++ b/camel/tests/folder/test2.c
@@ -10,7 +10,6 @@
#include "folders.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test3.c b/camel/tests/folder/test3.c
index 97fb0c6..81e54a8 100644
--- a/camel/tests/folder/test3.c
+++ b/camel/tests/folder/test3.c
@@ -8,7 +8,6 @@
#include "folders.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test4.c b/camel/tests/folder/test4.c
index a24b5b9..5dc53d0 100644
--- a/camel/tests/folder/test4.c
+++ b/camel/tests/folder/test4.c
@@ -5,7 +5,6 @@
#include "folders.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test5.c b/camel/tests/folder/test5.c
index d2cbbe4..3f8ef24 100644
--- a/camel/tests/folder/test5.c
+++ b/camel/tests/folder/test5.c
@@ -5,7 +5,6 @@
#include "folders.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test6.c b/camel/tests/folder/test6.c
index 900a87b..cd1e657 100644
--- a/camel/tests/folder/test6.c
+++ b/camel/tests/folder/test6.c
@@ -5,7 +5,6 @@
#include "folders.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test7.c b/camel/tests/folder/test7.c
index 7dec571..2b97032 100644
--- a/camel/tests/folder/test7.c
+++ b/camel/tests/folder/test7.c
@@ -6,7 +6,6 @@
#include "messages.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test8.c b/camel/tests/folder/test8.c
index b4cf7ff..203485f 100644
--- a/camel/tests/folder/test8.c
+++ b/camel/tests/folder/test8.c
@@ -9,7 +9,6 @@
#include "messages.h"
#include "session.h"
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
#include <camel/camel-store.h>
diff --git a/camel/tests/folder/test9.c b/camel/tests/folder/test9.c
index ad46335..aa1f4ba 100644
--- a/camel/tests/folder/test9.c
+++ b/camel/tests/folder/test9.c
@@ -8,7 +8,6 @@
#include "folders.h"
#include "session.h"
-#include "camel/camel-exception.h"
#include "camel/camel-service.h"
#include "camel/camel-store.h"
diff --git a/camel/tests/lib/camel-test-provider.c b/camel/tests/lib/camel-test-provider.c
index f2904f1..1734b48 100644
--- a/camel/tests/lib/camel-test-provider.c
+++ b/camel/tests/lib/camel-test-provider.c
@@ -1,7 +1,6 @@
#include "camel-test-provider.h"
#include "camel-test.h"
-#include "camel-exception.h"
#include "camel-provider.h"
diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c
index 3d752c4..c7059f5 100644
--- a/camel/tests/lib/folders.c
+++ b/camel/tests/lib/folders.c
@@ -4,8 +4,6 @@
#include "folders.h"
#include "messages.h"
-#include "camel/camel-exception.h"
-
/* check the total/unread is what we think it should be */
void
test_folder_counts(CamelFolder *folder, gint total, gint unread)
diff --git a/camel/tests/misc/split.c b/camel/tests/misc/split.c
index f459248..8d1f748 100644
--- a/camel/tests/misc/split.c
+++ b/camel/tests/misc/split.c
@@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>
#include <libedataserver/e-sexp.h>
-#include <camel/camel-exception.h>
#include <camel/camel-search-private.h>
#include "camel-test.h"
diff --git a/camel/tests/misc/url.c b/camel/tests/misc/url.c
index 207e0fb..b3b186c 100644
--- a/camel/tests/misc/url.c
+++ b/camel/tests/misc/url.c
@@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>
#include <camel/camel-url.h>
-#include <camel/camel-exception.h>
#include "camel-test.h"
diff --git a/camel/tests/misc/utf7.c b/camel/tests/misc/utf7.c
index dfbe534..94dfe83 100644
--- a/camel/tests/misc/utf7.c
+++ b/camel/tests/misc/utf7.c
@@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>
#include <camel/camel-utf8.h>
-#include <camel/camel-exception.h>
#include "camel-test.h"
diff --git a/docs/reference/camel/tmpl/camel-cipher-context.sgml b/docs/reference/camel/tmpl/camel-cipher-context.sgml
index eb3f1d1..65842c9 100644
--- a/docs/reference/camel/tmpl/camel-cipher-context.sgml
+++ b/docs/reference/camel/tmpl/camel-cipher-context.sgml
@@ -140,7 +140,7 @@ CamelCipherContext
@hash:
@ipart:
@opart:
- ex:
+ error:
@Returns:
@@ -151,7 +151,7 @@ CamelCipherContext
@context:
@ipart:
- ex:
+ error:
@Returns:
@@ -165,7 +165,7 @@ CamelCipherContext
@recipients:
@ipart:
@opart:
- ex:
+ error:
@Returns:
@@ -177,7 +177,7 @@ CamelCipherContext
@context:
@ipart:
@opart:
- ex:
+ error:
@Returns:
@@ -188,7 +188,7 @@ CamelCipherContext
@context:
@istream:
- ex:
+ error:
@Returns:
@@ -200,7 +200,7 @@ CamelCipherContext
@context:
@keys:
@ostream:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-data-cache.sgml b/docs/reference/camel/tmpl/camel-data-cache.sgml
index d2c094f..9f6251f 100644
--- a/docs/reference/camel/tmpl/camel-data-cache.sgml
+++ b/docs/reference/camel/tmpl/camel-data-cache.sgml
@@ -34,7 +34,7 @@ CamelDataCache
</para>
@path:
- ex:
+ error:
@Returns:
@@ -82,7 +82,7 @@ CamelDataCache
@cache:
@old:
@new:
- ex:
+ error:
@Returns:
@@ -94,7 +94,7 @@ CamelDataCache
@cdc:
@path:
@key:
- ex:
+ error:
@Returns:
@@ -106,7 +106,7 @@ CamelDataCache
@cdc:
@path:
@key:
- ex:
+ error:
@Returns:
@@ -118,7 +118,7 @@ CamelDataCache
@cdc:
@path:
@key:
- ex:
+ error:
@Returns:
@@ -129,7 +129,7 @@ CamelDataCache
@cache:
@path:
- ex:
+ error:
@Returns:
@@ -141,7 +141,7 @@ CamelDataCache
@cdc:
@path:
@key:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-db.sgml b/docs/reference/camel/tmpl/camel-db.sgml
index 71e9f2a..e4b3933 100644
--- a/docs/reference/camel/tmpl/camel-db.sgml
+++ b/docs/reference/camel/tmpl/camel-db.sgml
@@ -164,7 +164,7 @@ CamelDB
</para>
@path:
- ex:
+ error:
@Returns:
@@ -174,7 +174,7 @@ CamelDB
</para>
@cdb:
- ex:
+ error:
@Returns:
@@ -193,7 +193,7 @@ CamelDB
@cdb:
@stmt:
- ex:
+ error:
@Returns:
@@ -204,7 +204,7 @@ CamelDB
@cdb:
@qry_list:
- ex:
+ error:
@Returns:
@@ -214,7 +214,7 @@ CamelDB
</para>
@cdb:
- ex:
+ error:
@Returns:
@@ -225,7 +225,7 @@ CamelDB
@cdb:
@query:
- ex:
+ error:
@Returns:
@@ -235,7 +235,7 @@ CamelDB
</para>
@cdb:
- ex:
+ error:
@Returns:
@@ -245,7 +245,7 @@ CamelDB
</para>
@cdb:
- ex:
+ error:
@Returns:
@@ -256,7 +256,7 @@ CamelDB
@cdb:
@folder:
- ex:
+ error:
@Returns:
@@ -268,7 +268,7 @@ CamelDB
@cdb:
@old_folder:
@new_folder:
- ex:
+ error:
@Returns:
@@ -279,7 +279,7 @@ CamelDB
@cdb:
@folder:
- ex:
+ error:
@Returns:
@@ -291,7 +291,7 @@ CamelDB
@cdb:
@folder:
@uid:
- ex:
+ error:
@Returns:
@@ -303,7 +303,7 @@ CamelDB
@cdb:
@folder_name:
@uids:
- ex:
+ error:
@Returns:
@@ -316,7 +316,7 @@ CamelDB
@folder_name:
@shash:
@uids:
- ex:
+ error:
@Returns:
@@ -326,7 +326,7 @@ CamelDB
</para>
@cdb:
- ex:
+ error:
@Returns:
@@ -339,7 +339,7 @@ CamelDB
@stmt:
@callback:
@data:
- ex:
+ error:
@Returns:
@@ -350,7 +350,7 @@ CamelDB
@cdb:
@record:
- ex:
+ error:
@Returns:
@@ -362,7 +362,7 @@ CamelDB
@cdb:
@folder_name:
@record:
- ex:
+ error:
@Returns:
@@ -373,7 +373,7 @@ CamelDB
@cdb:
@folder_name:
- ex:
+ error:
@Returns:
@@ -385,7 +385,7 @@ CamelDB
@cdb:
@folder_name:
@record:
- ex:
+ error:
@Returns:
@@ -397,7 +397,7 @@ CamelDB
@cdb:
@folder_name:
@record:
- ex:
+ error:
@Returns:
@@ -410,7 +410,7 @@ CamelDB
@folder_name:
@p:
@read_mir_callback:
- ex:
+ error:
@Returns:
@@ -424,7 +424,7 @@ CamelDB
@uid:
@p:
@read_mir_callback:
- ex:
+ error:
@Returns:
@@ -436,7 +436,7 @@ CamelDB
@cdb:
@table_name:
@count:
- ex:
+ error:
@Returns:
@@ -448,7 +448,7 @@ CamelDB
@cdb:
@table_name:
@count:
- ex:
+ error:
@Returns:
@@ -460,7 +460,7 @@ CamelDB
@cdb:
@table_name:
@count:
- ex:
+ error:
@Returns:
@@ -472,7 +472,7 @@ CamelDB
@cdb:
@table_name:
@count:
- ex:
+ error:
@Returns:
@@ -484,7 +484,7 @@ CamelDB
@cdb:
@table_name:
@count:
- ex:
+ error:
@Returns:
@@ -496,7 +496,7 @@ CamelDB
@cdb:
@table_name:
@count:
- ex:
+ error:
@Returns:
@@ -508,7 +508,7 @@ CamelDB
@cdb:
@table_name:
@count:
- ex:
+ error:
@Returns:
@@ -520,7 +520,7 @@ CamelDB
@cdb:
@query:
@count:
- ex:
+ error:
@Returns:
@@ -539,7 +539,7 @@ CamelDB
@db:
@folder_name:
- ex:
+ error:
@Returns:
@@ -550,7 +550,7 @@ CamelDB
@db:
@folder_name:
- ex:
+ error:
@Returns:
@@ -562,7 +562,7 @@ CamelDB
@db:
@folder_name:
@vuid:
- ex:
+ error:
@Returns:
@@ -574,7 +574,7 @@ CamelDB
@db:
@folder_name:
@vuid:
- ex:
+ error:
@Returns:
@@ -586,7 +586,7 @@ CamelDB
@db:
@folder_name:
@filter:
- ex:
+ error:
@Returns:
@@ -598,7 +598,7 @@ CamelDB
@db:
@folder_name:
@vuid:
- ex:
+ error:
@Returns:
@@ -610,7 +610,7 @@ CamelDB
@db:
@folder_name:
@vuid:
- ex:
+ error:
@Returns:
@@ -624,7 +624,7 @@ CamelDB
@sort_by:
@collate:
@array:
- ex:
+ error:
@Returns:
@@ -639,7 +639,7 @@ CamelDB
@collate:
@summary:
@table:
- ex:
+ error:
@Returns:
@@ -650,7 +650,7 @@ CamelDB
@db:
@folder_name:
- ex:
+ error:
@Returns:
@@ -661,7 +661,7 @@ CamelDB
@db:
@folder_name:
- ex:
+ error:
@Returns:
@@ -710,7 +710,7 @@ CamelDB
@cdb:
@folder:
- ex:
+ error:
@Returns:
@@ -720,7 +720,7 @@ CamelDB
</para>
@cdb:
- ex:
+ error:
@Returns:
@@ -731,7 +731,7 @@ CamelDB
@cdb:
@folder_name:
- ex:
+ error:
@Returns:
@@ -742,7 +742,7 @@ CamelDB
@db:
@folder_name:
- ex:
+ error:
@Returns:
@@ -755,7 +755,7 @@ CamelDB
@folder_name:
@uid:
@msg:
- ex:
+ error:
@Returns:
@@ -767,7 +767,7 @@ CamelDB
@cdb:
@folder_name:
@reset_version:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-disco-diary.sgml b/docs/reference/camel/tmpl/camel-disco-diary.sgml
index 2114195..f661bb7 100644
--- a/docs/reference/camel/tmpl/camel-disco-diary.sgml
+++ b/docs/reference/camel/tmpl/camel-disco-diary.sgml
@@ -50,7 +50,7 @@ CamelDiscoDiary
@store:
@filename:
- ex:
+ error:
@Returns:
@@ -79,7 +79,7 @@ CamelDiscoDiary
</para>
@diary:
- ex:
+ error:
<!-- ##### FUNCTION camel_disco_diary_uidmap_add ##### -->
diff --git a/docs/reference/camel/tmpl/camel-disco-folder.sgml b/docs/reference/camel/tmpl/camel-disco-folder.sgml
index 1635928..db199f3 100644
--- a/docs/reference/camel/tmpl/camel-disco-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-disco-folder.sgml
@@ -30,7 +30,8 @@ CamelDiscoFolder
@folder:
@uids:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_disco_folder_cache_message ##### -->
@@ -40,7 +41,8 @@ CamelDiscoFolder
@disco_folder:
@uid:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_disco_folder_prepare_for_offline ##### -->
@@ -50,6 +52,7 @@ CamelDiscoFolder
@disco_folder:
@expression:
- ex:
+ error:
+ Returns:
diff --git a/docs/reference/camel/tmpl/camel-disco-store.sgml b/docs/reference/camel/tmpl/camel-disco-store.sgml
index ea7c191..fe0e02a 100644
--- a/docs/reference/camel/tmpl/camel-disco-store.sgml
+++ b/docs/reference/camel/tmpl/camel-disco-store.sgml
@@ -48,7 +48,7 @@ CamelDiscoStore
@store:
@status:
- ex:
+ error:
<!-- ##### FUNCTION camel_disco_store_can_work_offline ##### -->
@@ -66,7 +66,7 @@ CamelDiscoStore
</para>
@store:
- ex:
+ error:
@Returns:
@@ -76,6 +76,6 @@ CamelDiscoStore
</para>
@store:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-exception.sgml b/docs/reference/camel/tmpl/camel-exception.sgml
index c7b3685..1fa40be 100644
--- a/docs/reference/camel/tmpl/camel-exception.sgml
+++ b/docs/reference/camel/tmpl/camel-exception.sgml
@@ -17,112 +17,3 @@ camel-exception
<!-- ##### SECTION Stability_Level ##### -->
-<!-- ##### ENUM ExceptionId ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### STRUCT CamelException ##### -->
-<para>
-
-</para>
-
- id:
- desc:
-
-<!-- ##### MACRO CAMEL_EXCEPTION_INITIALISER ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### FUNCTION camel_exception_new ##### -->
-<para>
-
-</para>
-
- Returns:
-
-
-<!-- ##### FUNCTION camel_exception_free ##### -->
-<para>
-
-</para>
-
- ex:
-
-
-<!-- ##### FUNCTION camel_exception_init ##### -->
-<para>
-
-</para>
-
- ex:
-
-
-<!-- ##### FUNCTION camel_exception_clear ##### -->
-<para>
-
-</para>
-
- ex:
-
-
-<!-- ##### FUNCTION camel_exception_set ##### -->
-<para>
-
-</para>
-
- ex:
- id:
- desc:
-
-
-<!-- ##### FUNCTION camel_exception_setv ##### -->
-<para>
-
-</para>
-
- ex:
- id:
- format:
- Varargs:
-
-
-<!-- ##### FUNCTION camel_exception_xfer ##### -->
-<para>
-
-</para>
-
- ex_dst:
- ex_src:
-
-
-<!-- ##### FUNCTION camel_exception_get_id ##### -->
-<para>
-
-</para>
-
- ex:
- Returns:
-
-
-<!-- ##### FUNCTION camel_exception_get_description ##### -->
-<para>
-
-</para>
-
- ex:
- Returns:
-
-
-<!-- ##### MACRO camel_exception_is_set ##### -->
-<para>
-
-</para>
-
- ex:
-
-
diff --git a/docs/reference/camel/tmpl/camel-filter-driver.sgml b/docs/reference/camel/tmpl/camel-filter-driver.sgml
index 2c4ca18..9a98ae9 100644
--- a/docs/reference/camel/tmpl/camel-filter-driver.sgml
+++ b/docs/reference/camel/tmpl/camel-filter-driver.sgml
@@ -31,7 +31,7 @@ CamelFilterDriver
@driver:
@uri:
@data:
- ex:
+ error:
@Returns:
@@ -139,7 +139,7 @@ CamelFilterDriver
</para>
@driver:
- ex:
+ error:
<!-- ##### FUNCTION camel_filter_driver_filter_message ##### -->
@@ -154,7 +154,7 @@ CamelFilterDriver
@source:
@source_url:
@original_source_url:
- ex:
+ error:
@Returns:
@@ -166,7 +166,7 @@ CamelFilterDriver
@driver:
@mbox:
@original_source_url:
- ex:
+ error:
@Returns:
@@ -180,7 +180,7 @@ CamelFilterDriver
@cache:
@uids:
@remove:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-filter-search.sgml b/docs/reference/camel/tmpl/camel-filter-search.sgml
index 6228efe..02b5a52 100644
--- a/docs/reference/camel/tmpl/camel-filter-search.sgml
+++ b/docs/reference/camel/tmpl/camel-filter-search.sgml
@@ -23,7 +23,7 @@ camel-filter-search
</para>
@data:
- ex:
+ error:
@Returns:
@@ -38,7 +38,7 @@ camel-filter-search
@info:
@source:
@expression:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-folder-search.sgml b/docs/reference/camel/tmpl/camel-folder-search.sgml
index 8ba597c..84ad7c4 100644
--- a/docs/reference/camel/tmpl/camel-folder-search.sgml
+++ b/docs/reference/camel/tmpl/camel-folder-search.sgml
@@ -73,7 +73,7 @@ CamelFolderSearch
@search:
@expr:
- ex:
+ error:
@Returns:
@@ -85,7 +85,7 @@ CamelFolderSearch
@search:
@expr:
@uids:
- ex:
+ error:
@Returns:
@@ -96,7 +96,7 @@ CamelFolderSearch
@search:
@expr:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-folder-summary.sgml b/docs/reference/camel/tmpl/camel-folder-summary.sgml
index 1e5856b..9d7da0e 100644
--- a/docs/reference/camel/tmpl/camel-folder-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-folder-summary.sgml
@@ -239,7 +239,7 @@ CamelFolderSummary
</para>
@s:
- ex:
+ error:
@Returns:
@@ -249,7 +249,7 @@ CamelFolderSummary
</para>
@s:
- ex:
+ error:
@Returns:
@@ -270,7 +270,7 @@ CamelFolderSummary
@s:
@store:
@folder_name:
- ex:
+ error:
@Returns:
@@ -280,7 +280,7 @@ CamelFolderSummary
</para>
@s:
- ex:
+ error:
@Returns:
@@ -335,7 +335,7 @@ CamelFolderSummary
</para>
@s:
- ex:
+ error:
@Returns:
@@ -346,7 +346,7 @@ CamelFolderSummary
@s:
@at_least:
- ex:
+ error:
<!-- ##### FUNCTION camel_folder_summary_insert ##### -->
diff --git a/docs/reference/camel/tmpl/camel-folder.sgml b/docs/reference/camel/tmpl/camel-folder.sgml
index ae679b6..1cfc6db 100644
--- a/docs/reference/camel/tmpl/camel-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-folder.sgml
@@ -110,7 +110,8 @@ CamelFolder
</para>
@folder:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_folder_sync ##### -->
@@ -120,7 +121,8 @@ CamelFolder
@folder:
@expunge:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_folder_get_parent_store ##### -->
@@ -138,7 +140,8 @@ CamelFolder
</para>
@folder:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_folder_get_name ##### -->
@@ -243,7 +246,8 @@ CamelFolder
@message:
@info:
@appended_uid:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_folder_has_summary_capability ##### -->
@@ -307,7 +311,7 @@ CamelFolder
@folder:
@uid:
- ex:
+ error:
@Returns:
@@ -318,7 +322,8 @@ CamelFolder
@folder:
@uid:
- ex:
+ error:
+ Returns:
<!-- ##### MACRO camel_folder_delete_message ##### -->
@@ -355,7 +360,7 @@ CamelFolder
@Param1:
@uids:
- Param3:
+ error:
@Returns:
@@ -395,7 +400,7 @@ CamelFolder
@folder:
@expr:
- ex:
+ error:
@Returns:
@@ -407,7 +412,7 @@ CamelFolder
@folder:
@expr:
@uids:
- ex:
+ error:
@Returns:
@@ -427,7 +432,7 @@ CamelFolder
@folder:
@expression:
- ex:
+ error:
@Returns:
@@ -469,7 +474,8 @@ CamelFolder
@dest:
@transferred_uids:
@delete_originals:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_folder_delete ##### -->
@@ -585,7 +591,7 @@ CamelFolder
@folder:
@uid:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-groupwise-folder.sgml b/docs/reference/camel/tmpl/camel-groupwise-folder.sgml
index 2b966c0..c1aedda 100644
--- a/docs/reference/camel/tmpl/camel-groupwise-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-groupwise-folder.sgml
@@ -39,7 +39,7 @@ CamelGroupwiseFolder
@store:
@folder_dir:
@folder_name:
- ex:
+ error:
@Returns:
@@ -50,6 +50,6 @@ CamelGroupwiseFolder
@folder:
@item_list:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-groupwise-journal.sgml b/docs/reference/camel/tmpl/camel-groupwise-journal.sgml
index c84cd7e..b2956cc 100644
--- a/docs/reference/camel/tmpl/camel-groupwise-journal.sgml
+++ b/docs/reference/camel/tmpl/camel-groupwise-journal.sgml
@@ -54,7 +54,7 @@ CamelGroupwiseJournal
@message:
@mi:
@appended_uid:
- ex:
+ error:
<!-- ##### FUNCTION camel_groupwise_journal_transfer ##### -->
@@ -68,6 +68,6 @@ CamelGroupwiseJournal
@mi:
@orginal_uid:
@transferred_uid:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-groupwise-store.sgml b/docs/reference/camel/tmpl/camel-groupwise-store.sgml
index d9a2db1..8cef245 100644
--- a/docs/reference/camel/tmpl/camel-groupwise-store.sgml
+++ b/docs/reference/camel/tmpl/camel-groupwise-store.sgml
@@ -115,7 +115,7 @@ CamelGroupwiseStore
</para>
@store:
- ex:
+ error:
@Returns:
@@ -127,7 +127,7 @@ CamelGroupwiseStore
@store:
@folder:
@flags:
- ex:
+ error:
<!-- ##### FUNCTION groupwise_store_set_current_folder ##### -->
diff --git a/docs/reference/camel/tmpl/camel-imap-command.sgml b/docs/reference/camel/tmpl/camel-imap-command.sgml
index 8438be1..c670886 100644
--- a/docs/reference/camel/tmpl/camel-imap-command.sgml
+++ b/docs/reference/camel/tmpl/camel-imap-command.sgml
@@ -43,7 +43,7 @@ camel-imap-command
@store:
@folder:
- ex:
+ error:
@fmt:
@Varargs:
@Returns:
@@ -57,7 +57,7 @@ camel-imap-command
@store:
@cmd:
@cmdlen:
- ex:
+ error:
@Returns:
@@ -87,7 +87,7 @@ camel-imap-command
@store:
@response:
@type:
- ex:
+ error:
@Returns:
@@ -98,7 +98,7 @@ camel-imap-command
@store:
@response:
- ex:
+ error:
@Returns:
@@ -109,7 +109,7 @@ camel-imap-command
@store:
@folder:
- ex:
+ error:
@fmt:
@Varargs:
@Returns:
@@ -122,7 +122,7 @@ camel-imap-command
@store:
@response:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap-folder.sgml b/docs/reference/camel/tmpl/camel-imap-folder.sgml
index 9d4d279..07e08f4 100644
--- a/docs/reference/camel/tmpl/camel-imap-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-imap-folder.sgml
@@ -40,7 +40,7 @@ CamelImapFolder
@parent:
@folder_name:
@folder_dir:
- ex:
+ error:
@Returns:
@@ -51,7 +51,8 @@ CamelImapFolder
@folder:
@response:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_imap_folder_changed ##### -->
@@ -62,7 +63,8 @@ CamelImapFolder
@folder:
@exists:
@expunged:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_imap_folder_fetch_data ##### -->
@@ -74,7 +76,7 @@ CamelImapFolder
@uid:
@section_text:
@cache_only:
- ex:
+ error:
@Returns:
@@ -87,7 +89,8 @@ CamelImapFolder
@message:
@info:
@appended_uid:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION imap_transfer_resyncing ##### -->
@@ -100,7 +103,8 @@ CamelImapFolder
@dest:
@transferred_uids:
@delete_originals:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION imap_expunge_uids_resyncing ##### -->
@@ -110,6 +114,7 @@ CamelImapFolder
@folder:
@uids:
- ex:
+ error:
+ Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap-message-cache.sgml b/docs/reference/camel/tmpl/camel-imap-message-cache.sgml
index 191ea19..827a945 100644
--- a/docs/reference/camel/tmpl/camel-imap-message-cache.sgml
+++ b/docs/reference/camel/tmpl/camel-imap-message-cache.sgml
@@ -35,7 +35,7 @@ CamelImapMessageCache
@path:
@summary:
- ex:
+ error:
@Returns:
@@ -67,7 +67,7 @@ CamelImapMessageCache
@part_spec:
@data:
@len:
- ex:
+ error:
@Returns:
@@ -80,7 +80,7 @@ CamelImapMessageCache
@uid:
@part_spec:
@data_stream:
- ex:
+ error:
<!-- ##### FUNCTION camel_imap_message_cache_insert_wrapper ##### -->
@@ -92,7 +92,7 @@ CamelImapMessageCache
@uid:
@part_spec:
@wrapper:
- ex:
+ error:
<!-- ##### FUNCTION camel_imap_message_cache_get ##### -->
@@ -103,7 +103,7 @@ CamelImapMessageCache
@cache:
@uid:
@part_spec:
- ex:
+ error:
@Returns:
@@ -115,7 +115,7 @@ CamelImapMessageCache
@cache:
@uid:
@part_spec:
- ex:
+ error:
@Returns:
@@ -145,7 +145,7 @@ CamelImapMessageCache
@source_uid:
@dest:
@dest_uid:
- ex:
+ error:
<!-- ##### FUNCTION camel_imap_message_cache_delete ##### -->
@@ -154,7 +154,7 @@ CamelImapMessageCache
</para>
@path:
- ex:
+ error:
@Returns:
@@ -165,7 +165,7 @@ CamelImapMessageCache
@Param1:
@uids:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap-store.sgml b/docs/reference/camel/tmpl/camel-imap-store.sgml
index 25a717a..738d4d2 100644
--- a/docs/reference/camel/tmpl/camel-imap-store.sgml
+++ b/docs/reference/camel/tmpl/camel-imap-store.sgml
@@ -314,7 +314,7 @@ CamelImapStore
</para>
@store:
- ex:
+ error:
@Returns:
@@ -325,7 +325,7 @@ CamelImapStore
@store:
@dest:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap4-command.sgml b/docs/reference/camel/tmpl/camel-imap4-command.sgml
index 4dba211..03b6915 100644
--- a/docs/reference/camel/tmpl/camel-imap4-command.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-command.sgml
@@ -55,7 +55,7 @@ camel-imap4-command
@ic:
@linebuf:
@linelen:
- ex:
+ error:
@Returns:
@@ -68,7 +68,7 @@ camel-imap4-command
@ic:
@index:
@token:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap4-engine.sgml b/docs/reference/camel/tmpl/camel-imap4-engine.sgml
index e773c5c..3727697 100644
--- a/docs/reference/camel/tmpl/camel-imap4-engine.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-engine.sgml
@@ -116,7 +116,7 @@ CamelIMAP4Engine
</para>
@engine:
- ex:
+ error:
@Returns:
@@ -137,7 +137,7 @@ CamelIMAP4Engine
@engine:
@stream:
- ex:
+ error:
@Returns:
@@ -155,7 +155,7 @@ CamelIMAP4Engine
</para>
@engine:
- ex:
+ error:
@Returns:
@@ -165,7 +165,7 @@ CamelIMAP4Engine
</para>
@engine:
- ex:
+ error:
@Returns:
@@ -176,7 +176,7 @@ CamelIMAP4Engine
@engine:
@folder:
- ex:
+ error:
@Returns:
@@ -229,7 +229,7 @@ CamelIMAP4Engine
@engine:
@token:
- ex:
+ error:
@Returns:
@@ -239,7 +239,7 @@ CamelIMAP4Engine
</para>
@engine:
- ex:
+ error:
<!-- ##### FUNCTION camel_imap4_engine_next_token ##### -->
@@ -249,7 +249,7 @@ CamelIMAP4Engine
@engine:
@token:
- ex:
+ error:
@Returns:
@@ -261,7 +261,7 @@ CamelIMAP4Engine
@engine:
@line:
@len:
- ex:
+ error:
@Returns:
@@ -273,7 +273,7 @@ CamelIMAP4Engine
@engine:
@literal:
@len:
- ex:
+ error:
@Returns:
@@ -284,7 +284,7 @@ CamelIMAP4Engine
@engine:
@nstring:
- ex:
+ error:
@Returns:
@@ -294,7 +294,7 @@ CamelIMAP4Engine
</para>
@engine:
- ex:
+ error:
@Returns:
@@ -304,7 +304,7 @@ CamelIMAP4Engine
</para>
@engine:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap4-folder.sgml b/docs/reference/camel/tmpl/camel-imap4-folder.sgml
index 42448be..bbad80a 100644
--- a/docs/reference/camel/tmpl/camel-imap4-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-folder.sgml
@@ -38,7 +38,7 @@ CamelIMAP4Folder
@store:
@full_name:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap4-journal.sgml b/docs/reference/camel/tmpl/camel-imap4-journal.sgml
index 2095412..9812a36 100644
--- a/docs/reference/camel/tmpl/camel-imap4-journal.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-journal.sgml
@@ -60,6 +60,6 @@ CamelIMAP4Journal
@message:
@mi:
@appended_uid:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-imap4-summary.sgml b/docs/reference/camel/tmpl/camel-imap4-summary.sgml
index e2c78bc..1fb3c98 100644
--- a/docs/reference/camel/tmpl/camel-imap4-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-summary.sgml
@@ -122,7 +122,7 @@ CamelIMAP4Summary
</para>
@summary:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-imap4-utils.sgml b/docs/reference/camel/tmpl/camel-imap4-utils.sgml
index eb2ad9c..f351e20 100644
--- a/docs/reference/camel/tmpl/camel-imap4-utils.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-utils.sgml
@@ -120,7 +120,7 @@ camel-imap4-utils
</para>
- ex:
+ error:
@engine:
@token:
@@ -132,7 +132,7 @@ camel-imap4-utils
@engine:
@flags:
- ex:
+ error:
@Returns:
@@ -168,7 +168,7 @@ camel-imap4-utils
@ic:
@index:
@token:
- ex:
+ error:
@Returns:
@@ -206,7 +206,7 @@ camel-imap4-utils
@ic:
@index:
@token:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-local-folder.sgml b/docs/reference/camel/tmpl/camel-local-folder.sgml
index a0f2f11..d326cfd 100644
--- a/docs/reference/camel/tmpl/camel-local-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-local-folder.sgml
@@ -44,7 +44,7 @@ CamelLocalFolder
@parent_store:
@full_name:
@flags:
- ex:
+ error:
@Returns:
@@ -55,7 +55,7 @@ CamelLocalFolder
@lf:
@type:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-local-summary.sgml b/docs/reference/camel/tmpl/camel-local-summary.sgml
index 37238be..d91dcca 100644
--- a/docs/reference/camel/tmpl/camel-local-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-local-summary.sgml
@@ -54,7 +54,7 @@ CamelLocalSummary
@cls:
@forceindex:
- ex:
+ error:
@Returns:
@@ -65,7 +65,7 @@ CamelLocalSummary
@cls:
@Param2:
- ex:
+ error:
@Returns:
@@ -77,7 +77,7 @@ CamelLocalSummary
@cls:
@expunge:
@Param3:
- ex:
+ error:
@Returns:
@@ -90,7 +90,7 @@ CamelLocalSummary
@msg:
@info:
@Param4:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-lock-client.sgml b/docs/reference/camel/tmpl/camel-lock-client.sgml
index a073844..24e73d2 100644
--- a/docs/reference/camel/tmpl/camel-lock-client.sgml
+++ b/docs/reference/camel/tmpl/camel-lock-client.sgml
@@ -23,7 +23,7 @@ camel-lock-client
</para>
@path:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-lock.sgml b/docs/reference/camel/tmpl/camel-lock.sgml
index 3176915..891840a 100644
--- a/docs/reference/camel/tmpl/camel-lock.sgml
+++ b/docs/reference/camel/tmpl/camel-lock.sgml
@@ -66,7 +66,7 @@ camel-lock
</para>
@path:
- ex:
+ error:
@Returns:
@@ -77,7 +77,7 @@ camel-lock
@fd:
@type:
- ex:
+ error:
@Returns:
@@ -88,7 +88,7 @@ camel-lock
@fd:
@type:
- ex:
+ error:
@Returns:
@@ -124,7 +124,7 @@ camel-lock
@path:
@fd:
@type:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-maildir-folder.sgml b/docs/reference/camel/tmpl/camel-maildir-folder.sgml
index 95b400d..27d2e46 100644
--- a/docs/reference/camel/tmpl/camel-maildir-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-maildir-folder.sgml
@@ -32,7 +32,7 @@ CamelMaildirFolder
@parent_store:
@full_name:
@flags:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-mbox-folder.sgml b/docs/reference/camel/tmpl/camel-mbox-folder.sgml
index 4db83e0..1696aea 100644
--- a/docs/reference/camel/tmpl/camel-mbox-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-mbox-folder.sgml
@@ -33,7 +33,7 @@ CamelMboxFolder
@parent_store:
@full_name:
@flags:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-mbox-summary.sgml b/docs/reference/camel/tmpl/camel-mbox-summary.sgml
index 42b2e59..336b83b 100644
--- a/docs/reference/camel/tmpl/camel-mbox-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-mbox-summary.sgml
@@ -81,7 +81,7 @@ CamelMboxSummary
@changeinfo:
@fd:
@fdout:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-mh-folder.sgml b/docs/reference/camel/tmpl/camel-mh-folder.sgml
index 4c1daf4..10aeebd 100644
--- a/docs/reference/camel/tmpl/camel-mh-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-mh-folder.sgml
@@ -32,7 +32,7 @@ CamelMhFolder
@parent_store:
@full_name:
@flags:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-movemail.sgml b/docs/reference/camel/tmpl/camel-movemail.sgml
index f47ffc0..2199c47 100644
--- a/docs/reference/camel/tmpl/camel-movemail.sgml
+++ b/docs/reference/camel/tmpl/camel-movemail.sgml
@@ -24,7 +24,7 @@ camel-movemail
@source:
@dest:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-multipart-signed.sgml b/docs/reference/camel/tmpl/camel-multipart-signed.sgml
index 5b52b15..18d4d76 100644
--- a/docs/reference/camel/tmpl/camel-multipart-signed.sgml
+++ b/docs/reference/camel/tmpl/camel-multipart-signed.sgml
@@ -37,7 +37,7 @@ CamelMultipartSigned
</para>
@mps:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-net-utils.sgml b/docs/reference/camel/tmpl/camel-net-utils.sgml
index 3f3da61..d4fb65f 100644
--- a/docs/reference/camel/tmpl/camel-net-utils.sgml
+++ b/docs/reference/camel/tmpl/camel-net-utils.sgml
@@ -158,7 +158,7 @@ camel-net-utils
@name:
@service:
@hints:
- ex:
+ error:
@Returns:
@@ -180,7 +180,7 @@ camel-net-utils
@host:
@serv:
@flags:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-nntp-auth.sgml b/docs/reference/camel/tmpl/camel-nntp-auth.sgml
index b18d7b0..12cc0b2 100644
--- a/docs/reference/camel/tmpl/camel-nntp-auth.sgml
+++ b/docs/reference/camel/tmpl/camel-nntp-auth.sgml
@@ -23,7 +23,7 @@ camel-nntp-auth
</para>
@store:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-nntp-folder.sgml b/docs/reference/camel/tmpl/camel-nntp-folder.sgml
index 61fb2ed..27c674c 100644
--- a/docs/reference/camel/tmpl/camel-nntp-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-nntp-folder.sgml
@@ -35,7 +35,7 @@ CamelNNTPFolder
@parent:
@folder_name:
- ex:
+ error:
@Returns:
@@ -46,6 +46,7 @@ CamelNNTPFolder
@folder:
@line:
- ex:
+ error:
+ Returns:
diff --git a/docs/reference/camel/tmpl/camel-nntp-grouplist.sgml b/docs/reference/camel/tmpl/camel-nntp-grouplist.sgml
index cd46a81..2b0e81e 100644
--- a/docs/reference/camel/tmpl/camel-nntp-grouplist.sgml
+++ b/docs/reference/camel/tmpl/camel-nntp-grouplist.sgml
@@ -35,7 +35,7 @@ camel-nntp-grouplist
</para>
@store:
- ex:
+ error:
@Returns:
@@ -45,7 +45,7 @@ camel-nntp-grouplist
</para>
@group_list:
- ex:
+ error:
@Returns:
@@ -55,7 +55,7 @@ camel-nntp-grouplist
</para>
@group_list:
- ex:
+ error:
<!-- ##### FUNCTION camel_nntp_grouplist_free ##### -->
diff --git a/docs/reference/camel/tmpl/camel-nntp-store.sgml b/docs/reference/camel/tmpl/camel-nntp-store.sgml
index 4eb41de..38f50ea 100644
--- a/docs/reference/camel/tmpl/camel-nntp-store.sgml
+++ b/docs/reference/camel/tmpl/camel-nntp-store.sgml
@@ -118,7 +118,7 @@ CamelNNTPStore
</para>
@store:
- ex:
+ error:
@line:
@fmt:
@ap:
@@ -131,7 +131,7 @@ CamelNNTPStore
</para>
@store:
- ex:
+ error:
@line:
@fmt:
@Varargs:
@@ -144,7 +144,7 @@ CamelNNTPStore
</para>
@store:
- ex:
+ error:
@line:
@fmt:
@Varargs:
@@ -157,7 +157,7 @@ CamelNNTPStore
</para>
@store:
- ex:
+ error:
@folder:
@line:
@fmt:
diff --git a/docs/reference/camel/tmpl/camel-nntp-summary.sgml b/docs/reference/camel/tmpl/camel-nntp-summary.sgml
index 53e1332..aa8b0cd 100644
--- a/docs/reference/camel/tmpl/camel-nntp-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-nntp-summary.sgml
@@ -47,7 +47,7 @@ CamelNNTPSummary
@store:
@line:
@changes:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-nntp-utils.sgml b/docs/reference/camel/tmpl/camel-nntp-utils.sgml
index dbac1c0..2cd21d2 100644
--- a/docs/reference/camel/tmpl/camel-nntp-utils.sgml
+++ b/docs/reference/camel/tmpl/camel-nntp-utils.sgml
@@ -24,6 +24,6 @@ camel-nntp-utils
@store:
@nntp_folder:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-object.sgml b/docs/reference/camel/tmpl/camel-object.sgml
index 223de70..d86b939 100644
--- a/docs/reference/camel/tmpl/camel-object.sgml
+++ b/docs/reference/camel/tmpl/camel-object.sgml
@@ -116,7 +116,7 @@ CamelObject
</para>
@obj:
- ex:
+ error:
@Varargs:
@Returns:
@@ -127,7 +127,7 @@ CamelObject
</para>
@obj:
- ex:
+ error:
@Param3:
@Returns:
@@ -138,7 +138,7 @@ CamelObject
</para>
@obj:
- ex:
+ error:
@Varargs:
@Returns:
@@ -149,7 +149,7 @@ CamelObject
</para>
@obj:
- ex:
+ error:
@Param3:
@Returns:
@@ -160,7 +160,7 @@ CamelObject
</para>
@vo:
- ex:
+ error:
@tag:
@Returns:
@@ -171,7 +171,7 @@ CamelObject
</para>
@vo:
- ex:
+ error:
@tag:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-offline-folder.sgml b/docs/reference/camel/tmpl/camel-offline-folder.sgml
index 250e5f2..8a9160c 100644
--- a/docs/reference/camel/tmpl/camel-offline-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-offline-folder.sgml
@@ -30,6 +30,6 @@ CamelOfflineFolder
@offline:
@expression:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-offline-journal.sgml b/docs/reference/camel/tmpl/camel-offline-journal.sgml
index 9d732d7..824967e 100644
--- a/docs/reference/camel/tmpl/camel-offline-journal.sgml
+++ b/docs/reference/camel/tmpl/camel-offline-journal.sgml
@@ -54,7 +54,7 @@ CamelOfflineJournal
</para>
@journal:
- ex:
+ error:
@Returns:
@@ -64,7 +64,7 @@ CamelOfflineJournal
</para>
@journal:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-offline-store.sgml b/docs/reference/camel/tmpl/camel-offline-store.sgml
index 728e593..147181e 100644
--- a/docs/reference/camel/tmpl/camel-offline-store.sgml
+++ b/docs/reference/camel/tmpl/camel-offline-store.sgml
@@ -30,7 +30,7 @@ CamelOfflineStore
@store:
@state:
- ex:
+ error:
<!-- ##### FUNCTION camel_offline_store_get_network_state ##### -->
@@ -39,7 +39,7 @@ CamelOfflineStore
</para>
@store:
- ex:
+ error:
@Returns:
@@ -49,6 +49,6 @@ CamelOfflineStore
</para>
@store:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-pop3-folder.sgml b/docs/reference/camel/tmpl/camel-pop3-folder.sgml
index 2ceb77d..4f0e282 100644
--- a/docs/reference/camel/tmpl/camel-pop3-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-pop3-folder.sgml
@@ -47,7 +47,7 @@ CamelPOP3Folder
</para>
@parent:
- ex:
+ error:
@Returns:
@@ -58,7 +58,7 @@ CamelPOP3Folder
@folder:
@days_to_delete:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-pop3-store.sgml b/docs/reference/camel/tmpl/camel-pop3-store.sgml
index 89cf08b..f35f077 100644
--- a/docs/reference/camel/tmpl/camel-pop3-store.sgml
+++ b/docs/reference/camel/tmpl/camel-pop3-store.sgml
@@ -33,7 +33,7 @@ CamelPOP3Store
</para>
@store:
- ex:
+ error:
<!-- ##### FUNCTION camel_pop3_command ##### -->
@@ -43,7 +43,7 @@ CamelPOP3Store
@store:
@ret:
- ex:
+ error:
@fmt:
@Varargs:
@Returns:
@@ -56,7 +56,7 @@ CamelPOP3Store
@store:
@total:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-process.sgml b/docs/reference/camel/tmpl/camel-process.sgml
index b67d4ec..959857a 100644
--- a/docs/reference/camel/tmpl/camel-process.sgml
+++ b/docs/reference/camel/tmpl/camel-process.sgml
@@ -27,7 +27,7 @@ camel-process
@infd:
@outfd:
@errfd:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-provider.sgml b/docs/reference/camel/tmpl/camel-provider.sgml
index 13d3cde..8dbf4f1 100644
--- a/docs/reference/camel/tmpl/camel-provider.sgml
+++ b/docs/reference/camel/tmpl/camel-provider.sgml
@@ -397,7 +397,7 @@ camel-provider
@url:
@auto_detected:
- ex:
+ error:
@Returns:
@@ -446,7 +446,8 @@ camel-provider
</para>
@path:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_provider_register ##### -->
@@ -472,7 +473,7 @@ camel-provider
</para>
@url_string:
- ex:
+ error:
@Returns:
@@ -491,7 +492,7 @@ camel-provider
@provider:
@url:
@auto_detected:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-sasl.sgml b/docs/reference/camel/tmpl/camel-sasl.sgml
index 13fff82..e06c0bc 100644
--- a/docs/reference/camel/tmpl/camel-sasl.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl.sgml
@@ -50,7 +50,7 @@ CamelSasl
@sasl:
@token:
- ex:
+ error:
@Returns:
@@ -61,7 +61,7 @@ CamelSasl
@sasl:
@token:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-service.sgml b/docs/reference/camel/tmpl/camel-service.sgml
index b384dcb..b4c3625 100644
--- a/docs/reference/camel/tmpl/camel-service.sgml
+++ b/docs/reference/camel/tmpl/camel-service.sgml
@@ -87,7 +87,8 @@ CamelService
@session:
@provider:
@url:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_service_connect ##### -->
@@ -96,7 +97,7 @@ CamelService
</para>
@service:
- ex:
+ error:
@Returns:
@@ -107,7 +108,7 @@ CamelService
@service:
@clean:
- ex:
+ error:
@Returns:
@@ -171,7 +172,7 @@ CamelService
</para>
@service:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-session.sgml b/docs/reference/camel/tmpl/camel-session.sgml
index e868e6a..b68e809 100644
--- a/docs/reference/camel/tmpl/camel-session.sgml
+++ b/docs/reference/camel/tmpl/camel-session.sgml
@@ -56,7 +56,7 @@ CamelSession
@msg:
@id:
- ex:
+ error:
@ops:
@op:
@session:
@@ -79,7 +79,7 @@ CamelSession
@session:
@url_string:
@type:
- ex:
+ error:
@Returns:
@@ -91,7 +91,7 @@ CamelSession
@session:
@url_string:
@type:
- ex:
+ error:
@Returns:
@@ -122,7 +122,7 @@ CamelSession
@session:
@service:
- ex:
+ error:
@Returns:
@@ -137,7 +137,7 @@ CamelSession
@prompt:
@item:
@flags:
- ex:
+ error:
@Returns:
@@ -150,7 +150,7 @@ CamelSession
@service:
@domain:
@item:
- ex:
+ error:
<!-- ##### FUNCTION camel_session_alert_user ##### -->
@@ -201,7 +201,7 @@ CamelSession
@session:
@type:
- ex:
+ error:
@Returns:
@@ -320,6 +320,6 @@ CamelSession
@folder:
@message:
@address:
- ex:
+ error:
diff --git a/docs/reference/camel/tmpl/camel-spool-folder.sgml b/docs/reference/camel/tmpl/camel-spool-folder.sgml
index 06fef6b..4ab6b21 100644
--- a/docs/reference/camel/tmpl/camel-spool-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-spool-folder.sgml
@@ -34,7 +34,7 @@ CamelSpoolFolder
@parent_store:
@full_name:
@flags:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-spool-summary.sgml b/docs/reference/camel/tmpl/camel-spool-summary.sgml
index 3fd7936..1c2da32 100644
--- a/docs/reference/camel/tmpl/camel-spool-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-spool-summary.sgml
@@ -52,7 +52,7 @@ CamelSpoolSummary
@cls:
@forceindex:
- ex:
+ error:
@Returns:
@@ -63,7 +63,7 @@ CamelSpoolSummary
@cls:
@Param2:
- ex:
+ error:
@Returns:
@@ -75,7 +75,7 @@ CamelSpoolSummary
@cls:
@expunge:
@Param3:
- ex:
+ error:
@Returns:
@@ -88,7 +88,7 @@ CamelSpoolSummary
@msg:
@info:
@Param4:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-store.sgml b/docs/reference/camel/tmpl/camel-store.sgml
index f531d09..c9ff49b 100644
--- a/docs/reference/camel/tmpl/camel-store.sgml
+++ b/docs/reference/camel/tmpl/camel-store.sgml
@@ -306,7 +306,7 @@ CamelStore
@store:
@folder_name:
@flags:
- ex:
+ error:
@Returns:
@@ -316,7 +316,7 @@ CamelStore
</para>
@store:
- ex:
+ error:
@Returns:
@@ -326,7 +326,7 @@ CamelStore
</para>
@store:
- ex:
+ error:
@Returns:
@@ -336,7 +336,7 @@ CamelStore
</para>
@store:
- ex:
+ error:
@Returns:
@@ -348,7 +348,7 @@ CamelStore
@store:
@parent_name:
@folder_name:
- ex:
+ error:
@Returns:
@@ -359,7 +359,8 @@ CamelStore
@store:
@folder_name:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_store_rename_folder ##### -->
@@ -370,7 +371,8 @@ CamelStore
@store:
@old_namein:
@new_name:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_store_sync ##### -->
@@ -380,7 +382,8 @@ CamelStore
@store:
@expunge:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_store_get_folder_info ##### -->
@@ -391,7 +394,7 @@ CamelStore
@store:
@top:
@flags:
- ex:
+ error:
@Returns:
@@ -485,7 +488,8 @@ CamelStore
@store:
@folder_name:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_store_unsubscribe_folder ##### -->
@@ -495,7 +499,8 @@ CamelStore
@store:
@folder_name:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_store_noop ##### -->
@@ -504,7 +509,8 @@ CamelStore
</para>
@store:
- ex:
+ error:
+ Returns:
<!-- ##### FUNCTION camel_store_folder_uri_equal ##### -->
@@ -525,7 +531,7 @@ CamelStore
@store:
@info:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-transport.sgml b/docs/reference/camel/tmpl/camel-transport.sgml
index 4f43ce0..557ee9e 100644
--- a/docs/reference/camel/tmpl/camel-transport.sgml
+++ b/docs/reference/camel/tmpl/camel-transport.sgml
@@ -32,7 +32,7 @@ CamelTransport
@message:
@from:
@recipients:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-unused.sgml b/docs/reference/camel/tmpl/camel-unused.sgml
index 911549f..4a9ee9d 100644
--- a/docs/reference/camel/tmpl/camel-unused.sgml
+++ b/docs/reference/camel/tmpl/camel-unused.sgml
@@ -264,6 +264,12 @@ camel-types
@instance:
@g_type:
+<!-- ##### MACRO CAMEL_EXCEPTION_INITIALISER ##### -->
+<para>
+
+</para>
+
+
<!-- ##### MACRO CAMEL_GROUPWISE_FOLDER_LOCK ##### -->
<para>
@@ -407,6 +413,12 @@ camel-types
</para>
+<!-- ##### STRUCT CamelException ##### -->
+<para>
+
+</para>
+
+
<!-- ##### SIGNAL CamelFolder::deleted ##### -->
<para>
@@ -664,6 +676,12 @@ camel-types
</para>
+<!-- ##### ENUM ExceptionId ##### -->
+<para>
+
+</para>
+
+
<!-- ##### MACRO NI_MAXHOST ##### -->
<para>
@@ -715,6 +733,84 @@ camel-types
@context:
@session:
+<!-- ##### FUNCTION camel_exception_clear ##### -->
+<para>
+
+</para>
+
+ ex:
+
+<!-- ##### FUNCTION camel_exception_free ##### -->
+<para>
+
+</para>
+
+ ex:
+
+<!-- ##### FUNCTION camel_exception_get_description ##### -->
+<para>
+
+</para>
+
+ ex:
+ Returns:
+
+<!-- ##### FUNCTION camel_exception_get_id ##### -->
+<para>
+
+</para>
+
+ ex:
+ Returns:
+
+<!-- ##### FUNCTION camel_exception_init ##### -->
+<para>
+
+</para>
+
+ ex:
+
+<!-- ##### MACRO camel_exception_is_set ##### -->
+<para>
+
+</para>
+
+ ex:
+
+<!-- ##### FUNCTION camel_exception_new ##### -->
+<para>
+
+</para>
+
+ Returns:
+
+<!-- ##### FUNCTION camel_exception_set ##### -->
+<para>
+
+</para>
+
+ ex:
+ id:
+ desc:
+
+<!-- ##### FUNCTION camel_exception_setv ##### -->
+<para>
+
+</para>
+
+ ex:
+ id:
+ format:
+ Varargs:
+
+<!-- ##### FUNCTION camel_exception_xfer ##### -->
+<para>
+
+</para>
+
+ ex_dst:
+ ex_src:
+
<!-- ##### FUNCTION camel_file_util_decode_size_t ##### -->
<para>
diff --git a/docs/reference/camel/tmpl/camel-url.sgml b/docs/reference/camel/tmpl/camel-url.sgml
index 042b0e2..f6b9900 100644
--- a/docs/reference/camel/tmpl/camel-url.sgml
+++ b/docs/reference/camel/tmpl/camel-url.sgml
@@ -77,7 +77,7 @@ camel-url
</para>
@url_string:
- ex:
+ error:
@Returns:
diff --git a/docs/reference/camel/tmpl/camel-vee-folder.sgml b/docs/reference/camel/tmpl/camel-vee-folder.sgml
index 2d24836..ef7bf4d 100644
--- a/docs/reference/camel/tmpl/camel-vee-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-vee-folder.sgml
@@ -98,7 +98,7 @@ CamelVeeFolder
@vf:
@sub:
- ex:
+ error:
@Returns:
@@ -144,6 +144,6 @@ CamelVeeFolder
</para>
@vf:
- ex:
+ error:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]