summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-01-18 14:09:00 (UTC)
committer zautrix <zautrix>2005-01-18 14:09:00 (UTC)
commitced210b0c4643ddac6a2e80eab4c85c1994b20e0 (patch) (unidiff)
tree5126b599b1213553ae71512a400f46d7b2037d92 /kabc
parent4b82a36d1b2479dd2e6f00aef45af848f6793099 (diff)
downloadkdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.zip
kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.gz
kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.bz2
ab sync fixes
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index bfcfab5..18b4d58 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -7,466 +7,491 @@
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1; 91 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 //qDebug("csum: %d %d %d", i,k,cSum);
199 } 200 }
200 } 201 }
201 202
202 } 203 }
203 //QString dump = attList.join(","); 204 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 205 //qDebug("csum: %d %s", cSum,dump.latin1());
205 206
206 return cSum; 207 return cSum;
207 208
208} 209}
209void Addressee::computeCsum(const QString &dev) 210void Addressee::computeCsum(const QString &dev)
210{ 211{
211 QStringList l; 212 QStringList l;
212 //if ( !mData->name.isEmpty() ) l.append(mData->name); 213 //if ( !mData->name.isEmpty() ) l.append(mData->name);
213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 225 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 226 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 227 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 228 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 229 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 232 if ( !mData->logo.undefined() ) {
232 //if ( !mData->photo.isEmpty() ) l.append( ); 233 if ( !mData->logo.isIntern() )
233 //if ( !mData->sound.isEmpty() ) l.append( ); 234 l.append( mData->logo.url() );
235 else
236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
237 } else {
238 l.append( "nologo");
239 }
240 if ( !mData->photo.undefined() ) {
241 if ( !mData->photo.isIntern() )
242 l.append( mData->photo.url() );
243 else
244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
245 } else {
246 l.append( "nophoto");
247 }
248#if 0
249 if ( !mData->sound.undefined() ) {
250 if ( !mData->sound.isIntern() )
251 l.append( mData->sound.url() );
252 else
253 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
254 } else {
255 l.append( "nosound");
256 }
257#endif
234 //if ( !mData->agent.isEmpty() ) l.append( ); 258 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 259 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 261 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 262 KABC::PhoneNumber::List::Iterator phoneIter;
239 263
240 QStringList t; 264 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 266 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 268 t.sort();
245 uint iii; 269 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 270 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 271 l.append( t[iii] );
248 t = mData->emails; 272 t = mData->emails;
249 t.sort(); 273 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 274 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 275 l.append( t[iii] );
252 t = mData->categories; 276 t = mData->categories;
253 t.sort(); 277 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 278 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 279 l.append( t[iii] );
256 t = mData->custom; 280 t = mData->custom;
257 t.sort(); 281 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 282 for ( iii = 0; iii < t.count(); ++iii)
259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1; 284 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length()); 285 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length()) 286 if ( find < t[iii].length())
263 l.append( t[iii] ); 287 l.append( t[iii] );
264 288
265 } 289 }
266 KABC::Address::List::Iterator addressIter; 290 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 292 ++addressIter ) {
269 t = (*addressIter).asList(); 293 t = (*addressIter).asList();
270 t.sort(); 294 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 295 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 296 l.append( t[iii] );
273 } 297 }
274 uint cs = getCsum4List(l); 298 uint cs = getCsum4List(l);
275 299
276#if 0 300#if 0
277 for ( iii = 0; iii < l.count(); ++iii) 301 for ( iii = 0; iii < l.count(); ++iii)
278 qDebug("%d***%s***",iii,l[iii].latin1()); 302 qDebug("%d***%s***",iii,l[iii].latin1());
279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
280#endif 304#endif
305
281 306
282 setCsum( dev, QString::number (cs )); 307 setCsum( dev, QString::number (cs ));
283} 308}
284 309
285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
286{ 311{
287 // merge all standard non-outlook fields. 312 // merge all standard non-outlook fields.
288 //if isSubSet (e.g. mobile phone sync) merge all fields 313 //if isSubSet (e.g. mobile phone sync) merge all fields
289 314
290 detach(); 315 detach();
291 if ( isSubSet ) { 316 if ( isSubSet ) {
292 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
293 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
294 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
295 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
296 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
297 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 322 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
298 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 323 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
299 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 324 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
300 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 325 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
301 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 326 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
302 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 327 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
303 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 328 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 329 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 330 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 if ( !mData->birthday.isValid() ) 331 if ( !mData->birthday.isValid() )
307 if ( ad.mData->birthday.isValid()) 332 if ( ad.mData->birthday.isValid())
308 mData->birthday = ad.mData->birthday; 333 mData->birthday = ad.mData->birthday;
309 334
310 } 335 }
311 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 336 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
312 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 337 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
313 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 338 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
314 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 339 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
315 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 340 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
316 QStringList t; 341 QStringList t;
317 QStringList tAD; 342 QStringList tAD;
318 uint iii; 343 uint iii;
319 344
320 // ********** phone numbers 345 // ********** phone numbers
321 if ( isSubSet ) { 346 if ( isSubSet ) {
322 PhoneNumber::List phoneAD = ad.phoneNumbers(); 347 PhoneNumber::List phoneAD = ad.phoneNumbers();
323 PhoneNumber::List::Iterator phoneItAD; 348 PhoneNumber::List::Iterator phoneItAD;
324 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 349 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
325 bool found = false; 350 bool found = false;
326 PhoneNumber::List::Iterator it; 351 PhoneNumber::List::Iterator it;
327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 352 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
328 if ( ( *phoneItAD ).contains( (*it) ) ) { 353 if ( ( *phoneItAD ).contains( (*it) ) ) {
329 found = true; 354 found = true;
330 (*it).setType( ( *phoneItAD ).type() ); 355 (*it).setType( ( *phoneItAD ).type() );
331 (*it).setNumber( ( *phoneItAD ).number() ); 356 (*it).setNumber( ( *phoneItAD ).number() );
332 break; 357 break;
333 } 358 }
334 } 359 }
335 // if ( isSubSet && ! found ) 360 // if ( isSubSet && ! found )
336 if ( ! found ) // LR try this one... 361 if ( ! found ) // LR try this one...
337 mData->phoneNumbers.append( *phoneItAD ); 362 mData->phoneNumbers.append( *phoneItAD );
338 } 363 }
339 } else { 364 } else {
340 PhoneNumber::List phoneAD = ad.phoneNumbers(); 365 PhoneNumber::List phoneAD = ad.phoneNumbers();
341 PhoneNumber::List::Iterator phoneItAD; 366 PhoneNumber::List::Iterator phoneItAD;
342 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 367 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
343 bool found = false; 368 bool found = false;
344 PhoneNumber::List::Iterator it; 369 PhoneNumber::List::Iterator it;
345 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 370 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
346 if ( ( *phoneItAD ).contains( (*it) ) ) { 371 if ( ( *phoneItAD ).contains( (*it) ) ) {
347 found = true; 372 found = true;
348 (*it).setType( ( *phoneItAD ).type() ); 373 (*it).setType( ( *phoneItAD ).type() );
349 (*it).setNumber( ( *phoneItAD ).number() ); 374 (*it).setNumber( ( *phoneItAD ).number() );
350 break; 375 break;
351 } 376 }
352 } 377 }
353 if ( ! found ) { // append numbers which do not have work or home type 378 if ( ! found ) { // append numbers which do not have work or home type
354 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 379 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
355 mData->phoneNumbers.append( *phoneItAD ); 380 mData->phoneNumbers.append( *phoneItAD );
356 } 381 }
357 } 382 }
358 } 383 }
359 if ( isSubSet ) { 384 if ( isSubSet ) {
360 // ************* emails; 385 // ************* emails;
361 t = mData->emails; 386 t = mData->emails;
362 tAD = ad.mData->emails; 387 tAD = ad.mData->emails;
363 for ( iii = 0; iii < tAD.count(); ++iii) 388 for ( iii = 0; iii < tAD.count(); ++iii)
364 if ( !t.contains(tAD[iii] ) ) 389 if ( !t.contains(tAD[iii] ) )
365 mData->emails.append( tAD[iii] ); 390 mData->emails.append( tAD[iii] );
366 } 391 }
367 392
368 // ************* categories; 393 // ************* categories;
369 if ( isSubSet ) { 394 if ( isSubSet ) {
370 t = mData->categories; 395 t = mData->categories;
371 tAD = ad.mData->categories; 396 tAD = ad.mData->categories;
372 for ( iii = 0; iii < tAD.count(); ++iii) 397 for ( iii = 0; iii < tAD.count(); ++iii)
373 if ( !t.contains(tAD[iii] ) ) 398 if ( !t.contains(tAD[iii] ) )
374 mData->categories.append( tAD[iii] ); 399 mData->categories.append( tAD[iii] );
375 } 400 }
376 QStringList::ConstIterator it; 401 QStringList::ConstIterator it;
377 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 402 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
378 QString qualifiedName = (*it).left( (*it).find( ":" )); 403 QString qualifiedName = (*it).left( (*it).find( ":" ));
379 bool found = false; 404 bool found = false;
380 QStringList::ConstIterator itL; 405 QStringList::ConstIterator itL;
381 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 406 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
382 if ( (*itL).startsWith( qualifiedName ) ) { 407 if ( (*itL).startsWith( qualifiedName ) ) {
383 found = true; 408 found = true;
384 break; 409 break;
385 } 410 }
386 } 411 }
387 if ( ! found ) { 412 if ( ! found ) {
388 mData->custom.append( *it ); 413 mData->custom.append( *it );
389 } 414 }
390 } 415 }
391 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 416 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
392 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 417 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
393 if ( !mData->sound.isIntern() ) { 418 if ( !mData->sound.isIntern() ) {
394 if ( mData->sound.url().isEmpty() ) { 419 if ( mData->sound.url().isEmpty() ) {
395 mData->sound = ad.mData->sound; 420 mData->sound = ad.mData->sound;
396 } 421 }
397 } 422 }
398 if ( !mData->agent.isIntern() ) { 423 if ( !mData->agent.isIntern() ) {
399 if ( mData->agent.url().isEmpty() ) { 424 if ( mData->agent.url().isEmpty() ) {
400 mData->agent = ad.mData->agent; 425 mData->agent = ad.mData->agent;
401 } 426 }
402 } 427 }
403 { 428 {
404 Key::List::Iterator itA; 429 Key::List::Iterator itA;
405 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 430 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
406 bool found = false; 431 bool found = false;
407 Key::List::Iterator it; 432 Key::List::Iterator it;
408 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 433 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
409 if ( (*it) == (*itA)) { 434 if ( (*it) == (*itA)) {
410 found = true; 435 found = true;
411 break; 436 break;
412 437
413 } 438 }
414 } 439 }
415 if ( ! found ) { 440 if ( ! found ) {
416 mData->keys.append( *itA ); 441 mData->keys.append( *itA );
417 } 442 }
418 } 443 }
419 } 444 }
420 if ( isSubSet ) { 445 if ( isSubSet ) {
421 KABC::Address::List::Iterator addressIterA; 446 KABC::Address::List::Iterator addressIterA;
422 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 447 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
423 bool found = false; 448 bool found = false;
424 KABC::Address::List::Iterator addressIter; 449 KABC::Address::List::Iterator addressIter;
425 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 450 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
426 ++addressIter ) { 451 ++addressIter ) {
427 if ( (*addressIter) == (*addressIterA)) { 452 if ( (*addressIter) == (*addressIterA)) {
428 found = true; 453 found = true;
429 (*addressIter).setType( (*addressIterA).type() ); 454 (*addressIter).setType( (*addressIterA).type() );
430 break; 455 break;
431 } 456 }
432 457
433 } 458 }
434 if ( isSubSet && ! found ) { 459 if ( isSubSet && ! found ) {
435 mData->addresses.append( *addressIterA ); 460 mData->addresses.append( *addressIterA );
436 } 461 }
437 } 462 }
438 } 463 }
439 //qDebug("merge contact %s ", ad.uid().latin1()); 464 //qDebug("merge contact %s ", ad.uid().latin1());
440 setUid( ad.uid() ); 465 setUid( ad.uid() );
441 setRevision( ad.revision() ); 466 setRevision( ad.revision() );
442} 467}
443 468
444bool Addressee::removeVoice() 469bool Addressee::removeVoice()
445{ 470{
446 PhoneNumber::List phoneN = phoneNumbers(); 471 PhoneNumber::List phoneN = phoneNumbers();
447 PhoneNumber::List::Iterator phoneIt; 472 PhoneNumber::List::Iterator phoneIt;
448 bool found = false; 473 bool found = false;
449 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
450 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
451 if ((*phoneIt).type() - PhoneNumber::Voice ) { 476 if ((*phoneIt).type() - PhoneNumber::Voice ) {
452 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
453 insertPhoneNumber( (*phoneIt) ); 478 insertPhoneNumber( (*phoneIt) );
454 found = true; 479 found = true;
455 } 480 }
456 } 481 }
457 482
458 } 483 }
459 return found; 484 return found;
460} 485}
461 486
462bool Addressee::containsAdr(const Addressee& ad ) 487bool Addressee::containsAdr(const Addressee& ad )
463{ 488{
464 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
465 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
466 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
467 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
468 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
469 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
470 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
471 496
472 // compare phone numbers 497 // compare phone numbers