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 | |
parent | 97634e4d349969c7309b96cdbd4466d743ee9afb (diff) | |
download | gsoc2013-evolution-e68394b0d08bd873b39829da8a54ba08177b76e8.tar.gz 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
23 files changed, 521 insertions, 475 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 4550e08d32..177485a04b 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,146 @@ +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/. + 2004-04-09 Dan Winship <danw@ximian.com> * gui/component/addressbook.c (addressbook_new_control): create an diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 938385802f..5bd4d381e4 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -7,11 +7,10 @@ INCLUDES = \ -I$(top_srcdir)/shell \ -I$(top_builddir)/shell \ -I$(top_srcdir)/widgets/misc \ + -I$(top_srcdir)/addressbook/util \ -I$(top_srcdir)/addressbook/gui/contact-editor \ -I$(top_srcdir)/addressbook/gui/contact-list-editor \ -I$(top_srcdir)/addressbook/gui/widgets \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ -I$(top_builddir)/a11y/addressbook \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ 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; diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c index 1977abe95f..871bb8b3f6 100644 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ b/addressbook/gui/component/select-names/e-select-names-bonobo.c @@ -159,7 +159,6 @@ entry_set_property_fn (BonoboPropertyBag *bag, g_assert (model != NULL); e_entry_set_text (E_ENTRY (w), BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_load_all_contacts (model, NULL); break; } @@ -170,7 +169,6 @@ entry_set_property_fn (BonoboPropertyBag *bag, g_assert (model != NULL); e_select_names_model_import_destinationv (model, BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_load_all_contacts (model, NULL); break; } diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c index e3fa256dc8..2bf0341e40 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -36,7 +36,7 @@ #include <libebook/e-contact.h> #include <addressbook/util/eab-book-util.h> -#include <addressbook/util/eab-destination.h> +#include <addressbook/util/e-destination.h> #include <addressbook/gui/merging/eab-contact-compare.h> #include <e-util/e-sexp.h> @@ -97,7 +97,7 @@ static FILE *out; */ typedef gchar *(*BookQuerySExp) (ESelectNamesCompletion *); -typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EABDestination *); +typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EDestination *); static int utf8_casefold_collate_len (const gchar *str1, const gchar *str2, int len) @@ -127,16 +127,16 @@ our_match_destroy (ECompletionMatch *match) } static ECompletionMatch * -make_match (EABDestination *dest, const gchar *menu_form, double score) +make_match (EDestination *dest, const gchar *menu_form, double score) { ECompletionMatch *match; #if notyet - EContact *contact = eab_destination_get_contact (dest); + EContact *contact = e_destination_get_contact (dest); #endif - match = e_completion_match_new (eab_destination_get_name (dest), menu_form, score); + match = e_completion_match_new (e_destination_get_name (dest), menu_form, score); - e_completion_match_set_text (match, eab_destination_get_name (dest), menu_form); + e_completion_match_set_text (match, e_destination_get_name (dest), menu_form); /* Reject any match that has null text fields. */ if (! (e_completion_match_get_match_text (match) && e_completion_match_get_menu_text (match))) { @@ -152,10 +152,9 @@ make_match (EABDestination *dest, const gchar *menu_form, double score) match->sort_major = 0; #endif - match->sort_minor = eab_destination_get_email_num (dest); + match->sort_minor = e_destination_get_email_num (dest); - match->user_data = dest; - g_object_ref (dest); + match->user_data = g_object_ref (dest); match->destroy = our_match_destroy; @@ -175,11 +174,11 @@ sexp_nickname (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_nickname (ESelectNamesCompletion *comp, EABDestination *dest) +match_nickname (ESelectNamesCompletion *comp, EDestination *dest) { ECompletionMatch *match = NULL; gint len; - EContact *contact = eab_destination_get_contact (dest); + EContact *contact = e_destination_get_contact (dest); double score; const char *nickname; @@ -197,11 +196,11 @@ match_nickname (ESelectNamesCompletion *comp, EABDestination *dest) if (len == g_utf8_strlen (nickname, -1)) /* boost score on an exact match */ score *= 10; - name = eab_destination_get_name (dest); + name = e_destination_get_name (dest); if (name && *name) - str = g_strdup_printf ("'%s' %s <%s>", nickname, name, eab_destination_get_email (dest)); + str = g_strdup_printf ("'%s' %s <%s>", nickname, name, e_destination_get_email (dest)); else - str = g_strdup_printf ("'%s' <%s>", nickname, eab_destination_get_email (dest)); + str = g_strdup_printf ("'%s' <%s>", nickname, e_destination_get_email (dest)); match = make_match (dest, str, score); g_free (str); @@ -221,17 +220,17 @@ sexp_email (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_email (ESelectNamesCompletion *comp, EABDestination *dest) +match_email (ESelectNamesCompletion *comp, EDestination *dest) { ECompletionMatch *match; gint len = strlen (comp->priv->query_text); - const gchar *name = eab_destination_get_name (dest); - const gchar *email = eab_destination_get_email (dest); + const gchar *name = e_destination_get_name (dest); + const gchar *email = e_destination_get_email (dest); double score; if (email && !utf8_casefold_collate_len (comp->priv->query_text, email, len) - && !eab_destination_is_evolution_list (dest)) { + && !e_destination_is_evolution_list (dest)) { gchar *str; @@ -306,7 +305,7 @@ sexp_name (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_name (ESelectNamesCompletion *comp, EABDestination *dest) +match_name (ESelectNamesCompletion *comp, EDestination *dest) { ECompletionMatch *final_match = NULL; gchar *menu_text = NULL; @@ -319,13 +318,13 @@ match_name (ESelectNamesCompletion *comp, EABDestination *dest) gboolean have_given, have_additional, have_family; EContactName *contact_name; - contact = eab_destination_get_contact (dest); + contact = e_destination_get_contact (dest); contact_name = e_contact_get (contact, E_CONTACT_NAME); if (!contact_name) return NULL; - email = eab_destination_get_email (dest); + email = e_destination_get_email (dest); match = eab_contact_compare_name_to_string_full (contact, comp->priv->query_text, TRUE /* yes, allow partial matches */, NULL, &first_match, &match_len); @@ -411,7 +410,7 @@ sexp_file_as (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_file_as (ESelectNamesCompletion *comp, EABDestination *dest) +match_file_as (ESelectNamesCompletion *comp, EDestination *dest) { const gchar *name; const gchar *email; @@ -420,8 +419,8 @@ match_file_as (ESelectNamesCompletion *comp, EABDestination *dest) double score = 0.00001; ECompletionMatch *match; - name = eab_destination_get_name (dest); - email = eab_destination_get_email (dest); + name = e_destination_get_name (dest); + email = e_destination_get_email (dest); if (!(name && *name)) return NULL; @@ -513,13 +512,13 @@ book_query_sexp (ESelectNamesCompletion *comp) * string that applies to a given destination. */ static ECompletionMatch * -book_query_score (ESelectNamesCompletion *comp, EABDestination *dest) +book_query_score (ESelectNamesCompletion *comp, EDestination *dest) { ECompletionMatch *best_match = NULL; gint i; g_return_val_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp), NULL); - g_return_val_if_fail (EAB_IS_DESTINATION (dest), NULL); + g_return_val_if_fail (E_IS_DESTINATION (dest), NULL); if (! (comp->priv->query_text && *comp->priv->query_text)) return NULL; @@ -528,7 +527,7 @@ book_query_score (ESelectNamesCompletion *comp, EABDestination *dest) ECompletionMatch *this_match = NULL; - if (book_queries[i].tester && eab_destination_get_contact (dest)) { + if (book_queries[i].tester && e_destination_get_contact (dest)) { this_match = book_queries[i].tester (comp, dest); } @@ -555,9 +554,9 @@ book_query_process_card_list (ESelectNamesCompletion *comp, const GList *contact if (comp->priv->match_contact_lists) { - EABDestination *dest = eab_destination_new (); + EDestination *dest = e_destination_new (); ECompletionMatch *match; - eab_destination_set_contact (dest, contact, 0); + e_destination_set_contact (dest, contact, 0); match = book_query_score (comp, dest); if (match && match->score > 0) { e_completion_found_match (E_COMPLETION (comp), match); @@ -575,11 +574,11 @@ book_query_process_card_list (ESelectNamesCompletion *comp, const GList *contact GList *iter; gint i; for (i=0, iter = email; iter; ++i, iter = iter->next) { - EABDestination *dest = eab_destination_new (); + EDestination *dest = e_destination_new (); gchar *e; ECompletionMatch *match; - eab_destination_set_contact (dest, contact, i); + e_destination_set_contact (dest, contact, i); e = iter->data; if (e && *e) { @@ -822,9 +821,9 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo G_CALLBACK (e_select_names_completion_seq_complete_cb), book_data); - e_book_view_start (view); - book_data->sequence_complete_received = FALSE; + + e_book_view_start (view); } static void @@ -838,8 +837,7 @@ e_select_names_completion_contacts_added_cb (EBookView *book_view, const GList * /* Save the list of matching cards. */ while (cards) { - book_data->cached_cards = g_list_prepend (book_data->cached_cards, cards->data); - g_object_ref (cards->data); + book_data->cached_cards = g_list_prepend (book_data->cached_cards, g_object_ref (cards->data)); cards = g_list_next (cards); } } @@ -872,7 +870,9 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus book_data->cache_complete = TRUE; if (out) - fprintf (out, "\tending search, book_data->cache_complete == %d\n", book_data->cache_complete); + fprintf (out, "\tending search, book_data->cache_complete == %d, cached_cards = %p\n", + book_data->cache_complete, + book_data->cached_cards); if (!book_data->sequence_complete_received) { book_data->sequence_complete_received = TRUE; @@ -920,9 +920,7 @@ e_select_names_completion_stop_query (ESelectNamesCompletion *comp) for (l = comp->priv->book_data; l; l = l->next) { ESelectNamesCompletionBookData *book_data = l->data; if (book_data->book_view_tag) { -#if notyet - e_book_cancel (book_data->book, book_data->book_view_tag); -#endif + e_book_cancel (book_data->book, NULL); book_data->book_view_tag = 0; } if (book_data->book_view) { @@ -1035,9 +1033,8 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar comp->priv->query_text = NULL; } } else { - + g_free (comp->priv->waiting_query); comp->priv->waiting_query = g_strdup (query_text); - } } diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c index 1b7cbbb38e..d78ac0aef6 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ b/addressbook/gui/component/select-names/e-select-names-manager.c @@ -25,7 +25,7 @@ #include "e-select-names-completion.h" #include "e-select-names-popup.h" #include <addressbook/util/eab-book-util.h> -#include <addressbook/util/eab-destination.h> +#include <addressbook/util/e-destination.h> #include "addressbook/gui/component/addressbook.h" #include <bonobo/bonobo-object.h> @@ -153,75 +153,19 @@ populate_popup_cb (EEntry *eentry, GdkEventButton *ev, gint pos, GtkWidget *menu e_select_names_populate_popup (menu, text_model, ev, pos, GTK_WIDGET (eentry)); } -#if 0 -static gboolean -clean_cb (gpointer ptr) -{ - ESelectNamesManagerEntry *entry = ptr; - - e_select_names_model_clean (entry->model, TRUE); - entry->cleaning_tag = 0; - return FALSE; -} -#endif - -static gint -focus_in_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) -{ - ESelectNamesManagerEntry *entry = user_data; - - if (entry->cleaning_tag) { - g_source_remove (entry->cleaning_tag); - entry->cleaning_tag = 0; - } - - e_select_names_model_cancel_all_contact_load (entry->model); - - return FALSE; -} - -static gint -focus_out_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) -{ -#if 0 - /* XXX fix me */ - ESelectNamesManagerEntry *entry = user_data; - gboolean visible = e_entry_completion_popup_is_visible (entry->entry); - - if (! visible) { - e_select_names_model_load_all_contacts (entry->model, entry->manager->completion_book, 100); - if (entry->cleaning_tag == 0) - entry->cleaning_tag = gtk_timeout_add (100, clean_cb, entry); - } -#endif - return FALSE; -} - -static void -completion_popup_cb (EEntry *w, gint visible, gpointer user_data) -{ -#if 0 - /* XXX fix me */ - ESelectNamesManagerEntry *entry = user_data; - - if (!visible && !GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (entry->entry->canvas))) - e_select_names_model_load_all_contacts (entry->model, entry->manager->completion_book, 0); -#endif -} - static void completion_handler (EEntry *entry, ECompletionMatch *match) { ESelectNamesManagerEntry *mgr_entry; ESelectNamesTextModel *text_model; - EABDestination *dest; + EDestination *dest; gint i, pos, start_pos, len; if (match == NULL || match->user_data == NULL) return; mgr_entry = get_entry_info (entry); - dest = EAB_DESTINATION (match->user_data); + dest = E_DESTINATION (match->user_data); /* Sometimes I really long for garbage collection. Reference counting makes you feel 31337, but sometimes it is just a @@ -287,21 +231,6 @@ e_select_names_manager_entry_new (ESelectNamesManager *manager, ESelectNamesMode G_CALLBACK (populate_popup_cb), entry); - g_signal_connect (entry->entry->canvas, - "focus_in_event", - G_CALLBACK (focus_in_cb), - entry); - - g_signal_connect (entry->entry->canvas, - "focus_out_event", - G_CALLBACK (focus_out_cb), - entry); - - g_signal_connect (entry->entry, - "completion_popup", - G_CALLBACK (completion_popup_cb), - entry); - g_object_set_data (G_OBJECT (entry->entry), "entry_info", entry); g_object_set_data (G_OBJECT (entry->entry), "select_names_model", model); g_object_set_data (G_OBJECT (entry->entry), "select_names_text_model", text_model); diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index 74bda7a74b..506eb40124 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -41,7 +41,7 @@ struct _ESelectNamesModelPrivate { gchar *id; gchar *title; - GList *data; /* of EABDestination */ + GList *data; /* of EDestination */ gint limit; @@ -157,12 +157,6 @@ e_select_names_model_changed (ESelectNamesModel *model) } } -static void -destination_changed_proxy (EABDestination *dest, gpointer closure) -{ - e_select_names_model_changed (E_SELECT_NAMES_MODEL (closure)); -} - /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ ESelectNamesModel * @@ -183,7 +177,7 @@ e_select_names_model_duplicate (ESelectNamesModel *old) model->priv->title = g_strdup (old->priv->title); for (iter = old->priv->data; iter != NULL; iter = g_list_next (iter)) { - EABDestination *dup = eab_destination_copy (EAB_DESTINATION (iter->data)); + EDestination *dup = e_destination_copy (E_DESTINATION (iter->data)); e_select_names_model_append (model, dup); } @@ -211,8 +205,8 @@ e_select_names_model_get_textification (ESelectNamesModel *model, const char *se GList *iter = model->priv->data; while (iter) { - EABDestination *dest = EAB_DESTINATION (iter->data); - strv[i] = (gchar *) eab_destination_get_textrep (dest, FALSE); + EDestination *dest = E_DESTINATION (iter->data); + strv[i] = (gchar *) e_destination_get_textrep (dest, FALSE); ++i; iter = g_list_next (iter); } @@ -251,8 +245,8 @@ e_select_names_model_get_address_text (ESelectNamesModel *model, const char *sep GList *iter = model->priv->data; while (iter) { - EABDestination *dest = EAB_DESTINATION (iter->data); - strv[i] = (gchar *) eab_destination_get_address (dest); + EDestination *dest = E_DESTINATION (iter->data); + strv[i] = (gchar *) e_destination_get_address (dest); if (strv[i]) ++i; iter = g_list_next (iter); @@ -303,57 +297,51 @@ e_select_names_model_at_limit (ESelectNamesModel *model) return model->priv->limit >= 0 && g_list_length (model->priv->data) >= model->priv->limit; } -const EABDestination * +const EDestination * e_select_names_model_get_destination (ESelectNamesModel *model, gint index) { g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); - return EAB_DESTINATION (g_list_nth_data (model->priv->data, index)); + return E_DESTINATION (g_list_nth_data (model->priv->data, index)); } gchar * e_select_names_model_export_destinationv (ESelectNamesModel *model) { - EABDestination **destv; + EDestination **destv; gchar *str; gint i, len = 0; GList *j; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); len = g_list_length (model->priv->data); - destv = g_new0 (EABDestination *, len+1); + destv = g_new0 (EDestination *, len+1); for (i=0, j = model->priv->data; j != NULL; j = g_list_next (j)) { - EABDestination *dest = EAB_DESTINATION (j->data); + EDestination *dest = E_DESTINATION (j->data); if (dest) destv[i++] = dest; } - str = eab_destination_exportv (destv); + str = e_destination_exportv (destv); g_free (destv); return str; } -static void send_changed (EABDestination *dest, EContact *contact, gpointer closure) -{ - ESelectNamesModel *model = closure; - e_select_names_model_changed (model); -} - void e_select_names_model_import_destinationv (ESelectNamesModel *model, gchar *destinationv) { - EABDestination **destv; + EDestination **destv; gint i; g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - destv = eab_destination_importv (destinationv); + destv = e_destination_importv (destinationv); e_select_names_model_delete_all (model); @@ -361,7 +349,6 @@ e_select_names_model_import_destinationv (ESelectNamesModel *model, return; for (i = 0; destv[i]; i++) { - eab_destination_use_contact (destv[i], send_changed, model); e_select_names_model_append (model, destv[i]); } g_free (destv); @@ -370,21 +357,21 @@ e_select_names_model_import_destinationv (ESelectNamesModel *model, EContact * e_select_names_model_get_contact (ESelectNamesModel *model, gint index) { - const EABDestination *dest; + const EDestination *dest; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); dest = e_select_names_model_get_destination (model, index); - return dest ? eab_destination_get_contact (dest) : NULL; + return dest ? e_destination_get_contact (dest) : NULL; } const gchar * e_select_names_model_get_string (ESelectNamesModel *model, gint index) { - const EABDestination *dest; + const EDestination *dest; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); @@ -392,34 +379,19 @@ e_select_names_model_get_string (ESelectNamesModel *model, gint index) dest = e_select_names_model_get_destination (model, index); - return dest ? eab_destination_get_textrep (dest, FALSE) : ""; -} - -static void -connect_destination (ESelectNamesModel *model, EABDestination *dest) -{ - g_signal_connect (dest, - "changed", - G_CALLBACK (destination_changed_proxy), - model); -} - -static void -disconnect_destination (ESelectNamesModel *model, EABDestination *dest) -{ - g_signal_handlers_disconnect_by_func (dest, destination_changed_proxy, model); + return dest ? e_destination_get_textrep (dest, FALSE) : ""; } gboolean -e_select_names_model_contains (ESelectNamesModel *model, const EABDestination *dest) +e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest) { GList *iter; g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); - g_return_val_if_fail (EAB_IS_DESTINATION (dest), FALSE); + g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - if (iter->data != NULL && eab_destination_equal (dest, EAB_DESTINATION (iter->data))) + if (iter->data != NULL && e_destination_equal (dest, E_DESTINATION (iter->data))) return TRUE; } @@ -427,12 +399,12 @@ e_select_names_model_contains (ESelectNamesModel *model, const EABDestination *d } void -e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestination *dest) +e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest) { g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (0 <= index && index <= g_list_length (model->priv->data)); - g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); + g_return_if_fail (dest && E_IS_DESTINATION (dest)); if (e_select_names_model_at_limit (model)) { /* FIXME: This is bad. */ @@ -440,8 +412,6 @@ e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestinatio return; } - connect_destination (model, dest); - model->priv->data = g_list_insert (model->priv->data, dest, index); g_object_ref (dest); @@ -450,10 +420,10 @@ e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestinatio } void -e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest) +e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) { g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); + g_return_if_fail (dest && E_IS_DESTINATION (dest)); if (e_select_names_model_at_limit (model)) { /* FIXME: This is bad. */ @@ -461,8 +431,6 @@ e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest) return; } - connect_destination (model, dest); - model->priv->data = g_list_append (model->priv->data, dest); g_object_ref (dest); @@ -471,7 +439,7 @@ e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest) } void -e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestination *dest) +e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest) { GList *node; const gchar *new_str, *old_str; @@ -480,15 +448,13 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestinati g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (model->priv->data == NULL || (0 <= index && index < g_list_length (model->priv->data))); - g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); + g_return_if_fail (dest && E_IS_DESTINATION (dest)); - new_str = eab_destination_get_textrep (dest, FALSE); + new_str = e_destination_get_textrep (dest, FALSE); new_strlen = new_str ? strlen (new_str) : 0; if (model->priv->data == NULL) { - connect_destination (model, dest); - model->priv->data = g_list_append (model->priv->data, dest); g_object_ref (dest); @@ -498,10 +464,7 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestinati if (node->data != dest) { - disconnect_destination (model, EAB_DESTINATION (node->data)); - connect_destination (model, dest); - - old_str = eab_destination_get_textrep (EAB_DESTINATION (node->data), FALSE); + old_str = e_destination_get_textrep (E_DESTINATION (node->data), FALSE); old_strlen = old_str ? strlen (old_str) : 0; g_object_unref (node->data); @@ -521,16 +484,15 @@ void e_select_names_model_delete (ESelectNamesModel *model, gint index) { GList *node; - EABDestination *dest; + EDestination *dest; g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); node = g_list_nth (model->priv->data, index); - dest = EAB_DESTINATION (node->data); + dest = E_DESTINATION (node->data); - disconnect_destination (model, dest); g_object_unref (dest); model->priv->data = g_list_remove_link (model->priv->data, node); @@ -550,20 +512,18 @@ e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) iter = model->priv->data; while (iter) { - EABDestination *dest; + EDestination *dest; next = g_list_next (iter); if (next == NULL && !clean_last_entry) break; - dest = iter->data ? EAB_DESTINATION (iter->data) : NULL; + dest = iter->data ? E_DESTINATION (iter->data) : NULL; - if (dest == NULL || eab_destination_is_empty (dest)) { - if (dest) { - disconnect_destination (model, dest); + if (dest == NULL || e_destination_empty (dest)) { + if (dest) g_object_unref (dest); - } model->priv->data = g_list_remove_link (model->priv->data, iter); g_list_free_1 (iter); changed = TRUE; @@ -576,19 +536,12 @@ e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) e_select_names_model_changed (model); } -static void -delete_all_iter (gpointer data, gpointer closure) -{ - disconnect_destination (E_SELECT_NAMES_MODEL (closure), EAB_DESTINATION (data)); - g_object_unref (data); -} - void e_select_names_model_delete_all (ESelectNamesModel *model) { g_return_if_fail (model != NULL && E_IS_SELECT_NAMES_MODEL (model)); - g_list_foreach (model->priv->data, delete_all_iter, model); + g_list_foreach (model->priv->data, (GFunc)g_object_unref, model); g_list_free (model->priv->data); model->priv->data = NULL; @@ -609,9 +562,9 @@ e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel e_select_names_model_delete_all (dest); len = e_select_names_model_count (src); for (i = 0; i < len; ++i) { - const EABDestination *d = e_select_names_model_get_destination (src, i); + const EDestination *d = e_select_names_model_get_destination (src, i); if (d) - e_select_names_model_append (dest, eab_destination_copy (d)); + e_select_names_model_append (dest, e_destination_copy (d)); } } @@ -628,9 +581,9 @@ e_select_names_model_merge (ESelectNamesModel *dest, ESelectNamesModel *src) len = e_select_names_model_count (src); for (i = 0; i < len; ++i) { - const EABDestination *d = e_select_names_model_get_destination (src, i); + const EDestination *d = e_select_names_model_get_destination (src, i); if (d && !e_select_names_model_contains (dest, d)) - e_select_names_model_append (dest, eab_destination_copy (d)); + e_select_names_model_append (dest, e_destination_copy (d)); } } @@ -648,7 +601,7 @@ e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index iter = model->priv->data; while (iter && i <= index) { rp += len + (i > 0 ? seplen : 0); - str = eab_destination_get_textrep (EAB_DESTINATION (iter->data), FALSE); + str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); len = str ? g_utf8_strlen (str, -1) : 0; ++i; iter = g_list_next (iter); @@ -678,7 +631,7 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, iter = model->priv->data; while (iter != NULL) { - str = eab_destination_get_textrep (EAB_DESTINATION (iter->data), FALSE); + str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); len = str ? g_utf8_strlen (str, -1) : 0; if (sp <= pos && pos <= sp + len + adj) { @@ -717,39 +670,6 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, } void -e_select_names_model_load_all_contacts (ESelectNamesModel *model, EBook *book) -{ - GList *iter; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (book == NULL || E_IS_BOOK (book)); - - for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EABDestination *dest = EAB_DESTINATION (iter->data); - if (!eab_destination_is_empty (dest)) { - - eab_destination_load_contact (dest, book); - } - } -} - -void -e_select_names_model_cancel_all_contact_load (ESelectNamesModel *model) -{ - GList *iter; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EABDestination *dest = EAB_DESTINATION (iter->data); - if (!eab_destination_is_empty (dest)) { - - eab_destination_cancel_contact_load (dest); - } - } -} - -void e_select_names_model_freeze (ESelectNamesModel *model) { g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h index 0d21ee86b3..8bb8e3778b 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ b/addressbook/gui/component/select-names/e-select-names-model.h @@ -16,7 +16,7 @@ #include <stdio.h> #include <e-util/e-list.h> #include <libebook/e-contact.h> -#include <addressbook/util/eab-destination.h> +#include <addressbook/util/e-destination.h> #define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) #define E_SELECT_NAMES_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModel)) @@ -54,18 +54,18 @@ gint e_select_names_model_get_limit (ESelectNamesModel void e_select_names_model_set_limit (ESelectNamesModel *model, gint limit); gboolean e_select_names_model_at_limit (ESelectNamesModel *model); -const EABDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); +const EDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); void e_select_names_model_import_destinationv (ESelectNamesModel *model, gchar *destinationv); EContact *e_select_names_model_get_contact (ESelectNamesModel *model, gint index); const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index); -gboolean e_select_names_model_contains (ESelectNamesModel *model, const EABDestination *dest); +gboolean e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest); -void e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestination *dest); -void e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest); -void e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestination *dest); +void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest); +void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest); +void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest); void e_select_names_model_delete (ESelectNamesModel *model, gint index); void e_select_names_model_delete_all (ESelectNamesModel *model); void e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src); @@ -76,9 +76,6 @@ void e_select_names_model_clean (ESelectNamesModel *model, gboolea void e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index, gint *pos, gint *length); void e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, gint *index, gint *start_pos, gint *length); -void e_select_names_model_load_all_contacts (ESelectNamesModel *model, EBook *book); -void e_select_names_model_cancel_all_contact_load (ESelectNamesModel *model); - /* This is a mildly annoying freeze/thaw pair, in that it only applies to the 'changed' signal and not to 'resized'. This could cause unexpected results in some cases. */ void e_select_names_model_freeze (ESelectNamesModel *model); diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index eb7c7c5e88..0ad6fda909 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -36,7 +36,6 @@ #include <gtk/gtkcheckmenuitem.h> #include <gtk/gtkradiomenuitem.h> #include <gtk/gtkseparatormenuitem.h> -#include <gtk/gtklabel.h> #include <libgnome/gnome-i18n.h> #include <addressbook/util/eab-book-util.h> @@ -52,13 +51,13 @@ typedef struct _PopupInfo PopupInfo; struct _PopupInfo { ESelectNamesTextModel *text_model; - EABDestination *dest; + EDestination *dest; gint pos; gint index; }; static PopupInfo * -popup_info_new (ESelectNamesTextModel *text_model, EABDestination *dest, gint pos, gint index) +popup_info_new (ESelectNamesTextModel *text_model, EDestination *dest, gint pos, gint index) { PopupInfo *info = g_new0 (PopupInfo, 1); info->text_model = text_model; @@ -105,10 +104,10 @@ static void make_contact_editor_cb (EBook *book, gpointer user_data) { if (book) { - EABDestination *dest = EAB_DESTINATION (user_data); + EDestination *dest = E_DESTINATION (user_data); EContact *contact; - contact = (EContact *) eab_destination_get_contact (dest); + contact = (EContact *) e_destination_get_contact (dest); if (e_contact_get (contact, E_CONTACT_IS_LIST)) { EContactListEditor *ce; ce = e_addressbook_show_contact_list_editor (book, contact, FALSE, TRUE); @@ -140,7 +139,7 @@ change_email_num_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; gint n; - EABDestination *dest; + EDestination *dest; if (info == NULL) return; @@ -150,9 +149,9 @@ change_email_num_cb (GtkWidget *w, gpointer user_data) n = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "number")); - if (n != eab_destination_get_email_num (info->dest)) { - dest = eab_destination_new (); - eab_destination_set_contact (dest, eab_destination_get_contact (info->dest), n); + if (n != e_destination_get_email_num (info->dest)) { + dest = e_destination_new (); + e_destination_set_contact (dest, e_destination_get_contact (info->dest), n); e_select_names_model_replace (info->text_model->source, info->index, dest); } } @@ -177,7 +176,7 @@ toggle_html_mail_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (w); - const EABDestination *dest; + const EDestination *dest; if (info == NULL) return; @@ -185,7 +184,7 @@ toggle_html_mail_cb (GtkWidget *w, gpointer user_data) dest = info->dest; item = GTK_CHECK_MENU_ITEM (item); - eab_destination_set_html_mail_pref ((EABDestination *) dest, item->active); + e_destination_set_html_mail_pref ((EDestination *) dest, item->active); } #endif @@ -197,7 +196,7 @@ populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) GtkWidget *menuitem; GList *email_list; - contact = eab_destination_get_contact (info->dest); + contact = e_destination_get_contact (info->dest); #if TOO_MANY_MENU_ITEMS menuitem = gtk_separator_menu_item_new(); @@ -227,7 +226,7 @@ populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - eab_destination_get_html_mail_pref (info->dest)); + e_destination_get_html_mail_pref (info->dest)); g_signal_connect (menuitem, "toggled", G_CALLBACK (toggle_html_mail_cb), info); @@ -245,23 +244,14 @@ populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) if (g_list_length (email_list) > 1) { GList *l; GSList *radiogroup = NULL; - gint n = eab_destination_get_email_num (info->dest); + gint n = e_destination_get_email_num (info->dest); gint j = g_list_length (email_list) - 1; for (l = g_list_last (email_list); l; l = l->prev) { char *email = l->data; char *label = NULL; - if (!strncmp (email, "<?xml", 5)) { - EABDestination *dest = eab_destination_import (email); - if (dest) { - label = g_strdup (eab_destination_get_textrep (dest, TRUE)); - g_object_unref (dest); - } - } - else { - label = g_strdup (email); - } + label = g_strdup (email); if (list) { menuitem = gtk_menu_item_new_with_label (label); @@ -286,7 +276,7 @@ populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) g_free (label); } } else { - menuitem = gtk_menu_item_new_with_label (eab_destination_get_email (info->dest)); + menuitem = gtk_menu_item_new_with_label (e_destination_get_email (info->dest)); gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); } @@ -303,7 +293,7 @@ populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) ? EVOLUTION_IMAGESDIR "/" LIST_ICON_FILENAME : EVOLUTION_IMAGESDIR "/" CONTACT_ICON_FILENAME); gtk_widget_show (image); - menuitem = gtk_image_menu_item_new_with_label (eab_destination_get_name (info->dest)); + menuitem = gtk_image_menu_item_new_with_label (e_destination_get_name (info->dest)); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_widget_show (menuitem); @@ -314,7 +304,7 @@ static void quick_add_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; - e_contact_quick_add_free_form (eab_destination_get_address (info->dest), NULL, NULL); + e_contact_quick_add_free_form (e_destination_get_address (info->dest), NULL, NULL); } static void @@ -337,7 +327,7 @@ populate_popup_nocontact (GtkWidget *pop, PopupInfo *info) #if TOO_MANY_MENU_ITEMS menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - eab_destination_get_html_mail_pref (info->dest)); + e_destination_get_html_mail_pref (info->dest)); g_signal_connect (menuitem, "toggled", G_CALLBACK (toggle_html_mail_cb), info); @@ -349,9 +339,9 @@ populate_popup_nocontact (GtkWidget *pop, PopupInfo *info) gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - str = eab_destination_get_name (info->dest); + str = e_destination_get_name (info->dest); if (! (str && *str)) - str = eab_destination_get_email (info->dest); + str = e_destination_get_email (info->dest); if (! (str && *str)) str = _("Unnamed Contact"); @@ -366,7 +356,7 @@ e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_mode { ESelectNamesModel *model; PopupInfo *info; - EABDestination *dest; + EDestination *dest; gint index; g_return_if_fail (GTK_IS_MENU_SHELL (menu)); @@ -381,14 +371,14 @@ e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_mode return; /* XXX yuck, why does this return a const? */ - dest = (EABDestination *)e_select_names_model_get_destination (model, index); - if (eab_destination_is_empty (dest)) + dest = (EDestination *)e_select_names_model_get_destination (model, index); + if (e_destination_empty (dest)) return; info = popup_info_new (text_model, dest, pos, index); - if (eab_destination_get_contact (dest)) { - populate_popup_contact (menu, eab_destination_is_evolution_list (dest), info); + if (e_destination_get_contact (dest)) { + populate_popup_contact (menu, e_destination_is_evolution_list (dest), info); } else { populate_popup_nocontact (menu, info); } diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c index 4ff3e3c41a..0072e7d9fd 100644 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ b/addressbook/gui/component/select-names/e-select-names-table-model.c @@ -117,8 +117,8 @@ fill_in_info (ESelectNamesTableModel *model) model->data = g_new(ESelectNamesTableModelData, count); for (i = 0; i < count; ++i) { - const EABDestination *dest = e_select_names_model_get_destination (model->source, i); - EContact *contact = dest ? eab_destination_get_contact (dest) : NULL; + const EDestination *dest = e_select_names_model_get_destination (model->source, i); + EContact *contact = dest ? e_destination_get_contact (dest) : NULL; if (contact) { model->data[i].name = e_contact_get(contact, E_CONTACT_FILE_AS); @@ -128,8 +128,8 @@ fill_in_info (ESelectNamesTableModel *model) if (model->data[i].email == 0) model->data[i].email = g_strdup(""); } else { - const gchar *name = eab_destination_get_name (dest); - const gchar *email = eab_destination_get_email (dest); + const gchar *name = e_destination_get_name (dest); + const gchar *email = e_destination_get_email (dest); model->data[i].name = g_strdup (name && *name ? name : email); model->data[i].email = g_strdup (email); diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c index e885de5bf6..c207e02d79 100644 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ b/addressbook/gui/component/select-names/e-select-names-text-model.c @@ -372,9 +372,9 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha /* Is this a quoted or an unquoted separator we are dealing with? */ if (ut == g_utf8_get_char(text_model->sep) && index >= 0) { - const EABDestination *dest = e_select_names_model_get_destination (source, index); + const EDestination *dest = e_select_names_model_get_destination (source, index); if (dest) { - const gchar *str = eab_destination_get_textrep (dest, FALSE); + const gchar *str = e_destination_get_textrep (dest, FALSE); int j; const char *jp; @@ -400,8 +400,8 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (index == -1) { EReposAbsolute repos; - e_select_names_model_insert (source, 0, eab_destination_new ()); - e_select_names_model_insert (source, 0, eab_destination_new ()); + e_select_names_model_insert (source, 0, e_destination_new ()); + e_select_names_model_insert (source, 0, e_destination_new ()); repos.model = model; repos.pos = -1; /* At end */ @@ -420,7 +420,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha (e_select_names_model_get_string (source, ins_point) == NULL)) || (ins_point > 0 && (e_select_names_model_get_string (source, ins_point-1) == NULL)))) { - e_select_names_model_insert (source, ins_point, eab_destination_new ()); + e_select_names_model_insert (source, ins_point, e_destination_new ()); repos.model = model; repos.pos = pos; @@ -435,10 +435,10 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha const gchar *str = e_select_names_model_get_string (source, index); gchar *str1 = g_strndup (str, offset); gchar *str2 = g_strdup (str+offset); - EABDestination *d1 = eab_destination_new (), *d2 = eab_destination_new (); + EDestination *d1 = e_destination_new (), *d2 = e_destination_new (); - eab_destination_set_raw (d1, str1); - eab_destination_set_raw (d2, str2); + e_destination_set_raw (d1, str1); + e_destination_set_raw (d2, str2); e_select_names_model_replace (source, index, d1); e_select_names_model_insert (source, index+1, d2); @@ -498,12 +498,10 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (new_str->len) { - EABDestination *dest; - dest = index >= 0 ? eab_destination_copy (e_select_names_model_get_destination (source, index)) : eab_destination_new (); - eab_destination_set_raw (dest, new_str->str); + EDestination *dest; + dest = e_destination_new (); + e_destination_set_raw (dest, new_str->str); e_select_names_model_replace (source, index, dest); - - /* e_select_names_model_replace (source, index, dest); */ if (this_length > 0) { repos.model = model; @@ -589,7 +587,7 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) if (index+1 < e_select_names_model_count (source)) { EReposDeleteShift repos; - EABDestination *new_dest; + EDestination *new_dest; const gchar *str1 = e_select_names_model_get_string (source, index); const gchar *str2 = e_select_names_model_get_string (source, index+1); gchar *new_str; @@ -613,8 +611,8 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) e_select_names_model_delete (source, index+1); - new_dest = eab_destination_new (); - eab_destination_set_raw (new_dest, new_str); + new_dest = e_destination_new (); + e_destination_set_raw (new_dest, new_str); e_select_names_model_replace (source, index, new_dest); g_free (new_str); @@ -689,7 +687,7 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) char *np; int i; EReposDeleteShift repos; - EABDestination *dest; + EDestination *dest; new_str = g_new0 (char, strlen (str) * 6 + 1); /* worse case it can't be any longer than this */ @@ -718,8 +716,8 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) np = g_utf8_next_char (np); } - dest = index >= 0 ? eab_destination_copy (e_select_names_model_get_destination (source, index)) : eab_destination_new (); - eab_destination_set_raw (dest, new_str); + dest = e_destination_new (); + e_destination_set_raw (dest, new_str); e_select_names_model_replace (source, index, dest); if (out) @@ -764,10 +762,10 @@ e_select_names_text_model_obj_count (ETextModel *model) count = i = e_select_names_model_count (source); while (i > 0) { - const EABDestination *dest; + const EDestination *dest; --i; dest = e_select_names_model_get_destination (source, i); - if (eab_destination_get_contact (dest) == NULL) + if (e_destination_get_contact (dest) == NULL) --count; } @@ -783,8 +781,8 @@ nth_obj_index (ESelectNamesModel *source, gint n) N = e_select_names_model_count (source); do { - const EABDestination *dest = e_select_names_model_get_destination (source, i); - if (eab_destination_get_contact (dest)) + const EDestination *dest = e_select_names_model_get_destination (source, i); + if (e_destination_get_contact (dest)) --n; ++i; } while (n >= 0 && i < N); diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index cd8a2141f3..94ccef34c8 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -21,7 +21,10 @@ #include <config.h> #include <string.h> #include <glib.h> -#include <gtk/gtk.h> +#include <gtk/gtkalignment.h> +#include <gtk/gtkentry.h> +#include <gtk/gtklabel.h> +#include <gtk/gtkstock.h> #include <libgnome/gnome-i18n.h> #include <gal/e-table/e-table-simple.h> @@ -214,7 +217,7 @@ real_add_address_cb (int model_row, gpointer closure) ESelectNamesChild *child = closure; ESelectNames *names = child->names; const EContact *contact; - EABDestination *dest = eab_destination_new (); + EDestination *dest = e_destination_new (); gint mapped_row; mapped_row = e_table_subset_view_to_model_row (E_TABLE_SUBSET (names->without), model_row); @@ -222,7 +225,7 @@ real_add_address_cb (int model_row, gpointer closure) contact = eab_model_contact_at (EAB_MODEL(names->model), mapped_row); if (contact != NULL) { - eab_destination_set_contact (dest, (EContact*)contact, 0); + e_destination_set_contact (dest, (EContact*)contact, 0); e_select_names_model_append (child->source, dest); e_select_names_model_clean (child->source, FALSE); diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 0c762ff982..22dccfcb67 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -23,9 +23,12 @@ #include "e-contact-list-editor.h" #include <string.h> -#include <glib.h> + #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-window-icon.h> +#include <gtk/gtkentry.h> +#include <gtk/gtktogglebutton.h> + #include <bonobo/bonobo-ui-container.h> #include <bonobo/bonobo-ui-util.h> #include <bonobo/bonobo-window.h> @@ -868,7 +871,8 @@ table_drag_data_received_cb (ETable *table, int row, int col, if (!e_contact_get (contact, E_CONTACT_IS_LIST)) { e_contact_list_model_add_contact (E_CONTACT_LIST_MODEL (editor->model), - contact); + contact, + 0 /* Hard-wired for default e-mail */); changed = TRUE; } @@ -916,7 +920,6 @@ extract_info(EContactListEditor *editor) EContact *contact = editor->contact; if (contact) { int i; - GList *email_list; char *image_data; gsize image_data_len; char *string = gtk_editable_get_chars(GTK_EDITABLE (editor->list_name_entry), 0, -1); @@ -932,19 +935,19 @@ extract_info(EContactListEditor *editor) e_contact_set (contact, E_CONTACT_LIST_SHOW_ADDRESSES, GINT_TO_POINTER (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton)))); - email_list = NULL; + e_vcard_remove_attributes (E_VCARD (contact), "", EVC_EMAIL); + /* then refill it from the contact list model */ for (i = 0; i < e_table_model_row_count (editor->model); i ++) { - const EABDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i); - gchar *dest_xml = eab_destination_export (dest); - if (dest_xml) - email_list = g_list_append (email_list, dest_xml); - } + const EDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i); + EVCardAttribute *attr; - e_contact_set (contact, E_CONTACT_EMAIL, email_list); + attr = e_vcard_attribute_new (NULL, EVC_EMAIL); - g_list_foreach (email_list, (GFunc) g_free, NULL); - g_list_free (email_list); + e_vcard_add_attribute (E_VCARD (contact), attr); + + e_destination_export_to_vcard_attribute (dest, attr); + } if (editor->image_set && e_image_chooser_get_image_data (E_IMAGE_CHOOSER (editor->list_image), @@ -976,7 +979,7 @@ fill_in_info(EContactListEditor *editor) GList *iter; file_as = e_contact_get_const (editor->contact, E_CONTACT_FILE_AS); - email_list = e_contact_get (editor->contact, E_CONTACT_EMAIL); + email_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL); is_evolution_list = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_IS_LIST)); show_addresses = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_LIST_SHOW_ADDRESSES)); @@ -992,18 +995,54 @@ fill_in_info(EContactListEditor *editor) e_contact_list_model_remove_all (E_CONTACT_LIST_MODEL (editor->model)); for (iter = email_list; iter; iter = iter->next) { - char *dest_xml = iter->data; - EABDestination *dest; - - /* g_message ("incoming xml: [%s]", dest_xml); */ - dest = eab_destination_import (dest_xml); - - if (dest != NULL) { - e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), dest); + EVCardAttribute *attr = iter->data; + GList *p; + EDestination *list_dest = e_destination_new (); + char *contact_uid = NULL; + char *email = NULL; + char *name = NULL; + int email_num = -1; + gboolean html_pref = FALSE; + + for (p = e_vcard_attribute_get_params (attr); p; p = p->next) { + EVCardAttributeParam *param = p->data; + const char *param_name = e_vcard_attribute_param_get_name (param); + if (!g_ascii_strcasecmp (param_name, + EVC_X_DEST_CONTACT_UID)) { + GList *v = e_vcard_attribute_param_get_values (param); + contact_uid = v ? v->data : NULL; + } + else if (!g_ascii_strcasecmp (param_name, + EVC_X_DEST_EMAIL_NUM)) { + GList *v = e_vcard_attribute_param_get_values (param); + email_num = v ? atoi (v->data) : -1; + } + else if (!g_ascii_strcasecmp (param_name, + EVC_X_DEST_NAME)) { + GList *v = e_vcard_attribute_param_get_values (param); + name = v ? v->data : NULL; + } + else if (!g_ascii_strcasecmp (param_name, + EVC_X_DEST_EMAIL)) { + GList *v = e_vcard_attribute_param_get_values (param); + email = v ? v->data : NULL; + } + else if (!g_ascii_strcasecmp (param_name, + EVC_X_DEST_HTML_MAIL)) { + GList *v = e_vcard_attribute_param_get_values (param); + html_pref = v ? !g_ascii_strcasecmp (v->data, "true") : FALSE; + } } + + if (contact_uid) e_destination_set_contact_uid (list_dest, contact_uid, email_num); + if (name) e_destination_set_name (list_dest, name); + if (email) e_destination_set_email (list_dest, email); + e_destination_set_html_mail_pref (list_dest, html_pref); + + e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), list_dest); } - g_list_foreach (email_list, (GFunc) g_free, NULL); + g_list_foreach (email_list, (GFunc) e_vcard_attribute_free, NULL); g_list_free (email_list); photo = e_contact_get (editor->contact, E_CONTACT_LOGO); diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c index c7fd626372..8a22da19db 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c @@ -30,7 +30,7 @@ contact_list_value_at (ETableModel *etc, int col, int row) { EContactListModel *model = E_CONTACT_LIST_MODEL (etc); - return (void *) eab_destination_get_textrep (model->data[row], TRUE); + return (void *) e_destination_get_textrep (model->data[row], TRUE); } /* This function sets the value at a particular point in our ETableModel. */ @@ -80,7 +80,7 @@ contact_list_value_to_string (ETableModel *etc, int col, const void *value) } static void -contact_list_model_destroy (GtkObject *o) +contact_list_model_dispose (GObject *o) { EContactListModel *model = E_CONTACT_LIST_MODEL (o); int i; @@ -96,17 +96,17 @@ contact_list_model_destroy (GtkObject *o) model->data_count = 0; model->data_alloc = 0; - (* GTK_OBJECT_CLASS (parent_class)->destroy) (o); + (* G_OBJECT_CLASS (parent_class)->dispose) (o); } static void -e_contact_list_model_class_init (GtkObjectClass *object_class) +e_contact_list_model_class_init (GObjectClass *object_class) { ETableModelClass *model_class = (ETableModelClass *) object_class; parent_class = g_type_class_ref (PARENT_TYPE); - object_class->destroy = contact_list_model_destroy; + object_class->dispose = contact_list_model_dispose; model_class->column_count = contact_list_col_count; model_class->row_count = contact_list_row_count; @@ -121,13 +121,13 @@ e_contact_list_model_class_init (GtkObjectClass *object_class) } static void -e_contact_list_model_init (GtkObject *object) +e_contact_list_model_init (GObject *object) { EContactListModel *model = E_CONTACT_LIST_MODEL(object); model->data_alloc = 10; model->data_count = 0; - model->data = g_new (EABDestination*, model->data_alloc); + model->data = g_new (EDestination*, model->data_alloc); } GType @@ -172,16 +172,16 @@ e_contact_list_model_new () } void -e_contact_list_model_add_destination (EContactListModel *model, EABDestination *dest) +e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest) { g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (EAB_IS_DESTINATION (dest)); + g_return_if_fail (E_IS_DESTINATION (dest)); e_table_model_pre_change (E_TABLE_MODEL (model)); if (model->data_count + 1 >= model->data_alloc) { model->data_alloc *= 2; - model->data = g_renew (EABDestination*, model->data, model->data_alloc); + model->data = g_renew (EDestination*, model->data, model->data_alloc); } model->data[model->data_count ++] = dest; @@ -194,28 +194,29 @@ void e_contact_list_model_add_email (EContactListModel *model, const char *email) { - EABDestination *new_dest; + EDestination *new_dest; g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); g_return_if_fail (email != NULL); - new_dest = eab_destination_new (); - eab_destination_set_email (new_dest, email); + new_dest = e_destination_new (); + e_destination_set_email (new_dest, email); e_contact_list_model_add_destination (model, new_dest); } void e_contact_list_model_add_contact (EContactListModel *model, - EContact *contact) + EContact *contact, + int email_num) { - EABDestination *new_dest; + EDestination *new_dest; g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); g_return_if_fail (E_IS_CONTACT (contact)); - new_dest = eab_destination_new (); - eab_destination_set_contact (new_dest, contact, 0); /* Hard-wired for default e-mail */ + new_dest = e_destination_new (); + e_destination_set_contact (new_dest, contact, email_num); e_contact_list_model_add_destination (model, new_dest); } @@ -229,7 +230,7 @@ e_contact_list_model_remove_row (EContactListModel *model, int row) e_table_model_pre_change (E_TABLE_MODEL (model)); g_object_unref (model->data[row]); - memmove (model->data + row, model->data + row + 1, sizeof (EABDestination*) * (model->data_count - row - 1)); + memmove (model->data + row, model->data + row + 1, sizeof (EDestination*) * (model->data_count - row - 1)); model->data_count --; e_table_model_row_deleted (E_TABLE_MODEL (model), row); @@ -255,7 +256,7 @@ e_contact_list_model_remove_all (EContactListModel *model) } -const EABDestination * +const EDestination * e_contact_list_model_get_destination (EContactListModel *model, int row) { g_return_val_if_fail (E_IS_CONTACT_LIST_MODEL (model), NULL); diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index aec91ae329..c3fadfdf23 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -5,7 +5,6 @@ #include "e-addressbook-table-adapter.h" #include "eab-contact-merging.h" #include "eab-gui-util.h" -#include "util/eab-destination.h" #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/xmlmemory.h> @@ -92,16 +91,6 @@ addressbook_value_at (ETableModel *etc, int col, int row) value = e_contact_get_const((EContact*)eab_model_contact_at (priv->model, row), col); - if (value && !strncmp (value, "<?xml", 5)) { - EABDestination *dest = eab_destination_import (value); - if (dest) { - /* XXX blech, we leak this */ - value = g_strdup (eab_destination_get_textrep (dest, TRUE)); - g_object_unref (dest); - } - } - - return (void *)(value ? value : ""); } diff --git a/addressbook/gui/widgets/e-addressbook-treeview-adapter.c b/addressbook/gui/widgets/e-addressbook-treeview-adapter.c index 592f9d2b03..2d0c4b8c93 100644 --- a/addressbook/gui/widgets/e-addressbook-treeview-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-treeview-adapter.c @@ -379,15 +379,6 @@ adapter_get_value (GtkTreeModel *tree_model, v = e_card_simple_get_const(simple, column); - if (v && !strncmp (v, "<?xml", 5)) { - EABDestination *dest = eab_destination_import (v); - if (dest) { - /* XXX blech, we leak this */ - v = g_strdup (eab_destination_get_textrep (dest, TRUE)); - g_object_unref (dest); - } - } - g_value_init (value, G_TYPE_STRING); g_value_set_string (value, (v ? v : "")); } diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 36038eef48..fdaf1692ba 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -39,7 +39,7 @@ #include "e-minicard-label.h" #include "e-minicard-view.h" #include "e-contact-editor.h" -#include "util/eab-destination.h" +#include "util/e-destination.h" static void e_minicard_init (EMinicard *card); static void e_minicard_class_init (EMinicardClass *klass); @@ -537,12 +537,12 @@ activiate_editor(GnomeCanvasItem *item) if (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)) { EContactListEditor *editor = eab_show_contact_list_editor (book, e_minicard->contact, FALSE, e_minicard->editable); - e_minicard->editor = G_OBJECT (editor); + e_minicard->editor = EAB_EDITOR (editor); } else { EContactEditor *editor = eab_show_contact_editor (book, e_minicard->contact, FALSE, e_minicard->editable); - e_minicard->editor = G_OBJECT (editor); + e_minicard->editor = EAB_EDITOR (editor); } g_object_ref (e_minicard->editor); @@ -746,17 +746,6 @@ add_field (EMinicard *e_minicard, EContactField field, gdouble left_width) name = g_strdup_printf("%s:", e_contact_pretty_name (field)); string = e_contact_get (e_minicard->contact, field); - /* Magically convert embedded XML into an address. */ - if (!strncmp (string, "<?xml", 5)) { - EABDestination *dest = eab_destination_import (string); - if (dest != NULL) { - gchar *new_string = g_strdup (eab_destination_get_textrep (dest, TRUE)); - g_free (string); - string = new_string; - g_object_unref (dest); - } - } - new_item = e_minicard_label_new(group); gnome_canvas_item_set( new_item, "width", e_minicard->width - 4.0, @@ -852,17 +841,6 @@ remodel( EMinicard *e_minicard ) string = e_contact_get(e_minicard->contact, field); if (string && *string) { - /* Magically convert embedded XML into an address. */ - if (!strncmp (string, "<?xml", 4)) { - EABDestination *dest = eab_destination_import (string); - if (dest != NULL) { - gchar *new_string = g_strdup (eab_destination_get_textrep (dest, TRUE)); - g_free (string); - string = new_string; - g_object_unref (dest); - } - } - e_minicard->fields = g_list_append(e_minicard->fields, minicard_field); g_object_set(minicard_field->label, "field", string, diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c index d5e62d323a..a1dc832550 100644 --- a/addressbook/gui/widgets/eab-contact-display.c +++ b/addressbook/gui/widgets/eab-contact-display.c @@ -23,7 +23,6 @@ #include "eab-contact-display.h" #include "e-util/e-html-utils.h" -#include "util/eab-destination.h" #include <string.h> #include <libgnome/gnome-i18n.h> @@ -243,14 +242,9 @@ render_contact_list (GtkHTMLStream *html_stream, EContact *contact) email_list = e_contact_get (contact, E_CONTACT_EMAIL); for (l = email_list; l; l = l->next) { - EABDestination *dest = eab_destination_import (l->data); - if (dest) { - const char *textrep = eab_destination_get_textrep (dest, TRUE); - char *html = e_text_to_html (textrep, E_TEXT_TO_HTML_CONVERT_ADDRESSES); - gtk_html_stream_printf (html_stream, "%s<br>", html); - g_free (html); - g_object_unref (dest); - } + char *html = e_text_to_html (l->data, E_TEXT_TO_HTML_CONVERT_ADDRESSES); + gtk_html_stream_printf (html_stream, "%s<br>", html); + g_free (html); } gtk_html_stream_printf (html_stream, "</td></tr></table>"); } @@ -499,14 +493,9 @@ eab_contact_display_render_compact (EABContactDisplay *display, EContact *contac email_list = e_contact_get (contact, E_CONTACT_EMAIL); for (l = email_list; l; l = l->next) { - EABDestination *dest = eab_destination_import (l->data); - if (dest) { - const char *textrep = eab_destination_get_textrep (dest, TRUE); - char *html = e_text_to_html (textrep, 0); - gtk_html_stream_printf (html_stream, "%s, ", html); - g_free (html); - g_object_unref (dest); - } + char *html = e_text_to_html (l->data, 0); + gtk_html_stream_printf (html_stream, "%s, ", html); + g_free (html); } gtk_html_stream_printf (html_stream, "</td></tr></table>"); } diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index f08e2122ce..3ad9ae7a9f 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -29,7 +29,7 @@ #include <gal/util/e-util.h> #include "eab-gui-util.h" #include "util/eab-book-util.h" -#include "util/eab-destination.h" +#include "util/e-destination.h" #include "widgets/misc/e-image-chooser.h" #include "widgets/misc/e-source-selector.h" @@ -703,14 +703,8 @@ eab_send_contact_list (GList *contacts, EABDisposition disposition) addr = NULL; if (iterator && iterator->data) { if (is_list) { - /* We need to decode the list entries, which are XMLified EABDestinations. */ - EABDestination *dest = eab_destination_import ((char*)iterator->data); - if (dest != NULL) { - name = g_strdup (eab_destination_get_name (dest)); - addr = g_strdup (eab_destination_get_email (dest)); - g_object_unref (dest); - } - + /* XXX we should probably try to get the name from the attribute parameter here.. */ + addr = g_strdup ((char*)iterator->data); } else { /* is just a plain old card */ EContactName *contact_name = e_contact_get (contact, E_CONTACT_NAME); if (contact_name) { diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c index 77babb95a5..c7a883dc4e 100644 --- a/addressbook/importers/evolution-ldif-importer.c +++ b/addressbook/importers/evolution-ldif-importer.c @@ -32,7 +32,7 @@ #include <importer/evolution-importer.h> #include <importer/GNOME_Evolution_Importer.h> #include <widgets/misc/e-source-selector.h> -#include <util/eab-destination.h> +#include <util/e-destination.h> #define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory" #define COMPONENT_IID "OAFIID:GNOME_Evolution_Addressbook_LDIF_Importer" @@ -353,7 +353,8 @@ getNextLDIFEntry( FILE *f ) static void resolve_list_card (LDIFImporter *gci, EContact *contact) { - GList *email, *l, *new_email = NULL; + GList *email, *l; + GList *email_attrs = NULL; char *full_name; /* set file_as to full_name so we don't later try and figure @@ -372,26 +373,26 @@ resolve_list_card (LDIFImporter *gci, EContact *contact) /* break list chains here, since we don't support them just yet */ if (dn_contact && !e_contact_get (dn_contact, E_CONTACT_IS_LIST)) { - EABDestination *dest; - gchar *dest_xml; + EDestination *dest; + EVCardAttribute *attr = e_vcard_attribute_new (NULL, EVC_EMAIL); /* Hard-wired for default e-mail, since netscape only exports 1 email address */ - dest = eab_destination_new (); - eab_destination_set_contact (dest, dn_contact, 0); - dest_xml = eab_destination_export (dest); + dest = e_destination_new (); + e_destination_set_contact (dest, dn_contact, 0); + + e_destination_export_to_vcard_attribute (dest, attr); + g_object_unref (dest); - if (dest_xml) { - new_email = g_list_append (new_email, dest_xml); - } + email_attrs = g_list_append (email_attrs, attr); } } - e_contact_set (contact, E_CONTACT_EMAIL, new_email); + e_contact_set_attributes (contact, E_CONTACT_EMAIL, email_attrs); g_list_foreach (email, (GFunc) g_free, NULL); g_list_free (email); - g_list_foreach (new_email, (GFunc) g_free, NULL); - g_list_free (new_email); + g_list_foreach (email_attrs, (GFunc) e_vcard_attribute_free, NULL); + g_list_free (email_attrs); } static GList * diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c index 83bec58892..f457cefafc 100644 --- a/addressbook/importers/evolution-vcard-importer.c +++ b/addressbook/importers/evolution-vcard-importer.c @@ -40,13 +40,13 @@ #include <bonobo/bonobo-shlib-factory.h> #include <bonobo/bonobo-control.h> - #include <libebook/e-book.h> #include <importer/evolution-importer.h> #include <importer/GNOME_Evolution_Importer.h> #include <widgets/misc/e-source-selector.h> #include <util/eab-book-util.h> +#include <util/e-destination.h> #define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory" #define COMPONENT_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_Importer" @@ -70,6 +70,7 @@ process_item_fn (EvolutionImporter *importer, VCardImporter *gci = (VCardImporter *) closure; EContact *contact; EContactPhoto *photo; + GList *attrs, *attr; if (gci->iterator == NULL) gci->iterator = gci->contactlist; @@ -105,6 +106,25 @@ process_item_fn (EvolutionImporter *importer, e_contact_photo_free (photo); } + /* Deal with our XML EDestination stuff in EMAIL attributes, if there is any. */ + 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); + + } + } + } + e_contact_set_attributes (contact, E_CONTACT_EMAIL, attrs); + /* FIXME Error checking */ e_book_add_contact (gci->book, contact, NULL); diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c index 39094d18a3..3b2dde2c18 100644 --- a/addressbook/printing/e-contact-print.c +++ b/addressbook/printing/e-contact-print.c @@ -41,7 +41,6 @@ #include <libebook/e-book-async.h> #include <libebook/e-contact.h> #include <gal/util/e-util.h> -#include <addressbook/util/eab-destination.h> #define SCALE 5 #define HYPHEN_PIXELS 20 @@ -475,16 +474,6 @@ e_contact_print_contact (EContact *contact, EContactPrintContext *ctxt) char *string; string = e_contact_get(contact, field); - if (string && !strncmp (string, "<?xml", 4)) { - EABDestination *dest = eab_destination_import (string); - if (dest != NULL) { - gchar *new_string = g_strdup (eab_destination_get_address (dest)); - g_free (string); - string = new_string; - g_object_unref (dest); - } - } - if (string && *string) { double xoff = 0; e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, e_contact_pretty_name (field)); diff --git a/addressbook/util/Makefile.am b/addressbook/util/Makefile.am index 6cb70de06a..6d5592139d 100644 --- a/addressbook/util/Makefile.am +++ b/addressbook/util/Makefile.am @@ -14,8 +14,8 @@ noinst_LTLIBRARIES = libeabutil.la libeabutil_la_SOURCES = \ eab-marshal.c \ - eab-destination.c \ - eab-destination.h \ + e-destination.c \ + e-destination.h \ eab-book-util.c \ eab-book-util.h |