evolution-data-server r9745 - in branches/camel-gobject: . camel camel/providers/imap camel/providers/imap4 camel/providers/imapp camel/providers/local camel/providers/pop3
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9745 - in branches/camel-gobject: . camel camel/providers/imap camel/providers/imap4 camel/providers/imapp camel/providers/local camel/providers/pop3
- Date: Sun, 9 Nov 2008 06:35:11 +0000 (UTC)
Author: mbarnes
Date: Sun Nov 9 06:35:11 2008
New Revision: 9745
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9745&view=rev
Log:
Working code! Along with a very minimal patch for Evolution.
Still a ton of internal cleanup work to fully migrate Camel to GObject.
Added:
branches/camel-gobject/evolution.patch
Modified:
branches/camel-gobject/camel/Makefile.am
branches/camel-gobject/camel/camel-mime-filter-enriched.c
branches/camel-gobject/camel/camel-multipart-encrypted.c
branches/camel-gobject/camel/camel-multipart-signed.c
branches/camel-gobject/camel/camel-multipart.c
branches/camel-gobject/camel/camel-object.c
branches/camel-gobject/camel/camel-object.h
branches/camel-gobject/camel/camel-offline-folder.c
branches/camel-gobject/camel/camel-vee-store.c
branches/camel-gobject/camel/camel-vtrash-folder.c
branches/camel-gobject/camel/camel.h
branches/camel-gobject/camel/providers/imap/camel-imap-folder.c
branches/camel-gobject/camel/providers/imap/camel-imap-store-summary.c
branches/camel-gobject/camel/providers/imap4/camel-imap4-store-summary.c
branches/camel-gobject/camel/providers/imapp/camel-imapp-folder.c
branches/camel-gobject/camel/providers/local/camel-local-folder.c
branches/camel-gobject/camel/providers/local/camel-spool-folder.c
branches/camel-gobject/camel/providers/local/camel-spool-store.c
branches/camel-gobject/camel/providers/pop3/camel-pop3-folder.c
Modified: branches/camel-gobject/camel/Makefile.am
==============================================================================
--- branches/camel-gobject/camel/Makefile.am (original)
+++ branches/camel-gobject/camel/Makefile.am Sun Nov 9 06:35:11 2008
@@ -203,6 +203,7 @@
camel-net-utils.c \
camel-nntp-address.c \
camel-object.c \
+ camel-object-bag.c \
camel-operation.c \
camel-partition-table.c \
camel-seekable-stream.c \
@@ -275,6 +276,7 @@
camel-net-utils.h \
camel-nntp-address.h \
camel-object.h \
+ camel-object-bag.h \
camel-operation.h \
camel-partition-table.h \
camel-search-private.h \
Modified: branches/camel-gobject/camel/camel-mime-filter-enriched.c
==============================================================================
--- branches/camel-gobject/camel/camel-mime-filter-enriched.c (original)
+++ branches/camel-gobject/camel/camel-mime-filter-enriched.c Sun Nov 9 06:35:11 2008
@@ -133,7 +133,7 @@
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
int i;
- parent_class = CAMEL_MIME_FILTER_CLASS (camel_mime_filter_get_type ());
+ parent_class = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
filter_class->reset = filter_reset;
filter_class->filter = filter_filter;
Modified: branches/camel-gobject/camel/camel-multipart-encrypted.c
==============================================================================
--- branches/camel-gobject/camel/camel-multipart-encrypted.c (original)
+++ branches/camel-gobject/camel/camel-multipart-encrypted.c Sun Nov 9 06:35:11 2008
@@ -74,7 +74,7 @@
{
CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (klass);
- parent_class = (CamelMultipartClass *) camel_multipart_get_type ();
+ parent_class = (CamelMultipartClass *) camel_type_get_global_classfuncs (camel_multipart_get_type ());
/* virtual method overload */
camel_data_wrapper_class->set_mime_type_field = set_mime_type_field;
Modified: branches/camel-gobject/camel/camel-multipart-signed.c
==============================================================================
--- branches/camel-gobject/camel/camel-multipart-signed.c (original)
+++ branches/camel-gobject/camel/camel-multipart-signed.c Sun Nov 9 06:35:11 2008
@@ -78,7 +78,7 @@
CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS(camel_multipart_signed_class);
CamelMultipartClass *mpclass = (CamelMultipartClass *)camel_multipart_signed_class;
- parent_class = (CamelMultipartClass *)camel_multipart_get_type();
+ parent_class = (CamelMultipartClass *) camel_type_get_global_classfuncs (camel_multipart_get_type());
/* virtual method overload */
camel_data_wrapper_class->construct_from_stream = construct_from_stream;
Modified: branches/camel-gobject/camel/camel-multipart.c
==============================================================================
--- branches/camel-gobject/camel/camel-multipart.c (original)
+++ branches/camel-gobject/camel/camel-multipart.c Sun Nov 9 06:35:11 2008
@@ -76,7 +76,7 @@
CamelDataWrapperClass *camel_data_wrapper_class =
CAMEL_DATA_WRAPPER_CLASS (camel_multipart_class);
- parent_class = (CamelDataWrapperClass *) camel_data_wrapper_get_type ();
+ parent_class = (CamelDataWrapperClass *) camel_type_get_global_classfuncs (camel_data_wrapper_get_type ());
/* virtual method definition */
camel_multipart_class->add_part = add_part;
Modified: branches/camel-gobject/camel/camel-object.c
==============================================================================
--- branches/camel-gobject/camel/camel-object.c (original)
+++ branches/camel-gobject/camel/camel-object.c Sun Nov 9 06:35:11 2008
@@ -35,7 +35,6 @@
#include <libedataserver/e-data-server-util.h>
#include "camel-file-utils.h"
-#include "camel-list-utils.h"
#include "camel-object.h"
#define d(x)
@@ -50,6 +49,8 @@
#define CAMEL_OBJECT_CLASS_FINALISED_MAGIC 0x7621ABCD
#define CAMEL_INTERFACE_FINALISED_MAGIC 0x7CB2FE71
+static gpointer parent_class;
+
/* ** Quickie type system ************************************************* */
/* A 'locked' hooklist, that is only allocated on demand */
@@ -87,29 +88,6 @@
void *data;
} CamelHookPair;
-struct _CamelObjectBagKey {
- struct _CamelObjectBagKey *next;
-
- void *key; /* the key reserved */
- int waiters; /* count of threads waiting for key */
- pthread_t owner; /* the thread that has reserved the bag for a new entry */
- int have_owner;
- GCond *cond;
-};
-
-struct _CamelObjectBag {
- GHashTable *object_table; /* object by key */
- GHashTable *key_table; /* key by object */
- GEqualFunc equal_key;
- CamelCopyFunc copy_key;
- GFreeFunc free_key;
-
- struct _CamelObjectBagKey *reserved;
-};
-
-/* used to tag a bag hookpair */
-static const char bag_name[] = "object:bag";
-
/* meta-data stuff */
static void co_metadata_free(CamelObject *obj, CamelObjectMeta *meta);
static CamelObjectMeta *co_metadata_get(CamelObject *obj);
@@ -125,7 +103,6 @@
static CamelHookList *camel_object_get_hooks(CamelObject *o);
static void camel_object_free_hooks(CamelObject *o);
-static void camel_object_bag_remove_unlocked(CamelObjectBag *inbag, CamelObject *o, CamelHookList *hooks);
#define camel_object_unget_hooks(o) \
(g_static_rec_mutex_unlock(&CAMEL_OBJECT(o)->hooks->lock))
@@ -133,25 +110,16 @@
/* ********************************************************************** */
-/* type-lock must be recursive, for atomically creating classes */
-static GStaticRecMutex type_lock = G_STATIC_REC_MUTEX_INIT;
-/* ref-lock must be global :-( for object bags to work */
-static GMutex *ref_lock;
-
-static GHashTable *type_table;
-
+#ifndef CAMEL_DISABLE_DEPRECATED
/* fundamental types are accessed via global */
-CamelType camel_object_type = CAMEL_INVALID_TYPE;
-CamelType camel_interface_type = CAMEL_INVALID_TYPE;
+CamelType camel_object_type;
+CamelType camel_interface_type;
+#endif
#define P_LOCK(l) (pthread_mutex_lock(&l))
#define P_UNLOCK(l) (pthread_mutex_unlock(&l))
#define CLASS_LOCK(k) (g_mutex_lock((((CamelObjectClass *)k)->lock)))
#define CLASS_UNLOCK(k) (g_mutex_unlock((((CamelObjectClass *)k)->lock)))
-#define REF_LOCK() (g_mutex_lock(ref_lock))
-#define REF_UNLOCK() (g_mutex_unlock(ref_lock))
-#define TYPE_LOCK() (g_static_rec_mutex_lock(&type_lock))
-#define TYPE_UNLOCK() (g_static_rec_mutex_unlock(&type_lock))
static struct _CamelHookPair *
pair_alloc(void)
@@ -189,48 +157,10 @@
g_slice_free (CamelHookList, hooks);
}
-/* not checked locked, who cares, only required for people that want to redefine root objects */
-void
-camel_type_init(void)
-{
- static int init = FALSE;
-
- if (init)
- return;
-
- init = TRUE;
- type_table = g_hash_table_new(NULL, NULL);
- ref_lock = g_mutex_new();
-}
-
/* ************************************************************************ */
/* CamelObject base methods */
-/* Should this return the object to the caller? */
-static void
-cobject_init(CamelObject *o, CamelObjectClass *klass)
-{
- o->klass = klass;
- o->magic = CAMEL_OBJECT_MAGIC;
- o->ref_count = 1;
- o->flags = 0;
-}
-
-static void
-cobject_finalise(CamelObject *o)
-{
- /*printf("%p: finalise %s\n", o, o->klass->name);*/
-
- if (o->ref_count == 0)
- return;
-
- camel_object_free_hooks(o);
-
- o->magic = CAMEL_OBJECT_FINALISED_MAGIC;
- o->klass = NULL;
-}
-
static int
cobject_getv(CamelObject *o, CamelException *ex, CamelArgGetV *args)
{
@@ -588,665 +518,222 @@
}
-static void
-cobject_class_init(CamelObjectClass *klass)
-{
- klass->magic = CAMEL_OBJECT_CLASS_MAGIC;
-
- klass->getv = cobject_getv;
- klass->setv = cobject_setv;
- klass->free = cobject_free;
-
- klass->meta_get = cobject_meta_get;
- klass->meta_set = cobject_meta_set;
- klass->state_read = cobject_state_read;
- klass->state_write = cobject_state_write;
-
- camel_object_class_add_event(klass, "finalize", NULL);
- camel_object_class_add_event(klass, "meta_changed", NULL);
-}
-
-static void
-cobject_class_finalise(CamelObjectClass * klass)
-{
- klass->magic = CAMEL_OBJECT_CLASS_FINALISED_MAGIC;
-
- g_free(klass);
-}
-
-
/* CamelInterface base methods */
static void
-cinterface_init(CamelObject *o, CamelObjectClass *klass)
-{
- g_error("Cannot instantiate interfaces, trying to instantiate '%s'", klass->name);
- abort();
-}
-
-static int
-cinterface_getv(CamelObject *o, CamelException *ex, CamelArgGetV *args)
-{
- return 0;
-}
-
-static int
-cinterface_setv(CamelObject *o, CamelException *ex, CamelArgV *args)
-{
- return 0;
-}
-
-static void
-cinterface_free(CamelObject *o, guint32 tag, void *value)
+object_phoney_klass_init (CamelObjectClass *class)
{
- /* NOOP */
+ /* Give legacy Camel classes something to chain up to. */
}
static void
-cinterface_class_init(CamelObjectClass *klass)
+object_phoney_klass_finalise (CamelObjectClass *class)
{
- klass->magic = CAMEL_INTERFACE_MAGIC;
-
- /* just setup dummy callbacks, properties could be part of the interface but we support none */
- klass->getv = cinterface_getv;
- klass->setv = cinterface_setv;
- klass->free = cinterface_free;
-
- /* TODO: ok, these are cruft hanging around an interface, but it saves having to define two different class bases */
- klass->meta_get = NULL;
- klass->meta_set = NULL;
- klass->state_read = NULL;
- klass->state_write = NULL;
+ /* Give legacy Camel classes something to chain up to. */
}
static void
-cinterface_class_finalise(CamelObjectClass * klass)
-{
- klass->magic = CAMEL_INTERFACE_FINALISED_MAGIC;
- g_free(klass);
-}
-
-/* this function must be called for any other in the object system */
-CamelType
-camel_object_get_type(void)
+object_phoney_init (CamelObject *object,
+ CamelObjectClass *class)
{
- if (camel_object_type == CAMEL_INVALID_TYPE) {
- camel_type_init();
-
- camel_object_type = camel_type_register(NULL, "CamelObject", /*, 0, 0*/
- sizeof(CamelObject), sizeof(CamelObjectClass),
- cobject_class_init, cobject_class_finalise,
- cobject_init, cobject_finalise);
-
- camel_interface_type = camel_type_register(NULL, "CamelInterface",
- 0, sizeof(CamelInterface),
- cinterface_class_init, cinterface_class_finalise,
- cinterface_init, NULL);
-
- }
-
- return camel_object_type;
+ /* Give legacy Camel classes something to chain up to. */
}
static void
-camel_type_class_init(CamelObjectClass *klass, CamelObjectClass *type)
-{
- if (type->parent)
- camel_type_class_init(klass, type->parent);
-
- if (type->klass_init)
- type->klass_init(klass);
-}
-
-static CamelType
-co_type_register(CamelType parent, const char * name,
- /*unsigned int ver, unsigned int rev,*/
- size_t object_size, size_t klass_size,
- CamelObjectClassInitFunc class_init,
- CamelObjectClassFinalizeFunc class_finalise,
- CamelObjectInitFunc object_init,
- CamelObjectFinalizeFunc object_finalise)
+object_finalize (GObject *object)
{
- CamelObjectClass *klass;
- /*int offset;
- size_t size;*/
-
- TYPE_LOCK();
-
- /* Have to check creation, it might've happened in another thread before we got here */
- klass = g_hash_table_lookup(type_table, name);
- if (klass != NULL) {
- if (klass->klass_size != klass_size || klass->object_size != object_size
- || klass->klass_init != class_init || klass->klass_finalise != class_finalise
- || klass->init != object_init || klass->finalise != object_finalise) {
- g_warning("camel_type_register: Trying to re-register class '%s'", name);
- klass = NULL;
- }
- TYPE_UNLOCK();
- return klass;
- }
-
- /* this is for objects with no parent as part of their struct ('interfaces'?) */
- /*offset = parent?parent->klass_size:0;
- offset = (offset + 3) & (~3);
-
- size = offset + klass_size;
-
- klass = g_slice_alloc0(size);
-
- klass->klass_size = size;
- klass->klass_data = offset;
-
- offset = parent?parent->object_size:0;
- offset = (offset + 3) & (~3);
-
- klass->object_size = offset + object_size;
- klass->object_data = offset;*/
-
- if (parent
- && klass_size < parent->klass_size) {
- g_warning("camel_type_register: '%s' has smaller class size than parent '%s'", name, parent->name);
- TYPE_UNLOCK();
- return NULL;
- }
-
- klass = g_slice_alloc0 (klass_size);
- klass->klass_size = klass_size;
- klass->object_size = object_size;
- klass->lock = g_mutex_new();
- klass->hooks = NULL;
+ CamelObject *camel_object = CAMEL_OBJECT (object);
+ CamelObjectClass *camel_object_class;
- klass->parent = parent;
- if (parent) {
- klass->next = parent->child;
- parent->child = klass;
- }
- klass->name = name;
-
- /*klass->version = ver;
- klass->revision = rev;*/
-
- klass->klass_init = class_init;
- klass->klass_finalise = class_finalise;
-
- klass->init = object_init;
- klass->finalise = object_finalise;
+ camel_object_class = CAMEL_OBJECT_CLASS (G_OBJECT_GET_CLASS (object));
- /* setup before class init, incase class init func uses the type or looks it up ? */
- g_hash_table_insert(type_table, (void *)name, klass);
-
- camel_type_class_init(klass, klass);
-
- TYPE_UNLOCK();
-
- return klass;
-}
+ camel_object_trigger_event (object, "finalize", NULL);
-CamelType
-camel_type_register(CamelType parent, const char * name,
- /*unsigned int ver, unsigned int rev,*/
- size_t object_size, size_t klass_size,
- CamelObjectClassInitFunc class_init,
- CamelObjectClassFinalizeFunc class_finalise,
- CamelObjectInitFunc object_init,
- CamelObjectFinalizeFunc object_finalise)
-{
- if (parent != NULL && parent->magic != CAMEL_OBJECT_CLASS_MAGIC) {
- g_warning("camel_type_register: invalid junk parent class for '%s'", name);
- return NULL;
- }
+ /* Call the legacy finalise() method. */
+ if (camel_object_class->finalise != NULL)
+ camel_object_class->finalise (camel_object);
- return co_type_register(parent, name, object_size, klass_size, class_init, class_finalise, object_init, object_finalise);
-}
+ camel_object_free_hooks (camel_object);
-CamelType
-camel_interface_register(CamelType parent, const char *name,
- size_t class_size,
- CamelObjectClassInitFunc class_init,
- CamelObjectClassFinalizeFunc class_finalise)
-{
- if (parent != NULL && parent->magic != CAMEL_INTERFACE_MAGIC) {
- g_warning("camel_interface_register: invalid junk parent class for '%s'", name);
- return NULL;
- }
+ camel_object->klass = NULL;
+ camel_object->magic = CAMEL_OBJECT_FINALISED_MAGIC;
- return camel_type_register(parent, name, 0, class_size, class_init, class_finalise, NULL, NULL);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-camel_object_init(CamelObject *o, CamelObjectClass *klass, CamelType type)
-{
- if (type->parent)
- camel_object_init(o, klass, type->parent);
-
- if (type->init)
- type->init(o, klass);
-}
-
-CamelObject *
-camel_object_new(CamelType type)
+object_class_init (CamelObjectClass *class,
+ CamelObjectFinalizeFunc finalize_func)
{
- CamelObject *o;
-
- if (type == NULL)
- return NULL;
-
- if (type->magic != CAMEL_OBJECT_CLASS_MAGIC)
- return NULL;
+ GObjectClass *object_class;
- CLASS_LOCK(type);
+ parent_class = g_type_class_peek_parent (class);
- o = g_slice_alloc0 (type->object_size);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = object_finalize;
-#ifdef CAMEL_OBJECT_TRACK_INSTANCES
- if (type->instances)
- type->instances->prev = o;
- o->next = type->instances;
- o->prev = NULL;
- type->instances = o;
-#endif
+ class->magic = CAMEL_OBJECT_CLASS_MAGIC;
+ class->name = G_OBJECT_CLASS_NAME (class);
+ class->lock = g_mutex_new ();
+ class->hooks = NULL;
- CLASS_UNLOCK(type);
+ class->klass_init = object_phoney_klass_init;
+ class->klass_finalise = object_phoney_klass_finalise;
+ class->init = object_phoney_init;
+ class->finalise = finalize_func;
- camel_object_init(o, type, type);
+ class->getv = cobject_getv;
+ class->setv = cobject_setv;
+ class->free = cobject_free;
- d(printf("%p: new %s()\n", o, o->klass->name));
+ class->meta_get = cobject_meta_get;
+ class->meta_set = cobject_meta_set;
+ class->state_read = cobject_state_read;
+ class->state_write = cobject_state_write;
- return o;
+ camel_object_class_add_event (class, "finalize", NULL);
+ camel_object_class_add_event (class, "meta_changed", NULL);
}
-void
-camel_object_ref(void *vo)
+static void
+object_init (CamelObject *object,
+ CamelObjectClass *class)
{
- register CamelObject *o = vo;
-
- g_return_if_fail(CAMEL_IS_OBJECT(o));
-
- REF_LOCK();
-
- o->ref_count++;
- d(printf("%p: ref %s(%d)\n", o, o->klass->name, o->ref_count));
-
- REF_UNLOCK();
+ object->klass = class;
+ object->magic = CAMEL_OBJECT_MAGIC;
}
-void
-camel_object_unref(void *vo)
+GType
+camel_object_get_type(void)
{
- register CamelObject *o = vo;
- register CamelObjectClass *klass, *k;
- CamelHookList *hooks = NULL;
-
- g_return_if_fail(CAMEL_IS_OBJECT(o));
-
- klass = o->klass;
-
- if (o->hooks)
- hooks = camel_object_get_hooks(o);
-
- REF_LOCK();
-
- o->ref_count--;
-
- d(printf("%p: unref %s(%d)\n", o, o->klass->name, o->ref_count));
-
- if (o->ref_count > 0
- || (o->flags & CAMEL_OBJECT_DESTROY)) {
- REF_UNLOCK();
- if (hooks)
- camel_object_unget_hooks(o);
- return;
- }
-
- o->flags |= CAMEL_OBJECT_DESTROY;
-
- if (hooks)
- camel_object_bag_remove_unlocked(NULL, o, hooks);
-
- REF_UNLOCK();
-
- if (hooks)
- camel_object_unget_hooks(o);
-
- camel_object_trigger_event(o, "finalize", NULL);
+ static GType type = 0;
- k = klass;
- while (k) {
- if (k->finalise)
- k->finalise(o);
- k = k->parent;
- }
-
- o->magic = CAMEL_OBJECT_FINALISED_MAGIC;
-
- CLASS_LOCK(klass);
-#ifdef CAMEL_OBJECT_TRACK_INSTANCES
- if (o->prev)
- o->prev->next = o->next;
- else
- klass->instances = o->next;
- if (o->next)
- o->next->prev = o->prev;
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (CamelObjectClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) object_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (CamelObject),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) object_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "CamelObject", &type_info, 0);
+
+#ifndef CAMEL_DISABLE_DEPRECATED
+ camel_object_type = type;
+ camel_interface_type = G_TYPE_INVALID;
#endif
- g_slice_free1 (klass->object_size, o);
- CLASS_UNLOCK(klass);
-}
-
-const char *
-camel_type_to_name(CamelType type)
-{
- if (type == NULL)
- return "(NULL class)";
-
- if (type->magic == CAMEL_OBJECT_CLASS_MAGIC)
- return type->name;
-
- if (type->magic == CAMEL_INTERFACE_MAGIC)
- return type->name;
-
- return "(Junk class)";
-}
-
-CamelType camel_name_to_type(const char *name)
-{
- /* TODO: Load a class off disk (!) */
-
- return g_hash_table_lookup(type_table, name);
-}
-
-static char *
-desc_data(CamelObject *o, guint32 ok)
-{
- char *what;
-
- if (o == NULL)
- what = g_strdup("NULL OBJECT");
- else if (o->magic == ok)
- what = NULL;
- else if (o->magic == CAMEL_OBJECT_MAGIC)
- what = g_strdup_printf("CLASS '%s'", ((CamelObjectClass *)o)->name);
- else if (o->magic == CAMEL_OBJECT_CLASS_MAGIC)
- what = g_strdup_printf("CLASS '%s'", ((CamelObjectClass *)o)->name);
- else if (o->magic == CAMEL_INTERFACE_MAGIC)
- what = g_strdup_printf("INTERFACE '%s'", ((CamelObjectClass *)o)->name);
- else if (o->magic == CAMEL_OBJECT_FINALISED_MAGIC)
- what = g_strdup_printf("finalised OBJECT");
- else if (o->magic == CAMEL_OBJECT_CLASS_FINALISED_MAGIC)
- what = g_strdup_printf("finalised CLASS");
- else if (o->magic == CAMEL_INTERFACE_FINALISED_MAGIC)
- what = g_strdup_printf("finalised INTERFACE");
- else
- what = g_strdup_printf("junk data");
-
- return what;
-}
-
-#define check_magic(o, ctype, omagic) \
- ( ((CamelObject *)(o))->magic == (omagic) \
- && (ctype)->magic == CAMEL_OBJECT_CLASS_MAGIC) \
- ? 1 : check_magic_fail(o, ctype, omagic)
-
-static gboolean
-check_magic_fail(void *o, CamelType ctype, guint32 omagic)
-{
- char *what, *to;
-
- what = desc_data(o, omagic);
- to = desc_data((CamelObject *)ctype, CAMEL_OBJECT_CLASS_MAGIC);
-
- if (what || to) {
- if (what == NULL) {
- if (omagic == CAMEL_OBJECT_MAGIC)
- what = g_strdup_printf("OBJECT '%s'", ((CamelObject *)o)->klass->name);
- else
- what = g_strdup_printf("OBJECT '%s'", ((CamelObjectClass *)o)->name);
- }
- if (to == NULL)
- to = g_strdup_printf("OBJECT '%s'", ctype->name);
- g_warning("Trying to check %s is %s", what, to);
- g_free(what);
- g_free(to);
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-camel_object_is(CamelObject *o, CamelType ctype)
-{
- CamelObjectClass *k;
-
- g_return_val_if_fail(o != NULL, FALSE);
- g_return_val_if_fail(check_magic(o, ctype, CAMEL_OBJECT_MAGIC), FALSE);
-
- k = o->klass;
- while (k) {
- if (k == ctype)
- return TRUE;
- k = k->parent;
- }
-
- return FALSE;
-}
-
-gboolean
-camel_object_class_is(CamelObjectClass *k, CamelType ctype)
-{
- g_return_val_if_fail(k != NULL, FALSE);
- g_return_val_if_fail(check_magic(k, ctype, CAMEL_OBJECT_CLASS_MAGIC), FALSE);
-
- while (k) {
- if (k == ctype)
- return TRUE;
- k = k->parent;
- }
-
- return FALSE;
-}
-
-gboolean
-camel_interface_is(CamelObjectClass *k, CamelType ctype)
-{
- g_return_val_if_fail(k != NULL, FALSE);
- g_return_val_if_fail(check_magic(k, ctype, CAMEL_INTERFACE_MAGIC), FALSE);
-
- while (k) {
- if (k == ctype)
- return TRUE;
- k = k->parent;
- }
-
- return FALSE;
-}
-
-CamelObject *
-camel_object_cast(CamelObject *o, CamelType ctype)
-{
- CamelObjectClass *k;
-
- g_return_val_if_fail(o != NULL, NULL);
- g_return_val_if_fail(check_magic(o, ctype, CAMEL_OBJECT_MAGIC), NULL);
-
- k = o->klass;
- while (k) {
- if (k == ctype)
- return o;
- k = k->parent;
}
- g_warning("Object %p (class '%s') doesn't have '%s' in its hierarchy", (void *) o, o->klass->name, ctype->name);
-
- return NULL;
+ return type;
}
-CamelObjectClass *
-camel_object_class_cast(CamelObjectClass *k, CamelType ctype)
-{
- CamelObjectClass *r = k;
-
- g_return_val_if_fail(check_magic(k, ctype, CAMEL_OBJECT_CLASS_MAGIC), NULL);
-
- while (k) {
- if (k == ctype)
- return r;
- k = k->parent;
- }
-
- g_warning("Class '%s' doesn't have '%s' in its hierarchy", r->name, ctype->name);
-
- return NULL;
-}
-
-CamelObjectClass *
-camel_interface_cast(CamelObjectClass *k, CamelType ctype)
-{
- CamelObjectClass *r = k;
-
- g_return_val_if_fail(check_magic(k, ctype, CAMEL_INTERFACE_MAGIC), NULL);
-
- while (k) {
- if (k == ctype)
- return r;
- k = k->parent;
- }
-
- g_warning("Interface '%s' doesn't have '%s' in its hierarchy", r->name, ctype->name);
-
- return NULL;
-}
-
-static CamelHookPair *
-co_find_pair(CamelObjectClass *klass, const char *name)
-{
- CamelHookPair *hook;
-
- hook = klass->hooks;
- while (hook) {
- if (strcmp(hook->name, name) == 0)
- return hook;
- hook = hook->next;
- }
+CamelType
+camel_type_register (CamelType parent,
+ const char * name,
+ size_t object_size,
+ size_t class_size,
+ CamelObjectClassInitFunc class_init,
+ CamelObjectClassFinalizeFunc class_finalize,
+ CamelObjectInitFunc object_init,
+ CamelObjectFinalizeFunc object_finalize)
+{
+ GTypeInfo type_info;
+
+ /* Note: class_finalize argument is ignored. */
+
+ type_info.class_size = class_size;
+ type_info.base_init = NULL;
+ type_info.base_finalize = NULL;
+ type_info.class_init = (GClassInitFunc) class_init;
+ type_info.class_finalize = NULL;
+ type_info.class_data = (gpointer) object_finalize;
+ type_info.instance_size = object_size;
+ type_info.n_preallocs = 0;
+ type_info.instance_init = (GInstanceInitFunc) object_init;
+ type_info.value_table = NULL;
- return NULL;
+ return g_type_register_static (parent, name, &type_info, 0);
}
-static CamelHookPair *
-co_find_pair_ptr(CamelObjectClass *klass, const char *name)
-{
- CamelHookPair *hook;
-
- hook = klass->hooks;
- while (hook) {
- if (hook->name == name)
- return hook;
- hook = hook->next;
- }
+CamelType
+camel_interface_register (CamelType parent,
+ const char *name,
+ size_t class_size,
+ CamelObjectClassInitFunc class_init,
+ CamelObjectClassFinalizeFunc class_finalize)
+{
+ GTypeInfo type_info;
+
+ /* Note: parent and class_finalize arguments are ignored. */
+
+ parent = G_TYPE_INTERFACE;
+ type_info.class_size = class_size;
+ type_info.base_init = (GBaseInitFunc) class_init;
+ type_info.base_finalize = NULL;
+ type_info.class_init = NULL;
+ type_info.class_finalize = NULL;
+ type_info.class_data = NULL;
+ type_info.instance_size = 0;
+ type_info.n_preallocs = 0;
+ type_info.instance_init = NULL;
+ type_info.value_table = NULL;
- return NULL;
+ return g_type_register_static (parent, name, &type_info, 0);
}
/* class functions */
void
-camel_object_class_add_event(CamelObjectClass *klass, const char *name, CamelObjectEventPrepFunc prep)
-{
- CamelHookPair *pair;
-
- g_return_if_fail (name);
-
- pair = co_find_pair(klass, name);
- if (pair) {
- g_warning("camel_object_class_add_event: '%s' is already declared for '%s'",
- name, klass->name);
- return;
- }
-
- if (klass->magic == CAMEL_INTERFACE_MAGIC && prep != NULL) {
- g_warning("camel_object_class_add_event: '%s', CamelInterface '%s' may not have an event prep function - ignored",
- name, klass->name);
- prep = NULL;
- }
-
- pair = pair_alloc();
- pair->name = name;
- pair->func.prep = prep;
- pair->flags = 0;
-
- pair->next = klass->hooks;
- klass->hooks = pair;
-}
-
-void
-camel_object_class_add_interface(CamelObjectClass *klass, CamelType itype)
-{
- CamelHookPair *pair;
- CamelType iscan;
- GPtrArray *interfaces;
- int i;
-
- if (!camel_interface_is(itype, camel_interface_type)) {
- g_warning("Cannot add an interface not derived from CamelInterface on class '%s'", klass->name);
- return;
- }
-
- if (camel_object_class_is(klass, camel_interface_type)) {
- g_warning("Cannot add an interface onto a class derived from CamelInterface");
- return;
- }
-
- /* we store it on the class hooks so we don't have to add any extra space to the class */
- pair = co_find_pair_ptr(klass, interface_name);
- if (pair == NULL) {
- pair = pair_alloc();
- pair->data = g_ptr_array_new();
- pair->next = klass->hooks;
- klass->hooks = pair;
- }
-
- /* We just check that this type isn't added/derived anywhere else */
- interfaces = pair->data;
- iscan = itype;
- while (iscan && iscan != camel_interface_type) {
- for (i=0;i<interfaces->len;i++) {
- if (camel_interface_is((CamelType)interfaces->pdata[i], iscan)) {
- g_warning("Cannot add an interface twice '%s' on class '%s'\n", itype->name, klass->name);
- return;
- }
- }
- iscan = iscan->parent;
- }
-
- if (iscan == camel_interface_type)
- g_ptr_array_add(interfaces, itype);
+camel_object_class_add_event (CamelObjectClass *klass,
+ const char *name,
+ CamelObjectEventPrepFunc prep)
+{
+ /* XXX Need to do something with prep */
+ g_signal_new (
+ name,
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
}
/* free hook data */
static void
camel_object_free_hooks(CamelObject *o)
{
- CamelHookPair *pair, *next;
-
- if (o->hooks) {
- g_assert(o->hooks->depth == 0);
- g_assert((o->hooks->flags & CAMEL_HOOK_PAIR_REMOVED) == 0);
-
- pair = o->hooks->list;
- while (pair) {
- next = pair->next;
-
- if (pair->name == meta_name) {
- co_metadata_free(o, pair->data);
- g_free(pair->func.filename);
- }
+ CamelHookPair *pair, *next;
- pair_free(pair);
- pair = next;
- }
- g_static_rec_mutex_free(&o->hooks->lock);
- hooks_free(o->hooks);
- o->hooks = NULL;
- }
+ if (o->hooks) {
+ g_assert(o->hooks->depth == 0);
+ g_assert((o->hooks->flags & CAMEL_HOOK_PAIR_REMOVED) == 0);
+
+ pair = o->hooks->list;
+ while (pair) {
+ next = pair->next;
+
+ if (pair->name == meta_name) {
+ co_metadata_free(o, pair->data);
+ g_free(pair->func.filename);
+ }
+
+ pair_free(pair);
+ pair = next;
+ }
+ g_static_rec_mutex_free(&o->hooks->lock);
+ hooks_free(o->hooks);
+ o->hooks = NULL;
+ }
}
/* return (allocate if required) the object's hook list, locking at the same time */
@@ -1278,268 +765,43 @@
}
unsigned int
-camel_object_hook_event(void *vo, const char * name, CamelObjectEventHookFunc func, void *data)
+camel_object_hook_event (void *vo,
+ const char *name,
+ CamelObjectEventHookFunc func,
+ void *data)
{
- CamelObject *obj = vo;
- CamelHookPair *pair, *hook;
- CamelHookList *hooks;
- int id;
-
- g_return_val_if_fail(CAMEL_IS_OBJECT (obj), 0);
- g_return_val_if_fail(name != NULL, 0);
- g_return_val_if_fail(func != NULL, 0);
-
- hook = co_find_pair(obj->klass, name);
-
- /* Check all interfaces on this object for events defined on them */
- if (hook == NULL) {
- pair = co_find_pair_ptr(obj->klass, interface_name);
- if (pair) {
- GPtrArray *interfaces = pair->data;
- int i;
-
- for (i=0;i<interfaces->len;i++) {
- hook = co_find_pair(interfaces->pdata[i], name);
- if (hook)
- goto setup;
- }
- }
-
- g_warning("camel_object_hook_event: trying to hook event '%s' in class '%s' with no defined events.",
- name, obj->klass->name);
-
- return 0;
- }
-setup:
- /* setup hook pair */
- pair = pair_alloc();
- pair->name = hook->name; /* effectively static! */
- pair->func.event = func;
- pair->data = data;
- pair->flags = 0;
- id = pair->id;
-
- /* get the hook list object, locked, link in new event hook, unlock */
- hooks = camel_object_get_hooks(obj);
- pair->next = hooks->list;
- hooks->list = pair;
- hooks->list_length++;
- camel_object_unget_hooks(obj);
-
- h(printf("%p hook event '%s' %p %p = %d\n", vo, name, func, data, id));
-
- return id;
+ return (guint) g_signal_connect_after (
+ vo, name, G_CALLBACK (func), data);
}
void
-camel_object_remove_event(void *vo, unsigned int id)
+camel_object_remove_event (void *vo,
+ unsigned int id)
{
- CamelObject *obj = vo;
- CamelHookList *hooks;
- CamelHookPair *pair, *parent;
-
- g_return_if_fail (CAMEL_IS_OBJECT (obj));
- g_return_if_fail (id != 0);
-
- if (obj->hooks == NULL) {
- g_warning("camel_object_unhook_event: trying to unhook '%u' from an instance of '%s' with no hooks",
- id, obj->klass->name);
- return;
- }
-
- h(printf("%p remove event %d\n", vo, id));
-
- /* scan hooks for this event, remove it, or flag it if we're busy */
- hooks = camel_object_get_hooks(obj);
- parent = (CamelHookPair *)&hooks->list;
- pair = parent->next;
- while (pair) {
- if (pair->id == id
- && (pair->flags & CAMEL_HOOK_PAIR_REMOVED) == 0) {
- if (hooks->depth > 0) {
- pair->flags |= CAMEL_HOOK_PAIR_REMOVED;
- hooks->flags |= CAMEL_HOOK_PAIR_REMOVED;
- } else {
- parent->next = pair->next;
- pair_free(pair);
- hooks->list_length--;
- }
- camel_object_unget_hooks(obj);
- return;
- }
- parent = pair;
- pair = pair->next;
- }
- camel_object_unget_hooks(obj);
-
- g_warning("camel_object_unhook_event: cannot find hook id %u in instance of '%s'",
- id, obj->klass->name);
+ g_signal_handler_disconnect (vo, id);
}
void
-camel_object_unhook_event(void *vo, const char * name, CamelObjectEventHookFunc func, void *data)
-{
- CamelObject *obj = vo;
- CamelHookList *hooks;
- CamelHookPair *pair, *parent;
-
- g_return_if_fail (CAMEL_IS_OBJECT (obj));
- g_return_if_fail (name != NULL);
- g_return_if_fail (func != NULL);
-
- if (obj->hooks == NULL) {
- g_warning("camel_object_unhook_event: trying to unhook '%s' from an instance of '%s' with no hooks",
- name, obj->klass->name);
- return;
- }
-
- h(printf("%p unhook event '%s' %p %p\n", vo, name, func, data));
-
- /* scan hooks for this event, remove it, or flag it if we're busy */
- hooks = camel_object_get_hooks(obj);
- parent = (CamelHookPair *)&hooks->list;
- pair = parent->next;
- while (pair) {
- if (pair->func.event == func
- && pair->data == data
- && strcmp(pair->name, name) == 0
- && (pair->flags & CAMEL_HOOK_PAIR_REMOVED) == 0) {
- if (hooks->depth > 0) {
- pair->flags |= CAMEL_HOOK_PAIR_REMOVED;
- hooks->flags |= CAMEL_HOOK_PAIR_REMOVED;
- } else {
- parent->next = pair->next;
- pair_free(pair);
- hooks->list_length--;
- }
- camel_object_unget_hooks(obj);
- return;
- }
- parent = pair;
- pair = pair->next;
- }
- camel_object_unget_hooks(obj);
-
- g_warning("camel_object_unhook_event: cannot find hook/data pair %p/%p in an instance of '%s' attached to '%s'",
- (void *) func, data, obj->klass->name, name);
+camel_object_unhook_event (void *vo,
+ const char *name,
+ CamelObjectEventHookFunc func,
+ void *data)
+{
+ guint signal_id;
+
+ signal_id = g_signal_lookup (name, G_OBJECT_TYPE (vo));
+
+ g_signal_handlers_disconnect_matched (
+ vo, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC |
+ G_SIGNAL_MATCH_DATA, signal_id, 0, NULL, func, data);
}
void
-camel_object_trigger_event(void *vo, const char * name, void *event_data)
-{
- CamelObject *obj = vo;
- CamelHookList *hooks;
- CamelHookPair *pair, **pairs, *parent, *hook;
- int i, size;
- const char *prepname;
-
- g_return_if_fail (CAMEL_IS_OBJECT (obj));
- g_return_if_fail (name);
-
- hook = co_find_pair(obj->klass, name);
- if (hook)
- goto trigger;
-
- if (obj->hooks == NULL)
- return;
-
- /* interface events can't have prep functions */
- pair = co_find_pair_ptr(obj->klass, interface_name);
- if (pair) {
- GPtrArray *interfaces = pair->data;
-
- for (i=0;i<interfaces->len;i++) {
- hook = co_find_pair(interfaces->pdata[i], name);
- if (hook)
- goto trigger_interface;
- }
- }
-
- g_warning("camel_object_trigger_event: trying to trigger unknown event '%s' in class '%s'",
- name, obj->klass->name);
-
- return;
-
-trigger:
- /* try prep function, if false, then quit */
- if (hook->func.prep != NULL && !hook->func.prep(obj, event_data))
- return;
-
- /* also, no hooks, dont bother going further */
- if (obj->hooks == NULL)
- return;
-
-trigger_interface:
- /* lock the object for hook emission */
- camel_object_ref(obj);
- hooks = camel_object_get_hooks(obj);
-
- if (hooks->list) {
- /* first, copy the items in the list, and say we're in an event */
- hooks->depth++;
- pair = hooks->list;
- size = 0;
- pairs = alloca(sizeof(pairs[0]) * hooks->list_length);
- prepname = hook->name;
- while (pair) {
- if (pair->name == prepname)
- pairs[size++] = pair;
- pair = pair->next;
- }
-
- /* now execute the events we have, if they haven't been removed during our calls */
- for (i=size-1;i>=0;i--) {
- pair = pairs[i];
- if ((pair->flags & CAMEL_HOOK_PAIR_REMOVED) == 0)
- (pair->func.event) (obj, event_data, pair->data);
- }
- hooks->depth--;
-
- /* and if we're out of any events, then clean up any pending removes */
- if (hooks->depth == 0 && (hooks->flags & CAMEL_HOOK_PAIR_REMOVED)) {
- parent = (CamelHookPair *)&hooks->list;
- pair = parent->next;
- while (pair) {
- if (pair->flags & CAMEL_HOOK_PAIR_REMOVED) {
- parent->next = pair->next;
- pair_free(pair);
- hooks->list_length--;
- } else {
- parent = pair;
- }
- pair = parent->next;
- }
- hooks->flags &= ~CAMEL_HOOK_PAIR_REMOVED;
- }
- }
-
- camel_object_unget_hooks(obj);
- camel_object_unref(obj);
-}
-
-void *
-camel_object_get_interface(void *vo, CamelType itype)
+camel_object_trigger_event (void *vo,
+ const char *name,
+ void *event_data)
{
- CamelObject *obj = vo;
- CamelHookPair *pair;
-
- g_return_val_if_fail(CAMEL_IS_OBJECT (obj), NULL);
- g_return_val_if_fail(camel_interface_is(itype, camel_interface_type), NULL);
-
- pair = co_find_pair_ptr(obj->klass, interface_name);
- if (pair) {
- GPtrArray *interfaces = pair->data;
- int i;
-
- for (i=0;i<interfaces->len;i++) {
- if (camel_interface_is((CamelType)interfaces->pdata[i], itype))
- return (CamelType)interfaces->pdata[i];
- }
- }
-
- g_warning("Object %p class %s doesn't contain interface %s\n", vo, obj->klass->name, itype->name);
-
- return NULL;
+ g_signal_emit_by_name (vo, name, event_data);
}
/* get/set arg methods */
@@ -1547,13 +809,14 @@
{
CamelArgV args;
CamelObject *o = vo;
- CamelObjectClass *klass = o->klass;
+ CamelObjectClass *klass;
int ret = 0;
g_return_val_if_fail(CAMEL_IS_OBJECT(o), -1);
camel_argv_start(&args, ex);
+ klass = CAMEL_OBJECT_GET_CLASS (o);
while (camel_argv_build(&args) && ret == 0)
ret = klass->setv(o, ex, &args);
if (ret == 0)
@@ -1575,13 +838,14 @@
{
CamelObject *o = vo;
CamelArgGetV args;
- CamelObjectClass *klass = o->klass;
+ CamelObjectClass *klass;
int ret = 0;
g_return_val_if_fail(CAMEL_IS_OBJECT(o), -1);
camel_argv_start(&args, ex);
+ klass = CAMEL_OBJECT_GET_CLASS (o);
while (camel_arggetv_build(&args) && ret == 0)
ret = klass->getv(o, ex, &args);
if (ret == 0)
@@ -1596,7 +860,7 @@
{
CamelObject *o = vo;
CamelArgGetV args;
- CamelObjectClass *klass = o->klass;
+ CamelObjectClass *klass;
int ret = 0;
void *val = NULL;
@@ -1610,6 +874,7 @@
args.argv[0].tag = tag;
args.argv[0].ca_ptr = &val;
+ klass = CAMEL_OBJECT_GET_CLASS (o);
ret = klass->getv(o, ex, &args);
if (ret != 0)
return NULL;
@@ -1621,7 +886,7 @@
{
CamelObject *o = vo;
CamelArgGetV args;
- CamelObjectClass *klass = o->klass;
+ CamelObjectClass *klass;
int ret = 0;
int val = 0;
@@ -1634,6 +899,7 @@
args.argv[0].tag = tag;
args.argv[0].ca_int = &val;
+ klass = CAMEL_OBJECT_GET_CLASS (o);
ret = klass->getv(o, ex, &args);
if (ret != 0)
return 0;
@@ -1882,488 +1148,6 @@
((CamelObject *)vo)->klass->free(vo, tag, value);
}
-static void
-object_class_dump_tree_rec(CamelType root, int depth)
-{
- char *p;
-#ifdef CAMEL_OBJECT_TRACK_INSTANCES
- struct _CamelObject *o;
-#endif
-
- p = alloca(depth*2+1);
- memset(p, ' ', depth*2);
- p[depth*2] = 0;
-
- while (root) {
- CLASS_LOCK(root);
- printf("%sClass: %s\n", p, root->name);
- /*printf("%sVersion: %u.%u\n", p, root->version, root->revision);*/
- if (root->hooks) {
- CamelHookPair *pair = root->hooks;
-
- while (pair) {
- printf("%s event '%s' prep %p\n", p, pair->name, (void *) pair->func.prep);
- pair = pair->next;
- }
- }
-
-#ifdef CAMEL_OBJECT_TRACK_INSTANCES
- o = root->instances;
- while (o) {
- printf("%s instance %p [%d]\n", p, o, o->ref_count);
- /* todo: should lock hooks while it scans them */
- if (o->hooks) {
- CamelHookPair *pair = o->hooks->list;
-
- while (pair) {
- printf("%s hook '%s' func %p data %p\n", p, pair->name, pair->func.event, pair->data);
- pair = pair->next;
- }
- }
- o = o->next;
- }
-#endif
- CLASS_UNLOCK(root);
-
- if (root->child)
- object_class_dump_tree_rec(root->child, depth+1);
-
- root = root->next;
- }
-}
-
-void
-camel_object_class_dump_tree(CamelType root)
-{
- object_class_dump_tree_rec(root, 0);
-}
-
-/**
- * camel_object_bag_new:
- * @hash:
- * @equal:
- * @keycopy:
- * @keyfree:
- *
- * Allocate a new object bag. Object bag's are key'd hash tables of
- * camel-objects which can be updated atomically using transaction
- * semantics.
- *
- * Return value:
- **/
-CamelObjectBag *
-camel_object_bag_new(GHashFunc hash, GEqualFunc equal, CamelCopyFunc keycopy, GFreeFunc keyfree)
-{
- CamelObjectBag *bag;
-
- bag = g_malloc(sizeof(*bag));
- bag->object_table = g_hash_table_new(hash, equal);
- bag->equal_key = equal;
- bag->copy_key = keycopy;
- bag->free_key = keyfree;
- bag->key_table = g_hash_table_new(NULL, NULL);
- bag->reserved = NULL;
-
- return bag;
-}
-
-static void
-save_object(void *key, CamelObject *o, GPtrArray *objects)
-{
- g_ptr_array_add(objects, o);
-}
-
-void
-camel_object_bag_destroy(CamelObjectBag *bag)
-{
- GPtrArray *objects = g_ptr_array_new();
- int i;
-
- g_assert(bag->reserved == NULL);
-
- g_hash_table_foreach(bag->object_table, (GHFunc)save_object, objects);
- for (i=0;i<objects->len;i++)
- camel_object_bag_remove(bag, objects->pdata[i]);
-
- g_ptr_array_free(objects, TRUE);
- g_hash_table_destroy(bag->object_table);
- g_hash_table_destroy(bag->key_table);
- g_free(bag);
-}
-
-/* must be called with ref_lock held */
-static void
-co_bag_unreserve(CamelObjectBag *bag, const void *key)
-{
- struct _CamelObjectBagKey *res, *resp;
-
- resp = (struct _CamelObjectBagKey *)&bag->reserved;
- res = resp->next;
- while (res) {
- if (bag->equal_key(res->key, key))
- break;
- resp = res;
- res = res->next;
- }
-
- g_assert(res != NULL);
- g_assert(res->have_owner && pthread_equal(res->owner, pthread_self()));
-
- if (res->waiters > 0) {
- b(printf("unreserve bag '%s', waking waiters\n", (char *)key));
- res->have_owner = FALSE;
- g_cond_signal(res->cond);
- } else {
- b(printf("unreserve bag '%s', no waiters, freeing reservation\n", (char *)key));
- resp->next = res->next;
- bag->free_key(res->key);
- g_cond_free(res->cond);
- g_free(res);
- }
-}
-
-/**
- * camel_object_bag_add:
- * @bag:
- * @key:
- * @vo:
- *
- * Add an object @vo to the object bag @bag. The @key MUST have
- * previously been reserved using camel_object_bag_reserve().
- **/
-void
-camel_object_bag_add(CamelObjectBag *bag, const void *key, void *vo)
-{
- CamelObject *o = vo;
- CamelHookList *hooks;
- CamelHookPair *pair;
- void *k;
-
- hooks = camel_object_get_hooks(o);
- REF_LOCK();
-
- pair = hooks->list;
- while (pair) {
- if (pair->name == bag_name && pair->data == bag) {
- REF_UNLOCK();
- camel_object_unget_hooks(o);
- return;
- }
- pair = pair->next;
- }
-
- pair = pair_alloc();
- pair->name = bag_name;
- pair->data = bag;
- pair->flags = 0;
- pair->func.event = NULL;
-
- pair->next = hooks->list;
- hooks->list = pair;
- hooks->list_length++;
-
- k = bag->copy_key(key);
- g_hash_table_insert(bag->object_table, k, vo);
- g_hash_table_insert(bag->key_table, vo, k);
-
- co_bag_unreserve(bag, key);
-
- REF_UNLOCK();
- camel_object_unget_hooks(o);
-}
-
-/**
- * camel_object_bag_get:
- * @bag:
- * @key:
- *
- * Lookup an object by @key. If the key is currently reserved, then
- * wait until the key has been committed before continuing.
- *
- * Return value: NULL if the object corresponding to @key is not
- * in the bag. Otherwise a ref'd object pointer which the caller owns
- * the ref to.
- **/
-void *
-camel_object_bag_get(CamelObjectBag *bag, const void *key)
-{
- CamelObject *o;
-
- REF_LOCK();
-
- o = g_hash_table_lookup(bag->object_table, key);
- if (o) {
- b(printf("object bag get '%s' = %p\n", (char *)key, o));
-
- /* we use the same lock as the refcount */
- o->ref_count++;
- } else {
- struct _CamelObjectBagKey *res = bag->reserved;
-
- /* check if this name is reserved currently, if so wait till its finished */
- while (res) {
- if (bag->equal_key(res->key, key))
- break;
- res = res->next;
- }
-
- if (res) {
- b(printf("object bag get '%s', reserved, waiting\n", (char *)key));
-
- res->waiters++;
- g_assert(!res->have_owner || !pthread_equal(res->owner, pthread_self()));
- g_cond_wait(res->cond, ref_lock);
- res->waiters--;
-
- /* re-check if it slipped in */
- o = g_hash_table_lookup(bag->object_table, key);
- if (o)
- o->ref_count++;
-
- b(printf("object bag get '%s', finished waiting, got %p\n", (char *)key, o));
-
- /* we don't actually reserve it */
- res->owner = pthread_self();
- res->have_owner = TRUE;
- co_bag_unreserve(bag, key);
- }
- }
-
- REF_UNLOCK();
-
- return o;
-}
-
-/**
- * camel_object_bag_peek:
- * @bag:
- * @key:
- *
- * Lookup the object @key in @bag, ignoring any reservations. If it
- * isn't committed, then it isn't considered. This should only be
- * used where reliable transactional-based state is not required.
- *
- * Unlike other 'peek' operations, the object is still reffed if
- * found.
- *
- * Return value: A referenced object, or NULL if @key is not
- * present in the bag.
- **/
-void *
-camel_object_bag_peek(CamelObjectBag *bag, const void *key)
-{
- CamelObject *o;
-
- REF_LOCK();
-
- o = g_hash_table_lookup(bag->object_table, key);
- if (o) {
- /* we use the same lock as the refcount */
- o->ref_count++;
- }
-
- REF_UNLOCK();
-
- return o;
-}
-
-/**
- * camel_object_bag_reserve:
- * @bag:
- * @key:
- *
- * Reserve a key in the object bag. If the key is already reserved in
- * another thread, then wait until the reservation has been committed.
- *
- * After reserving a key, you either get a reffed pointer to the
- * object corresponding to the key, similar to object_bag_get, or you
- * get NULL, signifying that you then MIST call either object_bag_add
- * or object_bag_abort.
- *
- * You may reserve multiple keys from the same thread, but they should
- * always be reserved in the same order, to avoid deadlocks.
- *
- * Return value:
- **/
-void *
-camel_object_bag_reserve(CamelObjectBag *bag, const void *key)
-{
- CamelObject *o;
-
- REF_LOCK();
-
- o = g_hash_table_lookup(bag->object_table, key);
- if (o) {
- o->ref_count++;
- } else {
- struct _CamelObjectBagKey *res = bag->reserved;
-
- while (res) {
- if (bag->equal_key(res->key, key))
- break;
- res = res->next;
- }
-
- if (res) {
- b(printf("bag reserve %s, already reserved, waiting\n", (char *)key));
- g_assert(!res->have_owner || !pthread_equal(res->owner, pthread_self()));
- res->waiters++;
- g_cond_wait(res->cond, ref_lock);
- res->waiters--;
- /* incase its slipped in while we were waiting */
- o = g_hash_table_lookup(bag->object_table, key);
- if (o) {
- b(printf("finished wait, someone else created '%s' = %p\n", (char *)key, o));
- o->ref_count++;
- /* in which case we dont need to reserve the bag either */
- res->owner = pthread_self();
- res->have_owner = TRUE;
- co_bag_unreserve(bag, key);
- } else {
- b(printf("finished wait, now owner of '%s'\n", (char *)key));
- res->owner = pthread_self();
- res->have_owner = TRUE;
- }
- } else {
- b(printf("bag reserve %s, no key, reserving\n", (char *)key));
- res = g_malloc(sizeof(*res));
- res->waiters = 0;
- res->key = bag->copy_key(key);
- res->cond = g_cond_new();
- res->owner = pthread_self();
- res->have_owner = TRUE;
- res->next = bag->reserved;
- bag->reserved = res;
- }
- }
-
- REF_UNLOCK();
-
- return o;
-}
-
-/**
- * camel_object_bag_abort:
- * @bag:
- * @key:
- *
- * Abort a key reservation.
- **/
-void
-camel_object_bag_abort(CamelObjectBag *bag, const void *key)
-{
- REF_LOCK();
-
- co_bag_unreserve(bag, key);
-
- REF_UNLOCK();
-}
-
-/**
- * camel_object_bag_rekey:
- * @bag:
- * @o:
- * @newkey:
- *
- * Re-key an object, atomically. The key for object @o is set to
- * @newkey, in an atomic manner.
- *
- * It is an api (fatal) error if @o is not currently in the bag.
- **/
-void
-camel_object_bag_rekey(CamelObjectBag *bag, void *o, const void *newkey)
-{
- void *oldkey;
-
- REF_LOCK();
-
- if (g_hash_table_lookup_extended(bag->key_table, o, NULL, &oldkey)) {
- g_hash_table_remove(bag->object_table, oldkey);
- g_hash_table_remove(bag->key_table, o);
- bag->free_key(oldkey);
- oldkey = bag->copy_key(newkey);
- g_hash_table_insert(bag->object_table, oldkey, o);
- g_hash_table_insert(bag->key_table, o, oldkey);
- } else {
- abort();
- }
-
- REF_UNLOCK();
-}
-
-static void
-save_bag(void *key, CamelObject *o, GPtrArray *list)
-{
- /* we have the refcount lock already */
- o->ref_count++;
- g_ptr_array_add(list, o);
-}
-
-/* get a list of all objects in the bag, ref'd
- ignores any reserved keys */
-GPtrArray *
-camel_object_bag_list(CamelObjectBag *bag)
-{
- GPtrArray *list;
-
- list = g_ptr_array_new();
-
- REF_LOCK();
- g_hash_table_foreach(bag->object_table, (GHFunc)save_bag, list);
- REF_UNLOCK();
-
- return list;
-}
-
-/* if bag is NULL, remove all bags from object */
-static void
-camel_object_bag_remove_unlocked(CamelObjectBag *inbag, CamelObject *o, CamelHookList *hooks)
-{
- CamelHookPair *pair, *parent;
- void *oldkey;
- CamelObjectBag *bag;
-
- parent = (CamelHookPair *)&hooks->list;
- pair = parent->next;
- while (pair) {
- if (pair->name == bag_name
- && (inbag == NULL || inbag == pair->data)) {
- bag = pair->data;
- /* lookup object in table? */
- oldkey = g_hash_table_lookup(bag->key_table, o);
- if (oldkey) {
- g_hash_table_remove(bag->key_table, o);
- g_hash_table_remove(bag->object_table, oldkey);
- bag->free_key(oldkey);
- }
- parent->next = pair->next;
- pair_free(pair);
- hooks->list_length--;
- } else {
- parent = pair;
- }
- pair = parent->next;
- }
-}
-
-void
-camel_object_bag_remove(CamelObjectBag *inbag, void *vo)
-{
- CamelObject *o = vo;
- CamelHookList *hooks;
-
- if (o->hooks == NULL)
- return;
-
- hooks = camel_object_get_hooks(o);
- REF_LOCK();
-
- camel_object_bag_remove_unlocked(inbag, o, hooks);
-
- REF_UNLOCK();
- camel_object_unget_hooks(o);
-}
-
/* ********************************************************************** */
void *camel_iterator_new(CamelIteratorVTable *klass, size_t size)
Modified: branches/camel-gobject/camel/camel-object.h
==============================================================================
--- branches/camel-gobject/camel/camel-object.h (original)
+++ branches/camel-gobject/camel/camel-object.h Sun Nov 9 06:35:11 2008
@@ -26,6 +26,7 @@
#define CAMEL_OBJECT_H 1
#include <glib.h>
+#include <glib-object.h>
#include <stdio.h> /* FILE */
#include <stdlib.h> /* size_t */
#include <stdarg.h>
@@ -34,43 +35,99 @@
#include <camel/camel-arg.h>
#include <camel/camel-types.h> /* this is a @##$ #SF stupid header */
+/* The CamelObjectBag API was originally defined in this header,
+ * so include it here for backward-compatibility. */
+#include <camel/camel-object-bag.h>
+
/* turn on so that camel_object_class_dump_tree() dumps object instances as well */
#define CAMEL_OBJECT_TRACK_INSTANCES
-G_BEGIN_DECLS
-
-typedef struct _CamelObjectClass *CamelType;
+/* Standard GObject macros */
+#define CAMEL_TYPE_OBJECT \
+ (camel_object_get_type ())
+#define CAMEL_OBJECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_OBJECT, CamelObject))
+#define CAMEL_OBJECT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_OBJECT, CamelObjectClass))
+#define CAMEL_IS_OBJECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_OBJECT))
+#define CAMEL_IS_OBJECT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_OBJECT))
+#define CAMEL_OBJECT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_OBJECT, CamelObjectClass))
+
+/* Deprecated macros */
+#ifndef CAMEL_DISABLE_DEPRECATED
+
+#define CAMEL_CHECK_CAST(instance, g_type, c_type) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((instance), (g_type), c_type))
+#define CAMEL_CHECK_CLASS_CAST(g_class, g_type, c_type) \
+ (G_TYPE_CHECK_CLASS_CAST ((g_class), (g_type), c_type))
+#define CAMEL_CHECK_TYPE(instance, g_type) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((instance), (g_type)))
+#define CAMEL_CHECK_CLASS_TYPE(g_class, g_type) \
+ (G_TYPE_CHECK_CLASS_TYPE ((g_class), (g_type)))
+
+#define CAMEL_INVALID_TYPE G_TYPE_INVALID
+#define CAMEL_INTERFACE_TYPE G_TYPE_INTERFACE
+#define CAMEL_OBJECT_TYPE CAMEL_TYPE_OBJECT
+#define CAMEL_OBJECT_GET_TYPE(object) (G_OBJECT_TYPE (object))
+
+/* These used to be functions. */
+#define camel_type_init()
+#define camel_type_to_name(g_class) \
+ (G_OBJECT_CLASS_NAME (g_class))
+#define camel_type_get_global_classfuncs(type) \
+ (g_type_class_peek (type))
+#define camel_name_to_type(name) \
+ (g_type_from_name (name))
+#define camel_object_new(type) \
+ (g_object_new ((type), NULL))
+#define camel_object_cast(instance, g_type) \
+ (CAMEL_CHECK_CAST ((instance), (g_type), CamelObject))
+#define camel_object_class_cast(g_class, g_type) \
+ (CAMEL_CHECK_CLASS_CAST ((g_class), (g_type), CamelObjectClass))
+#define camel_object_is(instance, g_type) \
+ (CAMEL_CHECK_TYPE ((instance), (g_type)))
+#define camel_object_class_is(g_class, g_type) \
+ (CAMEL_CHECK_CLASS_TYPE ((g_class), (g_type)))
+#define camel_object_get_interface(instance, g_type) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((instance), (g_type), void))
+#define camel_object_class_dump_tree(g_type)
+
+/* The CamelInterface API was never really used. */
+#define camel_interface_cast(g_class, g_type) \
+ (g_type_interface_peek ((g_class), (g_type)))
+#define camel_interface_is(g_class, g_type) (FALSE)
+#define camel_interface_add_interface(g_class, g_type)
-#ifdef G_DISABLE_CHECKS
-#define CAMEL_CHECK_CAST(obj, ctype, ptype) ((ptype *) obj)
-#define CAMEL_CHECK_CLASS_CAST(klass, ctype, ptype) ((ptype *) klass)
-#else
-#define CAMEL_CHECK_CAST(obj, ctype, ptype) ((ptype *) camel_object_cast ((CamelObject *)(obj), (CamelType)(ctype)))
-#define CAMEL_CHECK_CLASS_CAST(klass, ctype, ptype) ((ptype *) camel_object_class_cast ((CamelObjectClass *)(klass), (CamelType)(ctype) ))
-#endif
-#define CAMEL_CHECK_TYPE(obj, ctype) (camel_object_is ((CamelObject *)(obj), (CamelType)(ctype) ))
-#define CAMEL_CHECK_CLASS_TYPE(klass, ctype) (camel_object_class_is ((CamelObjectClass *)(klass), (CamelType)(ctype)))
+#define camel_object_ref g_object_ref
+#define camel_object_unref g_object_unref
-extern CamelType camel_object_type;
+#endif /* CAMEL_DISABLE_DEPRECATED */
-#define CAMEL_OBJECT_TYPE (camel_object_type)
+G_BEGIN_DECLS
-/* we can't check casts till we've got the type, use the global type variable because its cheaper */
-#define CAMEL_OBJECT(obj) (CAMEL_CHECK_CAST((obj), camel_object_type, CamelObject))
-#define CAMEL_OBJECT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), camel_object_type, CamelObjectClass))
-#define CAMEL_IS_OBJECT(o) (CAMEL_CHECK_TYPE((o), camel_object_type))
-#define CAMEL_IS_OBJECT_CLASS(k) (CAMEL_CHECK_CLASS_TYPE((k), camel_object_type))
+/* XXX sizeof(CamelType) may have changed */
+typedef GType CamelType;
-#define CAMEL_OBJECT_GET_CLASS(o) ((CamelObjectClass *)(CAMEL_OBJECT(o))->klass)
-#define CAMEL_OBJECT_GET_TYPE(o) ((CamelType)(CAMEL_OBJECT(o))->klass)
+#ifndef CAMEL_DISABLE_DEPRECATED
+extern CamelType camel_object_type;
+extern CamelType camel_interface_type;
+#endif /* CAMEL_DISABLE_DEPRECATED */
typedef struct _CamelObjectClass CamelObjectClass;
typedef struct _CamelObject CamelObject;
typedef unsigned int CamelObjectHookID;
+#ifndef CAMEL_DISABLE_DEPRECATED
typedef struct _CamelObjectMeta CamelObjectMeta;
+#endif /* CAMEL_DISABLE_DEPRECATED */
-extern CamelType camel_interface_type;
-#define CAMEL_INTERFACE_TYPE (camel_interface_type)
typedef struct _CamelInterface CamelInterface;
typedef void (*CamelObjectClassInitFunc) (CamelObjectClass *);
@@ -81,8 +138,6 @@
typedef gboolean (*CamelObjectEventPrepFunc) (CamelObject *, gpointer);
typedef void (*CamelObjectEventHookFunc) (CamelObject *, gpointer, gpointer);
-#define CAMEL_INVALID_TYPE (NULL)
-
/* camel object args. */
enum {
/* Get a description of the object. */
@@ -116,6 +171,8 @@
/* TODO: create a simpleobject which has no events on it, or an interface for events */
struct _CamelObject {
+ GObject parent;
+
struct _CamelObjectClass *klass;
guint32 magic; /* only really needed for debugging ... */
@@ -131,8 +188,9 @@
#endif
};
-struct _CamelObjectClass
-{
+struct _CamelObjectClass {
+ GObjectClass parent_class;
+
struct _CamelObjectClass *parent;
guint32 magic; /* in same spot for validation */
@@ -188,8 +246,8 @@
struct _CamelObjectClass type;
};
+#ifndef CAMEL_DISABLE_DEPRECATED
/* The type system .... it's pretty simple..... */
-void camel_type_init (void);
CamelType camel_type_register(CamelType parent, const char * name, /*unsigned int ver, unsigned int rev,*/
size_t instance_size,
size_t classfuncs_size,
@@ -203,39 +261,12 @@
CamelObjectClassInitFunc class_init,
CamelObjectClassFinalizeFunc class_finalize);
-/* deprecated interface */
-#define camel_type_get_global_classfuncs(x) ((CamelObjectClass *)(x))
+#endif /* CAMEL_DISABLE_DEPRECATED */
/* object class methods (types == classes now) */
-const char *camel_type_to_name (CamelType type);
-CamelType camel_name_to_type (const char *name);
void camel_object_class_add_event (CamelObjectClass *klass, const char *name, CamelObjectEventPrepFunc prep);
-void camel_object_class_add_interface(CamelObjectClass *klass, CamelType itype);
-
-void camel_object_class_dump_tree (CamelType root);
-
-/* casting */
-CamelObject *camel_object_cast(CamelObject *obj, CamelType ctype);
-gboolean camel_object_is(CamelObject *obj, CamelType ctype);
-
-CamelObjectClass *camel_object_class_cast (CamelObjectClass *klass, CamelType ctype);
-gboolean camel_object_class_is (CamelObjectClass *klass, CamelType ctype);
-
-CamelObjectClass *camel_interface_cast(CamelObjectClass *klass, CamelType ctype);
-gboolean camel_interface_is(CamelObjectClass *k, CamelType ctype);
-
-CamelType camel_object_get_type (void);
-CamelObject *camel_object_new (CamelType type);
-CamelObject *camel_object_new_name (const char *name);
-
-void camel_object_ref(void *);
-void camel_object_unref(void *);
-
-#ifdef CAMEL_DEBUG
-#define camel_object_ref(o) (printf("%s (%s:%d):ref (%p)\n", __FUNCTION__, __FILE__, __LINE__, o), camel_object_ref(o))
-#define camel_object_unref(o) (printf("%s (%s:%d):unref (%p)\n", __FUNCTION__, __FILE__, __LINE__, o), camel_object_unref (o))
-#endif
+GType camel_object_get_type (void);
/* hooks */
CamelObjectHookID camel_object_hook_event(void *obj, const char *name, CamelObjectEventHookFunc hook, void *data);
@@ -243,9 +274,6 @@
void camel_object_unhook_event(void *obj, const char *name, CamelObjectEventHookFunc hook, void *data);
void camel_object_trigger_event(void *obj, const char *name, void *event_data);
-/* interfaces */
-void *camel_object_get_interface(void *vo, CamelType itype);
-
/* get/set methods */
int camel_object_set(void *obj, struct _CamelException *ex, ...);
int camel_object_setv(void *obj, struct _CamelException *ex, CamelArgV *);
@@ -267,21 +295,7 @@
/* free a retrieved object. May be a noop for static data. */
void camel_object_free(void *vo, guint32 tag, void *value);
-/* for managing bags of weakly-ref'd 'child' objects */
-typedef struct _CamelObjectBag CamelObjectBag;
-typedef void *(*CamelCopyFunc)(const void *vo);
-
-CamelObjectBag *camel_object_bag_new(GHashFunc hash, GEqualFunc equal, CamelCopyFunc keycopy, GFreeFunc keyfree);
-void *camel_object_bag_get(CamelObjectBag *bag, const void *key);
-void *camel_object_bag_peek(CamelObjectBag *bag, const void *key);
-void *camel_object_bag_reserve(CamelObjectBag *bag, const void *key);
-void camel_object_bag_add(CamelObjectBag *bag, const void *key, void *vo);
-void camel_object_bag_abort(CamelObjectBag *bag, const void *key);
-void camel_object_bag_rekey(CamelObjectBag *bag, void *o, const void *newkey);
-GPtrArray *camel_object_bag_list(CamelObjectBag *bag);
-void camel_object_bag_remove(CamelObjectBag *bag, void *o);
-void camel_object_bag_destroy(CamelObjectBag *bag);
-
+#ifndef CAMEL_DISABLE_DEPRECATED
#define CAMEL_MAKE_CLASS(type, tname, parent, pname) \
static CamelType type##_type; \
static pname##Class * type##_parent_class; \
@@ -303,6 +317,7 @@
\
return type##_type; \
}
+#endif /* CAMEL_DISABLE_DEPRECATED */
/* Utility functions, not object specific, but too small to separate */
typedef struct _CamelIteratorVTable CamelIteratorVTable;
Modified: branches/camel-gobject/camel/camel-offline-folder.c
==============================================================================
--- branches/camel-gobject/camel/camel-offline-folder.c (original)
+++ branches/camel-gobject/camel/camel-offline-folder.c Sun Nov 9 06:35:11 2008
@@ -56,7 +56,7 @@
CamelType
camel_offline_folder_get_type (void)
{
- static CamelType type = NULL;
+ static CamelType type = 0;
if (!type) {
type = camel_type_register (CAMEL_FOLDER_TYPE,
Modified: branches/camel-gobject/camel/camel-vee-store.c
==============================================================================
--- branches/camel-gobject/camel/camel-vee-store.c (original)
+++ branches/camel-gobject/camel/camel-vee-store.c Sun Nov 9 06:35:11 2008
@@ -75,7 +75,7 @@
{
CamelStoreClass *store_class = (CamelStoreClass *) klass;
- camel_vee_store_parent = (CamelStoreClass *)camel_store_get_type();
+ camel_vee_store_parent = camel_type_get_global_classfuncs (camel_store_get_type());
/* virtual method overload */
store_class->get_folder = vee_get_folder;
Modified: branches/camel-gobject/camel/camel-vtrash-folder.c
==============================================================================
--- branches/camel-gobject/camel/camel-vtrash-folder.c (original)
+++ branches/camel-gobject/camel/camel-vtrash-folder.c Sun Nov 9 06:35:11 2008
@@ -653,7 +653,7 @@
{
CamelFolderClass *folder_class = (CamelFolderClass *) klass;
- camel_vtrash_folder_parent = CAMEL_VEE_FOLDER_CLASS(camel_vee_folder_get_type());
+ camel_vtrash_folder_parent = camel_type_get_global_classfuncs (camel_vee_folder_get_type());
/* Not required from here on. We don't count */
((CamelObjectClass *)klass)->getv = vtrash_getv;
Modified: branches/camel-gobject/camel/camel.h
==============================================================================
--- branches/camel-gobject/camel/camel.h (original)
+++ branches/camel-gobject/camel/camel.h Sun Nov 9 06:35:11 2008
@@ -89,6 +89,7 @@
#include <camel/camel-news-address.h>
#include <camel/camel-nntp-address.h>
#include <camel/camel-object.h>
+#include <camel/camel-object-bag.h>
#include <camel/camel-offline-folder.h>
#include <camel/camel-offline-journal.h>
#include <camel/camel-offline-store.h>
Modified: branches/camel-gobject/camel/providers/imap/camel-imap-folder.c
==============================================================================
--- branches/camel-gobject/camel/providers/imap/camel-imap-folder.c (original)
+++ branches/camel-gobject/camel/providers/imap/camel-imap-folder.c Sun Nov 9 06:35:11 2008
@@ -148,7 +148,8 @@
{
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_imap_folder_class);
- offline_folder_class = CAMEL_OFFLINE_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_offline_folder_get_type ()));
+ parent_class = camel_type_get_global_classfuncs (camel_offline_folder_get_type());
+ offline_folder_class = camel_type_get_global_classfuncs (camel_offline_folder_get_type ());
/* virtual method overload */
((CamelObjectClass *)camel_imap_folder_class)->getv = imap_getv;
@@ -199,9 +200,8 @@
if (camel_imap_folder_type == CAMEL_INVALID_TYPE) {
int i;
- parent_class = camel_offline_folder_get_type();
camel_imap_folder_type =
- camel_type_register (parent_class, "CamelImapFolder",
+ camel_type_register (camel_offline_folder_get_type (), "CamelImapFolder",
sizeof (CamelImapFolder),
sizeof (CamelImapFolderClass),
(CamelObjectClassInitFunc) camel_imap_folder_class_init,
Modified: branches/camel-gobject/camel/providers/imap/camel-imap-store-summary.c
==============================================================================
--- branches/camel-gobject/camel/providers/imap/camel-imap-store-summary.c (original)
+++ branches/camel-gobject/camel/providers/imap/camel-imap-store-summary.c Sun Nov 9 06:35:11 2008
@@ -69,6 +69,8 @@
{
CamelStoreSummaryClass *ssklass = (CamelStoreSummaryClass *)klass;
+ camel_imap_store_summary_parent = camel_type_get_global_classfuncs (camel_store_summary_get_type());
+
ssklass->summary_header_load = summary_header_load;
ssklass->summary_header_save = summary_header_save;
@@ -108,8 +110,7 @@
static CamelType type = CAMEL_INVALID_TYPE;
if (type == CAMEL_INVALID_TYPE) {
- camel_imap_store_summary_parent = (CamelStoreSummaryClass *)camel_store_summary_get_type();
- type = camel_type_register((CamelType)camel_imap_store_summary_parent, "CamelImapStoreSummary",
+ type = camel_type_register(camel_store_summary_get_type (), "CamelImapStoreSummary",
sizeof (CamelImapStoreSummary),
sizeof (CamelImapStoreSummaryClass),
(CamelObjectClassInitFunc) camel_imap_store_summary_class_init,
Modified: branches/camel-gobject/camel/providers/imap4/camel-imap4-store-summary.c
==============================================================================
--- branches/camel-gobject/camel/providers/imap4/camel-imap4-store-summary.c (original)
+++ branches/camel-gobject/camel/providers/imap4/camel-imap4-store-summary.c Sun Nov 9 06:35:11 2008
@@ -82,7 +82,7 @@
{
CamelStoreSummaryClass *ssklass = (CamelStoreSummaryClass *) klass;
- parent_class = (CamelStoreSummaryClass *) camel_store_summary_get_type ();
+ parent_class = (CamelStoreSummaryClass *) camel_type_get_global_classfuncs (camel_store_summary_get_type ());
ssklass->summary_header_load = summary_header_load;
ssklass->summary_header_save = summary_header_save;
Modified: branches/camel-gobject/camel/providers/imapp/camel-imapp-folder.c
==============================================================================
--- branches/camel-gobject/camel/providers/imapp/camel-imapp-folder.c (original)
+++ branches/camel-gobject/camel/providers/imapp/camel-imapp-folder.c Sun Nov 9 06:35:11 2008
@@ -60,7 +60,7 @@
{
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_imapp_folder_class);
- parent_class = CAMEL_FOLDER_CLASS(camel_folder_get_type());
+ parent_class = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs(camel_folder_get_type()));
/* virtual method overload */
camel_folder_class->refresh_info = imap_refresh_info;
Modified: branches/camel-gobject/camel/providers/local/camel-local-folder.c
==============================================================================
--- branches/camel-gobject/camel/providers/local/camel-local-folder.c (original)
+++ branches/camel-gobject/camel/providers/local/camel-local-folder.c Sun Nov 9 06:35:11 2008
@@ -96,6 +96,8 @@
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_local_folder_class);
CamelObjectClass *oklass = (CamelObjectClass *)camel_local_folder_class;
+ parent_class = (CamelFolderClass *) camel_type_get_global_classfuncs(camel_folder_get_type());
+
/* virtual method definition */
/* virtual method overload */
@@ -184,7 +186,6 @@
if (camel_local_folder_type == CAMEL_INVALID_TYPE) {
int i;
- parent_class = (CamelFolderClass *)camel_folder_get_type();
camel_local_folder_type = camel_type_register(camel_folder_get_type(), "CamelLocalFolder",
sizeof(CamelLocalFolder),
sizeof(CamelLocalFolderClass),
Modified: branches/camel-gobject/camel/providers/local/camel-spool-folder.c
==============================================================================
--- branches/camel-gobject/camel/providers/local/camel-spool-folder.c (original)
+++ branches/camel-gobject/camel/providers/local/camel-spool-folder.c Sun Nov 9 06:35:11 2008
@@ -70,7 +70,7 @@
{
CamelLocalFolderClass *lklass = (CamelLocalFolderClass *)klass;
- parent_class = (CamelFolderClass *)camel_mbox_folder_get_type();
+ parent_class = (CamelFolderClass *)camel_type_get_global_classfuncs(camel_mbox_folder_get_type());
lklass->create_summary = spool_create_summary;
lklass->lock = spool_lock;
Modified: branches/camel-gobject/camel/providers/local/camel-spool-store.c
==============================================================================
--- branches/camel-gobject/camel/providers/local/camel-spool-store.c (original)
+++ branches/camel-gobject/camel/providers/local/camel-spool-store.c Sun Nov 9 06:35:11 2008
@@ -77,7 +77,7 @@
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_spool_store_class);
CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_spool_store_class);
- parent_class = CAMEL_STORE_CLASS(camel_mbox_store_get_type());
+ parent_class = CAMEL_STORE_CLASS(camel_type_get_global_classfuncs (camel_mbox_store_get_type()));
/* virtual method overload */
camel_service_class->construct = construct;
Modified: branches/camel-gobject/camel/providers/pop3/camel-pop3-folder.c
==============================================================================
--- branches/camel-gobject/camel/providers/pop3/camel-pop3-folder.c (original)
+++ branches/camel-gobject/camel/providers/pop3/camel-pop3-folder.c Sun Nov 9 06:35:11 2008
@@ -60,7 +60,7 @@
{
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_pop3_folder_class);
- parent_class = CAMEL_FOLDER_CLASS(camel_folder_get_type());
+ parent_class = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs(camel_folder_get_type()));
/* virtual method overload */
camel_folder_class->refresh_info = pop3_refresh_info;
Added: branches/camel-gobject/evolution.patch
==============================================================================
--- (empty file)
+++ branches/camel-gobject/evolution.patch Sun Nov 9 06:35:11 2008
@@ -0,0 +1,21 @@
+Index: mail/mail-session.c
+===================================================================
+--- mail/mail-session.c (revision 36765)
++++ mail/mail-session.c (working copy)
+@@ -115,6 +115,8 @@ class_init (MailSessionClass *mail_sessi
+ {
+ CamelSessionClass *camel_session_class = CAMEL_SESSION_CLASS (mail_session_class);
+
++ ms_parent_class = g_type_class_peek_parent (mail_session_class);
++
+ /* virtual method override */
+ camel_session_class->get_password = get_password;
+ camel_session_class->forget_password = forget_password;
+@@ -132,7 +134,6 @@ mail_session_get_type (void)
+ static CamelType mail_session_type = CAMEL_INVALID_TYPE;
+
+ if (mail_session_type == CAMEL_INVALID_TYPE) {
+- ms_parent_class = (CamelSessionClass *)camel_session_get_type();
+ mail_session_type = camel_type_register (
+ camel_session_get_type (),
+ "MailSession",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]