summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-19 12:24:31 (UTC)
committer zautrix <zautrix>2004-09-19 12:24:31 (UTC)
commite0d8e062c9d8092e47dcadd88b30614ebff43c0c (patch) (unidiff)
tree0a44246ce5e974c8db55ff84a03afb50abaf5d0d
parent5a78d90ce7a9824e52e70f40f41aa6e17f0d3d0d (diff)
downloadkdepimpi-e0d8e062c9d8092e47dcadd88b30614ebff43c0c.zip
kdepimpi-e0d8e062c9d8092e47dcadd88b30614ebff43c0c.tar.gz
kdepimpi-e0d8e062c9d8092e47dcadd88b30614ebff43c0c.tar.bz2
more AB sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 0157721..3a2dc5f 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,558 +1,565 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
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 );
46 46
47struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 QString externalUID; 69 QString externalUID;
70 KURL url; 70 KURL url;
71 Secrecy secrecy; 71 Secrecy secrecy;
72 Picture logo; 72 Picture logo;
73 Picture photo; 73 Picture photo;
74 Sound sound; 74 Sound sound;
75 Agent agent; 75 Agent agent;
76 QString mExternalId; 76 QString mExternalId;
77 PhoneNumber::List phoneNumbers; 77 PhoneNumber::List phoneNumbers;
78 Address::List addresses; 78 Address::List addresses;
79 Key::List keys; 79 Key::List keys;
80 QStringList emails; 80 QStringList emails;
81 QStringList categories; 81 QStringList categories;
82 QStringList custom; 82 QStringList custom;
83 int mTempSyncStat; 83 int mTempSyncStat;
84 Resource *resource; 84 Resource *resource;
85 85
86 bool empty :1; 86 bool empty :1;
87 bool changed :1; 87 bool changed :1;
88}; 88};
89 89
90Addressee::Addressee() 90Addressee::Addressee()
91{ 91{
92 mData = new AddresseeData; 92 mData = new AddresseeData;
93 mData->empty = true; 93 mData->empty = true;
94 mData->changed = false; 94 mData->changed = false;
95 mData->resource = 0; 95 mData->resource = 0;
96 mData->mExternalId = ":"; 96 mData->mExternalId = ":";
97 mData->revision = QDateTime ( QDate( 2004,1,1)); 97 mData->revision = QDateTime ( QDate( 2004,1,1));
98 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 98 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
99} 99}
100 100
101Addressee::~Addressee() 101Addressee::~Addressee()
102{ 102{
103} 103}
104 104
105Addressee::Addressee( const Addressee &a ) 105Addressee::Addressee( const Addressee &a )
106{ 106{
107 mData = a.mData; 107 mData = a.mData;
108} 108}
109 109
110Addressee &Addressee::operator=( const Addressee &a ) 110Addressee &Addressee::operator=( const Addressee &a )
111{ 111{
112 mData = a.mData; 112 mData = a.mData;
113 return (*this); 113 return (*this);
114} 114}
115 115
116Addressee Addressee::copy() 116Addressee Addressee::copy()
117{ 117{
118 Addressee a; 118 Addressee a;
119 *(a.mData) = *mData; 119 *(a.mData) = *mData;
120 return a; 120 return a;
121} 121}
122 122
123void Addressee::detach() 123void Addressee::detach()
124{ 124{
125 if ( mData.count() == 1 ) return; 125 if ( mData.count() == 1 ) return;
126 *this = copy(); 126 *this = copy();
127} 127}
128 128
129bool Addressee::operator==( const Addressee &a ) const 129bool Addressee::operator==( const Addressee &a ) const
130{ 130{
131 if ( uid() != a.uid() ) return false; 131 if ( uid() != a.uid() ) return false;
132 if ( mData->name != a.mData->name ) return false; 132 if ( mData->name != a.mData->name ) return false;
133 if ( mData->formattedName != a.mData->formattedName ) return false; 133 if ( mData->formattedName != a.mData->formattedName ) return false;
134 if ( mData->familyName != a.mData->familyName ) return false; 134 if ( mData->familyName != a.mData->familyName ) return false;
135 if ( mData->givenName != a.mData->givenName ) return false; 135 if ( mData->givenName != a.mData->givenName ) return false;
136 if ( mData->additionalName != a.mData->additionalName ) return false; 136 if ( mData->additionalName != a.mData->additionalName ) return false;
137 if ( mData->prefix != a.mData->prefix ) return false; 137 if ( mData->prefix != a.mData->prefix ) return false;
138 if ( mData->suffix != a.mData->suffix ) return false; 138 if ( mData->suffix != a.mData->suffix ) return false;
139 if ( mData->nickName != a.mData->nickName ) return false; 139 if ( mData->nickName != a.mData->nickName ) return false;
140 if ( mData->birthday != a.mData->birthday ) return false; 140 if ( mData->birthday != a.mData->birthday ) return false;
141 if ( mData->mailer != a.mData->mailer ) return false; 141 if ( mData->mailer != a.mData->mailer ) return false;
142 if ( mData->timeZone != a.mData->timeZone ) return false; 142 if ( mData->timeZone != a.mData->timeZone ) return false;
143 if ( mData->geo != a.mData->geo ) return false; 143 if ( mData->geo != a.mData->geo ) return false;
144 if ( mData->title != a.mData->title ) return false; 144 if ( mData->title != a.mData->title ) return false;
145 if ( mData->role != a.mData->role ) return false; 145 if ( mData->role != a.mData->role ) return false;
146 if ( mData->organization != a.mData->organization ) return false; 146 if ( mData->organization != a.mData->organization ) return false;
147 if ( mData->note != a.mData->note ) return false; 147 if ( mData->note != a.mData->note ) return false;
148 if ( mData->productId != a.mData->productId ) return false; 148 if ( mData->productId != a.mData->productId ) return false;
149 if ( mData->revision != a.mData->revision ) return false; 149 //if ( mData->revision != a.mData->revision ) return false;
150 if ( mData->sortString != a.mData->sortString ) return false; 150 if ( mData->sortString != a.mData->sortString ) return false;
151 if ( mData->secrecy != a.mData->secrecy ) return false; 151 if ( mData->secrecy != a.mData->secrecy ) return false;
152 if ( mData->logo != a.mData->logo ) return false; 152 if ( mData->logo != a.mData->logo ) return false;
153 if ( mData->photo != a.mData->photo ) return false; 153 if ( mData->photo != a.mData->photo ) return false;
154 if ( mData->sound != a.mData->sound ) return false; 154 if ( mData->sound != a.mData->sound ) return false;
155 if ( mData->agent != a.mData->agent ) return false; 155 if ( mData->agent != a.mData->agent ) return false;
156 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 156 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
157 ( mData->url != a.mData->url ) ) return false; 157 ( mData->url != a.mData->url ) ) return false;
158 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 158 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
159 if ( mData->addresses != a.mData->addresses ) return false; 159 if ( mData->addresses != a.mData->addresses ) return false;
160 if ( mData->keys != a.mData->keys ) return false; 160 if ( mData->keys != a.mData->keys ) return false;
161 if ( mData->emails != a.mData->emails ) return false; 161 if ( mData->emails != a.mData->emails ) return false;
162 if ( mData->categories != a.mData->categories ) return false; 162 if ( mData->categories != a.mData->categories ) return false;
163 if ( mData->custom != a.mData->custom ) return false; 163 if ( mData->custom != a.mData->custom ) return false;
164 164
165 return true; 165 return true;
166} 166}
167 167
168bool Addressee::operator!=( const Addressee &a ) const 168bool Addressee::operator!=( const Addressee &a ) const
169{ 169{
170 return !( a == *this ); 170 return !( a == *this );
171} 171}
172 172
173bool Addressee::isEmpty() const 173bool Addressee::isEmpty() const
174{ 174{
175 return mData->empty; 175 return mData->empty;
176} 176}
177ulong Addressee::getCsum4List( const QStringList & attList) 177ulong Addressee::getCsum4List( const QStringList & attList)
178{ 178{
179 int max = attList.count(); 179 int max = attList.count();
180 ulong cSum = 0; 180 ulong cSum = 0;
181 int j,k,i; 181 int j,k,i;
182 int add; 182 int add;
183 for ( i = 0; i < max ; ++i ) { 183 for ( i = 0; i < max ; ++i ) {
184 QString s = attList[i]; 184 QString s = attList[i];
185 if ( ! s.isEmpty() ){ 185 if ( ! s.isEmpty() ){
186 j = s.length(); 186 j = s.length();
187 for ( k = 0; k < j; ++k ) { 187 for ( k = 0; k < j; ++k ) {
188 int mul = k +1; 188 int mul = k +1;
189 add = s[k].unicode (); 189 add = s[k].unicode ();
190 if ( k < 16 ) 190 if ( k < 16 )
191 mul = mul * mul; 191 mul = mul * mul;
192 int ii = i+1; 192 int ii = i+1;
193 add = add * mul *ii*ii*ii; 193 add = add * mul *ii*ii*ii;
194 cSum += add; 194 cSum += add;
195 } 195 }
196 } 196 }
197 197
198 } 198 }
199 //QString dump = attList.join(","); 199 //QString dump = attList.join(",");
200 //qDebug("csum: %d %s", cSum,dump.latin1()); 200 //qDebug("csum: %d %s", cSum,dump.latin1());
201 201
202 return cSum; 202 return cSum;
203 203
204} 204}
205void Addressee::computeCsum(const QString &dev) 205void Addressee::computeCsum(const QString &dev)
206{ 206{
207 QStringList l; 207 QStringList l;
208 if ( !mData->name.isEmpty() ) l.append(mData->name); 208 if ( !mData->name.isEmpty() ) l.append(mData->name);
209 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 209 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
210 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 210 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
211 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 211 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
212 if ( !mData->additionalName ) l.append( mData->additionalName ); 212 if ( !mData->additionalName ) l.append( mData->additionalName );
213 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 213 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
214 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 214 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
215 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 215 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
216 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 216 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
217 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 217 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
218 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 218 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
219 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 219 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
220 if ( !mData->title .isEmpty() ) l.append( mData->title ); 220 if ( !mData->title .isEmpty() ) l.append( mData->title );
221 if ( !mData->role.isEmpty() ) l.append( mData->role ); 221 if ( !mData->role.isEmpty() ) l.append( mData->role );
222 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 222 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
223 if ( !mData->note.isEmpty() ) l.append( mData->note ); 223 if ( !mData->note.isEmpty() ) l.append( mData->note );
224 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 224 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
225 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 225 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
226 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 226 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
227 // if ( !mData->logo.isEmpty() ) l.append( ); 227 // if ( !mData->logo.isEmpty() ) l.append( );
228 //if ( !mData->photo.isEmpty() ) l.append( ); 228 //if ( !mData->photo.isEmpty() ) l.append( );
229 //if ( !mData->sound.isEmpty() ) l.append( ); 229 //if ( !mData->sound.isEmpty() ) l.append( );
230 //if ( !mData->agent.isEmpty() ) l.append( ); 230 //if ( !mData->agent.isEmpty() ) l.append( );
231 //if ( mData->url.isValid() ) l.append( ); 231 //if ( mData->url.isValid() ) l.append( );
232#if 0 232#if 0
233 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 233 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
234 if ( !mData->addresses.isEmpty() ) l.append( ); 234 if ( !mData->addresses.isEmpty() ) l.append( );
235 //if ( !mData->keys.isEmpty() ) l.append( ); 235 //if ( !mData->keys.isEmpty() ) l.append( );
236 if ( !mData->emails.isEmpty() ) l.append( ); 236 if ( !mData->emails.isEmpty() ) l.append( );
237 if ( !mData->categories .isEmpty() ) l.append( ); 237 if ( !mData->categories .isEmpty() ) l.append( );
238 if ( !mData->custom.isEmpty() ) l.append( ); 238 if ( !mData->custom.isEmpty() ) l.append( );
239#endif 239#endif
240 KABC::PhoneNumber::List phoneNumbers; 240 KABC::PhoneNumber::List phoneNumbers;
241 KABC::PhoneNumber::List::Iterator phoneIter; 241 KABC::PhoneNumber::List::Iterator phoneIter;
242 242
243 QStringList t; 243 QStringList t;
244 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 244 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
245 ++phoneIter ) 245 ++phoneIter )
246 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 246 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
247 t.sort(); 247 t.sort();
248 uint iii; 248 uint iii;
249 for ( iii = 0; iii < t.count(); ++iii) 249 for ( iii = 0; iii < t.count(); ++iii)
250 l.append( t[iii] ); 250 l.append( t[iii] );
251 t = mData->emails; 251 t = mData->emails;
252 t.sort(); 252 t.sort();
253 for ( iii = 0; iii < t.count(); ++iii) 253 for ( iii = 0; iii < t.count(); ++iii)
254 l.append( t[iii] ); 254 l.append( t[iii] );
255 t = mData->categories; 255 t = mData->categories;
256 t.sort(); 256 t.sort();
257 for ( iii = 0; iii < t.count(); ++iii) 257 for ( iii = 0; iii < t.count(); ++iii)
258 l.append( t[iii] ); 258 l.append( t[iii] );
259 t = mData->custom; 259 t = mData->custom;
260 t.sort(); 260 t.sort();
261 for ( iii = 0; iii < t.count(); ++iii) 261 for ( iii = 0; iii < t.count(); ++iii)
262 l.append( t[iii] ); 262 l.append( t[iii] );
263 KABC::Address::List::Iterator addressIter; 263 KABC::Address::List::Iterator addressIter;
264 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 264 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
265 ++addressIter ) { 265 ++addressIter ) {
266 t = (*addressIter).asList(); 266 t = (*addressIter).asList();
267 t.sort(); 267 t.sort();
268 for ( iii = 0; iii < t.count(); ++iii) 268 for ( iii = 0; iii < t.count(); ++iii)
269 l.append( t[iii] ); 269 l.append( t[iii] );
270 } 270 }
271 uint cs = getCsum4List(l); 271 uint cs = getCsum4List(l);
272 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 272 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
273 setCsum( dev, QString::number (cs )); 273 setCsum( dev, QString::number (cs ));
274} 274}
275 275
276void Addressee::mergeContact( const Addressee& ad ) 276void Addressee::mergeContact( const Addressee& ad )
277{ 277{
278 278
279 detach(); 279 detach();
280 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 280 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
281 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 281 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
282 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 282 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
283 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 283 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
284 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 284 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
285 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 285 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
286 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 286 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
287 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 287 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
288 if ( !mData->birthday.isValid() ) 288 if ( !mData->birthday.isValid() )
289 if ( ad.mData->birthday.isValid()) 289 if ( ad.mData->birthday.isValid())
290 mData->birthday = ad.mData->birthday; 290 mData->birthday = ad.mData->birthday;
291 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 291 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
292#if 0 292 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
293 if ( !mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 293 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
294 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 294 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
295 if ( !mData->title .isEmpty() ) l.append( mData->title ); 295 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
296 if ( !mData->role.isEmpty() ) l.append( mData->role ); 296 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
297 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 297 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
298 if ( !mData->note.isEmpty() ) l.append( mData->note ); 298 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
299 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 299 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
300 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 300 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
301 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 301 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
302#endif 302
303 // pending:
304 // merging phonenumbers
305 // merging addresses
306 // merging emails;
307 // merging categories;
308 // merging custom;
309 // merging keys
303} 310}
304 311
305void Addressee::removeID(const QString &prof) 312void Addressee::removeID(const QString &prof)
306{ 313{
307 detach(); 314 detach();
308 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 315 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
309 316
310} 317}
311void Addressee::setID( const QString & prof , const QString & id ) 318void Addressee::setID( const QString & prof , const QString & id )
312{ 319{
313 detach(); 320 detach();
314 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 321 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
315 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 322 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
316} 323}
317void Addressee::setTempSyncStat( int id ) 324void Addressee::setTempSyncStat( int id )
318{ 325{
319 if ( mData->mTempSyncStat == id ) return; 326 if ( mData->mTempSyncStat == id ) return;
320 detach(); 327 detach();
321 mData->mTempSyncStat = id; 328 mData->mTempSyncStat = id;
322} 329}
323int Addressee::tempSyncStat() const 330int Addressee::tempSyncStat() const
324{ 331{
325 return mData->mTempSyncStat; 332 return mData->mTempSyncStat;
326} 333}
327 334
328QString Addressee::getID( const QString & prof) 335QString Addressee::getID( const QString & prof)
329{ 336{
330 return KIdManager::getId ( mData->mExternalId, prof ); 337 return KIdManager::getId ( mData->mExternalId, prof );
331} 338}
332 339
333void Addressee::setCsum( const QString & prof , const QString & id ) 340void Addressee::setCsum( const QString & prof , const QString & id )
334{ 341{
335 detach(); 342 detach();
336 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 343 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
337 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 344 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
338 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 345 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
339} 346}
340 347
341QString Addressee::getCsum( const QString & prof) 348QString Addressee::getCsum( const QString & prof)
342{ 349{
343 return KIdManager::getCsum ( mData->mExternalId, prof ); 350 return KIdManager::getCsum ( mData->mExternalId, prof );
344} 351}
345 352
346void Addressee::setIDStr( const QString & s ) 353void Addressee::setIDStr( const QString & s )
347{ 354{
348 detach(); 355 detach();
349 mData->mExternalId = s; 356 mData->mExternalId = s;
350} 357}
351 358
352QString Addressee::IDStr() const 359QString Addressee::IDStr() const
353{ 360{
354 return mData->mExternalId; 361 return mData->mExternalId;
355} 362}
356 363
357void Addressee::setExternalUID( const QString &id ) 364void Addressee::setExternalUID( const QString &id )
358{ 365{
359 if ( id == mData->externalUID ) return; 366 if ( id == mData->externalUID ) return;
360 detach(); 367 detach();
361 mData->empty = false; 368 mData->empty = false;
362 mData->externalUID = id; 369 mData->externalUID = id;
363} 370}
364 371
365QString Addressee::externalUID() const 372QString Addressee::externalUID() const
366{ 373{
367 return mData->externalUID; 374 return mData->externalUID;
368} 375}
369 376
370void Addressee::setUid( const QString &id ) 377void Addressee::setUid( const QString &id )
371{ 378{
372 if ( id == mData->uid ) return; 379 if ( id == mData->uid ) return;
373 detach(); 380 detach();
374 mData->empty = false; 381 mData->empty = false;
375 mData->uid = id; 382 mData->uid = id;
376} 383}
377 384
378QString Addressee::uid() const 385QString Addressee::uid() const
379{ 386{
380 if ( mData->uid.isEmpty() ) 387 if ( mData->uid.isEmpty() )
381 mData->uid = KApplication::randomString( 10 ); 388 mData->uid = KApplication::randomString( 10 );
382 389
383 return mData->uid; 390 return mData->uid;
384} 391}
385 392
386QString Addressee::uidLabel() 393QString Addressee::uidLabel()
387{ 394{
388 return i18n("Unique Identifier"); 395 return i18n("Unique Identifier");
389} 396}
390 397
391void Addressee::setName( const QString &name ) 398void Addressee::setName( const QString &name )
392{ 399{
393 if ( name == mData->name ) return; 400 if ( name == mData->name ) return;
394 detach(); 401 detach();
395 mData->empty = false; 402 mData->empty = false;
396 mData->name = name; 403 mData->name = name;
397} 404}
398 405
399QString Addressee::name() const 406QString Addressee::name() const
400{ 407{
401 return mData->name; 408 return mData->name;
402} 409}
403 410
404QString Addressee::nameLabel() 411QString Addressee::nameLabel()
405{ 412{
406 return i18n("Name"); 413 return i18n("Name");
407} 414}
408 415
409 416
410void Addressee::setFormattedName( const QString &formattedName ) 417void Addressee::setFormattedName( const QString &formattedName )
411{ 418{
412 if ( formattedName == mData->formattedName ) return; 419 if ( formattedName == mData->formattedName ) return;
413 detach(); 420 detach();
414 mData->empty = false; 421 mData->empty = false;
415 mData->formattedName = formattedName; 422 mData->formattedName = formattedName;
416} 423}
417 424
418QString Addressee::formattedName() const 425QString Addressee::formattedName() const
419{ 426{
420 return mData->formattedName; 427 return mData->formattedName;
421} 428}
422 429
423QString Addressee::formattedNameLabel() 430QString Addressee::formattedNameLabel()
424{ 431{
425 return i18n("Formatted Name"); 432 return i18n("Formatted Name");
426} 433}
427 434
428 435
429void Addressee::setFamilyName( const QString &familyName ) 436void Addressee::setFamilyName( const QString &familyName )
430{ 437{
431 if ( familyName == mData->familyName ) return; 438 if ( familyName == mData->familyName ) return;
432 detach(); 439 detach();
433 mData->empty = false; 440 mData->empty = false;
434 mData->familyName = familyName; 441 mData->familyName = familyName;
435} 442}
436 443
437QString Addressee::familyName() const 444QString Addressee::familyName() const
438{ 445{
439 return mData->familyName; 446 return mData->familyName;
440} 447}
441 448
442QString Addressee::familyNameLabel() 449QString Addressee::familyNameLabel()
443{ 450{
444 return i18n("Family Name"); 451 return i18n("Family Name");
445} 452}
446 453
447 454
448void Addressee::setGivenName( const QString &givenName ) 455void Addressee::setGivenName( const QString &givenName )
449{ 456{
450 if ( givenName == mData->givenName ) return; 457 if ( givenName == mData->givenName ) return;
451 detach(); 458 detach();
452 mData->empty = false; 459 mData->empty = false;
453 mData->givenName = givenName; 460 mData->givenName = givenName;
454} 461}
455 462
456QString Addressee::givenName() const 463QString Addressee::givenName() const
457{ 464{
458 return mData->givenName; 465 return mData->givenName;
459} 466}
460 467
461QString Addressee::givenNameLabel() 468QString Addressee::givenNameLabel()
462{ 469{
463 return i18n("Given Name"); 470 return i18n("Given Name");
464} 471}
465 472
466 473
467void Addressee::setAdditionalName( const QString &additionalName ) 474void Addressee::setAdditionalName( const QString &additionalName )
468{ 475{
469 if ( additionalName == mData->additionalName ) return; 476 if ( additionalName == mData->additionalName ) return;
470 detach(); 477 detach();
471 mData->empty = false; 478 mData->empty = false;
472 mData->additionalName = additionalName; 479 mData->additionalName = additionalName;
473} 480}
474 481
475QString Addressee::additionalName() const 482QString Addressee::additionalName() const
476{ 483{
477 return mData->additionalName; 484 return mData->additionalName;
478} 485}
479 486
480QString Addressee::additionalNameLabel() 487QString Addressee::additionalNameLabel()
481{ 488{
482 return i18n("Additional Names"); 489 return i18n("Additional Names");
483} 490}
484 491
485 492
486void Addressee::setPrefix( const QString &prefix ) 493void Addressee::setPrefix( const QString &prefix )
487{ 494{
488 if ( prefix == mData->prefix ) return; 495 if ( prefix == mData->prefix ) return;
489 detach(); 496 detach();
490 mData->empty = false; 497 mData->empty = false;
491 mData->prefix = prefix; 498 mData->prefix = prefix;
492} 499}
493 500
494QString Addressee::prefix() const 501QString Addressee::prefix() const
495{ 502{
496 return mData->prefix; 503 return mData->prefix;
497} 504}
498 505
499QString Addressee::prefixLabel() 506QString Addressee::prefixLabel()
500{ 507{
501 return i18n("Honorific Prefixes"); 508 return i18n("Honorific Prefixes");
502} 509}
503 510
504 511
505void Addressee::setSuffix( const QString &suffix ) 512void Addressee::setSuffix( const QString &suffix )
506{ 513{
507 if ( suffix == mData->suffix ) return; 514 if ( suffix == mData->suffix ) return;
508 detach(); 515 detach();
509 mData->empty = false; 516 mData->empty = false;
510 mData->suffix = suffix; 517 mData->suffix = suffix;
511} 518}
512 519
513QString Addressee::suffix() const 520QString Addressee::suffix() const
514{ 521{
515 return mData->suffix; 522 return mData->suffix;
516} 523}
517 524
518QString Addressee::suffixLabel() 525QString Addressee::suffixLabel()
519{ 526{
520 return i18n("Honorific Suffixes"); 527 return i18n("Honorific Suffixes");
521} 528}
522 529
523 530
524void Addressee::setNickName( const QString &nickName ) 531void Addressee::setNickName( const QString &nickName )
525{ 532{
526 if ( nickName == mData->nickName ) return; 533 if ( nickName == mData->nickName ) return;
527 detach(); 534 detach();
528 mData->empty = false; 535 mData->empty = false;
529 mData->nickName = nickName; 536 mData->nickName = nickName;
530} 537}
531 538
532QString Addressee::nickName() const 539QString Addressee::nickName() const
533{ 540{
534 return mData->nickName; 541 return mData->nickName;
535} 542}
536 543
537QString Addressee::nickNameLabel() 544QString Addressee::nickNameLabel()
538{ 545{
539 return i18n("Nick Name"); 546 return i18n("Nick Name");
540} 547}
541 548
542 549
543void Addressee::setBirthday( const QDateTime &birthday ) 550void Addressee::setBirthday( const QDateTime &birthday )
544{ 551{
545 if ( birthday == mData->birthday ) return; 552 if ( birthday == mData->birthday ) return;
546 detach(); 553 detach();
547 mData->empty = false; 554 mData->empty = false;
548 mData->birthday = birthday; 555 mData->birthday = birthday;
549} 556}
550 557
551QDateTime Addressee::birthday() const 558QDateTime Addressee::birthday() const
552{ 559{
553 return mData->birthday; 560 return mData->birthday;
554} 561}
555 562
556QString Addressee::birthdayLabel() 563QString Addressee::birthdayLabel()
557{ 564{
558 return i18n("Birthday"); 565 return i18n("Birthday");