aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-01-22 05:23:30 +0800
committerChris Toshok <toshok@src.gnome.org>2004-01-22 05:23:30 +0800
commita455e65d39a3c9c2c7e95de44fd12d85d2761195 (patch)
treeb2c275611f8f54e5356b1cdc2d6f2aa31bab45a2 /addressbook
parent69c5b58a835f3a39916e9d6441acd60f6944fb79 (diff)
downloadgsoc2013-evolution-a455e65d39a3c9c2c7e95de44fd12d85d2761195.tar.gz
gsoc2013-evolution-a455e65d39a3c9c2c7e95de44fd12d85d2761195.tar.zst
gsoc2013-evolution-a455e65d39a3c9c2c7e95de44fd12d85d2761195.zip
new function.
2004-01-21 Chris Toshok <toshok@ximian.com> * gui/component/addressbook-component.c (addressbook_component_peek_gconf_client): new function. * gui/component/addressbook-component.h: add prototype for addressbook_component_peek_gconf_client. * gui/component/addressbook-migrate.c (migrate_completion_folders): more gross hacking. migrate the completion settings. (get_source_by_uri): function to search for an ESource given the entire uri. used for migrate_completion_folders. (migrate_ldap_servers): get_string_value -> get_string_child. same with get_integer_child. (get_string_child): rename to make it apparent it's a child, not a property. (get_integer_child): same. (addressbook_migrate): call migrate_completion_folders. svn path=/trunk/; revision=24357
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog20
-rw-r--r--addressbook/gui/component/addressbook-component.c11
-rw-r--r--addressbook/gui/component/addressbook-component.h3
-rw-r--r--addressbook/gui/component/addressbook-migrate.c168
4 files changed, 185 insertions, 17 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 875367ae08..09cdea572a 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,25 @@
2004-01-21 Chris Toshok <toshok@ximian.com>
+ * gui/component/addressbook-component.c
+ (addressbook_component_peek_gconf_client): new function.
+
+ * gui/component/addressbook-component.h: add prototype for
+ addressbook_component_peek_gconf_client.
+
+ * gui/component/addressbook-migrate.c
+ (migrate_completion_folders): more gross hacking. migrate the
+ completion settings.
+ (get_source_by_uri): function to search for an ESource given the
+ entire uri. used for migrate_completion_folders.
+ (migrate_ldap_servers): get_string_value -> get_string_child.
+ same with get_integer_child.
+ (get_string_child): rename to make it apparent it's a child, not a
+ property.
+ (get_integer_child): same.
+ (addressbook_migrate): call migrate_completion_folders.
+
+2004-01-21 Chris Toshok <toshok@ximian.com>
+
* gui/contact-editor/e-contact-editor.c (new_target_cb): call
widget_changed here too, since we're changing the destination.
diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c
index 51a76ceaee..1fa8c67f53 100644
--- a/addressbook/gui/component/addressbook-component.c
+++ b/addressbook/gui/component/addressbook-component.c
@@ -478,8 +478,7 @@ addressbook_component_init (AddressbookComponent *component)
priv = g_new0 (AddressbookComponentPrivate, 1);
- /* EPFIXME: Should use a custom one instead? Also we should add
- addressbook_component_peek_gconf_client(). */
+ /* EPFIXME: Should use a custom one instead? */
priv->gconf_client = gconf_client_get_default ();
priv->source_list = e_source_list_new_for_gconf (priv->gconf_client,
@@ -509,6 +508,14 @@ addressbook_component_peek (void)
return component;
}
+GConfClient*
+addressbook_component_peek_gconf_client (AddressbookComponent *component)
+{
+ g_return_val_if_fail (ADDRESSBOOK_IS_COMPONENT (component), NULL);
+
+ return component->priv->gconf_client;
+}
+
const char *
addressbook_component_peek_base_directory (AddressbookComponent *component)
{
diff --git a/addressbook/gui/component/addressbook-component.h b/addressbook/gui/component/addressbook-component.h
index 70cf548c22..76884b0bb8 100644
--- a/addressbook/gui/component/addressbook-component.h
+++ b/addressbook/gui/component/addressbook-component.h
@@ -57,7 +57,8 @@ GType addressbook_component_get_type (void);
AddressbookComponent *addressbook_component_peek (void);
-const char * addressbook_component_peek_base_directory (AddressbookComponent *component);
+GConfClient *addressbook_component_peek_gconf_client (AddressbookComponent *component);
+const char *addressbook_component_peek_base_directory (AddressbookComponent *component);
EActivityHandler *addressbook_component_peek_activity_handler (AddressbookComponent *component);
ESourceList *addressbook_component_peek_source_list (AddressbookComponent *component);
diff --git a/addressbook/gui/component/addressbook-migrate.c b/addressbook/gui/component/addressbook-migrate.c
index a693e768b0..79e21f4ed6 100644
--- a/addressbook/gui/component/addressbook-migrate.c
+++ b/addressbook/gui/component/addressbook-migrate.c
@@ -410,7 +410,7 @@ migrate_local_folders (AddressbookComponent *component, ESourceGroup *on_this_co
}
static char *
-get_string_value (xmlNode *node,
+get_string_child (xmlNode *node,
const char *name)
{
xmlNode *p;
@@ -433,7 +433,7 @@ get_string_value (xmlNode *node,
}
static int
-get_integer_value (xmlNode *node,
+get_integer_child (xmlNode *node,
const char *name,
int defval)
{
@@ -501,17 +501,17 @@ migrate_ldap_servers (AddressbookComponent *component, ESourceGroup *on_ldap_ser
GString *uri = g_string_new ("");
ESource *source;
- name = get_string_value (child, "name");
- description = get_string_value (child, "description");
- port = get_string_value (child, "port");
- host = get_string_value (child, "host");
- rootdn = get_string_value (child, "rootdn");
- scope = get_string_value (child, "scope");
- authmethod = get_string_value (child, "authmethod");
- ssl = get_string_value (child, "ssl");
- emailaddr = get_string_value (child, "emailaddr");
- binddn = get_string_value (child, "binddn");
- limit = get_integer_value (child, "limit", 100);
+ name = get_string_child (child, "name");
+ description = get_string_child (child, "description");
+ port = get_string_child (child, "port");
+ host = get_string_child (child, "host");
+ rootdn = get_string_child (child, "rootdn");
+ scope = get_string_child (child, "scope");
+ authmethod = get_string_child (child, "authmethod");
+ ssl = get_string_child (child, "ssl");
+ emailaddr = get_string_child (child, "emailaddr");
+ binddn = get_string_child (child, "binddn");
+ limit = get_integer_child (child, "limit", 100);
limitstr = g_strdup_printf ("%d", limit);
g_string_append_printf (uri,
@@ -556,6 +556,145 @@ migrate_ldap_servers (AddressbookComponent *component, ESourceGroup *on_ldap_ser
return TRUE;
}
+static ESource*
+get_source_by_uri (ESourceList *source_list, const char *uri)
+{
+ GSList *groups;
+ GSList *g;
+
+ groups = e_source_list_peek_groups (source_list);
+ if (!groups)
+ return NULL;
+
+ for (g = groups; g; g = g->next) {
+ GSList *sources;
+ GSList *s;
+ ESourceGroup *group = E_SOURCE_GROUP (g->data);
+
+ sources = e_source_group_peek_sources (group);
+ if (!sources)
+ continue;
+
+ for (s = sources; s; s = s->next) {
+ ESource *source = E_SOURCE (s->data);
+ char *source_uri = e_source_get_uri (source);
+ gboolean found = FALSE;
+
+ if (!strcmp (uri, source_uri))
+ found = TRUE;
+
+ g_free (source_uri);
+ if (found)
+ return source;
+ }
+ }
+
+ return NULL;
+}
+
+static gboolean
+migrate_completion_folders (AddressbookComponent *component, ESourceList *source_list)
+{
+ char *uris_xml = gconf_client_get_string (addressbook_component_peek_gconf_client (component),
+ "/apps/evolution/addressbook/completion/uris",
+ NULL);
+
+ printf ("trying to migrate completion folders\n");
+
+ if (uris_xml) {
+ xmlDoc *doc = xmlParseMemory (uris_xml, strlen (uris_xml));
+ xmlNode *root;
+ xmlNode *child;
+
+ if (!doc)
+ return FALSE;
+
+ dialog_set_folder_name (_("Autocompletion Settings"));
+
+ root = xmlDocGetRootElement (doc);
+ if (root == NULL || strcmp (root->name, "EvolutionFolderList") != 0) {
+ xmlFreeDoc (doc);
+ return FALSE;
+ }
+
+ for (child = root->children; child; child = child->next) {
+ if (!strcmp (child->name, "folder")) {
+ char *physical_uri = e_xml_get_string_prop_by_name (child, "physical-uri");
+ char *uri;
+ ESource *source;
+
+ /* if the physical uri is
+ file://... we need to convert the
+ path to the new directory
+ structure.
+
+ if the physical_uri is anything
+ else, we strip off the args
+ (anything after ;) before searching
+ for the uri. */
+
+ if (!strncmp (physical_uri, "file://", 7)) {
+ char *local_path = g_build_filename (g_get_home_dir (),
+ "/evolution/local/",
+ NULL);
+
+ if (!strncmp (physical_uri + 7, local_path, strlen (local_path))) {
+ char *path_extra;
+ char *path;
+
+ if (!strcmp (physical_uri + 7 + strlen (local_path), "Contacts"))
+ /* special case the ~/evolution/local/Contacts folder */
+ path_extra = "Personal";
+ else
+ path_extra = physical_uri + 7 + strlen (local_path);
+
+ path = g_build_filename (g_get_home_dir (),
+ "/.evolution/addressbook/local/OnThisComputer",
+ path_extra,
+ NULL);
+ uri = g_strdup_printf ("file://%s", path);
+ g_free (path);
+ }
+ else {
+ /* if they somehow created a folder that lies
+ outside the evolution folder tree, just pass
+ the uri straight on */
+ uri = g_strdup (physical_uri);
+ }
+
+ g_free (local_path);
+ }
+ else {
+ char *semi = strchr (physical_uri, ';');
+ if (semi)
+ uri = g_strndup (physical_uri, semi - physical_uri);
+ else
+ uri = g_strdup (physical_uri);
+ }
+
+ source = get_source_by_uri (source_list, uri);
+ if (source) {
+ e_source_set_property (source, "completion", "true");
+ }
+ else {
+ g_warning ("found completion folder with uri `%s' that "
+ "doesn't correspond to anything we migrated.", physical_uri);
+ }
+
+ g_free (physical_uri);
+ g_free (uri);
+ }
+ }
+
+ g_free (uris_xml);
+ }
+ else {
+ g_message ("no completion folder settings to migrate");
+ }
+
+ return TRUE;
+}
+
int
addressbook_migrate (AddressbookComponent *component, int major, int minor, int revision)
{
@@ -581,12 +720,13 @@ addressbook_migrate (AddressbookComponent *component, int major, int minor, int
(major == 0)) {
setup_progress_dialog ();
-
if (on_this_computer)
migrate_local_folders (component, on_this_computer);
if (on_ldap_servers)
migrate_ldap_servers (component, on_ldap_servers);
+ migrate_completion_folders (component, source_list);
+
dialog_close ();
}
}