aboutsummaryrefslogtreecommitdiffstats
path: root/wombat/wombat.c
blob: 47244afadbd9c4ab7fd69703db1c593a28412dfb (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/* Wombat personal information server - main file
 *
 * Author: Nat Friedman <nat@ximian.com>
 *
 * Copyright 2000, Ximian, Inc.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/* define this if you need/want to be able to send USR2 to wombat and
   get a list of the active backends */
/*#define DEBUG_BACKENDS*/

#include <stdlib.h>
#ifdef DEBUG_BACKENDS
#include <sys/signal.h>
#endif

#include <glib.h>
#include <libgnome/gnome-init.h>
#include <bonobo-activation/bonobo-activation.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-i18n.h>

#include "pas/pas-book-factory.h"
#include "pas/pas-backend-file.h"

#include "calendar/pcs/cal-factory.h"
#include "calendar/pcs/cal-backend-file.h"

#ifdef HAVE_LDAP
#include "pas/pas-backend-ldap.h"
#endif

#define CAL_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_CalendarFactory"
#define PAS_BOOK_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_ServerFactory"

/* The and addressbook calendar factories */

static CalFactory *cal_factory;

static PASBookFactory *pas_book_factory;

/* Timeout interval in milliseconds for termination */
#define EXIT_TIMEOUT 5000

/* Timeout ID for termination handler */
static guint termination_handler_id;



/* Termination */

/* Termination handler.  Checks if both factories have zero running backends,
 * and if so terminates the program.
 */
static gboolean
termination_handler (gpointer data)
{
    if (
        cal_factory_get_n_backends (cal_factory) == 0 &&
        pas_book_factory_get_n_backends (pas_book_factory) == 0) {
        fprintf (stderr, "termination_handler(): Terminating the Wombat.  Have a nice day.\n");
        bonobo_main_quit ();
    }

    termination_handler_id = 0;
    return FALSE;
}

/* Queues a timeout for handling termination of Wombat */
static void
queue_termination (void)
{
    if (termination_handler_id)
        return;

    termination_handler_id = g_timeout_add (EXIT_TIMEOUT, termination_handler, NULL);
}



static void
last_book_gone_cb (PASBookFactory *factory, gpointer data)
{
    queue_termination ();
}

static gboolean
setup_pas (int argc, char **argv)
{
    pas_book_factory = pas_book_factory_new ();

    if (!pas_book_factory)
        return FALSE;

    pas_book_factory_register_backend (
        pas_book_factory, "file", pas_backend_file_new);

#ifdef HAVE_LDAP
    pas_book_factory_register_backend (
        pas_book_factory, "ldap", pas_backend_ldap_new);
#endif

    g_signal_connect (pas_book_factory,
              "last_book_gone",
              G_CALLBACK (last_book_gone_cb),
              NULL);

    if (!pas_book_factory_activate (pas_book_factory, PAS_BOOK_FACTORY_OAF_ID)) {
        bonobo_object_unref (BONOBO_OBJECT (pas_book_factory));
        pas_book_factory = NULL;
        return FALSE;
    }

    return TRUE;
}



/* Personal calendar server */

/* Callback used when the calendar factory has no more running backends */
static void
last_calendar_gone_cb (CalFactory *factory, gpointer data)
{
    queue_termination ();
}

/* Creates the calendar factory object and registers it */
static gboolean
setup_pcs (int argc, char **argv)
{
    cal_factory = cal_factory_new ();

    if (!cal_factory) {
        g_message ("setup_pcs(): Could not create the calendar factory");
        return FALSE;
    }

    cal_factory_register_method (cal_factory, "file", CAL_BACKEND_FILE_TYPE);

    if (!cal_factory_oaf_register (cal_factory, CAL_FACTORY_OAF_ID)) {
        bonobo_object_unref (BONOBO_OBJECT (cal_factory));
        cal_factory = NULL;
        return FALSE;
    }

    g_signal_connect (G_OBJECT (cal_factory),
              "last_calendar_gone",
              G_CALLBACK (last_calendar_gone_cb),
              NULL);

    return TRUE;
}



#ifdef DEBUG_BACKENDS
static void
dump_backends (int signal)
{
    pas_book_factory_dump_active_backends (pas_book_factory);
    cal_factory_dump_active_backends (cal_factory);
}
#endif

int
main (int argc, char **argv)
{
    gboolean did_pas=FALSE, did_pcs=FALSE;

    bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR);
    textdomain (GETTEXT_PACKAGE);

    g_message ("Starting wombat");

#ifdef DEBUG_BACKENDS
    signal (SIGUSR2, dump_backends);
#endif

        gnome_program_init ("Wombat", VERSION,
                LIBGNOME_MODULE,
                argc, argv,
                GNOME_PROGRAM_STANDARD_PROPERTIES, NULL);

    bonobo_init_full (&argc, argv,
              bonobo_activation_orb_get(),
              CORBA_OBJECT_NIL,
              CORBA_OBJECT_NIL);

    /*g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
                G_LOG_LEVEL_CRITICAL |
                G_LOG_LEVEL_WARNING);*/

    if (!( (did_pas = setup_pas (argc, argv))
           && (did_pcs = setup_pcs (argc, argv))
           )) {

        const gchar *failed = NULL;

        if (!did_pas)
          failed = "PAS";
        else if (!did_pcs)
          failed = "PCS";

        g_message ("main(): could not initialize Wombat service \"%s\"; terminating", failed);

        if (pas_book_factory) {
            bonobo_object_unref (BONOBO_OBJECT (pas_book_factory));
            pas_book_factory = NULL;
        }

        if (cal_factory) {
            bonobo_object_unref (BONOBO_OBJECT (cal_factory));
            cal_factory = NULL;
        }
        exit (EXIT_FAILURE);
    }

    g_print ("Wombat up and running\n");

    bonobo_main ();

    bonobo_object_unref (BONOBO_OBJECT (cal_factory));
    cal_factory = NULL;

    bonobo_object_unref (BONOBO_OBJECT (pas_book_factory));
    pas_book_factory = NULL;

    gnome_vfs_shutdown ();

    return 0;
}
> * Translation updated.Priit Laes2005-01-072-5461/+6360 * MissingRodrigo Moya2005-01-072-0/+4 * added calendar-weather plugin to build.David Trowbridge2005-01-072-1/+11 * initial import of ECalEvent targetsDavid Trowbridge2005-01-074-0/+270 * Initial import of weather properties pluginDavid Trowbridge2005-01-0711-0/+833 * Translation updated by Ivar Smolin.Priit Laes2005-01-072-499/+380 * remove old code, setup transient parent and weak ref for refresh. someNot Zed2005-01-074-18/+14 * Add the GTK_DIALOG_NOSEPARATOR flag, and set appropriate border widthsRodney Dawes2005-01-072-1/+14 * add some uninstall rules for local dataJP Rosevear2005-01-072-0/+14 * install schemas properlyJP Rosevear2005-01-072-1/+5 * install schemas properlyJP Rosevear2005-01-072-1/+5 * install schemas properlyJP Rosevear2005-01-072-1/+5 * install schemas properly and add some uninstall rules for local installJP Rosevear2005-01-072-1/+16 * Handle the CamelOfflineStore case just like the CamelDiscoStore case.Jeffrey Stedfast2005-01-073-22/+53 * dist the glade fileJP Rosevear2005-01-062-0/+5 * include top_srcdirJP Rosevear2005-01-062-0/+5 * use the base name only, so if a full path is passed to us we still writeJP Rosevear2005-01-062-2/+11 * Commiting send optionsChenthill Palanisamy2005-01-0612-7/+588 * Commiting the files mentioned below again to HEAD since it was not addedChenthill Palanisamy2005-01-064-0/+1939 * merging send optionsChenthill Palanisamy2005-01-062-0/+12 * fix build for non gtk file chooser caseJP Rosevear2005-01-062-1/+6 * Dist the errors data properly, and add the .eplug output file toRodney Dawes2005-01-062-2/+8 * Remove mail-errors.xml (the .h belongs here, not the straight .xmlRodney Dawes2005-01-052-1/+5 * added a new argument to pass the calendar client, since it might happen toRodrigo Moya2005-01-053-4/+27 * Add the widget target, missed this.Not Zed2005-01-052-0/+11 * turn off debug, setup g private instance data structure. (setup_ui):Not Zed2005-01-052-3/+46 * add a semi-dummy target for widget target.Not Zed2005-01-053-0/+34 * handle the "reply" parameter, if set.Not Zed2005-01-053-9/+35 * -uu-:---F1 POTFILES.in (FundamentalJP Rosevear2005-01-052-5/+4 * new protos, modesJP Rosevear2005-01-057-36/+419 * add component button view itemsJP Rosevear2005-01-055-5/+38 * remove dead filesJP Rosevear2005-01-057-347/+4 * use the new e-categories API in e-d-s.Rodrigo Moya2005-01-052-1/+7 * removed most of the API. The rest will be removed as the GAL dependenciesRodrigo Moya2005-01-053-114/+15 * search our internal data for the correct event.Rodrigo Moya2005-01-052-2/+26 * Use standard error messagesPhilip Van Hoof2005-01-043-34/+14 * Use standard error messagesPhilip Van Hoof2005-01-042-17/+8 * add a11y name to calendar sidebar selector. add a11y name to task sidebarHarry Lu2005-01-043-0/+13 * add atk name for the treeview.Mengjie Yu2005-01-042-0/+9 * Modify the changelog's entry date to corret year.Harry Lu2005-01-041-1/+1 * add ea-combo-button.[ch] to Makefile.Harry Lu2005-01-046-1/+224 * new internal function to popup the menu. (impl_button_press_event): callHarry Lu2005-01-043-4/+61 * Don't do set_usize () on the containerRodney Dawes2005-01-042-1/+5 * load accountsJP Rosevear2005-01-042-0/+7 * remove unused messageJP Rosevear2005-01-043-9/+12 * implement cancel (update_item): add cancel info itemJP Rosevear2005-01-042-7/+19 * Fixes #69663JP Rosevear2005-01-042-1/+18 * utility routine to make it easier to add info itemsJP Rosevear2005-01-044-30/+74 * add itip-formatter to the "all" list, its not ready to be in the base yetJP Rosevear2005-01-042-2/+9 * move the adjust item work here when we actually have the calendarJP Rosevear2005-01-042-59/+60 * move the adjust item work here when we actually have the calendarJP Rosevear2005-01-042-5/+45 * add response enumsJP Rosevear2005-01-047-35/+288 * new protos, signalJP Rosevear2005-01-034-114/+749 * redo the queries after emitting the 'time_range_changed' signal, since nowRodrigo Moya2005-01-034-24/+19 * Warning when overwriting filePhilip Van Hoof2005-01-034-10/+60 * Warning when overwriting filePhilip Van Hoof2005-01-032-1/+30 * Fixing bug 61068 (removing a white space in a string)Andre Klapper2005-01-032-1/+6 * scriptyFunda Wang2005-01-021-90/+153 * add necessary includeJP Rosevear2005-01-0110-57/+114 * Updated Bulgarian translation by myselfAlexander Shopov2004-12-302-745/+293 * new protosJP Rosevear2004-12-305-40/+953 * 2.0 is the current stable version.Rodrigo Moya2004-12-302-1/+6 * Updated Bulgarian translation by Vladimir Petkov <vpetkov@i-space.org>Alexander Shopov2004-12-292-5190/+6417 * s/strcmp/strncmp.David Trowbridge2004-12-283-3/+9 * removed superfluous if check. (e_cal_view_objects_modified_cb): add allRodrigo Moya2004-12-272-6/+8 * set fields we free to NULL.Rodrigo Moya2004-12-272-0/+7 * kill warnings (map_default_cb): the to entry widget is now just a gtkJP Rosevear2004-12-242-13/+12 * Updated Simplified Chinese translationFunda Wang2004-12-241-623/+911 * Make intltool happy. Removed serveral non-exists file references.Funda Wang2004-12-242-58/+87 * set start_offline gconf key when ever offline state is changed.Sivaiah Nallaagatla2004-12-242-4/+15 * typo correctionHarish Krishnaswamy2004-12-241-1/+1 * Check for the existence of the meet/sched pages before attempting toHarish Krishnaswamy2004-12-242-2/+9 * Merging offline brnach with HEADSivaiah Nallagatla2004-12-242-0/+50 * Merge from offline brnachSivaiah Nallagatla2004-12-244-12/+104 * get instance times using the correct timezone. (redo_queries): emitRodrigo Moya2004-12-231-39/+0 * get instance times using the correct timezone. (redo_queries): emitRodrigo Moya2004-12-234-97/+56 * This is the last we see of ESelectNames.Hans Petter Jansson2004-12-2330-7290/+34 * Remove select-names from here.Hans Petter Jansson2004-12-233-6/+10 * Remove select-names from Makefile output list.Hans Petter Jansson2004-12-232-1/+4 * No more select-names. (libevolution_addressbook_la_LIBADD): RemoveHans Petter Jansson2004-12-234-18/+13 * Correct bad include.Hans Petter Jansson2004-12-233-14/+9 * Unref the name selector. (e_contact_list_editor_save_contact): Fix aHans Petter Jansson2004-12-2316-460/+525 * prevent compare against null default_fb_uri and fix thinkoJP Rosevear2004-12-232-1/+6 * Initial checkin of new itip formatterJP Rosevear2004-12-237-0/+1135 * list format-handler.h as a source so it distsJP Rosevear2004-12-222-1/+11 * Change copyright from ximian to novellJP Rosevear2004-12-222-1/+5 * add translation stuff.Not Zed2004-12-222-1/+13 * moved to after emae_authtype_changed to fix warning.Not Zed2004-12-227-29/+48 * translate strings based on translation-domain, if supplied.Not Zed2004-12-222-9/+29 * svn path=/trunk/; revision=28178Not Zed2004-12-223-2/+8 * svn path=/trunk/; revision=28177Not Zed2004-12-22