diff options
author | Milan Crha <mcrha@redhat.com> | 2008-01-21 18:21:29 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2008-01-21 18:21:29 +0800 |
commit | 2be6b60d8311b0fd537a2889f8997d3f084755b0 (patch) | |
tree | 3d867d516d19fcb3240c08d6beb3343e5110949d /addressbook/gui/widgets/e-addressbook-table-adapter.c | |
parent | a63fbb553de7beeec54b6d691e80f650b3548e91 (diff) | |
download | gsoc2013-evolution-2be6b60d8311b0fd537a2889f8997d3f084755b0.tar gsoc2013-evolution-2be6b60d8311b0fd537a2889f8997d3f084755b0.tar.gz gsoc2013-evolution-2be6b60d8311b0fd537a2889f8997d3f084755b0.tar.bz2 gsoc2013-evolution-2be6b60d8311b0fd537a2889f8997d3f084755b0.tar.lz gsoc2013-evolution-2be6b60d8311b0fd537a2889f8997d3f084755b0.tar.xz gsoc2013-evolution-2be6b60d8311b0fd537a2889f8997d3f084755b0.tar.zst gsoc2013-evolution-2be6b60d8311b0fd537a2889f8997d3f084755b0.zip |
** Fix for bug #324604 inspired by patch of makuchaku (Mayank)
2008-01-21 Milan Crha <mcrha@redhat.com>
** Fix for bug #324604 inspired by patch of makuchaku (Mayank)
* gui/widgets/eab-gui-util.h:
* gui/widgets/eab-gui-util.c: (eab_parse_qp_email),
(eab_parse_qp_email_to_html): New helper functions for decoding
email addresses from RFC822 or RFC2047 form to UTF-8.
* gui/widgets/e-minicard.c: (add_email_field):
* gui/widgets/eab-contact-display.c: (render_contact_list),
(render_contact), (eab_contact_display_render_compact):
* gui/widgets/e-addressbook-table-adapter.c:
(struct _EAddressbookTableAdapterPrivate), (addressbook_dispose),
(addressbook_value_at), (addressbook_set_value_at), (remove_contacts),
(modify_contact), (model_changed), (eab_table_adapter_construct):
* gui/widgets/eab-gui-util.c: (get_email),
(eab_send_contact_list_as_attachment):
Ensure the print of the email is transformed from RFC822 or RFC2047.
svn path=/trunk/; revision=34863
Diffstat (limited to 'addressbook/gui/widgets/e-addressbook-table-adapter.c')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index b208952245..95e3b214a9 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -15,6 +15,8 @@ struct _EAddressbookTableAdapterPrivate { EABModel *model; int create_contact_id, remove_contact_id, modify_contact_id, model_changed_id; + + GHashTable *emails; }; #define PARENT_TYPE e_table_model_get_type() @@ -54,6 +56,9 @@ addressbook_dispose(GObject *object) if (adapter->priv) { unlink_model(adapter); + g_hash_table_remove_all (adapter->priv->emails); + g_hash_table_destroy (adapter->priv->emails); + g_free (adapter->priv); adapter->priv = NULL; } @@ -92,6 +97,28 @@ 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 && *value && (col == E_CONTACT_EMAIL_1 || col == E_CONTACT_EMAIL_2 || col == E_CONTACT_EMAIL_3)) { + char *val = g_hash_table_lookup (priv->emails, value); + + if (val) { + /* we have this already cached, so use value from the cache */ + value = val; + } else { + char *name = NULL, *mail = NULL; + + if (eab_parse_qp_email (value, &name, &mail)) + val = g_strdup_printf ("%s <%s>", name, mail); + else + val = g_strdup (value); + + g_free (name); + g_free (mail); + + g_hash_table_insert (priv->emails, g_strdup (value), val); + value = val; + } + } + return (void *)(value ? value : ""); } @@ -122,9 +149,17 @@ addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) e_table_model_pre_change(etc); + if (col == E_CONTACT_EMAIL_1 || col == E_CONTACT_EMAIL_2 || col == E_CONTACT_EMAIL_3) { + const char *old_value = e_contact_get_const (contact, col); + + /* remove old value from cache and use new one */ + if (old_value && *old_value) + g_hash_table_remove (priv->emails, old_value); + } + e_contact_set(contact, col, (void *) val); eab_merging_book_commit_contact (eab_model_get_ebook (priv->model), - contact, contact_modified_cb, NULL); + contact, contact_modified_cb, etc); g_object_unref (contact); @@ -266,6 +301,8 @@ remove_contacts (EABModel *model, GArray *indices = (GArray *) data; int count = indices->len; + /* clear whole cache */ + g_hash_table_remove_all (adapter->priv->emails); e_table_model_pre_change (E_TABLE_MODEL (adapter)); if (count == 1) @@ -279,6 +316,9 @@ modify_contact (EABModel *model, gint index, EAddressbookTableAdapter *adapter) { + /* clear whole cache */ + g_hash_table_remove_all (adapter->priv->emails); + e_table_model_pre_change (E_TABLE_MODEL (adapter)); e_table_model_row_changed (E_TABLE_MODEL (adapter), index); } @@ -287,6 +327,9 @@ static void model_changed (EABModel *model, EAddressbookTableAdapter *adapter) { + /* clear whole cache */ + g_hash_table_remove_all (adapter->priv->emails); + e_table_model_pre_change (E_TABLE_MODEL (adapter)); e_table_model_changed (E_TABLE_MODEL (adapter)); } @@ -340,6 +383,8 @@ eab_table_adapter_construct (EAddressbookTableAdapter *adapter, "model_changed", G_CALLBACK(model_changed), adapter); + + priv->emails = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_free); } ETableModel * |