[PATCH 6/6] Fix problem with double numer in call log

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From be0a6ef8affbc3c1d0b1fbd94b1e78cd2c94f17c Mon Sep 17 00:00:00 2001
From: Rafal Michalski <michalski.raf@xxxxxxxxx>
Date: Tue, 28 Sep 2010 11:07:48 +0200
Subject: [PATCH 6/6] Fix problem with double number in call log

Previously after downloading call log there was two times the same number
for call binded with phonebook - one HOME/WORK type and second OTHER type
in downloaded vCard structure. Now there is only one number with proper
type (HOME or WORK).
---
 plugins/phonebook-tracker.c |   18 ++++++++++++++++--
 plugins/vcard.c             |    1 -
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index ab874e5..2d94bc6 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -774,10 +774,24 @@ static struct phonebook_contact *find_contact(GSList *contacts, const char *id)
 static struct phonebook_number *find_phone(GSList *numbers, const char *phone,
 								int type)
 {
-	GSList *l;
+	GSList *l = numbers;
 	struct phonebook_number *pb_num;
 
-	for (l = numbers; l; l = l->next) {
+	if (g_slist_length(l) == 1 && (pb_num = l->data) &&
+					g_strcmp0(pb_num->tel, phone) == 0) {
+
+		if ((type == TEL_TYPE_HOME || type == TEL_TYPE_WORK) &&
+					pb_num->type == TEL_TYPE_OTHER)	{
+			pb_num->type = type;
+			return pb_num;
+		}
+
+		if (type == TEL_TYPE_OTHER && (pb_num->type == TEL_TYPE_HOME ||
+					pb_num->type == TEL_TYPE_WORK))
+			return pb_num;
+	}
+
+	for (; l; l = l->next) {
 		pb_num = l->data;
 		/* Returning phonebook number if phone values and type values
 		 * are equal */
diff --git a/plugins/vcard.c b/plugins/vcard.c
index c720954..41f9fbd 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -452,7 +452,6 @@ static void vcard_printf_datetime(GString *vcards,
 static void vcard_printf_end(GString *vcards)
 {
 	vcard_printf(vcards, "END:VCARD");
-	vcard_printf(vcards, "");
 }
 
 void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
-- 
1.6.3.3


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux