summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 25c77f6..e571980 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,829 +1,861 @@
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 );
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}; 91};
92 92
93Addressee::Addressee() 93Addressee::Addressee()
94{ 94{
95 mData = new AddresseeData; 95 mData = new AddresseeData;
96 mData->empty = true; 96 mData->empty = true;
97 mData->changed = false; 97 mData->changed = false;
98 mData->resource = 0; 98 mData->resource = 0;
99 mData->mExternalId = ":"; 99 mData->mExternalId = ":";
100 mData->revision = QDateTime ( QDate( 2003,1,1)); 100 mData->revision = QDateTime ( QDate( 2003,1,1));
101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 102}
103 103
104Addressee::~Addressee() 104Addressee::~Addressee()
105{ 105{
106} 106}
107 107
108Addressee::Addressee( const Addressee &a ) 108Addressee::Addressee( const Addressee &a )
109{ 109{
110 mData = a.mData; 110 mData = a.mData;
111} 111}
112 112
113Addressee &Addressee::operator=( const Addressee &a ) 113Addressee &Addressee::operator=( const Addressee &a )
114{ 114{
115 mData = a.mData; 115 mData = a.mData;
116 return (*this); 116 return (*this);
117} 117}
118 118
119Addressee Addressee::copy() 119Addressee Addressee::copy()
120{ 120{
121 Addressee a; 121 Addressee a;
122 *(a.mData) = *mData; 122 *(a.mData) = *mData;
123 return a; 123 return a;
124} 124}
125 125
126void Addressee::detach() 126void Addressee::detach()
127{ 127{
128 if ( mData.count() == 1 ) return; 128 if ( mData.count() == 1 ) return;
129 *this = copy(); 129 *this = copy();
130} 130}
131 131
132bool Addressee::operator==( const Addressee &a ) const 132bool Addressee::operator==( const Addressee &a ) const
133{ 133{
134 if ( uid() != a.uid() ) return false; 134 if ( uid() != a.uid() ) return false;
135 if ( mData->name != a.mData->name ) return false; 135 if ( mData->name != a.mData->name ) return false;
136 if ( mData->formattedName != a.mData->formattedName ) return false; 136 if ( mData->formattedName != a.mData->formattedName ) return false;
137 if ( mData->familyName != a.mData->familyName ) return false; 137 if ( mData->familyName != a.mData->familyName ) return false;
138 if ( mData->givenName != a.mData->givenName ) return false; 138 if ( mData->givenName != a.mData->givenName ) return false;
139 if ( mData->additionalName != a.mData->additionalName ) return false; 139 if ( mData->additionalName != a.mData->additionalName ) return false;
140 if ( mData->prefix != a.mData->prefix ) return false; 140 if ( mData->prefix != a.mData->prefix ) return false;
141 if ( mData->suffix != a.mData->suffix ) return false; 141 if ( mData->suffix != a.mData->suffix ) return false;
142 if ( mData->nickName != a.mData->nickName ) return false; 142 if ( mData->nickName != a.mData->nickName ) return false;
143 if ( mData->birthday != a.mData->birthday ) return false; 143 if ( mData->birthday != a.mData->birthday ) return false;
144 if ( mData->mailer != a.mData->mailer ) return false; 144 if ( mData->mailer != a.mData->mailer ) return false;
145 if ( mData->timeZone != a.mData->timeZone ) return false; 145 if ( mData->timeZone != a.mData->timeZone ) return false;
146 if ( mData->geo != a.mData->geo ) return false; 146 if ( mData->geo != a.mData->geo ) return false;
147 if ( mData->title != a.mData->title ) return false; 147 if ( mData->title != a.mData->title ) return false;
148 if ( mData->role != a.mData->role ) return false; 148 if ( mData->role != a.mData->role ) return false;
149 if ( mData->organization != a.mData->organization ) return false; 149 if ( mData->organization != a.mData->organization ) return false;
150 if ( mData->note != a.mData->note ) return false; 150 if ( mData->note != a.mData->note ) return false;
151 if ( mData->productId != a.mData->productId ) return false; 151 if ( mData->productId != a.mData->productId ) return false;
152 //if ( mData->revision != a.mData->revision ) return false; 152 //if ( mData->revision != a.mData->revision ) return false;
153 if ( mData->sortString != a.mData->sortString ) return false; 153 if ( mData->sortString != a.mData->sortString ) return false;
154 if ( mData->secrecy != a.mData->secrecy ) return false; 154 if ( mData->secrecy != a.mData->secrecy ) return false;
155 if ( mData->logo != a.mData->logo ) return false; 155 if ( mData->logo != a.mData->logo ) return false;
156 if ( mData->photo != a.mData->photo ) return false; 156 if ( mData->photo != a.mData->photo ) return false;
157 if ( mData->sound != a.mData->sound ) return false; 157 if ( mData->sound != a.mData->sound ) return false;
158 if ( mData->agent != a.mData->agent ) return false; 158 if ( mData->agent != a.mData->agent ) return false;
159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
160 ( mData->url != a.mData->url ) ) return false; 160 ( mData->url != a.mData->url ) ) return false;
161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
162 if ( mData->addresses != a.mData->addresses ) return false; 162 if ( mData->addresses != a.mData->addresses ) return false;
163 if ( mData->keys != a.mData->keys ) return false; 163 if ( mData->keys != a.mData->keys ) return false;
164 if ( mData->emails != a.mData->emails ) return false; 164 if ( mData->emails != a.mData->emails ) return false;
165 if ( mData->categories != a.mData->categories ) return false; 165 if ( mData->categories != a.mData->categories ) return false;
166 if ( mData->custom != a.mData->custom ) return false; 166 if ( mData->custom != a.mData->custom ) return false;
167 167
168 return true; 168 return true;
169} 169}
170 170
171bool Addressee::operator!=( const Addressee &a ) const 171bool Addressee::operator!=( const Addressee &a ) const
172{ 172{
173 return !( a == *this ); 173 return !( a == *this );
174} 174}
175 175
176bool Addressee::isEmpty() const 176bool Addressee::isEmpty() const
177{ 177{
178 return mData->empty; 178 return mData->empty;
179} 179}
180ulong Addressee::getCsum4List( const QStringList & attList) 180ulong Addressee::getCsum4List( const QStringList & attList)
181{ 181{
182 int max = attList.count(); 182 int max = attList.count();
183 ulong cSum = 0; 183 ulong cSum = 0;
184 int j,k,i; 184 int j,k,i;
185 int add; 185 int add;
186 for ( i = 0; i < max ; ++i ) { 186 for ( i = 0; i < max ; ++i ) {
187 QString s = attList[i]; 187 QString s = attList[i];
188 if ( ! s.isEmpty() ){ 188 if ( ! s.isEmpty() ){
189 j = s.length(); 189 j = s.length();
190 for ( k = 0; k < j; ++k ) { 190 for ( k = 0; k < j; ++k ) {
191 int mul = k +1; 191 int mul = k +1;
192 add = s[k].unicode (); 192 add = s[k].unicode ();
193 if ( k < 16 ) 193 if ( k < 16 )
194 mul = mul * mul; 194 mul = mul * mul;
195 int ii = i+1; 195 int ii = i+1;
196 add = add * mul *ii*ii*ii; 196 add = add * mul *ii*ii*ii;
197 cSum += add; 197 cSum += add;
198 } 198 }
199 } 199 }
200 200
201 } 201 }
202 //QString dump = attList.join(","); 202 //QString dump = attList.join(",");
203 //qDebug("csum: %d %s", cSum,dump.latin1()); 203 //qDebug("csum: %d %s", cSum,dump.latin1());
204 204
205 return cSum; 205 return cSum;
206 206
207} 207}
208void Addressee::computeCsum(const QString &dev) 208void Addressee::computeCsum(const QString &dev)
209{ 209{
210 QStringList l; 210 QStringList l;
211 if ( !mData->name.isEmpty() ) l.append(mData->name); 211 if ( !mData->name.isEmpty() ) l.append(mData->name);
212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
215 if ( !mData->additionalName ) l.append( mData->additionalName ); 215 if ( !mData->additionalName ) l.append( mData->additionalName );
216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
223 if ( !mData->title .isEmpty() ) l.append( mData->title ); 223 if ( !mData->title .isEmpty() ) l.append( mData->title );
224 if ( !mData->role.isEmpty() ) l.append( mData->role ); 224 if ( !mData->role.isEmpty() ) l.append( mData->role );
225 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 225 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
226 if ( !mData->note.isEmpty() ) l.append( mData->note ); 226 if ( !mData->note.isEmpty() ) l.append( mData->note );
227 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 227 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
230 // if ( !mData->logo.isEmpty() ) l.append( ); 230 // if ( !mData->logo.isEmpty() ) l.append( );
231 //if ( !mData->photo.isEmpty() ) l.append( ); 231 //if ( !mData->photo.isEmpty() ) l.append( );
232 //if ( !mData->sound.isEmpty() ) l.append( ); 232 //if ( !mData->sound.isEmpty() ) l.append( );
233 //if ( !mData->agent.isEmpty() ) l.append( ); 233 //if ( !mData->agent.isEmpty() ) l.append( );
234 //if ( mData->url.isValid() ) l.append( ); 234 //if ( mData->url.isValid() ) l.append( );
235#if 0 235#if 0
236 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 236 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
237 if ( !mData->addresses.isEmpty() ) l.append( ); 237 if ( !mData->addresses.isEmpty() ) l.append( );
238 //if ( !mData->keys.isEmpty() ) l.append( ); 238 //if ( !mData->keys.isEmpty() ) l.append( );
239 if ( !mData->emails.isEmpty() ) l.append( ); 239 if ( !mData->emails.isEmpty() ) l.append( );
240 if ( !mData->categories .isEmpty() ) l.append( ); 240 if ( !mData->categories .isEmpty() ) l.append( );
241 if ( !mData->custom.isEmpty() ) l.append( ); 241 if ( !mData->custom.isEmpty() ) l.append( );
242#endif 242#endif
243 KABC::PhoneNumber::List phoneNumbers; 243 KABC::PhoneNumber::List phoneNumbers;
244 KABC::PhoneNumber::List::Iterator phoneIter; 244 KABC::PhoneNumber::List::Iterator phoneIter;
245 245
246 QStringList t; 246 QStringList t;
247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
248 ++phoneIter ) 248 ++phoneIter )
249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
250 t.sort(); 250 t.sort();
251 uint iii; 251 uint iii;
252 for ( iii = 0; iii < t.count(); ++iii) 252 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 253 l.append( t[iii] );
254 t = mData->emails; 254 t = mData->emails;
255 t.sort(); 255 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 256 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 257 l.append( t[iii] );
258 t = mData->categories; 258 t = mData->categories;
259 t.sort(); 259 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 260 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 261 l.append( t[iii] );
262 t = mData->custom; 262 t = mData->custom;
263 t.sort(); 263 t.sort();
264 for ( iii = 0; iii < t.count(); ++iii) 264 for ( iii = 0; iii < t.count(); ++iii)
265 l.append( t[iii] ); 265 l.append( t[iii] );
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
276 setCsum( dev, QString::number (cs )); 276 setCsum( dev, QString::number (cs ));
277} 277}
278 278
279void Addressee::mergeContact( const Addressee& ad ) 279void Addressee::mergeContact( const Addressee& ad )
280{ 280{
281 281
282 detach(); 282 detach();
283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
291 if ( !mData->birthday.isValid() ) 291 if ( !mData->birthday.isValid() )
292 if ( ad.mData->birthday.isValid()) 292 if ( ad.mData->birthday.isValid())
293 mData->birthday = ad.mData->birthday; 293 mData->birthday = ad.mData->birthday;
294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
305 305
306 // pending: 306 // pending:
307 // merging phonenumbers 307 // merging phonenumbers
308 // merging addresses 308 // merging addresses
309 // merging emails; 309 // merging emails;
310 // merging categories; 310 // merging categories;
311 // merging custom; 311 // merging custom;
312 // merging keys 312 // merging keys
313 qDebug("merge contact %s ", ad.uid().latin1()); 313 qDebug("merge contact %s ", ad.uid().latin1());
314 setUid( ad.uid() ); 314 setUid( ad.uid() );
315 setRevision( ad.revision() ); 315 setRevision( ad.revision() );
316} 316}
317 317
318// removes all emails but the first
319// needed by phone sync
320void Addressee::simplifyEmails()
321{
322 if ( mData->emails.count() == 0 ) return ;
323 QString email = mData->emails.first();
324 detach();
325 mData->emails.clear();
326 mData->emails.append( email );
327}
328
329void Addressee::simplifyPhoneNumbers()
330{
331 KABC::PhoneNumber::List removeNumbers;
332 KABC::PhoneNumber::List::Iterator phoneIter;
333 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
334 ++phoneIter ) {
335 if ( ! ( *phoneIter ).simplifyNumber() )
336 removeNumbers.append( ( *phoneIter ) );
337 }
338 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
339 ++phoneIter ) {
340 removePhoneNumber(( *phoneIter ));
341 }
342}
343void Addressee::simplifyPhoneNumberTypes()
344{
345 KABC::PhoneNumber::List::Iterator phoneIter;
346 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
347 ++phoneIter )
348 ( *phoneIter ).simplifyType();
349}
318void Addressee::removeID(const QString &prof) 350void Addressee::removeID(const QString &prof)
319{ 351{
320 detach(); 352 detach();
321 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 353 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
322 354
323} 355}
324void Addressee::setID( const QString & prof , const QString & id ) 356void Addressee::setID( const QString & prof , const QString & id )
325{ 357{
326 detach(); 358 detach();
327 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 359 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
328 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 360 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
329} 361}
330void Addressee::setTempSyncStat( int id ) 362void Addressee::setTempSyncStat( int id )
331{ 363{
332 if ( mData->mTempSyncStat == id ) return; 364 if ( mData->mTempSyncStat == id ) return;
333 detach(); 365 detach();
334 mData->mTempSyncStat = id; 366 mData->mTempSyncStat = id;
335} 367}
336int Addressee::tempSyncStat() const 368int Addressee::tempSyncStat() const
337{ 369{
338 return mData->mTempSyncStat; 370 return mData->mTempSyncStat;
339} 371}
340 372
341QString Addressee::getID( const QString & prof) 373QString Addressee::getID( const QString & prof)
342{ 374{
343 return KIdManager::getId ( mData->mExternalId, prof ); 375 return KIdManager::getId ( mData->mExternalId, prof );
344} 376}
345 377
346void Addressee::setCsum( const QString & prof , const QString & id ) 378void Addressee::setCsum( const QString & prof , const QString & id )
347{ 379{
348 detach(); 380 detach();
349 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 381 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
350 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 382 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
351 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 383 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
352} 384}
353 385
354QString Addressee::getCsum( const QString & prof) 386QString Addressee::getCsum( const QString & prof)
355{ 387{
356 return KIdManager::getCsum ( mData->mExternalId, prof ); 388 return KIdManager::getCsum ( mData->mExternalId, prof );
357} 389}
358 390
359void Addressee::setIDStr( const QString & s ) 391void Addressee::setIDStr( const QString & s )
360{ 392{
361 detach(); 393 detach();
362 mData->mExternalId = s; 394 mData->mExternalId = s;
363} 395}
364 396
365QString Addressee::IDStr() const 397QString Addressee::IDStr() const
366{ 398{
367 return mData->mExternalId; 399 return mData->mExternalId;
368} 400}
369 401
370void Addressee::setExternalUID( const QString &id ) 402void Addressee::setExternalUID( const QString &id )
371{ 403{
372 if ( id == mData->externalUID ) return; 404 if ( id == mData->externalUID ) return;
373 detach(); 405 detach();
374 mData->empty = false; 406 mData->empty = false;
375 mData->externalUID = id; 407 mData->externalUID = id;
376} 408}
377 409
378QString Addressee::externalUID() const 410QString Addressee::externalUID() const
379{ 411{
380 return mData->externalUID; 412 return mData->externalUID;
381} 413}
382void Addressee::setOriginalExternalUID( const QString &id ) 414void Addressee::setOriginalExternalUID( const QString &id )
383{ 415{
384 if ( id == mData->originalExternalUID ) return; 416 if ( id == mData->originalExternalUID ) return;
385 detach(); 417 detach();
386 mData->empty = false; 418 mData->empty = false;
387 //qDebug("*******Set orig uid %s ", id.latin1()); 419 //qDebug("*******Set orig uid %s ", id.latin1());
388 mData->originalExternalUID = id; 420 mData->originalExternalUID = id;
389} 421}
390 422
391QString Addressee::originalExternalUID() const 423QString Addressee::originalExternalUID() const
392{ 424{
393 return mData->originalExternalUID; 425 return mData->originalExternalUID;
394} 426}
395 427
396void Addressee::setUid( const QString &id ) 428void Addressee::setUid( const QString &id )
397{ 429{
398 if ( id == mData->uid ) return; 430 if ( id == mData->uid ) return;
399 detach(); 431 detach();
400 //qDebug("****setuid %s ", id.latin1()); 432 //qDebug("****setuid %s ", id.latin1());
401 mData->empty = false; 433 mData->empty = false;
402 mData->uid = id; 434 mData->uid = id;
403} 435}
404 436
405QString Addressee::uid() const 437QString Addressee::uid() const
406{ 438{
407 if ( mData->uid.isEmpty() ) 439 if ( mData->uid.isEmpty() )
408 mData->uid = KApplication::randomString( 10 ); 440 mData->uid = KApplication::randomString( 10 );
409 441
410 return mData->uid; 442 return mData->uid;
411} 443}
412 444
413QString Addressee::uidLabel() 445QString Addressee::uidLabel()
414{ 446{
415 return i18n("Unique Identifier"); 447 return i18n("Unique Identifier");
416} 448}
417 449
418void Addressee::setName( const QString &name ) 450void Addressee::setName( const QString &name )
419{ 451{
420 if ( name == mData->name ) return; 452 if ( name == mData->name ) return;
421 detach(); 453 detach();
422 mData->empty = false; 454 mData->empty = false;
423 mData->name = name; 455 mData->name = name;
424} 456}
425 457
426QString Addressee::name() const 458QString Addressee::name() const
427{ 459{
428 return mData->name; 460 return mData->name;
429} 461}
430 462
431QString Addressee::nameLabel() 463QString Addressee::nameLabel()
432{ 464{
433 return i18n("Name"); 465 return i18n("Name");
434} 466}
435 467
436 468
437void Addressee::setFormattedName( const QString &formattedName ) 469void Addressee::setFormattedName( const QString &formattedName )
438{ 470{
439 if ( formattedName == mData->formattedName ) return; 471 if ( formattedName == mData->formattedName ) return;
440 detach(); 472 detach();
441 mData->empty = false; 473 mData->empty = false;
442 mData->formattedName = formattedName; 474 mData->formattedName = formattedName;
443} 475}
444 476
445QString Addressee::formattedName() const 477QString Addressee::formattedName() const
446{ 478{
447 return mData->formattedName; 479 return mData->formattedName;
448} 480}
449 481
450QString Addressee::formattedNameLabel() 482QString Addressee::formattedNameLabel()
451{ 483{
452 return i18n("Formatted Name"); 484 return i18n("Formatted Name");
453} 485}
454 486
455 487
456void Addressee::setFamilyName( const QString &familyName ) 488void Addressee::setFamilyName( const QString &familyName )
457{ 489{
458 if ( familyName == mData->familyName ) return; 490 if ( familyName == mData->familyName ) return;
459 detach(); 491 detach();
460 mData->empty = false; 492 mData->empty = false;
461 mData->familyName = familyName; 493 mData->familyName = familyName;
462} 494}
463 495
464QString Addressee::familyName() const 496QString Addressee::familyName() const
465{ 497{
466 return mData->familyName; 498 return mData->familyName;
467} 499}
468 500
469QString Addressee::familyNameLabel() 501QString Addressee::familyNameLabel()
470{ 502{
471 return i18n("Family Name"); 503 return i18n("Family Name");
472} 504}
473 505
474 506
475void Addressee::setGivenName( const QString &givenName ) 507void Addressee::setGivenName( const QString &givenName )
476{ 508{
477 if ( givenName == mData->givenName ) return; 509 if ( givenName == mData->givenName ) return;
478 detach(); 510 detach();
479 mData->empty = false; 511 mData->empty = false;
480 mData->givenName = givenName; 512 mData->givenName = givenName;
481} 513}
482 514
483QString Addressee::givenName() const 515QString Addressee::givenName() const
484{ 516{
485 return mData->givenName; 517 return mData->givenName;
486} 518}
487 519
488QString Addressee::givenNameLabel() 520QString Addressee::givenNameLabel()
489{ 521{
490 return i18n("Given Name"); 522 return i18n("Given Name");
491} 523}
492 524
493 525
494void Addressee::setAdditionalName( const QString &additionalName ) 526void Addressee::setAdditionalName( const QString &additionalName )
495{ 527{
496 if ( additionalName == mData->additionalName ) return; 528 if ( additionalName == mData->additionalName ) return;
497 detach(); 529 detach();
498 mData->empty = false; 530 mData->empty = false;
499 mData->additionalName = additionalName; 531 mData->additionalName = additionalName;
500} 532}
501 533
502QString Addressee::additionalName() const 534QString Addressee::additionalName() const
503{ 535{
504 return mData->additionalName; 536 return mData->additionalName;
505} 537}
506 538
507QString Addressee::additionalNameLabel() 539QString Addressee::additionalNameLabel()
508{ 540{
509 return i18n("Additional Names"); 541 return i18n("Additional Names");
510} 542}
511 543
512 544
513void Addressee::setPrefix( const QString &prefix ) 545void Addressee::setPrefix( const QString &prefix )
514{ 546{
515 if ( prefix == mData->prefix ) return; 547 if ( prefix == mData->prefix ) return;
516 detach(); 548 detach();
517 mData->empty = false; 549 mData->empty = false;
518 mData->prefix = prefix; 550 mData->prefix = prefix;
519} 551}
520 552
521QString Addressee::prefix() const 553QString Addressee::prefix() const
522{ 554{
523 return mData->prefix; 555 return mData->prefix;
524} 556}
525 557
526QString Addressee::prefixLabel() 558QString Addressee::prefixLabel()
527{ 559{
528 return i18n("Honorific Prefixes"); 560 return i18n("Honorific Prefixes");
529} 561}
530 562
531 563
532void Addressee::setSuffix( const QString &suffix ) 564void Addressee::setSuffix( const QString &suffix )
533{ 565{
534 if ( suffix == mData->suffix ) return; 566 if ( suffix == mData->suffix ) return;
535 detach(); 567 detach();
536 mData->empty = false; 568 mData->empty = false;
537 mData->suffix = suffix; 569 mData->suffix = suffix;
538} 570}
539 571
540QString Addressee::suffix() const 572QString Addressee::suffix() const
541{ 573{
542 return mData->suffix; 574 return mData->suffix;
543} 575}
544 576
545QString Addressee::suffixLabel() 577QString Addressee::suffixLabel()
546{ 578{
547 return i18n("Honorific Suffixes"); 579 return i18n("Honorific Suffixes");
548} 580}
549 581
550 582
551void Addressee::setNickName( const QString &nickName ) 583void Addressee::setNickName( const QString &nickName )
552{ 584{
553 if ( nickName == mData->nickName ) return; 585 if ( nickName == mData->nickName ) return;
554 detach(); 586 detach();
555 mData->empty = false; 587 mData->empty = false;
556 mData->nickName = nickName; 588 mData->nickName = nickName;
557} 589}
558 590
559QString Addressee::nickName() const 591QString Addressee::nickName() const
560{ 592{
561 return mData->nickName; 593 return mData->nickName;
562} 594}
563 595
564QString Addressee::nickNameLabel() 596QString Addressee::nickNameLabel()
565{ 597{
566 return i18n("Nick Name"); 598 return i18n("Nick Name");
567} 599}
568 600
569 601
570void Addressee::setBirthday( const QDateTime &birthday ) 602void Addressee::setBirthday( const QDateTime &birthday )
571{ 603{
572 if ( birthday == mData->birthday ) return; 604 if ( birthday == mData->birthday ) return;
573 detach(); 605 detach();
574 mData->empty = false; 606 mData->empty = false;
575 mData->birthday = birthday; 607 mData->birthday = birthday;
576} 608}
577 609
578QDateTime Addressee::birthday() const 610QDateTime Addressee::birthday() const
579{ 611{
580 return mData->birthday; 612 return mData->birthday;
581} 613}
582 614
583QString Addressee::birthdayLabel() 615QString Addressee::birthdayLabel()
584{ 616{
585 return i18n("Birthday"); 617 return i18n("Birthday");
586} 618}
587 619
588 620
589QString Addressee::homeAddressStreetLabel() 621QString Addressee::homeAddressStreetLabel()
590{ 622{
591 return i18n("Home Address Street"); 623 return i18n("Home Address Street");
592} 624}
593 625
594 626
595QString Addressee::homeAddressLocalityLabel() 627QString Addressee::homeAddressLocalityLabel()
596{ 628{
597 return i18n("Home Address Locality"); 629 return i18n("Home Address Locality");
598} 630}
599 631
600 632
601QString Addressee::homeAddressRegionLabel() 633QString Addressee::homeAddressRegionLabel()
602{ 634{
603 return i18n("Home Address Region"); 635 return i18n("Home Address Region");
604} 636}
605 637
606 638
607QString Addressee::homeAddressPostalCodeLabel() 639QString Addressee::homeAddressPostalCodeLabel()
608{ 640{
609 return i18n("Home Address Postal Code"); 641 return i18n("Home Address Postal Code");
610} 642}
611 643
612 644
613QString Addressee::homeAddressCountryLabel() 645QString Addressee::homeAddressCountryLabel()
614{ 646{
615 return i18n("Home Address Country"); 647 return i18n("Home Address Country");
616} 648}
617 649
618 650
619QString Addressee::homeAddressLabelLabel() 651QString Addressee::homeAddressLabelLabel()
620{ 652{
621 return i18n("Home Address Label"); 653 return i18n("Home Address Label");
622} 654}
623 655
624 656
625QString Addressee::businessAddressStreetLabel() 657QString Addressee::businessAddressStreetLabel()
626{ 658{
627 return i18n("Business Address Street"); 659 return i18n("Business Address Street");
628} 660}
629 661
630 662
631QString Addressee::businessAddressLocalityLabel() 663QString Addressee::businessAddressLocalityLabel()
632{ 664{
633 return i18n("Business Address Locality"); 665 return i18n("Business Address Locality");
634} 666}
635 667
636 668
637QString Addressee::businessAddressRegionLabel() 669QString Addressee::businessAddressRegionLabel()
638{ 670{
639 return i18n("Business Address Region"); 671 return i18n("Business Address Region");
640} 672}
641 673
642 674
643QString Addressee::businessAddressPostalCodeLabel() 675QString Addressee::businessAddressPostalCodeLabel()
644{ 676{
645 return i18n("Business Address Postal Code"); 677 return i18n("Business Address Postal Code");
646} 678}
647 679
648 680
649QString Addressee::businessAddressCountryLabel() 681QString Addressee::businessAddressCountryLabel()
650{ 682{
651 return i18n("Business Address Country"); 683 return i18n("Business Address Country");
652} 684}
653 685
654 686
655QString Addressee::businessAddressLabelLabel() 687QString Addressee::businessAddressLabelLabel()
656{ 688{
657 return i18n("Business Address Label"); 689 return i18n("Business Address Label");
658} 690}
659 691
660 692
661QString Addressee::homePhoneLabel() 693QString Addressee::homePhoneLabel()
662{ 694{
663 return i18n("Home Phone"); 695 return i18n("Home Phone");
664} 696}
665 697
666 698
667QString Addressee::businessPhoneLabel() 699QString Addressee::businessPhoneLabel()
668{ 700{
669 return i18n("Business Phone"); 701 return i18n("Business Phone");
670} 702}
671 703
672 704
673QString Addressee::mobilePhoneLabel() 705QString Addressee::mobilePhoneLabel()
674{ 706{
675 return i18n("Mobile Phone"); 707 return i18n("Mobile Phone");
676} 708}
677 709
678 710
679QString Addressee::homeFaxLabel() 711QString Addressee::homeFaxLabel()
680{ 712{
681 return i18n("Home Fax"); 713 return i18n("Home Fax");
682} 714}
683 715
684 716
685QString Addressee::businessFaxLabel() 717QString Addressee::businessFaxLabel()
686{ 718{
687 return i18n("Business Fax"); 719 return i18n("Business Fax");
688} 720}
689 721
690 722
691QString Addressee::carPhoneLabel() 723QString Addressee::carPhoneLabel()
692{ 724{
693 return i18n("Car Phone"); 725 return i18n("Car Phone");
694} 726}
695 727
696 728
697QString Addressee::isdnLabel() 729QString Addressee::isdnLabel()
698{ 730{
699 return i18n("ISDN"); 731 return i18n("ISDN");
700} 732}
701 733
702 734
703QString Addressee::pagerLabel() 735QString Addressee::pagerLabel()
704{ 736{
705 return i18n("Pager"); 737 return i18n("Pager");
706} 738}
707 739
708QString Addressee::sipLabel() 740QString Addressee::sipLabel()
709{ 741{
710 return i18n("SIP"); 742 return i18n("SIP");
711} 743}
712 744
713QString Addressee::emailLabel() 745QString Addressee::emailLabel()
714{ 746{
715 return i18n("Email Address"); 747 return i18n("Email Address");
716} 748}
717 749
718 750
719void Addressee::setMailer( const QString &mailer ) 751void Addressee::setMailer( const QString &mailer )
720{ 752{
721 if ( mailer == mData->mailer ) return; 753 if ( mailer == mData->mailer ) return;
722 detach(); 754 detach();
723 mData->empty = false; 755 mData->empty = false;
724 mData->mailer = mailer; 756 mData->mailer = mailer;
725} 757}
726 758
727QString Addressee::mailer() const 759QString Addressee::mailer() const
728{ 760{
729 return mData->mailer; 761 return mData->mailer;
730} 762}
731 763
732QString Addressee::mailerLabel() 764QString Addressee::mailerLabel()
733{ 765{
734 return i18n("Mail Client"); 766 return i18n("Mail Client");
735} 767}
736 768
737 769
738void Addressee::setTimeZone( const TimeZone &timeZone ) 770void Addressee::setTimeZone( const TimeZone &timeZone )
739{ 771{
740 if ( timeZone == mData->timeZone ) return; 772 if ( timeZone == mData->timeZone ) return;
741 detach(); 773 detach();
742 mData->empty = false; 774 mData->empty = false;
743 mData->timeZone = timeZone; 775 mData->timeZone = timeZone;
744} 776}
745 777
746TimeZone Addressee::timeZone() const 778TimeZone Addressee::timeZone() const
747{ 779{
748 return mData->timeZone; 780 return mData->timeZone;
749} 781}
750 782
751QString Addressee::timeZoneLabel() 783QString Addressee::timeZoneLabel()
752{ 784{
753 return i18n("Time Zone"); 785 return i18n("Time Zone");
754} 786}
755 787
756 788
757void Addressee::setGeo( const Geo &geo ) 789void Addressee::setGeo( const Geo &geo )
758{ 790{
759 if ( geo == mData->geo ) return; 791 if ( geo == mData->geo ) return;
760 detach(); 792 detach();
761 mData->empty = false; 793 mData->empty = false;
762 mData->geo = geo; 794 mData->geo = geo;
763} 795}
764 796
765Geo Addressee::geo() const 797Geo Addressee::geo() const
766{ 798{
767 return mData->geo; 799 return mData->geo;
768} 800}
769 801
770QString Addressee::geoLabel() 802QString Addressee::geoLabel()
771{ 803{
772 return i18n("Geographic Position"); 804 return i18n("Geographic Position");
773} 805}
774 806
775 807
776void Addressee::setTitle( const QString &title ) 808void Addressee::setTitle( const QString &title )
777{ 809{
778 if ( title == mData->title ) return; 810 if ( title == mData->title ) return;
779 detach(); 811 detach();
780 mData->empty = false; 812 mData->empty = false;
781 mData->title = title; 813 mData->title = title;
782} 814}
783 815
784QString Addressee::title() const 816QString Addressee::title() const
785{ 817{
786 return mData->title; 818 return mData->title;
787} 819}
788 820
789QString Addressee::titleLabel() 821QString Addressee::titleLabel()
790{ 822{
791 return i18n("Title"); 823 return i18n("Title");
792} 824}
793 825
794 826
795void Addressee::setRole( const QString &role ) 827void Addressee::setRole( const QString &role )
796{ 828{
797 if ( role == mData->role ) return; 829 if ( role == mData->role ) return;
798 detach(); 830 detach();
799 mData->empty = false; 831 mData->empty = false;
800 mData->role = role; 832 mData->role = role;
801} 833}
802 834
803QString Addressee::role() const 835QString Addressee::role() const
804{ 836{
805 return mData->role; 837 return mData->role;
806} 838}
807 839
808QString Addressee::roleLabel() 840QString Addressee::roleLabel()
809{ 841{
810 return i18n("Role"); 842 return i18n("Role");
811} 843}
812 844
813 845
814void Addressee::setOrganization( const QString &organization ) 846void Addressee::setOrganization( const QString &organization )
815{ 847{
816 if ( organization == mData->organization ) return; 848 if ( organization == mData->organization ) return;
817 detach(); 849 detach();
818 mData->empty = false; 850 mData->empty = false;
819 mData->organization = organization; 851 mData->organization = organization;
820} 852}
821 853
822QString Addressee::organization() const 854QString Addressee::organization() const
823{ 855{
824 return mData->organization; 856 return mData->organization;
825} 857}
826 858
827QString Addressee::organizationLabel() 859QString Addressee::organizationLabel()
828{ 860{
829 return i18n("Organization"); 861 return i18n("Organization");