aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook/e-card-compare.c
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-06-30 13:23:09 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-06-30 13:23:09 +0800
commit7c5dd95cd7aefa8243edac3c67bf1910fc905c4e (patch)
tree5c8dc3c28a6bac7d3e1643e9cdcfb0b75f28ebbc /addressbook/backend/ebook/e-card-compare.c
parentc187a911c8926429946cc385fd5f7c8f0932d3e3 (diff)
downloadgsoc2013-evolution-7c5dd95cd7aefa8243edac3c67bf1910fc905c4e.tar
gsoc2013-evolution-7c5dd95cd7aefa8243edac3c67bf1910fc905c4e.tar.gz
gsoc2013-evolution-7c5dd95cd7aefa8243edac3c67bf1910fc905c4e.tar.bz2
gsoc2013-evolution-7c5dd95cd7aefa8243edac3c67bf1910fc905c4e.tar.lz
gsoc2013-evolution-7c5dd95cd7aefa8243edac3c67bf1910fc905c4e.tar.xz
gsoc2013-evolution-7c5dd95cd7aefa8243edac3c67bf1910fc905c4e.tar.zst
gsoc2013-evolution-7c5dd95cd7aefa8243edac3c67bf1910fc905c4e.zip
Make the standard for considering two cards to be match stricter.
2001-06-30 Jon Trowbridge <trow@ximian.com> * gui/merging/e-card-merging.c (match_query_callback): Make the standard for considering two cards to be match stricter. * gui/component/select-names/e-select-names-completion.c (make_match): Use the card's use-score to set the match's sort_major value. (match_name): Removed obsolete code. (e_select_names_completion_begin): Added (double) cast to make match->score calculation come out properly. * backend/ebook/e-card.c: Added X-EVOLUTION-LAST-USE and X-EVOLUTION-USE-SCORE to attribute_jump_array. (e_card_get_today): Added. A convenience routine for getting today's date and putting it in a GDate. (e_card_get_use_score): Added. Compute the current, time-decayed, use-score for the card. (e_card_touch): Increment the use-score by one; update the last used date. (e_card_date_to_string): Added as a convenience routine, getting rid of some code duplication. (e_card_get_vobject): Add handlers for X-EVOLUTION-USE-SCORE and X-EVOLUTION-LAST-USE. (parse_last_use): Added. (parse_use_score): Added. (e_card_class_init): Added args for last-use and use-score. (e_card_get_arg): Added handlers for last-use and use-score. o (e_card_set_arg): Added handlers for last-use and use-score. * backend/ebook/e-destination.c: Added pending_card_id to EDestinationPrivate struct. (e_destination_copy): Copy the pending_card_id. (e_destination_is_empty): Check for a pending_card_id. We are non-empty if we have one. (e_destination_clear_card): Clear pending_card_id. (e_destination_set_card): Clear pending_card_id. (e_destination_has_pending_card): Added. (e_destination_use_card): Added. An asynchronous way to load a pending card and then apply a callback to it. (build_field): Be paranoid, map our special characters to '_'. (e_destination_export): Use EXPORT_MAX_FIELDS symbol rather than a hard-wired array size. Added the "card" entry. (e_destination_import): Fix bug in handling of the "name" field. Process the "card" field. (e_destination_touch): "Touch" and commit the ECard corresponding to the e-mail address in the destination. (A query against the local addressbook is actually performed, in case the destination isn't cardified. * backend/ebook/e-card-compare.c (e_card_compare_name): Revamp the way E_CARD_MATCH_FOO results are mapped to comparison results. Report better matches when the family name is matched. svn path=/trunk/; revision=10626
Diffstat (limited to 'addressbook/backend/ebook/e-card-compare.c')
-rw-r--r--addressbook/backend/ebook/e-card-compare.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/addressbook/backend/ebook/e-card-compare.c b/addressbook/backend/ebook/e-card-compare.c
index 92f1cc9099..05be64d560 100644
--- a/addressbook/backend/ebook/e-card-compare.c
+++ b/addressbook/backend/ebook/e-card-compare.c
@@ -105,6 +105,7 @@ e_card_compare_name (ECard *card1, ECard *card2)
{
ECardName *a, *b;
gint matches=0, possible=0;
+ gboolean given_match = FALSE, additional_match = FALSE, family_match = FALSE;
g_return_val_if_fail (card1 && E_IS_CARD (card1), E_CARD_MATCH_NOT_APPLICABLE);
g_return_val_if_fail (card2 && E_IS_CARD (card2), E_CARD_MATCH_NOT_APPLICABLE);
@@ -117,36 +118,45 @@ e_card_compare_name (ECard *card1, ECard *card2)
if (a->given && b->given) {
++possible;
- if (name_fragment_match (a->given, b->given))
+ if (name_fragment_match (a->given, b->given)) {
++matches;
+ given_match = TRUE;
+ }
}
if (a->additional && b->additional) {
++possible;
- if (name_fragment_match (a->additional, b->additional))
+ if (name_fragment_match (a->additional, b->additional)) {
++matches;
+ additional_match = TRUE;
+ }
}
if (a->family && b->family) {
++possible;
- if (name_fragment_match (a->family, b->family))
+ if (name_fragment_match (a->family, b->family)) {
++matches;
+ family_match = TRUE;
+ }
}
/* Now look at the # of matches and try to intelligently map
- an E_CARD_MATCH_* type to it. */
+ an E_CARD_MATCH_* type to it. Special consideration is given
+ to family-name matches. */
if (possible == 0)
return E_CARD_MATCH_NOT_APPLICABLE;
- if (matches == 0)
- return E_CARD_MATCH_NONE;
- if (matches == possible) {
- return possible > 1 ? E_CARD_MATCH_EXACT : E_CARD_MATCH_PARTIAL;
- } else if (matches == possible-1)
- return E_CARD_MATCH_PARTIAL;
- else
- return E_CARD_MATCH_VAGUE;
+ if (possible == 1)
+ return family_match ? E_CARD_MATCH_VAGUE : E_CARD_MATCH_NONE;
+
+ if (possible == matches)
+ return family_match ? E_CARD_MATCH_EXACT : E_CARD_MATCH_PARTIAL;
+
+ if (possible == matches+1)
+ return family_match ? E_CARD_MATCH_PARTIAL : E_CARD_MATCH_VAGUE;
+
+ return E_CARD_MATCH_NONE;
}