aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mail-remote/mail-remote.c
blob: 7d082d3465bc3afcc4e656f91cdfa8eb6d18a837 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

#include <stdio.h>
#include <unistd.h>

#include "evolution-mail-session.h"
#include <bonobo/bonobo-main.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);
        printf(" ** Added mail interface to mail component\n");
    } else {
        /* can't easily disable this until restart? */
        /* can we just destroy it? */
    }

    return 0;
}