diff options
Diffstat (limited to 'plugins/mail-remote/mail-remote.c')
-rw-r--r-- | plugins/mail-remote/mail-remote.c | 49 |
1 files changed, 35 insertions, 14 deletions
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; } |