Bug 677687 - Broken migration of "namespace" IMAP setting
[platform/upstream/evolution-data-server.git] / services / evolution-source-registry / evolution-source-registry.c
1 /*
2  * e-source-registry.c
3  *
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.
8  *
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.
13  *
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/>
16  *
17  */
18
19 #include <config.h>
20 #include <locale.h>
21 #include <stdlib.h>
22 #include <glib/gi18n.h>
23
24 #include <libebackend/libebackend.h>
25
26 /* Forward Declarations */
27 void evolution_source_registry_migrate_basedir (void);
28 void evolution_source_registry_migrate_sources (void);
29
30 gint
31 main (gint argc,
32       gchar **argv)
33 {
34         EDBusServer *server;
35         EDBusServerExitCode exit_code;
36         GError *error = NULL;
37
38         setlocale (LC_ALL, "");
39         bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
40         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
41
42         g_type_init ();
43
44 reload:
45         /* Migrate user data from ~/.evolution to XDG base directories. */
46         evolution_source_registry_migrate_basedir ();
47
48         /* Migrate ESource data from GConf XML blobs to key files.
49          * Do this AFTER XDG base directory migration since the key
50          * files are saved according to XDG base directory settings. */
51         evolution_source_registry_migrate_sources ();
52
53         server = e_source_registry_server_new ();
54
55         /* Failure here is fatal.  Don't even try to keep going. */
56         e_source_registry_server_load_all (
57                 E_SOURCE_REGISTRY_SERVER (server), &error);
58
59         if (error != NULL) {
60                 g_printerr ("%s\n", error->message);
61                 g_object_unref (server);
62                 exit (EXIT_FAILURE);
63         }
64
65         g_print ("Server is up and running...\n");
66
67         /* Keep the server from quitting on its own.
68          * We don't have a way of tracking number of
69          * active clients, so once the server is up,
70          * it's up until the session bus closes. */
71         e_dbus_server_hold (server);
72
73         exit_code = e_dbus_server_run (server, FALSE);
74
75         g_object_unref (server);
76
77         if (exit_code == E_DBUS_SERVER_EXIT_RELOAD) {
78                 g_print ("Reloading...\n");
79                 goto reload;
80         }
81
82         g_print ("Bye.\n");
83
84         return 0;
85 }