camel-data-wrapper.c \
camel-db.c \
camel-debug.c \
- camel-exception.c \
camel-file-utils.c \
camel-html-parser.c \
camel-iconv.c \
camel-data-wrapper.h \
camel-db.h \
camel-debug.h \
- camel-exception-list.def \
- camel-exception.h \
camel-file-utils.h \
camel-iconv.h \
camel-index.h \
bl = g_malloc0(sizeof(*bl));
bl->id = id;
if (lseek(bs->fd, id, SEEK_SET) == -1 ||
- camel_read (bs->fd, (gchar *) bl->data, CAMEL_BLOCK_SIZE) == -1) {
+ camel_read (bs->fd, (gchar *) bl->data, CAMEL_BLOCK_SIZE, NULL) == -1) {
block_file_unuse(bs);
CAMEL_BLOCK_FILE_UNLOCK(bs, cache_lock);
g_free(bl);
#include <glib/gi18n-lib.h>
#include "camel-cipher-context.h"
+#include "camel-debug.h"
#include "camel-session.h"
#include "camel-stream.h"
#include "camel-operation.h"
CamelCipherHash hash,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Signing is not supported by this cipher"));
return -1;
* @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.
CamelCipherHash hash,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
gint retval;
CIPHER_LOCK (context);
- retval = class->sign (context, userid, hash, ipart, opart, ex);
+ retval = class->sign (context, userid, hash, ipart, opart, error);
+ CAMEL_CHECK_GERROR (context, sign, retval == 0, error);
CIPHER_UNLOCK (context);
static CamelCipherValidity *
cipher_verify (CamelCipherContext *context,
CamelMimePart *sigpart,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Verifying is not supported by this cipher"));
return NULL;
* 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
CamelCipherValidity *
camel_cipher_verify (CamelCipherContext *context,
CamelMimePart *ipart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
CamelCipherValidity *valid;
CIPHER_LOCK (context);
- valid = class->verify (context, ipart, ex);
+ valid = class->verify (context, ipart, error);
+ CAMEL_CHECK_GERROR (context, verify, valid != NULL, error);
CIPHER_UNLOCK (context);
GPtrArray *recipients,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Encryption is not supported by this cipher"));
return -1;
* @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.
GPtrArray *recipients,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
gint retval;
CIPHER_LOCK (context);
retval = class->encrypt (
- context, userid, recipients, ipart, opart, ex);
+ context, userid, recipients, ipart, opart, error);
+ CAMEL_CHECK_GERROR (context, encrypt, retval == 0, error);
CIPHER_UNLOCK (context);
cipher_decrypt (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Decryption is not supported by this cipher"));
return NULL;
* @context:
* @ipart:
* @opart:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Decrypts @ipart into @opart.
*
camel_cipher_decrypt (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
CamelCipherValidity *valid;
CIPHER_LOCK (context);
- valid = class->decrypt (context, ipart, opart, ex);
+ valid = class->decrypt (context, ipart, opart, error);
+ CAMEL_CHECK_GERROR (context, decrypt, valid != NULL, error);
CIPHER_UNLOCK (context);
static gint
cipher_import_keys (CamelCipherContext *context,
CamelStream *istream,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("You may not import keys with this cipher"));
return -1;
* 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.
gint
camel_cipher_import_keys (CamelCipherContext *context,
CamelStream *istream,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (istream), -1);
class = CAMEL_CIPHER_CONTEXT_GET_CLASS (context);
g_return_val_if_fail (class->import_keys != NULL, -1);
- return class->import_keys (context, istream, ex);
+ retval = class->import_keys (context, istream, error);
+ CAMEL_CHECK_GERROR (context, import_keys, retval == 0, error);
+
+ return retval;
}
static gint
cipher_export_keys (CamelCipherContext *context,
GPtrArray *keys,
CamelStream *ostream,
- CamelException *ex)
+ GError **error)
{
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("You may not export keys with this cipher"));
return -1;
* @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.
camel_cipher_export_keys (CamelCipherContext *context,
GPtrArray *keys,
CamelStream *ostream,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (ostream), -1);
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);
+ retval = class->export_keys (context, keys, ostream, error);
+ CAMEL_CHECK_GERROR (context, export_keys, retval == 0, error);
+
+ return retval;
}
static CamelCipherHash
* @part: Part to write.
* @flags: flags for the canonicalisation filter (CamelMimeFilterCanon)
* @ostream: stream to write canonicalised output to.
+ * @error: return location for a #GError, or %NULL
*
* Writes a part to a stream in a canonicalised format, suitable for signing/encrypting.
*
gint
camel_cipher_canonical_to_stream (CamelMimePart *part,
guint32 flags,
- CamelStream *ostream)
+ CamelStream *ostream,
+ GError **error)
{
CamelStream *filter;
CamelMimeFilter *canon;
camel_stream_filter_add (CAMEL_STREAM_FILTER (filter), canon);
g_object_unref (canon);
- if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)part, filter) != -1
- && camel_stream_flush (filter) != -1)
+ if (camel_data_wrapper_write_to_stream (
+ (CamelDataWrapper *)part, filter, error) != -1
+ && camel_stream_flush (filter, error) != -1)
res = 0;
g_object_unref (filter);
- camel_stream_reset (ostream);
+ camel_stream_reset (ostream, NULL);
return res;
}
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);
/* 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);
void camel_cipher_validity_free (CamelCipherValidity *validity);
/* utility functions */
-gint camel_cipher_canonical_to_stream(CamelMimePart *part, guint32 flags, CamelStream *ostream);
+gint camel_cipher_canonical_to_stream(CamelMimePart *part, guint32 flags, CamelStream *ostream, GError **error);
G_END_DECLS
#include <errno.h>
#include <string.h>
#include <stdlib.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
/**
* 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.
*
**/
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unable to create cache path"));
return NULL;
}
g_free (cdc->priv->path);
cdc->priv->path = g_strdup (path);
+
+ g_object_notify (G_OBJECT (cdc), "path");
}
/**
* @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.
*
camel_data_cache_add (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex)
+ GError **error)
{
gchar *real;
CamelStream *stream;
} while (stream != NULL);
stream = camel_stream_fs_new_with_name (
- real, O_RDWR|O_CREAT|O_TRUNC, 0600);
+ real, O_RDWR|O_CREAT|O_TRUNC, 0600, error);
if (stream)
camel_object_bag_add(cdc->priv->busy_bag, real, stream);
else
* @cdc: A #CamelDataCache
* @path: Path to the (sub) cache the item exists in.
* @key: Key for the cache item.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Lookup an item in the cache. If the item exists, a stream
* is returned for the item. The stream may be shared by
camel_data_cache_get (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex)
+ GError **error)
{
gchar *real;
CamelStream *stream;
stream = camel_object_bag_reserve(cdc->priv->busy_bag, real);
if (!stream) {
stream = camel_stream_fs_new_with_name (
- real, O_RDWR, 0600);
+ real, O_RDWR, 0600, error);
if (stream)
camel_object_bag_add(cdc->priv->busy_bag, real, stream);
else
* @cdc: A #CamelDataCache
* @path: Path to the (sub) cache the item exists in.
* @key: Key for the cache item.
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Lookup the filename for an item in the cache
*
camel_data_cache_get_filename (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex)
+ GError **error)
{
gchar *real;
* @cdc: A #CamelDataCache
* @path:
* @key:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Remove/expire a cache item.
*
camel_data_cache_remove (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex)
+ GError **error)
{
CamelStream *stream;
gchar *real;
/* maybe we were a mem stream */
if (g_unlink (real) == -1 && errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not remove cache entry: %s: %s"),
real, g_strerror (errno));
ret = -1;
#define CAMEL_DATA_CACHE_H
#include <camel/camel-stream.h>
-#include <camel/camel-exception.h>
/* Standard GObject macros */
#define CAMEL_TYPE_DATA_CACHE \
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);
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);
+ GError **error);
gchar * camel_data_cache_get_filename (CamelDataCache *cdc,
const gchar *path,
const gchar *key,
- CamelException *ex);
+ GError **error);
G_END_DECLS
#endif
#include <errno.h>
+#include <glib/gi18n-lib.h>
#include "camel-data-wrapper.h"
+#include "camel-debug.h"
#include "camel-mime-filter-basic.h"
#include "camel-mime-filter-crlf.h"
#include "camel-stream-filter.h"
static gssize
data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
gssize ret;
if (data_wrapper->stream == NULL) {
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("No stream available"));
return -1;
}
camel_data_wrapper_lock (data_wrapper, CAMEL_DATA_WRAPPER_STREAM_LOCK);
- if (camel_stream_reset (data_wrapper->stream) == -1) {
+ if (camel_stream_reset (data_wrapper->stream, error) == -1) {
camel_data_wrapper_unlock (data_wrapper, CAMEL_DATA_WRAPPER_STREAM_LOCK);
return -1;
}
- ret = camel_stream_write_to_stream (data_wrapper->stream, stream);
+ ret = camel_stream_write_to_stream (
+ data_wrapper->stream, stream, error);
camel_data_wrapper_unlock (data_wrapper, CAMEL_DATA_WRAPPER_STREAM_LOCK);
static gssize
data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelMimeFilter *filter;
CamelStream *fstream;
g_object_unref (filter);
}
- ret = camel_data_wrapper_write_to_stream (data_wrapper, fstream);
+ ret = camel_data_wrapper_write_to_stream (data_wrapper, fstream, error);
- camel_stream_flush (fstream);
+ camel_stream_flush (fstream, NULL);
g_object_unref (fstream);
return ret;
static gint
data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
if (data_wrapper->stream)
g_object_unref (data_wrapper->stream);
* camel_data_wrapper_write_to_stream:
* @data_wrapper: a #CamelDataWrapper object
* @stream: a #CamelStream for output
+ * @error: return location for a #GError, or %NULL
*
* Writes the content of @data_wrapper to @stream in a machine-independent
* format appropriate for the data. It should be possible to construct an
**/
gssize
camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelDataWrapperClass *class;
+ gssize n_bytes;
g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper);
g_return_val_if_fail (class->write_to_stream != NULL, -1);
- return class->write_to_stream (data_wrapper, stream);
+ n_bytes = class->write_to_stream (data_wrapper, stream, error);
+ CAMEL_CHECK_GERROR (data_wrapper, write_to_stream, n_bytes >= 0, error);
+
+ return n_bytes;
}
/**
* camel_data_wrapper_decode_to_stream:
* @data_wrapper: a #CamelDataWrapper object
* @stream: a #CamelStream for decoded data to be written to
+ * @error: return location for a #GError, or %NULL
*
* Writes the decoded data content to @stream.
*
**/
gssize
camel_data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelDataWrapperClass *class;
+ gssize n_bytes;
g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper);
g_return_val_if_fail (class->decode_to_stream != NULL, -1);
- return class->decode_to_stream (data_wrapper, stream);
+ n_bytes = class->decode_to_stream (data_wrapper, stream, error);
+ CAMEL_CHECK_GERROR (data_wrapper, decode_to_stream, n_bytes >= 0, error);
+
+ return n_bytes;
}
/**
* camel_data_wrapper_construct_from_stream:
* @data_wrapper: a #CamelDataWrapper object
* @stream: an input #CamelStream
+ * @error: return location for a #GError, or %NULL
*
* Constructs the content of @data_wrapper from the supplied @stream.
*
**/
gint
camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelDataWrapperClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
class = CAMEL_DATA_WRAPPER_GET_CLASS (data_wrapper);
g_return_val_if_fail (class->construct_from_stream != NULL, -1);
- return class->construct_from_stream (data_wrapper, stream);
+ retval = class->construct_from_stream (data_wrapper, stream, error);
+ CAMEL_CHECK_GERROR (
+ data_wrapper, construct_from_stream, retval == 0, error);
+
+ return retval;
}
/**
void (*set_mime_type_field) (CamelDataWrapper *data_wrapper,
CamelContentType *mime_type_field);
gssize (*write_to_stream) (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
+ CamelStream *stream,
+ GError **error);
gssize (*decode_to_stream) (CamelDataWrapper *data_wrapper,
- CamelStream *stream);
+ CamelStream *stream,
+ GError **error);
gint (*construct_from_stream)(CamelDataWrapper *data_wrapper,
- CamelStream *);
+ CamelStream *stream,
+ GError **error);
gboolean (*is_offline) (CamelDataWrapper *data_wrapper);
};
camel_data_wrapper_new (void);
gssize camel_data_wrapper_write_to_stream
(CamelDataWrapper *data_wrapper,
- CamelStream *stream);
+ CamelStream *stream,
+ GError **error);
gssize camel_data_wrapper_decode_to_stream
(CamelDataWrapper *data_wrapper,
- CamelStream *stream);
+ CamelStream *stream,
+ GError **error);
void camel_data_wrapper_set_mime_type(CamelDataWrapper *data_wrapper,
const gchar *mime_type);
gchar * camel_data_wrapper_get_mime_type(CamelDataWrapper *data_wrapper);
CamelContentType *mime_type);
gint camel_data_wrapper_construct_from_stream
(CamelDataWrapper *data_wrapper,
- CamelStream *stream);
+ CamelStream *stream,
+ GError **error);
gboolean camel_data_wrapper_is_offline (CamelDataWrapper *data_wrapper);
void camel_data_wrapper_lock (CamelDataWrapper *data_wrapper,
CamelDataWrapperLock lock);
#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
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;
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_GENERIC, "%s", errmsg);
sqlite3_free (errmsg);
errmsg = NULL;
return -1;
* Since: 2.24
**/
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;
if (ret) {
if (!db) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Insufficient memory"));
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
+ _("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_GENERIC, "%s", errmsg);
sqlite3_close(db);
}
return NULL;
* Since: 2.26
**/
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);
}
/**
* Since: 2.24
**/
gint
-camel_db_command (CamelDB *cdb, const gchar *stmt, CamelException *ex)
+camel_db_command (CamelDB *cdb,
+ const gchar *stmt,
+ GError **error)
{
gint ret;
- /* XXX Should this be really exposed ? */
-
if (!cdb)
return TRUE;
g_mutex_lock (cdb->lock);
START(stmt);
- ret = cdb_sql_exec (cdb->db, stmt, ex);
+ ret = cdb_sql_exec (cdb->db, stmt, error);
END;
g_mutex_unlock (cdb->lock);
* Since: 2.24
**/
gint
-camel_db_begin_transaction (CamelDB *cdb, CamelException *ex)
+camel_db_begin_transaction (CamelDB *cdb,
+ GError **error)
{
if (!cdb)
return -1;
g_mutex_lock (cdb->lock);
STARTTS("BEGIN");
- return (cdb_sql_exec (cdb->db, "BEGIN", ex));
+ return (cdb_sql_exec (cdb->db, "BEGIN", error));
}
/**
* Since: 2.24
**/
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"))
* Since: 2.24
**/
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);
* Since: 2.24
**/
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));
}
/**
* Since: 2.24
**/
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;
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);
* Since: 2.26
**/
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;
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_GENERIC, "%s", errmsg);
sqlite3_free (errmsg);
errmsg = NULL;
}
* Since: 2.24
**/
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;
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;
* Since: 2.24
**/
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;
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;
* Since: 2.24
**/
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;
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;
* Since: 2.24
**/
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;
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;
* Since: 2.24
**/
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;
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;
* Since: 2.24
**/
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;
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;
* Since: 2.24
**/
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;
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;
* Since: 2.24
**/
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;*/
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_GENERIC, "%s", errmsg);
sqlite3_free (errmsg);
errmsg = NULL;
}
* Since: 2.24
**/
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);
* Since: 2.24
**/
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);
}
/**
* Since: 2.24
**/
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;
* Since: 2.24
**/
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);
* Since: 2.26
**/
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 ();
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++) {
* Since: 2.24
**/
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;
* Since: 2.24
**/
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;
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);
* Since: 2.24
**/
GPtrArray *
-camel_db_get_folder_deleted_uids (CamelDB *db, const gchar *folder_name, CamelException *ex)
+camel_db_get_folder_deleted_uids (CamelDB *db,
+ const gchar *folder_name,
+ GError **error)
{
gchar *sel_query;
gint ret;
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) {
* Since: 2.28
**/
GHashTable *
-camel_db_get_folder_preview (CamelDB *db, const gchar *folder_name, CamelException *ex)
+camel_db_get_folder_preview (CamelDB *db,
+ const gchar *folder_name,
+ GError **error)
{
gchar *sel_query;
gint ret;
sel_query = sqlite3_mprintf("SELECT uid, preview FROM '%q_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) {
* Since: 2.28
**/
gint
-camel_db_write_preview_record (CamelDB *db, const gchar *folder_name, const gchar *uid, const gchar *msg, CamelException *ex)
+camel_db_write_preview_record (CamelDB *db,
+ const gchar *folder_name,
+ const gchar *uid,
+ const gchar *msg,
+ GError **error)
{
gchar *query;
gint ret;
query = sqlite3_mprintf("INSERT OR REPLACE INTO '%q_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;
* Since: 2.24
**/
GPtrArray *
-camel_db_get_vuids_from_vfolder (CamelDB *db, const gchar *folder_name, gchar *filter, CamelException *ex)
+camel_db_get_vuids_from_vfolder (CamelDB *db,
+ const gchar *folder_name,
+ gchar *filter,
+ GError **error)
{
gchar *sel_query;
gchar *cond = NULL;
/* 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) {
* Since: 2.24
**/
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;
* Since: 2.24
**/
gint
-camel_db_add_to_vfolder_transaction (CamelDB *db, const gchar *folder_name, const gchar *vuid, CamelException *ex)
+camel_db_add_to_vfolder_transaction (CamelDB *db,
+ const gchar *folder_name,
+ const 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);
* Since: 2.24
**/
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 '%q_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 '%q_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 '%q_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);
}
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;
* */
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 */
}
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;
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);
}
* Since: 2.28
**/
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;
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);
}
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;
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);
}
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;
* Since: 2.24
**/
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;
}
-/**
- * camel_db_write_fresh_message_info_record:
- *
- * Since: 2.26
- **/
-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);
-}
-
-/**
- * camel_db_write_message_info_record:
- *
- * Since: 2.24
- **/
-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;*/
/* 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
if (ret == 0) {
ins_query = sqlite3_mprintf ("INSERT OR REPLACE INTO '%q_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);
}
}
/**
+ * camel_db_write_fresh_message_info_record:
+ *
+ * Since: 2.26
+ **/
+gint
+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);
+}
+
+/**
+ * camel_db_write_message_info_record:
+ *
+ * Since: 2.24
+ **/
+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);
+}
+
+/**
* camel_db_write_folder_info_record:
*
* Since: 2.24
**/
gint
-camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, CamelException *ex)
+camel_db_write_folder_info_record (CamelDB *cdb,
+ CamelFIRecord *record,
+ GError **error)
{
gint ret;
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
* Since: 2.24
**/
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);
* Since: 2.24
**/
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);
* Since: 2.24
**/
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);
* Since: 2.24
**/
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;
* Since: 2.24
**/
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 '%q_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;
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);
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;
* Since: 2.24
**/
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);
}
/**
* Since: 2.26
**/
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);
}
/**
* Since: 2.24
**/
gint
-camel_db_clear_folder_summary (CamelDB *cdb, const gchar *folder, CamelException *ex)
+camel_db_clear_folder_summary (CamelDB *cdb,
+ const gchar *folder,
+ GError **error)
{
gint ret;
msginfo_del = sqlite3_mprintf ("DELETE FROM %Q ", folder);
bstruct_del = sqlite3_mprintf ("DELETE FROM '%q_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);
* Since: 2.24
**/
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 '%q_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;
* Since: 2.24
**/
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;
* Since: 2.24
**/
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;
* Since: 2.26
**/
gint
-camel_db_start_in_memory_transactions (CamelDB *cdb, CamelException *ex)
+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);
* Since: 2.26
**/
gint
-camel_db_flush_in_memory_transactions (CamelDB *cdb, const gchar * folder_name, CamelException *ex)
+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;
**/
#define CAMEL_DB_IN_MEMORY_TABLE_LIMIT 100000
-#include "camel-exception.h"
-
typedef struct _CamelDBPrivate CamelDBPrivate;
/**
**/
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, const 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, const 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, const 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, const gchar *folder_name, const 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, const 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, const gchar *folder_name, const 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, const 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, const gchar *folder_name, GError **error);
gchar * camel_db_sqlize_string (const gchar *string);
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, const gchar *folder_name, CamelException *ex);
-gint camel_db_write_preview_record (CamelDB *db, const gchar *folder_name, const gchar *uid, const gchar *msg, CamelException *ex);
+camel_db_get_folder_preview (CamelDB *db, const gchar *folder_name, GError **error);
+gint camel_db_write_preview_record (CamelDB *db, const 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
gboolean camel_debug_start(const gchar *mode);
void camel_debug_end(void);
+/* This sanity checks return values and GErrors. If returning
+ * failure, make sure the GError is set. If returning success,
+ * make sure the GError is NOT set.
+ *
+ * Example:
+ *
+ * success = class->foo (object, some_data, error);
+ * CAMEL_CHECK_GERROR (object, foo, success, error);
+ * return success;
+ */
+#define CAMEL_CHECK_GERROR(object, method, expr, error) \
+ G_STMT_START { \
+ if (expr) { \
+ if ((error) != NULL && *(error) != NULL) { \
+ g_warning ( \
+ "%s::%s() set its GError " \
+ "but then reported success", \
+ G_OBJECT_TYPE_NAME (object), \
+ G_STRINGIFY (method)); \
+ g_warning ( \
+ "Error message was: %s", \
+ (*(error))->message); \
+ } \
+ } else { \
+ if ((error) != NULL && *(error) == NULL) { \
+ g_warning ( \
+ "%s::%s() reported failure " \
+ "without setting its GError", \
+ G_OBJECT_TYPE_NAME (object), \
+ G_STRINGIFY (method)); \
+ } \
+ } \
+ } G_STMT_END
+
G_END_DECLS
#endif /* CAMEL_DEBUG_H */
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);
+ CAMEL_STORE (diary->store), name, 0, &error);
if (folder)
g_hash_table_insert (diary->folders, name, folder);
else {
_("Could not open '%s':\n%s\n"
"Changes made to this folder "
"will not be resynchronized."),
- name, camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
+ name, error->message);
+ g_error_free (error);
camel_session_alert_user (
camel_service_get_session (CAMEL_SERVICE (diary->store)),
CAMEL_SESSION_ALERT_WARNING,
void
camel_disco_diary_replay (CamelDiscoDiary *diary,
- CamelException *ex)
+ GError **error)
{
guint32 action;
off_t size;
gdouble pc;
+ GError *local_error = NULL;
d(printf("disco diary replay\n"));
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);
if (folder)
camel_disco_folder_expunge_uids (
- folder, uids, ex);
+ folder, uids, &local_error);
free_uids (uids);
break;
}
info = camel_folder_get_message_info (folder, uid);
camel_folder_append_message (
- folder, message, info, &ret_uid, ex);
+ folder, message, info, &ret_uid, &local_error);
camel_folder_free_message_info (folder, info);
if (ret_uid) {
camel_folder_transfer_messages_to (
source, uids, destination, &ret_uids,
- delete_originals, ex);
+ delete_originals, &local_error);
if (ret_uids) {
for (i = 0; i < uids->len; i++) {
/* 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)
+ GError **error)
{
CamelDiscoDiary *diary;
diary->file = g_fopen (filename, "a+b");
if (!diary->file) {
g_object_unref (diary);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
"Could not open journal file: %s",
g_strerror (errno));
return NULL;
CamelDiscoDiary *
camel_disco_diary_new (CamelDiscoStore *store,
const gchar *filename,
- CamelException *ex);
+ GError **error);
gboolean camel_disco_diary_empty (CamelDiscoDiary *diary);
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,
#include <glib/gi18n-lib.h>
+#include "camel-debug.h"
#include "camel-disco-folder.h"
#include "camel-disco-store.h"
-#include "camel-exception.h"
#include "camel-session.h"
#define CAMEL_DISCO_FOLDER_GET_PRIVATE(obj) \
G_DEFINE_TYPE (CamelDiscoFolder, camel_disco_folder, CAMEL_TYPE_FOLDER)
/* Forward Declarations */
-static gboolean disco_expunge (CamelFolder *folder, CamelException *ex);
+static gboolean disco_expunge (CamelFolder *folder, GError **error);
static void
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);
static gboolean
disco_refresh_info (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelDiscoFolderClass *disco_folder_class;
CamelStore *parent_store;
+ gboolean success;
parent_store = camel_folder_get_parent_store (folder);
disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder);
- return disco_folder_class->refresh_info_online (folder, ex);
+ success = disco_folder_class->refresh_info_online (folder, error);
+ CAMEL_CHECK_GERROR (folder, refresh_info_online, success, error);
+
+ return success;
}
static gboolean
disco_sync (CamelFolder *folder,
gboolean expunge,
- CamelException *ex)
+ GError **error)
{
CamelDiscoFolderClass *disco_folder_class;
CamelStore *parent_store;
+ gboolean success;
- if (expunge && !disco_expunge (folder, ex)) {
- if (camel_exception_is_set (ex))
- return FALSE;
- }
+ if (expunge && !disco_expunge (folder, error))
+ return FALSE;
camel_object_state_write (CAMEL_OBJECT (folder));
switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
case CAMEL_DISCO_STORE_ONLINE:
- return disco_folder_class->sync_online (folder, ex);
+ success = disco_folder_class->sync_online (folder, error);
+ CAMEL_CHECK_GERROR (folder, sync_online, success, error);
+ return success;
case CAMEL_DISCO_STORE_OFFLINE:
- return disco_folder_class->sync_offline (folder, ex);
+ success = disco_folder_class->sync_offline (folder, error);
+ CAMEL_CHECK_GERROR (folder, sync_offline, success, error);
+ return success;
case CAMEL_DISCO_STORE_RESYNCING:
- return disco_folder_class->sync_resyncing (folder, ex);
+ success = disco_folder_class->sync_resyncing (folder, error);
+ CAMEL_CHECK_GERROR (folder, sync_resyncing, success, error);
+ return success;
}
g_return_val_if_reached (FALSE);
static gboolean
disco_expunge_uids (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelDiscoFolderClass *disco_folder_class;
CamelStore *parent_store;
+ gboolean success;
if (uids->len == 0)
return TRUE;
switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
case CAMEL_DISCO_STORE_ONLINE:
- return disco_folder_class->expunge_uids_online (
- folder, uids, ex);
+ success = disco_folder_class->expunge_uids_online (
+ folder, uids, error);
+ CAMEL_CHECK_GERROR (
+ folder, expunge_uids_online, success, error);
+ return success;
case CAMEL_DISCO_STORE_OFFLINE:
- return disco_folder_class->expunge_uids_offline (
- folder, uids, ex);
+ success = disco_folder_class->expunge_uids_offline (
+ folder, uids, error);
+ CAMEL_CHECK_GERROR (
+ folder, expunge_uids_offline, success, error);
+ return success;
case CAMEL_DISCO_STORE_RESYNCING:
- return disco_folder_class->expunge_uids_resyncing (
- folder, uids, ex);
+ success = disco_folder_class->expunge_uids_resyncing (
+ folder, uids, error);
+ CAMEL_CHECK_GERROR (
+ folder, expunge_uids_resyncing, success, error);
+ return success;
}
g_return_val_if_reached (FALSE);
static gboolean
disco_expunge (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
GPtrArray *uids;
gint i;
gboolean success;
uids = g_ptr_array_new ();
- camel_folder_summary_prepare_fetch_all (folder->summary, ex);
+ camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
count = camel_folder_summary_count (folder->summary);
for (i = 0; i < count; i++) {
info = camel_folder_summary_index (folder->summary, i);
camel_message_info_free(info);
}
- success = 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]);
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelDiscoFolderClass *disco_folder_class;
CamelStore *parent_store;
+ gboolean success;
parent_store = camel_folder_get_parent_store (folder);
disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder);
switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
case CAMEL_DISCO_STORE_ONLINE:
- return disco_folder_class->append_online (
- folder, message, info, appended_uid, ex);
+ success = disco_folder_class->append_online (
+ folder, message, info, appended_uid, error);
+ CAMEL_CHECK_GERROR (folder, append_online, success, error);
+ return success;
case CAMEL_DISCO_STORE_OFFLINE:
- return disco_folder_class->append_offline (
- folder, message, info, appended_uid, ex);
+ success = disco_folder_class->append_offline (
+ folder, message, info, appended_uid, error);
+ CAMEL_CHECK_GERROR (folder, append_offline, success, error);
+ return success;
case CAMEL_DISCO_STORE_RESYNCING:
- return disco_folder_class->append_resyncing (
- folder, message, info, appended_uid, ex);
+ success = disco_folder_class->append_resyncing (
+ folder, message, info, appended_uid, error);
+ CAMEL_CHECK_GERROR (folder, append_resyncing, success, error);
+ return success;
}
g_return_val_if_reached (FALSE);
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
CamelDiscoFolderClass *disco_folder_class;
CamelStore *parent_store;
+ gboolean success;
parent_store = camel_folder_get_parent_store (source);
disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (source);
switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
case CAMEL_DISCO_STORE_ONLINE:
- return disco_folder_class->transfer_online (
+ success = disco_folder_class->transfer_online (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
+ CAMEL_CHECK_GERROR (source, transfer_online, success, error);
+ return success;
case CAMEL_DISCO_STORE_OFFLINE:
- return disco_folder_class->transfer_offline (
+ success = disco_folder_class->transfer_offline (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
+ CAMEL_CHECK_GERROR (source, transfer_offline, success, error);
+ return success;
case CAMEL_DISCO_STORE_RESYNCING:
- return disco_folder_class->transfer_resyncing (
+ success = disco_folder_class->transfer_resyncing (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
+ CAMEL_CHECK_GERROR (source, transfer_resyncing, success, error);
+ return success;
}
g_return_val_if_reached (FALSE);
static gboolean
disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder = CAMEL_FOLDER (disco_folder);
GPtrArray *uids;
camel_folder_get_full_name (folder));
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);
camel_operation_progress(NULL, pc);
success = camel_disco_folder_cache_message (
- disco_folder, uids->pdata[i], ex);
+ disco_folder, uids->pdata[i], error);
}
if (expression)
static gboolean
disco_refresh_info_online (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
return TRUE;
}
* 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,
gboolean
camel_disco_folder_expunge_uids (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
g_return_val_if_fail (CAMEL_IS_DISCO_FOLDER (folder), FALSE);
g_return_val_if_fail (uids != NULL, FALSE);
- return disco_expunge_uids (folder, uids, ex);
+ 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.
*
gboolean
camel_disco_folder_cache_message (CamelDiscoFolder *disco_folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelDiscoFolderClass *class;
+ gboolean success;
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, ex);
+ success = class->cache_message (disco_folder, uid, error);
+ CAMEL_CHECK_GERROR (disco_folder, cache_message, success, error);
+
+ return success;
}
/**
* @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
gboolean
camel_disco_folder_prepare_for_offline (CamelDiscoFolder *disco_folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelDiscoFolderClass *class;
+ gboolean success;
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);
- return class->prepare_for_offline (disco_folder, expression, ex);
+ success = class->prepare_for_offline (disco_folder, expression, error);
+ CAMEL_CHECK_GERROR (disco_folder, prepare_for_offline, success, error);
+
+ return success;
}
CamelFolderClass parent_class;
gboolean (*refresh_info_online) (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
gboolean (*sync_online) (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
gboolean (*sync_offline) (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
gboolean (*sync_resyncing) (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
gboolean (*expunge_uids_online) (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
gboolean (*expunge_uids_offline) (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
gboolean (*expunge_uids_resyncing)
(CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
gboolean (*append_online) (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex);
+ GError **error);
gboolean (*append_offline) (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex);
+ GError **error);
gboolean (*append_resyncing) (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex);
+ GError **error);
gboolean (*transfer_online) (CamelFolder *source,
GPtrArray *uids,
CamelFolder *destination,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
gboolean (*transfer_offline) (CamelFolder *source,
GPtrArray *uids,
CamelFolder *destination,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
gboolean (*transfer_resyncing) (CamelFolder *source,
GPtrArray *uids,
CamelFolder *destination,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
gboolean (*cache_message) (CamelDiscoFolder *disco_folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
gboolean (*prepare_for_offline) (CamelDiscoFolder *disco_folder,
const gchar *expression,
- CamelException *ex);
+ GError **error);
void (*update_uid) (CamelFolder *folder,
const gchar *old_uid,
const gchar *new_uid);
gboolean offline_sync);
gboolean camel_disco_folder_expunge_uids (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
gboolean camel_disco_folder_cache_message(CamelDiscoFolder *disco_folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
gboolean camel_disco_folder_prepare_for_offline
(CamelDiscoFolder *disco_folder,
const gchar *expression,
- CamelException *ex);
+ GError **error);
G_END_DECLS
#include <glib/gi18n-lib.h>
+#include "camel-debug.h"
#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)
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
CamelDiscoStore *disco = CAMEL_DISCO_STORE (service);
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_disco_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ if (!service_class->construct (service, session, provider, url, error))
return FALSE;
disco->status = camel_session_get_online (session) ?
static gboolean
disco_store_connect (CamelService *service,
- CamelException *ex)
+ 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 (camel_disco_store_parent_class)->connect (service, ex)) {
+ if (!CAMEL_SERVICE_CLASS (camel_disco_store_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)
disconnect could be called, which will remove store->diary and unref it */
store->status = CAMEL_DISCO_STORE_RESYNCING;
diary = g_object_ref (store->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 ();
static gboolean
disco_store_disconnect (CamelService *service,
gboolean clean,
- CamelException *ex)
+ 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 (camel_disco_store_parent_class)->disconnect (service, clean, ex);
+ return CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->disconnect (service, clean, error);
}
static void
disco_store_get_folder (CamelStore *store,
const gchar *name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store);
CamelDiscoStoreClass *class;
+ CamelFolder *folder;
class = CAMEL_DISCO_STORE_GET_CLASS (disco_store);
g_return_val_if_fail (class->get_folder_online != NULL, NULL);
switch (camel_disco_store_status (disco_store)) {
case CAMEL_DISCO_STORE_ONLINE:
- return class->get_folder_online (store, name, flags, ex);
+ folder = class->get_folder_online (store, name, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder_online, folder != NULL, error);
+ return folder;
case CAMEL_DISCO_STORE_OFFLINE:
- return class->get_folder_offline (store, name, flags, ex);
+ folder = class->get_folder_offline (store, name, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder_offline, folder != NULL, error);
+ return folder;
case CAMEL_DISCO_STORE_RESYNCING:
- return class->get_folder_resyncing (store, name, flags, ex);
+ folder = class->get_folder_resyncing (store, name, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder_resyncing, folder != NULL, error);
+ return folder;
}
g_return_val_if_reached (NULL);
disco_store_get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store);
CamelDiscoStoreClass *class;
+ CamelFolderInfo *info;
class = CAMEL_DISCO_STORE_GET_CLASS (disco_store);
g_return_val_if_fail (class->get_folder_info_online != NULL, NULL);
switch (camel_disco_store_status (disco_store)) {
case CAMEL_DISCO_STORE_ONLINE:
- return class->get_folder_info_online (store, top, flags, ex);
+ info = class->get_folder_info_online (store, top, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder_info_online, info != NULL, error);
+ return info;
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 class->get_folder_info_offline (store, top, flags, ex);
+ info = class->get_folder_info_offline (store, top, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder_info_offline, info != NULL, error);
+ return info;
case CAMEL_DISCO_STORE_RESYNCING:
- return class->get_folder_info_resyncing (store, top, flags, ex);
+ info = class->get_folder_info_resyncing (store, top, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder_info_resyncing, info != NULL, error);
+ return info;
}
g_return_val_if_reached (NULL);
}
-static void
+static gboolean
disco_store_set_status (CamelDiscoStore *disco_store,
CamelDiscoStoreStatus status,
- CamelException *ex)
+ GError **error)
{
- CamelException x;
CamelService *service = CAMEL_SERVICE (disco_store);
gboolean network_available;
if (disco_store->status == status)
- return;
+ return TRUE;
- 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 */
folder = folders->pdata[i];
if (G_TYPE_CHECK_INSTANCE_TYPE(folder, CAMEL_TYPE_DISCO_FOLDER)
&& (sync || camel_disco_folder_get_offline_sync (CAMEL_DISCO_FOLDER (folder)))) {
- 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);
}
}
}
- 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_available, ex))
- return;
+ if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), network_available, error))
+ return FALSE;
disco_store->status = status;
- camel_service_connect (CAMEL_SERVICE (disco_store), ex);
+
+ return camel_service_connect (CAMEL_SERVICE (disco_store), error);
}
static void
* 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
+gboolean
camel_disco_store_set_status (CamelDiscoStore *store,
CamelDiscoStoreStatus status,
- CamelException *ex)
+ GError **error)
{
CamelDiscoStoreClass *class;
+ gboolean success;
- g_return_if_fail (CAMEL_IS_DISCO_STORE (store));
+ g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), FALSE);
class = CAMEL_DISCO_STORE_GET_CLASS (store);
- g_return_if_fail (class->set_status != NULL);
+ g_return_val_if_fail (class->set_status != NULL, FALSE);
+
+ success = class->set_status (store, status, error);
+ CAMEL_CHECK_GERROR (store, set_status, success, error);
- class->set_status (store, status, ex);
+ return success;
}
/**
/**
* 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
**/
gboolean
camel_disco_store_check_online (CamelDiscoStore *store,
- CamelException *ex)
+ GError **error)
{
g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), FALSE);
if (camel_disco_store_status (store) == CAMEL_DISCO_STORE_ONLINE)
return TRUE;
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ 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)
+ GError **error)
{
- CamelException x;
CamelService *service;
g_return_if_fail (CAMEL_IS_DISCO_STORE (disco_store));
service = CAMEL_SERVICE (disco_store);
- camel_exception_init(&x);
/* Sync the folder fully if we've been told to sync online for this store or this folder */
if (camel_session_get_network_available (service->session)) {
folder = folders->pdata[i];
if (G_TYPE_CHECK_INSTANCE_TYPE(folder, CAMEL_TYPE_DISCO_FOLDER)
&& (sync || camel_disco_folder_get_offline_sync (CAMEL_DISCO_FOLDER (folder)))) {
- 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);
}
}
}
- camel_store_sync(CAMEL_STORE (disco_store), FALSE, &x);
- camel_exception_clear(&x);
+ camel_store_sync(CAMEL_STORE (disco_store), FALSE, NULL);
}
}
struct _CamelDiscoStoreClass {
CamelStoreClass parent_class;
- void (*set_status) (CamelDiscoStore *,
+ gboolean (*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);
/* Public methods */
CamelDiscoStoreStatus camel_disco_store_status (CamelDiscoStore *store);
-void camel_disco_store_set_status (CamelDiscoStore *store,
+gboolean 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
+++ /dev/null
-/* WARNING: Exceptions MUST NOT be renumbered: they need to be
- * consistent across libraries compiled at different times.
- * Categories should be widely separated, old unused exceptions can
- * never be deleted, and new exceptions can be added only to the
- * ends of categories.
- */
-
-CAMEL_EXCEPTION_NONE = 0,
-
-/* Generic exceptions */
-CAMEL_EXCEPTION_INVALID_PARAM,
-CAMEL_EXCEPTION_SYSTEM,
-CAMEL_EXCEPTION_USER_CANCEL,
-
-/* CamelFolderException */
-CAMEL_EXCEPTION_FOLDER_NULL = 100,
-CAMEL_EXCEPTION_FOLDER_INVALID,
-CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
-CAMEL_EXCEPTION_FOLDER_NON_EMPTY,
-CAMEL_EXCEPTION_FOLDER_NON_UID,
-CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
-CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
-CAMEL_EXCEPTION_FOLDER_INVALID_UID,
-CAMEL_EXCEPTION_FOLDER_SUMMARY_INVALID,
-
-/* CamelStoreException */
-CAMEL_EXCEPTION_STORE_NULL = 200,
-CAMEL_EXCEPTION_STORE_INVALID,
-CAMEL_EXCEPTION_STORE_NO_FOLDER,
-
-/* CamelServiceException */
-CAMEL_EXCEPTION_SERVICE_NULL = 300,
-CAMEL_EXCEPTION_SERVICE_INVALID,
-CAMEL_EXCEPTION_SERVICE_URL_INVALID,
-CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
-CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
-CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
-
-
-/* CamelOperation */
-CAMEL_EXCEPTION_OPERATION_IN_PROGRESS = 400
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- *
- * Author :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-
-#include "camel-debug.h"
-#include "camel-exception.h"
-
-/* dont turn this off */
-#define w(x) x
-
-#define ERROR_OVERWRITTEN_WARNING \
- "CamelException set over top of a previous CamelException.\n" \
- "This indicates a bug in someone's code. You must ensure a " \
- "CamelException is clear before it's set.\n" \
- "The overwriting error message was: %s"
-
-/**
- * camel_exception_new: allocate a new exception object.
- *
- * Create and returns a new exception object.
- *
- * Returns: the newly allocated exception object
- **/
-CamelException *
-camel_exception_new (void)
-{
- CamelException *ex;
-
- ex = g_slice_new (CamelException);
- ex->desc = NULL;
-
- /* set the Exception Id to NULL */
- ex->id = CAMEL_EXCEPTION_NONE;
-
- return ex;
-}
-
-/**
- * camel_exception_init:
- * @ex: a #CamelException
- *
- * Init an exception. This routine is mainly useful when using a
- * statically allocated exception.
- **/
-void
-camel_exception_init (CamelException *ex)
-{
- ex->desc = NULL;
-
- /* set the Exception Id to NULL */
- ex->id = CAMEL_EXCEPTION_NONE;
-}
-
-/**
- * camel_exception_clear:
- * @ex: a #CamelException
- *
- * Clear an exception, that is, set the exception ID to
- * #CAMEL_EXCEPTION_NONE and free the description text. If the
- * exception is %NULL, this funtion just returns.
- **/
-void
-camel_exception_clear (CamelException *exception)
-{
- if (!exception)
- return;
-
- if (exception->desc)
- g_free (exception->desc);
- exception->desc = NULL;
- exception->id = CAMEL_EXCEPTION_NONE;
-}
-
-/**
- * camel_exception_free:
- * @ex: a #CamelException
- *
- * Free an exception object. If the exception is %NULL, nothing is
- * done, the routine simply returns.
- **/
-void
-camel_exception_free (CamelException *exception)
-{
- if (!exception)
- return;
-
- if (exception->desc)
- g_free (exception->desc);
-
- g_slice_free (CamelException, exception);
-}
-
-/**
- * camel_exception_set: set an exception
- * @ex: a #CamelException
- * @id: exception id
- * @desc: textual description of the exception
- *
- * Set the value of an exception. The exception id is
- * a unique number representing the exception. The
- * textual description is a small text explaining
- * what happened and provoked the exception.
- *
- * When @ex is %NULL, nothing is done, this routine
- * simply returns.
- **/
-void
-camel_exception_set (CamelException *ex, ExceptionId id, const gchar *desc)
-{
- if (camel_debug("exception"))
- printf("CamelException.set(%p, %u, '%s')\n", (gpointer) ex, id, desc);
- if (!ex)
- return;
-
- if (camel_exception_is_set (ex)) {
- g_warning (ERROR_OVERWRITTEN_WARNING, desc);
- return;
- }
-
- ex->id = id;
- if (desc != ex->desc) {
- g_free (ex->desc);
- ex->desc = g_strdup (desc);
- }
-}
-
-/**
- * camel_exception_setv: set an exception
- * @ex: a #CamelException
- * @id: exception id
- * @format: format of the description string. The format string is
- * used as in printf().
- *
- * Set the value of an exception. The exception id is
- * a unique number representing the exception. The
- * textual description is a small text explaining
- * what happened and provoked the exception.
- * In this version, the string is created from the format
- * string and the variable argument list.
- *
- * It is safe to say:
- * camel_exception_setv (ex, ..., camel_exception_get_description (ex), ...);
- *
- * When @ex is %NULL, nothing is done, this routine
- * simply returns.
- **/
-void
-camel_exception_setv (CamelException *ex, ExceptionId id, const gchar *format, ...)
-{
- va_list args;
- gchar *desc;
-
- va_start(args, format);
- desc = g_strdup_vprintf (format, args);
- va_end (args);
-
- if (camel_debug("exception"))
- printf("CamelException.setv(%p, %u, '%s')\n", (gpointer) ex, id, desc);
-
- if (!ex) {
- g_free(desc);
- return;
- }
-
- if (camel_exception_is_set (ex)) {
- g_warning (ERROR_OVERWRITTEN_WARNING, desc);
- return;
- }
-
- g_free(ex->desc);
- ex->desc = desc;
- ex->id = id;
-}
-
-/**
- * camel_exception_xfer:
- * @ex_dst: Destination exception object
- * @ex_src: Source exception object
- *
- * Transfer the content of an exception from an exception object to
- * another. The destination exception receives the id and the
- * description text of the source exception.
- **/
-void
-camel_exception_xfer (CamelException *ex_dst,
- CamelException *ex_src)
-{
- if (ex_src == NULL) {
- w(g_warning ("camel_exception_xfer: trying to transfer NULL exception to %p\n", (gpointer) ex_dst));
- return;
- }
-
- if (ex_dst == NULL) {
- /* must have same side-effects */
- camel_exception_clear (ex_src);
- return;
- }
-
- if (camel_exception_is_set (ex_dst)) {
- g_warning (ERROR_OVERWRITTEN_WARNING, ex_src->desc);
- return;
- }
-
- if (ex_dst->desc)
- g_free (ex_dst->desc);
-
- ex_dst->id = ex_src->id;
- ex_dst->desc = ex_src->desc;
-
- ex_src->desc = NULL;
- ex_src->id = CAMEL_EXCEPTION_NONE;
-}
-
-/**
- * camel_exception_get_id:
- * @ex: a #CamelException
- *
- * Get the id of an exception.
- *
- * Returns: the exception id (#CAMEL_EXCEPTION_NONE will be returned if
- * @ex is %NULL or unset)
- **/
-ExceptionId
-camel_exception_get_id (CamelException *ex)
-{
- if (ex)
- return ex->id;
-
- w(g_warning ("camel_exception_get_id called with NULL parameter."));
-
- return CAMEL_EXCEPTION_NONE;
-}
-
-/**
- * camel_exception_get_description:
- * @ex: a #CamelException
- *
- * Get the exception description text.
- *
- * Returns: the exception description text (%NULL will be returned if
- * @ex is %NULL or unset)
- **/
-const gchar *
-camel_exception_get_description (CamelException *ex)
-{
- gchar *ret = NULL;
-
- if (ex)
- ret = ex->desc;
- else
- w(g_warning ("camel_exception_get_description called with NULL parameter."));
-
- return ret ? ret : (_("No description available"));
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-execpetion.h : exception utils */
-
-/*
- *
- * Author :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
-#error "Only <camel/camel.h> can be included directly."
-#endif
-
-#ifndef CAMEL_EXCEPTION_H
-#define CAMEL_EXCEPTION_H
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef struct _CamelException CamelException;
-
-typedef enum {
-#include "camel-exception-list.def"
-
-} ExceptionId;
-
-struct _CamelException {
- /* do not access the fields directly */
- ExceptionId id;
- gchar *desc;
-};
-
-#define CAMEL_EXCEPTION_INITIALISER { 0, NULL }
-
-/* creation and destruction functions */
-CamelException * camel_exception_new (void);
-void camel_exception_free (CamelException *ex);
-void camel_exception_init (CamelException *ex);
-
-/* exception content manipulation */
-void camel_exception_clear (CamelException *ex);
-void camel_exception_set (CamelException *ex,
- ExceptionId id,
- const gchar *desc);
-void camel_exception_setv (CamelException *ex,
- ExceptionId id,
- const gchar *format,
- ...);
-
-/* exception content transfer */
-void camel_exception_xfer (CamelException *ex_dst,
- CamelException *ex_src);
-
-/* exception content retrieval */
-ExceptionId camel_exception_get_id (CamelException *ex);
-const gchar * camel_exception_get_description (CamelException *ex);
-
-#define camel_exception_is_set(ex) (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE)
-
-G_END_DECLS
-
-#endif /* CAMEL_EXCEPTION_H */
-
#include <sys/stat.h>
#include <sys/types.h>
+#include <glib/gi18n-lib.h>
+
#include "camel-file-utils.h"
+#include "camel-object.h"
#include "camel-operation.h"
#include "camel-url.h"
* @fd: file descriptor
* @buf: buffer to fill
* @n: number of bytes to read into @buf
+ * @error: return location for a #GError, or %NULL
*
* Cancellable libc read() replacement.
*
gssize
camel_read (gint fd,
gchar *buf,
- gsize n)
+ gsize n,
+ GError **error)
{
gssize nread;
gint cancel_fd;
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
return -1;
}
+
#ifndef G_OS_WIN32
cancel_fd = camel_operation_cancel_fd (NULL);
#else
#endif
}
+ if (nread == -1) {
+ if (errno == EINTR)
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
+ else
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+ }
+
return nread;
}
* @fd: file descriptor
* @buf: buffer to write
* @n: number of bytes of @buf to write
+ * @error: return location for a #GError, or %NULL
*
* Cancellable libc write() replacement.
*
gssize
camel_write (gint fd,
const gchar *buf,
- gsize n)
+ gsize n,
+ GError **error)
{
gssize w, written = 0;
gint cancel_fd;
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
return -1;
}
+
#ifndef G_OS_WIN32
cancel_fd = camel_operation_cancel_fd (NULL);
#else
#endif
}
- if (w == -1)
+ if (w == -1) {
+ if (errno == EINTR)
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
+ else
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
+ }
return written;
}
* @fd: a socket
* @buf: buffer to fill
* @n: number of bytes to read into @buf
+ * @error: return location for a #GError, or %NULL
*
* Cancellable read() replacement for sockets. Code that intends to be
* portable to Win32 should call this function only on sockets
gssize
camel_read_socket (gint fd,
gchar *buf,
- gsize n)
+ gsize n,
+ GError **error)
{
#ifndef G_OS_WIN32
- return camel_read (fd, buf, n);
+ return camel_read (fd, buf, n, error);
#else
gssize nread;
gint cancel_fd;
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Canceled"));
return -1;
}
cancel_fd = camel_operation_cancel_fd (NULL);
;
}
+ if (nread == -1) {
+ if (errno == EINTR)
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
+ else
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+ }
+
return nread;
#endif
}
* @fd: file descriptor
* @buf: buffer to write
* @n: number of bytes of @buf to write
+ * @error: return location for a #GError, or %NULL
*
* Cancellable write() replacement for sockets. Code that intends to
* be portable to Win32 should call this function only on sockets
gssize
camel_write_socket (gint fd,
const gchar *buf,
- gsize n)
+ gsize n,
+ GError **error)
{
#ifndef G_OS_WIN32
- return camel_write (fd, buf, n);
+ return camel_write (fd, buf, n, error);
#else
gssize w, written = 0;
gint cancel_fd;
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Canceled"));
return -1;
}
ioctlsocket (fd, FIONBIO, &arg);
}
- if (w == -1)
+ if (w == -1) {
+ if (errno == EINTR)
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Canceled"));
+ else
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
+ }
return written;
#endif
* camel_read_socket() and camel_write_socket(). These are cancellable
* also on Win32.
*/
-gssize camel_read (gint fd, gchar *buf, gsize n);
-gssize camel_write (gint fd, const gchar *buf, gsize n);
+gssize camel_read (gint fd, gchar *buf, gsize n, GError **error);
+gssize camel_write (gint fd, const gchar *buf, gsize n, GError **error);
-gssize camel_read_socket (gint fd, gchar *buf, gsize n);
-gssize camel_write_socket (gint fd, const gchar *buf, gsize n);
+gssize camel_read_socket (gint fd, gchar *buf, gsize n, GError **error);
+gssize camel_write_socket (gint fd, const gchar *buf, gsize n, GError **error);
gchar *camel_file_util_savename(const gchar *filename);
CamelDList rules; /* list of _filter_rule structs */
- CamelException *ex;
+ GError *error;
/* evaluator */
ESExp *eval;
/* 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;
}
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",
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
}
}
- 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);
}
/* 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;
}
&error)) {
g_ptr_array_free (args, TRUE);
- camel_exception_setv (
- p->ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ &p->error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to create child process '%s': %s"),
argv[0]->value.string, error->message);
g_error_free (error);
g_ptr_array_free (args, TRUE);
stream = camel_stream_fs_new_with_fd (pipe_to_child);
- if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (p->message), stream) == -1) {
+ if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (p->message), stream, NULL) == -1) {
g_object_unref (stream);
close (pipe_from_child);
goto wait;
}
- if (camel_stream_flush (stream) == -1) {
+ if (camel_stream_flush (stream, NULL) == -1) {
g_object_unref (stream);
close (pipe_from_child);
goto wait;
stream = camel_stream_fs_new_with_fd (pipe_from_child);
mem = camel_stream_mem_new ();
- if (camel_stream_write_to_stream (stream, mem) == -1) {
+ if (camel_stream_write_to_stream (stream, mem, NULL) == -1) {
g_object_unref (stream);
g_object_unref (mem);
goto wait;
}
g_object_unref (stream);
- camel_stream_reset (mem);
+ camel_stream_reset (mem, NULL);
parser = camel_mime_parser_new ();
- camel_mime_parser_init_with_stream (parser, mem);
+ camel_mime_parser_init_with_stream (parser, mem, NULL);
camel_mime_parser_scan_from (parser, FALSE);
g_object_unref (mem);
message = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser ((CamelMimePart *) message, parser) == -1) {
- camel_exception_setv (
- p->ex, CAMEL_EXCEPTION_SYSTEM,
+ if (camel_mime_part_construct_from_parser ((CamelMimePart *) message, parser, NULL) == -1) {
+ gint err = camel_mime_parser_errno (parser);
+ g_set_error (
+ &p->error, G_IO_ERROR,
+ g_io_error_from_errno (err),
_("Invalid message stream received from %s: %s"),
- argv[0]->value.string,
- g_strerror (camel_mime_parser_errno (parser)));
+ argv[0]->value.string, g_strerror (err));
g_object_unref (message);
message = NULL;
} else {
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) {
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);
}
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,
+ if (data->error == NULL)
+ g_set_error (
+ &data->error,
+ CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ if (data->error == NULL)
+ g_set_error (
+ &data->error,
+ CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Error executing filter: %s: %s"),
e_sexp_error (p->eval), action);
goto done;
/**
* 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)
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
struct _run_only_once data;
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
* @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
camel_filter_driver_filter_mbox (CamelFilterDriver *driver,
const gchar *mbox,
const gchar *original_source_url,
- CamelException *ex)
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
CamelMimeParser *mp = NULL;
fd = g_open (mbox, O_RDONLY|O_BINARY, 0);
if (fd == -1) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unable to open spool folder"));
goto fail;
}
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unable to process spool folder"));
goto fail;
}
CamelMimePart *mime_part;
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));
message = camel_mime_message_new ();
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"));
+ if (camel_mime_part_construct_from_parser (mime_part, mp, error) == -1) {
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d"), i);
g_object_unref (message);
goto fail;
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);
+ original_source_url ? original_source_url : source_url,
+ &local_error);
g_object_unref (message);
- if (camel_exception_is_set (ex) || status == -1) {
+ 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;
}
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"));
* @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.
CamelUIDCache *cache,
GPtrArray *uids,
gboolean remove,
- CamelException *ex)
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
gboolean freeuids = FALSE;
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);
status = camel_filter_driver_filter_message (
driver, NULL, info, uids->pdata[i],
- folder, source_url, source_url, ex);
+ 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) {
+ 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;
}
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)
};
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;
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)
* @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
CamelFolder *source,
const gchar *source_url,
const gchar *original_source_url,
- CamelException *ex)
+ GError **error)
{
struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
struct _filter_rule *node;
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;
}
g_object_ref (message);
}
- p->ex = ex;
p->terminated = FALSE;
p->deleted = FALSE;
p->copied = FALSE;
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);
+ node->match, &p->error);
switch (result) {
case CAMEL_SEARCH_ERROR:
/* 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"),
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("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"),
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Error executing filter: %s: %s"),
e_sexp_error (p->eval), node->action);
goto error;
}
g_ptr_array_add (uids, (gchar *) p->uid);
camel_folder_transfer_messages_to (
p->source, uids, p->defaultfolder,
- NULL, FALSE, p->ex);
+ 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);
+ p->info, NULL, &p->error);
}
}
if (freeinfo)
camel_message_info_free (info);
+ g_propagate_error (error, p->error);
+ p->error = NULL;
+
return -1;
}
};
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);
/*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);
G_END_DECLS
#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"
CamelMimeMessage *message;
CamelMessageInfo *info;
const gchar *source;
- CamelException *ex;
+ GError **error;
} FilterMessageSearch;
/* ESExp callbacks */
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"));
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.boolean = regexec (&pattern, contents, 0, NULL, 0) == 0;
regfree (&pattern);
} else
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.boolean = regexec (&pattern, contents, 0, NULL, 0) == 0;
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.boolean = camel_search_message_body_contains ((CamelDataWrapper *) message, &pattern);
regfree (&pattern);
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.boolean = camel_search_message_body_contains ((CamelDataWrapper *) message, &pattern);
regfree (&pattern);
&error)) {
g_ptr_array_free (args, TRUE);
- camel_exception_setv (
- fms->ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ fms->error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to create child process '%s': %s"),
argv[0]->value.string, error->message);
g_error_free (error);
stream = camel_stream_fs_new_with_fd (pipe_to_child);
camel_data_wrapper_write_to_stream (
- CAMEL_DATA_WRAPPER (message), stream);
- camel_stream_flush (stream);
+ CAMEL_DATA_WRAPPER (message), stream, NULL);
+ camel_stream_flush (stream, NULL);
g_object_unref (stream);
context = g_main_context_new ();
* @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;
fms.message = NULL;
fms.info = info;
fms.source = source;
- fms.ex = ex;
+ fms.error = error;
sexp = e_sexp_new ();
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_GENERIC,
+ _("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_GENERIC,
+ _("Error executing filter search: %s: %s"),
+ e_sexp_error (sexp), expression);
goto error;
}
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
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-folder-search.h"
#include "camel-folder-thread.h"
#include "camel-iconv.h"
((obj), CAMEL_TYPE_FOLDER_SEARCH, CamelFolderSearchPrivate))
struct _CamelFolderSearchPrivate {
- CamelException *ex;
+ GError **error;
CamelFolderThread *threads;
GHashTable *threads_hash;
* 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.
GPtrArray *
camel_folder_search_execute_expression (CamelFolderSearch *search,
const gchar *expr,
- CamelException *ex)
+ GError **error)
{
ESExpResult *r;
GPtrArray *matches;
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot parse search expression: %s:\n%s"),
e_sexp_error(search->sexp), expr);
return NULL;
}
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_GENERIC,
+ _("Error executing search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
return NULL;
}
* @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.
guint32
camel_folder_search_count (CamelFolderSearch *search,
const gchar *expr,
- CamelException *ex)
+ GError **error)
{
ESExpResult *r;
GPtrArray *summary_set;
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")) {
|| 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot parse search expression: %s:\n%s"),
e_sexp_error(search->sexp), expr);
goto fail;
}
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_GENERIC,
+ _("Error executing search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
goto fail;
}
} else {
CamelStore *parent_store;
const gchar *full_name;
+ GError *local_error = NULL;
full_name = camel_folder_get_full_name (search->folder);
parent_store = camel_folder_get_parent_store (search->folder);
/* 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"))
dd(printf("Equivalent sql %s\n", tmp));
cdb = (CamelDB *) (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_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 */
- camel_exception_clear (ex);
+ g_clear_error (&local_error);
}
+ g_propagate_error (error, local_error);
}
g_free (tmp);
}
* @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.
camel_folder_search_search (CamelFolderSearch *search,
const gchar *expr,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
ESExpResult *r;
GPtrArray *matches = NULL, *summary_set;
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)) {
|| 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot parse search expression: %s:\n%s"),
e_sexp_error(search->sexp), expr);
goto fail;
}
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_GENERIC,
+ _("Error executing search expression: %s:\n%s"),
+ e_sexp_error(search->sexp), expr);
goto fail;
}
} else {
CamelStore *parent_store;
const gchar *full_name;
+ GError *local_error = NULL;
full_name = camel_folder_get_full_name (search->folder);
parent_store = camel_folder_get_parent_store (search->folder);
/* 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"))
matches = g_ptr_array_new();
cdb = (CamelDB *) (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_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 */
- camel_exception_clear (ex);
+ g_clear_error (&local_error);
}
+ g_propagate_error (error, local_error);
}
g_free (tmp);
v = search->summary_set?search->summary_set:search->summary;
if (!CAMEL_IS_VEE_FOLDER (search->folder)) {
- camel_folder_summary_prepare_fetch_all (search->folder->summary, search->priv->ex);
+ camel_folder_summary_prepare_fetch_all (search->folder->summary, search->priv->error);
}
for (i=0;i<v->len;i++) {
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 *
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.boolean = regexec (&pattern, contents, 0, NULL, 0) == 0;
regfree (&pattern);
} else
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);
match_message_index (CamelIndex *idx,
const gchar *uid,
const gchar *match,
- CamelException *ex)
+ GError **error)
{
CamelIndexCursor *wc, *nc;
const gchar *word, *name;
static GPtrArray *
match_words_index (CamelFolderSearch *search,
struct _camel_search_words *words,
- CamelException *ex)
+ GError **error)
{
GPtrArray *result = g_ptr_array_new();
GHashTable *ht = g_hash_table_new(g_str_hash, g_str_equal);
stream = camel_stream_mem_new_with_byte_array (byte_array);
/* FIXME: The match should be part of a stream op */
- camel_data_wrapper_decode_to_stream (containee, stream);
- camel_stream_write (stream, "", 1);
+ camel_data_wrapper_decode_to_stream (containee, stream, NULL);
+ camel_stream_write (stream, "", 1, NULL);
for (i=0;i<words->len;i++) {
/* FIXME: This is horridly slow, and should use a real search algorithm */
if (camel_ustrstrcase((const gchar *) byte_array->data, words->words[i]->word) != NULL) {
match_words_message (CamelFolder *folder,
const gchar *uid,
struct _camel_search_words *words,
- CamelException *ex)
+ GError **error)
{
guint32 mask;
CamelMimeMessage *msg;
- CamelException x = CAMEL_EXCEPTION_INITIALISER;
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);
+ }
return truth;
}
static GPtrArray *
match_words_messages (CamelFolderSearch *search,
struct _camel_search_words *words,
- CamelException *ex)
+ GError **error)
{
gint i;
GPtrArray *matches = g_ptr_array_new();
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);
}
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);
}
}
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;
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);
}
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]);
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.boolean = camel_search_message_body_contains ((CamelDataWrapper *) msg, &pattern);
regfree (&pattern);
} else
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);
}
}
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
static CamelMessageContentInfo * content_info_migrate(CamelFolderSummary *, FILE *);
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);
static CamelFIRecord *
summary_header_to_db (CamelFolderSummary *s,
- CamelException *ex)
+ GError **error)
{
CamelFIRecord * record = g_new0 (CamelFIRecord, 1);
CamelStore *parent_store;
* Get the number of summary items stored in this summary.
*
* Returns: the number of items in the summary
- *
- * @see camel_folder_summary_prepare_fetch_all()
**/
guint
camel_folder_summary_count(CamelFolderSummary *s)
* ref'd or free'd as appropriate.
*
* Returns: the summary item, or %NULL if @index is out of range
- *
- * @see camel_folder_summary_prepare_fetch_all()
**/
CamelMessageInfo *
camel_folder_summary_index (CamelFolderSummary *s, gint i)
if (!info) {
CamelDB *cdb;
- CamelException ex;
CamelStore *parent_store;
const 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 = camel_folder_get_full_name (s->folder);
ret = camel_db_read_message_info_record_with_uid (
cdb, folder_name, uid, &data,
- camel_read_mir_callback, &ex);
- if (ret != 0) {
- camel_folder_summary_unlock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
- if (camel_exception_is_set (&ex))
- g_warning ("%s: Failed read '%s' in '%s' from db: %s (0x%x)", G_STRFUNC, uid, folder_name, camel_exception_get_description (&ex), camel_exception_get_id (&ex));
- camel_exception_clear (&ex);
+ camel_read_mir_callback, NULL);
+ if (ret != 0)
return NULL;
- }
/* 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);
- }
-
cfs_schedule_info_release_timer (s);
}
* ref'd or free'd as appropriate.
*
* Returns: the summary item, or %NULL if the uid @uid is not available
- *
- * @see camel_folder_summary_prepare_fetch_all()
**/
CamelMessageInfo *
camel_folder_summary_uid (CamelFolderSummary *summary,
CamelSessionThreadMsg msg;
CamelFolder *folder;
- CamelException ex;
+ GError *error;
};
static void
CamelMessageInfoBase *info = (CamelMessageInfoBase *)camel_folder_summary_uid (folder->summary, uid);
CamelMimeMessage *msg;
CamelStore *parent_store;
- CamelException ex;
const gchar *full_name;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- 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 (parent_store->cdb_w, full_name, info->uid, info->preview, NULL);
}
- camel_exception_clear(&ex);
camel_message_info_free(info);
}
/* end */
static gint
-cfs_reload_from_db (CamelFolderSummary *s, CamelException *ex)
+cfs_reload_from_db (CamelFolderSummary *s, GError **error)
{
CamelDB *cdb;
CamelStore *parent_store;
m = camel_session_thread_msg_new(((CamelService *)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 *)parent_store)->session, &m->msg, 0);
}
/**
* camel_folder_summary_prepare_fetch_all:
* @s: #CamelFolderSummary object
- * @ex: #CamelException object.
+ * @error: return location for a #GError, or %NULL
*
* Loads all infos into memory, if they are not yet and ensures
* they will not be freed in next couple minutes. Call this function
* Since: 3.0
**/
void
-camel_folder_summary_prepare_fetch_all (CamelFolderSummary *s, CamelException *ex)
+camel_folder_summary_prepare_fetch_all (CamelFolderSummary *s,
+ GError **error)
{
guint loaded, known;
if (known - loaded > 50) {
camel_folder_summary_lock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
- cfs_reload_from_db (s, ex);
+ cfs_reload_from_db (s, error);
camel_folder_summary_unlock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
}
**/
gint
camel_folder_summary_load_from_db (CamelFolderSummary *s,
- CamelException *ex)
+ GError **error)
{
CamelDB *cdb;
CamelStore *parent_store;
const gchar *full_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"));
full_name = camel_folder_get_full_name (s->folder);
parent_store = camel_folder_get_parent_store (s->folder);
- ret = camel_folder_summary_header_load_from_db (s, parent_store, full_name, ex);
+ ret = camel_folder_summary_header_load_from_db (s, parent_store, full_name, error);
if (ret)
return ret;
cdb = parent_store->cdb_r;
- camel_exception_init (&ex2);
-
ret = camel_db_get_folder_uids_flags (
cdb, full_name, s->sort_by, s->collate,
- s->uids, p->flag_cache, &ex2);
+ s->uids, p->flag_cache, &local_error);
- 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, full_name, ex);
- } else if (ex) {
- camel_exception_xfer (ex, &ex2);
- }
-
- camel_exception_clear (&ex2);
+ ret = camel_db_prepare_message_info_table (cdb, full_name, error);
+ } else if (local_error != NULL)
+ g_propagate_error (error, local_error);
return ret == 0 ? 0 : -1;
}
gint ret = 0;
CamelDB *cdb;
CamelFIRecord *record;
- CamelException ex;
parent_store = camel_folder_get_parent_store (s->folder);
cdb = parent_store->cdb_w;
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) {
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);
}
typedef struct {
- CamelException *ex;
+ GError **error;
gboolean migration;
gint progress;
} SaveToDBArgs;
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;
CamelStore *parent_store;
}
if (!args->migration) {
- if (camel_db_write_message_info_record (cdb, full_name, mir, ex) != 0) {
+ if (camel_db_write_message_info_record (cdb, full_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, full_name, ex);
- camel_db_start_in_memory_transactions (cdb, ex);
+ camel_db_flush_in_memory_transactions (cdb, full_name, error);
+ camel_db_start_in_memory_transactions (cdb, error);
args->progress = 0;
} else {
args->progress ++;
static gint
save_message_infos_to_db (CamelFolderSummary *s,
gboolean fresh_mirs,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelDB *cdb;
const gchar *full_name;
SaveToDBArgs args;
- args.ex = ex;
+ args.error = error;
args.migration = fresh_mirs;
args.progress = 0;
parent_store = camel_folder_get_parent_store (s->folder);
cdb = parent_store->cdb_w;
- if (camel_db_prepare_message_info_table (cdb, full_name, ex) != 0)
+ if (camel_db_prepare_message_info_table (cdb, full_name, error) != 0)
return -1;
camel_folder_summary_lock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
**/
gint
camel_folder_summary_save_to_db (CamelFolderSummary *s,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelDB *cdb;
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);
- 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 this logic is nasty. */
+ if (error != NULL && *error != NULL &&
+ strstr ((*error)->message, "26 columns but 28 values") != NULL) {
const gchar *full_name;
/* This is an error is previous migration. Let remigrate this folder alone. */
- camel_db_abort_transaction (cdb, ex);
+ camel_db_abort_transaction (cdb, NULL);
full_name = camel_folder_get_full_name (s->folder);
- camel_db_reset_folder_version (cdb, full_name, 0, ex);
+ camel_db_reset_folder_version (cdb, full_name, 0, NULL);
g_warning ("Fixing up a broken summary migration on %s\n", 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->folder_name);
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)
+ GError **error)
{
CamelStore *parent_store;
CamelFIRecord *record;
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;
}
camel_folder_summary_header_load_from_db (CamelFolderSummary *s,
CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelDB *cdb;
CamelFIRecord *record;
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)
* Returns: the newly added record
**/
CamelMessageInfo *
-camel_folder_summary_add_from_header(CamelFolderSummary *s, struct _camel_header_raw *h)
+camel_folder_summary_add_from_header (CamelFolderSummary *summary,
+ struct _camel_header_raw *h)
{
- CamelMessageInfo *info = camel_folder_summary_info_new_from_header(s, h);
+ CamelMessageInfo *info;
+
+ g_return_val_if_fail (CAMEL_IS_FOLDER_SUMMARY (summary), NULL);
+
+ info = camel_folder_summary_info_new_from_header (summary, h);
+
+ camel_folder_summary_add (summary, info);
+ update_summary (summary, (CamelMessageInfoBase *) info);
- camel_folder_summary_add (s, info);
- update_summary (s, (CamelMessageInfoBase *) info);
return info;
}
gint i;
CamelDB *cdb;
CamelStore *parent_store;
- CamelException ex; /* May be this should come from the caller */
const gchar *folder_name;
GSList *uids = NULL;
g_hash_table_remove (s->loaded_infos, uid);
}
}
- camel_exception_init (&ex);
folder_name = camel_folder_get_full_name (s->folder);
parent_store = camel_folder_get_parent_store (s->folder);
* 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);
s->flags |= CAMEL_SUMMARY_DIRTY;
camel_folder_summary_unlock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
-
- camel_exception_clear (&ex);
} else {
camel_folder_summary_unlock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
}
CAMEL_STREAM_FILTER (p->filter_stream),
p->filter_index);
- camel_data_wrapper_decode_to_stream(containee, p->filter_stream);
- camel_stream_flush(p->filter_stream);
+ camel_data_wrapper_decode_to_stream (
+ containee, p->filter_stream, NULL);
+ camel_stream_flush (p->filter_stream, NULL);
camel_stream_filter_remove (
CAMEL_STREAM_FILTER (p->filter_stream), idx_id);
/* 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 *);
void camel_folder_summary_set_uid (CamelFolderSummary *summary, guint32 uid);
/* 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);
/* Get only the uids of dirty/changed things to sync to server/db */
GPtrArray * camel_folder_summary_get_changed (CamelFolderSummary *s);
/* reload the summary at any required point if required */
-void camel_folder_summary_prepare_fetch_all (CamelFolderSummary *s, CamelException *ex);
+void camel_folder_summary_prepare_fetch_all (CamelFolderSummary *s, GError **error);
/* insert mi to summary */
void camel_folder_summary_insert (CamelFolderSummary *s, CamelMessageInfo *info, gboolean load);
#include "camel-db.h"
#include "camel-debug.h"
-#include "camel-exception.h"
#include "camel-filter-driver.h"
#include "camel-folder.h"
#include "camel-mempool.h"
GPtrArray *notjunk;
CamelFolder *folder;
CamelFilterDriver *driver;
- CamelException ex;
+ GError *error;
};
enum {
gint i, status = 0;
CamelURL *uri;
gchar *source_url;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CamelJunkPlugin *csp;
const gchar *full_name;
+ GError *local_error = NULL;
full_name = camel_folder_get_full_name (m->folder);
parent_store = camel_folder_get_parent_store (m->folder);
m->junk->len), full_name);
for (i = 0; i < m->junk->len; i ++) {
- CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->junk->pdata[i], &ex);
+ CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->junk->pdata[i], NULL);
gint pc = 100 * i / m->junk->len;
- camel_exception_clear (&ex);
camel_operation_progress (NULL, pc);
if (msg) {
"Learning new ham messages in '%s'",
m->notjunk->len), full_name);
for (i = 0; i < m->notjunk->len; i ++) {
- CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->notjunk->pdata[i], &ex);
+ CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->notjunk->pdata[i], NULL);
gint pc = 100 * i / m->notjunk->len;
- camel_exception_clear (&ex);
camel_operation_progress (NULL, pc);
if (msg) {
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, NULL);
camel_folder_free_message_info (m->folder, info);
}
- camel_filter_driver_flush (m->driver, &ex);
- if (!camel_exception_is_set (&m->ex))
- camel_exception_xfer (&m->ex, &ex);
+ camel_filter_driver_flush (m->driver, &local_error);
+ if (m->error == NULL)
+ g_propagate_error (&m->error, local_error);
g_free (source_url);
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);
}
CamelFolder *dest,
gchar **transferred_uid,
gboolean delete_original,
- CamelException *ex)
+ 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;
/* 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 gboolean
folder_refresh_info (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
return TRUE;
}
static GPtrArray *
folder_get_uncached_uids (CamelFolder *folder,
GPtrArray * uids,
- CamelException *ex)
+ GError **error)
{
GPtrArray *result;
gint i;
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ 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;
-
if (delete_originals)
camel_operation_start (NULL, _("Moving messages"));
else
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]);
folder_transfer_message_to (
- source, uids->pdata[i], dest,
- ret_uid, delete_originals, ex);
+ source, uids->pdata[i], dest, ret_uid,
+ delete_originals, &local_error);
camel_operation_progress (NULL, i * 100 / uids->len);
}
}
camel_operation_end (NULL);
- camel_exception_clear (&local);
+
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
return TRUE;
}
camel_folder_change_info_cat (folder->priv->changed_frozen, info);
camel_folder_unlock (folder, CAMEL_FOLDER_CHANGE_LOCK);
msg->driver = driver;
- camel_exception_init (&msg->ex);
camel_session_thread_queue (session, &msg->msg, 0);
g_signal_stop_emission (folder, signals[CHANGED], 0);
}
g_static_mutex_init (&folder->priv->change_lock);
}
+GQuark
+camel_folder_error_quark (void)
+{
+ 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;
+}
+
/**
* camel_folder_set_lock_async:
* @folder: a #CamelFolder
gchar *
camel_folder_get_filename (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ gchar *filename;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (uid != NULL, NULL);
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->get_filename != NULL, NULL);
- return class->get_filename (folder, uid, ex);
+ filename = class->get_filename (folder, uid, error);
+ CAMEL_CHECK_GERROR (folder, get_filename, filename != NULL, error);
+
+ return filename;
}
/**
* camel_folder_sync:
* @folder: a #CamelFolder
* @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.
gboolean
camel_folder_sync (CamelFolder *folder,
gboolean expunge,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
gboolean success = TRUE;
camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK);
- if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
- success = class->sync (folder, expunge, ex);
+ if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED)) {
+ success = class->sync (folder, expunge, error);
+ CAMEL_CHECK_GERROR (folder, sync, success, error);
+ }
camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK);
/**
* camel_folder_refresh_info:
* @folder: a #CamelFolder
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Updates a folder's summary to be in sync with its backing store.
*
**/
gboolean
camel_folder_refresh_info (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
gboolean success;
camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK);
- success = class->refresh_info (folder, ex);
+ success = class->refresh_info (folder, error);
+ CAMEL_CHECK_GERROR (folder, refresh_info, success, error);
camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK);
/**
* camel_folder_expunge:
* @folder: a #CamelFolder
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Delete messages which have been marked as "DELETED"
*
**/
gboolean
camel_folder_expunge (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
gboolean success = TRUE;
camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK);
- if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
- success = class->expunge (folder, ex);
+ if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED)) {
+ success = class->expunge (folder, error);
+ CAMEL_CHECK_GERROR (folder, expunge, success, error);
+ }
camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK);
* 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.
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
gboolean success;
camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK);
success = class->append_message (
- folder, message, info, appended_uid, ex);
+ folder, message, info, appended_uid, error);
+ CAMEL_CHECK_GERROR (folder, append_message, success, error);
camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK);
* camel_folder_get_message:
* @folder: a #CamelFolder
* @uid: the UID
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Get a message from its UID in the folder.
*
CamelMimeMessage *
camel_folder_get_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
CamelMimeMessage *ret;
camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK);
- ret = class->get_message (folder, uid, ex);
+ ret = class->get_message (folder, uid, error);
+ CAMEL_CHECK_GERROR (folder, get_message, ret != NULL, error);
camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK);
* camel_folder_sync_message:
* @folder: a #CamelFolder
* @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).
gboolean
camel_folder_sync_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
gboolean success = FALSE;
camel_folder_lock (folder, CAMEL_FOLDER_REC_LOCK);
/* Use the sync_message method if the class implements it. */
- if (class->sync_message != NULL)
- success = class->sync_message (folder, uid, ex);
- else {
+ if (class->sync_message != NULL) {
+ success = class->sync_message (folder, uid, error);
+ CAMEL_CHECK_GERROR (folder, sync_message, success, error);
+ } else {
CamelMimeMessage *message;
- message = class->get_message (folder, uid, ex);
+ message = class->get_message (folder, uid, error);
+ CAMEL_CHECK_GERROR (folder, get_message, message != NULL, error);
+
if (message != NULL) {
g_object_unref (message);
success = TRUE;
**/
GPtrArray *
camel_folder_get_uncached_uids (CamelFolder *folder,
- GPtrArray * uids,
- CamelException *ex)
+ GPtrArray *uids,
+ GError **error)
{
CamelFolderClass *class;
+ GPtrArray *uncached_uids;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (uids != NULL, NULL);
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);
+ uncached_uids = class->get_uncached_uids (folder, uids, error);
+ CAMEL_CHECK_GERROR (folder, get_uncached_uids, uncached_uids != NULL, error);
+
+ return uncached_uids;
}
/**
* camel_folder_search_by_expression:
* @folder: a #CamelFolder
* @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.
*
GPtrArray *
camel_folder_search_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ GPtrArray *matches;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (folder->folder_flags & CAMEL_FOLDER_HAS_SEARCH_CAPABILITY, NULL);
/* NOTE: that it is upto the callee to CAMEL_FOLDER_REC_LOCK */
- return class->search_by_expression (folder, expression, ex);
+ matches = class->search_by_expression (folder, expression, error);
+ CAMEL_CHECK_GERROR (folder, search_by_expression, matches != NULL, error);
+
+ return matches;
}
/**
* camel_folder_count_by_expression:
* @folder: a #CamelFolder
* @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.
*
guint32
camel_folder_count_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
/* NOTE: that it is upto the callee to CAMEL_FOLDER_REC_LOCK */
- return class->count_by_expression (folder, expression, ex);
+ return class->count_by_expression (folder, expression, error);
}
/**
* @folder: a #CamelFolder
* @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.
*
camel_folder_search_by_uids (CamelFolder *folder,
const gchar *expr,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
+ GPtrArray *matches;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (folder->folder_flags & CAMEL_FOLDER_HAS_SEARCH_CAPABILITY, NULL);
/* NOTE: that it is upto the callee to CAMEL_FOLDER_REC_LOCK */
- return class->search_by_uids (folder, expr, uids, ex);
+ matches = class->search_by_uids (folder, expr, uids, error);
+ CAMEL_CHECK_GERROR (folder, search_by_uids, matches != NULL, error);
+
+ return matches;
}
/**
* @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
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
CamelFolderClass *class;
gboolean success;
class = CAMEL_FOLDER_GET_CLASS (source);
success = class->transfer_messages_to (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
} else
success = folder_transfer_messages_to (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
return success;
}
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_FOLDER, CamelFolderClass))
+/**
+ * CAMEL_FOLDER_ERROR:
+ *
+ * Since: 3.0
+ **/
+#define CAMEL_FOLDER_ERROR \
+ (camel_folder_error_quark ())
+
G_BEGIN_DECLS
struct _CamelStore;
typedef struct _CamelFolderPrivate CamelFolderPrivate;
/**
+ * CamelFolderError:
+ *
+ * Since: 3.0
+ **/
+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;
+
+/**
* CamelFolderLock:
*
* Since: 3.0
/* Methods */
gboolean (*refresh_info) (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
gboolean (*sync) (CamelFolder *folder,
gboolean expunge,
- CamelException *ex);
+ GError **error);
gboolean (*expunge) (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
gint (*get_message_count) (CamelFolder *folder);
gboolean (*append_message) (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex);
+ GError **error);
guint32 (*get_permanent_flags) (CamelFolder *folder);
guint32 (*get_message_flags) (CamelFolder *folder,
const gchar *uid);
CamelMimeMessage *
(*get_message) (CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
GPtrArray * (*get_uids) (CamelFolder *folder);
void (*free_uids) (CamelFolder *folder,
GPtrArray *array);
gboolean (*has_search_capability)(CamelFolder *folder);
GPtrArray * (*search_by_expression) (CamelFolder *folder,
const gchar *expression,
- CamelException *ex);
+ GError **error);
GPtrArray * (*search_by_uids) (CamelFolder *folder,
const gchar *expression,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
void (*search_free) (CamelFolder *folder,
GPtrArray *result);
CamelMessageInfo *
CamelFolder *destination,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
void (*delete) (CamelFolder *folder);
void (*rename) (CamelFolder *folder,
const gchar *newname);
(*get_quota_info) (CamelFolder *folder);
guint32 (*count_by_expression) (CamelFolder *folder,
const gchar *expression,
- CamelException *ex);
+ GError **error);
gboolean (*sync_message) (CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
GPtrArray * (*get_uncached_uids) (CamelFolder *folder,
- GPtrArray * uids,
- CamelException *ex);
+ GPtrArray *uids,
+ GError **error);
gchar * (*get_filename) (CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
/* Signals */
void (*changed) (CamelFolder *folder,
};
GType camel_folder_get_type (void);
+GQuark camel_folder_error_quark (void) G_GNUC_CONST;
gboolean camel_folder_refresh_info (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
gboolean camel_folder_sync (CamelFolder *folder,
gboolean expunge,
- CamelException *ex);
+ GError **error);
void camel_folder_set_lock_async (CamelFolder *folder,
gboolean skip_folder_lock);
/* delete operations */
gboolean camel_folder_expunge (CamelFolder *folder,
- CamelException *ex);
+ GError **error);
/* folder name operations */
const gchar * camel_folder_get_name (CamelFolder *folder);
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex);
+ GError **error);
/* summary related operations */
gboolean camel_folder_has_summary_capability
CamelMimeMessage *
camel_folder_get_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
gboolean camel_folder_sync_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
+
#define camel_folder_delete_message(folder, uid) \
(camel_folder_set_message_flags \
(folder, uid, CAMEL_MESSAGE_DELETED | \
GPtrArray *array);
GPtrArray * camel_folder_get_uncached_uids (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
gint camel_folder_cmp_uids (CamelFolder *folder,
const gchar *uid1,
const gchar *uid2);
GPtrArray * camel_folder_search_by_expression
(CamelFolder *folder,
const gchar *expr,
- CamelException *ex);
+ GError **error);
GPtrArray * camel_folder_search_by_uids (CamelFolder *folder,
const gchar *expr,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
void camel_folder_search_free (CamelFolder *folder,
GPtrArray *result);
guint32 camel_folder_count_by_expression(CamelFolder *folder,
const gchar *expression,
- CamelException *ex);
+ GError **error);
/* summary info */
CamelMessageInfo *
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
void camel_folder_delete (CamelFolder *folder);
void camel_folder_rename (CamelFolder *folder,
gchar * camel_folder_get_filename (CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
/* update functions for change info */
CamelFolderChangeInfo *
{
if (!gpg->diagflushed) {
gpg->diagflushed = TRUE;
- camel_stream_flush (gpg->diagnostics);
+ camel_stream_flush (gpg->diagnostics, NULL);
if (gpg->diagbuf->len == 0)
return NULL;
#endif
-static gint
-gpg_ctx_op_start (struct _GpgCtx *gpg)
+static gboolean
+gpg_ctx_op_start (struct _GpgCtx *gpg,
+ GError **error)
{
#ifndef G_OS_WIN32
gchar *status_fd = NULL, *passwd_fd = NULL;
flags = fcntl (gpg->status_fd, F_GETFL);
fcntl (gpg->status_fd, F_SETFL, flags | O_NONBLOCK);
- return 0;
+ return TRUE;
- exception:
+exception:
errnosave = errno;
errno = EINVAL;
#endif
- return -1;
+ if (errno != 0)
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Failed to execute gpg: %s"),
+ g_strerror (errno));
+ else
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Failed to execute gpg: %s"), _("Unknown"));
+
+ return FALSE;
}
#ifndef G_OS_WIN32
static gint
gpg_ctx_parse_status (struct _GpgCtx *gpg,
- CamelException *ex)
+ GError **error)
{
register guchar *inptr;
const guchar *status;
message = g_locale_to_utf8 (
(const gchar *) status, -1, NULL, NULL, NULL);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unexpected GnuPG status message encountered:\n\n%s"),
message);
g_free(message);
status += 12;
status = (const guchar *) next_token ((gchar *) status, &hint);
if (!hint) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to parse gpg userid hint."));
return -1;
}
status = (const guchar *) next_token ((gchar *) status, &userid);
if (!userid) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to parse gpg passphrase request."));
return -1;
}
status = (const guchar *) next_token ((gchar *) status, &userid);
if (!userid) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to parse gpg passphrase request."));
return -1;
}
const gchar *name = NULL;
gchar *prompt, *passwd;
guint32 flags;
+ GError *local_error = NULL;
status += 11;
"user: \"%s\""), name);
} else {
next_token ((gchar *) status, &prompt);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unexpected request from GnuPG for '%s'"),
prompt);
g_free (prompt);
}
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;
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, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
+ g_propagate_error (error, local_error);
+
return -1;
}
} 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Failed to unlock secret key: "
"3 bad passphrases given."));
return -1;
message = g_locale_to_utf8 (
(const gchar *) status+11, -1, NULL, NULL, NULL);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unexpected response from GnuPG: %s"), message);
g_free (message);
} 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to encrypt: No valid recipients specified."));
return -1;
}
static gint
gpg_ctx_op_step (struct _GpgCtx *gpg,
- CamelException *ex)
+ GError **error)
{
#ifndef G_OS_WIN32
GPollFD polls[6];
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, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
gpg_ctx_op_cancel(gpg);
return -1;
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;
if (nread > 0) {
gsize written = camel_stream_write (
- gpg->ostream, buffer, (gsize) nread);
+ gpg->ostream, buffer, (gsize) nread, error);
if (written != nread)
- goto exception;
+ return -1;
} else {
gpg->seen_eof1 = TRUE;
}
goto exception;
if (nread > 0) {
- camel_stream_write (gpg->diagnostics, buffer, nread);
+ camel_stream_write (gpg->diagnostics, buffer, nread, error);
} else {
gpg->seen_eof2 = TRUE;
}
/* write our stream to gpg's stdin */
nread = camel_stream_read (
- gpg->istream, buffer, sizeof (buffer));
+ gpg->istream, buffer, sizeof (buffer), NULL);
if (nread > 0) {
gssize w, nwritten = 0;
exception:
/* always called on an i/o error */
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Failed to execute gpg: %s"), g_strerror (errno));
gpg_ctx_op_cancel(gpg);
#endif
CamelCipherHash hash,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
struct _GpgCtx *gpg = NULL;
CamelCipherContextClass *class;
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));
+ istream, error) == -1) {
+ g_prefix_error (
+ error, _("Could not generate signing data: "));
goto fail;
}
gpg_ctx_set_istream (gpg, istream);
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));
+ if (!gpg_ctx_op_start (gpg, error))
goto fail;
- }
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1) {
+ if (gpg_ctx_op_step (gpg, error) == -1) {
gpg_ctx_op_cancel (gpg);
goto fail;
}
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
(diagnostics != NULL && *diagnostics != '\0') ?
diagnostics : _("Failed to execute gpg."));
res = 0;
dw = camel_data_wrapper_new();
- camel_stream_reset(ostream);
- camel_data_wrapper_construct_from_stream(dw, ostream);
+ camel_stream_reset(ostream, NULL);
+ camel_data_wrapper_construct_from_stream(dw, ostream, NULL);
sigpart = camel_mime_part_new();
ct = camel_content_type_new("application", "pgp-signature");
mps->signature = sigpart;
mps->contentraw = istream;
- camel_stream_reset(istream);
+ camel_stream_reset(istream, NULL);
g_object_ref (istream);
camel_medium_set_content ((CamelMedium *)opart, (CamelDataWrapper *)mps);
}
static gchar *
-swrite (CamelMimePart *sigpart)
+swrite (CamelMimePart *sigpart,
+ GError **error)
{
CamelStream *ostream;
gchar *template;
ostream = camel_stream_fs_new_with_fd (fd);
ret = camel_data_wrapper_write_to_stream (
- CAMEL_DATA_WRAPPER (sigpart), ostream);
+ CAMEL_DATA_WRAPPER (sigpart), ostream, error);
if (ret != -1) {
- ret = camel_stream_flush (ostream);
+ ret = camel_stream_flush (ostream, error);
if (ret != -1)
- ret = camel_stream_close (ostream);
+ ret = camel_stream_close (ostream, error);
}
g_object_unref (ostream);
static CamelCipherValidity *
gpg_verify (CamelCipherContext *context,
CamelMimePart *ipart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
CamelCipherValidity *validity;
if (!CAMEL_IS_MULTIPART_SIGNED(mps)
|| tmp == NULL
|| g_ascii_strcasecmp(tmp, class->sign_protocol) != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot verify message signature: "
"Incorrect message format"));
g_object_unref (istream);
CamelDataWrapper *content;
content = camel_medium_get_content ((CamelMedium *) ipart);
istream = camel_stream_mem_new();
- camel_data_wrapper_decode_to_stream (content, istream);
- camel_stream_reset(istream);
+ camel_data_wrapper_decode_to_stream (content, istream, NULL);
+ camel_stream_reset(istream, NULL);
sigpart = NULL;
} else {
/* Invalid Mimetype */
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot verify message signature: "
"Incorrect message format"));
return NULL;
#endif
if (sigpart) {
- sigfile = swrite (sigpart);
+ sigfile = swrite (sigpart, error);
if (sigfile == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot verify message signature: "
- "could not create temp file: %s"),
- g_strerror (errno));
+ g_prefix_error (
+ error, _("Cannot verify message signature: "));
goto exception;
}
}
- camel_stream_reset(istream);
+ camel_stream_reset (istream, NULL);
canon_stream = camel_stream_mem_new ();
/* strip trailing white-spaces */
camel_stream_filter_add (CAMEL_STREAM_FILTER (filter), canon);
g_object_unref (canon);
- camel_stream_write_to_stream (istream, filter);
+ camel_stream_write_to_stream (istream, filter, NULL);
g_object_unref (filter);
- camel_stream_reset (istream);
+ camel_stream_reset (istream, NULL);
- camel_stream_reset (canon_stream);
+ camel_stream_reset (canon_stream, NULL);
gpg = gpg_ctx_new (context);
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_VERIFY);
gpg_ctx_set_sigfile (gpg, sigfile);
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."));
+ if (!gpg_ctx_op_start (gpg, error))
goto exception;
- }
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1) {
+ if (gpg_ctx_op_step (gpg, error) == -1) {
gpg_ctx_op_cancel (gpg);
goto exception;
}
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
(diagnostics != NULL && *diagnostics != '\0') ?
diagnostics : _("Failed to execute gpg."));
goto exception;
GPtrArray *recipients,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
CamelGpgContext *ctx = (CamelGpgContext *) context;
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));
+ if (camel_cipher_canonical_to_stream (
+ ipart, CAMEL_MIME_FILTER_CANON_CRLF, istream, error) == -1) {
+ g_prefix_error (
+ error, _("Could not generate encrypting data: "));
goto fail1;
}
gpg_ctx_add_recipient (gpg, recipients->pdata[i]);
}
- if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg."));
+ if (!gpg_ctx_op_start (gpg, error))
goto fail;
- }
/* FIXME: move this 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) {
gpg_ctx_op_cancel (gpg);
goto fail;
}
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
(diagnostics != NULL && *diagnostics != '\0') ?
diagnostics : _("Failed to execute gpg."));
goto fail;
res = 0;
dw = camel_data_wrapper_new();
- camel_data_wrapper_construct_from_stream (dw, ostream);
+ camel_data_wrapper_construct_from_stream (dw, ostream, NULL);
encpart = camel_mime_part_new();
ct = camel_content_type_new("application", "octet-stream");
camel_mime_part_set_description(encpart, _("This is a digitally encrypted message part"));
vstream = camel_stream_mem_new();
- camel_stream_write (vstream, "Version: 1\n", strlen("Version: 1\n"));
- camel_stream_reset (vstream);
+ camel_stream_write (vstream, "Version: 1\n", strlen("Version: 1\n"), NULL);
+ camel_stream_reset (vstream, NULL);
verpart = camel_mime_part_new();
dw = camel_data_wrapper_new();
camel_data_wrapper_set_mime_type(dw, class->encrypt_protocol);
- camel_data_wrapper_construct_from_stream (dw, vstream);
+ camel_data_wrapper_construct_from_stream (dw, vstream, NULL);
g_object_unref (vstream);
camel_medium_set_content ((CamelMedium *)verpart, dw);
g_object_unref (dw);
gpg_decrypt (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
struct _GpgCtx *gpg;
CamelCipherValidity *valid = NULL;
gint rv;
if (!ipart) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot decrypt message: Incorrect message format"));
return NULL;
}
content = camel_medium_get_content ((CamelMedium *)ipart);
if (!content) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot decrypt message: Incorrect message format"));
return NULL;
}
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_GENERIC,
+ _("Failed to decrypt MIME part: "
+ "protocol error"));
return NULL;
}
content = camel_medium_get_content ((CamelMedium *) ipart);
} else {
/* Invalid Mimetype */
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot decrypt message: Incorrect message format"));
return NULL;
}
istream = camel_stream_mem_new();
- camel_data_wrapper_decode_to_stream (content, istream);
- camel_stream_reset (istream);
+ camel_data_wrapper_decode_to_stream (content, istream, NULL);
+ camel_stream_reset (istream, NULL);
ostream = camel_stream_mem_new();
camel_stream_mem_set_secure((CamelStreamMem *)ostream);
gpg_ctx_set_istream (gpg, istream);
gpg_ctx_set_ostream (gpg, ostream);
- if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg."));
+ if (!gpg_ctx_op_start (gpg, error))
goto fail;
- }
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1) {
+ if (gpg_ctx_op_step (gpg, error) == -1) {
gpg_ctx_op_cancel (gpg);
goto fail;
}
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
(diagnostics != NULL && *diagnostics != '\0') ?
diagnostics : _("Failed to execute gpg."));
goto fail;
}
- camel_stream_reset (ostream);
+ camel_stream_reset (ostream, NULL);
if (camel_content_type_is(ct, "multipart", "encrypted")) {
CamelDataWrapper *dw;
CamelStream *null = camel_stream_null_new ();
/* Multipart encrypted - parse a full mime part */
rv = camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (opart), ostream);
+ CAMEL_DATA_WRAPPER (opart), ostream, error);
dw = camel_medium_get_content ((CamelMedium *)opart);
- if (!camel_data_wrapper_decode_to_stream (dw, null)) {
+ if (!camel_data_wrapper_decode_to_stream (dw, null, NULL)) {
/* nothing had been decoded from the stream, it doesn't
contain any header, like Content-Type or such, thus
write it as a message body */
- rv = camel_data_wrapper_construct_from_stream (dw, ostream);
+ rv = camel_data_wrapper_construct_from_stream (dw, ostream, error);
}
g_object_unref (null);
/* Inline signed - raw data (may not be a mime part) */
CamelDataWrapper *dw;
dw = camel_data_wrapper_new ();
- rv = camel_data_wrapper_construct_from_stream (dw, ostream);
+ rv = camel_data_wrapper_construct_from_stream (dw, ostream, error);
camel_data_wrapper_set_mime_type(dw, "application/octet-stream");
camel_medium_set_content ((CamelMedium *)opart, dw);
g_object_unref (dw);
add_signers (valid, gpg->signers);
}
- } else {
- camel_exception_setv(
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unable to parse message content"));
}
fail:
static gint
gpg_import_keys (CamelCipherContext *context,
CamelStream *istream,
- CamelException *ex)
+ GError **error)
{
struct _GpgCtx *gpg;
gint res = -1;
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_IMPORT);
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"));
+ if (!gpg_ctx_op_start (gpg, error))
goto fail;
- }
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1) {
+ if (gpg_ctx_op_step (gpg, error) == -1) {
gpg_ctx_op_cancel (gpg);
goto fail;
}
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
(diagnostics != NULL && *diagnostics != '\0') ?
diagnostics : _("Failed to execute gpg."));
goto fail;
gpg_export_keys (CamelCipherContext *context,
GPtrArray *keys,
CamelStream *ostream,
- CamelException *ex)
+ GError **error)
{
struct _GpgCtx *gpg;
gint i;
gpg_ctx_add_recipient (gpg, keys->pdata[i]);
}
- if (gpg_ctx_op_start (gpg) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to execute gpg: %s"),
- errno ? g_strerror (errno) : _("Unknown"));
+ if (!gpg_ctx_op_start (gpg, error))
goto fail;
- }
while (!gpg_ctx_op_complete (gpg)) {
- if (gpg_ctx_op_step (gpg, ex) == -1) {
+ if (gpg_ctx_op_step (gpg, error) == -1) {
gpg_ctx_op_cancel (gpg);
goto fail;
}
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
(diagnostics != NULL && *diagnostics != '\0') ?
diagnostics : _("Failed to execute gpg."));
goto fail;
#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"
static CamelStream *
http_connect (CamelHttpStream *http,
- CamelURL *url)
+ CamelURL *url,
+ GError **error)
{
CamelTcpStream *tcp_stream;
CamelStream *stream = NULL;
if (stream == NULL) {
errno = EINVAL;
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return NULL;
}
}
hints.ai_socktype = SOCK_STREAM;
- ai = camel_getaddrinfo(url->host, serv, &hints, NULL);
+ ai = camel_getaddrinfo(url->host, serv, &hints, error);
if (ai == NULL) {
g_object_unref (stream);
return NULL;
tcp_stream = CAMEL_TCP_STREAM (stream);
- if (camel_tcp_stream_connect (tcp_stream, ai) == -1) {
+ if (camel_tcp_stream_connect (tcp_stream, ai, error) == -1) {
errsave = errno;
g_object_unref (stream);
camel_freeaddrinfo(ai);
}
static gint
-http_method_invoke (CamelHttpStream *http)
+http_method_invoke (CamelHttpStream *http,
+ GError **error)
{
const gchar *method = NULL, *use_url;
gchar *url;
"%s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
method, use_url, http->user_agent ? http->user_agent :
"CamelHttpStream/1.0", http->url->host) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
http_disconnect(http);
g_free (url);
return -1;
if (http->authrealm && camel_stream_printf (
http->raw, "WWW-Authenticate: %s\r\n",
http->authrealm) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
http_disconnect(http);
return -1;
}
if (http->authpass && http->proxy && camel_stream_printf (
http->raw, "Proxy-Authorization: Basic %s\r\n",
http->authpass) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
http_disconnect(http);
return -1;
}
/* end the headers */
- if (camel_stream_write (http->raw, "\r\n", 2) == -1 ||
- camel_stream_flush (http->raw) == -1) {
+ if (camel_stream_write (http->raw, "\r\n", 2, error) == -1 ||
+ camel_stream_flush (http->raw, error) == -1) {
http_disconnect(http);
return -1;
}
}
static gint
-http_get_headers (CamelHttpStream *http)
+http_get_headers (CamelHttpStream *http,
+ GError **error)
{
struct _camel_header_raw *headers, *node, *tail;
const gchar *type;
g_object_unref (http->parser);
http->parser = camel_mime_parser_new ();
- camel_mime_parser_init_with_stream (http->parser, http->read);
+ camel_mime_parser_init_with_stream (http->parser, http->read, NULL);
switch (camel_mime_parser_step (http->parser, &buf, &len)) {
case CAMEL_MIME_PARSER_STATE_MESSAGE:
err = camel_mime_parser_errno (http->parser);
if (err != 0) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (err),
+ "%s", g_strerror (err));
g_object_unref (http->parser);
http->parser = NULL;
goto exception;
}
static gint
-http_get_statuscode (CamelHttpStream *http)
+http_get_statuscode (CamelHttpStream *http,
+ GError **error)
{
const gchar *token;
gchar buffer[4096];
if (camel_stream_buffer_gets (
CAMEL_STREAM_BUFFER (http->read),
- buffer, sizeof (buffer)) <= 0)
+ buffer, sizeof (buffer), error) <= 0)
return -1;
d(printf("HTTP Status: %s\n", buffer));
static gssize
http_stream_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelHttpStream *http = CAMEL_HTTP_STREAM (stream);
const gchar *parser_buf;
gssize nread;
- if (http->method != CAMEL_HTTP_METHOD_GET && http->method != CAMEL_HTTP_METHOD_HEAD) {
+ if (http->method != CAMEL_HTTP_METHOD_GET &&
+ http->method != CAMEL_HTTP_METHOD_HEAD) {
errno = EIO;
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
}
if (!http->raw) {
if (http_connect (
http, http->proxy ? http->proxy :
- http->url) == NULL)
+ http->url, error) == NULL)
return -1;
- if (http_method_invoke (http) == -1) {
+ if (http_method_invoke (http, error) == -1) {
http_disconnect(http);
return -1;
}
- if (http_get_statuscode (http) == -1) {
+ if (http_get_statuscode (http, error) == -1) {
http_disconnect(http);
return -1;
}
- if (http_get_headers (http) == -1) {
+ if (http_get_headers (http, error) == -1) {
http_disconnect(http);
return -1;
}
if (n == 0)
return 0;
- nread = camel_mime_parser_read (http->parser, &parser_buf, n);
+ nread = camel_mime_parser_read (http->parser, &parser_buf, n, error);
if (nread > 0)
memcpy (buffer, parser_buf, nread);
static gssize
http_stream_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
return -1;
}
static gint
-http_stream_flush (CamelStream *stream)
+http_stream_flush (CamelStream *stream,
+ GError **error)
{
CamelHttpStream *http = (CamelHttpStream *) stream;
if (http->raw)
- return camel_stream_flush (http->raw);
+ return camel_stream_flush (http->raw, error);
else
return 0;
}
static gint
-http_stream_close (CamelStream *stream)
+http_stream_close (CamelStream *stream,
+ GError **error)
{
CamelHttpStream *http = (CamelHttpStream *) stream;
if (http->raw) {
- if (camel_stream_close (http->raw) == -1)
+ if (camel_stream_close (http->raw, error) == -1)
return -1;
http_disconnect(http);
}
static gint
-http_stream_reset (CamelStream *stream)
+http_stream_reset (CamelStream *stream,
+ GError **error)
{
CamelHttpStream *http = CAMEL_HTTP_STREAM (stream);
if (!http_stream->content_type && !http_stream->raw) {
CamelStream *stream = CAMEL_STREAM (http_stream);
- if (http_stream_read (stream, NULL, 0) == -1)
+ if (http_stream_read (stream, NULL, 0, NULL) == -1)
return NULL;
}
camel_mime_filter_index_set_name (
CAMEL_MIME_FILTER_INDEX (filter_index), idn);
name = g_strdup_printf("%s/%s", path, d->d_name);
- stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0);
- camel_stream_write_to_stream(stream, filter);
+ stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0, NULL);
+ camel_stream_write_to_stream(stream, filter, NULL);
g_object_unref (stream);
g_free(name);
#ifndef CAMEL_INDEX_H
#define CAMEL_INDEX_H
-#include <camel/camel-exception.h>
#include <camel/camel-object.h>
/* Standard GObject macros */
#include <sys/types.h>
#include <sys/wait.h>
-#include "camel-exception.h"
#include "camel-lock-client.h"
#include "camel-lock-helper.h"
+#include "camel-object.h"
#define d(x)
}
static gint
-lock_helper_init (CamelException *ex)
+lock_helper_init (GError **error)
{
gint i;
lock_stdout_pipe[1] = -1;
if (pipe(lock_stdin_pipe) == -1
|| pipe(lock_stdout_pipe) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot build locking helper pipe: %s"),
g_strerror (errno));
if (lock_stdin_pipe[0] != -1)
close(lock_stdin_pipe[1]);
close(lock_stdout_pipe[0]);
close(lock_stdout_pipe[1]);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot fork locking helper: %s"),
g_strerror (errno));
return -1;
gint
camel_lock_helper_lock (const gchar *path,
- CamelException *ex)
+ GError **error)
{
struct _CamelLockHelperMsg *msg;
gint len = strlen(path);
LOCK();
if (lock_helper_pid == -1) {
- if (lock_helper_init(ex) == -1) {
+ if (lock_helper_init(error) == -1) {
UNLOCK();
return -1;
}
|| msg->seq > lock_sequence) {
res = CAMEL_LOCK_HELPER_STATUS_PROTOCOL;
d(printf("lock child protocol error\n"));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
_("Could not lock '%s': protocol "
"error with lock-helper"), path);
goto fail;
res = msg->data;
break;
default:
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
_("Could not lock '%s'"), path);
- d(printf("locking failed !status = %d\n", msg->id));
+ d(printf("locking failed ! status = %d\n", msg->id));
break;
}
} else if (retry > 0) {
retry--;
goto again;
} else {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
_("Could not lock '%s': protocol "
"error with lock-helper"), path);
}
#ifndef CAMEL_LOCK_CLIENT_H
#define CAMEL_LOCK_CLIENT_H
-#include <camel/camel-exception.h>
+#include <glib.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
#include <sys/time.h>
#include <sys/types.h>
+#include <glib/gstdio.h>
+
#define SETEUID_SAVES (1)
/* we try and include as little as possible */
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 *
}
/* check we are allowed to lock it, we must own it, be able to write to it, and it has to exist */
- if (stat(path, &st) == -1
+ if (g_stat(path, &st) == -1
|| st.st_uid != getuid()
|| !S_ISREG(st.st_mode)
|| (st.st_mode & 0400) == 0) {
#include <time.h>
#include <sys/stat.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
#ifdef USE_DOT
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/file.h>
#endif
+#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
/**
* 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).
**/
gint
camel_lock_dot (const gchar *path,
- CamelException *ex)
+ GError **error)
{
#ifdef USE_DOT
gchar *locktmp, *lock;
sprintf(locktmp, "%sXXXXXX", path);
fdtmp = g_mkstemp(locktmp);
if (fdtmp == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not create lock file for %s: %s"),
path, g_strerror (errno));
return -1;
link(locktmp, lock);
/* but we check stat instead (again, see link(2)) */
- if (stat(locktmp, &st) == -1) {
+ if (g_stat(locktmp, &st) == -1) {
d(printf("Our lock file %s vanished!?\n", locktmp));
/* well that was unexpected, try cleanup/retry */
}
/* check for stale lock, kill it */
- if (stat(lock, &st) == 0) {
+ if (g_stat(lock, &st) == 0) {
time_t now = time (NULL);
(printf("There is an existing lock %ld seconds old\n", now-st.st_ctime));
if (st.st_ctime < now - CAMEL_LOCK_DOT_STALE) {
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. "
+ g_set_error (
+ error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Timed out trying to get lock file on %s. "
"Try again later."), path);
return -1;
#else /* !USE_DOT */
* camel_lock_fcntl:
* @fd:
* @type:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Create a lock using fcntl(2).
*
gint
camel_lock_fcntl (gint fd,
CamelLockType type,
- CamelException *ex)
+ GError **error)
{
#ifdef USE_FCNTL
struct flock lock;
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Failed to get lock using fcntl(2): %s"),
g_strerror (errno));
return -1;
* camel_lock_flock:
* @fd:
* @type:
- * @ex:
+ * @error: return location for a #GError, or %NULL
*
* Create a lock using flock(2).
*
gint
camel_lock_flock (gint fd,
CamelLockType type,
- CamelException *ex)
+ GError **error)
{
#ifdef USE_FLOCK
gint op;
op = LOCK_EX|LOCK_NB;
if (flock(fd, op) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Failed to get lock using flock(2): %s"),
g_strerror (errno));
return -1;
* @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.
camel_lock_folder (const gchar *path,
gint fd,
CamelLockType type,
- CamelException *ex)
+ GError **error)
{
gint retry = 0;
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);
}
#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);
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);
}
#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 */
} 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
priv = CAMEL_MIME_FILTER_SAVE_GET_PRIVATE (mime_filter);
if (priv->stream != NULL)
- camel_stream_write (priv->stream, in, len);
+ camel_stream_write (priv->stream, in, len, NULL);
*out = (gchar *) in;
*outlen = len;
static gssize
mime_message_write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelDataWrapperClass *data_wrapper_class;
CamelMimeMessage *mm = CAMEL_MIME_MESSAGE (data_wrapper);
/* Chain up to parent's write_to_stream() method. */
data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_message_parent_class);
- return data_wrapper_class->write_to_stream (data_wrapper, stream);
+ return data_wrapper_class->write_to_stream (data_wrapper, stream, error);
}
static void
static gint
mime_message_construct_from_parser (CamelMimePart *dw,
- CamelMimeParser *mp)
+ CamelMimeParser *mp,
+ GError **error)
{
CamelMimePartClass *mime_part_class;
gchar *buf;
/* let the mime-part construct the guts ... */
mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_message_parent_class);
- ret = mime_part_class->construct_from_parser (dw, mp);
+ ret = mime_part_class->construct_from_parser (dw, mp, error);
if (ret == -1)
return -1;
err = camel_mime_parser_errno(mp);
if (err != 0) {
errno = err;
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
ret = -1;
}
idb = camel_stream_filter_add (
CAMEL_STREAM_FILTER (filter), bestenc);
d(printf("writing to checking stream\n"));
- camel_data_wrapper_decode_to_stream (content, filter);
+ camel_data_wrapper_decode_to_stream (content, filter, NULL);
camel_stream_filter_remove (CAMEL_STREAM_FILTER (filter), idb);
if (idc != -1) {
camel_stream_filter_remove (CAMEL_STREAM_FILTER (filter), idc);
CAMEL_STREAM_FILTER (filter), bestenc);
/* and write it to the new stream */
- camel_data_wrapper_write_to_stream (content, filter);
+ camel_data_wrapper_write_to_stream (
+ content, filter, NULL);
g_object_unref (charenc);
}
static void folder_scan_step(struct _header_scan_state *s, gchar **databuffer, gsize *datalength);
static void folder_scan_drop_step(struct _header_scan_state *s);
static gint folder_scan_init_with_fd(struct _header_scan_state *s, gint fd);
-static gint folder_scan_init_with_stream(struct _header_scan_state *s, CamelStream *stream);
+static gint folder_scan_init_with_stream(struct _header_scan_state *s, CamelStream *stream, GError **error);
static struct _header_scan_state *folder_scan_init(void);
static void folder_scan_close(struct _header_scan_state *s);
static struct _header_scan_stack *folder_scan_content(struct _header_scan_state *s, gint *lastone, gchar **data, gsize *length);
* camel_mime_parser_init_with_stream:
* @m:
* @stream:
+ * @error: return location for a #GError, or %NULL
*
* Initialise the scanner with a source stream. The scanner's
* offsets will be relative to the current file position of
**/
gint
camel_mime_parser_init_with_stream (CamelMimeParser *parser,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
struct _header_scan_state *s = _PRIVATE (parser);
- return folder_scan_init_with_stream (s, stream);
+ return folder_scan_init_with_stream (s, stream, error);
}
/**
* @parser: MIME parser object
* @databuffer:
* @len:
+ * @error: return location for a #GError, or %NULL
*
* Read at most @len bytes from the internal mime parser buffer.
*
* Returns: The number of bytes available, or -1 on error.
**/
gint
-camel_mime_parser_read (CamelMimeParser *parser, const gchar **databuffer, gint len)
+camel_mime_parser_read (CamelMimeParser *parser,
+ const gchar **databuffer,
+ gint len,
+ GError **error)
{
struct _header_scan_state *s = _PRIVATE (parser);
gint there;
return there;
}
- if (folder_read(s) == -1)
+ if (folder_read(s) == -1) {
+ gint err = camel_mime_parser_errno (parser);
+
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (err),
+ "%s", g_strerror (err));
return -1;
+ }
there = MIN(s->inend - s->inptr, len);
d(printf("parser::read() had to re-read, now there = %d bytes\n", there));
memmove(s->inbuf, s->inptr, inoffset);
}
if (s->stream) {
- len = camel_stream_read(s->stream, s->inbuf+inoffset, SCAN_BUF-inoffset);
+ len = camel_stream_read (
+ s->stream, s->inbuf+inoffset, SCAN_BUF-inoffset, NULL);
} else {
len = read(s->fd, s->inbuf+inoffset, SCAN_BUF-inoffset);
}
the case (or bloody well should've been) */
newoffset = camel_seekable_stream_seek (
CAMEL_SEEKABLE_STREAM (s->stream),
- offset, whence);
+ offset, whence, NULL);
} else {
newoffset = -1;
errno = EINVAL;
static gint
folder_scan_init_with_stream (struct _header_scan_state *s,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
folder_scan_reset(s);
s->stream = g_object_ref (stream);
/* using an fd will be a little faster, but not much (over a simple stream) */
gint camel_mime_parser_init_with_fd (CamelMimeParser *m, gint fd);
-gint camel_mime_parser_init_with_stream (CamelMimeParser *m, CamelStream *stream);
+gint camel_mime_parser_init_with_stream (CamelMimeParser *m, CamelStream *stream, GError **error);
/* get the stream or fd back of the parser */
CamelStream *camel_mime_parser_stream (CamelMimeParser *parser);
void camel_mime_parser_push_state(CamelMimeParser *mp, camel_mime_parser_state_t newstate, const gchar *boundary);
/* read through the parser */
-gint camel_mime_parser_read (CamelMimeParser *parser, const gchar **databuffer, gint len);
+gint camel_mime_parser_read (CamelMimeParser *parser, const gchar **databuffer, gint len, GError **error);
/* get content type for the current part/header */
CamelContentType *camel_mime_parser_content_type (CamelMimeParser *parser);
#include <stdio.h>*/
/* simple data wrapper */
-static void
-simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser *mp)
+static gboolean
+simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw,
+ CamelMimeParser *mp,
+ GError **error)
{
gchar *buf;
GByteArray *buffer;
CamelStream *mem;
gsize len;
+ gint retval;
d(printf ("simple_data_wrapper_construct_from_parser()\n"));
d(printf("message part kept in memory!\n"));
mem = camel_stream_mem_new_with_byte_array (buffer);
- camel_data_wrapper_construct_from_stream (dw, mem);
+ retval = camel_data_wrapper_construct_from_stream (dw, mem, error);
g_object_unref (mem);
+
+ return (retval == 0);
}
/**
*
* Since: 2.24
**/
-void
-camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParser *mp)
+gboolean
+camel_mime_part_construct_content_from_parser (CamelMimePart *dw,
+ CamelMimeParser *mp,
+ GError **error)
{
CamelDataWrapper *content = NULL;
CamelContentType *ct;
gchar *encoding;
+ gboolean success = TRUE;
- g_return_if_fail (CAMEL_IS_MIME_PART (dw));
+ g_return_val_if_fail (CAMEL_IS_MIME_PART (dw), FALSE);
ct = camel_mime_parser_content_type (mp);
camel_multipart_construct_from_parser ((CamelMultipart *) content, mp);
} else {
content = camel_data_wrapper_new ();
- simple_data_wrapper_construct_from_parser (content, mp);
+ success = simple_data_wrapper_construct_from_parser (
+ content, mp, error);
}
break;
case CAMEL_MIME_PARSER_STATE_MESSAGE:
d(printf("Creating message part\n"));
content = (CamelDataWrapper *) camel_mime_message_new ();
- camel_mime_part_construct_from_parser ((CamelMimePart *)content, mp);
+ success = (camel_mime_part_construct_from_parser (
+ (CamelMimePart *)content, mp, error) == 0);
break;
case CAMEL_MIME_PARSER_STATE_MULTIPART:
d(printf("Creating multi-part\n"));
}
g_free (encoding);
+
+ return success;
}
/**
!camel_content_type_is (dw->mime_type, "text", "calendar")) {
CamelStream *mstream, *bstream;
mstream = camel_stream_mem_new();
- if (camel_data_wrapper_decode_to_stream (dw, mstream) > 0) {
+ if (camel_data_wrapper_decode_to_stream (dw, mstream, NULL) > 0) {
gchar *line = NULL;
GString *str = g_string_new (NULL);
- camel_stream_reset (mstream);
+ camel_stream_reset (mstream, NULL);
bstream = camel_stream_buffer_new (mstream, CAMEL_STREAM_BUFFER_READ|CAMEL_STREAM_BUFFER_BUFFER);
/* We should fetch just 200 unquoted lines. */
- while ((line = camel_stream_buffer_read_line((CamelStreamBuffer *)bstream)) && str->len < 200) {
+ while ((line = camel_stream_buffer_read_line((CamelStreamBuffer *)bstream, NULL)) && str->len < 200) {
gchar *tmp = line;
if (!line)
continue;
G_BEGIN_DECLS
-void camel_mime_part_construct_content_from_parser
+gboolean camel_mime_part_construct_content_from_parser
(CamelMimePart *mime_part,
- CamelMimeParser *mp);
+ CamelMimeParser *mp,
+ GError **error);
gboolean camel_mime_message_build_preview(CamelMimePart *mime_part,
CamelMessageInfo *info);
#include <string.h>
#include "camel-charset-map.h"
-#include "camel-exception.h"
+#include "camel-debug.h"
#include "camel-iconv.h"
#include "camel-mime-filter-basic.h"
#include "camel-mime-filter-charset.h"
total += out;
len = 0;
}
- out = camel_stream_write (stream, ids, ide-ids);
+ out = camel_stream_write (stream, ids, ide-ids, NULL);
if (out == -1)
return -1;
len += out;
total += out;
}
- camel_stream_write (stream, "\n", 1);
+ camel_stream_write (stream, "\n", 1, NULL);
return total;
}
static gssize
mime_part_write_to_stream (CamelDataWrapper *dw,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelMimePart *mp = CAMEL_MIME_PART (dw);
CamelMedium *medium = CAMEL_MEDIUM (dw);
} else {
count = writefn(stream, h);
}
- if (count == -1)
+ if (count == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
+ }
total += count;
h = h->next;
}
}
- count = camel_stream_write (stream, "\n", 1);
+ count = camel_stream_write (stream, "\n", 1, error);
if (count == -1)
return -1;
total += count;
count = camel_stream_printf (
ostream, "begin 644 %s\n",
filename ? filename : "untitled");
- if (count == -1)
+ if (count == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
+ }
total += count;
filter = camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_UU_ENC);
break;
}
if (reencode)
- count = camel_data_wrapper_decode_to_stream (content, stream);
+ count = camel_data_wrapper_decode_to_stream (
+ content, stream, error);
else
- count = camel_data_wrapper_write_to_stream (content, stream);
+ count = camel_data_wrapper_write_to_stream (
+ content, stream, error);
if (filter_stream) {
errnosav = errno;
- camel_stream_flush (stream);
+ camel_stream_flush (stream, NULL);
g_object_unref (filter_stream);
errno = errnosav;
}
total += count;
if (reencode && mp->priv->encoding == CAMEL_TRANSFER_ENCODING_UUENCODE) {
- count = camel_stream_write (ostream, "end\n", 4);
+ count = camel_stream_write (ostream, "end\n", 4, error);
if (count == -1)
return -1;
total += count;
static gint
mime_part_construct_from_stream (CamelDataWrapper *dw,
- CamelStream *s)
+ CamelStream *s,
+ GError **error)
{
CamelMimeParser *mp;
gint ret;
d(printf("mime_part::construct_from_stream()\n"));
mp = camel_mime_parser_new();
- if (camel_mime_parser_init_with_stream (mp, s) == -1) {
- g_warning ("Cannot create parser for stream");
+ if (camel_mime_parser_init_with_stream (mp, s, error) == -1) {
ret = -1;
} else {
ret = camel_mime_part_construct_from_parser (
- CAMEL_MIME_PART (dw), mp);
+ CAMEL_MIME_PART (dw), mp, error);
}
g_object_unref (mp);
return ret;
static gint
mime_part_construct_from_parser (CamelMimePart *mime_part,
- CamelMimeParser *mp)
+ CamelMimeParser *mp,
+ GError **error)
{
CamelDataWrapper *dw = (CamelDataWrapper *) mime_part;
struct _camel_header_raw *headers;
gchar *buf;
gsize len;
gint err;
+ gboolean success;
+ gboolean retval = 0;
d(printf("mime_part::construct_from_parser()\n"));
headers = headers->next;
}
- camel_mime_part_construct_content_from_parser (mime_part, mp);
+ success = camel_mime_part_construct_content_from_parser (
+ mime_part, mp, error);
+ retval = success ? 0 : -1;
break;
default:
g_warning("Invalid state encountered???: %u", camel_mime_parser_state(mp));
err = camel_mime_parser_errno(mp);
if (err != 0) {
errno = err;
- return -1;
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+ retval = -1;
}
- return 0;
+ return retval;
}
static void
**/
gint
camel_mime_part_construct_from_parser (CamelMimePart *mime_part,
- CamelMimeParser *mp)
+ CamelMimeParser *mp,
+ GError **error)
{
CamelMimePartClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), -1);
g_return_val_if_fail (CAMEL_IS_MIME_PARSER (mp), -1);
class = CAMEL_MIME_PART_GET_CLASS (mime_part);
g_return_val_if_fail (class->construct_from_parser != NULL, -1);
- return class->construct_from_parser (mime_part, mp);
+ retval = class->construct_from_parser (mime_part, mp, error);
+ CAMEL_CHECK_GERROR (mime_part, construct_from_parser, retval == 0, error);
+
+ return retval;
}
/**
dw = camel_data_wrapper_new ();
camel_data_wrapper_set_mime_type (dw, type);
stream = camel_stream_mem_new_with_buffer (data, length);
- camel_data_wrapper_construct_from_stream (dw, stream);
+ camel_data_wrapper_construct_from_stream (dw, stream, NULL);
g_object_unref (stream);
camel_medium_set_content (medium, dw);
g_object_unref (dw);
dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
null = (CamelStreamNull *) camel_stream_null_new ();
- camel_data_wrapper_decode_to_stream (dw, (CamelStream *) null);
+ camel_data_wrapper_decode_to_stream (dw, (CamelStream *) null, NULL);
size = null->written;
g_object_unref (null);
CamelMediumClass parent_class;
gint (*construct_from_parser)(CamelMimePart *mime_part,
- CamelMimeParser *parser);
+ CamelMimeParser *parser,
+ GError **error);
};
GType camel_mime_part_get_type (void);
CamelContentType *camel_mime_part_get_content_type (CamelMimePart *mime_part);
/* construction */
-gint camel_mime_part_construct_from_parser (CamelMimePart *mime_part, CamelMimeParser *parser);
+gint camel_mime_part_construct_from_parser (CamelMimePart *mime_part, CamelMimeParser *parser, GError **error);
/* utility functions */
void camel_mime_part_set_content (CamelMimePart *mime_part,
#include <sys/stat.h>
#include <sys/uio.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
+#include <glib/gstdio.h>
#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"
#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
* 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)
gint
camel_movemail (const gchar *source,
const gchar *dest,
- CamelException *ex)
+ GError **error)
{
gint lockid = -1;
gint res = -1;
* assuming it's unlocked is equivalent to pretending we were
* called a fraction earlier.)
*/
- if (stat (source, &st) == -1) {
+ if (g_stat (source, &st) == -1) {
if (errno != ENOENT)
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not check mail file %s: %s"),
source, g_strerror (errno));
return -1;
/* open files */
sfd = open (source, O_RDWR);
if (sfd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("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, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("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);
#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
if (close (dfd) == 0) {
ftruncate (sfd, 0);
} else {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Failed to store mail in temp file %s: %s"),
dest, g_strerror (errno));
res = -1;
static void
movemail_external (const gchar *source,
const gchar *dest,
- CamelException *ex)
+ GError **error)
{
sigset_t mask, omask;
pid_t pid;
if (pipe (fd) == -1) {
sigprocmask (SIG_SETMASK, &omask, NULL);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not create pipe: %s"),
g_strerror (errno));
return;
close (fd[0]);
close (fd[1]);
sigprocmask (SIG_SETMASK, &omask, NULL);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not fork: %s"), g_strerror (errno));
return;
sigprocmask (SIG_SETMASK, &omask, NULL);
if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Movemail program failed: %s"),
output ? output : _("(Unknown error)"));
}
static gint
camel_movemail_copy_file (gint sfd,
gint dfd,
- CamelException *ex)
+ GError **error)
{
gint nread, nwrote;
gchar buf[4096];
else if (nread == -1) {
if (errno == EINTR)
continue;
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Error reading mail file: %s"),
g_strerror (errno));
return -1;
if (nwrote == -1) {
if (errno == EINTR)
continue; /* continues inner loop */
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Error writing mail temp file: %s"),
g_strerror (errno));
return -1;
static gint
camel_movemail_solaris (gint oldsfd,
gint dfd,
- CamelException *ex)
+ GError **error)
{
CamelMimeParser *mp;
gchar *buffer;
/* need to dup as the mime parser will close on finish */
sfd = dup(oldsfd);
if (sfd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Error copying mail temp file: %s"),
g_strerror (errno));
return -1;
fail:
g_free(from);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Error copying mail temp file: %s"),
g_strerror (errno));
#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
#include <time.h>
#include <unistd.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
#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"
This is so we can parse all cases properly, without altering the content.
All we are doing is finding part offsets. */
- camel_stream_reset (stream);
+ camel_stream_reset (stream, NULL);
cmp = camel_mime_parser_new ();
- camel_mime_parser_init_with_stream (cmp, stream);
+ camel_mime_parser_init_with_stream (cmp, stream, NULL);
camel_mime_parser_push_state(cmp, CAMEL_MIME_PARSER_STATE_MULTIPART, boundary);
mps->start1 = -1;
static gssize
multipart_signed_write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper;
CamelMultipart *mp = (CamelMultipart *)mps;
/* 1 */
/* FIXME: locking? */
if (data_wrapper->stream) {
- camel_stream_reset (data_wrapper->stream);
- return camel_stream_write_to_stream (data_wrapper->stream, stream);
+ camel_stream_reset (data_wrapper->stream, NULL);
+ return camel_stream_write_to_stream (
+ data_wrapper->stream, stream, error);
+ }
+
+ /* 3 */
+ if (mps->contentraw == NULL) {
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("No content available"));
+ return -1;
}
/* 3 */
- if (mps->signature == NULL || mps->contentraw == NULL)
+ if (mps->signature == NULL) {
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("No signature available"));
return -1;
+ }
/* 2 */
boundary = camel_multipart_get_boundary(mp);
if (mp->preface) {
- count = camel_stream_write_string (stream, mp->preface);
+ count = camel_stream_write_string (stream, mp->preface, error);
if (count == -1)
return -1;
total += count;
/* first boundary */
count = camel_stream_printf (stream, "\n--%s\n", boundary);
if (count == -1)
- return -1;
+ goto file_error;
total += count;
/* output content part */
- camel_stream_reset (mps->contentraw);
- count = camel_stream_write_to_stream (mps->contentraw, stream);
+ camel_stream_reset (mps->contentraw, NULL);
+ count = camel_stream_write_to_stream (mps->contentraw, stream, error);
if (count == -1)
return -1;
total += count;
/* boundary */
count = camel_stream_printf (stream, "\n--%s\n", boundary);
if (count == -1)
- return -1;
+ goto file_error;
total += count;
/* signature */
count = camel_data_wrapper_write_to_stream (
- CAMEL_DATA_WRAPPER (mps->signature), stream);
+ CAMEL_DATA_WRAPPER (mps->signature), stream, error);
if (count == -1)
return -1;
total += count;
/* write the terminating boudary delimiter */
count = camel_stream_printf (stream, "\n--%s--\n", boundary);
if (count == -1)
- return -1;
+ goto file_error;
total += count;
/* and finally the postface */
if (mp->postface) {
- count = camel_stream_write_string (stream, mp->postface);
+ count = camel_stream_write_string (stream, mp->postface, error);
if (count == -1)
return -1;
total += count;
}
return total;
+
+file_error:
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+
+ return -1;
}
static gint
multipart_signed_construct_from_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper;
CamelStream *mem = camel_stream_mem_new();
- if (camel_stream_write_to_stream (stream, mem) == -1)
+ if (camel_stream_write_to_stream (stream, mem, error) == -1)
return -1;
multipart_signed_set_stream (mps, mem);
} else {
stream = camel_seekable_substream_new((CamelSeekableStream *)dw->stream, mps->start1, mps->end1);
}
- camel_stream_reset (stream);
+ camel_stream_reset (stream, NULL);
mps->content = camel_mime_part_new();
camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (mps->content), stream);
+ CAMEL_DATA_WRAPPER (mps->content), stream, NULL);
g_object_unref (stream);
return mps->content;
case CAMEL_MULTIPART_SIGNED_SIGNATURE:
return NULL;
}
stream = camel_seekable_substream_new((CamelSeekableStream *)dw->stream, mps->start2, mps->end2);
- camel_stream_reset (stream);
+ camel_stream_reset (stream, NULL);
mps->signature = camel_mime_part_new();
camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (mps->signature), stream);
+ CAMEL_DATA_WRAPPER (mps->signature), stream, NULL);
g_object_unref (stream);
return mps->signature;
default:
stream = camel_stream_mem_new();
while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_BODY_END)
- camel_stream_write(stream, buf, len);
+ camel_stream_write(stream, buf, len, NULL);
multipart_signed_set_stream (mps, 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.
**/
CamelStream *
camel_multipart_signed_get_content_stream (CamelMultipartSigned *mps,
- CamelException *ex)
+ GError **error)
{
CamelStream *constream;
CamelMimeFilter *canon_filter;
if (mps->start1 == -1 && multipart_signed_parse_content(mps) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
_("parse error"));
return NULL;
}
/* 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
#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"
/* this is MIME specific, doesn't belong here really */
static gssize
multipart_write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper);
const gchar *boundary;
* your mail client probably doesn't support ...."
*/
if (multipart->preface) {
- count = camel_stream_write_string (stream, multipart->preface);
+ count = camel_stream_write_string (
+ stream, multipart->preface, error);
if (count == -1)
return -1;
total += count;
count = camel_stream_printf (
stream, "\n--%s\n", boundary);
if (count == -1)
- return -1;
+ goto file_error;
total += count;
count = camel_data_wrapper_write_to_stream (
- CAMEL_DATA_WRAPPER (node->data), stream);
+ CAMEL_DATA_WRAPPER (node->data), stream, error);
if (count == -1)
return -1;
total += count;
count = camel_stream_printf (
stream, "\n--%s--\n", boundary);
if (count == -1)
- return -1;
+ goto file_error;
total += count;
/* and finally the postface */
if (multipart->postface) {
count = camel_stream_write_string (
- stream, multipart->postface);
+ stream, multipart->postface, error);
if (count == -1)
return -1;
total += count;
}
return total;
+
+file_error:
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+
+ return -1;
}
static gboolean
while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) {
camel_mime_parser_unstep(mp);
bodypart = camel_mime_part_new();
- camel_mime_part_construct_from_parser (bodypart, mp);
+ camel_mime_part_construct_from_parser (bodypart, mp, NULL);
camel_multipart_add_part(multipart, bodypart);
g_object_unref (bodypart);
}
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-msgport.h"
#include "camel-net-utils.h"
#ifdef G_OS_WIN32
#include <ws2tcpip.h>
#include "camel-net-utils-win32.h"
#endif
+#include "camel-object.h"
#include "camel-operation.h"
#define d(x)
cs_waitinfo (gpointer (worker)(gpointer),
struct _addrinfo_msg *msg,
const gchar *errmsg,
- CamelException *ex)
+ GError **error)
{
CamelMsgPort *reply_port;
GThread *thread;
- GError *err = NULL;
gint cancel_fd, cancel = 0, fd;
cancel_fd = camel_operation_cancel_fd(NULL);
reply_port = msg->msg.reply_port = camel_msgport_new();
fd = camel_msgport_fd(msg->msg.reply_port);
- if ((thread = g_thread_create (worker, msg, TRUE, &err)) != NULL) {
+ if ((thread = g_thread_create (worker, msg, TRUE, error)) != NULL) {
gint status;
#ifndef G_OS_WIN32
GPollFD polls[2];
#endif
) {
if (status == -1)
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
"%s: %s", errmsg,
#ifndef G_OS_WIN32
g_strerror (errno)
#endif
);
else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Canceled"));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
/* We cancel so if the thread impl is decent it causes immediate exit.
We check the reply port incase we had a reply in the mean time, which we free later */
if (reply != msg)
g_warning ("%s: Received msg reply %p doesn't match msg %p", G_STRFUNC, reply, msg);
}
- } else {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- "%s: %s: %s", errmsg, _("cannot create thread"),
- err ? err->message : _("Unknown error"));
- if (err)
- g_error_free (err);
}
camel_msgport_destroy(reply_port);
camel_getaddrinfo (const gchar *name,
const gchar *service,
const struct addrinfo *hints,
- CamelException *ex)
+ GError **error)
{
struct _addrinfo_msg *msg;
struct addrinfo *res = NULL;
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, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
return NULL;
}
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Host lookup failed: %s: %s"),
name, gai_strerror (msg->result));
}
gchar **host,
gchar **serv,
gint flags,
- CamelException *ex)
+ GError **error)
{
struct _addrinfo_msg *msg;
gint result;
- if (camel_operation_cancel_check(NULL)) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Canceled"));
+ if (camel_operation_cancel_check (NULL)) {
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
return -1;
}
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Name lookup failed: %s"), gai_strerror (result));
else {
if (host)
G_BEGIN_DECLS
-struct _CamelException;
-
#ifndef _WIN32
#ifdef NEED_ADDRINFO
/* Some of this is copied from GNU's netdb.h
#endif
struct addrinfo *camel_getaddrinfo(const gchar *name, const gchar *service,
- const struct addrinfo *hints, struct _CamelException *ex);
+ const struct addrinfo *hints, 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, GError **error);
G_END_DECLS
object->priv = CAMEL_OBJECT_GET_PRIVATE (object);
}
+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;
+}
+
/**
* camel_object_state_read:
* @object: a #CamelObject
#ifndef CAMEL_OBJECT_H
#define CAMEL_OBJECT_H
-#include <glib-object.h>
#include <stdio.h> /* FILE */
#include <stdlib.h> /* gsize */
#include <stdarg.h>
+#include <gio/gio.h>
/* Standard GObject macros */
#define CAMEL_TYPE_OBJECT \
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_OBJECT, CamelObjectClass))
+#define CAMEL_ERROR \
+ (camel_error_quark ())
+
G_BEGIN_DECLS
typedef struct _CamelObject CamelObject;
CAMEL_PARAM_PERSISTENT = 1 << (G_PARAM_USER_SHIFT + 0)
} CamelParamFlags;
+typedef enum {
+ CAMEL_ERROR_GENERIC /* lazy fallback error */
+} CamelError;
+
struct _CamelObject {
GObject parent;
CamelObjectPrivate *priv;
};
GType camel_object_get_type (void);
+GQuark camel_error_quark (void) G_GNUC_CONST;
gint camel_object_state_read (CamelObject *object);
gint camel_object_state_write (CamelObject *object);
const gchar * camel_object_get_state_filename (CamelObject *object);
#include <glib/gi18n-lib.h>
+#include "camel-debug.h"
#include "camel-offline-folder.h"
#include "camel-operation.h"
#include "camel-service.h"
gint pc = i * 100 / m->changes->uid_added->len;
camel_operation_progress (NULL, pc);
- camel_folder_sync_message (m->folder, m->changes->uid_added->pdata[i], &mm->ex);
+ camel_folder_sync_message (m->folder, m->changes->uid_added->pdata[i], &mm->error);
}
} 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);
static gboolean
offline_folder_downsync (CamelOfflineFolder *offline,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder = (CamelFolder *) offline;
GPtrArray *uids, *uncached_uids = NULL;
camel_folder_get_full_name (folder));
if (expression)
- uids = camel_folder_search_by_expression (folder, expression, ex);
+ uids = camel_folder_search_by_expression (folder, expression, NULL);
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, NULL);
if (uids) {
if (expression)
camel_folder_search_free (folder, uids);
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], NULL);
camel_operation_progress (NULL, pc);
}
* 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.
gboolean
camel_offline_folder_downsync (CamelOfflineFolder *offline,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelOfflineFolderClass *class;
+ gboolean success;
g_return_val_if_fail (CAMEL_IS_OFFLINE_FOLDER (offline), FALSE);
class = CAMEL_OFFLINE_FOLDER_GET_CLASS (offline);
g_return_val_if_fail (class->downsync != NULL, FALSE);
- return class->downsync (offline, expression, ex);
+ success = class->downsync (offline, expression, error);
+ CAMEL_CHECK_GERROR (offline, downsync, success, error);
+
+ return success;
}
gboolean (*downsync) (CamelOfflineFolder *folder,
const gchar *expression,
- CamelException *ex);
+ GError **error);
};
GType camel_offline_folder_get_type (void);
gboolean offline_sync);
gboolean camel_offline_folder_downsync (CamelOfflineFolder *offline,
const gchar *expression,
- CamelException *ex);
+ GError **error);
G_END_DECLS
/**
* camel_offline_journal_write:
* @journal: a #CamelOfflineJournal object
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Save the journal to disk.
*
**/
gint
camel_offline_journal_write (CamelOfflineJournal *journal,
- CamelException *ex)
+ 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot write offline journal for folder '%s': %s"),
camel_folder_get_full_name (journal->folder),
g_strerror (errno));
exception:
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot write offline journal for folder '%s': %s"),
camel_folder_get_full_name (journal->folder),
g_strerror (errno));
/**
* 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.
*
**/
gint
camel_offline_journal_replay (CamelOfflineJournal *journal,
- CamelException *ex)
+ 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);
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);
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
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 (camel_offline_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ if (!service_class->construct (service, session, provider, url, error))
return FALSE;
store->state = camel_session_get_online (session) ?
/**
* 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)
+ GError **error)
{
return store->state;
}
* 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.
gboolean
camel_offline_store_set_network_state (CamelOfflineStore *store,
gint state,
- CamelException *ex)
+ GError **error)
{
- CamelException lex;
CamelService *service = CAMEL_SERVICE (store);
gboolean network_available;
network_available =
camel_session_get_network_available (service->session);
- camel_exception_init (&lex);
if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
/* network available -> network unavailable */
if (network_available) {
if (G_TYPE_CHECK_INSTANCE_TYPE (folder, CAMEL_TYPE_OFFLINE_FOLDER)
&& (sync || camel_offline_folder_get_offline_sync (CAMEL_OFFLINE_FOLDER (folder)))) {
- camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex);
- camel_exception_clear (&lex);
+ camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, NULL);
}
g_object_unref (folder);
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_available, ex))
+ if (!camel_service_disconnect (CAMEL_SERVICE (store), network_available, error))
return FALSE;
} 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 FALSE;
}
**/
gboolean
camel_offline_store_prepare_for_offline (CamelOfflineStore *store,
- CamelException *ex)
+ GError **error)
{
- CamelException lex;
CamelService *service = CAMEL_SERVICE (store);
gboolean network_available;
network_available = camel_session_get_network_available (service->session);
- camel_exception_init (&lex);
if (network_available) {
if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
if (((CamelStore *) store)->folders) {
if (G_TYPE_CHECK_INSTANCE_TYPE (folder, CAMEL_TYPE_OFFLINE_FOLDER)
&& (sync || camel_offline_folder_get_offline_sync (CAMEL_OFFLINE_FOLDER (folder)))) {
- camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex);
- camel_exception_clear (&lex);
+ camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, NULL);
}
g_object_unref (folder);
}
}
}
- camel_store_sync (CAMEL_STORE (store), FALSE, &lex);
- camel_exception_clear (&lex);
+ camel_store_sync (CAMEL_STORE (store), FALSE, NULL);
}
return TRUE;
struct _CamelOfflineStoreClass {
CamelStoreClass parent_class;
- gboolean (* set_network_state) (CamelOfflineStore *store, gint state, CamelException *ex);
+ gboolean (* set_network_state) (CamelOfflineStore *store, gint state, GError **error);
};
GType camel_offline_store_get_type (void);
-gboolean camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, CamelException *ex);
-gint camel_offline_store_get_network_state (CamelOfflineStore *store, CamelException *ex);
+gboolean camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, GError **error);
+gint camel_offline_store_get_network_state (CamelOfflineStore *store, GError **error);
-gboolean camel_offline_store_prepare_for_offline (CamelOfflineStore *store, CamelException *ex);
+gboolean camel_offline_store_prepare_for_offline (CamelOfflineStore *store, GError **error);
G_END_DECLS
#include <glib/gstdio.h>
#include <gmodule.h>
-#include "camel-exception.h"
#include "camel-provider.h"
#include "camel-string-utils.h"
#include "camel-vee-store.h"
/**
* 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
**/
gboolean
camel_provider_load (const gchar *path,
- CamelException *ex)
+ GError **error)
{
GModule *module;
CamelProvider *(*provider_module_init) (void);
g_once (&setup_once, provider_setup, NULL);
if (!g_module_supported ()) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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 == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Could not load %s: No initialization "
"code in module."), path);
g_module_close (module);
/**
* 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.
*
- * Returns: the provider, or %NULL, in which case @ex will be set.
+ * Returns: the provider, or %NULL, in which case @error will be set.
**/
CamelProvider *
camel_provider_get (const gchar *url_string,
- CamelException *ex)
+ GError **error)
{
CamelProvider *provider = NULL;
gchar *protocol;
m = g_hash_table_lookup(module_table, protocol);
if (m && !m->loaded) {
m->loaded = 1;
- if (!camel_provider_load (m->path, 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
_("No provider available for protocol '%s'"),
protocol);
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
camel_provider_auto_detect (CamelProvider *provider,
CamelURL *url,
GHashTable **auto_detected,
- CamelException *ex)
+ 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;
#ifndef CAMEL_PROVIDER_H
#define CAMEL_PROVIDER_H
-#include <camel/camel-exception.h>
#include <camel/camel-object.h>
#include <camel/camel-object-bag.h>
#include <camel/camel-url.h>
#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. */
void camel_provider_init (void);
gboolean camel_provider_load (const gchar *path,
- CamelException *ex);
+ GError **error);
void camel_provider_register (CamelProvider *provider);
GList * camel_provider_list (gboolean load);
CamelProvider * camel_provider_get (const gchar *url_string,
- CamelException *ex);
+ GError **error);
/* This is defined by each module, not by camel-provider.c. */
void camel_provider_module_init (void);
gint camel_provider_auto_detect (CamelProvider *provider,
CamelURL *url,
GHashTable **auto_detected,
- CamelException *ex);
+ GError **error);
G_END_DECLS
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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Authentication failed."));
return NULL;
}
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,
+ 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);
break;
case CAMEL_SASL_ANON_TRACE_OPAQUE:
if (strchr (sasl_anon->trace_info, '@')) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ 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 ();
break;
default:
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Invalid trace information:\n%s"),
sasl_anon->trace_info);
return NULL;
static GByteArray *
sasl_cram_md5_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelService *service;
GChecksum *checksum;
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;
switch (priv->state) {
case STATE_AUTH:
if (token->len > 2048) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Server challenge too long (>2048 octets)"));
return NULL;
}
priv->challenge = parse_server_challenge (tokens, &abort);
g_free (tokens);
if (!priv->challenge || abort) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Server challenge contained invalid "
"\"Quality of Protection\" token"));
return NULL;
if (!tokens || !*tokens) {
g_free (tokens);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Server response did not contain "
"authorization data"));
return NULL;
if (!rspauth->value) {
g_free (rspauth->name);
g_free (rspauth);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Server response contained incomplete "
"authorization data"));
return NULL;
g_free (rspauth->name);
g_free (rspauth->value);
g_free (rspauth);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Server response does not match"));
camel_sasl_set_authenticated (sasl, TRUE);
static void
gssapi_set_exception (OM_uint32 major,
OM_uint32 minor,
- CamelException *ex)
+ GError **error)
{
const gchar *str;
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
static GByteArray *
sasl_gssapi_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslGssapiPrivate *priv;
CamelService *service;
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;
g_free (str);
if (major != GSS_S_COMPLETE) {
- gssapi_set_exception (major, minor, ex);
+ gssapi_set_exception (major, minor, error);
return NULL;
}
break;
case GSSAPI_STATE_CONTINUE_NEEDED:
if (token == NULL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Bad authentication response from server."));
return NULL;
}
send_dbus_message (service->url->user))
goto challenge;
- gssapi_set_exception (major, minor, ex);
+ gssapi_set_exception (major, minor, error);
return NULL;
}
break;
case GSSAPI_STATE_COMPLETE:
if (token == NULL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Bad authentication response from server."));
return NULL;
}
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,
+ 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);
/* 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Unsupported security layer."));
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
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;
}
static GByteArray *
sasl_login_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslLoginPrivate *priv;
GByteArray *buf = NULL;
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++;
static GByteArray *
sasl_ntlm_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelService *service;
GByteArray *ret;
static GByteArray *
sasl_plain_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
GByteArray *buf = NULL;
CamelService *service;
static GByteArray *
sasl_popb4smtp_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
gchar *popuri;
CamelService *service;
popuri = camel_session_get_password (
session, service, NULL, _("POP Source URI"),
- "popb4smtp_uri", 0, ex);
+ "popb4smtp_uri", 0, error);
if (popuri == NULL) {
- camel_exception_setv (
- ex, 1,
+ 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("POP Before SMTP auth using a non-pop source"));
return NULL;
}
}
/* 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);
#include <string.h>
+#include "camel-debug.h"
#include "camel-mime-utils.h"
#include "camel-sasl-cram-md5.h"
#include "camel-sasl-digest-md5.h"
* 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
GByteArray *
camel_sasl_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex)
+ GError **error)
{
CamelSaslClass *class;
+ GByteArray *response;
g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL);
class = CAMEL_SASL_GET_CLASS (sasl);
g_return_val_if_fail (class->challenge != NULL, NULL);
- return class->challenge (sasl, token, ex);
+ response = class->challenge (sasl, token, error);
+ CAMEL_CHECK_GERROR (sasl, challenge, response != NULL, error);
+
+ return response;
}
/**
* 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.
gchar *
camel_sasl_challenge_base64 (CamelSasl *sasl,
const gchar *token,
- CamelException *ex)
+ GError **error)
{
GByteArray *token_binary, *ret_binary;
gchar *ret;
} 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)
#define CAMEL_SASL_H
#include <camel/camel-object.h>
-#include <camel/camel-exception.h>
#include <camel/camel-service.h>
/* Standard GObject macros */
GByteArray * (*challenge) (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex);
+ GError **error);
};
GType camel_sasl_get_type (void);
GByteArray * camel_sasl_challenge (CamelSasl *sasl,
GByteArray *token,
- CamelException *ex);
+ GError **error);
gchar * camel_sasl_challenge_base64 (CamelSasl *sasl,
const gchar *token,
- CamelException *ex);
+ GError **error);
CamelSasl * camel_sasl_new (const gchar *service_name,
const gchar *mechanism,
CamelService *service);
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-mime-message.h"
#include "camel-multipart.h"
#include "camel-search-private.h"
camel_search_flags_t type,
gint argc,
struct _ESExpResult **argv,
- CamelException *ex)
+ GError **error)
{
GString *match = g_string_new("");
gint c, i, count=0, err;
gchar *buffer = g_malloc0 (len + 1);
regerror (err, pattern, buffer, len);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Regular expression compilation failed: %s: %s"),
match->str, buffer);
byte_array = g_byte_array_new ();
stream = camel_stream_mem_new_with_byte_array (byte_array);
- camel_data_wrapper_write_to_stream (containee, stream);
- camel_stream_write (stream, "", 1);
+ camel_data_wrapper_write_to_stream (containee, stream, NULL);
+ camel_stream_write (stream, "", 1, NULL);
truth = regexec (pattern, (gchar *) byte_array->data, 0, NULL, 0) == 0;
g_object_unref (stream);
}
} 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);
#include <config.h>
#endif
+#include "camel-debug.h"
#include "camel-seekable-stream.h"
G_DEFINE_TYPE (CamelSeekableStream, camel_seekable_stream, CAMEL_TYPE_STREAM)
static gint
-seekable_stream_reset (CamelStream *stream)
+seekable_stream_reset (CamelStream *stream,
+ GError **error)
{
CamelSeekableStream *seekable_stream;
return camel_seekable_stream_seek (
seekable_stream, seekable_stream->bound_start,
- CAMEL_STREAM_SET);
+ CAMEL_STREAM_SET, error);
}
static off_t
static gint
seekable_stream_set_bounds (CamelSeekableStream *stream,
off_t start,
- off_t end)
+ off_t end,
+ GError **error)
{
/* store the bounds */
stream->bound_start = start;
if (start > stream->position)
return camel_seekable_stream_seek (
- stream, start, CAMEL_STREAM_SET);
+ stream, start, CAMEL_STREAM_SET, error);
return 0;
}
* @stream: a #CamelStream object
* @offset: offset value
* @policy: what to do with the offset
+ * @error: return location for a #GError, or %NULL
*
* Seek to the specified position in @stream.
*
off_t
camel_seekable_stream_seek (CamelSeekableStream *stream,
off_t offset,
- CamelStreamSeekPolicy policy)
+ CamelStreamSeekPolicy policy,
+ GError **error)
{
CamelSeekableStreamClass *class;
+ off_t new_offset;
g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (stream), -1);
class = CAMEL_SEEKABLE_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->seek != NULL, -1);
- return class->seek (stream, offset, policy);
+ new_offset = class->seek (stream, offset, policy, error);
+ CAMEL_CHECK_GERROR (stream, seek, new_offset >= 0, error);
+
+ return new_offset;
}
/**
* @stream: a #CamelSeekableStream object
* @start: the first valid position
* @end: the first invalid position, or #CAMEL_STREAM_UNBOUND
+ * @error: return location for a #GError, or %NULL
*
* Set the range of valid data this stream is allowed to cover. If
* there is to be no @end value, then @end should be set to
gint
camel_seekable_stream_set_bounds (CamelSeekableStream *stream,
off_t start,
- off_t end)
+ off_t end,
+ GError **error)
{
CamelSeekableStreamClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (stream), -1);
g_return_val_if_fail (end == CAMEL_STREAM_UNBOUND || end >= start, -1);
class = CAMEL_SEEKABLE_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->set_bounds != NULL, -1);
- return class->set_bounds (stream, start, end);
+ retval = class->set_bounds (stream, start, end, error);
+ CAMEL_CHECK_GERROR (stream, set_bounds, retval == 0, error);
+
+ return retval;
}
off_t (*seek) (CamelSeekableStream *stream,
off_t offset,
- CamelStreamSeekPolicy policy);
+ CamelStreamSeekPolicy policy,
+ GError **error);
off_t (*tell) (CamelSeekableStream *stream);
gint (*set_bounds) (CamelSeekableStream *stream,
off_t start,
- off_t end);
+ off_t end,
+ GError **error);
};
GType camel_seekable_stream_get_type (void);
off_t camel_seekable_stream_seek (CamelSeekableStream *stream,
off_t offset,
- CamelStreamSeekPolicy policy);
+ CamelStreamSeekPolicy policy,
+ GError **error);
off_t camel_seekable_stream_tell (CamelSeekableStream *stream);
gint camel_seekable_stream_set_bounds(CamelSeekableStream *stream,
off_t start,
- off_t end);
+ off_t end,
+ GError **error);
G_END_DECLS
return camel_seekable_stream_seek (
parent, (off_t) seekable_stream->position,
- CAMEL_STREAM_SET) == seekable_stream->position;
+ CAMEL_STREAM_SET, NULL) == seekable_stream->position;
}
static void
static gssize
seekable_substream_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelSeekableStream *parent;
CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM (stream);
return 0;
}
- v = camel_stream_read (CAMEL_STREAM (parent), buffer, n);
+ v = camel_stream_read (CAMEL_STREAM (parent), buffer, n, error);
/* ignore <0 - it's an error, let the caller deal */
if (v > 0)
static gssize
seekable_substream_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelSeekableStream *parent;
CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM(stream);
return 0;
}
- v = camel_stream_write (CAMEL_STREAM (parent), buffer, n);
+ v = camel_stream_write (CAMEL_STREAM (parent), buffer, n, error);
/* ignore <0 - it's an error, let the caller deal */
if (v > 0)
}
static gint
-seekable_substream_flush (CamelStream *stream)
+seekable_substream_flush (CamelStream *stream,
+ GError **error)
{
CamelSeekableSubstream *sus = (CamelSeekableSubstream *)stream;
- return camel_stream_flush (CAMEL_STREAM (sus->parent_stream));
+ return camel_stream_flush (CAMEL_STREAM (sus->parent_stream), error);
}
static gint
-seekable_substream_close (CamelStream *stream)
+seekable_substream_close (CamelStream *stream,
+ GError **error)
{
/* we dont really want to close the substream ... */
return 0;
static off_t
seekable_substream_seek (CamelSeekableStream *seekable_stream,
off_t offset,
- CamelStreamSeekPolicy policy)
+ CamelStreamSeekPolicy policy,
+ GError **error)
{
CamelStream *stream;
CamelSeekableSubstream *seekable_substream;
if (seekable_stream->bound_end == CAMEL_STREAM_UNBOUND) {
real_offset = camel_seekable_stream_seek (
seekable_substream->parent_stream,
- offset, CAMEL_STREAM_END);
+ offset, CAMEL_STREAM_END, error);
if (real_offset != -1) {
if (real_offset<seekable_stream->bound_start)
real_offset = seekable_stream->bound_start;
* here, because if we fail to seek now, it will try again later. */
camel_seekable_stream_set_bounds (
CAMEL_SEEKABLE_STREAM (seekable_substream),
- start, end);
+ start, end, NULL);
return CAMEL_STREAM (seekable_substream);
}
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
+#include "camel-debug.h"
#include "camel-operation.h"
#include "camel-service.h"
#include "camel-session.h"
{
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 ("camel_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);
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
gchar *err, *url_string;
fail:
url_string = camel_url_to_string(url, CAMEL_URL_HIDE_PASSWORD);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
err, url_string);
g_free(url_string);
static gboolean
service_connect (CamelService *service,
- CamelException *ex)
+ GError **error)
{
/* Things like the CamelMboxStore can validly
* not define a connect function. */
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. */
static GList *
service_query_auth_types (CamelService *service,
- CamelException *ex)
+ GError **error)
{
return NULL;
}
g_static_mutex_init (&service->priv->connect_op_lock);
}
+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.
*
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
+ gboolean success;
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_val_if_fail (class->construct != NULL, FALSE);
- return class->construct (service, session, provider, url, ex);
+ success = class->construct (service, session, provider, url, error);
+ CAMEL_CHECK_GERROR (service, construct, success, error);
+
+ return success;
}
/**
* 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.
**/
gboolean
camel_service_connect (CamelService *service,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
gboolean ret = FALSE;
camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
service->status = CAMEL_SERVICE_CONNECTING;
- ret = class->connect (service, ex);
+ ret = class->connect (service, error);
+ CAMEL_CHECK_GERROR (service, connect, ret, error);
service->status = ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED;
camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
* 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.
gboolean
camel_service_disconnect (CamelService *service,
gboolean clean,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
gboolean res = TRUE;
camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
service->status = CAMEL_SERVICE_DISCONNECTING;
- res = class->disconnect (service, clean, ex);
+ res = class->disconnect (service, clean, error);
+ CAMEL_CHECK_GERROR (service, disconnect, res, error);
service->status = CAMEL_SERVICE_DISCONNECTED;
camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
/**
* 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
**/
GList *
camel_service_query_auth_types (CamelService *service,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *class;
GList *ret;
/* Note that we get the connect lock here, which means the
* callee must not call the connect functions itself. */
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- ret = class->query_auth_types (service, ex);
+ ret = class->query_auth_types (service, error);
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return ret;
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_SERVICE, CamelServiceClass))
+/**
+ * CAMEL_SERVICE_ERROR:
+ *
+ * Since: 3.0
+ **/
+#define CAMEL_SERVICE_ERROR \
+ (camel_service_error_quark ())
+
G_BEGIN_DECLS
struct _CamelSession;
typedef struct _CamelServiceClass CamelServiceClass;
typedef struct _CamelServicePrivate CamelServicePrivate;
+/**
+ * CamelServiceError:
+ *
+ * Since: 3.0
+ **/
+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;
+
typedef enum {
CAMEL_SERVICE_DISCONNECTED,
CAMEL_SERVICE_CONNECTING,
struct _CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex);
+ GError **error);
gboolean (*connect) (CamelService *service,
- CamelException *ex);
+ GError **error);
gboolean (*disconnect) (CamelService *service,
gboolean clean,
- CamelException *ex);
+ GError **error);
void (*cancel_connect) (CamelService *service);
GList * (*query_auth_types) (CamelService *service,
- CamelException *ex);
+ GError **error);
gchar * (*get_name) (CamelService *service,
gboolean brief);
gchar * (*get_path) (CamelService *service);
} CamelServiceAuthType;
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,
- CamelException *ex);
+ GError **error);
gboolean camel_service_connect (CamelService *service,
- CamelException *ex);
+ GError **error);
gboolean camel_service_disconnect (CamelService *service,
gboolean clean,
- CamelException *ex);
+ GError **error);
void camel_service_cancel_connect (CamelService *service);
gchar * camel_service_get_url (CamelService *service);
gchar * camel_service_get_name (CamelService *service,
camel_service_get_session (CamelService *service);
CamelProvider * camel_service_get_provider (CamelService *service);
GList * camel_service_query_auth_types (CamelService *service,
- CamelException *ex);
+ GError **error);
void camel_service_lock (CamelService *service,
CamelServiceLock lock);
void camel_service_unlock (CamelService *service,
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
-#include "camel-exception.h"
+#include "camel-debug.h"
#include "camel-file-utils.h"
#include "camel-session.h"
#include "camel-store.h"
session_get_service (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex)
+ GError **error)
{
CamelURL *url;
CamelProvider *provider;
CamelService *service;
- 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
_("No provider available for protocol '%s'"),
url->protocol);
provider = NULL;
service = camel_object_bag_reserve(provider->service_cache[type], url);
if (service == NULL) {
service = g_object_new (provider->object_types[type], NULL);
- if (!camel_service_construct (service, session, provider, url, 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);
static gchar *
session_get_storage_path (CamelSession *session,
CamelService *service,
- CamelException *ex)
+ GError **error)
{
gchar *path, *p;
return path;
if (g_mkdir_with_parents (path, S_IRWXU) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not create directory %s:\n%s"),
path, g_strerror (errno));
g_free (path);
m->ops = ops;
m->session = g_object_ref (session);
m->op = camel_operation_new(cs_thread_status, m);
- camel_exception_init(&m->ex);
camel_session_lock (session, CAMEL_SESSION_THREAD_LOCK);
m->id = session->priv->thread_id++;
g_hash_table_insert(session->priv->thread_active, GINT_TO_POINTER(m->id), m);
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);
}
* @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.
camel_session_get_service (CamelSession *session,
const gchar *url_string,
CamelProviderType type,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
CamelService *service;
camel_session_lock (session, CAMEL_SESSION_SESSION_LOCK);
- service = class->get_service (session, url_string, type, ex);
+ service = class->get_service (session, url_string, type, error);
+ CAMEL_CHECK_GERROR (session, get_service, service != NULL, error);
camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
* @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
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;
}
* 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
gchar *
camel_session_get_storage_path (CamelSession *session,
CamelService *service,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
+ gchar *storage_path;
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
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);
+ storage_path = class->get_storage_path (session, service, error);
+ CAMEL_CHECK_GERROR (session, get_storage_path, storage_path != NULL, error);
+
+ return storage_path;
}
/**
* @domain: domain of password request. May be null to use the default.
* @prompt: prompt to provide to user
* @item: an identifier, unique within this service, for the information
- * @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
+ * @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
+ * @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.
* caller is concerned with.
*
* @prompt is a question to ask the user (if the application doesn't
- * already have the answer cached). If #CAMEL_SESSION_PASSWORD_SECRET
+ * already have the answer cached). If %CAMEL_SESSION_PASSWORD_SECRET
* is set, the user's input will not be echoed back.
*
- * If #CAMEL_SESSION_PASSWORD_STATIC is set, it means the password returned
+ * If %CAMEL_SESSION_PASSWORD_STATIC is set, it means the password returned
* will be stored statically by the caller automatically, for the current
* session.
*
- * The authenticator should set @ex to #CAMEL_EXCEPTION_USER_CANCEL if
- * the user did not provide the information. The caller must #g_free
+ * The authenticator should set @error to %G_IO_ERROR_CANCELLED if
+ * the user did not provide the information. The caller must g_free()
* the information returned when it is done with it.
*
* Returns: the authentication information or %NULL
const gchar *prompt,
const gchar *item,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
+ gchar *password;
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (prompt != NULL, NULL);
class = CAMEL_SESSION_GET_CLASS (session);
g_return_val_if_fail (class->get_password != NULL, NULL);
- return class->get_password (
- session, service, domain, prompt, item, flags, ex);
+ password = class->get_password (
+ session, service, domain, prompt, item, flags, error);
+ CAMEL_CHECK_GERROR (session, get_password, password != NULL, error);
+
+ return password;
}
/**
* @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
CamelService *service,
const gchar *domain,
const gchar *item,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
+ gboolean success;
g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE);
g_return_val_if_fail (item != NULL, FALSE);
class = CAMEL_SESSION_GET_CLASS (session);
g_return_val_if_fail (class->forget_password, FALSE);
- return class->forget_password (session, service, domain, item, ex);
+ success = class->forget_password (session, service, domain, item, error);
+ CAMEL_CHECK_GERROR (session, forget_password, success, error);
+
+ return success;
}
/**
* 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;
+ CamelFilterDriver *driver;
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (type != NULL, NULL);
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);
+ driver = class->get_filter_driver (session, type, error);
+ CAMEL_CHECK_GERROR (session, get_filter_driver, driver != NULL, error);
+
+ return driver;
}
/**
*
* Since: 2.26
**/
-void
+gboolean
camel_session_forward_to (CamelSession *session,
CamelFolder *folder,
CamelMimeMessage *message,
const gchar *address,
- CamelException *ex)
+ GError **error)
{
CamelSessionClass *class;
+ gboolean success;
- g_return_if_fail (CAMEL_IS_SESSION (session));
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
- g_return_if_fail (address != NULL);
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE);
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
+ g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), FALSE);
+ g_return_val_if_fail (address != NULL, FALSE);
class = CAMEL_SESSION_GET_CLASS (session);
- g_return_if_fail (class->forward_to != NULL);
+ g_return_val_if_fail (class->forward_to != NULL, FALSE);
+
+ success = class->forward_to (session, folder, message, address, error);
+ CAMEL_CHECK_GERROR (session, forward_to, success, error);
- class->forward_to (session, folder, message, address, ex);
+ return success;
}
/**
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,
const gchar *domain,
const gchar *prompt,
const gchar *item,
guint32 flags,
- CamelException *ex);
+ GError **error);
gboolean (*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,
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,
gboolean (*lookup_addressbook) (CamelSession *session,
const gchar *name);
- void (*forward_to) (CamelSession *session,
+ gboolean (*forward_to) (CamelSession *session,
CamelFolder *folder,
CamelMimeMessage *message,
const gchar *address,
- CamelException *ex);
+ GError **error);
};
GType camel_session_get_type (void);
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) \
+#define camel_session_get_store(session, url_string, error) \
((CamelStore *) camel_session_get_service_connected \
- (session, url_string, CAMEL_PROVIDER_STORE, ex))
-#define camel_session_get_transport(session, url_string, ex) \
+ (session, url_string, CAMEL_PROVIDER_STORE, error))
+#define camel_session_get_transport(session, url_string, error) \
((CamelTransport *) camel_session_get_service_connected \
- (session, url_string, CAMEL_PROVIDER_TRANSPORT, ex))
+ (session, url_string, CAMEL_PROVIDER_TRANSPORT, error))
gchar * camel_session_get_storage_path (CamelSession *session,
CamelService *service,
- CamelException *ex);
+ GError **error);
gchar * camel_session_get_password (CamelSession *session,
CamelService *service,
const gchar *domain,
const gchar *prompt,
const gchar *item,
guint32 flags,
- CamelException *ex);
+ GError **error);
gboolean 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,
CamelFilterDriver *
camel_session_get_filter_driver (CamelSession *session,
const gchar *type,
- CamelException *ex);
+ GError **error);
gboolean camel_session_get_check_junk (CamelSession *session);
void camel_session_set_check_junk (CamelSession *session,
gboolean check_junk);
gint id;
- CamelException ex;
+ GError *error;
CamelSessionThreadOps *ops;
CamelOperation *op;
CamelSession *session;
gint len);
gboolean camel_session_lookup_addressbook(CamelSession *session,
const gchar *name);
-void camel_session_forward_to (CamelSession *session,
+gboolean camel_session_forward_to (CamelSession *session,
CamelFolder *folder,
CamelMimeMessage *message,
const gchar *address,
- CamelException *ex);
+ GError **error);
void camel_session_lock (CamelSession *session,
CamelSessionLock lock);
void camel_session_unlock (CamelSession *session,
#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"
static void
sm_write_stream (gpointer arg, const gchar *buf, gulong len)
{
- camel_stream_write ((CamelStream *)arg, buf, len);
+ camel_stream_write ((CamelStream *)arg, buf, len, NULL);
}
static PK11SymKey *
}
static void
-set_nss_error (CamelException *ex,
+set_nss_error (GError **error,
const gchar *def_error)
{
glong err_code;
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;
if (!err_str)
err_str = "Uknown error.";
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
"%s (%d) - %s", err_str, (gint) err_code, def_error);
}
}
const gchar *nick,
SECOidTag *hash,
gint detached,
- CamelException *ex)
+ GError **error)
{
CamelSMIMEContextPrivate *p = context->priv;
NSSCMSMessage *cmsg = NULL;
certUsageEmailSigner,
PR_TRUE,
NULL)) == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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;
}
#if 0
/* this can but needn't be added. not sure what general usage is */
if (NSS_CMSSignerInfo_AddSMIMECaps (signerinfo) != SECSuccess) {
- fprintf(stderr, "ERROR: cannot add SMIMECaps attribute.\n");
+ fprintf (stderr, "ERROR: cannot add SMIMECaps attribute.\n");
goto loser;
}
#endif
if (p->encrypt_key) {
/* encrypt key has its own nick */
- if ((ekpcert = CERT_FindUserCertByUsage(
+ if ((ekpcert = CERT_FindUserCertByUsage (
p->certdb,
p->encrypt_key,
certUsageEmailRecipient, PR_TRUE, NULL)) == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Encryption certificate for '%s' does not exist"),
p->encrypt_key);
goto fail;
if ((ekpcert = CERT_FindUserCertByUsage (
p->certdb, (gchar *)nick,
certUsageEmailRecipient, PR_TRUE, NULL)) == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Encryption certificate for '%s' does not exist"), nick);
goto fail;
}
}
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;
}
sm_verify_cmsg (CamelCipherContext *context,
NSSCMSMessage *cmsg,
CamelStream *extstream,
- CamelException *ex)
+ GError **error)
{
CamelSMIMEContextPrivate *p = ((CamelSMIMEContext *)context)->priv;
NSSCMSSignedData *sigd = NULL;
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;
}
digcx = NSS_CMSDigestContext_StartMultiple (digestalgs);
if (digcx == NULL) {
- set_nss_error (ex, _("Cannot calculate digests"));
+ set_nss_error (error, _("Cannot calculate digests"));
goto fail;
}
buffer = g_byte_array_new ();
mem = camel_stream_mem_new_with_byte_array (buffer);
- camel_stream_write_to_stream (extstream, mem);
+ camel_stream_write_to_stream (extstream, mem, NULL);
NSS_CMSDigestContext_Update (digcx, buffer->data, buffer->len);
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;
}
}
/* 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;
}
}
} else {
if (!NSS_CMSSignedData_HasDigests (sigd)) {
- set_nss_error (ex, _("Cannot find signature digests"));
+ set_nss_error (error, _("Cannot find signature digests"));
goto fail;
}
CamelCipherHash hash,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
gint res = -1;
cmsg = sm_signing_cmsmessage (
(CamelSMIMEContext *)context, userid, &sechash,
- ((CamelSMIMEContext *)context)->priv->sign_mode == CAMEL_SMIME_SIGN_CLEARSIGN, ex);
+ ((CamelSMIMEContext *)context)->priv->sign_mode == CAMEL_SMIME_SIGN_CLEARSIGN, error);
if (cmsg == NULL)
return -1;
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));
+ istream, error) == -1) {
+ g_prefix_error (
+ error, _("Could not generate signing data: "));
goto fail;
}
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;
}
res = 0;
dw = camel_data_wrapper_new ();
- camel_stream_reset (ostream);
- camel_data_wrapper_construct_from_stream (dw, ostream);
+ camel_stream_reset (ostream, NULL);
+ camel_data_wrapper_construct_from_stream (dw, ostream, NULL);
dw->encoding = CAMEL_TRANSFER_ENCODING_BINARY;
if (((CamelSMIMEContext *)context)->priv->sign_mode == CAMEL_SMIME_SIGN_CLEARSIGN) {
mps->signature = sigpart;
mps->contentraw = istream;
- camel_stream_reset (istream);
+ camel_stream_reset (istream, NULL);
g_object_ref (istream);
camel_medium_set_content ((CamelMedium *)opart, (CamelDataWrapper *)mps);
static CamelCipherValidity *
smime_context_verify (CamelCipherContext *context,
CamelMimePart *ipart,
- CamelException *ex)
+ GError **error)
{
CamelCipherContextClass *class;
NSSCMSDecoderContext *dec;
|| 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_GENERIC,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
goto fail;
}
constream = camel_multipart_signed_get_content_stream (
- (CamelMultipartSigned *)mps, ex);
+ (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_GENERIC,
+ _("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_GENERIC,
+ _("Cannot verify message signature: "
+ "Incorrect message format"));
goto fail;
}
NULL, NULL); /* decrypt key callback */
camel_data_wrapper_decode_to_stream (
- camel_medium_get_content (CAMEL_MEDIUM (sigpart)), mem);
+ camel_medium_get_content (CAMEL_MEDIUM (sigpart)), mem, NULL);
(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:
GPtrArray *recipients,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
CamelSMIMEContextPrivate *p = ((CamelSMIMEContext *)context)->priv;
/*NSSCMSRecipientInfo **recipient_infos;*/
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_GENERIC,
+ _("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;
}
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;
}
/* 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;
}
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;
}
}
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;
}
/* FIXME: Stream the input */
buffer = g_byte_array_new ();
mem = camel_stream_mem_new_with_byte_array (buffer);
- camel_cipher_canonical_to_stream (ipart, CAMEL_MIME_FILTER_CANON_CRLF, mem);
+ camel_cipher_canonical_to_stream (ipart, CAMEL_MIME_FILTER_CANON_CRLF, mem, NULL);
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"));
+ if (NSS_CMSEncoder_Finish (enc) != SECSuccess) {
+ set_nss_error (error, _("Failed to encode data"));
goto fail;
}
PORT_FreeArena (poolp, PR_FALSE);
dw = camel_data_wrapper_new ();
- camel_data_wrapper_construct_from_stream (dw, ostream);
+ camel_data_wrapper_construct_from_stream (dw, ostream, NULL);
g_object_unref (ostream);
dw->encoding = CAMEL_TRANSFER_ENCODING_BINARY;
smime_context_decrypt (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
- CamelException *ex)
+ GError **error)
{
NSSCMSDecoderContext *dec;
NSSCMSMessage *cmsg;
/* FIXME: stream this to the decoder incrementally */
buffer = g_byte_array_new ();
istream = camel_stream_mem_new_with_byte_array (buffer);
- camel_data_wrapper_decode_to_stream (camel_medium_get_content ((CamelMedium *)ipart), istream);
- camel_stream_reset (istream);
+ camel_data_wrapper_decode_to_stream (
+ camel_medium_get_content ((CamelMedium *)ipart), istream, NULL);
+ camel_stream_reset (istream, NULL);
dec = NSS_CMSDecoder_Start (NULL,
sm_write_stream, ostream, /* content callback */
g_object_unref (istream);
if (cmsg == NULL) {
- set_nss_error (ex, _("Decoder failed"));
+ set_nss_error (error, _("Decoder failed"));
goto fail;
}
}
#endif
- camel_stream_reset (ostream);
- camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)opart, ostream);
+ camel_stream_reset (ostream, NULL);
+ camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)opart, ostream, NULL);
if (NSS_CMSMessage_IsSigned (cmsg)) {
- camel_stream_reset (ostream);
- valid = sm_verify_cmsg (context, cmsg, ostream, ex);
+ camel_stream_reset (ostream, NULL);
+ valid = sm_verify_cmsg (context, cmsg, ostream, error);
} else {
valid = camel_cipher_validity_new ();
valid->encrypt.description = g_strdup (_("Encrypted content"));
/* FIXME: stream this to the decoder incrementally */
buffer = g_byte_array_new ();
istream = camel_stream_mem_new_with_byte_array (buffer);
- camel_data_wrapper_decode_to_stream (camel_medium_get_content ((CamelMedium *)part), istream);
- camel_stream_reset (istream);
+ camel_data_wrapper_decode_to_stream (
+ camel_medium_get_content ((CamelMedium *)part),
+ istream, NULL);
+ camel_stream_reset (istream, NULL);
dec = NSS_CMSDecoder_Start (NULL,
NULL, NULL,
#include "camel-db.h"
#include "camel-debug.h"
-#include "camel-exception.h"
#include "camel-folder.h"
#include "camel-marshal.h"
#include "camel-session.h"
* 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 *
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
CamelStore *store = CAMEL_STORE(service);
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ 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);
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 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");
return FALSE;
}
- if (camel_exception_is_set (ex))
- return FALSE;
-
/* 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;
static CamelFolder *
store_get_inbox (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
+ CamelFolder *folder;
/* 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);
+ folder = class->get_folder (store, "inbox", 0, error);
+ CAMEL_CHECK_GERROR (store, get_folder, folder != NULL, error);
+
+ return folder;
}
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 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 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);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ success = FALSE;
+ }
g_ptr_array_free (folders, TRUE);
static gboolean
store_noop (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
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);
}
g_static_rec_mutex_init (&store->priv->folder_lock);
}
+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.
*
camel_store_get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolder *folder = NULL;
/* 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot create folder '%s': folder exists"),
folder_name);
camel_object_bag_abort (store->folders, folder_name);
}
if ((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0) {
- folder = class->get_trash(store, ex);
+ folder = class->get_trash(store, error);
+ CAMEL_CHECK_GERROR (store, get_trash, folder != NULL, error);
} else if ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0) {
- folder = class->get_junk(store, ex);
+ folder = class->get_junk(store, error);
+ CAMEL_CHECK_GERROR (store, get_junk, folder != NULL, error);
} else {
- folder = class->get_folder(store, folder_name, flags, ex);
+ folder = class->get_folder(store, folder_name, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder, folder != NULL, error);
+
if (folder) {
CamelVeeFolder *vfolder;
* @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.
camel_store_create_folder (CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolderInfo *fi;
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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
_("Cannot create folder: %s: folder exists"),
folder_name);
return NULL;
}
camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK);
- fi = class->create_folder (store, parent_name, folder_name, ex);
+ fi = class->create_folder (store, parent_name, folder_name, error);
+ CAMEL_CHECK_GERROR (store, create_folder, fi != NULL, error);
camel_store_unlock (store, CAMEL_STORE_FOLDER_LOCK);
return fi;
* 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.
*
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_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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot delete folder: %s: Invalid operation"),
folder_name);
return FALSE;
}
- camel_exception_init(&local);
-
camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK);
- success = class->delete_folder (store, folder_name, &local);
+ success = class->delete_folder (store, folder_name, &local_error);
+ CAMEL_CHECK_GERROR (store, delete_folder, success, &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);
+ g_propagate_error (error, local_error);
camel_store_unlock (store, CAMEL_STORE_FOLDER_LOCK);
* @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.
*
camel_store_rename_folder (CamelStore *store,
const gchar *old_namein,
const gchar *new_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolder *folder;
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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot rename folder: %s: Invalid operation"),
old_namein);
return FALSE;
}
/* Now try the real rename (will emit renamed signal) */
- success = class->rename_folder (store, old_name, new_name, ex);
+ success = class->rename_folder (store, old_name, new_name, error);
+ CAMEL_CHECK_GERROR (store, rename_folder, success, error);
/* If it worked, update all open folders/unlock them */
if (folders) {
folder = folders->pdata[i];
full_name = camel_folder_get_full_name (folder);
- new = g_strdup_printf("%s%s", new_name, full_name+strlen(old_name));
+ new = g_strdup_printf("%s%s", new_name, full_name + strlen(old_name));
camel_object_bag_rekey(store->folders, folder, new);
camel_folder_rename(folder, new);
g_free(new);
if (store->flags & CAMEL_STORE_SUBSCRIPTIONS)
flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
- folder_info = class->get_folder_info(store, new_name, flags, ex);
+ folder_info = class->get_folder_info(store, new_name, flags, error);
+ CAMEL_CHECK_GERROR (store, get_folder_info, folder_info != NULL, error);
+
if (folder_info != NULL) {
camel_store_folder_renamed (store, old_name, folder_info);
class->free_folder_info (store, folder_info);
/**
* 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;
camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK);
- folder = class->get_inbox (store, ex);
+ folder = class->get_inbox (store, error);
+ CAMEL_CHECK_GERROR (store, get_inbox, folder != NULL, error);
camel_store_unlock (store, CAMEL_STORE_FOLDER_LOCK);
/**
* 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);
if ((store->flags & CAMEL_STORE_VTRASH) == 0) {
CamelStoreClass *class;
+ CamelFolder *folder;
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->get_trash != NULL, NULL);
- return class->get_trash (store, ex);
+ folder = class->get_trash (store, error);
+ CAMEL_CHECK_GERROR (store, get_trash, folder != NULL, error);
+
+ return folder;
}
- 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)
+ GError **error)
{
g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
if ((store->flags & CAMEL_STORE_VJUNK) == 0) {
CamelStoreClass *class;
+ CamelFolder *folder;
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->get_junk != NULL, NULL);
- return class->get_junk (store, ex);
+ folder = class->get_junk (store, error);
+ CAMEL_CHECK_GERROR (store, get_junk, folder != NULL, error);
+
+ return folder;
}
- 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.
gboolean
camel_store_sync (CamelStore *store,
gint expunge,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
+ gboolean success;
g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->sync != NULL, FALSE);
- return class->sync (store, expunge, ex);
+ success = class->sync (store, expunge, error);
+ CAMEL_CHECK_GERROR (store, sync, success, error);
+
+ return success;
}
static void
* @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
camel_store_get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
CamelFolderInfo *info;
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);
+ CAMEL_CHECK_GERROR (store, get_folder_info, info != NULL, error);
if (info && (top == NULL || *top == '\0') && (flags & CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL) == 0) {
if (info->uri && (store->flags & CAMEL_STORE_VTRASH))
* 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.
*
gboolean
camel_store_subscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
gboolean success;
camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK);
- success = class->subscribe_folder (store, folder_name, ex);
+ success = class->subscribe_folder (store, folder_name, error);
+ CAMEL_CHECK_GERROR (store, subscribe_folder, success, error);
camel_store_unlock (store, CAMEL_STORE_FOLDER_LOCK);
* 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.
*
gboolean
camel_store_unsubscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
gboolean success;
camel_store_lock (store, CAMEL_STORE_FOLDER_LOCK);
- success = class->unsubscribe_folder (store, folder_name, ex);
+ success = class->unsubscribe_folder (store, folder_name, error);
+ CAMEL_CHECK_GERROR (store, unsubscribe_folder, success, error);
if (success)
cs_delete_cached_folder (store, folder_name);
/**
* 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.
*
**/
gboolean
camel_store_noop (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
+ gboolean success;
g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->noop != NULL, FALSE);
- return class->noop (store, ex);
+ success = class->noop (store, error);
+ CAMEL_CHECK_GERROR (store, noop, success, error);
+
+ return success;
}
/**
* 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
gboolean
camel_store_can_refresh_folder (CamelStore *store,
CamelFolderInfo *info,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *class;
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);
}
/**
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_STORE, CamelStoreClass))
+/**
+ * CAMEL_STORE_ERROR:
+ *
+ * Since: 3.0
+ **/
+#define CAMEL_STORE_ERROR \
+ (camel_store_error_quark ())
+
G_BEGIN_DECLS
/**
+ * CamelStoreError:
+ *
+ * Since: 3.0
+ **/
+typedef enum {
+ CAMEL_STORE_ERROR_INVALID,
+ CAMEL_STORE_ERROR_NO_FOLDER
+} CamelStoreError;
+
+/**
* CamelStoreLock:
*
* Since: 3.0
CamelFolder * (*get_folder) (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException *ex);
+ GError **error);
CamelFolder * (*get_inbox) (CamelStore *store,
- CamelException *ex);
+ GError **error);
CamelFolder * (*get_trash) (CamelStore *store,
- CamelException *ex);
+ GError **error);
CamelFolder * (*get_junk) (CamelStore *store,
- CamelException *ex);
+ GError **error);
CamelFolderInfo *
(*create_folder) (CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean (*delete_folder) (CamelStore *store,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean (*rename_folder) (CamelStore *store,
const gchar *old_name,
const gchar *new_name,
- CamelException *ex);
+ GError **error);
gboolean (*sync) (CamelStore *store,
gint expunge,
- CamelException *ex);
+ GError **error);
CamelFolderInfo *
(*get_folder_info) (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex);
+ GError **error);
void (*free_folder_info) (CamelStore *store,
CamelFolderInfo *fi);
gboolean (*folder_is_subscribed) (CamelStore *store,
const gchar *folder_name);
gboolean (*subscribe_folder) (CamelStore *store,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean (*unsubscribe_folder) (CamelStore *store,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean (*noop) (CamelStore *store,
- CamelException *ex);
+ GError **error);
gboolean (*can_refresh_folder) (CamelStore *store,
CamelFolderInfo *info,
- CamelException *ex);
+ GError **error);
/* Signals */
void (*folder_created) (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);
+ GError **error);
CamelFolder * camel_store_get_inbox (CamelStore *store,
- CamelException *ex);
+ GError **error);
CamelFolder * camel_store_get_trash (CamelStore *store,
- CamelException *ex);
+ GError **error);
CamelFolder * camel_store_get_junk (CamelStore *store,
- CamelException *ex);
+ GError **error);
CamelFolderInfo *
camel_store_create_folder (CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean camel_store_delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean camel_store_rename_folder (CamelStore *store,
const gchar *old_namein,
const gchar *new_name,
- CamelException *ex);
+ GError **error);
void camel_store_folder_created (CamelStore *store,
CamelFolderInfo *info);
void camel_store_folder_deleted (CamelStore *store,
CamelFolderInfo *info);
gboolean camel_store_sync (CamelStore *store,
gint expunge,
- CamelException *ex);
+ GError **error);
CamelFolderInfo *
camel_store_get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex);
+ GError **error);
void camel_store_free_folder_info (CamelStore *store,
CamelFolderInfo *fi);
void camel_store_free_folder_info_full
const gchar *folder_name);
gboolean camel_store_subscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean camel_store_unsubscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex);
+ GError **error);
gboolean camel_store_noop (CamelStore *store,
- CamelException *ex);
+ 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,
- CamelException *ex);
+ GError **error);
void camel_store_lock (CamelStore *store,
CamelStoreLock lock);
void camel_store_unlock (CamelStore *store,
static gssize
stream_write_all (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
gsize left = n, w;
while (left > 0) {
- w = camel_stream_write (stream, buffer, left);
+ w = camel_stream_write (stream, buffer, left, error);
if (w == -1)
return -1;
left -= w;
static gssize
stream_buffer_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamBufferPrivate *priv;
gssize bytes_read = 1;
/* if we are reading a lot, then read directly to the destination buffer */
if (n >= priv->size/3) {
bytes_read = camel_stream_read (
- priv->stream, bptr, n);
+ priv->stream, bptr, n, error);
if (bytes_read>0) {
n -= bytes_read;
bptr += bytes_read;
} else {
bytes_read = camel_stream_read (
priv->stream, (gchar *)
- priv->buf, priv->size);
+ priv->buf, priv->size, error);
if (bytes_read>0) {
gsize bytes_used = bytes_read > n ? n : bytes_read;
priv->ptr = priv->buf;
static gssize
stream_buffer_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamBufferPrivate *priv;
gssize total = n;
if (left == todo) {
if (stream_write_all (
priv->stream, (gchar *) priv->buf,
- priv->size) == -1)
+ priv->size, error) == -1)
return -1;
priv->ptr = priv->buf;
if (n > 0) {
if (n >= priv->size/3) {
if (stream_write_all (
- priv->stream, buffer, n) == -1)
+ priv->stream, buffer, n, error) == -1)
return -1;
} else {
memcpy(priv->ptr, buffer, n);
}
static gint
-stream_buffer_flush (CamelStream *stream)
+stream_buffer_flush (CamelStream *stream,
+ GError **error)
{
CamelStreamBufferPrivate *priv;
gsize len = priv->ptr - priv->buf;
if (camel_stream_write (
- priv->stream, (gchar *) priv->buf, len) == -1)
+ priv->stream, (gchar *) priv->buf, len, error) == -1)
return -1;
priv->ptr = priv->buf;
/* nothing to do for read mode 'flush' */
}
- return camel_stream_flush (priv->stream);
+ return camel_stream_flush (priv->stream, error);
}
static gint
-stream_buffer_close (CamelStream *stream)
+stream_buffer_close (CamelStream *stream,
+ GError **error)
{
CamelStreamBufferPrivate *priv;
priv = CAMEL_STREAM_BUFFER_GET_PRIVATE (stream);
- if (stream_buffer_flush (stream) == -1)
+ if (stream_buffer_flush (stream, error) == -1)
return -1;
- return camel_stream_close (priv->stream);
+ return camel_stream_close (priv->stream, error);
}
static gboolean
* @sbf: a #CamelStreamBuffer object
* @buf: Memory to write the string to.
* @max: Maxmimum number of characters to store.
+ * @error: return location for a #GError, or %NULL
*
* Read a line of characters up to the next newline character or
* @max-1 characters.
gint
camel_stream_buffer_gets (CamelStreamBuffer *sbf,
gchar *buf,
- guint max)
+ guint max,
+ GError **error)
{
register gchar *outptr, *inptr, *inend, c, *outend;
gint bytes_read;
bytes_read = camel_stream_read (
sbf->priv->stream, (gchar *)
- sbf->priv->buf, sbf->priv->size);
+ sbf->priv->buf, sbf->priv->size, error);
if (bytes_read == -1) {
if (buf == outptr)
return -1;
/**
* camel_stream_buffer_read_line:
* @sbf: a #CamelStreamBuffer object
+ * @error: return location for a @GError, or %NULL
*
* This function reads a complete newline-terminated line from the stream
* and returns it in allocated memory. The trailing newline (and carriage
* return if any) are not included in the returned string.
*
* Returns: the line read, which the caller must free when done with,
- * or %NULL on eof. If an error occurs, @ex will be set.
+ * or %NULL on eof. If an error occurs, @error will be set.
**/
gchar *
-camel_stream_buffer_read_line (CamelStreamBuffer *sbf)
+camel_stream_buffer_read_line (CamelStreamBuffer *sbf,
+ GError **error)
{
guchar *p;
gint nread;
while (1) {
nread = camel_stream_buffer_gets (
sbf, (gchar *) p, sbf->priv->linesize -
- (p - sbf->priv->linebuf));
+ (p - sbf->priv->linebuf), error);
if (nread <=0) {
if (p > sbf->priv->linebuf)
break;
guint32 size);
gint camel_stream_buffer_gets (CamelStreamBuffer *sbf,
gchar *buf,
- guint max);
-gchar * camel_stream_buffer_read_line (CamelStreamBuffer *sbf);
+ guint max,
+ GError **error);
+gchar * camel_stream_buffer_read_line (CamelStreamBuffer *sbf,
+ GError **error);
G_END_DECLS
#include <config.h>
#endif
+#include <errno.h>
#include <stdio.h>
#include <string.h>
static gssize
stream_filter_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamFilterPrivate *priv;
gssize size;
gsize presize = READ_PAD;
size = camel_stream_read (
- priv->source, priv->buffer, READ_SIZE);
+ priv->source, priv->buffer, READ_SIZE, error);
if (size <= 0) {
/* this is somewhat untested */
if (camel_stream_eos(priv->source)) {
static gssize
stream_filter_write (CamelStream *stream,
const gchar *buf,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamFilterPrivate *priv;
struct _filter *f;
f = f->next;
}
- if (camel_stream_write (priv->source, buffer, len) != len)
+ if (camel_stream_write (priv->source, buffer, len, error) != len)
return -1;
}
}
static gint
-stream_filter_flush (CamelStream *stream)
+stream_filter_flush (CamelStream *stream,
+ GError **error)
{
CamelStreamFilterPrivate *priv;
struct _filter *f;
f = f->next;
}
- if (len > 0 && camel_stream_write (priv->source, buffer, len) == -1)
+ if (len > 0 && camel_stream_write (priv->source, buffer, len, error) == -1)
return -1;
- return camel_stream_flush (priv->source);
+ return camel_stream_flush (priv->source, error);
}
static gint
-stream_filter_close (CamelStream *stream)
+stream_filter_close (CamelStream *stream,
+ GError **error)
{
CamelStreamFilterPrivate *priv;
priv = CAMEL_STREAM_FILTER_GET_PRIVATE (stream);
- if (!priv->last_was_read)
- stream_filter_flush (stream);
+ if (!priv->last_was_read) {
+ if (stream_filter_flush (stream, error) == -1)
+ return -1;
+ }
- return camel_stream_close (priv->source);
+ return camel_stream_close (priv->source, error);
}
static gboolean
}
static gint
-stream_filter_reset (CamelStream *stream)
+stream_filter_reset (CamelStream *stream,
+ GError **error)
{
CamelStreamFilterPrivate *priv;
struct _filter *f;
f = f->next;
}
- return camel_stream_reset (priv->source);
+ return camel_stream_reset (priv->source, error);
}
static void
static gssize
stream_fs_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamFsPrivate *priv;
CamelSeekableStream *seekable;
if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
n = MIN (seekable->bound_end - seekable->position, n);
- if ((nread = camel_read (priv->fd, buffer, n)) > 0)
+ if ((nread = camel_read (priv->fd, buffer, n, error)) > 0)
seekable->position += nread;
else if (nread == 0)
stream->eos = TRUE;
static gssize
stream_fs_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamFsPrivate *priv;
CamelSeekableStream *seekable;
if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
n = MIN (seekable->bound_end - seekable->position, n);
- if ((nwritten = camel_write (priv->fd, buffer, n)) > 0)
+ if ((nwritten = camel_write (priv->fd, buffer, n, error)) > 0)
seekable->position += nwritten;
return nwritten;
}
static gint
-stream_fs_flush (CamelStream *stream)
+stream_fs_flush (CamelStream *stream,
+ GError **error)
{
CamelStreamFsPrivate *priv;
priv = CAMEL_STREAM_FS_GET_PRIVATE (stream);
- return fsync (priv->fd);
+ if (fsync (priv->fd) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+ return -1;
+ }
+
+ return 0;
}
static gint
-stream_fs_close (CamelStream *stream)
+stream_fs_close (CamelStream *stream,
+ GError **error)
{
CamelStreamFsPrivate *priv;
priv = CAMEL_STREAM_FS_GET_PRIVATE (stream);
- if (close (priv->fd) == -1)
+ if (close (priv->fd) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
+ }
priv->fd = -1;
static off_t
stream_fs_seek (CamelSeekableStream *stream,
off_t offset,
- CamelStreamSeekPolicy policy)
+ CamelStreamSeekPolicy policy,
+ GError **error)
{
CamelStreamFsPrivate *priv;
off_t real = 0;
if (real<stream->bound_start)
real = stream->bound_start;
stream->position = real;
- }
+ } else
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return real;
}
real = stream->bound_end + offset;
real = MAX (real, stream->bound_start);
real = lseek(priv->fd, real, SEEK_SET);
- if (real == -1)
+ if (real == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
+ }
if (real != stream->position && ((CamelStream *)stream)->eos)
((CamelStream *)stream)->eos = FALSE;
CamelStream *
camel_stream_fs_new_with_fd_and_bounds (gint fd,
off_t start,
- off_t end)
+ off_t end,
+ GError **error)
{
CamelStream *stream;
stream = camel_stream_fs_new_with_fd (fd);
camel_seekable_stream_set_bounds (
- CAMEL_SEEKABLE_STREAM (stream), start, end);
+ CAMEL_SEEKABLE_STREAM (stream), start, end, error);
return stream;
}
* @name: a local filename
* @flags: flags as in open(2)
* @mode: a file mode
+ * @error: return location for a #GError, or %NULL
*
* Creates a new #CamelStreamFs corresponding to the named file, flags,
* and mode.
CamelStream *
camel_stream_fs_new_with_name (const gchar *name,
gint flags,
- mode_t mode)
+ mode_t mode,
+ GError **error)
{
gint fd;
fd = g_open (name, flags|O_BINARY, mode);
- if (fd == -1)
+ if (fd == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return NULL;
+ }
return camel_stream_fs_new_with_fd (fd);
}
* @mode: a file mode
* @start: the first valid position in the file
* @end: the first invalid position in the file, or #CAMEL_STREAM_UNBOUND
+ * @error: return location for a #GError, or %NULL
*
* Creates a new CamelStream corresponding to the given arguments.
*
gint flags,
mode_t mode,
off_t start,
- off_t end)
+ off_t end,
+ GError **error)
{
CamelStream *stream;
+ gint retval;
- stream = camel_stream_fs_new_with_name (name, flags, mode);
+ stream = camel_stream_fs_new_with_name (name, flags, mode, error);
if (stream == NULL)
return NULL;
- camel_seekable_stream_set_bounds (
+ retval = camel_seekable_stream_set_bounds (
CAMEL_SEEKABLE_STREAM (stream),
- start, end);
+ start, end, error);
+
+ if (retval == -1) {
+ g_object_unref (stream);
+ stream = NULL;
+ }
return stream;
}
GType camel_stream_fs_get_type (void);
CamelStream * camel_stream_fs_new_with_name (const gchar *name,
gint flags,
- mode_t mode);
+ mode_t mode,
+ GError **error);
CamelStream * camel_stream_fs_new_with_name_and_bounds
(const gchar *name,
gint flags,
mode_t mode,
off_t start,
- off_t end);
+ off_t end,
+ GError **error);
CamelStream * camel_stream_fs_new_with_fd (gint fd);
CamelStream * camel_stream_fs_new_with_fd_and_bounds
(gint fd,
off_t start,
- off_t end);
+ off_t end,
+ GError **error);
gint camel_stream_fs_get_fd (CamelStreamFs *stream);
G_END_DECLS
static gssize
stream_mem_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamMemPrivate *priv;
CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
static gssize
stream_mem_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamMemPrivate *priv;
CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
static off_t
stream_mem_seek (CamelSeekableStream *stream,
off_t offset,
- CamelStreamSeekPolicy policy)
+ CamelStreamSeekPolicy policy,
+ GError **error)
{
CamelStreamMemPrivate *priv;
off_t position;
static gssize
stream_null_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CAMEL_STREAM_NULL (stream)->written += n;
}
static gint
-stream_null_reset (CamelStream *stream)
+stream_null_reset (CamelStream *stream,
+ GError **error)
{
CAMEL_STREAM_NULL (stream)->written = 0;
{
/* Ensure we clean up after ourselves -- kill
the child process and reap it. */
- camel_stream_close (CAMEL_STREAM (object));
+ camel_stream_close (CAMEL_STREAM (object), NULL);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (camel_stream_process_parent_class)->finalize (object);
static gssize
stream_process_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamProcess *stream_process = CAMEL_STREAM_PROCESS (stream);
- return camel_read (stream_process->sockfd, buffer, n);
+ return camel_read (stream_process->sockfd, buffer, n, error);
}
static gssize
stream_process_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamProcess *stream_process = CAMEL_STREAM_PROCESS (stream);
- return camel_write (stream_process->sockfd, buffer, n);
+ return camel_write (stream_process->sockfd, buffer, n, error);
}
static gint
-stream_process_close (CamelStream *object)
+stream_process_close (CamelStream *object,
+ GError **error)
{
CamelStreamProcess *stream = CAMEL_STREAM_PROCESS (object);
}
static gint
-stream_process_flush (CamelStream *stream)
+stream_process_flush (CamelStream *stream,
+ GError **error)
{
return 0;
}
g_return_val_if_fail (command != NULL, -1);
if (stream->sockfd != -1 || stream->childpid)
- camel_stream_close (CAMEL_STREAM (stream));
+ camel_stream_close (CAMEL_STREAM (stream), NULL);
if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockfds))
return -1;
static gssize
stream_vfs_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
gssize nread;
- GError *error = NULL;
+ GError *local_error = NULL;
nread = g_input_stream_read (
G_INPUT_STREAM (stream_vfs->stream),
- buffer, n, NULL, &error);
+ buffer, n, NULL, &local_error);
- if (nread == 0 || error != NULL)
+ if (nread == 0 || local_error != NULL)
stream->eos = TRUE;
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
return nread;
}
static gssize
stream_vfs_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
gboolean success;
gsize bytes_written;
- GError *error = NULL;
success = g_output_stream_write_all (
G_OUTPUT_STREAM (stream_vfs->stream),
- buffer, n, &bytes_written, NULL, &error);
-
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ buffer, n, &bytes_written, NULL, error);
return success ? bytes_written : -1;
}
static gint
-stream_vfs_flush (CamelStream *stream)
+stream_vfs_flush (CamelStream *stream,
+ GError **error)
{
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
gboolean success;
- GError *error = NULL;
success = g_output_stream_flush (
- G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
-
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ G_OUTPUT_STREAM (stream_vfs->stream), NULL, error);
return success ? 0 : -1;
}
static gint
-stream_vfs_close (CamelStream *stream)
+stream_vfs_close (CamelStream *stream,
+ GError **error)
{
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
gboolean success;
- GError *error = NULL;
if (G_IS_OUTPUT_STREAM (stream_vfs->stream))
success = g_output_stream_close (
- G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
+ G_OUTPUT_STREAM (stream_vfs->stream), NULL, error);
else
success = g_input_stream_close (
- G_INPUT_STREAM (stream_vfs->stream), NULL, &error);
-
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ G_INPUT_STREAM (stream_vfs->stream), NULL, error);
if (success) {
g_object_unref (stream_vfs->stream);
#include <config.h>
#endif
+#include <errno.h>
#include <string.h>
+#include "camel-debug.h"
#include "camel-stream.h"
G_DEFINE_ABSTRACT_TYPE (CamelStream, camel_stream, CAMEL_TYPE_OBJECT)
static gssize
stream_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
return 0;
}
static gssize
stream_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
return n;
}
static gint
-stream_close (CamelStream *stream)
+stream_close (CamelStream *stream,
+ GError **error)
{
return 0;
}
static gint
-stream_flush (CamelStream *stream)
+stream_flush (CamelStream *stream,
+ GError **error)
{
return 0;
}
}
static gint
-stream_reset (CamelStream *stream)
+stream_reset (CamelStream *stream,
+ GError **error)
{
return 0;
}
* @stream: a #CamelStream object.
* @buffer: output buffer
* @n: max number of bytes to read.
+ * @error: return location for a #GError, or %NULL
*
* Attempts to read up to @len bytes from @stream into @buf.
*
gssize
camel_stream_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamClass *class;
+ gssize n_bytes;
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
g_return_val_if_fail (n == 0 || buffer, -1);
class = CAMEL_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->read != NULL, -1);
- return class->read (stream, buffer, n);
+ n_bytes = class->read (stream, buffer, n, error);
+ CAMEL_CHECK_GERROR (stream, read, n_bytes >= 0, error);
+
+ return n_bytes;
}
/**
* @stream: a #CamelStream object
* @buffer: buffer to write.
* @n: number of bytes to write
+ * @error: return location for a #GError, or %NULL
*
* Attempts to write up to @n bytes of @buffer into @stream.
*
gssize
camel_stream_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelStreamClass *class;
+ gssize n_bytes;
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
g_return_val_if_fail (n == 0 || buffer, -1);
class = CAMEL_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->write != NULL, -1);
- return class->write (stream, buffer, n);
+ n_bytes = class->write (stream, buffer, n, error);
+ CAMEL_CHECK_GERROR (stream, write, n_bytes >= 0, error);
+
+ return n_bytes;
}
/**
* camel_stream_flush:
* @stream: a #CamelStream object
+ * @error: return location for a #GError, or %NULL
*
* Flushes any buffered data to the stream's backing store. Only
* meaningful for writable streams.
*
- * Returns: %0 on success or %-1 on fail along with setting errno.
+ * Returns: %0 on success or %-1 on fail along with setting @error
**/
gint
-camel_stream_flush (CamelStream *stream)
+camel_stream_flush (CamelStream *stream,
+ GError **error)
{
CamelStreamClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
class = CAMEL_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->flush != NULL, -1);
- return class->flush (stream);
+ retval = class->flush (stream, error);
+ CAMEL_CHECK_GERROR (stream, flush, retval == 0, error);
+
+ return retval;
}
/**
* camel_stream_close:
* @stream: a #CamelStream object
+ * @error: return location for a #GError, or %NULL
*
* Closes the stream.
*
* Returns: %0 on success or %-1 on error.
**/
gint
-camel_stream_close (CamelStream *stream)
+camel_stream_close (CamelStream *stream,
+ GError **error)
{
CamelStreamClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
class = CAMEL_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->close != NULL, -1);
- return class->close (stream);
+ retval = class->close (stream, error);
+ CAMEL_CHECK_GERROR (stream, close, retval == 0, error);
+
+ return retval;
}
/**
/**
* camel_stream_reset:
* @stream: a #CamelStream object
+ * @error: return location for a #GError, or %NULL
*
* Resets the stream. That is, put it in a state where it can be read
* from the beginning again. Not all streams in Camel are seekable,
* but they must all be resettable.
*
- * Returns: %0 on success or %-1 on error along with setting errno.
+ * Returns: %0 on success or %-1 on error along with setting @error.
**/
gint
-camel_stream_reset (CamelStream *stream)
+camel_stream_reset (CamelStream *stream,
+ GError **error)
{
CamelStreamClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
class = CAMEL_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->reset != NULL, -1);
- return class->reset (stream);
+ retval = class->reset (stream, error);
+ CAMEL_CHECK_GERROR (stream, reset, retval == 0, error);
+
+ return retval;
}
/***************** Utility functions ********************/
* camel_stream_write_string:
* @stream: a #CamelStream object
* @string: a string
+ * @error: return location for a #GError, or %NULL
*
* Writes the string to the stream.
*
**/
gssize
camel_stream_write_string (CamelStream *stream,
- const gchar *string)
+ const gchar *string,
+ GError **error)
{
- return camel_stream_write (stream, string, strlen (string));
+ g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
+ g_return_val_if_fail (string != NULL, -1);
+
+ return camel_stream_write (stream, string, strlen (string), error);
}
/**
if (string == NULL)
return -1;
- ret = camel_stream_write (stream, string, strlen (string));
+ ret = camel_stream_write (stream, string, strlen (string), NULL);
g_free (string);
return ret;
* camel_stream_write_to_stream:
* @stream: source #CamelStream object
* @output_stream: destination #CamelStream object
+ * @error: return location for a #GError, or %NULL
*
* Write all of a stream (until eos) into another stream, in a
* blocking fashion.
**/
gssize
camel_stream_write_to_stream (CamelStream *stream,
- CamelStream *output_stream)
+ CamelStream *output_stream,
+ GError **error)
{
gchar tmp_buf[4096];
gssize total = 0;
while (!camel_stream_eos (stream)) {
nb_read = camel_stream_read (
- stream, tmp_buf, sizeof (tmp_buf));
+ stream, tmp_buf, sizeof (tmp_buf), error);
if (nb_read < 0)
return -1;
else if (nb_read > 0) {
while (nb_written < nb_read) {
gssize len = camel_stream_write (
output_stream, tmp_buf + nb_written,
- nb_read - nb_written);
+ nb_read - nb_written, error);
if (len < 0)
return -1;
nb_written += len;
gssize (*read) (CamelStream *stream,
gchar *buffer,
- gsize n);
+ gsize n,
+ GError **error);
gssize (*write) (CamelStream *stream,
const gchar *buffer,
- gsize n);
- gint (*close) (CamelStream *stream);
- gint (*flush) (CamelStream *stream);
+ gsize n,
+ GError **error);
+ gint (*close) (CamelStream *stream,
+ GError **error);
+ gint (*flush) (CamelStream *stream,
+ GError **error);
gboolean (*eos) (CamelStream *stream);
- gint (*reset) (CamelStream *stream);
+ gint (*reset) (CamelStream *stream,
+ GError **error);
};
GType camel_stream_get_type (void);
gssize camel_stream_read (CamelStream *stream,
gchar *buffer,
- gsize n);
+ gsize n,
+ GError **error);
gssize camel_stream_write (CamelStream *stream,
const gchar *buffer,
- gsize n);
-gint camel_stream_flush (CamelStream *stream);
-gint camel_stream_close (CamelStream *stream);
+ gsize n,
+ GError **error);
+gint camel_stream_flush (CamelStream *stream,
+ GError **error);
+gint camel_stream_close (CamelStream *stream,
+ GError **error);
gboolean camel_stream_eos (CamelStream *stream);
-gint camel_stream_reset (CamelStream *stream);
+gint camel_stream_reset (CamelStream *stream,
+ GError **error);
/* utility macros and funcs */
gssize camel_stream_write_string (CamelStream *stream,
- const gchar *string);
+ const gchar *string,
+ GError **error);
gssize camel_stream_printf (CamelStream *stream,
const gchar *fmt,
...) G_GNUC_PRINTF (2, 3);
/* Write a whole stream to another stream, until eof or error on
* either stream. */
gssize camel_stream_write_to_stream (CamelStream *stream,
- CamelStream *output_stream);
+ CamelStream *output_stream,
+ GError **error);
G_END_DECLS
static gssize
tcp_stream_raw_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
- return camel_read_socket (raw->sockfd, buffer, n);
+ return camel_read_socket (raw->sockfd, buffer, n, error);
}
static gssize
tcp_stream_raw_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
- return camel_write_socket (raw->sockfd, buffer, n);
+ return camel_write_socket (raw->sockfd, buffer, n, error);
}
static gint
-tcp_stream_raw_flush (CamelStream *stream)
+tcp_stream_raw_flush (CamelStream *stream,
+ GError **error)
{
return 0;
}
static gint
-tcp_stream_raw_close (CamelStream *stream)
+tcp_stream_raw_close (CamelStream *stream,
+ GError **error)
{
- if (SOCKET_CLOSE (((CamelTcpStreamRaw *)stream)->sockfd) == -1)
+ if (SOCKET_CLOSE (((CamelTcpStreamRaw *)stream)->sockfd) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
+ }
((CamelTcpStreamRaw *)stream)->sockfd = -1;
return 0;
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
- ai = camel_getaddrinfo (proxy_host, serv, &hints, NULL); /* NULL-CamelException */
+ ai = camel_getaddrinfo (proxy_host, serv, &hints, NULL); /* NULL-GError */
if (!ai) {
#ifdef G_OS_WIN32
errno = WSAEHOSTUNREACH;
#else
- errno = EHOSTUNREACH; /* FIXME: this is not an accurate error; we should translate the CamelException to an errno */
+ errno = EHOSTUNREACH; /* FIXME: this is not an accurate error; we should translate the GError to an errno */
#endif
return -1;
}
memcpy (request + 4, &sin->sin_addr.s_addr, 4); /* address in network byte order */
request[8] = 0x00; /* terminator */
- if (camel_write_socket (fd, request, sizeof (request)) != sizeof (request))
+ if (camel_write_socket (fd, request, sizeof (request), NULL) != sizeof (request))
goto error;
- if (camel_read_socket (fd, reply, sizeof (reply)) != sizeof (reply))
+ if (camel_read_socket (fd, reply, sizeof (reply), NULL) != sizeof (reply))
goto error;
if (!(reply[0] == 0 /* first byte of reply is 0 */
static gint
tcp_stream_raw_connect (CamelTcpStream *stream,
- struct addrinfo *host)
+ struct addrinfo *host,
+ GError **error)
{
CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
const gchar *proxy_host;
}
static gssize
-read_from_prfd (PRFileDesc *fd, gchar *buffer, gsize n)
+read_from_prfd (PRFileDesc *fd,
+ gchar *buffer,
+ gsize n)
{
PRFileDesc *cancel_fd;
gssize nread;
static gssize
tcp_stream_ssl_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelTcpStreamSSL *ssl = CAMEL_TCP_STREAM_SSL (stream);
gssize result;
result = read_from_prfd (ssl->priv->sockfd, buffer, n);
+ if (result == -1)
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+
d (g_print ("SSL stream %p: read %" G_GSSIZE_FORMAT " bytes, errno = %d\n", ssl, result, result == -1 ? errno : 0));
return result;
static gssize
tcp_stream_ssl_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelTcpStreamSSL *ssl = CAMEL_TCP_STREAM_SSL (stream);
gssize result;
result = write_to_prfd (ssl->priv->sockfd, buffer, n);
+ if (result == -1)
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+
d (g_print ("SSL stream %p: wrote %" G_GSSIZE_FORMAT " bytes, errno = %d\n", ssl, result, result == -1 ? errno : 0));
return result;
}
static gint
-tcp_stream_ssl_flush (CamelStream *stream)
+tcp_stream_ssl_flush (CamelStream *stream,
+ GError **error)
{
/*return PR_Sync (((CamelTcpStreamSSL *)stream)->priv->sockfd);*/
return 0;
}
static gint
-tcp_stream_ssl_close (CamelStream *stream)
+tcp_stream_ssl_close (CamelStream *stream,
+ GError **error)
{
d (g_print ("SSL stream %p: closing\n", stream));
if (((CamelTcpStreamSSL *)stream)->priv->sockfd == NULL) {
errno = EINVAL;
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
}
PR_Shutdown (((CamelTcpStreamSSL *)stream)->priv->sockfd, PR_SHUTDOWN_BOTH);
+
+ /* FIXME Need to set the GError if this fails. */
if (PR_Close (((CamelTcpStreamSSL *)stream)->priv->sockfd) == PR_FAILURE)
return -1;
g_free (dir);
stream = camel_stream_fs_new_with_name (
- path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ path, O_WRONLY | O_CREAT | O_TRUNC, 0600, NULL);
if (stream != NULL) {
if (camel_stream_write (
stream, (const gchar *) ccert->rawcert->data,
- ccert->rawcert->len) == -1) {
+ ccert->rawcert->len, NULL) == -1) {
g_warning ("Could not save cert: %s: %s", path, g_strerror (errno));
g_unlink (path);
}
- camel_stream_close (stream);
+ camel_stream_close (stream, NULL);
g_object_unref (stream);
} else {
g_warning ("Could not save cert: %s: %s", path, g_strerror (errno));
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
- ai = camel_getaddrinfo (proxy_host, serv, &hints, NULL); /* NULL-CamelException */
+ ai = camel_getaddrinfo (proxy_host, serv, &hints, NULL); /* NULL-GError */
if (!ai) {
#ifdef G_OS_WIN32
errno = WSAEHOSTUNREACH;
#else
- errno = EHOSTUNREACH; /* FIXME: this is not an accurate error; we should translate the CamelException to an errno */
+ errno = EHOSTUNREACH; /* FIXME: this is not an accurate error; we should translate the GError to an errno */
#endif
d (g_print (" camel_getaddrinfo() for the proxy failed\n}\n"));
return NULL;
static gint
tcp_stream_ssl_connect (CamelTcpStream *stream,
- struct addrinfo *host)
+ struct addrinfo *host,
+ GError **error)
{
CamelTcpStreamSSL *ssl = CAMEL_TCP_STREAM_SSL (stream);
const gchar *proxy_host;
#include <string.h>
+#include "camel-debug.h"
#include "camel-tcp-stream.h"
#ifdef G_OS_WIN32
* @stream: a #CamelTcpStream object
* @host: a linked list of addrinfo structures to try to connect, in
* the order of most likely to least likely to work.
+ * @error: return location for a #GError, or %NULL
*
* Create a socket and connect based upon the data provided.
*
**/
gint
camel_tcp_stream_connect (CamelTcpStream *stream,
- struct addrinfo *host)
+ struct addrinfo *host,
+ GError **error)
{
CamelTcpStreamClass *class;
+ gint retval;
g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
class = CAMEL_TCP_STREAM_GET_CLASS (stream);
g_return_val_if_fail (class->connect != NULL, -1);
- return class->connect (stream, host);
+ retval = class->connect (stream, host, error);
+ CAMEL_CHECK_GERROR (stream, connect, retval == 0, error);
+
+ return retval;
}
/**
CamelStreamClass parent_class;
gint (*connect) (CamelTcpStream *stream,
- struct addrinfo *host);
+ struct addrinfo *host,
+ GError **error);
gint (*getsockopt) (CamelTcpStream *stream,
CamelSockOptData *data);
gint (*setsockopt) (CamelTcpStream *stream,
GType camel_tcp_stream_get_type (void);
gint camel_tcp_stream_connect (CamelTcpStream *stream,
- struct addrinfo *host);
+ struct addrinfo *host,
+ GError **error);
gint camel_tcp_stream_getsockopt (CamelTcpStream *stream,
CamelSockOptData *data);
gint camel_tcp_stream_setsockopt (CamelTcpStream *stream,
* support SOCKS4a/SOCKS5 proxies should be well-contained within Camel,
* with no extra changes required in Evolution.
*/
-void camel_tcp_stream_set_socks_proxy (CamelTcpStream *stream, const gchar *socks_host, gint socks_port);
-void camel_tcp_stream_peek_socks_proxy (CamelTcpStream *stream, const gchar **socks_host_ret, gint *socks_port_ret);
+void camel_tcp_stream_set_socks_proxy(CamelTcpStream *stream,
+ const gchar *socks_host,
+ gint socks_port);
+void camel_tcp_stream_peek_socks_proxy
+ (CamelTcpStream *stream,
+ const gchar **socks_host_ret,
+ gint *socks_port_ret);
struct sockaddr *
camel_tcp_stream_get_local_address
#ifndef CAMEL_TEXT_INDEX_H
#define CAMEL_TEXT_INDEX_H
-#include <camel/camel-exception.h>
#include <camel/camel-object.h>
#include "camel-index.h"
#endif
#include "camel-address.h"
+#include "camel-debug.h"
#include "camel-mime-message.h"
#include "camel-transport.h"
* @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
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex)
+ GError **error)
{
CamelTransportClass *class;
- gboolean sent;
+ gboolean success;
g_return_val_if_fail (CAMEL_IS_TRANSPORT (transport), FALSE);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), FALSE);
g_return_val_if_fail (class->send_to != NULL, FALSE);
camel_transport_lock (transport, CAMEL_TRANSPORT_SEND_LOCK);
- sent = class->send_to (transport, message, from, recipients, ex);
+
+ success = class->send_to (transport, message, from, recipients, error);
+ CAMEL_CHECK_GERROR (transport, send_to, success, error);
+
camel_transport_unlock (transport, CAMEL_TRANSPORT_SEND_LOCK);
- return sent;
+ return success;
}
/**
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex);
+ GError **error);
};
GType camel_transport_get_type (void);
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex);
+ GError **error);
void camel_transport_lock (CamelTransport *transport,
CamelTransportLock lock);
void camel_transport_unlock (CamelTransport *transport,
buf = g_malloc (st.st_size + 1);
- if (st.st_size > 0 && camel_read (fd, buf, st.st_size) == -1) {
+ if (st.st_size > 0 && camel_read (fd, buf, st.st_size, NULL) == -1) {
close (fd);
g_free (buf);
return NULL;
return;
if (state && state->level == cache->level && state->save) {
- if (camel_write (cache->fd, key, strlen (key)) == -1 ||
- camel_write (cache->fd, "\n", 1) == -1) {
+ if (camel_write (cache->fd, key, strlen (key), NULL) == -1 ||
+ camel_write (cache->fd, "\n", 1, NULL) == -1) {
cache->fd = -1;
} else {
cache->size += strlen (key) + 1;
#include <glib/gi18n-lib.h>
-#include "camel-exception.h"
#include "camel-mime-utils.h"
#include "camel-object.h"
#include "camel-service.h"
/**
* camel_url_new:
* @url_string: a URL string
- * @ex: a #CamelException
+ * @error: return location for a #GError, or %NULL
*
* Parses an absolute URL.
*
**/
CamelURL *
camel_url_new (const gchar *url_string,
- CamelException *ex)
+ GError **error)
{
CamelURL *url;
if (!url->protocol) {
camel_url_free (url);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Could not parse URL '%s'"), url_string);
return NULL;
}
#include <glib.h>
-#include <camel/camel-exception.h>
-
G_BEGIN_DECLS
/* if this changes, remember to change camel_url_copy */
#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);
#include "camel-db.h"
#include "camel-debug.h"
-#include "camel-exception.h"
#include "camel-folder-search.h"
#include "camel-mime-message.h"
#include "camel-session.h"
vuid = camel_pstring_strdup (camel_message_info_uid (vinfo));
camel_message_info_free ((CamelMessageInfo *) vinfo);
if (use_db) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-
full_name = camel_folder_get_full_name (folder);
camel_db_add_to_vfolder_transaction (
- parent_store->cdb_w, full_name, vuid, &ex);
- camel_exception_clear (&ex);
+ parent_store->cdb_w, full_name, 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) {
}
vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info ((CamelFolder *)folder_unmatched, vuid);
if (vinfo) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-
full_name = camel_folder_get_full_name (
CAMEL_FOLDER (folder_unmatched));
camel_folder_change_info_remove_uid (
folder_unmatched->changes, vuid);
camel_db_delete_uid_from_vfolder_transaction (
- parent_store->cdb_w, full_name, vuid, &ex);
+ parent_store->cdb_w, full_name, vuid, NULL);
camel_folder_summary_remove_uid_fast (
CAMEL_FOLDER (folder_unmatched)->summary, vuid);
camel_folder_free_message_info (
CAMEL_FOLDER (folder_unmatched),
(CamelMessageInfo *) vinfo);
- camel_exception_clear (&ex);
}
}
camel_folder_change_info_remove_uid (vf->changes, vuid);
if (use_db) {
- /* FIXME[disk-summary] Handle exception */
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-
full_name = camel_folder_get_full_name (folder);
camel_db_delete_uid_from_vfolder_transaction (
- parent_store->cdb_w, full_name, vuid, &ex);
- camel_exception_clear (&ex);
+ parent_store->cdb_w, full_name, vuid, NULL);
}
camel_folder_summary_remove_uid_fast (folder->summary, vuid);
vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info ((CamelFolder *)folder_unmatched, vuid);
if (vinfo) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-
full_name = camel_folder_get_full_name (
CAMEL_FOLDER (folder_unmatched));
camel_folder_change_info_remove_uid (
folder_unmatched->changes, vuid);
camel_db_delete_uid_from_vfolder_transaction (
- parent_store->cdb_w, full_name, vuid, &ex);
+ parent_store->cdb_w, full_name, vuid, NULL);
camel_folder_summary_remove_uid_fast (
CAMEL_FOLDER (folder_unmatched)->summary, vuid);
camel_folder_free_message_info (
CAMEL_FOLDER (folder_unmatched),
(CamelMessageInfo *) vinfo);
- camel_exception_clear (&ex);
}
}
}
/* 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:
/* 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) {
}
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, CAMEL_VEE_FOLDER_SUMMARY_LOCK);
camel_db_begin_transaction (parent_store->cdb_w, NULL);
}
- dd (printf (" changed %u added %u removed %u\n", changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len));
-
/* Always remove removed uid's, in any case */
for (i=0;i<changes->uid_removed->len;i++) {
dd (printf (" removing uid '%s'\n", (gchar *)changes->uid_removed->pdata[i]));
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)
} else {
CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_uid (((CamelFolder *)u->folder_unmatched)->summary, uid);
if (mi) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CamelStore *parent_store;
const gchar *full_name;
CAMEL_FOLDER (u->folder_unmatched));
camel_db_delete_uid_from_vfolder_transaction (
- parent_store->cdb_w, full_name, uid, &ex);
+ parent_store->cdb_w, 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);
}
}
}
/* FIXME[disk-summary] Make all these as transactions, just
* testing atm */
if (u->rebuilt && !u->correlating) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CamelStore *parent_store;
const gchar *full_name;
CAMEL_FOLDER (u->vee_folder));
camel_db_add_to_vfolder_transaction (
parent_store->cdb_w, full_name,
- camel_message_info_uid (mi), &ex);
- camel_exception_clear (&ex);
+ 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)) {
static gint
count_result (CamelFolderSummary *summary,
const gchar *query,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder = summary->folder;
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
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;
}
static CamelFIRecord *
summary_header_to_db (CamelFolderSummary *s,
- CamelException *ex)
+ GError **error)
{
CamelFIRecord * record = g_new0 (CamelFIRecord, 1);
CamelStore *parent_store;
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;
if (!vf->deleted) {
CamelFolder *folder;
CamelStore *parent_store;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
folder = CAMEL_FOLDER (vf);
parent_store = camel_folder_get_parent_store (folder);
record = summary_header_to_db (folder->summary, NULL);
- camel_db_write_folder_info_record (parent_store->cdb_w, record, &ex);
+ camel_db_write_folder_info_record (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 */
static gboolean
vee_folder_refresh_info (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
CamelVeeFolderPrivate *p = CAMEL_VEE_FOLDER_GET_PRIVATE (vf);
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;
}
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;
while (node) {
CamelFolder *f = node->data;
- if (!camel_folder_sync (f, expunge, ex)) {
- if (strncmp (camel_exception_get_description (ex), "no such table", 13)) {
+ if (!camel_folder_sync (f, expunge, &local_error)) {
+ if (strncmp (local_error->message, "no such table", 13) != 0) {
const gchar *desc;
desc = camel_folder_get_description (f);
- camel_exception_setv (ex, ex->id, _("Error storing '%s': %s"), desc, ex->desc);
- g_warning ("%s", camel_exception_get_description (ex));
+ g_warning ("%s", local_error->message);
+ g_propagate_prefixed_error (
+ error, local_error,
+ _("Error storing '%s': "), desc);
} else
- camel_exception_clear (ex);
+ g_clear_error (&local_error);
}
/* auto update vfolders shouldn't need a rebuild */
GSList *del = NULL;
gint i, count;
- camel_folder_summary_prepare_fetch_all (folder->summary, ex);
+ camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
count = camel_folder_summary_count (folder->summary);
for (i=0; i < count; i++) {
CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (folder->summary, i);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- camel_db_delete_vuids (parent_store->cdb_w, full_name, "", del, ex);
+ camel_db_delete_vuids (parent_store->cdb_w, full_name, "", del, NULL);
g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
g_slist_free (del);
}
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;
- return 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,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
_("No such message %s in %s"), uid,
camel_folder_get_name (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_GENERIC,
_("Cannot copy or move messages into a Virtual Folder"));
return FALSE;
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_GENERIC,
_("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 ();
/* 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;
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 ();
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;
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);
static guint32
vee_folder_count_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
GList *node;
gchar *expr;
/* 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);
{
CamelVeeFolderPrivate *p = CAMEL_VEE_FOLDER_GET_PRIVATE (vee_folder);
GList *node;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
camel_vee_folder_lock (vee_folder, CAMEL_VEE_FOLDER_SUBFOLDER_LOCK);
summary = folder->summary;
camel_folder_summary_clear (summary);
- camel_db_recreate_vfolder (parent_store->cdb_w, full_name, &ex);
- camel_exception_clear (&ex);
+ camel_db_recreate_vfolder (parent_store->cdb_w, full_name, NULL);
summary->junk_count = 0;
summary->deleted_count = 0;
summary->unread_count = 0;
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, CAMEL_VEE_FOLDER_CHANGED_LOCK);
g_list_free (p->folders_changed);
p->folders_changed = NULL;
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
static gint
vee_folder_rebuild_folder (CamelVeeFolder *vee_folder,
CamelFolder *source,
- CamelException *ex)
+ GError **error)
{
GPtrArray *match, *all;
GHashTable *allhash, *matchhash, *fullhash;
/* 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;
current source) */
start = -1;
last = -1;
- camel_folder_summary_prepare_fetch_all (folder->summary, ex);
+ camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
count = camel_folder_summary_count (folder->summary);
for (i=0;i<count;i++) {
CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (folder->summary, i);
/* Del the unwanted things from the summary, we don't hold any locks now. */
if (del_list) {
if (!correlating) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CamelStore *parent_store;
const gchar *full_name;
parent_store = camel_folder_get_parent_store (folder);
camel_db_delete_vuids (
parent_store->cdb_w,
- full_name, shash, del_list, &ex);
- camel_exception_clear (&ex);
+ full_name, shash, del_list, NULL);
}
((CamelVeeSummary *)folder->summary)->force_counts = TRUE;
g_slist_foreach (del_list, (GFunc) camel_pstring_free, NULL);
* 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)
+ 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
**/
void
camel_vee_folder_sync_headers (CamelFolder *vf,
- CamelException *ex)
+ GError **error)
{
CamelFIRecord * record;
CamelStore *parent_store;
/* Save the counts to DB */
start = time (NULL);
- record = summary_header_to_db (vf->summary, ex);
+ record = summary_header_to_db (vf->summary, error);
parent_store = camel_folder_get_parent_store (vf);
- camel_db_write_folder_info_record (parent_store->cdb_w, record, ex);
+ camel_db_write_folder_info_record (parent_store->cdb_w, record, error);
end = time (NULL);
g_free (record);
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 *);
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);
gint camel_vee_folder_get_unread_vfolder (CamelVeeFolder *folder);
void camel_vee_folder_set_unread_vfolder (CamelVeeFolder *folder, gint unread_vfolder);
#include <glib/gstdio.h>
#include "camel-db.h"
-#include "camel-exception.h"
#include "camel-session.h"
#include "camel-vee-folder.h"
#include "camel-vee-store.h"
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
CamelStore *store;
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_vee_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ if (!service_class->construct (service, session, provider, url, error))
return FALSE;
/* Set up unmatched folder */
vee_store_get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelVeeFolder *vf;
CamelFolder *folder;
vee_store_rename_folder (CamelStore *store,
const gchar *old,
const gchar *new,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder, *oldfolder;
gchar *p, *name;
d (printf ("vee rename folder '%s' '%s'\n", old, new));
if (strcmp (old, CAMEL_UNMATCHED_NAME) == 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ 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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot rename folder: %s: No such folder"), old);
return FALSE;
}
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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot delete folder: %s: Invalid operation"),
folder_name);
return FALSE;
g_object_unref (folder);
} else {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot delete folder: %s: No such folder"),
folder_name);
return FALSE;
vee_store_get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelFolderInfo *info, *res = NULL, *tail;
GPtrArray *folders;
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;
}
#include <glib/gi18n-lib.h>
#include "camel-db.h"
-#include "camel-exception.h"
#include "camel-mime-message.h"
#include "camel-store.h"
#include "camel-vee-store.h"
static void
transfer_messages (CamelFolder *folder,
struct _transfer_data *md,
- CamelException *ex)
+ 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]);
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_GENERIC, "%s",
_(vdata[((CamelVTrashFolder *)folder)->type].error_copy));
return FALSE;
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
CamelVeeMessageInfo *mi;
gint i;
if (CAMEL_IS_VTRASH_FOLDER (dest)) {
/* Copy to trash is meaningless. */
if (!delete_originals) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM, "%s",
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
_(vdata[((CamelVTrashFolder *)dest)->type].error_copy));
return FALSE;
}
}
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);
}
#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>
extern gint camel_application_is_exiting;
/*prototypes*/
-static gboolean groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
+static gboolean groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, GPtrArray **transferred_uids, gboolean delete_originals, GError **error);
void convert_to_calendar (EGwItem *item, gchar **str, gint *len);
static void convert_to_task (EGwItem *item, gchar **str, gint *len);
static void convert_to_note (EGwItem *item, gchar **str, gint *len);
-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 gboolean groupwise_sync (CamelFolder *folder, gboolean expunge, CamelMessageInfo *update_single, CamelException *ex);
+static void groupwise_refresh_folder(CamelFolder *folder, GError **error);
+static gboolean groupwise_sync (CamelFolder *folder, gboolean expunge, CamelMessageInfo *update_single, GError **error);
#define d(x)
G_DEFINE_TYPE (CamelGroupwiseFolder, camel_groupwise_folder, CAMEL_TYPE_OFFLINE_FOLDER)
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;
mi = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->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: %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 ();
- camel_stream_reset (stream);
- camel_stream_write_to_stream (cache_stream, stream);
- camel_stream_reset (stream);
- if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream) == -1) {
+ camel_stream_reset (stream, NULL);
+ camel_stream_write_to_stream (cache_stream, stream, NULL);
+ camel_stream_reset (stream, NULL);
+ if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream, error) == -1) {
if (errno == EINTR) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_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_prefix_error (
+ error, _("Cannot get message %s: "), uid);
g_object_unref (msg);
msg = NULL;
}
}
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ 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,
+ if (!camel_groupwise_store_connected (gw_store, NULL)) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("This message is not available in offline mode."));
camel_message_info_free (&mi->info);
return NULL;
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,
+ 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, NULL);
if (!msg) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_INVALID,
+ 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);
/* add to cache */
CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", uid, NULL))) {
- if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream) == -1
- || camel_stream_flush (cache_stream) == -1)
+ if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream, NULL) == -1
+ || camel_stream_flush (cache_stream, NULL) == -1)
camel_data_cache_remove (gw_folder->cache, "cache", uid, NULL);
g_object_unref (cache_stream);
}
}
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;
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);
}
static void
-move_to_mailbox (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
+move_to_mailbox (CamelFolder *folder, CamelMessageInfo *info, GError **error)
{
CamelFolder *dest;
CamelStore *parent_store;
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gpointer) uid);
- dest = camel_store_get_folder (parent_store, "Mailbox", 0, ex);
+ dest = camel_store_get_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");
}
static void
-move_to_junk (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
+move_to_junk (CamelFolder *folder, CamelMessageInfo *info, GError **error)
{
CamelFolder *dest;
CamelFolderInfo *fi;
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gpointer) uid);
- dest = camel_store_get_folder (parent_store, JUNK_FOLDER, 0, ex);
+ dest = camel_store_get_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 (parent_store);
- dest = camel_store_get_folder (parent_store, JUNK_FOLDER, 0, ex);
+ dest = camel_store_get_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 (parent_store, info, ADD_JUNK_ENTRY);
}
/********************* back to folder functions*************************/
static gboolean
-groupwise_sync_summary (CamelFolder *folder, CamelException *ex)
+groupwise_sync_summary (CamelFolder *folder, GError **error)
{
CamelStoreInfo *si;
CamelStore *parent_store;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, error);
si = camel_store_summary_path ((CamelStoreSummary *) ((CamelGroupwiseStore *) parent_store)->summary, full_name);
sync_immediately = g_getenv ("GW_SYNC_IMMEDIATE");
- if (sync_immediately) {
- CamelException ex;
-
- camel_exception_init (&ex);
- groupwise_sync (folder, FALSE, info, &ex);
- camel_exception_clear (&ex);
- }
+ if (sync_immediately)
+ groupwise_sync (folder, FALSE, info, NULL);
camel_message_info_free (info);
return res;
}
static gboolean
-groupwise_sync_all (CamelFolder *folder, gboolean expunge, CamelException *ex)
+groupwise_sync_all (CamelFolder *folder, gboolean expunge, GError **error)
{
- return groupwise_sync (folder, expunge, NULL, ex);
+ return groupwise_sync (folder, expunge, NULL, error);
}
/* This may need to be reorganized. */
static gboolean
-groupwise_sync (CamelFolder *folder, gboolean expunge, CamelMessageInfo *update_single, CamelException *ex)
+groupwise_sync (CamelFolder *folder, gboolean expunge, CamelMessageInfo *update_single, GError **error)
{
CamelGroupwiseStore *gw_store;
CamelGroupwiseFolder *gw_folder;
deleted_items = deleted_head = NULL;
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
- return groupwise_sync_summary (folder, ex);
+ return groupwise_sync_summary (folder, error);
camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_groupwise_store_connected (gw_store, ex)) {
+ if (!camel_groupwise_store_connected (gw_store, NULL)) {
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_clear (ex);
return TRUE;
}
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return TRUE;
changes = camel_folder_change_info_new ();
- camel_folder_summary_prepare_fetch_all (folder->summary, ex);
+ camel_folder_summary_prepare_fetch_all (folder->summary, error);
count = camel_folder_summary_count (folder->summary);
CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
for (i=0; i < count; i++) {
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;
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;
}
camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- success = groupwise_sync_summary (folder, ex);
+ success = groupwise_sync_summary (folder, error);
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
camel_folder_changed (folder, changes);
}
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;
g_free(summary_file);
if (!folder->summary) {
g_object_unref (CAMEL_OBJECT (folder));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Could not load summary for %s"), folder_name);
return NULL;
}
g_free(state_file);
camel_object_state_read (CAMEL_OBJECT (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;
{
struct _folder_update_msg *m = (struct _folder_update_msg *)msg;
EGwConnectionStatus status;
- CamelException *ex = NULL;
CamelGroupwiseStore *gw_store;
CamelStore *parent_store;
GList *item_list, *items_full_list = NULL, *last_element=NULL;
}*/
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, NULL);
camel_operation_end (NULL);
return;
};
static gboolean
-groupwise_refresh_info(CamelFolder *folder, CamelException *ex)
+groupwise_refresh_info(CamelFolder *folder, GError **error)
{
CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *) folder->summary;
CamelStoreInfo *si;
* 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 *)parent_store)->summary, full_name);
if (si) {
guint32 unread, total;
* 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 void
-update_summary_string (CamelFolder *folder, const gchar *time_string, CamelException *ex)
+update_summary_string (CamelFolder *folder, const gchar *time_string)
{
CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *) folder->summary;
((CamelGroupwiseSummary *) folder->summary)->time_string = g_strdup (time_string);
camel_folder_summary_touch (folder->summary);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
}
static void
-groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
+groupwise_refresh_folder(CamelFolder *folder, GError **error)
{
CamelGroupwiseStore *gw_store;
CamelGroupwiseFolder *gw_folder;
/* Sync-up the (un)read changes before getting updates,
so that the getFolderList will reflect the most recent changes too */
- groupwise_sync_all (folder, FALSE, ex);
+ groupwise_sync_all (folder, FALSE, error);
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
g_warning ("In offline mode. Cannot refresh!!!\n");
camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_groupwise_store_connected (gw_store, ex))
+ if (!camel_groupwise_store_connected (gw_store, error))
goto end1;
if (!strcmp (full_name, "Trash")) {
-#if 0
- status = e_gw_connection_get_items (cnc, container_id, "peek recipient distribution created delivered attachments subject status size", NULL, &list);
- if (status != E_GW_CONNECTION_STATUS_OK) {
- if (status ==E_GW_CONNECTION_STATUS_OTHER) {
- g_warning ("Trash full....Empty Trash!!!!\n");
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Trash Folder Full. Please Empty."));
- goto end1;
- /*groupwise_expunge (folder, ex);*/
- } else
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
- goto end1;
- }
- if (list || g_list_length(list)) {
- camel_folder_summary_clear (folder->summary);
- gw_update_summary (folder, list, ex);
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
- list = NULL;
- }
- goto end1;
-#endif
is_proxy = TRUE;
}
"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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
_("Authentication failed"));
goto end2;
}
"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;
}
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);
}
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
/* 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;
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 (gw_store->priv));
CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", id, NULL))) {
- if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) mail_msg, cache_stream) == -1 || camel_stream_flush (cache_stream) == -1)
+ if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) mail_msg, cache_stream, NULL) == -1 || camel_stream_flush (cache_stream, NULL) == -1)
camel_data_cache_remove (gw_folder->cache, "cache", id, NULL);
g_object_unref (cache_stream);
}
camel_operation_end (NULL);
g_free (container_id);
g_string_free (str, TRUE);
- groupwise_sync_summary (folder, ex);
+ groupwise_sync_summary (folder, error);
camel_folder_changed (folder, changes);
camel_folder_change_info_free (changes);
/* 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;
static CamelMimeMessage *
groupwise_folder_item_to_msg( CamelFolder *folder,
EGwItem *item,
- CamelException *ex )
+ GError **error )
{
CamelMimeMessage *msg = NULL;
CamelGroupwiseStore *gw_store;
(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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
_("Could not get message"));
return NULL;
}
(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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
_("Could not get message"));
return NULL;
}
msg = camel_mime_message_new ();
if (has_mime_822 && body) {
temp_stream = camel_stream_mem_new_with_buffer (body, body_len);
- if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, temp_stream) == -1) {
+ if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, temp_stream, error) == -1) {
g_object_unref (msg);
g_object_unref (temp_stream);
msg = NULL;
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 ();
}
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;
index ++;
}
- groupwise_sync_summary (folder, ex);
+ groupwise_sync_summary (folder, error);
camel_folder_changed (folder, changes);
if (item_list) {
parent_store = camel_folder_get_parent_store (folder);
camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- gw_update_cache (folder, item_list, ex, TRUE);
+ gw_update_cache (folder, item_list, error, TRUE);
camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
g_list_foreach (item_list, (GFunc)g_free, NULL);
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;
is_ok = TRUE;
if (!is_ok) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot append message to folder '%s': %s"),
full_name, e_gw_connection_get_error_message (status));
return FALSE;
offline = CAMEL_OFFLINE_STORE (parent_store);
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_groupwise_journal_append ((CamelGroupwiseJournal *) ((CamelGroupwiseFolder *)folder)->journal, message, info, appended_uid, ex);
+ camel_groupwise_journal_append ((CamelGroupwiseJournal *) ((CamelGroupwiseFolder *)folder)->journal, message, info, appended_uid, error);
return FALSE;
}
cnc = cnc_lookup (gw_store->priv);
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"),
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot create message: %s"),
e_gw_connection_get_error_message (status));
if (appended_uid)
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot append message to folder '%s': %s"),
full_name, e_gw_connection_get_error_message (status));
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;
for (l = item_ids, i = 0; l; l = l->next, i++) {
CamelMessageInfo *info;
+ gboolean success;
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);
+ success = camel_groupwise_journal_transfer (journal, (CamelGroupwiseFolder *)source, message, info, uids->pdata[i], NULL, error);
g_object_unref (message);
- if (camel_exception_is_set (ex))
+ if (!success)
break;
if (delete_originals) {
if (!strcmp(source_full_name, SENT)) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("This message is not available in offline mode."));
} else {
/* 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);
}
static gboolean
-groupwise_expunge (CamelFolder *folder, CamelException *ex)
+groupwise_expunge (CamelFolder *folder, GError **error)
{
CamelGroupwiseStore *gw_store;
CamelGroupwiseFolder *gw_folder;
container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, full_name));
- camel_folder_summary_prepare_fetch_all (folder->summary, ex);
+ camel_folder_summary_prepare_fetch_all (folder->summary, error);
max = camel_folder_summary_count (folder->summary);
for (i = 0; i < max; i++) {
info = camel_folder_summary_index (folder->summary, i);
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
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);
G_DEFINE_TYPE (CamelGroupwiseJournal, camel_groupwise_journal, CAMEL_TYPE_OFFLINE_JOURNAL)
}
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;
- gboolean success;
+ gboolean success = FALSE;
/* 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))) {
+ success = TRUE;
goto done;
+ }
message = camel_mime_message_new ();
- if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
+ if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream, error) == -1) {
g_object_unref (message);
g_object_unref (stream);
goto done;
info = camel_message_info_new (NULL);
}
- success = camel_folder_append_message (folder, message, info, NULL, ex);
+ success = camel_folder_append_message (folder, message, info, NULL, error);
camel_message_info_free (info);
g_object_unref (message);
- if (!success)
- return -1;
-
- done:
+done:
camel_folder_summary_remove_uid (folder->summary, entry->uid);
camel_data_cache_remove (gw_folder->cache, "cache", entry->uid, NULL);
- return 0;
+ return (success == 0);
}
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;
}
name = camel_groupwise_store_folder_lookup ((CamelGroupwiseStore *) parent_store, entry->source_container);
- if (name && (src = camel_store_get_folder (parent_store, name, 0, ex))) {
+ if (name && (src = camel_store_get_folder (parent_store, name, 0, error))) {
uids = g_ptr_array_sized_new (1);
g_ptr_array_add (uids, entry->original_uid);
- if (camel_folder_transfer_messages_to (src, uids, folder, &xuids, FALSE, ex)) {
+ 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 */
g_ptr_array_free (uids, TRUE);
g_object_unref (src);
} else if (!name) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot get folder container %s"),
entry->source_container);
goto exception;
}
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;
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;
gchar *uid;
if (groupwise_folder->cache == NULL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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;
}
- 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));
+ if (camel_data_wrapper_write_to_stream (
+ (CamelDataWrapper *) message, cache, error) == -1
+ || camel_stream_flush (cache, error) == -1) {
+ g_prefix_error (
+ error, _("Cannot append message in offline mode: "));
camel_data_cache_remove (groupwise_folder->cache, "cache", uid, NULL);
folder->summary->nextuid--;
g_object_unref (cache);
return TRUE;
}
-void
+gboolean
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))
- return;
+ if (!update_cache (groupwise_journal, message, mi, &uid, error))
+ return FALSE;
entry = g_new (CamelGroupwiseJournalEntry, 1);
entry->type = CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND;
if (appended_uid)
*appended_uid = g_strdup (uid);
+
+ return TRUE;
}
-void
+gboolean
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;
parent_store = camel_folder_get_parent_store (journal->folder);
gw_store = CAMEL_GROUPWISE_STORE (parent_store);
- if (!update_cache (groupwise_journal, message, mi, &uid, ex))
- return;
+ if (!update_cache (groupwise_journal, message, mi, &uid, error))
+ return FALSE;
entry = g_new (CamelGroupwiseJournalEntry, 1);
entry->type = CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND;
if (transferred_uid)
*transferred_uid = g_strdup (uid);
+
+ return TRUE;
}
CamelOfflineJournal *camel_groupwise_journal_new (struct _CamelGroupwiseFolder *folder, const gchar *filename);
/* interfaces for adding a journal entry */
-void camel_groupwise_journal_append (CamelGroupwiseJournal *journal, CamelMimeMessage *message, const CamelMessageInfo *mi,
- gchar **appended_uid, CamelException *ex);
-void camel_groupwise_journal_transfer (CamelGroupwiseJournal *journal, CamelGroupwiseFolder *source_folder, CamelMimeMessage *message,
- const CamelMessageInfo *mi, const gchar *orginal_uid, gchar **transferred_uid, CamelException *ex);
+gboolean camel_groupwise_journal_append (CamelGroupwiseJournal *journal, CamelMimeMessage *message, const CamelMessageInfo *mi,
+ gchar **appended_uid, GError **error);
+gboolean camel_groupwise_journal_transfer (CamelGroupwiseJournal *journal, CamelGroupwiseFolder *source_folder, CamelMimeMessage *message,
+ const CamelMessageInfo *mi, const gchar *orginal_uid, gchar **transferred_uid, GError **error);
G_END_DECLS
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);
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("imapx://", &ex);
+ imap_provider = camel_provider_get("imapx://", NULL);
groupwise_provider.url_hash = groupwise_url_hash;
groupwise_provider.url_equal = groupwise_url_equal;
};
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 gboolean 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);
G_DEFINE_TYPE (CamelGroupwiseStore, camel_groupwise_store, CAMEL_TYPE_OFFLINE_STORE)
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);
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_groupwise_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ if (!service_class->construct (service, session, provider, url, error))
return FALSE;
if (!(url->host || url->user)) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_INVALID,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
_("Host or user not available in url"));
}
/*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 FALSE;
}
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);
"GroupWise", service->url->user, service->url->host);
service->url->passwd =
camel_session_get_password (session, service, "Groupwise",
- prompt, "password", prompt_flags, ex);
+ prompt, "password", prompt_flags, error);
g_free (prompt);
if (!service->url->passwd) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
_("You did not enter a password."));
return FALSE;
}
prompt_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
g_free (service->url->passwd);
service->url->passwd = NULL;
- camel_exception_clear (ex);
} else {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- errors.description ?
+ 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;
}
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, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_clear_error (&local_error);
+ ai = camel_getaddrinfo(priv->server_name, priv->port, &hints, &local_error);
}
- if (ai == NULL)
+
+ if (ai == NULL) {
+ g_propagate_error (error, local_error);
return FALSE;
+ }
camel_freeaddrinfo (ai);
}
static gboolean
-groupwise_connect (CamelService *service, CamelException *ex)
+groupwise_connect (CamelService *service, GError **error)
{
CamelGroupwiseStore *store = CAMEL_GROUPWISE_STORE (service);
CamelGroupwiseStorePrivate *priv = store->priv;
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_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
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_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
#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;
#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);
}
static GList*
-groupwise_store_query_auth_types (CamelService *service, CamelException *ex)
+groupwise_store_query_auth_types (CamelService *service, GError **error)
{
GList *auth_types = NULL;
}
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;
}
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;
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,
+ 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;
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);
-
camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_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_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_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_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return NULL;
}
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, NULL);
if (!folder) {
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_INVALID,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
_("Authentication failed"));
g_free (folder_dir);
g_free (container_id);
if (status != E_GW_CONNECTION_STATUS_OK) {
all_ok = FALSE;
break;
- /*
- camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
- //camel_folder_summary_clear (folder->summary);
- camel_folder_summary_save_to_db (folder->summary, ex);
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
- camel_operation_end (NULL);
- g_object_unref (folder);
- g_free (container_id);
- return NULL;*/
}
/* This full block is repeated in the reload_folder code as well. We need
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
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);
return folder;
}
-void
-gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guint32 flags, CamelException *ex)
+gboolean
+gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guint32 flags, GError **error)
{
CamelGroupwiseStorePrivate *priv = gw_store->priv;
CamelGroupwiseSummary *summary;
name = camel_folder_get_name (folder);
full_name = camel_folder_get_full_name (folder);
- camel_exception_clear (ex);
-
camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_groupwise_store_connected (gw_store, ex)) {
+ if (!camel_groupwise_store_connected (gw_store, error)) {
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- return;
+ return FALSE;
}
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_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- return;
+ return FALSE;
}
}
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) {
if (status != E_GW_CONNECTION_STATUS_OK) {
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
g_free (container_id);
- return;
+ return FALSE;
}
camel_operation_start (
if (status != E_GW_CONNECTION_STATUS_OK) {
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_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,
+ 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;
+ return FALSE;
}
/* This full block is repeated in the get_folder code as well. We need
better modularity */
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
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);
g_free (container_id);
camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- return;
+ return TRUE;
}
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;
if (store->current_folder
&& !strcmp (camel_folder_get_full_name (store->current_folder), fi->full_name)
&& type != E_GW_CONTAINER_TYPE_INBOX) {
- CAMEL_FOLDER_GET_CLASS (store->current_folder)->refresh_info (store->current_folder, ex);
+ CAMEL_FOLDER_GET_CLASS (store->current_folder)->refresh_info (store->current_folder, error);
}
return fi;
}
}
static gboolean
-groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex)
+groupwise_folders_sync (CamelGroupwiseStore *store, GError **error)
{
CamelGroupwiseStorePrivate *priv = store->priv;
gint status;
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)
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;
return fi;
}
-/*** Thread stuff for refreshing folder tree begins ***/
-struct _store_refresh_msg {
- CamelSessionThreadMsg msg;
-
- CamelStore *store;
- CamelException ex;
-};
-
-#if 0
-static void
-store_refresh_refresh (CamelSession *session, CamelSessionThreadMsg *msg)
-{
- struct _store_refresh_msg *m = (struct _store_refresh_msg *)msg;
- CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE(m->store);
-
- camel_service_lock (CAMEL_SERVICE (m->store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_groupwise_store_connected (groupwise_store, &m->ex))
- goto done;
- /*Get the folder list and save it here*/
- groupwise_folders_sync (groupwise_store, &m->ex);
- if (camel_exception_is_set (&m->ex))
- goto done;
- camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
-done:
- camel_service_unlock (CAMEL_SERVICE (m->store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-}
-
-static void
-store_refresh_free(CamelSession *session, CamelSessionThreadMsg *msg)
-{
- struct _store_refresh_msg *m = (struct _store_refresh_msg *)msg;
-
- g_object_unref (m->store);
- camel_exception_clear (&m->ex);
-}
-
-static CamelSessionThreadOps store_refresh_ops = {
- store_refresh_refresh,
- store_refresh_free,
-};
-#endif
-
-/*** 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);
CamelFolderInfo *info = NULL;
/* Do not call groupwise_store_connected function as it would internall call folders_sync
to populate the hash table which is used for mapping container id */
if (!(((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
- && camel_service_connect ((CamelService *)store, ex)))
+ && camel_service_connect ((CamelService *)store, error)))
goto offline;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- groupwise_folders_sync (groupwise_store, ex);
- if (camel_exception_is_set (ex)) {
+ if (!groupwise_folders_sync (groupwise_store, error)) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return NULL;
}
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
offline:
- info = groupwise_get_folder_info_offline (store, top, flags, ex);
+ info = groupwise_get_folder_info_offline (store, top, flags, error);
return info;
}
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;
gint status;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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 /* XXX Um, hello? Error message? */);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot create a special system folder"));
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,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_STATE,
_("The parent folder is not allowed to contain subfolders"));
return NULL;
}
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;
}
}
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;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_groupwise_store_connected (groupwise_store, ex)) {
+ if (!camel_groupwise_store_connected (groupwise_store, error)) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return FALSE;
}
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,NULL);
g_hash_table_remove (priv->id_hash, container);
g_hash_table_remove (priv->name_hash, folder_name);
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;
gchar *temp_new = NULL;
if (groupwise_is_system_folder (old_name)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot rename GroupWise folder '%s' to '%s'"),
old_name, new_name);
return FALSE;
camel_service_lock (CAMEL_SERVICE (groupwise_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_groupwise_store_connected (groupwise_store, ex)) {
+ if (!camel_groupwise_store_connected (groupwise_store, error)) {
camel_service_unlock (CAMEL_SERVICE (groupwise_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return FALSE;
}
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot rename GroupWise folder '%s' to '%s'"),
old_name, new_name);
camel_service_unlock (CAMEL_SERVICE (groupwise_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
}
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) {
CamelObject *object = CAMEL_OBJECT (folder);
gchar *state = g_build_filename((CAMEL_GROUPWISE_STORE(store))->priv->storage_path, "folders", "Trash", "cmeta", NULL);
}
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(camel_groupwise_store_parent_class)->can_refresh_folder (store, info, ex) ||
+ res = CAMEL_STORE_CLASS(camel_groupwise_store_parent_class)->can_refresh_folder (store, info, error) ||
(camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL);
return res;
* 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)) {
CamelGroupwiseStore *gw_store = (CamelGroupwiseStore *) store;
CamelGroupwiseStorePrivate *priv = gw_store->priv;
if (g_hash_table_size (priv->name_hash) == 0)
- groupwise_folders_sync ((CamelGroupwiseStore *) gw_store, ex);
+ return groupwise_folders_sync ((CamelGroupwiseStore *) gw_store, error);
return TRUE;
}
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);
+gboolean 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
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);
camel_groupwise_summary_new (struct _CamelFolder *folder, const gchar *filename)
{
CamelFolderSummary *summary;
- CamelException ex;
summary = g_object_new (CAMEL_TYPE_GROUPWISE_SUMMARY, NULL);
summary->folder = folder;
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) {
- camel_folder_summary_clear_db (summary);
- }
+ camel_folder_summary_load_from_db (summary, NULL);
return summary;
}
}
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 (camel_groupwise_summary_parent_class)->summary_header_to_db (s, ex);
+ fir = CAMEL_FOLDER_SUMMARY_CLASS (camel_groupwise_summary_parent_class)->summary_header_to_db (s, error);
if (!fir)
return NULL;
static gboolean
groupwise_transport_connect (CamelService *service,
- CamelException *ex)
+ GError **error)
{
return TRUE;
}
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex)
+ GError **error)
{
CamelService *service;
CamelStore *store = NULL;
EGwItemLinkInfo *info = NULL;
if (!transport) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Authentication failed"));
return FALSE;
}
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, NULL);
g_free (url);
if (!store) {
g_warning ("ERROR: Could not get a pointer to the store");
- camel_exception_set (
- ex, CAMEL_EXCEPTION_STORE_INVALID,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_INVALID,
_("Cannot get folder: Invalid operation on this store"));
return FALSE;
}
if (!cnc) {
g_warning ("||| Eh!!! Failure |||\n");
camel_operation_end (NULL);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Authentication failed"));
return FALSE;
}
/* FIXME: 58652 should be changed with an enum.*/
if (status == 58652)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not send message: %s"),
_("Unknown error"));
status = 0;
filtered_stream = g_object_ref (content);
}
- camel_data_wrapper_decode_to_stream (dw, filtered_stream);
- camel_stream_flush (filtered_stream);
+ camel_data_wrapper_decode_to_stream (dw, filtered_stream, NULL);
+ camel_stream_flush (filtered_stream, NULL);
g_object_unref (filtered_stream);
- camel_stream_write (content, "", 1);
+ camel_stream_write (content, "", 1, NULL);
e_gw_item_set_message (item, (const gchar *)byte_array->data);
} else {
- camel_data_wrapper_decode_to_stream (dw, content);
+ camel_data_wrapper_decode_to_stream (dw, content, NULL);
send_as_attachment (cnc, item, content, type, dw, NULL, NULL, &attach_list);
}
if (temp_part) {
is_alternative = TRUE;
temp_dw = camel_medium_get_content (CAMEL_MEDIUM (temp_part));
- camel_data_wrapper_write_to_stream(temp_dw, temp_content);
+ camel_data_wrapper_write_to_stream(temp_dw, temp_content, NULL);
filename = camel_mime_part_get_filename (temp_part);
disposition = camel_mime_part_get_disposition (temp_part);
cid = camel_mime_part_get_content_id (temp_part);
filtered_stream = g_object_ref (content);
}
- camel_data_wrapper_decode_to_stream (dw, filtered_stream);
- camel_stream_flush (filtered_stream);
+ camel_data_wrapper_decode_to_stream (dw, filtered_stream, NULL);
+ camel_stream_flush (filtered_stream, NULL);
g_object_unref (filtered_stream);
- camel_stream_write (content, "", 1);
+ camel_stream_write (content, "", 1, NULL);
e_gw_item_set_message (item, (const gchar *) buffer->data);
} else {
filename = camel_mime_part_get_filename (part);
disposition = camel_mime_part_get_disposition (part);
content_id = camel_mime_part_get_content_id (part);
- camel_data_wrapper_decode_to_stream (dw, content);
+ camel_data_wrapper_decode_to_stream (dw, content, NULL);
send_as_attachment (cnc, item, content, type, dw, filename, content_id, attach_list);
}
extern gint camel_verbose_debug;
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,
* @store: the IMAP store
* @folder: The folder to perform the operation in (or %NULL if not
* relevant).
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
* @fmt: a sort of printf-style format string, followed by arguments
*
* This function calls camel_imap_command_start() to send the
CamelImapResponse *
camel_imap_command (CamelImapStore *store,
CamelFolder *folder,
- CamelException *ex,
+ GError **error,
const gchar *fmt, ...)
{
va_list ap;
cmd = imap_command_strdup_printf (store, "SELECT %F", full_name);
}
- if (!imap_command_start (store, folder, cmd, ex)) {
+ if (!imap_command_start (store, folder, cmd, error)) {
g_free (cmd);
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return NULL;
}
g_free (cmd);
- return imap_read_response (store, ex);
+ return imap_read_response (store, error);
}
/**
* @store: the IMAP store
* @folder: The folder to perform the operation in (or %NULL if not
* relevant).
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
* @fmt: a sort of printf-style format string, followed by arguments
*
* This function makes sure that @folder (if non-%NULL) is the
gboolean
camel_imap_command_start (CamelImapStore *store,
CamelFolder *folder,
- CamelException *ex,
+ GError **error,
const gchar *fmt, ...)
{
va_list ap;
va_end (ap);
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- ok = imap_command_start (store, folder, cmd, ex);
+ ok = imap_command_start (store, folder, cmd, error);
g_free (cmd);
if (!ok)
imap_command_start (CamelImapStore *store,
CamelFolder *folder,
const gchar *cmd,
- CamelException *ex)
+ GError **error)
{
gssize nwritten;
if (!store->ostream) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_STORE_INVALID,
+ 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,
+ 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;
}
}
if (nwritten == -1) {
if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
_("Operation cancelled"));
else
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- g_strerror (errno));
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
return FALSE;
* @store: the IMAP store
* @cmd: buffer containing the response/request data
* @cmdlen: command length
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This method is for sending continuing responses to the IMAP server
* after camel_imap_command() or camel_imap_command_response() returns
camel_imap_command_continuation (CamelImapStore *store,
const gchar *cmd,
gsize cmdlen,
- CamelException *ex)
+ 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,
+ 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,
+ 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"));
- else
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- g_strerror (errno));
+ if (camel_stream_write (store->ostream, cmd, cmdlen, error) == -1 ||
+ camel_stream_write (store->ostream, "\r\n", 2, error) == -1) {
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return NULL;
}
- return imap_read_response (store, ex);
+ return imap_read_response (store, error);
}
/**
* camel_imap_command_response:
* @store: the IMAP store
* @response: a pointer to pass back the response data in
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This reads a single tagged, untagged, or continuation response from
* @store into *@response. The caller must free the string when it is
**/
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_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return CAMEL_IMAP_RESPONSE_ERROR;
}
/* Connection was lost, no more data to fetch */
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Server unexpectedly disconnected: %s"), err);
store->connected = FALSE;
g_free (respbuf);
/* 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)
}
static CamelImapResponse *
-imap_read_response (CamelImapStore *store, CamelException *ex)
+imap_read_response (CamelImapStore *store, GError **error)
{
CamelImapResponse *response;
CamelImapResponseType type;
} */
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);
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,
+ 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);
p += 3;
if (!*p++)
p = NULL;
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_INVALID,
+ 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);
* 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;
n = camel_stream_read (
store->istream,
str->str + nread + 1,
- length - nread);
+ length - nread, error);
if (n == -1) {
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Operation cancelled"));
- else
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- g_strerror (errno));
- camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
+ camel_service_disconnect (
+ CAMEL_SERVICE (store), FALSE, NULL);
g_string_free (str, TRUE);
goto lose;
}
} while (n > 0 && nread < length);
if (nread < length) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ 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);
/* 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
* @store: the store the response came from
* @response: the response data returned from camel_imap_command
* @type: the response type to extract
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This checks that @response contains a single untagged response of
* type @type and returns just that response data. If @response
camel_imap_response_extract (CamelImapStore *store,
CamelImapResponse *response,
const gchar *type,
- CamelException *ex)
+ GError **error)
{
gint len = strlen (type), i;
gchar *resp;
g_ptr_array_remove_index (response->untagged, i);
} else {
resp = NULL;
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("IMAP server response did not "
"contain %s information"), type);
}
* camel_imap_response_extract_continuation:
* @store: the store the response came from
* @response: the response data returned from camel_imap_command
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* This checks that @response contains a continuation response, and
* returns just that data. If @response doesn't contain a continuation
gchar *
camel_imap_response_extract_continuation (CamelImapStore *store,
CamelImapResponse *response,
- CamelException *ex)
+ GError **error)
{
gchar *status;
return status;
}
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Unexpected OK response from IMAP server: %s"),
response->status);
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);
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
extern gint camel_application_is_exiting;
-static gboolean imap_rescan (CamelFolder *folder, gint exists, CamelException *ex);
-static gboolean imap_refresh_info (CamelFolder *folder, CamelException *ex);
-static gboolean imap_sync_offline (CamelFolder *folder, CamelException *ex);
-static gboolean imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static gboolean imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, CamelException *ex);
-static gboolean imap_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, CamelException *ex);
-static gboolean imap_expunge (CamelFolder *folder, CamelException *ex);
-/*static void imap_cache_message (CamelDiscoFolder *disco_folder, const gchar *uid, CamelException *ex);*/
+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);
+ GError **error);
static gboolean imap_sync_message (CamelFolder *folder, const gchar *uid,
- CamelException *ex);
+ GError **error);
static gboolean imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex);
+ GError **error);
static gboolean imap_append_offline (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex);
+ GError **error);
static gboolean imap_transfer_online (CamelFolder *source, GPtrArray *uids,
CamelFolder *dest, GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ 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);
static CamelImapMessageInfo * imap_folder_summary_uid_or_error(
CamelFolderSummary *summary,
const gchar * uid,
- CamelException *ex);
+ GError **error);
static gboolean
imap_transfer_messages (CamelFolder *source, GPtrArray *uids,
CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex,
- gboolean can_call_sync);
+ gboolean delete_originals, gboolean can_call_sync,
+ GError **error);
#ifdef G_OS_WIN32
/* The strtok() in Microsoft's C library is MT-safe (but still uses
}
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;
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);
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;
gchar *summary_file, *state_file, *path;
if (g_mkdir_with_parents (folder_dir, S_IRWXU) != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not create directory %s: %s"),
folder_dir, g_strerror (errno));
return NULL;
g_free (summary_file);
if (!folder->summary) {
g_object_unref (CAMEL_OBJECT (folder));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Could not load summary for %s"), folder_name);
return NULL;
}
g_free(state_file);
camel_object_state_read (CAMEL_OBJECT (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;
gboolean
camel_imap_folder_selected (CamelFolder *folder,
CamelImapResponse *response,
- CamelException *ex)
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapSummary *imap_summary = CAMEL_IMAP_SUMMARY (folder->summary);
camel_imap_message_cache_clear (imap_folder->cache);
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
imap_folder->need_rescan = FALSE;
- return camel_imap_folder_changed (folder, exists, NULL, ex);
+ return camel_imap_folder_changed (folder, exists, NULL, error);
}
/* If we've lost messages, we have to rescan everything */
* 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 FALSE;
uid = 0;
/* Now rescan if we need to */
if (imap_folder->need_rescan)
- return imap_rescan (folder, exists, ex);
+ 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. */
static gchar *
imap_get_filename (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ 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 void
/* 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)
{
CamelStore *parent_store;
CamelImapStore *imap_store;
imap_store = CAMEL_IMAP_STORE (parent_store);
- response = camel_imap_command (imap_store, folder, ex, "STATUS %F (MESSAGES UNSEEN)", full_name);
+ response = camel_imap_command (imap_store, folder, error, "STATUS %F (MESSAGES UNSEEN)", full_name);
if (response) {
gint i;
static gboolean
imap_refresh_info (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *imap_store;
CamelStoreInfo *si;
const gchar *full_name;
gint check_rescan = -1;
+ GError *local_error = NULL;
parent_store = camel_folder_get_parent_store (folder);
imap_store = CAMEL_IMAP_STORE (parent_store);
* should do it. */
camel_service_lock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_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);
full_name = camel_folder_get_full_name (folder);
if (imap_store->current_folder != folder
|| g_ascii_strcasecmp (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) {
* 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 (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);
}
camel_store_summary_info_free((CamelStoreSummary *)((CamelImapStore *)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;
/* 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)) {
total = camel_folder_summary_count (folder->summary);
unread = folder->summary->unread_count;
}
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_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_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 *)parent_store)->summary);
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
return TRUE;
}
/* Called with the store's connect_lock locked */
static gboolean
-imap_rescan (CamelFolder *folder, gint exists, CamelException *ex)
+imap_rescan (CamelFolder *folder, gint exists, GError **error)
{
CamelStore *parent_store;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
summary_len = camel_folder_summary_count (folder->summary);
if (summary_len == 0) {
if (exists)
- return camel_imap_folder_changed (folder, exists, NULL, ex);
+ return camel_imap_folder_changed (folder, exists, NULL, error);
return TRUE;
}
}
ok = camel_imap_command_start (
- store, folder, ex,
+ store, folder, error,
"UID FETCH 1:%s (FLAGS)", uid);
g_free (uid);
if (!ok) {
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;
*/
removed = g_array_new (FALSE, FALSE, sizeof (gint));
- camel_folder_summary_prepare_fetch_all (folder->summary, ex);
+ camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
for (i = 0, j = 0; i < summary_len && new[j].uid; i++) {
gboolean changed = FALSE;
}
/* And finally update the summary. */
- success = 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 gboolean
imap_sync_offline (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
}
}
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
camel_store_summary_save((CamelStoreSummary *)((CamelImapStore *)parent_store)->summary);
return TRUE;
}
static void
-move_messages (CamelFolder *src_folder, GPtrArray *uids, CamelFolder *des_folder, CamelException *ex)
+move_messages (CamelFolder *src_folder,
+ GPtrArray *uids,
+ CamelFolder *des_folder,
+ GError **error)
{
g_return_if_fail (src_folder != NULL);
/* moving to the same folder means expunge only */
if (src_folder != des_folder) {
/* do 'copy' to not be bothered with CAMEL_MESSAGE_DELETED again */
- if (!imap_transfer_messages (src_folder, uids, des_folder, NULL, FALSE, ex, FALSE))
+ if (!imap_transfer_messages (src_folder, uids, des_folder, NULL, FALSE, FALSE, error))
return;
}
- if (!camel_exception_is_set (ex))
- camel_imap_expunge_uids_only (src_folder, uids, ex);
+ camel_imap_expunge_uids_only (src_folder, uids, error);
}
static gboolean
imap_sync (CamelFolder *folder,
gboolean expunge,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
CamelImapMessageInfo *info;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
gboolean success;
- CamelException local_ex;
- CamelFolder *real_trash = NULL, *real_junk = NULL;
+ CamelFolder *real_junk = NULL;
+ CamelFolder *real_trash = NULL;
+ GError *local_error = NULL;
GPtrArray *matches, *summary, *deleted_uids = NULL, *junked_uids = NULL;
gchar *set, *flaglist, *uid;
if (folder->permanent_flags == 0 || CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
if (expunge) {
- if (!imap_expunge (folder, ex))
+ if (!imap_expunge (folder, error))
return FALSE;
}
- return imap_sync_offline (folder, ex);
+ return imap_sync_offline (folder, error);
}
- camel_exception_init (&local_ex);
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_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
real_trash = folder;
g_object_ref (real_trash);
} else {
- CamelException ex2;
-
- camel_exception_init (&ex2);
- real_trash = camel_store_get_trash (parent_store, &ex2);
- camel_exception_clear (&ex2);
+ real_trash = camel_store_get_trash (parent_store, NULL);
if (!store->real_trash_path && real_trash) {
/* failed to open real trash */
/* syncing the junk, but cannot move messages to itself, thus do nothing */
real_junk = NULL;
} else {
- CamelException ex2;
-
- camel_exception_init (&ex2);
- real_junk = camel_store_get_junk (parent_store, &ex2);
- camel_exception_clear (&ex2);
+ real_junk = camel_store_get_junk (parent_store, NULL);
if (!store->real_junk_path && real_junk) {
/* failed to open real junk */
}
/* 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);
camel_message_info_free(info);
break;
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)
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);
}
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];
if (deleted_uids) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
/* check for an exception */
- if (camel_exception_is_set (&local_ex)) {
- camel_exception_xfer (ex, &local_ex);
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
if (deleted_uids) {
g_ptr_array_foreach (deleted_uids, (GFunc) camel_pstring_free, NULL);
g_ptr_array_free (deleted_uids, TRUE);
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
}
- if (!camel_exception_is_set (ex))
- move_messages (folder, deleted_uids, real_trash, &local_ex);
- if (!camel_exception_is_set (&local_ex))
- move_messages (folder, junked_uids, real_junk, &local_ex);
- if (camel_exception_is_set (&local_ex))
- camel_exception_xfer (ex, &local_ex);
+ if (local_error == NULL)
+ move_messages (folder, deleted_uids, real_trash, &local_error);
+ if (local_error == NULL)
+ move_messages (folder, junked_uids, real_junk, &local_error);
if (deleted_uids) {
g_ptr_array_foreach (deleted_uids, (GFunc) camel_pstring_free, NULL);
if (real_junk)
g_object_unref (real_junk);
- if (expunge && !camel_exception_is_set (ex))
- imap_expunge (folder, ex);
+ if (expunge && local_error == NULL)
+ imap_expunge (folder, &local_error);
+
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
g_ptr_array_foreach (summary, (GFunc) camel_pstring_free, NULL);
g_ptr_array_free (summary, TRUE);
/* Save the summary */
- success = imap_sync_offline (folder, ex);
+ success = imap_sync_offline (folder, error);
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
static gboolean
imap_expunge_uids_offline (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelFolderChangeInfo *changes;
CamelStore *parent_store;
*/
}
- camel_db_delete_uids (parent_store->cdb_w, full_name, list, ex);
+ camel_db_delete_uids (parent_store->cdb_w, 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);
static gboolean
imap_expunge_uids_online (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *store;
CamelImapResponse *response;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
if ((store->capabilities & IMAP_CAPABILITY_UIDPLUS) == 0) {
- if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, ex)) {
+ if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, error)) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return FALSE;
}
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)
}
if (!full_expunge) {
- response = camel_imap_command (store, folder, ex,
- "UID EXPUNGE %s", set);
+ 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_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
}
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);
*/
}
- camel_db_delete_uids (parent_store->cdb_w, full_name, list, ex);
+ camel_db_delete_uids (parent_store->cdb_w, 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_folder_changed (folder, changes);
camel_folder_change_info_free (changes);
static gboolean
imap_expunge (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
GPtrArray *uids = NULL;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- camel_folder_summary_save_to_db (folder->summary, ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
if ((parent_store->flags & CAMEL_STORE_VTRASH) == 0) {
CamelFolder *trash;
- CamelException ex2;
+ GError *local_error = NULL;
- camel_exception_init (&ex2);
- trash = camel_store_get_trash (parent_store, &ex2);
+ trash = camel_store_get_trash (parent_store, &local_error);
- if (!camel_exception_is_set (&ex2) && trash && (folder == trash || g_ascii_strcasecmp (full_name, camel_folder_get_full_name (trash)) == 0)) {
+ if (local_error == NULL && trash && (folder == trash || g_ascii_strcasecmp (full_name, camel_folder_get_full_name (trash)) == 0)) {
/* it's a real trash folder, thus get all mails from there */
uids = camel_folder_summary_array (folder->summary);
}
- camel_exception_clear (&ex2);
+ if (local_error != NULL)
+ g_clear_error (&local_error);
}
if (!uids)
- uids = camel_db_get_folder_deleted_uids (parent_store->cdb_r, full_name, ex);
+ uids = camel_db_get_folder_deleted_uids (parent_store->cdb_r, full_name, NULL);
if (!uids)
return TRUE;
if (CAMEL_OFFLINE_STORE (parent_store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL)
- success = imap_expunge_uids_online (folder, uids, ex);
+ success = imap_expunge_uids_online (folder, uids, error);
else
- success = 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);
gboolean
camel_imap_expunge_uids_resyncing (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
return TRUE;
if (store->capabilities & IMAP_CAPABILITY_UIDPLUS)
- return imap_expunge_uids_online (folder, uids, ex);
+ 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,
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, ex)) {
+ if (!CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, 0, error)) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
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_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return FALSE;
}
- result = camel_imap_response_extract (store, response, "SEARCH", ex);
+ result = camel_imap_response_extract (store, response, "SEARCH", error);
if (!result) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return FALSE;
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);
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);
}
/* Do the actual expunging */
- response = camel_imap_command (store, folder, ex, "EXPUNGE");
+ response = camel_imap_command (store, folder, NULL, "EXPUNGE");
if (response)
camel_imap_response_free (store, response);
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);
return TRUE;
}
-void
-camel_imap_expunge_uids_only (CamelFolder *folder, GPtrArray *uids, CamelException *ex)
+gboolean
+camel_imap_expunge_uids_only (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
{
CamelStore *parent_store;
- g_return_if_fail (folder != NULL);
+ g_return_val_if_fail (folder != NULL, FALSE);
parent_store = camel_folder_get_parent_store (folder);
- g_return_if_fail (parent_store != NULL);
+ g_return_val_if_fail (parent_store != NULL, FALSE);
- g_return_if_fail (uids != NULL);
+ g_return_val_if_fail (uids != NULL, FALSE);
if (CAMEL_OFFLINE_STORE (parent_store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL)
- camel_imap_expunge_uids_resyncing (folder, uids, ex);
+ return camel_imap_expunge_uids_resyncing (folder, uids, error);
else
- imap_expunge_uids_offline (folder, uids, ex);
+ return imap_expunge_uids_offline (folder, uids, error);
}
static gchar *
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelImapMessageCache *cache = CAMEL_IMAP_FOLDER (folder)->cache;
CamelFolderChangeInfo *changes;
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_imap_message_cache_insert_wrapper (
+ cache, uid, "", CAMEL_DATA_WRAPPER (message));
CAMEL_IMAP_FOLDER_REC_UNLOCK (folder, cache_lock);
changes = camel_folder_change_info_new ();
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **uid,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
const gchar *full_name;
gchar *flagstr, *end;
guint32 flags = 0;
+ GError *local_error = NULL;
parent_store = camel_folder_get_parent_store (folder);
store = CAMEL_IMAP_STORE (parent_store);
camel_stream_filter_add (
CAMEL_STREAM_FILTER (streamfilter), crlf_filter);
camel_data_wrapper_write_to_stream (
- CAMEL_DATA_WRAPPER (message), streamfilter);
+ CAMEL_DATA_WRAPPER (message), streamfilter, NULL);
g_object_unref (streamfilter);
g_object_unref (crlf_filter);
g_object_unref (memstream);
full_name = camel_folder_get_full_name (folder);
response = camel_imap_command (
- store, NULL, ex, "APPEND %F%s%s {%d}",
+ store, NULL, &local_error, "APPEND %F%s%s {%d}",
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;
}
+ g_propagate_error (error, local_error);
g_byte_array_free (ba, TRUE);
return NULL;
}
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);
-
camel_imap_response_free (store, response);
g_byte_array_free (ba, TRUE);
return NULL;
}
/* 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, 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 (!response2)
return response2;
- }
if (store->capabilities & IMAP_CAPABILITY_UIDPLUS) {
*uid = camel_strstrcase (response2->status, "[APPENDUID ");
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
store = CAMEL_IMAP_STORE (parent_store);
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- return imap_append_offline (folder, message, info, appended_uid, ex);
+ 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!"));
+ response = do_append (folder, message, info, &uid, error);
+ if (!response)
return FALSE;
- }
if (uid) {
/* Cache first, since freeing response may trigger a
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));
CAMEL_IMAP_FOLDER_REC_UNLOCK (folder, cache_lock);
if (appended_uid)
*appended_uid = uid;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
if (store->current_folder != folder ||
camel_folder_summary_count (folder->summary) == count)
- success = imap_refresh_info (folder, ex);
+ success = imap_refresh_info (folder, error);
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return success;
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
parent_store = camel_folder_get_parent_store (folder);
store = CAMEL_IMAP_STORE (parent_store);
- response = do_append (folder, message, info, &uid, ex);
+ response = do_append (folder, message, info, &uid, error);
if (!response)
return FALSE;
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);
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
if (appended_uid)
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
CamelMessageInfo *mi;
gchar *uid, *destuid;
gint i;
+ GError *local_error = NULL;
parent_store = camel_folder_get_parent_store (source);
store = CAMEL_IMAP_STORE (parent_store);
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 ();
} 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);
camel_message_info_free(mi);
camel_folder_change_info_add_uid (changes, destuid);
else
g_free (destuid);
- if (delete_originals && !camel_exception_is_set (ex))
+ if (delete_originals && local_error == NULL)
camel_folder_delete_message (source, uid);
}
camel_imap_journal_log (
CAMEL_IMAP_FOLDER (source)->journal,
CAMEL_IMAP_JOURNAL_ENTRY_TRANSFER,
- dest, uids, delete_originals, ex);
+ dest, uids, delete_originals, NULL);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
return TRUE;
}
CAMEL_IMAP_FOLDER_REC_LOCK (destination, cache_lock);
for (i = 0; i < src->len; i++) {
camel_imap_message_cache_copy (scache, src->pdata[i],
- dcache, dest->pdata[i],
- NULL);
+ dcache, dest->pdata[i]);
imap_folder_add_ignore_recent (CAMEL_IMAP_FOLDER (destination), dest->pdata[i]);
}
gchar *validity, *srcset, *destset;
GPtrArray *src, *dest;
gint i;
- CamelException ex;
validity = camel_strstrcase (response->status, "[COPYUID ");
if (!validity)
CAMEL_IMAP_STORE (parent_store), camel_imap_command (
CAMEL_IMAP_STORE (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);
+ if (!imap_refresh_info (destination, NULL))
goto lose;
- }
- camel_exception_clear (&ex);
src = imap_uid_set_to_array (source->summary, srcset);
dest = imap_uid_set_to_array (destination->summary, destset);
GPtrArray *uids,
CamelFolder *destination,
gint delete_originals,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
const gchar *full_name;
gchar *uidset;
gint uid = 0, last=0, i;
+ GError *local_error = NULL;
parent_store = camel_folder_get_parent_store (source);
store = CAMEL_IMAP_STORE (parent_store);
full_name = camel_folder_get_full_name (destination);
- 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,
+ store, source, &local_error,
"UID XGWMOVE %s %F", uidset,
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,
+ store, source, &local_error,
"UID COPY %s %F", uidset,
full_name);
if (response && (store->capabilities & IMAP_CAPABILITY_UIDPLUS))
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 gboolean
imap_transfer_messages (CamelFolder *source,
- GPtrArray *uids,
- CamelFolder *dest,
- GPtrArray **transferred_uids,
- gboolean delete_originals,
- CamelException *ex,
- gboolean can_call_sync)
+ GPtrArray *uids,
+ CamelFolder *dest,
+ GPtrArray **transferred_uids,
+ gboolean delete_originals,
+ gboolean can_call_sync,
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return imap_transfer_offline (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
/* Sync message flags if needed. */
- if (can_call_sync && !imap_sync (source, FALSE, ex))
+ if (can_call_sync && !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 */
- if (!do_copy(source, uids, dest, delete_originals, ex))
+ 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)
- success = imap_refresh_info (dest, ex);
+ success = imap_refresh_info (dest, error);
/* FIXME */
if (transferred_uids)
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
- return imap_transfer_messages (source, uids, dest, transferred_uids, delete_originals, ex, TRUE);
+ return imap_transfer_messages (source, uids, dest, transferred_uids, delete_originals, TRUE, error);
}
gboolean
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ 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);
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];
/* 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) {
info = camel_folder_get_message_info (source, uid);
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++;
}
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)
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *matches;
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);
static guint32
imap_count_by_expression (CamelFolder *folder,
const gchar *expression,
- CamelException *ex)
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
guint32 matches;
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);
imap_search_by_uids (CamelFolder *folder,
const gchar *expression,
GPtrArray *uids,
- CamelException *ex)
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER(folder);
GPtrArray *matches;
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);
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;
get_content (CamelImapFolder *imap_folder, const gchar *uid,
CamelMimePart *part, CamelMessageContentInfo *ci,
gint frommsg,
- CamelException *ex)
+ GError **error)
{
CamelDataWrapper *content = NULL;
CamelStream *stream;
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);
+ CAMEL_DATA_WRAPPER (body_mp), stream, error);
g_object_unref (CAMEL_OBJECT (stream));
if (ret == -1) {
g_object_unref ( body_mp);
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;
part = camel_mime_part_new ();
- ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream);
+ ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream, error);
g_object_unref (CAMEL_OBJECT (stream));
if (ret == -1) {
g_object_unref (CAMEL_OBJECT (part));
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) {
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 {
static CamelMimeMessage *
get_message (CamelImapFolder *imap_folder, const gchar *uid,
CamelMessageContentInfo *ci,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
CamelStore *parent_store;
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)
msg = camel_mime_message_new ();
ret = camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (msg), stream);
+ CAMEL_DATA_WRAPPER (msg), stream, error);
g_object_unref (CAMEL_OBJECT (stream));
if (ret == -1) {
g_object_unref (CAMEL_OBJECT (msg));
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;
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;
}
msg = camel_mime_message_new ();
ret = camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (msg), stream);
+ CAMEL_DATA_WRAPPER (msg), stream, error);
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_prefix_error (error, _("Unable to retrieve message: "));
g_object_unref (CAMEL_OBJECT (msg));
return NULL;
}
}
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."));
}
static CamelMimeMessage *
imap_get_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelMimeMessage *msg = NULL;
CamelStream *stream = NULL;
gint retry;
+ GError *local_error = NULL;
parent_store = camel_folder_get_parent_store (folder);
store = CAMEL_IMAP_STORE (parent_store);
- 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
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
|| 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);
gint i;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_imap_store_connected(store, ex)) {
+ if (!camel_imap_store_connected(store, NULL)) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ 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_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
if (response) {
camel_imap_response_free (store, response);
} else {
- camel_exception_clear(ex);
+ g_clear_error (&local_error);
}
}
* 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) {
}
} 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));
done:
if (msg) {
static gboolean
imap_sync_message (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelImapMessageInfo *mi;
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.
g_object_unref (stream);
return TRUE;
}
- msg = imap_get_message(folder, uid, ex);
+ msg = imap_get_message(folder, uid, error);
if (msg != NULL) {
g_object_unref (msg);
success = TRUE;
/* 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;
msg = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (msg), stream) == -1) {
+ CAMEL_DATA_WRAPPER (msg), stream, NULL) == -1) {
g_object_unref (CAMEL_OBJECT (msg));
return;
}
imap_update_summary (CamelFolder *folder,
gint exists,
CamelFolderChangeInfo *changes,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelImapStore *store;
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);
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);
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);
}
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);
mi = messages->pdata[i];
if (!mi) {
g_warning ("No information for message %d", i + first);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Incomplete server response: "
"no information provided for message %d"),
i + first);
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Incomplete server response: "
"no UID provided for message %d"),
i + first);
/* break; */
/* } */
-/* g_warning("Message already present? %s", camel_message_info_uid(mi)); */
-/* camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, */
-/* _("Unexpected server response: Identical UIDs provided for messages %d and %d"), */
-/* seq + 1, i + first); */
-
-/* camel_message_info_free(&info->info); */
-/* break; */
-/* } */
-
((CamelMessageInfoBase *)mi)->dirty = TRUE;
if (((CamelMessageInfoBase *)mi)->summary)
camel_folder_summary_touch (((CamelMessageInfoBase *)mi)->summary);
/* Called with the store's connect_lock locked */
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;
/* Delete all in one transaction */
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- camel_db_delete_uids (parent_store->cdb_w, full_name, deleted, ex);
+ camel_db_delete_uids (parent_store->cdb_w, 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)
- success = 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_folder_changed (folder, changes);
imap_folder = CAMEL_IMAP_FOLDER (folder);
if (imap_folder->need_refresh) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-
imap_folder->need_refresh = FALSE;
- imap_refresh_info (folder, &ex);
- camel_exception_clear (&ex);
+ imap_refresh_info (folder, NULL);
}
}
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);
CamelStore *parent_store;
* 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, NULL);
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);
+ stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", NULL);
}
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
if (stream || cache_only)
return stream;
- camel_exception_clear(ex);
-
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_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,
+ if (!camel_imap_store_connected (store, NULL)) {
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("This message is not currently available"));
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return NULL;
}
- camel_exception_clear (ex);
if (store->server_level < IMAP_LEVEL_IMAP4REV1 && !*section_text) {
response = camel_imap_command (
- store, folder, ex,
+ store, folder, error,
"UID FETCH %s RFC822.PEEK", uid);
} else {
response = camel_imap_command (
- store, folder, ex,
+ store, folder, error,
"UID FETCH %s BODY.PEEK[%s]", uid,
section_text);
}
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,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not find message body in FETCH response."));
} else {
g_object_ref (CAMEL_OBJECT (stream));
static GPtrArray *
imap_get_uncached_uids (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex)
+ 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);
+ imap_folder->cache, uids, error);
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
CamelFolder * camel_imap_folder_new (CamelStore *parent,
const gchar *folder_name,
const gchar *folder_dir,
- CamelException *ex);
+ GError **error);
gboolean camel_imap_folder_get_check_folder
(CamelImapFolder *imap_folder);
void camel_imap_folder_set_check_folder
gboolean check_folder);
gboolean camel_imap_folder_selected (CamelFolder *folder,
CamelImapResponse *response,
- CamelException *ex);
+ GError **error);
gboolean camel_imap_folder_changed (CamelFolder *folder,
gint exists,
GArray *expunged,
- CamelException *ex);
+ GError **error);
CamelStream * camel_imap_folder_fetch_data (CamelImapFolder *imap_folder,
const gchar *uid,
const gchar *section_text,
gboolean cache_only,
- CamelException *ex);
+ GError **error);
gboolean camel_imap_append_resyncing (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex);
+ GError **error);
gboolean camel_imap_transfer_resyncing (CamelFolder *source,
GPtrArray *uids,
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex);
+ GError **error);
gboolean camel_imap_expunge_uids_resyncing
(CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex);
-
-void camel_imap_expunge_uids_only (CamelFolder *folder,
+ GError **error);
+gboolean camel_imap_expunge_uids_only (CamelFolder *folder,
GPtrArray *uids,
- CamelException *ex);
+ GError **error);
G_END_DECLS
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);
}
if (!folder) {
CamelStore *parent_store;
- CamelException ex;
gchar *msg;
+ GError *local_error = NULL;
- camel_exception_init (&ex);
parent_store = camel_folder_get_parent_store (
CAMEL_OFFLINE_JOURNAL (journal)->folder);
- folder = camel_store_get_folder (parent_store, name, 0, &ex);
+ folder = camel_store_get_folder (parent_store, 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 (parent_store)),
CAMEL_SESSION_ALERT_WARNING,
}
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;
switch (imap_entry->type) {
case CAMEL_IMAP_JOURNAL_ENTRY_EXPUNGE:
camel_imap_expunge_uids_resyncing (
- journal->folder, imap_entry->uids, ex);
+ journal->folder, imap_entry->uids, NULL);
return 0;
case CAMEL_IMAP_JOURNAL_ENTRY_APPEND:
{
CamelMimeMessage *message;
CamelMessageInfo *info;
- message = camel_folder_get_message (journal->folder, imap_entry->append_uid, NULL);
+ message = camel_folder_get_message (journal->folder, imap_entry->append_uid, error);
if (!message)
return -1;
info = camel_folder_get_message_info (journal->folder, imap_entry->append_uid);
camel_imap_append_resyncing (
- journal->folder, message, info, &ret_uid, ex);
+ journal->folder, message, info, &ret_uid, NULL);
camel_folder_free_message_info (journal->folder, info);
if (ret_uid) {
return -1;
}
- camel_exception_clear (ex);
if (!camel_imap_transfer_resyncing (
journal->folder, imap_entry->uids, destination,
- &ret_uids, imap_entry->move, ex))
+ &ret_uids, imap_entry->move, error))
return -1;
if (ret_uids) {
* 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
*
* Returns: a new CamelImapMessageCache object using @path for
* storage. If cache files already exist in @path, then any that do not
CamelImapMessageCache *
camel_imap_message_cache_new (const gchar *path,
CamelFolderSummary *summary,
- CamelException *ex)
+ 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;
}
/**
* 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)
+ 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;
}
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;
fd = g_open (*path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Failed to cache message %s: %s"),
uid, g_strerror (errno));
g_free (*path);
gchar *key,
CamelStream *stream)
{
- camel_stream_flush (stream);
- camel_stream_reset (stream);
+ camel_stream_flush (stream, NULL);
+ camel_stream_reset (stream, NULL);
cache_put (cache, uid, key, stream);
g_free (path);
const gchar *part_spec,
const gchar *data,
gint len,
- CamelException *ex)
+ 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));
+ if (camel_stream_write (stream, data, len, error) == -1) {
+ g_prefix_error (error, _("Failed to cache message %s: "), uid);
return insert_abort (path, stream);
}
camel_imap_message_cache_insert_stream (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
- CamelStream *data_stream,
- CamelException *ex)
+ CamelStream *data_stream)
{
gchar *path, *key;
CamelStream *stream;
- stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
+ stream = insert_setup (cache, uid, part_spec, &path, &key, NULL);
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));
+ if (camel_stream_write_to_stream (data_stream, stream, NULL) == -1) {
insert_abort (path, stream);
} else {
insert_finish (cache, uid, path, key, stream);
camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
- CamelDataWrapper *wrapper,
- CamelException *ex)
+ CamelDataWrapper *wrapper)
{
gchar *path, *key;
CamelStream *stream;
- stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
+ stream = insert_setup (cache, uid, part_spec, &path, &key, NULL);
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));
+ if (camel_data_wrapper_write_to_stream (wrapper, stream, NULL) == -1) {
insert_abort (path, stream);
} else {
insert_finish (cache, uid, path, key, stream);
* @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
*
* Returns: the filename of a cache item
**/
camel_imap_message_cache_get_filename (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
- CamelException *ex)
+ GError **error)
{
gchar *path;
* @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
*
* Returns: 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;
stream = g_hash_table_lookup (cache->parts, key);
if (stream) {
- camel_stream_reset (CAMEL_STREAM (stream));
+ camel_stream_reset (CAMEL_STREAM (stream), NULL);
g_object_ref (stream);
g_free (path);
return stream;
}
- stream = camel_stream_fs_new_with_name (path, O_RDONLY, 0);
+ stream = camel_stream_fs_new_with_name (path, O_RDONLY, 0, error);
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_prefix_error (error, _("Failed to cache %s: "), part_spec);
g_free (path);
camel_imap_message_cache_copy (CamelImapMessageCache *source,
const gchar *source_uid,
CamelImapMessageCache *dest,
- const gchar *dest_uid,
- CamelException *ex)
+ const gchar *dest_uid)
{
GPtrArray *subparts;
CamelStream *stream;
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);
- g_object_unref (CAMEL_OBJECT (stream));
+ if ((stream = camel_imap_message_cache_get (source, source_uid, part, NULL))) {
+ camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream);
+ g_object_unref (stream);
}
}
}
* 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;
/* 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);
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);
+ CamelStream *data_stream);
void camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache,
const gchar *uid,
const gchar *part_spec,
- CamelDataWrapper *wrapper,
- CamelException *ex);
+ CamelDataWrapper *wrapper);
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);
void camel_imap_message_cache_copy (CamelImapMessageCache *source,
const gchar *source_uid,
CamelImapMessageCache *dest,
- const gchar *dest_uid,
- CamelException *ex);
+ const gchar *dest_uid);
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);
header.lastuid = mr->lastuid;
header.validity = mr->validity;
- if (camel_stream_write(stream, (gchar *)&header, sizeof(header)) != sizeof(header)
- || camel_stream_write(stream, mr->matches->data, mr->matches->len*sizeof(guint32)) != mr->matches->len*sizeof(guint32)
- || camel_seekable_stream_seek((CamelSeekableStream *)stream, 0, CAMEL_STREAM_SET) == -1
- || camel_stream_write(stream, (gchar *)&mark, sizeof(mark)) != sizeof(mark)) {
+ if (camel_stream_write(stream, (gchar *)&header, sizeof(header), NULL) != sizeof(header)
+ || camel_stream_write(stream, mr->matches->data, mr->matches->len*sizeof(guint32), NULL) != mr->matches->len*sizeof(guint32)
+ || camel_seekable_stream_seek((CamelSeekableStream *)stream, 0, CAMEL_STREAM_SET, NULL) == -1
+ || camel_stream_write(stream, (gchar *)&mark, sizeof(mark), NULL) != sizeof(mark)) {
d(printf(" saving failed, removing cache entry\n"));
camel_data_cache_remove(is->cache, "search/body-contains", mr->hash, NULL);
ret = -1;
should be sufficient to key it */
/* This check should also handle endianness changes, we just throw away
the data (its only a cache) */
- if (camel_stream_read(stream, (gchar *)&header, sizeof(header)) == sizeof(header)
+ if (camel_stream_read(stream, (gchar *)&header, sizeof(header), NULL) == sizeof(header)
&& header.validity == is->validity
&& header.mark == MATCH_MARK
&& header.termcount == 0) {
d(printf(" found %d matches\n", header.matchcount));
g_array_set_size(mr->matches, header.matchcount);
- camel_stream_read(stream, mr->matches->data, sizeof(guint32)*header.matchcount);
+ camel_stream_read(stream, mr->matches->data, sizeof(guint32)*header.matchcount, NULL);
} else {
d(printf(" file format invalid/validity changed\n"));
memset(&header, 0, sizeof(header));
static gboolean construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex);
+ GError **error);
static gchar *imap_get_name (CamelService *service, gboolean brief);
-static gboolean 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 gboolean delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
-static gboolean 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_is_subscribed (CamelStore *store, const gchar *folder_name);
static gboolean subscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex);
+ GError **error);
static gboolean unsubscribe_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex);
+ GError **error);
-static gboolean 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 gboolean 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);
G_DEFINE_TYPE (CamelImapStore, camel_imap_store, CAMEL_TYPE_OFFLINE_STORE)
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);
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_imap_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ 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 FALSE;
}
static gboolean
-imap_get_capability (CamelService *service, CamelException *ex)
+imap_get_capability (CamelService *service, GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelImapResponse *response;
/* 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;
#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;
CamelSession *session;
else
tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
#else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, _("SSL unavailable"));
g_free (socks_host);
}
- if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_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));
+ if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai, error) == -1) {
+ g_prefix_error (
+ error, _("Could not connect to %s: "),
+ service->url->host);
g_object_unref (tcp_stream);
return FALSE;
}
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;
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;
clean_quit = FALSE;
if (!(store->capabilities & IMAP_CAPABILITY_STARTTLS)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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);
/* 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("SSL is not available in this build"));
goto exception;
/* 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;
if (store->capabilities & IMAP_CAPABILITY_LOGINDISABLED ) {
clean_quit = TRUE;
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("Unknown error"));
goto 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);
}
/* 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;
if (ret == -1) {
if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
_("Connection cancelled"));
else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not connect with command \"%s\": %s"),
full_cmd, g_strerror (errno));
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;
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;
};
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"))) {
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, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ 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);
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;
gboolean connected;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("You must be working online to complete this operation"));
return NULL;
}
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
connected = store->istream != NULL && store->connected;
if (!connected)
- connected = connect_to_server_wrapper (service, ex);
+ connected = connect_to_server_wrapper (service, error);
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
if (!connected)
return NULL;
static gboolean
imap_folder_effectively_unsubscribed (CamelImapStore *imap_store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelFolderInfo *fi;
CamelStoreInfo *si;
}
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;
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);
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, NULL, "LIST \"\" %F",
full_name);
if (response) {
return TRUE;
}
-#if 0
-/* This is a little 'hack' to avoid the deadlock conditions that would otherwise
- ensue when calling camel_folder_refresh_info from inside a lock */
-/* NB: on second thougts this is probably not entirely safe, but it'll do for now */
-/* No, its definetly not safe. So its been changed to copy the folders first */
-/* the alternative is to:
- make the camel folder->lock recursive (which should probably be done)
- 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)
-{
- GPtrArray *folders;
- gint i;
-
- folders = camel_object_bag_list(CAMEL_STORE (store)->folders);
-
- for (i = 0; i <folders->len; i++) {
- CamelFolder *folder = folders->pdata[i];
-
- /* NB: we can have vtrash folders also in our store ... bit hacky */
- if (!CAMEL_IS_IMAP_FOLDER(folder)) {
- g_object_unref (folder);
- continue;
- }
-
- CAMEL_IMAP_FOLDER (folder)->need_rescan = TRUE;
- if (!camel_exception_is_set(ex))
- CAMEL_FOLDER_GET_CLASS (folder)->refresh_info (folder, ex);
-
- if (camel_exception_is_set (ex) &&
- imap_check_folder_still_extant (store, folder->full_name, ex) == FALSE) {
- gchar *namedup;
-
- /* the folder was deleted (may happen when we come back online
- * after being offline */
-
- namedup = g_strdup (folder->full_name);
- g_object_unref (folder);
- imap_folder_effectively_unsubscribed (store, namedup, ex);
- imap_forget_folder (store, namedup, ex);
- g_free (namedup);
- } else
- g_object_unref (folder);
- }
-
- g_ptr_array_free (folders, TRUE);
-}
-#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;
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);
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,
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ 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 */
prompt_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
service->url->passwd = camel_session_get_password (
session, service, auth_domain, full_prompt,
- "password", prompt_flags, ex);
+ "password", prompt_flags, error);
g_free (base_prompt);
g_free (full_prompt);
errbuf = NULL;
if (!service->url->passwd) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
_("You did not enter a password."));
return FALSE;
}
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);
authenticated = TRUE;
}
}
- 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 (local_error != NULL) {
+ if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
+ 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);
}
}
}
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_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_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_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
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;
/* 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 {
* 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);
}
CamelStoreInfo *si;
/* look in all namespaces */
- if (!get_folders_sync (store, NULL, 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", &local_error);
}
store->refresh_stamp = time(NULL);
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_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);
}
if (store->istream) {
- camel_stream_close(store->istream);
+ camel_stream_close(store->istream, NULL);
g_object_unref (store->istream);
store->istream = NULL;
}
if (store->ostream) {
- camel_stream_close(store->ostream);
+ camel_stream_close(store->ostream, NULL);
g_object_unref (store->ostream);
store->ostream = NULL;
}
static gboolean
imap_noop (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *imap_store = (CamelImapStore *) store;
CamelImapResponse *response;
camel_service_lock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_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 */
- success = 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
}
static CamelFolder *
-imap_get_trash(CamelStore *store, CamelException *ex)
+imap_get_trash(CamelStore *store, GError **error)
{
CamelFolder *folder = NULL;
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
if (imap_store->real_trash_path && *imap_store->real_trash_path) {
- CamelException ex2;
-
- camel_exception_init (&ex2);
-
- folder = camel_store_get_folder (store, imap_store->real_trash_path, 0, &ex2);
+ folder = camel_store_get_folder (store, imap_store->real_trash_path, 0, NULL);
if (!folder) {
/* cannot find configured folder, just report on console and unset in a store structure to not try again */
- g_print ("%s: Cannot open '%s': %s", G_STRFUNC, imap_store->real_trash_path, camel_exception_get_description (&ex2) ? camel_exception_get_description (&ex2) : "Unknown error.");
g_free (imap_store->real_trash_path);
imap_store->real_trash_path = NULL;
}
-
- camel_exception_clear (&ex2);
}
if (folder)
return folder;
- folder = CAMEL_STORE_CLASS(camel_imap_store_parent_class)->get_trash(store, ex);
+ folder = CAMEL_STORE_CLASS(camel_imap_store_parent_class)->get_trash(store, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
}
static CamelFolder *
-imap_get_junk(CamelStore *store, CamelException *ex)
+imap_get_junk(CamelStore *store, GError **error)
{
CamelFolder *folder = NULL;
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
if (imap_store->real_junk_path && *imap_store->real_junk_path) {
- CamelException ex2;
-
- camel_exception_init (&ex2);
-
- folder = camel_store_get_folder (store, imap_store->real_junk_path, 0, &ex2);
+ folder = camel_store_get_folder (store, imap_store->real_junk_path, 0, NULL);
if (!folder) {
/* cannot find configured folder, just report on console and unset in a store structure to not try again */
- g_print ("%s: Cannot open '%s': %s", G_STRFUNC, imap_store->real_junk_path, camel_exception_get_description (&ex2) ? camel_exception_get_description (&ex2) : "Unknown error.");
g_free (imap_store->real_junk_path);
imap_store->real_junk_path = NULL;
}
-
- camel_exception_clear (&ex2);
}
if (folder)
return folder;
- folder = CAMEL_STORE_CLASS(camel_imap_store_parent_class)->get_junk(store, ex);
+ folder = CAMEL_STORE_CLASS(camel_imap_store_parent_class)->get_junk(store, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
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;
}
}
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, &local_error);
if (new_folder)
return new_folder;
+ g_clear_error (&local_error);
+
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ 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_lock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_imap_store_connected(imap_store, ex)) {
+ if (!camel_imap_store_connected(imap_store, error)) {
camel_service_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return NULL;
}
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, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
camel_service_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_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_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("No such folder %s"), folder_name);
return NULL;
}
if (*c != '\0') {
camel_service_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
+ 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;
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_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
g_free (parent_name);
g_free (parent_real);
if (need_convert) {
struct imap_status_item *items, *item;
guint32 messages = 0;
- CamelException lex;
gchar *name;
item = items = get_folder_status (imap_store, parent_name, "MESSAGES");
imap_status_item_free (items);
if (messages > 0) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_STATE,
_("The parent folder is not allowed to contain subfolders"));
camel_service_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
g_free (parent_name);
}
/* delete the old parent and recreate it */
- camel_exception_init (&lex);
- delete_folder (store, parent_name, &lex);
- if (camel_exception_is_set (&lex)) {
+ if (!delete_folder (store, parent_name, error)) {
camel_service_unlock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_xfer (ex, &lex);
g_free (parent_name);
g_free (parent_real);
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);
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);
return NULL;
}
} else if (flags & CAMEL_STORE_FOLDER_EXCL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot create folder '%s': folder exists."),
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);
if (new_folder) {
imap_store->current_folder = g_object_ref (new_folder);
- if (!camel_imap_folder_selected (new_folder, response, ex)) {
+ if (!camel_imap_folder_selected (new_folder, response, error)) {
g_object_unref (imap_store->current_folder);
imap_store->current_folder = NULL;
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;
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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("No such folder %s"), folder_name);
}
static gboolean
delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
camel_service_lock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_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");
+ response = camel_imap_command (imap_store, NULL, error, "SELECT INBOX");
if (!response) {
success = FALSE;
goto fail;
/* 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, NULL);
} else
success = FALSE;
rename_folder (CamelStore *store,
const gchar *old_name,
const gchar *new_name_in,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
camel_service_lock (CAMEL_SERVICE (imap_store), CAMEL_SERVICE_REC_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");
+ response = camel_imap_command (imap_store, NULL, error, "SELECT INBOX");
if (!response) {
success = FALSE;
goto fail;
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);
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;
const gchar *c;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("You must be working online to complete this operation"));
return NULL;
}
c++;
if (*c != '\0') {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
+ 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;
/* 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);
imap_status_item_free (items);
if (messages > 0) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
+ 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 */
- if (!delete_folder (store, parent_name, 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);
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;
}
static gboolean
-get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, CamelException *ex)
+get_folders_sync (CamelImapStore *imap_store, const gchar *ppattern, GError **error)
{
CamelImapResponse *response;
CamelFolderInfo *fi, *hfi;
}
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) {
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);
}
CamelSessionThreadMsg msg;
CamelStore *store;
- CamelException ex;
+ GError *error;
};
static void
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_imap_store_connected (store, &m->ex))
+ if (!camel_imap_store_connected (store, &m->error))
goto done;
if (store->users_namespace && store->users_namespace[0]) {
- if (!get_folders_sync (store, "INBOX", &m->ex))
+ if (!get_folders_sync (store, "INBOX", &m->error))
goto done;
} else {
- get_folders_sync (store, "*", &m->ex);
+ get_folders_sync (store, "*", NULL);
}
/* look in all namespaces */
- get_folders_sync (store, NULL, &m->ex);
+ get_folders_sync (store, NULL, &m->error);
camel_store_summary_save ((CamelStoreSummary *)store->summary);
done:
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
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 = {
get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelFolderInfo *tree = NULL;
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;
}
m = camel_session_thread_msg_new(((CamelService *)store)->session, &refresh_ops, sizeof(*m));
m->store = g_object_ref (store);
- camel_exception_init(&m->ex);
+ m->error = NULL;
camel_session_thread_queue(((CamelService *)store)->session, &m->msg, 0);
}
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_imap_store_connected((CamelImapStore *)store, ex))
+ if (!camel_imap_store_connected((CamelImapStore *)store, error))
goto fail;
if (top[0] == 0) {
}
ns = camel_imap_store_summary_get_main_namespace (imap_store->summary);
- if (!get_folders_sync (imap_store, pattern, 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_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
}
- tree = get_folder_info_offline(store, top, flags, ex);
+ tree = get_folder_info_offline(store, top, flags, error);
return tree;
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;
static gboolean
subscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_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) {
success = FALSE;
static gboolean
unsubscribe_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_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) {
success = FALSE;
camel_imap_response_free (imap_store, response);
- success = imap_folder_effectively_unsubscribed (imap_store, folder_name, ex);
+ success = imap_folder_effectively_unsubscribed (imap_store, folder_name, error);
done:
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
/* 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)
{
/* This looks stupid ... because it is.
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, NULL)
&& 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"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
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};
* 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);
ba = g_byte_array_new ();
- while ((nread = camel_stream_buffer_gets (stream, linebuf, sizeof (linebuf))) > 0) {
+ while ((nread = camel_stream_buffer_gets (stream, linebuf, sizeof (linebuf), error)) > 0) {
g_byte_array_append (ba, (const guint8 *) linebuf, nread);
if (linebuf[nread - 1] == '\n')
break;
}
if (nread <= 0) {
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Operation cancelled"));
- else if (errno == 0)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ if (nread == 0)
+ 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_prefix_error (
+ error, _("Server unexpectedly disconnected: "));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
g_byte_array_free (ba, TRUE);
static gboolean
imap_can_refresh_folder (CamelStore *store,
CamelFolderInfo *info,
- CamelException *ex)
+ GError **error)
{
gboolean res;
+ GError *local_error = NULL;
- res = CAMEL_STORE_CLASS(camel_imap_store_parent_class)->can_refresh_folder (store, info, ex) ||
+ res = CAMEL_STORE_CLASS(camel_imap_store_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);
}
}
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
+
return res;
}
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
static CamelMessageContentInfo *content_info_migrate (CamelFolderSummary *s, FILE *in);
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);
{
CamelStore *parent_store;
CamelFolderSummary *summary;
- CamelException ex;
- camel_exception_init (&ex);
parent_store = camel_folder_get_parent_store (folder);
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, NULL) == -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_ptr_array_sort (summary->uids, (GCompareFunc) uid_compare);
}
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 (camel_imap_summary_parent_class)->summary_header_to_db (s, ex);
+ fir = CAMEL_FOLDER_SUMMARY_CLASS (camel_imap_summary_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);
static gssize
imap_wrapper_write_to_stream (CamelDataWrapper *data_wrapper,
- CamelStream *stream)
+ CamelStream *stream,
+ GError **error)
{
CamelImapWrapper *imap_wrapper = CAMEL_IMAP_WRAPPER (data_wrapper);
CAMEL_IMAP_WRAPPER_LOCK (imap_wrapper, lock);
if (data_wrapper->offline) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CamelStream *datastream;
datastream = camel_imap_folder_fetch_data (
imap_wrapper->folder, imap_wrapper->uid,
- imap_wrapper->part_spec, FALSE, &ex);
-
- camel_exception_clear (&ex);
+ imap_wrapper->part_spec, FALSE, NULL);
if (!datastream) {
CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
/* FIXME[disk-summary] what errno to use if no ENETUNREACH */
errno = EINVAL;
#endif
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
return -1;
}
CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
return CAMEL_DATA_WRAPPER_CLASS (camel_imap_wrapper_parent_class)->
- write_to_stream (data_wrapper, stream);
+ write_to_stream (data_wrapper, stream, error);
}
static void
-DG_LOG_DOMAIN=\"camel-imapx\"
libcamelimapx_la_SOURCES = \
- camel-imapx-exception.c \
camel-imapx-stream.c \
camel-imapx-utils.c \
camel-imapx-provider.c \
camel-imapx-server.c
noinst_HEADERS = \
- camel-imapx-exception.h \
camel-imapx-stream.h \
camel-imapx-store-summary.h \
camel-imapx-summary.h \
+++ /dev/null
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include <glib.h>
-
-#include "camel-imapx-exception.h"
-
-static GStaticPrivate handler_key = G_STATIC_PRIVATE_INIT;
-
-void camel_exception_setup(void)
-{
- /* No need for 'new' with GStaticPrivate */
- /* g_static_private_new (&handler_key); */
-}
-
-void
-camel_exception_try(struct _CamelExceptionEnv *env)
-{
- struct _CamelExceptionEnv *handler;
-
- handler = g_static_private_get (&handler_key);
- env->parent = handler;
- handler = env;
- env->ex = NULL;
-
- g_static_private_set (&handler_key, handler, NULL);
-}
-
-void
-camel_exception_throw_ex(CamelException *ex)
-{
- struct _CamelExceptionEnv *env;
-
- printf("throwing exception '%s'\n", ex->desc);
-
- env = g_static_private_get (&handler_key);
- if (env != NULL) {
- env->ex = ex;
- g_static_private_set (&handler_key, env->parent, NULL);
- longjmp(env->env, ex->id);
- } else {
- fprintf(stderr, "\nUncaught exception: %s\n", ex->desc);
- /* we just crash and burn, this is a code problem */
- /* we dont use g_assert_not_reached() since its not a noreturn function */
- abort();
- }
-}
-
-void
-camel_exception_throw(gint id, gchar *fmt, ...)
-{
- CamelException *ex;
- va_list ap;
-
- ex = camel_exception_new();
- ex->id = id;
- va_start(ap, fmt);
- ex->desc = g_strdup_vprintf(fmt, ap);
- va_end(ap);
-
- camel_exception_throw_ex(ex);
-}
-
-void
-camel_exception_drop(struct _CamelExceptionEnv *env)
-{
- g_static_private_set (&handler_key, env->parent, NULL);
-}
-
-void
-camel_exception_done(struct _CamelExceptionEnv *env)
-{
- g_static_private_set (&handler_key, env->parent, NULL);
- if (env->ex != NULL) {
- camel_exception_free(env->ex);
- }
-}
+++ /dev/null
-
-/* This implements 'real' exceptions that work a bit like c++/java exceptions */
-
-/* Still experimental code */
-
-#ifndef CAMEL_IMAPX_EXCEPTION_H
-#define CAMEL_IMAPX_EXCEPTION_H
-
-#include <setjmp.h>
-#include <camel/camel.h>
-
-struct _CamelExceptionEnv {
- struct _CamelExceptionEnv *parent;
- CamelException *ex;
- jmp_buf env;
-};
-
-#define CAMEL_TRY { struct _CamelExceptionEnv __env; camel_exception_try(&__env); if (setjmp(__env.env) == 0)
-#define CAMEL_IGNORE camel_exception_done(&__env); }
-#define CAMEL_CATCH(x) { CamelException *x; x=__env.ex; if (x != NULL)
-#define CAMEL_DONE } camel_exception_done(&__env); }
-#define CAMEL_DROP() camel_exception_drop(&__env)
-
-void camel_exception_setup(void);
-
-/* internal functions, use macro's above */
-void camel_exception_try(struct _CamelExceptionEnv *env);
-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(gint id, gchar *fmt, ...) __attribute__ ((noreturn));
-
-#endif
#include "camel-imapx-store.h"
#include "camel-imapx-folder.h"
#include "camel-imapx-summary.h"
-#include "camel-imapx-exception.h"
#include "camel-imapx-server.h"
#include <stdlib.h>
G_DEFINE_TYPE (CamelIMAPXFolder, camel_imapx_folder, CAMEL_TYPE_OFFLINE_FOLDER)
CamelFolder *
-camel_imapx_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *folder_name, CamelException *ex)
+camel_imapx_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *folder_name, GError **error)
{
CamelFolder *folder;
CamelIMAPXFolder *ifolder;
summary_file = g_strdup_printf ("%s/summary", folder_dir);
folder->summary = camel_imapx_summary_new(folder, summary_file);
if (!folder->summary) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create folder summary for %s"),
- short_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Could not create folder summary for %s"),
+ short_name);
return NULL;
}
- ifolder->cache = camel_data_cache_new (folder_dir, ex);
+ ifolder->cache = camel_data_cache_new (folder_dir, error);
if (!ifolder->cache) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create cache for %s"),
- short_name);
+ g_prefix_error (
+ error, _("Could not create cache for %s: "),
+ short_name);
return NULL;
}
}
static gboolean
-imapx_refresh_info (CamelFolder *folder, CamelException *ex)
+imapx_refresh_info (CamelFolder *folder, GError **error)
{
CamelStore *parent_store;
CamelIMAPXStore *istore;
CamelIMAPXServer *server;
+ gboolean success = FALSE;
parent_store = camel_folder_get_parent_store (folder);
istore = CAMEL_IMAPX_STORE (parent_store);
if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- camel_service_connect((CamelService *)istore, ex);
- server = camel_imapx_store_get_server(istore, ex);
- if (server) {
- camel_imapx_server_refresh_info(server, folder, ex);
+ if (!camel_service_connect((CamelService *)istore, error))
+ return FALSE;
+
+ server = camel_imapx_store_get_server(istore, error);
+ if (server != NULL) {
+ success = camel_imapx_server_refresh_info(server, folder, error);
g_object_unref(server);
}
- return !camel_exception_is_set (ex);
+ return success;
}
static gboolean
-imapx_expunge (CamelFolder *folder, CamelException *ex)
+imapx_expunge (CamelFolder *folder, GError **error)
{
CamelStore *parent_store;
CamelIMAPXStore *is;
if (CAMEL_OFFLINE_STORE (is)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- server = camel_imapx_store_get_server(is, ex);
+ server = camel_imapx_store_get_server(is, error);
if (server) {
- camel_imapx_server_expunge(server, folder, ex);
+ camel_imapx_server_expunge(server, folder, error);
g_object_unref(server);
+ return TRUE;
}
- return !camel_exception_is_set (ex);
+ return FALSE;
}
static gboolean
-imapx_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+imapx_sync (CamelFolder *folder, gboolean expunge, GError **error)
{
CamelStore *parent_store;
CamelIMAPXStore *is;
CamelIMAPXServer *server;
- CamelException eex = CAMEL_EXCEPTION_INITIALISER;
parent_store = camel_folder_get_parent_store (folder);
is = CAMEL_IMAPX_STORE (parent_store);
if (CAMEL_OFFLINE_STORE (is)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- if (!ex)
- ex = &eex;
-
- server = camel_imapx_store_get_server(is, ex);
+ server = camel_imapx_store_get_server(is, NULL);
if (server)
- camel_imapx_server_sync_changes (server, folder, ex);
+ camel_imapx_server_sync_changes (server, folder, NULL);
/* Sync twice - make sure deleted flags are written out,
then sync again incase expunge changed anything */
- camel_exception_clear(ex);
- if (server && expunge) {
- camel_imapx_server_expunge(server, folder, ex);
- camel_exception_clear(ex);
- }
+ if (server && expunge)
+ camel_imapx_server_expunge(server, folder, NULL);
if (server)
g_object_unref(server);
- return !camel_exception_is_set (ex);
+ return TRUE;
}
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 = NULL;
stream = camel_data_cache_get (ifolder->cache, path, uid, NULL);
if (!stream) {
if (offline_message) {
- camel_exception_setv(ex, 2, "Offline message vanished from disk: %s", uid);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ "Offline message vanished from disk: %s", uid);
return NULL;
}
if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return NULL;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (server) {
- stream = camel_imapx_server_get_message(server, folder, uid, ex);
+ stream = camel_imapx_server_get_message(server, folder, uid, error);
g_object_unref(server);
- } else {
- /* It should _always_ be set */
- if (!camel_exception_is_set (ex))
- camel_exception_setv(ex, 1, "not authenticated");
+ } else
return NULL;
- }
}
- if (!camel_exception_is_set (ex) && stream) {
+ if (stream != NULL) {
msg = camel_mime_message_new();
g_mutex_lock (ifolder->stream_lock);
- if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) == -1) {
+ if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream, error) == -1) {
g_object_unref (msg);
msg = NULL;
}
}
static gboolean
-imapx_sync_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+imapx_sync_message (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelStore *parent_store;
CamelIMAPXStore *istore;
CamelIMAPXServer *server;
+ gboolean success;
parent_store = camel_folder_get_parent_store (folder);
istore = CAMEL_IMAPX_STORE (parent_store);
if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- server = camel_imapx_store_get_server(istore, ex);
- if (server) {
- camel_imapx_server_sync_message (server, folder, uid, ex);
- g_object_unref(server);
- }
- return !camel_exception_is_set (ex);
+ server = camel_imapx_store_get_server(istore, error);
+ if (server == NULL)
+ return FALSE;
+
+ success = camel_imapx_server_sync_message (server, folder, uid, error);
+ g_object_unref(server);
+
+ return success;
}
static gboolean
imapx_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
CamelFolder *dest, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+ gboolean delete_originals, GError **error)
{
CamelStore *parent_store;
CamelIMAPXStore *istore;
CamelIMAPXServer *server;
+ gboolean success = FALSE;
parent_store = camel_folder_get_parent_store (source);
istore = CAMEL_IMAPX_STORE (parent_store);
if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (server) {
- camel_imapx_server_copy_message (server, source, dest, uids, delete_originals, ex);
+ success = camel_imapx_server_copy_message (server, source, dest, uids, delete_originals, error);
g_object_unref(server);
}
- imapx_refresh_info (dest, ex);
+ imapx_refresh_info (dest, NULL);
- return !camel_exception_is_set (ex);
+ return success;
}
static gboolean
-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)
{
CamelStore *parent_store;
CamelIMAPXStore *istore;
CamelIMAPXServer *server;
+ gboolean success = FALSE;
parent_store = camel_folder_get_parent_store (folder);
istore = CAMEL_IMAPX_STORE (parent_store);
if (appended_uid)
*appended_uid = NULL;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (server) {
- camel_imapx_server_append_message(server, folder, message, info, ex);
+ success = camel_imapx_server_append_message(server, folder, message, info, error);
g_object_unref(server);
}
- return !camel_exception_is_set (ex);
+ return success;
}
gchar *
-imapx_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+imapx_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
- return camel_data_cache_get_filename (ifolder->cache, "cache", uid, NULL);
+ return camel_data_cache_get_filename (ifolder->cache, "cache", uid, error);
}
/* Algorithm for selecting a folder:
}
static GPtrArray *
-imapx_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+imapx_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error)
{
CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER(folder);
GPtrArray *matches;
g_mutex_lock (ifolder->search_lock);
camel_folder_search_set_folder(ifolder->search, folder);
- matches = camel_folder_search_search(ifolder->search, expression, uids, ex);
+ matches = camel_folder_search_search(ifolder->search, expression, uids, error);
g_mutex_unlock (ifolder->search_lock);
}
static guint32
-imapx_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+imapx_count_by_expression (CamelFolder *folder, const gchar *expression, GError **error)
{
CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER(folder);
guint32 matches;
g_mutex_lock (ifolder->search_lock);
camel_folder_search_set_folder (ifolder->search, folder);
- matches = camel_folder_search_count (ifolder->search, expression, ex);
+ matches = camel_folder_search_count (ifolder->search, expression, error);
g_mutex_unlock (ifolder->search_lock);
}
static GPtrArray *
-imapx_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+imapx_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error)
{
CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder);
GPtrArray *matches;
g_mutex_lock (ifolder->search_lock);
camel_folder_search_set_folder (ifolder->search, folder);
- matches = camel_folder_search_search(ifolder->search, expression, NULL, ex);
+ matches = camel_folder_search_search(ifolder->search, expression, NULL, error);
g_mutex_unlock (ifolder->search_lock);
CamelFolder * camel_imapx_folder_new (CamelStore *parent,
const gchar *path,
const gchar *raw,
- CamelException *ex);
+ GError **error);
gchar * imapx_get_filename (CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
+ GError **error);
G_END_DECLS
void camel_imapx_module_init(void);
-extern void camel_exception_setup(void);
extern void imapx_utils_init(void);
void
imapx_provider.translation_domain = GETTEXT_PACKAGE;
/* TEMPORARY */
- camel_exception_setup();
imapx_utils_init();
camel_provider_register(&imapx_provider);
#endif
#include "camel-imapx-utils.h"
-#include "camel-imapx-exception.h"
#include "camel-imapx-stream.h"
#include "camel-imapx-server.h"
#include "camel-imapx-folder.h"
#define c(x) camel_imapx_debug(command, x)
#define e(x) camel_imapx_debug(extra, x)
-#define CFS_CLASS(x) ((CamelFolderSummaryClass *)((CamelObject *)x)->klass)
-
#define CIF(x) ((CamelIMAPXFolder *)x)
#define QUEUE_LOCK(x) (g_static_rec_mutex_lock(&(x)->queue_lock))
void imapx_uidset_init(struct _uidset_state *ss, gint total, gint limit);
gint imapx_uidset_done(struct _uidset_state *ss, struct _CamelIMAPXCommand *ic);
gint imapx_uidset_add(struct _uidset_state *ss, struct _CamelIMAPXCommand *ic, const gchar *uid);
-static gboolean imapx_command_idle_stop (CamelIMAPXServer *is, CamelException *ex);
-static gint imapx_continuation(CamelIMAPXServer *imap, CamelException *ex, gboolean litplus);
+static gboolean imapx_command_idle_stop (CamelIMAPXServer *is, GError **error);
+static gint imapx_continuation(CamelIMAPXServer *imap, gboolean litplus, GError **error);
static gboolean imapx_disconnect (CamelIMAPXServer *is);
static gint imapx_uid_cmp(gconstpointer ap, gconstpointer bp, gpointer data);
/* If exception is set, it means we were not able to parse above status, it might be
because user cancelled the operation or io error */
- CamelException *ex;
+ GError *error;
guint32 tag;
struct _CamelIMAPXJob {
CamelMsg msg;
- CamelException *ex;
+ GError *error;
void (*start)(CamelIMAPXServer *is, struct _CamelIMAPXJob *job);
};
static void imapx_job_done (CamelIMAPXServer *is, CamelIMAPXJob *job);
-static void imapx_run_job (CamelIMAPXServer *is, CamelIMAPXJob *job);
+static gboolean imapx_run_job (CamelIMAPXServer *is, CamelIMAPXJob *job, GError **error);
static void imapx_job_fetch_new_messages_start (CamelIMAPXServer *is, CamelIMAPXJob *job);
static void imapx_command_copy_messages_step_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic);
static gint imapx_refresh_info_uid_cmp(gconstpointer ap, gconstpointer bp);
static gint imapx_uids_array_cmp (gconstpointer ap, gconstpointer bp);
-static void imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, gint pri, CamelException *ex);
+static gboolean imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, gint pri, GError **error);
enum _idle_state {
IMAPX_IDLE_OFF,
static void imapx_start_idle (CamelIMAPXServer *is);
static void imapx_exit_idle (CamelIMAPXServer *is);
static void imapx_init_idle (CamelIMAPXServer *is);
-static gboolean imapx_stop_idle (CamelIMAPXServer *is, CamelException *ex);
-static void camel_imapx_server_idle (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex);
+static gboolean imapx_stop_idle (CamelIMAPXServer *is, GError **error);
+static gboolean camel_imapx_server_idle (CamelIMAPXServer *is, CamelFolder *folder, GError **error);
enum {
USE_SSL_NEVER,
#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, gboolean force, CamelException *ex);
+static gboolean imapx_select(CamelIMAPXServer *is, CamelFolder *folder, gboolean force, GError **error);
G_DEFINE_TYPE (CamelIMAPXServer, camel_imapx_server, CAMEL_TYPE_OBJECT)
/* TODO: seekable streams we could just seek to the end and back */
null = (CamelStreamNull *)camel_stream_null_new();
if ( (type & CAMEL_IMAPX_COMMAND_MASK) == CAMEL_IMAPX_COMMAND_DATAWRAPPER) {
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)ob, (CamelStream *)null);
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)ob, (CamelStream *)null, NULL);
} else {
- camel_stream_reset((CamelStream *)ob);
- camel_stream_write_to_stream((CamelStream *)ob, (CamelStream *)null);
- camel_stream_reset((CamelStream *)ob);
+ camel_stream_reset((CamelStream *)ob, NULL);
+ camel_stream_write_to_stream((CamelStream *)ob, (CamelStream *)null, NULL);
+ camel_stream_reset((CamelStream *)ob, NULL);
}
type |= CAMEL_IMAPX_COMMAND_LITERAL_PLUS;
g_object_ref (ob);
gchar *path = o;
struct stat st;
- if (stat(path, &st) == 0) {
+ if (g_stat(path, &st) == 0) {
o = g_strdup(o);
ob_size = st.st_size;
} else
memcpy(cp->data, byte_array->data, cp->data_size);
cp->data[cp->data_size] = 0;
- camel_stream_reset((CamelStream *)ic->mem);
+ camel_stream_reset((CamelStream *)ic->mem, NULL);
/* FIXME: hackish? */
g_byte_array_set_size(byte_array, 0);
CamelStore *parent_store;
gchar *fname = NULL, *encoded = NULL;
const gchar *full_name;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
c(printf("adding command, fmt = '%s'\n", fmt));
switch (c) {
case '%':
if (*p == '%') {
- camel_stream_write((CamelStream *)ic->mem, ps, p-ps);
+ camel_stream_write((CamelStream *)ic->mem, ps, p-ps, NULL);
p++;
ps = p;
} else {
- camel_stream_write((CamelStream *)ic->mem, ps, p-ps-1);
+ camel_stream_write((CamelStream *)ic->mem, ps, p-ps-1, NULL);
start = p-1;
width = 0;
left = FALSE;
break;
case 't': /* token */
s = va_arg(ap, gchar *);
- camel_stream_write((CamelStream *)ic->mem, s, strlen(s));
+ camel_stream_write((CamelStream *)ic->mem, s, strlen(s), NULL);
break;
case 's': /* simple string */
s = va_arg(ap, gchar *);
guchar mask = imapx_is_mask(s);
if (mask & IMAPX_TYPE_ATOM_CHAR)
- camel_stream_write((CamelStream *)ic->mem, s, strlen(s));
+ camel_stream_write((CamelStream *)ic->mem, s, strlen(s), NULL);
else if (mask & IMAPX_TYPE_TEXT_CHAR) {
- camel_stream_write((CamelStream *)ic->mem, "\"", 1);
+ camel_stream_write((CamelStream *)ic->mem, "\"", 1, NULL);
while (*s) {
gchar *start = s;
while (*s && imapx_is_quoted_char(*s))
s++;
- camel_stream_write((CamelStream *)ic->mem, start, s-start);
+ camel_stream_write((CamelStream *)ic->mem, start, s-start, NULL);
if (*s) {
- camel_stream_write((CamelStream *)ic->mem, "\\", 1);
- camel_stream_write((CamelStream *)ic->mem, s, 1);
+ camel_stream_write((CamelStream *)ic->mem, "\\", 1, NULL);
+ camel_stream_write((CamelStream *)ic->mem, s, 1, NULL);
s++;
}
}
- camel_stream_write((CamelStream *)ic->mem, "\"", 1);
+ camel_stream_write((CamelStream *)ic->mem, "\"", 1, NULL);
} else {
imapx_command_add_part(ic, CAMEL_IMAPX_COMMAND_STRING, s);
}
} else {
- camel_stream_write((CamelStream *)ic->mem, "\"\"", 2);
+ camel_stream_write((CamelStream *)ic->mem, "\"\"", 2, NULL);
}
if (encoded) {
g_free(encoded);
s = encoded;
goto output_string;
} else
- camel_stream_write((CamelStream *)ic->mem, "\"\"", 2);
+ camel_stream_write((CamelStream *)ic->mem, "\"\"", 2, NULL);
break;
case 'F': /* IMAP flags set */
f = va_arg(ap, guint32);
F = va_arg(ap, CamelFlag *);
- imapx_write_flags((CamelStream *)ic->mem, f, F, &ex);
+ imapx_write_flags((CamelStream *)ic->mem, f, F, NULL);
break;
case 'c':
d = va_arg(ap, gint);
ch = d;
- camel_stream_write((CamelStream *)ic->mem, &ch, 1);
+ camel_stream_write((CamelStream *)ic->mem, &ch, 1, NULL);
break;
case 'd': /* int/unsigned */
case 'u':
c = *p;
if (c) {
g_assert(c == '\\');
- camel_stream_write((CamelStream *)ic->mem, ps, p-ps);
+ camel_stream_write((CamelStream *)ic->mem, ps, p-ps, NULL);
p++;
ps = p;
}
}
}
- camel_stream_write((CamelStream *)ic->mem, ps, p-ps-1);
+ camel_stream_write((CamelStream *)ic->mem, ps, p-ps-1, NULL);
}
CamelIMAPXCommand *
ic->select = select;
ic->is = is;
camel_dlist_init(&ic->parts);
- ic->ex = camel_exception_new ();
if (fmt && fmt[0]) {
va_start(ap, fmt);
g_free(cp);
}
- camel_exception_free (ic->ex);
+ /* Do NOT try to free the GError. If set it should have been
+ * propagated to the CamelIMAPXJob, so it's either NULL or the
+ * CamelIMAPXJob owns it now. */
+
g_free(ic);
}
c(printf("Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data));
if (!imap->stream || camel_stream_printf((CamelStream *)imap->stream, "%c%05u %s\r\n", imap->tagprefix, ic->tag, cp->data) == -1) {
- camel_exception_set (ic->ex, 1, "Failed to issue the command");
+ g_set_error (
+ &ic->error, CAMEL_IMAPX_ERROR, 1,
+ "Failed to issue the command");
err:
g_static_rec_mutex_unlock (&imap->ostream_lock);
while (imap->literal == ic &&
ic->current->type & CAMEL_IMAPX_COMMAND_LITERAL_PLUS) {
/* Sent LITERAL+ continuation immediately */
- imapx_continuation(imap, ic->ex, TRUE);
- if (camel_exception_is_set(ic->ex))
+ if (!imapx_continuation(imap, TRUE, &ic->error))
goto err;
}
must have QUEUE lock */
static void
-imapx_command_start_next(CamelIMAPXServer *is, CamelException *ex)
+imapx_command_start_next(CamelIMAPXServer *is, GError **error)
{
CamelIMAPXCommand *ic, *nc;
gint count = 0;
/* if imapx_stop_idle() returns FALSE, it was only
pending and we can go ahead and send a new command
immediately. If it returns TRUE, we must wait. */
- if (imapx_stop_idle (is, ex)) {
+ if (imapx_stop_idle (is, error)) {
c(printf ("waiting for idle to stop \n"));
return;
}
if (ic->select) {
c(printf("Selecting folder '%s' for command '%s'(%p)\n",
camel_folder_get_full_name(ic->select), ic->name, ic));
- imapx_select(is, ic->select, FALSE, ex);
+ imapx_select(is, ic->select, FALSE, error);
} else {
pri = ic->pri;
nc = ic->next;
if (is->state == IMAPX_SHUTDOWN) {
c(printf("refuse to queue job on disconnected server\n"));
- camel_exception_set(ic->ex, 1, "Server disconnected");
+ g_set_error (
+ &ic->error, CAMEL_IMAPX_ERROR, 1,
+ "Server disconnected");
QUEUE_UNLOCK(is);
if (ic->complete)
ic->complete(is, ic);
/* 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;
e(printf("got untagged response\n"));
id = 0;
- tok = camel_imapx_stream_token(imap->stream, &token, &len, ex);
- if (camel_exception_is_set (ex))
+ tok = camel_imapx_stream_token(imap->stream, &token, &len, error);
+ if (tok < 0)
return -1;
if (tok == IMAPX_TOK_INT) {
id = strtoul((gchar *) token, NULL, 10);
- tok = camel_imapx_stream_token(imap->stream, &token, &len, ex);
+ tok = camel_imapx_stream_token(imap->stream, &token, &len, error);
+ if (tok < 0)
+ return -1;
}
if (tok == '\n') {
- camel_exception_set (ex, 1, "truncated server response");
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "truncated server response");
return -1;
}
case IMAPX_CAPABILITY:
if (imap->cinfo)
imapx_free_capability(imap->cinfo);
- imap->cinfo = imapx_parse_capability(imap->stream, ex);
+ imap->cinfo = imapx_parse_capability(imap->stream, error);
+ if (imap->cinfo == NULL)
+ return -1;
c(printf("got capability flags %08x\n", imap->cinfo->capa));
return 0;
case IMAPX_EXPUNGE: {
guchar *token;
gint tok;
- tok = camel_imapx_stream_token (imap->stream, &token, &len, ex);
- if (camel_exception_is_set(ex))
+ tok = camel_imapx_stream_token (imap->stream, &token, &len, error);
+ if (tok < 0)
return -1;
if (tok == '(') {
unsolicited = FALSE;
while (tok != ')') {
/* We expect this to be 'EARLIER' */
- tok = camel_imapx_stream_token(imap->stream, &token, &len, ex);
- if (camel_exception_is_set(ex))
+ tok = camel_imapx_stream_token(imap->stream, &token, &len, error);
+ if (tok < 0)
return -1;
}
} else
camel_imapx_stream_ungettoken(imap->stream, tok, token, len);
- uids = imapx_parse_uids(imap->stream, ex);
- if (camel_exception_is_set(ex))
+ uids = imapx_parse_uids(imap->stream, error);
+ if (uids == NULL)
return -1;
for (i = 0; i < uids->len; i++) {
gchar *uid = g_strdup_printf("%u", GPOINTER_TO_UINT(g_ptr_array_index (uids, i)));
case IMAPX_NAMESPACE: {
CamelIMAPXNamespaceList *nsl = NULL;
- nsl = imapx_parse_namespace_list (imap->stream, ex);
+ nsl = imapx_parse_namespace_list (imap->stream, error);
if (nsl != NULL) {
CamelIMAPXStore *imapx_store = (CamelIMAPXStore *) imap->store;
CamelIMAPXStoreNamespace *ns;
if (imapx_idle_supported (imap) && imapx_in_idle (imap)) {
if (camel_folder_summary_count (imap->select_folder->summary) < id)
- imapx_stop_idle (imap, ex);
+ imapx_stop_idle (imap, error);
}
break;
case IMAPX_FLAGS: {
guint32 flags;
- imapx_parse_flags(imap->stream, &flags, NULL, ex);
+ imapx_parse_flags(imap->stream, &flags, NULL, error);
c(printf("flags: %08x\n", flags));
break;
case IMAPX_FETCH: {
struct _fetch_info *finfo;
- finfo = imapx_parse_fetch(imap->stream, ex);
- if (camel_exception_is_set (ex)) {
+ finfo = imapx_parse_fetch(imap->stream, error);
+ if (finfo == NULL) {
imapx_free_fetch(finfo);
return -1;
}
/* This must've been a get-message request, fill out the body stream,
in the right spot */
- if (job && !camel_exception_is_set (job->ex)) {
+ if (job && job->error == NULL) {
if (job->u.get_message.use_multi_fetch) {
job->u.get_message.body_offset = finfo->offset;
- camel_seekable_stream_seek((CamelSeekableStream *)job->u.get_message.stream, finfo->offset, CAMEL_STREAM_SET);
+ camel_seekable_stream_seek((CamelSeekableStream *)job->u.get_message.stream, finfo->offset, CAMEL_STREAM_SET, NULL);
}
- job->u.get_message.body_len = camel_stream_write_to_stream(finfo->body, job->u.get_message.stream);
+ job->u.get_message.body_len = camel_stream_write_to_stream(finfo->body, job->u.get_message.stream, &job->error);
if (job->u.get_message.body_len == -1)
- camel_exception_setv(job->ex, 1, "error writing to cache stream: %s\n", g_strerror(errno));
+ g_prefix_error (
+ &job->error,
+ _("Error writing to cache stream: "));
}
}
/* Do we want to save these headers for later too? Do we care? */
mp = camel_mime_parser_new();
- camel_mime_parser_init_with_stream(mp, finfo->header);
+ camel_mime_parser_init_with_stream(mp, finfo->header, NULL);
mi = camel_folder_summary_info_new_from_parser(job->folder->summary, mp);
g_object_unref (mp);
case IMAPX_LSUB:
lsub = TRUE;
case IMAPX_LIST: {
- struct _list_info *linfo = imapx_parse_list(imap->stream, ex);
+ struct _list_info *linfo = imapx_parse_list(imap->stream, error);
CamelIMAPXJob *job = imapx_match_active_job(imap, IMAPX_JOB_LIST, linfo->name);
// TODO: we want to make sure the names match?
imap->recent = id;
break;
case IMAPX_STATUS: {
- struct _state_info *sinfo = imapx_parse_status_info (imap->stream, ex);
+ struct _state_info *sinfo = imapx_parse_status_info (imap->stream, error);
if (sinfo) {
CamelIMAPXStoreSummary *s = ((CamelIMAPXStore *)imap->store)->summary;
CamelIMAPXStoreNamespace *ns;
path_name = camel_imapx_store_summary_full_to_path(s, sinfo->name, ns->sep);
c(printf("Got folder path '%s' for full '%s'\n", path_name, sinfo->name));
if (path_name) {
- ifolder = (void *)camel_store_get_folder(imap->store, path_name, 0, ex);
+ ifolder = (void *)camel_store_get_folder(imap->store, path_name, 0, error);
g_free (path_name);
}
}
case IMAPX_BYE: {
guchar *token;
- camel_imapx_stream_text (imap->stream, &token, ex);
- if (!camel_exception_is_set(ex)) {
+ if (!camel_imapx_stream_text (imap->stream, &token, NULL)) {
c(printf("BYE: %s\n", token));
- camel_exception_setv(ex, 1, "IMAP server said BYE: %s", token);
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "IMAP server said BYE: %s", token);
}
imap->state = IMAPX_SHUTDOWN;
return -1;
/* TODO: validate which ones of these can happen as unsolicited responses */
/* TODO: handle bye/preauth differently */
camel_imapx_stream_ungettoken(imap->stream, tok, token, len);
- sinfo = imapx_parse_status(imap->stream, ex);
- if (camel_exception_is_set(ex))
+ sinfo = imapx_parse_status(imap->stream, error);
+ if (sinfo == NULL)
return -1;
switch (sinfo->condition) {
case IMAPX_CLOSED:
c(printf("unknown token: %s\n", token));
}
- return camel_imapx_stream_skip(imap->stream, ex);
+ return camel_imapx_stream_skip(imap->stream, error);
}
/* handle any continuation requests
either data continuations, or auth continuation */
static gint
-imapx_continuation(CamelIMAPXServer *imap, CamelException *ex, gboolean litplus)
+imapx_continuation(CamelIMAPXServer *imap, gboolean litplus, GError **error)
{
CamelIMAPXCommand *ic, *newliteral = NULL;
CamelIMAPXCommandPart *cp;
ohter lock here. All other writes go through
queue-lock */
if (imapx_idle_supported (imap) && imapx_in_idle (imap)) {
- camel_imapx_stream_skip (imap->stream, ex);
+ camel_imapx_stream_skip (imap->stream, error);
c(printf("Got continuation response for IDLE \n"));
IDLE_LOCK(imap->idle);
/* IDLE got cancelled after we sent the command, while
we were waiting for this continuation. Send DONE
immediately. */
- imapx_command_idle_stop(imap, ex);
+ imapx_command_idle_stop(imap, error);
imap->idle->state = IMAPX_IDLE_OFF;
} else {
c(printf("idle starts in wrong state %d\n",
QUEUE_LOCK(imap);
imap->literal = NULL;
- imapx_command_start_next(imap, ex);
+ imapx_command_start_next(imap, error);
QUEUE_UNLOCK(imap);
return 1;
ic = imap->literal;
if (!litplus) {
if (ic == NULL) {
- camel_imapx_stream_skip(imap->stream, ex);
+ camel_imapx_stream_skip(imap->stream, error);
c(printf("got continuation response with no outstanding continuation requests?\n"));
return 1;
}
switch (cp->type & CAMEL_IMAPX_COMMAND_MASK) {
case CAMEL_IMAPX_COMMAND_DATAWRAPPER:
c(printf("writing data wrapper to literal\n"));
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)cp->ob, (CamelStream *)imap->stream);
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)cp->ob, (CamelStream *)imap->stream, NULL);
break;
case CAMEL_IMAPX_COMMAND_STREAM:
c(printf("writing stream to literal\n"));
- camel_stream_write_to_stream((CamelStream *)cp->ob, (CamelStream *)imap->stream);
+ camel_stream_write_to_stream((CamelStream *)cp->ob, (CamelStream *)imap->stream, NULL);
break;
case CAMEL_IMAPX_COMMAND_AUTH: {
gchar *resp;
guchar *token;
- camel_imapx_stream_text (imap->stream, &token, ex);
- if (camel_exception_is_set(ex))
+ if (!camel_imapx_stream_text (imap->stream, &token, error))
return -1;
- resp = camel_sasl_challenge_base64((CamelSasl *)cp->ob, (const gchar *) token, ex);
+ resp = camel_sasl_challenge_base64((CamelSasl *)cp->ob, (const gchar *) token, error);
g_free(token);
- if (camel_exception_is_set(ex))
- return -1;
- if (!resp) {
- camel_exception_set (ex, 1, "Authentication mechanism failed");
+ if (resp == NULL)
return -1;
- }
c(printf("got auth continuation, feeding token '%s' back to auth mech\n", resp));
- camel_stream_write((CamelStream *)imap->stream, resp, strlen(resp));
+ camel_stream_write((CamelStream *)imap->stream, resp, strlen(resp), NULL);
g_free(resp);
/* we want to keep getting called until we get a status reponse from the server
ignore what sasl tells us */
c(printf("writing file '%s' to literal\n", (gchar *)cp->ob));
// FIXME: errors
- if (cp->ob && (file = camel_stream_fs_new_with_name(cp->ob, O_RDONLY, 0))) {
- camel_stream_write_to_stream(file, (CamelStream *)imap->stream);
+ if (cp->ob && (file = camel_stream_fs_new_with_name(cp->ob, O_RDONLY, 0, NULL))) {
+ camel_stream_write_to_stream(file, (CamelStream *)imap->stream, NULL);
g_object_unref (file);
} else if (cp->ob_size > 0) {
// Server is expecting data ... ummm, send it zeros? abort?
}
break; }
case CAMEL_IMAPX_COMMAND_STRING:
- camel_stream_write((CamelStream *)imap->stream, cp->ob, cp->ob_size);
+ camel_stream_write((CamelStream *)imap->stream, cp->ob, cp->ob_size, NULL);
break;
default:
/* should we just ignore? */
imap->literal = NULL;
- camel_exception_set (ex, 1, "continuation response for non-continuation request");
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "continuation response for non-continuation request");
return -1;
}
if (!litplus)
- camel_imapx_stream_skip(imap->stream, ex);
+ camel_imapx_stream_skip(imap->stream, error);
noskip:
cp = cp->next;
if (cp->next) {
imap->literal = newliteral;
if (!litplus)
- imapx_command_start_next(imap, ex);
+ imapx_command_start_next(imap, error);
QUEUE_UNLOCK(imap);
return 1;
/* 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 *ic;
guint tag;
if (token[0] != imap->tagprefix) {
- camel_exception_setv (ex, 1, "Server sent unexpected response: %s", token);
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "Server sent unexpected response: %s", token);
return -1;
}
tag = strtoul( (const gchar *)token+1, NULL, 10);
if ((ic = imapx_find_command_tag(imap, tag)) == NULL) {
- camel_exception_setv (ex, 1, "got response tag unexpectedly: %s", token);
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "got response tag unexpectedly: %s", token);
return -1;
}
if (ic->current->next->next) {
QUEUE_UNLOCK(imap);
- camel_exception_setv (ex, 1, "command still has unsent parts? %s", ic->name);
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "command still has unsent parts? %s", ic->name);
return -1;
}
- /* A follow-on command might've already queued a new literal since were were done with ours? */
-// if (imap->literal != NULL) {
-// QUEUE_UNLOCK(imap);
-// camel_exception_throw(1, "command still has outstanding continuation", imap->literal->name);
-// }
-
camel_dlist_remove ((CamelDListNode *) ic);
QUEUE_UNLOCK(imap);
- ic->status = imapx_parse_status(imap->stream, ex);
+ ic->status = imapx_parse_status(imap->stream, error);
if (ic->complete)
ic->complete (imap, ic);
QUEUE_LOCK(imap);
- imapx_command_start_next(imap, ex);
+ imapx_command_start_next(imap, error);
QUEUE_UNLOCK(imap);
return 1;
}
static void
-imapx_step(CamelIMAPXServer *is, CamelException *ex)
+imapx_step(CamelIMAPXServer *is, GError **error)
{
guint len;
guchar *token;
gint tok;
// poll ? wait for other stuff? loop?
- tok = camel_imapx_stream_token (is->stream, &token, &len, ex);
- if (camel_exception_is_set (ex))
+ tok = camel_imapx_stream_token (is->stream, &token, &len, error);
+ if (tok < 0)
return;
if (tok == '*')
- imapx_untagged (is, ex);
+ imapx_untagged (is, error);
else if (tok == IMAPX_TOK_TOKEN)
- imapx_completion (is, token, len, ex);
+ imapx_completion (is, token, len, error);
else if (tok == '+')
- imapx_continuation (is, ex, FALSE);
+ imapx_continuation (is, FALSE, error);
else
- camel_exception_set (ex, 1, "unexpected server response:");
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "unexpected server response:");
}
/* Used to run 1 command synchronously,
use for capa, login, and namespaces only. */
-static void
+static gboolean
imapx_command_run (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
/* throws IO,PARSE exception */
{
imapx_command_start(is, ic);
QUEUE_UNLOCK(is);
- while (ic->status == NULL && !camel_exception_is_set (ic->ex))
- imapx_step(is, ic->ex);
+ while (ic->status == NULL && ic->error == NULL)
+ imapx_step(is, &ic->error);
if (is->literal == ic)
is->literal = NULL;
QUEUE_LOCK(is);
camel_dlist_remove((CamelDListNode *)ic);
QUEUE_UNLOCK(is);
+
+ return (ic->error == NULL);
}
static void
QUEUE_UNLOCK (is);
if (job->noreply) {
- camel_exception_clear(job->ex);
+ g_clear_error (&job->error);
g_free(job);
} else
camel_msgport_reply((CamelMsg *) job);
}
static gboolean
-imapx_register_job (CamelIMAPXServer *is, CamelIMAPXJob *job)
+imapx_register_job (CamelIMAPXServer *is,
+ CamelIMAPXJob *job,
+ GError **error)
{
if (is->state >= IMAPX_INITIALISED) {
QUEUE_LOCK (is);
} else {
e(printf ("NO connection yet, maybe user cancelled jobs earlier ?"));
- camel_exception_set (job->ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED, "Not authenticated");
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_NOT_CONNECTED,
+ _("Not authenticated"));
return FALSE;
}
return TRUE;
}
-static void
-imapx_run_job (CamelIMAPXServer *is, CamelIMAPXJob *job)
+static gboolean
+imapx_run_job (CamelIMAPXServer *is,
+ CamelIMAPXJob *job,
+ GError **error)
{
CamelMsgPort *reply = NULL;
g_assert(completed == (CamelMsg *)job);
}
+
+ if (job->error != NULL) {
+ g_propagate_error (error, job->error);
+ job->error = NULL;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+imapx_submit_job (CamelIMAPXServer *is,
+ CamelIMAPXJob *job,
+ GError **error)
+{
+ if (!imapx_register_job (is, job, error))
+ return FALSE;
+
+ return imapx_run_job (is, job, error);
}
/* ********************************************************************** */
/*TODO handle negative cases sanely */
static gboolean
-imapx_command_idle_stop (CamelIMAPXServer *is, CamelException *ex)
+imapx_command_idle_stop (CamelIMAPXServer *is, GError **error)
{
if (!is->stream || camel_stream_printf((CamelStream *)is->stream, "%s", "DONE\r\n") == -1) {
- camel_exception_set (ex, 1, "Unable to issue DONE");
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "Unable to issue DONE");
return FALSE;
}
{
CamelIMAPXIdle *idle = is->idle;
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error performing IDLE: %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error performing IDLE: %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
}
IDLE_LOCK (idle);
QUEUE_UNLOCK (is);
}
-static void
-camel_imapx_server_idle (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+static gboolean
+camel_imapx_server_idle (CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
CamelIMAPXJob *job;
+ gboolean success;
job = g_malloc0 (sizeof(*job));
job->type = IMAPX_JOB_IDLE;
job->start = imapx_job_idle_start;
job->folder = folder;
- job->ex = ex;
- if (imapx_register_job (is, job))
- imapx_run_job(is, job);
+ success = imapx_submit_job (is, job, error);
+
g_free(job);
+
+ return success;
}
-static void
-imapx_server_fetch_new_messages (CamelIMAPXServer *is, CamelFolder *folder, gboolean async,
- gboolean update_unseen, CamelException *ex)
+static gboolean
+imapx_server_fetch_new_messages (CamelIMAPXServer *is,
+ CamelFolder *folder,
+ gboolean async,
+ gboolean update_unseen,
+ GError **error)
{
CamelIMAPXJob *job;
+ gboolean success;
job = g_malloc0(sizeof(*job));
job->type = IMAPX_JOB_FETCH_NEW_MESSAGES;
job->start = imapx_job_fetch_new_messages_start;
job->folder = folder;
job->noreply = async;
- job->ex = ex;
job->u.refresh_info.changes = camel_folder_change_info_new();
job->u.refresh_info.update_unseen = update_unseen;
job->op = camel_operation_registered ();
- if (imapx_register_job (is, job))
- imapx_run_job (is, job);
+ success = imapx_submit_job (is, job, error);
if (!async)
g_free (job);
+
+ return success;
}
static gpointer
imapx_idle_thread (gpointer data)
{
- CamelException *ex = camel_exception_new ();
CamelIMAPXServer *is = (CamelIMAPXServer *) data;
+ GError *local_error = NULL;
while (TRUE) {
CamelIMAPXFolder *ifolder;
continue;
}
IDLE_UNLOCK(is->idle);
- camel_imapx_server_idle (is, (void *)ifolder, ex);
+ camel_imapx_server_idle (is, (void *)ifolder, &local_error);
- if (!camel_exception_is_set (ex) && ifolder->exists_on_server >
+ if (local_error == NULL && ifolder->exists_on_server >
camel_folder_summary_count (((CamelFolder *) ifolder)->summary) && imapx_is_command_queue_empty (is))
- imapx_server_fetch_new_messages (is, is->select_folder, TRUE, TRUE, ex);
+ imapx_server_fetch_new_messages (is, is->select_folder, TRUE, TRUE, &local_error);
- if (camel_exception_is_set (ex)) {
- e(printf ("Caught exception in idle thread: %s \n", ex->desc));
+ if (local_error != NULL) {
+ e(printf ("Caught exception in idle thread: %s \n", local_error->message));
/* No way to asyncronously notify UI ? */
- camel_exception_clear (ex);
+ g_clear_error (&local_error);
}
IDLE_LOCK(is->idle);
}
break;
}
- camel_exception_free (ex);
+ g_clear_error (&local_error);
is->idle->idle_thread = NULL;
return NULL;
}
static gboolean
-imapx_stop_idle (CamelIMAPXServer *is, CamelException *ex)
+imapx_stop_idle (CamelIMAPXServer *is, GError **error)
{
CamelIMAPXIdle *idle = is->idle;
int stopped = FALSE;
break;
case IMAPX_IDLE_STARTED:
- imapx_command_idle_stop (is, ex);
+ imapx_command_idle_stop (is, error);
idle->state = IMAPX_IDLE_OFF;
stopped = TRUE;
c(printf("Stopping idle after %ld seconds\n",
static void
imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
CamelDList failed;
CamelIMAPXCommand *cw, *cn;
while (cn) {
if (ic->status)
cw->status = imapx_copy_status(ic->status);
- if (camel_exception_is_set(ic->ex))
- camel_exception_xfer (cw->ex, ic->ex);
- else {
- camel_exception_setv (cw->ex, 1, "SELECT %s failed: %s",
- camel_folder_get_full_name(cw->select),
- ic->status->text?:"<unknown reason>");
- }
+ if (ic->error != NULL)
+ g_propagate_error (&cw->error, ic->error);
+ else
+ g_set_error (
+ &cw->error, CAMEL_IMAPX_ERROR, 1,
+ "SELECT %s failed: %s",
+ camel_folder_get_full_name(cw->select),
+ ic->status->text?:"<unknown reason>");
cw->complete(is, cw);
cw = cn;
cn = cn->next;
}
/* Should have a queue lock. TODO Change the way select is written */
-static void
-imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, CamelException *ex)
+static gboolean
+imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, GError **error)
{
CamelIMAPXCommand *ic;
const gchar *full_name;
for another select */
if (is->select_pending)
- return;
+ return TRUE;
if (is->select_folder == folder && !forced)
- return;
+ return TRUE;
if (!camel_dlist_empty(&is->active))
- return;
+ return TRUE;
is->select_pending = folder;
g_object_ref (folder);
uid = camel_folder_summary_uid_from_index (folder->summary, 0);
if (isum->modseq && ifolder->uidvalidity_on_server) {
- c(printf("SELECT QRESYNC %ld %ld\n", ifolder->uidvalidity_on_server, isum->modseq));
- camel_imapx_command_add(ic, " (QRESYNC (%ld %ld %s:*", ifolder->uidvalidity_on_server, isum->modseq, uid);
+ c(printf("SELECT QRESYNC %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT "\n", ifolder->uidvalidity_on_server, isum->modseq));
+ camel_imapx_command_add(ic, " (QRESYNC (%" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %s:*", ifolder->uidvalidity_on_server, isum->modseq, uid);
if (total > 10) {
int i;
ic->complete = imapx_command_select_done;
imapx_command_start (is, ic);
+
+ return TRUE;
}
#ifndef G_OS_WIN32
/* Using custom commands to connect to IMAP servers is not supported on Win32 */
static gboolean
-connect_to_server_process (CamelIMAPXServer *is, const gchar *cmd, CamelException *ex)
+connect_to_server_process (CamelIMAPXServer *is, const gchar *cmd, GError **error)
{
CamelStream *cmd_stream;
gint ret, i = 0;
if (ret == -1) {
if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection cancelled"));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("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, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Could not connect with command \"%s\": %s"),
+ full_cmd, g_strerror (errno));
g_object_unref (cmd_stream);
g_free (full_cmd);
#endif /* !G_OS_WIN32 */
gboolean
-imapx_connect_to_server (CamelIMAPXServer *is, CamelException *ex)
+imapx_connect_to_server (CamelIMAPXServer *is, GError **error)
{
CamelStream * tcp_stream = NULL;
gchar *socks_host;
const gchar *port = NULL;
struct addrinfo *ai, hints = { 0 };
CamelIMAPXCommand *ic;
+ GError *local_error = NULL;
#ifndef G_OS_WIN32
const gchar *command;
if (camel_url_get_param(is->url, "use_command") &&
(command = camel_url_get_param(is->url, "command"))) {
- camel_exception_clear(ex);
- connect_to_server_process(is, command, ex);
- if (camel_exception_is_set (ex))
+ if (!connect_to_server_process(is, command, &local_error))
goto exit;
else
goto connected;
}
hints.ai_socktype = SOCK_STREAM;
- ai = camel_getaddrinfo(is->url->host, serv, &hints, ex);
- if (ex && ex->id && ex->id != CAMEL_EXCEPTION_USER_CANCEL && port != NULL) {
- camel_exception_clear(ex);
- ai = camel_getaddrinfo(is->url->host, port, &hints, ex);
+ ai = camel_getaddrinfo(is->url->host, serv, &hints, &local_error);
+ if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && port != NULL) {
+ g_clear_error (&local_error);
+ ai = camel_getaddrinfo(is->url->host, port, &hints, &local_error);
}
- if (ex && ex->id) {
- e(printf ("Unable to connect %d %s \n", ex->id, ex->desc));
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
g_object_unref (tcp_stream);
return FALSE;
}
- ret = camel_tcp_stream_connect(CAMEL_TCP_STREAM(tcp_stream), ai);
+ ret = camel_tcp_stream_connect(CAMEL_TCP_STREAM(tcp_stream), ai, error);
camel_freeaddrinfo(ai);
if (ret == -1) {
- if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Connection cancelled"));
- else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not connect to %s (port %s): %s"),
- is->url->host, serv, g_strerror(errno));
+ g_prefix_error (
+ error, _("Could not connect to %s (port %s): "),
+ is->url->host, serv);
g_object_unref (tcp_stream);
return FALSE;
}
while (1) {
// poll ? wait for other stuff? loop?
if (camel_application_is_exiting || is->parser_quit) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- "Connection to server cancelled\n");
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ "Connection to server cancelled\n");
return FALSE;
}
- tok = camel_imapx_stream_token (is->stream, &token, &len, ex);
- if (camel_exception_is_set (ex)) {
+ tok = camel_imapx_stream_token (is->stream, &token, &len, error);
+ if (tok < 0)
return FALSE;
- }
if (tok == '*') {
- imapx_untagged (is, ex);
+ imapx_untagged (is, error);
break;
}
camel_imapx_stream_ungettoken(is->stream, tok, token, len);
- camel_imapx_stream_text (is->stream, &token, ex);
- if (camel_exception_is_set (ex)) {
+ if (!camel_imapx_stream_text (is->stream, &token, error))
return FALSE;
- }
e(printf("Got unexpected line before greeting: '%s'\n", token));
g_free(token);
}
ic = camel_imapx_command_new(is, "CAPABILITY", NULL, "CAPABILITY");
imapx_command_run(is, ic);
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "%s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
+ "%s", ic->status->text);
else
- camel_exception_xfer (ex, ic->ex);
+ g_propagate_error (error, ic->error);
camel_imapx_command_free(ic);
return FALSE;
{
if (!(is->cinfo->capa & IMAPX_CAPABILITY_STARTTLS)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to connect to IMAP server %s in secure mode: %s"),
- is->url->host, _("STARTTLS not supported"));
+ g_set_error (
+ &local_error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
+ _("Failed to connect to IMAP server %s in secure mode: %s"),
+ is->url->host, _("STARTTLS not supported"));
goto exit;
}
ic = camel_imapx_command_new (is, "STARTTLS", NULL, "STARTTLS");
imapx_command_run (is, ic);
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "%s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &local_error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
+ "%s", ic->status->text);
else
- camel_exception_xfer (ex, ic->ex);
+ g_propagate_error (&local_error, ic->error);
camel_imapx_command_free(ic);
goto exit;
camel_imapx_command_free(ic);
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"),
- is->url->host, _("SSL negotiations failed"));
+ g_set_error (
+ &local_error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
+ _("Failed to connect to IMAP server %s in secure mode: %s"),
+ is->url->host, _("SSL negotiations failed"));
goto exit;
}
/* Get new capabilities if they weren't already given */
if (!is->cinfo) {
ic = camel_imapx_command_new(is, "CAPABILITY", NULL, "CAPABILITY");
- imapx_command_run (is, ic);
- camel_exception_xfer (ex, ic->ex);
- camel_imapx_command_free(ic);
-
- if (camel_exception_is_set (ex))
+ if (!imapx_command_run (is, ic)) {
+ g_propagate_error (&local_error, ic->error);
+ camel_imapx_command_free (ic);
goto exit;
+ }
+
+ camel_imapx_command_free(ic);
}
}
#endif
exit:
- if (camel_exception_is_set (ex)) {
- e(printf("Unable to connect %d %s \n", ex->id, ex->desc));
+ if (local_error != NULL) {
+ e(printf("Unable to connect %d %s \n", local_error->code, local_error->message));
+ g_propagate_error (error, local_error);
g_object_unref (is->stream);
is->stream = NULL;
return TRUE;
}
-static void
-imapx_reconnect (CamelIMAPXServer *is, CamelException *ex)
+static gboolean
+imapx_reconnect (CamelIMAPXServer *is, GError **error)
{
CamelSasl *sasl;
CamelIMAPXCommand *ic;
prompt_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
g_free (service->url->passwd);
service->url->passwd = NULL;
- camel_exception_clear (ex);
}
- imapx_connect_to_server (is, ex);
- if (camel_exception_is_set (ex))
+ if (!imapx_connect_to_server (is, error))
goto exception;
if (is->state == IMAPX_AUTHENTICATED)
if (!authtype && service->url->authmech) {
if (!g_hash_table_lookup (is->cinfo->auth_types, 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,
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("No support for authentication type %s"),
service->url->authmech);
goto exception;
auth_domain = camel_url_get_param (service->url, "auth-domain");
service->url->passwd = camel_session_get_password(is->session, (CamelService *)is->store,
auth_domain,
- full_prompt, "password", prompt_flags, ex);
+ full_prompt, "password", prompt_flags, error);
g_free (base_prompt);
g_free (full_prompt);
errbuf = NULL;
if (!service->url->passwd) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("You did not enter a password."));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("You did not enter a password."));
goto exception;
}
}
imapx_command_run (is, ic);
- if (!(camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK)) {
+ if (ic->error == NULL && ic->status->result == IMAPX_OK) {
/* Forget old capabilities after login */
if (is->cinfo) {
imapx_free_capability(is->cinfo);
/* If exception is set, it might be mostly due to cancellation and we would get an
io error, else re-prompt. If authentication fails for other reasons ic->status would be
set with the error message */
- if (camel_exception_is_set (ic->ex)) {
- camel_exception_xfer (ex, ic->ex);
+ if (ic->error != NULL) {
+ g_propagate_error (error, ic->error);
camel_imapx_command_free(ic);
goto exception;
}
errbuf = g_markup_printf_escaped (
_("Unable to authenticate to IMAP server.\n%s\n\n"),
ic->status->text);
- camel_exception_clear (ex);
-
}
camel_imapx_command_free(ic);
}
- if (camel_exception_is_set (ex))
- goto exception;
-
/* After login we re-capa unless the server already told us */
if (!is->cinfo) {
ic = camel_imapx_command_new(is, "CAPABILITY", NULL, "CAPABILITY");
- imapx_command_run (is, ic);
- camel_exception_xfer (ex, ic->ex);
- camel_imapx_command_free(ic);
-
- if (camel_exception_is_set (ex))
+ if (!imapx_command_run (is, ic)) {
+ g_propagate_error (error, ic->error);
+ camel_imapx_command_free(ic);
goto exception;
+ }
+
+ camel_imapx_command_free (ic);
}
is->state = IMAPX_AUTHENTICATED;
/* Fetch namespaces */
if (is->cinfo->capa & IMAPX_CAPABILITY_NAMESPACE) {
ic = camel_imapx_command_new (is, "NAMESPACE", NULL, "NAMESPACE");
- imapx_command_run (is, ic);
- camel_exception_xfer (ex, ic->ex);
- camel_imapx_command_free (ic);
-
- if (camel_exception_is_set (ex))
+ if (!imapx_command_run (is, ic)) {
+ g_propagate_error (error, ic->error);
+ camel_imapx_command_free (ic);
goto exception;
+ }
+
+ camel_imapx_command_free (ic);
}
+
if (((CamelIMAPXStore *)is->store)->rec_options & IMAPX_USE_QRESYNC &&
is->cinfo->capa & IMAPX_CAPABILITY_QRESYNC) {
ic = camel_imapx_command_new (is, "ENABLE", NULL, "ENABLE CONDSTORE QRESYNC");
- imapx_command_run (is, ic);
- camel_exception_xfer (ex, ic->ex);
- camel_imapx_command_free (ic);
-
- if (camel_exception_is_set (ex))
+ if (!imapx_command_run (is, ic)) {
+ g_propagate_error (error, ic->error);
+ camel_imapx_command_free (ic);
goto exception;
+ }
+
+ camel_imapx_command_free (ic);
is->use_qresync = TRUE;
} else
imapx_store->dir_sep = ns->sep;
}
- if (!camel_exception_is_set (ex)) {
- is->state = IMAPX_INITIALISED;
- return;
- }
+ is->state = IMAPX_INITIALISED;
+ return TRUE;
exception:
+
imapx_disconnect (is);
if (is->cinfo) {
imapx_free_capability(is->cinfo);
is->cinfo = NULL;
}
+
+ return FALSE;
}
/* ********************************************************************** */
full_name = camel_folder_get_full_name (job->folder);
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
failed = TRUE;
job->u.get_message.body_len = -1;
} else if (job->u.get_message.use_multi_fetch) {
/* return the exception from last command */
if (failed) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(job->ex, 1, "Error fetching message: %s", ic->status->text);
+ if (ic->error == NULL)
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error fetching message: %s", ic->status->text);
else
- camel_exception_xfer (job->ex, ic->ex);
+ g_propagate_error (&job->error, ic->error);
g_object_unref (stream);
job->u.get_message.stream = NULL;
} else {
if (stream) {
gchar *tmp = camel_data_cache_get_filename (ifolder->cache, "tmp", job->u.get_message.uid, NULL);
- if (camel_stream_flush (stream) == 0 && camel_stream_close (stream) == 0) {
+ if (camel_stream_flush (stream, &job->error) == 0 && camel_stream_close (stream, &job->error) == 0) {
gchar *cache_file = camel_data_cache_get_filename (ifolder->cache, "cur", job->u.get_message.uid, NULL);
gchar *temp = g_strrstr (cache_file, "/"), *dir;
g_free (dir);
if (g_rename (tmp, cache_file) != 0)
- camel_exception_set (job->ex, 1, "failed to copy the tmp file");
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "failed to copy the tmp file");
g_free (cache_file);
} else
- camel_exception_setv(job->ex, 1, "closing tmp stream failed: %s", g_strerror(errno));
+ g_prefix_error (
+ &job->error,
+ _("Closing tmp stream failed: "));
g_free (tmp);
job->u.get_message.stream = camel_data_cache_get (ifolder->cache, "cur", job->u.get_message.uid, NULL);
gint i = job->u.copy_messages.index;
GPtrArray *uids = job->u.copy_messages.uids;
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_set (job->ex, 1, "Error copying messages");
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error copying messages");
else
- camel_exception_xfer (job->ex, ic->ex);
+ g_propagate_error (&job->error, ic->error);
goto cleanup;
}
static void
imapx_job_copy_messages_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
{
- imapx_server_sync_changes (is, job->folder, job->pri, job->ex);
- if (camel_exception_is_set (job->ex))
+ if (!imapx_server_sync_changes (is, job->folder, job->pri, &job->error))
imapx_job_done (is, job);
g_ptr_array_sort (job->u.copy_messages.uids, (GCompareFunc) imapx_uids_array_cmp);
mi = camel_message_info_clone (job->u.append_message.info);
old_uid = g_strdup (job->u.append_message.info->uid);
- if (!camel_exception_is_set (ic->ex) && ic->status->result == IMAPX_OK) {
+ if (ic->error == NULL && ic->status->result == IMAPX_OK) {
if (ic->status->condition == IMAPX_APPENDUID) {
c(printf("Got appenduid %d %d\n", (gint)ic->status->u.appenduid.uidvalidity, (gint)ic->status->u.appenduid.uid));
if (ic->status->u.appenduid.uidvalidity == ifolder->uidvalidity_on_server) {
}
}
} else {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(job->ex, 1, "Error appending message: %s", ic->status->text);
+ if (ic->error == NULL)
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error appending message: %s", ic->status->text);
else
- camel_exception_xfer (job->ex, ic->ex);
+ g_propagate_error (&job->error, ic->error);
}
camel_data_cache_remove (ifolder->cache, "new", old_uid, NULL);
gint i = job->u.refresh_info.index;
GArray *infos = job->u.refresh_info.infos;
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_set (job->ex, 1, "Error fetching message headers");
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error fetching message headers");
else
- camel_exception_xfer (job->ex, ic->ex);
+ g_propagate_error (&job->error, ic->error);
goto cleanup;
}
gint i;
GArray *infos = job->u.refresh_info.infos;
- if (!camel_exception_is_set (ic->ex) && ic->status->result == IMAPX_OK) {
+ if (ic->error == NULL && ic->status->result == IMAPX_OK) {
GCompareDataFunc uid_cmp = imapx_uid_cmp;
CamelMessageInfo *s_minfo = NULL;
CamelIMAPXMessageInfo *info;
return;
}
} else {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(job->ex, 1, "Error retriving message: %s", ic->status->text);
+ if (ic->error == NULL)
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error retriving message: %s", ic->status->text);
else
- camel_exception_xfer (job->ex, ic->ex);
+ g_propagate_error (&job->error, ic->error);
}
for (i=0;i<infos->len;i++) {
CamelIMAPXSummary *isum = (CamelIMAPXSummary *)ic->job->folder->summary;
CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *)ic->job->folder;
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error fetching new messages : %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error fetching new messages: %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
goto exception;
}
isum->uidnext = ifolder->uidnext_on_server;
CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) job->folder;
CamelIMAPXSummary *isum = (CamelIMAPXSummary *)job->folder->summary;
CamelFolder *folder = job->folder;
- CamelException *ex = job->ex;
const gchar *full_name;
gboolean need_rescan = FALSE;
gboolean is_selected = FALSE;
/* Sync changes first, else unread count will not
match. Need to think about better ways for this */
- imapx_server_sync_changes (is, folder, job->pri, ex);
- if (camel_exception_is_set (job->ex))
+ if (!imapx_server_sync_changes (is, folder, job->pri, &job->error))
goto done;
#if 0 /* There are issues with this still; continue with the buggy behaviour
/* We may not issue STATUS on the current folder. Use SELECT or NOOP instead. */
if (0 /* server needs SELECT not just NOOP*/) {
if (imapx_idle_supported(is) && imapx_in_idle(is))
- imapx_stop_idle(is, job->ex);
- if (camel_exception_is_set(job->ex))
- goto done;
+ if (!imapx_stop_idle(is, &job->error))
+ goto done;
/* This doesn't work -- this is an immediate command, not queued */
- imapx_select(is, folder, TRUE, job->ex);
- if (camel_exception_is_set(job->ex))
+ if (!imapx_select(is, folder, TRUE, &job->error))
goto done;
} else {
/* Or maybe just NOOP, unless we're in IDLE in which case do nothing */
if (!imapx_idle_supported(is) || !imapx_in_idle(is)) {
- camel_imapx_server_noop(is, folder, job->ex);
- if (camel_exception_is_set(job->ex))
+ if (!camel_imapx_server_noop(is, folder, &job->error))
goto done;
}
}
imapx_command_run_sync (is, ic);
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(job->ex, 1, "Error refreshing folder: %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error refreshing folder: %s", ic->status->text);
else
- camel_exception_xfer (job->ex, ic->ex);
+ g_propagate_error (&job->error, ic->error);
camel_imapx_command_free (ic);
goto done;
if (!total)
need_rescan = FALSE;
- imapx_server_fetch_new_messages (is, folder, FALSE, FALSE, job->ex);
- if (camel_exception_is_set (job->ex))
+ if (!imapx_server_fetch_new_messages (is, folder, FALSE, FALSE, &job->error))
goto done;
/* If QRESYNC-capable we'll have got all flags changes in SELECT */
if (can_qresync) {
/* Actually we only want to select it; no need for the NOOP */
- camel_imapx_server_noop(is, folder, ex);
+ camel_imapx_server_noop(is, folder, &job->error);
qresync_done:
isum->modseq = ifolder->modseq_on_server;
total = camel_folder_summary_count(job->folder->summary);
static void
imapx_command_expunge_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error expunging message : %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error expunging message: %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
} else {
GPtrArray *uids;
CamelFolder *folder = ic->job->folder;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- camel_folder_summary_save_to_db (folder->summary, ic->job->ex);
- uids = camel_db_get_folder_deleted_uids (parent_store->cdb_r, full_name, ic->job->ex);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ uids = camel_db_get_folder_deleted_uids (parent_store->cdb_r, full_name, &ic->job->error);
if (uids && uids->len) {
CamelFolderChangeInfo *changes;
removed = g_slist_prepend (removed, (gpointer) uids->pdata[i]);
}
- camel_db_delete_uids (parent_store->cdb_w, full_name, removed, ic->job->ex);
- camel_folder_summary_save_to_db (folder->summary, ic->job->ex);
+ camel_db_delete_uids (parent_store->cdb_w, full_name, removed, NULL);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
camel_folder_changed (folder, changes);
camel_folder_change_info_free (changes);
{
CamelIMAPXCommand *ic;
- imapx_server_sync_changes (is, job->folder, job->pri, job->ex);
+ imapx_server_sync_changes (is, job->folder, job->pri, &job->error);
/* TODO handle UIDPLUS capability */
ic = camel_imapx_command_new(is, "EXPUNGE", job->folder, "EXPUNGE");
static void
imapx_command_list_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error fetching folders : %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error fetching folders: %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
}
e(printf ("==== list or lsub completed ==== \n"));
static void
imapx_command_subscription_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error subscribing to folder : %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error subscribing to folder : %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
}
imapx_job_done (is, ic->job);
static void
imapx_command_create_folder_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error creating to folder : %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error creating to folder: %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
}
imapx_job_done (is, ic->job);
static void
imapx_command_delete_folder_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error deleting to folder : %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error deleting to folder : %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
}
imapx_job_done (is, ic->job);
encoded_fname = imapx_encode_folder_name ((CamelIMAPXStore *) is->store, job->u.folder_name);
- job->folder = camel_store_get_folder(is->store, "INBOX", 0, job->ex);
+ job->folder = camel_store_get_folder(is->store, "INBOX", 0, &job->error);
/* make sure to-be-deleted folder is not selected by selecting INBOX for this operation */
ic = camel_imapx_command_new (is, "DELETE", job->folder, "DELETE %s", encoded_fname);
/* ********************************************************************** */
- static void
+static void
imapx_command_rename_folder_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error renaming to folder : %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error renaming to folder: %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
}
imapx_job_done (is, ic->job);
CamelIMAPXCommand *ic;
gchar *en_ofname = NULL, *en_nfname = NULL;
- job->folder = camel_store_get_folder(is->store, "INBOX", 0, job->ex);
+ job->folder = camel_store_get_folder(is->store, "INBOX", 0, &job->error);
en_ofname = imapx_encode_folder_name ((CamelIMAPXStore *) is->store, job->u.rename_folder.ofolder_name);
en_nfname = imapx_encode_folder_name ((CamelIMAPXStore *) is->store, job->u.rename_folder.nfolder_name);
static void
imapx_command_noop_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
{
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(ic->job->ex, 1, "Error performing NOOP: %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error performing NOOP: %s", ic->status->text);
else
- camel_exception_xfer (ic->job->ex, ic->ex);
+ g_propagate_error (&ic->job->error, ic->error);
}
imapx_job_done (is, ic->job);
that what we just set is actually what is on the server now .. but
if it isn't, i guess we'll fix up next refresh */
- if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
- if (!camel_exception_is_set (ic->ex))
- camel_exception_setv(job->ex, 1, "Error syncing changes: %s", ic->status->text);
+ if (ic->error != NULL || ic->status->result != IMAPX_OK) {
+ if (ic->error == NULL)
+ g_set_error (
+ &job->error, CAMEL_IMAPX_ERROR, 1,
+ "Error syncing changes: %s", ic->status->text);
else
- camel_exception_xfer (job->ex, ic->ex);
+ g_propagate_error (&job->error, ic->error);
failed = TRUE;
}
}
}
- camel_folder_summary_save_to_db (job->folder->summary, job->ex);
+ camel_folder_summary_save_to_db (job->folder->summary, &job->error);
camel_store_summary_save((CamelStoreSummary *)((CamelIMAPXStore *) parent_store)->summary);
imapx_job_done (is, job);
/* we cancel all the commands and their jobs, so associated jobs will be notified */
static void
-cancel_all_jobs (CamelIMAPXServer *is, CamelException *ex)
+cancel_all_jobs (CamelIMAPXServer *is, GError *error)
{
CamelIMAPXCommand **cw, *ic;
gint i = 0;
camel_dlist_remove ((CamelDListNode *)ic);
QUEUE_UNLOCK(is);
- camel_exception_set (ic->ex, ex->id, ex->desc);
+ ic->error = g_error_copy (error);
ic->complete (is, ic);
QUEUE_LOCK(is);
/* ********************************************************************** */
static void
-parse_contents (CamelIMAPXServer *is, CamelException *ex)
+parse_contents (CamelIMAPXServer *is, GError **error)
{
gint buffered = 0;
+ GError *local_error = NULL;
do {
- imapx_step(is, ex);
+ imapx_step (is, &local_error);
buffered = camel_imapx_stream_buffered (is->stream);
- } while (buffered && !camel_exception_is_set (ex));
+ } while (buffered && local_error == NULL);
+
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
}
/*
imapx_parser_thread (gpointer d)
{
CamelIMAPXServer *is = d;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CamelOperation *op;
+ GError *local_error = NULL;
op = camel_operation_new (NULL, NULL);
op = camel_operation_register (op);
is->op = op;
- while (!camel_exception_is_set (&ex) && is->stream) {
+ while (local_error == NULL && is->stream) {
camel_operation_uncancel (op);
#ifdef HAVE_SSL
if (is->is_ssl_stream) {
else if (res == 0) {
/* timed out */
} else if ((pollfds[0].out_flags & PR_POLL_READ)) {
- parse_contents (is, &ex);
+ parse_contents (is, &local_error);
} else if (pollfds[1].out_flags & PR_POLL_READ)
errno = EINTR;
}
else if (res == 0)
/* timed out */;
else if (fds[0].revents & G_IO_IN) {
- parse_contents (is, &ex);
+ parse_contents (is, &local_error);
} else if (fds[1].revents & G_IO_IN)
errno = EINTR;
}
else if (res == 0)
/* timed out */;
else if (fds[0].revents & G_IO_IN) {
- parse_contents (is, &ex);
+ parse_contents (is, &local_error);
} else if (fds[1].revents & G_IO_IN)
errno = EINTR;
}
if (is->parser_quit) {
- camel_exception_setv (&ex, CAMEL_EXCEPTION_USER_CANCEL, "Operation Cancelled: %s", g_strerror(errno));
+ g_set_error (
+ &local_error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
break;
}
if ((is_empty || (imapx_idle_supported (is) && imapx_in_idle (is))))
camel_operation_uncancel (op);
else
- camel_exception_setv (&ex, CAMEL_EXCEPTION_USER_CANCEL, "Operation Cancelled: %s", g_strerror(errno));
+ g_set_error (
+ &local_error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
}
}
is->state = IMAPX_SHUTDOWN;
QUEUE_UNLOCK(is);
- cancel_all_jobs (is, &ex);
+ cancel_all_jobs (is, local_error);
- camel_exception_clear (&ex);
+ g_clear_error (&local_error);
if (op) {
camel_operation_unregister (op);
g_static_rec_mutex_lock (&is->ostream_lock);
if (is->stream) {
- if (camel_stream_close (is->stream->source) == -1)
+ if (camel_stream_close (is->stream->source, NULL) == -1)
ret = FALSE;
g_object_unref (CAMEL_OBJECT (is->stream));
/* Client commands */
gboolean
-camel_imapx_server_connect (CamelIMAPXServer *is, CamelException *ex)
+camel_imapx_server_connect (CamelIMAPXServer *is, GError **error)
{
+ gboolean success;
+
if (is->state == IMAPX_SHUTDOWN)
return FALSE;
return TRUE;
g_static_rec_mutex_lock (&is->ostream_lock);
- imapx_reconnect (is, ex);
+ success = imapx_reconnect (is, error);
g_static_rec_mutex_unlock (&is->ostream_lock);
- if (camel_exception_is_set (ex))
+ if (!success)
return FALSE;
is->parser_thread = g_thread_create((GThreadFunc) imapx_parser_thread, is, TRUE, NULL);
}
static CamelStream *
-imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, CamelOperation *op, const gchar *uid, gint pri, CamelException *ex)
+imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, CamelOperation *op, const gchar *uid, gint pri, GError **error)
{
CamelStream *stream = NULL, *tmp_stream;
CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
CamelMessageInfo *mi;
gboolean registered;
EFlag *flag = NULL;
+ gboolean success;
cache_file = camel_data_cache_get_filename (ifolder->cache, "cur", uid, NULL);
if (g_file_test (cache_file, G_FILE_TEST_EXISTS)) {
stream = camel_data_cache_get (ifolder->cache, "cur", uid, NULL);
if (!stream)
- camel_exception_set (ex, 1, "Could not retrieve the message");
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "Could not retrieve the message");
return stream;
}
mi = camel_folder_summary_uid (folder->summary, uid);
if (!mi) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message with message ID %s: %s"),
- uid, _("No such message available."));
+ 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."));
QUEUE_UNLOCK (is);
return NULL;
}
job->op = op;
job->u.get_message.uid = (gchar *)uid;
job->u.get_message.stream = tmp_stream;
- job->ex = ex;
if (((CamelMessageInfoBase *) mi)->size > MULTI_SIZE)
job->u.get_message.use_multi_fetch = TRUE;
job->u.get_message.size = ((CamelMessageInfoBase *) mi)->size;
camel_message_info_free (mi);
- registered = imapx_register_job (is, job);
+ registered = imapx_register_job (is, job, error);
flag = e_flag_new ();
g_hash_table_insert (is->uid_eflags, g_strdup (uid), flag);
QUEUE_UNLOCK (is);
- if (registered)
- imapx_run_job(is, job);
+ success = registered && imapx_run_job (is, job, error);
e_flag_set (flag);
- if (!camel_exception_is_set (job->ex))
+
+ if (success)
stream = job->u.get_message.stream;
g_free(job);
}
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)
{
CamelStream *stream;
CamelOperation *op = camel_operation_registered ();
- stream = imapx_server_get_message(is, folder, op, uid, IMAPX_PRIORITY_GET_MESSAGE, ex);
+ stream = imapx_server_get_message(is, folder, op, uid, IMAPX_PRIORITY_GET_MESSAGE, error);
if (op)
camel_operation_unref (op);
return stream;
}
-void
-camel_imapx_server_sync_message (CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, CamelException *ex)
+gboolean
+camel_imapx_server_sync_message (CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, GError **error)
{
gchar *cache_file = NULL;
CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
cache_file = camel_data_cache_get_filename (ifolder->cache, "cur", uid, NULL);
if (g_file_test (cache_file, G_FILE_TEST_EXISTS)) {
g_free (cache_file);
- return;
+ return TRUE;
}
- stream = imapx_server_get_message (is, folder, NULL, uid, IMAPX_PRIORITY_SYNC_MESSAGE, ex);
- if (stream)
- g_object_unref (stream);
+ stream = imapx_server_get_message (is, folder, NULL, uid, IMAPX_PRIORITY_SYNC_MESSAGE, error);
+
+ if (stream == NULL)
+ return FALSE;
+
+ g_object_unref (stream);
+
+ return TRUE;
}
-void
-camel_imapx_server_copy_message (CamelIMAPXServer *is, CamelFolder *source, CamelFolder *dest, GPtrArray *uids, gboolean delete_originals, CamelException *ex)
+gboolean
+camel_imapx_server_copy_message (CamelIMAPXServer *is, CamelFolder *source, CamelFolder *dest, GPtrArray *uids, gboolean delete_originals, GError **error)
{
CamelIMAPXJob *job;
job->u.copy_messages.dest = dest;
job->u.copy_messages.uids = uids;
job->u.copy_messages.delete_originals = delete_originals;
- job->ex = ex;
g_object_ref (source);
g_object_ref (dest);
- if (imapx_register_job (is, job))
- imapx_run_job (is, job);
+ return imapx_submit_job (is, job, error);
}
-void
-camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *mi, CamelException *ex)
+gboolean
+camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *mi, GError **error)
{
gchar *uid = NULL, *tmp = NULL;
CamelStream *stream, *filter;
uid = imapx_get_temp_uid ();
stream = camel_data_cache_add (ifolder->cache, "new", uid, NULL);
if (stream == NULL) {
- camel_exception_setv(ex, 2, "Cannot create spool file: %s", g_strerror((gint) errno));
- return;
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Cannot create spool file: %s"),
+ g_strerror (errno));
+ return FALSE;
}
filter = camel_stream_filter_new (stream);
g_object_unref (stream);
canon = camel_mime_filter_canon_new(CAMEL_MIME_FILTER_CANON_CRLF);
camel_stream_filter_add((CamelStreamFilter *)filter, canon);
- res = camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, filter);
+ res = camel_data_wrapper_write_to_stream (
+ (CamelDataWrapper *)message, filter, error);
g_object_unref (canon);
g_object_unref (filter);
if (res == -1) {
- camel_exception_setv(ex, 2, "Cannot create spool file: %s", g_strerror(errno));
+ g_prefix_error (error, _("Cannot create spool file: "));
camel_data_cache_remove (ifolder->cache, "new", uid, NULL);
- return;
+ return FALSE;
}
tmp = camel_data_cache_get_filename (ifolder->cache, "new", uid, NULL);
job = g_malloc0(sizeof(*job));
job->pri = IMAPX_PRIORITY_APPEND_MESSAGE;
- job->ex = ex;
job->type = IMAPX_JOB_APPEND_MESSAGE;
job->start = imapx_job_append_message_start;
- job->folder = folder;
- g_object_ref (folder);
+ job->folder = g_object_ref (folder);
job->u.append_message.info = info;
job->u.append_message.path = tmp;
- if (imapx_register_job (is, job))
- imapx_run_job(is, job);
- return;
+ return imapx_submit_job (is, job, error);
}
-void
-camel_imapx_server_noop (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+gboolean
+camel_imapx_server_noop (CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
CamelIMAPXJob *job;
+ gboolean success;
job = g_malloc0(sizeof(*job));
job->type = IMAPX_JOB_NOOP;
job->start = imapx_job_noop_start;
job->folder = folder;
- job->ex = ex;
job->pri = IMAPX_PRIORITY_NOOP;
- if (imapx_register_job (is, job))
- imapx_run_job(is, job);
+ success = imapx_submit_job (is, job, error);
g_free(job);
+
+ return success;
}
-void
-camel_imapx_server_refresh_info (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+gboolean
+camel_imapx_server_refresh_info (CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
CamelIMAPXJob *job;
gboolean registered = TRUE;
const gchar *full_name;
+ gboolean success = TRUE;
full_name = camel_folder_get_full_name (folder);
if (imapx_is_job_in_queue (is, folder, IMAPX_JOB_REFRESH_INFO, NULL)) {
QUEUE_UNLOCK (is);
- return;
+ return TRUE;
}
job = g_malloc0(sizeof(*job));
job->type = IMAPX_JOB_REFRESH_INFO;
job->start = imapx_job_refresh_info_start;
job->folder = folder;
- job->ex = ex;
job->op = camel_operation_registered ();
job->u.refresh_info.changes = camel_folder_change_info_new();
job->pri = IMAPX_PRIORITY_REFRESH_INFO;
if (g_ascii_strcasecmp(full_name, "INBOX") == 0)
job->pri += 10;
- registered = imapx_register_job (is, job);
+ registered = imapx_register_job (is, job, error);
QUEUE_UNLOCK (is);
- if (registered) {
- imapx_run_job (is, job);
+ success = registered && imapx_run_job (is, job, error);
- if (camel_folder_change_info_changed(job->u.refresh_info.changes))
- camel_folder_changed (folder, job->u.refresh_info.changes);
- }
+ if (success && camel_folder_change_info_changed(job->u.refresh_info.changes))
+ camel_folder_changed (folder, job->u.refresh_info.changes);
camel_folder_change_info_free(job->u.refresh_info.changes);
if (job->op)
camel_operation_unref (job->op);
g_free(job);
+
+ return success;
}
static void
g_array_free(user_set, TRUE);
}
-static void
-imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, gint pri, CamelException *ex)
+static gboolean
+imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, gint pri, GError **error)
{
guint i, on_orset, off_orset;
GPtrArray *uids;
CamelIMAPXMessageInfo *info;
CamelIMAPXJob *job;
gboolean registered;
+ gboolean success = TRUE;
/* We calculate two masks, a mask of all flags which have been
turned off and a mask of all flags which have been turned
if (uids->len == 0) {
g_ptr_array_free (uids, TRUE);
- return;
+ return TRUE;
}
off_orset = on_orset = 0;
}
if ((on_orset|off_orset) == 0 && on_user == NULL && off_user == NULL)
- return;
+ return TRUE;
/* TODO above code should go into changes_start */
job->start = imapx_job_sync_changes_start;
job->pri = pri;
job->folder = folder;
- job->ex = ex;
job->u.sync_changes.changed_uids = uids;
job->u.sync_changes.on_set = on_orset;
job->u.sync_changes.off_set = off_orset;
job->u.sync_changes.on_user = on_user;
job->u.sync_changes.off_user = off_user;
- registered = imapx_register_job (is, job);
+ registered = imapx_register_job (is, job, error);
QUEUE_UNLOCK (is);
- if (registered)
- imapx_run_job(is, job);
+ success = registered && imapx_run_job (is, job, error);
g_free(job);
imapx_sync_free_user(off_user);
camel_folder_free_uids (folder, uids);
+
+ return success;
}
-void
-camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+gboolean
+camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
- imapx_server_sync_changes (is, folder, IMAPX_PRIORITY_SYNC_CHANGES, ex);
+ return imapx_server_sync_changes (is, folder, IMAPX_PRIORITY_SYNC_CHANGES, error);
}
/* expunge-uids? */
-void
-camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+gboolean
+camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, GError **error)
{
CamelIMAPXJob *job;
gboolean registered;
+ gboolean success;
/* Do we really care to wait for this one to finish? */
QUEUE_LOCK (is);
if (imapx_is_job_in_queue (is, folder, IMAPX_JOB_EXPUNGE, NULL)) {
QUEUE_UNLOCK (is);
- return;
+ return TRUE;
}
job = g_malloc0(sizeof(*job));
job->start = imapx_job_expunge_start;
job->pri = IMAPX_PRIORITY_EXPUNGE;
job->folder = folder;
- job->ex = ex;
- registered = imapx_register_job (is, job);
+ registered = imapx_register_job (is, job, error);
QUEUE_UNLOCK (is);
- if (registered)
- imapx_run_job(is, job);
+ success = registered && imapx_run_job (is, job, error);
g_free(job);
+
+ return success;
}
static guint
}
GPtrArray *
-camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags,
- const gchar *ext, CamelException *ex)
+camel_imapx_server_list (CamelIMAPXServer *is,
+ const gchar *top,
+ guint32 flags,
+ const gchar *ext,
+ GError **error)
{
CamelIMAPXJob *job;
GPtrArray *folders = NULL;
job->type = IMAPX_JOB_LIST;
job->start = imapx_job_list_start;
job->pri = IMAPX_PRIORITY_LIST;
- job->ex = ex;
job->u.list.ext = ext;
job->u.list.flags = flags;
job->u.list.folders = g_hash_table_new(imapx_name_hash, imapx_name_equal);
if (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST)
job->pri += 300;
- if (imapx_register_job (is, job)) {
- imapx_run_job (is, job);
-
+ if (imapx_submit_job (is, job, error)) {
folders = g_ptr_array_new();
g_hash_table_foreach(job->u.list.folders, imapx_list_flatten, folders);
qsort(folders->pdata, folders->len, sizeof(folders->pdata[0]), imapx_list_cmp);
return folders;
}
-void
-camel_imapx_server_manage_subscription (CamelIMAPXServer *is, const gchar *folder_name, gboolean subscribe, CamelException *ex)
+gboolean
+camel_imapx_server_manage_subscription (CamelIMAPXServer *is, const gchar *folder_name, gboolean subscribe, GError **error)
{
CamelIMAPXJob *job;
+ gboolean success;
job = g_malloc0(sizeof(*job));
job->type = IMAPX_JOB_MANAGE_SUBSCRIPTION;
job->start = imapx_job_manage_subscription_start;
job->pri = IMAPX_PRIORITY_MANAGE_SUBSCRIPTION;
- job->ex = ex;
job->u.manage_subscriptions.subscribe = subscribe;
job->u.manage_subscriptions.folder_name = folder_name;
- if (imapx_register_job (is, job))
- imapx_run_job (is, job);
+ success = imapx_submit_job (is, job, error);
g_free (job);
+
+ return success;
}
-void
-camel_imapx_server_create_folder (CamelIMAPXServer *is, const gchar *folder_name, CamelException *ex)
+gboolean
+camel_imapx_server_create_folder (CamelIMAPXServer *is, const gchar *folder_name, GError **error)
{
CamelIMAPXJob *job;
+ gboolean success;
job = g_malloc0(sizeof(*job));
job->type = IMAPX_JOB_CREATE_FOLDER;
job->start = imapx_job_create_folder_start;
job->pri = IMAPX_PRIORITY_CREATE_FOLDER;
- job->ex = ex;
job->u.folder_name = folder_name;
- if (imapx_register_job (is, job))
- imapx_run_job (is, job);
+ success = imapx_submit_job (is, job, error);
g_free (job);
+
+ return success;
}
-void
-camel_imapx_server_delete_folder (CamelIMAPXServer *is, const gchar *folder_name, CamelException *ex)
+gboolean
+camel_imapx_server_delete_folder (CamelIMAPXServer *is, const gchar *folder_name, GError **error)
{
CamelIMAPXJob *job;
+ gboolean success;
job = g_malloc0(sizeof(*job));
job->type = IMAPX_JOB_DELETE_FOLDER;
job->start = imapx_job_delete_folder_start;
job->pri = IMAPX_PRIORITY_DELETE_FOLDER;
- job->ex = ex;
job->u.folder_name = folder_name;
- if (imapx_register_job (is, job))
- imapx_run_job (is, job);
+ success = imapx_submit_job (is, job, error);
g_free (job);
+
+ return success;
}
-void
-camel_imapx_server_rename_folder (CamelIMAPXServer *is, const gchar *old_name, const gchar *new_name, CamelException *ex)
+gboolean
+camel_imapx_server_rename_folder (CamelIMAPXServer *is, const gchar *old_name, const gchar *new_name, GError **error)
{
CamelIMAPXJob *job;
+ gboolean success;
job = g_malloc0(sizeof(*job));
job->type = IMAPX_JOB_RENAME_FOLDER;
job->start = imapx_job_rename_folder_start;
job->pri = IMAPX_PRIORITY_RENAME_FOLDER;
- job->ex = ex;
job->u.rename_folder.ofolder_name = old_name;
job->u.rename_folder.nfolder_name = new_name;
- if (imapx_register_job (is, job))
- imapx_run_job (is, job);
+ success = imapx_submit_job (is, job, error);
g_free (job);
+ return success;
}
IMAPXJobQueueInfo *
camel_imapx_server_new (CamelStore *store,
CamelURL *url);
gboolean camel_imapx_server_connect (CamelIMAPXServer *is,
- CamelException *ex);
+ GError **error);
gboolean imapx_connect_to_server (CamelIMAPXServer *is,
- CamelException *ex);
+ GError **error);
GPtrArray * camel_imapx_server_list (CamelIMAPXServer *is,
const gchar *top,
guint32 flags,
const gchar *ext,
- CamelException *ex);
-void camel_imapx_server_refresh_info (CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_refresh_info (CamelIMAPXServer *is,
CamelFolder *folder,
- CamelException *ex);
-void camel_imapx_server_sync_changes (CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_sync_changes (CamelIMAPXServer *is,
CamelFolder *folder,
- CamelException *ex);
-void camel_imapx_server_expunge (CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_expunge (CamelIMAPXServer *is,
CamelFolder *folder,
- CamelException *ex);
-void camel_imapx_server_noop (CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_noop (CamelIMAPXServer *is,
CamelFolder *folder,
- CamelException *ex);
+ GError **error);
CamelStream * camel_imapx_server_get_message (CamelIMAPXServer *is,
CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
-void camel_imapx_server_copy_message (CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_copy_message (CamelIMAPXServer *is,
CamelFolder *source,
CamelFolder *dest,
GPtrArray *uids,
gboolean delete_originals,
- CamelException *ex);
-void camel_imapx_server_append_message
+ GError **error);
+gboolean camel_imapx_server_append_message
(CamelIMAPXServer *is,
CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *mi,
- CamelException *ex);
-void camel_imapx_server_sync_message (CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_sync_message (CamelIMAPXServer *is,
CamelFolder *folder,
const gchar *uid,
- CamelException *ex);
-void camel_imapx_server_manage_subscription
+ GError **error);
+gboolean camel_imapx_server_manage_subscription
(CamelIMAPXServer *is,
const gchar *folder_name,
gboolean subscribe,
- CamelException *ex);
-void camel_imapx_server_create_folder(CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_create_folder(CamelIMAPXServer *is,
const gchar *folder_name,
- CamelException *ex);
-void camel_imapx_server_delete_folder(CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_delete_folder(CamelIMAPXServer *is,
const gchar *folder_name,
- CamelException *ex);
-void camel_imapx_server_rename_folder(CamelIMAPXServer *is,
+ GError **error);
+gboolean camel_imapx_server_rename_folder(CamelIMAPXServer *is,
const gchar *old_name,
const gchar *new_name,
- CamelException *ex);
+ GError **error);
struct _IMAPXJobQueueInfo *
camel_imapx_server_get_job_queue_info
(CamelIMAPXServer *is);
#include "camel-imapx-store.h"
#include "camel-imapx-folder.h"
-#include "camel-imapx-exception.h"
#include "camel-imapx-utils.h"
#include "camel-imapx-server.h"
#include "camel-imapx-summary.h"
}
static gboolean
-imapx_construct(CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+imapx_construct(CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, GError **error)
{
gchar *summary;
CamelIMAPXStore *store = (CamelIMAPXStore *)service;
CamelServiceClass *service_class;
service_class = CAMEL_SERVICE_CLASS (camel_imapx_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ if (!service_class->construct (service, session, provider, url, error))
return FALSE;
store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
imapx_parse_receiving_options (store, service->url);
store->summary = camel_imapx_store_summary_new();
- store->storage_path = camel_session_get_storage_path(session, service, ex);
+ store->storage_path = camel_session_get_storage_path(session, service, error);
if (store->storage_path == NULL)
return FALSE;
extern CamelServiceAuthType camel_imapx_password_authtype;
static GList *
-imapx_query_auth_types (CamelService *service, CamelException *ex)
+imapx_query_auth_types (CamelService *service, GError **error)
{
CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (service);
CamelServiceAuthType *authtype;
gboolean connected;
if (CAMEL_OFFLINE_STORE (istore)->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;
}
connected = istore->server->stream != NULL;
if (!connected)
- connected = imapx_connect_to_server (istore->server, ex);
+ connected = imapx_connect_to_server (istore->server, error);
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
if (!connected)
return NULL;
}
CamelIMAPXServer *
-camel_imapx_store_get_server(CamelIMAPXStore *store, CamelException *ex)
+camel_imapx_store_get_server(CamelIMAPXStore *store, GError **error)
{
CamelIMAPXServer *server = NULL;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (store->server && camel_imapx_server_connect(store->server, ex)) {
+ if (store->server && camel_imapx_server_connect(store->server, NULL)) {
g_object_ref(store->server);
server = store->server;
} else {
}
server = camel_imapx_server_new(CAMEL_STORE(store), CAMEL_SERVICE(store)->url);
- if (camel_imapx_server_connect(server, ex)) {
+ if (camel_imapx_server_connect(server, error)) {
store->server = server;
g_object_ref(server);
} else {
}
static gboolean
-imapx_connect (CamelService *service, CamelException *ex)
+imapx_connect (CamelService *service, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *)service;
CamelIMAPXServer *server;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (server) {
g_object_unref(server);
return TRUE;
}
static gboolean
-imapx_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+imapx_disconnect (CamelService *service, gboolean clean, GError **error)
{
CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (service);
CamelServiceClass *service_class;
service_class = CAMEL_SERVICE_CLASS (camel_imapx_store_parent_class);
- service_class->disconnect (service, clean, ex);
+ if (!service_class->disconnect (service, clean, error))
+ return FALSE;
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
}
static CamelFolder *
-imapx_get_junk(CamelStore *store, CamelException *ex)
+imapx_get_junk(CamelStore *store, GError **error)
{
CamelFolder *folder;
CamelStoreClass *store_class;
store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class);
- folder = store_class->get_junk (store, ex);
+ folder = store_class->get_junk (store, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
}
static CamelFolder *
-imapx_get_trash (CamelStore *store, CamelException *ex)
+imapx_get_trash (CamelStore *store, GError **error)
{
CamelFolder *folder;
CamelStoreClass *store_class;
store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class);
- folder = store_class->get_trash (store, ex);
+ folder = store_class->get_trash (store, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
}
static gboolean
-imapx_noop (CamelStore *store, CamelException *ex)
+imapx_noop (CamelStore *store, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *) store;
CamelIMAPXServer *server;
+ gboolean success = FALSE;
if (CAMEL_OFFLINE_STORE(store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (server) {
- camel_imapx_server_noop (server, NULL, ex);
+ success = camel_imapx_server_noop (server, NULL, error);
g_object_unref(server);
}
- return TRUE;
+
+ return success;
}
static guint
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;
folder_dir = imapx_path_to_physical (storage_path, folder_name);
g_free(storage_path);
/* FIXME */
- new_folder = camel_imapx_folder_new (store, folder_dir, folder_name, ex);
+ new_folder = camel_imapx_folder_new (store, folder_dir, folder_name, error);
g_free(folder_dir);
camel_store_summary_info_free((CamelStoreSummary *)imapx_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 CamelFolder *
-imapx_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+imapx_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelFolder *folder;
- folder = get_folder_offline(store, folder_name, flags, ex);
+ folder = get_folder_offline(store, folder_name, flags, NULL);
if (folder == NULL) {
- camel_exception_setv(ex, 2, "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;
}
return folder;
}
-static CamelFolder *
-imapx_get_inbox(CamelStore *store, CamelException *ex)
-{
- camel_exception_setv(ex, 1, "get_inbox::unimplemented");
-
- return NULL;
-}
-
/* folder_name is path name */
static CamelFolderInfo *
imapx_build_folder_info (CamelIMAPXStore *imapx_store, const gchar *folder_name)
}
static void
-imapx_unmark_folder_subscribed (CamelIMAPXStore *istore, const gchar *folder_name, gboolean emit_signal, CamelException *ex)
+imapx_unmark_folder_subscribed (CamelIMAPXStore *istore, const gchar *folder_name, gboolean emit_signal)
{
CamelStoreInfo *si;
}
static void
-imapx_mark_folder_subscribed (CamelIMAPXStore *istore, const gchar *folder_name, gboolean emit_signal, CamelException *ex)
+imapx_mark_folder_subscribed (CamelIMAPXStore *istore, const gchar *folder_name, gboolean emit_signal)
{
CamelStoreInfo *si;
}
static gboolean
-imapx_subscribe_folder (CamelStore *store, const gchar *folder_name, gboolean emit_signal, CamelException *ex)
+imapx_subscribe_folder (CamelStore *store, const gchar *folder_name, gboolean emit_signal, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *) store;
CamelIMAPXServer *server;
+ gboolean success;
if (CAMEL_OFFLINE_STORE(store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (!server)
return FALSE;
- camel_imapx_server_manage_subscription (server, folder_name, TRUE, ex);
+ success = camel_imapx_server_manage_subscription (server, folder_name, TRUE, error);
g_object_unref(server);
- if (!camel_exception_is_set (ex)) {
- imapx_mark_folder_subscribed (istore, folder_name, emit_signal, ex);
- return TRUE;
- }
+ if (success)
+ imapx_mark_folder_subscribed (istore, folder_name, emit_signal);
- return FALSE;
+ return success;
}
static gboolean
-imapx_unsubscribe_folder (CamelStore *store, const gchar *folder_name, gboolean emit_signal, CamelException *ex)
+imapx_unsubscribe_folder (CamelStore *store, const gchar *folder_name, gboolean emit_signal, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *) store;
CamelIMAPXServer *server;
+ gboolean success;
if (CAMEL_OFFLINE_STORE(store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (!server)
return FALSE;
- camel_imapx_server_manage_subscription (server, folder_name, FALSE, ex);
+ success = camel_imapx_server_manage_subscription (server, folder_name, FALSE, error);
g_object_unref(server);
- if (!camel_exception_is_set (ex)) {
- imapx_unmark_folder_subscribed (istore, folder_name, emit_signal, ex);
- return TRUE;
- }
+ if (success)
+ imapx_unmark_folder_subscribed (istore, folder_name, emit_signal);
- return FALSE;
+ return success;
}
static gboolean
-imapx_store_subscribe_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imapx_store_subscribe_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
- return imapx_subscribe_folder (store, folder_name, TRUE, ex);
+ return imapx_subscribe_folder (store, folder_name, TRUE, error);
}
static gboolean
-imapx_store_unsubscribe_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imapx_store_unsubscribe_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
- CamelException eex = CAMEL_EXCEPTION_INITIALISER;
-
- if (!ex)
- ex = &eex;
-
- return imapx_unsubscribe_folder (store, folder_name, TRUE, ex);
+ return imapx_unsubscribe_folder (store, folder_name, TRUE, error);
}
static void
-imapx_delete_folder_from_cache (CamelIMAPXStore *istore, const gchar *folder_name, CamelException *ex)
+imapx_delete_folder_from_cache (CamelIMAPXStore *istore, const gchar *folder_name)
{
gchar *state_file;
gchar *folder_dir, *storage_path;
g_unlink (state_file);
g_free (state_file);
- camel_db_delete_folder (((CamelStore *)istore)->cdb_w, folder_name, ex);
+ camel_db_delete_folder (((CamelStore *)istore)->cdb_w, folder_name, NULL);
g_rmdir (folder_dir);
state_file = g_strdup_printf("%s/subfolders", folder_dir);
}
static gboolean
-imapx_delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+imapx_delete_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *) store;
CamelIMAPXServer *server;
+ gboolean success;
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 FALSE;
}
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (!server)
return FALSE;
- camel_imapx_server_delete_folder (server, folder_name, ex);
+ success = camel_imapx_server_delete_folder (server, folder_name, error);
g_object_unref(server);
- if (!camel_exception_is_set (ex)) {
- imapx_delete_folder_from_cache (istore, folder_name, ex);
- return FALSE;
- }
+ if (success)
+ imapx_delete_folder_from_cache (istore, folder_name);
- return TRUE;
+ return success;
}
static void
-rename_folder_info (CamelIMAPXStore *istore, const gchar *old_name, const gchar *new_name, CamelException *ex)
+rename_folder_info (CamelIMAPXStore *istore, const gchar *old_name, const gchar *new_name)
{
gint i, count;
CamelStoreInfo *si;
}
static gboolean
-imapx_rename_folder (CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+imapx_rename_folder (CamelStore *store, const gchar *old, const gchar *new, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *) store;
CamelIMAPXServer *server;
gchar *oldpath, *newpath, *storage_path;
+ gboolean success = FALSE;
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 FALSE;
}
if (istore->rec_options & IMAPX_SUBSCRIPTIONS)
- imapx_unsubscribe_folder (store, old, FALSE, ex);
+ imapx_unsubscribe_folder (store, old, FALSE, NULL);
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (server) {
- camel_imapx_server_rename_folder (server, old, new, ex);
+ success = camel_imapx_server_rename_folder (server, old, new, error);
g_object_unref(server);
}
- if (camel_exception_is_set (ex)) {
- imapx_subscribe_folder (store, old, FALSE, ex);
+ if (!success) {
+ imapx_subscribe_folder (store, old, FALSE, NULL);
return FALSE;
}
/* rename summary, and handle broken server */
- rename_folder_info(istore, old, new, ex);
+ rename_folder_info(istore, old, new);
if (istore->rec_options & IMAPX_SUBSCRIPTIONS)
- imapx_subscribe_folder (store, new, FALSE, ex);
+ success = imapx_subscribe_folder (store, new, FALSE, error);
storage_path = g_strdup_printf("%s/folders", istore->storage_path);
oldpath = imapx_path_to_physical (storage_path, old);
g_free (oldpath);
g_free (newpath);
- return !camel_exception_is_set (ex);
+ return success;
}
static CamelFolderInfo *
-imapx_create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex)
+imapx_create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GError **error)
{
CamelStoreInfo *si;
CamelIMAPXStoreNamespace *ns;
gchar *real_name, *full_name, *parent_real;
CamelFolderInfo *fi = NULL;
gchar dir_sep;
+ gboolean success;
if (CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- 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;
}
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (!server)
return NULL;
dir_sep = '/';
if (strchr(folder_name, dir_sep)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
- _("The folder name \"%s\" is invalid because it contains the character \"%c\""),
- folder_name, dir_sep);
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_PATH,
+ _("The folder name \"%s\" is invalid because it contains the character \"%c\""),
+ folder_name, dir_sep);
g_object_unref(server);
return NULL;
}
parent_real = camel_imapx_store_summary_full_from_path(istore->summary, parent_name);
if (parent_real == NULL) {
- 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);
g_object_unref(server);
return NULL;
}
si = camel_store_summary_path ((CamelStoreSummary *)istore->summary, parent_name);
if (si && si->flags & CAMEL_STORE_INFO_FOLDER_NOINFERIORS) {
- 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_object_unref(server);
return NULL;
}
full_name = imapx_concat (istore, parent_real, real_name);
g_free(real_name);
- camel_imapx_server_create_folder (server, full_name, ex);
+ success = camel_imapx_server_create_folder (server, full_name, error);
g_object_unref(server);
- if (!camel_exception_is_set (ex)) {
+ if (!success) {
CamelIMAPXStoreInfo *si;
si = camel_imapx_store_summary_add_from_full(istore->summary, full_name, dir_sep);
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;
camel_folder_info_free(v);
}
-static void
-fetch_folders_for_pattern (CamelIMAPXStore *istore, CamelIMAPXServer *server, const gchar *pattern, guint32 flags,
- const gchar *ext, GHashTable *table, CamelException *ex)
+static gboolean
+fetch_folders_for_pattern (CamelIMAPXStore *istore,
+ CamelIMAPXServer *server,
+ const gchar *pattern,
+ guint32 flags,
+ const gchar *ext,
+ GHashTable *table,
+ GError **error)
{
- GPtrArray *folders = NULL;
+ GPtrArray *folders;
- folders = camel_imapx_server_list (server, pattern, flags, ext, ex);
- if (camel_exception_is_set (ex))
- return;
+ folders = camel_imapx_server_list (server, pattern, flags, ext, error);
+ if (folders == NULL)
+ return FALSE;
add_folders_to_summary (istore, server, folders, table, (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED));
g_ptr_array_foreach (folders, free_list, folders);
g_ptr_array_free (folders, TRUE);
+
+ return TRUE;
}
static GSList *
}
static GHashTable *
-fetch_folders_for_namespaces (CamelIMAPXStore *istore, const gchar *pattern, gboolean sync, CamelException *ex)
+fetch_folders_for_namespaces (CamelIMAPXStore *istore, const gchar *pattern, gboolean sync, GError **error)
{
CamelIMAPXServer *server;
GHashTable *folders = NULL;
GSList *namespaces = NULL, *l;
- server = camel_imapx_store_get_server(istore, ex);
+ server = camel_imapx_store_get_server(istore, error);
if (!server)
return NULL;
list_ext = "RETURN (SUBSCRIBED)";
flags |= CAMEL_STORE_FOLDER_INFO_RECURSIVE;
- fetch_folders_for_pattern (istore, server, pat, flags, list_ext, folders, ex);
- if (camel_exception_is_set (ex)) {
+ if (!fetch_folders_for_pattern (istore, server, pat, flags, list_ext, folders, error)) {
g_free (pat);
goto exception;
}
/* If the server doesn't support LIST-EXTENDED then we have to
issue LSUB to list the subscribed folders separately */
flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
- fetch_folders_for_pattern (istore, server, pat, flags, NULL, folders, ex);
- if (camel_exception_is_set (ex)) {
+ if (!fetch_folders_for_pattern (istore, server, pat, flags, NULL, folders, error)) {
g_free (pat);
goto exception;
}
return NULL;
}
-static void
-sync_folders (CamelIMAPXStore *istore, const gchar *pattern, gboolean sync, CamelException *ex)
+static gboolean
+sync_folders (CamelIMAPXStore *istore, const gchar *pattern, gboolean sync, GError **error)
{
GHashTable *folders_from_server;
gint i, total;
- folders_from_server = fetch_folders_for_namespaces (istore, pattern, sync, ex);
- if (camel_exception_is_set (ex))
- return;
+ folders_from_server = fetch_folders_for_namespaces (istore, pattern, sync, error);
+ if (folders_from_server == NULL)
+ return FALSE;
total = camel_store_summary_count ((CamelStoreSummary *) istore->summary);
for (i = 0; i < total; i++) {
gchar *dup_folder_name = g_strdup (camel_store_info_path (istore->summary, si));
if (dup_folder_name) {
- CamelException eex;
-
- camel_exception_init (&eex);
- imapx_unmark_folder_subscribed (istore,dup_folder_name, TRUE, &eex);
- imapx_delete_folder_from_cache (istore, dup_folder_name, &eex);
-
+ imapx_unmark_folder_subscribed (istore,dup_folder_name, TRUE);
+ imapx_delete_folder_from_cache (istore, dup_folder_name);
g_free (dup_folder_name);
- camel_exception_clear (&eex);
} else {
camel_store_summary_remove ((CamelStoreSummary *)istore->summary, si);
}
g_hash_table_foreach (folders_from_server, imapx_get_folders_free, NULL);
g_hash_table_destroy (folders_from_server);
+
+ return TRUE;
}
struct _imapx_refresh_msg {
CamelSessionThreadMsg msg;
CamelStore *store;
- CamelException ex;
+ GError *error;
};
static void
if (CAMEL_OFFLINE_STORE(istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return;
- if (!camel_service_connect((CamelService *)istore, &m->ex))
+ if (!camel_service_connect((CamelService *)istore, &m->error))
return;
/* look in all namespaces */
- sync_folders (istore, "", FALSE, &m->ex);
+ sync_folders (istore, "", FALSE, &m->error);
camel_store_summary_save ((CamelStoreSummary *)istore->summary);
}
struct _imapx_refresh_msg *m = (struct _imapx_refresh_msg *)msg;
g_object_unref (m->store);
- camel_exception_clear(&m->ex);
+ g_clear_error (&m->error);
}
static CamelSessionThreadOps imapx_refresh_ops = {
};
static void
-discover_inbox (CamelStore *store, CamelException *ex)
+discover_inbox (CamelStore *store)
{
CamelStoreInfo *si;
CamelIMAPXStore *istore = (CamelIMAPXStore *)store;
si = camel_store_summary_path((CamelStoreSummary *) istore->summary, "INBOX");
if (si == NULL || (si->flags & CAMEL_FOLDER_SUBSCRIBED) == 0) {
- imapx_subscribe_folder (store, "INBOX", FALSE, ex);
-
- if (!camel_exception_is_set(ex) && !si)
- sync_folders (istore, "INBOX", TRUE, ex);
+ if (imapx_subscribe_folder (store, "INBOX", FALSE, NULL) && !si)
+ sync_folders (istore, "INBOX", TRUE, NULL);
if (si)
camel_store_summary_info_free((CamelStoreSummary *) istore->summary, si);
}
static CamelFolderInfo *
-imapx_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+imapx_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
CamelIMAPXStore *istore = (CamelIMAPXStore *)store;
CamelFolderInfo * fi= NULL;
g_mutex_lock (istore->get_finfo_lock);
if (CAMEL_OFFLINE_STORE(store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- fi = get_folder_info_offline (store, top, flags, ex);
+ fi = get_folder_info_offline (store, top, flags, error);
g_mutex_unlock (istore->get_finfo_lock);
return fi;
istore->last_refresh_time = time (NULL);
m = camel_session_thread_msg_new(((CamelService *)store)->session, &imapx_refresh_ops, sizeof(*m));
- m->store = store;
- g_object_ref (store);
- camel_exception_init(&m->ex);
+ m->store = g_object_ref (store);
camel_session_thread_queue(((CamelService *)store)->session, &m->msg, 0);
}
- fi = get_folder_info_offline (store, top, flags, ex);
+ fi = get_folder_info_offline (store, top, flags, error);
g_mutex_unlock (istore->get_finfo_lock);
return fi;
}
- if (!camel_service_connect((CamelService *)store, ex)) {
+ if (!camel_service_connect((CamelService *)store, error)) {
g_mutex_unlock (istore->get_finfo_lock);
return NULL;
}
if (*top && flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST) {
- fi = get_folder_info_offline (store, top, flags, ex);
+ fi = get_folder_info_offline (store, top, flags, error);
g_mutex_unlock (istore->get_finfo_lock);
return fi;
}
pattern[0] = '\0';
}
- sync_folders (istore, pattern, TRUE, ex);
- if (camel_exception_is_set (ex)) {
+ if (!sync_folders (istore, pattern, TRUE, error)) {
g_mutex_unlock (istore->get_finfo_lock);
return NULL;
}
/* ensure the INBOX is subscribed if lsub was preferred*/
if (initial_setup && istore->rec_options & IMAPX_SUBSCRIPTIONS)
- discover_inbox (store, ex);
+ discover_inbox (store);
- fi = get_folder_info_offline (store, top, flags, ex);
+ fi = get_folder_info_offline (store, top, flags, error);
g_mutex_unlock (istore->get_finfo_lock);
return fi;
}
static gboolean
-imapx_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+imapx_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
{
CamelStoreClass *store_class;
gboolean res;
+ GError *local_error = NULL;
store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class);
- res = store_class->can_refresh_folder (store, info, ex) ||
+ res = store_class->can_refresh_folder (store, info, &local_error) ||
(camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL) ||
(camel_url_get_param (((CamelService *)store)->url, "check_lsub") != NULL && (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
- if (!res && !camel_exception_is_set (ex) && CAMEL_IS_IMAPX_STORE (store)) {
+ if (!res && local_error == NULL && CAMEL_IS_IMAPX_STORE (store)) {
CamelStoreInfo *si;
CamelStoreSummary *sm = CAMEL_STORE_SUMMARY (((CamelIMAPXStore *)(store))->summary);
}
}
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
+
return res;
}
store_class->get_junk = imapx_get_junk;
store_class->noop = imapx_noop;
store_class->get_folder = imapx_get_folder;
- store_class->get_inbox = imapx_get_inbox;
store_class->hash_folder_name = imapx_hash_folder_name;
store_class->compare_folder_name = imapx_compare_folder_name;
store_class->can_refresh_folder = imapx_can_refresh_folder;
};
GType camel_imapx_store_get_type (void);
-CamelIMAPXServer *camel_imapx_store_get_server(CamelIMAPXStore *store, CamelException *ex);
+CamelIMAPXServer *camel_imapx_store_get_server(CamelIMAPXStore *store, GError **error);
G_END_DECLS
#include <ctype.h>
#include <errno.h>
-#include <glib.h>
+#include <glib/gi18n-lib.h>
#include "camel-imapx-utils.h"
#include "camel-imapx-stream.h"
-#include "camel-imapx-exception.h"
#define t(x) camel_imapx_debug(token, x)
#define io(x) camel_imapx_debug(io, x)
G_DEFINE_TYPE (CamelIMAPXStream, camel_imapx_stream, CAMEL_TYPE_STREAM)
static gint
-imapx_stream_fill (CamelIMAPXStream *is)
+imapx_stream_fill (CamelIMAPXStream *is,
+ GError **error)
{
gint left = 0;
memcpy(is->buf, is->ptr, left);
is->end = is->buf + left;
is->ptr = is->buf;
- left = camel_stream_read(is->source, (gchar *) is->end, CAMEL_IMAPX_STREAM_SIZE - (is->end - is->buf));
+ left = camel_stream_read (
+ is->source, (gchar *) is->end,
+ CAMEL_IMAPX_STREAM_SIZE - (is->end - is->buf), error);
if (left > 0) {
is->end += left;
io(printf("camel_imapx_read: buffer is '%.*s'\n", (gint)(is->end - is->ptr), is->ptr));
io(printf("camel_imapx_read: -1\n"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Source stream unavailable"));
+
return -1;
}
static gssize
imapx_stream_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelIMAPXStream *is = (CamelIMAPXStream *)stream;
gssize max;
is->ptr += max;
} else {
max = MIN(is->literal, n);
- max = camel_stream_read(is->source, buffer, max);
+ max = camel_stream_read (is->source, buffer, max, error);
if (max <= 0)
return max;
}
static gssize
imapx_stream_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelIMAPXStream *is = (CamelIMAPXStream *)stream;
io(printf("camel_imapx_write: '%.*s'\n", (gint)n, buffer));
- return camel_stream_write(is->source, buffer, n);
+ return camel_stream_write (is->source, buffer, n, error);
}
static gint
-imapx_stream_close (CamelStream *stream)
+imapx_stream_close (CamelStream *stream,
+ GError **error)
{
/* nop? */
return 0;
}
static gint
-imapx_stream_flush (CamelStream *stream)
+imapx_stream_flush (CamelStream *stream,
+ GError **error)
{
/* nop? */
return 0;
}
static gint
-imapx_stream_reset (CamelStream *stream)
+imapx_stream_reset (CamelStream *stream,
+ GError **error)
{
/* nop? reset literal mode? */
return 0;
return (CamelStream *)is;
}
+GQuark
+camel_imapx_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0)) {
+ const gchar *string = "camel-imapx-error-quark";
+ quark = g_quark_from_static_string (string);
+ }
+
+ return quark;
+}
+
/* Returns if there is any data buffered that is ready for processing */
gint
camel_imapx_stream_buffered(CamelIMAPXStream *is)
do {
while (p >= e ) {
is->ptr = p;
- if (imapx_stream_fill(is) == IMAPX_TOK_ERROR)
+ if (imapx_stream_fill(is, NULL) == IMAPX_TOK_ERROR)
return IMAPX_TOK_ERROR;
p = is->ptr;
e = is->end;
/* 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;
/* this is only 'approximate' atom */
- switch (camel_imapx_stream_token(is, data, lenp, ex)) {
+ switch (camel_imapx_stream_token(is, data, lenp, NULL)) {
case IMAPX_TOK_TOKEN:
p = *data;
while ((c = *p))
case IMAPX_TOK_ERROR:
return IMAPX_TOK_ERROR;
default:
- camel_exception_set (ex, 1, "expecting atom");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting atom");
io(printf("expecting atom!\n"));
return IMAPX_TOK_PROTOCOL;
}
/* 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;
gint ret;
- switch (camel_imapx_stream_token(is, data, &len, ex)) {
+ switch (camel_imapx_stream_token(is, data, &len, NULL)) {
case IMAPX_TOK_TOKEN:
case IMAPX_TOK_INT:
case IMAPX_TOK_STRING:
case IMAPX_TOK_LITERAL:
/* FIXME: just grow buffer */
if (len >= CAMEL_IMAPX_STREAM_TOKEN) {
- camel_exception_set (ex, 1, "astring: literal too long");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "astring: literal too long");
io(printf("astring too long\n"));
return IMAPX_TOK_PROTOCOL;
}
/* wont get unless no exception hanlder*/
return IMAPX_TOK_ERROR;
default:
- camel_exception_set (ex, 1, "expecting astring");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting astring");
io(printf("expecting astring!\n"));
return IMAPX_TOK_PROTOCOL;
}
/* 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;
gint ret;
- switch (camel_imapx_stream_token(is, data, &len, ex)) {
+ switch (camel_imapx_stream_token(is, data, &len, NULL)) {
case IMAPX_TOK_STRING:
return 0;
case IMAPX_TOK_LITERAL:
/* FIXME: just grow buffer */
if (len >= CAMEL_IMAPX_STREAM_TOKEN) {
- camel_exception_set (ex, 1, "nstring: literal too long");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "nstring: literal too long");
return IMAPX_TOK_PROTOCOL;
}
p = is->tokenptr;
return 0;
}
default:
- camel_exception_set (ex, 1, "expecting nstring");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting nstring");
return IMAPX_TOK_PROTOCOL;
case IMAPX_TOK_ERROR:
/* we'll never get this unless there are no exception handlers anyway */
/* 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;
*stream = NULL;
- switch (camel_imapx_stream_token(is, &token, &len, ex)) {
+ switch (camel_imapx_stream_token(is, &token, &len, NULL)) {
case IMAPX_TOK_STRING:
mem = camel_stream_mem_new_with_buffer((gchar *)token, len);
*stream = mem;
/* if len is big, we could automatically use a file backing */
camel_imapx_stream_set_literal(is, len);
mem = camel_stream_mem_new();
- if (camel_stream_write_to_stream((CamelStream *)is, mem) == -1) {
- camel_exception_setv (ex, 1, "nstring: io error: %s", strerror(errno));
+ if (camel_stream_write_to_stream((CamelStream *)is, mem, error) == -1) {
g_object_unref (mem);
ret = -1;
break;
}
- camel_stream_reset(mem);
+ camel_stream_reset(mem, NULL);
*stream = mem;
break;
case IMAPX_TOK_TOKEN:
}
default:
ret = -1;
- camel_exception_set (ex, 1, "nstring: token not string");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "nstring: token not string");
}
return ret;
}
guint64
-camel_imapx_stream_number(CamelIMAPXStream *is, CamelException *ex)
+camel_imapx_stream_number(CamelIMAPXStream *is, GError **error)
{
guchar *token;
guint len;
- if (camel_imapx_stream_token(is, &token, &len, ex) != IMAPX_TOK_INT) {
- camel_exception_set (ex, 1, "expecting number");
+ if (camel_imapx_stream_token(is, &token, &len, NULL) != IMAPX_TOK_INT) {
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting number");
return 0;
}
}
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;
do {
tok = camel_imapx_stream_gets(is, &token, &len);
if (tok < 0) {
- camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "io error: %s", strerror(errno));
*text = NULL;
g_byte_array_free(build, TRUE);
return -1;
/* 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;
do {
while (p >= e ) {
is->ptr = p;
- if (imapx_stream_fill(is) == IMAPX_TOK_ERROR)
- goto io_error;
+ if (imapx_stream_fill (is, error) == IMAPX_TOK_ERROR)
+ return IMAPX_TOK_ERROR;
p = is->ptr;
e = is->end;
}
}
}
is->ptr = p;
- if (imapx_stream_fill(is) == IMAPX_TOK_ERROR)
- goto io_error;
+ if (imapx_stream_fill (is, error) == IMAPX_TOK_ERROR)
+ return IMAPX_TOK_ERROR;
p = is->ptr;
e = is->end;
}
}
}
is->ptr = p;
- if (imapx_stream_fill(is) == IMAPX_TOK_ERROR)
- goto io_error;
+ if (imapx_stream_fill (is, error) == IMAPX_TOK_ERROR)
+ return IMAPX_TOK_ERROR;
p = is->ptr;
e = is->end;
}
if (c == '\\') {
while (p >= e) {
is->ptr = p;
- if (imapx_stream_fill(is) == IMAPX_TOK_ERROR)
- goto io_error;
+ if (imapx_stream_fill (is, error) == IMAPX_TOK_ERROR)
+ return IMAPX_TOK_ERROR;
p = is->ptr;
e = is->end;
}
}
}
is->ptr = p;
- if (imapx_stream_fill(is) == IMAPX_TOK_ERROR)
- goto io_error;
+ if (imapx_stream_fill (is, error) == IMAPX_TOK_ERROR)
+ return IMAPX_TOK_ERROR;
p = is->ptr;
e = is->end;
}
}
}
is->ptr = p;
- if (imapx_stream_fill(is) == IMAPX_TOK_ERROR)
- goto io_error;
+ if (imapx_stream_fill (is, error) == IMAPX_TOK_ERROR)
+ return IMAPX_TOK_ERROR;
p = is->ptr;
e = is->end;
}
}
- /* Had an i/o erorr */
-io_error:
- camel_exception_set (ex, 1, "io error");
- return IMAPX_TOK_ERROR;
-
/* Protocol error, skip until next lf? */
protocol_error:
io(printf("Got protocol error\n"));
else
is->ptr = p;
- camel_exception_set (ex, 1, "protocol error");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "protocol error");
return IMAPX_TOK_PROTOCOL;
}
max = is->end - is->ptr;
if (max == 0) {
- max = imapx_stream_fill(is);
+ max = imapx_stream_fill(is, NULL);
if (max <= 0)
return max;
}
if (is->literal > 0) {
max = is->end - is->ptr;
if (max == 0) {
- max = imapx_stream_fill(is);
+ max = imapx_stream_fill(is, NULL);
if (max <= 0)
return max;
}
/* 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;
guint len;
do {
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, error);
if (tok == IMAPX_TOK_LITERAL) {
camel_imapx_stream_set_literal(is, len);
while ((tok = camel_imapx_stream_getl(is, &token, &len)) > 0) {
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_IMAPX_STREAM, CamelIMAPXStreamClass))
+#define CAMEL_IMAPX_ERROR \
+ (camel_imapx_error_quark ())
+
G_BEGIN_DECLS
typedef struct _CamelIMAPXStream CamelIMAPXStream;
};
GType camel_imapx_stream_get_type (void);
+GQuark camel_imapx_error_quark (void) G_GNUC_CONST;
CamelStream * camel_imapx_stream_new (CamelStream *source);
gint camel_imapx_stream_buffered (CamelIMAPXStream *is);
camel_imapx_stream_token (CamelIMAPXStream *is,
guchar **start,
guint *len,
- CamelException *ex);
+ GError **error);
void camel_imapx_stream_ungettoken (CamelIMAPXStream *is,
camel_imapx_token_t tok,
gint camel_imapx_stream_atom (CamelIMAPXStream *is,
guchar **start,
guint *len,
- CamelException *ex);
+ GError **error);
/* gets an atom or string */
gint camel_imapx_stream_astring (CamelIMAPXStream *is,
guchar **start,
- CamelException *ex);
+ GError **error);
/* gets a NIL or a string, start==NULL if NIL */
gint camel_imapx_stream_nstring (CamelIMAPXStream *is,
guchar **start,
- CamelException *ex);
+ 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);
+ GError **error);
/* gets 'text' */
gint camel_imapx_stream_text (CamelIMAPXStream *is,
guchar **text,
- CamelException *ex);
+ GError **error);
/* gets a 'number' */
guint64 camel_imapx_stream_number (CamelIMAPXStream *is,
- CamelException *ex);
+ GError **error);
/* skips the rest of a line, including literals, etc */
gint camel_imapx_stream_skip (CamelIMAPXStream *is,
- CamelException *ex);
+ GError **error);
G_END_DECLS
static CamelMessageContentInfo *content_info_migrate (CamelFolderSummary *s, FILE *in);
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);
{
CamelStore *parent_store;
CamelFolderSummary *summary;
- CamelException ex;
- camel_exception_init (&ex);
+ GError *local_error = NULL;
parent_store = camel_folder_get_parent_store (folder);
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. ? */
+ We need to pass the error 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);
}
static CamelFIRecord *
-summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+summary_header_to_db (CamelFolderSummary *s, GError **error)
{
CamelIMAPXSummary *ims = CAMEL_IMAPX_SUMMARY(s);
CamelFolderSummaryClass *folder_summary_class;
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
camel_imapx_summary_parent_class);
- fir = folder_summary_class->summary_header_to_db (s, ex);
+ fir = folder_summary_class->summary_header_to_db (s, error);
if (!fir)
return NULL;
fir->bdata = g_strdup_printf ("%d %llu %u %llu", CAMEL_IMAPX_SUMMARY_VERSION,
#include "camel-imapx-summary.h"
#include "camel-imapx-store-summary.h"
#include "camel-imapx-utils.h"
-#include "camel-imapx-exception.h"
/* high-level parser state */
#define p(x) camel_imapx_debug(parse, x)
shoudl this be part of imapx-driver? */
/* mabye this should be a stream op? */
void
-imapx_parse_flags(CamelIMAPXStream *stream, guint32 *flagsp, CamelFlag **user_flagsp, CamelException *ex)
+imapx_parse_flags(CamelIMAPXStream *stream, guint32 *flagsp, CamelFlag **user_flagsp, GError **error)
/* throws IO,PARSE exception */
{
gint tok, i;
*flagsp = flags;
- tok = camel_imapx_stream_token(stream, &token, &len, ex);
+ tok = camel_imapx_stream_token(stream, &token, &len, NULL);
if (tok == '(') {
do {
- tok = camel_imapx_stream_token(stream, &token, &len, ex);
+ tok = camel_imapx_stream_token(stream, &token, &len, NULL);
if (tok == IMAPX_TOK_TOKEN) {
p = token;
// FIXME: ascii_toupper
found:
tok = tok; /* fixes stupid warning */
} else if (tok != ')') {
- camel_exception_set (ex, 1, "expecting flag");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting flag");
return;
}
} while (tok != ')');
} else {
- camel_exception_set (ex, 1, "expecting flag list");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "execting flag list");
return;
}
}
void
-imapx_write_flags(CamelStream *stream, guint32 flags, CamelFlag *user_flags, CamelException *ex)
+imapx_write_flags(CamelStream *stream, guint32 flags, CamelFlag *user_flags, GError **error)
/* throws IO exception */
{
gint i;
gboolean first = TRUE;
- if (camel_stream_write(stream, "(", 1) == -1) {
- camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
+ if (camel_stream_write(stream, "(", 1, error) == -1) {
return;
}
if (flag_table[i].flag & flags) {
if (flags & CAMEL_IMAPX_MESSAGE_RECENT)
continue;
- if (!first && camel_stream_write(stream, " ", 1) == -1) {
- camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
+ if (!first && camel_stream_write(stream, " ", 1, error) == -1) {
return;
}
first = FALSE;
- if (camel_stream_write (stream, flag_table[i].name, strlen(flag_table[i].name)) == -1) {
- camel_exception_setv (ex,1, "io error: %s", strerror(errno));
+ if (camel_stream_write (stream, flag_table[i].name, strlen(flag_table[i].name), error) == -1) {
return;
}
while (user_flags) {
const gchar *flag_name = rename_label_flag (user_flags->name, strlen (user_flags->name), FALSE);
- if (!first && camel_stream_write(stream, " ", 1) == -1) {
- camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
+ if (!first && camel_stream_write(stream, " ", 1, error) == -1) {
return;
}
first = FALSE;
- if (camel_stream_write(stream, flag_name, strlen (flag_name)) == -1) {
- camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
+ if (camel_stream_write(stream, flag_name, strlen (flag_name), error) == -1) {
return;
}
user_flags = user_flags->next;
}
- if (camel_stream_write(stream, ")", 1) == -1) {
- camel_exception_setv (ex, 1, "io error: %s", strerror(errno));
+ if (camel_stream_write(stream, ")", 1, error) == -1) {
return;
}
}
};
struct _capability_info *
-imapx_parse_capability(CamelIMAPXStream *stream, CamelException *ex)
+imapx_parse_capability(CamelIMAPXStream *stream, GError **error)
{
gint tok, i;
guint len;
guchar *token, *p, c;
gboolean free_token = FALSE;
struct _capability_info * cinfo;
+ GError *local_error = NULL;
cinfo = g_malloc0(sizeof(*cinfo));
cinfo->auth_types = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
/* FIXME: handle auth types */
- while ((tok = camel_imapx_stream_token(stream, &token, &len, ex)) != '\n' &&
- !camel_exception_is_set (ex)) {
+ while ((tok = camel_imapx_stream_token(stream, &token, &len, &local_error)) != '\n' &&
+ local_error == NULL) {
switch (tok) {
case ']':
/* Put it back so that imapx_untagged() isn't unhappy */
free_token = FALSE;
break;
default:
- camel_exception_set (ex, 1, "capability: expecting name");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "capability: expecting name");
break;
}
}
- if (camel_exception_is_set (ex)) {
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
imapx_free_capability(cinfo);
cinfo = NULL;
}
}
struct _CamelIMAPXNamespaceList *
-imapx_parse_namespace_list (CamelIMAPXStream *stream, CamelException *ex)
+imapx_parse_namespace_list (CamelIMAPXStream *stream, GError **error)
{
CamelIMAPXStoreNamespace *namespaces[3], *node, *tail;
CamelIMAPXNamespaceList *nsl = NULL;
nsl->shared = NULL;
nsl->other = NULL;
- tok = camel_imapx_stream_token (stream, &token, &len, ex);
+ tok = camel_imapx_stream_token (stream, &token, &len, NULL);
do {
namespaces[n] = NULL;
tail = (CamelIMAPXStoreNamespace *) &namespaces[n];
if (tok == '(') {
- tok = camel_imapx_stream_token (stream, &token, &len, ex);
+ tok = camel_imapx_stream_token (stream, &token, &len, NULL);
while (tok == '(') {
- tok = camel_imapx_stream_token (stream, &token, &len, ex);
+ tok = camel_imapx_stream_token (stream, &token, &len, NULL);
if (tok != IMAPX_TOK_STRING) {
- camel_exception_set (ex, 1, "namespace: expected a string path name");
+ g_set_error (error, 1, CAMEL_IMAPX_ERROR, "namespace: expected a string path name");
goto exception;
}
node->next = NULL;
node->path = g_strdup ((gchar *) token);
- tok = camel_imapx_stream_token (stream, &token, &len, ex);
+ tok = camel_imapx_stream_token (stream, &token, &len, NULL);
if (tok == IMAPX_TOK_STRING) {
if (strlen ((gchar *) token) == 1) {
/* will a NIL be possible here? */
node->sep = '\0';
} else {
- camel_exception_set (ex, 1, "namespace: expected a string separator");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "namespace: expected a string separtor");
g_free (node->path);
g_free (node);
goto exception;
/* TODO remove full_name later. not required */
node->full_name = g_strdup (node->path);
- tok = camel_imapx_stream_token (stream, &token, &len, ex);
+ tok = camel_imapx_stream_token (stream, &token, &len, NULL);
if (tok != ')') {
- camel_exception_set (ex, 1, "namespace: expected a ')'");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "namespace: expected a ')'");
goto exception;
}
- tok = camel_imapx_stream_token (stream, &token, &len, ex);
+ tok = camel_imapx_stream_token (stream, &token, &len, NULL);
}
if (tok != ')') {
- camel_exception_set (ex, 1, "namespace: expected a ')'");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "namespace: expected a ')'");
goto exception;
}
} else if (tok == IMAPX_TOK_TOKEN && !strcmp ((gchar *) token, "NIL")) {
namespaces [n] = NULL;
} else {
- camel_exception_set (ex, 1, "namespace: expected either a '(' or NIL");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "namespace: expected either a '(' or NIL");
goto exception;
}
- tok = camel_imapx_stream_token (stream, &token, &len, ex);
+ tok = camel_imapx_stream_token (stream, &token, &len, NULL);
n++;
} while (n < 3);
g_free(cinfo);
}
-void
-imapx_parse_param_list(CamelIMAPXStream *is, struct _camel_header_param **plist, CamelException *ex)
+gboolean
+imapx_parse_param_list(CamelIMAPXStream *is, struct _camel_header_param **plist, GError **error)
{
gint tok;
guint len;
p(printf("body_fld_param\n"));
/* body_fld_param ::= "(" 1#(string SPACE string) ")" / nil */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok == '(') {
while (1) {
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok == ')')
break;
camel_imapx_stream_ungettoken(is, tok, token, len);
- camel_imapx_stream_astring(is, &token, ex);
+ camel_imapx_stream_astring(is, &token, NULL);
param = alloca (strlen ((gchar *) token)+1);
strcpy(param, (gchar *) token);
- camel_imapx_stream_astring(is, &token, ex);
+ camel_imapx_stream_astring(is, &token, NULL);
camel_header_set_param(plist, param, (gchar *) token);
}
} /* else check nil? no need */
+
+ return TRUE;
}
struct _CamelContentDisposition *
-imapx_parse_ext_optional(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_ext_optional(CamelIMAPXStream *is, GError **error)
{
gint tok;
guint len;
guchar *token;
struct _CamelContentDisposition *dinfo = NULL;
+ GError *local_error = NULL;
/* this parses both extension types, from the body_fld_dsp onwards */
/* although the grammars are different, they can be parsed the same way */
/* body_fld_dsp ::= "(" string SPACE body_fld_param ")" / nil */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
switch (tok) {
case '(':
dinfo = g_malloc0(sizeof(*dinfo));
dinfo->refcount = 1;
/* should be string */
- camel_imapx_stream_astring(is, &token, ex);
+ camel_imapx_stream_astring(is, &token, NULL);
dinfo->disposition = g_strdup((gchar *) token);
- imapx_parse_param_list(is, &dinfo->params, ex);
+ imapx_parse_param_list(is, &dinfo->params, NULL);
case IMAPX_TOK_TOKEN:
d(printf("body_fld_dsp: NIL\n"));
break;
default:
- camel_exception_set (ex, 1, "body_fld_disp: expecting nil or list");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "body_fld_disp: expecting nil or list");
return NULL;
}
/* we just drop the lang string/list, save it somewhere? */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
switch (tok) {
case '(':
while (1) {
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok == ')') {
break;
} else if (tok != IMAPX_TOK_STRING) {
- camel_exception_set (ex, 1, "expecting string");
+ g_clear_error (&local_error);
+ g_set_error (&local_error, CAMEL_IMAPX_ERROR, 1, "expecting string");
break;
}
}
}
- if camel_exception_is_set (ex) {
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
if (dinfo)
camel_content_disposition_unref(dinfo);
+ dinfo = NULL;
}
return dinfo;
}
struct _CamelMessageContentInfo *
-imapx_parse_body_fields(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_body_fields(CamelIMAPXStream *is, GError **error)
{
guchar *token;
gchar *type;
struct _CamelMessageContentInfo *cinfo;
+ GError *local_error = NULL;
/* body_fields ::= body_fld_param SPACE body_fld_id SPACE
body_fld_desc SPACE body_fld_enc SPACE
cinfo = g_malloc0(sizeof(*cinfo));
/* this should be string not astring */
- camel_imapx_stream_astring(is, &token, ex);
- if (camel_exception_is_set (ex))
+ if (!camel_imapx_stream_astring(is, &token, error))
goto error;
type = alloca(strlen( (gchar *) token)+1);
strcpy(type, (gchar *) token);
- camel_imapx_stream_astring(is, &token, ex);
- if (camel_exception_is_set (ex))
+ if (!camel_imapx_stream_astring(is, &token, error))
goto error;
cinfo->type = camel_content_type_new(type, (gchar *) token);
- imapx_parse_param_list(is, &cinfo->type->params, ex);
- if (camel_exception_is_set (ex))
+ if (!imapx_parse_param_list(is, &cinfo->type->params, error))
goto error;
/* body_fld_id ::= nstring */
- camel_imapx_stream_nstring(is, &token, ex);
- if (camel_exception_is_set (ex))
+ if (!camel_imapx_stream_nstring(is, &token, error))
goto error;
cinfo->id = g_strdup((gchar *) token);
/* body_fld_desc ::= nstring */
- camel_imapx_stream_nstring(is, &token, ex);
- if (camel_exception_is_set (ex))
+ if (!camel_imapx_stream_nstring(is, &token, error))
goto error;
cinfo->description = g_strdup((gchar *) token);
/* body_fld_enc ::= (<"> ("7BIT" / "8BIT" / "BINARY" / "BASE64"/
"QUOTED-PRINTABLE") <">) / string */
- camel_imapx_stream_astring(is, &token, ex);
- if (camel_exception_is_set (ex))
+ if (!camel_imapx_stream_astring(is, &token, error))
goto error;
cinfo->encoding = g_strdup((gchar *) token);
/* body_fld_octets ::= number */
- cinfo->size = camel_imapx_stream_number(is, ex);
- if (camel_exception_is_set (ex))
+ cinfo->size = camel_imapx_stream_number(is, &local_error);
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
goto error;
+ }
return cinfo;
error:
}
struct _camel_header_address *
-imapx_parse_address_list(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_address_list(CamelIMAPXStream *is, GError **error)
/* throws PARSE,IO exception */
{
gint tok;
guchar *token, *host;
gchar *mbox;
struct _camel_header_address *list = NULL;
+ GError *local_error = NULL;
/* "(" 1*address ")" / nil */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok == '(') {
while (1) {
struct _camel_header_address *addr, *group = NULL;
/* address ::= "(" addr_name SPACE addr_adl SPACE addr_mailbox
SPACE addr_host ")" */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok == ')')
break;
if (tok != '(') {
+ g_clear_error (&local_error);
camel_header_address_list_clear(&list);
- camel_exception_set (ex, 1, "missing '(' for address");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "missing '(' for address");
return NULL;
}
addr = camel_header_address_new();
addr->type = CAMEL_HEADER_ADDRESS_NAME;
- tok = camel_imapx_stream_nstring(is, &token, ex);
+ tok = camel_imapx_stream_nstring(is, &token, &local_error);
addr->name = g_strdup((gchar *) token);
/* we ignore the route, nobody uses it in the real world */
- tok = camel_imapx_stream_nstring(is, &token, ex);
+ tok = camel_imapx_stream_nstring(is, &token, &local_error);
/* [RFC-822] group syntax is indicated by a special
form of address structure in which the host name
non-NIL, this is a start of group marker, and the
mailbox name field holds the group name phrase. */
- tok = camel_imapx_stream_nstring(is,(guchar **) &mbox, ex);
+ tok = camel_imapx_stream_nstring(is,(guchar **) &mbox, &local_error);
mbox = g_strdup(mbox);
- tok = camel_imapx_stream_nstring(is, &host, ex);
+ tok = camel_imapx_stream_nstring(is, &host, &local_error);
if (host == NULL) {
if (mbox == NULL) {
group = NULL;
camel_header_address_list_append(&list, addr);
}
do {
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
} while (tok != ')');
}
} else {
}
/* CHEN TODO handle exception at required places */
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
return list;
}
struct _CamelMessageInfo *
-imapx_parse_envelope(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_envelope(CamelIMAPXStream *is, GError **error)
{
gint tok;
guint len;
struct _camel_header_address *addr, *addr_from;
gchar *addrstr;
struct _CamelMessageInfoBase *minfo;
+ GError *local_error = NULL;
/* envelope ::= "(" env_date SPACE env_subject SPACE env_from
SPACE env_sender SPACE env_reply_to SPACE env_to
minfo = (CamelMessageInfoBase *)camel_message_info_new(NULL);
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok != '(') {
+ g_clear_error (&local_error);
camel_message_info_free(minfo);
- camel_exception_set (ex, 1, "envelope: expecting '('");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "envelope: expecting '('");
return NULL;
}
/* env_date ::= nstring */
- camel_imapx_stream_nstring(is, &token, ex);
+ camel_imapx_stream_nstring(is, &token, &local_error);
minfo->date_sent = camel_header_decode_date((gchar *) token, NULL);
/* env_subject ::= nstring */
- tok = camel_imapx_stream_nstring(is, &token, ex);
+ tok = camel_imapx_stream_nstring(is, &token, &local_error);
minfo->subject = camel_pstring_strdup((gchar *) token);
/* we merge from/sender into from, append should probably merge more smartly? */
/* env_from ::= "(" 1*address ")" / nil */
- addr_from = imapx_parse_address_list(is, ex);
+ addr_from = imapx_parse_address_list(is, &local_error);
/* env_sender ::= "(" 1*address ")" / nil */
- addr = imapx_parse_address_list(is, ex);
+ addr = imapx_parse_address_list(is, &local_error);
if (addr_from) {
camel_header_address_list_clear(&addr);
#if 0
/* we dont keep reply_to */
/* env_reply_to ::= "(" 1*address ")" / nil */
- addr = imapx_parse_address_list(is, ex);
+ addr = imapx_parse_address_list(is, &local_error);
camel_header_address_list_clear(&addr);
/* env_to ::= "(" 1*address ")" / nil */
- addr = imapx_parse_address_list(is, ex);
+ addr = imapx_parse_address_list(is, &local_error);
if (addr) {
addrstr = camel_header_address_list_format(addr);
minfo->to = camel_pstring_strdup(addrstr);
}
/* env_cc ::= "(" 1*address ")" / nil */
- addr = imapx_parse_address_list(is, ex);
+ addr = imapx_parse_address_list(is, &local_error);
if (addr) {
addrstr = camel_header_address_list_format(addr);
minfo->cc = camel_pstring_strdup(addrstr);
/* we dont keep bcc either */
/* env_bcc ::= "(" 1*address ")" / nil */
- addr = imapx_parse_address_list(is, ex);
+ addr = imapx_parse_address_list(is, &local_error);
camel_header_address_list_clear(&addr);
/* FIXME: need to put in-reply-to into references hash list */
/* env_in_reply_to ::= nstring */
- tok = camel_imapx_stream_nstring(is, &token, ex);
+ tok = camel_imapx_stream_nstring(is, &token, &local_error);
/* FIXME: need to put message-id into message-id hash */
/* env_message_id ::= nstring */
- tok = camel_imapx_stream_nstring(is, &token, ex);
+ tok = camel_imapx_stream_nstring(is, &token, &local_error);
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok != ')') {
+ g_clear_error (&local_error);
camel_message_info_free(minfo);
- camel_exception_set (ex, 1, "expecting ')'");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting ')'");
return NULL;
}
/* CHEN TODO handle exceptions better */
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
return (CamelMessageInfo *)minfo;
}
struct _CamelMessageContentInfo *
-imapx_parse_body(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_body(CamelIMAPXStream *is, GError **error)
{
gint tok;
guint len;
struct _CamelMessageContentInfo *subinfo, *last;
struct _CamelContentDisposition * dinfo = NULL;
struct _CamelMessageInfo * minfo = NULL;
+ GError *local_error = NULL;
/* body ::= "(" body_type_1part / body_type_mpart ")" */
p(printf("body\n"));
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok != '(') {
- camel_exception_set (ex, 1, "body: expecting '('");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "body: expecting '('");
return NULL;
}
/* 1*body (optional for multiparts) */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
camel_imapx_stream_ungettoken(is, tok, token, len);
if (tok == '(') {
/* body_type_mpart ::= 1*body SPACE media_subtype
cinfo = g_malloc0(sizeof(*cinfo));
last = (struct _CamelMessageContentInfo *)&cinfo->childs;
do {
- subinfo = imapx_parse_body(is, ex);
+ subinfo = imapx_parse_body(is, &local_error);
last->next = subinfo;
last = subinfo;
subinfo->parent = cinfo;
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
camel_imapx_stream_ungettoken(is, tok, token, len);
} while (tok == '(');
d(printf("media_subtype\n"));
- camel_imapx_stream_astring(is, &token, ex);
+ camel_imapx_stream_astring(is, &token, &local_error);
cinfo->type = camel_content_type_new("multipart", (gchar *) token);
/* body_ext_mpart ::= body_fld_param
d(printf("body_ext_mpart\n"));
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
camel_imapx_stream_ungettoken(is, tok, token, len);
if (tok == '(') {
- imapx_parse_param_list(is, &cinfo->type->params, ex);
+ imapx_parse_param_list(is, &cinfo->type->params, &local_error);
/* body_fld_dsp ::= "(" string SPACE body_fld_param ")" / nil */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
camel_imapx_stream_ungettoken(is, tok, token, len);
if (tok == '(' || tok == IMAPX_TOK_TOKEN) {
- dinfo = imapx_parse_ext_optional(is, ex);
+ dinfo = imapx_parse_ext_optional(is, &local_error);
/* other extension fields?, soaked up below */
} else {
camel_imapx_stream_ungettoken(is, tok, token, len);
d(printf("Single part body\n"));
- cinfo = imapx_parse_body_fields(is, ex);
+ cinfo = imapx_parse_body_fields(is, &local_error);
d(printf("envelope?\n"));
/* do we have an envelope following */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
camel_imapx_stream_ungettoken(is, tok, token, len);
if (tok == '(') {
/* what do we do with the envelope?? */
- minfo = imapx_parse_envelope(is, ex);
+ minfo = imapx_parse_envelope(is, &local_error);
/* what do we do with the message content info?? */
//((CamelMessageInfoBase *)minfo)->content = imapx_parse_body(is);
camel_message_info_free(minfo);
d(printf("fld_lines?\n"));
/* do we have fld_lines following? */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok == IMAPX_TOK_INT) {
d(printf("field lines: %s\n", token));
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
}
camel_imapx_stream_ungettoken(is, tok, token, len);
d(printf("extension data?\n"));
if (tok != ')') {
- camel_imapx_stream_nstring(is, &token, ex);
+ camel_imapx_stream_nstring(is, &token, &local_error);
d(printf("md5: %s\n", token?(gchar *)token:"NIL"));
/* body_fld_dsp ::= "(" string SPACE body_fld_param ")" / nil */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
camel_imapx_stream_ungettoken(is, tok, token, len);
if (tok == '(' || tok == IMAPX_TOK_TOKEN) {
- dinfo = imapx_parse_ext_optional(is, ex);
+ dinfo = imapx_parse_ext_optional(is, &local_error);
/* then other extension fields, soaked up below */
}
}
/* soak up any other extension fields that may be present */
/* there should only be simple tokens, no lists */
do {
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, &local_error);
if (tok != ')') {
d(printf("Dropping extension data '%s'\n", token));
}
} while (tok != ')');
/* CHEN TODO handle exceptions better */
- if (camel_exception_is_set (ex)) {
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
if (cinfo)
imapx_free_body(cinfo);
if (dinfo)
}
gchar *
-imapx_parse_section(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_section(CamelIMAPXStream *is, GError **error)
{
gint tok;
guint len;
SPACE header_list / "TEXT"
*/
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok != '[') {
- camel_exception_set (ex, 1, "section: expecting '['");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "section: expecting '['");
return NULL;
}
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok == IMAPX_TOK_INT || tok == IMAPX_TOK_TOKEN)
section = g_strdup((gchar *) token);
else if (tok == ']') {
section = g_strdup("");
camel_imapx_stream_ungettoken(is, tok, token, len);
} else {
- camel_exception_set (ex, 1, "section: expecting token");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "section: expecting token");
return NULL;
}
header_fld_name ::= astring */
/* we dont need the header specifiers */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok == '(') {
do {
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok == IMAPX_TOK_STRING || tok == IMAPX_TOK_TOKEN || tok == IMAPX_TOK_INT) {
/* ?do something? */
} else if (tok != ')') {
- camel_exception_set (ex, 1, "section: header fields: expecting string");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "section: header fields: expecting string");
g_free (section);
return NULL;
}
} while (tok != ')');
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
}
if (tok != ']') {
- camel_exception_set (ex, 1, "section: expecting ']'");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "section: expecting ']'");
g_free(section);
return NULL;
}
}
static guint64
-imapx_parse_modseq(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_modseq(CamelIMAPXStream *is, GError **error)
{
guint64 ret;
gint tok;
guchar *token;
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok != '(') {
- camel_exception_set (ex, 1, "fetch: expecting '('");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "fetch: expecting '('");
return 0;
}
- ret = camel_imapx_stream_number(is, ex);
- if (camel_exception_is_set(ex))
+ ret = camel_imapx_stream_number(is, error);
+ if (ret == 0)
return 0;
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok != ')') {
- camel_exception_set (ex, 1, "fetch: expecting '('");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "fetch: expecting '('");
return 0;
}
return ret;
sout = camel_stream_fs_new_with_fd(fd);
if (finfo->body) {
camel_stream_printf(sout, "Body content:\n");
- camel_stream_write_to_stream(finfo->body, sout);
- camel_stream_reset(finfo->body);
+ camel_stream_write_to_stream(finfo->body, sout, NULL);
+ camel_stream_reset(finfo->body, NULL);
}
if (finfo->text) {
camel_stream_printf(sout, "Text content:\n");
- camel_stream_write_to_stream(finfo->text, sout);
- camel_stream_reset(finfo->text);
+ camel_stream_write_to_stream(finfo->text, sout, NULL);
+ camel_stream_reset(finfo->text, NULL);
}
if (finfo->header) {
camel_stream_printf(sout, "Header content:\n");
- camel_stream_write_to_stream(finfo->header, sout);
- camel_stream_reset(finfo->header);
+ camel_stream_write_to_stream(finfo->header, sout, NULL);
+ camel_stream_reset(finfo->header, NULL);
}
if (finfo->minfo) {
camel_stream_printf(sout, "Message Info:\n");
}
struct _fetch_info *
-imapx_parse_fetch(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_fetch(CamelIMAPXStream *is, GError **error)
{
gint tok;
guint len;
finfo = g_malloc0(sizeof(*finfo));
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok != '(') {
- camel_exception_set (ex, 1, "fetch: expecting '('");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "fetch: expecting '('");
g_free (finfo);
return NULL;
}
- while ((tok = camel_imapx_stream_token(is, &token, &len, ex)) == IMAPX_TOK_TOKEN) {
+ while ((tok = camel_imapx_stream_token(is, &token, &len, NULL)) == IMAPX_TOK_TOKEN) {
p = token;
while ((c=*p))
switch (imapx_tokenise((gchar *) token, len)) {
case IMAPX_ENVELOPE:
- finfo->minfo = imapx_parse_envelope(is, ex);
+ finfo->minfo = imapx_parse_envelope(is, NULL);
finfo->got |= FETCH_MINFO;
break;
case IMAPX_FLAGS:
- imapx_parse_flags(is, &finfo->flags, &finfo->user_flags, ex);
+ imapx_parse_flags(is, &finfo->flags, &finfo->user_flags, NULL);
finfo->got |= FETCH_FLAGS;
break;
case IMAPX_INTERNALDATE:
- camel_imapx_stream_nstring(is, &token, ex);
+ camel_imapx_stream_nstring(is, &token, NULL);
/* TODO: convert to camel format? */
finfo->date = g_strdup((gchar *) token);
finfo->got |= FETCH_DATE;
break;
case IMAPX_RFC822_HEADER:
- camel_imapx_stream_nstring_stream(is, &finfo->header, ex);
+ camel_imapx_stream_nstring_stream(is, &finfo->header, NULL);
finfo->got |= FETCH_HEADER;
break;
case IMAPX_RFC822_TEXT:
- camel_imapx_stream_nstring_stream(is, &finfo->text, ex);
+ camel_imapx_stream_nstring_stream(is, &finfo->text, NULL);
finfo->got |= FETCH_TEXT;
break;
case IMAPX_RFC822_SIZE:
- finfo->size = camel_imapx_stream_number(is, ex);
+ finfo->size = camel_imapx_stream_number(is, NULL);
finfo->got |= FETCH_SIZE;
break;
case IMAPX_BODYSTRUCTURE:
- finfo->cinfo = imapx_parse_body(is, ex);
+ finfo->cinfo = imapx_parse_body(is, NULL);
finfo->got |= FETCH_CINFO;
break;
case IMAPX_MODSEQ:
- finfo->modseq = imapx_parse_modseq(is, ex);
+ finfo->modseq = imapx_parse_modseq(is, NULL);
finfo->got |= FETCH_MODSEQ;
break;
case IMAPX_BODY:
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
camel_imapx_stream_ungettoken(is, tok, token, len);
if (tok == '(') {
- finfo->cinfo = imapx_parse_body(is, ex);
+ finfo->cinfo = imapx_parse_body(is, NULL);
finfo->got |= FETCH_CINFO;
} else if (tok == '[') {
- finfo->section = imapx_parse_section(is, ex);
+ finfo->section = imapx_parse_section(is, NULL);
finfo->got |= FETCH_SECTION;
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (token[0] == '<') {
finfo->offset = strtoul((gchar *) token+1, NULL, 10);
} else {
camel_imapx_stream_ungettoken(is, tok, token, len);
}
- camel_imapx_stream_nstring_stream(is, &finfo->body, ex);
+ camel_imapx_stream_nstring_stream(is, &finfo->body, NULL);
finfo->got |= FETCH_BODY;
} else {
- camel_exception_set (ex, 1, "unknown body response");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "unknown body response");
imapx_free_fetch(finfo);
return NULL;
}
break;
case IMAPX_UID:
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok != IMAPX_TOK_INT) {
- camel_exception_set (ex, 1, "uid not integer");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "uid not integer");
}
finfo->uid = g_strdup((gchar *) token);
break;
default:
imapx_free_fetch(finfo);
- camel_exception_set (ex, 1, "unknown body response");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "unknown body response");
return NULL;
}
}
if (tok != ')') {
- camel_exception_set (ex, 1, "missing closing ')' on fetch response");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "missing closing ')' on fetch response");
imapx_free_fetch (finfo);
return NULL;
}
}
struct _state_info *
-imapx_parse_status_info (struct _CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_status_info (struct _CamelIMAPXStream *is, GError **error)
{
struct _state_info *sinfo;
gint tok;
sinfo = g_malloc0 (sizeof(*sinfo));
/* skip the folder name */
- camel_imapx_stream_astring (is, &token, ex);
- if (camel_exception_is_set(ex)) {
+ if (!camel_imapx_stream_astring (is, &token, error)) {
g_free (sinfo);
return NULL;
}
sinfo->name = camel_utf7_utf8 ((gchar *)token);
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok != '(') {
- camel_exception_set (ex, 1, "parse status info: expecting '('");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "parse status info: expecting '('");
g_free (sinfo);
return NULL;
}
- while ((tok = camel_imapx_stream_token(is, &token, &len, ex)) == IMAPX_TOK_TOKEN) {
+ while ((tok = camel_imapx_stream_token(is, &token, &len, NULL)) == IMAPX_TOK_TOKEN) {
switch (imapx_tokenise((gchar *) token, len)) {
case IMAPX_MESSAGES:
- sinfo->messages = camel_imapx_stream_number (is, ex);
+ sinfo->messages = camel_imapx_stream_number (is, NULL);
break;
case IMAPX_RECENT:
- sinfo->recent = camel_imapx_stream_number (is, ex);
+ sinfo->recent = camel_imapx_stream_number (is, NULL);
break;
case IMAPX_UIDNEXT:
- sinfo->uidnext = camel_imapx_stream_number (is, ex);
+ sinfo->uidnext = camel_imapx_stream_number (is, NULL);
break;
case IMAPX_UIDVALIDITY:
- sinfo->uidvalidity = camel_imapx_stream_number (is, ex);
+ sinfo->uidvalidity = camel_imapx_stream_number (is, NULL);
break;
case IMAPX_UNSEEN:
- sinfo->unseen = camel_imapx_stream_number (is, ex);
+ sinfo->unseen = camel_imapx_stream_number (is, NULL);
break;
case IMAPX_HIGHESTMODSEQ:
- sinfo->highestmodseq = camel_imapx_stream_number (is, ex);
+ sinfo->highestmodseq = camel_imapx_stream_number (is, NULL);
break;
case IMAPX_NOMODSEQ:
break;
default:
g_free (sinfo);
- camel_exception_set (ex, 1, "unknown status response");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "unknown status response");
return NULL;
}
}
if (tok != ')') {
- camel_exception_set (ex, 1, "missing closing ')' on status response");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "missing closing ')' on status response");
g_free (sinfo);
return NULL;
}
}
GPtrArray *
-imapx_parse_uids (CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_uids (CamelIMAPXStream *is, GError **error)
{
GPtrArray *uids = g_ptr_array_new ();
guchar *token;
guint len, str_len;
gint tok, i;
- tok = camel_imapx_stream_token (is, &token, &len, ex);
+ tok = camel_imapx_stream_token (is, &token, &len, NULL);
splits = g_strsplit ((gchar *) token, ",", -1);
str_len = g_strv_length (splits);
/* rfc 2060 section 7.1 Status Responses */
/* shoudl this start after [ or before the [? token_unget anyone? */
struct _status_info *
-imapx_parse_status(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_status(CamelIMAPXStream *is, GError **error)
{
gint tok;
guint len;
sinfo = g_malloc0(sizeof(*sinfo));
- camel_imapx_stream_atom(is, &token, &len, ex);
+ camel_imapx_stream_atom(is, &token, &len, NULL);
/*
resp_cond_auth ::= ("OK" / "PREAUTH") SPACE resp_text
case IMAPX_BYE:
break;
default:
- camel_exception_set (ex, 1, "expecting OK/NO/BAD");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting OK/NO/BAD");
g_free (sinfo);
return NULL;
}
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok == '[') {
- camel_imapx_stream_atom(is, &token, &len, ex);
+ camel_imapx_stream_atom(is, &token, &len, NULL);
sinfo->condition = imapx_tokenise((gchar *) token, len);
/* parse any details */
case IMAPX_CLOSED:
break;
case IMAPX_APPENDUID:
- sinfo->u.appenduid.uidvalidity = camel_imapx_stream_number(is, ex);
- sinfo->u.appenduid.uid = camel_imapx_stream_number(is, ex);
+ sinfo->u.appenduid.uidvalidity = camel_imapx_stream_number(is, NULL);
+ sinfo->u.appenduid.uid = camel_imapx_stream_number(is, NULL);
break;
case IMAPX_COPYUID:
- sinfo->u.copyuid.uidvalidity = camel_imapx_stream_number(is, ex);
- sinfo->u.copyuid.uids = imapx_parse_uids (is, ex);
- sinfo->u.copyuid.copied_uids = imapx_parse_uids (is, ex);
+ sinfo->u.copyuid.uidvalidity = camel_imapx_stream_number(is, NULL);
+ sinfo->u.copyuid.uids = imapx_parse_uids (is, NULL);
+ sinfo->u.copyuid.copied_uids = imapx_parse_uids (is, NULL);
break;
case IMAPX_NEWNAME:
/* the rfc doesn't specify the bnf for this */
- camel_imapx_stream_astring(is, &token, ex);
+ camel_imapx_stream_astring(is, &token, NULL);
sinfo->u.newname.oldname = g_strdup((gchar *) token);
- camel_imapx_stream_astring(is, &token, ex);
+ camel_imapx_stream_astring(is, &token, NULL);
sinfo->u.newname.newname = g_strdup((gchar *) token);
break;
case IMAPX_PERMANENTFLAGS:
/* we only care about \* for permanent flags, not user flags */
- imapx_parse_flags(is, &sinfo->u.permanentflags, NULL, ex);
+ imapx_parse_flags(is, &sinfo->u.permanentflags, NULL, NULL);
break;
case IMAPX_UIDVALIDITY:
- sinfo->u.uidvalidity = camel_imapx_stream_number(is, ex);
+ sinfo->u.uidvalidity = camel_imapx_stream_number(is, NULL);
break;
case IMAPX_UIDNEXT:
- sinfo->u.uidnext = camel_imapx_stream_number (is, ex);
+ sinfo->u.uidnext = camel_imapx_stream_number (is, NULL);
break;
case IMAPX_UNSEEN:
- sinfo->u.unseen = camel_imapx_stream_number(is, ex);
+ sinfo->u.unseen = camel_imapx_stream_number(is, NULL);
break;
case IMAPX_HIGHESTMODSEQ:
- sinfo->u.highestmodseq = camel_imapx_stream_number(is, ex);
+ sinfo->u.highestmodseq = camel_imapx_stream_number(is, NULL);
break;
case IMAPX_CAPABILITY:
- sinfo->u.cinfo = imapx_parse_capability(is, ex);
+ sinfo->u.cinfo = imapx_parse_capability(is, NULL);
break;
default:
sinfo->condition = IMAPX_UNKNOWN;
/* ignore anything we dont know about */
do {
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok == '\n') {
- camel_exception_set (ex, 1, "server response truncated");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "server response truncated");
imapx_free_status(sinfo);
return NULL;
}
}
/* and take the human readable response */
- camel_imapx_stream_text(is, (guchar **)&sinfo->text, ex);
+ camel_imapx_stream_text(is, (guchar **)&sinfo->text, NULL);
return sinfo;
}
};
struct _list_info *
-imapx_parse_list(CamelIMAPXStream *is, CamelException *ex)
+imapx_parse_list(CamelIMAPXStream *is, GError **error)
/* throws io, parse */
{
gint tok, i;
"\Noselect" / "\Unmarked" / flag_extension) ")"
SPACE (<"> QUOTED_CHAR <"> / nil) SPACE mailbox */
- tok = camel_imapx_stream_token(is, &token, &len, ex);
+ tok = camel_imapx_stream_token(is, &token, &len, NULL);
if (tok != '(') {
- camel_exception_set (ex, 1, "list: expecting '('");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "list: expecting '('");
g_free (linfo);
return NULL;
}
- while ((tok = camel_imapx_stream_token(is, &token, &len, ex)) != ')') {
+ while ((tok = camel_imapx_stream_token(is, &token, &len, NULL)) != ')') {
if (tok == IMAPX_TOK_STRING || tok == IMAPX_TOK_TOKEN) {
p = token;
while ((c=*p))
linfo->flags |= list_flag_table[i].flag;
} else {
imapx_free_list(linfo);
- camel_exception_set (ex, 1, "list: expecting flag or ')'");
+ g_set_error (error, CAMEL_IMAPX_ERROR, 1, "list: execting flag or ')'");
return NULL;
}
}
- camel_imapx_stream_nstring(is, &token, ex);
+ camel_imapx_stream_nstring(is, &token, NULL);
linfo->separator = token?*token:0;
- camel_imapx_stream_astring(is, &token, ex);
+ camel_imapx_stream_astring(is, &token, NULL);
linfo->name = camel_utf7_utf8 ((gchar *) token);
return linfo;
/* ********************************************************************** */
-GPtrArray *imapx_parse_uids (CamelIMAPXStream *is, CamelException *ex);
-void imapx_parse_flags(struct _CamelIMAPXStream *stream, guint32 *flagsp, struct _CamelFlag **user_flagsp, CamelException *ex);
-void imapx_write_flags(CamelStream *stream, guint32 flags, struct _CamelFlag *user_flags, CamelException *ex);
+GPtrArray *imapx_parse_uids (CamelIMAPXStream *is, GError **error);
+void imapx_parse_flags(struct _CamelIMAPXStream *stream, guint32 *flagsp, struct _CamelFlag **user_flagsp, GError **error);
+void imapx_write_flags(CamelStream *stream, guint32 flags, struct _CamelFlag *user_flags, GError **error);
gboolean imapx_update_message_info_flags (CamelMessageInfo *info, guint32 server_flags, CamelFlag *server_user_flags, CamelFolder *folder, gboolean unsolicited);
void imapx_set_message_info_flags_for_new_message (CamelMessageInfo *info, guint32 server_flags, CamelFlag *server_user_flags,
CamelFolder *folder);
GHashTable *auth_types;
};
-struct _capability_info *imapx_parse_capability(struct _CamelIMAPXStream *stream, CamelException *ex);
+struct _capability_info *imapx_parse_capability(struct _CamelIMAPXStream *stream, GError **error);
void imapx_free_capability(struct _capability_info *);
-void imapx_parse_param_list(struct _CamelIMAPXStream *is, struct _camel_header_param **plist, CamelException *ex) /* IO,PARSE */;
-struct _CamelContentDisposition *imapx_parse_ext_optional(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-struct _CamelMessageContentInfo *imapx_parse_body_fields(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-struct _camel_header_address *imapx_parse_address_list(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-struct _CamelMessageInfo *imapx_parse_envelope(struct _CamelIMAPXStream *is, CamelException *ex) /* IO, PARSE */;
-struct _CamelMessageContentInfo *imapx_parse_body(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
-gchar *imapx_parse_section(struct _CamelIMAPXStream *is, CamelException *ex) /* IO,PARSE */;
+gboolean imapx_parse_param_list(struct _CamelIMAPXStream *is, struct _camel_header_param **plist, GError **error) /* IO,PARSE */;
+struct _CamelContentDisposition *imapx_parse_ext_optional(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+struct _CamelMessageContentInfo *imapx_parse_body_fields(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+struct _camel_header_address *imapx_parse_address_list(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+struct _CamelMessageInfo *imapx_parse_envelope(struct _CamelIMAPXStream *is, GError **error) /* IO, PARSE */;
+struct _CamelMessageContentInfo *imapx_parse_body(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
+gchar *imapx_parse_section(struct _CamelIMAPXStream *is, GError **error) /* IO,PARSE */;
void imapx_free_body(struct _CamelMessageContentInfo *cinfo);
/* ********************************************************************** */
#define FETCH_UID (1<<10)
#define FETCH_MODSEQ (1<<11)
-struct _fetch_info *imapx_parse_fetch(struct _CamelIMAPXStream *is, CamelException *ex);
+struct _fetch_info *imapx_parse_fetch(struct _CamelIMAPXStream *is, GError **error);
void imapx_free_fetch(struct _fetch_info *finfo);
void imapx_dump_fetch(struct _fetch_info *finfo);
gchar *text;
};
-struct _status_info *imapx_parse_status(struct _CamelIMAPXStream *is, CamelException *ex);
+struct _status_info *imapx_parse_status(struct _CamelIMAPXStream *is, GError **error);
struct _status_info *imapx_copy_status(struct _status_info *sinfo);
void imapx_free_status(struct _status_info *sinfo);
};
/* use g_free to free the return value */
-struct _state_info *imapx_parse_status_info (struct _CamelIMAPXStream *is, CamelException *ex);
+struct _state_info *imapx_parse_status_info (struct _CamelIMAPXStream *is, GError **error);
/* ********************************************************************** */
gchar *name;
};
-struct _list_info *imapx_parse_list(struct _CamelIMAPXStream *is, CamelException *ex);
+struct _list_info *imapx_parse_list(struct _CamelIMAPXStream *is, GError **error);
gchar *imapx_list_get_path(struct _list_info *li);
void imapx_free_list(struct _list_info *linfo);
gchar * imapx_get_temp_uid (void);
void camel_imapx_namespace_list_clear (struct _CamelIMAPXNamespaceList *nsl);
-struct _CamelIMAPXNamespaceList * imapx_parse_namespace_list (struct _CamelIMAPXStream *stream, CamelException *ex);
+struct _CamelIMAPXNamespaceList * imapx_parse_namespace_list (struct _CamelIMAPXStream *stream, GError **error);
struct _CamelIMAPXNamespaceList *camel_imapx_namespace_list_copy (const struct _CamelIMAPXNamespaceList *nsl);
#endif
* Returns: 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);
}
GType camel_imapx_view_summary_get_type (void);
CamelIMAPXViewSummary *
camel_imapx_view_summary_new (const gchar *base,
- CamelException *ex);
+ GError **error);
/* called on root view */
guint32 camel_imapx_view_next_uid (CamelIMAPXView *view);
main (gint argc, gchar *argv [])
{
CamelSession *session;
- CamelException *ex;
gchar *uri = NULL;
CamelService *service;
CamelFolder *folder;
system ("rm -rf /tmp/test-camel-imapx");
camel_init ("/tmp/test-camel-imapx", TRUE);
camel_provider_init ();
- ex = camel_exception_new ();
session = g_object_new (CAMEL_TYPE_SESSION, NULL);
camel_session_construct (session, "/tmp/test-camel-imapx");
- service = camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, ex);
- camel_service_connect (service, ex);
+ service = camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, NULL);
+ camel_service_connect (service, NULL);
camel_store_get_folder_info ((CamelStore *)service, "", 3, NULL);
folder = camel_store_get_folder ((CamelStore *)service, "INBOX", 0, NULL);
PROP_INDEX_BODY = 0x2400
};
-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 gboolean local_refresh_info(CamelFolder *folder, CamelException *ex);
+static gboolean local_refresh_info(CamelFolder *folder, GError **error);
-static gboolean local_sync(CamelFolder *folder, gboolean expunge, CamelException *ex);
-static gboolean 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);
}
CamelLocalFolder *
-camel_local_folder_construct(CamelLocalFolder *lf, guint32 flags, CamelException *ex)
+camel_local_folder_construct(CamelLocalFolder *lf, guint32 flags, GError **error)
{
CamelFolder *folder;
CamelFolderInfo *fi;
}
#ifndef G_OS_WIN32
/* follow any symlinks to the mailbox */
- if (lstat (lf->folder_path, &st) != -1 && S_ISLNK (st.st_mode) &&
+ if (g_lstat (lf->folder_path, &st) != -1 && S_ISLNK (st.st_mode) &&
realpath (lf->folder_path, folder_path) != NULL) {
g_free (lf->folder_path);
lf->folder_path = g_strdup (folder_path);
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));
return NULL;
}
/* 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;
}
}
static gint
-local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
+local_lock(CamelLocalFolder *lf, CamelLockType type, GError **error)
{
return 0;
}
/* for auto-check to work */
static gboolean
-local_refresh_info(CamelFolder *folder, CamelException *ex)
+local_refresh_info(CamelFolder *folder, GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
- if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1) {
+ if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, error) == -1)
return FALSE;
- }
if (camel_folder_change_info_changed(lf->changes)) {
camel_folder_changed (folder, lf->changes);
}
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. */
}
static gboolean
-local_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
+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)
+ if (camel_local_folder_lock(lf, CAMEL_LOCK_WRITE, error) == -1)
return FALSE;
camel_object_state_write (CAMEL_OBJECT (lf));
/* if sync fails, we'll pass it up on exit through ex */
- 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)) {
}
static gboolean
-local_expunge(CamelFolder *folder, CamelException *ex)
+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 */
- return CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, TRUE, ex);
+ return CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, TRUE, error);
}
static void
}
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;
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);
}
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;
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);
}
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;
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);
}
void
-set_cannot_get_message_ex (CamelException *ex, ExceptionId exId, const gchar *msgID, const gchar *folder_path, const gchar *detailErr)
+set_cannot_get_message_ex (GError **error, gint err_code, const gchar *msgID, const gchar *folder_path, const gchar *detailErr)
{
/* Translators: The first %s is replaced with a message ID,
the second %s is replaced with the folder path,
the third %s is replaced with a detailed error string */
- camel_exception_setv (ex, exId, _("Cannot get message %s from folder %s\n%s"), msgID, folder_path, detailErr);
+ g_set_error (
+ error, CAMEL_ERROR, err_code,
+ _("Cannot get message %s from folder %s\n%s"),
+ msgID, folder_path, detailErr);
}
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 *);
CamelLocalFolder *
camel_local_folder_construct (CamelLocalFolder *local_folder,
guint32 flags,
- CamelException *ex);
+ GError **error);
gboolean camel_local_folder_get_index_body
(CamelLocalFolder *local_folder);
void camel_local_folder_set_index_body
/* UNIMPLEMENTED */
gint camel_local_folder_lock (CamelLocalFolder *local_folder,
CamelLockType type,
- CamelException *ex);
+ GError **error);
gint camel_local_folder_unlock (CamelLocalFolder *local_folder);
-void set_cannot_get_message_ex (CamelException *ex,
- ExceptionId exId,
+void set_cannot_get_message_ex (GError **error,
+ gint err_code,
const gchar *msgID,
const gchar *folder_path,
const gchar *detailErr);
#define d(x)
-static gboolean 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 gboolean delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex);
-static gboolean 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);
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelLocalStore *local_store = CAMEL_LOCAL_STORE (service);
CamelServiceClass *service_class;
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_local_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ if (!service_class->construct (service, session, provider, url, error))
return FALSE;
len = strlen (service->url->path);
}
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);
path[len-1] = '\0';
if (!g_path_is_absolute(path)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ 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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Store root %s is not a regular directory"), path);
return NULL;
}
if (errno != ENOENT
|| (flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_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, 0700) == -1 && errno != EEXIST) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot get folder: %s: %s"),
path, g_strerror (errno));
return NULL;
}
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,
+ 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)
+ GError **error)
{
CamelFolder *folder;
/* Chain up to parent's get_trash() method. */
- folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)->get_trash (store, ex);
+ folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)->get_trash (store, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
static CamelFolder *
local_get_junk (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
/* Chain up to parent's get_junk() method. */
- folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)->get_junk (store, ex);
+ folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)->get_junk (store, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
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.
create_folder (CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
gchar *path = ((CamelLocalStore *)store)->toplevel_dir;
gchar *name;
/* 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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Store root %s is not an absolute path"), path);
return NULL;
}
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot get folder: %s: %s"),
name, g_strerror (errno));
g_free(name);
name = g_strdup_printf("%s", folder_name);
folder = CAMEL_STORE_GET_CLASS (store)->get_folder (
- store, name, CAMEL_STORE_FOLDER_CREATE, ex);
+ 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);
+ store, name, 0, error);
}
g_free(name);
const gchar *prefix,
const gchar *suffix,
gint missingok,
- CamelException *ex)
+ GError **error)
{
struct stat st;
gchar *old = g_strconcat(prefix, oldp, suffix, NULL);
}
if (ret == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (err),
_("Could not rename folder %s to %s: %s"),
old, new, g_strerror (err));
}
rename_folder(CamelStore *store,
const gchar *old,
const gchar *new,
- CamelException *ex)
+ GError **error)
{
gchar *path = CAMEL_LOCAL_STORE (store)->toplevel_dir;
CamelLocalFolder *folder = NULL;
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);
/* 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)
} else
camel_text_index_rename(newibex, oldibex);
ibex_failed:
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not rename '%s': %s"),
old, g_strerror (errno));
static gboolean
delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelFolderInfo *fi;
- CamelException lex;
CamelFolder *lf;
gchar *name;
gchar *str;
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder index file '%s': %s"),
str, g_strerror (errno));
g_free(str);
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))) {
CamelObject *object = CAMEL_OBJECT (lf);
const gchar *state_filename;
camel_object_set_state_filename (object, 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder meta file '%s': %s"),
str, g_strerror (errno));
g_free (name);
}
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;
#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 *);
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);
G_DEFINE_TYPE (CamelLocalSummary, camel_local_summary, CAMEL_TYPE_FOLDER_SUMMARY)
}
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;
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;
gint
camel_local_summary_check (CamelLocalSummary *cls,
CamelFolderChangeInfo *changeinfo,
- CamelException *ex)
+ GError **error)
{
CamelLocalSummaryClass *local_summary_class;
gint ret;
local_summary_class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
- ret = local_summary_class->check(cls, changeinfo, ex);
+ ret = local_summary_class->check(cls, changeinfo, error);
#ifdef DOSTATS
if (ret != -1) {
camel_local_summary_sync (CamelLocalSummary *cls,
gboolean expunge,
CamelFolderChangeInfo *changeinfo,
- CamelException *ex)
+ GError **error)
{
CamelLocalSummaryClass *local_summary_class;
local_summary_class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
- return local_summary_class->sync (cls, expunge, changeinfo, ex);
+ return local_summary_class->sync (cls, expunge, changeinfo, error);
}
CamelMessageInfo *
CamelMimeMessage *msg,
const CamelMessageInfo *info,
CamelFolderChangeInfo *ci,
- CamelException *ex)
+ GError **error)
{
CamelLocalSummaryClass *local_summary_class;
local_summary_class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
- return local_summary_class->add (cls, msg, info, ci, ex);
+ return local_summary_class->add (cls, msg, info, ci, error);
}
/**
}
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;
local_summary_sync (CamelLocalSummary *cls,
gboolean expunge,
CamelFolderChangeInfo *changeinfo,
- CamelException *ex)
+ GError **error)
{
CamelFolderSummary *folder_summary;
folder_summary = CAMEL_FOLDER_SUMMARY (cls);
- if (camel_folder_summary_save_to_db (folder_summary, ex) == -1) {
+ if (camel_folder_summary_save_to_db (folder_summary, error) == -1) {
g_warning ("Could not save summary for local providers");
return -1;
}
}
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;
if (mi->info.size == 0) {
CamelStreamNull *sn = (CamelStreamNull *)camel_stream_null_new();
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)sn);
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)sn, NULL);
mi->info.size = sn->written;
g_object_unref (sn);
}
camel_folder_change_info_add_uid(ci, camel_message_info_uid(mi));
} else {
d(printf("Failed!\n"));
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unable to add message to summary: unknown reason"));
}
return (CamelMessageInfo *)mi;
}
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;
/* Chain up to parent's summary_header_to_db() method. */
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (camel_local_summary_parent_class);
- fir = folder_summary_class->summary_header_to_db (s, ex);
+ fir = folder_summary_class->summary_header_to_db (s, NULL);
if (fir)
fir->bdata = g_strdup_printf ("%d", CAMEL_LOCAL_SUMMARY_VERSION);
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);
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);
static CamelLocalSummary *maildir_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index);
-static gboolean 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 gboolean 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);
G_DEFINE_TYPE (CamelMaildirFolder, camel_maildir_folder, CAMEL_TYPE_LOCAL_FOLDER)
camel_maildir_folder_new (CamelStore *parent_store,
const gchar *full_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
gchar *basename;
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
folder = (CamelFolder *) camel_local_folder_construct (
- CAMEL_LOCAL_FOLDER (folder), flags, ex);
+ CAMEL_LOCAL_FOLDER (folder), flags, error);
g_free (basename);
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *output_stream;
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)
+ 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 (
CAMEL_LOCAL_SUMMARY (folder->summary),
- message, info, lf->changes, ex);
+ message, info, lf->changes, error);
if (mi == NULL)
goto check_changed;
/* write it out to tmp, use the uid we got from the summary */
name = g_strdup_printf ("%s/tmp/%s", lf->folder_path, camel_message_info_uid(mi));
output_stream = camel_stream_fs_new_with_name (
- name, O_WRONLY|O_CREAT, 0600);
+ name, O_WRONLY|O_CREAT, 0600, error);
if (output_stream == NULL)
goto fail_write;
- if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, output_stream) == -1
- || camel_stream_close (output_stream) == -1)
+ if (camel_data_wrapper_write_to_stream (
+ (CamelDataWrapper *)message, output_stream, error) == -1
+ || camel_stream_close (output_stream, error) == -1)
goto fail_write;
/* now move from tmp to cur (bypass new, does it matter?) */
dest = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename (mdi));
- if (rename (name, dest) == -1)
+ if (g_rename (name, dest) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
goto fail_write;
+ }
g_free (dest);
g_free (name);
camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
camel_message_info_uid (mi));
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_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_prefix_error (
+ error, _("Cannot append message to maildir folder: %s: "),
+ name);
if (output_stream) {
g_object_unref (CAMEL_OBJECT (output_stream));
static gchar *
maildir_get_filename (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelMaildirMessageInfo *mdi;
/* get the message summary info */
if ((info = camel_folder_summary_uid(folder->summary, uid)) == NULL) {
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ error, CAMEL_FOLDER_ERROR_INVALID_UID,
uid, lf->folder_path, _("No such message"));
return NULL;
}
static CamelMimeMessage *
maildir_get_message (CamelFolder *folder,
const gchar *uid,
- CamelException * ex)
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *message_stream = NULL;
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) {
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ error, CAMEL_FOLDER_ERROR_INVALID_UID,
uid, lf->folder_path, _("No such message"));
goto fail;
}
camel_message_info_free(info);
- if ((message_stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0)) == NULL) {
- set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_SYSTEM,
- uid, lf->folder_path, g_strerror (errno));
+ message_stream = camel_stream_fs_new_with_name (
+ name, O_RDONLY, 0, error);
+ if (message_stream == NULL) {
+ g_prefix_error (
+ error, _("Cannot get message %s from folder %s: "),
+ uid, lf->folder_path);
goto fail;
}
message = camel_mime_message_new();
- if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream) == -1) {
- set_cannot_get_message_ex (
- ex, (errno==EINTR) ?
- CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- uid, lf->folder_path, _("Invalid message contents"));
+ if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream, error) == -1) {
+ g_prefix_error (
+ error, _("Cannot get message %s from folder %s: "),
+ uid, lf->folder_path);
g_object_unref (message);
message = NULL;
g_return_if_fail (camel_maildir_folder_parent_class != NULL);
g_return_if_fail (folder != NULL);
- if (uids && uids->len > 1) {
- CamelException ex;
-
- camel_exception_init (&ex);
-
- camel_folder_summary_prepare_fetch_all (folder->summary, &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_prepare_fetch_all (folder->summary, NULL);
/* Chain up to parent's sort_uids() method. */
CAMEL_FOLDER_CLASS (camel_maildir_folder_parent_class)->sort_uids (folder, uids);
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_originals,
- CamelException *ex)
+ GError **error)
{
gboolean fallback = FALSE;
if ((info = camel_folder_summary_uid (source->summary, uid)) == NULL) {
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ error, CAMEL_FOLDER_ERROR_INVALID_UID,
uid, lf->folder_path, _("No such message"));
return FALSE;
}
i = uids->len + 1;
fallback = TRUE;
} else {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot transfer message to destination folder"));
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Cannot transfer message to destination folder: %s"),
+ g_strerror (errno));
camel_message_info_free (info);
break;
}
folder_class = CAMEL_FOLDER_CLASS (camel_maildir_folder_parent_class);
return folder_class->transfer_messages_to (
source, uids, dest, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
}
return TRUE;
};
/* 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);
#include <sys/stat.h>
#include <sys/types.h>
+#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include "camel-maildir-folder.h"
#define d(x)
-static CamelFolder *get_folder(CamelStore * store, const gchar *folder_name, guint32 flags, CamelException * ex);
-static CamelFolder *get_inbox (CamelStore *store, CamelException *ex);
-static gboolean delete_folder(CamelStore * store, const gchar *folder_name, CamelException * ex);
-static gboolean 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);
get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException * ex)
+ GError **error)
{
CamelStoreClass *store_class;
gchar *name, *tmp, *cur, *new;
/* Chain up to parent's get_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
- if (!store_class->get_folder (store, folder_name, flags, ex))
+ 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);
if (!strcmp(folder_name, ".")) {
/* special case "." (aka inbox), may need to be created */
- if (stat(tmp, &st) != 0 || !S_ISDIR(st.st_mode)
- || stat(cur, &st) != 0 || !S_ISDIR(st.st_mode)
- || stat(new, &st) != 0 || !S_ISDIR(st.st_mode)) {
+ if (g_stat(tmp, &st) != 0 || !S_ISDIR(st.st_mode)
+ || g_stat(cur, &st) != 0 || !S_ISDIR(st.st_mode)
+ || g_stat(new, &st) != 0 || !S_ISDIR(st.st_mode)) {
if (mkdir(tmp, 0700) != 0
|| mkdir(cur, 0700) != 0
|| mkdir(new, 0700) != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot create folder '%s': %s"),
folder_name, g_strerror(errno));
rmdir(tmp);
goto fail;
}
}
- folder = camel_maildir_folder_new(store, folder_name, flags, ex);
- } else if (stat(name, &st) == -1) {
+ folder = camel_maildir_folder_new(store, folder_name, flags, error);
+ } else if (g_stat(name, &st) == -1) {
/* folder doesn't exist, see if we should create it */
if (errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot get folder '%s': %s"),
folder_name, g_strerror (errno));
} else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot get folder '%s': folder does not exist."),
folder_name);
} else {
|| mkdir(tmp, 0700) != 0
|| mkdir(cur, 0700) != 0
|| mkdir(new, 0700) != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot create folder '%s': %s"),
folder_name, g_strerror (errno));
rmdir(tmp);
rmdir(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)
- || stat(tmp, &st) != 0 || !S_ISDIR(st.st_mode)
- || stat(cur, &st) != 0 || !S_ISDIR(st.st_mode)
- || stat(new, &st) != 0 || !S_ISDIR(st.st_mode)) {
+ || g_stat(tmp, &st) != 0 || !S_ISDIR(st.st_mode)
+ || g_stat(cur, &st) != 0 || !S_ISDIR(st.st_mode)
+ || g_stat(new, &st) != 0 || !S_ISDIR(st.st_mode)) {
/* folder exists, but not maildir */
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot get folder '%s': not a maildir directory."),
name);
} else if (flags & CAMEL_STORE_FOLDER_EXCL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot create folder '%s': folder exists."),
folder_name);
} else {
- folder = camel_maildir_folder_new(store, folder_name, flags, ex);
+ folder = camel_maildir_folder_new(store, folder_name, flags, error);
}
fail:
g_free(name);
static CamelFolder *
get_inbox (CamelStore *store,
- CamelException *ex)
+ GError **error)
{
return camel_store_get_folder (
- store, ".", CAMEL_STORE_FOLDER_CREATE, ex);
+ store, ".", CAMEL_STORE_FOLDER_CREATE, error);
}
static gboolean
delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ 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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot delete folder: %s: Invalid operation"),
_("Inbox"));
return FALSE;
cur = g_strdup_printf("%s/cur", name);
new = g_strdup_printf("%s/new", name);
- if (stat(name, &st) == -1 || !S_ISDIR(st.st_mode)
- || 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,
+ if (g_stat(name, &st) == -1 || !S_ISDIR(st.st_mode)
+ || g_stat(tmp, &st) == -1 || !S_ISDIR(st.st_mode)
+ || g_stat(cur, &st) == -1 || !S_ISDIR(st.st_mode)
+ || g_stat(new, &st) == -1 || !S_ISDIR(st.st_mode)) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder '%s': %s"),
folder_name, errno ? g_strerror (errno) :
_("not a maildir directory"));
mkdir(cur, 0700);
mkdir(new, 0700);
mkdir(tmp, 0700);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (err),
_("Could not delete folder '%s': %s"),
folder_name, g_strerror (err));
} else {
/* Chain up to parent's delete_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
success = store_class->delete_folder (
- store, folder_name, ex);
+ store, folder_name, error);
}
}
maildir_rename_folder (CamelStore *store,
const gchar *old,
const gchar *new,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *store_class;
if (strcmp(old, ".") == 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Cannot rename folder: %s: Invalid operation"),
_("Inbox"));
return FALSE;
/* Chain up to parent's rename_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
- return store_class->rename_folder(store, old, new, ex);
+ return store_class->rename_folder(store, old, new, error);
}
static void
cur = g_build_filename(url->path, fi->full_name, "cur", NULL);
new = g_build_filename(url->path, fi->full_name, "new", NULL);
- if (!(stat(tmp, &st) == 0 && S_ISDIR(st.st_mode)
- && stat(cur, &st) == 0 && S_ISDIR(st.st_mode)
- && stat(new, &st) == 0 && S_ISDIR(st.st_mode)))
+ if (!(g_stat(tmp, &st) == 0 && S_ISDIR(st.st_mode)
+ && g_stat(cur, &st) == 0 && S_ISDIR(st.st_mode)
+ && g_stat(new, &st) == 0 && S_ISDIR(st.st_mode)))
fi->flags |= CAMEL_FOLDER_NOSELECT;
g_free(new);
guint32 flags,
CamelFolderInfo *topfi,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelDList queue = CAMEL_DLIST_INITIALISER(queue);
struct _scan_node *sn;
dir = opendir(name);
if (dir == NULL) {
g_free(name);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not scan folder '%s': %s"),
root, g_strerror (errno));
goto fail;
continue;
tmp = g_build_filename(name, d->d_name, NULL);
- if (stat(tmp, &st) == 0 && S_ISDIR(st.st_mode)) {
+ if (g_stat(tmp, &st) == 0 && S_ISDIR(st.st_mode)) {
struct _scan_node in;
in.dnode = st.st_dev;
get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelFolderInfo *fi = NULL;
CamelLocalStore *local_store = (CamelLocalStore *)store;
/* 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;
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;
}
#include <sys/types.h>
#include <sys/uio.h>
+#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include "camel-maildir-summary.h"
static CamelMessageInfo *message_info_new_from_header(CamelFolderSummary *, struct _camel_header_raw *);
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);
CamelMimeMessage *msg,
const CamelMessageInfo *info,
CamelFolderChangeInfo *changes,
- CamelException *ex)
+ GError **error)
{
CamelLocalSummaryClass *local_summary_class;
CamelMaildirMessageInfo *mi;
/* Chain up to parent's add() method. */
local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (camel_maildir_summary_parent_class);
mi = (CamelMaildirMessageInfo *) local_summary_class->add (
- cls, msg, info, changes, ex);
+ cls, msg, info, changes, error);
if (mi) {
if (info) {
camel_maildir_info_set_filename(mi, camel_maildir_summary_info_to_name(mi));
uid = g_strdup_printf("%ld.%d_%u.%s", time(NULL), getpid(), nextuid, mds->priv->hostname);
name = g_strdup_printf("%s/tmp/%s", cls->folder_path, uid);
retry++;
- } while (stat(name, &st) == 0 && retry<3);
+ } while (g_stat(name, &st) == 0 && retry<3);
/* I dont know what we're supposed to do if it fails to find a unique name?? */
static gint
maildir_summary_load (CamelLocalSummary *cls,
gint forceindex,
- CamelException *ex)
+ GError **error)
{
CamelLocalSummaryClass *local_summary_class;
gchar *cur;
dir = opendir(cur);
if (dir == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot open maildir directory path: %s: %s"),
cls->folder_path, g_strerror (errno));
g_free(cur);
/* Chain up to parent's load() method. */
local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (camel_maildir_summary_parent_class);
- ret = local_summary_class->load (cls, forceindex, ex);
+ ret = local_summary_class->load (cls, forceindex, error);
g_hash_table_destroy(mds->priv->load_map);
mds->priv->load_map = NULL;
}
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;
no longer exist */
dir = opendir(cur);
if (dir == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot open maildir directory path: %s: %s"),
cls->folder_path, g_strerror (errno));
g_free(cur);
/* keeps track of all uid's that have not been processed */
left = g_hash_table_new(g_str_hash, g_str_equal);
- camel_folder_summary_prepare_fetch_all (s, ex);
+ camel_folder_summary_prepare_fetch_all (s, error);
count = camel_folder_summary_count (s);
forceindex = count == 0;
for (i=0;i<count;i++) {
/* FIXME: This should probably use link/unlink */
- if (rename(src, dest) == 0) {
+ if (g_rename (src, dest) == 0) {
camel_maildir_summary_add (cls, destfilename, forceindex);
if (changes) {
camel_folder_change_info_add_uid(changes, destname);
maildir_summary_sync (CamelLocalSummary *cls,
gboolean expunge,
CamelFolderChangeInfo *changes,
- CamelException *ex)
+ GError **error)
{
CamelLocalSummaryClass *local_summary_class;
gint count, i;
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"));
- camel_folder_summary_prepare_fetch_all ((CamelFolderSummary *)cls, ex);
+ camel_folder_summary_prepare_fetch_all ((CamelFolderSummary *)cls, error);
count = camel_folder_summary_count((CamelFolderSummary *)cls);
for (i=count-1;i>=0;i--) {
camel_operation_progress(NULL, (count-i)*100/count);
if (strcmp(newname, camel_maildir_info_filename(mdi))) {
name = g_strdup_printf("%s/cur/%s", cls->folder_path, camel_maildir_info_filename(mdi));
dest = g_strdup_printf("%s/cur/%s", cls->folder_path, newname);
- rename(name, dest);
- if (stat(dest, &st) == -1) {
+ g_rename (name, dest);
+ if (g_stat(dest, &st) == -1) {
/* we'll assume it didn't work, but dont change anything else */
g_free(newname);
} else {
/* Chain up to parent's sync() method. */
local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (camel_maildir_summary_parent_class);
- return local_summary_class->sync (cls, expunge, changes, ex);
+ return local_summary_class->sync (cls, expunge, changes, error);
}
#define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
-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 gboolean 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);
}
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;
gchar *basename;
"name", basename, "full-name", full_name,
"parent-store", parent_store, NULL);
folder = (CamelFolder *)camel_local_folder_construct (
- (CamelLocalFolder *)folder, flags, ex);
+ (CamelLocalFolder *)folder, flags, error);
g_free (basename);
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;
mf->lockfd = open(lf->folder_path, O_RDWR|O_LARGEFILE, 0);
if (mf->lockfd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_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;
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *output_stream = NULL, *filter_stream = NULL;
gchar *xev;
#endif
/* If we can't lock, dont do anything */
- if (camel_local_folder_lock(lf, CAMEL_LOCK_WRITE, ex) == -1)
+ 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;
output_stream = camel_stream_fs_new_with_name (
lf->folder_path, O_WRONLY | O_APPEND |
- O_LARGEFILE, 0666);
+ O_LARGEFILE, 0666, error);
if (output_stream == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot open mailbox: %s: %s\n"),
- lf->folder_path, g_strerror (errno));
+ g_prefix_error (
+ error, _("Cannot open mailbox: %s: "),
+ lf->folder_path);
goto fail;
}
/* we must write this to the non-filtered stream ... */
fromline = camel_mime_message_build_mbox_from(message);
- if (camel_stream_write(output_stream, fromline, strlen(fromline)) == -1)
+ if (camel_stream_write(output_stream, fromline, strlen(fromline), error) == -1)
goto fail_write;
/* and write the content to the filtering stream, that translates '\nFrom' into '\n>From' */
camel_stream_filter_add((CamelStreamFilter *) filter_stream, filter_from);
g_object_unref (filter_from);
- if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) message, filter_stream) == -1 ||
- camel_stream_write (filter_stream, "\n", 1) == -1 ||
- camel_stream_flush (filter_stream) == -1)
+ if (camel_data_wrapper_write_to_stream (
+ (CamelDataWrapper *) message, filter_stream, error) == -1 ||
+ camel_stream_write (filter_stream, "\n", 1, error) == -1 ||
+ camel_stream_flush (filter_stream, error) == -1)
goto fail_write;
/* filter stream ref's the output stream itself, so we need to unref it too */
return TRUE;
fail_write:
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_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_prefix_error (
+ error, _("Cannot append message to mbox file: %s: "),
+ lf->folder_path);
if (output_stream) {
gint fd;
}
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;
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;
}
if (info == NULL) {
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ error, CAMEL_FOLDER_ERROR_INVALID_UID,
uid, lf->folder_path, _("No such message"));
goto 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;
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;
}
if (info == NULL) {
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ error, CAMEL_FOLDER_ERROR_INVALID_UID,
uid, lf->folder_path, _("No such message"));
goto fail;
}
fd = g_open(lf->folder_path, O_LARGEFILE | O_RDONLY | O_BINARY, 0);
if (fd == -1) {
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ error, CAMEL_ERROR_GENERIC,
uid, lf->folder_path, g_strerror (errno));
goto fail;
}
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;
}
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ error, CAMEL_FOLDER_ERROR_INVALID,
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) {
- set_cannot_get_message_ex (
- ex, errno == EINTR ?
- CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- uid, lf->folder_path,
- _("Message construction failed."));
+ if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser, error) == -1) {
+ g_prefix_error (
+ error, _("Cannot get message %s from folder %s: "),
+ uid, lf->folder_path);
g_object_unref (message);
message = NULL;
goto fail;
g_return_if_fail (camel_mbox_folder_parent_class != NULL);
g_return_if_fail (folder != NULL);
- if (uids && uids->len > 1) {
- CamelException ex;
-
- camel_exception_init (&ex);
-
- camel_folder_summary_prepare_fetch_all (folder->summary, &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_prepare_fetch_all (folder->summary, NULL);
CAMEL_FOLDER_CLASS (camel_mbox_folder_parent_class)->sort_uids (folder, uids);
}
/* 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);
#define d(x)
-static CamelFolder *get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex);
-static gboolean delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex);
-static gboolean 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);
get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *store_class;
struct stat st;
/* Chain up to parent's get_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_mbox_store_parent_class);
- if (!store_class->get_folder (store, folder_name, flags, ex))
+ if (!store_class->get_folder (store, folder_name, flags, error))
return NULL;
name = camel_local_store_get_full_path(store, folder_name);
gint fd;
if (errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot get folder '%s': %s"),
folder_name, g_strerror (errno));
g_free(name);
}
if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ 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);
basename = g_path_get_basename (folder_name);
if (basename[0] == '.' || ignore_file (basename, TRUE)) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot create a folder by this name."));
g_free (name);
g_free (basename);
dirname = g_path_get_dirname(name);
if (g_mkdir_with_parents(dirname, 0700) == -1 && errno != EEXIST) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot create folder '%s': %s"),
folder_name, g_strerror (errno));
g_free(dirname);
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot create folder '%s': %s"),
folder_name, g_strerror (errno));
g_free(name);
g_free(name);
close(fd);
} else if (!S_ISREG(st.st_mode)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot create folder '%s': folder exists."),
folder_name);
g_free (name);
} 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 gboolean
-delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+delete_folder(CamelStore *store, const gchar *folder_name, GError **error)
{
CamelFolderInfo *fi;
- CamelException lex;
CamelFolder *lf;
gchar *name, *path;
struct stat st;
path = g_strdup_printf("%s.sbd", name);
if (g_rmdir(path) == -1 && errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder '%s':\n%s"),
folder_name, g_strerror (errno));
g_free(path);
g_free(path);
if (g_stat(name, &st) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder '%s':\n%s"),
folder_name, g_strerror (errno));
g_free(name);
}
if (!S_ISREG(st.st_mode)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("'%s' is not a regular file."), name);
g_free(name);
return FALSE;
}
if (st.st_size != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_NON_EMPTY,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_NON_EMPTY,
_("Folder '%s' is not empty. Not deleted."),
folder_name);
g_free(name);
}
if (g_unlink(name) == -1 && errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder '%s':\n%s"),
name, g_strerror(errno));
g_free(name);
* 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder summary file '%s': %s"),
path, g_strerror(errno));
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder summary file '%s': %s"),
path, g_strerror(errno));
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder index file '%s': %s"),
path, g_strerror(errno));
g_free(path);
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))) {
CamelObject *object = CAMEL_OBJECT (lf);
const gchar *state_filename;
camel_object_set_state_filename (object, 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder meta file '%s': %s"),
path, g_strerror (errno));
}
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? */
struct stat st;
if (!g_path_is_absolute(toplevel_dir)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot create a folder by this name."));
return NULL;
}
dir = g_path_get_dirname(path);
if (g_mkdir_with_parents(dir, 0777) == -1 && errno != EEXIST) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot create directory '%s': %s."),
dir, g_strerror (errno));
g_free(dir);
if (g_stat(path, &st) == 0 || errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot create folder: %s: %s"),
path, errno ? g_strerror (errno) :
_("Folder already exists"));
g_free(path);
folder = CAMEL_STORE_GET_CLASS (store)->get_folder (
- store, name, CAMEL_STORE_FOLDER_CREATE, ex);
+ 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);
+ store, name, 0, error);
}
g_free(name);
#ifndef G_OS_WIN32
} else if (S_ISDIR(st.st_mode)) {
/* use rename for dirs */
- if (rename(oldpath, newpath) == 0 || stat(newpath, &st) == 0) {
+ if (g_rename (oldpath, newpath) == 0 || g_stat(newpath, &st) == 0) {
ret = 0;
} else {
err = errno;
ret = -1;
}
} else if (link(oldpath, newpath) == 0 /* and link for files */
- ||(stat(newpath, &st) == 0 && st.st_nlink == 2)) {
+ ||(g_stat(newpath, &st) == 0 && st.st_nlink == 2)) {
if (unlink(oldpath) == 0) {
ret = 0;
} else {
}
static gboolean
-rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("The new folder name is illegal."));
return FALSE;
}
newdir = g_path_get_dirname(newibex);
if (g_mkdir_with_parents(newdir, 0700) == -1) {
if (errno != EEXIST) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not rename '%s': '%s': %s"),
old, new, g_strerror(errno));
g_free(oldibex);
g_free(newdir);
}
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errnosav),
_("Could not rename '%s' to %s: %s"),
old, new, g_strerror(errnosav));
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;
*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;
}
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
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);
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
#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);
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 */
}
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);
/* Chain up to parent's summary_header_to_db() method. */
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (camel_mbox_summary_parent_class);
- fir = folder_summary_class->summary_header_to_db (s, ex);
+ 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);
/* 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;
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not open folder: %s: %s"),
cls->folder_path, g_strerror (errno));
camel_operation_end(NULL);
/* we mark messages as to whether we've seen them or not.
If we're not starting from the start, we must be starting
from the old end, so everything must be treated as new */
- camel_folder_summary_prepare_fetch_all (s, ex);
+ camel_folder_summary_prepare_fetch_all (s, NULL);
count = camel_folder_summary_count(s);
for (i=0;i<count;i++) {
mi = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i);
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_GENERIC,
+ _("Fatal mail parser error near position %" G_GINT64_FORMAT " in folder %s"),
+ (gint64) camel_mime_parser_tell(mp), cls->folder_path);
ok = -1;
break;
}
/* Delete all in one transaction */
full_name = camel_folder_get_full_name (s->folder);
parent_store = camel_folder_get_parent_store (s->folder);
- camel_db_delete_uids (parent_store->cdb_w, full_name, del, ex);
+ camel_db_delete_uids (parent_store->cdb_w, full_name, del, NULL);
g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
g_slist_free (del);
}
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;
/* 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot check folder: %s: %s"),
cls->folder_path, g_strerror (errno));
return -1;
if (st.st_size == 0) {
/* empty? No need to scan at all */
d(printf("Empty mbox, clearing summary\n"));
- camel_folder_summary_prepare_fetch_all (s, ex);
+ camel_folder_summary_prepare_fetch_all (s, NULL);
count= camel_folder_summary_count(s);
for (i=0;i<count;i++) {
CamelMessageInfo *info = camel_folder_summary_index(s, i);
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"));
/* 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;
fd = g_open(cls->folder_path, O_LARGEFILE | O_RDONLY | O_BINARY, 0);
if (fd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not open file: %s: %s"),
cls->folder_path, g_strerror (errno));
camel_operation_end(NULL);
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not close source folder %s: %s"),
cls->folder_path, g_strerror (errno));
fd = -1;
if (close(fdout) == -1) {
g_warning("Cannot close temporary folder: %s", g_strerror (errno));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not close temporary folder: %s"),
g_strerror (errno));
fdout = -1;
#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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not rename folder: %s"),
g_strerror (errno));
goto error;
/* 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;
fd = g_open(cls->folder_path, O_LARGEFILE|O_RDWR|O_BINARY, 0);
if (fd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not open file: %s: %s"),
cls->folder_path, g_strerror (errno));
/* 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not store folder: %s"),
g_strerror(errno));
close(fd);
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Summary and folder mismatch, even after a sync"));
goto error;
}
if (close(fd) == -1) {
g_warning ("Cannot close source folder: %s", g_strerror (errno));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not close source folder %s: %s"),
cls->folder_path, g_strerror (errno));
fd = -1;
}
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;
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;
full_name = camel_folder_get_full_name (s->folder);
if (quick && expunge) {
guint32 dcount =0;
- if (camel_db_count_deleted_message_info (parent_store->cdb_w, full_name, &dcount, ex) == -1)
+ if (camel_db_count_deleted_message_info (parent_store->cdb_w, full_name, &dcount, error) == -1)
return -1;
if (dcount)
quick = FALSE;
ret = -1;
if (quick) {
if (work) {
- ret = CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_quick (mbs, expunge, changeinfo, ex);
- if (ret == -1) {
+ ret = CAMEL_MBOX_SUMMARY_GET_CLASS (cls)->sync_quick (mbs, expunge, changeinfo, NULL);
+ if (ret == -1)
g_warning("failed a quick-sync, trying a full sync");
- camel_exception_clear (ex);
- }
} else {
ret = 0;
}
}
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Unknown error: %s"), g_strerror (errno));
return -1;
}
camel_folder_summary_touch(s);
}
- return CAMEL_LOCAL_SUMMARY_CLASS (camel_mbox_summary_parent_class)->sync(cls, expunge, changeinfo, ex);
+ return CAMEL_LOCAL_SUMMARY_CLASS (camel_mbox_summary_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;
/* 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not store folder: %s"),
g_strerror (errno));
return -1;
camel_mime_parser_init_with_fd(mp, fd);
camel_folder_summary_lock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
- camel_folder_summary_prepare_fetch_all (s, ex);
+ camel_folder_summary_prepare_fetch_all (s, NULL);
count = camel_folder_summary_count(s);
for (i = 0; i < count; i++) {
gint pc = (i + 1) * 100 / count;
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Summary and folder mismatch, even after a sync"));
goto error;
}
#endif
if (len == -1) {
d(printf("Error writing to temporary mailbox\n"));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Writing to temporary mailbox failed: %s"),
g_strerror (errno));
goto error;
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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Writing to temporary mailbox failed: %s: %s"),
((CamelLocalSummary *)cls)->folder_path,
g_strerror (errno));
}
if (write(fdout, "\n", 1) != 1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Writing to temporary mailbox failed: %s"),
g_strerror (errno));
goto error;
full_name = camel_folder_get_full_name (s->folder);
parent_store = camel_folder_get_parent_store (s->folder);
- camel_db_delete_uids (parent_store->cdb_w, full_name, del, ex);
+ camel_db_delete_uids (parent_store->cdb_w, full_name, del, NULL);
g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
g_slist_free (del);
}
if (touched)
- camel_folder_summary_header_save_to_db (s, ex);
+ camel_folder_summary_header_save_to_db (s, NULL);
camel_folder_summary_unlock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
#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;
/* Chain up to parent's add() method. */
local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (camel_mbox_summary_parent_class);
mi = (CamelMboxMessageInfo *) local_summary_class->add (
- cls, msg, info, ci, ex);
+ cls, msg, info, ci, error);
if (mi && ((CamelMboxSummary *)cls)->xstatus) {
gchar status[8];
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);
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
static CamelLocalSummary *mh_create_summary(CamelLocalFolder *lf, const gchar *path, const gchar *folder, CamelIndex *index);
-static gboolean 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);
G_DEFINE_TYPE (CamelMhFolder, camel_mh_folder, CAMEL_TYPE_LOCAL_FOLDER)
camel_mh_folder_new (CamelStore *parent_store,
const gchar *full_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
gchar *basename;
"name", basename, "full-name", full_name,
"parent-store", parent_store, NULL);
folder = (CamelFolder *) camel_local_folder_construct (
- CAMEL_LOCAL_FOLDER (folder), flags, ex);
+ CAMEL_LOCAL_FOLDER (folder), flags, error);
g_free (basename);
CamelMimeMessage *message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *output_stream;
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)
+ 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);
+ mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, error);
if (mi == NULL)
goto check_changed;
/* write it out, use the uid we got from the summary */
name = g_strdup_printf("%s/%s", lf->folder_path, camel_message_info_uid(mi));
output_stream = camel_stream_fs_new_with_name (
- name, O_WRONLY|O_CREAT, 0600);
+ name, O_WRONLY|O_CREAT, 0600, error);
if (output_stream == NULL)
goto fail_write;
- if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, output_stream) == -1
- || camel_stream_close (output_stream) == -1)
+ if (camel_data_wrapper_write_to_stream (
+ (CamelDataWrapper *)message, output_stream, error) == -1
+ || camel_stream_close (output_stream, error) == -1)
goto fail_write;
/* close this? */
camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
camel_message_info_uid (mi));
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_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_prefix_error (
+ error, _("Cannot append message to mh folder: %s: "), name);
if (output_stream) {
g_object_unref (CAMEL_OBJECT (output_stream));
static gchar *
mh_get_filename (CamelFolder *folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
static CamelMimeMessage *
mh_get_message (CamelFolder *folder,
const gchar *uid,
- CamelException * ex)
+ GError **error)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *message_stream = NULL;
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) {
set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ error, CAMEL_FOLDER_ERROR_INVALID_UID,
uid, lf->folder_path, _("No such message"));
goto fail;
}
camel_message_info_free(info);
name = g_strdup_printf("%s/%s", lf->folder_path, uid);
- if ((message_stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0)) == NULL) {
- set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_SYSTEM,
- name, lf->folder_path, g_strerror (errno));
+ message_stream = camel_stream_fs_new_with_name (
+ name, O_RDONLY, 0, error);
+ if (message_stream == NULL) {
+ g_prefix_error (
+ error, _("Cannot get message %s from folder %s: "),
+ name, lf->folder_path);
goto fail;
}
message = camel_mime_message_new();
- if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream) == -1) {
- set_cannot_get_message_ex (
- ex, CAMEL_EXCEPTION_SYSTEM,
- name, lf->folder_path,
- _("Message construction failed."));
+ if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream, error) == -1) {
+ g_prefix_error (
+ error, _("Cannot get message %s from folder %s: "),
+ name, lf->folder_path);
g_object_unref (message);
message = NULL;
};
/* 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);
#include <unistd.h>
#include <sys/stat.h>
+#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include "camel-mh-folder.h"
#define d(x)
-static gboolean 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 gboolean delete_folder(CamelStore * store, const gchar *folder_name, CamelException * ex);
-static gboolean 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);
G_DEFINE_TYPE (CamelMhStore, camel_mh_store, CAMEL_TYPE_LOCAL_STORE)
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
CamelMhStore *mh_store = (CamelMhStore *)service;
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_mh_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ if (!service_class->construct (service, session, provider, url, error))
return FALSE;
if (camel_url_get_param(url, "dotfolders"))
sprintf (tmpnew, "%s.folders~", root);
out = camel_stream_fs_new_with_name (
- tmpnew, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+ tmpnew, O_WRONLY|O_CREAT|O_TRUNC, 0666, NULL);
if (out == NULL)
goto fail;
tmp = g_alloca (strlen (root) + 16);
sprintf (tmp, "%s.folders", root);
- stream = camel_stream_fs_new_with_name (tmp, O_RDONLY, 0);
+ stream = camel_stream_fs_new_with_name (tmp, O_RDONLY, 0, NULL);
if (stream) {
in = camel_stream_buffer_new(stream, CAMEL_STREAM_BUFFER_READ);
g_object_unref (stream);
goto done;
}
- while ((line = camel_stream_buffer_read_line((CamelStreamBuffer *)in))) {
+ while ((line = camel_stream_buffer_read_line((CamelStreamBuffer *)in, NULL))) {
gint copy = TRUE;
switch (mode) {
case UPDATE_RENAME:
if (strncmp(line, folder, flen) == 0
&& (line[flen] == 0 || line[flen] == '/')) {
- if (camel_stream_write(out, new, strlen(new)) == -1
- || camel_stream_write(out, line+flen, strlen(line)-flen) == -1
- || camel_stream_write(out, "\n", 1) == -1)
+ if (camel_stream_write(out, new, strlen(new), NULL) == -1
+ || camel_stream_write(out, line+flen, strlen(line)-flen, NULL) == -1
+ || camel_stream_write(out, "\n", 1, NULL) == -1)
goto fail;
copy = FALSE;
}
if (mode == UPDATE_ADD && camel_stream_printf(out, "%s\n", folder) == -1)
goto fail;
- if (camel_stream_close(out) == -1)
+ if (camel_stream_close(out, NULL) == -1)
goto fail;
done:
/* should we care if this fails? I suppose so ... */
- rename(tmpnew, tmp);
+ g_rename (tmpnew, tmp);
fail:
unlink(tmpnew); /* remove it if its there */
g_free(line);
get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException * ex)
+ GError **error)
{
CamelStoreClass *store_class;
gchar *name;
/* Chain up to parent's get_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class);
- if (store_class->get_folder (store, folder_name, flags, ex) == NULL)
+ 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 (g_stat(name, &st) == -1) {
if (errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot get folder '%s': %s"),
folder_name, g_strerror (errno));
g_free (name);
return NULL;
}
if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ 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);
}
if (mkdir(name, 0777) != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not create folder '%s': %s"),
folder_name, g_strerror (errno));
g_free (name);
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,
+ 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot create folder '%s': folder exists."),
folder_name);
g_free (name);
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)
+ GError **error)
{
- return get_folder (store, "inbox", 0, ex);
+ return get_folder (store, "inbox", 0, error);
}
static gboolean
delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not delete folder '%s': %s"),
folder_name, g_strerror (errno));
g_free(name);
/* Chain up to parent's delete_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class);
- return store_class->delete_folder (store, folder_name, ex);
+ return store_class->delete_folder (store, folder_name, error);
}
static gboolean
rename_folder (CamelStore *store,
const gchar *old,
const gchar *new,
- CamelException *ex)
+ GError **error)
{
CamelStoreClass *store_class;
/* Chain up to parent's rename_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class);
- if (!store_class->rename_folder (store, old, new, ex))
+ if (!store_class->rename_folder (store, old, new, error))
return FALSE;
if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) {
} else
fullpath = (gchar *)root;
- if (stat(fullpath, &st) == -1 || !S_ISDIR(st.st_mode))
+ if (g_stat(fullpath, &st) == -1 || !S_ISDIR(st.st_mode))
return;
in.dnode = st.st_dev;
tmp = g_alloca (strlen (root) + 16);
sprintf (tmp, "%s/.folders", root);
- stream = camel_stream_fs_new_with_name(tmp, 0, O_RDONLY);
+ stream = camel_stream_fs_new_with_name(tmp, 0, O_RDONLY, NULL);
if (stream == NULL)
return;
visited = g_hash_table_new(g_str_hash, g_str_equal);
folders = g_ptr_array_new();
- while ( (len = camel_stream_buffer_gets((CamelStreamBuffer *)in, line, sizeof(line))) > 0) {
+ while ( (len = camel_stream_buffer_gets((CamelStreamBuffer *)in, line, sizeof(line), NULL)) > 0) {
/* ignore blank lines */
if (len <= 1)
continue;
g_hash_table_insert(visited, tmp, tmp);
path = g_strdup_printf("%s/%s", root, line);
- if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
+ if (g_stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
fi = folder_info_new(store, url, root, line, flags);
g_ptr_array_add(folders, fi);
}
get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelFolderInfo *fi = NULL;
CamelURL *url;
(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);
static gint
mh_summary_check (CamelLocalSummary *cls,
CamelFolderChangeInfo *changeinfo,
- CamelException *ex)
+ GError **error)
{
DIR *dir;
struct dirent *d;
no longer exist */
dir = opendir(cls->folder_path);
if (dir == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot open MH directory path: %s: %s"),
cls->folder_path, g_strerror (errno));
return -1;
/* keeps track of all uid's that have not been processed */
left = g_hash_table_new(g_str_hash, g_str_equal);
- camel_folder_summary_prepare_fetch_all ((CamelFolderSummary *)cls, ex);
+ camel_folder_summary_prepare_fetch_all ((CamelFolderSummary *)cls, error);
count = camel_folder_summary_count((CamelFolderSummary *)cls);
forceindex = count == 0;
for (i=0;i<count;i++) {
mh_summary_sync (CamelLocalSummary *cls,
gboolean expunge,
CamelFolderChangeInfo *changes,
- CamelException *ex)
+ GError **error)
{
CamelLocalSummaryClass *local_summary_class;
gint count, i;
/* 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 */
- camel_folder_summary_prepare_fetch_all ((CamelFolderSummary *)cls, ex);
+ camel_folder_summary_prepare_fetch_all ((CamelFolderSummary *)cls, error);
count = camel_folder_summary_count((CamelFolderSummary *)cls);
for (i=count-1;i>=0;i--) {
info = (CamelLocalMessageInfo *)camel_folder_summary_index((CamelFolderSummary *)cls, i);
/* Chain up to parent's sync() method. */
local_summary_class = CAMEL_LOCAL_SUMMARY_CLASS (camel_mh_summary_parent_class);
- return local_summary_class->sync (cls, expunge, changes, ex);
+ return local_summary_class->sync (cls, expunge, changes, error);
}
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);
G_DEFINE_TYPE (CamelSpoolFolder, camel_spool_folder, CAMEL_TYPE_MBOX_FOLDER)
camel_spool_folder_new (CamelStore *parent_store,
const gchar *full_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
gchar *basename;
flags &= ~CAMEL_STORE_FOLDER_BODY_INDEX;
folder = (CamelFolder *)camel_local_folder_construct (
- (CamelLocalFolder *)folder, flags, ex);
+ (CamelLocalFolder *)folder, flags, error);
if (folder) {
if (camel_url_get_param(((CamelService *)parent_store)->url, "xstatus"))
camel_mbox_summary_xstatus((CamelMboxSummary *)folder->summary, TRUE);
static gint
spool_lock (CamelLocalFolder *lf,
CamelLockType type,
- CamelException *ex)
+ GError **error)
{
gint retry = 0;
CamelMboxFolder *mf = (CamelMboxFolder *)lf;
CamelSpoolFolder *sf = (CamelSpoolFolder *)lf;
+ GError *local_error = NULL;
mf->lockfd = open(lf->folder_path, O_RDWR|O_LARGEFILE, 0);
if (mf->lockfd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot create folder lock on %s: %s"),
lf->folder_path, g_strerror (errno));
return -1;
if (retry > 0)
sleep(CAMEL_LOCK_DELAY);
- camel_exception_clear(ex);
+ g_clear_error (&local_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, &local_error) == 0) {
+ if (camel_lock_flock(mf->lockfd, type, &local_error) == 0) {
+ if ((sf->lockid = camel_lock_helper_lock(lf->folder_path, &local_error)) != -1)
return 0;
camel_unlock_flock(mf->lockfd);
}
close (mf->lockfd);
mf->lockfd = -1;
+ if (local_error != NULL)
+ g_propagate_error (error, local_error);
+
return -1;
}
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
#include <sys/stat.h>
#include <sys/types.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
+#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include "camel-spool-folder.h"
#define d(x)
-static gboolean 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 gboolean 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 gboolean 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);
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
struct stat st;
/* Chain up to parent's construct() method. */
service_class = CAMEL_SERVICE_CLASS (camel_spool_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ 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,
+ 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,
+ if (g_stat(service->url->path, &st) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Spool '%s' cannot be opened: %s"),
service->url->path, g_strerror (errno));
return FALSE;
/* we could check here for slight variations */
((CamelSpoolStore *)service)->type = CAMEL_SPOOL_STORE_ELM;
else {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ 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;
get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException * ex)
+ GError **error)
{
CamelFolder *folder = NULL;
struct stat st;
/* 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,
+ 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 (g_stat(name, &st) == -1) {
if (errno != ENOENT) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not open folder '%s':\n%s"),
folder_name, g_strerror (errno));
} else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not create folder '%s':\n%s"),
folder_name, g_strerror (errno));
} else {
- folder = camel_spool_folder_new(store, folder_name, flags, 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,
+ 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);
}
static CamelFolder *
get_inbox (CamelStore *store,
- CamelException *ex)
+ 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,
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
_("Store does not support an INBOX"));
return NULL;
}
rename_folder (CamelStore *store,
const gchar *old,
const gchar *new,
- CamelException *ex)
+ GError **error)
{
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Spool folders cannot be renamed"));
return FALSE;
static gboolean
delete_folder (CamelStore *store,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Spool folders cannot be deleted"));
return FALSE;
guint32 flags,
CamelFolderInfo *parent,
CamelFolderInfo **fip,
- CamelException *ex)
+ GError **error)
{
DIR *dir;
struct dirent *d;
} else
name = root;
- if (stat(name, &st) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ if (g_stat(name, &st) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not scan folder '%s': %s"),
name, g_strerror (errno));
} else if (S_ISREG(st.st_mode)) {
dir = opendir(name);
if (dir == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not scan folder '%s': %s"),
name, g_strerror (errno));
return -1;
continue;
tmp = g_strdup_printf("%s/%s", name, d->d_name);
- if (stat(tmp, &st) == 0) {
+ if (g_stat(tmp, &st) == 0) {
if (path)
fname = g_strdup_printf("%s/%s", path, d->d_name);
else
*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);
get_folder_info_elm (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ 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;
}
get_folder_info_mbox (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
CamelFolderInfo *fi = NULL, *fip = NULL;
get_folder_info (CamelStore *store,
const gchar *top,
guint32 flags,
- CamelException *ex)
+ 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 *
#include <sys/stat.h>
#include <sys/types.h>
+#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include "camel-spool-summary.h"
#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);
G_DEFINE_TYPE (CamelSpoolSummary, camel_spool_summary, CAMEL_TYPE_MBOX_SUMMARY)
static gint
spool_summary_load (CamelLocalSummary *cls,
gint forceindex,
- CamelException *ex)
+ GError **error)
{
g_warning("spool summary - not loading anything\n");
return 0;
spool_summary_sync_full (CamelMboxSummary *cls,
gboolean expunge,
CamelFolderChangeInfo *changeinfo,
- CamelException *ex)
+ GError **error)
{
gint fd = -1, fdout = -1;
gchar tmpname[64] = { '\0' };
fd = open(((CamelLocalSummary *)cls)->folder_path, O_RDWR|O_LARGEFILE);
if (fd == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not open file: %s: %s"),
((CamelLocalSummary *)cls)->folder_path,
g_strerror (errno));
d(printf("Writing tmp file to %s\n", tmpname));
if (fdout == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not sync temporary folder %s: %s"),
((CamelLocalSummary *)cls)->folder_path,
g_strerror (errno));
/* 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not sync temporary folder %s: %s"),
((CamelLocalSummary *)cls)->folder_path,
g_strerror (errno));
if (fstat(fdout, &st) == -1) {
g_warning("Cannot sync temporary folder: %s", g_strerror (errno));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not sync temporary folder %s: %s"),
((CamelLocalSummary *)cls)->folder_path,
g_strerror (errno));
|| 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not sync spool folder %s: %s"),
((CamelLocalSummary *)cls)->folder_path,
g_strerror (errno));
}
if (size == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not sync spool folder %s: %s\n"
"Folder may be corrupt, copy saved in '%s'"),
((CamelLocalSummary *)cls)->folder_path,
d(printf("Closing folders\n"));
if (ftruncate(fd, outlen) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not sync spool folder %s: %s\n"
"Folder may be corrupt, copy saved in '%s'"),
((CamelLocalSummary *)cls)->folder_path,
if (close(fd) == -1) {
g_warning("Cannot close source folder: %s", g_strerror (errno));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not sync spool folder %s: %s\n"
"Folder may be corrupt, copy saved in '%s'"),
((CamelLocalSummary *)cls)->folder_path,
static gint
spool_summary_check (CamelLocalSummary *cls,
CamelFolderChangeInfo *changeinfo,
- CamelException *ex)
+ GError **error)
{
gint i, work, count;
struct stat st;
CamelFolderSummary *s = (CamelFolderSummary *)cls;
- if (CAMEL_LOCAL_SUMMARY_CLASS (camel_spool_summary_parent_class)->check(cls, changeinfo, ex) == -1)
+ if (CAMEL_LOCAL_SUMMARY_CLASS (camel_spool_summary_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 */
work = FALSE;
- camel_folder_summary_prepare_fetch_all (s, ex);
+ camel_folder_summary_prepare_fetch_all (s, error);
count = camel_folder_summary_count(s);
for (i=0;!work && i<count; i++) {
CamelMboxMessageInfo *info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i);
/* 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,
+ if (g_stat(cls->folder_path, &st) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Unknown error: %s"),
g_strerror (errno));
return -1;
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);
-DG_LOG_DOMAIN=\"camel-nntp-provider\"
libcamelnntp_la_SOURCES = \
+ camel-nntp-folder.c \
camel-nntp-provider.c \
+ camel-nntp-store-summary.c \
camel-nntp-store.c \
- camel-nntp-folder.c \
camel-nntp-stream.c \
- camel-nntp-summary.c \
- camel-nntp-store-summary.c
+ camel-nntp-summary.c
-noinst_HEADERS = \
- camel-nntp-store.h \
+noinst_HEADERS = \
camel-nntp-folder.h \
+ camel-nntp-private.h \
camel-nntp-resp-codes.h \
- camel-nntp-stream.h \
- camel-nntp-summary.h \
camel-nntp-store-summary.h \
- camel-nntp-private.h
+ camel-nntp-store.h \
+ camel-nntp-stream.h \
+ camel-nntp-summary.h
libcamelnntp_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-auth.c : authentication for nntp */
-
-/*
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#include "camel-nntp-auth.h"
-#include "camel-nntp-store.h"
-#include "camel-nntp-resp-codes.h"
-
-gint
-camel_nntp_auth_authenticate (CamelNNTPStore *store, CamelException *ex)
-{
- CamelService *service = CAMEL_SERVICE (store);
- CamelSession *session = camel_service_get_session (service);
- gint resp;
-
- if (!service->url->authmech && !service->url->passwd) {
- gchar *prompt;
-
- prompt = camel_session_build_password_prompt (
- "NNTP", service->url->user, service->url->host);
-
- service->url->passwd = camel_session_get_password (
- session, service, NULL, prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
-
- g_free (prompt);
-
- if (!service->url->passwd) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- "You didn\'t enter a password.");
- resp = 666;
- goto done;
- }
- }
-
- /* first send username */
- resp = camel_nntp_command (store, ex, NULL, "AUTHINFO USER %s", service->url->user);
-
- if (resp == NNTP_AUTH_REJECTED) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server rejected username"));
- goto done;
-
- }
- else if (resp != NNTP_AUTH_CONTINUE) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Failed to send username to server"));
- goto done;
- }
-
- /* then send the username if the server asks for it */
- resp = camel_nntp_command (store, ex, NULL, "AUTHINFO PASS %s", service->url->passwd);
-
- if (resp == NNTP_AUTH_REJECTED) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- _("Server rejected username/password"));
- goto done;
- }
-
- done:
-
- if (service->url->passwd) {
- /* let's be paranoid */
- memset (service->url->passwd, 0, strlen (service->url->passwd));
- g_free (service->url->passwd);
- service->url->passwd = NULL;
- }
- return resp;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-auth.h : authentication for nntp */
-
-/*
- *
- * Author : Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#ifndef CAMEL_NNTP_AUTH_H
-#define CAMEL_NNTP_AUTH_H
-
-#include "camel-nntp-store.h"
-
-G_BEGIN_DECLS
-
-gint camel_nntp_auth_authenticate (CamelNNTPStore *store, CamelException *ex);
-
-G_END_DECLS
-
-#endif /* CAMEL_NNTP_AUTH_H */
gboolean
camel_nntp_folder_selected (CamelNNTPFolder *nntp_folder,
gchar *line,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
CamelStore *parent_store;
return camel_nntp_summary_check (
CAMEL_NNTP_SUMMARY (folder->summary),
CAMEL_NNTP_STORE (parent_store),
- line, nntp_folder->changes, ex);
+ line, nntp_folder->changes, error);
}
static gboolean
nntp_folder_refresh_info_online (CamelFolder *folder,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelNNTPStore *nntp_store;
/* When invoked with no fmt, camel_nntp_command() just selects the folder
and should return zero. */
success = !camel_nntp_command (
- nntp_store, ex, nntp_folder, &line, NULL);
+ nntp_store, error, nntp_folder, &line, NULL);
if (camel_folder_change_info_changed(nntp_folder->changes)) {
changes = nntp_folder->changes;
}
static gboolean
-nntp_folder_sync (CamelFolder *folder, CamelException *ex)
+nntp_folder_sync (CamelFolder *folder, GError **error)
{
CamelStore *parent_store;
GPtrArray *changed;
g_ptr_array_free (changed, TRUE);
camel_folder_summary_touch (folder->summary);
}
- success = camel_folder_summary_save_to_db (folder->summary, ex);
+ success = camel_folder_summary_save_to_db (folder->summary, NULL);
camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
}
static gboolean
-nntp_folder_sync_online (CamelFolder *folder, CamelException *ex)
+nntp_folder_sync_online (CamelFolder *folder, GError **error)
{
- return nntp_folder_sync (folder, ex);
+ return nntp_folder_sync (folder, error);
}
static gboolean
-nntp_folder_sync_offline (CamelFolder *folder, CamelException *ex)
+nntp_folder_sync_offline (CamelFolder *folder, GError **error)
{
- return nntp_folder_sync (folder, ex);
+ return nntp_folder_sync (folder, error);
}
static gchar *
-nntp_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+nntp_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelStore *parent_store;
CamelNNTPStore *nntp_store;
strcpy(article, uid);
msgid = strchr (article, ',');
if (msgid == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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)
{
CamelFolder *folder;
CamelStore *parent_store;
parent_store = camel_folder_get_parent_store (folder);
nntp_store = CAMEL_NNTP_STORE (parent_store);
- 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) {
- if (camel_stream_write_to_stream ((CamelStream *) nntp_store->stream, stream) == -1)
+ if (camel_stream_write_to_stream ((CamelStream *) nntp_store->stream, stream, error) == -1)
goto fail;
- if (camel_stream_reset (stream) == -1)
+ if (camel_stream_reset (stream, error) == -1)
goto fail;
} else {
stream = g_object_ref (nntp_store->stream);
}
} else if (ret == 423 || ret == 430) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot get message %s: %s"), msgid, line);
}
return stream;
fail:
- if (errno == EINTR)
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("User cancelled the operation"));
- else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message %s: %s"), msgid,
- g_strerror (errno));
+ g_prefix_error (error, _("Cannot get message %s: "), msgid);
return NULL;
}
static gboolean
nntp_folder_cache_message (CamelDiscoFolder *disco_folder,
const gchar *uid,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
CamelStore *parent_store;
strcpy(article, uid);
msgid = strchr(article, ',');
if (!msgid) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Internal error: UID in invalid format: %s"), uid);
return FALSE;
}
camel_service_lock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
stream = nntp_folder_download_message (
- (CamelNNTPFolder *) disco_folder, article, msgid, ex);
+ (CamelNNTPFolder *) disco_folder, article, msgid, error);
if (stream)
g_object_unref (stream);
else
}
static CamelMimeMessage *
-nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+nntp_folder_get_message (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelStore *parent_store;
CamelMimeMessage *message = NULL;
strcpy(article, uid);
msgid = strchr (article, ',');
if (msgid == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Internal error: UID in invalid format: %s"), uid);
return NULL;
}
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,
+ 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;
}
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 cancelled the operation"));
- else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message %s: %s"), uid,
- g_strerror (errno));
+ if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream, error) == -1) {
+ g_prefix_error (error, _("Cannot get message %s: "), uid);
g_object_unref (message);
message = NULL;
}
}
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;
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);
}
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;
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);
}
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;
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);
CamelMimeMessage *mime_message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelNNTPStore *nntp_store;
camel_service_lock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_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,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INSUFFICIENT_PERMISSION,
_("Posting failed: %s"), line);
success = FALSE;
} else if (ret != -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
_("Posting failed: %s"), line);
success = FALSE;
}
}
/* write the message */
- if (camel_stream_write(stream, group, strlen(group)) == -1
- || camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (mime_message), filtered_stream) == -1
- || 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 cancelled the operation"));
- else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Posting failed: %s"), g_strerror (errno));
+ if (camel_stream_write(stream, group, strlen(group), error) == -1
+ || camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (mime_message), filtered_stream, error) == -1
+ || camel_stream_flush (filtered_stream, error) == -1
+ || camel_stream_write (stream, "\r\n.\r\n", 5, error) == -1
+ || (ret = camel_nntp_stream_line (nntp_store->stream, (guchar **)&line, &u, error)) == -1) {
+ g_prefix_error (error, _("Posting failed: "));
success = FALSE;
} else if (atoi(line) != 240) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Posting failed: %s"), line);
success = FALSE;
}
CamelMimeMessage *mime_message,
const CamelMessageInfo *info,
gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("You cannot post NNTP messages while working offline!"));
return FALSE;
CamelFolder *dest,
GPtrArray **transferred_uids,
gboolean delete_orig,
- CamelException *ex)
+ GError **error)
{
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("You cannot copy messages from a NNTP folder!"));
return FALSE;
CamelFolder *
camel_nntp_folder_new (CamelStore *parent,
const gchar *folder_name,
- CamelException *ex)
+ GError **error)
{
CamelFolder *folder;
CamelNNTPFolder *nntp_folder;
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;
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) {
camel_store_summary_info_free ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, si);
}
- if (subscribed && !camel_folder_refresh_info (folder, ex)) {
+ if (subscribed && !camel_folder_refresh_info (folder, error)) {
g_object_unref (folder);
folder = NULL;
}
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);
-gboolean camel_nntp_folder_selected(CamelNNTPFolder *folder, gchar *line, CamelException *ex);
+gboolean camel_nntp_folder_selected(CamelNNTPFolder *folder, gchar *line, GError **error);
G_END_DECLS
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-grouplist.c : getting/updating the list of newsgroups on the server. */
-
-/*
- * Author : Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <string.h>
-
-#include <glib/gstdio.h>
-
-#include "camel-nntp-grouplist.h"
-#include "camel-nntp-resp-codes.h"
-
-static CamelNNTPGroupList *
-camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, CamelException *ex)
-{
- gint status;
- gboolean done = FALSE;
- CamelNNTPGroupList *list;
-
- CAMEL_NNTP_STORE_LOCK(store);
- status = camel_nntp_command (store, ex, NULL, &line, "LIST");
-
- if (status != NNTP_LIST_FOLLOWS) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not get group list from server."));
- return NULL;
- }
-
- list = g_new0 (CamelNNTPGroupList, 1);
- list->time = time (NULL);
-
- while (!done) {
- gchar *line;
-
- if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), &line, ex) < 0) {
- list->group_list = g_list_reverse(list->group_list);
- return list;
- }
-
- if (*line == '.') {
- done = TRUE;
- }
- else {
- CamelNNTPGroupListEntry *entry = g_new (CamelNNTPGroupListEntry, 1);
- gchar **split_line = g_strsplit (line, " ", 4);
-
- entry->group_name = g_strdup (split_line[0]);
- entry->high = atoi (split_line[1]);
- entry->low = atoi (split_line[2]);
-
- g_strfreev (split_line);
-
- list->group_list = g_list_prepend (list->group_list, entry);
- }
- }
- CAMEL_NNTP_STORE_UNLOCK(store);
-
- list->group_list = g_list_reverse(list->group_list);
- return list;
-}
-
-static CamelNNTPGroupList*
-camel_nntp_get_grouplist_from_file (CamelNNTPStore *store, CamelException *ex)
-{
- gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store));
- gchar *grouplist_file = g_strdup_printf ("%s/grouplist", root_dir);
- CamelNNTPGroupList *list;
- FILE *fp;
- gchar buf[300];
- gulong time;
-
- g_free (root_dir);
- fp = g_fopen (grouplist_file, "r");
- g_free (grouplist_file);
-
- if (fp == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Unable to load grouplist file for %s: %s"),
- CAMEL_SERVICE(store)->url->host,
- g_strerror(errno));
- return NULL;
- }
-
- /* read the time */
- if (!fgets (buf, sizeof (buf), fp)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Unable to load grouplist file for %s: %s"),
- CAMEL_SERVICE(store)->url->host,
- g_strerror(errno));
- fclose (fp);
- return NULL;
- }
-
- list = g_new0 (CamelNNTPGroupList, 1);
- list->store = store;
- sscanf (buf, "%lu", &time);
- list->time = time;
-
- while (fgets (buf, sizeof (buf), fp)) {
- CamelNNTPGroupListEntry *entry = g_new (CamelNNTPGroupListEntry, 1);
- gchar **split_line = g_strsplit (buf, " ", 4);
-
- entry->group_name = g_strdup (split_line[0]);
- entry->high = atoi (split_line[1]);
- entry->low = atoi (split_line[2]);
-
- g_strfreev (split_line);
-
- list->group_list = g_list_prepend (list->group_list, entry);
- }
-
- fclose (fp);
-
- list->group_list = g_list_reverse(list->group_list);
- return list;
-}
-
-static void
-save_entry (CamelNNTPGroupListEntry *entry, FILE *fp)
-{
- fprintf (fp, "%s %d %d\n", entry->group_name, entry->low, entry->high);
-}
-
-void
-camel_nntp_grouplist_save (CamelNNTPGroupList *group_list, CamelException *ex)
-{
- FILE *fp;
- gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(group_list->store));
- gchar *grouplist_file = g_strdup_printf ("%s/grouplist", root_dir);
-
- g_free (root_dir);
- fp = g_fopen (grouplist_file, "w");
- g_free (grouplist_file);
-
- if (fp == NULL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Unable to save grouplist file for %s: %s"),
- CAMEL_SERVICE(group_list->store)->url->host,
- g_strerror(errno));
- return;
- }
-
- fprintf (fp, "%lu\n", (glong)group_list->time);
-
- g_list_foreach (group_list->group_list, (GFunc)save_entry, fp);
-
- fclose (fp);
-}
-
-static void
-free_entry (CamelNNTPGroupListEntry *entry, gpointer data)
-{
- g_free (entry->group_name);
- g_free (entry);
-}
-
-void
-camel_nntp_grouplist_free (CamelNNTPGroupList *group_list)
-{
- g_return_if_fail (group_list);
-
- g_list_foreach (group_list->group_list, (GFunc)free_entry, NULL);
-
- g_free (group_list);
-}
-
-CamelNNTPGroupList*
-camel_nntp_grouplist_fetch (CamelNNTPStore *store, CamelException *ex)
-{
- CamelNNTPGroupList *list;
-
- list = camel_nntp_get_grouplist_from_file (store, ex);
-
- printf ("camel_nntp_get_grouplist_from_file returned %p\n", list);
-
- if (!list) {
- camel_exception_clear (ex);
-
- list = camel_nntp_get_grouplist_from_server (store, ex);
-
- if (!list) {
- camel_nntp_grouplist_free (list);
- }
- else {
- list->store = store;
- camel_nntp_grouplist_save (list, ex);
- return list;
- }
- }
-
- return list;
-}
-
-gint
-camel_nntp_grouplist_update (CamelNNTPGroupList *group_list, CamelException *ex)
-{
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-grouplist.h : getting/updating the list of newsgroups on the server. */
-
-/*
- * Author : Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#ifndef CAMEL_NNTP_GROUPLIST_H
-#define CAMEL_NNTP_GROUPLIST_H
-
-#include <time.h>
-#include "camel-nntp-store.h"
-
-G_BEGIN_DECLS
-
-struct CamelNNTPGroupListEntry {
- gchar *group_name;
- guint32 low;
- guint32 high;
- guint32 flags;
-};
-
-struct CamelNNTPGroupList {
- CamelNNTPStore *store;
- time_t time;
- GList *group_list;
-};
-
-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);
-void camel_nntp_grouplist_free (struct CamelNNTPGroupList *group_list);
-
-G_END_DECLS
-
-#endif /* CAMEL_NNTP_GROUPLIST_H */
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors: Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <glib/gstdio.h>
-
-#include "camel-nntp-newsrc.h"
-
-#define NEWSRC_LOCK(f, l) (g_mutex_lock(((CamelNNTPNewsrc *)f)->l))
-#define NEWSRC_UNLOCK(f, l) (g_mutex_unlock(((CamelNNTPNewsrc *)f)->l))
-
-typedef struct {
- guint low;
- guint high;
-} ArticleRange;
-
-typedef struct {
- gchar *name;
- GArray *ranges;
- gboolean subscribed;
-} NewsrcGroup;
-
-struct CamelNNTPNewsrc {
- gchar *filename;
- GHashTable *groups;
- gboolean dirty;
- GMutex *lock;
-};
-
-static NewsrcGroup *
-camel_nntp_newsrc_group_add (CamelNNTPNewsrc *newsrc, const gchar *group_name, gboolean subscribed)
-{
- NewsrcGroup *new_group = g_malloc(sizeof(NewsrcGroup));
-
- new_group->name = g_strdup(group_name);
- new_group->subscribed = subscribed;
- new_group->ranges = g_array_new (FALSE, FALSE, sizeof (ArticleRange));
-
- g_hash_table_insert (newsrc->groups, new_group->name, new_group);
-
- newsrc->dirty = TRUE;
-
- return new_group;
-}
-
-static gint
-camel_nntp_newsrc_group_get_highest_article_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group)
-{
- if (!group || group->ranges->len == 0)
- return 0;
-
- return g_array_index(group->ranges, ArticleRange, group->ranges->len - 1).high;
-}
-
-static gint
-camel_nntp_newsrc_group_get_num_articles_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group)
-{
- gint i;
- gint count = 0;
-
- if (group == NULL)
- return 0;
-
- for (i = 0; i < group->ranges->len; i ++)
- count += (g_array_index(group->ranges, ArticleRange, i).high -
- g_array_index(group->ranges, ArticleRange, i).low) + 1;
-
- return count;
-}
-
-static void
-camel_nntp_newsrc_group_mark_range_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group, glong low, glong high)
-{
- gint i;
-
- if (group->ranges->len == 1
- && g_array_index (group->ranges, ArticleRange, 0).low == 0
- && g_array_index (group->ranges, ArticleRange, 0).high == 0) {
- g_array_index (group->ranges, ArticleRange, 0).low = low;
- g_array_index (group->ranges, ArticleRange, 0).high = high;
-
- newsrc->dirty = TRUE;
- }
- else {
- ArticleRange tmp_range;
-
- for (i = 0; i < group->ranges->len; i ++) {
- guint range_low = g_array_index (group->ranges, ArticleRange, i).low;
- guint range_high = g_array_index (group->ranges, ArticleRange, i).high;
-
- /* if it's already part of a range, return immediately. */
- if (low >= range_low &&
- low <= range_high &&
- high >= range_low &&
- high <= range_high) {
- return;
- }
- /* if we have a new lower bound for this range, set it. */
- else if (low <= range_low
- && high >= range_low
- && high <= range_high) {
- g_array_index (group->ranges, ArticleRange, i).low = low;
- newsrc->dirty = TRUE;
- return;
- }
- /* if we have a new upper bound for this range, set it. */
- else if (high >= range_high
- && low >= range_low
- && low <= range_high) {
- g_array_index (group->ranges, ArticleRange, i).high = high;
- newsrc->dirty = TRUE;
- return;
- }
- /* if we would be inserting another range that
- starts one index higher than an existing
- one, make the upper value of the existing
- range the upper value of the new one. */
- else if (low == range_high + 1) {
- g_array_index (group->ranges, ArticleRange, i).high = high;
- newsrc->dirty = TRUE;
- return;
- }
- /* if we would be inserting another range that
- ends one index lower than an existing one,
- group the existing range by setting its low
- to the new low */
- else if (high == range_low - 1) {
- g_array_index (group->ranges, ArticleRange, i).low = low;
- newsrc->dirty = TRUE;
- return;
- }
- /* if the range lies entirely outside another
- range, doesn't coincide with it's
- endpoints, and has lower values, insert it
- into the middle of the list. */
- else if (low < range_low
- && high < range_low) {
- tmp_range.low = low;
- tmp_range.high = high;
-
- group->ranges = g_array_insert_val (group->ranges, i, tmp_range);
- newsrc->dirty = TRUE;
-
- return;
- }
- }
-
- /* if we made it here, the range needs to go at the end */
- tmp_range.low = low;
- tmp_range.high = high;
- group->ranges = g_array_append_val (group->ranges, tmp_range);
- newsrc->dirty = TRUE;
- }
-}
-
-gint
-camel_nntp_newsrc_get_highest_article_read (CamelNNTPNewsrc *newsrc, const gchar *group_name)
-{
- NewsrcGroup *group;
- gint ret;
-
- NEWSRC_LOCK(newsrc, lock);
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- if (group)
- ret = camel_nntp_newsrc_group_get_highest_article_read (newsrc, group);
- else
- ret = 0;
-
- NEWSRC_UNLOCK(newsrc, lock);
-
- return ret;
-}
-
-gint
-camel_nntp_newsrc_get_num_articles_read (CamelNNTPNewsrc *newsrc, const gchar *group_name)
-{
- NewsrcGroup *group;
- gint ret;
-
- NEWSRC_LOCK(newsrc, lock);
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- if (group)
- ret = camel_nntp_newsrc_group_get_num_articles_read (newsrc, group);
- else
- ret = 0;
-
- NEWSRC_UNLOCK(newsrc, lock);
-
- return ret;
-}
-
-void
-camel_nntp_newsrc_mark_article_read (CamelNNTPNewsrc *newsrc, const gchar *group_name, gint num)
-{
- camel_nntp_newsrc_mark_range_read (newsrc, group_name, num, num);
-}
-
-void
-camel_nntp_newsrc_mark_range_read(CamelNNTPNewsrc *newsrc, const gchar *group_name, glong low, glong high)
-{
- NewsrcGroup *group;
-
- /* swap them if they're in the wrong order. */
- if (low > high) {
- glong tmp;
-
- tmp = high;
- high = low;
- low = tmp;
- }
-
- NEWSRC_LOCK(newsrc, lock);
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- if (group)
- camel_nntp_newsrc_group_mark_range_read (newsrc, group, low, high);
- NEWSRC_UNLOCK(newsrc, lock);
-}
-
-gboolean
-camel_nntp_newsrc_article_is_read (CamelNNTPNewsrc *newsrc, const gchar *group_name, glong num)
-{
- gint i;
- NewsrcGroup *group;
- gint ret = FALSE;
-
- NEWSRC_LOCK(newsrc, lock);
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- if (group) {
- for (i = 0; i < group->ranges->len; i++) {
- if (num >= g_array_index (group->ranges, ArticleRange, i).low &&
- num <= g_array_index (group->ranges, ArticleRange, i).high) {
- ret = TRUE;
- break;
- }
- }
- }
-
- NEWSRC_UNLOCK(newsrc, lock);
-
- return FALSE;
-}
-
-gboolean
-camel_nntp_newsrc_group_is_subscribed (CamelNNTPNewsrc *newsrc, const gchar *group_name)
-{
- NewsrcGroup *group;
- gint ret = FALSE;
-
- NEWSRC_LOCK(newsrc, lock);
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- if (group) {
- ret = group->subscribed;
- }
-
- NEWSRC_UNLOCK(newsrc, lock);
-
- return ret;
-}
-
-void
-camel_nntp_newsrc_subscribe_group (CamelNNTPNewsrc *newsrc, const gchar *group_name)
-{
- NewsrcGroup *group;
-
- NEWSRC_LOCK(newsrc, lock);
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- if (group) {
- if (!group->subscribed)
- newsrc->dirty = TRUE;
- group->subscribed = TRUE;
- }
- else {
- camel_nntp_newsrc_group_add (newsrc, group_name, TRUE);
- }
-
- NEWSRC_UNLOCK(newsrc, lock);
-}
-
-void
-camel_nntp_newsrc_unsubscribe_group (CamelNNTPNewsrc *newsrc, const gchar *group_name)
-{
- NewsrcGroup *group;
-
- NEWSRC_LOCK(newsrc, lock);
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
- if (group) {
- if (group->subscribed)
- newsrc->dirty = TRUE;
- group->subscribed = FALSE;
- }
- else {
- camel_nntp_newsrc_group_add (newsrc, group_name, FALSE);
- }
-
- NEWSRC_UNLOCK(newsrc, lock);
-}
-
-struct newsrc_ptr_array {
- GPtrArray *ptr_array;
- gboolean subscribed_only;
-};
-
-/* this needs to strdup the grup_name, if the group array is likely to change */
-static void
-get_group_foreach (gchar *group_name, NewsrcGroup *group, struct newsrc_ptr_array *npa)
-{
- if (group->subscribed || !npa->subscribed_only) {
- g_ptr_array_add (npa->ptr_array, group_name);
- }
-}
-
-GPtrArray *
-camel_nntp_newsrc_get_subscribed_group_names (CamelNNTPNewsrc *newsrc)
-{
- struct newsrc_ptr_array npa;
-
- g_return_val_if_fail (newsrc, NULL);
-
- NEWSRC_LOCK(newsrc, lock);
-
- npa.ptr_array = g_ptr_array_new();
- npa.subscribed_only = TRUE;
-
- g_hash_table_foreach (newsrc->groups,
- (GHFunc)get_group_foreach, &npa);
-
- NEWSRC_UNLOCK(newsrc, lock);
-
- return npa.ptr_array;
-}
-
-GPtrArray *
-camel_nntp_newsrc_get_all_group_names (CamelNNTPNewsrc *newsrc)
-{
- struct newsrc_ptr_array npa;
-
- g_return_val_if_fail (newsrc, NULL);
-
- NEWSRC_LOCK(newsrc, lock);
-
- npa.ptr_array = g_ptr_array_new();
- npa.subscribed_only = FALSE;
-
- g_hash_table_foreach (newsrc->groups,
- (GHFunc)get_group_foreach, &npa);
-
- NEWSRC_UNLOCK(newsrc, lock);
-
- return npa.ptr_array;
-}
-
-void
-camel_nntp_newsrc_free_group_names (CamelNNTPNewsrc *newsrc, GPtrArray *group_names)
-{
- g_ptr_array_free (group_names, TRUE);
-}
-
-struct newsrc_fp {
- CamelNNTPNewsrc *newsrc;
- FILE *fp;
-};
-
-static void
-camel_nntp_newsrc_write_group_line(gpointer key, NewsrcGroup *group, struct newsrc_fp *newsrc_fp)
-{
- CamelNNTPNewsrc *newsrc;
- FILE *fp;
- gint i;
-
- fp = newsrc_fp->fp;
- newsrc = newsrc_fp->newsrc;
-
- fprintf (fp, "%s%c", group->name, group->subscribed ? ':' : '!');
-
- if (group->ranges->len == 1
- && g_array_index (group->ranges, ArticleRange, 0).low == 0
- && g_array_index (group->ranges, ArticleRange, 0).high == 0) {
- fprintf (fp, "\n");
-
- return; /* special case since our parsing code will insert this
- bogus range if there were no read articles. The code
- to add a range is smart enough to remove this one if we
- ever mark an article read, but we still need to deal with
- it if that code doesn't get hit. */
- }
-
- fprintf (fp, " ");
-
- for (i = 0; i < group->ranges->len; i ++) {
- gchar range_buffer[100];
- guint low = g_array_index (group->ranges, ArticleRange, i).low;
- guint high = g_array_index (group->ranges, ArticleRange, i).high;
-
- if (low == high)
- sprintf(range_buffer, "%d", low);
- else if (low == high - 1)
- sprintf(range_buffer, "%d,%d", low, high);
- else
- sprintf(range_buffer, "%d-%d", low, high);
-
- if (i != group->ranges->len - 1)
- strcat(range_buffer, ",");
-
- fprintf (fp, range_buffer);
- }
-
- fprintf (fp, "\n");
-}
-
-void
-camel_nntp_newsrc_write_to_file(CamelNNTPNewsrc *newsrc, FILE *fp)
-{
- struct newsrc_fp newsrc_fp;
-
- g_return_if_fail (newsrc);
-
- newsrc_fp.newsrc = newsrc;
- newsrc_fp.fp = fp;
-
- NEWSRC_LOCK(newsrc, lock);
-
- g_hash_table_foreach (newsrc->groups,
- (GHFunc)camel_nntp_newsrc_write_group_line,
- &newsrc_fp);
-
- NEWSRC_UNLOCK(newsrc, lock);
-}
-
-void
-camel_nntp_newsrc_write(CamelNNTPNewsrc *newsrc)
-{
- FILE *fp;
-
- g_return_if_fail (newsrc);
-
- NEWSRC_LOCK(newsrc, lock);
-
- if (!newsrc->dirty) {
- NEWSRC_UNLOCK(newsrc, lock);
- return;
- }
-
- if ((fp = g_fopen(newsrc->filename, "w")) == NULL) {
- g_warning ("Couldn't open newsrc file '%s'.\n", newsrc->filename);
- NEWSRC_UNLOCK(newsrc, lock);
- return;
- }
-
- newsrc->dirty = FALSE;
- NEWSRC_UNLOCK(newsrc, lock);
-
- camel_nntp_newsrc_write_to_file(newsrc, fp);
-
- fclose(fp);
-}
-
-static void
-camel_nntp_newsrc_parse_line(CamelNNTPNewsrc *newsrc, gchar *line)
-{
- gchar *p, *comma, *dash;
- gboolean is_subscribed;
- NewsrcGroup *group;
-
- p = strchr(line, ':');
-
- if (p) {
- is_subscribed = TRUE;
- }
- else {
- p = strchr(line, '!');
- if (p)
- is_subscribed = FALSE;
- else
- return; /* bogus line. */
- }
-
- *p++ = '\0';
-
- group = camel_nntp_newsrc_group_add (newsrc, line, is_subscribed);
-
- do {
- guint high, low;
-
- comma = strchr(p, ',');
-
- if (comma)
- *comma = '\0';
-
- dash = strchr(p, '-');
-
- if (!dash) { /* there wasn't a dash. must be just one number */
- high = low = atol(p);
- }
- else { /* there was a dash. */
- *dash = '\0';
- low = atol(p);
- *dash = '-';
- p = dash + 1;
- high = atol(p);
- }
-
- camel_nntp_newsrc_group_mark_range_read (newsrc, group, low, high);
-
- if (comma) {
- *comma = ',';
- p = comma + 1;
- }
-
- } while (comma);
-}
-
-static gchar *
-get_line (gchar *buf, gchar **p)
-{
- gchar *l;
- gchar *line;
-
- g_assert (*p == NULL || **p == '\n' || **p == '\0');
-
- if (*p == NULL) {
- *p = buf;
-
- if (**p == '\0')
- return NULL;
- }
- else {
- if (**p == '\0')
- return NULL;
-
- (*p) ++;
-
- /* if we just incremented to the end of the buffer, return NULL */
- if (**p == '\0')
- return NULL;
- }
-
- l = strchr (*p, '\n');
- if (l) {
- *l = '\0';
- line = g_strdup (*p);
- *l = '\n';
- *p = l;
- }
- else {
- /* we're at the last line (which isn't terminated by a \n, btw) */
- line = g_strdup (*p);
- (*p) += strlen (*p);
- }
-
- return line;
-}
-
-CamelNNTPNewsrc *
-camel_nntp_newsrc_read_for_server (const gchar *server)
-{
- gint fd;
- gchar buf[1024];
- gchar *file_contents, *line, *p;
- gchar *filename;
- CamelNNTPNewsrc *newsrc;
- gint newsrc_len;
- gint len_read = 0;
- struct stat sb;
-
- filename = g_strdup_printf ("%s/.newsrc-%s", g_get_home_dir(), server);
-
- newsrc = g_new0(CamelNNTPNewsrc, 1);
- newsrc->filename = filename;
- newsrc->groups = g_hash_table_new (g_str_hash, g_str_equal);
- newsrc->lock = g_mutex_new();
-
- if ((fd = g_open(filename, O_RDONLY, 0)) == -1) {
- g_warning ("~/.newsrc-%s not present.\n", server);
- return newsrc;
- }
-
- if (fstat (fd, &sb) == -1) {
- g_warning ("failed fstat on ~/.newsrc-%s: %s\n", server, g_strerror(errno));
- close (fd);
- return newsrc;
- }
- newsrc_len = sb.st_size;
-
- file_contents = g_malloc (newsrc_len + 1);
-
- while (len_read < newsrc_len) {
- gint c = read (fd, buf, sizeof (buf));
-
- if (c == -1)
- break;
-
- memcpy (&file_contents[len_read], buf, c);
- len_read += c;
- }
- file_contents [len_read] = 0;
-
- p = NULL;
- while ((line = get_line (file_contents, &p))) {
- camel_nntp_newsrc_parse_line(newsrc, line);
- g_free (line);
- }
-
- close (fd);
- g_free (file_contents);
-
- return newsrc;
-}
+++ /dev/null
-
-#ifndef CAMEL_NNTP_NEWSRC_H
-#define CAMEL_NNTP_NEWSRC_H
-
-#include <stdio.h>
-#include "glib.h"
-
-G_BEGIN_DECLS
-
-typedef struct CamelNNTPNewsrc CamelNNTPNewsrc;
-
-gint camel_nntp_newsrc_get_highest_article_read (CamelNNTPNewsrc *newsrc, const gchar *group_name);
-gint camel_nntp_newsrc_get_num_articles_read (CamelNNTPNewsrc *newsrc, const gchar *group_name);
-void camel_nntp_newsrc_mark_article_read (CamelNNTPNewsrc *newsrc,
- const gchar *group_name, gint num);
-void camel_nntp_newsrc_mark_range_read (CamelNNTPNewsrc *newsrc,
- const gchar *group_name, glong low, glong high);
-
-gboolean camel_nntp_newsrc_article_is_read (CamelNNTPNewsrc *newsrc,
- const gchar *group_name, glong num);
-
-gboolean camel_nntp_newsrc_group_is_subscribed (CamelNNTPNewsrc *newsrc, const gchar *group_name);
-void camel_nntp_newsrc_subscribe_group (CamelNNTPNewsrc *newsrc, const gchar *group_name);
-void camel_nntp_newsrc_unsubscribe_group (CamelNNTPNewsrc *newsrc, const gchar *group_name);
-
-GPtrArray* camel_nntp_newsrc_get_subscribed_group_names (CamelNNTPNewsrc *newsrc);
-GPtrArray* camel_nntp_newsrc_get_all_group_names (CamelNNTPNewsrc *newsrc);
-void camel_nntp_newsrc_free_group_names (CamelNNTPNewsrc *newsrc, GPtrArray *group_names);
-
-void camel_nntp_newsrc_write_to_file (CamelNNTPNewsrc *newsrc, FILE *fp);
-void camel_nntp_newsrc_write (CamelNNTPNewsrc *newsrc);
-CamelNNTPNewsrc *camel_nntp_newsrc_read_for_server (const gchar *server);
-
-G_END_DECLS
-
-#endif /* CAMEL_NNTP_NEWSRC_H */
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), CAMEL_TYPE_NNTP_STORE, CamelNNTPStorePrivate))
-static gint camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex);
+static gint camel_nntp_try_authenticate (CamelNNTPStore *store, GError **error);
G_DEFINE_TYPE (CamelNNTPStore, camel_nntp_store, CAMEL_TYPE_DISCO_STORE)
};
static gint
-xover_setup(CamelNNTPStore *store, CamelException *ex)
+xover_setup(CamelNNTPStore *store, GError **error)
{
gint ret, i;
gchar *line;
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)
last = (struct _xover_header *)&store->xover;
/* supported command */
- while ((ret = camel_nntp_stream_line(store->stream, (guchar **)&line, &len)) > 0) {
+ while ((ret = camel_nntp_stream_line(store->stream, (guchar **)&line, &len, error)) > 0) {
p = (guchar *) line;
xover = g_malloc0(sizeof(*xover));
last->next = xover;
#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;
tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
}
#else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_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;
g_free (socks_host);
}
- if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_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));
+ if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai, error) == -1) {
+ g_prefix_error (
+ error, _("Could not connect to %s: "),
+ service->url->host);
g_object_unref (tcp_stream);
goto fail;
g_object_unref (tcp_stream);
/* 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"));
- else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not read greeting from %s: %s"),
- service->url->host, g_strerror (errno));
+ if (camel_nntp_stream_line (store->stream, &buf, &len, error) == -1) {
+ g_prefix_error (
+ error, _("Could not read greeting from %s: "),
+ service->url->host);
g_object_unref (store->stream);
store->stream = NULL;
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_GENERIC,
+ _("NNTP server %s returned error code %d: %s"),
+ service->url->host, len, buf);
g_object_unref (store->stream);
store->stream = NULL;
/* 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);
}
};
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++)
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, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ 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);
}
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;
/* 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;
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)
}
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);
gchar *line;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_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");
g_object_unref (store->stream);
store->stream = NULL;
}
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);
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_lock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- folder = camel_nntp_folder_new(store, folder_name, ex);
+ folder = camel_nntp_folder_new(store, folder_name, error);
camel_service_unlock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
}
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;
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, NULL);
if (folder) {
CamelFolderChangeInfo *changes = NULL;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_nntp_command(store, ex, folder, &line, NULL);
+ camel_nntp_command(store, NULL, folder, &line, NULL);
if (camel_folder_change_info_changed(folder->changes)) {
changes = folder->changes;
folder->changes = camel_folder_change_info_new();
}
g_object_unref (folder);
}
- camel_exception_clear(ex);
}
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;
* 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,
/* 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;
}
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;
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) {
goto do_complete_list;
}
- while ((ret = camel_nntp_stream_line (nntp_store->stream, &line, &len)) > 0)
+ while ((ret = camel_nntp_stream_line (nntp_store->stream, &line, &len, error)) > 0)
nntp_store_info_update(nntp_store, (gchar *) line);
} else {
GHashTable *all;
/* 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
_("Error retrieving newsgroups:\n\n%s"), line);
goto error;
}
for (i = 0; (si = (CamelNNTPStoreInfo *)camel_store_summary_index ((CamelStoreSummary *)nntp_store->summary, i)); i++)
g_hash_table_insert(all, si->info.path, si);
- while ((ret = camel_nntp_stream_line(nntp_store->stream, &line, &len)) > 0) {
+ while ((ret = camel_nntp_stream_line(nntp_store->stream, &line, &len, error)) > 0) {
si = nntp_store_info_update(nntp_store, (gchar *) line);
g_hash_table_remove(all, si->info.path);
}
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_unlock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
}
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;
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
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;
si = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
if (!si) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ 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."));
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;
fitem = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
if (!fitem) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ 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;
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,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
_("You cannot create a folder in a News store: "
"subscribe instead."));
}
static gboolean
-nntp_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name_in, CamelException *ex)
+nntp_rename_folder (CamelStore *store, const gchar *old_name, const gchar *new_name_in, GError **error)
{
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
_("You cannot rename a folder in a News store."));
return FALSE;
}
static gboolean
-nntp_delete_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+nntp_delete_folder (CamelStore *store, const gchar *folder_name, GError **error)
{
- nntp_store_unsubscribe_folder (store, folder_name, ex);
+ nntp_store_unsubscribe_folder (store, folder_name, NULL);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
_("You cannot remove a folder in a News store: "
"unsubscribe instead."));
}
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;
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);
/* construct the parent first */
service_class = CAMEL_SERVICE_CLASS (camel_nntp_store_parent_class);
- if (!service_class->construct (service, session, provider, url, ex))
+ 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 FALSE;
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 FALSE;
}
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Authentication requested but no username provided"));
return -1;
}
service->url->passwd =
camel_session_get_password (session, service, NULL,
- prompt, "password", CAMEL_SESSION_PASSWORD_SECRET | (store->password_reprompt ? CAMEL_SESSION_PASSWORD_REPROMPT : 0), ex);
+ prompt, "password", CAMEL_SESSION_PASSWORD_SECRET | (store->password_reprompt ? CAMEL_SESSION_PASSWORD_REPROMPT : 0), error);
g_free(prompt);
g_free(base);
}
/* 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, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
+ g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE)) {
+ g_propagate_error (error, local_error);
return ret;
+ }
/* To force password reprompt */
store->password_reprompt = TRUE;
/* 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 *byte_array;
const guchar *p, *ps;
switch (c) {
case '%':
c = *p++;
- camel_stream_write ((CamelStream *) store->mem, (const gchar *) ps, p - ps - (c == '%' ? 1 : 2));
+ camel_stream_write ((CamelStream *) store->mem, (const gchar *) ps, p - ps - (c == '%' ? 1 : 2), NULL);
ps = p;
switch (c) {
case 's':
s = va_arg(ap, gchar *);
- camel_stream_write((CamelStream *)store->mem, s, strlen(s));
+ camel_stream_write((CamelStream *)store->mem, s, strlen(s), NULL);
break;
case 'd':
d = va_arg(ap, gint);
}
}
- camel_stream_write ((CamelStream *) store->mem, (const gchar *) ps, p-ps-1);
- camel_stream_write ((CamelStream *) store->mem, "\r\n", 2);
+ camel_stream_write ((CamelStream *) store->mem, (const gchar *) ps, p-ps-1, NULL);
+ camel_stream_write ((CamelStream *) store->mem, "\r\n", 2, NULL);
byte_array = camel_stream_mem_get_byte_array (store->mem);
- if (camel_stream_write((CamelStream *) store->stream, (const gchar *) byte_array->data, byte_array->len) == -1)
+ if (camel_stream_write((CamelStream *) store->stream, (const gchar *) byte_array->data, byte_array->len, error) == -1)
goto ioerror;
/* FIXME: hack */
- camel_stream_reset ((CamelStream *) store->mem);
+ camel_stream_reset ((CamelStream *) store->mem, NULL);
g_byte_array_set_size (byte_array, 0);
- if (camel_nntp_stream_line (store->stream, (guchar **) line, &u) == -1)
+ if (camel_nntp_stream_line (store->stream, (guchar **) line, &u, error) == -1)
goto ioerror;
u = strtoul (*line, NULL, 10);
return u;
ioerror:
- if (errno == EINTR)
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("User cancelled the operation"));
- else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("NNTP Command failed: %s"), g_strerror(errno));
+ g_prefix_error (error, _("NNTP Command failed: "));
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;
/* 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;
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;
}
}
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 gchar *full_name = NULL;
const guchar *p;
va_list ap;
gint ret, retry;
guint u;
+ GError *local_error = NULL;
if (((CamelDiscoStore *)store)->status == CAMEL_DISCO_STORE_OFFLINE) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_NOT_CONNECTED,
_("Not connected."));
return -1;
}
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, !*/
if (folder != NULL
&& (store->current_folder == NULL || strcmp(store->current_folder, full_name) != 0)) {
- ret = camel_nntp_raw_command_auth(store, ex, line, "group %s", full_name);
+ ret = camel_nntp_raw_command_auth(store, &local_error, line, "group %s", full_name);
if (ret == 211) {
g_free(store->current_folder);
store->current_folder = g_strdup (full_name);
- camel_nntp_folder_selected(folder, *line, ex);
- if (camel_exception_is_set(ex)) {
+ if (!camel_nntp_folder_selected(folder, *line, &local_error)) {
ret = -1;
goto error;
}
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"), *line);
return -1;
case 400: /* service discontinued */
case 401: /* wrong client state - this should quit but this is what the old code did */
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, G_IO_ERROR, G_IO_ERROR_CANCELLED) || 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);
G_BEGIN_DECLS
struct _CamelNNTPFolder;
-struct _CamelException;
typedef struct _CamelNNTPStore CamelNNTPStore;
typedef struct _CamelNNTPStoreClass 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
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <glib/gi18n-lib.h>
#include "camel-nntp-stream.h"
}
static gint
-nntp_stream_fill (CamelNNTPStream *is)
+nntp_stream_fill (CamelNNTPStream *is,
+ GError **error)
{
gint left = 0;
memcpy (is->buf, is->ptr, left);
is->end = is->buf + left;
is->ptr = is->buf;
- left = camel_stream_read (is->source, (gchar *) is->end, CAMEL_NNTP_STREAM_SIZE - (is->end - is->buf));
+ left = camel_stream_read (
+ is->source, (gchar *) is->end,
+ CAMEL_NNTP_STREAM_SIZE - (is->end - is->buf), error);
if (left > 0) {
is->end += left;
is->end[0] = '\n';
return is->end - is->ptr;
} else {
- if (left == 0)
+ if (left == 0) {
errno = ECONNRESET;
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "%s", g_strerror (errno));
+ }
dd (printf ("NNTP_STREAM_FILL (ERROR): %d - '%s'\n", left, g_strerror (errno)));
return -1;
}
static gssize
nntp_stream_read (CamelStream *stream,
gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelNNTPStream *is = (CamelNNTPStream *)stream;
gchar *o, *oe;
case 0: /* start of line, always read at least 3 chars */
while (e - p < 3) {
is->ptr = p;
- if (nntp_stream_fill (is) == -1)
+ if (nntp_stream_fill (is, error) == -1)
return -1;
p = is->ptr;
e = is->end;
/* end of input sentinal check */
if (p > e) {
is->ptr = e;
- if (nntp_stream_fill (is) == -1)
+ if (nntp_stream_fill (is, error) == -1)
return -1;
p = is->ptr;
e = is->end;
static gssize
nntp_stream_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelNNTPStream *is = (CamelNNTPStream *)stream;
- return camel_stream_write (is->source, buffer, n);
+ return camel_stream_write (is->source, buffer, n, error);
}
static gint
-nntp_stream_close (CamelStream *stream)
+nntp_stream_close (CamelStream *stream,
+ GError **error)
{
/* nop? */
return 0;
}
static gint
-nntp_stream_flush (CamelStream *stream)
+nntp_stream_flush (CamelStream *stream,
+ GError **error)
{
/* nop? */
return 0;
}
static gint
-nntp_stream_reset (CamelStream *stream)
+nntp_stream_reset (CamelStream *stream,
+ GError **error)
{
/* nop? reset literal mode? */
return 0;
gint
camel_nntp_stream_line (CamelNNTPStream *is,
guchar **data,
- guint *len)
+ guint *len,
+ GError **error)
{
register guchar c, *p, *o, *oe;
gint newlen, oldlen;
/* need at least 3 chars in buffer */
while (e-p < 3) {
is->ptr = p;
- if (nntp_stream_fill (is) == -1)
+ if (nntp_stream_fill (is, error) == -1)
return -1;
p = is->ptr;
e = is->end;
/* sentinal? */
if (p> e) {
is->ptr = e;
- if (nntp_stream_fill (is) == -1)
+ if (nntp_stream_fill (is, error) == -1)
return -1;
p = is->ptr;
e = is->end;
oe = is->lineend - 1;
o = is->linebuf + oldlen;
}
-
- return -1;
}
/* returns -1 on error, 0 if last lot of data, >0 if more remaining */
max = is->end - is->ptr;
if (max == 0) {
- max = nntp_stream_fill (is);
+ max = nntp_stream_fill (is, NULL);
if (max <= 0)
return max;
}
while (e - p < 3) {
is->ptr = p;
- if (nntp_stream_fill (is) == -1)
+ if (nntp_stream_fill (is, NULL) == -1)
return -1;
p = is->ptr;
e = is->end;
camel_nntp_stream_mode_t mode);
gint camel_nntp_stream_line (CamelNNTPStream *is,
guchar **data,
- guint *len);
+ guint *len,
+ GError **error);
gint camel_nntp_stream_gets (CamelNNTPStream *is,
guchar **start,
guint *len);
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);
G_DEFINE_TYPE (CamelNNTPSummary, camel_nntp_summary, CAMEL_TYPE_FOLDER_SUMMARY)
}
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 (camel_nntp_summary_parent_class)->summary_header_to_db (s, ex);
+ fir = CAMEL_FOLDER_SUMMARY_CLASS (camel_nntp_summary_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);
/* 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;
camel_operation_start (NULL, _("%s: Scanning new messages"), ((CamelService *)store)->url->host);
- ret = camel_nntp_raw_command_auth (store, ex, &line, "over %r", low, high);
+ ret = camel_nntp_raw_command_auth (store, error, &line, "over %r", low, high);
if (ret != 224)
- 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unexpected server response from xover: %s"), line);
return -1;
}
count = 0;
total = high-low+1;
- while ((ret = camel_nntp_stream_line (store->stream, (guchar **)&line, &len)) > 0) {
+ while ((ret = camel_nntp_stream_line (store->stream, (guchar **)&line, &len, error)) > 0) {
camel_operation_progress (NULL, (count * 100) / total);
count++;
n = strtoul (line, &tab, 10);
/* 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;
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Unexpected server response from head: %s"),
line);
goto ioerror;
line[1] = 0;
cns->priv->uid = g_strdup_printf ("%u,%s\n", n, msgid);
if (!GPOINTER_TO_INT (g_hash_table_lookup (summary_table, cns->priv->uid))) {
- if (camel_mime_parser_init_with_stream (mp, (CamelStream *)store->stream) == -1)
+ if (camel_mime_parser_init_with_stream (mp, (CamelStream *)store->stream, error) == -1)
goto error;
mi = camel_folder_summary_add_from_parser (s, mp);
while (camel_mime_parser_step (mp, NULL, NULL) != CAMEL_MIME_PARSER_STATE_EOF)
error:
if (ret == -1) {
if (errno == EINTR)
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("User cancelled the operation"));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Operation failed: %s"), g_strerror(errno));
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Operation failed: %s"),
+ g_strerror(errno));
}
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;
cns->low = f;
}
- camel_db_delete_uids (parent_store->cdb_w, full_name, del, ex);
+ camel_db_delete_uids (parent_store->cdb_w, full_name, del, NULL);
g_slist_foreach (del, (GFunc) g_free, NULL);
g_slist_free (del);
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 */
guint32 unread = 0;
count = camel_folder_summary_count (s);
- camel_db_count_unread_message_info (parent_store->cdb_r, full_name, &unread, ex);
+ camel_db_count_unread_message_info (parent_store->cdb_r, full_name, &unread, NULL);
if (si->info.unread != unread
|| si->info.total != count
struct _CamelNNTPStore;
struct _CamelFolderChangeInfo;
-struct _CamelException;
typedef struct _CamelNNTPSummary CamelNNTPSummary;
typedef struct _CamelNNTPSummaryClass 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
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-utils.c : utilities used by the nntp code. */
-
-/*
- * Author : Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "camel-nntp-resp-codes.h"
-#include "camel-nntp-folder.h"
-#include "camel-nntp-store.h"
-#include "camel-nntp-utils.h"
-
-static void
-get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
- gint first_message, gint last_message, CamelException *ex)
-{
- gint status;
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
- guint8 *digest;
- gsize length;
-
- length = g_checksum_type_get_length (G_CHECKSUM_MD5);
- digest = g_alloca (length);
-
- status = camel_nntp_command (nntp_store, ex, NULL,
- "XOVER %d-%d",
- first_message,
- last_message);
-
- if (status == NNTP_DATA_FOLLOWS) {
- gboolean done = FALSE;
-
- while (!done) {
- gchar *line;
-
- if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (nntp_store), &line, ex) < 0) {
- g_warning ("failed to recv_line while building OVER header list\n");
- break;
- }
-
- if (*line == '.') {
- done = TRUE;
- g_print ("done\n");
- }
- else {
- CamelMessageInfo *new_info = camel_folder_summary_info_new(folder->summary);
- GChecksum *checksum;
- gchar **split_line = g_strsplit (line, "\t", 7);
- gchar *subject, *from, *date, *message_id, *bytes;
- gchar *uid;
-
- subject = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_SUBJECT].index];
- from = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_FROM].index];
- date = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_DATE].index];
- message_id = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_MESSAGE_ID].index];
- bytes = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_BYTES].index];
-
- /* if the overview format flagged this
- field as "full", skip over the
- preceding field name and colon */
- if (nntp_store->overview_field [ CAMEL_NNTP_OVER_SUBJECT ].full)
- subject += strlen ("Subject:");
- if (nntp_store->overview_field [ CAMEL_NNTP_OVER_FROM ].full)
- from += strlen ("From:");
- if (nntp_store->overview_field [ CAMEL_NNTP_OVER_DATE ].full)
- date += strlen ("Date:");
- if (nntp_store->overview_field [ CAMEL_NNTP_OVER_MESSAGE_ID ].full)
- message_id += strlen ("Message-ID:");
- if (nntp_store->overview_field [ CAMEL_NNTP_OVER_BYTES ].full)
- bytes += strlen ("Bytes:");
-
- uid = g_strdup_printf ("%s,%s", split_line[0], message_id);
- camel_message_info_set_subject(new_info, g_strdup(subject));
- camel_message_info_set_from(new_info, g_strdup(from));
- camel_message_info_set_to(new_info, g_strdup(folder->name));
- new_info->uid = camel_pstring_strdup (uid);
- g_free (uid);
-
- new_info->date_sent = camel_header_decode_date(date, NULL);
-#if 0
- /* XXX do we need to fill in both dates? */
- new_info->headers.date_received = g_strdup(date);
-#endif
- new_info->size = atoi(bytes);
- checksum = g_checksum_new (G_CHECKSUM_MD5);
- g_checksum_update (checksum, (guchar *) message_id, -1);
- g_checksum_get_digest (checksum, digest, &length);
- g_checksum_free (checksum);
- memcpy(new_info->message_id.id.hash, digest, sizeof(new_info->message_id.id.hash));
-
- if (camel_nntp_newsrc_article_is_read (nntp_store->newsrc,
- folder->name,
- atoi (split_line[0])))
- new_info->flags |= CAMEL_MESSAGE_SEEN;
-
- camel_folder_summary_add (folder->summary, new_info);
- g_strfreev (split_line);
- }
- g_free (line);
- }
- }
- else {
- /* XXX */
- g_warning ("weird nntp response for XOVER: %d\n", status);
- }
-}
-
-#if 0
-static GArray*
-get_HEAD_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
- gint first_message, gint last_message, CamelException *ex)
-{
- gint i;
- gint status;
-
- for (i = first_message; i < last_message; i ++) {
- status = camel_nntp_command (nntp_store, ex, NULL,
- "HEAD %d", i);
-
- if (status == NNTP_HEAD_FOLLOWS) {
- gboolean done = FALSE;
- gchar *buf;
- gint buf_len;
- gint buf_alloc;
- gint h;
- CamelStream *header_stream;
- GArray *header_array;
- CamelStream *nntp_istream;
- CamelMessageInfo *new_info = g_new0(CamelMessageInfo, 1);
-
- buf_alloc = 2048;
- buf_len = 0;
- buf = g_malloc(buf_alloc);
- done = FALSE;
-
- buf[0] = 0;
-
- nntp_istream = nntp_store->istream;
-
- while (!done) {
- gchar *line;
- gint line_length;
-
- line = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER ( nntp_istream ));
- line_length = strlen ( line );
-
- if (*line == '.') {
- done = TRUE;
- }
- else {
- if (buf_len + line_length > buf_alloc) {
- buf_alloc *= 2;
- buf = g_realloc (buf, buf_alloc);
- }
- strcat(buf, line);
- strcat(buf, "\n");
- buf_len += strlen(line);
- g_free (line);
- }
- }
-
- /* create a stream from which to parse the headers */
- header_stream = camel_stream_mem_new_with_buffer (buf, buf_len,
- CAMEL_STREAM_MEM_READ);
-
- header_array = get_header_array_from_stream (header_stream);
-
- memset (&info, 0, sizeof(info));
-
- for (h = 0; h < header_array->len; h ++) {
- Rfc822Header *header = &((Rfc822Header*)header_array->data)[h];
- if (!g_ascii_strcasecmp(header->name, "From"))
- new_info->from = g_strdup(header->value);
- else if (!g_ascii_strcasecmp(header->name, "To"))
- new_info->to = g_strdup(header->value);
- else if (!g_ascii_strcasecmp(header->name, "Subject"))
- new_info->subject = g_strdup(header->value);
- else if (!g_ascii_strcasecmp(header->name, "Message-ID")) {
- gchar *uid = g_strdup_printf("%d,%s", i, header->value);
-
- new_info->uid = camel_pstring_strdup (uid);
- g_free (uid);
- new_info->message_id = g_strdup(header->value);
- }
- else if (!g_ascii_strcasecmp(header->name, "Date")) {
- new_info->date_sent = camel_header_decode_date (header->value);
-#if 0
- new_info->date_sent = g_strdup(header->value);
- new_info->date_received = g_strdup(header->value);
-#endif
- }
- }
-
- camel_folder_summary_add (nntp_folder->summary, new_info);
- }
- else if (status == CAMEL_NNTP_FAIL) {
- /* nasty things are afoot */
- g_warning ("failure doing HEAD\n");
- break;
- }
- }
-}
-#endif
-
-static inline gint
-uid_num (CamelFolderSummary *summary, gint index)
-{
- gchar *tmp;
- gchar *brk;
- gint ret;
-
- tmp = camel_folder_summary_uid_from_index(summary, index);
-
- if ((brk = strchr(tmp, ',')) == NULL)
- ret = 0;
- else {
- *brk = 0;
- ret = atoi(tmp);
- }
-
- g_free(tmp);
-
- return ret;
-}
-
-void
-camel_nntp_get_headers (CamelStore *store,
- CamelNNTPFolder *nntp_folder,
- CamelException *ex)
-{
- CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
- CamelFolder *folder = CAMEL_FOLDER (nntp_folder);
- gchar *ret;
- gint first_message, nb_message, last_message, last_summary;
- gint status;
- gint i;
-
- status = camel_nntp_command (nntp_store, ex, &ret,
- "GROUP %s", folder->name);
- sscanf (ret, "%d %d %d", &nb_message, &first_message, &last_message);
- g_free (ret);
-
- i = camel_folder_summary_count(folder->summary);
- if (i != 0) {
- GSList *del = NULL;
- last_summary = uid_num(folder->summary, i-1);
-
- if (last_summary < first_message)
- camel_folder_summary_clear(folder->summary);
- else {
- while (uid_num(folder->summary, 0) < first_message) {
- gchar *uid = camel_folder_summary_uid_from_index (folder->summary, 0);
- del = g_slist_prepend (del, uid);
- camel_folder_summary_remove_index_fast (s, 0);
- }
-
- camel_db_delete_uids (folder->parent_store->cdb_w, folder->full_name, del, ex);
- g_slist_foreach (del, (GFunc) g_free, NULL);
- g_slist_free (del);
-
- if (last_summary >= last_message)
- return;
-
- first_message = last_summary;
- }
- }
-
- if (status == NNTP_NO_SUCH_GROUP) {
- /* XXX throw invalid group exception */
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "group %s not found on server",
- folder->name);
- return;
- }
-
- if (nntp_store->extensions & CAMEL_NNTP_EXT_OVER) {
- get_XOVER_headers (nntp_store, folder, first_message, last_message, ex);
- }
- else {
- g_warning ("need to fix get_HEAD_headers\n");
-#if 0
- get_HEAD_headers (nntp_store, folder, first_message, last_message, ex);
-#endif
- }
-
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-utils.h : Utilities for the NNTP provider */
-
-/*
- *
- * Author : Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA
- */
-
-#ifndef CAMEL_NNTP_UTILS_H
-#define CAMEL_NNTP_UTILS_H
-
-G_BEGIN_DECLS
-
-void camel_nntp_get_headers (CamelStore *store, CamelNNTPFolder *nntp_folder, CamelException *ex);
-
-G_END_DECLS
-
-#endif /* CAMEL_NNTP_UTILS_H */
}
/* ??? */
- if (camel_stream_write((CamelStream *)pe->stream, pc->data, strlen(pc->data)) == -1) {
+ if (camel_stream_write((CamelStream *)pe->stream, pc->data, strlen(pc->data), NULL) == -1) {
camel_dlist_addtail(&pe->queue, (CamelDListNode *)pc);
return FALSE;
}
&& pe->current != NULL)
break;
- if (camel_stream_write((CamelStream *)pe->stream, pw->data, strlen(pw->data)) == -1)
+ if (camel_stream_write((CamelStream *)pe->stream, pw->data, strlen(pw->data), NULL) == -1)
goto ioerror;
camel_dlist_remove((CamelDListNode *)pw);
#define d(x)
-static gboolean pop3_refresh_info (CamelFolder *folder, CamelException *ex);
-static gboolean 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);
G_DEFINE_TYPE (CamelPOP3Folder, camel_pop3_folder, CAMEL_TYPE_FOLDER)
}
CamelFolder *
-camel_pop3_folder_new (CamelStore *parent, CamelException *ex)
+camel_pop3_folder_new (CamelStore *parent, GError **error)
{
CamelFolder *folder;
"parent-store", parent, NULL);
/* mt-ok, since we dont have the folder-lock for new() */
- if (!camel_folder_refresh_info (folder, ex)) { /* mt-ok */
+ if (!camel_folder_refresh_info (folder, error)) { /* mt-ok */
g_object_unref (folder);
folder = NULL;
}
checksum = g_checksum_new (G_CHECKSUM_MD5);
mp = camel_mime_parser_new();
- camel_mime_parser_init_with_stream(mp, (CamelStream *)stream);
+ camel_mime_parser_init_with_stream(mp, (CamelStream *)stream, NULL);
switch (camel_mime_parser_step(mp, NULL, NULL)) {
case CAMEL_MIME_PARSER_STATE_HEADER:
case CAMEL_MIME_PARSER_STATE_MESSAGE:
}
static gboolean
-pop3_refresh_info (CamelFolder *folder, CamelException *ex)
+pop3_refresh_info (CamelFolder *folder, GError **error)
{
CamelStore *parent_store;
CamelPOP3Store *pop3_store;
if (i == -1) {
if (errno == EINTR)
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("User canceled"));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Cannot get POP summary: %s"),
g_strerror (errno));
success = FALSE;
static gboolean
pop3_sync (CamelFolder *folder,
gboolean expunge,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelPOP3Folder *pop3_folder;
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) {
camel_operation_end(NULL);
- camel_pop3_store_expunge (pop3_store, ex);
+ camel_pop3_store_expunge (pop3_store, error);
return TRUE;
}
g_return_val_if_fail (pop3_store->cache != NULL, FALSE);
if ((stream = camel_data_cache_get (pop3_store->cache, "cache", uid, NULL)) != NULL
- && camel_stream_read (stream, buffer, 1) == 1
+ && camel_stream_read (stream, buffer, 1, NULL) == 1
&& buffer[0] == '#') {
CamelMimeMessage *message;
message = camel_mime_message_new ();
- if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, stream) == -1) {
+ if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, stream, NULL) == -1) {
g_warning (_("Cannot get message %s: %s"), uid, g_strerror (errno));
g_object_unref (message);
message = NULL;
gint
camel_pop3_delete_old (CamelFolder *folder,
gint days_to_delete,
- CamelException *ex)
+ GError **error)
{
CamelStore *parent_store;
CamelPOP3Folder *pop3_folder;
d(printf("%s(%d): fi->uid=[%s]\n", __FILE__, __LINE__, fi->uid));
if (!pop3_get_message_time_from_cache (folder, fi->uid, &message_time)) {
d(printf("could not get message time from cache, trying from pop3\n"));
- message = pop3_get_message (folder, fi->uid, ex);
+ message = pop3_get_message (folder, fi->uid, error);
if (message) {
message_time = message->date + message->date_offset;
g_object_unref (message);
camel_operation_end(NULL);
- camel_pop3_store_expunge (pop3_store, ex);
+ camel_pop3_store_expunge (pop3_store, error);
return 0;
}
/* We write an '*' to the start of the stream to say its not complete yet */
/* This should probably be part of the cache code */
- if ((n = camel_stream_write (fi->stream, "*", 1)) == -1)
+ if ((n = camel_stream_write (fi->stream, "*", 1, NULL)) == -1)
goto done;
- while ((n = camel_stream_read((CamelStream *)stream, buffer, sizeof(buffer))) > 0) {
- n = camel_stream_write(fi->stream, buffer, n);
+ while ((n = camel_stream_read((CamelStream *)stream, buffer, sizeof(buffer), NULL)) > 0) {
+ n = camel_stream_write(fi->stream, buffer, n, NULL);
if (n == -1)
break;
/* it all worked, output a '#' to say we're a-ok */
if (n != -1) {
- camel_stream_reset(fi->stream);
- n = camel_stream_write(fi->stream, "#", 1);
+ camel_stream_reset(fi->stream, NULL);
+ n = camel_stream_write(fi->stream, "#", 1, NULL);
}
done:
if (n == -1) {
}
static gchar *
-pop3_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
+pop3_get_filename (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelStore *parent_store;
CamelPOP3Folder *pop3_folder;
fi = g_hash_table_lookup(pop3_folder->uids_uid, uid);
if (fi == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
_("No message with UID %s"), uid);
return NULL;
}
}
static CamelMimeMessage *
-pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
+pop3_get_message (CamelFolder *folder, const gchar *uid, GError **error)
{
CamelStore *parent_store;
CamelMimeMessage *message = NULL;
fi = g_hash_table_lookup(pop3_folder->uids_uid, uid);
if (fi == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
_("No message with UID %s"), uid);
return NULL;
}
if (fi->err != 0) {
if (fi->err == EINTR)
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("User canceled"));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
_("Cannot get message %s: %s"),
uid, g_strerror (fi->err));
goto fail;
/* check to see if we have safely written flag set */
if (pop3_store->cache == NULL
|| (stream = camel_data_cache_get(pop3_store->cache, "cache", fi->uid, NULL)) == NULL
- || camel_stream_read(stream, buffer, 1) != 1
+ || camel_stream_read(stream, buffer, 1, NULL) != 1
|| buffer[0] != '#') {
/* Initiate retrieval, if disk backing fails, use a memory backing */
/* getting error code? */
/*g_assert (pcr->state == CAMEL_POP3_COMMAND_DATA);*/
camel_pop3_engine_command_free(pop3_store->engine, pcr);
- camel_stream_reset(stream);
+ camel_stream_reset(stream, NULL);
/* 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, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
_("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"));
+ if (camel_stream_read (stream, buffer, 1, error) == -1)
+ goto done;
+
+ if (buffer[0] != '#') {
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot get message %s: %s"), uid,
+ _("Unknown reason"));
goto done;
}
}
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"));
- else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot get message %s: %s"),
- uid, g_strerror (errno));
+ if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, stream, error) == -1) {
+ g_prefix_error (error, _("Cannot get message %s: "), uid);
g_object_unref (message);
message = NULL;
}
};
/* 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
/* defines the length of the server error message we can display in the error dialog */
#define POP3_ERROR_SIZE_LIMIT 60
-static gpointer camel_pop3_store_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);
G_DEFINE_TYPE (CamelPOP3Store, camel_pop3_store, CAMEL_TYPE_STORE)
connect_to_server (CamelService *service,
struct addrinfo *ai,
gint ssl_mode,
- CamelException *ex)
+ GError **error)
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
CamelSession *session;
tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
}
#else
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, _("SSL unavailable"));
g_free (socks_host);
}
- if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
- if (errno == EINTR)
- camel_exception_set (
- ex, CAMEL_EXCEPTION_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));
-
+ if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai, error) == -1) {
g_object_unref (tcp_stream);
-
return FALSE;
}
/* parent class connect initialization */
- if (CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class)->connect (service, ex) == FALSE) {
+ if (CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class)->connect (service, error) == FALSE) {
g_object_unref (tcp_stream);
return FALSE;
}
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_GENERIC,
_("Failed to read a valid greeting from POP server %s"),
service->url->host);
g_object_unref (tcp_stream);
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_GENERIC,
_("Failed to connect to POP server %s in secure mode: %s"),
service->url->host, _("STLS not supported by server"));
goto stls_exception;
gchar *tmp;
tmp = get_valid_utf8_error ((gchar *) store->engine->line);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("Failed to connect to POP server %s in secure mode%s"),
service->url->host, (tmp != NULL) ? tmp : "");
ret = camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream));
if (ret == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to POP server %s in secure mode: %s"),
service->url->host, _("TLS negotiations failed"));
goto stls_exception;
}
#else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to POP server %s in secure mode: %s"),
service->url->host, _("TLS is not available in this build"));
goto stls_exception;
static gboolean
connect_to_server_wrapper (CamelService *service,
- CamelException *ex)
+ 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++)
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, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ 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);
static GList *
query_auth_types (CamelService *service,
- CamelException *ex)
+ 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 (camel_pop3_store_parent_class);
- types = service_class->query_auth_types (service, ex);
+ types = service_class->query_auth_types (service, &local_error);
- 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,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to POP server %s"),
service->url->host);
}
/**
* camel_pop3_store_expunge:
* @store: the store
- * @ex: a CamelException
+ * @error: return location for a #GError, or %NULL
*
* Expunge messages from the store. This will result in the connection
* being closed, which may cause later commands to fail if they can't
* reconnect.
**/
void
-camel_pop3_store_expunge (CamelPOP3Store *store, CamelException *ex)
+camel_pop3_store_expunge (CamelPOP3Store *store, GError **error)
{
CamelPOP3Command *pc;
;
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)
+ GError **error)
{
CamelPOP3Stream *stream = store->engine->stream;
guchar *line, *resp;
sasl = camel_sasl_new("pop", mech, (CamelService *)store);
if (sasl == NULL) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ 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);
tmp = get_valid_utf8_error (
(gchar *) store->engine->line);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("SASL '%s' Login failed for POP server %s%s"),
mech, CAMEL_SERVICE (store)->url->host,
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"),
+ 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;
}
return 0;
ioerror:
- if (errno == EINTR) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_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_prefix_error (
+ error, _("Failed to authenticate on POP server %s: "),
+ CAMEL_SERVICE (store)->url->host);
+
done:
g_object_unref (sasl);
return -1;
pop3_try_authenticate (CamelService *service,
gboolean reprompt,
const gchar *errmsg,
- CamelException *ex)
+ GError **error)
{
CamelPOP3Store *store = (CamelPOP3Store *)service;
CamelPOP3Command *pcu = NULL, *pcp = NULL;
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);
if (!isascii((gint)*d)) {
/* README for Translators: The string APOP should not be translated */
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ 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."),
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,
+ 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);
if (status == -1) {
if (errno == EINTR) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Cancelled"));
} else {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("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) {
- gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
+ gchar *tmp;
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ tmp = get_valid_utf8_error ((gchar *) store->engine->line);
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("Unable to connect to POP server %s.\n"
"Error sending username%s"),
gchar *tmp;
tmp = get_valid_utf8_error ((gchar *) store->engine->line);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("Unable to connect to POP server %s.\n"
"Error sending password%s"),
static gboolean
pop3_connect (CamelService *service,
- CamelException *ex)
+ 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 */
}
}
- 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);
+ 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) {
- errbuf = g_markup_printf_escaped ("%s\n\n", camel_exception_get_description (ex));
- camel_exception_clear (ex);
+ 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);
+
+ g_clear_error (&local_error);
g_free (service->url->passwd);
service->url->passwd = NULL;
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;
}
static gboolean
pop3_disconnect (CamelService *service,
gboolean clean,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
/* Chain up to parent's disconnect() method. */
service_class = CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class);
- if (!service_class->disconnect (service, clean, ex))
+ if (!service_class->disconnect (service, clean, error))
return FALSE;
g_object_unref (store->engine);
get_folder (CamelStore *store,
const gchar *folder_name,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
if (g_ascii_strcasecmp (folder_name, "inbox") != 0) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ 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;
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
}
static gint
-stream_fill (CamelPOP3Stream *is)
+stream_fill (CamelPOP3Stream *is,
+ GError **error)
{
gint left = 0;
is->ptr = is->buf;
left = camel_stream_read (
is->source, (gchar *) is->end,
- CAMEL_POP3_STREAM_SIZE - (is->end - is->buf));
+ CAMEL_POP3_STREAM_SIZE - (is->end - is->buf), error);
if (left > 0) {
is->end += left;
is->end[0] = '\n';
return is->end - is->ptr;
- } else {
- dd (printf ("POP3_STREAM_FILL (ERROR): '%s'\n", g_strerror (errno)));
+ } else
return -1;
- }
}
return 0;
}
static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
+stream_read (CamelStream *stream,
+ gchar *buffer,
+ gsize n,
+ GError **error)
{
CamelPOP3Stream *is = (CamelPOP3Stream *)stream;
gchar *o, *oe;
case 0: /* start of line, always read at least 3 chars */
while (e - p < 3) {
is->ptr = p;
- if (stream_fill (is) == -1)
+ if (stream_fill (is, error) == -1)
return -1;
p = is->ptr;
e = is->end;
/* end of input sentinal check */
if (p > e) {
is->ptr = e;
- if (stream_fill (is) == -1)
+ if (stream_fill (is, error) == -1)
return -1;
p = is->ptr;
e = is->end;
static gssize
stream_write (CamelStream *stream,
const gchar *buffer,
- gsize n)
+ gsize n,
+ GError **error)
{
CamelPOP3Stream *is = (CamelPOP3Stream *)stream;
else
dd (printf ("POP3_STREAM_WRITE (%d):\nPASS xxxxxxxx\n", (gint)n));
- return camel_stream_write (is->source, buffer, n);
+ return camel_stream_write (is->source, buffer, n, error);
}
static gint
-stream_close (CamelStream *stream)
+stream_close (CamelStream *stream,
+ GError **error)
{
/* nop? */
return 0;
}
static gint
-stream_flush (CamelStream *stream)
+stream_flush (CamelStream *stream,
+ GError **error)
{
/* nop? */
return 0;
}
static gint
-stream_reset (CamelStream *stream)
+stream_reset (CamelStream *stream,
+ GError **error)
{
/* nop? reset literal mode? */
return 0;
/* need at least 3 chars in buffer */
while (e-p < 3) {
is->ptr = p;
- if (stream_fill (is) == -1)
+ if (stream_fill (is, NULL) == -1)
return -1;
p = is->ptr;
e = is->end;
/* sentinal? */
if (p> e) {
is->ptr = e;
- if (stream_fill (is) == -1)
+ if (stream_fill (is, NULL) == -1)
return -1;
p = is->ptr;
e = is->end;
max = is->end - is->ptr;
if (max == 0) {
- max = stream_fill (is);
+ max = stream_fill (is, NULL);
if (max <= 0)
return max;
}
while (e - p < 3) {
is->ptr = p;
- if (stream_fill (is) == -1)
+ if (stream_fill (is, NULL) == -1)
return -1;
p = is->ptr;
e = is->end;
static gboolean sendmail_send_to (CamelTransport *transport,
CamelMimeMessage *message,
CamelAddress *from, CamelAddress *recipients,
- CamelException *ex);
+ GError **error);
G_DEFINE_TYPE (CamelSendmailTransport, camel_sendmail_transport, CAMEL_TYPE_TRANSPORT)
CamelMimeMessage *message,
CamelAddress *from,
CamelAddress *recipients,
- CamelException *ex)
+ GError **error)
{
struct _camel_header_raw *header, *savedbcc, *n, *tail;
const gchar *from_addr, *addr, **argv;
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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Could not parse recipient list"));
g_free (argv);
return FALSE;
}
if (pipe (fd) == -1) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not create pipe to sendmail: %s: "
"mail not sent"), g_strerror (errno));
pid = fork ();
switch (pid) {
case -1:
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
_("Could not fork sendmail: %s: "
"mail not sent"), g_strerror (errno));
close (fd[0]);
g_object_unref (out);
out = (CamelStream *) filter;
- if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1
- || camel_stream_close (out) == -1) {
+ if (camel_data_wrapper_write_to_stream (
+ CAMEL_DATA_WRAPPER (message), out, error) == -1
+ || camel_stream_close (out, error) == -1) {
g_object_unref (CAMEL_OBJECT (out));
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not send message: %s"),
- g_strerror (errno));
+ g_prefix_error (error, _("Could not send message: "));
/* Wait for sendmail to exit. */
while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR)
header->next = savedbcc;
if (!WIFEXITED (wstat)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Could not execute %s: mail not sent."),
SENDMAIL_PATH);
} else {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("sendmail exited with status %d: "
"mail not sent."),
WEXITSTATUS (wstat));
/* 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);
+static void smtp_set_error (CamelSmtpTransport *transport, const gchar *respbuf, GError **error);
G_DEFINE_TYPE (CamelSmtpTransport, camel_smtp_transport, CAMEL_TYPE_TRANSPORT)
connect_to_server (CamelService *service,
struct addrinfo *ai,
gint ssl_mode,
- CamelException *ex)
+ GError **error)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelSession *session;
gint socks_port;
CamelStream *tcp_stream;
gchar *respbuf = NULL;
- gint ret;
- if (!CAMEL_SERVICE_CLASS (camel_smtp_transport_parent_class)->connect (service, ex))
+ if (!CAMEL_SERVICE_CLASS (camel_smtp_transport_parent_class)->connect (service, error))
return FALSE;
/* set some smtp transport defaults */
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 */
g_free (socks_host);
}
- if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
- if (errno == EINTR)
- camel_exception_set (ex, CAMEL_EXCEPTION_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));
-
+ if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai, error) == -1) {
g_object_unref (tcp_stream);
-
return FALSE;
}
do {
/* Check for "220" */
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);
+ respbuf = camel_stream_buffer_read_line (
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("Welcome response error: "));
+ transport->connected = FALSE;
+ return FALSE;
+ }
+ if (strncmp (respbuf, "220", 3)) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (error, _("Welcome response error: "));
g_free (respbuf);
return FALSE;
}
/* 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;
}
/* 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 */
#ifdef HAVE_SSL
if (!(transport->flags & CAMEL_SMTP_TRANSPORT_STARTTLS)) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to SMTP server %s in secure mode: %s"),
service->url->host, _("STARTTLS not supported"));
}
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 (camel_stream_write (tcp_stream, "STARTTLS\r\n", 10, error) == -1) {
+ g_prefix_error (error, _("STARTTLS command failed: "));
goto exception_cleanup;
}
do {
/* Check for "220 Ready for TLS" */
g_free (respbuf);
- respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
- if (!respbuf || strncmp (respbuf, "220", 3) != 0) {
- smtp_set_exception (
- transport, FALSE, respbuf,
- _("STARTTLS command failed"), ex);
+ respbuf = camel_stream_buffer_read_line (
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("STARTTLS command failed: "));
+ transport->connected = FALSE;
+ goto exception_cleanup;
+ }
+ if (strncmp (respbuf, "220", 3) != 0) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (error, _("STARTTLS command failed: "));
g_free (respbuf);
goto exception_cleanup;
}
/* 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,
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to SMTP server %s in secure mode: %s"),
service->url->host, _("SSL is not available in this build"));
goto exception_cleanup;
/* 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;
static gboolean
connect_to_server_wrapper (CamelService *service,
- CamelException *ex)
+ 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++)
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, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ 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);
}
static gboolean
-smtp_connect (CamelService *service, CamelException *ex)
+smtp_connect (CamelService *service, GError **error)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
gboolean has_authtypes;
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);
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 */
gchar *errbuf = NULL;
if (!g_hash_table_lookup (transport->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,
_("SMTP server %s does not support "
"requested authentication type %s."),
service->url->host, service->url->authmech);
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ 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);
/* authentication mechanism doesn't need a password,
so if it fails there's nothing we can do */
authenticated = smtp_auth (
- transport, authtype->authproto, ex);
+ transport, authtype->authproto, error);
if (!authenticated) {
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
/* 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 */
g_free (service->url->passwd);
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);
}
}
- 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, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
+ 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;
static gboolean
smtp_disconnect (CamelService *service,
gboolean clean,
- CamelException *ex)
+ GError **error)
{
CamelServiceClass *service_class;
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
if (transport->connected && clean) {
/* send the QUIT command to the SMTP server */
- smtp_quit (transport, ex);
+ smtp_quit (transport, NULL);
}
/* Chain up to parent's disconnect() method. */
service_class = CAMEL_SERVICE_CLASS (camel_smtp_transport_parent_class);
- if (!service_class->disconnect (service, clean, ex))
+ if (!service_class->disconnect (service, clean, error))
return FALSE;
if (transport->authtypes) {
}
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);
static gboolean
smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
CamelAddress *from, CamelAddress *recipients,
- CamelException *ex)
+ GError **error)
{
CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT (transport);
CamelInternetAddress *cia;
gint i, len;
if (!smtp_transport->connected) {
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot send message: sender address not valid."));
return FALSE;
}
/* 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,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot send message: no recipients defined."));
camel_operation_end (NULL);
return FALSE;
gchar *enc;
if (!camel_internet_address_get (cia, i, NULL, &addr)) {
- camel_exception_set (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot send message: "
"one or more invalid recipients"));
camel_operation_end (NULL);
}
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;
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);
}
static void
-smtp_set_exception (CamelSmtpTransport *transport,
- gboolean disconnect,
- const gchar *respbuf,
- const gchar *message,
- CamelException *ex)
+smtp_set_error (CamelSmtpTransport *transport,
+ const gchar *respbuf,
+ 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, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ "%s", smtp_error_string (errnum));
+ else
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
+ "%s", smtp_error_string (errnum));
} else {
string = g_string_new ("");
do {
if (*(rbuf + 3) == '-') {
g_free (buffer);
buffer = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
+ CAMEL_STREAM_BUFFER (transport->istream), NULL);
g_string_append_c (string, '\n');
} else {
g_free (buffer);
goto fake_status_code;
}
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
- "%s: %s", message, string->str);
+ g_set_error (
+ error, CAMEL_ERROR,
+ CAMEL_ERROR_GENERIC,
+ "%s", string->str);
g_string_free (string, TRUE);
} else {
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_GENERIC,
+ "%s", buffer);
g_free (buffer);
}
}
-
- if (!respbuf) {
- /* we got disconnected */
- if (disconnect)
- camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
- else
- transport->connected = FALSE;
- }
}
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;
g_free (name);
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("HELO command failed: %s"), g_strerror (errno));
+ g_prefix_error (error, _("HELO command failed: "));
camel_operation_end (NULL);
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
/* Check for "250" */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
- if (!respbuf || strncmp (respbuf, "250", 3)) {
- smtp_set_exception (
- transport, FALSE, respbuf,
- _("HELO command failed"), ex);
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("HELO command failed: "));
+ transport->connected = FALSE;
+ camel_operation_end (NULL);
+ return FALSE;
+ }
+ if (strncmp (respbuf, "250", 3)) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (error, _("HELO command failed: "));
camel_operation_end (NULL);
g_free (respbuf);
return FALSE;
static gboolean
smtp_auth (CamelSmtpTransport *transport,
const gchar *mech,
- CamelException *ex)
+ GError **error)
{
CamelService *service;
gchar *cmdbuf, *respbuf = NULL, *challenge;
sasl = camel_sasl_new ("smtp", mech, service);
if (!sasl) {
camel_operation_end (NULL);
- camel_exception_setv (
- ex, CAMEL_EXCEPTION_SYSTEM,
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("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);
}
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("AUTH command failed: %s"), g_strerror (errno));
+ g_prefix_error (error, _("AUTH command failed: "));
goto lose;
}
g_free (cmdbuf);
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
+ CAMEL_STREAM_BUFFER (transport->istream), error);
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));
+ g_prefix_error (error, _("AUTH command failed: "));
+ transport->connected = FALSE;
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_error (transport, respbuf, error);
+ g_prefix_error (error, _("AUTH command failed: "));
goto lose;
}
/* 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;
cmdbuf = g_strdup_printf ("%s\r\n", challenge);
g_free (challenge);
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -1) {
g_free (cmdbuf);
goto lose;
}
/* get the server's response */
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
+ CAMEL_STREAM_BUFFER (transport->istream), error);
}
if (respbuf == NULL)
}
/* 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);
break_and_lose:
/* Get the server out of "waiting for continuation data" mode. */
d(fprintf (stderr, "sending : *\n"));
- camel_stream_write (transport->ostream, "*\r\n", 3);
+ camel_stream_write (transport->ostream, "*\r\n", 3, NULL);
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
+ CAMEL_STREAM_BUFFER (transport->istream), NULL);
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);
}
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;
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -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));
+ g_prefix_error (error, _("MAIL FROM command failed: "));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
/* Check for "250 Sender OK..." */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
- if (!respbuf || strncmp (respbuf, "250", 3)) {
- smtp_set_exception (
- transport, TRUE, respbuf,
- _("MAIL FROM command failed"), ex);
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("MAIL FROM command failed: "));
+ camel_service_disconnect (
+ CAMEL_SERVICE (transport), FALSE, NULL);
+ return FALSE;
+ }
+ if (strncmp (respbuf, "250", 3)) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (error, _("MAIL FROM command failed: "));
g_free (respbuf);
return FALSE;
}
}
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 */
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -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));
-
+ g_prefix_error (error, _("RCPT TO command failed: "));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
do {
/* Check for "250 Recipient OK..." */
g_free (respbuf);
- respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
- d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
- if (!respbuf || strncmp (respbuf, "250", 3)) {
- gchar *message;
-
- message = g_strdup_printf (_("RCPT TO <%s> failed"), recipient);
- smtp_set_exception (transport, TRUE, respbuf, message, ex);
- g_free (message);
+ respbuf = camel_stream_buffer_read_line (
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (
+ error, _("RCPT TO <%s> failed: "), recipient);
+ camel_service_disconnect (
+ CAMEL_SERVICE (transport), FALSE, NULL);
+ return FALSE;
+ }
+ if (strncmp (respbuf, "250", 3)) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (
+ error, _("RCPT TO <%s> failed: "), recipient);
g_free (respbuf);
+
return FALSE;
}
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
}
static gboolean
-smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelException *ex)
+smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, GError **error)
{
struct _camel_header_raw *header, *savedbcc, *n, *tail;
CamelBestencEncoding enctype = CAMEL_BESTENC_8BIT;
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -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));
-
+ g_prefix_error (error, _("DATA command failed: "));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
g_free (cmdbuf);
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
-
- if (!respbuf || strncmp (respbuf, "354", 3) != 0) {
- /* we should have gotten instructions on how to use the DATA command:
- * 354 Enter mail, end with "." on a line by itself
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("DATA command failed: "));
+ camel_service_disconnect (
+ CAMEL_SERVICE (transport), FALSE, NULL);
+ return FALSE;
+ }
+ if (strncmp (respbuf, "354", 3) != 0) {
+ /* 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_error (transport, respbuf, error);
+ g_prefix_error (error, _("DATA command failed: "));
g_free (respbuf);
return FALSE;
}
/* find out how large the message is... */
null = CAMEL_STREAM_NULL (camel_stream_null_new ());
camel_data_wrapper_write_to_stream (
- CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (null));
+ CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (null), NULL);
filtered_stream = camel_stream_filter_new (transport->ostream);
/* write the message */
ret = camel_data_wrapper_write_to_stream (
- CAMEL_DATA_WRAPPER (message), filtered_stream);
+ CAMEL_DATA_WRAPPER (message), filtered_stream, error);
/* restore the bcc headers */
header->next = savedbcc;
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));
+ g_prefix_error (error, _("DATA command failed: "));
g_object_unref (filtered_stream);
return FALSE;
}
- camel_stream_flush (filtered_stream);
+ camel_stream_flush (filtered_stream, NULL);
g_object_unref (filtered_stream);
/* terminate the message body */
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 (camel_stream_write (transport->ostream, "\r\n.\r\n", 5, error) == -1) {
+ g_prefix_error (error, _("DATA command failed: "));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
/* Check for "250 Sender OK..." */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
- if (!respbuf || strncmp (respbuf, "250", 3) != 0) {
- smtp_set_exception (transport, TRUE, respbuf, _("DATA command failed"), ex);
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("DATA command failed: "));
+ camel_service_disconnect (
+ CAMEL_SERVICE (transport), FALSE, NULL);
+ return FALSE;
+ }
+ if (strncmp (respbuf, "250", 3) != 0) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (error, _("DATA command failed: "));
g_free (respbuf);
return FALSE;
}
}
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;
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("RSET command failed: %s"), g_strerror (errno));
-
+ g_prefix_error (error, _("RSET command failed: "));
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
/* Check for "250" */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER (transport->istream));
- if (!respbuf || strncmp (respbuf, "250", 3) != 0) {
- smtp_set_exception (
- transport, TRUE, respbuf,
- _("RSET command failed"), ex);
+ CAMEL_STREAM_BUFFER (transport->istream), error);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("RSET command failed: "));
+ camel_service_disconnect (
+ CAMEL_SERVICE (transport), FALSE, NULL);
+ return FALSE;
+ }
+ if (strncmp (respbuf, "250", 3) != 0) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (error, _("RSET command failed: "));
g_free (respbuf);
return FALSE;
}
}
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;
d(fprintf (stderr, "sending : %s", cmdbuf));
- if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
+ if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf), error) == -1) {
g_free (cmdbuf);
- camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
- _("QUIT command failed: %s"), g_strerror (errno));
-
+ g_prefix_error (error, _("QUIT command failed: "));
return FALSE;
}
g_free (cmdbuf);
do {
/* Check for "221" */
g_free (respbuf);
- respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
+ respbuf = camel_stream_buffer_read_line (
+ CAMEL_STREAM_BUFFER (transport->istream), error);
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
- if (!respbuf || strncmp (respbuf, "221", 3) != 0) {
- smtp_set_exception (
- transport, FALSE, respbuf,
- _("QUIT command failed"), ex);
+ if (respbuf == NULL) {
+ g_prefix_error (error, _("QUIT command failed: "));
+ transport->connected = FALSE;
+ return FALSE;
+ }
+ if (strncmp (respbuf, "221", 3) != 0) {
+ smtp_set_error (transport, respbuf, error);
+ g_prefix_error (error, _("QUIT command failed: "));
g_free (respbuf);
return FALSE;
}
gint main(gint argc, gchar **argv)
{
CamelSession *session;
- CamelException *ex;
gint i;
gchar *path;
camel_test_init(argc, argv);
camel_test_provider_init(1, local_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
}
g_object_unref (session);
- camel_exception_free(ex);
return 0;
}
worker(gpointer d)
{
gint i;
- CamelException *ex = camel_exception_new();
CamelStore *store;
CamelFolder *folder;
for (i=0;i<MAX_LOOP;i++) {
- store = camel_session_get_store(session, path, ex);
- camel_exception_clear(ex);
- folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
- camel_exception_clear(ex);
+ store = camel_session_get_store(session, path, NULL);
+ folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, NULL);
if (testid == 0) {
g_object_unref (folder);
g_object_unref (store);
}
}
- camel_exception_free(ex);
-
return NULL;
}
gint
main(gint argc, gchar **argv)
{
- CamelException *ex;
gint i, j;
GThread *threads[MAX_THREADS];
camel_test_init(argc, argv);
camel_test_provider_init(1, local_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
}
g_object_unref (session);
- camel_exception_free(ex);
return 0;
}
gint
main(gint argc, gchar **argv)
{
- CamelException *ex;
CamelFolder *f1, *f2;
CamelStore *store;
CamelFolderInfo *fi;
+ GError *error = NULL;
camel_test_init(argc, argv);
camel_test_provider_init(1, local_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
session = camel_test_session_new("/tmp/camel-test");
- store = camel_session_get_store(session, "maildir:///tmp/camel-test/maildir", ex);
- camel_exception_clear(ex);
+ store = camel_session_get_store(session, "maildir:///tmp/camel-test/maildir", NULL);
camel_test_start("Maildir backward compatability tests");
camel_test_push("./ prefix path, one level");
- f1 = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- f2 = camel_store_get_folder(store, "./testbox", CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ f1 = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
+ f2 = camel_store_get_folder(store, "./testbox", CAMEL_STORE_FOLDER_CREATE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check(f1 == f2);
check_unref(f2, 2);
check_unref(f1, 1);
camel_test_pull();
camel_test_push("./ prefix path, one level, no create");
- f1 = camel_store_get_folder(store, "testbox2", CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- f2 = camel_store_get_folder(store, "./testbox2", 0, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ f1 = camel_store_get_folder(store, "testbox2", CAMEL_STORE_FOLDER_CREATE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
+ f2 = camel_store_get_folder(store, "./testbox2", 0, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check(f1 == f2);
check_unref(f2, 2);
check_unref(f1, 1);
camel_test_pull();
camel_test_push("./ prefix path, two levels");
- f1 = camel_store_get_folder(store, "testbox/foo", CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- f2 = camel_store_get_folder(store, "./testbox/foo", CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ f1 = camel_store_get_folder(store, "testbox/foo", CAMEL_STORE_FOLDER_CREATE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
+ f2 = camel_store_get_folder(store, "./testbox/foo", CAMEL_STORE_FOLDER_CREATE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check(f1 == f2);
check_unref(f2, 2);
check_unref(f1, 1);
camel_test_pull();
camel_test_push("'.' == Inbox");
- f2 = camel_store_get_inbox(store, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- f1 = camel_store_get_folder(store, ".", 0, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ f2 = camel_store_get_inbox(store, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
+ f1 = camel_store_get_folder(store, ".", 0, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check(f1 == f2);
check_unref(f2, 2);
check_unref(f1, 1);
camel_test_pull();
camel_test_push("folder info, recursive");
- fi = camel_store_get_folder_info(store, "", CAMEL_STORE_FOLDER_INFO_RECURSIVE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ fi = camel_store_get_folder_info(store, "", CAMEL_STORE_FOLDER_INFO_RECURSIVE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check(fi != NULL);
check_fi(fi, fi_list_1, G_N_ELEMENTS (fi_list_1));
camel_test_pull();
camel_test_push("folder info, flat");
- fi = camel_store_get_folder_info(store, "", 0, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ fi = camel_store_get_folder_info(store, "", 0, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check(fi != NULL);
check_fi(fi, fi_list_2, G_N_ELEMENTS (fi_list_2));
camel_test_pull();
camel_test_push("folder info, recursive, non root");
- fi = camel_store_get_folder_info(store, "testbox", CAMEL_STORE_FOLDER_INFO_RECURSIVE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ fi = camel_store_get_folder_info(store, "testbox", CAMEL_STORE_FOLDER_INFO_RECURSIVE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check(fi != NULL);
check_fi(fi, fi_list_3, G_N_ELEMENTS (fi_list_3));
camel_test_pull();
check_unref(store, 1);
check_unref(session, 1);
- camel_exception_free(ex);
-
camel_test_end();
return 0;
gint main(gint argc, gchar **argv)
{
CamelSession *session;
- CamelException *ex;
gint i;
camel_test_init(argc, argv);
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
- ex = camel_exception_new();
-
session = camel_test_session_new ("/tmp/camel-test");
/* we iterate over all stores we want to test, with indexing or indexing turned on or off */
test_folder_message_ops(session, "spool:///tmp/camel-test/testbox", TRUE, "INBOX");
check_unref(session, 1);
- camel_exception_free(ex);
return 0;
}
static void
test_folder_search_sub(CamelFolder *folder, const gchar *expr, gint expected)
{
- CamelException *ex = camel_exception_new();
GPtrArray *uids;
GHashTable *hash;
gint i;
+ GError *error = NULL;
- uids = camel_folder_search_by_expression(folder, expr, ex);
+ uids = camel_folder_search_by_expression(folder, expr, &error);
check(uids != NULL);
check_msg(uids->len == expected, "search %s expected %d got %d", expr, expected, uids->len);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
/* check the uid's are actually unique, too */
hash = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_destroy(hash);
camel_folder_search_free(folder, uids);
-
- camel_exception_free(ex);
}
static void
static struct {
gint counts[3];
- gchar *expr;
+ const gchar *expr;
} searches[] = {
{ { 1, 1, 0 }, "(header-matches \"subject\" \"Test1 message99 subject\")" },
{
CamelSession *session;
CamelStore *store;
- CamelException *ex;
CamelFolder *folder;
CamelMimeMessage *msg;
gint i, j;
gint indexed;
GPtrArray *uids;
+ GError *error = NULL;
camel_test_init(argc, argv);
camel_test_provider_init(1, local_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
test_free(what);
push("getting store");
- store = camel_session_get_store(session, stores[i], ex);
- check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex));
+ store = camel_session_get_store(session, stores[i], &error);
+ check_msg(error == NULL, "getting store: %s", error->message);
check(store != NULL);
+ g_clear_error (&error);
pull();
push("creating %sindexed folder", indexed?"":"non-");
flags = CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX;
else
flags = CAMEL_STORE_FOLDER_CREATE;
- folder = camel_store_get_folder(store, "testbox", flags, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ folder = camel_store_get_folder(store, "testbox", flags, &error);
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
/* we need an empty folder for this to work */
test_folder_counts(folder, 0, 0);
+ g_clear_error (&error);
pull();
/* append a bunch of messages with specific content */
pull();
push("appending simple message %d", j);
- camel_folder_append_message(folder, msg, NULL, NULL, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_append_message(folder, msg, NULL, NULL, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
test_free(subject);
camel_test_fatal();
push("syncing folder, searching");
- camel_folder_sync(folder, FALSE, ex);
+ camel_folder_sync(folder, FALSE, NULL);
run_search(folder, 100);
pull();
push("syncing wiht expunge, search");
- camel_folder_sync(folder, TRUE, ex);
+ camel_folder_sync(folder, TRUE, NULL);
run_search(folder, 100);
pull();
run_search(folder, 100);
push("syncing");
- camel_folder_sync(folder, FALSE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_sync(folder, FALSE, &error);
+ check_msg(error == NULL, "%s", error->message);
run_search(folder, 100);
+ g_clear_error (&error);
pull();
push("expunging");
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_expunge(folder, &error);
+ check_msg(error == NULL, "%s", error->message);
run_search(folder, 50);
+ g_clear_error (&error);
pull();
pull();
push("closing and re-opening folder");
check_unref(folder, 1);
- folder = camel_store_get_folder(store, "testbox", flags&~(CAMEL_STORE_FOLDER_CREATE), ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ folder = camel_store_get_folder(store, "testbox", flags&~(CAMEL_STORE_FOLDER_CREATE), &error);
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
+ g_clear_error (&error);
push("deleting remaining messages");
uids = camel_folder_get_uids(folder);
run_search(folder, 50);
push("syncing");
- camel_folder_sync(folder, FALSE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_sync(folder, FALSE, &error);
+ check_msg(error == NULL, "%s", error->message);
run_search(folder, 50);
+ g_clear_error (&error);
pull();
push("expunging");
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_expunge(folder, &error);
+ check_msg(error == NULL, "%s", error->message);
run_search(folder, 0);
+ g_clear_error (&error);
pull();
pull();
pull();
push("deleting test folder, with no messages in it");
- camel_store_delete_folder(store, "testbox", ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_store_delete_folder(store, "testbox", &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
check_unref(store, 1);
}
check_unref(session, 1);
- camel_exception_free(ex);
return 0;
}
gint main(gint argc, gchar **argv)
{
CamelSession *session;
- CamelException *ex;
gint i;
gchar *path;
camel_test_init(argc, argv);
camel_test_provider_init(1, imap_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
}
g_object_unref (session);
- camel_exception_free(ex);
return 0;
}
gint main(gint argc, gchar **argv)
{
CamelSession *session;
- CamelException *ex;
gint i;
gchar *path;
camel_test_init(argc, argv);
camel_test_provider_init(1, nntp_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
}
g_object_unref (session);
- camel_exception_free(ex);
return 0;
}
gint main(gint argc, gchar **argv)
{
CamelSession *session;
- CamelException *ex;
gint i;
gchar *path;
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
- ex = camel_exception_new();
-
session = camel_test_session_new ("/tmp/camel-test");
for (i = 0; i < G_N_ELEMENTS (remote_providers); i++) {
}
check_unref(session, 1);
- camel_exception_free(ex);
return 0;
}
gint main(gint argc, gchar **argv)
{
CamelSession *session;
- CamelException *ex;
gint i;
gchar *path;
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
- ex = camel_exception_new();
-
session = camel_test_session_new ("/tmp/camel-test");
for (i = 0; i < G_N_ELEMENTS (remote_providers); i++) {
}
check_unref(session, 1);
- camel_exception_free(ex);
return 0;
}
CamelMimeMessage *msg;
gchar *content;
gchar *subject;
- CamelException ex;
-
- camel_exception_init(&ex);
+ GError *error = NULL;
push("creating message %d\n", j);
msg = test_message_create_simple();
pull();
push("appending simple message %d", j);
- camel_folder_append_message(folder, msg, NULL, NULL, &ex);
- check_msg(!camel_exception_is_set(&ex), "%s", camel_exception_get_description(&ex));
+ camel_folder_append_message(folder, msg, NULL, NULL, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
check_unref(msg, 1);
gint i, j, id = info->id;
gchar *sub, *content;
GPtrArray *res;
- CamelException *ex = camel_exception_new();
CamelMimeMessage *msg;
+ GError *error = NULL;
/* we add a message, search for it, twiddle some flags, delete it */
/* and flat out */
sub = g_strdup_printf("(match-all (header-contains \"subject\" \"message %08x subject\"))", id+i);
push("searching for message %d\n\tusing: %s", id+i, sub);
- res = camel_folder_search_by_expression(info->folder, sub, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ res = camel_folder_search_by_expression(info->folder, sub, &error);
+ check_msg(error == NULL, "%s", error->message);
check_msg(res->len == 1, "res->len = %d", res->len);
+ g_clear_error (&error);
pull();
push("getting message '%s'", res->pdata[0]);
- msg = camel_folder_get_message(info->folder, (gchar *)res->pdata[0], ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ msg = camel_folder_get_message(info->folder, (gchar *)res->pdata[0], &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
content = g_strdup_printf("Test message %08x contents\n\n", id+i);
if (j<=2) {
d(printf("Forcing an expuge\n"));
push("expunging folder");
- camel_folder_expunge(info->folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_expunge(info->folder, &error);
+ check_msg(error == NULL, "%s", error->message);
pull();
}
}
- camel_exception_free(ex);
-
return info;
}
gint main(gint argc, gchar **argv)
{
CamelSession *session;
- CamelException *ex;
gint i, j, index;
gchar *path;
CamelStore *store;
struct _threadinfo *info;
CamelFolder *folder;
GPtrArray *uids;
+ GError *error = NULL;
camel_test_init(argc, argv);
camel_test_provider_init(1, local_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
push("trying %s index %d", local_providers[j], index);
path = g_strdup_printf("%s:///tmp/camel-test/%s", local_providers[j], local_providers[j]);
- store = camel_session_get_store(session, path, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ store = camel_session_get_store(session, path, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
test_free(path);
if (index == 0)
- folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
+ folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, &error);
else
folder = camel_store_get_folder(store, "testbox",
- CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
for (i = 0; i < MAX_THREADS; i++) {
GError *error = NULL;
}
camel_folder_free_uids(folder, uids);
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_expunge(folder, &error);
+ check_msg(error == NULL, "%s", error->message);
check_unref(folder, 1);
- camel_store_delete_folder(store, "testbox", ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_store_delete_folder(store, "testbox", &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
check_unref(store, 1);
}
g_object_unref (session);
- camel_exception_free(ex);
return 0;
}
get_folder (CamelFilterDriver *d,
const gchar *uri,
gpointer data,
- CamelException *ex)
+ GError **error)
{
gint i;
{
CamelSession *session;
CamelStore *store;
- CamelException *ex;
CamelFolder *folder;
CamelMimeMessage *msg;
gint i, j;
CamelStream *mbox;
CamelFilterDriver *driver;
+ GError *error = NULL;
camel_test_init(argc, argv);
camel_test_provider_init(1, local_drivers);
- ex = camel_exception_new();
-
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
/* todo: work out how to do imap/pop/nntp tests */
push("getting store");
- store = camel_session_get_store(session, "mbox:///tmp/camel-test/mbox", ex);
- check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex));
+ store = camel_session_get_store(session, "mbox:///tmp/camel-test/mbox", &error);
+ check_msg(error == NULL, "getting store: %s", error->message);
check(store != NULL);
+ g_clear_error (&error);
pull();
push("Creating output folders");
for (i = 0; i < G_N_ELEMENTS (mailboxes); i++) {
push("creating %s", mailboxes[i].name);
- mailboxes[i].folder = folder = camel_store_get_folder(store, mailboxes[i].name, CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ mailboxes[i].folder = folder = camel_store_get_folder(store, mailboxes[i].name, CAMEL_STORE_FOLDER_CREATE, &error);
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
/* we need an empty folder for this to work */
test_folder_counts(folder, 0, 0);
+ g_clear_error (&error);
pull();
}
pull();
/* append a bunch of messages with specific content */
push("creating 100 test message mbox");
- mbox = camel_stream_fs_new_with_name("/tmp/camel-test/inbox", O_WRONLY|O_CREAT|O_EXCL, 0600);
+ mbox = camel_stream_fs_new_with_name("/tmp/camel-test/inbox", O_WRONLY|O_CREAT|O_EXCL, 0600, NULL);
for (j=0;j<100;j++) {
gchar *content, *subject;
pull();
camel_stream_printf(mbox, "From \n");
- check(camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, mbox) != -1);
+ check(camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, mbox, NULL) != -1);
#if 0
push("appending simple message %d", j);
camel_folder_append_message(folder, msg, NULL, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
#endif
test_free(subject);
check_unref(msg, 1);
}
- check(camel_stream_close(mbox) != -1);
+ check(camel_stream_close(mbox, NULL) != -1);
check_unref(mbox, 1);
pull();
push("Executing filters");
camel_filter_driver_set_default_folder(driver, mailboxes[0].folder);
- camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, &error);
+ check_msg(error == NULL, "%s", error->message);
/* now need to check the folder counts/etc */
check_unref(driver, 1);
+ g_clear_error (&error);
pull();
/* this tests that invalid rules are caught */
driver = camel_filter_driver_new(session);
camel_filter_driver_set_folder_func(driver, get_folder, NULL);
camel_filter_driver_add_rule(driver, brokens[i].name, brokens[i].match, brokens[i].action);
- camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex);
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
+ camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, &error);
+ check(error != NULL);
check_unref(driver, 1);
+ g_clear_error (&error);
pull();
}
pull();
driver = camel_filter_driver_new(session);
camel_filter_driver_set_folder_func(driver, get_folder, NULL);
camel_filter_driver_add_rule(driver, brokena[i].name, brokena[i].match, brokena[i].action);
- camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex);
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
+ camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, &error);
+ check(error != NULL);
check_unref(driver, 1);
+ g_clear_error (&error);
pull();
}
pull();
check_unref(store, 1);
check_unref(session, 1);
- camel_exception_free(ex);
camel_test_end();
{
gchar *name, *path;
gint i;
- CamelException ex = { 0 };
+ GError *error = NULL;
for (i=0;i<argc;i++) {
name = g_strdup_printf("libcamel%s."G_MODULE_SUFFIX, argv[i]);
path = g_build_filename(CAMEL_BUILD_DIR, "providers", argv[i], ".libs", name, NULL);
g_free(name);
- camel_provider_load(path, &ex);
- check_msg(!ex.id, "Cannot load provider for '%s', test aborted", argv[i]);
+ camel_provider_load(path, &error);
+ check_msg(error == NULL, "Cannot load provider for '%s', test aborted", argv[i]);
g_free(path);
}
}
return info;
}
-void camel_test_init(gint argc, gchar **argv)
+void
+camel_test_init(gint argc, gchar **argv)
{
struct stat st;
gchar *path;
if (mkdir (path, 0700) == -1 && errno != EEXIST)
abort ();
- if (stat (path, &st) == -1)
+ if (g_stat (path, &st) == -1)
abort ();
if (!S_ISDIR (st.st_mode) || access (path, R_OK | W_OK | X_OK) == -1)
#include "config.h"
#include <stdlib.h>
+#include <glib/gstdio.h>
#include <camel/camel.h>
void camel_test_failv(const gchar *why, va_list ap);
CamelMessageInfo *info;
GPtrArray *s;
gint i;
- CamelException *ex = camel_exception_new();
gint found;
+ GError *error = NULL;
push("uid %s is in folder", uid);
camel_folder_free_message_info(folder, info);
/* then, getting message */
- msg = camel_folder_get_message(folder, uid, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ msg = camel_folder_get_message(folder, uid, &error);
+ check_msg(error == NULL, "%s", error->message);
check(msg != NULL);
/* cross check with info */
check(found == 1);
camel_folder_free_uids(folder, s);
- camel_exception_free(ex);
+ g_clear_error (&error);
pull();
}
CamelMessageInfo *info;
GPtrArray *s;
gint i;
- CamelException *ex = camel_exception_new();
gint found;
+ GError *error = NULL;
push("uid '%s' is not in folder", uid);
/* then, getting message */
push("no message");
- msg = camel_folder_get_message(folder, uid, ex);
- check(camel_exception_is_set(ex));
+ msg = camel_folder_get_message(folder, uid, &error);
+ check(error != NULL);
check(msg == NULL);
- camel_exception_clear(ex);
+ g_clear_error (&error);
pull();
/* see if it is not in the summary (only once) */
camel_folder_free_uids(folder, s);
pull();
- camel_exception_free(ex);
+ g_clear_error (&error);
pull();
}
test_folder_basic(CamelSession *session, const gchar *storename, gint local, gint spool)
{
CamelStore *store;
- CamelException *ex = camel_exception_new();
CamelFolder *folder;
gchar *what = g_strdup_printf("testing store: %s", storename);
+ GError *error = NULL;
camel_test_start(what);
test_free(what);
push("getting store");
- store = camel_session_get_store(session, storename, ex);
- check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex));
+ store = camel_session_get_store(session, storename, &error);
+ check_msg(error == NULL, "getting store: %s", error->message);
check(store != NULL);
+ g_clear_error (&error);
pull();
/* local providers == no inbox */
push("getting inbox folder");
- folder = camel_store_get_inbox(store, ex);
+ folder = camel_store_get_inbox(store, &error);
if (local) {
/* Well, maildir can have an inbox */
if (folder) {
- check(!camel_exception_is_set(ex));
+ check(error == NULL);
check_unref(folder, 1);
} else {
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
+ check(error != NULL);
}
} else {
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
check_unref(folder, 2);
}
+ g_clear_error (&error);
pull();
push("getting a non-existant folder, no create");
- folder = camel_store_get_folder(store, "unknown", 0, ex);
- check(camel_exception_is_set(ex));
+ folder = camel_store_get_folder(store, "unknown", 0, &error);
+ check(error != NULL);
check(folder == NULL);
- camel_exception_clear(ex);
+ g_clear_error (&error);
pull();
if (!spool) {
push("getting a non-existant folder, with create");
- folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, &error);
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
if (local)
check_unref(folder, 1);
else
check_unref(folder, 2);
+ g_clear_error (&error);
pull();
push("getting an existing folder");
- folder = camel_store_get_folder(store, "testbox", 0, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ folder = camel_store_get_folder(store, "testbox", 0, &error);
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
if (local)
check_unref(folder, 1);
else
check_unref(folder, 2);
+ g_clear_error (&error);
pull();
push("renaming a non-existant folder");
- camel_store_rename_folder(store, "unknown1", "unknown2", ex);
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
+ camel_store_rename_folder(store, "unknown1", "unknown2", &error);
+ check(error != NULL);
+ g_clear_error (&error);
pull();
push("renaming an existing folder");
- camel_store_rename_folder(store, "testbox", "testbox2", ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_store_rename_folder(store, "testbox", "testbox2", &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
push("opening the old name of a renamed folder");
- folder = camel_store_get_folder(store, "testbox", 0, ex);
- check(camel_exception_is_set(ex));
+ folder = camel_store_get_folder(store, "testbox", 0, &error);
+ check(error != NULL);
check(folder == NULL);
- camel_exception_clear(ex);
+ g_clear_error (&error);
pull();
push("opening the new name of a renamed folder");
- folder = camel_store_get_folder(store, "testbox2", 0, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ folder = camel_store_get_folder(store, "testbox2", 0, &error);
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
if (local)
check_unref(folder, 1);
}
push("deleting a non-existant folder");
- camel_store_delete_folder(store, "unknown", ex);
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
+ camel_store_delete_folder(store, "unknown", &error);
+ check(error != NULL);
+ g_clear_error (&error);
pull();
if (!spool) {
push("deleting an existing folder");
- camel_store_delete_folder(store, "testbox2", ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_store_delete_folder(store, "testbox2", &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
}
push("opening a folder that has been deleted");
- folder = camel_store_get_folder(store, "testbox2", 0, ex);
- check(camel_exception_is_set(ex));
+ folder = camel_store_get_folder(store, "testbox2", 0, &error);
+ check(error != NULL);
check(folder == NULL);
- camel_exception_clear(ex);
+ g_clear_error (&error);
pull();
check_unref(store, 1);
camel_test_end();
-
- camel_exception_free(ex);
}
/* todo: cross-check everything with folder_info checks as well */
test_folder_message_ops(CamelSession *session, const gchar *name, gint local, const gchar *mailbox)
{
CamelStore *store;
- CamelException *ex = camel_exception_new();
CamelFolder *folder;
CamelMimeMessage *msg;
gint j;
gint indexed, max;
GPtrArray *uids;
CamelMessageInfo *info;
+ GError *error = NULL;
max=local?2:1;
test_free(what);
push("getting store");
- store = camel_session_get_store(session, name, ex);
- check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex));
+ store = camel_session_get_store(session, name, &error);
+ check_msg(error == NULL, "getting store: %s", error->message);
check(store != NULL);
+ g_clear_error (&error);
pull();
push("creating %sindexed folder", indexed?"":"non-");
flags = CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX;
else
flags = CAMEL_STORE_FOLDER_CREATE;
- folder = camel_store_get_folder(store, mailbox, flags, ex);
+ folder = camel_store_get_folder(store, mailbox, flags, &error);
/* we can't create mailbox outside of namespace, since we have no api for it, try
using inbox namespace, works for courier */
if (folder == NULL) {
gchar *mbox = g_strdup_printf("INBOX/%s", mailbox);
mailbox = mbox;
- camel_exception_clear(ex);
- folder = camel_store_get_folder(store, mailbox, flags, ex);
+ g_clear_error (&error);
+ folder = camel_store_get_folder(store, mailbox, flags, &error);
}
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
/* verify empty/can't get nonexistant stuff */
pull();
push("appending simple message %d", j);
- camel_folder_append_message(folder, msg, NULL, NULL, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_append_message(folder, msg, NULL, NULL, &error);
+ check_msg(error == NULL, "%s", error->message);
#if 0
/* sigh, this shouldn't be required, but the imap code is too dumb to do it itself */
if (!local) {
push("forcing a refresh of folder updates");
camel_folder_refresh_info(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check_msg(error == NULL, "%s", error->message);
pull();
}
#endif
#endif
push("re-opening folder");
- folder = camel_store_get_folder(store, mailbox, flags, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ folder = camel_store_get_folder(store, mailbox, flags, &error);
+ check_msg(error == NULL, "%s", error->message);
check(folder != NULL);
+ g_clear_error (&error);
/* verify counts */
test_folder_counts(folder, 10, 10);
push("deleting first message & expunging");
camel_folder_delete_message(folder, uids->pdata[0]);
test_folder_counts(folder, 10, 9);
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_expunge(folder, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
test_folder_not_message(folder, uids->pdata[0]);
test_folder_counts(folder, 9, 9);
camel_folder_delete_message(folder, uids->pdata[8]);
/* sync? */
test_folder_counts(folder, 9, 8);
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_expunge(folder, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
test_folder_not_message(folder, uids->pdata[8]);
test_folder_counts(folder, 8, 8);
}
/* sync? */
test_folder_counts(folder, 8, 0);
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_folder_expunge(folder, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
for (j=0;j<8;j++) {
test_folder_not_message(folder, uids->pdata[j]);
}
if (g_ascii_strcasecmp(mailbox, "INBOX") != 0) {
push("deleting test folder, with no messages in it");
- camel_store_delete_folder(store, mailbox, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_store_delete_folder(store, mailbox, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
}
if (!local) {
push("disconneect service");
- camel_service_disconnect((CamelService *)store, TRUE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ camel_service_disconnect((CamelService *)store, TRUE, &error);
+ check_msg(error == NULL, "%s", error->message);
+ g_clear_error (&error);
pull();
}
check_unref(store, 1);
camel_test_end();
}
-
- camel_exception_free(ex);
}
dw = camel_data_wrapper_new();
camel_data_wrapper_set_mime_type (dw, type);
- camel_data_wrapper_construct_from_stream(dw, (CamelStream *)content);
+ camel_data_wrapper_construct_from_stream(dw, (CamelStream *)content, NULL);
camel_medium_set_content ((CamelMedium *)part, dw);
check_unref(content, 2);
CamelStreamFs *file;
gint ret;
- file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_CREAT|O_WRONLY, 0600);
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)file);
- ret = camel_stream_close((CamelStream *)file);
+ file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_CREAT|O_WRONLY, 0600, NULL);
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)file, NULL);
+ ret = camel_stream_close((CamelStream *)file, NULL);
check(G_OBJECT (file)->ref_count == 1);
g_object_unref (file);
CamelStreamFs *file;
CamelMimeMessage *msg2;
- file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_RDONLY, 0);
+ file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_RDONLY, 0, NULL);
msg2 = camel_mime_message_new();
- camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg2, (CamelStream *)file);
+ camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg2, (CamelStream *)file, NULL);
/* file's refcount may be > 1 if the message is real big */
check(G_OBJECT(file)->ref_count >=1);
g_object_unref (file);
byte_array = g_byte_array_new ();
content = camel_stream_mem_new_with_byte_array (byte_array);
- camel_data_wrapper_decode_to_stream (dw, content);
+ camel_data_wrapper_decode_to_stream (dw, content, NULL);
if (byte_array->len != len) {
printf ("original text:\n");
byte_array1 = g_byte_array_new ();
stream1 = camel_stream_mem_new_with_byte_array (byte_array1);
- check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, stream1) != -1, "write_to_stream 1 failed");
- camel_stream_reset (stream1);
+ check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, stream1, NULL) != -1, "write_to_stream 1 failed", NULL);
+ camel_stream_reset (stream1, NULL);
msg2 = camel_mime_message_new ();
- check_msg(camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg2, (CamelStream *) stream1) != -1, "construct_from_stream 1 failed");
- camel_stream_reset ((CamelStream *) stream1);
+ check_msg(camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg2, (CamelStream *) stream1, NULL) != -1, "construct_from_stream 1 failed");
+ camel_stream_reset ((CamelStream *) stream1, NULL);
byte_array2 = g_byte_array_new ();
stream2 = camel_stream_mem_new_with_byte_array (byte_array2);
- check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg2, stream2) != -1, "write_to_stream 2 failed");
- camel_stream_reset (stream2);
+ check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg2, stream2, NULL) != -1, "write_to_stream 2 failed");
+ camel_stream_reset (stream2, NULL);
if (byte_array1->len != byte_array2->len) {
CamelDataWrapper *content;
push("seekable stream test, writing ");
check(camel_seekable_stream_tell(s) == 0);
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET) == 0);
+ check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET, NULL) == 0);
check(camel_seekable_stream_tell(s) == 0);
- check(camel_stream_write(CAMEL_STREAM(s), "", 0) == 0);
+ check(camel_stream_write(CAMEL_STREAM(s), "", 0, NULL) == 0);
check(camel_seekable_stream_tell(s) == 0);
- check(camel_stream_write(CAMEL_STREAM(s), "\n", 1) == 1);
+ check(camel_stream_write(CAMEL_STREAM(s), "\n", 1, NULL) == 1);
check(camel_seekable_stream_tell(s) == 1);
for (i=0;i<10240;i++) {
- check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring)) == sizeof(teststring));
+ check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring), NULL) == sizeof(teststring));
check(camel_seekable_stream_tell(s) == 1 + (i+1)*sizeof(teststring));
}
end = 10240*sizeof(teststring)+1;
- check_msg(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END) == end, "seek =%d end = %d",
- camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END), end);
+ check_msg(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END, NULL) == end, "seek =%d end = %d",
+ camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END, NULL), end);
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END) == end);
+ check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END, NULL) == end);
check(camel_seekable_stream_tell(s) == end);
/* need to read 0 first to set eos */
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 0);
+ check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240, NULL) == 0);
check(camel_stream_eos(CAMEL_STREAM(s)));
pull();
end = 10240*sizeof(teststring)+1;
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET) == 0);
+ check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET, NULL) == 0);
check(camel_seekable_stream_tell(s) == 0);
check(!camel_stream_eos(CAMEL_STREAM(s)));
/* exercise all seek methods */
switch (i % 3) {
case 0:
- check(camel_seekable_stream_seek(s, new, CAMEL_STREAM_SET) == new);
+ check(camel_seekable_stream_seek(s, new, CAMEL_STREAM_SET, NULL) == new);
break;
case 1:
- check(camel_seekable_stream_seek(s, new-off, CAMEL_STREAM_CUR) == new);
+ check(camel_seekable_stream_seek(s, new-off, CAMEL_STREAM_CUR, NULL) == new);
break;
case 2:
- check(camel_seekable_stream_seek(s, new-end, CAMEL_STREAM_END) == new);
+ check(camel_seekable_stream_seek(s, new-end, CAMEL_STREAM_END, NULL) == new);
break;
}
check(camel_seekable_stream_tell(s) == new);
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, i*3) == i*3);
+ check(camel_stream_read(CAMEL_STREAM(s), testbuf, i*3, NULL) == i*3);
for (j=0;j<i*3;j++) {
gint k = new + j;
}
/* verify end-of-file behaviour */
- check(camel_seekable_stream_seek(s, -1, CAMEL_STREAM_END) == end-1);
+ check(camel_seekable_stream_seek(s, -1, CAMEL_STREAM_END, NULL) == end-1);
check(camel_seekable_stream_tell(s) == end-1);
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 1);
+ check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240, NULL) == 1);
check(testbuf[0] == teststring[sizeof(teststring)-1]);
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 0);
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_CUR) == end);
+ check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240, NULL) == 0);
+ check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_CUR, NULL) == end);
check(camel_seekable_stream_tell(s) == end);
check(camel_stream_eos(CAMEL_STREAM(s)));
push("writing substream, type %d", type);
if (type == 1) {
- check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET) == ss->bound_start);
+ check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET, NULL) == ss->bound_start);
s = (CamelStream *)sp;
} else {
check(camel_seekable_stream_tell(ss) == ss->bound_start);
- check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET) == ss->bound_start);
+ check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET, NULL) == ss->bound_start);
}
check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start);
- check(camel_stream_write(s, "", 0) == 0);
+ check(camel_stream_write(s, "", 0, NULL) == 0);
check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start);
/* fill up the bounds with writes */
if (ss->bound_end != CAMEL_STREAM_UNBOUND) {
for (i=0;i<(ss->bound_end-ss->bound_start)/sizeof(teststring);i++) {
- check(camel_stream_write(s, teststring, sizeof(teststring)) == sizeof(teststring));
+ check(camel_stream_write(s, teststring, sizeof(teststring), NULL) == sizeof(teststring));
check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start + (i+1)*sizeof(teststring));
}
len = (ss->bound_end-ss->bound_start) % sizeof(teststring);
- check(camel_stream_write(s, teststring, len) == len);
+ check(camel_stream_write(s, teststring, len, NULL) == len);
check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_end);
if (G_UNLIKELY (type == G_TYPE_INVALID)) {
- check(camel_stream_write(s, teststring, sizeof(teststring)) == 0);
+ check(camel_stream_write(s, teststring, sizeof(teststring), NULL) == 0);
check(camel_stream_eos(s));
check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_end);
}
} else {
/* just 10K */
for (i=0;i<10240;i++) {
- check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring)) == sizeof(teststring));
+ check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring), NULL) == sizeof(teststring));
check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start + (i+1)*sizeof(teststring));
}
push("reading substream");
- check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET) == ss->bound_start);
+ check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET, NULL) == ss->bound_start);
check(camel_seekable_stream_tell(ss) == ss->bound_start);
- check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET) == ss->bound_start);
+ check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET, NULL) == ss->bound_start);
check(camel_seekable_stream_tell(sp) == ss->bound_start);
/* check writes, cross check with parent stream */
if (ss->bound_end != CAMEL_STREAM_UNBOUND) {
for (i=0;i<(ss->bound_end-ss->bound_start)/sizeof(teststring);i++) {
- check(camel_stream_read(s, testbuf, sizeof(teststring)) == sizeof(teststring));
+ check(camel_stream_read(s, testbuf, sizeof(teststring), NULL) == sizeof(teststring));
check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
check(camel_seekable_stream_tell(ss) == ss->bound_start + (i+1)*sizeof(teststring));
/* yeah great, the substreams affect the seek ... */
- check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET) == ss->bound_start + i*sizeof(teststring));
- check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring)) == sizeof(teststring));
+ check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET, NULL) == ss->bound_start + i*sizeof(teststring));
+ check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring), NULL) == sizeof(teststring));
check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
check(camel_seekable_stream_tell(sp) == ss->bound_start + (i+1)*sizeof(teststring));
}
len = (ss->bound_end-ss->bound_start) % sizeof(teststring);
- check(camel_stream_read(s, testbuf, len) == len);
+ check(camel_stream_read(s, testbuf, len, NULL) == len);
check(memcmp(testbuf, teststring, len) == 0);
- check(camel_seekable_stream_seek(sp, ss->bound_end - len, CAMEL_STREAM_SET) == ss->bound_end - len);
- check(camel_stream_read(CAMEL_STREAM(sp), testbuf, len) == len);
+ check(camel_seekable_stream_seek(sp, ss->bound_end - len, CAMEL_STREAM_SET, NULL) == ss->bound_end - len);
+ check(camel_stream_read(CAMEL_STREAM(sp), testbuf, len, NULL) == len);
check(memcmp(testbuf, teststring, len) == 0);
check(camel_stream_eos(s));
check(camel_seekable_stream_tell(ss) == ss->bound_end);
check(camel_seekable_stream_tell(sp) == ss->bound_end);
- check(camel_stream_read(s, testbuf, 1024) == 0);
+ check(camel_stream_read(s, testbuf, 1024, NULL) == 0);
check(camel_seekable_stream_tell(ss) == ss->bound_end);
check(camel_seekable_stream_tell(sp) == ss->bound_end);
check(camel_stream_eos(s));
} else {
/* just 10K */
for (i=0;i<10240;i++) {
- check(camel_stream_read(s, testbuf, sizeof(teststring)) == sizeof(teststring));
+ check(camel_stream_read(s, testbuf, sizeof(teststring), NULL) == sizeof(teststring));
check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
check(camel_seekable_stream_tell(ss) == ss->bound_start + (i+1)*sizeof(teststring));
- check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET) == ss->bound_start + i*sizeof(teststring));
- check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring)) == sizeof(teststring));
+ check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET, NULL) == ss->bound_start + i*sizeof(teststring));
+ check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring), NULL) == sizeof(teststring));
check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
check(camel_seekable_stream_tell(sp) == ss->bound_start + (i+1)*sizeof(teststring));
}
continue;
filename = g_strdup_printf ("../data/messages/%s", dent->d_name);
- if (stat (filename, &st) == -1 || !S_ISREG (st.st_mode)) {
+ if (g_stat (filename, &st) == -1 || !S_ISREG (st.st_mode)) {
g_free (filename);
continue;
}
stream = camel_stream_fs_new_with_fd (fd);
message = camel_mime_message_new ();
- camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream);
- camel_stream_reset (stream);
+ camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream, NULL);
+ camel_stream_reset (stream, NULL);
/*dump_mime_struct ((CamelMimePart *) message, 0);*/
test_message_compare (message);
g_free (work);
infile = g_strdup_printf ("%s/%s", SOURCEDIR, dent->d_name);
- if (!(source = camel_stream_fs_new_with_name (infile, 0, O_RDONLY))) {
+ if (!(source = camel_stream_fs_new_with_name (infile, 0, O_RDONLY, NULL))) {
camel_test_fail ("Failed to open input case in \"%s\"", infile);
g_free (outfile);
continue;
outfile = g_strdup_printf ("%s/%.*s.out", SOURCEDIR, ext - dent->d_name, dent->d_name);
- if (!(correct = camel_stream_fs_new_with_name (outfile, 0, O_RDONLY))) {
+ if (!(correct = camel_stream_fs_new_with_name (outfile, 0, O_RDONLY, NULL))) {
camel_test_fail ("Failed to open correct output in \"%s\"", outfile);
g_free (outfile);
continue;
comp_progress = 0;
while (1) {
- comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE);
+ comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE, NULL);
comp_filter_chunk = 0;
if (comp_correct_chunk == 0)
delta = camel_stream_read (CAMEL_STREAM (filter),
comp_filter + comp_filter_chunk,
- CHUNK_SIZE - comp_filter_chunk);
+ CHUNK_SIZE - comp_filter_chunk, NULL);
if (delta == 0) {
camel_test_fail ("Chunks are different sizes: correct is %d, "
}
camel_test_push ("Initializing objects");
- source = camel_stream_fs_new_with_name (infile, 0, O_RDONLY);
+ source = camel_stream_fs_new_with_name (infile, 0, O_RDONLY, NULL);
if (!source) {
camel_test_fail ("Failed to open input case in \"%s\"", infile);
g_free (infile);
}
g_free (infile);
- correct = camel_stream_fs_new_with_name (outfile, 0, O_RDONLY);
+ correct = camel_stream_fs_new_with_name (outfile, 0, O_RDONLY, NULL);
if (!correct) {
camel_test_fail ("Failed to open correct output in \"%s\"", outfile);
g_free (outfile);
comp_progress = 0;
while (1) {
- comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE);
+ comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE, NULL);
comp_filter_chunk = 0;
if (comp_correct_chunk == 0)
delta = camel_stream_read (CAMEL_STREAM (filter),
comp_filter + comp_filter_chunk,
- CHUNK_SIZE - comp_filter_chunk);
+ CHUNK_SIZE - comp_filter_chunk, NULL);
if (delta == 0) {
camel_test_fail ("Chunks are different sizes: correct is %d, "
camel_test_push("setup");
- indisk = camel_stream_fs_new_with_name(inname, O_RDONLY, 0);
+ indisk = camel_stream_fs_new_with_name(inname, O_RDONLY, 0, NULL);
check(indisk);
- outdisk = camel_stream_fs_new_with_name(outname, O_RDONLY, 0);
+ outdisk = camel_stream_fs_new_with_name(outname, O_RDONLY, 0, NULL);
check(outdisk);
byte_array_out = g_byte_array_new ();
out = camel_stream_mem_new_with_byte_array (byte_array_out);
- check(camel_stream_write_to_stream(outdisk, out) > 0);
+ check(camel_stream_write_to_stream(outdisk, out, NULL) > 0);
camel_test_pull();
id = camel_stream_filter_add((CamelStreamFilter *)filter, f);
check_count(f, 2);
- check(camel_stream_write_to_stream(filter, in) > 0);
+ check(camel_stream_write_to_stream(filter, in, NULL) > 0);
check_msg(byte_array_in->len == byte_array_out->len
&& memcmp(byte_array_in->data, byte_array_out->data, byte_array_in->len) == 0,
"Buffer content mismatch, %d != %d, in = '%.*s' != out = '%.*s'", byte_array_in->len, byte_array_out->len,
check_count(f, 1);
check_unref(in, 1);
- check(camel_stream_reset(indisk) == 0);
+ check(camel_stream_reset(indisk, NULL) == 0);
camel_test_push("writing through filter stream");
id = camel_stream_filter_add((CamelStreamFilter *)filter, f);
check_count(f, 2);
- check(camel_stream_write_to_stream(indisk, filter) > 0);
- check(camel_stream_flush(filter) == 0);
+ check(camel_stream_write_to_stream(indisk, filter, NULL) > 0);
+ check(camel_stream_flush(filter, NULL) == 0);
check_msg(byte_array_in->len == byte_array_out->len
&& memcmp(byte_array_in->data, byte_array_out->data, byte_array_in->len) == 0,
"Buffer content mismatch, %d != %d, in = '%.*s' != out = '%.*s'", byte_array_in->len, byte_array_out->len,
sprintf(inname, "data/html.%d.in", i);
sprintf(outname, "data/html.%d.out", i);
- if (stat(inname, &st) == -1)
+ if (g_stat(inname, &st) == -1)
break;
f = camel_mime_filter_tohtml_new(CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0);
while (*p) {
gint w = MIN(strlen(p), step);
- check(camel_stream_write((CamelStream *)filter, p, w) == w);
+ check(camel_stream_write((CamelStream *)filter, p, w, NULL) == w);
p += w;
}
- camel_stream_flush((CamelStream *)filter);
+ camel_stream_flush((CamelStream *)filter, NULL);
check_msg(byte_array->len == strlen(tests[i].out), "Buffer length mismatch: expected %d got %d\n or '%s' got '%.*s'", strlen(tests[i].out), byte_array->len, tests[i].out, byte_array->len, byte_array->data);
check_msg(0 == memcmp(byte_array->data, tests[i].out, byte_array->len), "Buffer mismatch: expected '%s' got '%.*s'", tests[i].out, byte_array->len, byte_array->data);
main (gint argc, gchar **argv)
{
CamelURL *base_url, *url;
- CamelException ex;
gchar *url_string;
gint i;
+ GError *error = NULL;
camel_test_init (argc, argv);
camel_test_start ("URL parsing");
camel_test_push ("base URL parsing");
- camel_exception_init (&ex);
- base_url = camel_url_new (base, &ex);
+ base_url = camel_url_new (base, &error);
if (!base_url) {
- camel_test_fail ("Could not parse %s: %s\n", base,
- camel_exception_get_description (&ex));
+ camel_test_fail (
+ "Could not parse %s: %s\n",
+ base, error->message);
}
camel_test_pull ();
static gchar *get_password (CamelSession *session, const gchar *prompt,
guint32 flags,
CamelService *service, const gchar *item,
- CamelException *ex);
+ GError **error);
static void
init (CamelPgpSession *session)
static gchar *
get_password (CamelSession *session, const gchar *prompt, guint32 flags,
- CamelService *service, const gchar *item, CamelException *ex)
+ CamelService *service, const gchar *item, GError **error)
{
return g_strdup ("no.secret");
}
{
CamelSession *session;
CamelCipherContext *ctx;
- CamelException *ex;
+ GError **error;
CamelCipherValidity *valid;
CamelMimePart *mime_part;
CamelMultipartSigned *mps;
const gchar *prompt,
const gchar *item,
guint32 flags,
- CamelException *ex)
+ GError **error)
{
return g_strdup ("no.secret");
}
{
CamelSession *session;
CamelCipherContext *ctx;
- CamelException *ex;
CamelCipherValidity *valid;
CamelStream *stream1, *stream2;
GByteArray *buffer1, *buffer2;
GPtrArray *recipients;
gchar *before, *after;
gint ret;
+ GError *error = NULL;
if (getenv("CAMEL_TEST_GPG") == NULL)
return 77;
session = camel_pgp_session_new ("/tmp/camel-test");
- ex = camel_exception_new ();
-
ctx = camel_gpg_context_new (session);
camel_gpg_context_set_always_trust (CAMEL_GPG_CONTEXT (ctx), TRUE);
camel_test_start ("Test of PGP functions");
stream1 = camel_stream_mem_new ();
- camel_stream_write (stream1, "Hello, I am a test stream.\n", 27);
- camel_stream_reset (stream1);
+ camel_stream_write (stream1, "Hello, I am a test stream.\n", 27, NULL);
+ camel_stream_reset (stream1, NULL);
conpart = camel_mime_part_new();
dw = camel_data_wrapper_new();
- camel_data_wrapper_construct_from_stream(dw, stream1);
+ camel_data_wrapper_construct_from_stream(dw, stream1, NULL);
camel_medium_set_content ((CamelMedium *)conpart, dw);
g_object_unref (stream1);
g_object_unref (dw);
sigpart = camel_mime_part_new();
camel_test_push ("PGP signing");
- camel_cipher_sign (ctx, "no.user@no.domain", CAMEL_CIPHER_HASH_SHA1, conpart, sigpart, ex);
- if (camel_exception_is_set(ex)) {
- printf("PGP signing failed assuming non-functional environment\n%s", camel_exception_get_description (ex));
+ camel_cipher_sign (ctx, "no.user@no.domain", CAMEL_CIPHER_HASH_SHA1, conpart, sigpart, &error);
+ if (error != NULL) {
+ printf("PGP signing failed assuming non-functional environment\n%s", error->message);
camel_test_pull();
return 77;
}
camel_test_pull ();
- camel_exception_clear (ex);
+ g_clear_error (&error);
camel_test_push ("PGP verify");
- valid = camel_cipher_verify (ctx, sigpart, ex);
- check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
+ valid = camel_cipher_verify (ctx, sigpart, &error);
+ check_msg (error == NULL, "%s", error->message);
check_msg (camel_cipher_validity_get_valid (valid), "%s", camel_cipher_validity_get_description (valid));
camel_cipher_validity_free (valid);
camel_test_pull ();
g_object_unref (sigpart);
stream1 = camel_stream_mem_new ();
- camel_stream_write (stream1, "Hello, I am a test of encryption/decryption.", 44);
- camel_stream_reset (stream1);
+ camel_stream_write (stream1, "Hello, I am a test of encryption/decryption.", 44, NULL);
+ camel_stream_reset (stream1, NULL);
conpart = camel_mime_part_new();
dw = camel_data_wrapper_new();
- camel_stream_reset(stream1);
- camel_data_wrapper_construct_from_stream(dw, stream1);
+ camel_stream_reset(stream1, NULL);
+ camel_data_wrapper_construct_from_stream(dw, stream1, NULL);
camel_medium_set_content ((CamelMedium *)conpart, dw);
g_object_unref (stream1);
g_object_unref (dw);
encpart = camel_mime_part_new();
- camel_exception_clear (ex);
+ g_clear_error (&error);
camel_test_push ("PGP encrypt");
recipients = g_ptr_array_new ();
g_ptr_array_add (recipients, (guint8 *) "no.user@no.domain");
- camel_cipher_encrypt (ctx, "no.user@no.domain", recipients, conpart, encpart, ex);
- check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
+ camel_cipher_encrypt (ctx, "no.user@no.domain", recipients, conpart, encpart, &error);
+ check_msg (error == NULL, "%s", error->message);
g_ptr_array_free (recipients, TRUE);
camel_test_pull ();
- camel_exception_clear (ex);
+ g_clear_error (&error);
camel_test_push ("PGP decrypt");
outpart = camel_mime_part_new();
- valid = camel_cipher_decrypt (ctx, encpart, outpart, ex);
- check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
+ valid = camel_cipher_decrypt (ctx, encpart, outpart, &error);
+ check_msg (error == NULL, "%s", error->message);
check_msg (valid->encrypt.status == CAMEL_CIPHER_VALIDITY_ENCRYPT_ENCRYPTED, "%s", valid->encrypt.description);
buffer1 = g_byte_array_new ();
buffer2 = g_byte_array_new ();
stream2 = camel_stream_mem_new_with_byte_array (buffer2);
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)conpart, stream1);
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)outpart, stream2);
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)conpart, stream1, NULL);
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)outpart, stream2, NULL);
before = g_strndup ((gchar *) buffer1->data, buffer1->len);
after = g_strndup ((gchar *) buffer2->data, buffer2->len);
static gchar *get_password (CamelSession *session, const gchar *prompt,
guint32 flags, CamelService *service,
- const gchar *item, CamelException *ex);
+ const gchar *item, GError **error);
static void
init (CamelTestSession *session)
static gchar *
get_password (CamelSession *session, const gchar *prompt, guint32 flags,
- CamelService *service, const gchar *item, CamelException *ex)
+ CamelService *service, const gchar *item, GError **error)
{
return g_strdup ("S/MIME v3 is rfc263x, now go and read them.");
}
{
CamelSession *session;
CamelSMimeContext *ctx;
- CamelException *ex;
+ GError **error;
CamelCipherValidity *valid;
CamelStream *stream1, *stream2, *stream3;
GPtrArray *recipients;
push("trying to open a nonexistant stream, method %d", i);
switch (i) {
case 0:
- ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0);
+ ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0, NULL);
break;
case 1:
fd = open("stream.txt", O_RDWR, 0);
break;
}
check(ss == NULL && errno == ENOENT);
- check(stat("stream.txt", &st) == -1 && errno == ENOENT);
+ check(g_stat("stream.txt", &st) == -1 && errno == ENOENT);
pull();
push("Creating stream using method %d", i);
switch (i) {
case 0:
- ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_CREAT|O_RDWR|O_TRUNC, 0600);
+ ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_CREAT|O_RDWR|O_TRUNC, 0600, NULL);
fd = camel_stream_fs_get_fd ((CamelStreamFs *)ss);
break;
case 1:
break;
}
check(ss != NULL);
- check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0);
+ check(g_stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0);
pull();
test_stream_seekable_writepart(ss);
test_stream_seekable_readpart(ss);
push("getting filesize");
- check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode));
+ check(g_stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode));
size = st.st_size;
pull();
push("re-opening stream");
switch (i) {
case 0:
- ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0);
+ ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0, NULL);
fd = camel_stream_fs_get_fd ((CamelStreamFs *)ss);
break;
case 1:
break;
}
check(ss != NULL);
- check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == size);
+ check(g_stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == size);
test_stream_seekable_readpart(ss);
push("re-opening stream with truncate");
switch (i) {
case 0:
- ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR|O_TRUNC, 0);
+ ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR|O_TRUNC, 0, NULL);
fd = camel_stream_fs_get_fd ((CamelStreamFs *)ss);
break;
case 1:
break;
}
check(ss != NULL);
- check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0);
+ check(g_stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0);
/* read has to return 0 before eos is set */
- check(camel_stream_read(CAMEL_STREAM(ss), buffer, 1) == 0);
+ check(camel_stream_read(CAMEL_STREAM(ss), buffer, 1, NULL) == 0);
check(camel_stream_eos(CAMEL_STREAM(ss)));
check_unref(ss, 1);
camel_test_start("CamelSeekableSubstream, file backing");
for (j=0;j<SEEKABLE_SUBSTREAM_WAYS;j++) {
push("testing writing method %d", j);
- ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR|O_CREAT|O_TRUNC, 0600);
+ ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
check(ss != NULL);
for (i = 0; i < G_N_ELEMENTS (ranges); i++) {
push("stream subrange %d-%d", ranges[i].lower, ranges[i].upper);
LIBEGROUPWISE_REVISION=1
LIBEGROUPWISE_AGE=0
-LIBCAMEL_CURRENT=17
+LIBCAMEL_CURRENT=18
LIBCAMEL_REVISION=0
LIBCAMEL_AGE=0
@const gchar *tzid, gconstpointer custom, GError **error:
@const gchar *tzid, gconstpointer custom, GError **error:
@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
+@const gchar *tzid, gconstpointer custom, GError **error:
@const gchar *tzid, gconstpointer custom, GError **error:
@custom:
@error:
<title>Fundamentals</title>
<xi:include href="xml/camel.xml"/>
<xi:include href="xml/camel-debug.xml"/>
- <xi:include href="xml/camel-exception.xml"/>
<xi:include href="xml/camel-object.xml"/>
<xi:include href="xml/camel-operation.xml"/>
<xi:include href="xml/camel-url.xml"/>
</SECTION>
<SECTION>
-<FILE>camel-exception</FILE>
-ExceptionId
-CamelException
-CAMEL_EXCEPTION_INITIALISER
-camel_exception_new
-camel_exception_free
-camel_exception_init
-camel_exception_clear
-camel_exception_set
-camel_exception_setv
-camel_exception_xfer
-camel_exception_get_id
-camel_exception_get_description
-camel_exception_is_set
-</SECTION>
-
-<SECTION>
<FILE>camel-file-utils</FILE>
O_BINARY
camel_file_util_encode_fixed_int32
@hash:
@ipart:
@opart:
-@ex:
+@error:
@Returns:
@context:
@ipart:
-@ex:
+@error:
@Returns:
@recipients:
@ipart:
@opart:
-@ex:
+@error:
@Returns:
@context:
@ipart:
@opart:
-@ex:
+@error:
@Returns:
@context:
@istream:
-@ex:
+@error:
@Returns:
@context:
@keys:
@ostream:
-@ex:
+@error:
@Returns:
@gpointer cert_data:
@gpointer cert_data:
@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
+@gpointer cert_data:
@gpointer cert_data:
@part:
@flags:
@ostream:
+@error:
@Returns:
</para>
@path:
-@ex:
+@error:
@Returns:
@cdc:
@path:
@key:
-@ex:
+@error:
@Returns:
@cdc:
@path:
@key:
-@ex:
+@error:
@Returns:
@cdc:
@path:
@key:
-@ex:
+@error:
@Returns:
@cdc:
@path:
@key:
-@ex:
+@error:
@Returns:
@data_wrapper:
@stream:
+@error:
@Returns:
@data_wrapper:
@stream:
+@error:
@Returns:
@data_wrapper:
@stream:
+@error:
@Returns:
</para>
@path:
-@ex:
+@error:
@Returns:
</para>
@cdb:
-@ex:
+@error:
@Returns:
@cdb:
@stmt:
-@ex:
+@error:
@Returns:
@cdb:
@qry_list:
-@ex:
+@error:
@Returns:
</para>
@cdb:
-@ex:
+@error:
@Returns:
@cdb:
@query:
-@ex:
+@error:
@Returns:
</para>
@cdb:
-@ex:
+@error:
@Returns:
</para>
@cdb:
-@ex:
+@error:
@Returns:
@cdb:
@folder:
-@ex:
+@error:
@Returns:
@cdb:
@old_folder:
@new_folder:
-@ex:
+@error:
@Returns:
@cdb:
@folder:
-@ex:
+@error:
@Returns:
@cdb:
@folder:
@uid:
-@ex:
+@error:
@Returns:
@cdb:
@folder_name:
@uids:
-@ex:
+@error:
@Returns:
@folder_name:
@shash:
@uids:
-@ex:
+@error:
@Returns:
</para>
@cdb:
-@ex:
+@error:
@Returns:
@stmt:
@callback:
@data:
-@ex:
+@error:
@Returns:
@cdb:
@record:
-@ex:
+@error:
@Returns:
@cdb:
@folder_name:
@record:
-@ex:
+@error:
@Returns:
@cdb:
@folder_name:
-@ex:
+@error:
@Returns:
@cdb:
@folder_name:
@record:
-@ex:
+@error:
@Returns:
@cdb:
@folder_name:
@record:
-@ex:
+@error:
@Returns:
@folder_name:
@p:
@read_mir_callback:
-@ex:
+@error:
@Returns:
@uid:
@p:
@read_mir_callback:
-@ex:
+@error:
@Returns:
@cdb:
@table_name:
@count:
-@ex:
+@error:
@Returns:
@cdb:
@table_name:
@count:
-@ex:
+@error:
@Returns:
@cdb:
@table_name:
@count:
-@ex:
+@error:
@Returns:
@cdb:
@table_name:
@count:
-@ex:
+@error:
@Returns:
@cdb:
@table_name:
@count:
-@ex:
+@error:
@Returns:
@cdb:
@table_name:
@count:
-@ex:
+@error:
@Returns:
@cdb:
@table_name:
@count:
-@ex:
+@error:
@Returns:
@cdb:
@query:
@count:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
@vuid:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
@vuid:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
@filter:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
@vuid:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
@vuid:
-@ex:
+@error:
@Returns:
@sort_by:
@collate:
@array:
-@ex:
+@error:
@Returns:
@collate:
@summary:
@table:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
-@ex:
+@error:
@Returns:
@cdb:
@folder:
-@ex:
+@error:
@Returns:
</para>
@cdb:
-@ex:
+@error:
@Returns:
@cdb:
@folder_name:
-@ex:
+@error:
@Returns:
@db:
@folder_name:
-@ex:
+@error:
@Returns:
@folder_name:
@uid:
@msg:
-@ex:
+@error:
@Returns:
@cdb:
@folder_name:
@reset_version:
-@ex:
+@error:
@Returns:
@store:
@filename:
-@ex:
+@error:
@Returns:
</para>
@diary:
-@ex:
+@error:
<!-- ##### FUNCTION camel_disco_diary_uidmap_add ##### -->
@folder:
@uids:
-@ex:
+@error:
@Returns:
@disco_folder:
@uid:
-@ex:
+@error:
@Returns:
@disco_folder:
@expression:
-@ex:
+@error:
@Returns:
@store:
@status:
-@ex:
+@error:
+@Returns:
<!-- ##### FUNCTION camel_disco_store_can_work_offline ##### -->
</para>
@store:
-@ex:
+@error:
@Returns:
</para>
@store:
-@ex:
+@error:
<!-- ##### SECTION Image ##### -->
-<!-- ##### ENUM ExceptionId ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### STRUCT CamelException ##### -->
-<para>
-
-</para>
-
-@id:
-@desc:
-
-<!-- ##### MACRO CAMEL_EXCEPTION_INITIALISER ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### FUNCTION camel_exception_new ##### -->
-<para>
-
-</para>
-
-@void:
-@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:
-
-
@fd:
@buf:
@n:
+@error:
@Returns:
@fd:
@buf:
@n:
+@error:
@Returns:
@fd:
@buf:
@n:
+@error:
@Returns:
@fd:
@buf:
@n:
+@error:
@Returns:
@driver:
@uri:
@data:
-@ex:
+@error:
@Returns:
</para>
@driver:
-@ex:
+@error:
<!-- ##### FUNCTION camel_filter_driver_filter_message ##### -->
@source:
@source_url:
@original_source_url:
-@ex:
+@error:
@Returns:
@driver:
@mbox:
@original_source_url:
-@ex:
+@error:
@Returns:
@cache:
@uids:
@remove:
-@ex:
+@error:
@Returns:
</para>
@data:
-@ex:
+@error:
@Returns:
@info:
@source:
@expression:
-@ex:
+@error:
@Returns:
@search:
@expr:
-@ex:
+@error:
@Returns:
@search:
@expr:
@uids:
-@ex:
+@error:
@Returns:
@search:
@expr:
-@ex:
+@error:
@Returns:
</para>
@s:
-@ex:
+@error:
@Returns:
</para>
@s:
-@ex:
+@error:
@Returns:
@s:
@store:
@folder_name:
-@ex:
+@error:
@Returns:
</para>
@s:
-@ex:
+@error:
@Returns:
</para>
@s:
-@ex:
+@error:
<!-- ##### FUNCTION camel_folder_summary_insert ##### -->
</para>
@folder:
-@ex:
+@error:
@Returns:
@folder:
@expunge:
-@ex:
+@error:
@Returns:
</para>
@folder:
-@ex:
+@error:
@Returns:
@message:
@info:
@appended_uid:
-@ex:
+@error:
@Returns:
@folder:
@uid:
-@ex:
+@error:
@Returns:
@folder:
@uid:
-@ex:
+@error:
@Returns:
@folder:
@uids:
-@ex:
+@error:
@Returns:
@folder:
@expr:
-@ex:
+@error:
@Returns:
@folder:
@expr:
@uids:
-@ex:
+@error:
@Returns:
@folder:
@expression:
-@ex:
+@error:
@Returns:
@dest:
@transferred_uids:
@delete_originals:
-@ex:
+@error:
@Returns:
@folder:
@uid:
-@ex:
+@error:
@Returns:
</para>
@path:
-@ex:
+@error:
@Returns:
</para>
@path:
-@ex:
+@error:
@Returns:
@fd:
@type:
-@ex:
+@error:
@Returns:
@fd:
@type:
-@ex:
+@error:
@Returns:
@path:
@fd:
@type:
-@ex:
+@error:
@Returns:
@m:
@stream:
+@error:
@Returns:
@parser:
@databuffer:
@len:
+@error:
@Returns:
@mime_part:
@parser:
+@error:
@Returns:
@mime_part:
@mp:
+@error:
+@Returns:
<!-- ##### FUNCTION camel_mime_message_build_preview ##### -->
@source:
@dest:
-@ex:
+@error:
@Returns:
</para>
@mps:
-@ex:
+@error:
@Returns:
@name:
@service:
@hints:
-@ex:
+@error:
@Returns:
@host:
@serv:
@flags:
-@ex:
+@error:
@Returns:
@offline:
@expression:
-@ex:
+@error:
@Returns:
</para>
@journal:
-@ex:
+@error:
@Returns:
</para>
@journal:
-@ex:
+@error:
@Returns:
@store:
@state:
-@ex:
+@error:
@Returns:
</para>
@store:
-@ex:
+@error:
@Returns:
</para>
@store:
-@ex:
+@error:
@Returns:
@url:
@auto_detected:
-@ex:
+@error:
@Returns:
</para>
@path:
-@ex:
+@error:
@Returns:
</para>
@url_string:
-@ex:
+@error:
@Returns:
@provider:
@url:
@auto_detected:
-@ex:
+@error:
@Returns:
@sasl:
@token:
-@ex:
+@error:
@Returns:
@sasl:
@token:
-@ex:
+@error:
@Returns:
@stream:
@offset:
@policy:
+@error:
@Returns:
@stream:
@start:
@end:
+@error:
@Returns:
@session:
@provider:
@url:
-@ex:
+@error:
@Returns:
</para>
@service:
-@ex:
+@error:
@Returns:
@service:
@clean:
-@ex:
+@error:
@Returns:
</para>
@service:
-@ex:
+@error:
@Returns:
@msg:
@id:
-@ex:
+@error:
@ops:
@op:
@session:
@session:
@url_string:
@type:
-@ex:
+@error:
@Returns:
@session:
@url_string:
@type:
-@ex:
+@error:
@Returns:
@session:
@url_string:
-@ex:
+@error:
<!-- ##### MACRO camel_session_get_transport ##### -->
@session:
@url_string:
-@ex:
+@error:
<!-- ##### FUNCTION camel_session_get_storage_path ##### -->
@session:
@service:
-@ex:
+@error:
@Returns:
@prompt:
@item:
@flags:
-@ex:
+@error:
@Returns:
@service:
@domain:
@item:
-@ex:
+@error:
@Returns:
@session:
@type:
-@ex:
+@error:
@Returns:
@folder:
@message:
@address:
-@ex:
+@error:
+@Returns:
<!-- ##### ENUM CamelSessionLock ##### -->
@store:
@folder_name:
@flags:
-@ex:
+@error:
@Returns:
</para>
@store:
-@ex:
+@error:
@Returns:
</para>
@store:
-@ex:
+@error:
@Returns:
</para>
@store:
-@ex:
+@error:
@Returns:
@store:
@parent_name:
@folder_name:
-@ex:
+@error:
@Returns:
@store:
@folder_name:
-@ex:
+@error:
@Returns:
@store:
@old_namein:
@new_name:
-@ex:
+@error:
@Returns:
@store:
@expunge:
-@ex:
+@error:
@Returns:
@store:
@top:
@flags:
-@ex:
+@error:
@Returns:
@store:
@folder_name:
-@ex:
+@error:
@Returns:
@store:
@folder_name:
-@ex:
+@error:
@Returns:
</para>
@store:
-@ex:
+@error:
@Returns:
@store:
@info:
-@ex:
+@error:
@Returns:
@sbf:
@buf:
@max:
+@error:
@Returns:
</para>
@sbf:
+@error:
@Returns:
@name:
@flags:
@mode:
+@error:
@Returns:
@mode:
@start:
@end:
+@error:
@Returns:
@fd:
@start:
@end:
+@error:
@Returns:
@stream:
@buffer:
@n:
+@error:
@Returns:
@stream:
@buffer:
@n:
+@error:
@Returns:
</para>
@stream:
+@error:
@Returns:
</para>
@stream:
+@error:
@Returns:
</para>
@stream:
+@error:
@Returns:
@stream:
@string:
+@error:
@Returns:
@stream:
@output_stream:
+@error:
@Returns:
@stream:
@host:
+@error:
@Returns:
@message:
@from:
@recipients:
-@ex:
+@error:
@Returns:
CamelDigestSummary
+<!-- ##### SECTION ./tmpl/camel-exception.sgml:Image ##### -->
+
+
+
+<!-- ##### SECTION ./tmpl/camel-exception.sgml:Long_Description ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### SECTION ./tmpl/camel-exception.sgml:See_Also ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### SECTION ./tmpl/camel-exception.sgml:Short_Description ##### -->
+
+
+
+<!-- ##### SECTION ./tmpl/camel-exception.sgml:Stability_Level ##### -->
+
+
+
+<!-- ##### SECTION ./tmpl/camel-exception.sgml:Title ##### -->
+camel-exception
+
+
<!-- ##### SECTION ./tmpl/camel-groupwise-folder.sgml:Image ##### -->
@obj:
@ctype:
+<!-- ##### MACRO CAMEL_EXCEPTION_INITIALISER ##### -->
+<para>
+
+</para>
+
+
<!-- ##### MACRO CAMEL_GROUPWISE_FOLDER_LOCK ##### -->
<para>
@CAMEL_DISCO_DIARY_ARG_UID:
@CAMEL_DISCO_DIARY_ARG_UID_LIST:
+<!-- ##### STRUCT CamelException ##### -->
+<para>
+
+</para>
+
+
<!-- ##### STRUCT CamelGroupwiseFolder ##### -->
<para>
@user_data:
@Returns:
+<!-- ##### ENUM ExceptionId ##### -->
+<para>
+
+</para>
+
+
<!-- ##### MACRO GW_PARAM_FILTER_INBOX ##### -->
<para>
@Returns:
+<!-- ##### 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>
+
+@void:
+@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>
</para>
@url_string:
-@ex:
+@error:
@Returns:
@vf:
@sub:
-@ex:
+@error:
@Returns:
</para>
@vf:
-@ex:
+@error:
<!-- ##### FUNCTION camel_vee_folder_get_unread_vfolder ##### -->
camel/camel-disco-diary.c
camel/camel-disco-folder.c
camel/camel-disco-store.c
-camel/camel-exception.c
camel/camel-file-utils.c
camel/camel-filter-driver.c
camel/camel-filter-search.c
camel/providers/imapx/camel-imapx-provider.c
camel/providers/imapx/camel-imapx-server.c
camel/providers/imapx/camel-imapx-store.c
+camel/providers/imapx/camel-imapx-stream.c
camel/providers/local/camel-local-folder.c
camel/providers/local/camel-local-provider.c
camel/providers/local/camel-local-store.c