aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2004-06-26 09:42:27 +0800
committerHans Petter <hansp@src.gnome.org>2004-06-26 09:42:27 +0800
commit8993f0bf1298bcbad2fd9f7eb044ccb493897d9d (patch)
treeec42acbfa3583bc3711961367ae971ebaaedc60a
parent19ed9cded5ddbf8529262c647f8688bfa4f408ef (diff)
downloadgsoc2013-evolution-8993f0bf1298bcbad2fd9f7eb044ccb493897d9d.tar
gsoc2013-evolution-8993f0bf1298bcbad2fd9f7eb044ccb493897d9d.tar.gz
gsoc2013-evolution-8993f0bf1298bcbad2fd9f7eb044ccb493897d9d.tar.bz2
gsoc2013-evolution-8993f0bf1298bcbad2fd9f7eb044ccb493897d9d.tar.lz
gsoc2013-evolution-8993f0bf1298bcbad2fd9f7eb044ccb493897d9d.tar.xz
gsoc2013-evolution-8993f0bf1298bcbad2fd9f7eb044ccb493897d9d.tar.zst
gsoc2013-evolution-8993f0bf1298bcbad2fd9f7eb044ccb493897d9d.zip
Implement. (eab_contact_compare_name): Don't leak if only one of the
2004-06-25 Hans Petter Jansson <hpj@ximian.com> * gui/meging/eab-contact-compare.[ch] (eab_contact_compare_file_as): Implement. (eab_contact_compare_name): Don't leak if only one of the strings is NULL. (use_common_book_cb): Include file_as in query. svn path=/trunk/; revision=26527
-rw-r--r--addressbook/ChangeLog8
-rw-r--r--addressbook/gui/merging/eab-contact-compare.c45
-rw-r--r--addressbook/gui/merging/eab-contact-compare.h1
3 files changed, 52 insertions, 2 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index a7b390ac49..76b734b563 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,13 @@
2004-06-25 Hans Petter Jansson <hpj@ximian.com>
+ * gui/meging/eab-contact-compare.[ch] (eab_contact_compare_file_as):
+ Implement.
+ (eab_contact_compare_name): Don't leak if only one of the strings is
+ NULL.
+ (use_common_book_cb): Include file_as in query.
+
+2004-06-25 Hans Petter Jansson <hpj@ximian.com>
+
* gui/contact-editor/e-contact-editor.c (fill_in_address_textview): Add
a newline between street line and rest of extended address.
(extract_address_textview): Omit the newline trailing the street line.
diff --git a/addressbook/gui/merging/eab-contact-compare.c b/addressbook/gui/merging/eab-contact-compare.c
index f4f9afe1a7..bc68784ed7 100644
--- a/addressbook/gui/merging/eab-contact-compare.c
+++ b/addressbook/gui/merging/eab-contact-compare.c
@@ -286,6 +286,37 @@ eab_contact_compare_name_to_string_full (EContact *contact, const gchar *str, gb
}
EABContactMatchType
+eab_contact_compare_file_as (EContact *contact1, EContact *contact2)
+{
+ EABContactMatchType match_type;
+ gchar *a, *b;
+
+ g_return_val_if_fail (E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+ g_return_val_if_fail (E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ a = e_contact_get (contact1, E_CONTACT_FILE_AS);
+ b = e_contact_get (contact2, E_CONTACT_FILE_AS);
+
+ if (a == NULL || b == NULL) {
+ g_free (a);
+ g_free (b);
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+ }
+
+ if (!strcmp (a, b))
+ match_type = EAB_CONTACT_MATCH_EXACT;
+ else if (g_utf8_validate (a, -1, NULL) && g_utf8_validate (b, -1, NULL) &&
+ !g_utf8_collate (a, b))
+ match_type = EAB_CONTACT_MATCH_PARTIAL;
+ else
+ match_type = EAB_CONTACT_MATCH_NONE;
+
+ g_free (a);
+ g_free (b);
+ return match_type;
+}
+
+EABContactMatchType
eab_contact_compare_name (EContact *contact1, EContact *contact2)
{
EContactName *a, *b;
@@ -298,8 +329,11 @@ eab_contact_compare_name (EContact *contact1, EContact *contact2)
a = e_contact_get (contact1, E_CONTACT_NAME);
b = e_contact_get (contact2, E_CONTACT_NAME);
- if (a == NULL || b == NULL)
+ if (a == NULL || b == NULL) {
+ g_free (a);
+ g_free (b);
return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+ }
if (a->given && b->given && *a->given && *b->given) {
++possible;
@@ -530,6 +564,7 @@ eab_contact_compare (EContact *contact1, EContact *contact2)
result = combine_comparisons (result, eab_contact_compare_email (contact1, contact2));
result = combine_comparisons (result, eab_contact_compare_address (contact1, contact2));
result = combine_comparisons (result, eab_contact_compare_telephone (contact1, contact2));
+ result = combine_comparisons (result, eab_contact_compare_file_as (contact1, contact2));
return result;
}
@@ -618,7 +653,7 @@ use_common_book_cb (EBook *book, gpointer closure)
GList *contact_email;
gchar *query_parts[MAX_QUERY_PARTS];
gint p=0;
- gchar *qj;
+ gchar *contact_file_as, *qj;
EBookQuery *query = NULL;
int i;
@@ -628,6 +663,12 @@ use_common_book_cb (EBook *book, gpointer closure)
return;
}
+ contact_file_as = e_contact_get (contact, E_CONTACT_FILE_AS);
+ if (contact_file_as) {
+ query_parts [p++] = g_strdup_printf ("(contains \"file_as\" \"%s\")", contact_file_as);
+ g_free (contact_file_as);
+ }
+
contact_name = e_contact_get (contact, E_CONTACT_NAME);
if (contact_name) {
if (contact_name->given && *contact_name->given)
diff --git a/addressbook/gui/merging/eab-contact-compare.h b/addressbook/gui/merging/eab-contact-compare.h
index 4b97b3c698..153e44aef1 100644
--- a/addressbook/gui/merging/eab-contact-compare.h
+++ b/addressbook/gui/merging/eab-contact-compare.h
@@ -56,6 +56,7 @@ EABContactMatchType eab_contact_compare_name_to_string_full (EContact *contact,
gint *matched_parts, EABContactMatchPart *first_matched_part,
gint *matched_character_count);
+EABContactMatchType eab_contact_compare_file_as (EContact *contact1, EContact *contact2);
EABContactMatchType eab_contact_compare_name (EContact *contact1, EContact *contact2);
EABContactMatchType eab_contact_compare_nickname (EContact *contact1, EContact *contact2);
EABContactMatchType eab_contact_compare_email (EContact *contact1, EContact *contact2);