diff options
author | Chris Toshok <toshok@ximian.com> | 2004-04-10 01:29:51 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2004-04-10 01:29:51 +0800 |
commit | e68394b0d08bd873b39829da8a54ba08177b76e8 (patch) | |
tree | 2ad52a40cb1cd9912e883fe96a9055ed8faaa14a /addressbook/gui/component/addressbook-migrate.c | |
parent | 97634e4d349969c7309b96cdbd4466d743ee9afb (diff) | |
download | gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.tar gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.tar.gz gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.tar.bz2 gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.tar.lz gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.tar.xz gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.tar.zst gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.zip |
use the new e_destination_export_to_vcard_attribute call to build up the
2004-04-09 Chris Toshok <toshok@ximian.com>
* importers/evolution-ldif-importer.c (resolve_list_card): use the
new e_destination_export_to_vcard_attribute call to build up the
attributes.
* importers/evolution-vcard-importer.c (process_item_fn): if we're
importing a vcard that we wrote out previously containing xml in
the EMAIL attributes, DTRT and strip it out and use
e_destination_export_to_vcard_attribute to build up the proper
attribute.
* util/Makefile.am (libeabutil_la_SOURCES): remove
eab-destination.[ch] and add e-destination.[ch].
* printing/e-contact-print.c (e_contact_print_contact): we don't
have to worry about the "<?xml..." EMAIL fields anymore.
* gui/widgets/eab-gui-util.c (eab_send_contact_list): just use the
value as the address (since that's what it is) in the list case.
* gui/widgets/eab-contact-display.c (render_contact_list): remove
the EABDestination stuff from here.
(eab_contact_display_render_compact): same.
* gui/widgets/e-minicard.c (activiate_editor): fix warnings - use
EAB_EDITOR instead of G_OBJECT.
(add_field): we don't have to worry about the "<?xml..." EMAIL
fields anymore.
(remodel): same.
* gui/widgets/e-addressbook-treeview-adapter.c
(adapter_get_value): we don't have to worry about the "<?xml..."
EMAIL fields anymore.
* gui/widgets/e-addressbook-table-adapter.c
(addressbook_value_at): we don't have to worry about the
"<?xml..." EMAIL fields anymore.
* gui/contact-list-editor/e-contact-list-model.c
(contact_list_value_at): eab->e.
(contact_list_model_dispose): we're not a GtkObject, we're a
GObject. rename _destroy to _dispose, and chain up to the parent
class's ::dispose.
(e_contact_list_model_class_init): GtkObject -> GObject, and
destroy -> dispose.
(e_contact_list_model_init): GtkObject -> GObject, and EAB -> E.
(e_contact_list_model_add_destination): EAB -> E.
(e_contact_list_model_add_email): same.
(e_contact_list_model_add_contact): same.
(e_contact_list_model_get_destination): same.
* gui/contact-list-editor/e-contact-list-editor.c
(table_drag_data_received_cb): add email num arg to
e_contact_list_model_add_contact.
(extract_info): fill in the vcard attributes instead of just
generating xml.
(fill_in_info): extract the values from the vcard attributes.
* gui/component/select-names/e-select-names-text-model.c
(e_select_names_text_model_insert_length): eab->e, and don't
sometimes copy, sometimes ::new. always ::new.
(e_select_names_text_model_delete): same.
(e_select_names_text_model_obj_count): same.
(nth_obj_index): same.
* gui/component/select-names/e-select-names-table-model.c
(fill_in_info): eab -> e.
* gui/component/select-names/e-select-names-popup.c
(make_contact_editor_cb): eab -> e.
(change_email_num_cb): same.
(toggle_html_mail_cb): same.
(populate_popup_contact): same, and remove code that checks for
<?xml, then imports the EDestination.
(quick_add_cb): eab -> e.
(populate_popup_nocontact): same.
(e_select_names_populate_popup): same.
* gui/component/select-names/e-select-names-model.h: eab -> e, and
remove prototypes for nuked functions.
* gui/component/select-names/e-select-names-model.c
(destination_changed_proxy, send_changed, connect_destination,
disconnect_destination): nuke.
(e_select_names_model_duplicate): EAB -> E.
(e_select_names_model_get_textification): same.
(e_select_names_model_get_address_text): same.
(e_select_names_model_get_destination): same.
(e_select_names_model_export_destinationv): same.
(send_changed): same.
(e_select_names_model_import_destinationv): same.
(e_select_names_model_get_contact): same.
(e_select_names_model_contains): same.
(e_select_names_model_insert): same, and remove call to
connect_destination.
(e_select_names_model_append): same.
(e_select_names_model_replace): same, and remove call to
disconnect/connect_destination.
(e_select_names_model_delete): same.
(delete_all_iter): nuke.
(e_select_names_model_delete_all): use g_object_unref for the
foreach call.
(e_select_names_model_merge): EAB -> E.
(e_select_names_model_name_pos): same.
(e_select_names_model_name_pos): same.
(e_select_names_model_load_all_contacts): nuke.
(e_select_names_model_cancel_all_contact_load): nuke.
* gui/component/select-names/e-select-names-manager.c
(clean_cb, focus_in_cb, focus_out_cb, completion_popup_cb): nuke.
(completion_handler): EAB -> E, and the signals are gone.
* gui/component/select-names/e-select-names-completion.c: in
general, s/eab_dest/e_dest and s/EABDest/EDest.
(e_select_names_completion_got_book_view_cb): move the
e_book_view_start to below the assignment of
sequence_complete_received, just to put my mind at ease.
(e_select_names_completion_stop_query): un-#if notyet the call to
e_book_cancel.
(e_select_names_completion_start_query): free the waiting_query
before assigning to it.
* gui/component/select-names/e-select-names-bonobo.c
(entry_set_property_fn): remove calls to
e_select_names_model_load_all_contacts, since that function is
dead.
* gui/component/addressbook-migrate.c (setup_progress_dialog):
take the label to display to the user as an arg.
(migrate_contact_lists_for_local_folders): loop over all contacts
in all local addressbooks looking for ones that have <?xml in
their EMAIL attributes. for the ones we find, call
e_destination_export_to_vcard_attribute to build up the proper
attribute.
(addressbook_migrate): add in a clause for all versions under
1.5.7 to convert contact lists. also, move the unrefs of the
sources/groups to outside the if, as they're created outside it.
* gui/component/Makefile.am (INCLUDES): remove the
addressbook/backend/ dirs, since libebook isn't there anymore
(nothing is, actually). Add addressbook/util/.
svn path=/trunk/; revision=25390
Diffstat (limited to 'addressbook/gui/component/addressbook-migrate.c')
-rw-r--r-- | addressbook/gui/component/addressbook-migrate.c | 123 |
1 files changed, 102 insertions, 21 deletions
diff --git a/addressbook/gui/component/addressbook-migrate.c b/addressbook/gui/component/addressbook-migrate.c index 1878b6504b..7c81a91d17 100644 --- a/addressbook/gui/component/addressbook-migrate.c +++ b/addressbook/gui/component/addressbook-migrate.c @@ -22,6 +22,7 @@ #include <glib.h> #include <string.h> #include "addressbook-migrate.h" +#include "e-destination.h" #include <libebook/e-book-async.h> #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> @@ -49,7 +50,7 @@ typedef struct { } MigrationContext; static void -setup_progress_dialog (MigrationContext *context) +setup_progress_dialog (MigrationContext *context, const char *str) { GtkWidget *vbox, *hbox, *w; @@ -62,9 +63,7 @@ setup_progress_dialog (MigrationContext *context) gtk_widget_show (vbox); gtk_container_add (GTK_CONTAINER (context->window), vbox); - w = gtk_label_new (_("The location and hierarchy of the Evolution contact " - "folders has changed since Evolution 1.x.\n\nPlease be " - "patient while Evolution migrates your folders...")); + w = gtk_label_new (str); gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_widget_show (w); gtk_box_pack_start_defaults (GTK_BOX (vbox), w); @@ -735,6 +734,78 @@ migrate_completion_folders (MigrationContext *context) return TRUE; } +static void +migrate_contact_lists_for_local_folders (MigrationContext *context, ESourceGroup *on_this_computer) +{ + GSList *sources, *s; + + sources = e_source_group_peek_sources (on_this_computer); + for (s = sources; s; s = s->next) { + ESource *source = s->data; + EBook *book; + EBookQuery *query; + GList *l, *contacts; + int num_contacts, num_converted; + + book = e_book_new (); + if (!e_book_load_source (book, source, TRUE, NULL)) { + char *uri = e_source_get_uri (source); + g_warning ("failed to migrate contact lists for source %s", uri); + g_free (uri); + continue; + } + + query = e_book_query_any_field_contains (""); + + e_book_get_contacts (book, query, &contacts, NULL); + + num_converted = 0; + num_contacts = g_list_length (contacts); + for (l = contacts; l; l = l->next) { + EContact *contact = l->data; + GError *e = NULL; + GList *attrs, *attr; + gboolean converted = FALSE; + + attrs = e_contact_get_attributes (contact, E_CONTACT_EMAIL); + for (attr = attrs; attr; attr = attr->next) { + EVCardAttribute *a = attr->data; + GList *v = e_vcard_attribute_get_values (a); + + if (v && v->data) { + if (!strncmp ((char*)v->data, "<?xml", 5)) { + EDestination *dest = e_destination_import ((char*)v->data); + + e_destination_export_to_vcard_attribute (dest, a); + + g_object_unref (dest); + + converted = TRUE; + } + } + } + + if (converted) { + e_contact_set_attributes (contact, E_CONTACT_EMAIL, attrs); + + if (!e_book_commit_contact (book, + contact, + &e)) + g_warning ("contact add failed: `%s'", e->message); + } + + num_converted ++; + + dialog_set_progress (context, (double)num_converted / num_contacts); + } + + g_list_foreach (contacts, (GFunc)g_object_unref, NULL); + g_list_free (contacts); + + g_object_unref (book); + } +} + static MigrationContext* migration_context_new (AddressbookComponent *component) { @@ -774,35 +845,45 @@ addressbook_migrate (AddressbookComponent *component, int major, int minor, int groups/sources. */ create_groups (context, &on_this_computer, &on_ldap_servers, &personal_source); - if (major <= 1) { + if (major == 1) { - if (/* we're <= 1.5.2 */ - (major == 1 - && ((minor == 5 && revision <= 2) - || (minor < 5))) - || - /* we're 0.x */ - (major == 0)) { + if (minor < 5 || (minor == 5 && revision <= 2)) { /* initialize our dialog */ - setup_progress_dialog (context); + setup_progress_dialog (context, + _("The location and hierarchy of the Evolution contact " + "folders has changed since Evolution 1.x.\n\nPlease be " + "patient while Evolution migrates your folders...")); - if (on_this_computer) { + if (on_this_computer) migrate_local_folders (context, on_this_computer, personal_source); - g_object_unref (on_this_computer); - } - if (on_ldap_servers) { + if (on_ldap_servers) migrate_ldap_servers (context, on_ldap_servers); - g_object_unref (on_ldap_servers); - } - if (personal_source) - g_object_unref (personal_source); migrate_completion_folders (context); dialog_close (context); } + + if (minor <= 5 || (minor == 5 && revision <= 6)) { + setup_progress_dialog (context, + _("The format of mailing list contacts has changed.\n\n" + "Please be patient while Evolution migrates your " + "folders...")); + + migrate_contact_lists_for_local_folders (context, on_this_computer); + + dialog_close (context); + } } + if (on_this_computer) + g_object_unref (on_this_computer); + if (on_ldap_servers) + g_object_unref (on_ldap_servers); + if (personal_source) + g_object_unref (personal_source); + + migration_context_free (context); return TRUE; |