noinst_HEADERS = \
camel-charset-map-private.h \
- camel-private.h
+ camel-win32.h
BUILT_SOURCES = camel-mime-tables.c
#include "camel-block-file.h"
#include "camel-file-utils.h"
#include "camel-list-utils.h"
-#include "camel-private.h"
#define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/
#include "camel-certdb.h"
#include "camel-file-utils.h"
-#include "camel-private.h"
+#include "camel-win32.h"
#define CAMEL_CERTDB_VERSION 0x100
+struct _CamelCertDBPrivate {
+ GMutex *db_lock; /* for the db hashtable/array */
+ GMutex *io_lock; /* load/save lock, for access to saved_count, etc */
+ GMutex *alloc_lock; /* for setting up and using allocators */
+ GMutex *ref_lock; /* for reffing/unreffing certs */
+};
+
static gint certdb_header_load (CamelCertDB *certdb, FILE *istream);
static gint certdb_header_save (CamelCertDB *certdb, FILE *ostream);
static CamelCert *certdb_cert_load (CamelCertDB *certdb, FILE *istream);
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
g_return_if_fail (filename != NULL);
- CAMEL_CERTDB_LOCK (certdb, db_lock);
+ camel_certdb_lock (certdb, CCD_DB_LOCK);
g_free (certdb->filename);
certdb->filename = g_strdup (filename);
- CAMEL_CERTDB_UNLOCK (certdb, db_lock);
+ camel_certdb_unlock (certdb, CCD_DB_LOCK);
}
static gint
g_return_val_if_fail (class->header_load != NULL, -1);
g_return_val_if_fail (class->cert_load != NULL, -1);
- CAMEL_CERTDB_LOCK (certdb, io_lock);
+ camel_certdb_lock (certdb, CCD_IO_LOCK);
if (class->header_load (certdb, in) == -1)
goto error;
camel_certdb_add (certdb, cert);
}
- CAMEL_CERTDB_UNLOCK (certdb, io_lock);
+ camel_certdb_unlock (certdb, CCD_IO_LOCK);
if (fclose (in) != 0)
return -1;
g_warning ("Cannot load certificate database: %s", g_strerror (ferror (in)));
- CAMEL_CERTDB_UNLOCK (certdb, io_lock);
+ camel_certdb_unlock (certdb, CCD_IO_LOCK);
fclose (in);
g_return_val_if_fail (class->header_save != NULL, -1);
g_return_val_if_fail (class->cert_save != NULL, -1);
- CAMEL_CERTDB_LOCK (certdb, io_lock);
+ camel_certdb_lock (certdb, CCD_IO_LOCK);
certdb->saved_certs = certdb->certs->len;
if (class->header_save (certdb, out) == -1)
goto error;
}
- CAMEL_CERTDB_UNLOCK (certdb, io_lock);
+ camel_certdb_unlock (certdb, CCD_IO_LOCK);
if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
i = errno;
g_warning ("Cannot save certificate database: %s", g_strerror (ferror (out)));
- CAMEL_CERTDB_UNLOCK (certdb, io_lock);
+ camel_certdb_unlock (certdb, CCD_IO_LOCK);
i = errno;
fclose (out);
g_return_val_if_fail (CAMEL_IS_CERTDB (certdb), NULL);
- CAMEL_CERTDB_LOCK (certdb, db_lock);
+ camel_certdb_lock (certdb, CCD_DB_LOCK);
cert = g_hash_table_lookup (certdb->cert_hash, fingerprint);
if (cert)
camel_certdb_cert_ref (certdb, cert);
- CAMEL_CERTDB_UNLOCK (certdb, db_lock);
+ camel_certdb_unlock (certdb, CCD_DB_LOCK);
return cert;
}
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
- CAMEL_CERTDB_LOCK (certdb, db_lock);
+ camel_certdb_lock (certdb, CCD_DB_LOCK);
if (g_hash_table_lookup (certdb->cert_hash, cert->fingerprint)) {
- CAMEL_CERTDB_UNLOCK (certdb, db_lock);
+ camel_certdb_unlock (certdb, CCD_DB_LOCK);
return;
}
certdb->flags |= CAMEL_CERTDB_DIRTY;
- CAMEL_CERTDB_UNLOCK (certdb, db_lock);
+ camel_certdb_unlock (certdb, CCD_DB_LOCK);
}
void
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
- CAMEL_CERTDB_LOCK (certdb, db_lock);
+ camel_certdb_lock (certdb, CCD_DB_LOCK);
if (g_hash_table_lookup (certdb->cert_hash, cert->fingerprint)) {
g_hash_table_remove (certdb->cert_hash, cert->fingerprint);
certdb->flags |= CAMEL_CERTDB_DIRTY;
}
- CAMEL_CERTDB_UNLOCK (certdb, db_lock);
+ camel_certdb_unlock (certdb, CCD_DB_LOCK);
}
static CamelCert *
class = CAMEL_CERTDB_GET_CLASS (certdb);
g_return_val_if_fail (class->cert_new != NULL, NULL);
- CAMEL_CERTDB_LOCK (certdb, alloc_lock);
+ camel_certdb_lock (certdb, CCD_ALLOC_LOCK);
cert = class->cert_new (certdb);
- CAMEL_CERTDB_UNLOCK (certdb, alloc_lock);
+ camel_certdb_unlock (certdb, CCD_ALLOC_LOCK);
return cert;
}
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
g_return_if_fail (cert != NULL);
- CAMEL_CERTDB_LOCK (certdb, ref_lock);
+ camel_certdb_lock (certdb, CCD_REF_LOCK);
cert->refcount++;
- CAMEL_CERTDB_UNLOCK (certdb, ref_lock);
+ camel_certdb_unlock (certdb, CCD_REF_LOCK);
}
static void
class = CAMEL_CERTDB_GET_CLASS (certdb);
g_return_if_fail (class->cert_free != NULL);
- CAMEL_CERTDB_LOCK (certdb, ref_lock);
+ camel_certdb_lock (certdb, CCD_REF_LOCK);
if (cert->refcount <= 1) {
class->cert_free (certdb, cert);
cert->refcount--;
}
- CAMEL_CERTDB_UNLOCK (certdb, ref_lock);
+ camel_certdb_unlock (certdb, CCD_REF_LOCK);
}
static gboolean
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
- CAMEL_CERTDB_LOCK (certdb, db_lock);
+ camel_certdb_lock (certdb, CCD_DB_LOCK);
g_hash_table_foreach_remove (certdb->cert_hash, cert_remove, NULL);
for (i = 0; i < certdb->certs->len; i++) {
g_ptr_array_set_size (certdb->certs, 0);
certdb->flags |= CAMEL_CERTDB_DIRTY;
- CAMEL_CERTDB_UNLOCK (certdb, db_lock);
+ camel_certdb_unlock (certdb, CCD_DB_LOCK);
}
static const gchar *
cert->trust = trust;
}
+
+/**
+ * camel_certdb_lock:
+ * @certdb: a #CamelCertDB
+ * @lock: lock type to lock
+ *
+ * Locks #certdb's #lock. Unlock it with camel_certdb_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_certdb_lock (CamelCertDB *certdb, CamelCertDBLock lock)
+{
+ g_return_if_fail (certdb != NULL);
+ g_return_if_fail (CAMEL_IS_CERTDB (certdb));
+ g_return_if_fail (certdb->priv != NULL);
+
+ switch (lock) {
+ case CCD_DB_LOCK:
+ g_mutex_lock (certdb->priv->db_lock);
+ break;
+ case CCD_IO_LOCK:
+ g_mutex_lock (certdb->priv->io_lock);
+ break;
+ case CCD_ALLOC_LOCK:
+ g_mutex_lock (certdb->priv->alloc_lock);
+ break;
+ case CCD_REF_LOCK:
+ g_mutex_lock (certdb->priv->ref_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_certdb_unlock:
+ * @certdb: a #CamelCertDB
+ * @lock: lock type to unlock
+ *
+ * Unlocks #certdb's #lock, previously locked with camel_certdb_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_certdb_unlock (CamelCertDB *certdb, CamelCertDBLock lock)
+{
+ g_return_if_fail (certdb != NULL);
+ g_return_if_fail (CAMEL_IS_CERTDB (certdb));
+ g_return_if_fail (certdb->priv != NULL);
+
+ switch (lock) {
+ case CCD_DB_LOCK:
+ g_mutex_unlock (certdb->priv->db_lock);
+ break;
+ case CCD_IO_LOCK:
+ g_mutex_unlock (certdb->priv->io_lock);
+ break;
+ case CCD_ALLOC_LOCK:
+ g_mutex_unlock (certdb->priv->alloc_lock);
+ break;
+ case CCD_REF_LOCK:
+ g_mutex_unlock (certdb->priv->ref_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
GByteArray *rawcert;
} CamelCert;
+typedef enum _CamelCertDBLock {
+ CCD_DB_LOCK,
+ CCD_IO_LOCK,
+ CCD_ALLOC_LOCK,
+ CCD_REF_LOCK
+} CamelCertDBLock;
+
struct _CamelCertDB {
CamelObject parent;
CamelCertDBPrivate *priv;
CamelCertTrust camel_cert_get_trust (CamelCertDB *certdb, CamelCert *cert);
void camel_cert_set_trust (CamelCertDB *certdb, CamelCert *cert, CamelCertTrust trust);
+void camel_certdb_lock (CamelCertDB *certdb, CamelCertDBLock lock);
+void camel_certdb_unlock (CamelCertDB *certdb, CamelCertDBLock lock);
+
G_END_DECLS
#endif /* CAMEL_CERTDB_H */
#include "camel-data-wrapper.h"
#include "camel-mime-filter-basic.h"
#include "camel-mime-filter-crlf.h"
-#include "camel-private.h"
#include "camel-stream-filter.h"
#include "camel-stream.h"
#define d(x)
+struct _CamelDataWrapperPrivate {
+ GStaticMutex stream_lock;
+};
+
static CamelObjectClass *parent_class = NULL;
static void
return -1;
}
- CAMEL_DATA_WRAPPER_LOCK (data_wrapper, stream_lock);
+ camel_data_wrapper_lock (data_wrapper, CDW_STREAM_LOCK);
if (camel_stream_reset (data_wrapper->stream) == -1) {
- CAMEL_DATA_WRAPPER_UNLOCK (data_wrapper, stream_lock);
+ camel_data_wrapper_unlock (data_wrapper, CDW_STREAM_LOCK);
return -1;
}
ret = camel_stream_write_to_stream (data_wrapper->stream, stream);
- CAMEL_DATA_WRAPPER_UNLOCK (data_wrapper, stream_lock);
+ camel_data_wrapper_unlock (data_wrapper, CDW_STREAM_LOCK);
return ret;
}
return class->is_offline (data_wrapper);
}
+
+/**
+ * camel_data_wrapper_lock:
+ * @data_wrapper: a #CamelDataWrapper
+ * @lock: lock type to lock
+ *
+ * Locks #data_wrapper's #lock. Unlock it with camel_data_wrapper_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_data_wrapper_lock (CamelDataWrapper *data_wrapper, CamelDataWrapperLock lock)
+{
+ g_return_if_fail (data_wrapper != NULL);
+ g_return_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper));
+ g_return_if_fail (data_wrapper->priv != NULL);
+
+ switch (lock) {
+ case CDW_STREAM_LOCK:
+ g_static_mutex_lock (&data_wrapper->priv->stream_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_data_wrapper_unlock:
+ * @data_wrapper: a #CamelDataWrapper
+ * @lock: lock type to unlock
+ *
+ * Unlocks #data_wrapper's #lock, previously locked with camel_data_wrapper_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_data_wrapper_unlock (CamelDataWrapper *data_wrapper, CamelDataWrapperLock lock)
+{
+ g_return_if_fail (data_wrapper != NULL);
+ g_return_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper));
+ g_return_if_fail (data_wrapper->priv != NULL);
+
+ switch (lock) {
+ case CDW_STREAM_LOCK:
+ g_static_mutex_unlock (&data_wrapper->priv->stream_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
typedef struct _CamelDataWrapperClass CamelDataWrapperClass;
typedef struct _CamelDataWrapperPrivate CamelDataWrapperPrivate;
+typedef enum _CamelDataWrapperLock {
+ CDW_STREAM_LOCK
+} CamelDataWrapperLock;
+
struct _CamelDataWrapper {
CamelObject parent;
CamelDataWrapperPrivate *priv;
CamelStream *stream);
gboolean camel_data_wrapper_is_offline (CamelDataWrapper *data_wrapper);
+void camel_data_wrapper_lock (CamelDataWrapper *data_wrapper, CamelDataWrapperLock lock);
+void camel_data_wrapper_unlock (CamelDataWrapper *data_wrapper, CamelDataWrapperLock lock);
+
G_END_DECLS
#endif /* CAMEL_DATA_WRAPPER_H */
#include "camel-filter-search.h"
#include "camel-list-utils.h"
#include "camel-mime-message.h"
-#include "camel-private.h"
#include "camel-service.h"
#include "camel-session.h"
#include "camel-stream-fs.h"
#include "camel-mime-filter.h"
#include "camel-mime-message.h"
#include "camel-multipart.h"
-#include "camel-private.h"
#include "camel-session.h"
#include "camel-stream-filter.h"
#include "camel-stream-mem.h"
#include "camel-store.h"
#include "camel-vee-folder.h"
#include "camel-mime-part-utils.h"
+#include "camel-win32.h"
/* Make 5 minutes as default cache drop */
#define SUMMARY_CACHE_DROP 300
#define dd(x) if (camel_debug("sync")) x
+struct _CamelFolderSummaryPrivate {
+ GHashTable *filter_charset; /* CamelMimeFilterCharset's indexed by source charset */
+
+ struct _CamelMimeFilter *filter_index;
+ struct _CamelMimeFilter *filter_64;
+ struct _CamelMimeFilter *filter_qp;
+ struct _CamelMimeFilter *filter_uu;
+ struct _CamelMimeFilter *filter_save;
+ struct _CamelMimeFilter *filter_html;
+
+ struct _CamelStream *filter_stream;
+
+ struct _CamelIndex *index;
+
+ GMutex *summary_lock; /* for the summary hashtable/array */
+ GMutex *io_lock; /* load/save lock, for access to saved_count, etc */
+ GMutex *filter_lock; /* for accessing any of the filtering/indexing stuff, since we share them */
+ GMutex *alloc_lock; /* for setting up and using allocators */
+ GMutex *ref_lock; /* for reffing/unreffing messageinfo's ALWAYS obtain before summary_lock */
+ GHashTable *flag_cache;
+
+ gboolean need_preview;
+ GHashTable *preview_updates;
+};
+
static GStaticMutex info_lock = G_STATIC_MUTEX_INIT;
/* this lock is ONLY for the standalone messageinfo stuff */
void
camel_folder_summary_set_filename(CamelFolderSummary *s, const gchar *name)
{
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
g_free(s->summary_path);
s->summary_path = g_strdup(name);
g_free(s->meta_summary->path);
s->meta_summary->path = g_strconcat(name, "-meta", NULL);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
/**
{
CamelMessageInfo *info = NULL;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
- CAMEL_SUMMARY_LOCK(s, ref_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
+ camel_folder_summary_lock (s, CFS_REF_LOCK);
if (i < s->uids->len) {
gchar *uid;
/* FIXME: Get exception from caller
and pass it on below */
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return camel_folder_summary_uid (s, uid);
}
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return info;
}
camel_folder_summary_uid_from_index (CamelFolderSummary *s, gint i)
{
gchar *uid=NULL;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
if (i<s->uids->len)
uid = g_strdup (g_ptr_array_index(s->uids, i));
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return uid;
gboolean ret = FALSE;
gint i;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
for (i=0; i<s->uids->len; i++) {
if (strcmp(s->uids->pdata[i], uid) == 0) {
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return TRUE;
}
}
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return ret;
}
GPtrArray *res = g_ptr_array_new();
gint i;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
g_ptr_array_set_size(res, s->uids->len);
for (i=0;i<s->uids->len;i++)
res->pdata[i] = (gpointer) camel_pstring_strdup ((gchar *)g_ptr_array_index(s->uids, i));
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return res;
}
GHashTable *hash = g_hash_table_new (g_str_hash, g_str_equal);
gint i;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
for (i=0;i<s->uids->len;i++)
g_hash_table_insert (hash, (gpointer)camel_pstring_strdup ((gchar *)g_ptr_array_index(s->uids, i)), GINT_TO_POINTER(1));
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return hash;
}
CamelMessageInfo *info;
gint ret;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
info = g_hash_table_lookup (s->loaded_infos, uid);
folder_name = s->folder->full_name;
cdb = s->folder->parent_store->cdb_r;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
data.summary = s;
data.double_ref = TRUE;
return NULL;
}
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
/* We would have double reffed at camel_read_mir_callback */
info = g_hash_table_lookup (s->loaded_infos, uid);
if (info)
camel_message_info_ref (info);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return info;
}
{
guint32 uid;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
uid = s->nextuid++;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
/* FIXME: sync this to disk */
/* summary_header_save(s);*/
camel_folder_summary_set_uid(CamelFolderSummary *s, guint32 uid)
{
/* TODO: sync to disk? */
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
s->nextuid = MAX(s->nextuid, uid);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
/**
* We need to have collate or something to get the modified ones
* from DB and merge */
- CAMEL_SUMMARY_LOCK (s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
g_hash_table_foreach (s->loaded_infos, (GHFunc) append_changed_uids, res);
- CAMEL_SUMMARY_UNLOCK (s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return res;
}
{
gint count = 0;
- CAMEL_SUMMARY_LOCK (s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
g_hash_table_foreach (s->loaded_infos, (GHFunc) count_changed_uids, &count);
- CAMEL_SUMMARY_UNLOCK (s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return count;
}
dd(printf("removing cache for %s %d %p\n", s->folder ? s->folder->full_name : s->summary_path, g_hash_table_size (s->loaded_infos), (gpointer) s->loaded_infos));
/* FIXME[disk-summary] hack. fix it */
- CAMEL_SUMMARY_LOCK (s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
- CAMEL_SUMMARY_LOCK(s, ref_lock);
+ camel_folder_summary_lock (s, CFS_REF_LOCK);
g_hash_table_foreach_remove (s->loaded_infos, (GHRFunc) remove_item, &to_free_list);
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
/* Deferred freeing as _free function will try to remove
entries from the hash_table in foreach_remove otherwise */
camel_message_info_free (l->data);
g_slist_free (to_free_list);
- CAMEL_SUMMARY_UNLOCK (s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
dd(printf("done .. now %d\n",g_hash_table_size (s->loaded_infos)));
s->cache_load_time = time(NULL);
g_hash_table_destroy (preview_data);
}
- CAMEL_SUMMARY_LOCK (m->folder->summary, summary_lock);
+ camel_folder_summary_lock (m->folder->summary, CFS_SUMMARY_LOCK);
g_hash_table_foreach (m->folder->summary->loaded_infos, (GHFunc)pick_uids, uids_uncached);
- CAMEL_SUMMARY_UNLOCK (m->folder->summary, summary_lock);
+ camel_folder_summary_unlock (m->folder->summary, CFS_SUMMARY_LOCK);
for (i=0; i < uids_uncached->len; i++) {
g_hash_table_remove (hash, uids_uncached->pdata[i]);
camel_pstring_free (uids_uncached->pdata[i]); /* unref the hash table key */
}
- CAMEL_FOLDER_REC_LOCK(m->folder, lock);
+ camel_folder_lock (m->folder, CF_REC_LOCK);
camel_db_begin_transaction (m->folder->parent_store->cdb_w, NULL);
g_hash_table_foreach (hash, (GHFunc)msg_update_preview, m->folder);
camel_db_end_transaction (m->folder->parent_store->cdb_w, NULL);
- CAMEL_FOLDER_REC_UNLOCK(m->folder, lock);
+ camel_folder_unlock (m->folder, CF_REC_LOCK);
camel_folder_free_uids(m->folder, uids_uncached);
camel_folder_summary_free_hashtable (hash);
}
void
camel_folder_summary_add_preview (CamelFolderSummary *s, CamelMessageInfo *info)
{
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
g_hash_table_insert (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates, (gchar *)info->uid, ((CamelMessageInfoBase *)info)->preview);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
/**
mir = g_new0 (CamelMIRecord , 1);
mir_from_cols (mir, s, ncol, cols, name);
- CAMEL_SUMMARY_LOCK (s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
if (g_hash_table_lookup (s->loaded_infos, mir->uid)) {
/* Unlock and better return*/
- CAMEL_SUMMARY_UNLOCK (s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
camel_db_camel_mir_free (mir);
return ret;
}
- CAMEL_SUMMARY_UNLOCK (s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_from_db (s, mir);
if (in == NULL)
return -1;
- CAMEL_SUMMARY_LOCK(s, io_lock);
+ camel_folder_summary_lock (s, CFS_IO_LOCK);
if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in) == -1)
goto error;
camel_folder_summary_add (s, mi);
}
- CAMEL_SUMMARY_UNLOCK(s, io_lock);
+ camel_folder_summary_unlock (s, CFS_IO_LOCK);
if (fclose (in) != 0)
return -1;
if (errno != EINVAL)
g_warning ("Cannot load summary file: '%s': %s", s->summary_path, g_strerror (errno));
- CAMEL_SUMMARY_UNLOCK(s, io_lock);
+ camel_folder_summary_unlock (s, CFS_IO_LOCK);
fclose (in);
s->flags |= ~CAMEL_SUMMARY_DIRTY;
#endif
if (camel_db_prepare_message_info_table (cdb, folder_name, ex) != 0) {
return -1;
}
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
/* Push MessageInfo-es */
g_hash_table_foreach (s->loaded_infos, save_to_db_cb, &args);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
/* FIXME[disk-summary] make sure we free the message infos that are loaded
* are freed if not used anymore or should we leave that to the timer? */
d(printf ("\ncamel_folder_summary_save_to_db called \n"));
if (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->need_preview && g_hash_table_size(CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates)) {
camel_db_begin_transaction (s->folder->parent_store->cdb_w, NULL);
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
g_hash_table_foreach (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates, (GHFunc)msg_save_preview, s->folder);
g_hash_table_remove_all (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
camel_db_end_transaction (s->folder->parent_store->cdb_w, NULL);
}
io(printf("saving header\n"));
- CAMEL_SUMMARY_LOCK(s, io_lock);
+ camel_folder_summary_lock (s, CFS_IO_LOCK);
if (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_save(s, out) == -1)
goto exception;
fclose (out);
fclose (out_meta);
- CAMEL_SUMMARY_UNLOCK(s, io_lock);
+ camel_folder_summary_unlock (s, CFS_IO_LOCK);
#ifdef G_OS_WIN32
g_unlink(s->summary_path);
fclose (out);
fclose (out_meta);
- CAMEL_SUMMARY_UNLOCK(s, io_lock);
+ camel_folder_summary_unlock (s, CFS_IO_LOCK);
g_unlink (path);
g_unlink (path_meta);
return -1;
}
- CAMEL_SUMMARY_LOCK(s, io_lock);
+ camel_folder_summary_lock (s, CFS_IO_LOCK);
ret = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in);
ret = summary_meta_header_load(s, in_meta);
- CAMEL_SUMMARY_UNLOCK(s, io_lock);
+ camel_folder_summary_unlock (s, CFS_IO_LOCK);
fclose(in);
fclose(in_meta);
uid = info->uid = (gchar *)camel_pstring_add (camel_folder_summary_next_uid_string(s), TRUE);
}
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
while ((mi = g_hash_table_lookup(s->loaded_infos, uid))) {
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
if (mi == info)
return 0;
uid = info->uid = camel_pstring_add (camel_folder_summary_next_uid_string(s), TRUE);
camel_message_info_set_flags(info, CAMEL_MESSAGE_FOLDER_FLAGGED, CAMEL_MESSAGE_FOLDER_FLAGGED);
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
}
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return 1;
}
if (summary_assign_uid(s, info) == 0)
return;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
/* Summary always holds a ref for the loaded infos */
/* camel_message_info_ref(info); FIXME: Check how things are loaded. */
g_hash_table_insert (s->loaded_infos, (gpointer) camel_message_info_uid (info), info);
s->flags |= CAMEL_SUMMARY_DIRTY;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
/**
if (info == NULL)
return;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
/* Summary always holds a ref for the loaded infos */
/* camel_message_info_ref(info); FIXME: Check how things are loaded. */
if (!load)
s->flags |= CAMEL_SUMMARY_DIRTY;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
static void
if (p->index)
summary_assign_uid(s, info);
- CAMEL_SUMMARY_LOCK(s, filter_lock);
+ camel_folder_summary_lock (s, CFS_FILTER_LOCK);
if (p->index) {
if (p->filter_index == NULL)
CAMEL_MIME_FILTER_INDEX (p->filter_index), NULL);
}
- CAMEL_SUMMARY_UNLOCK(s, filter_lock);
+ camel_folder_summary_unlock (s, CFS_FILTER_LOCK);
((CamelMessageInfoBase *)info)->size = camel_mime_parser_tell(mp) - start;
}
if (p->index)
summary_assign_uid(s, info);
- CAMEL_SUMMARY_LOCK(s, filter_lock);
+ camel_folder_summary_lock (s, CFS_FILTER_LOCK);
if (p->index) {
if (p->filter_index == NULL)
CAMEL_MIME_FILTER_INDEX (p->filter_index), NULL);
}
- CAMEL_SUMMARY_UNLOCK(s, filter_lock);
+ camel_folder_summary_unlock (s, CFS_FILTER_LOCK);
return info;
}
void
camel_folder_summary_touch(CamelFolderSummary *s)
{
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
s->flags |= CAMEL_SUMMARY_DIRTY;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
/**
d(printf ("\ncamel_folder_summary_clearcalled \n"));
s->flags &= ~CAMEL_SUMMARY_DIRTY;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
if (camel_folder_summary_count(s) == 0) {
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return;
}
g_hash_table_destroy(s->loaded_infos);
s->loaded_infos = g_hash_table_new(g_str_hash, g_str_equal);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
/**
folder_name = s->folder->full_name;
cdb = s->folder->parent_store->cdb_w;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
if (camel_folder_summary_count(s) == 0) {
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return;
}
g_hash_table_destroy(s->loaded_infos);
s->loaded_infos = g_hash_table_new(g_str_hash, g_str_equal);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
camel_db_clear_folder_summary (cdb, folder_name, NULL);
}
gboolean found;
gint ret;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
found = g_hash_table_lookup (s->loaded_infos, camel_message_info_uid (info)) != NULL;
g_hash_table_remove (s->loaded_infos, camel_message_info_uid(info));
s->flags |= CAMEL_SUMMARY_DIRTY;
s->meta_summary->msg_expunged = TRUE;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
if (!ret && camel_db_delete_uid (s->folder->parent_store->cdb_w, s->folder->full_name, camel_message_info_uid(info), NULL) != 0)
return;
CamelMessageInfo *oldinfo;
gchar *olduid;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
- CAMEL_SUMMARY_LOCK(s, ref_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
+ camel_folder_summary_lock (s, CFS_REF_LOCK);
if (g_hash_table_lookup_extended(s->loaded_infos, uid, (gpointer)&olduid, (gpointer)&oldinfo)) {
/* make sure it doesn't vanish while we're removing it */
oldinfo->refcount++;
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
camel_folder_summary_remove(s, oldinfo);
camel_message_info_free(oldinfo);
} else {
gint ret;
/* Info isn't loaded into the memory. We must just remove the UID*/
ret = summary_remove_uid (s, uid);
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
if (!ret && camel_db_delete_uid (s->folder->parent_store->cdb_w, s->folder->full_name, tmpid, NULL) != 0) {
g_free(tmpid);
CamelMessageInfo *oldinfo;
gchar *olduid;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
- CAMEL_SUMMARY_LOCK(s, ref_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
+ camel_folder_summary_lock (s, CFS_REF_LOCK);
if (g_hash_table_lookup_extended(s->loaded_infos, uid, (gpointer)&olduid, (gpointer)&oldinfo)) {
/* make sure it doesn't vanish while we're removing it */
oldinfo->refcount++;
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
g_hash_table_remove (s->loaded_infos, olduid);
summary_remove_uid (s, olduid);
s->flags |= CAMEL_SUMMARY_DIRTY;
s->meta_summary->msg_expunged = TRUE;
camel_message_info_free(oldinfo);
camel_message_info_free(oldinfo);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
} else {
gchar *tmpid = g_strdup (uid);
/* Info isn't loaded into the memory. We must just remove the UID*/
summary_remove_uid (s, uid);
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
g_free (tmpid);
}
}
CamelMessageInfo *oldinfo;
gchar *olduid;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
- CAMEL_SUMMARY_LOCK(s, ref_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
+ camel_folder_summary_lock (s, CFS_REF_LOCK);
if (g_hash_table_lookup_extended(s->loaded_infos, uid, (gpointer)&olduid, (gpointer)&oldinfo)) {
/* make sure it doesn't vanish while we're removing it */
g_hash_table_remove (s->loaded_infos, uid);
camel_pstring_free (uid);
g_ptr_array_remove_index(s->uids, index);
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
camel_message_info_free(oldinfo);
} else {
/* Info isn't loaded into the memory. We must just remove the UID*/
g_ptr_array_remove_index(s->uids, index);
camel_pstring_free (uid);
- CAMEL_SUMMARY_UNLOCK(s, ref_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
-
+ camel_folder_summary_unlock (s, CFS_REF_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
}
if (end < start)
return;
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
if (start < s->uids->len) {
s->flags |= CAMEL_SUMMARY_DIRTY;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
camel_exception_clear (&ex);
} else {
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
}
}
class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
- CAMEL_SUMMARY_LOCK(s, alloc_lock);
+ camel_folder_summary_lock (s, CFS_ALLOC_LOCK);
ci = g_slice_alloc0 (class->content_info_size);
- CAMEL_SUMMARY_UNLOCK(s, alloc_lock);
+ camel_folder_summary_unlock (s, CFS_ALLOC_LOCK);
return ci;
}
CamelMessageInfo *info;
if (s) {
- CAMEL_SUMMARY_LOCK(s, alloc_lock);
+ camel_folder_summary_lock (s, CFS_ALLOC_LOCK);
class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
info = g_slice_alloc0 (class->message_info_size);
- CAMEL_SUMMARY_UNLOCK(s, alloc_lock);
+ camel_folder_summary_unlock (s, CFS_ALLOC_LOCK);
} else {
info = g_slice_alloc0 (sizeof(CamelMessageInfoBase));
}
CamelMessageInfo *mi = o;
if (mi->summary) {
- CAMEL_SUMMARY_LOCK(mi->summary, ref_lock);
+ camel_folder_summary_lock (mi->summary, CFS_REF_LOCK);
g_assert(mi->refcount >= 1);
mi->refcount++;
- CAMEL_SUMMARY_UNLOCK(mi->summary, ref_lock);
+ camel_folder_summary_unlock (mi->summary, CFS_REF_LOCK);
} else {
GLOBAL_INFO_LOCK(info);
g_assert(mi->refcount >= 1);
g_return_if_fail(mi != NULL);
if (mi->summary) {
- CAMEL_SUMMARY_LOCK(mi->summary, ref_lock);
+ camel_folder_summary_lock (mi->summary, CFS_REF_LOCK);
if (mi->refcount >= 1)
mi->refcount--;
if (mi->refcount > 0) {
- CAMEL_SUMMARY_UNLOCK(mi->summary, ref_lock);
+ camel_folder_summary_unlock (mi->summary, CFS_REF_LOCK);
return;
}
- CAMEL_SUMMARY_UNLOCK(mi->summary, ref_lock);
+ camel_folder_summary_unlock (mi->summary, CFS_REF_LOCK);
/* FIXME: this is kinda busted, should really be handled by message info free */
if (mi->summary->build_content
return NULL;
}
+
+/**
+ * camel_folder_summary_lock:
+ * @summary: a #CamelFolderSummary
+ * @lock: lock type to lock
+ *
+ * Locks #summary's #lock. Unlock it with camel_folder_summary_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_folder_summary_lock (CamelFolderSummary *summary, CamelFolderSummaryLock lock)
+{
+ g_return_if_fail (summary != NULL);
+ g_return_if_fail (CAMEL_IS_FOLDER_SUMMARY (summary));
+ g_return_if_fail (summary->priv != NULL);
+
+ switch (lock) {
+ case CFS_SUMMARY_LOCK:
+ g_mutex_lock (summary->priv->summary_lock);
+ break;
+ case CFS_IO_LOCK:
+ g_mutex_lock (summary->priv->io_lock);
+ break;
+ case CFS_FILTER_LOCK:
+ g_mutex_lock (summary->priv->filter_lock);
+ break;
+ case CFS_ALLOC_LOCK:
+ g_mutex_lock (summary->priv->alloc_lock);
+ break;
+ case CFS_REF_LOCK:
+ g_mutex_lock (summary->priv->ref_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_folder_summary_unlock:
+ * @summary: a #CamelFolderSummary
+ * @lock: lock type to unlock
+ *
+ * Unlocks #summary's #lock, previously locked with camel_folder_summary_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_folder_summary_unlock (CamelFolderSummary *summary, CamelFolderSummaryLock lock)
+{
+ g_return_if_fail (summary != NULL);
+ g_return_if_fail (CAMEL_IS_FOLDER_SUMMARY (summary));
+ g_return_if_fail (summary->priv != NULL);
+
+ switch (lock) {
+ case CFS_SUMMARY_LOCK:
+ g_mutex_unlock (summary->priv->summary_lock);
+ break;
+ case CFS_IO_LOCK:
+ g_mutex_unlock (summary->priv->io_lock);
+ break;
+ case CFS_FILTER_LOCK:
+ g_mutex_unlock (summary->priv->filter_lock);
+ break;
+ case CFS_ALLOC_LOCK:
+ g_mutex_unlock (summary->priv->alloc_lock);
+ break;
+ case CFS_REF_LOCK:
+ g_mutex_unlock (summary->priv->ref_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
CAMEL_SUMMARY_DIRTY = 1<<0
} CamelFolderSummaryFlags;
+typedef enum _CamelFolderSummaryLock {
+ CFS_SUMMARY_LOCK,
+ CFS_IO_LOCK,
+ CFS_FILTER_LOCK,
+ CFS_ALLOC_LOCK,
+ CFS_REF_LOCK
+} CamelFolderSummaryLock;
+
struct _CamelFolderSummary {
CamelObject parent;
CamelFolderSummaryPrivate *priv;
/* Migration code */
gint camel_folder_summary_migrate_infos(CamelFolderSummary *s);
+void camel_folder_summary_lock (CamelFolderSummary *summary, CamelFolderSummaryLock lock);
+void camel_folder_summary_unlock (CamelFolderSummary *summary, CamelFolderSummaryLock lock);
+
G_END_DECLS
#endif /* CAMEL_FOLDER_SUMMARY_H */
#include "camel-mempool.h"
#include "camel-mime-message.h"
#include "camel-operation.h"
-#include "camel-private.h"
#include "camel-session.h"
#include "camel-store.h"
#include "camel-vtrash-folder.h"
#define d(x)
#define w(x)
+struct _CamelFolderPrivate {
+ GStaticRecMutex lock;
+ GStaticMutex change_lock;
+ /* must require the 'change_lock' to access this */
+ gint frozen;
+ struct _CamelFolderChangeInfo *changed_frozen; /* queues changed events */
+ gboolean skip_folder_lock;
+};
+
static CamelObjectClass *parent_class = NULL;
/* Forward Declarations */
{
g_return_if_fail (folder->priv->frozen >= 0);
- CAMEL_FOLDER_LOCK (folder, change_lock);
+ camel_folder_lock (folder, CF_CHANGE_LOCK);
folder->priv->frozen++;
d (printf ("freeze (%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
- CAMEL_FOLDER_UNLOCK (folder, change_lock);
+ camel_folder_unlock (folder, CF_CHANGE_LOCK);
}
static void
g_return_if_fail (folder->priv->frozen > 0);
- CAMEL_FOLDER_LOCK (folder, change_lock);
+ camel_folder_lock (folder, CF_CHANGE_LOCK);
folder->priv->frozen--;
folder->priv->changed_frozen = camel_folder_change_info_new ();
}
- CAMEL_FOLDER_UNLOCK (folder, change_lock);
+ camel_folder_unlock (folder, CF_CHANGE_LOCK);
if (info) {
camel_object_trigger_event (folder, "folder_changed", info);
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_if_fail (class->sync != NULL);
- CAMEL_FOLDER_REC_LOCK (folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
class->sync (folder, expunge, ex);
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
}
/**
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_if_fail (class->refresh_info != NULL);
- CAMEL_FOLDER_REC_LOCK (folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
class->refresh_info (folder, ex);
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
}
/**
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_if_fail (class->expunge != NULL);
- CAMEL_FOLDER_REC_LOCK (folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
class->expunge (folder, ex);
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
}
/**
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_if_fail (class->append_message != NULL);
- CAMEL_FOLDER_REC_LOCK (folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
class->append_message (folder, message, info, appended_uid, ex);
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
}
/**
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->get_message != NULL, NULL);
- CAMEL_FOLDER_REC_LOCK (folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
ret = class->get_message (folder, uid, ex);
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
if (ret && camel_debug_start (":folder")) {
printf ("CamelFolder:get_message ('%s', '%s') =\n", folder->full_name, uid);
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_if_fail (class->get_message != NULL);
- CAMEL_FOLDER_REC_LOCK (folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
/* Use the sync_message method if the class implements it. */
if (class->sync_message != NULL)
camel_object_unref (message);
}
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
}
/**
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->search_by_expression != NULL, NULL);
- /* NOTE: that it is upto the callee to lock */
+ /* NOTE: that it is upto the callee to CF_REC_LOCK */
return class->search_by_expression (folder, expression, ex);
}
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->count_by_expression != NULL, 0);
- /* NOTE: that it is upto the callee to lock */
+ /* NOTE: that it is upto the callee to CF_REC_LOCK */
return class->count_by_expression (folder, expression, ex);
}
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->search_by_uids != NULL, NULL);
- /* NOTE: that it is upto the callee to lock */
+ /* NOTE: that it is upto the callee to CF_REC_LOCK */
return class->search_by_uids (folder, expr, uids, ex);
}
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_if_fail (class->search_free != NULL);
- /* NOTE: upto the callee to lock */
+ /* NOTE: upto the callee to CF_REC_LOCK */
class->search_free (folder, result);
}
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_if_fail (class->delete != NULL);
- CAMEL_FOLDER_REC_LOCK (folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
if (folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED) {
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
return;
}
class->delete (folder);
- CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
/* Delete the references of the folder from the DB.*/
camel_db_delete_folder (folder->parent_store->cdb_w, folder->full_name, NULL);
return class->is_frozen (folder);
}
+/* FIXME: This function shouldn't be needed, but it's used in CamelVeeFolder */
+gint
+camel_folder_get_frozen_count (CamelFolder *folder)
+{
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
+
+ return folder->priv->frozen;
+}
+
/**
* camel_folder_get_quota_info:
* @folder: a #CamelFolder
return TRUE;
}
- CAMEL_FOLDER_LOCK (folder, change_lock);
+ camel_folder_lock (folder, CF_CHANGE_LOCK);
if (folder->priv->frozen) {
camel_folder_change_info_cat (folder->priv->changed_frozen, changed);
- CAMEL_FOLDER_UNLOCK (folder, change_lock);
+ camel_folder_unlock (folder, CF_CHANGE_LOCK);
return FALSE;
}
- CAMEL_FOLDER_UNLOCK (folder, change_lock);
+ camel_folder_unlock (folder, CF_CHANGE_LOCK);
if (session->junk_plugin && changed->uid_changed->len) {
guint32 flags;
camel_folder_freeze (folder);
/* Copy changes back to changed_frozen list to retain
* them while we are filtering */
- CAMEL_FOLDER_LOCK (folder, change_lock);
+ camel_folder_lock (folder, CF_CHANGE_LOCK);
camel_folder_change_info_cat (folder->priv->changed_frozen, changed);
- CAMEL_FOLDER_UNLOCK (folder, change_lock);
+ camel_folder_unlock (folder, CF_CHANGE_LOCK);
msg->driver = driver;
camel_exception_init (&msg->ex);
camel_session_thread_queue (session, &msg->msg, 0);
g_ptr_array_free (info->uid_recent, TRUE);
g_slice_free (CamelFolderChangeInfo, info);
}
+
+/**
+ * camel_folder_lock:
+ * @folder: a #CamelFolder
+ * @lock: lock type to lock
+ *
+ * Locks #folder's #lock. Unlock it with camel_folder_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_folder_lock (CamelFolder *folder, CamelFolderLock lock)
+{
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail (folder->priv != NULL);
+
+ switch (lock) {
+ case CF_CHANGE_LOCK:
+ g_static_mutex_lock (&folder->priv->change_lock);
+ break;
+ case CF_REC_LOCK:
+ if (folder->priv->skip_folder_lock == FALSE) g_static_rec_mutex_lock (&folder->priv->lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_folder_unlock:
+ * @folder: a #CamelFolder
+ * @lock: lock type to unlock
+ *
+ * Unlocks #folder's #lock, previously locked with camel_folder_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_folder_unlock (CamelFolder *folder, CamelFolderLock lock)
+{
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail (folder->priv != NULL);
+
+ switch (lock) {
+ case CF_CHANGE_LOCK:
+ g_static_mutex_unlock (&folder->priv->change_lock);
+ break;
+ case CF_REC_LOCK:
+ if (folder->priv->skip_folder_lock == FALSE) g_static_rec_mutex_unlock (&folder->priv->lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
CAMEL_FOLDER_PROPERTIES = CAMEL_FOLDER_ARG_PROPERTIES | CAMEL_ARG_PTR
};
+typedef enum _CamelFolderLock {
+ CF_CHANGE_LOCK,
+ CF_REC_LOCK
+} CamelFolderLock;
+
struct _CamelFolderChangeInfo {
GPtrArray *uid_added;
GPtrArray *uid_removed;
void camel_folder_freeze (CamelFolder *folder);
void camel_folder_thaw (CamelFolder *folder);
gboolean camel_folder_is_frozen (CamelFolder *folder);
+gint camel_folder_get_frozen_count (CamelFolder *folder);
/* quota support */
CamelFolderQuotaInfo *
(CamelFolderChangeInfo *info,
const gchar *uid);
+void camel_folder_lock (CamelFolder *folder, CamelFolderLock lock);
+void camel_folder_unlock (CamelFolder *folder, CamelFolderLock lock);
+
G_END_DECLS
#endif /* CAMEL_FOLDER_H */
#include "camel-mime-filter.h"
#include "camel-mime-parser.h"
#include "camel-mime-utils.h"
-#include "camel-private.h"
#include "camel-seekable-stream.h"
#include "camel-stream.h"
#include "camel-folder-summary.h"
#include "camel-folder.h"
#include "camel-offline-journal.h"
-#include "camel-private.h"
+#include "camel-win32.h"
#define d(x)
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * camel-private.h: Private info for class implementers.
- *
- * Authors: Michael Zucchi <notzed@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_PRIVATE_H
-#define CAMEL_PRIVATE_H
-
-/* need a way to configure and save this data, if this header is to
- be installed. For now, dont install it */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-extern gint camel_verbose_debug;
-
-struct _CamelFolderPrivate {
- GStaticRecMutex lock;
- GStaticMutex change_lock;
- /* must require the 'change_lock' to access this */
- gint frozen;
- struct _CamelFolderChangeInfo *changed_frozen; /* queues changed events */
- gboolean skip_folder_lock;
-};
-
-#define CAMEL_FOLDER_LOCK(f, l) \
- (g_static_mutex_lock(&((CamelFolder *) (f))->priv->l))
-#define CAMEL_FOLDER_UNLOCK(f, l) \
- (g_static_mutex_unlock(&((CamelFolder *) (f))->priv->l))
-#define CAMEL_FOLDER_REC_LOCK(f, l) \
- if (((CamelFolder *) (f))->priv->skip_folder_lock == FALSE) g_static_rec_mutex_lock(&((CamelFolder *) (f))->priv->l);
-#define CAMEL_FOLDER_REC_UNLOCK(f, l) \
- if (((CamelFolder *) (f))->priv->skip_folder_lock == FALSE) g_static_rec_mutex_unlock(&((CamelFolder *) (f))->priv->l);
-
-struct _CamelStorePrivate {
- GStaticRecMutex folder_lock; /* for locking folder operations */
-};
-
-#define CAMEL_STORE_LOCK(f, l) \
- (g_static_rec_mutex_lock(&((CamelStore *) (f))->priv->l))
-#define CAMEL_STORE_UNLOCK(f, l) \
- (g_static_rec_mutex_unlock(&((CamelStore *) (f))->priv->l))
-
-struct _CamelTransportPrivate {
- GMutex *send_lock; /* for locking send operations */
-};
-
-#define CAMEL_TRANSPORT_LOCK(f, l) \
- (g_mutex_lock(((CamelTransport *) (f))->priv->l))
-#define CAMEL_TRANSPORT_UNLOCK(f, l) \
- (g_mutex_unlock(((CamelTransport *) (f))->priv->l))
-
-struct _CamelServicePrivate {
- GStaticRecMutex connect_lock; /* for locking connection operations */
- GStaticMutex connect_op_lock; /* for locking the connection_op */
-};
-
-#define CAMEL_SERVICE_LOCK(f, l) \
- (g_static_mutex_lock(&((CamelService *) (f))->priv->l))
-#define CAMEL_SERVICE_UNLOCK(f, l) \
- (g_static_mutex_unlock(&((CamelService *) (f))->priv->l))
-#define CAMEL_SERVICE_REC_LOCK(f, l) \
- (g_static_rec_mutex_lock(&((CamelService *) (f))->priv->l))
-#define CAMEL_SERVICE_REC_UNLOCK(f, l) \
- (g_static_rec_mutex_unlock(&((CamelService *) (f))->priv->l))
-#define CAMEL_SERVICE_REC_TRYLOCK(f, l) \
- (g_static_rec_mutex_trylock(&((CamelService *) (f))->priv->l))
-
-struct _CamelSessionPrivate {
- GMutex *lock; /* for locking everything basically */
- GMutex *thread_lock; /* locking threads */
-
- gint thread_id;
- GHashTable *thread_active;
- GThreadPool *thread_pool;
-
- GHashTable *thread_msg_op;
- GHashTable *junk_headers;
-
-};
-
-#define CAMEL_SESSION_LOCK(f, l) \
- (g_mutex_lock(((CamelSession *) (f))->priv->l))
-#define CAMEL_SESSION_UNLOCK(f, l) \
- (g_mutex_unlock(((CamelSession *) (f))->priv->l))
-
-/* most of this stuff really is private, but the lock can be used by subordinate classes */
-struct _CamelFolderSummaryPrivate {
- GHashTable *filter_charset; /* CamelMimeFilterCharset's indexed by source charset */
-
- struct _CamelMimeFilter *filter_index;
- struct _CamelMimeFilter *filter_64;
- struct _CamelMimeFilter *filter_qp;
- struct _CamelMimeFilter *filter_uu;
- struct _CamelMimeFilter *filter_save;
- struct _CamelMimeFilter *filter_html;
-
- struct _CamelStream *filter_stream;
-
- struct _CamelIndex *index;
-
- GMutex *summary_lock; /* for the summary hashtable/array */
- GMutex *io_lock; /* load/save lock, for access to saved_count, etc */
- GMutex *filter_lock; /* for accessing any of the filtering/indexing stuff, since we share them */
- GMutex *alloc_lock; /* for setting up and using allocators */
- GMutex *ref_lock; /* for reffing/unreffing messageinfo's ALWAYS obtain before summary_lock */
- GHashTable *flag_cache;
-
- gboolean need_preview;
- GHashTable *preview_updates;
-};
-
-#define CAMEL_SUMMARY_LOCK(f, l) \
- (g_mutex_lock(((CamelFolderSummary *) (f))->priv->l))
-#define CAMEL_SUMMARY_UNLOCK(f, l) \
- (g_mutex_unlock(((CamelFolderSummary *) (f))->priv->l))
-
-struct _CamelStoreSummaryPrivate {
- GMutex *summary_lock; /* for the summary hashtable/array */
- GMutex *io_lock; /* load/save lock, for access to saved_count, etc */
- GMutex *alloc_lock; /* for setting up and using allocators */
- GMutex *ref_lock; /* for reffing/unreffing messageinfo's ALWAYS obtain before summary_lock */
-};
-
-#define CAMEL_STORE_SUMMARY_LOCK(f, l) \
- (g_mutex_lock(((CamelStoreSummary *) (f))->priv->l))
-#define CAMEL_STORE_SUMMARY_UNLOCK(f, l) \
- (g_mutex_unlock(((CamelStoreSummary *) (f))->priv->l))
-
-struct _CamelVeeFolderPrivate {
- gboolean destroyed;
- GList *folders; /* lock using subfolder_lock before changing/accessing */
- GList *folders_changed; /* for list of folders that have changed between updates */
-
- GMutex *summary_lock; /* for locking vfolder summary */
- GMutex *subfolder_lock; /* for locking the subfolder list */
- GMutex *changed_lock; /* for locking the folders-changed list */
- gint unread_vfolder;
-};
-
-#define CAMEL_VEE_FOLDER_LOCK(f, l) \
- (g_mutex_lock(((CamelVeeFolder *) (f))->priv->l))
-#define CAMEL_VEE_FOLDER_UNLOCK(f, l) \
- (g_mutex_unlock(((CamelVeeFolder *) (f))->priv->l))
-
-struct _CamelDataWrapperPrivate {
- GStaticMutex stream_lock;
-};
-
-#define CAMEL_DATA_WRAPPER_LOCK(dw, l) \
- (g_static_mutex_lock(&((CamelDataWrapper *) (dw))->priv->l))
-#define CAMEL_DATA_WRAPPER_UNLOCK(dw, l) \
- (g_static_mutex_unlock(&((CamelDataWrapper *) (dw))->priv->l))
-
-/* most of this stuff really is private, but the lock can be used by subordinate classes */
-struct _CamelCertDBPrivate {
- GMutex *db_lock; /* for the db hashtable/array */
- GMutex *io_lock; /* load/save lock, for access to saved_count, etc */
- GMutex *alloc_lock; /* for setting up and using allocators */
- GMutex *ref_lock; /* for reffing/unreffing certs */
-};
-
-#define CAMEL_CERTDB_LOCK(db, l) \
- (g_mutex_lock (((CamelCertDB *) (db))->priv->l))
-#define CAMEL_CERTDB_UNLOCK(db, l) \
- (g_mutex_unlock (((CamelCertDB *) (db))->priv->l))
-
-#ifdef G_OS_WIN32
-#define fsync(fd) _commit(fd)
-
-const gchar *_camel_get_localedir (void) G_GNUC_CONST;
-const gchar *_camel_get_libexecdir (void) G_GNUC_CONST;
-const gchar *_camel_get_providerdir (void) G_GNUC_CONST;
-
-#undef EVOLUTION_LOCALEDIR
-#define EVOLUTION_LOCALEDIR _camel_get_localedir ()
-
-#undef CAMEL_LIBEXECDIR
-#define CAMEL_LIBEXECDIR _camel_get_libexecdir ()
-
-#undef CAMEL_PROVIDERDIR
-#define CAMEL_PROVIDERDIR _camel_get_providerdir ()
-
-#endif /* G_OS_WIN32 */
-
-G_END_DECLS
-
-#endif /* CAMEL_PRIVATE_H */
#include <gmodule.h>
#include "camel-exception.h"
-#include "camel-private.h"
#include "camel-provider.h"
#include "camel-string-utils.h"
#include "camel-vee-store.h"
+#include "camel-win32.h"
/* table of CamelProviderModule's */
static GHashTable *module_table;
#include "camel-exception.h"
#include "camel-operation.h"
-#include "camel-private.h"
#include "camel-service.h"
#include "camel-session.h"
#define d(x)
#define w(x)
+struct _CamelServicePrivate {
+ GStaticRecMutex connect_lock; /* for locking connection operations */
+ GStaticMutex connect_op_lock; /* for locking the connection_op */
+};
+
static CamelObjectClass *camel_service_parent_class = NULL;
static void
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_val_if_fail (class->connect != NULL, FALSE);
- CAMEL_SERVICE_REC_LOCK (service, connect_lock);
+ camel_service_lock (service, CS_REC_CONNECT_LOCK);
if (service->status == CAMEL_SERVICE_CONNECTED) {
- CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
return TRUE;
}
/* Register a separate operation for connecting, so that
* the offline code can cancel it. */
- CAMEL_SERVICE_LOCK (service, connect_op_lock);
+ camel_service_lock (service, CS_CONNECT_OP_LOCK);
service->connect_op = camel_operation_registered ();
if (!service->connect_op) {
service->connect_op = camel_operation_new (NULL, NULL);
unreg = TRUE;
}
connect_op = service->connect_op;
- CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
+ camel_service_unlock (service, CS_CONNECT_OP_LOCK);
service->status = CAMEL_SERVICE_CONNECTING;
ret = class->connect (service, ex);
service->status = ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED;
- CAMEL_SERVICE_LOCK (service, connect_op_lock);
+ camel_service_lock (service, CS_CONNECT_OP_LOCK);
if (connect_op) {
if (unreg && service->connect_op)
camel_operation_unregister (connect_op);
camel_operation_unref (connect_op);
service->connect_op = NULL;
}
- CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
+ camel_service_unlock (service, CS_CONNECT_OP_LOCK);
- CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
return ret;
}
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_val_if_fail (class->disconnect != NULL, FALSE);
- CAMEL_SERVICE_REC_LOCK (service, connect_lock);
+ camel_service_lock (service, CS_REC_CONNECT_LOCK);
if (service->status != CAMEL_SERVICE_DISCONNECTED
&& service->status != CAMEL_SERVICE_DISCONNECTING) {
- CAMEL_SERVICE_LOCK (service, connect_op_lock);
+ camel_service_lock (service, CS_CONNECT_OP_LOCK);
service->connect_op = camel_operation_registered ();
if (!service->connect_op) {
service->connect_op = camel_operation_new (NULL, NULL);
camel_operation_register (service->connect_op);
unreg = TRUE;
}
- CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
+ camel_service_unlock (service, CS_CONNECT_OP_LOCK);
service->status = CAMEL_SERVICE_DISCONNECTING;
res = class->disconnect (service, clean, ex);
service->status = CAMEL_SERVICE_DISCONNECTED;
- CAMEL_SERVICE_LOCK (service, connect_op_lock);
+ camel_service_lock (service, CS_CONNECT_OP_LOCK);
if (unreg)
camel_operation_unregister (service->connect_op);
camel_operation_unref (service->connect_op);
service->connect_op = NULL;
- CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
+ camel_service_unlock (service, CS_CONNECT_OP_LOCK);
}
- CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
- service->status = CAMEL_SERVICE_DISCONNECTED;
+ service->status = CAMEL_SERVICE_DISCONNECTED;
return res;
}
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_if_fail (class->cancel_connect != NULL);
- CAMEL_SERVICE_LOCK (service, connect_op_lock);
+ camel_service_lock (service, CS_CONNECT_OP_LOCK);
if (service->connect_op)
class->cancel_connect (service);
- CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
+ camel_service_unlock (service, CS_CONNECT_OP_LOCK);
}
/**
/* Note that we get the connect lock here, which means the
* callee must not call the connect functions itself. */
- CAMEL_SERVICE_REC_LOCK (service, connect_lock);
+ camel_service_lock (service, CS_REC_CONNECT_LOCK);
ret = class->query_auth_types (service, ex);
- CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
return ret;
}
+
+/**
+ * camel_service_lock:
+ * @service: a #CamelService
+ * @lock: lock type to lock
+ *
+ * Locks #service's #lock. Unlock it with camel_service_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_service_lock (CamelService *service, CamelServiceLock lock)
+{
+ g_return_if_fail (service != NULL);
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
+ g_return_if_fail (service->priv != NULL);
+
+ switch (lock) {
+ case CS_REC_CONNECT_LOCK:
+ g_static_rec_mutex_lock (&service->priv->connect_lock);
+ break;
+ case CS_CONNECT_OP_LOCK:
+ g_static_mutex_lock (&service->priv->connect_op_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_service_unlock:
+ * @service: a #CamelService
+ * @lock: lock type to unlock
+ *
+ * Unlocks #service's #lock, previously locked with camel_service_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_service_unlock (CamelService *service, CamelServiceLock lock)
+{
+ g_return_if_fail (service != NULL);
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
+ g_return_if_fail (service->priv != NULL);
+
+ switch (lock) {
+ case CS_REC_CONNECT_LOCK:
+ g_static_rec_mutex_unlock (&service->priv->connect_lock);
+ break;
+ case CS_CONNECT_OP_LOCK:
+ g_static_mutex_unlock (&service->priv->connect_op_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
CAMEL_SERVICE_DISCONNECTING
} CamelServiceConnectionStatus;
+typedef enum _CamelServiceLock {
+ CS_REC_CONNECT_LOCK,
+ CS_CONNECT_OP_LOCK
+} CamelServiceLock;
+
struct _CamelService {
CamelObject parent;
CamelServicePrivate *priv;
GList * camel_service_query_auth_types (CamelService *service,
CamelException *ex);
+void camel_service_lock (CamelService *service, CamelServiceLock lock);
+void camel_service_unlock (CamelService *service, CamelServiceLock lock);
+
G_END_DECLS
#endif /* CAMEL_SERVICE_H */
#include "camel-exception.h"
#include "camel-file-utils.h"
-#include "camel-private.h"
#include "camel-session.h"
#include "camel-store.h"
#include "camel-string-utils.h"
#define d(x)
+struct _CamelSessionPrivate {
+ GMutex *lock; /* for locking everything basically */
+ GMutex *thread_lock; /* locking threads */
+
+ gint thread_id;
+ GHashTable *thread_active;
+ GThreadPool *thread_pool;
+
+ GHashTable *thread_msg_op;
+ GHashTable *junk_headers;
+
+};
+
static void
cs_thread_status (CamelOperation *op,
const gchar *what,
m->session = camel_object_ref (session);
m->op = camel_operation_new(cs_thread_status, m);
camel_exception_init(&m->ex);
- CAMEL_SESSION_LOCK(session, thread_lock);
+ camel_session_lock (session, CS_THREAD_LOCK);
m->id = session->priv->thread_id++;
g_hash_table_insert(session->priv->thread_active, GINT_TO_POINTER(m->id), m);
- CAMEL_SESSION_UNLOCK(session, thread_lock);
+ camel_session_unlock (session, CS_THREAD_LOCK);
return m;
}
d(printf("free message %p session %p\n", msg, session));
- CAMEL_SESSION_LOCK(session, thread_lock);
+ camel_session_lock (session, CS_THREAD_LOCK);
g_hash_table_remove(session->priv->thread_active, GINT_TO_POINTER(msg->id));
- CAMEL_SESSION_UNLOCK(session, thread_lock);
+ camel_session_unlock (session, CS_THREAD_LOCK);
d(printf("free msg, ops->free = %p\n", msg->ops->free));
GThreadPool *thread_pool;
gint id;
- CAMEL_SESSION_LOCK(session, thread_lock);
+ camel_session_lock (session, CS_THREAD_LOCK);
thread_pool = session->priv->thread_pool;
if (thread_pool == NULL) {
thread_pool = g_thread_pool_new (
session, 1, FALSE, NULL);
session->priv->thread_pool = thread_pool;
}
- CAMEL_SESSION_UNLOCK(session, thread_lock);
+ camel_session_unlock (session, CS_THREAD_LOCK);
id = msg->id;
g_thread_pool_push(thread_pool, msg, NULL);
/* we just busy wait, only other alternative is to setup a reply port? */
do {
- CAMEL_SESSION_LOCK(session, thread_lock);
+ camel_session_lock (session, CS_THREAD_LOCK);
wait = g_hash_table_lookup(session->priv->thread_active, GINT_TO_POINTER(id)) != NULL;
- CAMEL_SESSION_UNLOCK(session, thread_lock);
+ camel_session_unlock (session, CS_THREAD_LOCK);
if (wait) {
g_usleep(20000);
}
class = CAMEL_SESSION_GET_CLASS (session);
g_return_val_if_fail (class->get_service != NULL, NULL);
- CAMEL_SESSION_LOCK (session, lock);
+ camel_session_lock (session, CS_SESSION_LOCK);
service = class->get_service (session, url_string, type, ex);
- CAMEL_SESSION_UNLOCK (session, lock);
+ camel_session_unlock (session, CS_SESSION_LOCK);
return service;
}
class->forward_to (session, folder, message, address, ex);
}
+
+/**
+ * camel_session_lock:
+ * @session: a #CamelSession
+ * @lock: lock type to lock
+ *
+ * Locks #session's #lock. Unlock it with camel_session_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_session_lock (CamelSession *session, CamelSessionLock lock)
+{
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (CAMEL_IS_SESSION (session));
+ g_return_if_fail (session->priv != NULL);
+
+ switch (lock) {
+ case CS_SESSION_LOCK:
+ g_mutex_lock (session->priv->lock);
+ break;
+ case CS_THREAD_LOCK:
+ g_mutex_lock (session->priv->thread_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_session_unlock:
+ * @session: a #CamelSession
+ * @lock: lock type to unlock
+ *
+ * Unlocks #session's #lock, previously locked with camel_session_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_session_unlock (CamelSession *session, CamelSessionLock lock)
+{
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (CAMEL_IS_SESSION (session));
+ g_return_if_fail (session->priv != NULL);
+
+ switch (lock) {
+ case CS_SESSION_LOCK:
+ g_mutex_unlock (session->priv->lock);
+ break;
+ case CS_THREAD_LOCK:
+ g_mutex_unlock (session->priv->thread_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
CAMEL_SESSION_PASSPHRASE = 1 << 4
};
+typedef enum _CamelSessionLock {
+ CS_SESSION_LOCK,
+ CS_THREAD_LOCK
+} CamelSessionLock;
+
struct _CamelSession {
CamelObject parent;
CamelSessionPrivate *priv;
const gchar *address,
CamelException *ex);
+void camel_session_lock (CamelSession *session, CamelSessionLock lock);
+void camel_session_unlock (CamelSession *session, CamelSessionLock lock);
+
G_END_DECLS
#endif /* CAMEL_SESSION_H */
#include <libedataserver/e-memory.h>
#include "camel-file-utils.h"
-#include "camel-private.h"
#include "camel-store-summary.h"
#include "camel-url.h"
+#include "camel-win32.h"
#define d(x)
#define io(x) /* io debug */
+struct _CamelStoreSummaryPrivate {
+ GMutex *summary_lock; /* for the summary hashtable/array */
+ GMutex *io_lock; /* load/save lock, for access to saved_count, etc */
+ GMutex *ref_lock; /* for reffing/unreffing messageinfo's ALWAYS obtain before CSS_SUMMARY_LOCK */
+};
+
/* possible versions, for versioning changes */
#define CAMEL_STORE_SUMMARY_VERSION_0 (1)
#define CAMEL_STORE_SUMMARY_VERSION_2 (2)
g_mutex_free (summary->priv->summary_lock);
g_mutex_free (summary->priv->io_lock);
- g_mutex_free (summary->priv->alloc_lock);
g_mutex_free (summary->priv->ref_lock);
g_free (summary->priv);
switch (type) {
case CAMEL_STORE_INFO_PATH:
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
g_hash_table_remove (summary->folders_path, (gchar *)camel_store_info_path (summary, info));
g_free (info->path);
g_free (info->uri);
info->path = g_strdup (str);
g_hash_table_insert (summary->folders_path, (gchar *)camel_store_info_path (summary, info), info);
summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
break;
case CAMEL_STORE_INFO_NAME:
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
g_hash_table_remove (summary->folders_path, (gchar *)camel_store_info_path (summary, info));
p = strrchr (info->path, '/');
if (p) {
g_free (info->uri);
info->uri = NULL;
g_hash_table_insert (summary->folders_path, (gchar *)camel_store_info_path (summary, info), info);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
break;
case CAMEL_STORE_INFO_URI:
g_warning ("Cannot set store info uri, aborting");
summary->priv->summary_lock = g_mutex_new ();
summary->priv->io_lock = g_mutex_new ();
- summary->priv->alloc_lock = g_mutex_new ();
summary->priv->ref_lock = g_mutex_new ();
}
{
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
g_free (summary->summary_path);
summary->summary_path = g_strdup (name);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
}
/**
{
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
if (summary->uri_base)
camel_url_free (summary->uri_base);
summary->uri_base = camel_url_new_with_base (base, "");
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
}
/**
g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
- CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_REF_LOCK);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
if (i < summary->folders->len)
info = g_ptr_array_index (summary->folders, i);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
if (info)
info->refcount++;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
return info;
}
g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
- CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_REF_LOCK);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
res = g_ptr_array_new ();
g_ptr_array_set_size (res, summary->folders->len);
info->refcount++;
}
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
return res;
}
g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
g_return_val_if_fail (path != NULL, NULL);
- CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_REF_LOCK);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
info = g_hash_table_lookup (summary->folders_path, path);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
if (info)
info->refcount++;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
return info;
}
if (in == NULL)
return -1;
- CAMEL_STORE_SUMMARY_LOCK (summary, io_lock);
+ camel_store_summary_lock (summary, CSS_IO_LOCK);
if (class->summary_header_load (summary, in) == -1)
goto error;
camel_store_summary_add (summary, info);
}
- CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
+ camel_store_summary_unlock (summary, CSS_IO_LOCK);
if (fclose (in) != 0)
return -1;
error:
i = ferror (in);
g_warning ("Cannot load summary file: %s", g_strerror (ferror (in)));
- CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
+ camel_store_summary_unlock (summary, CSS_IO_LOCK);
fclose (in);
summary->flags |= ~CAMEL_STORE_SUMMARY_DIRTY;
errno = i;
io (printf ("saving header\n"));
- CAMEL_STORE_SUMMARY_LOCK (summary, io_lock);
+ camel_store_summary_lock (summary, CSS_IO_LOCK);
if (class->summary_header_save (summary, out) == -1) {
i = errno;
fclose (out);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
+ camel_store_summary_unlock (summary, CSS_IO_LOCK);
errno = i;
return -1;
}
class->store_info_save (summary, out, info);
}
- CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
+ camel_store_summary_unlock (summary, CSS_IO_LOCK);
if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
i = errno;
if (in == NULL)
return -1;
- CAMEL_STORE_SUMMARY_LOCK (summary, io_lock);
+ camel_store_summary_lock (summary, CSS_IO_LOCK);
ret = class->summary_header_load (summary, in);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
+ camel_store_summary_unlock (summary, CSS_IO_LOCK);
fclose (in);
summary->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
return;
}
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
g_ptr_array_add (summary->folders, info);
g_hash_table_insert (summary->folders_path, (gchar *)camel_store_info_path (summary, info), info);
summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
}
/**
g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
g_return_val_if_fail (path != NULL, NULL);
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
info = g_hash_table_lookup (summary->folders_path, path);
if (info != NULL) {
summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
}
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
return info;
}
class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
g_return_if_fail (class->store_info_free != NULL);
- CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
+ camel_store_summary_lock (summary, CSS_REF_LOCK);
info->refcount--;
if (info->refcount > 0) {
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
return;
}
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
class->store_info_free (summary, info);
}
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
g_return_if_fail (info != NULL && info->refcount >= 1);
- CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
+ camel_store_summary_lock (summary, CSS_REF_LOCK);
info->refcount++;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
}
/**
{
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
}
/**
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
if (camel_store_summary_count (summary) == 0) {
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
return;
}
g_hash_table_destroy (summary->folders_path);
summary->folders_path = g_hash_table_new (g_str_hash, g_str_equal);
summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
}
/**
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
g_return_if_fail (info != NULL);
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
g_hash_table_remove (summary->folders_path, camel_store_info_path (summary, info));
g_ptr_array_remove (summary->folders, info);
summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
camel_store_summary_info_free (summary, info);
}
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
g_return_if_fail (path != NULL);
- CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_REF_LOCK);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
if (g_hash_table_lookup_extended (summary->folders_path, path, (gpointer)&oldpath, (gpointer)&oldinfo)) {
/* make sure it doesn't vanish while we're removing it */
oldinfo->refcount++;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
camel_store_summary_remove (summary, oldinfo);
camel_store_summary_info_free (summary, oldinfo);
} else {
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
- CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
+ camel_store_summary_unlock (summary, CSS_REF_LOCK);
}
}
{
g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
- CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+ camel_store_summary_lock (summary, CSS_SUMMARY_LOCK);
if (index < summary->folders->len) {
CamelStoreInfo *info = summary->folders->pdata[index];
g_ptr_array_remove_index (summary->folders, index);
summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
camel_store_summary_info_free (summary, info);
} else {
- CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+ camel_store_summary_unlock (summary, CSS_SUMMARY_LOCK);
}
}
class->store_info_set_string (summary, info, type, value);
}
+
+/**
+ * camel_store_summary_lock:
+ * @summary: a #CamelStoreSummary
+ * @lock: lock type to lock
+ *
+ * Locks #summary's #lock. Unlock it with camel_store_summary_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_store_summary_lock (CamelStoreSummary *summary, CamelStoreSummaryLock lock)
+{
+ g_return_if_fail (summary != NULL);
+ g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+ g_return_if_fail (summary->priv != NULL);
+
+ switch (lock) {
+ case CSS_SUMMARY_LOCK:
+ g_mutex_lock (summary->priv->summary_lock);
+ break;
+ case CSS_IO_LOCK:
+ g_mutex_lock (summary->priv->io_lock);
+ break;
+ case CSS_REF_LOCK:
+ g_mutex_lock (summary->priv->ref_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_store_summary_unlock:
+ * @summary: a #CamelStoreSummary
+ * @lock: lock type to unlock
+ *
+ * Unlocks #summary's #lock, previously locked with camel_store_summary_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_store_summary_unlock (CamelStoreSummary *summary, CamelStoreSummaryLock lock)
+{
+ g_return_if_fail (summary != NULL);
+ g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+ g_return_if_fail (summary->priv != NULL);
+
+ switch (lock) {
+ case CSS_SUMMARY_LOCK:
+ g_mutex_unlock (summary->priv->summary_lock);
+ break;
+ case CSS_IO_LOCK:
+ g_mutex_unlock (summary->priv->io_lock);
+ break;
+ case CSS_REF_LOCK:
+ g_mutex_unlock (summary->priv->ref_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
CAMEL_STORE_SUMMARY_FRAGMENT = 1<<1 /* path name is stored in fragment rather than path */
} CamelStoreSummaryFlags;
+typedef enum _CamelStoreSummaryLock {
+ CSS_SUMMARY_LOCK,
+ CSS_IO_LOCK,
+ CSS_REF_LOCK
+} CamelStoreSummaryLock;
+
struct _CamelStoreSummary {
CamelObject parent;
CamelStoreSummaryPrivate *priv;
#define camel_store_info_uri(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_URI))
#define camel_store_info_name(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_NAME))
+void camel_store_summary_lock (CamelStoreSummary *summary, CamelStoreSummaryLock lock);
+void camel_store_summary_unlock (CamelStoreSummary *summary, CamelStoreSummaryLock lock);
+
G_END_DECLS
#endif /* CAMEL_STORE_SUMMARY_H */
#include "camel-debug.h"
#include "camel-exception.h"
#include "camel-folder.h"
-#include "camel-private.h"
#include "camel-session.h"
#include "camel-store.h"
#include "camel-vtrash-folder.h"
#define d(x)
#define w(x)
+struct _CamelStorePrivate {
+ GStaticRecMutex folder_lock; /* for locking folder operations */
+};
+
static gpointer camel_store_parent_class;
/**
return NULL;
}
- CAMEL_STORE_LOCK(store, folder_lock);
+ camel_store_lock (store, CS_FOLDER_LOCK);
fi = class->create_folder (store, parent_name, folder_name, ex);
- CAMEL_STORE_UNLOCK(store, folder_lock);
+ camel_store_unlock (store, CS_FOLDER_LOCK);
return fi;
}
camel_exception_init(&local);
- CAMEL_STORE_LOCK(store, folder_lock);
+ camel_store_lock (store, CS_FOLDER_LOCK);
class->delete_folder(store, folder_name, &local);
else
camel_exception_xfer(ex, &local);
- CAMEL_STORE_UNLOCK(store, folder_lock);
+ camel_store_unlock (store, CS_FOLDER_LOCK);
}
/**
old_name = g_strdup(old_namein);
oldlen = strlen(old_name);
- CAMEL_STORE_LOCK(store, folder_lock);
+ camel_store_lock (store, CS_FOLDER_LOCK);
/* If the folder is open (or any subfolders of the open folder)
We need to rename them atomically with renaming the actual folder path */
&& strncmp(folder->full_name, old_name, oldlen) == 0
&& folder->full_name[oldlen] == '/')) {
d(printf("Found subfolder of '%s' == '%s'\n", old_name, folder->full_name));
- CAMEL_FOLDER_REC_LOCK(folder, lock);
+ camel_folder_lock (folder, CF_REC_LOCK);
} else {
g_ptr_array_remove_index_fast(folders, i);
i--;
camel_folder_rename(folder, new);
g_free(new);
- CAMEL_FOLDER_REC_UNLOCK(folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
camel_object_unref (folder);
}
/* Failed, just unlock our folders for re-use */
for (i=0;i<folders->len;i++) {
folder = folders->pdata[i];
- CAMEL_FOLDER_REC_UNLOCK(folder, lock);
+ camel_folder_unlock (folder, CF_REC_LOCK);
camel_object_unref (folder);
}
}
}
- CAMEL_STORE_UNLOCK(store, folder_lock);
+ camel_store_unlock (store, CS_FOLDER_LOCK);
g_ptr_array_free(folders, TRUE);
g_free(old_name);
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->get_inbox != NULL, NULL);
- CAMEL_STORE_LOCK (store, folder_lock);
+ camel_store_lock (store, CS_FOLDER_LOCK);
folder = class->get_inbox (store, ex);
- CAMEL_STORE_UNLOCK (store, folder_lock);
+ camel_store_unlock (store, CS_FOLDER_LOCK);
return folder;
}
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->folder_subscribed != NULL, FALSE);
- CAMEL_STORE_LOCK (store, folder_lock);
+ camel_store_lock (store, CS_FOLDER_LOCK);
ret = class->folder_subscribed (store, folder_name);
- CAMEL_STORE_UNLOCK (store, folder_lock);
+ camel_store_unlock (store, CS_FOLDER_LOCK);
return ret;
}
class = CAMEL_STORE_GET_CLASS (store);
g_return_if_fail (class->subscribe_folder != NULL);
- CAMEL_STORE_LOCK (store, folder_lock);
+ camel_store_lock (store, CS_FOLDER_LOCK);
class->subscribe_folder (store, folder_name, ex);
- CAMEL_STORE_UNLOCK (store, folder_lock);
+ camel_store_unlock (store, CS_FOLDER_LOCK);
}
/**
camel_exception_init (&local);
- CAMEL_STORE_LOCK (store, folder_lock);
+ camel_store_lock (store, CS_FOLDER_LOCK);
class->unsubscribe_folder (store, folder_name, ex);
else
camel_exception_xfer (ex, &local);
- CAMEL_STORE_UNLOCK (store, folder_lock);
+ camel_store_unlock (store, CS_FOLDER_LOCK);
}
/**
return class->can_refresh_folder (store, info, ex);
}
+
+/**
+ * camel_store_lock:
+ * @store: a #CamelStore
+ * @lock: lock type to lock
+ *
+ * Locks #store's #lock. Unlock it with camel_store_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_store_lock (CamelStore *store, CamelStoreLock lock)
+{
+ g_return_if_fail (store != NULL);
+ g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_if_fail (store->priv != NULL);
+
+ switch (lock) {
+ case CS_FOLDER_LOCK:
+ g_static_rec_mutex_lock (&store->priv->folder_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_store_unlock:
+ * @store: a #CamelStore
+ * @lock: lock type to unlock
+ *
+ * Unlocks #store's #lock, previously locked with camel_store_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_store_unlock (CamelStore *store, CamelStoreLock lock)
+{
+ g_return_if_fail (store != NULL);
+ g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_if_fail (store->priv != NULL);
+
+ switch (lock) {
+ case CS_FOLDER_LOCK:
+ g_static_rec_mutex_unlock (&store->priv->folder_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
CAMEL_STORE_ARG_FIRST = CAMEL_SERVICE_ARG_FIRST + 100
};
+typedef enum _CamelStoreLock {
+ CS_FOLDER_LOCK
+} CamelStoreLock;
+
typedef struct _CamelFolderInfo {
struct _CamelFolderInfo *next;
struct _CamelFolderInfo *parent;
CamelFolderInfo *info,
CamelException *ex);
+void camel_store_lock (CamelStore *store, CamelStoreLock lock);
+void camel_store_unlock (CamelStore *store, CamelStoreLock lock);
+
G_END_DECLS
#endif /* CAMEL_STORE_H */
#include "camel-file-utils.h"
#include "camel-operation.h"
-#include "camel-private.h"
#include "camel-stream-fs.h"
+#include "camel-win32.h"
struct _CamelStreamFsPrivate {
gint fd; /* file descriptor on the underlying file */
#include "camel-file-utils.h"
#include "camel-operation.h"
-#include "camel-private.h"
#include "camel-stream-vfs.h"
static CamelStreamClass *parent_class = NULL;
#include "camel-certdb.h"
#include "camel-file-utils.h"
#include "camel-operation.h"
-#include "camel-private.h"
#include "camel-session.h"
#include "camel-stream-fs.h"
#include "camel-tcp-stream-ssl.h"
#include "camel-mempool.h"
#include "camel-object.h"
#include "camel-partition-table.h"
-#include "camel-private.h"
#include "camel-text-index.h"
#define w(x)
#include "camel-address.h"
#include "camel-mime-message.h"
-#include "camel-private.h"
#include "camel-transport.h"
+struct _CamelTransportPrivate {
+ GMutex *send_lock; /* for locking send operations */
+};
+
static CamelServiceClass *parent_class = NULL;
static void
class = CAMEL_TRANSPORT_GET_CLASS (transport);
g_return_val_if_fail (class->send_to != NULL, FALSE);
- CAMEL_TRANSPORT_LOCK (transport, send_lock);
+ camel_transport_lock (transport, CT_SEND_LOCK);
sent = class->send_to (transport, message, from, recipients, ex);
- CAMEL_TRANSPORT_UNLOCK (transport, send_lock);
+ camel_transport_unlock (transport, CT_SEND_LOCK);
return sent;
}
+
+/**
+ * camel_transport_lock:
+ * @transport: a #CamelTransport
+ * @lock: lock type to lock
+ *
+ * Locks #transport's #lock. Unlock it with camel_transport_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_transport_lock (CamelTransport *transport, CamelTransportLock lock)
+{
+ g_return_if_fail (transport != NULL);
+ g_return_if_fail (CAMEL_IS_TRANSPORT (transport));
+ g_return_if_fail (transport->priv != NULL);
+
+ switch (lock) {
+ case CT_SEND_LOCK:
+ g_mutex_lock (transport->priv->send_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_transport_unlock:
+ * @transport: a #CamelTransport
+ * @lock: lock type to unlock
+ *
+ * Unlocks #transport's #lock, previously locked with camel_transport_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_transport_unlock (CamelTransport *transport, CamelTransportLock lock)
+{
+ g_return_if_fail (transport != NULL);
+ g_return_if_fail (CAMEL_IS_TRANSPORT (transport));
+ g_return_if_fail (transport->priv != NULL);
+
+ switch (lock) {
+ case CT_SEND_LOCK:
+ g_mutex_unlock (transport->priv->send_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
CAMEL_TRANSPORT_ARG_FIRST = CAMEL_SERVICE_ARG_FIRST + 100
};
+typedef enum _CamelTransportLock {
+ CT_SEND_LOCK
+} CamelTransportLock;
+
struct _CamelTransport {
CamelService parent;
CamelTransportPrivate *priv;
CamelType camel_transport_get_type (void);
+void camel_transport_lock (CamelTransport *transport, CamelTransportLock lock);
+void camel_transport_unlock (CamelTransport *transport, CamelTransportLock lock);
+
G_END_DECLS
#endif /* CAMEL_TRANSPORT_H */
#include <glib/gstdio.h>
#include "camel-file-utils.h"
-#include "camel-private.h"
#include "camel-uid-cache.h"
+#include "camel-win32.h"
struct _uid_state {
gint level;
#include "camel-exception.h"
#include "camel-folder-search.h"
#include "camel-mime-message.h"
-#include "camel-private.h"
#include "camel-session.h"
#include "camel-store.h"
#include "camel-vee-folder.h"
#define d(x)
#define dd(x) (camel_debug ("vfolder")?(x):0)
+struct _CamelVeeFolderPrivate {
+ gboolean destroyed;
+ GList *folders; /* lock using subfolder_lock before changing/accessing */
+ GList *folders_changed; /* for list of folders that have changed between updates */
+
+ GMutex *summary_lock; /* for locking vfolder summary */
+ GMutex *subfolder_lock; /* for locking the subfolder list */
+ GMutex *changed_lock; /* for locking the folders-changed list */
+ gint unread_vfolder;
+};
+
#define _PRIVATE(o) (((CamelVeeFolder *)(o))->priv)
#if 0
return;
}
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
/* for normal vfolders we want only unique ones, for unmatched we want them all recorded */
if (g_list_find (p->folders, sub) == NULL) {
p->folders = g_list_append (
p->folders, camel_object_ref (sub));
- CAMEL_FOLDER_LOCK (vf, change_lock);
+ camel_folder_lock (CAMEL_FOLDER (vf), CF_CHANGE_LOCK);
/* update the freeze state of 'sub' to match our freeze state */
- for (i = 0; i < ((CamelFolder *)vf)->priv->frozen; i++)
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)vf); i++)
camel_folder_freeze (sub);
- CAMEL_FOLDER_UNLOCK (vf, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (vf), CF_CHANGE_LOCK);
}
if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL) {
struct _CamelVeeFolderPrivate *up = _PRIVATE (folder_unmatched);
up->folders = g_list_append (
up->folders, camel_object_ref (sub));
- CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
+ camel_folder_lock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
/* update the freeze state of 'sub' to match Unmatched's freeze state */
- for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)folder_unmatched); i++)
camel_folder_freeze (sub);
- CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
}
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
d (printf ("camel_vee_folder_add_folder (%s, %s)\n", ((CamelFolder *)vf)->full_name, sub->full_name));
gint i;
CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
- CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+ camel_vee_folder_lock (vf, CVF_CHANGED_LOCK);
p->folders_changed = g_list_remove (p->folders_changed, sub);
- CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
+ camel_vee_folder_unlock (vf, CVF_CHANGED_LOCK);
if (g_list_find (p->folders, sub) == NULL) {
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
return;
}
p->folders = g_list_remove (p->folders, sub);
/* undo the freeze state that we have imposed on this source folder */
- CAMEL_FOLDER_LOCK (vf, change_lock);
- for (i = 0; i < ((CamelFolder *)vf)->priv->frozen; i++)
+ camel_folder_lock (CAMEL_FOLDER (vf), CF_CHANGE_LOCK);
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)vf); i++)
camel_folder_thaw (sub);
- CAMEL_FOLDER_UNLOCK (vf, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (vf), CF_CHANGE_LOCK);
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
if (folder_unmatched != NULL) {
struct _CamelVeeFolderPrivate *up = _PRIVATE (folder_unmatched);
- CAMEL_VEE_FOLDER_LOCK (folder_unmatched, subfolder_lock);
+ camel_vee_folder_lock (folder_unmatched, CVF_SUBFOLDER_LOCK);
/* if folder deleted, then blow it away from unmatched always, and remove all refs to it */
if (sub->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED) {
while (g_list_find (up->folders, sub)) {
camel_object_unref (sub);
/* undo the freeze state that Unmatched has imposed on this source folder */
- CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
- for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
+ camel_folder_lock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)folder_unmatched); i++)
camel_folder_thaw (sub);
- CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
}
} else if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
if (g_list_find (up->folders, sub) != NULL) {
camel_object_unref (sub);
/* undo the freeze state that Unmatched has imposed on this source folder */
- CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
- for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
+ camel_folder_lock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)folder_unmatched); i++)
camel_folder_thaw (sub);
- CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
}
}
- CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, subfolder_lock);
+ camel_vee_folder_unlock (folder_unmatched, CVF_SUBFOLDER_LOCK);
}
((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->remove_folder (vf, sub);
CamelFolder *folder;
/* setup a table of all folders we have currently */
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
l = p->folders;
while (l) {
g_hash_table_insert (remove, l->data, l->data);
camel_object_ref (l->data);
l = l->next;
}
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
/* if we already have the folder, ignore it, otherwise add it */
l = folders;
struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
GList *node, *list;
- CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+ camel_vee_folder_lock (vf, CVF_CHANGED_LOCK);
list = p->folders_changed;
p->folders_changed = NULL;
- CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
+ camel_vee_folder_unlock (vf, CVF_CHANGED_LOCK);
node = list;
while (node) {
folder->summary->visible_count = ((CamelVeeSummary *)folder->summary)->fake_visible_count;
((CamelVeeSummary *)folder->summary)->fake_visible_count = 0;
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
node = p->folders;
while (node) {
* actually rebuilding. */
#if 0
if (node == NULL) {
- CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+ camel_vee_folder_lock (vf, CVF_CHANGED_LOCK);
g_list_free (p->folders_changed);
p->folders_changed = NULL;
- CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
+ camel_vee_folder_unlock (vf, CVF_CHANGED_LOCK);
}
#endif
if (vf->priv->unread_vfolder == 1) {
g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
g_slist_free (del);
}
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
camel_object_state_write (vf);
}
struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
GHashTable *searched = g_hash_table_new (NULL, NULL);
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
expr = g_strdup_printf ("(and %s %s)", vf->expression ? vf->expression : "", expression);
node = p->folders;
}
g_free (expr);
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
g_hash_table_destroy (searched);
g_ptr_array_free (folder_uids, TRUE);
/* NB: this is never called on UNMTACHED */
- CAMEL_VEE_FOLDER_LOCK (folder, subfolder_lock);
+ camel_vee_folder_lock (CAMEL_VEE_FOLDER (folder), CVF_SUBFOLDER_LOCK);
while (p->folders) {
CamelFolder *f = p->folders->data;
camel_object_ref (f);
- CAMEL_VEE_FOLDER_UNLOCK (folder, subfolder_lock);
+ camel_vee_folder_unlock (CAMEL_VEE_FOLDER (folder), CVF_SUBFOLDER_LOCK);
camel_vee_folder_remove_folder ((CamelVeeFolder *)folder, f);
camel_object_unref (f);
- CAMEL_VEE_FOLDER_LOCK (folder, subfolder_lock);
+ camel_vee_folder_lock (CAMEL_VEE_FOLDER (folder), CVF_SUBFOLDER_LOCK);
}
- CAMEL_VEE_FOLDER_UNLOCK (folder, subfolder_lock);
+ camel_vee_folder_unlock (CAMEL_VEE_FOLDER (folder), CVF_SUBFOLDER_LOCK);
((CamelFolderClass *)camel_vee_folder_parent)->delete (folder);
((CamelVeeFolder *)folder)->deleted = TRUE;
if ((source->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
killun = TRUE;
- CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
+ camel_vee_folder_lock (vf, CVF_SUMMARY_LOCK);
if (folder_unmatched != NULL) {
/* check if this folder is still to be part of unmatched */
if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !killun) {
- CAMEL_VEE_FOLDER_LOCK (folder_unmatched, subfolder_lock);
+ camel_vee_folder_lock (folder_unmatched, CVF_SUBFOLDER_LOCK);
still = g_list_find (_PRIVATE (folder_unmatched)->folders, source) != NULL;
- CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, subfolder_lock);
+ camel_vee_folder_unlock (folder_unmatched, CVF_SUBFOLDER_LOCK);
camel_vee_folder_hash_folder (source, hash);
}
- CAMEL_VEE_FOLDER_LOCK (folder_unmatched, summary_lock);
+ camel_vee_folder_lock (folder_unmatched, CVF_SUMMARY_LOCK);
/* See if we just blow all uid's from this folder away from unmatched, regardless */
if (killun) {
folder_unmatched->changes = camel_folder_change_info_new ();
}
- CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, summary_lock);
+ camel_vee_folder_unlock (folder_unmatched, CVF_SUMMARY_LOCK);
}
if (camel_folder_change_info_changed (vf->changes)) {
vf->changes = camel_folder_change_info_new ();
}
- CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
+ camel_vee_folder_unlock (vf, CVF_SUMMARY_LOCK);
if (unmatched_changes) {
camel_object_trigger_event ((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
u.rebuilt = rebuilded;
u.correlating = correlating;
- CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
+ camel_vee_folder_lock (vf, CVF_SUMMARY_LOCK);
/* we build 2 hash tables, one for all uid's not matched, the
other for all matched uid's, we just ref the real memory */
}
if (folder_unmatched != NULL)
- CAMEL_VEE_FOLDER_LOCK (folder_unmatched, summary_lock);
+ camel_vee_folder_lock (folder_unmatched, CVF_SUMMARY_LOCK);
/* scan, looking for "old" uid's to be removed. "old" uid's
are those that are from previous added sources (not in
folder_unmatched->changes = camel_folder_change_info_new ();
}
- CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, summary_lock);
+ camel_vee_folder_unlock (folder_unmatched, CVF_SUMMARY_LOCK);
}
if (camel_folder_change_info_changed (vf->changes)) {
vf->changes = camel_folder_change_info_new ();
}
- CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
+ camel_vee_folder_unlock (vf, CVF_SUMMARY_LOCK);
/* Del the unwanted things from the summary, we don't hold any locks now. */
if (del_list) {
gboolean correlating = expression_is_correlating (vf->expression);
/* Check the folder hasn't beem removed while we weren't watching */
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
if (g_list_find (_PRIVATE (vf)->folders, sub) == NULL) {
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
return;
}
camel_exception_clear (&ex);
}
- CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
+ camel_vee_folder_lock (vf, CVF_SUMMARY_LOCK);
if (folder_unmatched != NULL)
- CAMEL_VEE_FOLDER_LOCK (folder_unmatched, summary_lock);
+ camel_vee_folder_lock (folder_unmatched, CVF_SUMMARY_LOCK);
if (matches_changed || matches_added || changes->uid_removed->len||present)
camel_db_begin_transaction (folder->parent_store->cdb_w, NULL);
folder_unmatched->changes = camel_folder_change_info_new ();
}
- CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, summary_lock);
+ camel_vee_folder_unlock (folder_unmatched, CVF_SUMMARY_LOCK);
}
if (camel_folder_change_info_changed (vf->changes)) {
if (matches_changed || matches_added || changes->uid_removed->len || present)
camel_db_end_transaction (folder->parent_store->cdb_w, NULL);
- CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
+ camel_vee_folder_unlock (vf, CVF_SUMMARY_LOCK);
/* Cleanup stuff on our folder */
if (matches_added)
if (matches_changed)
camel_folder_search_free (sub, matches_changed);
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
/* cleanup the rest */
if (newchanged)
* rather be safe than sorry.)
*/
if ((vf_changes && (vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0) || correlating) {
- CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+ camel_vee_folder_lock (vf, CVF_CHANGED_LOCK);
if (g_list_find (vf->priv->folders_changed, sub) == NULL)
vf->priv->folders_changed = g_list_prepend (vf->priv->folders_changed, sub);
- CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
+ camel_vee_folder_unlock (vf, CVF_CHANGED_LOCK);
}
if (vf_changes) {
GHashTable *unmatched_uids = vf->parent_vee_store ? vf->parent_vee_store->unmatched_uids : NULL;
CamelFolderSummary *ssummary = sub->summary;
- CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
+ camel_vee_folder_lock (vf, CVF_SUMMARY_LOCK);
count = camel_folder_summary_count (((CamelFolder *)vf)->summary);
for (i=0;i<count;i++) {
vf->changes = camel_folder_change_info_new ();
}
- CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
+ camel_vee_folder_unlock (vf, CVF_SUMMARY_LOCK);
if (changes) {
camel_object_trigger_event ((CamelObject *)vf, "folder_changed", changes);
struct _CamelVeeFolderPrivate *p = _PRIVATE (vfolder);
GList *node;
- CAMEL_VEE_FOLDER_LOCK (vfolder, subfolder_lock);
+ camel_vee_folder_lock (vfolder, CVF_SUBFOLDER_LOCK);
node = p->folders;
while (node) {
node = node->next;
}
- CAMEL_VEE_FOLDER_UNLOCK (vfolder, subfolder_lock);
+ camel_vee_folder_unlock (vfolder, CVF_SUBFOLDER_LOCK);
/* call parent implementation */
CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->freeze (folder);
struct _CamelVeeFolderPrivate *p = _PRIVATE (vfolder);
GList *node;
- CAMEL_VEE_FOLDER_LOCK (vfolder, subfolder_lock);
+ camel_vee_folder_lock (vfolder, CVF_SUBFOLDER_LOCK);
node = p->folders;
while (node) {
node = node->next;
}
- CAMEL_VEE_FOLDER_UNLOCK (vfolder, subfolder_lock);
+ camel_vee_folder_unlock (vfolder, CVF_SUBFOLDER_LOCK);
/* call parent implementation */
CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->thaw (folder);
GList *node;
CamelException ex = CAMEL_EXCEPTION_INITIALISER;
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
/* no change, do nothing */
if ((vf->expression && query && strcmp (vf->expression, query) == 0)
|| (vf->expression == NULL && query == NULL)) {
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
return;
}
camel_exception_clear (&ex);
- CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+ camel_vee_folder_lock (vf, CVF_CHANGED_LOCK);
g_list_free (p->folders_changed);
p->folders_changed = NULL;
- CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
+ camel_vee_folder_unlock (vf, CVF_CHANGED_LOCK);
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
}
/* This entire code will be useless, since we sync the counts always. */
gint i;
CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
- CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+ camel_vee_folder_lock (vf, CVF_SUBFOLDER_LOCK);
- CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+ camel_vee_folder_lock (vf, CVF_CHANGED_LOCK);
p->folders_changed = g_list_remove (p->folders_changed, sub);
- CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
+ camel_vee_folder_unlock (vf, CVF_CHANGED_LOCK);
if (g_list_find (p->folders, sub) == NULL) {
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
return;
}
p->folders = g_list_remove (p->folders, sub);
/* undo the freeze state that we have imposed on this source folder */
- CAMEL_FOLDER_LOCK (vf, change_lock);
- for (i = 0; i < ((CamelFolder *)vf)->priv->frozen; i++)
+ camel_folder_lock (CAMEL_FOLDER (vf), CF_CHANGE_LOCK);
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)vf); i++)
camel_folder_thaw (sub);
- CAMEL_FOLDER_UNLOCK (vf, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (vf), CF_CHANGE_LOCK);
- CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
+ camel_vee_folder_unlock (vf, CVF_SUBFOLDER_LOCK);
if (folder_unmatched != NULL) {
struct _CamelVeeFolderPrivate *up = _PRIVATE (folder_unmatched);
- CAMEL_VEE_FOLDER_LOCK (folder_unmatched, subfolder_lock);
+ camel_vee_folder_lock (folder_unmatched, CVF_SUBFOLDER_LOCK);
/* if folder deleted, then blow it away from unmatched always, and remove all refs to it */
if (sub->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED) {
while (g_list_find (up->folders, sub)) {
camel_object_unref (sub);
/* undo the freeze state that Unmatched has imposed on this source folder */
- CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
- for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
+ camel_folder_lock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)folder_unmatched); i++)
camel_folder_thaw (sub);
- CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
}
} else if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
if (g_list_find (up->folders, sub) != NULL) {
camel_object_unref (sub);
/* undo the freeze state that Unmatched has imposed on this source folder */
- CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
- for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
+ camel_folder_lock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
+ for (i = 0; i < camel_folder_get_frozen_count ((CamelFolder *)folder_unmatched); i++)
camel_folder_thaw (sub);
- CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
+ camel_folder_unlock (CAMEL_FOLDER (folder_unmatched), CF_CHANGE_LOCK);
}
}
- CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, subfolder_lock);
+ camel_vee_folder_unlock (folder_unmatched, CVF_SUBFOLDER_LOCK);
}
if (CAMEL_IS_VEE_FOLDER (sub))
g_hash_table_destroy (vf->hashes);
g_free (p);
}
+
+/* FIXME: This shouldn't be needed */
+gint
+camel_vee_folder_get_unread_vfolder (CamelVeeFolder *folder)
+{
+ g_return_val_if_fail (folder != NULL, 0);
+ g_return_val_if_fail (CAMEL_IS_VEE_FOLDER (folder), 0);
+
+ return folder->priv->unread_vfolder;
+}
+
+/* FIXME: This shouldn't be needed */
+void
+camel_vee_folder_set_unread_vfolder (CamelVeeFolder *folder, gint unread_vfolder)
+{
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (CAMEL_IS_VEE_FOLDER (folder));
+
+ folder->priv->unread_vfolder = unread_vfolder;
+}
+
+/**
+ * camel_vee_folder_lock:
+ * @folder: a #CamelVeeFolder
+ * @lock: lock type to lock
+ *
+ * Locks #folder's #lock. Unlock it with camel_vee_folder_unlock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_vee_folder_lock (CamelVeeFolder *folder, CamelVeeFolderLock lock)
+{
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (CAMEL_IS_VEE_FOLDER (folder));
+ g_return_if_fail (folder->priv != NULL);
+
+ switch (lock) {
+ case CVF_SUMMARY_LOCK:
+ g_mutex_lock (folder->priv->summary_lock);
+ break;
+ case CVF_SUBFOLDER_LOCK:
+ g_mutex_lock (folder->priv->subfolder_lock);
+ break;
+ case CVF_CHANGED_LOCK:
+ g_mutex_lock (folder->priv->changed_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
+
+/**
+ * camel_vee_folder_unlock:
+ * @folder: a #CamelVeeFolder
+ * @lock: lock type to unlock
+ *
+ * Unlocks #folder's #lock, previously locked with camel_vee_folder_lock().
+ *
+ * Since: 2.31.1
+ **/
+void
+camel_vee_folder_unlock (CamelVeeFolder *folder, CamelVeeFolderLock lock)
+{
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (CAMEL_IS_VEE_FOLDER (folder));
+ g_return_if_fail (folder->priv != NULL);
+
+ switch (lock) {
+ case CVF_SUMMARY_LOCK:
+ g_mutex_unlock (folder->priv->summary_lock);
+ break;
+ case CVF_SUBFOLDER_LOCK:
+ g_mutex_unlock (folder->priv->subfolder_lock);
+ break;
+ case CVF_CHANGED_LOCK:
+ g_mutex_unlock (folder->priv->changed_lock);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+}
typedef struct _CamelVeeFolderClass CamelVeeFolderClass;
typedef struct _CamelVeeFolderPrivate CamelVeeFolderPrivate;
+typedef enum _CamelVeeFolderLock {
+ CVF_SUMMARY_LOCK,
+ CVF_SUBFOLDER_LOCK,
+ CVF_CHANGED_LOCK
+} CamelVeeFolderLock;
+
struct _CamelVeeFolder {
CamelFolder parent;
CamelVeeFolderPrivate *priv;
void camel_vee_folder_hash_folder (CamelFolder *folder, gchar buffer[8]);
void camel_vee_folder_sync_headers (CamelFolder *vf, CamelException *ex);
+gint camel_vee_folder_get_unread_vfolder (CamelVeeFolder *folder);
+void camel_vee_folder_set_unread_vfolder (CamelVeeFolder *folder, gint unread_vfolder);
+
+void camel_vee_folder_lock (CamelVeeFolder *folder, CamelVeeFolderLock lock);
+void camel_vee_folder_unlock (CamelVeeFolder *folder, CamelVeeFolderLock lock);
+
G_END_DECLS
#endif /* CAMEL_VEE_FOLDER_H */
#include "camel-db.h"
#include "camel-exception.h"
-#include "camel-private.h"
#include "camel-session.h"
#include "camel-vee-folder.h"
#include "camel-vee-store.h"
#include "camel-vee-summary.h"
#include "camel-vee-folder.h"
#include "camel-vee-store.h"
-#include "camel-private.h"
#include "camel-string-utils.h"
#define d(x)
if (camel_debug("vfolderexp"))
printf("Expression for vfolder '%s' is '%s'\n", mi->summary->folder->full_name, g_strescape(vf->expression, ""));
- if (vf->priv->unread_vfolder == -1)
+ if (camel_vee_folder_get_unread_vfolder (vf) == -1)
camel_vee_summary_load_check_unread_vfolder (CAMEL_VEE_SUMMARY (mi->summary));
- if (vf->priv->unread_vfolder == 1)
+ if (camel_vee_folder_get_unread_vfolder (vf) == 1)
hacked_unread_folder = TRUE;
if (mi->uid) {
hacked_unread_folder = TRUE;
if (hacked_unread_folder)
- vf->priv->unread_vfolder = 1;
+ camel_vee_folder_set_unread_vfolder (vf, 1);
else
- vf->priv->unread_vfolder = 0;
+ camel_vee_folder_set_unread_vfolder (vf, 0);
}
static gboolean
if (camel_debug("vfolderexp"))
printf("Expression for vfolder '%s' is '%s'\n", mi->summary->folder->full_name, g_strescape(vf->expression, ""));
- if (vf->priv->unread_vfolder == -1)
+ if (camel_vee_folder_get_unread_vfolder (vf) == -1)
camel_vee_summary_load_check_unread_vfolder (CAMEL_VEE_SUMMARY (mi->summary));
- if (vf->priv->unread_vfolder == 1)
+ if (camel_vee_folder_get_unread_vfolder (vf) == 1)
hacked_unread_folder = TRUE;
if (mi->uid) {
/* FIXME[disk-summary] too bad design. Need to peek it from cfs
* instead of hacking ugly like this */
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
info = g_hash_table_lookup (s->loaded_infos, uid);
if (info)
camel_message_info_ref (info);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
if (!info) {
CamelVeeMessageInfo *vinfo;
memcpy(vuid, hash, 8);
strcpy(vuid+8, uid);
- CAMEL_SUMMARY_LOCK(s, summary_lock);
+ camel_folder_summary_lock (CAMEL_FOLDER_SUMMARY (s), CFS_SUMMARY_LOCK);
mi = (CamelVeeMessageInfo *) g_hash_table_lookup(((CamelFolderSummary *) s)->loaded_infos, vuid);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_unlock (CAMEL_FOLDER_SUMMARY (s), CFS_SUMMARY_LOCK);
if (mi) {
/* Possible that the entry is loaded, see if it has the summary */
#include "camel-db.h"
#include "camel-exception.h"
#include "camel-mime-message.h"
-#include "camel-private.h"
#include "camel-store.h"
#include "camel-vee-store.h"
#include "camel-vtrash-folder.h"
G_UNLOCK (mutex);
}
-#include "camel-private.h" /* For prototypes */
+#include "camel-win32.h" /* For prototypes */
#define GETTER(varbl) \
const gchar * \
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * camel-win32.h: Private info for win32.
+ *
+ * Authors: Michael Zucchi <notzed@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_WIN32_H
+#define CAMEL_WIN32_H
+
+/* need a way to configure and save this data, if this header is to
+ be installed. For now, dont install it */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+
+#ifdef G_OS_WIN32
+
+G_BEGIN_DECLS
+
+#define fsync(fd) _commit(fd)
+
+const gchar *_camel_get_localedir (void) G_GNUC_CONST;
+const gchar *_camel_get_libexecdir (void) G_GNUC_CONST;
+const gchar *_camel_get_providerdir (void) G_GNUC_CONST;
+
+#undef EVOLUTION_LOCALEDIR
+#define EVOLUTION_LOCALEDIR _camel_get_localedir ()
+
+#undef CAMEL_LIBEXECDIR
+#define CAMEL_LIBEXECDIR _camel_get_libexecdir ()
+
+#undef CAMEL_PROVIDERDIR
+#define CAMEL_PROVIDERDIR _camel_get_providerdir ()
+
+G_END_DECLS
+
+#endif /* G_OS_WIN32 */
+
+#endif /* CAMEL_WIN32_H */
#include "camel-certdb.h"
#include "camel-debug.h"
#include "camel-provider.h"
-#include "camel-private.h"
+#include "camel-win32.h"
#ifdef HAVE_NSS
/* To protect NSS initialization and shutdown. This prevents
#include <e-gw-connection.h>
#include <e-gw-item.h>
-#include <camel/camel-private.h>
-
#include "camel-groupwise-folder.h"
#include "camel-groupwise-journal.h"
#include "camel-groupwise-private.h"
return;
}
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
if (!camel_groupwise_store_connected (gw_store, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
camel_exception_clear (ex);
return;
}
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
cnc = cnc_lookup (priv);
container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name);
}
if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
/*
Sync up the READ changes before deleting the message.
status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
if (status == E_GW_CONNECTION_STATUS_OK) {
gchar *uid;
while (deleted_items) {
read_items = g_list_concat (read_items, deleted_read_items);
if (read_items) {
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_mark_read (cnc, read_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_mark_read (cnc, read_items);
sync_flags (folder, read_items);
g_list_free (read_items);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
}
if (deleted_items) {
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
if (!strcmp (folder->full_name, "Trash")) {
status = e_gw_connection_purge_selected_items (cnc, deleted_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
}
}
g_list_free (deleted_items);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
}
if (unread_items) {
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_mark_unread (cnc, unread_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_mark_unread (cnc, unread_items);
sync_flags (folder, unread_items);
g_list_free (unread_items);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
}
if (expunge) {
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_purge_deleted_items (cnc);
if (status == E_GW_CONNECTION_STATUS_OK) {
g_message ("Purged deleted items in %s", folder->name);
}
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
}
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
groupwise_sync_summary (folder, ex);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
camel_folder_change_info_free (changes);
In case if user went offline, don't do anything.
m->cnc would have become invalid, as the store disconnect unrefs it.
*/
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
goto end1;
while (!done) {
if (camel_application_is_exiting) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return;
}
}
e_gw_connection_destroy_cursor (m->cnc, m->container_id, cursor);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
/* Take out only the first part in the list until the @ since it is guaranteed
to be unique only until that symbol */
return;
end1:
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
camel_operation_end (NULL);
if (items_full_list) {
g_list_foreach (items_full_list, (GFunc)g_free, NULL);
gw_folder->need_refresh = TRUE;
}
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
if (!camel_groupwise_store_connected (gw_store, ex))
goto end1;
update_summary_string (folder, new_sync_time, ex);
}
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
is_locked = FALSE;
/*
g_free (container_id);
end1:
if (is_locked)
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return;
}
if (item_list) {
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
gw_update_cache (folder, item_list, ex, TRUE);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
g_list_foreach (item_list, (GFunc)g_free, NULL);
g_list_free (item_list);
}
cnc = cnc_lookup (priv);
- CAMEL_SERVICE_REC_LOCK (folder->parent_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
/*Get the container id*/
container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name);
if (appended_uid)
*appended_uid = NULL;
- CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
return;
}
if (appended_uid)
*appended_uid = NULL;
- CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
return;
}
if (appended_uid)
*appended_uid = g_strdup (id);
g_free (id);
- CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
}
/* A function to compare uids, inspired by strcmp .
source_container_id = NULL;
dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination->full_name);
- CAMEL_SERVICE_REC_LOCK (source->parent_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (source->parent_store), CS_REC_CONNECT_LOCK);
/* check for offline operation */
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
CamelGroupwiseJournal *journal = (CamelGroupwiseJournal *) ((CamelGroupwiseFolder *) destination)->journal;
}
}
- CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (source->parent_store), CS_REC_CONNECT_LOCK);
return;
}
*/
wrapper = g_list_prepend (wrapper, (gchar *)uid);
- CAMEL_SERVICE_REC_LOCK (source->parent_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (source->parent_store), CS_REC_CONNECT_LOCK);
e_gw_connection_mark_read (cnc, wrapper);
- CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (source->parent_store), CS_REC_CONNECT_LOCK);
g_list_free (wrapper);
wrapper = NULL;
}
if (unset_flags.bits & CAMEL_MESSAGE_SEEN) {
wrapper = g_list_prepend (wrapper, (gchar *)uid);
- CAMEL_SERVICE_REC_LOCK (source->parent_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (source->parent_store), CS_REC_CONNECT_LOCK);
e_gw_connection_mark_unread (cnc, wrapper);
- CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (source->parent_store), CS_REC_CONNECT_LOCK);
g_list_free (wrapper);
wrapper = NULL;
}
groupwise_store_set_current_folder (gw_store, source);
- CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (source->parent_store), CS_REC_CONNECT_LOCK);
}
static void
return;
if (!strcmp (folder->full_name, "Trash")) {
- CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_purge_deleted_items (cnc);
if (status == E_GW_CONNECTION_STATUS_OK) {
camel_folder_freeze (folder);
camel_folder_thaw (folder);
} else
g_warning ("Could not Empty Trash\n");
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
return;
}
}
if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
/* Read the FIXME below */
- CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
if (status == E_GW_CONNECTION_STATUS_OK) {
gchar *uid;
while (deleted_items) {
if (deleted_items) {
/* FIXME: Put these in a function and reuse it inside the above loop, here and in groupwise_sync*/
- CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
if (status == E_GW_CONNECTION_STATUS_OK) {
gchar *uid;
while (deleted_items) {
#include <string.h>
#include <unistd.h>
-#include <camel/camel-private.h>
-
#include "camel-groupwise-store-summary.h"
#define CAMEL_GW_STORE_SUMMARY_VERSION (0)
switch (type) {
case CAMEL_STORE_INFO_LAST:
d(printf("Set full name %s -> %s\n", isi->full_name, str));
- CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+ camel_store_summary_lock (s, CSS_SUMMARY_LOCK);
g_free(isi->full_name);
isi->full_name = g_strdup(str);
- CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+ camel_store_summary_unlock (s, CSS_SUMMARY_LOCK);
break;
default:
camel_groupwise_store_summary_parent->store_info_set_string(s, mi, type, str);
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
-#include <camel/camel-private.h>
-
#include "camel-groupwise-folder.h"
#include "camel-groupwise-store-summary.h"
#include "camel-groupwise-store.h"
groupwise_store_set_current_folder (CamelGroupwiseStore *groupwise_store, CamelFolder *folder)
{
- CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
if (groupwise_store->current_folder) {
camel_object_unref (groupwise_store->current_folder);
if (folder)
groupwise_store->current_folder = camel_object_ref (folder);
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
}
static gboolean
camel_service_construct (service, service->session, service->provider, service->url, ex);
}
- CAMEL_SERVICE_REC_LOCK (service, connect_lock);
+ camel_service_lock (service, CS_REC_CONNECT_LOCK);
if (priv->cnc) {
- CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
return TRUE;
}
if (!check_for_connection (service, ex) || !groupwise_auth_loop (service, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
camel_store_summary_save ((CamelStoreSummary *) store->summary);
- CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
if (E_IS_GW_CONNECTION (priv->cnc)) {
return TRUE;
}
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
if (clean) {
- CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
+ camel_service_lock (service, CS_REC_CONNECT_LOCK);
if (groupwise_store->priv && groupwise_store->priv->cnc) {
g_object_unref (groupwise_store->priv->cnc);
groupwise_store->priv->cnc = NULL;
groupwise_store_set_current_folder (groupwise_store, NULL);
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
}
/* groupwise_disconnect_cleanup (service, clean, ex); */
camel_exception_clear (ex);
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
groupwise_store_set_current_folder (gw_store, NULL);
if (!camel_groupwise_store_connected (gw_store, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return NULL;
}
if (!E_IS_GW_CONNECTION( priv->cnc)) {
if (!groupwise_connect (CAMEL_SERVICE(store), ex)) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return NULL;
}
}
g_free(storage_path);
folder = camel_gw_folder_new (store, folder_name, folder_dir, ex);
if (!folder) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
g_free (folder_dir);
g_free (container_id);
&cursor);
if (status != E_GW_CONNECTION_STATUS_OK) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
g_free (container_id);
return NULL;
}
all_ok = FALSE;
break;
/*
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_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);
groupwise_store_set_current_folder (gw_store, folder);
g_free (container_id);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return folder;
}
camel_exception_clear (ex);
- CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
if (!camel_groupwise_store_connected (gw_store, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return;
}
if (!E_IS_GW_CONNECTION( priv->cnc)) {
if (!groupwise_connect (CAMEL_SERVICE((CamelStore*)gw_store), ex)) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return;
}
}
NULL,
&cursor);
if (status != E_GW_CONNECTION_STATUS_OK) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
g_free (container_id);
return;
}
cursor, FALSE,
CURSOR_ITEM_LIMIT, position, &list);
if (status != E_GW_CONNECTION_STATUS_OK) {
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_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, _("Authentication failed"));
groupwise_store_set_current_folder (gw_store, NULL);
g_free (container_id);
- CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (gw_store), CS_REC_CONNECT_LOCK);
return;
}
struct _store_refresh_msg *m = (struct _store_refresh_msg *)msg;
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE(m->store);
- CAMEL_SERVICE_REC_LOCK (m->store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (m->store), CS_REC_CONNECT_LOCK);
if (!camel_groupwise_store_connected (groupwise_store, &m->ex))
goto done;
/*Get the folder list and save it here*/
goto done;
camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
done:
- CAMEL_SERVICE_REC_UNLOCK (m->store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (m->store), CS_REC_CONNECT_LOCK);
}
static void
&& camel_service_connect ((CamelService *)store, ex)))
goto offline;
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
groupwise_folders_sync (groupwise_store, ex);
if (camel_exception_is_set (ex)) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return NULL;
}
camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
offline:
info = groupwise_get_folder_info_offline (store, top, flags, ex);
parent_id = "";
/* TODO: check for offlining*/
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0, JUNK_PERSISTENCE);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0, JUNK_PERSISTENCE);
g_hash_table_insert (priv->parent_hash, g_strdup(child_container_id), g_strdup(parent_id));
camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", root);
}
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return root;
}
return NULL;
}
}
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
status = e_gw_connection_create_folder(priv->cnc,parent_id,folder_name, &child_container_id);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_create_folder(priv->cnc,parent_id,folder_name, &child_container_id);
camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", root);
}
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return root;
}
EGwConnectionStatus status;
const gchar * container;
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!camel_groupwise_store_connected (groupwise_store, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
g_hash_table_remove (priv->parent_hash, container);
}
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
static void
return;
}
- CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
if (!camel_groupwise_store_connected (groupwise_store, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
return;
}
{
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename GroupWise folder '%s' to '%s'"),
old_name, new_name);
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
return;
}
g_free (oldpath);
g_free (newpath);
- CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (groupwise_store), CS_REC_CONNECT_LOCK);
}
gchar *
#include <glib/gi18n-lib.h>
-#include <camel/camel-private.h>
-
#include "camel-imap-command.h"
#include "camel-imap-folder.h"
#include "camel-imap-store-summary.h"
#include "camel-imap-store.h"
#include "camel-imap-utils.h"
+extern gint camel_verbose_debug;
+
static gboolean imap_command_start (CamelImapStore *store, CamelFolder *folder,
const gchar *cmd, CamelException *ex);
static CamelImapResponse *imap_read_response (CamelImapStore *store,
va_list ap;
gchar *cmd;
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (fmt) {
va_start (ap, fmt);
if (!imap_command_start (store, folder, cmd, ex)) {
g_free (cmd);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return NULL;
}
g_free (cmd);
cmd = imap_command_strdup_vprintf (store, fmt, ap);
va_end (ap);
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
ok = imap_command_start (store, folder, cmd, ex);
g_free (cmd);
if (!ok)
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return ok;
}
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
g_strerror (errno));
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return NULL;
}
gchar *respbuf;
if (camel_imap_store_readline (store, &respbuf, ex) < 0) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return CAMEL_IMAP_RESPONSE_ERROR;
}
if (type == CAMEL_IMAP_RESPONSE_ERROR ||
type == CAMEL_IMAP_RESPONSE_TAGGED)
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return type;
}
* we're still locked. This lock is owned by response
* and gets unlocked when response is freed.
*/
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
response = g_new0 (CamelImapResponse, 1);
/*FIXME if (store->current_folder && camel_disco_store_status (CAMEL_DISCO_STORE (store)) != CAMEL_DISCO_STORE_RESYNCING) {
}
g_free (response);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
/**
#include <libedataserver/e-time-utils.h>
-#include <camel/camel-private.h>
-
#include "camel-imap-command.h"
#include "camel-imap-folder.h"
#include "camel-imap-journal.h"
* Also, if this is the INBOX, some servers (cryus) wont tell
* us with a NOOP of new messages, so force a reselect which
* should do it. */
- CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
if (camel_application_is_exiting || !camel_imap_store_connected(imap_store, ex))
goto done;
imap_rescan (folder, camel_folder_summary_count (folder->summary), ex);
}
done:
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
camel_folder_summary_save_to_db (folder->summary, ex);
camel_store_summary_save ((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary);
if (summary_got == 0 && summary_len == 0) {
camel_operation_end (NULL);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
g_free(new);
return;
}
g_free (new);
if (type != CAMEL_IMAP_RESPONSE_ERROR && type != CAMEL_IMAP_RESPONSE_TAGGED)
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
}
camel_exception_init (&local_ex);
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
/* write local changes first */
replay_offline_journal (store, imap_folder, ex);
g_ptr_array_free (matches, TRUE);
/* We unlock here so that other threads can have a chance to grab the connect_lock */
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
/* check for an exception */
if (camel_exception_is_set (&local_ex)) {
}
/* Re-lock the connect_lock */
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
if (expunge)
/* Save the summary */
imap_sync_offline (folder, ex);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
static gint
gint i;
GSList *list=NULL;
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if ((store->capabilities & IMAP_CAPABILITY_UIDPLUS) == 0) {
((CamelFolderClass *)CAMEL_OBJECT_GET_CLASS(folder))->sync(folder, 0, ex);
if (camel_exception_is_set(ex)) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
}
if (response)
camel_imap_response_free (store, response);
if (camel_exception_is_set (ex)) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
g_free (set);
return;
}
g_free (set);
}
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
changes = camel_folder_change_info_new ();
for (i = 0; i < uids->len; i++) {
* marked un-deleted.
*/
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
((CamelFolderClass *)CAMEL_OBJECT_GET_CLASS(folder))->sync(folder, 0, ex);
if (camel_exception_is_set(ex)) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
response = camel_imap_command (store, folder, ex, "UID SEARCH DELETED");
if (!response) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
result = camel_imap_response_extract (store, response, "SEARCH", ex);
if (!result) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
if (!response) {
g_ptr_array_free (keep_uids, TRUE);
g_ptr_array_free (mark_uids, TRUE);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
camel_imap_response_free (store, response);
if (!response) {
g_ptr_array_free (keep_uids, TRUE);
g_ptr_array_free (mark_uids, TRUE);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return;
}
camel_imap_response_free (store, response);
/* now we can free this, now that we're done with keep_uids */
g_free (result);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
static gchar *
camel_imap_response_free (store, response);
/* Make sure a "folder_changed" is emitted. */
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (store->current_folder != folder ||
camel_folder_summary_count (folder->summary) == count)
imap_refresh_info (folder, ex);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
void
* deadlock in the case where we're simultaneously also trying
* to copy messages in the other direction from another thread.
*/
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
CAMEL_IMAP_FOLDER_REC_LOCK (source, cache_lock);
CAMEL_IMAP_FOLDER_REC_LOCK (dest, cache_lock);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (transferred_uids) {
*transferred_uids = g_ptr_array_new ();
gchar *body, *found_uid;
gint i;
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected(store, ex)) {
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("This message is not currently available"));
goto fail;
}
response = camel_imap_command (store, folder, ex, "UID FETCH %s BODY", uid);
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (response) {
for (i = 0, body = NULL; i < response->untagged->len; i++) {
if (type == CAMEL_IMAP_RESPONSE_ERROR || camel_application_is_exiting) {
if (type != CAMEL_IMAP_RESPONSE_ERROR && type != CAMEL_IMAP_RESPONSE_TAGGED)
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
goto lose;
}
camel_operation_end (NULL);
if (type != CAMEL_IMAP_RESPONSE_ERROR && type != CAMEL_IMAP_RESPONSE_TAGGED)
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
goto lose;
}
camel_exception_clear(ex);
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_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,
_("This message is not currently available"));
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return NULL;
}
uid, section_text);
}
/* We won't need the connect_lock again after this. */
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!response) {
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
if (CAMEL_OFFLINE_STORE (imap_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return NULL;
- CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected (imap_store, NULL))
goto done;
g_free (folder_name);
}
done:
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
return res;
}
#include <string.h>
#include <unistd.h>
-#include <camel/camel-private.h>
-
#include "camel-imap-store-summary.h"
#define d(x)
switch (type) {
case CAMEL_IMAP_STORE_INFO_FULL_NAME:
d(printf("Set full name %s -> %s\n", isi->full_name, str));
- CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+ camel_store_summary_lock (s, CSS_SUMMARY_LOCK);
g_free(isi->full_name);
isi->full_name = g_strdup(str);
- CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+ camel_store_summary_unlock (s, CSS_SUMMARY_LOCK);
break;
default:
camel_imap_store_summary_parent->store_info_set_string(s, mi, type, str);
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
-#include <camel/camel-private.h>
-
#include "camel-imap-command.h"
#include "camel-imap-folder.h"
#include "camel-imap-message-cache.h"
#define strtok_r(s,sep,lasts) (*(lasts)=strtok((s),(sep)))
#endif
+extern gint camel_verbose_debug;
+
static CamelOfflineStoreClass *parent_class = NULL;
static gchar imap_tag_prefix = 'A';
return NULL;
}
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
connected = store->istream != NULL && store->connected;
if (!connected)
connected = connect_to_server_wrapper (service, ex);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!connected)
return NULL;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!connect_to_server_wrapper (service, ex) ||
!imap_auth_loop (service, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
/* save any changes we had */
camel_store_summary_save((CamelStoreSummary *)store->summary);
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (camel_exception_is_set (ex))
camel_service_disconnect (service, TRUE, NULL);
CamelImapResponse *response;
CamelFolder *current_folder;
- CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected(imap_store, ex))
goto done;
camel_imap_response_free (imap_store, response);
}
done:
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
}
static CamelFolder *
camel_exception_clear(ex);
- CAMEL_SERVICE_REC_LOCK(imap_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected(imap_store, ex)) {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
return NULL;
}
const gchar *c;
if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL) {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
return NULL;
}
camel_exception_clear (ex);
if (!(flags & CAMEL_STORE_FOLDER_CREATE)) {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("No such folder %s"), folder_name);
return NULL;
c++;
if (*c != '\0') {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
_("The folder name \"%s\" is invalid because it contains the character \"%c\""),
folder_name, *c);
gint i;
if (!(response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %G", parent_real))) {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
g_free (parent_name);
g_free (parent_real);
return NULL;
if (messages > 0) {
camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
_("The parent folder is not allowed to contain subfolders"));
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
g_free (parent_name);
g_free (parent_real);
return NULL;
camel_exception_init (&lex);
delete_folder (store, parent_name, &lex);
if (camel_exception_is_set (&lex)) {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
camel_exception_xfer (ex, &lex);
g_free (parent_name);
g_free (parent_real);
g_free (name);
if (!response) {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
g_free (parent_name);
g_free (parent_real);
return NULL;
}
g_free(folder_real);
if (!response) {
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
return NULL;
}
} else if (flags & CAMEL_STORE_FOLDER_EXCL) {
camel_imap_response_free_without_processing (imap_store, response);
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
return NULL;
}
}
camel_imap_response_free_without_processing (imap_store, response);
- CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
return new_folder;
}
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
- CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected(imap_store, ex))
goto fail;
imap_forget_folder (imap_store, folder_name, ex);
}
fail:
- CAMEL_SERVICE_REC_UNLOCK(imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
}
static void
CamelImapResponse *response;
gchar *oldpath, *newpath, *storage_path;
- CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected(imap_store, ex))
goto fail;
g_free (newpath);
fail:
imap_store->renaming = FALSE;
- CAMEL_SERVICE_REC_UNLOCK(imap_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (imap_store), CS_REC_CONNECT_LOCK);
}
static CamelFolderInfo *
struct _refresh_msg *m = (struct _refresh_msg *)msg;
CamelImapStore *store = (CamelImapStore *)m->store;
- CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected (store, &m->ex))
goto done;
get_folders_sync (store, NULL, &m->ex);
camel_store_summary_save ((CamelStoreSummary *)store->summary);
done:
- CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
static void
now = time(NULL);
ref = now > imap_store->refresh_stamp+60*60*1;
if (ref) {
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
ref = now > imap_store->refresh_stamp+60*60*1;
if (ref) {
struct _refresh_msg *m;
camel_exception_init(&m->ex);
camel_session_thread_queue(((CamelService *)store)->session, &m->msg, 0);
}
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
} else {
gchar *pattern;
gint i;
CamelImapStoreNamespace *ns;
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected((CamelImapStore *)store, ex))
goto fail;
get_folders_sync(imap_store, pattern, ex);
}
camel_store_summary_save((CamelStoreSummary *)imap_store->summary);
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
tree = get_folder_info_offline(store, top, flags, ex);
return tree;
fail:
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return NULL;
}
CamelFolderInfo *fi;
CamelStoreInfo *si;
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected (imap_store, ex))
goto done;
camel_object_trigger_event (CAMEL_OBJECT (store), "folder_subscribed", fi);
camel_folder_info_free (fi);
done:
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
static void
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (!camel_imap_store_connected (imap_store, ex))
goto done;
imap_folder_effectively_unsubscribed (imap_store, folder_name, ex);
done:
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
}
#if 0
#include <prerr.h>
#endif
-#include <camel/camel-private.h>
-
#include "camel-imapx-utils.h"
#include "camel-imapx-exception.h"
#include "camel-imapx-stream.h"
{
gboolean ret = FALSE;
- CAMEL_SERVICE_REC_LOCK (is->store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (is->store), CS_REC_CONNECT_LOCK);
if (connect) {
if (is->state == IMAPX_AUTHENTICATED || is->state == IMAPX_SELECTED) {
ret = TRUE;
}
exit:
- CAMEL_SERVICE_REC_UNLOCK (is->store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (is->store), CS_REC_CONNECT_LOCK);
return ret;
}
#include <string.h>
#include <unistd.h>
-#include <camel/camel-private.h>
-
#include "camel-imapx-utils.h"
#include "camel-imapx-store-summary.h"
switch (type) {
case CAMEL_IMAPX_STORE_INFO_FULL_NAME:
d(printf("Set full name %s -> %s\n", isi->full_name, str));
- CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+ camel_store_summary_lock (s, CSS_SUMMARY_LOCK);
g_free(isi->full_name);
isi->full_name = g_strdup(str);
- CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+ camel_store_summary_unlock (s, CSS_SUMMARY_LOCK);
break;
default:
camel_imapx_store_summary_parent->store_info_set_string(s, mi, type, str);
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
-#include <camel/camel-private.h>
-
#include "camel-imapx-store.h"
#include "camel-imapx-folder.h"
#include "camel-imapx-exception.h"
return NULL;
}
- CAMEL_SERVICE_REC_LOCK (istore, connect_lock);
+ camel_service_lock (service, CS_REC_CONNECT_LOCK);
if (istore->server == NULL)
istore->server = camel_imapx_server_new((CamelStore *)istore, service->url);
connected = istore->server->stream != NULL;
if (!connected)
connected = imapx_connect_to_server (istore->server, ex);
- CAMEL_SERVICE_REC_UNLOCK (istore, connect_lock);
+ camel_service_unlock (service, CS_REC_CONNECT_LOCK);
if (!connected)
return NULL;
-/* ANSI-C code produced by gperf version 3.0.2 */
+/* ANSI-C code produced by gperf version 3.0.3 */
/* Command-line: /usr/bin/gperf -H imapx_hash -N imapx_tokenise_struct -L ANSI-C -o -t -k'1,$' --output-file=camel-imapx-tokenise.h camel-imapx-tokens.txt */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
#ifdef __GNUC__
__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
#endif
struct _imapx_keyword *
imapx_tokenise_struct (register const char *str, register unsigned int len)
#include <posix1_lim.h>
#endif
-#include <camel/camel-private.h>
-
#include "camel-local-folder.h"
#include "camel-local-private.h"
#include "camel-local-store.h"
#include <glib/gi18n-lib.h>
-#include <camel/camel-private.h>
-
#include "camel-mh-summary.h"
#include "camel-local-private.h"
g_hash_table_destroy(left);
/* sort the summary based on message number (uid), since the directory order is not useful */
- CAMEL_SUMMARY_LOCK(s, summary_lock);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+ camel_folder_summary_lock (s, CFS_SUMMARY_LOCK);
+ camel_folder_summary_unlock (s, CFS_SUMMARY_LOCK);
return 0;
}
#include "camel-spool-summary.h"
#include "camel-local-private.h"
+#include "camel-win32.h"
#define io(x)
#define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
#include <glib/gi18n-lib.h>
-#include <camel/camel-private.h>
-
#include "camel-nntp-folder.h"
#include "camel-nntp-private.h"
#include "camel-nntp-store.h"
nntp_store = (CamelNNTPStore *) folder->parent_store;
nntp_folder = (CamelNNTPFolder *) folder;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
camel_nntp_command(nntp_store, ex, nntp_folder, &line, NULL);
nntp_folder->changes = camel_folder_change_info_new();
}
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
if (changes) {
camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
static void
nntp_folder_sync_online (CamelFolder *folder, CamelException *ex)
{
- CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
camel_folder_summary_save_to_db (folder->summary, ex);
- CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
}
static void
nntp_folder_sync_offline (CamelFolder *folder, CamelException *ex)
{
- CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
camel_folder_summary_save_to_db (folder->summary, ex);
- CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (folder->parent_store), CS_REC_CONNECT_LOCK);
}
static gboolean
}
*msgid++ = 0;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
stream = nntp_folder_download_message ((CamelNNTPFolder *) disco_folder, article, msgid, ex);
if (stream)
camel_object_unref (stream);
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
}
static CamelMimeMessage *
}
*msgid++ = 0;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
/* Lookup in cache, NEWS is global messageid's so use a global cache path */
stream = camel_data_cache_get (nntp_store->cache, "cache", msgid, NULL);
changes = NULL;
}
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
if (changes) {
camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
struct _camel_header_raw *header, *savedhdrs, *n, *tail;
gchar *group, *line;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
/* send 'POST' command */
ret = camel_nntp_command (nntp_store, ex, NULL, &line, "post");
else if (ret != -1)
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Posting failed: %s"), line);
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
return;
}
g_free(group);
header->next = savedhdrs;
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
return;
}
#include <string.h>
#include <unistd.h>
-#include <camel/camel-private.h>
-
#include "camel-nntp-store-summary.h"
#define d(x)
switch (type) {
case CAMEL_NNTP_STORE_INFO_FULL_NAME:
d(printf("Set full name %s -> %s\n", nsi->full_name, str));
- CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+ camel_store_summary_lock (s, CSS_SUMMARY_LOCK);
g_free (nsi->full_name);
nsi->full_name = g_strdup (str);
- CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+ camel_store_summary_unlock (s, CSS_SUMMARY_LOCK);
break;
default:
camel_nntp_store_summary_parent->store_info_set_string (s, mi, type, str);
#include <glib/gi18n-lib.h>
-#include <camel/camel-private.h>
-
#include "camel-nntp-summary.h"
#include "camel-nntp-store.h"
#include "camel-nntp-store-summary.h"
guint len;
gchar *path;
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (ssl_mode != MODE_CLEAR) {
#ifdef HAVE_SSL
store->current_folder = NULL;
fail:
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return retval;
}
CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
gchar *line;
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (clean) {
camel_nntp_raw_command (store, ex, &line, "quit");
}
if (!service_class->disconnect (service, clean, ex)) {
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return FALSE;
}
g_free(store->current_folder);
store->current_folder = NULL;
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
return TRUE;
}
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
CamelFolder *folder;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
folder = camel_nntp_folder_new(store, folder_name, ex);
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
return folder;
}
if (folder) {
CamelFolderChangeInfo *changes = NULL;
- CAMEL_SERVICE_REC_LOCK(store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
camel_nntp_command(store, ex, folder, &line, NULL);
if (camel_folder_change_info_changed(folder->changes)) {
changes = folder->changes;
folder->changes = camel_folder_change_info_new();
}
- CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (store), CS_REC_CONNECT_LOCK);
if (changes) {
camel_object_trigger_event((CamelObject *) folder, "folder_changed", changes);
camel_folder_change_info_free(changes);
gint ret = -1;
CamelFolderInfo *fi = NULL;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
if (top == NULL)
top = "";
fi = nntp_store_get_cached_folder_info (nntp_store, top, flags, ex);
error:
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
return fi;
}
CamelStoreInfo *si;
CamelFolderInfo *fi;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
si = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
if (!si) {
fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN;
camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
camel_object_trigger_event ((CamelObject *) nntp_store, "folder_subscribed", fi);
camel_folder_info_free (fi);
return;
}
}
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
}
static void
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
CamelFolderInfo *fi;
CamelStoreInfo *fitem;
- CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
+ camel_service_lock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
fitem = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
fi = nntp_folder_info_from_store_info (nntp_store, nntp_store->do_short_folder_notation, fitem);
camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
camel_object_trigger_event ((CamelObject *) nntp_store, "folder_unsubscribed", fi);
camel_folder_info_free (fi);
return;
}
}
- CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
+ camel_service_unlock (CAMEL_SERVICE (nntp_store), CS_REC_CONNECT_LOCK);
}
/* stubs for various folder operations we're not implementing */
#include <glib.h>
#include <glib/gi18n-lib.h>
-#include <camel/camel-private.h>
-
#include "camel-pop3-engine.h"
#include "camel-pop3-stream.h"
extern CamelServiceAuthType camel_pop3_password_authtype;
extern CamelServiceAuthType camel_pop3_apop_authtype;
+extern gint camel_verbose_debug;
#define dd(x) (camel_verbose_debug?(x):0)
static void get_capabilities(CamelPOP3Engine *pe);
#include <glib/gi18n-lib.h>
-#include <camel/camel-private.h>
-
#include "camel-smtp-transport.h"
#ifdef G_OS_WIN32
#undef MIN
#undef MAX
+extern gint camel_verbose_debug;
+
#define d(x) (camel_verbose_debug ? (x) : 0)
/* Specified in RFC 821 */