aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-config-upgrade.c
blob: 4868d99bf7b147a04ef074ad144d2316c090bd60 (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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-upgrade.c - upgrade previous config versions
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 * Authors: Michael Zucchi <notzed@ximian.com>
 *      Jeffery Stedfast <fejj@ximian.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#include <config.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <ctype.h>

#include <glib.h>

#include <gconf/gconf.h>
#include <gconf/gconf-client.h>

#include <libedataserver/e-xml-utils.h>

#include "e-util/e-bconf-map.h"

#include "e-config-upgrade.h"

/* ********************************************************************** */
/*  Tables for bonobo conf -> gconf conversion                */
/* ********************************************************************** */

/* ********************************************************************** */

static e_gconf_map_t importer_elm_map[] = {
    /* /Importer/Elm */
    { "mail", "importer/elm/mail", E_GCONF_MAP_BOOL },
    { "mail-imported", "importer/elm/mail-imported", E_GCONF_MAP_BOOL },
    { NULL },
};

static e_gconf_map_t importer_pine_map[] = {
    /* /Importer/Pine */
    { "mail", "importer/elm/mail", E_GCONF_MAP_BOOL },
    { "address", "importer/elm/address", E_GCONF_MAP_BOOL },
    { NULL },
};

static e_gconf_map_t importer_netscape_map[] = {
    /* /Importer/Netscape */
    { "mail", "importer/netscape/mail", E_GCONF_MAP_BOOL },
    { "settings", "importer/netscape/settings", E_GCONF_MAP_BOOL },
    { "filters", "importer/netscape/filters", E_GCONF_MAP_BOOL },
    { NULL },
};

/* ********************************************************************** */

/* This grabs the defaults from the first view ... (?) */
static e_gconf_map_t shell_views_map[] = {
    /* /Shell/Views/0 */
    { "Width", "shell/view_defaults/width", E_GCONF_MAP_INT },
    { "Height", "shell/view_defaults/height", E_GCONF_MAP_INT },
    { "ViewPanedPosition", "shell/view_defaults/folder_bar/width", E_GCONF_MAP_INT },
    { NULL },
};

static e_gconf_map_t offlinefolders_map[] = {
    /* /OfflineFolders */
    { "paths", "shell/offline/folder_paths", E_GCONF_MAP_ANYLIST },
    { NULL },
};

static e_gconf_map_t shell_map[] = {
    /* /Shell */
    { "StartOffline", "shell/start_offline", E_GCONF_MAP_BOOL },
    { NULL },
};

/* ********************************************************************** */

static e_gconf_map_t addressbook_map[] = {
    /* /Addressbook */
    { "select_names_uri", "addressbook/select_names/last_used_uri", E_GCONF_MAP_STRING },
    { NULL },
};

static e_gconf_map_t addressbook_completion_map[] = {
    /* /Addressbook/Completion */
    { "uris", "addressbook/completion/uris", E_GCONF_MAP_STRING },
    { NULL },
};

/* ********************************************************************** */

static e_gconf_map_t general_map[] = {
    /* /General */
    { "CategoryMasterList", "general/category_master_list", E_GCONF_MAP_STRING }
};

/* ********************************************************************** */

static e_gconf_map_list_t remap_list[] = {
    { "/Importer/Elm", importer_elm_map },
    { "/Importer/Pine", importer_pine_map },
    { "/Importer/Netscape", importer_netscape_map },

    { "/Shell", shell_map },
    { "/Shell/Views/0", shell_views_map },
    { "/OfflineFolders", offlinefolders_map },

    { "/Addressbook", addressbook_map },
    { "/Addressbook/Completion", addressbook_completion_map },

    { "/General", general_map },

    { NULL },
};

int
e_config_upgrade(int major, int minor, int revision)
{
    xmlDocPtr config_doc;
    char *conf_file;
    int res = 0;

    conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL);
    config_doc = e_xml_parse_file (conf_file);
    g_free (conf_file);

    if (config_doc && major <=1 && minor < 3) {
        GConfClient *gconf;

        /* move bonobo config to gconf */
        gconf = gconf_client_get_default ();

        res = e_bconf_import (gconf, config_doc, remap_list);
        if (res != 0)
            g_warning("Could not move config from bonobo-conf to gconf");

        g_object_unref (gconf);

        xmlFreeDoc(config_doc);
    }

    return res;
}