4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
22 #include <glib/gi18n.h>
24 #ifdef ENABLE_MAINTAINER_MODE
28 #include <libebackend/libebackend.h>
30 /* Forward Declarations */
31 void evolution_source_registry_migrate_basedir (void);
32 void evolution_source_registry_migrate_sources (void);
39 EDBusServerExitCode exit_code;
42 setlocale (LC_ALL, "");
43 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
44 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
46 #ifdef ENABLE_MAINTAINER_MODE
47 /* This is only to load gtk-modules, like
48 * bug-buddy's gnomesegvhandler, if possible */
49 gtk_init_check (&argc, &argv);
54 e_gdbus_templates_init_main_thread ();
57 /* Migrate user data from ~/.evolution to XDG base directories. */
58 evolution_source_registry_migrate_basedir ();
60 /* Migrate ESource data from GConf XML blobs to key files.
61 * Do this AFTER XDG base directory migration since the key
62 * files are saved according to XDG base directory settings. */
63 evolution_source_registry_migrate_sources ();
65 server = e_source_registry_server_new ();
67 /* Failure here is fatal. Don't even try to keep going. */
68 e_source_registry_server_load_all (
69 E_SOURCE_REGISTRY_SERVER (server), &error);
72 g_printerr ("%s\n", error->message);
73 g_object_unref (server);
77 g_print ("Server is up and running...\n");
79 /* Keep the server from quitting on its own.
80 * We don't have a way of tracking number of
81 * active clients, so once the server is up,
82 * it's up until the session bus closes. */
83 e_dbus_server_hold (server);
85 exit_code = e_dbus_server_run (server, FALSE);
87 g_object_unref (server);
89 if (exit_code == E_DBUS_SERVER_EXIT_RELOAD) {
90 const gchar *config_dir;
93 g_print ("Reloading...\n");
95 /* It's possible the Reload is called after restore, where
96 the ~/.config/evolution/sources directory can be missing,
97 thus create it, because e_server_side_source_get_user_dir()
98 may have its static variable already set to non-NULL value.
100 config_dir = e_get_user_config_dir ();
101 dirname = g_build_filename (config_dir, "sources", NULL);
102 g_mkdir_with_parents (dirname, 0700);