[evolution-data-server/camel-gobject] Break CamelFolderSummary API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/camel-gobject] Break CamelFolderSummary API.
- Date: Sun, 29 Nov 2009 18:38:44 +0000 (UTC)
commit 68e6917bf2971e46873464d66920fb80cd2509ee
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Nov 29 12:17:22 2009 -0500
Break CamelFolderSummary API.
Move message_info_size and content_info_size into the class structure.
They are class-specific, not instance-specific.
camel/camel-digest-summary.c | 10 ++-
camel/camel-folder-summary.c | 87 +++++---------------
camel/camel-folder-summary.h | 13 +--
camel/camel-session.c | 6 +-
camel/camel-vee-summary.c | 13 +--
.../providers/groupwise/camel-groupwise-summary.c | 6 +-
camel/providers/imap/camel-imap-summary.c | 14 +---
camel/providers/local/camel-local-summary.c | 6 +-
camel/providers/local/camel-maildir-summary.c | 5 +-
camel/providers/local/camel-mbox-summary.c | 6 +-
camel/providers/nntp/camel-nntp-summary.c | 6 +-
11 files changed, 49 insertions(+), 123 deletions(-)
---
diff --git a/camel/camel-digest-summary.c b/camel/camel-digest-summary.c
index 5be8335..e94cb47 100644
--- a/camel/camel-digest-summary.c
+++ b/camel/camel-digest-summary.c
@@ -33,7 +33,13 @@ static gpointer parent_class;
static void
digest_summary_class_init (CamelDigestSummaryClass *class)
{
+ CamelFolderSummaryClass *folder_summary_class;
+
parent_class = g_type_class_peek_parent (class);
+
+ folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelMessageInfo);
+ folder_summary_class->content_info_size = sizeof (CamelMessageContentInfo);
}
static void
@@ -43,10 +49,6 @@ digest_summary_init (CamelDigestSummary *digest_summary)
summary = CAMEL_FOLDER_SUMMARY (digest_summary);
- /* subclasses need to set the right instance data sizes */
- summary->message_info_size = sizeof (CamelMessageInfo);
- summary->content_info_size = sizeof (CamelMessageContentInfo);
-
/* and a unique file version */
summary->version += CAMEL_DIGEST_SUMMARY_VERSION;
}
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index b733036..5c7fd29 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -37,8 +37,6 @@
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
-#include <libedataserver/e-memory.h>
-
#include "camel-db.h"
#include "camel-debug.h"
#include "camel-file-utils.h"
@@ -66,10 +64,6 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), CAMEL_TYPE_FOLDER_SUMMARY, CamelFolderSummaryPrivate))
-/* To switch between e-memchunk and g-alloc */
-#define ALWAYS_ALLOC 1
-#define USE_GSLICE 1
-
/* Make 5 minutes as default cache drop */
#define SUMMARY_CACHE_DROP 300
#define dd(x) if (camel_debug("sync")) x
@@ -218,13 +212,6 @@ folder_summary_finalize (GObject *object)
g_free(summary->summary_path);
-#ifndef ALWAYS_ALLOC
- if (summary->message_info_chunks)
- e_memchunk_destroy(summary->message_info_chunks);
- if (summary->content_info_chunks)
- e_memchunk_destroy(summary->content_info_chunks);
-#endif
-
/* Freeing memory occupied by meta-summary-header */
g_free(summary->meta_summary->path);
g_free(summary->meta_summary);
@@ -872,6 +859,9 @@ folder_summary_class_init (CamelFolderSummaryClass *class)
object_class->dispose = folder_summary_dispose;
object_class->finalize = folder_summary_finalize;
+ class->message_info_size = sizeof (CamelMessageInfoBase);
+ class->content_info_size = sizeof (CamelMessageContentInfo);
+
class->summary_header_load = summary_header_load;
class->summary_header_save = summary_header_save;
@@ -928,8 +918,6 @@ folder_summary_init (CamelFolderSummary *summary)
summary->priv->filter_charset = g_hash_table_new (
camel_strcase_hash, camel_strcase_equal);
- summary->message_info_size = sizeof(CamelMessageInfoBase);
- summary->content_info_size = sizeof(CamelMessageContentInfo);
summary->priv->flag_cache = g_hash_table_new (g_str_hash, g_str_equal);
summary->message_info_chunks = NULL;
@@ -3680,23 +3668,15 @@ summary_format_string (GQueue *header_queue,
CamelMessageContentInfo *
camel_folder_summary_content_info_new(CamelFolderSummary *s)
{
+ CamelFolderSummaryClass *class;
CamelMessageContentInfo *ci;
+ class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+
CAMEL_SUMMARY_LOCK(s, alloc_lock);
-#ifndef ALWAYS_ALLOC
- if (s->content_info_chunks == NULL)
- s->content_info_chunks = e_memchunk_new(32, s->content_info_size);
- ci = e_memchunk_alloc(s->content_info_chunks);
-#else
-#ifndef USE_GSLICE
- ci = g_malloc (s->content_info_size);
-#else
- ci = g_slice_alloc (s->content_info_size);
-#endif
-#endif
+ ci = g_slice_alloc0 (class->content_info_size);
CAMEL_SUMMARY_UNLOCK(s, alloc_lock);
- memset(ci, 0, s->content_info_size);
return ci;
}
@@ -3966,6 +3946,7 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *info)
static void
message_info_free(CamelFolderSummary *s, CamelMessageInfo *info)
{
+ CamelFolderSummaryClass *class;
CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
if (mi->uid) {
@@ -3987,22 +3968,11 @@ message_info_free(CamelFolderSummary *s, CamelMessageInfo *info)
if (mi->headers)
camel_header_param_list_free (mi->headers);
- if (s)
-#ifndef ALWAYS_ALLOC
- e_memchunk_free(s->message_info_chunks, mi);
-#else
-#ifndef USE_GSLICE
- g_free(mi);
-#else
- g_slice_free1 (s->message_info_size, mi);
-#endif
-#endif
- else
-#ifndef USE_GSLICE
- g_free(mi);
-#else
+ if (s) {
+ class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+ g_slice_free1 (class->message_info_size, mi);
+ } else
g_slice_free (CamelMessageInfoBase, mi);
-#endif
}
static CamelMessageContentInfo *
@@ -4122,19 +4092,15 @@ content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentInfo *ci)
static void
content_info_free(CamelFolderSummary *s, CamelMessageContentInfo *ci)
{
+ CamelFolderSummaryClass *class;
+
+ class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+
camel_content_type_unref(ci->type);
g_free(ci->id);
g_free(ci->description);
g_free(ci->encoding);
-#ifndef ALWAYS_ALLOC
- e_memchunk_free(s->content_info_chunks, ci);
-#else
-#ifndef USE_GSLICE
- g_free(ci);
-#else
- g_slice_free1 (s->content_info_size, ci);
-#endif
-#endif
+ g_slice_free1 (class->content_info_size, ci);
}
static gchar *
@@ -4799,29 +4765,16 @@ camel_system_flag_get (guint32 flags, const gchar *name)
gpointer
camel_message_info_new (CamelFolderSummary *s)
{
+ CamelFolderSummaryClass *class;
CamelMessageInfo *info;
if (s) {
CAMEL_SUMMARY_LOCK(s, alloc_lock);
-#ifndef ALWAYS_ALLOC
- if (s->message_info_chunks == NULL)
- s->message_info_chunks = e_memchunk_new(32, s->message_info_size);
- info = e_memchunk_alloc0(s->message_info_chunks);
-#else
-#ifndef USE_GSLICE
- info = g_malloc0(s->message_info_size);
-#else
- info = g_slice_alloc0 (s->message_info_size);
-#endif
-#endif
+ class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+ info = g_slice_alloc0 (class->message_info_size);
CAMEL_SUMMARY_UNLOCK(s, alloc_lock);
} else {
-#ifndef USE_GSLICE
- info = g_malloc0(sizeof(CamelMessageInfoBase));
-#else
info = g_slice_alloc0 (sizeof(CamelMessageInfoBase));
-#endif
-
}
info->refcount = 1;
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index e35a046..6aacb81 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -245,10 +245,6 @@ struct _CamelFolderSummary {
guint32 junk_not_deleted_count;
guint32 visible_count;
- /* sizes of memory objects */
- guint32 message_info_size;
- guint32 content_info_size;
-
/* memory allocators (setup automatically) */
struct _EMemChunk *message_info_chunks;
struct _EMemChunk *content_info_chunks;
@@ -256,11 +252,6 @@ struct _CamelFolderSummary {
gchar *summary_path;
gboolean build_content; /* do we try and parse/index the content, or not? */
-#if 0 /* Deprecated */
- GPtrArray *messages; /* CamelMessageInfo's */
- GHashTable *messages_uid; /* CamelMessageInfo's by uid */
-#endif
-
/* New members to replace the above depreacted members */
GPtrArray *uids;
GHashTable *loaded_infos;
@@ -283,6 +274,10 @@ struct _CamelFIRecord;
struct _CamelFolderSummaryClass {
CamelObjectClass parent_class;
+ /* sizes of memory objects */
+ gsize message_info_size;
+ gsize content_info_size;
+
/* load/save the global info */
gint (*summary_header_load)(CamelFolderSummary *, FILE *);
gint (*summary_header_save)(CamelFolderSummary *, FILE *);
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 226dd0a..ca20dc9 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -554,11 +554,11 @@ camel_session_forget_password (CamelSession *session,
{
CamelSessionClass *class;
- g_return_if_fail (CAMEL_IS_SESSION (session));
- g_return_if_fail (item != NULL);
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE);
+ g_return_val_if_fail (item != NULL, FALSE);
class = CAMEL_SESSION_GET_CLASS (session);
- g_return_if_fail (class->forget_password);
+ g_return_val_if_fail (class->forget_password, FALSE);
return class->forget_password (session, service, domain, item, error);
}
diff --git a/camel/camel-vee-summary.c b/camel/camel-vee-summary.c
index 141d974..fac3801 100644
--- a/camel/camel-vee-summary.c
+++ b/camel/camel-vee-summary.c
@@ -390,6 +390,8 @@ vee_summary_class_init (CamelVeeSummaryClass *class)
parent_class = g_type_class_peek_parent (class);
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelVeeMessageInfo);
+ folder_summary_class->content_info_size = 0;
folder_summary_class->message_info_clone = vee_message_info_clone;
folder_summary_class->message_info_free = vee_message_info_free;
folder_summary_class->info_ptr = vee_info_ptr;
@@ -403,15 +405,6 @@ vee_summary_class_init (CamelVeeSummaryClass *class)
folder_summary_class->message_info_from_uid = message_info_from_uid;
}
-static void
-vee_summary_init (CamelVeeSummary *vee_summary)
-{
- CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (vee_summary);
-
- summary->message_info_size = sizeof (CamelVeeMessageInfo);
- summary->content_info_size = 0;
-}
-
GType
camel_vee_summary_get_type (void)
{
@@ -424,7 +417,7 @@ camel_vee_summary_get_type (void)
sizeof (CamelVeeSummaryClass),
(GClassInitFunc) vee_summary_class_init,
sizeof (CamelVeeSummary),
- (GInstanceInitFunc) vee_summary_init,
+ (GInstanceInitFunc) NULL,
0);
return type;
diff --git a/camel/providers/groupwise/camel-groupwise-summary.c b/camel/providers/groupwise/camel-groupwise-summary.c
index 29a006b..72fa651 100644
--- a/camel/providers/groupwise/camel-groupwise-summary.c
+++ b/camel/providers/groupwise/camel-groupwise-summary.c
@@ -88,6 +88,8 @@ groupwise_summary_class_init (CamelGroupwiseSummaryClass *class)
parent_class = g_type_class_peek_parent (class);
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelGroupwiseMessageInfo);
+ folder_summary_class->content_info_size = sizeof (CamelGroupwiseMessageContentInfo);
folder_summary_class->message_info_clone = gw_message_info_clone;
folder_summary_class->summary_header_load = gw_summary_header_load;
folder_summary_class->summary_header_save = gw_summary_header_save;
@@ -109,10 +111,6 @@ groupwise_summary_init (CamelGroupwiseSummary *gw_summary)
{
CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (gw_summary);
- /* subclasses need to set the right instance data sizes */
- summary->message_info_size = sizeof (CamelGroupwiseMessageInfo);
- summary->content_info_size = sizeof (CamelGroupwiseMessageContentInfo);
-
/* Meta-summary - Overriding UID len */
summary->meta_summary->uid_len = 2048;
}
diff --git a/camel/providers/imap/camel-imap-summary.c b/camel/providers/imap/camel-imap-summary.c
index 6382fa5..9ee535c 100644
--- a/camel/providers/imap/camel-imap-summary.c
+++ b/camel/providers/imap/camel-imap-summary.c
@@ -82,6 +82,8 @@ imap_summary_class_init (CamelImapSummaryClass *class)
parent_class = g_type_class_peek_parent (class);
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelImapMessageInfo);
+ folder_summary_class->content_info_size = sizeof (CamelImapMessageContentInfo);
folder_summary_class->message_info_clone = imap_message_info_clone;
folder_summary_class->summary_header_load = summary_header_load;
folder_summary_class->summary_header_save = summary_header_save;
@@ -98,16 +100,6 @@ imap_summary_class_init (CamelImapSummaryClass *class)
folder_summary_class->info_set_user_flag = info_set_user_flag;
}
-static void
-imap_summary_init (CamelImapSummary *imap_summary)
-{
- CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (imap_summary);
-
- /* subclasses need to set the right instance data sizes */
- summary->message_info_size = sizeof (CamelImapMessageInfo);
- summary->content_info_size = sizeof (CamelImapMessageContentInfo);
-}
-
GType
camel_imap_summary_get_type (void)
{
@@ -120,7 +112,7 @@ camel_imap_summary_get_type (void)
sizeof (CamelImapSummaryClass),
(GClassInitFunc) imap_summary_class_init,
sizeof (CamelImapSummary),
- (GInstanceInitFunc) imap_summary_init,
+ (GInstanceInitFunc) NULL,
0);
return type;
diff --git a/camel/providers/local/camel-local-summary.c b/camel/providers/local/camel-local-summary.c
index 20cd62b..1553021 100644
--- a/camel/providers/local/camel-local-summary.c
+++ b/camel/providers/local/camel-local-summary.c
@@ -104,6 +104,8 @@ local_summary_class_init (CamelLocalSummaryClass *class)
object_class->finalize = local_summary_finalize;
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelLocalMessageInfo);
+ folder_summary_class->content_info_size = sizeof (CamelMessageContentInfo);
folder_summary_class->summary_header_load = summary_header_load;
folder_summary_class->summary_header_save = summary_header_save;
folder_summary_class->summary_header_from_db = summary_header_from_db;
@@ -126,10 +128,6 @@ local_summary_init (CamelLocalSummary *local_summary)
folder_summary = CAMEL_FOLDER_SUMMARY (local_summary);
- /* subclasses need to set the right instance data sizes */
- folder_summary->message_info_size = sizeof (CamelLocalMessageInfo);
- folder_summary->content_info_size = sizeof (CamelMessageContentInfo);
-
/* and a unique file version */
folder_summary->version += CAMEL_LOCAL_SUMMARY_VERSION;
}
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c
index 1da4a5a..e05dd75 100644
--- a/camel/providers/local/camel-maildir-summary.c
+++ b/camel/providers/local/camel-maildir-summary.c
@@ -99,6 +99,8 @@ maildir_summary_class_init (CamelMaildirSummaryClass *class)
object_class->finalize = maildir_summary_finalize;
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelMaildirMessageInfo);
+ folder_summary_class->content_info_size = sizeof (CamelMaildirMessageContentInfo);
folder_summary_class->message_info_load = message_info_load;
folder_summary_class->message_info_new_from_header = message_info_new_from_header;
folder_summary_class->message_info_free = message_info_free;
@@ -127,9 +129,6 @@ maildir_summary_init (CamelMaildirSummary *maildir_summary)
/* set unique file version */
folder_summary->version += CAMEL_MAILDIR_SUMMARY_VERSION;
- folder_summary->message_info_size = sizeof (CamelMaildirMessageInfo);
- folder_summary->content_info_size = sizeof (CamelMaildirMessageContentInfo);
-
if (gethostname(hostname, 256) == 0) {
maildir_summary->priv->hostname = g_strdup(hostname);
} else {
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 1ef6c1a..99badf0 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -131,6 +131,8 @@ mbox_summary_class_init (CamelMboxSummaryClass *class)
parent_class = g_type_class_peek_parent (class);
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelMboxMessageInfo);
+ folder_summary_class->content_info_size = sizeof (CamelMboxMessageContentInfo);
folder_summary_class->summary_header_load = summary_header_load;
folder_summary_class->summary_header_save = summary_header_save;
folder_summary_class->summary_header_from_db = summary_header_from_db;
@@ -168,10 +170,6 @@ mbox_summary_init (CamelMboxSummary *mbox_summary)
folder_summary = CAMEL_FOLDER_SUMMARY (mbox_summary);
- /* subclasses need to set the right instance data sizes */
- folder_summary->message_info_size = sizeof (CamelMboxMessageInfo);
- folder_summary->content_info_size = sizeof (CamelMboxMessageContentInfo);
-
/* and a unique file version */
folder_summary->version += CAMEL_MBOX_SUMMARY_VERSION;
}
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index dd90088..b27b137 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -75,6 +75,8 @@ nntp_summary_class_init (CamelNNTPSummaryClass *class)
g_type_class_add_private (class, sizeof (CamelNNTPSummaryPrivate));
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+ folder_summary_class->message_info_size = sizeof (CamelMessageInfoBase);
+ folder_summary_class->content_info_size = sizeof (CamelMessageContentInfo);
folder_summary_class->message_info_new_from_header = message_info_new_from_header;
folder_summary_class->summary_header_load = summary_header_load;
folder_summary_class->summary_header_save = summary_header_save;
@@ -89,10 +91,6 @@ nntp_summary_init (CamelNNTPSummary *nntp_summary)
nntp_summary->priv = CAMEL_NNTP_SUMMARY_GET_PRIVATE (nntp_summary);
- /* subclasses need to set the right instance data sizes */
- summary->message_info_size = sizeof (CamelMessageInfoBase);
- summary->content_info_size = sizeof (CamelMessageContentInfo);
-
/* and a unique file version */
summary->version += CAMEL_NNTP_SUMMARY_VERSION;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]