aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mail-remote
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2005-05-26 18:40:56 +0800
committerMichael Zucci <zucchi@src.gnome.org>2005-05-26 18:40:56 +0800
commit10c92931e083b34d3395744433edda5a493a3054 (patch)
treee433d945f32e7316771e3b518afb29736c64a4f0 /plugins/mail-remote
parentf657c69d7b4375a9a4fd202890b17a1e7e280d89 (diff)
downloadgsoc2013-evolution-10c92931e083b34d3395744433edda5a493a3054.tar
gsoc2013-evolution-10c92931e083b34d3395744433edda5a493a3054.tar.gz
gsoc2013-evolution-10c92931e083b34d3395744433edda5a493a3054.tar.bz2
gsoc2013-evolution-10c92931e083b34d3395744433edda5a493a3054.tar.lz
gsoc2013-evolution-10c92931e083b34d3395744433edda5a493a3054.tar.xz
gsoc2013-evolution-10c92931e083b34d3395744433edda5a493a3054.tar.zst
gsoc2013-evolution-10c92931e083b34d3395744433edda5a493a3054.zip
New helpers for listeners.
2005-05-26 Not Zed <NotZed@Ximian.com> * evolution-mail-folderlistener.[ch]: * evolution-mail-sessionlistener.[ch]: * evolution-mail-storelistener.[ch]: New helpers for listeners. * evolution-mail-listener.[ch]: removed. * Evolution-DataServer-Mail.idl: removed the GNOME prefix, Bonobo doesn't use it, and it just adds pointless typing. Added getmessage and appendmessage interaces. Moved listeners to each object rather than one global listener. svn path=/trunk/; revision=29414
Diffstat (limited to 'plugins/mail-remote')
-rw-r--r--plugins/mail-remote/ChangeLog13
-rw-r--r--plugins/mail-remote/Evolution-DataServer-Mail.idl68
-rw-r--r--plugins/mail-remote/Makefile.am16
-rw-r--r--plugins/mail-remote/client.c89
-rw-r--r--plugins/mail-remote/e-corba-utils.c188
-rw-r--r--plugins/mail-remote/e-corba-utils.h24
-rw-r--r--plugins/mail-remote/evolution-mail-folder.c175
-rw-r--r--plugins/mail-remote/evolution-mail-folder.h5
-rw-r--r--plugins/mail-remote/evolution-mail-folderlistener.c155
-rw-r--r--plugins/mail-remote/evolution-mail-folderlistener.h54
-rw-r--r--plugins/mail-remote/evolution-mail-listener.c232
-rw-r--r--plugins/mail-remote/evolution-mail-listener.h56
-rw-r--r--plugins/mail-remote/evolution-mail-marshal.list4
-rw-r--r--plugins/mail-remote/evolution-mail-messageiterator.c25
-rw-r--r--plugins/mail-remote/evolution-mail-messageiterator.h2
-rw-r--r--plugins/mail-remote/evolution-mail-session.c206
-rw-r--r--plugins/mail-remote/evolution-mail-session.h8
-rw-r--r--plugins/mail-remote/evolution-mail-sessionlistener.c179
-rw-r--r--plugins/mail-remote/evolution-mail-sessionlistener.h54
-rw-r--r--plugins/mail-remote/evolution-mail-store.c138
-rw-r--r--plugins/mail-remote/evolution-mail-store.h5
-rw-r--r--plugins/mail-remote/evolution-mail-storelistener.c155
-rw-r--r--plugins/mail-remote/evolution-mail-storelistener.h54
23 files changed, 1233 insertions, 672 deletions
diff --git a/plugins/mail-remote/ChangeLog b/plugins/mail-remote/ChangeLog
index 21ad107acd..de6a0cb4b9 100644
--- a/plugins/mail-remote/ChangeLog
+++ b/plugins/mail-remote/ChangeLog
@@ -1,3 +1,16 @@
+2005-05-26 Not Zed <NotZed@Ximian.com>
+
+ * evolution-mail-folderlistener.[ch]:
+ * evolution-mail-sessionlistener.[ch]:
+ * evolution-mail-storelistener.[ch]: New helpers for listeners.
+
+ * evolution-mail-listener.[ch]: removed.
+
+ * Evolution-DataServer-Mail.idl: removed the GNOME prefix, Bonobo
+ doesn't use it, and it just adds pointless typing. Added
+ getmessage and appendmessage interaces. Moved listeners to each
+ object rather than one global listener.
+
2005-05-24 Not Zed <NotZed@Ximian.com>
* Lots more work. Now implements a full listener interface.
diff --git a/plugins/mail-remote/Evolution-DataServer-Mail.idl b/plugins/mail-remote/Evolution-DataServer-Mail.idl
index ffd32f8594..4d6b0ad43d 100644
--- a/plugins/mail-remote/Evolution-DataServer-Mail.idl
+++ b/plugins/mail-remote/Evolution-DataServer-Mail.idl
@@ -10,7 +10,6 @@
#include <Bonobo.idl>
-module GNOME {
module Evolution {
module Mail {
exception NOT_SUPPORTED {
@@ -18,7 +17,7 @@ module Mail {
};
exception FAILED {
- string why;
+// string why;
};
interface Folder;
@@ -113,43 +112,43 @@ module Mail {
};
typedef sequence <FolderChange> FolderChanges;
- interface Listener : Bonobo::Unknown {
- oneway void sessionChanged(in Session session, in SessionChanges changes);
- // maybe folder/store should be folderinfo/storeinfo?
- oneway void storeChanged(in Session session, in Store store, in StoreChanges changes);
- oneway void folderChanged(in Session session, in Store store, in Folder folder, in FolderChanges changes);
+ /* ********************************************************************** */
+ /* listeners */
+
+ interface SessionListener : Bonobo::Unknown {
+ oneway void changed(in Session session, in SessionChanges changes);
+
+ oneway void shutdown(in Session session);
+ };
+
+ interface StoreListener : Bonobo::Unknown {
+ oneway void changed(in Store store, in StoreChanges changes);
+ };
- // session is closed/exited?
- //oneway void closed();
+ interface FolderListener : Bonobo::Unknown {
+ oneway void changed(in Folder folder, in FolderChanges changes);
};
/* ********************************************************************** */
- interface Session : Bonobo::Unknown {
- // Flags to pass to addListener
- const long SESSION_ADDED = 1 << 0;
- const long SESSION_CHANGED = 1 << 1;
- const long SESSION_REMOVED = 1 << 2;
- const long STORE_ADDED = 1 << 3;
- const long STORE_CHANGED = 1 << 4;
- const long STORE_REMOVED = 1 << 5;
- const long FOLDER_ADDED = 1 << 6;
- const long FOLDER_CHANGED = 1 << 7;
- const long FOLDER_REMOVED = 1 << 8;
+// If this is done, then Session shouldn't have add/removeListener anymore
+// interface Factory : Bonobo::Unknown {
+// Session getSession(in string base, in SessionListener listener);
+// };
+ interface Session : Bonobo::Unknown {
boolean getProperties(in PropertyNames names, out Properties props);
- StoreInfos getStores(in string pattern);
+ StoreInfos getStores(in string pattern, in StoreListener listener);
- /* flags defines what to listen to */
- void addListener(in Listener listener, in long flags);
- void removeListener(in Listener listener);
+ void addListener(in SessionListener listener);
+ void removeListener(in SessionListener listener);
};
interface Store : Bonobo::Unknown {
boolean getProperties(in PropertyNames names, out Properties props);
- FolderInfos getFolders(in string pattern)
+ FolderInfos getFolders(in string pattern, in FolderListener listener)
raises (NOT_SUPPORTED, FAILED);
void sendMessage(in Bonobo::Stream msg)
@@ -157,21 +156,28 @@ module Mail {
};
interface MessageIterator : Bonobo::Unknown {
- MessageInfos next(in long limit);
+ MessageInfos next(in long limit)
+ raises (FAILED);
+
+ void dispose();
};
interface Folder : Bonobo::Unknown {
boolean getProperties(in PropertyNames names, out Properties props);
- MessageIterator getMessages(in string pattern);
+ MessageIterator getMessages(in string pattern)
+ raises (NOT_SUPPORTED, FAILED);
- void changeMessages(in MessageInfoSets infos);
+ void changeMessages(in MessageInfoSets infos)
+ raises (NOT_SUPPORTED);
-// Bonobo::Stream getMessage(in string uid);
-// void appendMessage(in MessageInfoSet info, in Bonobo::Stream msg);
+ Bonobo::Stream getMessage(in string uid)
+ raises (NOT_SUPPORTED, FAILED);
+
+ void appendMessage(in MessageInfoSet info, in Bonobo::Stream msg)
+ raises (NOT_SUPPORTED, FAILED);
};
};
};
-};
#endif
diff --git a/plugins/mail-remote/Makefile.am b/plugins/mail-remote/Makefile.am
index 8a43ea3473..8214ce36f1 100644
--- a/plugins/mail-remote/Makefile.am
+++ b/plugins/mail-remote/Makefile.am
@@ -15,16 +15,20 @@ liborg_gnome_evolution_mail_remote_la_SOURCES = \
e-corba-utils.h \
evolution-mail-folder.c \
evolution-mail-folder.h \
- evolution-mail-listener.c \
- evolution-mail-listener.h \
+ evolution-mail-folderlistener.c \
+ evolution-mail-folderlistener.h \
+ evolution-mail-marshal.c \
+ evolution-mail-marshal.h \
evolution-mail-messageiterator.c \
evolution-mail-messageiterator.h \
evolution-mail-session.c \
evolution-mail-session.h \
+ evolution-mail-sessionlistener.c \
+ evolution-mail-sessionlistener.h \
evolution-mail-store.c \
evolution-mail-store.h \
- evolution-mail-marshal.c \
- evolution-mail-marshal.h \
+ evolution-mail-storelistener.c \
+ evolution-mail-storelistener.h \
mail-remote.c
liborg_gnome_evolution_mail_remote_la_LDFLAGS = -module -avoid-version
@@ -34,7 +38,9 @@ client_SOURCES = \
client_LDADD = \
$(EVOLUTION_MAIL_LIBS) \
- evolution-mail-listener.o \
+ evolution-mail-sessionlistener.o \
+ evolution-mail-storelistener.o \
+ evolution-mail-folderlistener.o \
evolution-mail-marshal.o \
Evolution-DataServer-Mail-common.o \
Evolution-DataServer-Mail-stubs.o \
diff --git a/plugins/mail-remote/client.c b/plugins/mail-remote/client.c
index fae7401a36..0db3212426 100644
--- a/plugins/mail-remote/client.c
+++ b/plugins/mail-remote/client.c
@@ -6,17 +6,21 @@
#include "Evolution-DataServer-Mail.h"
-#include "evolution-mail-listener.h"
+#include "evolution-mail-sessionlistener.h"
+#include "evolution-mail-storelistener.h"
+#include "evolution-mail-folderlistener.h"
#include <camel/camel-folder.h>
-static EvolutionMailListener *listener;
+static EvolutionMailSessionListener *listener_sess;
+static EvolutionMailStoreListener *listener_store;
+static EvolutionMailFolderListener *listener_folder;
-static GNOME_Evolution_Mail_Session
+static Evolution_Mail_Session
get_session(void)
{
char *path, *ior;
- GNOME_Evolution_Mail_Session sess = NULL;
+ Evolution_Mail_Session sess = NULL;
CORBA_Environment ev = { 0 };
/* The new-improved bonobo-activation ... */
@@ -28,8 +32,10 @@ get_session(void)
}
if (sess != CORBA_OBJECT_NIL) {
- listener = evolution_mail_listener_new();
- GNOME_Evolution_Mail_Session_addListener(sess, bonobo_object_corba_objref((BonoboObject *)listener), 0, &ev);
+ listener_sess = evolution_mail_sessionlistener_new();
+ listener_store = evolution_mail_storelistener_new();
+ listener_folder = evolution_mail_folderlistener_new();
+ Evolution_Mail_Session_addListener(sess, bonobo_object_corba_objref((BonoboObject *)listener_sess), &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("AddListener failed: %s\n", ev._id);
CORBA_exception_free(&ev);
@@ -40,13 +46,13 @@ get_session(void)
}
static void
-list_folder(GNOME_Evolution_Mail_Folder folder)
+list_folder(Evolution_Mail_Folder folder)
{
CORBA_Environment ev = { 0 };
- GNOME_Evolution_Mail_MessageIterator iter;
+ Evolution_Mail_MessageIterator iter;
int more, total = 0;
- iter = GNOME_Evolution_Mail_Folder_getMessages(folder, "", &ev);
+ iter = Evolution_Mail_Folder_getMessages(folder, "", &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("getmessages failed: %s\n", ev._id);
CORBA_exception_free(&ev);
@@ -54,10 +60,10 @@ list_folder(GNOME_Evolution_Mail_Folder folder)
}
do {
- GNOME_Evolution_Mail_MessageInfos *msgs;
+ Evolution_Mail_MessageInfos *msgs;
int i;
- msgs = GNOME_Evolution_Mail_MessageIterator_next(iter, 50, &ev);
+ msgs = Evolution_Mail_MessageIterator_next(iter, 50, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("msgs.next(): %s\n", ev._id);
CORBA_exception_free(&ev);
@@ -66,19 +72,19 @@ list_folder(GNOME_Evolution_Mail_Folder folder)
/* NB: set the first 50 messages in private to unseen */
if (total == 0) {
- GNOME_Evolution_Mail_MessageInfoSets *changes;
+ Evolution_Mail_MessageInfoSets *changes;
int j;
- changes = GNOME_Evolution_Mail_MessageInfoSets__alloc();
+ changes = Evolution_Mail_MessageInfoSets__alloc();
changes->_length = msgs->_length;
changes->_maximum = msgs->_maximum;
- changes->_buffer = GNOME_Evolution_Mail_MessageInfoSets_allocbuf(changes->_maximum);
+ changes->_buffer = Evolution_Mail_MessageInfoSets_allocbuf(changes->_maximum);
for (j=0;j<msgs->_length;j++) {
changes->_buffer[j].uid = CORBA_string_dup(msgs->_buffer[j].uid);
changes->_buffer[j].flagSet = 0;
changes->_buffer[j].flagMask = CAMEL_MESSAGE_SEEN;
}
- GNOME_Evolution_Mail_Folder_changeMessages(folder, changes, &ev);
+ Evolution_Mail_Folder_changeMessages(folder, changes, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("changemessages failed: %s\n", ev._id);
CORBA_exception_free(&ev);
@@ -96,22 +102,47 @@ list_folder(GNOME_Evolution_Mail_Folder folder)
CORBA_free(msgs);
} while (more);
+ Evolution_Mail_MessageIterator_dispose(iter, &ev);
CORBA_Object_release(iter, &ev);
printf("Got %d messages total\n", total);
}
+static void
+add_message(Evolution_Mail_Folder folder, const char *msg)
+{
+ BonoboObject *mem;
+ CORBA_Environment ev = { 0 };
+ Evolution_Mail_MessageInfoSet mis = { 0 };
+
+ mis.uid = "";
+ mis.flagSet = CAMEL_MESSAGE_SEEN;
+ mis.flagMask = CAMEL_MESSAGE_SEEN;
+
+ mem = bonobo_stream_mem_create(msg, strlen(msg), TRUE, FALSE);
+
+ printf("attempt send mail to store\n");
+ Evolution_Mail_Folder_appendMessage(folder, &mis, bonobo_object_corba_objref(mem), &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ printf("appendmessage failed: %s\n", ev._id);
+ CORBA_exception_free(&ev);
+ CORBA_exception_init(&ev);
+ }
+
+ bonobo_object_unref(mem);
+}
+
static int domain(void *data)
{
- GNOME_Evolution_Mail_Session sess;
- GNOME_Evolution_Mail_StoreInfos *stores;
- GNOME_Evolution_Mail_FolderInfos *folders;
+ Evolution_Mail_Session sess;
+ Evolution_Mail_StoreInfos *stores;
+ Evolution_Mail_FolderInfos *folders;
CORBA_Environment ev = { 0 };
int i, j, f;
sess = get_session();
- stores = GNOME_Evolution_Mail_Session_getStores(sess, "", &ev);
+ stores = Evolution_Mail_Session_getStores(sess, "", bonobo_object_corba_objref((BonoboObject *)listener_store), &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("getStores failed: %s\n", ev._id);
CORBA_exception_free(&ev);
@@ -122,22 +153,22 @@ static int domain(void *data)
printf("Got %d stores\n", stores->_length);
for (i=0;i<stores->_length;i++) {
#if 0
- GNOME_Evolution_Mail_PropertyName namesarray[] = {
+ Evolution_Mail_PropertyName namesarray[] = {
"name", "uid"
};
- GNOME_Evolution_Mail_PropertyNames names = {
+ Evolution_Mail_PropertyNames names = {
2, 2,
namesarray,
FALSE,
};
- GNOME_Evolution_Mail_Properties *props;
+ Evolution_Mail_Properties *props;
#endif
- GNOME_Evolution_Mail_Store store = stores->_buffer[i].store;
+ Evolution_Mail_Store store = stores->_buffer[i].store;
printf("store %p '%s' uid '%s'\n", store, stores->_buffer[i].name, stores->_buffer[i].uid);
#if 0
- GNOME_Evolution_Mail_Store_getProperties(store, &names, &props, &ev);
+ Evolution_Mail_Store_getProperties(store, &names, &props, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("getProperties failed\n");
return 1;
@@ -167,7 +198,7 @@ static int domain(void *data)
mem = bonobo_stream_mem_create(msg, strlen(msg), TRUE, FALSE);
printf("attempt send mail to store\n");
- GNOME_Evolution_Mail_Store_sendMessage(store, bonobo_object_corba_objref(mem), &ev);
+ Evolution_Mail_Store_sendMessage(store, bonobo_object_corba_objref(mem), &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("sendmessage failed: %s\n", ev._id);
CORBA_exception_free(&ev);
@@ -178,7 +209,7 @@ static int domain(void *data)
}
#endif
- folders = GNOME_Evolution_Mail_Store_getFolders(store, "", &ev);
+ folders = Evolution_Mail_Store_getFolders(store, "", bonobo_object_corba_objref((BonoboObject *)listener_folder), &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
printf("getfolders failed\n");
/* FIXME: leaks ex data? */
@@ -190,7 +221,13 @@ static int domain(void *data)
for (f = 0; f<folders->_length;f++) {
if (!strcmp(folders->_buffer[f].full_name, "Private")) {
+ const char *msg = "To: notzed@novell.com\r\n"
+ "Subject: This is a test append from client\r\n"
+ "\r\n"
+ "Blah blah, test appended message!\r\n";
+
list_folder(folders->_buffer[f].folder);
+ add_message(folders->_buffer[f].folder, msg);
}
}
diff --git a/plugins/mail-remote/e-corba-utils.c b/plugins/mail-remote/e-corba-utils.c
index 545ac425e3..2396f52d70 100644
--- a/plugins/mail-remote/e-corba-utils.c
+++ b/plugins/mail-remote/e-corba-utils.c
@@ -5,9 +5,24 @@
#include "evolution-mail-folder.h"
#include <camel/camel-folder-summary.h>
+#include <camel/camel-stream-mem.h>
+#include <camel/camel-mime-message.h>
+
+#include <bonobo/bonobo-stream-memory.h>
+
+#include <libedataserver/e-msgport.h>
+
+CORBA_char *
+e_corba_strdup(const char *v)
+{
+ if (v)
+ return CORBA_string_dup(v);
+ else
+ return CORBA_string_dup("");
+}
void
-e_mail_property_set_string(GNOME_Evolution_Mail_Property *prop, const char *name, const char *val)
+e_mail_property_set_string(Evolution_Mail_Property *prop, const char *name, const char *val)
{
prop->value._release = CORBA_TRUE;
prop->value._type = TC_CORBA_string;
@@ -17,7 +32,7 @@ e_mail_property_set_string(GNOME_Evolution_Mail_Property *prop, const char *name
}
void
-e_mail_property_set_null(GNOME_Evolution_Mail_Property *prop, const char *name)
+e_mail_property_set_null(Evolution_Mail_Property *prop, const char *name)
{
prop->value._release = CORBA_TRUE;
prop->value._type = TC_null;
@@ -25,7 +40,7 @@ e_mail_property_set_null(GNOME_Evolution_Mail_Property *prop, const char *name)
}
void
-e_mail_storeinfo_set_store(GNOME_Evolution_Mail_StoreInfo *si, EvolutionMailStore *store)
+e_mail_storeinfo_set_store(Evolution_Mail_StoreInfo *si, EvolutionMailStore *store)
{
si->name = CORBA_string_dup(evolution_mail_store_get_name(store));
si->uid = CORBA_string_dup(evolution_mail_store_get_uid(store));
@@ -33,23 +48,23 @@ e_mail_storeinfo_set_store(GNOME_Evolution_Mail_StoreInfo *si, EvolutionMailStor
}
void
-e_mail_messageinfo_set_message(GNOME_Evolution_Mail_MessageInfo *mi, CamelMessageInfo *info)
+e_mail_messageinfo_set_message(Evolution_Mail_MessageInfo *mi, CamelMessageInfo *info)
{
const CamelTag *tag;
const CamelFlag *flag;
int i;
mi->uid = CORBA_string_dup(camel_message_info_uid(info));
- mi->subject = CORBA_string_dup(camel_message_info_subject(info));
- mi->to = CORBA_string_dup(camel_message_info_to(info));
- mi->from = CORBA_string_dup(camel_message_info_from(info));
+ mi->subject = e_corba_strdup(camel_message_info_subject(info));
+ mi->to = e_corba_strdup(camel_message_info_to(info));
+ mi->from = e_corba_strdup(camel_message_info_from(info));
mi->flags = camel_message_info_flags(info);
flag = camel_message_info_user_flags(info);
mi->userFlags._maximum = camel_flag_list_size((CamelFlag **)&flag);
mi->userFlags._length = mi->userFlags._maximum;
if (mi->userFlags._maximum) {
- mi->userFlags._buffer = GNOME_Evolution_Mail_UserFlags_allocbuf(mi->userFlags._maximum);
+ mi->userFlags._buffer = Evolution_Mail_UserFlags_allocbuf(mi->userFlags._maximum);
CORBA_sequence_set_release(&mi->userFlags, CORBA_TRUE);
for (i=0;flag;flag = flag->next,i++) {
@@ -62,7 +77,7 @@ e_mail_messageinfo_set_message(GNOME_Evolution_Mail_MessageInfo *mi, CamelMessag
mi->userTags._maximum = camel_tag_list_size((CamelTag **)&tag);
mi->userTags._length = mi->userTags._maximum;
if (mi->userTags._maximum) {
- mi->userTags._buffer = GNOME_Evolution_Mail_UserTags_allocbuf(mi->userTags._maximum);
+ mi->userTags._buffer = Evolution_Mail_UserTags_allocbuf(mi->userTags._maximum);
CORBA_sequence_set_release(&mi->userFlags, CORBA_TRUE);
for (i=0;tag;tag = tag->next,i++) {
@@ -74,8 +89,24 @@ e_mail_messageinfo_set_message(GNOME_Evolution_Mail_MessageInfo *mi, CamelMessag
}
}
+CamelMessageInfo *
+e_mail_messageinfoset_to_info(const Evolution_Mail_MessageInfoSet *mi)
+{
+ CamelMessageInfo *info;
+ int i;
+
+ info = camel_message_info_new(NULL);
+ camel_message_info_set_flags(info, mi->flagSet, mi->flagMask);
+ for (i=0;i<mi->userFlagSet._length;i++)
+ camel_message_info_set_user_flag(info, mi->userFlagSet._buffer[i], TRUE);
+ for (i=0;i<mi->userTags._length;i++)
+ camel_message_info_set_user_tag(info, mi->userTags._buffer[i].name, mi->userTags._buffer[i].value);
+
+ return info;
+}
+
void
-e_mail_folderinfo_set_folder(GNOME_Evolution_Mail_FolderInfo *fi, EvolutionMailFolder *emf)
+e_mail_folderinfo_set_folder(Evolution_Mail_FolderInfo *fi, EvolutionMailFolder *emf)
{
fi->name = CORBA_string_dup(emf->name);
fi->full_name = CORBA_string_dup(emf->full_name);
@@ -111,3 +142,140 @@ e_stream_bonobo_to_camel(Bonobo_Stream in, CamelStream *out)
return 0;
}
+CamelMimeMessage *
+e_stream_bonobo_to_message(Bonobo_Stream in)
+{
+ CamelStream *mem;
+ CamelMimeMessage *msg;
+
+ mem = camel_stream_mem_new();
+ if (e_stream_bonobo_to_camel(in, mem) == -1)
+ return NULL;
+
+ msg = camel_mime_message_new();
+ if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, mem) == -1) {
+ camel_object_unref(msg);
+ msg = NULL;
+ }
+ camel_object_unref(mem);
+
+ return msg;
+}
+
+Bonobo_Stream
+e_stream_message_to_bonobo(CamelMimeMessage *msg)
+{
+ CamelStreamMem *mem;
+ BonoboObject *bmem;
+
+ /* didn't say it was going to be efficient ... */
+
+ mem = (CamelStreamMem *)camel_stream_mem_new();
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)mem);
+ bmem = bonobo_stream_mem_create(mem->buffer->data, mem->buffer->len, TRUE, FALSE);
+ camel_object_unref(mem);
+
+ return bonobo_object_corba_objref((BonoboObject *)bmem);
+}
+
+struct _e_mail_listener {
+ struct _e_mail_listener *next;
+ struct _e_mail_listener *prev;
+
+ CORBA_Object listener;
+};
+
+static struct _e_mail_listener *
+eml_find(struct _EDList *list, CORBA_Object listener)
+{
+ struct _e_mail_listener *l, *n;
+
+ l = (struct _e_mail_listener *)list->head;
+ n = l->next;
+ while (n) {
+ if (l->listener == listener)
+ return l;
+ l = n;
+ n = n->next;
+ }
+
+ return NULL;
+}
+
+static void
+eml_remove(struct _e_mail_listener *l)
+{
+ CORBA_Environment ev = { 0 };
+
+ e_dlist_remove((EDListNode *)l);
+ CORBA_Object_release(l->listener, &ev);
+ g_free(l);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ CORBA_exception_free(&ev);
+}
+
+void e_mail_listener_add(struct _EDList *list, CORBA_Object listener)
+{
+ struct _e_mail_listener *l;
+ CORBA_Environment ev = { 0 };
+
+ if (eml_find(list, listener) != NULL)
+ return;
+
+ listener = CORBA_Object_duplicate(listener, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ CORBA_exception_free(&ev);
+ } else {
+ l = g_malloc(sizeof(*l));
+ l->listener = listener;
+ e_dlist_addtail(list, (EDListNode *)l);
+ }
+}
+
+gboolean e_mail_listener_remove(struct _EDList *list, CORBA_Object listener)
+{
+ struct _e_mail_listener *l;
+
+ l = eml_find(list, listener);
+ if (l)
+ eml_remove(l);
+
+ return !e_dlist_empty(list);
+}
+
+gboolean e_mail_listener_emit(struct _EDList *list, EMailListenerChanged emit, CORBA_Object source, void *changes)
+{
+ struct _e_mail_listener *l, *n;
+ CORBA_Environment ev = { 0 };
+
+ l = (struct _e_mail_listener *)list->head;
+ n = l->next;
+ while (n) {
+ emit(l->listener, source, changes, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ printf("emit changed failed '%s', removing listener\n", ev._id);
+ CORBA_exception_free(&ev);
+ eml_remove(l);
+ }
+ l = n;
+ n = n->next;
+ }
+
+ return !e_dlist_empty(list);
+}
+
+void e_mail_listener_free(struct _EDList *list)
+{
+ struct _e_mail_listener *l, *n;
+
+ l = (struct _e_mail_listener *)list->head;
+ n = l->next;
+ while (n) {
+ eml_remove(l);
+
+ l = n;
+ n = n->next;
+ }
+}
+
diff --git a/plugins/mail-remote/e-corba-utils.h b/plugins/mail-remote/e-corba-utils.h
index b72e8043dd..cba1fb49ac 100644
--- a/plugins/mail-remote/e-corba-utils.h
+++ b/plugins/mail-remote/e-corba-utils.h
@@ -8,14 +8,28 @@ struct _EvolutionMailStore;
struct _EvolutionMailFolder;
struct _CamelMessageInfo;
struct _CamelStream;
+struct _CamelMimeMessage;
-void e_mail_property_set_string(GNOME_Evolution_Mail_Property *prop, const char *name, const char *val);
-void e_mail_property_set_null(GNOME_Evolution_Mail_Property *prop, const char *name);
+void e_mail_property_set_string(Evolution_Mail_Property *prop, const char *name, const char *val);
+void e_mail_property_set_null(Evolution_Mail_Property *prop, const char *name);
-void e_mail_storeinfo_set_store(GNOME_Evolution_Mail_StoreInfo *si, struct _EvolutionMailStore *store);
-void e_mail_folderinfo_set_folder(GNOME_Evolution_Mail_FolderInfo *fi, struct _EvolutionMailFolder *emf);
-void e_mail_messageinfo_set_message(GNOME_Evolution_Mail_MessageInfo *mi, struct _CamelMessageInfo *info);
+void e_mail_storeinfo_set_store(Evolution_Mail_StoreInfo *si, struct _EvolutionMailStore *store);
+void e_mail_folderinfo_set_folder(Evolution_Mail_FolderInfo *fi, struct _EvolutionMailFolder *emf);
+
+void e_mail_messageinfo_set_message(Evolution_Mail_MessageInfo *mi, struct _CamelMessageInfo *info);
+struct _CamelMessageInfo *e_mail_messageinfoset_to_info(const Evolution_Mail_MessageInfoSet *mi);
int e_stream_bonobo_to_camel(Bonobo_Stream in, struct _CamelStream *out);
+struct _CamelMimeMessage *e_stream_bonobo_to_message(Bonobo_Stream in);
+Bonobo_Stream e_stream_message_to_bonobo(struct _CamelMimeMessage *msg);
+
+struct _EDList;
+
+typedef void (*EMailListenerChanged)(CORBA_Object, CORBA_Object, void *changes, CORBA_Environment *);
+
+void e_mail_listener_add(struct _EDList *list, CORBA_Object listener);
+gboolean e_mail_listener_remove(struct _EDList *list, CORBA_Object listener);
+gboolean e_mail_listener_emit(struct _EDList *list, EMailListenerChanged emit, CORBA_Object source, void *changes);
+void e_mail_listener_free(struct _EDList *list);
#endif /* !_E_CORBA_UTILS_H */
diff --git a/plugins/mail-remote/evolution-mail-folder.c b/plugins/mail-remote/evolution-mail-folder.c
index c121c3bf3f..a64881015e 100644
--- a/plugins/mail-remote/evolution-mail-folder.c
+++ b/plugins/mail-remote/evolution-mail-folder.c
@@ -37,6 +37,8 @@
#include <camel/camel-store.h>
#include <camel/camel-folder.h>
+#include <libedataserver/e-msgport.h>
+
#include "e-corba-utils.h"
#define PARENT_TYPE bonobo_object_get_type ()
@@ -49,6 +51,8 @@ struct _EvolutionMailFolderPrivate {
CamelFolder *folder;
guint32 folder_changed;
+
+ EDList listeners;
};
/* GObject methods */
@@ -64,6 +68,8 @@ impl_dispose (GObject *object)
p->folder = NULL;
}
+ e_mail_listener_free(&p->listeners);
+
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
@@ -74,6 +80,7 @@ impl_finalize (GObject *object)
struct _EvolutionMailFolderPrivate *p = _PRIVATE(object);
p = p;
+
g_warning("EvolutionMailFolder is finalised!\n");
g_free(emf->full_name);
@@ -86,24 +93,24 @@ impl_finalize (GObject *object)
static CORBA_boolean
impl_getProperties(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_PropertyNames* names,
- GNOME_Evolution_Mail_Properties **propsp,
+ const Evolution_Mail_PropertyNames* names,
+ Evolution_Mail_Properties **propsp,
CORBA_Environment * ev)
{
EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant);
int i;
- GNOME_Evolution_Mail_Properties *props;
+ Evolution_Mail_Properties *props;
CORBA_boolean ok = CORBA_TRUE;
- *propsp = props = GNOME_Evolution_Mail_Properties__alloc();
+ *propsp = props = Evolution_Mail_Properties__alloc();
props->_length = names->_length;
props->_maximum = props->_length;
- props->_buffer = GNOME_Evolution_Mail_Properties_allocbuf(props->_maximum);
+ props->_buffer = Evolution_Mail_Properties_allocbuf(props->_maximum);
CORBA_sequence_set_release(props, CORBA_TRUE);
for (i=0;i<names->_length;i++) {
const CORBA_char *name = names->_buffer[i];
- GNOME_Evolution_Mail_Property *prop = &props->_buffer[i];
+ Evolution_Mail_Property *prop = &props->_buffer[i];
prop->value._release = CORBA_TRUE;
@@ -124,22 +131,17 @@ impl_getProperties(PortableServer_Servant _servant,
return ok;
}
-static GNOME_Evolution_Mail_MessageIterator
+static Evolution_Mail_MessageIterator
impl_getMessages(PortableServer_Servant _servant, const CORBA_char * pattern, CORBA_Environment * ev)
{
EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant);
struct _CamelFolder *folder;
EvolutionMailMessageIterator *emi;
- GNOME_Evolution_Mail_MessageIterator iter;
+ Evolution_Mail_MessageIterator iter;
folder = evolution_mail_folder_get_folder(emf);
if (folder == NULL) {
- GNOME_Evolution_Mail_FAILED *x;
-
- x = GNOME_Evolution_Mail_FAILED__alloc();
- x->why = CORBA_string_dup("Unable to open folder");
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_FAILED, x);
-
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
return CORBA_OBJECT_NIL;
}
@@ -154,7 +156,7 @@ impl_getMessages(PortableServer_Servant _servant, const CORBA_char * pattern, CO
}
static void
-impl_changeMessages(PortableServer_Servant _servant, const GNOME_Evolution_Mail_MessageInfoSets *infos, CORBA_Environment * ev)
+impl_changeMessages(PortableServer_Servant _servant, const Evolution_Mail_MessageInfoSets *infos, CORBA_Environment * ev)
{
EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant);
struct _CamelFolder *folder;
@@ -162,18 +164,14 @@ impl_changeMessages(PortableServer_Servant _servant, const GNOME_Evolution_Mail_
folder = evolution_mail_folder_get_folder(emf);
if (folder == NULL) {
- GNOME_Evolution_Mail_FAILED *x;
-
- x = GNOME_Evolution_Mail_FAILED__alloc();
- x->why = CORBA_string_dup("Unable to open folder");
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_FAILED, x);
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
return;
}
camel_folder_freeze(folder);
for (i=0;i<infos->_length;i++) {
CamelMessageInfo *mi;
- GNOME_Evolution_Mail_MessageInfoSet *mis = &infos->_buffer[i];
+ Evolution_Mail_MessageInfoSet *mis = &infos->_buffer[i];
mi = camel_folder_get_message_info(folder, mis->uid);
if (mi == NULL)
@@ -196,12 +194,82 @@ impl_changeMessages(PortableServer_Servant _servant, const GNOME_Evolution_Mail_
camel_object_unref(folder);
}
+static Bonobo_Stream
+impl_getMessage(PortableServer_Servant _servant, const CORBA_char * uid, CORBA_Environment *ev)
+{
+ EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant);
+ struct _CamelFolder *folder;
+ CamelMimeMessage *msg;
+ Bonobo_Stream out;
+ CamelException ex = { 0 };
+
+ folder = evolution_mail_folder_get_folder(emf);
+ if (folder == NULL)
+ goto fail;
+
+ msg = camel_folder_get_message(folder, uid, &ex);
+ if (msg == NULL)
+ goto fail;
+
+ out = e_stream_message_to_bonobo(msg);
+ camel_object_unref(msg);
+
+ return out;
+
+fail:
+ if (folder)
+ camel_object_unref(folder);
+
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
+ camel_exception_clear(&ex);
+
+ return CORBA_OBJECT_NIL;
+}
+
+static void
+impl_appendMessage(PortableServer_Servant _servant, const Evolution_Mail_MessageInfoSet*mi, const Bonobo_Stream message, CORBA_Environment *ev)
+{
+ EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant);
+ struct _CamelFolder *folder;
+ CamelMimeMessage *msg = NULL;
+ CamelMessageInfo *info;
+ CamelException ex = { 0 };
+
+ folder = evolution_mail_folder_get_folder(emf);
+ if (folder == NULL)
+ goto fail3;
+
+ msg = e_stream_bonobo_to_message(message);
+ if (msg == NULL)
+ goto fail2;
+
+ info = e_mail_messageinfoset_to_info(mi);
+ camel_folder_append_message(folder, msg, info, NULL, &ex);
+ camel_message_info_free(info);
+
+ if (camel_exception_is_set(&ex))
+ goto fail;
+
+ camel_object_unref(msg);
+ camel_object_unref(folder);
+
+ return;
+
+fail:
+ camel_object_unref(msg);
+fail2:
+ camel_object_unref(folder);
+fail3:
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
+ camel_exception_clear(&ex);
+}
+
/* Initialization */
static void
evolution_mail_folder_class_init (EvolutionMailFolderClass *klass)
{
- POA_GNOME_Evolution_Mail_Folder__epv *epv = &klass->epv;
+ POA_Evolution_Mail_Folder__epv *epv = &klass->epv;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -209,6 +277,8 @@ evolution_mail_folder_class_init (EvolutionMailFolderClass *klass)
epv->getProperties = impl_getProperties;
epv->getMessages = impl_getMessages;
epv->changeMessages = impl_changeMessages;
+ epv->getMessage = impl_getMessage;
+ epv->appendMessage = impl_appendMessage;
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
@@ -217,11 +287,15 @@ evolution_mail_folder_class_init (EvolutionMailFolderClass *klass)
}
static void
-evolution_mail_folder_init(EvolutionMailFolder *component, EvolutionMailFolderClass *klass)
+evolution_mail_folder_init(EvolutionMailFolder *emf, EvolutionMailFolderClass *klass)
{
+ struct _EvolutionMailFolderPrivate *p = _PRIVATE(emf);
+
+ bonobo_object_set_immortal((BonoboObject *)emf, TRUE);
+ e_dlist_init(&p->listeners);
}
-BONOBO_TYPE_FUNC_FULL (EvolutionMailFolder, GNOME_Evolution_Mail_Folder, PARENT_TYPE, evolution_mail_folder)
+BONOBO_TYPE_FUNC_FULL (EvolutionMailFolder, Evolution_Mail_Folder, PARENT_TYPE, evolution_mail_folder)
EvolutionMailFolder *
evolution_mail_folder_new(EvolutionMailStore *ems, const char *name, const char *full_name)
@@ -237,13 +311,13 @@ evolution_mail_folder_new(EvolutionMailStore *ems, const char *name, const char
}
static void
-emf_set_change(GNOME_Evolution_Mail_FolderChange *change, GNOME_Evolution_Mail_ChangeType how, CamelFolder *folder, GPtrArray *uids)
+emf_set_change(Evolution_Mail_FolderChange *change, Evolution_Mail_ChangeType how, CamelFolder *folder, GPtrArray *uids)
{
int total = 0, i;
change->type = how;
change->messages._maximum = uids->len;
- change->messages._buffer = GNOME_Evolution_Mail_MessageInfos_allocbuf(uids->len);
+ change->messages._buffer = Evolution_Mail_MessageInfos_allocbuf(uids->len);
for (i=0;i<uids->len;i++) {
CamelMessageInfo *info = camel_folder_get_message_info(folder, uids->pdata[i]);
@@ -267,40 +341,30 @@ emf_folder_changed(CamelObject *o, void *d, void *data)
CamelFolder *folder = (CamelFolder *)o;
CamelFolderChangeInfo *ci = d;
int count = 0;
- GNOME_Evolution_Mail_FolderChanges *changes;
- CORBA_long flags;
-
- flags = evolution_mail_session_listening(emf->store->session);
-
- if ((flags & (GNOME_Evolution_Mail_Session_FOLDER_ADDED|GNOME_Evolution_Mail_Session_FOLDER_CHANGED|GNOME_Evolution_Mail_Session_FOLDER_REMOVED)) == 0)
- return;
+ Evolution_Mail_FolderChanges *changes;
- changes = GNOME_Evolution_Mail_FolderChanges__alloc();
+ changes = Evolution_Mail_FolderChanges__alloc();
changes->_maximum = 3;
- changes->_buffer = GNOME_Evolution_Mail_FolderChanges_allocbuf(3);
+ changes->_buffer = Evolution_Mail_FolderChanges_allocbuf(3);
CORBA_sequence_set_release(changes, TRUE);
/* could be a race if a new listener is added */
- if (ci->uid_added->len && (flags & GNOME_Evolution_Mail_Session_FOLDER_ADDED)) {
- emf_set_change(&changes->_buffer[count], GNOME_Evolution_Mail_ADDED, folder, ci->uid_added);
+ if (ci->uid_added->len) {
+ emf_set_change(&changes->_buffer[count], Evolution_Mail_ADDED, folder, ci->uid_added);
count++;
}
- if (ci->uid_removed->len && (flags & GNOME_Evolution_Mail_Session_FOLDER_REMOVED)) {
- emf_set_change(&changes->_buffer[count], GNOME_Evolution_Mail_REMOVED, folder, ci->uid_removed);
+ if (ci->uid_removed->len) {
+ emf_set_change(&changes->_buffer[count], Evolution_Mail_REMOVED, folder, ci->uid_removed);
count++;
}
- if (ci->uid_changed->len && (flags & GNOME_Evolution_Mail_Session_FOLDER_CHANGED)) {
- emf_set_change(&changes->_buffer[count], GNOME_Evolution_Mail_CHANGED, folder, ci->uid_changed);
+ if (ci->uid_changed->len) {
+ emf_set_change(&changes->_buffer[count], Evolution_Mail_CHANGED, folder, ci->uid_changed);
count++;
}
changes->_length = count;
- evolution_mail_session_folder_changed(emf->store->session,
- bonobo_object_corba_objref((BonoboObject *)emf->store),
- bonobo_object_corba_objref((BonoboObject *)emf),
- changes);
-
+ evolution_mail_folder_changed(emf, changes);
CORBA_free(changes);
}
@@ -330,3 +394,22 @@ struct _CamelFolder *evolution_mail_folder_get_folder(EvolutionMailFolder *emf)
return p->folder;
}
+
+void evolution_mail_folder_addlistener(EvolutionMailFolder *emf, Evolution_Mail_FolderListener listener)
+{
+ struct _EvolutionMailFolderPrivate *p = _PRIVATE(emf);
+
+ /* FIXME: locking */
+ e_mail_listener_add(&p->listeners, listener);
+}
+
+void
+evolution_mail_folder_changed(EvolutionMailFolder *emf, Evolution_Mail_FolderChanges *changes)
+{
+ struct _EvolutionMailFolderPrivate *p = _PRIVATE(emf);
+
+ if (!e_mail_listener_emit(&p->listeners, (EMailListenerChanged)Evolution_Mail_FolderListener_changed,
+ bonobo_object_corba_objref((BonoboObject *)emf), changes)) {
+ printf("No more listeners for folder, could dispose store object now\n");
+ }
+}
diff --git a/plugins/mail-remote/evolution-mail-folder.h b/plugins/mail-remote/evolution-mail-folder.h
index 398d3f2d42..74320f4d78 100644
--- a/plugins/mail-remote/evolution-mail-folder.h
+++ b/plugins/mail-remote/evolution-mail-folder.h
@@ -48,13 +48,16 @@ struct _EvolutionMailFolder {
struct _EvolutionMailFolderClass {
BonoboObjectClass parent_class;
- POA_GNOME_Evolution_Mail_Folder__epv epv;
+ POA_Evolution_Mail_Folder__epv epv;
};
GType evolution_mail_folder_get_type(void);
EvolutionMailFolder *evolution_mail_folder_new(struct _EvolutionMailStore *ems, const char *name, const char *full_name);
+void evolution_mail_folder_addlistener(EvolutionMailFolder *emf, Evolution_Mail_FolderListener listener);
+void evolution_mail_folder_changed(EvolutionMailFolder *emf, Evolution_Mail_FolderChanges *changes);
+
struct _CamelFolder *evolution_mail_folder_get_folder(EvolutionMailFolder *emf);
#endif /* _EVOLUTION_MAIL_FOLDER_H_ */
diff --git a/plugins/mail-remote/evolution-mail-folderlistener.c b/plugins/mail-remote/evolution-mail-folderlistener.c
new file mode 100644
index 0000000000..ba758d9483
--- /dev/null
+++ b/plugins/mail-remote/evolution-mail-folderlistener.c
@@ -0,0 +1,155 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Michael Zucchi <notzed@novell.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <bonobo/bonobo-i18n.h>
+#include <bonobo/bonobo-exception.h>
+#include "evolution-mail-folderlistener.h"
+
+#include "evolution-mail-marshal.h"
+
+#define PARENT_TYPE bonobo_object_get_type ()
+
+static BonoboObjectClass *parent_class = NULL;
+
+#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, evolution_mail_folderlistener_get_type()))
+
+struct _EvolutionMailFolderListenerPrivate {
+ int dummy;
+};
+
+enum {
+ EML_CHANGED,
+ EML_LAST_SIGNAL
+};
+
+static guint eml_signals[EML_LAST_SIGNAL];
+
+/* GObject methods */
+
+static void
+impl_dispose (GObject *object)
+{
+ struct _EvolutionMailFolderListenerPrivate *p = _PRIVATE(object);
+
+ p = p;
+
+ (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+}
+
+static void
+impl_finalize (GObject *object)
+{
+ printf("EvolutionMailFolderListener finalised!\n");
+
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+/* Evolution.Mail.Listener */
+static const char *change_type_name(int type)
+{
+ switch (type) {
+ case Evolution_Mail_ADDED:
+ return "added";
+ break;
+ case Evolution_Mail_CHANGED:
+ return "changed";
+ break;
+ case Evolution_Mail_REMOVED:
+ return "removed";
+ break;
+ default:
+ return "";
+ }
+}
+
+static void
+impl_changed(PortableServer_Servant _servant,
+ const Evolution_Mail_Folder folder,
+ const Evolution_Mail_FolderChanges * changes,
+ CORBA_Environment * ev)
+{
+ EvolutionMailFolderListener *eml = (EvolutionMailFolderListener *)bonobo_object_from_servant(_servant);
+ int i, j;
+
+ printf("folder changed!\n");
+ for (i=0;i<changes->_length;i++) {
+ printf(" %d %s", changes->_buffer[i].messages._length, change_type_name(changes->_buffer[i].type));
+ for (j=0;j<changes->_buffer[i].messages._length;j++) {
+ printf(" %s %s\n", changes->_buffer[i].messages._buffer[j].uid, changes->_buffer[i].messages._buffer[j].subject);
+ }
+ }
+
+ g_signal_emit(eml, eml_signals[EML_CHANGED], 0, folder, changes);
+}
+
+/* Initialization */
+
+static void
+evolution_mail_folderlistener_class_init (EvolutionMailFolderListenerClass *klass)
+{
+ POA_Evolution_Mail_FolderListener__epv *epv = &klass->epv;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ epv->changed = impl_changed;
+
+ object_class->dispose = impl_dispose;
+ object_class->finalize = impl_finalize;
+
+ g_type_class_add_private(klass, sizeof(struct _EvolutionMailFolderListenerPrivate));
+
+ eml_signals[EML_CHANGED] =
+ g_signal_new("changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvolutionMailFolderListenerClass, changed),
+ NULL, NULL,
+ evolution_mail_marshal_VOID__POINTER_POINTER,
+ G_TYPE_NONE, 2,
+ G_TYPE_POINTER, G_TYPE_POINTER);
+}
+
+static void
+evolution_mail_folderlistener_init (EvolutionMailFolderListener *ems, EvolutionMailFolderListenerClass *klass)
+{
+ struct _EvolutionMailFolderListenerPrivate *p = _PRIVATE(ems);
+
+ p = p;
+}
+
+EvolutionMailFolderListener *
+evolution_mail_folderlistener_new(void)
+{
+ EvolutionMailFolderListener *eml;
+
+ eml = g_object_new(evolution_mail_folderlistener_get_type(), NULL);
+
+ return eml;
+}
+
+BONOBO_TYPE_FUNC_FULL (EvolutionMailFolderListener, Evolution_Mail_FolderListener, PARENT_TYPE, evolution_mail_folderlistener)
diff --git a/plugins/mail-remote/evolution-mail-folderlistener.h b/plugins/mail-remote/evolution-mail-folderlistener.h
new file mode 100644
index 0000000000..f555d36aa9
--- /dev/null
+++ b/plugins/mail-remote/evolution-mail-folderlistener.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * Author: Michael Zucchi <notzed@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _EVOLUTION_MAIL_FOLDERLISTENER_H_
+#define _EVOLUTION_MAIL_FOLDERLISTENER_H_
+
+#include <bonobo/bonobo-object.h>
+#include "Evolution-DataServer-Mail.h"
+
+#define EVOLUTION_MAIL_TYPE_FOLDERLISTENER (evolution_mail_folderlistener_get_type ())
+#define EVOLUTION_MAIL_FOLDERLISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailFolderListener))
+#define EVOLUTION_MAIL_FOLDERLISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailFolderListenerClass))
+#define EVOLUTION_MAIL_IS_FOLDERLISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
+#define EVOLUTION_MAIL_IS_FOLDERLISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
+
+typedef struct _EvolutionMailFolderListener EvolutionMailFolderListener;
+typedef struct _EvolutionMailFolderListenerClass EvolutionMailFolderListenerClass;
+
+struct _EvolutionMailFolderListener {
+ BonoboObject parent;
+};
+
+struct _EvolutionMailFolderListenerClass {
+ BonoboObjectClass parent_class;
+
+ POA_Evolution_Mail_FolderListener__epv epv;
+
+ void (*changed)(EvolutionMailFolderListener *, const Evolution_Mail_Folder folder, const Evolution_Mail_FolderChanges *);
+};
+
+GType evolution_mail_folderlistener_get_type(void);
+
+EvolutionMailFolderListener *evolution_mail_folderlistener_new(void);
+
+#endif /* _EVOLUTION_MAIL_FOLDERLISTENER_H_ */
diff --git a/plugins/mail-remote/evolution-mail-listener.c b/plugins/mail-remote/evolution-mail-listener.c
deleted file mode 100644
index 842edf4f4f..0000000000
--- a/plugins/mail-remote/evolution-mail-listener.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/*
- * Copyright (C) 2005 Novell, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Michael Zucchi <notzed@novell.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <string.h>
-#include <bonobo/bonobo-shlib-factory.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-i18n.h>
-#include <bonobo/bonobo-exception.h>
-#include "evolution-mail-listener.h"
-
-#include "evolution-mail-store.h"
-
-#include "evolution-mail-marshal.h"
-
-#define PARENT_TYPE bonobo_object_get_type ()
-
-static BonoboObjectClass *parent_class = NULL;
-
-#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, evolution_mail_listener_get_type()))
-
-struct _EvolutionMailListenerPrivate {
- int dummy;
-};
-
-enum {
- EML_SESSION_CHANGED,
- EML_STORE_CHANGED,
- EML_FOLDER_CHANGED,
- EML_LAST_SIGNAL
-};
-
-static guint eml_signals[EML_LAST_SIGNAL];
-
-/* GObject methods */
-
-static void
-impl_dispose (GObject *object)
-{
- struct _EvolutionMailListenerPrivate *p = _PRIVATE(object);
-
- p = p;
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- printf("EvolutionMailListener finalised!\n");
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-/* Evolution.Mail.Listener */
-static const char *change_type_name(int type)
-{
- switch (type) {
- case GNOME_Evolution_Mail_ADDED:
- return "added";
- break;
- case GNOME_Evolution_Mail_CHANGED:
- return "changed";
- break;
- case GNOME_Evolution_Mail_REMOVED:
- return "removed";
- break;
- default:
- return "";
- }
-}
-
-static void
-impl_sessionChanged(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_Session session,
- const GNOME_Evolution_Mail_SessionChanges *changes, CORBA_Environment * ev)
-{
- EvolutionMailListener *eml = (EvolutionMailListener *)bonobo_object_from_servant(_servant);
- int i, j;
-
- printf("session changed!\n");
- for (i=0;i<changes->_length;i++) {
- printf(" %d %s", changes->_buffer[i].stores._length, change_type_name(changes->_buffer[i].type));
- for (j=0;j<changes->_buffer[i].stores._length;j++) {
- printf(" %s %s\n", changes->_buffer[i].stores._buffer[j].uid, changes->_buffer[i].stores._buffer[j].name);
- }
- }
-
- g_signal_emit(eml, eml_signals[EML_SESSION_CHANGED], 0, session, changes);
-}
-
-static void
-impl_storeChanged(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_Session session,
- const GNOME_Evolution_Mail_Store store,
- const GNOME_Evolution_Mail_StoreChanges * changes,
- CORBA_Environment * ev)
-{
- EvolutionMailListener *eml = (EvolutionMailListener *)bonobo_object_from_servant(_servant);
- int i, j;
-
- printf("store changed!\n");
- for (i=0;i<changes->_length;i++) {
- printf(" %d %s", changes->_buffer[i].folders._length, change_type_name(changes->_buffer[i].type));
- for (j=0;j<changes->_buffer[i].folders._length;j++) {
- printf(" %s %s\n", changes->_buffer[i].folders._buffer[j].full_name, changes->_buffer[i].folders._buffer[j].name);
- }
- }
-
- g_signal_emit(eml, eml_signals[EML_STORE_CHANGED], 0, session, store, changes);
-}
-
-static void
-impl_folderChanged(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_Session session,
- const GNOME_Evolution_Mail_Store store,
- const GNOME_Evolution_Mail_Folder folder,
- const GNOME_Evolution_Mail_FolderChanges *changes, CORBA_Environment * ev)
-{
- EvolutionMailListener *eml = (EvolutionMailListener *)bonobo_object_from_servant(_servant);
- int i, j;
-
- printf("folder changed!\n");
- for (i=0;i<changes->_length;i++) {
- printf(" %d %s", changes->_buffer[i].messages._length, change_type_name(changes->_buffer[i].type));
- for (j=0;j<changes->_buffer[i].messages._length;j++) {
- printf(" %s %s\n", changes->_buffer[i].messages._buffer[j].uid, changes->_buffer[i].messages._buffer[j].subject);
- }
- }
-
- g_signal_emit(eml, eml_signals[EML_STORE_CHANGED], 0, session, store, folder, changes);
-}
-
-/* Initialization */
-
-static void
-evolution_mail_listener_class_init (EvolutionMailListenerClass *klass)
-{
- POA_GNOME_Evolution_Mail_Listener__epv *epv = &klass->epv;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- epv->sessionChanged = impl_sessionChanged;
- epv->storeChanged = impl_storeChanged;
- epv->folderChanged = impl_folderChanged;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- g_type_class_add_private(klass, sizeof(struct _EvolutionMailListenerPrivate));
-
- eml_signals[EML_SESSION_CHANGED] =
- g_signal_new("session-changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionMailListenerClass, session_changed),
- NULL, NULL,
- evolution_mail_marshal_VOID__POINTER_POINTER,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER, G_TYPE_POINTER);
-
- eml_signals[EML_STORE_CHANGED] =
- g_signal_new("store-changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionMailListenerClass, store_changed),
- NULL, NULL,
- evolution_mail_marshal_VOID__POINTER_POINTER_POINTER,
- G_TYPE_NONE, 3,
- G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
-
- eml_signals[EML_FOLDER_CHANGED] =
- g_signal_new("folder-changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionMailListenerClass, folder_changed),
- NULL, NULL,
- evolution_mail_marshal_VOID__POINTER_POINTER_POINTER_POINTER,
- G_TYPE_NONE, 4,
- G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
-}
-
-static void
-evolution_mail_listener_init (EvolutionMailListener *ems, EvolutionMailListenerClass *klass)
-{
- struct _EvolutionMailListenerPrivate *p = _PRIVATE(ems);
-
- p = p;
-}
-
-EvolutionMailListener *
-evolution_mail_listener_new(void)
-{
- EvolutionMailListener *eml;
-#if 0
- static PortableServer_POA poa = NULL;
-
- /* NB: to simplify signal handling, we should only run in the idle loop? */
-
- if (poa == NULL)
- poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL);
- eml = g_object_new(evolution_mail_listener_get_type(), "poa", poa, NULL);
-#else
- eml = g_object_new(evolution_mail_listener_get_type(), NULL);
-#endif
- return eml;
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionMailListener, GNOME_Evolution_Mail_Listener, PARENT_TYPE, evolution_mail_listener)
diff --git a/plugins/mail-remote/evolution-mail-listener.h b/plugins/mail-remote/evolution-mail-listener.h
deleted file mode 100644
index 5dbf4aaf3a..0000000000
--- a/plugins/mail-remote/evolution-mail-listener.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/*
- * Copyright (C) 2005 Novell, Inc.
- *
- * Author: Michael Zucchi <notzed@novell.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _EVOLUTION_MAIL_LISTENER_H_
-#define _EVOLUTION_MAIL_LISTENER_H_
-
-#include <bonobo/bonobo-object.h>
-#include "Evolution-DataServer-Mail.h"
-
-#define EVOLUTION_MAIL_TYPE_LISTENER (evolution_mail_listener_get_type ())
-#define EVOLUTION_MAIL_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailListener))
-#define EVOLUTION_MAIL_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailListenerClass))
-#define EVOLUTION_MAIL_IS_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
-#define EVOLUTION_MAIL_IS_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
-
-typedef struct _EvolutionMailListener EvolutionMailListener;
-typedef struct _EvolutionMailListenerClass EvolutionMailListenerClass;
-
-struct _EvolutionMailListener {
- BonoboObject parent;
-};
-
-struct _EvolutionMailListenerClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Mail_Listener__epv epv;
-
- void (*session_changed)(const GNOME_Evolution_Mail_Session session, const GNOME_Evolution_Mail_SessionChange *change);
- void (*store_changed)(const GNOME_Evolution_Mail_Session session, const GNOME_Evolution_Mail_Store store, const GNOME_Evolution_Mail_StoreChanges *);
- void (*folder_changed)(const GNOME_Evolution_Mail_Session session, const GNOME_Evolution_Mail_Store store, const GNOME_Evolution_Mail_Folder folder, const GNOME_Evolution_Mail_FolderChanges *);
-};
-
-GType evolution_mail_listener_get_type(void);
-
-EvolutionMailListener *evolution_mail_listener_new(void);
-
-#endif /* _EVOLUTION_MAIL_LISTENER_H_ */
diff --git a/plugins/mail-remote/evolution-mail-marshal.list b/plugins/mail-remote/evolution-mail-marshal.list
index 14a6fbd358..7af68d8567 100644
--- a/plugins/mail-remote/evolution-mail-marshal.list
+++ b/plugins/mail-remote/evolution-mail-marshal.list
@@ -1,3 +1,3 @@
VOID:POINTER,POINTER
-VOID:POINTER,POINTER,POINTER
-VOID:POINTER,POINTER,POINTER,POINTER
+VOID:POINTER
+
diff --git a/plugins/mail-remote/evolution-mail-messageiterator.c b/plugins/mail-remote/evolution-mail-messageiterator.c
index 8cf123640d..0fa25f730f 100644
--- a/plugins/mail-remote/evolution-mail-messageiterator.c
+++ b/plugins/mail-remote/evolution-mail-messageiterator.c
@@ -74,12 +74,12 @@ impl_finalize (GObject *object)
}
/* Evolution.Mail.MessageIterator */
-static GNOME_Evolution_Mail_MessageInfos *
+static Evolution_Mail_MessageInfos *
impl_next(PortableServer_Servant _servant, const CORBA_long limit, CORBA_Environment * ev)
{
EvolutionMailMessageIterator *emf = (EvolutionMailMessageIterator *)bonobo_object_from_servant(_servant);
int i, j;
- GNOME_Evolution_Mail_MessageInfos *msgs;
+ Evolution_Mail_MessageInfos *msgs;
struct _EvolutionMailMessageIteratorPrivate *p = _PRIVATE(emf);
CamelException ex = { 0 };
@@ -97,9 +97,9 @@ impl_next(PortableServer_Servant _servant, const CORBA_long limit, CORBA_Environ
p->index = 0;
}
- msgs = GNOME_Evolution_Mail_MessageInfos__alloc();
+ msgs = Evolution_Mail_MessageInfos__alloc();
msgs->_maximum = MIN(limit, p->search->len - p->index);
- msgs->_buffer = GNOME_Evolution_Mail_MessageInfos_allocbuf(msgs->_maximum);
+ msgs->_buffer = Evolution_Mail_MessageInfos_allocbuf(msgs->_maximum);
CORBA_sequence_set_release(msgs, CORBA_TRUE);
j=0;
@@ -119,17 +119,27 @@ impl_next(PortableServer_Servant _servant, const CORBA_long limit, CORBA_Environ
return msgs;
}
+static void
+impl_mi_dispose(PortableServer_Servant _servant, CORBA_Environment *ev)
+{
+ EvolutionMailMessageIterator *emmi = (EvolutionMailMessageIterator *)bonobo_object_from_servant(_servant);
+
+ bonobo_object_set_immortal((BonoboObject *)emmi, FALSE);
+ /*bonobo_object_unref((BonoboObject *)emmi);*/
+}
+
/* Initialization */
static void
evolution_mail_messageiterator_class_init (EvolutionMailMessageIteratorClass *klass)
{
- POA_GNOME_Evolution_Mail_MessageIterator__epv *epv = &klass->epv;
+ POA_Evolution_Mail_MessageIterator__epv *epv = &klass->epv;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
epv->next = impl_next;
+ epv->dispose = impl_mi_dispose;
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
@@ -138,11 +148,12 @@ evolution_mail_messageiterator_class_init (EvolutionMailMessageIteratorClass *kl
}
static void
-evolution_mail_messageiterator_init(EvolutionMailMessageIterator *component, EvolutionMailMessageIteratorClass *klass)
+evolution_mail_messageiterator_init(EvolutionMailMessageIterator *emi, EvolutionMailMessageIteratorClass *klass)
{
+ bonobo_object_set_immortal((BonoboObject *)emi, TRUE);
}
-BONOBO_TYPE_FUNC_FULL (EvolutionMailMessageIterator, GNOME_Evolution_Mail_MessageIterator, PARENT_TYPE, evolution_mail_messageiterator)
+BONOBO_TYPE_FUNC_FULL (EvolutionMailMessageIterator, Evolution_Mail_MessageIterator, PARENT_TYPE, evolution_mail_messageiterator)
EvolutionMailMessageIterator *
evolution_mail_messageiterator_new(CamelFolder *folder, const char *expr)
diff --git a/plugins/mail-remote/evolution-mail-messageiterator.h b/plugins/mail-remote/evolution-mail-messageiterator.h
index 746e96fbe8..772ea8f2b0 100644
--- a/plugins/mail-remote/evolution-mail-messageiterator.h
+++ b/plugins/mail-remote/evolution-mail-messageiterator.h
@@ -37,7 +37,7 @@ struct _EvolutionMailMessageIterator {
struct _EvolutionMailMessageIteratorClass {
BonoboObjectClass parent_class;
- POA_GNOME_Evolution_Mail_MessageIterator__epv epv;
+ POA_Evolution_Mail_MessageIterator__epv epv;
};
GType evolution_mail_messageiterator_get_type(void);
diff --git a/plugins/mail-remote/evolution-mail-session.c b/plugins/mail-remote/evolution-mail-session.c
index 6cdee95b2b..9fa6fdfdb7 100644
--- a/plugins/mail-remote/evolution-mail-session.c
+++ b/plugins/mail-remote/evolution-mail-session.c
@@ -44,14 +44,6 @@ static BonoboObjectClass *parent_class = NULL;
#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, evolution_mail_session_get_type()))
-struct _listener {
- struct _listener *next;
- struct _listener *prev;
-
- CORBA_long flags;
- GNOME_Evolution_Mail_Listener listener;
-};
-
struct _EvolutionMailSessionPrivate {
EAccountList *accounts;
GList *stores;
@@ -105,8 +97,8 @@ impl_finalize (GObject *object)
static CORBA_boolean
impl_getProperties(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_PropertyNames* names,
- GNOME_Evolution_Mail_Properties **props,
+ const Evolution_Mail_PropertyNames* names,
+ Evolution_Mail_Properties **props,
CORBA_Environment * ev)
{
EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant);
@@ -116,18 +108,19 @@ impl_getProperties(PortableServer_Servant _servant,
return CORBA_TRUE;
}
-static GNOME_Evolution_Mail_StoreInfos *
+static Evolution_Mail_StoreInfos *
impl_getStores(PortableServer_Servant _servant,
const CORBA_char * pattern,
+ const Evolution_Mail_StoreListener listener,
CORBA_Environment * ev)
{
EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant);
struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems);
- GNOME_Evolution_Mail_StoreInfos *seq;
+ Evolution_Mail_StoreInfos *seq;
int i, len;
GList *l;
- seq = GNOME_Evolution_Mail_StoreInfos__alloc();
+ seq = Evolution_Mail_StoreInfos__alloc();
/* FIXME: pattern? */
@@ -135,13 +128,15 @@ impl_getStores(PortableServer_Servant _servant,
seq->_length = len;
seq->_maximum = len;
- seq->_buffer = GNOME_Evolution_Mail_StoreInfos_allocbuf(seq->_length);
+ seq->_buffer = Evolution_Mail_StoreInfos_allocbuf(seq->_length);
CORBA_sequence_set_release(seq, TRUE);
l = p->stores;
for (i=0;l && i<len;i++) {
EvolutionMailStore *store = l->data;
+ evolution_mail_store_addlistener(store, listener);
+
e_mail_storeinfo_set_store(&seq->_buffer[i], store);
l = g_list_next(l);
}
@@ -151,54 +146,27 @@ impl_getStores(PortableServer_Servant _servant,
static void
impl_addListener(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_Listener listener,
- CORBA_long flags,
+ const Evolution_Mail_SessionListener listener,
CORBA_Environment * ev)
{
EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant);
struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems);
- struct _listener *l;
-
- printf("Adding listener to session %p\n", listener);
- l = g_malloc0(sizeof(*l));
- l->listener = CORBA_Object_duplicate(listener, ev);
- l->flags = flags?flags:~0;
- e_dlist_addtail(&p->listeners, (EDListNode *)l);
-}
-
-static void
-remove_listener(struct _listener *l)
-{
- CORBA_Environment ev = { 0 };
-
- CORBA_Object_release(l->listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- CORBA_exception_free(&ev);
- e_dlist_remove((EDListNode *)l);
- g_free(l);
+ e_mail_listener_add(&p->listeners, listener);
}
static void
impl_removeListener(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_Listener listener,
+ const Evolution_Mail_SessionListener listener,
CORBA_Environment * ev)
{
EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant);
struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems);
- struct _listener *l;
printf("Removing listener from session\n");
- l = (struct _listener *)p->listeners.head;
- while (l->next) {
- /* FIXME: need to use proper comparison function & free stuff, this works with orbit though */
- if (l->listener == listener) {
- remove_listener(l);
- break;
- }
-
- l = l->next;
+ if (!e_mail_listener_remove(&p->listeners, listener)) {
+ printf("no more listeners, could shut down session?\n");
}
}
@@ -207,7 +175,7 @@ impl_removeListener(PortableServer_Servant _servant,
static void
evolution_mail_session_class_init (EvolutionMailSessionClass *klass)
{
- POA_GNOME_Evolution_Mail_Session__epv *epv = &klass->epv;
+ POA_Evolution_Mail_Session__epv *epv = &klass->epv;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -225,48 +193,32 @@ evolution_mail_session_class_init (EvolutionMailSessionClass *klass)
}
static void
-ems_set_changes(GNOME_Evolution_Mail_SessionChange *change, GNOME_Evolution_Mail_ChangeType how, EvolutionMailStore *store)
+ems_set_changes(Evolution_Mail_SessionChange *change, Evolution_Mail_ChangeType how, EvolutionMailStore *store)
{
change->type = how;
change->stores._length = 1;
change->stores._maximum = 1;
- change->stores._buffer = GNOME_Evolution_Mail_StoreInfos_allocbuf(change->stores._maximum);
+ change->stores._buffer = Evolution_Mail_StoreInfos_allocbuf(change->stores._maximum);
CORBA_sequence_set_release(&change->stores, TRUE);
e_mail_storeinfo_set_store(&change->stores._buffer[0], store);
}
static void
-ems_listener_session_event(EvolutionMailSession *ems, GNOME_Evolution_Mail_ChangeType how, EvolutionMailStore *store)
+ems_listener_session_event(EvolutionMailSession *ems, Evolution_Mail_ChangeType how, EvolutionMailStore *store)
{
- GNOME_Evolution_Mail_SessionChanges *changes;
- CORBA_long flags = 0;
-
- switch (how) {
- case GNOME_Evolution_Mail_ADDED:
- flags = GNOME_Evolution_Mail_Session_SESSION_ADDED;
- break;
- case GNOME_Evolution_Mail_CHANGED:
- flags = GNOME_Evolution_Mail_Session_SESSION_CHANGED;
- break;
- case GNOME_Evolution_Mail_REMOVED:
- flags = GNOME_Evolution_Mail_Session_SESSION_REMOVED;
- break;
- }
-
- if ((evolution_mail_session_listening(ems) & flags) == 0)
- return;
+ Evolution_Mail_SessionChanges *changes;
/* NB: we only ever create 1 changetype at the moment */
- changes = GNOME_Evolution_Mail_SessionChanges__alloc();
+ changes = Evolution_Mail_SessionChanges__alloc();
changes->_maximum = 1;
changes->_length = 1;
- changes->_buffer = GNOME_Evolution_Mail_SessionChanges_allocbuf(1);
+ changes->_buffer = Evolution_Mail_SessionChanges_allocbuf(1);
CORBA_sequence_set_release(changes, TRUE);
ems_set_changes(&changes->_buffer[0], how, store);
- evolution_mail_session_session_changed(ems, changes);
+ evolution_mail_session_changed(ems, changes);
CORBA_free(changes);
}
@@ -282,7 +234,7 @@ ems_account_added(EAccountList *eal, EAccount *ea, EvolutionMailSession *ems)
printf("Account added %s\n", ea->uid);
store = evolution_mail_store_new(ems, ea);
p->stores = g_list_append(p->stores, store);
- ems_listener_session_event(ems, GNOME_Evolution_Mail_ADDED, store);
+ ems_listener_session_event(ems, Evolution_Mail_ADDED, store);
}
}
@@ -305,17 +257,17 @@ ems_account_changed(EAccountList *eal, EAccount *ea, EvolutionMailSession *ems)
if (!ea->enabled) {
printf("Account changed, now disabled %s\n", ea->uid);
p->stores = g_list_remove(p->stores, store);
- ems_listener_session_event(ems, GNOME_Evolution_Mail_REMOVED, store);
+ ems_listener_session_event(ems, Evolution_Mail_REMOVED, store);
g_object_unref(store);
} else {
printf("Account changed, dont know how %s\n", ea->uid);
- ems_listener_session_event(ems, GNOME_Evolution_Mail_CHANGED, store);
+ ems_listener_session_event(ems, Evolution_Mail_CHANGED, store);
}
} else if (ea->enabled && is_storage(ea)) {
printf("Account changed, now added %s\n", ea->uid);
store = evolution_mail_store_new(ems, ea);
p->stores = g_list_append(p->stores, store);
- ems_listener_session_event(ems, GNOME_Evolution_Mail_ADDED, store);
+ ems_listener_session_event(ems, Evolution_Mail_ADDED, store);
}
}
@@ -333,7 +285,7 @@ ems_account_removed(EAccountList *eal, EAccount *ea, EvolutionMailSession *ems)
if (store->account == ea) {
printf("Account removed %s\n", ea->uid);
p->stores = g_list_remove(p->stores, store);
- ems_listener_session_event(ems, GNOME_Evolution_Mail_REMOVED, store);
+ ems_listener_session_event(ems, Evolution_Mail_REMOVED, store);
g_object_unref(store);
break;
}
@@ -379,108 +331,14 @@ evolution_mail_session_init (EvolutionMailSession *ems, EvolutionMailSessionClas
}
void
-evolution_mail_session_session_changed(EvolutionMailSession *ems, GNOME_Evolution_Mail_SessionChanges *changes)
-{
- struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems);
- struct _listener *l, *n;
- CORBA_Environment ev;
-
- l=(struct _listener *)p->listeners.head;
- n=l->next;
- while (n) {
- if (l->flags & (GNOME_Evolution_Mail_Session_SESSION_CHANGED|GNOME_Evolution_Mail_Session_SESSION_ADDED|GNOME_Evolution_Mail_Session_SESSION_REMOVED)) {
- memset(&ev, 0, sizeof(ev));
- GNOME_Evolution_Mail_Listener_sessionChanged(l->listener, bonobo_object_corba_objref((BonoboObject *)ems), changes, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- printf("listener.sessionChanged() failed, removing listener: %s\n", ev._id);
- CORBA_exception_free(&ev);
-
- remove_listener(l);
- } else {
- printf("listener.sessionChanged() successful\n");
- }
- }
- l = n;
- n = n->next;
- }
-}
-
-void
-evolution_mail_session_store_changed(EvolutionMailSession *ems, GNOME_Evolution_Mail_Store store, GNOME_Evolution_Mail_StoreChanges *changes)
+evolution_mail_session_changed(EvolutionMailSession *ems, Evolution_Mail_SessionChanges *changes)
{
struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems);
- struct _listener *l, *n;
- CORBA_Environment ev;
-
- l=(struct _listener *)p->listeners.head;
- n=l->next;
- while (n) {
- if (l->flags & (GNOME_Evolution_Mail_Session_STORE_CHANGED|GNOME_Evolution_Mail_Session_STORE_ADDED|GNOME_Evolution_Mail_Session_STORE_REMOVED)) {
- memset(&ev, 0, sizeof(ev));
- GNOME_Evolution_Mail_Listener_storeChanged(l->listener, bonobo_object_corba_objref((BonoboObject *)ems),
- store, changes, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- printf("listener.storeChanged() failed, removing listener: %s\n", ev._id);
- CORBA_exception_free(&ev);
-
- remove_listener(l);
- } else {
- printf("listener.storeChanged() successful\n");
- }
- }
- l = n;
- n = n->next;
- }
-}
-void
-evolution_mail_session_folder_changed(EvolutionMailSession *ems, GNOME_Evolution_Mail_Store store, GNOME_Evolution_Mail_Folder folder, GNOME_Evolution_Mail_FolderChanges *changes)
-{
- struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems);
- struct _listener *l, *n;
- CORBA_Environment ev;
-
- l=(struct _listener *)p->listeners.head;
- n=l->next;
- while (n) {
- if (l->flags & (GNOME_Evolution_Mail_Session_FOLDER_CHANGED|GNOME_Evolution_Mail_Session_FOLDER_ADDED|GNOME_Evolution_Mail_Session_FOLDER_REMOVED)) {
- memset(&ev, 0, sizeof(ev));
- GNOME_Evolution_Mail_Listener_folderChanged(l->listener, bonobo_object_corba_objref((BonoboObject *)ems),
- store, folder, changes, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- printf("listener.folderChanged() failed, removing listener: %s\n", ev._id);
- CORBA_exception_free(&ev);
- remove_listener(l);
- } else {
- printf("listener.folderChanged() successful\n");
- }
- }
- l = n;
- n = n->next;
+ if (!e_mail_listener_emit(&p->listeners, (EMailListenerChanged)Evolution_Mail_SessionListener_changed,
+ bonobo_object_corba_objref((BonoboObject *)ems), changes)) {
+ printf("No more listeners for store, could dispose session object now?\n");
}
}
-/**
- * evolution_mail_session_listening:
- * @ems:
- *
- * Check if anything is listening for events. Used to optimise the
- * code so it doesn't generate events if it doesn't need to.
- *
- * Return value:
- **/
-CORBA_long evolution_mail_session_listening(EvolutionMailSession *ems)
-{
- struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems);
- struct _listener *l;
- CORBA_long flags = 0;
-
- for (l=(struct _listener *)p->listeners.head;l->next;l=l->next)
- flags |= l->flags;
-
- return flags;
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionMailSession, GNOME_Evolution_Mail_Session, PARENT_TYPE, evolution_mail_session)
+BONOBO_TYPE_FUNC_FULL (EvolutionMailSession, Evolution_Mail_Session, PARENT_TYPE, evolution_mail_session)
diff --git a/plugins/mail-remote/evolution-mail-session.h b/plugins/mail-remote/evolution-mail-session.h
index 6b9ff61abc..bb29a53120 100644
--- a/plugins/mail-remote/evolution-mail-session.h
+++ b/plugins/mail-remote/evolution-mail-session.h
@@ -44,15 +44,11 @@ struct _EvolutionMailSession {
struct _EvolutionMailSessionClass {
BonoboObjectClass parent_class;
- POA_GNOME_Evolution_Mail_Session__epv epv;
+ POA_Evolution_Mail_Session__epv epv;
};
GType evolution_mail_session_get_type(void);
-CORBA_long evolution_mail_session_listening(EvolutionMailSession *ems);
-
-void evolution_mail_session_session_changed(EvolutionMailSession *ems, GNOME_Evolution_Mail_SessionChanges *changes);
-void evolution_mail_session_store_changed(EvolutionMailSession *ems, GNOME_Evolution_Mail_Store store, GNOME_Evolution_Mail_StoreChanges *changes);
-void evolution_mail_session_folder_changed(EvolutionMailSession *ems, GNOME_Evolution_Mail_Store store, GNOME_Evolution_Mail_Folder folder, GNOME_Evolution_Mail_FolderChanges *changes);
+void evolution_mail_session_changed(EvolutionMailSession *ems, Evolution_Mail_SessionChanges *changes);
#endif /* _EVOLUTION_MAIL_SESSION_H_ */
diff --git a/plugins/mail-remote/evolution-mail-sessionlistener.c b/plugins/mail-remote/evolution-mail-sessionlistener.c
new file mode 100644
index 0000000000..addbe1a820
--- /dev/null
+++ b/plugins/mail-remote/evolution-mail-sessionlistener.c
@@ -0,0 +1,179 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Michael Zucchi <notzed@novell.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <bonobo/bonobo-i18n.h>
+#include <bonobo/bonobo-exception.h>
+#include "evolution-mail-sessionlistener.h"
+
+#include "evolution-mail-marshal.h"
+
+#define PARENT_TYPE bonobo_object_get_type ()
+
+static BonoboObjectClass *parent_class = NULL;
+
+#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, evolution_mail_sessionlistener_get_type()))
+
+struct _EvolutionMailSessionListenerPrivate {
+ int dummy;
+};
+
+enum {
+ EML_CHANGED,
+ EML_SHUTDOWN,
+ EML_LAST_SIGNAL
+};
+
+static guint eml_signals[EML_LAST_SIGNAL];
+
+/* GObject methods */
+
+static void
+impl_dispose (GObject *object)
+{
+ struct _EvolutionMailSessionListenerPrivate *p = _PRIVATE(object);
+
+ p = p;
+
+ (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+}
+
+static void
+impl_finalize (GObject *object)
+{
+ printf("EvolutionMailSessionListener finalised!\n");
+
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+/* Evolution.Mail.Listener */
+static const char *change_type_name(int type)
+{
+ switch (type) {
+ case Evolution_Mail_ADDED:
+ return "added";
+ break;
+ case Evolution_Mail_CHANGED:
+ return "changed";
+ break;
+ case Evolution_Mail_REMOVED:
+ return "removed";
+ break;
+ default:
+ return "";
+ }
+}
+
+static void
+impl_changed(PortableServer_Servant _servant,
+ const Evolution_Mail_Session session,
+ const Evolution_Mail_SessionChanges * changes,
+ CORBA_Environment * ev)
+{
+ EvolutionMailSessionListener *eml = (EvolutionMailSessionListener *)bonobo_object_from_servant(_servant);
+ int i, j;
+
+ printf("session changed!\n");
+ for (i=0;i<changes->_length;i++) {
+ printf(" %d %s", changes->_buffer[i].stores._length, change_type_name(changes->_buffer[i].type));
+ for (j=0;j<changes->_buffer[i].stores._length;j++) {
+ printf(" %s %s\n", changes->_buffer[i].stores._buffer[j].uid, changes->_buffer[i].stores._buffer[j].name);
+ }
+ }
+
+ g_signal_emit(eml, eml_signals[EML_CHANGED], 0, session, changes);
+}
+
+static void
+impl_shutdown(PortableServer_Servant _servant,
+ const Evolution_Mail_Session session,
+ CORBA_Environment * ev)
+{
+ EvolutionMailSessionListener *eml = (EvolutionMailSessionListener *)bonobo_object_from_servant(_servant);
+
+ printf("session shutdown?\n");
+
+ g_signal_emit(eml, eml_signals[EML_SHUTDOWN], 0, session);
+}
+
+/* Initialization */
+
+static void
+evolution_mail_sessionlistener_class_init (EvolutionMailSessionListenerClass *klass)
+{
+ POA_Evolution_Mail_SessionListener__epv *epv = &klass->epv;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ epv->changed = impl_changed;
+ epv->shutdown = impl_shutdown;
+
+ object_class->dispose = impl_dispose;
+ object_class->finalize = impl_finalize;
+
+ g_type_class_add_private(klass, sizeof(struct _EvolutionMailSessionListenerPrivate));
+
+ eml_signals[EML_CHANGED] =
+ g_signal_new("changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvolutionMailSessionListenerClass, changed),
+ NULL, NULL,
+ evolution_mail_marshal_VOID__POINTER_POINTER,
+ G_TYPE_NONE, 2,
+ G_TYPE_POINTER, G_TYPE_POINTER);
+
+ eml_signals[EML_CHANGED] =
+ g_signal_new("shutdown",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvolutionMailSessionListenerClass, changed),
+ NULL, NULL,
+ evolution_mail_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
+}
+
+static void
+evolution_mail_sessionlistener_init (EvolutionMailSessionListener *ems, EvolutionMailSessionListenerClass *klass)
+{
+ struct _EvolutionMailSessionListenerPrivate *p = _PRIVATE(ems);
+
+ p = p;
+}
+
+EvolutionMailSessionListener *
+evolution_mail_sessionlistener_new(void)
+{
+ EvolutionMailSessionListener *eml;
+
+ eml = g_object_new(evolution_mail_sessionlistener_get_type(), NULL);
+
+ return eml;
+}
+
+BONOBO_TYPE_FUNC_FULL (EvolutionMailSessionListener, Evolution_Mail_SessionListener, PARENT_TYPE, evolution_mail_sessionlistener)
diff --git a/plugins/mail-remote/evolution-mail-sessionlistener.h b/plugins/mail-remote/evolution-mail-sessionlistener.h
new file mode 100644
index 0000000000..654de4e238
--- /dev/null
+++ b/plugins/mail-remote/evolution-mail-sessionlistener.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * Author: Michael Zucchi <notzed@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _EVOLUTION_MAIL_SESSIONLISTENER_H_
+#define _EVOLUTION_MAIL_SESSIONLISTENER_H_
+
+#include <bonobo/bonobo-object.h>
+#include "Evolution-DataServer-Mail.h"
+
+#define EVOLUTION_MAIL_TYPE_SESSIONLISTENER (evolution_mail_sessionlistener_get_type ())
+#define EVOLUTION_MAIL_SESSIONLISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailSessionListener))
+#define EVOLUTION_MAIL_SESSIONLISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailSessionListenerClass))
+#define EVOLUTION_MAIL_IS_SESSIONLISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
+#define EVOLUTION_MAIL_IS_SESSIONLISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
+
+typedef struct _EvolutionMailSessionListener EvolutionMailSessionListener;
+typedef struct _EvolutionMailSessionListenerClass EvolutionMailSessionListenerClass;
+
+struct _EvolutionMailSessionListener {
+ BonoboObject parent;
+};
+
+struct _EvolutionMailSessionListenerClass {
+ BonoboObjectClass parent_class;
+
+ POA_Evolution_Mail_SessionListener__epv epv;
+
+ void (*changed)(EvolutionMailSessionListener *, const Evolution_Mail_Session session, const Evolution_Mail_SessionChanges *);
+};
+
+GType evolution_mail_sessionlistener_get_type(void);
+
+EvolutionMailSessionListener *evolution_mail_sessionlistener_new(void);
+
+#endif /* _EVOLUTION_MAIL_SESSIONLISTENER_H_ */
diff --git a/plugins/mail-remote/evolution-mail-store.c b/plugins/mail-remote/evolution-mail-store.c
index b5cfd3840d..349925dd61 100644
--- a/plugins/mail-remote/evolution-mail-store.c
+++ b/plugins/mail-remote/evolution-mail-store.c
@@ -67,6 +67,8 @@ struct _EvolutionMailStorePrivate {
guint32 folder_renamed;
guint32 folder_subscribed;
guint32 folder_unsubscribed;
+
+ EDList listeners;
};
/* GObject methods */
@@ -77,8 +79,6 @@ impl_dispose (GObject *object)
EvolutionMailStore *ems = (EvolutionMailStore *)object;
struct _EvolutionMailStorePrivate *p = _PRIVATE(object);
- p = p;
-
/* FIXME: unref store
unhook events */
@@ -87,6 +87,8 @@ impl_dispose (GObject *object)
ems->account = NULL;
}
+ e_mail_listener_free(&p->listeners);
+
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
@@ -111,25 +113,25 @@ impl_finalize (GObject *object)
static CORBA_boolean
impl_getProperties(PortableServer_Servant _servant,
- const GNOME_Evolution_Mail_PropertyNames* names,
- GNOME_Evolution_Mail_Properties **propsp,
+ const Evolution_Mail_PropertyNames* names,
+ Evolution_Mail_Properties **propsp,
CORBA_Environment * ev)
{
EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant);
int i;
- GNOME_Evolution_Mail_Properties *props;
+ Evolution_Mail_Properties *props;
/*struct _EvolutionMailStorePrivate *p = _PRIVATE(ems);*/
CORBA_boolean ok = CORBA_TRUE;
- *propsp = props = GNOME_Evolution_Mail_Properties__alloc();
+ *propsp = props = Evolution_Mail_Properties__alloc();
props->_length = names->_length;
props->_maximum = props->_length;
- props->_buffer = GNOME_Evolution_Mail_Properties_allocbuf(props->_maximum);
+ props->_buffer = Evolution_Mail_Properties_allocbuf(props->_maximum);
CORBA_sequence_set_release(props, CORBA_TRUE);
for (i=0;i<names->_length;i++) {
const CORBA_char *name = names->_buffer[i];
- GNOME_Evolution_Mail_Property *prop = &props->_buffer[i];
+ Evolution_Mail_Property *prop = &props->_buffer[i];
printf("getting property '%s'\n", name);
@@ -212,31 +214,31 @@ ems_sort_folders(struct _EvolutionMailStorePrivate *p)
}
static void
-ems_set_changes(GNOME_Evolution_Mail_StoreChange *change, GNOME_Evolution_Mail_ChangeType how, GPtrArray *changed)
+ems_set_changes(Evolution_Mail_StoreChange *change, Evolution_Mail_ChangeType how, GPtrArray *changed)
{
int i;
change->type = how;
change->folders._maximum = changed->len;
change->folders._length = changed->len;
- change->folders._buffer = GNOME_Evolution_Mail_FolderInfos_allocbuf(change->folders._maximum);
+ change->folders._buffer = Evolution_Mail_FolderInfos_allocbuf(change->folders._maximum);
CORBA_sequence_set_release(&change->folders, TRUE);
for (i=0;i<changed->len;i++)
e_mail_folderinfo_set_folder(&change->folders._buffer[i], changed->pdata[i]);
}
-static GNOME_Evolution_Mail_StoreChanges *
-ems_create_changes(EvolutionMailStore *ems, GNOME_Evolution_Mail_ChangeType how, GPtrArray *changed)
+static Evolution_Mail_StoreChanges *
+ems_create_changes(EvolutionMailStore *ems, Evolution_Mail_ChangeType how, GPtrArray *changed)
{
- GNOME_Evolution_Mail_StoreChanges *changes;
+ Evolution_Mail_StoreChanges *changes;
/* NB: we only ever create 1 changetype at the moment */
- changes = GNOME_Evolution_Mail_StoreChanges__alloc();
+ changes = Evolution_Mail_StoreChanges__alloc();
changes->_maximum = 1;
changes->_length = 1;
- changes->_buffer = GNOME_Evolution_Mail_StoreChanges_allocbuf(1);
+ changes->_buffer = Evolution_Mail_StoreChanges_allocbuf(1);
CORBA_sequence_set_release(changes, TRUE);
ems_set_changes(&changes->_buffer[0], how, changed);
@@ -260,19 +262,17 @@ ems_folder_subscribed(CamelObject *o, void *d, void *data)
{
EvolutionMailStore *ems = data;
CamelFolderInfo *fi = d;
- GPtrArray *added = NULL;
+ GPtrArray *added;
int i;
- if (evolution_mail_session_listening(ems->session) & GNOME_Evolution_Mail_Session_STORE_ADDED)
- added = g_ptr_array_new();
-
+ added = g_ptr_array_new();
ems_add_folders(ems, fi, added);
if (added) {
if (added->len) {
- GNOME_Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, GNOME_Evolution_Mail_ADDED, added);
+ Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, Evolution_Mail_ADDED, added);
- evolution_mail_session_store_changed(ems->session, bonobo_object_corba_objref((BonoboObject *)ems), changes);
+ evolution_mail_store_changed(ems, changes);
CORBA_free(changes);
for (i=0;i<added->len;i++)
@@ -290,16 +290,14 @@ ems_folder_unsubscribed(CamelObject *o, void *d, void *data)
GPtrArray *removed = NULL;
int i;
- if (evolution_mail_session_listening(ems->session) & GNOME_Evolution_Mail_Session_STORE_REMOVED)
- removed = g_ptr_array_new();
-
+ removed = g_ptr_array_new();
ems_remove_folders(ems, fi, removed);
if (removed) {
if (removed->len) {
- GNOME_Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, GNOME_Evolution_Mail_REMOVED, removed);
+ Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, Evolution_Mail_REMOVED, removed);
- evolution_mail_session_store_changed(ems->session, bonobo_object_corba_objref((BonoboObject *)ems), changes);
+ evolution_mail_store_changed(ems, changes);
CORBA_free(changes);
for (i=0;i<removed->len;i++)
@@ -356,13 +354,10 @@ ems_folder_renamed(CamelObject *o, void *d, void *data)
struct _EvolutionMailStorePrivate *p = _PRIVATE(ems);
CamelRenameInfo *reninfo = d;
int i, oldlen, newlen;
- GPtrArray *renamed = NULL, *folders = g_ptr_array_new();
+ GPtrArray *renamed = g_ptr_array_new(), *folders = g_ptr_array_new();
CamelFolderInfo *top;
GString *name = g_string_new("");
- if (evolution_mail_session_listening(ems->session) & GNOME_Evolution_Mail_Session_STORE_CHANGED)
- renamed = g_ptr_array_new();
-
/* flatten/sort folders to make sure they're in the right order */
get_folders(reninfo->new, folders);
qsort(folders->pdata, folders->len, sizeof(folders->pdata[0]), folder_cmp);
@@ -397,9 +392,9 @@ ems_folder_renamed(CamelObject *o, void *d, void *data)
if (renamed) {
if (renamed->len) {
- GNOME_Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, GNOME_Evolution_Mail_CHANGED, renamed);
+ Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, Evolution_Mail_CHANGED, renamed);
- evolution_mail_session_store_changed(ems->session, bonobo_object_corba_objref((BonoboObject *)ems), changes);
+ evolution_mail_store_changed(ems, changes);
CORBA_free(changes);
for (i=0;i<renamed->len;i++)
@@ -409,27 +404,23 @@ ems_folder_renamed(CamelObject *o, void *d, void *data)
}
}
-static GNOME_Evolution_Mail_FolderInfos *
+static Evolution_Mail_FolderInfos *
impl_getFolders(PortableServer_Servant _servant,
const CORBA_char * pattern,
+ const Evolution_Mail_FolderListener listener,
CORBA_Environment * ev)
{
EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant);
struct _EvolutionMailStorePrivate *p = _PRIVATE(ems);
CamelFolderInfo *fi;
CamelException ex = { 0 };
- GNOME_Evolution_Mail_FolderInfos *folders = NULL;
+ Evolution_Mail_FolderInfos *folders = NULL;
int i;
CamelStore *store;
store = evolution_mail_store_get_store(ems);
if (store == NULL) {
- GNOME_Evolution_Mail_FAILED *x;
-
- x = GNOME_Evolution_Mail_FAILED__alloc();
- x->why = CORBA_string_dup("Unable to open store");
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_FAILED, x);
-
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
return CORBA_OBJECT_NIL;
}
@@ -443,26 +434,23 @@ impl_getFolders(PortableServer_Servant _servant,
camel_store_free_folder_info(store, fi);
ems_sort_folders(p);
} else {
- GNOME_Evolution_Mail_FAILED *x;
-
- x = GNOME_Evolution_Mail_FAILED__alloc();
- x->why = CORBA_string_dup("Unable to list folders");
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_FAILED, x);
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
camel_object_unref(store);
return CORBA_OBJECT_NIL;
}
}
- folders = GNOME_Evolution_Mail_FolderInfos__alloc();
+ folders = Evolution_Mail_FolderInfos__alloc();
folders->_length = p->folders_array->len;
folders->_maximum = folders->_length;
- folders->_buffer = GNOME_Evolution_Mail_FolderInfos_allocbuf(folders->_maximum);
+ folders->_buffer = Evolution_Mail_FolderInfos_allocbuf(folders->_maximum);
CORBA_sequence_set_release(folders, CORBA_TRUE);
for (i=0;i<p->folders_array->len;i++) {
EvolutionMailFolder *emf = p->folders_array->pdata[i];
+ evolution_mail_folder_addlistener(emf, listener);
e_mail_folderinfo_set_folder(&folders->_buffer[i], emf);
}
@@ -481,37 +469,25 @@ impl_sendMessage(PortableServer_Servant _servant,
CamelMimeMessage *msg;
CamelInternetAddress *from;
CamelMessageInfo *info;
- CamelStream *mem;
if (ems->account == NULL
|| ems->account->transport == NULL
|| ems->account->transport->url == NULL) {
#if 0
- GNOME_Evolution_Mail_NOT_SUPPORTED *x;
+ Evolution_Mail_NOT_SUPPORTED *x;
- x = GNOME_Evolution_Mail_NOT_SUPPORTED__alloc();
+ x = Evolution_Mail_NOT_SUPPORTED__alloc();
x->why = CORBA_string_dup(ex.desc);
#endif
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_NOT_SUPPORTED, NULL);
- return;
- }
-
- mem = camel_stream_mem_new();
- if (e_stream_bonobo_to_camel(message, mem) == -1) {
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_FAILED, NULL);
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_NOT_SUPPORTED, NULL);
return;
}
- printf("Sending message '%.*s'\n", ((CamelStreamMem *)mem)->buffer->len, ((CamelStreamMem *)mem)->buffer->data);
-
- msg = camel_mime_message_new();
- if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, mem) == -1) {
- camel_object_unref(mem);
- camel_object_unref(msg);
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_FAILED, NULL);
+ msg = e_stream_bonobo_to_message(message);
+ if (msg == NULL) {
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
return;
}
- camel_object_unref(mem);
from = camel_internet_address_new();
camel_internet_address_add(from, ems->account->id->name, ems->account->id->address);
@@ -530,7 +506,7 @@ impl_sendMessage(PortableServer_Servant _servant,
camel_message_info_free(info);
if (camel_exception_is_set(&ex)) {
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Mail_FAILED, NULL);
+ CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_FAILED, NULL);
camel_exception_clear(&ex);
} else {
/*mail_send();*/
@@ -544,7 +520,7 @@ impl_sendMessage(PortableServer_Servant _servant,
static void
evolution_mail_store_class_init (EvolutionMailStoreClass *klass)
{
- POA_GNOME_Evolution_Mail_Store__epv *epv = &klass->epv;
+ POA_Evolution_Mail_Store__epv *epv = &klass->epv;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -560,11 +536,15 @@ evolution_mail_store_class_init (EvolutionMailStoreClass *klass)
}
static void
-evolution_mail_store_init(EvolutionMailStore *component, EvolutionMailStoreClass *klass)
+evolution_mail_store_init(EvolutionMailStore *ems, EvolutionMailStoreClass *klass)
{
+ struct _EvolutionMailStorePrivate *p = _PRIVATE(ems);
+
+ bonobo_object_set_immortal((BonoboObject *)ems, TRUE);
+ e_dlist_init(&p->listeners);
}
-BONOBO_TYPE_FUNC_FULL (EvolutionMailStore, GNOME_Evolution_Mail_Store, PARENT_TYPE, evolution_mail_store)
+BONOBO_TYPE_FUNC_FULL (EvolutionMailStore, Evolution_Mail_Store, PARENT_TYPE, evolution_mail_store)
EvolutionMailStore *
evolution_mail_store_new(struct _EvolutionMailSession *s, struct _EAccount *ea)
@@ -642,3 +622,23 @@ CamelStore *evolution_mail_store_get_store(EvolutionMailStore *ems)
camel_object_ref(p->store);
return p->store;
}
+
+void
+evolution_mail_store_addlistener(EvolutionMailStore *ems, Evolution_Mail_StoreListener listener)
+{
+ struct _EvolutionMailStorePrivate *p = _PRIVATE(ems);
+
+ /* FIXME: locking */
+ e_mail_listener_add(&p->listeners, listener);
+}
+
+void
+evolution_mail_store_changed(EvolutionMailStore *ems, Evolution_Mail_StoreChanges *changes)
+{
+ struct _EvolutionMailStorePrivate *p = _PRIVATE(ems);
+
+ if (!e_mail_listener_emit(&p->listeners, (EMailListenerChanged)Evolution_Mail_StoreListener_changed,
+ bonobo_object_corba_objref((BonoboObject *)ems), changes)) {
+ printf("No more listeners for store, could dispose store object now\n");
+ }
+}
diff --git a/plugins/mail-remote/evolution-mail-store.h b/plugins/mail-remote/evolution-mail-store.h
index b0e8be8e84..d93c32c26e 100644
--- a/plugins/mail-remote/evolution-mail-store.h
+++ b/plugins/mail-remote/evolution-mail-store.h
@@ -48,13 +48,16 @@ struct _EvolutionMailStore {
struct _EvolutionMailStoreClass {
BonoboObjectClass parent_class;
- POA_GNOME_Evolution_Mail_Store__epv epv;
+ POA_Evolution_Mail_Store__epv epv;
};
GType evolution_mail_store_get_type(void);
EvolutionMailStore *evolution_mail_store_new(struct _EvolutionMailSession *s, struct _EAccount *ea);
+void evolution_mail_store_addlistener(EvolutionMailStore *store, Evolution_Mail_StoreListener listener);
+void evolution_mail_store_changed(EvolutionMailStore *ems, Evolution_Mail_StoreChanges *changes);
+
const char *evolution_mail_store_get_name(EvolutionMailStore *);
const char *evolution_mail_store_get_uid(EvolutionMailStore *);
diff --git a/plugins/mail-remote/evolution-mail-storelistener.c b/plugins/mail-remote/evolution-mail-storelistener.c
new file mode 100644
index 0000000000..3d859383c0
--- /dev/null
+++ b/plugins/mail-remote/evolution-mail-storelistener.c
@@ -0,0 +1,155 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Michael Zucchi <notzed@novell.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <bonobo/bonobo-i18n.h>
+#include <bonobo/bonobo-exception.h>
+#include "evolution-mail-storelistener.h"
+
+#include "evolution-mail-marshal.h"
+
+#define PARENT_TYPE bonobo_object_get_type ()
+
+static BonoboObjectClass *parent_class = NULL;
+
+#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, evolution_mail_storelistener_get_type()))
+
+struct _EvolutionMailStoreListenerPrivate {
+ int dummy;
+};
+
+enum {
+ EML_CHANGED,
+ EML_LAST_SIGNAL
+};
+
+static guint eml_signals[EML_LAST_SIGNAL];
+
+/* GObject methods */
+
+static void
+impl_dispose (GObject *object)
+{
+ struct _EvolutionMailStoreListenerPrivate *p = _PRIVATE(object);
+
+ p = p;
+
+ (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+}
+
+static void
+impl_finalize (GObject *object)
+{
+ printf("EvolutionMailStoreListener finalised!\n");
+
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+/* Evolution.Mail.Listener */
+static const char *change_type_name(int type)
+{
+ switch (type) {
+ case Evolution_Mail_ADDED:
+ return "added";
+ break;
+ case Evolution_Mail_CHANGED:
+ return "changed";
+ break;
+ case Evolution_Mail_REMOVED:
+ return "removed";
+ break;
+ default:
+ return "";
+ }
+}
+
+static void
+impl_changed(PortableServer_Servant _servant,
+ const Evolution_Mail_Store store,
+ const Evolution_Mail_StoreChanges * changes,
+ CORBA_Environment * ev)
+{
+ EvolutionMailStoreListener *eml = (EvolutionMailStoreListener *)bonobo_object_from_servant(_servant);
+ int i, j;
+
+ printf("store changed!\n");
+ for (i=0;i<changes->_length;i++) {
+ printf(" %d %s", changes->_buffer[i].folders._length, change_type_name(changes->_buffer[i].type));
+ for (j=0;j<changes->_buffer[i].folders._length;j++) {
+ printf(" %s %s\n", changes->_buffer[i].folders._buffer[j].full_name, changes->_buffer[i].folders._buffer[j].name);
+ }
+ }
+
+ g_signal_emit(eml, eml_signals[EML_CHANGED], 0, store, changes);
+}
+
+/* Initialization */
+
+static void
+evolution_mail_storelistener_class_init (EvolutionMailStoreListenerClass *klass)
+{
+ POA_Evolution_Mail_StoreListener__epv *epv = &klass->epv;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ epv->changed = impl_changed;
+
+ object_class->dispose = impl_dispose;
+ object_class->finalize = impl_finalize;
+
+ g_type_class_add_private(klass, sizeof(struct _EvolutionMailStoreListenerPrivate));
+
+ eml_signals[EML_CHANGED] =
+ g_signal_new("changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvolutionMailStoreListenerClass, changed),
+ NULL, NULL,
+ evolution_mail_marshal_VOID__POINTER_POINTER,
+ G_TYPE_NONE, 2,
+ G_TYPE_POINTER, G_TYPE_POINTER);
+}
+
+static void
+evolution_mail_storelistener_init (EvolutionMailStoreListener *ems, EvolutionMailStoreListenerClass *klass)
+{
+ struct _EvolutionMailStoreListenerPrivate *p = _PRIVATE(ems);
+
+ p = p;
+}
+
+EvolutionMailStoreListener *
+evolution_mail_storelistener_new(void)
+{
+ EvolutionMailStoreListener *eml;
+
+ eml = g_object_new(evolution_mail_storelistener_get_type(), NULL);
+
+ return eml;
+}
+
+BONOBO_TYPE_FUNC_FULL (EvolutionMailStoreListener, Evolution_Mail_StoreListener, PARENT_TYPE, evolution_mail_storelistener)
diff --git a/plugins/mail-remote/evolution-mail-storelistener.h b/plugins/mail-remote/evolution-mail-storelistener.h
new file mode 100644
index 0000000000..4aa002bdd2
--- /dev/null
+++ b/plugins/mail-remote/evolution-mail-storelistener.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * Author: Michael Zucchi <notzed@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _EVOLUTION_MAIL_STORELISTENER_H_
+#define _EVOLUTION_MAIL_STORELISTENER_H_
+
+#include <bonobo/bonobo-object.h>
+#include "Evolution-DataServer-Mail.h"
+
+#define EVOLUTION_MAIL_TYPE_STORELISTENER (evolution_mail_storelistener_get_type ())
+#define EVOLUTION_MAIL_STORELISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailStoreListener))
+#define EVOLUTION_MAIL_STORELISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_MAIL_TYPE_LISTENER, EvolutionMailStoreListenerClass))
+#define EVOLUTION_MAIL_IS_STORELISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
+#define EVOLUTION_MAIL_IS_STORELISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_MAIL_TYPE_LISTENER))
+
+typedef struct _EvolutionMailStoreListener EvolutionMailStoreListener;
+typedef struct _EvolutionMailStoreListenerClass EvolutionMailStoreListenerClass;
+
+struct _EvolutionMailStoreListener {
+ BonoboObject parent;
+};
+
+struct _EvolutionMailStoreListenerClass {
+ BonoboObjectClass parent_class;
+
+ POA_Evolution_Mail_StoreListener__epv epv;
+
+ void (*changed)(EvolutionMailStoreListener *, const Evolution_Mail_Store store, const Evolution_Mail_StoreChanges *);
+};
+
+GType evolution_mail_storelistener_get_type(void);
+
+EvolutionMailStoreListener *evolution_mail_storelistener_new(void);
+
+#endif /* _EVOLUTION_MAIL_STORELISTENER_H_ */