Handle the EINTR error when doing a waitpid() in wvmagicloopback.
[wvapps.git] / evolution / main.cc
blob68f351c47f0a35e96b8abdc29c728f3e526794a7
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Authors : Patrick Patterson <ppatters@nit.ca>
4 * Peter Colijn <pcolijn@nit.ca>
5 * Scott MacLean <scott@nit.ca>
6 * William Lachance <wlach@nit.ca>
7 * Hubert Figuiere <hub@nit.ca>
9 * Based on code written by JP Rosevear <jpr@ximian.com>
11 * Copyright 2003-2004, Net Integration Technologies, Inc.
12 * Copyright 2003, Novell, Inc.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of version 2 of the GNU General Public
16 * License as published by the Free Software Foundation.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 * USA
29 extern "C" {
30 /* Hackery because of Evolution headers screwing up C++ */
31 #define delete _delete
32 #include <e-util/e-account-list.h>
33 #undef delete
37 #include "wvstring.h"
38 #include "wvlinklist.h"
39 #include "wvstringlist.h"
40 #include "wvistreamlist.h"
41 #include "wvglibstreamclone.h"
42 #include "wvcrash.h"
43 #include "wvlogfile.h"
44 #include "strutils.h"
46 #include "uniconfroot.h"
47 #include "uniinigen.h"
49 #include "exchangeitaccountcontrol.h"
50 #include "wvexcconnmanager.h"
51 #include "exchangeitaccount.h"
52 #include "exchangeitstorage.h"
53 #include "acldialog.h"
55 #include "eituniconfkeys.h"
57 #include <string.h>
58 #include <fcntl.h>
59 #include <sys/stat.h>
60 #include <map>
62 extern "C"
64 #include <bonobo-activation/bonobo-activation.h>
65 #include <bonobo/bonobo-main.h>
66 #include <bonobo/bonobo-generic-factory.h>
67 #include <bonobo/bonobo-moniker-util.h>
68 #include <bonobo/bonobo-exception.h>
69 #include <libgnomeui/gnome-ui-init.h>
70 #include <libgnomevfs/gnome-vfs-init.h>
71 #include <gconf/gconf-client.h>
72 #include <gtk/gtkmessagedialog.h>
73 #include <gtk/gtk.h>
74 #include <glade/glade.h>
76 #include <e-util/e-passwords.h>
77 #include <e-util/e-account.h>
78 #include <pcs/cal-factory.h>
79 #include <shell/evolution-shell-component.h>
80 #include <shell/evolution-shell-component-client.h>
81 #include <shell/evolution-storage.h>
83 #include <dirent.h>
84 #include <unistd.h>
85 #include <signal.h>
88 #include "wvglibstreamclone.h"
89 #include "wvexcconn.h"
90 #include "evoutils.h"
92 #define EXCHANGEIT_COMPONENT_ID "OAFIID:GNOME_Evolution_ExchangeIT_ShellComponent"
93 #define EXCHANGEIT_ACCOUNT_CONTROL_ID "OAFIID:GNOME_Evolution_ExchangeIT_AccountConfigControl"
94 #define EXCHANGEIT_CONFIG_FACTORY_ID "OAFIID:GNOME_Evolution_ExchangeIT_ConfigFactory"
96 // Use a WvString to make this:
97 // WvString(CAMEL_ACCT_FORMAT, uid, enabled, user, user, server, sync-freq, server,
98 // user, server, g_get_home_dir(), g_get_home_dir())
99 #define CAMEL_ACCT_FORMAT "<?xml version=\"1.0\"?><account name=\"ExchangeIT\" uid=\"%s\" enabled=\"%s\"><identity><name>%s</name><addr-spec>%s@%s</addr-spec><reply-to></reply-to><organization></organization><signature auto=\"false\" default=\"-1\"/></identity><source save-passwd=\"false\" keep-on-server=\"false\" auto-check=\"true\" auto-check-timeout=\"%s\"><url>ExchangeIT://%s</url></source><transport save-passwd=\"false\"><url>smtp://%s@%s</url></transport><drafts-folder>file://%s/evolution/local/Drafts</drafts-folder><sent-folder>file://%s/evolution/local/Sent</sent-folder><auto-cc always=\"false\"><recipients></recipients></auto-cc><auto-bcc always=\"false\"><recipients></recipients></auto-bcc><pgp encrypt-to-self=\"false\" always-trust=\"false\" always-sign=\"false\" no-imip-sign=\"false\"><key-id></key-id></pgp><smime encrypt-to-self=\"false\" always-sign=\"false\"/></account>"
101 static BonoboGenericFactory *config_factory = NULL;
102 const char * public_folders_path = "/Public Folders/";
103 //UniWatch *connection_watch = NULL;
105 /* this function lifted from evolution code: mail/component-factory.h */
106 static void notify_listener(const Bonobo_Listener listener,
107 GNOME_Evolution_Storage_Result result)
109 CORBA_any any;
110 CORBA_Environment ev;
112 CORBA_exception_init(&ev);
114 any._type = TC_GNOME_Evolution_Storage_Result;
115 any._value = &result;
117 Bonobo_Listener_event(listener, "result", &any, &ev);
119 CORBA_exception_free(&ev);
122 static void sync_evo(ExchangeItStorage *storage)
124 UniConf::Iter i(storage->get_state()[EVO_FOLDERS_KEY]);
125 for (i.rewind(); i.next(); )
127 WvString path("/%s", i().key().printable());
128 storage->sync_folder_hierarchy(path);
132 static void create_folder_cb(EvolutionStorage *storage,
133 Bonobo_Listener listener, const char *path,
134 const char *type,
135 const char *desc, const char *uri, void *data)
137 WvLog log("create_folder_cb");
138 ExchangeItStorage *eit_storage = static_cast<ExchangeItStorage *>(data);
140 log("Creating folder %s, of type %s\n", path, type);
142 assert(path && *path);
143 // FIXME: shouldn't the user be able to do this if they have admin
144 // rights on the folder?
145 if (!strncmp(path, "/Public Folders", 15))
147 notify_listener(listener, GNOME_Evolution_Storage_PERMISSION_DENIED);
148 return;
151 if (eit_storage->get_owner())
153 WvString eit_path(
154 convert_evopath_to_eitpath(path, eit_storage->get_owner()));
156 if (!eit_storage->get_dict()[eit_path])
158 WvString eit_type;
159 if (!strcmp(type, "calendar"))
160 eit_type = EXCHANGEIT_CALENDAR_TYPE;
161 else if (!strcmp(type, "mail") || !strcmp(type, "folder"))
162 eit_type = EXCHANGEIT_NULL_TYPE;
163 else if (!strcmp(type, "contacts"))
164 eit_type = EXCHANGEIT_CONTACTS_TYPE;
165 else if (!strcmp(type, "tasks"))
166 eit_type = EXCHANGEIT_TASKS_TYPE;
167 else
169 // what are they trying to create?
170 notify_listener(listener,
171 GNOME_Evolution_Storage_UNSUPPORTED_TYPE);
172 return;
175 eit_storage->add_folder(eit_path, eit_type, true);
179 notify_listener(listener, GNOME_Evolution_Storage_OK);
182 static void remove_folder_cb(EvolutionStorage *storage,
183 Bonobo_Listener listener, const char *path,
184 const char *uri, void *data)
186 WvLog log("remove_folder_cb");
187 ExchangeItStorage *eit_storage = static_cast<ExchangeItStorage *>(data);
189 if (!strcmp(path, "/Public Folders"))
191 GtkWidget *msg = gtk_message_dialog_new(NULL,
192 GTK_DIALOG_DESTROY_WITH_PARENT,
193 GTK_MESSAGE_ERROR,
194 GTK_BUTTONS_CLOSE,
195 "Public Folders cannot be deleted.");
196 gtk_dialog_run(GTK_DIALOG(msg));
197 gtk_widget_destroy(msg);
198 return;
201 log("Removing folder %s\n", path);
203 if (eit_storage->get_owner())
205 WvString eit_path(
206 convert_evopath_to_eitpath(path, eit_storage->get_owner()));
208 eit_storage->remove_folder(eit_path, true);
213 static void xfer_folder_cb(EvolutionStorage *storage, Bonobo_Listener listener,
214 const char *src_path, const char *dest_path,
215 gboolean remove_src, void *data)
217 // FIXME: have to funk in code to move/copy the actual ExchangeIT folder
218 WvLog log("xfer_folder_cb");
219 WvString cmd = remove_src ? "mv " : "cp -a ";
220 WvString dest("%s" STORAGE_PATH "%s", g_get_home_dir(), dest_path);
221 WvString cmd_line("%s%s" STORAGE_PATH "%s %s",
222 cmd, g_get_home_dir(), src_path, dest.cstr());
224 if (system(cmd_line) != 0)
226 log("An error occured while moving or copying folders.");
227 return;
230 sync_folder(storage, dest, dest_path, strrchr(dest_path, '/') + 1);
231 sync_evo_to_fs(storage, dest_path);
232 if (remove_src)
234 evolution_storage_removed_folder(storage, src_path);
239 static void show_dialog(WvStringParm title, WvStringParm message)
241 GtkWidget *dialog, *label;
242 GdkPixbuf *icon;
243 dialog = gtk_dialog_new_with_buttons (title,
244 NULL,
245 (GtkDialogFlags)NULL,
246 GTK_STOCK_OK,
247 GTK_RESPONSE_NONE,
248 NULL);
249 gtk_container_set_border_width (GTK_CONTAINER (dialog), PADDING);
250 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog)->vbox), PADDING);
251 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
252 icon = gtk_widget_render_icon (dialog, GTK_STOCK_DIALOG_WARNING,
253 GTK_ICON_SIZE_DIALOG, NULL);
254 gtk_window_set_icon (GTK_WINDOW (dialog), icon);
255 g_object_unref (icon);
257 g_signal_connect_swapped (GTK_OBJECT (dialog),
258 "response",
259 G_CALLBACK (gtk_widget_destroy),
260 GTK_OBJECT (dialog));
262 label = gtk_label_new (message);
263 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
264 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
265 label);
267 gtk_widget_show_all (dialog);
268 gtk_window_present(GTK_WINDOW(dialog));
271 static void show_properties_cb(EvolutionStorage *storage, const char *path,
272 unsigned int item, unsigned long parent,
273 void *data)
275 WvLog log("show_properties_cb", WvLog::Debug1);
276 ExchangeItStorage *eit_storage = static_cast<ExchangeItStorage *>(data);
278 // permissions don't make sense
279 if (!strcmp(path, "/") || !strcmp(path, "/Public Folders"))
281 WvString name = path + 1;
282 if (!name)
283 name = "ExchangeIT";
285 WvString msg("\"%s\" is a top-level folder. You "
286 "cannot change its permissions.", name);
288 show_dialog("Permissions", msg);
289 return;
292 WvString eit_path =
293 convert_evopath_to_eitpath(path, eit_storage->get_owner());
294 WvString owner = eit_storage->get_owner();
296 UniConf users = eit_storage->get_state()[USERS_KEY];
297 UniConf folder_info = eit_storage->get_state()[eit_path];
299 if (users.exists() && folder_info.exists())
301 char *fold_name = strrchr(path, '/');
302 assert(fold_name && *(fold_name + 1)); // all paths have slashes
303 WvString folder_name(fold_name + 1);
304 log("eit_path is %s\n", eit_path);
305 log("folder_name is %s\n", folder_name);
306 bool admin = (folder_info[ACL_KEY][owner].getmeint() == 3);
308 // gets deleted in dialog_closed(), called when the window is closed
309 new AclDialog(eit_path, folder_name,
310 eit_storage->get_state(), admin);
312 else
313 show_dialog("Permissions", "There is no ACL information about this "
314 "folder (yet).");
317 static void owner_set_cb(EvolutionShellComponent *shell_component,
318 EvolutionShellClient *shell_client,
319 const char *evo_dir, gpointer user_data)
321 WvLog log("owner_set_cb");
323 EvolutionStorage *storage = static_cast<EvolutionStorage *>(user_data);
325 if (evolution_storage_register_on_shell(
326 storage, evolution_shell_client_corba_objref(shell_client)) !=
327 EVOLUTION_STORAGE_OK)
329 log("Error registering custom storage on shell.");
330 bonobo_object_unref(BONOBO_OBJECT(storage));
334 /* This returns %TRUE all the time, so if set as an idle callback it
335 effectively causes each and every nested glib mainloop to be quit. */
336 static gboolean quit_cb(gpointer closure)
338 bonobo_main_quit();
339 return TRUE;
342 static void owner_unset_cb (EvolutionShellComponent *shell_component,
343 gpointer user_data)
345 g_timeout_add(500, quit_cb, NULL);
348 static void interactive_cb(EvolutionShellComponent *shell_component,
349 gboolean on, gulong new_view_xid,
350 gpointer user_data)
352 // Nothing special...
355 #if 0
356 static void last_calendar_gone_cb(CalFactory *factory, gpointer data)
358 /* FIXME: what to do? */
360 #endif
362 static void remove_camel_acct()
364 GConfClient *gconf = gconf_client_get_default();
365 EAccount *camel_account = NULL;
367 EAccountList *account_list = e_account_list_new(gconf);
369 camel_account = const_cast<EAccount *>(e_account_list_find
370 (account_list, E_ACCOUNT_FIND_NAME,
371 "ExchangeIT"));
372 if (camel_account)
374 e_account_list_remove(account_list, camel_account);
375 // I wonder if camel_account leak from here.
376 e_account_list_save(account_list);
380 static void configure_camel_acct(WvStringParm user, WvStringParm server,
381 int sync_freq, bool enabled)
383 WvLog log("configure_camel_acct");
385 log("configure_camel_acct: %s %s %s %s\n", user, server, sync_freq, enabled);
386 // User probably hasn't set up an account yet
387 if (!user || !server)
389 remove_camel_acct();
390 return;
393 GConfClient *gconf = gconf_client_get_default();
394 char *uid = e_account_gen_uid();
395 bool acct_replaced = false;
397 WvString homedir(g_get_home_dir());
398 WvString new_camel_acct(CAMEL_ACCT_FORMAT,
399 uid, (enabled?"true":"false"), user, user, server, sync_freq, server,
400 user, server, homedir, homedir);
402 // WvStrings are unique(), so we really do want to free this
403 g_free(uid);
405 EAccount *camel_account;
406 EAccountList *account_list = e_account_list_new(gconf);
408 camel_account = const_cast<EAccount *>(e_account_list_find
409 (account_list, E_ACCOUNT_FIND_NAME,
410 "ExchangeIT"));
411 acct_replaced = (camel_account != NULL);
412 if (!acct_replaced)
414 camel_account = e_account_new();
417 e_account_set_from_xml (camel_account, new_camel_acct);
418 if (acct_replaced)
420 e_account_list_change(account_list, camel_account);
422 else
424 e_account_list_add(account_list, camel_account);
426 e_account_list_save(account_list);
429 static void configure_default_folders()
431 GConfClient *gconf = gconf_client_get_default();
433 WvString homedir(g_get_home_dir());
434 WvString folders_key("/apps/evolution/shell/default_folders");
435 WvString base_path("evolution:/ExchangeIT");
437 WvString tasks_uri("file://%s%s/Tasks", homedir, STORAGE_PATH);
438 WvString calendar_uri("file://%s%s/Calendar", homedir, STORAGE_PATH);
439 WvString contacts_uri("file://%s%s/Contacts", homedir, STORAGE_PATH);
441 WvString tasks_path("%s/Tasks", base_path);
442 WvString calendar_path("%s/Calendar", base_path);
443 WvString contacts_path("%s/Contacts", base_path);
445 WvString tasks_uri_key("%s/tasks_uri", folders_key);
446 WvString calendar_uri_key("%s/calendar_uri", folders_key);
447 WvString contacts_uri_key("%s/contacts_uri", folders_key);
449 WvString tasks_path_key("%s/tasks_path", folders_key);
450 WvString calendar_path_key("%s/calendar_path", folders_key);
451 WvString contacts_path_key("%s/contacts_path", folders_key);
453 gconf_client_set_string(gconf, tasks_uri_key, tasks_uri, NULL);
454 gconf_client_set_string(gconf, calendar_uri_key, calendar_uri, NULL);
455 gconf_client_set_string(gconf, contacts_uri_key, contacts_uri, NULL);
457 gconf_client_set_string(gconf, tasks_path_key, tasks_path, NULL);
458 gconf_client_set_string(gconf, calendar_path_key, calendar_path, NULL);
459 gconf_client_set_string(gconf, contacts_path_key, contacts_path, NULL);
462 static void control_apply_cb(EvolutionConfigControl *config_control,
463 gpointer data)
465 EItAccountControl *eicc = EXCHANGEIT_ACCOUNT_CONTROL(config_control);
466 ExchangeItAccount *tmp_account =
467 (ExchangeItAccount *)g_object_get_data(G_OBJECT (eicc), "tmp_account");
469 WvExcConnManager *conn_manager = static_cast<WvExcConnManager *>(data);
470 assert(conn_manager);
471 UniConf config = conn_manager->get_config();
473 configure_camel_acct(tmp_account->username, tmp_account->server,
474 tmp_account->resync_freq, tmp_account->enabled);
475 configure_default_folders();
477 bool needs_migration = false;
479 if (config[USERNAME_KEY].getme() != tmp_account->username ||
480 config[SERVER_KEY].getme() != tmp_account->server)
481 needs_migration = true;
483 config[USERNAME_KEY].setme(tmp_account->username);
484 config[PASSWORD_KEY].setme(tmp_account->password);
485 config[SERVER_KEY].setme(tmp_account->server);
486 config[RESYNC_FREQ_KEY].setmeint(tmp_account->resync_freq);
487 config[ENABLED_KEY].setmeint(tmp_account->enabled);
489 if (needs_migration)
490 config[OLD_USERNAME_KEY].setme(config[USERNAME_KEY].getme());
492 if (!config[USE_SSL_KEY].exists())
493 config[USE_SSL_KEY].setmeint(1);
495 conn_manager->account_changed_callback();
498 static void config_destroy(gpointer data, GObject *where_object_was)
500 ExchangeItAccount *tmp_account = static_cast<ExchangeItAccount *>(data);
501 delete tmp_account;
504 static BonoboObject *config_factory_func(BonoboGenericFactory *factory,
505 const char *component_id,
506 gpointer data)
508 g_message ("%s : %s", EXCHANGEIT_ACCOUNT_CONTROL_ID, component_id);
509 WvExcConnManager *conn_manager = static_cast<WvExcConnManager *>(data);
510 assert(conn_manager);
512 UniConf config = conn_manager->get_config();
514 if (!config[RESYNC_FREQ_KEY].exists())
516 config[RESYNC_FREQ_KEY].setmeint((int)RESYNC_MIN_INTERVAL);
518 // set the defaut value for the key, or user upgrading may have problem
519 // with account being disabled
520 if (!config[ENABLED_KEY].exists())
522 config[ENABLED_KEY].setmeint(1);
525 ExchangeItAccount *tmp_account =
526 new ExchangeItAccount(config[SERVER_KEY].getme(),
527 config[USERNAME_KEY].getme(),
528 config[PASSWORD_KEY].getme(),
529 config[RESYNC_FREQ_KEY].getmeint(),
530 config[ENABLED_KEY].getmeint());
532 if (!strcmp(component_id, EXCHANGEIT_ACCOUNT_CONTROL_ID))
534 BonoboObject *control;
536 control = exchangeit_account_control_new(tmp_account);
538 g_object_set_data(G_OBJECT(control), "tmp_account", tmp_account);
539 g_signal_connect(control, "apply",
540 G_CALLBACK(control_apply_cb), conn_manager);
541 g_object_weak_ref(G_OBJECT(control), config_destroy, tmp_account);
543 return control;
546 return NULL;
549 static bool setup_config(WvExcConnManager *conn_manager)
551 config_factory =
552 bonobo_generic_factory_new(EXCHANGEIT_CONFIG_FACTORY_ID,
553 config_factory_func, conn_manager);
555 return (config_factory != CORBA_OBJECT_NIL);
558 // setup_paths: determine if the base path (~/evolution/local) exists
559 // if it does not exist, this function will attempt to create it
560 // returns true on success, false on failure
561 static bool check_paths()
563 WvString base_path("%s" EXCHANGEIT_PATH, g_get_home_dir());
564 WvString storage_path("%s" STORAGE_PATH, g_get_home_dir());
566 struct stat stat_buf;
568 if (stat(base_path.cstr(), &stat_buf) != 0)
570 g_message("Base path not found. Attempting to create it.");
571 if (mkdir(base_path.cstr(), 0770) != 0)
572 g_message("ERROR: Couldn't create base path");
575 if (stat(storage_path.cstr(), &stat_buf) != 0)
577 g_message("Storage path not found. Attempting to create it.");
578 if (mkdir(storage_path.cstr(), 0770) != 0)
579 g_message("ERROR: Couldn't create storage path");
582 return true;
585 extern "C"
587 int main (int argc, char **argv)
589 WvString exchangeit_path("%s" EXCHANGEIT_PATH, g_get_home_dir());
590 WvString storage_path("%s" STORAGE_PATH, g_get_home_dir());
592 EvolutionShellComponent *shell_component = NULL;
593 EvolutionShellComponentFolderType types[] = {
594 { "exchangeit-server", "none", "exchangeit-server",
595 "ExchangeIT server", FALSE, NULL, NULL },
596 { NULL, NULL, NULL, NULL, FALSE, NULL, NULL }
599 if (!check_paths())
601 g_warning("\nCould not initialize basic directory structure.\n"
602 "There is likely something wrong with your system.\n");
603 return 1;
606 UniConfRoot root;
608 WvString state_path("%s/evolution-exchangeit.ini", exchangeit_path);
609 root.mountgen(new UniIniGen(state_path));
611 if (0 != chdir(exchangeit_path.cstr()))
612 g_message("WARNING: could not change directory "
613 "to %s for wvcrash reports\n", EXCHANGEIT_PATH);
615 wvcrash_setup(argv[0]);
616 // un-ifdef for file-logging nirvana
617 WvString evo_eit_log("%s/evolution-exchangeit", exchangeit_path);
618 WvLogFile filelogger(evo_eit_log, WvLog::Debug1);
620 WvIStreamList *global_list = new WvIStreamList;
621 WvGlibStreamClone *glib_stream = new WvGlibStreamClone(NULL, global_list);
623 gnome_program_init(PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
624 GNOME_PROGRAM_STANDARD_PROPERTIES,
625 GNOME_PARAM_HUMAN_READABLE_NAME,
626 _("Net-Itech Connector for ExchangeIT"),
627 LIBGNOMEUI_PARAM_CRASH_DIALOG,
628 FALSE);
630 gnome_vfs_init();
631 glade_init();
632 configure_camel_acct(root[USERNAME_KEY].getme(), root[SERVER_KEY].getme(),
633 root[RESYNC_FREQ_KEY].getmeint(), root[ENABLED_KEY].getmeint());
635 EvolutionStorage *evo_storage =
636 evolution_storage_new("ExchangeIT", TRUE);
638 ExchangeItStorage storage(evo_storage, storage_path,
639 root[USERNAME_KEY].getme(), root);
641 WvExcConnManager *conn_manager =
642 new WvExcConnManager(&storage, root, global_list);
644 evolution_storage_add_property_item(evo_storage, "Permissions...",
645 "Change permissions for this folder",
646 NULL);
648 g_signal_connect(evo_storage, "create_folder",
649 G_CALLBACK(create_folder_cb), &storage);
650 g_signal_connect(evo_storage, "remove_folder",
651 G_CALLBACK(remove_folder_cb), &storage);
652 //g_signal_connect(evo_storage, "xfer_folder",
653 // G_CALLBACK(xfer_folder_cb), &storage);
654 g_signal_connect(evo_storage, "show_folder_properties",
655 G_CALLBACK(show_properties_cb), &storage);
657 shell_component = evolution_shell_component_new(types, NULL, NULL, NULL,
658 NULL, NULL, NULL, NULL,
659 NULL, NULL, NULL);
661 g_signal_connect(shell_component, "owner_set",
662 G_CALLBACK(owner_set_cb),
663 evo_storage);
664 g_signal_connect(shell_component, "owner_unset",
665 G_CALLBACK(owner_unset_cb),
666 NULL);
667 g_signal_connect(shell_component, "interactive",
668 G_CALLBACK(interactive_cb),
669 NULL);
671 sync_evo(&storage);
673 /* register factories */
674 int ret =
675 bonobo_activation_active_server_register(
676 EXCHANGEIT_COMPONENT_ID,
677 bonobo_object_corba_objref(BONOBO_OBJECT(shell_component)));
679 if (ret != Bonobo_ACTIVATION_REG_SUCCESS)
681 g_message("Unable to activate Bonobo component");
682 goto failed;
685 // Initialize the account dialog handler stuff...
686 if (!setup_config(conn_manager))
687 goto failed;
689 conn_manager->connect(0); // connect with no commands,
691 bonobo_main();
693 WVRELEASE(glib_stream);
694 delete conn_manager;
696 return 0;
698 failed:
699 g_warning("\nCould not register Evolution ExchangeIT backend services.\n"
700 "This probably means another copy of "
701 "evolution-exchangeit-storage\nis already running.\n");
703 return 1;
706 /* extern end brace */