gnokii-users
[Top][All Lists]
Advanced

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

[PATCH] Avoid duplicate phone and address entries


From: Keith Packard
Subject: [PATCH] Avoid duplicate phone and address entries
Date: Sun, 8 Jul 2007 21:33:01 -0700

---
 common/phones/nk6510.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/common/phones/nk6510.c b/common/phones/nk6510.c
index d48ea49..81eca47 100644
--- a/common/phones/nk6510.c
+++ b/common/phones/nk6510.c
@@ -2387,10 +2387,19 @@ static gn_error NK6510_WritePhonebookLocation(gn_data 
*data, struct gn_statemach
                                case GN_PHONEBOOK_ENTRY_StateProvince:
                                case GN_PHONEBOOK_ENTRY_ZipCode:
                                case GN_PHONEBOOK_ENTRY_Country:
+                               case GN_PHONEBOOK_ENTRY_Postal:
                                case GN_PHONEBOOK_ENTRY_LastName:
                                case GN_PHONEBOOK_ENTRY_FirstName:
                                        break;
                                case GN_PHONEBOOK_ENTRY_Number:
+                                       for (j = 0; j < i; j++) {
+                                               if 
(entry->subentries[i].entry_type == entry->subentries[j].entry_type &&
+                                                   
entry->subentries[i].number_type == entry->subentries[j].number_type &&
+                                                   !strcmp 
(entry->subentries[i].data.number, entry->subentries[j].data.number))
+                                                       break;
+                                       }
+                                       if (j < i)
+                                               break;
                                        if (i != defaultn) {
                                                string[0] = 
entry->subentries[i].number_type;
                                                string[1] = string[2] = 
string[3] = 0;
@@ -2447,11 +2456,20 @@ static gn_error NK6510_WritePhonebookLocation(gn_data 
*data, struct gn_statemach
                                for (i = 0; i < entry->subentries_count; i++) {
                                        switch 
(entry->subentries[i].entry_type) {
                                        case GN_PHONEBOOK_ENTRY_ExtendedAddress:
+                                       case GN_PHONEBOOK_ENTRY_Postal:
                                        case GN_PHONEBOOK_ENTRY_Street:
                                        case GN_PHONEBOOK_ENTRY_City:
                                        case GN_PHONEBOOK_ENTRY_StateProvince:
                                        case GN_PHONEBOOK_ENTRY_ZipCode:
                                        case GN_PHONEBOOK_ENTRY_Country:
+                                               for (j = 0; j < i; j++) {
+                                                       if 
(entry->subentries[i].entry_type == entry->subentries[j].entry_type &&
+                                                           
entry->subentries[i].number_type == entry->subentries[j].number_type &&
+                                                           !strcmp 
(entry->subentries[i].data.number, entry->subentries[j].data.number))
+                                                               break;
+                                               }
+                                               if (j < i)
+                                                       break;
                                                j = 
strlen(entry->subentries[i].data.number);
                                                j = char_unicode_encode((string 
+ 1), entry->subentries[i].data.number, j);
                                                string[j + 1] = 0;
-- 
1.5.2.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]