diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mail-remote/ChangeLog | 4 | ||||
-rw-r--r-- | plugins/mail-remote/Makefile.am | 44 | ||||
-rw-r--r-- | plugins/mail-remote/client.c | 87 | ||||
-rw-r--r-- | plugins/mail-remote/evolution-mail-store.c | 31 | ||||
-rw-r--r-- | plugins/mail-remote/mail-remote.c | 49 |
5 files changed, 181 insertions, 34 deletions
diff --git a/plugins/mail-remote/ChangeLog b/plugins/mail-remote/ChangeLog index e69de29bb2..f89a5d55f2 100644 --- a/plugins/mail-remote/ChangeLog +++ b/plugins/mail-remote/ChangeLog @@ -0,0 +1,4 @@ +2005-05-12 Not Zed <NotZed@Ximian.com> + + * A remote mail interface plugin for evolution. + diff --git a/plugins/mail-remote/Makefile.am b/plugins/mail-remote/Makefile.am index 25653f666b..6f0601b541 100644 --- a/plugins/mail-remote/Makefile.am +++ b/plugins/mail-remote/Makefile.am @@ -1,4 +1,35 @@ +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) \ + evolution-mail-folder.c \ + evolution-mail-folder.h \ + evolution-mail-session.c \ + evolution-mail-session.h \ + evolution-mail-store.c \ + evolution-mail-store.h \ + mail-remote.c + +liborg_gnome_evolution_mail_remote_la_LDFLAGS = -module -avoid-version + +client_SOURCES = \ + client.c + +client_LDADD = \ + $(EVOLUTION_MAIL_LIBS) \ + liborg-gnome-evolution-mail-remote.la + +noinst_PROGRAMS = \ + client # mail idl @@ -17,19 +48,10 @@ $(IDL_GENERATED_H) $(IDL_GENERATED_C): $(IDL) # 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 +#idl_DATA = $(IDL) EXTRA_DIST = \ $(IDL) BUILT_SOURCES = $(IDL_GENERATED_H) $(IDL_GENERATED_C) +CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/mail-remote/client.c b/plugins/mail-remote/client.c new file mode 100644 index 0000000000..d275de107d --- /dev/null +++ b/plugins/mail-remote/client.c @@ -0,0 +1,87 @@ + +#include <libbonobo.h> + +#include "Evolution-DataServer-Mail.h" + +static GNOME_Evolution_Mail_Session +get_session(void) +{ + char *path, *ior; + GNOME_Evolution_Mail_Session sess = NULL; + CORBA_Environment ev = { 0 }; + + /* The new-improved bonobo-activation ... */ + + path = g_build_filename(g_get_home_dir(), ".evolution-mail-remote.ior", NULL); + if (g_file_get_contents(path, &ior, NULL, NULL)) { + sess = CORBA_ORB_string_to_object(bonobo_orb(), ior, &ev); + g_free(ior); + } + + return sess; +} + +int main(int argc, char **argv) +{ + GNOME_Evolution_Mail_Session sess; + GNOME_Evolution_Mail_Stores *stores; + CORBA_Environment ev = { 0 }; + + bonobo_init(&argc, argv); + + sess = get_session(); + + stores = GNOME_Evolution_Mail_Session_getStores(sess, "", &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + printf("getStores failed\n"); + return 1; + } + + printf("Got %d stores\n", stores->_length); + { + GNOME_Evolution_Mail_PropertyName namesarray[] = { + "name", "uid" + }; + GNOME_Evolution_Mail_PropertyNames names = { + 1, 1, + namesarray, + FALSE, + }; + GNOME_Evolution_Mail_Properties *props; + int i, j; + + for (i=0;i<stores->_length;i++) { + GNOME_Evolution_Mail_Store store = stores->_buffer[i]; + + printf("store %p\n", store); + + GNOME_Evolution_Mail_Store_getProperties(store, &names, &props, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + printf("getProperties failed\n"); + return 1; + } + + for (j=0;j<props->_length;j++) { + printf(" %s = (%s)", props->_buffer[j].name, ORBit_tk_to_name(props->_buffer[j].value._type->kind)); + if (props->_buffer[j].value._type == TC_CORBA_string) { + printf(" '%s'\n", props->_buffer[j].value._value); + } else { + printf(" '%s' ", BONOBO_ARG_GET_STRING(&props->_buffer[j].value)); + printf(" <unknonw type>\n"); + } + } + + CORBA_free(props); + + printf("attempt send mail to store\n"); + GNOME_Evolution_Mail_Store_sendMessage(store, NULL, "notzed@ximian.com", "notzed@novell.com, user@host", &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + printf("sendmessage failed\n"); + /* FIXME:L leaks ex data? */ + CORBA_exception_init(&ev); + } + } + } + + CORBA_free(stores); +} diff --git a/plugins/mail-remote/evolution-mail-store.c b/plugins/mail-remote/evolution-mail-store.c index 2d2157ac0a..c704778370 100644 --- a/plugins/mail-remote/evolution-mail-store.c +++ b/plugins/mail-remote/evolution-mail-store.c @@ -91,27 +91,34 @@ impl_getProperties(PortableServer_Servant _servant, for (i=0;i<names->_length;i++) { const CORBA_char *name = names->_buffer[i]; GNOME_Evolution_Mail_Property *prop = &props->_buffer[i]; + char *val = NULL; prop->value._release = CORBA_TRUE; + printf("getting property '%s'\n", name); + if (!strcmp(name, "name")) { - prop->value._type = TC_CORBA_string; if (p->account) - prop->value._value = CORBA_string_dup(p->account->name); + val = p->account->name; else /* FIXME: name & i18n */ - prop->value._value = CORBA_string_dup("Local"); + val = "Local"; } else if (!strcmp(name, "uid")) { - prop->value._type = TC_CORBA_string; if (p->account) - prop->value._value = CORBA_string_dup(p->account->uid); + val = p->account->uid; else - prop->value._value = CORBA_string_dup("local@local"); + val = "local@local"; } else { prop->value._type = TC_null; ok = CORBA_FALSE; } + if (val) { + 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); } @@ -123,8 +130,8 @@ impl_getFolders(PortableServer_Servant _servant, const CORBA_char * pattern, CORBA_Environment * ev) { - EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); #if 0 + EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); GNOME_Evolution_Mail_NOT_SUPPORTED *ex; ex = GNOME_Evolution_Mail_NOT_SUPPORTED__alloc(); @@ -144,10 +151,16 @@ impl_sendMessage(PortableServer_Servant _servant, CORBA_Environment * ev) { EvolutionMailStore *ems = (EvolutionMailStore *)bonobo_object_from_servant(_servant); + struct _EvolutionMailStorePrivate *p = _PRIVATE(ems); printf("Sending message from '%s' to '%s'\n", from, recipients); - - ems = ems; + if (p->account == NULL) { + printf("Local mail can only store ...\n"); + } else if (p->account->transport && p->account->transport->url) { + printf("via '%s'\n", p->account->transport->url); + } else { + printf("Account not setup for sending '%s'\n", p->account->name); + } } /* Initialization */ diff --git a/plugins/mail-remote/mail-remote.c b/plugins/mail-remote/mail-remote.c index 369a38da2b..6ee41f6c9d 100644 --- a/plugins/mail-remote/mail-remote.c +++ b/plugins/mail-remote/mail-remote.c @@ -1,31 +1,52 @@ +#include <stdio.h> +#include <unistd.h> + #include "evolution-mail-session.h" #include <bonobo/bonobo-main.h> #define MAIL_SESSION_ID "OAFIID:GNOME_Evolution_Mail_Session:" BASE_VERSION -init() +int e_plugin_lib_enable(int enable); + +int e_plugin_lib_enable(int enable) { static EvolutionMailSession *sess; - /* placeholder for EvolutionMailSession registration, this must use a different poa */ - if (sess == NULL) { + char *path; + FILE *fp; + + if (enable) { static PortableServer_POA poa = NULL; - int res; - CORBA_Object existing; + CORBA_string ior; + CORBA_Environment ev = { 0 }; + + if (sess != NULL) + return 0; 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); + sess = g_object_new(evolution_mail_session_get_type(), "poa", poa, NULL); + ior = CORBA_ORB_object_to_string(bonobo_orb(), bonobo_object_corba_objref((BonoboObject *)sess), &ev); - 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; - } + path = g_build_filename(g_get_home_dir(), ".evolution-mail-remote.ior", NULL); + fp = fopen(path, "w"); + fprintf(fp, "%s", ior); + fclose(fp); + g_free(path); - if (existing != CORBA_OBJECT_NIL) - CORBA_Object_release(existing, NULL); + printf("Enable mail-remote: IOR=%s\n", ior); + } else { + if (sess == NULL) + return 0; + + path = g_build_filename(g_get_home_dir(), ".evolution-mail-remote.ior", NULL); + unlink(path); + g_free(path); + + g_object_unref(sess); + sess = NULL; } + + return 0; } |