diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2007-12-17 21:22:59 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2007-12-17 21:22:59 +0800 |
commit | 70aeb47914023a4cb9931cd7d45dd00d64aae288 (patch) | |
tree | 197e7a414051560719e7ad6242627220838bff39 /plugins | |
parent | 8bdb85463f20be52906aad05ce7e09ffb929e331 (diff) | |
download | gsoc2013-evolution-70aeb47914023a4cb9931cd7d45dd00d64aae288.tar gsoc2013-evolution-70aeb47914023a4cb9931cd7d45dd00d64aae288.tar.gz gsoc2013-evolution-70aeb47914023a4cb9931cd7d45dd00d64aae288.tar.bz2 gsoc2013-evolution-70aeb47914023a4cb9931cd7d45dd00d64aae288.tar.lz gsoc2013-evolution-70aeb47914023a4cb9931cd7d45dd00d64aae288.tar.xz gsoc2013-evolution-70aeb47914023a4cb9931cd7d45dd00d64aae288.tar.zst gsoc2013-evolution-70aeb47914023a4cb9931cd7d45dd00d64aae288.zip |
Actually remove the mail-remote plugin, like the ChangeLog says.
svn path=/trunk/; revision=34721
Diffstat (limited to 'plugins')
28 files changed, 0 insertions, 4066 deletions
diff --git a/plugins/mail-remote/ChangeLog b/plugins/mail-remote/ChangeLog deleted file mode 100644 index 0377147c38..0000000000 --- a/plugins/mail-remote/ChangeLog +++ /dev/null @@ -1,99 +0,0 @@ -2007-10-29 Matthew Barnes <mbarnes@redhat.com> - - * evolution-mail-sessionlistener.c: - Use g_cclosure_marshal_VOID__POINTER instead of - evolution_mail_marshal_VOID__POINTER. - -2007-09-27 Hiroyuki Ikezoe <poincare@ikezoe.net> - - ** Fix for bug #461195 - - * evolution-mail-marshal.list: Remove needless marshalers. - -2007-05-12 Matthew Barnes <mbarnes@redhat.com> - - ** Fixes part of bug #337616 - - * Makefile.am: Add "eplug.xml" file to EXTRA_DIST. - -2007-04-02 Sankar P <psankar@novell.com> - - * Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr> - - * org-gnome-evolution-mail-remote.eplug.xml: - Cleanup. - Fixes part of #301149 - -2006-01-06 Simon Zheng <simon.zheng@sun.com> - - * evolution-mail-session.c: - * evolution-mail-store.c: - use libedataserver/e-account-list.h instead of e-util/e-account-list.h. - use libedataserver/e-account.h instead of e-util/e-account.h. - -2005-08-10 Not Zed <NotZed@Ximian.com> - - ** See #271985. - - * evolution-mail-session.c (is_storage): check for uri "" and pass - exception to provider get. - -2005-08-02 Not Zed <NotZed@Ximian.com> - - * org-gnome-evolution-mail-remote.eplug.xml: How strange, this was - never added, but nobody noticed till now. - -2005-06-02 Not Zed <NotZed@Ximian.com> - - * Evolution.idl: seutp an idl file so we only need to generate one - set of skels/stubs for all imported. - - * mail-remote.c (e_plugin_lib_enable): instead of writing ior to a - file, just add the Session interface to the mail component. - - * client.c (get_session): use the new shell interface to find the - mail compnent and retrieve the session interface using - bonobo-activation, so the mailer starts if we try to access it. - -2005-05-27 Not Zed <NotZed@Ximian.com> - - * em-message-stream.[ch]: A camel-stream to wrap - Evolution_Mail_MessageStream. - - * evolution-mail-messagestream.[ch]: simplified read-only stream - interface rather than using bonobo-stream. It wraps a - camel-stream only & simplified lifecycle management. - - * evolution-mail-store.c (evolution_mail_store_changed): if we - have no more listeners, close the camelstore object off. - - * Evolution-DataServer-Mail.idl: changed exceptions to use one - exception type with details. Fixed code to use these. - -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. - Filled out api. - -2005-05-20 Not Zed <NotZed@Ximian.com> - - * Lots of work, filled out functions, cleaned up idl to make the - data more useful, added a listener interface, etc. - -2005-05-12 Not Zed <NotZed@Ximian.com> - - * A remote mail interface plugin for evolution. - diff --git a/plugins/mail-remote/Evolution-DataServer-Mail.idl b/plugins/mail-remote/Evolution-DataServer-Mail.idl deleted file mode 100644 index 453637f643..0000000000 --- a/plugins/mail-remote/Evolution-DataServer-Mail.idl +++ /dev/null @@ -1,209 +0,0 @@ -/* Evolution Mail Data Interface - * - * Copyright (C) 2005 Novell, Inc. - * - * Authors: Michael Zucchi <notzed@novell.com> - */ - -#ifndef _EVOLUTION_DATASERVER_MAIL_IDL_ -#define _EVOLUTION_DATASERVER_MAIL_IDL_ - -#include <Bonobo.idl> - -module Evolution { -module Mail { - /* ********************************************************************** */ - // NB: tiny subset of omg properties service - typedef string PropertyName; - typedef sequence <PropertyName> PropertyNames; - struct Property { - PropertyName name; - any value; - }; - typedef sequence <Property> Properties; - - /* ********************************************************************** */ - // exceptions - - enum ErrorType { - SYSTEM_ERROR, - CAMEL_ERROR, - FAILED, - NOT_SUPPORTED, - NO_PERMISSION - }; - - exception MailException { - ErrorType id; - string desc; - }; - - /* ********************************************************************** */ - // Main interfaces - interface Folder; - typedef sequence<Folder> Folders; - - struct FolderInfo { - string name; - string full_name; - Folder folder; - }; - typedef sequence <FolderInfo> FolderInfos; - - interface Store; - typedef sequence<Store> Stores; - - struct StoreInfo { - string name; - string uid; - Store store; - }; - typedef sequence <StoreInfo> StoreInfos; - - interface Session; - - // ********************************************************************** - // MessageInfo wrappers - typedef string UserFlag; - typedef sequence <UserFlag> UserFlags; - - struct UserTag { - string name; - string value; // value == "" == unset - }; - typedef sequence <UserTag> UserTags; - - struct MessageInfo { - string uid; - string subject; - string to; - string from; - long flags; // CamelMessageInfo flag bits - UserFlags userFlags; - UserTags userTags; - }; - typedef sequence <MessageInfo> MessageInfos; - - // Used to pass to altering functions - struct MessageInfoSet { - string uid; - long flagSet; // values bits to set in the flags - long flagMask; // mask of bits to change in the flags - UserFlags userFlagSet; - UserFlags userFlagUnset; - UserTags userTags; - }; - typedef sequence <MessageInfoSet> MessageInfoSets; - - /* ********************************************************************** */ - /* Messages are passed as full rfc822 encoded messages in a stream */ - typedef sequence <octet>Buffer; - - interface MessageStream : Bonobo::Unknown { - Buffer next(in long size) - raises (MailException); - - void dispose(); - }; - - interface MessageIterator : Bonobo::Unknown { - MessageInfos next(in long limit) - raises (MailException); - - void dispose(); - }; - - /* ********************************************************************** */ - - enum ChangeType { - ADDED, - REMOVED, - CHANGED - }; - - // ?? - struct SessionChange { - ChangeType type; - StoreInfos stores; - }; - typedef sequence <SessionChange> SessionChanges; - - struct StoreChange { - ChangeType type; - FolderInfos folders; - }; - typedef sequence <StoreChange> StoreChanges; - - struct FolderChange { - ChangeType type; - MessageInfos messages; - }; - typedef sequence <FolderChange> FolderChanges; - - /* ********************************************************************** */ - /* listeners */ - - interface SessionListener : Bonobo::Unknown { - oneway void changed(in Session session, in SessionChanges changes); - - oneway void shutdown(in Session session); - - // We need to use gnome-keyring instead of an interface like this? - // Or does gnome-keyring run off this? - //string getPassword(in Session session, string uri, string domain, string item, string prompt, long flags); - }; - - interface StoreListener : Bonobo::Unknown { - oneway void changed(in Store store, in StoreChanges changes); - }; - - interface FolderListener : Bonobo::Unknown { - oneway void changed(in Folder folder, in FolderChanges changes); - }; - - /* ********************************************************************** */ - -// 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, in StoreListener listener) - raises (MailException); - - 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, in FolderListener listener) - raises (MailException); - - void sendMessage(in MessageStream msg) - raises (MailException); - }; - - interface Folder : Bonobo::Unknown { - boolean getProperties(in PropertyNames names, out Properties props); - - MessageIterator getMessages(in string pattern) - raises (MailException); - - void changeMessages(in MessageInfoSets infos) - raises (MailException); - - MessageStream getMessage(in string uid) - raises (MailException); - - void appendMessage(in MessageInfoSet info, in MessageStream msg) - raises (MailException); - }; -}; -}; - -#endif diff --git a/plugins/mail-remote/Evolution.idl b/plugins/mail-remote/Evolution.idl deleted file mode 100644 index c5385d5800..0000000000 --- a/plugins/mail-remote/Evolution.idl +++ /dev/null @@ -1,6 +0,0 @@ - -/* All external interfaces should go here, so we only create a single skels file */ - -#include <Bonobo.idl> -#include <shell/Evolution.idl> -#include <mail/Evolution-Mail.idl> diff --git a/plugins/mail-remote/Makefile.am b/plugins/mail-remote/Makefile.am deleted file mode 100644 index 99375bc92f..0000000000 --- a/plugins/mail-remote/Makefile.am +++ /dev/null @@ -1,94 +0,0 @@ - -INCLUDES = \ - -I$(top_srcdir) \ - $(EVOLUTION_MAIL_CFLAGS) - -@EVO_PLUGIN_RULE@ - -plugin_DATA = org-gnome-evolution-mail-remote.eplug -plugin_LTLIBRARIES = liborg-gnome-evolution-mail-remote.la - -liborg_gnome_evolution_mail_remote_la_SOURCES = \ - $(IDL_GENERATED_C) \ - $(IDL_GENERATED_H) \ - e-corba-utils.c \ - e-corba-utils.h \ - em-message-stream.c \ - em-message-stream.h \ - evolution-mail-folder.c \ - evolution-mail-folder.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-messagestream.c \ - evolution-mail-messagestream.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-storelistener.c \ - evolution-mail-storelistener.h \ - mail-remote.c - -liborg_gnome_evolution_mail_remote_la_LDFLAGS = -module -avoid-version - -client_SOURCES = \ - client.c - -client_LDADD = \ - $(EVOLUTION_MAIL_LIBS) \ - evolution-mail-sessionlistener.o \ - evolution-mail-storelistener.o \ - evolution-mail-folderlistener.o \ - evolution-mail-marshal.o \ - evolution-mail-messagestream.o \ - Evolution-DataServer-Mail-common.o \ - Evolution-DataServer-Mail-stubs.o \ - Evolution-DataServer-Mail-skels.o \ - Evolution-common.o \ - Evolution-stubs.o - -noinst_PROGRAMS = \ - client - -# mail idl - -IDL = Evolution-DataServer-Mail.idl - -IDL_GENERATED_H = \ - Evolution-DataServer-Mail.h - -IDL_GENERATED_C = \ - Evolution-DataServer-Mail-common.c \ - Evolution-DataServer-Mail-skels.c \ - Evolution-DataServer-Mail-stubs.c - -EVO_GENERATED = Evolution.h Evolution-common.c Evolution-stubs.c Evolution-skels.c - -$(IDL_GENERATED_H) $(IDL_GENERATED_C): $(IDL) - $(ORBIT_IDL) -I $(srcdir) -I $(datadir)/idl $(IDL_INCLUDES) $^ - -$(EVO_GENERATED): $(srcdir)/Evolution.idl - $(ORBIT_IDL) -I $(top_srcdir) -I $(top_srcdir)/shell -I $(datadir)/idl $(IDL_INCLUDES) $^ - -# installed idls - -#idl_DATA = $(IDL) - -# marshallers for glib -MARSHAL_GENERATED = evolution-mail-marshal.c evolution-mail-marshal.h -@EVO_MARSHAL_RULE@ - -EXTRA_DIST = \ - $(IDL) \ - Evolution.idl \ - evolution-mail-marshal.list \ - org-gnome-evolution-mail-remote.eplug.xml - -BUILT_SOURCES = $(IDL_GENERATED_H) $(IDL_GENERATED_C) $(MARSHAL_GENERATED) $(SHELL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/mail-remote/client.c b/plugins/mail-remote/client.c deleted file mode 100644 index 2c633c9d1d..0000000000 --- a/plugins/mail-remote/client.c +++ /dev/null @@ -1,342 +0,0 @@ - -#include <stdio.h> -#include <string.h> - -#include <libbonobo.h> - -#include "Evolution-DataServer-Mail.h" - -#include "evolution-mail-sessionlistener.h" -#include "evolution-mail-storelistener.h" -#include "evolution-mail-folderlistener.h" -#include "evolution-mail-messagestream.h" - -#include "shell/e-shell.h" - -#include <camel/camel-folder.h> - -static EvolutionMailSessionListener *listener_sess; -static EvolutionMailStoreListener *listener_store; -static EvolutionMailFolderListener *listener_folder; - -#if 0 -static char * -em_map_mail_ex(CORBA_Environment *ev, void *data) -{ - Evolution_Mail_MailException *x = CORBA_exception_value(ev); - - switch (x->id) { - case Evolution_Mail_SYSTEM_ERROR: - return g_strdup_printf(_("System error: %s"), x->desc); - case Evolution_Mail_CAMEL_ERROR: - return g_strdup_printf(_("Camel error: %s"), x->desc); - default: - return g_strdup(x->desc); - } -} -#endif - -static void e_mail_exception_dump(CORBA_Environment *ev, char *what) -{ -#if 0 - static int init = 0; - char *d; - - /* *shrug* this doesn't work */ - if (!init) { - bonobo_exception_add_handler_fn(ex_Evolution_Mail_MailException, em_map_mail_ex, NULL, NULL); - init = 1; - } - - d = bonobo_exception_get_text(ev); - - if (d) { - printf("Failed %s: %s\n", what, d); - g_free(d); - } - CORBA_exception_free(ev); -#else - const char *id = CORBA_exception_id(ev); - - switch (ev->_major) { - case CORBA_USER_EXCEPTION: - if (!strcmp(id, ex_Evolution_Mail_MailException)) { - Evolution_Mail_MailException *x = CORBA_exception_value(ev); - - switch (x->id) { - case Evolution_Mail_SYSTEM_ERROR: - printf("Failed %s: System error %s\n", what, x->desc); - break; - case Evolution_Mail_CAMEL_ERROR: - printf("Failed %s: Camel error %s\n", what, x->desc); - break; - default: - printf("Failed %s: %s\n", what, x->desc); - break; - } - break; - } - default: - printf("Failed %s: %s\n", what, id); - break; - } - - CORBA_exception_free(ev); -#endif -} - -static Evolution_Mail_Session -get_session(void) -{ - Evolution_Mail_Session sess = NULL; - CORBA_Environment ev = { 0 }; - GNOME_Evolution_Component mail; - GNOME_Evolution_Shell shell; - - shell = bonobo_activation_activate_from_id("OAFIID:GNOME_Evolution_Shell:2.4", 0, NULL, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "activating shell"); - return NULL; - } - - do { - mail = GNOME_Evolution_Shell_findComponent(shell, "mail", &ev); - if (ev._major == CORBA_USER_EXCEPTION - && !strcmp(ev._id, ex_GNOME_Evolution_Shell_NotReady)) { - CORBA_exception_free(&ev); - printf("Shell not ready yet, waiting\n"); - sleep(1); - } else if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "finding mail component"); - CORBA_Object_release(shell, NULL); - return NULL; - } else - break; - } while (1); - - printf("got mail interface\n"); - GNOME_Evolution_MailComponent_test(mail, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "testing mail interface?"); - } - - sess = Bonobo_Unknown_queryInterface(mail, "IDL:Evolution/Mail/Session:1.0", &ev); - if (sess == NULL || ev._major != CORBA_NO_EXCEPTION) { - if (ev._major != CORBA_NO_EXCEPTION) - e_mail_exception_dump(&ev, "querying for session interface"); - else - printf("can't find session interface?\n"); - CORBA_Object_release(shell, NULL); - CORBA_Object_release(mail, NULL); - return NULL; - } - - printf("got session interface: %p\n", sess); - - 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) { - e_mail_exception_dump(&ev, "adding store listener"); - return NULL; - } - - return sess; -} - -static void -list_folder(Evolution_Mail_Folder folder) -{ - CORBA_Environment ev = { 0 }; - Evolution_Mail_MessageIterator iter; - int more, total = 0; - - iter = Evolution_Mail_Folder_getMessages(folder, "", &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "getting mssages"); - return; - } - - do { - Evolution_Mail_MessageInfos *msgs; - int i; - - msgs = Evolution_Mail_MessageIterator_next(iter, 50, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "getting next messages"); - break; - } - - /* NB: set the first 50 messages in private to unseen */ - if (total == 0) { - Evolution_Mail_MessageInfoSets *changes; - int j; - - changes = Evolution_Mail_MessageInfoSets__alloc(); - changes->_length = msgs->_length; - changes->_maximum = msgs->_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; - } - Evolution_Mail_Folder_changeMessages(folder, changes, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - e_mail_exception_dump(&ev, "changing messages"); - } - - total += msgs->_length; - more = msgs->_length == 50; -#if 0 - for (i=0;i<msgs->_length;i++) { - printf("uid: %s '%s'\n", msgs->_buffer[i].uid, msgs->_buffer[i].subject); - } -#endif - CORBA_free(msgs); - } while (more); - - printf("calling dispose\n"); - Evolution_Mail_MessageIterator_dispose(iter, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - e_mail_exception_dump(&ev, "disposing messageiterator"); - - 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 = (BonoboObject *)evolution_mail_messagestream_new_buffer(msg, strlen(msg)); - - 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); - } -} - -static int domain(void *data) -{ - Evolution_Mail_Session sess; - Evolution_Mail_StoreInfos *stores; - Evolution_Mail_FolderInfos *folders; - CORBA_Environment ev = { 0 }; - int i, j, f; - - sess = get_session(); - - stores = Evolution_Mail_Session_getStores(sess, "", bonobo_object_corba_objref((BonoboObject *)listener_store), &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "getting stores"); - _exit(1); - return 0; - } - - printf("Got %d stores\n", stores->_length); - for (i=0;i<stores->_length;i++) { -#if 0 - Evolution_Mail_PropertyName namesarray[] = { - "name", "uid" - }; - Evolution_Mail_PropertyNames names = { - 2, 2, - namesarray, - FALSE, - }; - Evolution_Mail_Properties *props; -#endif - 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 - Evolution_Mail_Store_getProperties(store, &names, &props, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "getting store properties"); - return 1; - } - - for (j=0;j<props->_length;j++) { - printf(" %s = (%s)", props->_buffer[j].name, (char *)ORBit_tk_to_name(props->_buffer[j].value._type->kind)); - if (props->_buffer[j].value._type == TC_CORBA_string) { - printf(" '%s'\n", (char *)props->_buffer[j].value._value); - } else { - printf(" '%s' ", BONOBO_ARG_GET_STRING(&props->_buffer[j].value)); - printf(" <unknonw type>\n"); - } - } - - CORBA_free(props); -#endif - -#if 1 - { - char *msg = "To: notzed@novell.com\r\n" - "Subject: This is a test from auto-send\r\n" - "\r\n" - "Blah blah, test message!\r\n"; - BonoboObject *mem; - - mem = (BonoboObject *)evolution_mail_messagestream_new_buffer(msg, strlen(msg)); - - printf("attempt send mail to store\n"); - Evolution_Mail_Store_sendMessage(store, bonobo_object_corba_objref(mem), &ev); - if (ev._major != CORBA_NO_EXCEPTION) - e_mail_exception_dump(&ev, "sending message to store"); - /* If we get a system exception, do we have to dispose it ourselves?? */ - } -#endif - - folders = Evolution_Mail_Store_getFolders(store, "", bonobo_object_corba_objref((BonoboObject *)listener_folder), &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - e_mail_exception_dump(&ev, "getting folders"); - } else { - for (f = 0; f<folders->_length;f++) { - printf("folder %p full:'%s' name:'%s'\n", folders->_buffer[f].folder, folders->_buffer[f].full_name, folders->_buffer[f].name); - } - - 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); - } - } - - } - CORBA_free(folders); - } - - CORBA_free(stores); - - return 0; -} - -int main(int argc, char **argv) -{ - bonobo_init(&argc, argv); - - g_idle_add(domain, NULL); - - bonobo_main(); - - return 0; -} diff --git a/plugins/mail-remote/e-corba-utils.c b/plugins/mail-remote/e-corba-utils.c deleted file mode 100644 index 0b4aae19a4..0000000000 --- a/plugins/mail-remote/e-corba-utils.c +++ /dev/null @@ -1,288 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <errno.h> - -#include "e-corba-utils.h" - -#include "evolution-mail-store.h" -#include "evolution-mail-folder.h" -#include "evolution-mail-messagestream.h" - -#include "em-message-stream.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 <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> - -#include <libedataserver/e-msgport.h> - -static 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(Evolution_Mail_Property *prop, const char *name, const char *val) -{ - prop->value._release = CORBA_TRUE; - prop->value._type = TC_CORBA_string; - prop->value._value = CORBA_sequence_CORBA_string_allocbuf(1); - ((char **)prop->value._value)[0] = CORBA_string_dup(val); - prop->name = CORBA_string_dup(name); -} - -void -e_mail_property_set_null(Evolution_Mail_Property *prop, const char *name) -{ - prop->value._release = CORBA_TRUE; - prop->value._type = TC_null; - prop->name = CORBA_string_dup(name); -} - -void -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)); - si->store = CORBA_Object_duplicate(bonobo_object_corba_objref((BonoboObject *)store), NULL); -} - -void -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 = 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 = Evolution_Mail_UserFlags_allocbuf(mi->userFlags._maximum); - CORBA_sequence_set_release(&mi->userFlags, CORBA_TRUE); - - for (i=0;flag;flag = flag->next,i++) { - mi->userFlags._buffer[i] = CORBA_string_dup(flag->name); - g_assert(mi->userFlags._buffer[i]); - } - } - - tag = camel_message_info_user_tags(info); - mi->userTags._maximum = camel_tag_list_size((CamelTag **)&tag); - mi->userTags._length = mi->userTags._maximum; - if (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++) { - mi->userTags._buffer[i].name = CORBA_string_dup(tag->name); - mi->userTags._buffer[i].value = CORBA_string_dup(tag->value); - g_assert(mi->userTags._buffer[i].name); - g_assert(mi->userTags._buffer[i].value); - } - } -} - -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(Evolution_Mail_FolderInfo *fi, EvolutionMailFolder *emf) -{ - fi->name = CORBA_string_dup(emf->name); - fi->full_name = CORBA_string_dup(emf->full_name); - fi->folder = CORBA_Object_duplicate(bonobo_object_corba_objref((BonoboObject *)emf), NULL); -} - -CamelMimeMessage * -e_messagestream_to_message(const Evolution_Mail_MessageStream in, CORBA_Environment *ev) -{ - CamelStream *emms; - CamelMimeMessage *msg; - - emms = em_message_stream_new(in); - if (emms == NULL) { - e_mail_exception_set(ev, Evolution_Mail_FAILED, _("Unknown reason")); - return NULL; - } - - msg = camel_mime_message_new(); - if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, emms) == -1) { - e_mail_exception_set(ev, Evolution_Mail_SYSTEM_ERROR, g_strerror(errno)); - camel_object_unref(msg); - msg = NULL; - } - camel_object_unref(emms); - - return msg; -} - -Evolution_Mail_MessageStream -e_messagestream_from_message(CamelMimeMessage *msg, CORBA_Environment *ev) -{ - CamelStreamMem *mem; - EvolutionMailMessageStream *emms; - Evolution_Mail_MessageStream out; - - /* didn't say it was going to be efficient ... */ - - mem = (CamelStreamMem *)camel_stream_mem_new(); - if (camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)mem) == -1) { - e_mail_exception_set(ev, Evolution_Mail_SYSTEM_ERROR, g_strerror(errno)); - out = CORBA_OBJECT_NIL; - } else { - camel_stream_reset((CamelStream *)mem); - emms = evolution_mail_messagestream_new((CamelStream *)mem); - out = CORBA_Object_duplicate(bonobo_object_corba_objref((BonoboObject *)emms), NULL); - } - camel_object_unref(mem); - - return out; -} - -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) { - e(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; - } -} - -void e_mail_exception_set(CORBA_Environment *ev, Evolution_Mail_ErrorType id, const char *desc) -{ - Evolution_Mail_MailException *x; - - x = Evolution_Mail_MailException__alloc(); - x->id = id; - x->desc = CORBA_string_dup(desc); - CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_MailException, x); -} - -void e_mail_exception_xfer_camel(CORBA_Environment *ev, CamelException *ex) -{ - e_mail_exception_set(ev, Evolution_Mail_CAMEL_ERROR, ex && ex->desc ? ex->desc:""); - camel_exception_clear(ex); -} diff --git a/plugins/mail-remote/e-corba-utils.h b/plugins/mail-remote/e-corba-utils.h deleted file mode 100644 index 43fef0c474..0000000000 --- a/plugins/mail-remote/e-corba-utils.h +++ /dev/null @@ -1,44 +0,0 @@ - -#ifndef _E_CORBA_UTILS_H -#define _E_CORBA_UTILS_H - -#include "Evolution-DataServer-Mail.h" - -/* Debug, warning debug, error debug, global for whole plugin to make it easier to enable/disable */ -#define d(x) -#define w(x) -#define e(x) - -struct _EvolutionMailStore; -struct _EvolutionMailFolder; -struct _CamelMessageInfo; -struct _CamelStream; -struct _CamelMimeMessage; -struct _CamelException; - -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(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); - -struct _CamelMimeMessage *e_messagestream_to_message(const Evolution_Mail_MessageStream in, CORBA_Environment *ev); -Evolution_Mail_MessageStream e_messagestream_from_message(struct _CamelMimeMessage *msg, CORBA_Environment *ev); - -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); - -/* raise an exception */ -void e_mail_exception_set(CORBA_Environment *ev, Evolution_Mail_ErrorType id, const char *desc); -void e_mail_exception_xfer_camel(CORBA_Environment *ev, struct _CamelException *ex); - -#endif /* !_E_CORBA_UTILS_H */ diff --git a/plugins/mail-remote/em-message-stream.c b/plugins/mail-remote/em-message-stream.c deleted file mode 100644 index 4506cde6bb..0000000000 --- a/plugins/mail-remote/em-message-stream.c +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@novel.com> - * - * Copyright 2005 Novell, Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdio.h> -#include <errno.h> -#include <camel/camel-stream.h> -#include "em-message-stream.h" - -#include "e-corba-utils.h" - -#define EMSS_CLASS(x) ((EMMessageStreamClass *)(((CamelObject *)(x))->klass)) - -static CamelStreamClass *parent_class = NULL; - -static ssize_t -emms_read(CamelStream *stream, char *buffer, size_t n) -{ - EMMessageStream *emms = (EMMessageStream *)stream; - ssize_t len; - Evolution_Mail_Buffer *buf; - CORBA_Environment ev = { 0 }; - - /* To avoid all of the rount-trip overhead, this could always fire off - one request in advance, to pipeline the data. Using another thread. */ - - if (emms->source == CORBA_OBJECT_NIL) { - errno = EBADF; - return -1; - } - - buf = Evolution_Mail_MessageStream_next(emms->source, n, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - CORBA_exception_free(&ev); - Evolution_Mail_MessageStream_dispose(emms->source, &ev); - emms->source = CORBA_OBJECT_NIL; - stream->eos = TRUE; - errno = EBADF; - return -1; - } - - if (buf->_length == 0) - stream->eos = TRUE; - - len = buf->_length; - memcpy(buffer, buf->_buffer, buf->_length); - CORBA_free(buf); - - return len; -} - -static void -em_message_stream_init (CamelObject *object) -{ - /*EMMessageStream *emss = (EMMessageStream *)object;*/ -} - -static void -em_message_stream_finalize (CamelObject *object) -{ - EMMessageStream *emms = (EMMessageStream *)object; - - d(printf("EMMessageStream.finalise()\n")); - - if (emms->source) { - CORBA_Environment ev = { 0 }; - - Evolution_Mail_MessageStream_dispose(emms->source, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - CORBA_exception_free(&ev); - - CORBA_Object_release(emms->source, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - CORBA_exception_free(&ev); - } -} - -static void -em_message_stream_class_init (EMMessageStreamClass *klass) -{ - CamelStreamClass *stream_class = CAMEL_STREAM_CLASS (klass); - - parent_class = (CamelStreamClass *) CAMEL_STREAM_TYPE; - - stream_class->read = emms_read; -} - -CamelType -em_message_stream_get_type (void) -{ - static CamelType type = CAMEL_INVALID_TYPE; - - if (type == CAMEL_INVALID_TYPE) { - type = camel_type_register (CAMEL_STREAM_TYPE, - "EMMessageStream", - sizeof (EMMessageStream), - sizeof (EMMessageStreamClass), - (CamelObjectClassInitFunc) em_message_stream_class_init, - NULL, - (CamelObjectInitFunc) em_message_stream_init, - (CamelObjectFinalizeFunc) em_message_stream_finalize); - } - - return type; -} - -CamelStream * -em_message_stream_new(const Evolution_Mail_MessageStream source) -{ - EMMessageStream *ems = (EMMessageStream *)camel_object_new(em_message_stream_get_type()); - CORBA_Environment ev = { 0 }; - - ems->source = CORBA_Object_duplicate(source, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - CORBA_exception_free(&ev); - camel_object_unref(ems); - ems = NULL; - } - - return (CamelStream *)ems; -} diff --git a/plugins/mail-remote/em-message-stream.h b/plugins/mail-remote/em-message-stream.h deleted file mode 100644 index da3f2367ba..0000000000 --- a/plugins/mail-remote/em-message-stream.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2003 Ximian, Inc. (www.ximian.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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef EM_MESSAGE_STREAM_H -#define EM_MESSAGE_STREAM_H - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define EM_MESSAGE_STREAM_TYPE (em_message_stream_get_type ()) -#define EM_MESSAGE_STREAM(obj) (CAMEL_CHECK_CAST((obj), EM_MESSAGE_STREAM_TYPE, EMMessageStream)) -#define EM_MESSAGE_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), EM_MESSAGE_STREAM_TYPE, EMMessageStreamClass)) -#define EM_IS_MESSAGE_STREAM(o) (CAMEL_CHECK_TYPE((o), EM_MESSAGE_STREAM_TYPE)) - -#include <camel/camel-stream.h> -#include "Evolution-DataServer-Mail.h" - -typedef struct _EMMessageStream { - CamelStream parent_stream; - - Evolution_Mail_MessageStream source; -} EMMessageStream; - -typedef struct { - CamelStreamClass parent_class; -} EMMessageStreamClass; - -CamelType em_message_stream_get_type (void); - -CamelStream *em_message_stream_new(const Evolution_Mail_MessageStream source); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* EM_MESSAGE_STREAM_H */ diff --git a/plugins/mail-remote/evolution-mail-folder.c b/plugins/mail-remote/evolution-mail-folder.c deleted file mode 100644 index 55adac81eb..0000000000 --- a/plugins/mail-remote/evolution-mail-folder.c +++ /dev/null @@ -1,417 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2005 Novell, Inc. - * - * Authors: 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <errno.h> -#include <string.h> -#include <bonobo/bonobo-shlib-factory.h> -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-arg.h> -#include "evolution-mail-folder.h" -#include "evolution-mail-store.h" -#include "evolution-mail-messageiterator.h" -#include "evolution-mail-session.h" - -#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 () - -static BonoboObjectClass *parent_class = NULL; - -#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, evolution_mail_folder_get_type())) - -struct _EvolutionMailFolderPrivate { - CamelFolder *folder; - - guint32 folder_changed; - - EDList listeners; -}; - -/* GObject methods */ - -static void -impl_dispose (GObject *object) -{ - struct _EvolutionMailFolderPrivate *p = _PRIVATE(object); - - if (p->folder) { - camel_object_remove_event(p->folder, p->folder_changed); - camel_object_unref(p->folder); - p->folder = NULL; - } - - e_mail_listener_free(&p->listeners); - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EvolutionMailFolder *emf = (EvolutionMailFolder *)object; - struct _EvolutionMailFolderPrivate *p = _PRIVATE(object); - - p = p; - - g_warning("EvolutionMailFolder is finalised!\n"); - - g_free(emf->full_name); - g_free(emf->name); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Evolution.Mail.Folder */ - -static CORBA_boolean -impl_getProperties(PortableServer_Servant _servant, - const Evolution_Mail_PropertyNames* names, - Evolution_Mail_Properties **propsp, - CORBA_Environment * ev) -{ - EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant); - int i; - Evolution_Mail_Properties *props; - CORBA_boolean ok = CORBA_TRUE; - - *propsp = props = Evolution_Mail_Properties__alloc(); - props->_length = names->_length; - props->_maximum = props->_length; - 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]; - Evolution_Mail_Property *prop = &props->_buffer[i]; - - prop->value._release = CORBA_TRUE; - - if (!strcmp(name, "name")) { - prop->value._type = TC_CORBA_string; - prop->value._value = CORBA_string_dup(emf->name); - } else if (!strcmp(name, "full_name")) { - prop->value._type = TC_CORBA_string; - prop->value._value = CORBA_string_dup(emf->full_name); - } else { - prop->value._type = TC_null; - ok = CORBA_FALSE; - } - - prop->name = CORBA_string_dup(name); - } - - return ok; -} - -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; - Evolution_Mail_MessageIterator iter; - - folder = evolution_mail_folder_get_folder(emf, ev); - if (folder == NULL) - return CORBA_OBJECT_NIL; - - emi = evolution_mail_messageiterator_new(folder, pattern); - camel_object_unref(folder); - - /* NB: How do we destroy the object once we're done? */ - - iter = CORBA_Object_duplicate(bonobo_object_corba_objref((BonoboObject *)emi), NULL); - - return iter; -} - -static void -impl_changeMessages(PortableServer_Servant _servant, const Evolution_Mail_MessageInfoSets *infos, CORBA_Environment * ev) -{ - EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant); - struct _CamelFolder *folder; - int i, j; - - folder = evolution_mail_folder_get_folder(emf, ev); - if (folder == NULL) - return; - - camel_folder_freeze(folder); - for (i=0;i<infos->_length;i++) { - CamelMessageInfo *mi; - Evolution_Mail_MessageInfoSet *mis = &infos->_buffer[i]; - - mi = camel_folder_get_message_info(folder, mis->uid); - if (mi == NULL) - continue; - - if (mis->flagMask) - camel_message_info_set_flags(mi, mis->flagMask, mis->flagSet); - - for (j=0;j<mis->userFlagSet._length;j++) - camel_message_info_set_user_flag(mi, mis->userFlagSet._buffer[j], TRUE); - for (j=0;j<mis->userFlagUnset._length;j++) - camel_message_info_set_user_flag(mi, mis->userFlagUnset._buffer[j], FALSE); - for (j=0;j<mis->userTags._length;j++) - camel_message_info_set_user_tag(mi, mis->userTags._buffer[j].name, mis->userTags._buffer[j].value[0]?mis->userTags._buffer[j].value:NULL); - - camel_message_info_free(mi); - } - camel_folder_thaw(folder); - - camel_object_unref(folder); -} - -static Evolution_Mail_MessageStream -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; - Evolution_Mail_MessageStream out; - CamelException ex = { 0 }; - - folder = evolution_mail_folder_get_folder(emf, ev); - if (folder == NULL) - return CORBA_OBJECT_NIL; - - msg = camel_folder_get_message(folder, uid, &ex); - if (msg == NULL) { - e_mail_exception_xfer_camel(ev, &ex); - out = CORBA_OBJECT_NIL; - } else { - out = e_messagestream_from_message(msg, ev); - camel_object_unref(msg); - } - camel_object_unref(folder); - - return out; -} - -static void -impl_appendMessage(PortableServer_Servant _servant, const Evolution_Mail_MessageInfoSet*mi, const Evolution_Mail_MessageStream message, CORBA_Environment *ev) -{ - EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant); - struct _CamelFolder *folder; - CamelMimeMessage *msg = NULL; - CamelMessageInfo *info; - CamelException ex = { 0 }; - CORBA_Environment wev = { 0 }; - - folder = evolution_mail_folder_get_folder(emf, ev); - if (folder == NULL) - goto fail3; - - msg = e_messagestream_to_message(message, ev); - 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)) - e_mail_exception_xfer_camel(ev, &ex); - - camel_object_unref(msg); -fail2: - camel_object_unref(folder); -fail3: - Evolution_Mail_MessageStream_dispose(message, &wev); -} - -/* Initialization */ - -static void -evolution_mail_folder_class_init (EvolutionMailFolderClass *klass) -{ - POA_Evolution_Mail_Folder__epv *epv = &klass->epv; - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (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; - - g_type_class_add_private(klass, sizeof(struct _EvolutionMailFolderPrivate)); -} - -static void -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, Evolution_Mail_Folder, PARENT_TYPE, evolution_mail_folder) - -EvolutionMailFolder * -evolution_mail_folder_new(EvolutionMailStore *ems, const char *name, const char *full_name) -{ - EvolutionMailFolder *emf = g_object_new (EVOLUTION_MAIL_TYPE_FOLDER, NULL); - - emf->name = g_strdup(name); - emf->full_name = g_strdup(full_name); - - emf->store = ems; - - return emf; -} - -static void -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 = Evolution_Mail_MessageInfos_allocbuf(uids->len); - - for (i=0;i<uids->len;i++) { - CamelMessageInfo *info = camel_folder_get_message_info(folder, uids->pdata[i]); - - if (info) { - e_mail_messageinfo_set_message(&change->messages._buffer[total], info); - camel_message_info_free(info); - total++; - } else { - w(printf("couldn't get info for changed uid '%s'?\n", (char *)uids->pdata[i])); - } - } - - change->messages._length = total; -} - -static void -emf_folder_changed(CamelObject *o, void *d, void *data) -{ - EvolutionMailFolder *emf = data; - CamelFolder *folder = (CamelFolder *)o; - CamelFolderChangeInfo *ci = d; - int count = 0; - Evolution_Mail_FolderChanges *changes; - - changes = Evolution_Mail_FolderChanges__alloc(); - changes->_maximum = 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) { - emf_set_change(&changes->_buffer[count], Evolution_Mail_ADDED, folder, ci->uid_added); - count++; - } - if (ci->uid_removed->len) { - emf_set_change(&changes->_buffer[count], Evolution_Mail_REMOVED, folder, ci->uid_removed); - count++; - } - if (ci->uid_changed->len) { - emf_set_change(&changes->_buffer[count], Evolution_Mail_CHANGED, folder, ci->uid_changed); - count++; - } - - changes->_length = count; - - evolution_mail_folder_changed(emf, changes); - CORBA_free(changes); -} - -struct _CamelFolder *evolution_mail_folder_get_folder(EvolutionMailFolder *emf, CORBA_Environment *ev) -{ - struct _EvolutionMailFolderPrivate *p = _PRIVATE(emf); - CamelStore *store; - CamelException ex; - - if (p->folder == NULL) { - store = evolution_mail_store_get_store(emf->store, ev); - if (store == NULL) - return NULL; - - camel_exception_init(&ex); - p->folder = camel_store_get_folder(store, emf->full_name, 0, &ex); - if (p->folder) { - p->folder_changed = camel_object_hook_event(p->folder, "folder_changed", emf_folder_changed, emf); - } else { - e_mail_exception_xfer_camel(ev, &ex); - } - camel_object_unref(store); - } - - if (p->folder) - camel_object_ref(p->folder); - - return p->folder; -} - -int evolution_mail_folder_close_folder(EvolutionMailFolder *emf) -{ - struct _EvolutionMailFolderPrivate *p = _PRIVATE(emf); - - /* FIXME: locking */ - if (p->folder) { - if (!e_dlist_empty(&p->listeners)) - return -1; - - camel_object_remove_event(p->folder, p->folder_changed); - camel_object_unref(p->folder); - p->folder = NULL; - } - - return 0; -} - -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)) { - d(printf("No more listeners for folder, could dispose store object now\n")); - evolution_mail_folder_close_folder(emf); - } -} diff --git a/plugins/mail-remote/evolution-mail-folder.h b/plugins/mail-remote/evolution-mail-folder.h deleted file mode 100644 index 1848d0f0d0..0000000000 --- a/plugins/mail-remote/evolution-mail-folder.h +++ /dev/null @@ -1,64 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Michael Zucchi <notzed@novell.com> - */ - -#ifndef _EVOLUTION_MAIL_FOLDER_H_ -#define _EVOLUTION_MAIL_FOLDER_H_ - -#include <bonobo/bonobo-object.h> -#include "Evolution-DataServer-Mail.h" - -#define EVOLUTION_MAIL_TYPE_FOLDER (evolution_mail_folder_get_type ()) -#define EVOLUTION_MAIL_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_MAIL_TYPE_FOLDER, EvolutionMailFolder)) -#define EVOLUTION_MAIL_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_MAIL_TYPE_FOLDER, EvolutionMailFolderClass)) -#define EVOLUTION_MAIL_IS_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_MAIL_TYPE_FOLDER)) -#define EVOLUTION_MAIL_IS_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_MAIL_TYPE_FOLDER)) - -struct _EvolutionMailStore; - -typedef struct _EvolutionMailFolder EvolutionMailFolder; -typedef struct _EvolutionMailFolderClass EvolutionMailFolderClass; - -struct _EvolutionMailFolder { - BonoboObject parent; - - struct _EvolutionMailStore *store; - - char *full_name; - char *name; -}; - -struct _EvolutionMailFolderClass { - BonoboObjectClass parent_class; - - 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, CORBA_Environment *ev); -int evolution_mail_folder_close_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 deleted file mode 100644 index e9fa86dd4f..0000000000 --- a/plugins/mail-remote/evolution-mail-folderlistener.c +++ /dev/null @@ -1,156 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, 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" -#include "e-corba-utils.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) -{ - d(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; - - d(printf("folder changed!\n")); - for (i=0;i<changes->_length;i++) { - d(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++) { - d(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 deleted file mode 100644 index 783c11a294..0000000000 --- a/plugins/mail-remote/evolution-mail-folderlistener.h +++ /dev/null @@ -1,54 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, 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-marshal.list b/plugins/mail-remote/evolution-mail-marshal.list deleted file mode 100644 index cd4885308e..0000000000 --- a/plugins/mail-remote/evolution-mail-marshal.list +++ /dev/null @@ -1 +0,0 @@ -VOID:POINTER,POINTER diff --git a/plugins/mail-remote/evolution-mail-messageiterator.c b/plugins/mail-remote/evolution-mail-messageiterator.c deleted file mode 100644 index bb254100d1..0000000000 --- a/plugins/mail-remote/evolution-mail-messageiterator.c +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2005 Novell, Inc. - * - * Authors: 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <errno.h> -#include <string.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-arg.h> -#include "evolution-mail-messageiterator.h" - -#include <camel/camel-folder.h> - -#include "e-corba-utils.h" - -#define d(x) - -#define PARENT_TYPE bonobo_object_get_type () - -static BonoboObjectClass *parent_class = NULL; - -#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, evolution_mail_messageiterator_get_type())) - -struct _EvolutionMailMessageIteratorPrivate { - int index; - CamelFolder *folder; - char *expr; - GPtrArray *search; -}; - -/* GObject methods */ - -static void -impl_dispose (GObject *object) -{ - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - struct _EvolutionMailMessageIteratorPrivate *p = _PRIVATE(object); - - d(printf("EvolutionMailMessageIterator: finalise\n")); - - if (*p->expr) - camel_folder_search_free(p->folder, p->search); - else - camel_folder_free_uids(p->folder, p->search); - - g_free(p->expr); - camel_object_unref(p->folder); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Evolution.Mail.MessageIterator */ -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; - Evolution_Mail_MessageInfos *msgs; - struct _EvolutionMailMessageIteratorPrivate *p = _PRIVATE(emf); - CamelException ex = { 0 }; - - if (p->search == NULL) { - if (*p->expr) - p->search = camel_folder_search_by_expression(p->folder, p->expr, &ex); - else - p->search = camel_folder_get_uids(p->folder); - - if (camel_exception_is_set(&ex)) { - camel_exception_clear(&ex); - return NULL; - } - - p->index = 0; - } - - msgs = Evolution_Mail_MessageInfos__alloc(); - msgs->_maximum = MIN(limit, p->search->len - p->index); - msgs->_buffer = Evolution_Mail_MessageInfos_allocbuf(msgs->_maximum); - CORBA_sequence_set_release(msgs, CORBA_TRUE); - - j=0; - for (i=p->index;i<p->search->len && j<msgs->_maximum;i++) { - CamelMessageInfo *info = camel_folder_get_message_info(p->folder, p->search->pdata[i]); - - if (info) { - e_mail_messageinfo_set_message(&msgs->_buffer[j], info); - j++; - camel_message_info_free(info); - } - } - - p->index = i; - msgs->_length = j; - - 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_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; - - g_type_class_add_private(klass, sizeof(struct _EvolutionMailMessageIteratorPrivate)); -} - -static void -evolution_mail_messageiterator_init(EvolutionMailMessageIterator *emi, EvolutionMailMessageIteratorClass *klass) -{ - bonobo_object_set_immortal((BonoboObject *)emi, TRUE); -} - -BONOBO_TYPE_FUNC_FULL (EvolutionMailMessageIterator, Evolution_Mail_MessageIterator, PARENT_TYPE, evolution_mail_messageiterator) - -EvolutionMailMessageIterator * -evolution_mail_messageiterator_new(CamelFolder *folder, const char *expr) -{ - EvolutionMailMessageIterator *emf = g_object_new(evolution_mail_messageiterator_get_type(), NULL); - struct _EvolutionMailMessageIteratorPrivate *p = _PRIVATE(emf); - - p->folder = folder; - camel_object_ref(folder); - p->expr = g_strdup(expr); - - return emf; -} diff --git a/plugins/mail-remote/evolution-mail-messageiterator.h b/plugins/mail-remote/evolution-mail-messageiterator.h deleted file mode 100644 index dc1fd6f83d..0000000000 --- a/plugins/mail-remote/evolution-mail-messageiterator.h +++ /dev/null @@ -1,47 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Michael Zucchi <notzed@novell.com> - */ - -#ifndef _EVOLUTION_MAIL_MESSAGEITERATOR_H_ -#define _EVOLUTION_MAIL_MESSAGEITERATOR_H_ - -#include <bonobo/bonobo-object.h> -#include "Evolution-DataServer-Mail.h" - -struct _CamelFolder; - -typedef struct _EvolutionMailMessageIterator EvolutionMailMessageIterator; -typedef struct _EvolutionMailMessageIteratorClass EvolutionMailMessageIteratorClass; - -struct _EvolutionMailMessageIterator { - BonoboObject parent; -}; - -struct _EvolutionMailMessageIteratorClass { - BonoboObjectClass parent_class; - - POA_Evolution_Mail_MessageIterator__epv epv; -}; - -GType evolution_mail_messageiterator_get_type(void); - -EvolutionMailMessageIterator *evolution_mail_messageiterator_new(struct _CamelFolder *folder, const char *expr); - -#endif /* _EVOLUTION_MAIL_MESSAGEITERATOR_H_ */ diff --git a/plugins/mail-remote/evolution-mail-messagestream.c b/plugins/mail-remote/evolution-mail-messagestream.c deleted file mode 100644 index 7a7ce9b192..0000000000 --- a/plugins/mail-remote/evolution-mail-messagestream.c +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2005 Novell, Inc. - * - * Authors: 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <errno.h> -#include <string.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> -#include "evolution-mail-messagestream.h" -#include <camel/camel-stream-mem.h> - -#include "e-corba-utils.h" - -#define PARENT_TYPE bonobo_object_get_type () - -static BonoboObjectClass *parent_class = NULL; - -/* GObject methods */ - -static void -impl_dispose (GObject *object) -{ - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EvolutionMailMessageStream *emms = (EvolutionMailMessageStream *)object; - - d(printf("EvolutionMailMessageStream: finalise\n")); - - if (emms->source) - camel_object_unref(emms->source); - g_free(emms->buffer); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Evolution.Mail.MessageStream */ - -static Evolution_Mail_Buffer * -impl_next(PortableServer_Servant _servant, const CORBA_long limit, CORBA_Environment * ev) -{ - EvolutionMailMessageStream *emf = (EvolutionMailMessageStream *)bonobo_object_from_servant(_servant); - Evolution_Mail_Buffer *buf; - ssize_t len; - - buf = Evolution_Mail_Buffer__alloc(); - buf->_maximum = limit; - buf->_buffer = Evolution_Mail_Buffer_allocbuf(buf->_maximum); - - if (emf->source) { - len = camel_stream_read(emf->source, buf->_buffer, buf->_maximum); - if (len == -1) { - Evolution_Mail_MailException *x; - - x = Evolution_Mail_MailException__alloc(); - x->id = Evolution_Mail_SYSTEM_ERROR; - x->desc = CORBA_string_dup(g_strerror(errno)); - CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_Evolution_Mail_MailException, x); - CORBA_free(buf); - buf = CORBA_OBJECT_NIL; - } else { - buf->_length = len; - } - } else { - len = MIN(limit, (emf->len - emf->pos)); - memcpy(buf->_buffer, emf->buffer + emf->pos, len); - emf->pos += len; - buf->_length = len; - } - - return buf; -} - -static void -impl_mi_dispose(PortableServer_Servant _servant, CORBA_Environment *ev) -{ - EvolutionMailMessageStream *emmi = (EvolutionMailMessageStream *)bonobo_object_from_servant(_servant); - - bonobo_object_set_immortal((BonoboObject *)emmi, FALSE); - bonobo_object_unref((BonoboObject *)emmi); -} - -/* Initialization */ - -static void -evolution_mail_messagestream_class_init (EvolutionMailMessageStreamClass *klass) -{ - POA_Evolution_Mail_MessageStream__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; -} - -static void -evolution_mail_messagestream_init(EvolutionMailMessageStream *emi, EvolutionMailMessageStreamClass *klass) -{ - bonobo_object_set_immortal((BonoboObject *)emi, TRUE); -} - -BONOBO_TYPE_FUNC_FULL (EvolutionMailMessageStream, Evolution_Mail_MessageStream, PARENT_TYPE, evolution_mail_messagestream) - -EvolutionMailMessageStream * -evolution_mail_messagestream_new(CamelStream *source) -{ - /* FIXME: use right poa, thread per object? */ - EvolutionMailMessageStream *emf = g_object_new(evolution_mail_messagestream_get_type(), NULL); - - emf->source = source; - camel_object_ref(source); - - return emf; -} - -EvolutionMailMessageStream * -evolution_mail_messagestream_new_buffer(const char *buffer, size_t len) -{ - /* FIXME: use right poa, thread per object? */ - EvolutionMailMessageStream *emf = g_object_new(evolution_mail_messagestream_get_type(), NULL); - - emf->buffer = g_malloc(len); - memcpy(emf->buffer, buffer, len); - emf->len = len; - emf->pos = 0; - - return emf; -} - - diff --git a/plugins/mail-remote/evolution-mail-messagestream.h b/plugins/mail-remote/evolution-mail-messagestream.h deleted file mode 100644 index 3db485e56a..0000000000 --- a/plugins/mail-remote/evolution-mail-messagestream.h +++ /dev/null @@ -1,53 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Michael Zucchi <notzed@novell.com> - */ - -#ifndef _EVOLUTION_MAIL_MESSAGESTREAM_H_ -#define _EVOLUTION_MAIL_MESSAGESTREAM_H_ - -#include <bonobo/bonobo-object.h> -#include "Evolution-DataServer-Mail.h" - -typedef struct _EvolutionMailMessageStream EvolutionMailMessageStream; -typedef struct _EvolutionMailMessageStreamClass EvolutionMailMessageStreamClass; - -struct _EvolutionMailMessageStream { - BonoboObject parent; - - /* only one or the other is set */ - struct _CamelStream *source; - - char *buffer; - size_t len; - size_t pos; -}; - -struct _EvolutionMailMessageStreamClass { - BonoboObjectClass parent_class; - - POA_Evolution_Mail_MessageStream__epv epv; -}; - -GType evolution_mail_messagestream_get_type(void); - -EvolutionMailMessageStream *evolution_mail_messagestream_new(struct _CamelStream *source); -EvolutionMailMessageStream *evolution_mail_messagestream_new_buffer(const char *buffer, size_t len); - -#endif /* _EVOLUTION_MAIL_MESSAGESTREAM_H_ */ diff --git a/plugins/mail-remote/evolution-mail-session.c b/plugins/mail-remote/evolution-mail-session.c deleted file mode 100644 index cf9ad7b8f2..0000000000 --- a/plugins/mail-remote/evolution-mail-session.c +++ /dev/null @@ -1,354 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, 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-session.h" - -#include <libedataserver/e-account-list.h> - -#include "evolution-mail-store.h" -#include "e-corba-utils.h" - -#include <camel/camel-session.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_session_get_type())) - -struct _EvolutionMailSessionPrivate { - EAccountList *accounts; - GList *stores; - - /* FIXME: locking */ - EDList listeners; - - guint account_added; - guint account_changed; - guint account_removed; -}; - -static int -is_storage(EAccount *ea) -{ - const char *uri; - int ok = FALSE; - - uri = e_account_get_string(ea, E_ACCOUNT_SOURCE_URL); - if (uri && uri[0]) { - CamelProvider *prov; - CamelException ex = { 0 }; - - prov = camel_provider_get(uri, &ex); - camel_exception_clear(&ex); - ok = prov && (prov->flags & CAMEL_PROVIDER_IS_STORAGE); - } - - return ok; -} - -/* GObject methods */ - -static void -impl_dispose (GObject *object) -{ - struct _EvolutionMailSessionPrivate *p = _PRIVATE(object); - - if (p->stores) { - /* FIXME: free stores */ - } - - /* FIXME: Free accounts */ - - /* FIXME: free listners */ - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - g_warning("EvolutionMailStore is finalised!\n"); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Evolution.Mail.Session */ - -static CORBA_boolean -impl_getProperties(PortableServer_Servant _servant, - const Evolution_Mail_PropertyNames* names, - Evolution_Mail_Properties **props, - CORBA_Environment * ev) -{ - EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant); - - ems = ems; - - return CORBA_TRUE; -} - -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); - Evolution_Mail_StoreInfos *seq; - int i, len; - GList *l; - - seq = Evolution_Mail_StoreInfos__alloc(); - - /* FIXME: pattern? */ - - len = g_list_length(p->stores); - - seq->_length = len; - seq->_maximum = len; - 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); - } - - return seq; -} - -static void -impl_addListener(PortableServer_Servant _servant, - const Evolution_Mail_SessionListener listener, - CORBA_Environment * ev) -{ - EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant); - struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); - - e_mail_listener_add(&p->listeners, listener); -} - -static void -impl_removeListener(PortableServer_Servant _servant, - const Evolution_Mail_SessionListener listener, - CORBA_Environment * ev) -{ - EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant); - struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); - - d(printf("Removing listener from session\n")); - - if (!e_mail_listener_remove(&p->listeners, listener)) { - d(printf("no more listeners, could shut down session?\n")); - } -} - -/* Initialization */ - -static void -evolution_mail_session_class_init (EvolutionMailSessionClass *klass) -{ - POA_Evolution_Mail_Session__epv *epv = &klass->epv; - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - epv->getProperties = impl_getProperties; - epv->getStores = impl_getStores; - - epv->addListener = impl_addListener; - epv->removeListener = impl_removeListener; - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - g_type_class_add_private(klass, sizeof(struct _EvolutionMailSessionPrivate)); -} - -static void -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 = 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, Evolution_Mail_ChangeType how, EvolutionMailStore *store) -{ - Evolution_Mail_SessionChanges *changes; - - /* NB: we only ever create 1 changetype at the moment */ - - changes = Evolution_Mail_SessionChanges__alloc(); - changes->_maximum = 1; - changes->_length = 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_changed(ems, changes); - - CORBA_free(changes); -} - -static void -ems_account_added(EAccountList *eal, EAccount *ea, EvolutionMailSession *ems) -{ - struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); - - if (ea->enabled && is_storage(ea)) { - EvolutionMailStore *store; - - d(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, Evolution_Mail_ADDED, store); - } -} - -static void -ems_account_changed(EAccountList *eal, EAccount *ea, EvolutionMailSession *ems) -{ - struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); - EvolutionMailStore *store = NULL; - GList *l; - - for (l = p->stores;l;l=l->next) { - if (((EvolutionMailStore *)l->data)->account == ea) { - store = l->data; - break; - } - } - - if (store) { - /* account has been disabled? */ - if (!ea->enabled) { - d(printf("Account changed, now disabled %s\n", ea->uid)); - p->stores = g_list_remove(p->stores, store); - ems_listener_session_event(ems, Evolution_Mail_REMOVED, store); - g_object_unref(store); - } else { - d(printf("Account changed, dont know how %s\n", ea->uid)); - ems_listener_session_event(ems, Evolution_Mail_CHANGED, store); - } - } else if (ea->enabled && is_storage(ea)) { - d(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, Evolution_Mail_ADDED, store); - } -} - -static void -ems_account_removed(EAccountList *eal, EAccount *ea, EvolutionMailSession *ems) -{ - struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); - GList *l; - - /* for accounts we dont have, we dont care */ - - for (l = p->stores;l;l=l->next) { - EvolutionMailStore *store = l->data; - - if (store->account == ea) { - d(printf("Account removed %s\n", ea->uid)); - p->stores = g_list_remove(p->stores, store); - ems_listener_session_event(ems, Evolution_Mail_REMOVED, store); - g_object_unref(store); - break; - } - } -} - -static void -evolution_mail_session_init (EvolutionMailSession *ems, EvolutionMailSessionClass *klass) -{ - GConfClient *gconf = gconf_client_get_default(); - struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); - EIterator *iter; - - d(printf("EvolutionMailSession.init\n")); - - e_dlist_init(&p->listeners); - - /* local store first */ - p->stores = g_list_append(p->stores, evolution_mail_store_new(ems, NULL)); - - p->accounts = e_account_list_new(gconf); - iter = e_list_get_iterator((EList *)p->accounts); - while (e_iterator_is_valid (iter)) { - EAccount *ea; - - if ((ea = (EAccount *)e_iterator_get(iter)) - && ea->enabled - && is_storage(ea)) { - p->stores = g_list_append(p->stores, evolution_mail_store_new(ems, ea)); - } - - e_iterator_next(iter); - } - g_object_unref(iter); - - g_object_unref(gconf); - - p->account_added = g_signal_connect(p->accounts, "account_added", G_CALLBACK(ems_account_added), ems); - p->account_changed = g_signal_connect(p->accounts, "account_changed", G_CALLBACK(ems_account_changed), ems); - p->account_removed = g_signal_connect(p->accounts, "account_removed", G_CALLBACK(ems_account_removed), ems); - - ems->session = mail_component_peek_session(NULL); - - bonobo_object_set_immortal((BonoboObject *)ems, TRUE); -} - -void -evolution_mail_session_changed(EvolutionMailSession *ems, Evolution_Mail_SessionChanges *changes) -{ - struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); - - if (!e_mail_listener_emit(&p->listeners, (EMailListenerChanged)Evolution_Mail_SessionListener_changed, - bonobo_object_corba_objref((BonoboObject *)ems), changes)) { - w(printf("No more listeners for store, could dispose session object now?\n")); - } -} - -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 deleted file mode 100644 index d2e31fe4fd..0000000000 --- a/plugins/mail-remote/evolution-mail-session.h +++ /dev/null @@ -1,54 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef _EVOLUTION_MAIL_SESSION_H_ -#define _EVOLUTION_MAIL_SESSION_H_ - -#include <bonobo/bonobo-object.h> -#include "Evolution-DataServer-Mail.h" - -#define EVOLUTION_MAIL_TYPE_SESSION (evolution_mail_session_get_type ()) -#define EVOLUTION_MAIL_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_MAIL_TYPE_SESSION, EvolutionMailSession)) -#define EVOLUTION_MAIL_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_MAIL_TYPE_SESSION, EvolutionMailSessionClass)) -#define EVOLUTION_MAIL_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_MAIL_TYPE_SESSION)) -#define EVOLUTION_MAIL_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_MAIL_TYPE_SESSION)) - -typedef struct _EvolutionMailSession EvolutionMailSession; -typedef struct _EvolutionMailSessionClass EvolutionMailSessionClass; - -struct _EvolutionMailSession { - BonoboObject parent; - - struct _CamelSession *session; -}; - -struct _EvolutionMailSessionClass { - BonoboObjectClass parent_class; - - POA_Evolution_Mail_Session__epv epv; -}; - -GType evolution_mail_session_get_type(void); - -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 deleted file mode 100644 index 3c84092bf0..0000000000 --- a/plugins/mail-remote/evolution-mail-sessionlistener.c +++ /dev/null @@ -1,180 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, 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" -#include "e-corba-utils.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) -{ - d(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; - - d(printf("session changed!\n")); - for (i=0;i<changes->_length;i++) { - d(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++) { - d(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); - - d(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, - g_cclosure_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 deleted file mode 100644 index 0f460e47a2..0000000000 --- a/plugins/mail-remote/evolution-mail-sessionlistener.h +++ /dev/null @@ -1,54 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, 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 deleted file mode 100644 index 2286441128..0000000000 --- a/plugins/mail-remote/evolution-mail-store.c +++ /dev/null @@ -1,665 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2005 Novell, Inc. - * - * Authors: 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <errno.h> -#include <string.h> -#include <bonobo/bonobo-shlib-factory.h> -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-arg.h> -#include <bonobo/bonobo-main.h> - -#include "evolution-mail-session.h" -#include "evolution-mail-store.h" -#include "evolution-mail-folder.h" - -#include "e-corba-utils.h" - -#include <camel/camel-store.h> -#include <camel/camel-session.h> -#include <camel/camel-stream-mem.h> -#include <camel/camel-mime-message.h> -#include <camel/camel-folder.h> - -#include <libedataserver/e-account.h> - -#include "mail/mail-component.h" -#include "mail/mail-send-recv.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_store_get_type())) - -struct _EvolutionMailStorePrivate { - CamelStore *store; - - GHashTable *folders; - /* sorted array of folders by full_name */ - GPtrArray *folders_array; - - guint32 folder_opened; - guint32 folder_created; - guint32 folder_deleted; - guint32 folder_renamed; - guint32 folder_subscribed; - guint32 folder_unsubscribed; - - EDList listeners; -}; - -/* GObject methods */ - -static void -impl_dispose (GObject *object) -{ - EvolutionMailStore *ems = (EvolutionMailStore *)object; - struct _EvolutionMailStorePrivate *p = _PRIVATE(object); - - /* FIXME: unref store - unhook events */ - - if (ems->account) { - g_object_unref(ems->account); - ems->account = NULL; - } - - e_mail_listener_free(&p->listeners); - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - struct _EvolutionMailStorePrivate *p = _PRIVATE(object); - - g_warning("EvolutionMailStore is finalised!\n"); - - if (p->folders) { - /* FIXME: bonobo unref? */ - g_hash_table_foreach(p->folders, (GHFunc)g_object_unref, NULL); - g_hash_table_destroy(p->folders); - g_ptr_array_free(p->folders_array, TRUE); - } - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Evolution.Mail.Store */ - -static CORBA_boolean -impl_getProperties(PortableServer_Servant _servant, - const Evolution_Mail_PropertyNames* names, - Evolution_Mail_Properties **propsp, - CORBA_Environment * ev) -{ - EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); - int i; - Evolution_Mail_Properties *props; - /*struct _EvolutionMailStorePrivate *p = _PRIVATE(ems);*/ - CORBA_boolean ok = CORBA_TRUE; - - *propsp = props = Evolution_Mail_Properties__alloc(); - props->_length = names->_length; - props->_maximum = props->_length; - 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]; - Evolution_Mail_Property *prop = &props->_buffer[i]; - - d(printf("getting property '%s'\n", name)); - - if (!strcmp(name, "name")) { - e_mail_property_set_string(prop, name, evolution_mail_store_get_name(ems)); - } else if (!strcmp(name, "uid")) { - e_mail_property_set_string(prop, name, evolution_mail_store_get_uid(ems)); - } else { - e_mail_property_set_null(prop, name); - ok = CORBA_FALSE; - } - } - - return ok; -} - -static void -ems_add_folders(EvolutionMailStore *ems, CamelFolderInfo *fi, GPtrArray *added) -{ - struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); - - while (fi) { - if (g_hash_table_lookup(p->folders, fi->full_name) == NULL) { - EvolutionMailFolder *emf = evolution_mail_folder_new(ems, fi->name, fi->full_name); - - g_hash_table_insert(p->folders, emf->full_name, emf); - g_ptr_array_add(p->folders_array, emf); - if (added) { - g_object_ref(emf); - g_ptr_array_add(added, emf); - } - } - - if (fi->child) - ems_add_folders(ems, fi->child, added); - - fi = fi->next; - } -} - -static void -ems_remove_folders(EvolutionMailStore *ems, CamelFolderInfo *fi, GPtrArray *removed) -{ - struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); - EvolutionMailFolder *emf; - - while (fi) { - emf = g_hash_table_lookup(p->folders, fi->full_name); - if (emf) { - g_hash_table_remove(p->folders, fi->full_name); - g_ptr_array_remove(p->folders_array, emf); - if (removed) - g_ptr_array_add(removed, emf); - else - g_object_unref(emf); - } else { - g_warning("Folder removed I didn't know existed '%s'\n", fi->full_name); - } - - if (fi->child) - ems_remove_folders(ems, fi->child, removed); - - fi = fi->next; - } -} - -static int -ems_sort_folders_cmp(const void *ap, const void *bp) -{ - const EvolutionMailFolder *a = ((const EvolutionMailFolder **)ap)[0]; - const EvolutionMailFolder *b = ((const EvolutionMailFolder **)bp)[0]; - - return strcmp(a->full_name, b->full_name); -} - -static void -ems_sort_folders(struct _EvolutionMailStorePrivate *p) -{ - qsort(p->folders_array->pdata, p->folders_array->len, sizeof(p->folders_array->pdata[0]), ems_sort_folders_cmp); -} - -static void -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 = 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 Evolution_Mail_StoreChanges * -ems_create_changes(EvolutionMailStore *ems, Evolution_Mail_ChangeType how, GPtrArray *changed) -{ - Evolution_Mail_StoreChanges *changes; - - /* NB: we only ever create 1 changetype at the moment */ - - changes = Evolution_Mail_StoreChanges__alloc(); - changes->_maximum = 1; - changes->_length = 1; - changes->_buffer = Evolution_Mail_StoreChanges_allocbuf(1); - CORBA_sequence_set_release(changes, TRUE); - - ems_set_changes(&changes->_buffer[0], how, changed); - - return changes; -} - -static void -ems_folder_opened(CamelObject *o, void *d, void *data) -{ - EvolutionMailStore *ems = data; - CamelFolder *folder = d; - - ems = ems; - folder = folder; - /* noop */ -} - -static void -ems_folder_subscribed(CamelObject *o, void *d, void *data) -{ - EvolutionMailStore *ems = data; - CamelFolderInfo *fi = d; - GPtrArray *added; - int i; - - added = g_ptr_array_new(); - ems_add_folders(ems, fi, added); - - if (added) { - if (added->len) { - Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, Evolution_Mail_ADDED, added); - - evolution_mail_store_changed(ems, changes); - CORBA_free(changes); - - for (i=0;i<added->len;i++) - g_object_unref(added->pdata[i]); - } - g_ptr_array_free(added, TRUE); - } -} - -static void -ems_folder_unsubscribed(CamelObject *o, void *d, void *data) -{ - EvolutionMailStore *ems = data; - CamelFolderInfo *fi = d; - GPtrArray *removed = NULL; - int i; - - removed = g_ptr_array_new(); - ems_remove_folders(ems, fi, removed); - - if (removed) { - if (removed->len) { - Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, Evolution_Mail_REMOVED, removed); - - evolution_mail_store_changed(ems, changes); - CORBA_free(changes); - - for (i=0;i<removed->len;i++) - g_object_unref(removed->pdata[i]); - } - g_ptr_array_free(removed, TRUE); - } -} - -static void -ems_folder_created(CamelObject *o, void *d, void *data) -{ - CamelStore *store = (CamelStore *)o; - - if (!camel_store_supports_subscriptions(store)) - ems_folder_subscribed(o, d, data); -} - -static void -ems_folder_deleted(CamelObject *o, void *d, void *data) -{ - CamelStore *store = (CamelStore *)o; - - if (!camel_store_supports_subscriptions(store)) - ems_folder_unsubscribed(o, d, data); -} - -static void -get_folders(CamelFolderInfo *fi, GPtrArray *folders) -{ - while (fi) { - g_ptr_array_add(folders, fi); - - if (fi->child) - get_folders(fi->child, folders); - - fi = fi->next; - } -} - -static int -folder_cmp(const void *ap, const void *bp) -{ - const CamelFolderInfo *a = ((CamelFolderInfo **)ap)[0]; - const CamelFolderInfo *b = ((CamelFolderInfo **)bp)[0]; - - return strcmp(a->full_name, b->full_name); -} - -static void -ems_folder_renamed(CamelObject *o, void *d, void *data) -{ - EvolutionMailStore *ems = data; - struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); - CamelRenameInfo *reninfo = d; - int i, oldlen, newlen; - GPtrArray *renamed = g_ptr_array_new(), *folders = g_ptr_array_new(); - CamelFolderInfo *top; - GString *name = g_string_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); - top = folders->pdata[0]; - - oldlen = strlen(reninfo->old_base); - newlen = strlen(top->full_name); - - for (i=0;i<folders->len;i++) { - CamelFolderInfo *fi = folders->pdata[i]; - EvolutionMailFolder *emf; - - if (strlen(fi->full_name) >= newlen) { - g_string_printf(name, "%s%s", reninfo->old_base, fi->full_name + newlen); - if ((emf = g_hash_table_lookup(p->folders, name->str))) { - /* FIXME: locking / or api to rename */ - g_hash_table_remove(p->folders, emf->full_name); - g_free(emf->full_name); - g_free(emf->name); - emf->full_name = g_strdup(fi->full_name); - emf->name = g_strdup(fi->name); - g_hash_table_insert(p->folders, emf->full_name, emf); - - g_object_ref(emf); - g_ptr_array_add(renamed, emf); - } - } - } - - g_string_free(name, TRUE); - g_ptr_array_free(folders, TRUE); - - if (renamed) { - if (renamed->len) { - Evolution_Mail_StoreChanges *changes = ems_create_changes(ems, Evolution_Mail_CHANGED, renamed); - - evolution_mail_store_changed(ems, changes); - CORBA_free(changes); - - for (i=0;i<renamed->len;i++) - g_object_unref(renamed->pdata[i]); - } - g_ptr_array_free(renamed, TRUE); - } -} - -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 }; - Evolution_Mail_FolderInfos *folders = NULL; - int i; - CamelStore *store; - - store = evolution_mail_store_get_store(ems, ev); - if (store == NULL) { - return CORBA_OBJECT_NIL; - } - - if (p->folders == NULL) { - fi = camel_store_get_folder_info(store, "", CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST, &ex); - - if (fi) { - p->folders = g_hash_table_new(g_str_hash, g_str_equal); - p->folders_array = g_ptr_array_new(); - ems_add_folders(ems, fi, NULL); - camel_store_free_folder_info(store, fi); - ems_sort_folders(p); - } else { - e_mail_exception_xfer_camel(ev, &ex); - camel_object_unref(store); - return CORBA_OBJECT_NIL; - } - } - - folders = Evolution_Mail_FolderInfos__alloc(); - folders->_length = p->folders_array->len; - folders->_maximum = folders->_length; - 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); - } - - camel_object_unref(store); - - return folders; -} - -static void -impl_sendMessage(PortableServer_Servant _servant, - const Evolution_Mail_MessageStream message, - CORBA_Environment * ev) -{ - EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); - CamelException ex = { 0 }; - CamelMimeMessage *msg; - CamelInternetAddress *from; - CamelMessageInfo *info; - CORBA_Environment wev = { 0 }; - - if (ems->account == NULL - || ems->account->transport == NULL - || ems->account->transport->url == NULL) { - e_mail_exception_set(ev, Evolution_Mail_NOT_SUPPORTED, _("Account cannot send e-mail")); - goto done; - } - - msg = e_messagestream_to_message(message, ev); - if (msg == NULL) - goto done; - - from = camel_internet_address_new(); - camel_internet_address_add(from, ems->account->id->name, ems->account->id->address); - camel_mime_message_set_from(msg, from); - camel_object_unref(from); - - camel_medium_set_header((CamelMedium *)msg, "X-Evolution-Account", ems->account->uid); - - if (msg->date == 0) - camel_mime_message_set_date(msg, CAMEL_MESSAGE_DATE_CURRENT, 0); - - info = camel_message_info_new(NULL); - camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0); - - camel_folder_append_message(mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX), msg, info, NULL, &ex); - camel_message_info_free(info); - - if (camel_exception_is_set(&ex)) { - e_mail_exception_xfer_camel(ev, &ex); - } else { - mail_send(); - } - - camel_object_unref(msg); -done: - Evolution_Mail_MessageStream_dispose(message, &wev); - if (wev._major != CORBA_NO_EXCEPTION) - CORBA_exception_free(&wev); -} - -/* Initialization */ - -static void -evolution_mail_store_class_init (EvolutionMailStoreClass *klass) -{ - POA_Evolution_Mail_Store__epv *epv = &klass->epv; - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - epv->getProperties = impl_getProperties; - epv->getFolders = impl_getFolders; - epv->sendMessage = impl_sendMessage; - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - g_type_class_add_private(klass, sizeof(struct _EvolutionMailStorePrivate)); -} - -static void -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, Evolution_Mail_Store, PARENT_TYPE, evolution_mail_store) - -EvolutionMailStore * -evolution_mail_store_new(struct _EvolutionMailSession *s, struct _EAccount *ea) -{ - EvolutionMailStore *ems; - struct _EvolutionMailStorePrivate *p; - static PortableServer_POA poa = NULL; - - d(printf("EvolutionMailStore.new(\"%s\")\n", ea?ea->name:"local")); - - if (poa == NULL) - poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL); - - ems = g_object_new (EVOLUTION_MAIL_TYPE_STORE, "poa", poa, NULL); - p = _PRIVATE(ems); - - if (ea) { - ems->account = ea; - g_object_ref(ea); - } - - ems->session = s; - - return ems; -} - -const char *evolution_mail_store_get_name(EvolutionMailStore *ems) -{ - if (ems->account) - return ems->account->name; - else - return ("On This Computer"); -} - -const char *evolution_mail_store_get_uid(EvolutionMailStore *ems) -{ - if (ems->account) - return ems->account->uid; - else - return "local@local"; -} - -CamelStore *evolution_mail_store_get_store(EvolutionMailStore *ems, CORBA_Environment *ev) -{ - struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); - - if (p->store == NULL) { - if (ems->account == NULL) { - p->store = mail_component_peek_local_store(NULL); - camel_object_ref(p->store); - } else { - const char *uri; - CamelException ex = { 0 }; - - uri = e_account_get_string(ems->account, E_ACCOUNT_SOURCE_URL); - if (uri && *uri) { - p->store = camel_session_get_store(ems->session->session, uri, &ex); - if (camel_exception_is_set(&ex)) { - e_mail_exception_xfer_camel(ev, &ex); - return NULL; - } - } else { - e_mail_exception_set(ev, Evolution_Mail_NOT_SUPPORTED, _("No store available")); - return NULL; - } - } - - p->folder_opened = camel_object_hook_event(p->store, "folder_opened", ems_folder_opened, ems); - p->folder_created = camel_object_hook_event(p->store, "folder_created", ems_folder_created, ems); - p->folder_deleted = camel_object_hook_event(p->store, "folder_deleted", ems_folder_deleted, ems); - p->folder_renamed = camel_object_hook_event(p->store, "folder_renamed", ems_folder_renamed, ems); - p->folder_subscribed = camel_object_hook_event(p->store, "folder_subscribed", ems_folder_subscribed, ems); - p->folder_unsubscribed = camel_object_hook_event(p->store, "folder_unsubscribed", ems_folder_unsubscribed, ems); - } - - camel_object_ref(p->store); - return p->store; -} - -int evolution_mail_store_close_store(EvolutionMailStore *ems) -{ - struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); - - /* FIXME: locking */ - if (p->store) { - if (!e_dlist_empty(&p->listeners)) - return -1; - - camel_object_remove_event(p->store, p->folder_opened); - camel_object_remove_event(p->store, p->folder_created); - camel_object_remove_event(p->store, p->folder_deleted); - camel_object_remove_event(p->store, p->folder_renamed); - camel_object_remove_event(p->store, p->folder_subscribed); - camel_object_remove_event(p->store, p->folder_unsubscribed); - camel_object_unref(p->store); - p->store = NULL; - } - - /* FIXME: need to close of sub-folders too? */ - - return 0; -} - -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)) { - evolution_mail_store_close_store(ems); - w(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 deleted file mode 100644 index 800f536fbd..0000000000 --- a/plugins/mail-remote/evolution-mail-store.h +++ /dev/null @@ -1,68 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Michael Zucchi <notzed@novell.com> - */ - -#ifndef _EVOLUTION_MAIL_STORE_H_ -#define _EVOLUTION_MAIL_STORE_H_ - -#include <bonobo/bonobo-object.h> -#include "Evolution-DataServer-Mail.h" - -#define EVOLUTION_MAIL_TYPE_STORE (evolution_mail_store_get_type ()) -#define EVOLUTION_MAIL_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_MAIL_TYPE_STORE, EvolutionMailStore)) -#define EVOLUTION_MAIL_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_MAIL_TYPE_STORE, EvolutionMailStoreClass)) -#define EVOLUTION_MAIL_IS_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_MAIL_TYPE_STORE)) -#define EVOLUTION_MAIL_IS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_MAIL_TYPE_STORE)) - -struct _EAccount; -struct _EvolutionMailSession; - -typedef struct _EvolutionMailStore EvolutionMailStore; -typedef struct _EvolutionMailStoreClass EvolutionMailStoreClass; - -struct _EvolutionMailStore { - BonoboObject parent; - - struct _EvolutionMailSession *session; - - struct _EAccount *account; -}; - -struct _EvolutionMailStoreClass { - BonoboObjectClass parent_class; - - 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 *); - -/* unref when done */ -struct _CamelStore *evolution_mail_store_get_store(EvolutionMailStore *ems, CORBA_Environment *ev); -int evolution_mail_store_close_store(EvolutionMailStore *ems); - -#endif /* _EVOLUTION_MAIL_STORE_H_ */ diff --git a/plugins/mail-remote/evolution-mail-storelistener.c b/plugins/mail-remote/evolution-mail-storelistener.c deleted file mode 100644 index ef7a83fdcf..0000000000 --- a/plugins/mail-remote/evolution-mail-storelistener.c +++ /dev/null @@ -1,156 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, 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" -#include "e-corba-utils.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) -{ - d(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; - - d(printf("store changed!\n")); - for (i=0;i<changes->_length;i++) { - d(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++) { - d(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 deleted file mode 100644 index fc2c7b8918..0000000000 --- a/plugins/mail-remote/evolution-mail-storelistener.h +++ /dev/null @@ -1,54 +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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, 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_ */ diff --git a/plugins/mail-remote/mail-remote.c b/plugins/mail-remote/mail-remote.c deleted file mode 100644 index 3c8eb7c988..0000000000 --- a/plugins/mail-remote/mail-remote.c +++ /dev/null @@ -1,59 +0,0 @@ - -#include <stdio.h> -#include <unistd.h> - -#include "evolution-mail-session.h" -#include <bonobo/bonobo-main.h> - -#include "e-corba-utils.h" - -struct _EPlugin; -struct _ESEventTargetUpgrade; - -void org_gnome_evolution_mail_remote_startup(struct _EPlugin *ep, struct _ESEventTargetUpgrade *target); -int e_plugin_lib_enable(int enable); - -void org_gnome_evolution_mail_remote_startup(struct _EPlugin *ep, struct _ESEventTargetUpgrade *target) { - /* noop */ ; -} - -int e_plugin_lib_enable(int enable) -{ - static EvolutionMailSession *sess; - char *path; - FILE *fp; - - if (enable) { - static PortableServer_POA poa = NULL; - void *component; - - if (sess != NULL) - return 0; - - component = mail_component_peek(); - if (component == NULL) { - g_warning("Unable to find mail component, cannot instantiate mail remote api"); - return -1; - } - - if (poa == NULL) - poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL); - - sess = g_object_new(evolution_mail_session_get_type(), "poa", poa, NULL); - - /* - NB: This only works if this is done early enough in the process ... - I guess it will be. But i'm not entirely sure ... - - If this wrong, then we have to add a mechanism to the mailcomponent directly - to retrieve it */ - - bonobo_object_add_interface((BonoboObject *)component, (BonoboObject *)sess); - w(printf(" ** Added mail interface to mail component\n")); - } else { - /* can't easily disable this until restart? */ - /* can we just destroy it? */ - } - - return 0; -} diff --git a/plugins/mail-remote/org-gnome-evolution-mail-remote.eplug.xml b/plugins/mail-remote/org-gnome-evolution-mail-remote.eplug.xml deleted file mode 100644 index 8435fb9619..0000000000 --- a/plugins/mail-remote/org-gnome-evolution-mail-remote.eplug.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0"?> -<e-plugin-list> - <e-plugin - type="shlib" - id="org.gnome.evolution.plugin.mailRemote" - location="@PLUGINDIR@/liborg-gnome-evolution-mail-remote@SOEXT@" - _name="Mail Remote"> - <_description>A plugin which implements a CORBA - interface for accessing mail data remotely.</_description> - <author name="Michael Zucchi" email="notzed@novell.com"/> - - <!-- hacky way to find out if the system has started up --> - <hook class="org.gnome.evolution.shell.events:1.0"> - <event target="upgrade" id="upgrade.done" handle="org_gnome_evolution_mail_remote_startup"/> - </hook> - - </e-plugin> -</e-plugin-list> |