From 3509757d148d80a78a942b1e3938bead90b5d506 Mon Sep 17 00:00:00 2001 From: Michael Zucci Date: Wed, 4 May 2005 05:37:51 +0000 Subject: Initial work on remote mail interface, as a plugin. svn path=/trunk/; revision=29265 --- plugins/mail-remote/ChangeLog | 0 plugins/mail-remote/Evolution-DataServer-Mail.idl | 77 ++++++++ plugins/mail-remote/Makefile.am | 35 ++++ plugins/mail-remote/evolution-mail-folder.c | 148 +++++++++++++++ plugins/mail-remote/evolution-mail-folder.h | 53 ++++++ plugins/mail-remote/evolution-mail-session.c | 194 ++++++++++++++++++++ plugins/mail-remote/evolution-mail-session.h | 50 +++++ plugins/mail-remote/evolution-mail-store.c | 212 ++++++++++++++++++++++ plugins/mail-remote/evolution-mail-store.h | 53 ++++++ plugins/mail-remote/mail-remote.c | 31 ++++ 10 files changed, 853 insertions(+) create mode 100644 plugins/mail-remote/ChangeLog create mode 100644 plugins/mail-remote/Evolution-DataServer-Mail.idl create mode 100644 plugins/mail-remote/Makefile.am create mode 100644 plugins/mail-remote/evolution-mail-folder.c create mode 100644 plugins/mail-remote/evolution-mail-folder.h create mode 100644 plugins/mail-remote/evolution-mail-session.c create mode 100644 plugins/mail-remote/evolution-mail-session.h create mode 100644 plugins/mail-remote/evolution-mail-store.c create mode 100644 plugins/mail-remote/evolution-mail-store.h create mode 100644 plugins/mail-remote/mail-remote.c (limited to 'plugins') diff --git a/plugins/mail-remote/ChangeLog b/plugins/mail-remote/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/mail-remote/Evolution-DataServer-Mail.idl b/plugins/mail-remote/Evolution-DataServer-Mail.idl new file mode 100644 index 0000000000..d7a1aa736c --- /dev/null +++ b/plugins/mail-remote/Evolution-DataServer-Mail.idl @@ -0,0 +1,77 @@ +/* Evolution Mail Interface + * + * Copyright (C) 2005 Novell, Inc. + * + * Authors: Michael Zucchi + */ + +#ifndef _EVOLUTION_DATASERVER_MAIL_IDL_ +#define _EVOLUTION_DATASERVER_MAIL_IDL_ + +#include + +module GNOME { +module Evolution { +module Mail { + exception NOT_SUPPORTED { + string why; + }; + + interface Folder; + typedef sequence Folders; + + interface Store; + typedef sequence Stores; + + // NB: tiny subset of omg properties service + typedef string PropertyName; + typedef sequence PropertyNames; + struct Property { + PropertyName name; + any value; + }; + typedef sequence Properties; + + interface Session : Bonobo::Unknown { + boolean getProperties(in PropertyNames names, out Properties props); + + Stores getStores(in string pattern); + }; + + interface Store : Bonobo::Unknown { + boolean getProperties(in PropertyNames names, out Properties props); + + Folders getFolders(in string pattern) + raises (NOT_SUPPORTED); + + void sendMessage(in Bonobo::Stream msg, in string from, in string recipients) + raises (NOT_SUPPORTED); + }; + + struct MessageInfo { + string uid; + string subject; + string to; + string from; + }; + + typedef sequence MessageInfos; + +// interface MessageInfoIterator : Bonobo::Unknown { +// MessageInfos next(in long limit); +// }; + + interface Folder : Bonobo::Unknown { + void getProperties(inout Properties pseq); + +// MessageInfoIterator getMessageInfo(in string pattern); + + Bonobo::Stream getMessage(in string uid); + +// void appendMessage(in MessageInfo info, in Bonobo::Stream msg); + }; +}; +}; +}; + +#endif diff --git a/plugins/mail-remote/Makefile.am b/plugins/mail-remote/Makefile.am new file mode 100644 index 0000000000..25653f666b --- /dev/null +++ b/plugins/mail-remote/Makefile.am @@ -0,0 +1,35 @@ + + +# 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 + +$(IDL_GENERATED_H) $(IDL_GENERATED_C): $(IDL) + $(ORBIT_IDL) -I $(srcdir) -I $(datadir)/idl $(IDL_INCLUDES) $^ + +# installed idls + +idl_DATA = $(IDL) + +_SOURCES = \ + $(IDL_GENERATED_C) \ + $(IDL_GENERATED_H) \ + evolution-mail-folder.c \ + evolution-mail-folder.h \ + evolution-mail-session.c \ + evolution-mail-session.h \ + evolution-mail-store.c \ + evolution-mail-store.h + +EXTRA_DIST = \ + $(IDL) + +BUILT_SOURCES = $(IDL_GENERATED_H) $(IDL_GENERATED_C) diff --git a/plugins/mail-remote/evolution-mail-folder.c b/plugins/mail-remote/evolution-mail-folder.c new file mode 100644 index 0000000000..b7bba2a5cb --- /dev/null +++ b/plugins/mail-remote/evolution-mail-folder.c @@ -0,0 +1,148 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2005 Novell, Inc. + * + * Authors: Michael Zucchi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include "evolution-mail-folder.h" + +#include + +#define FACTORY_ID "OAFIID:GNOME_Evolution_Mail_Folder_Factory:" BASE_VERSION +#define MAIL_FOLDER_ID "OAFIID:GNOME_Evolution_Mail_Folder:" BASE_VERSION + +#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 { + char *full_name; + char *name; +}; + +/* GObject methods */ + +static void +impl_dispose (GObject *object) +{ + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +static void +impl_finalize (GObject *object) +{ + struct _EvolutionMailFolderPrivate *p = _PRIVATE(object); + + g_free(p->full_name); + g_free(p->name); + + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +/* Evolution.Mail.Folder */ + +static CORBA_boolean +impl_getProperties(PortableServer_Servant _servant, + const GNOME_Evolution_Mail_PropertyNames* names, + GNOME_Evolution_Mail_Properties **propsp, + CORBA_Environment * ev) +{ + EvolutionMailFolder *emf = (EvolutionMailFolder *)bonobo_object_from_servant(_servant); + int i; + GNOME_Evolution_Mail_Properties *props; + struct _EvolutionMailFolderPrivate *p = _PRIVATE(emf); + CORBA_boolean ok = CORBA_TRUE; + + *propsp = props = GNOME_Evolution_Mail_Properties__alloc(); + props->_length = names->_length; + props->_maximum = props->_length; + props->_buffer = GNOME_Evolution_Mail_Properties_allocbuf(props->_maximum); + CORBA_sequence_set_release(props, CORBA_TRUE); + + for (i=0;i_length;i++) { + const CORBA_char *name = names->_buffer[i]; + GNOME_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(p->name); + } else if (!strcmp(name, "full_name")) { + prop->value._type = TC_CORBA_string; + prop->value._value = CORBA_string_dup(p->full_name); + } else { + prop->value._type = TC_null; + ok = CORBA_FALSE; + } + + prop->name = CORBA_string_dup(name); + } + + return ok; +} + +/* Initialization */ + +static void +evolution_mail_folder_class_init (EvolutionMailFolderClass *klass) +{ + POA_GNOME_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; + + 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 *component, EvolutionMailFolderClass *klass) +{ +} + +BONOBO_TYPE_FUNC_FULL (EvolutionMailFolder, GNOME_Evolution_Mail_Folder, PARENT_TYPE, evolution_mail_folder) + +EvolutionMailFolder * +evolution_mail_folder_new(const char *name, const char *full_name) +{ + EvolutionMailFolder *emf = g_object_new (EVOLUTION_MAIL_TYPE_FOLDER, NULL); + struct _EvolutionMailFolderPrivate *p = _PRIVATE(emf); + + p->name = g_strdup(name); + p->full_name = g_strdup(full_name); + + return emf; +} diff --git a/plugins/mail-remote/evolution-mail-folder.h b/plugins/mail-remote/evolution-mail-folder.h new file mode 100644 index 0000000000..02bc0aa26a --- /dev/null +++ b/plugins/mail-remote/evolution-mail-folder.h @@ -0,0 +1,53 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2005 Novell, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: JP Rosevear + */ + +#ifndef _EVOLUTION_MAIL_FOLDER_H_ +#define _EVOLUTION_MAIL_FOLDER_H_ + +#include +#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 _EAccount; + +typedef struct _EvolutionMailFolder EvolutionMailFolder; +typedef struct _EvolutionMailFolderClass EvolutionMailFolderClass; + +struct _EvolutionMailFolder { + BonoboObject parent; +}; + +struct _EvolutionMailFolderClass { + BonoboObjectClass parent_class; + + POA_GNOME_Evolution_Mail_Folder__epv epv; +}; + +GType evolution_mail_folder_get_type(void); + +EvolutionMailFolder *evolution_mail_folder_new(const char *name, const char *full_name); + +#endif /* _EVOLUTION_MAIL_FOLDER_H_ */ diff --git a/plugins/mail-remote/evolution-mail-session.c b/plugins/mail-remote/evolution-mail-session.c new file mode 100644 index 0000000000..5907f7f2fb --- /dev/null +++ b/plugins/mail-remote/evolution-mail-session.c @@ -0,0 +1,194 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2005 Novell, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: JP Rosevear + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include "evolution-mail-session.h" + +#include + +#include "evolution-mail-store.h" + +#define FACTORY_ID "OAFIID:GNOME_Evolution_Mail_Session_Factory:" BASE_VERSION +#define MAIL_SESSION_ID "OAFIID:GNOME_Evolution_Mail_Session:" BASE_VERSION + +#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; +}; + +/* GObject methods */ + +static void +impl_dispose (GObject *object) +{ + struct _EvolutionMailSessionPrivate *p = _PRIVATE(object); + + if (p->stores) { + /* FIXME: free stores */ + } + + /* FIXME: Free accounts */ + + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +static void +impl_finalize (GObject *object) +{ + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +/* Evolution.Mail.Session */ + +static CORBA_boolean +impl_getProperties(PortableServer_Servant _servant, + const GNOME_Evolution_Mail_PropertyNames* names, + GNOME_Evolution_Mail_Properties **props, + CORBA_Environment * ev) +{ + EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant); + + ems = ems; + + return CORBA_TRUE; +} + +static GNOME_Evolution_Mail_Stores * +impl_getStores(PortableServer_Servant _servant, + const CORBA_char * pattern, + CORBA_Environment * ev) +{ + EvolutionMailSession *ems = (EvolutionMailSession *)bonobo_object_from_servant(_servant); + struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); + GNOME_Evolution_Mail_Stores *seq; + int i, len; + GList *l; + + seq = GNOME_Evolution_Mail_Stores__alloc(); + + /* FIXME: pattern? */ + + len = g_list_length(p->stores); + + seq->_length = len; + seq->_maximum = len; + seq->_buffer = GNOME_Evolution_Mail_Stores_allocbuf(seq->_length); + + CORBA_sequence_set_release(seq, TRUE); + + l = p->stores; + for (i=0;l && i_buffer[i] = bonobo_object_corba_objref(l->data); + bonobo_object_ref(l->data); /* ?? */ + l = g_list_next(l); + } + + return seq; +} + +/* Initialization */ + +static void +evolution_mail_session_class_init (EvolutionMailSessionClass *klass) +{ + POA_GNOME_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; + + object_class->dispose = impl_dispose; + object_class->finalize = impl_finalize; + + g_type_class_add_private(klass, sizeof(struct _EvolutionMailSessionPrivate)); +} + +static void +evolution_mail_session_init (EvolutionMailSession *ems, EvolutionMailSessionClass *klass) +{ + GConfClient *gconf = gconf_client_get_default(); + struct _EvolutionMailSessionPrivate *p = _PRIVATE(ems); + EIterator *iter; + EvolutionMailStore *store; + + /* FIXME: listen to changes */ + + /* local store first */ + p->stores = g_list_append(p->stores, evolution_mail_store_new(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)) + && (store = evolution_mail_store_new((struct _EAccount *)ea))) { + p->stores = g_list_append(p->stores, store); + } + + e_iterator_next(iter); + } + g_object_unref(iter); + + g_object_unref(gconf); +} + +BONOBO_TYPE_FUNC_FULL (EvolutionMailSession, GNOME_Evolution_Mail_Session, PARENT_TYPE, evolution_mail_session) + +#if 0 +static BonoboObject * +factory (BonoboGenericFactory *factory, const char *component_id, void *closure) +{ + if (strcmp(component_id, MAIL_SESSION_ID) == 0) { + static BonoboObject *object; + + /* Enfoce singleton instance */ + if (object == NULL) + object = BONOBO_OBJECT (g_object_new (EVOLUTION_MAIL_TYPE_SESSION, NULL)); + + bonobo_object_ref (object); + return object; + } + + g_warning (FACTORY_ID ": Don't know what to do with %s", component_id); + + return NULL; +} + +BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Mail Session factory", factory, NULL) +#endif diff --git a/plugins/mail-remote/evolution-mail-session.h b/plugins/mail-remote/evolution-mail-session.h new file mode 100644 index 0000000000..2564ae113d --- /dev/null +++ b/plugins/mail-remote/evolution-mail-session.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2005 Novell, Inc. + * + * Author: Michael Zucchi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _EVOLUTION_MAIL_SESSION_H_ +#define _EVOLUTION_MAIL_SESSION_H_ + +#include +#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 _EvolutionMailSessionClass { + BonoboObjectClass parent_class; + + POA_GNOME_Evolution_Mail_Session__epv epv; +}; + +GType evolution_mail_session_get_type(void); + +#endif /* _EVOLUTION_MAIL_SESSION_H_ */ diff --git a/plugins/mail-remote/evolution-mail-store.c b/plugins/mail-remote/evolution-mail-store.c new file mode 100644 index 0000000000..2d2157ac0a --- /dev/null +++ b/plugins/mail-remote/evolution-mail-store.c @@ -0,0 +1,212 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2005 Novell, Inc. + * + * Authors: Michael Zucchi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include "evolution-mail-store.h" + +#include + +#define FACTORY_ID "OAFIID:GNOME_Evolution_Mail_Store_Factory:" BASE_VERSION +#define MAIL_STORE_ID "OAFIID:GNOME_Evolution_Mail_Store:" BASE_VERSION + +#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 { + struct _EAccount *account; +}; + +/* GObject methods */ + +static void +impl_dispose (GObject *object) +{ + struct _EvolutionMailStorePrivate *p = _PRIVATE(object); + + if (p->account) { + g_object_unref(p->account); + p->account = NULL; + } + + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +static void +impl_finalize (GObject *object) +{ + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +/* Evolution.Mail.Store */ + +static CORBA_boolean +impl_getProperties(PortableServer_Servant _servant, + const GNOME_Evolution_Mail_PropertyNames* names, + GNOME_Evolution_Mail_Properties **propsp, + CORBA_Environment * ev) +{ + EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); + int i; + GNOME_Evolution_Mail_Properties *props; + struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); + CORBA_boolean ok = CORBA_TRUE; + + *propsp = props = GNOME_Evolution_Mail_Properties__alloc(); + props->_length = names->_length; + props->_maximum = props->_length; + props->_buffer = GNOME_Evolution_Mail_Properties_allocbuf(props->_maximum); + CORBA_sequence_set_release(props, CORBA_TRUE); + + for (i=0;i_length;i++) { + const CORBA_char *name = names->_buffer[i]; + GNOME_Evolution_Mail_Property *prop = &props->_buffer[i]; + + prop->value._release = CORBA_TRUE; + + if (!strcmp(name, "name")) { + prop->value._type = TC_CORBA_string; + if (p->account) + prop->value._value = CORBA_string_dup(p->account->name); + else + /* FIXME: name & i18n */ + prop->value._value = CORBA_string_dup("Local"); + } else if (!strcmp(name, "uid")) { + prop->value._type = TC_CORBA_string; + if (p->account) + prop->value._value = CORBA_string_dup(p->account->uid); + else + prop->value._value = CORBA_string_dup("local@local"); + } else { + prop->value._type = TC_null; + ok = CORBA_FALSE; + } + + prop->name = CORBA_string_dup(name); + } + + return ok; +} + +static GNOME_Evolution_Mail_Folders * +impl_getFolders(PortableServer_Servant _servant, + const CORBA_char * pattern, + CORBA_Environment * ev) +{ + EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); +#if 0 + GNOME_Evolution_Mail_NOT_SUPPORTED *ex; + + ex = GNOME_Evolution_Mail_NOT_SUPPORTED__alloc(); + ex->why = CORBA_string_dup("Unimplemented"); + + ev->_id = ex_GNOME_Evolution_Mail_NOT_SUPPORTED; + ev->_major = CORBA_USER_EXCEPTION; + ev->_any = ex; +#endif + return NULL; +} + +static void +impl_sendMessage(PortableServer_Servant _servant, + const Bonobo_Stream msg, const CORBA_char * from, + const CORBA_char * recipients, + CORBA_Environment * ev) +{ + EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); + + printf("Sending message from '%s' to '%s'\n", from, recipients); + + ems = ems; +} + +/* Initialization */ + +static void +evolution_mail_store_class_init (EvolutionMailStoreClass *klass) +{ + POA_GNOME_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 *component, EvolutionMailStoreClass *klass) +{ +} + +BONOBO_TYPE_FUNC_FULL (EvolutionMailStore, GNOME_Evolution_Mail_Store, PARENT_TYPE, evolution_mail_store) + +EvolutionMailStore * +evolution_mail_store_new(struct _EAccount *ea) +{ + EvolutionMailStore *ems = g_object_new (EVOLUTION_MAIL_TYPE_STORE, NULL); + struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); + + if (ea) { + p->account = ea; + g_object_ref(ea); + } + + return ems; +} + +#if 0 +static BonoboObject * +factory (BonoboGenericFactory *factory, + const char *component_id, + void *closure) +{ + if (strcmp (component_id, MAIL_STORE_ID) == 0) { + BonoboObject *object = BONOBO_OBJECT (g_object_new (EVOLUTION_MAIL_TYPE_STORE, NULL)); + bonobo_object_ref (object); + return object; + } + + g_warning (FACTORY_ID ": Don't know what to do with %s", component_id); + + return NULL; +} + +BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Calendar component factory", factory, NULL) +#endif diff --git a/plugins/mail-remote/evolution-mail-store.h b/plugins/mail-remote/evolution-mail-store.h new file mode 100644 index 0000000000..c4c78d0c38 --- /dev/null +++ b/plugins/mail-remote/evolution-mail-store.h @@ -0,0 +1,53 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2005 Novell, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: JP Rosevear + */ + +#ifndef _EVOLUTION_MAIL_STORE_H_ +#define _EVOLUTION_MAIL_STORE_H_ + +#include +#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; + +typedef struct _EvolutionMailStore EvolutionMailStore; +typedef struct _EvolutionMailStoreClass EvolutionMailStoreClass; + +struct _EvolutionMailStore { + BonoboObject parent; +}; + +struct _EvolutionMailStoreClass { + BonoboObjectClass parent_class; + + POA_GNOME_Evolution_Mail_Store__epv epv; +}; + +GType evolution_mail_store_get_type(void); + +EvolutionMailStore *evolution_mail_store_new(struct _EAccount *ea); + +#endif /* _EVOLUTION_MAIL_STORE_H_ */ diff --git a/plugins/mail-remote/mail-remote.c b/plugins/mail-remote/mail-remote.c new file mode 100644 index 0000000000..369a38da2b --- /dev/null +++ b/plugins/mail-remote/mail-remote.c @@ -0,0 +1,31 @@ + +#include "evolution-mail-session.h" +#include + +#define MAIL_SESSION_ID "OAFIID:GNOME_Evolution_Mail_Session:" BASE_VERSION + +init() +{ + static EvolutionMailSession *sess; + /* placeholder for EvolutionMailSession registration, this must use a different poa */ + if (sess == NULL) { + static PortableServer_POA poa = NULL; + int res; + CORBA_Object existing; + + if (poa == NULL) + poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL); + + sess = g_object_new(evolution_mail_session_get_type(), NULL); //"poa", poa, NULL); + + if ((res = bonobo_activation_register_active_server_ext(MAIL_SESSION_ID, bonobo_object_corba_objref((BonoboObject *)sess), NULL, + Bonobo_REGISTRATION_FLAG_NO_SERVERINFO, &existing, NULL)) != Bonobo_ACTIVATION_REG_SUCCESS) { + g_warning("Could not register Mail EDS Interface: %d", res); + g_object_unref(sess); + sess = NULL; + } + + if (existing != CORBA_OBJECT_NIL) + CORBA_Object_release(existing, NULL); + } +} -- cgit v1.2.3