summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 39d14bb..7f592e9 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,2197 +1,2222 @@
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 defaultFormattedName;
54 QString familyName; 55 QString familyName;
55 QString givenName; 56 QString givenName;
56 QString additionalName; 57 QString additionalName;
57 QString prefix; 58 QString prefix;
58 QString suffix; 59 QString suffix;
59 QString nickName; 60 QString nickName;
60 QDateTime birthday; 61 QDateTime birthday;
61 QString mailer; 62 QString mailer;
62 TimeZone timeZone; 63 TimeZone timeZone;
63 Geo geo; 64 Geo geo;
64 QString title; 65 QString title;
65 QString role; 66 QString role;
66 QString organization; 67 QString organization;
67 QString note; 68 QString note;
68 QString productId; 69 QString productId;
69 QDateTime revision; 70 QDateTime revision;
70 QString sortString; 71 QString sortString;
71 QString externalUID; 72 QString externalUID;
72 QString originalExternalUID; 73 QString originalExternalUID;
73 KURL url; 74 KURL url;
74 Secrecy secrecy; 75 Secrecy secrecy;
75 Picture logo; 76 Picture logo;
76 Picture photo; 77 Picture photo;
77 Sound sound; 78 Sound sound;
78 Agent agent; 79 Agent agent;
79 QString mExternalId; 80 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 81 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 82 Address::List addresses;
82 Key::List keys; 83 Key::List keys;
83 QStringList emails; 84 QStringList emails;
84 QStringList categories; 85 QStringList categories;
85 QStringList custom; 86 QStringList custom;
86 int mTempSyncStat; 87 int mTempSyncStat;
87 Resource *resource; 88 Resource *resource;
88 89
89 bool empty :1; 90 bool empty :1;
90 bool changed :1; 91 bool changed :1;
91 bool tagged :1; 92 bool tagged :1;
92}; 93};
93 94
94Addressee::Addressee() 95Addressee::Addressee()
95{ 96{
96 mData = new AddresseeData; 97 mData = new AddresseeData;
97 mData->empty = true; 98 mData->empty = true;
98 mData->changed = false; 99 mData->changed = false;
99 mData->resource = 0; 100 mData->resource = 0;
100 mData->mExternalId = ":"; 101 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 102 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 103 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 104}
104 105
105Addressee::~Addressee() 106Addressee::~Addressee()
106{ 107{
107} 108}
108 109
109Addressee::Addressee( const Addressee &a ) 110Addressee::Addressee( const Addressee &a )
110{ 111{
111 mData = a.mData; 112 mData = a.mData;
112} 113}
113 114
114Addressee &Addressee::operator=( const Addressee &a ) 115Addressee &Addressee::operator=( const Addressee &a )
115{ 116{
116 mData = a.mData; 117 mData = a.mData;
117 return (*this); 118 return (*this);
118} 119}
119 120
120Addressee Addressee::copy() 121Addressee Addressee::copy()
121{ 122{
122 Addressee a; 123 Addressee a;
123 *(a.mData) = *mData; 124 *(a.mData) = *mData;
124 return a; 125 return a;
125} 126}
126 127
127void Addressee::detach() 128void Addressee::detach()
128{ 129{
129 if ( mData.count() == 1 ) return; 130 if ( mData.count() == 1 ) return;
130 *this = copy(); 131 *this = copy();
131} 132}
132 133
133bool Addressee::operator==( const Addressee &a ) const 134bool Addressee::operator==( const Addressee &a ) const
134{ 135{
135 if ( uid() != a.uid() ) return false; 136 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 137 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 138 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 139 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 140 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 141 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 142 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 143 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 144 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 145 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 146 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 147 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 148 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 149 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 150 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 151 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 152 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 153 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 154 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 155 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 156 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 157 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 158 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 159 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 160 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 161 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 162 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 163 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 164 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 165 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 166 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 167 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 168 if ( mData->custom != a.mData->custom ) return false;
168 169
169 return true; 170 return true;
170} 171}
171 172
172bool Addressee::operator!=( const Addressee &a ) const 173bool Addressee::operator!=( const Addressee &a ) const
173{ 174{
174 return !( a == *this ); 175 return !( a == *this );
175} 176}
176 177
177bool Addressee::isEmpty() const 178bool Addressee::isEmpty() const
178{ 179{
179 return mData->empty; 180 return mData->empty;
180} 181}
181ulong Addressee::getCsum4List( const QStringList & attList) 182ulong Addressee::getCsum4List( const QStringList & attList)
182{ 183{
183 int max = attList.count(); 184 int max = attList.count();
184 ulong cSum = 0; 185 ulong cSum = 0;
185 int j,k,i; 186 int j,k,i;
186 int add; 187 int add;
187 for ( i = 0; i < max ; ++i ) { 188 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 189 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 190 if ( ! s.isEmpty() ){
190 j = s.length(); 191 j = s.length();
191 for ( k = 0; k < j; ++k ) { 192 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 193 int mul = k +1;
193 add = s[k].unicode (); 194 add = s[k].unicode ();
194 if ( k < 16 ) 195 if ( k < 16 )
195 mul = mul * mul; 196 mul = mul * mul;
196 int ii = i+1; 197 int ii = i+1;
197 add = add * mul *ii*ii*ii; 198 add = add * mul *ii*ii*ii;
198 cSum += add; 199 cSum += add;
199 //qDebug("csum: %d %d %d", i,k,cSum); 200 //qDebug("csum: %d %d %d", i,k,cSum);
200 } 201 }
201 } 202 }
202 203
203 } 204 }
204 //QString dump = attList.join(","); 205 //QString dump = attList.join(",");
205 //qDebug("csum: %d %s", cSum,dump.latin1()); 206 //qDebug("csum: %d %s", cSum,dump.latin1());
206 207
207 return cSum; 208 return cSum;
208 209
209} 210}
210void Addressee::computeCsum(const QString &dev) 211void Addressee::computeCsum(const QString &dev)
211{ 212{
212 QStringList l; 213 QStringList l;
213 //if ( !mData->name.isEmpty() ) l.append(mData->name); 214 //if ( !mData->name.isEmpty() ) l.append(mData->name);
214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 215 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 216 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 217 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 218 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 219 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 220 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 221 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 222 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 223 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 224 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 225 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
225 if ( !mData->title .isEmpty() ) l.append( mData->title ); 226 if ( !mData->title .isEmpty() ) l.append( mData->title );
226 if ( !mData->role.isEmpty() ) l.append( mData->role ); 227 if ( !mData->role.isEmpty() ) l.append( mData->role );
227 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 228 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
228 if ( !mData->note.isEmpty() ) l.append( mData->note ); 229 if ( !mData->note.isEmpty() ) l.append( mData->note );
229 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 230 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 231 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 232 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
232 if ( !mData->logo.undefined() ) { 233 if ( !mData->logo.undefined() ) {
233 if ( !mData->logo.isIntern() ) 234 if ( !mData->logo.isIntern() )
234 l.append( mData->logo.url() ); 235 l.append( mData->logo.url() );
235 else 236 else
236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); 237 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
237 } else { 238 } else {
238 l.append( "nologo"); 239 l.append( "nologo");
239 } 240 }
240 if ( !mData->photo.undefined() ) { 241 if ( !mData->photo.undefined() ) {
241 if ( !mData->photo.isIntern() ) 242 if ( !mData->photo.isIntern() )
242 l.append( mData->photo.url() ); 243 l.append( mData->photo.url() );
243 else 244 else
244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); 245 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
245 } else { 246 } else {
246 l.append( "nophoto"); 247 l.append( "nophoto");
247 } 248 }
248#if 0 249#if 0
249 if ( !mData->sound.undefined() ) { 250 if ( !mData->sound.undefined() ) {
250 if ( !mData->sound.isIntern() ) 251 if ( !mData->sound.isIntern() )
251 l.append( mData->sound.url() ); 252 l.append( mData->sound.url() );
252 else 253 else
253 l.append( QString(mData->sound.data().with()* mData->sound.data().height())); 254 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
254 } else { 255 } else {
255 l.append( "nosound"); 256 l.append( "nosound");
256 } 257 }
257#endif 258#endif
258 //if ( !mData->agent.isEmpty() ) l.append( ); 259 //if ( !mData->agent.isEmpty() ) l.append( );
259 if ( mData->url.isValid() ) 260 if ( mData->url.isValid() )
260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 261 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
261 KABC::PhoneNumber::List phoneNumbers; 262 KABC::PhoneNumber::List phoneNumbers;
262 KABC::PhoneNumber::List::Iterator phoneIter; 263 KABC::PhoneNumber::List::Iterator phoneIter;
263 264
264 QStringList t; 265 QStringList t;
265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 266 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
266 ++phoneIter ) 267 ++phoneIter )
267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 268 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
268 t.sort(); 269 t.sort();
269 uint iii; 270 uint iii;
270 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
271 l.append( t[iii] ); 272 l.append( t[iii] );
272 t = mData->emails; 273 t = mData->emails;
273 t.sort(); 274 t.sort();
274 for ( iii = 0; iii < t.count(); ++iii) 275 for ( iii = 0; iii < t.count(); ++iii)
275 l.append( t[iii] ); 276 l.append( t[iii] );
276 t = mData->categories; 277 t = mData->categories;
277 t.sort(); 278 t.sort();
278 for ( iii = 0; iii < t.count(); ++iii) 279 for ( iii = 0; iii < t.count(); ++iii)
279 l.append( t[iii] ); 280 l.append( t[iii] );
280 t = mData->custom; 281 t = mData->custom;
281 t.sort(); 282 t.sort();
282 for ( iii = 0; iii < t.count(); ++iii) 283 for ( iii = 0; iii < t.count(); ++iii)
283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 284 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
284 int find = t[iii].find (':')+1; 285 int find = t[iii].find (':')+1;
285 //qDebug("lennnn %d %d ", find, t[iii].length()); 286 //qDebug("lennnn %d %d ", find, t[iii].length());
286 if ( find < t[iii].length()) 287 if ( find < t[iii].length())
287 l.append( t[iii] ); 288 l.append( t[iii] );
288 289
289 } 290 }
290 KABC::Address::List::Iterator addressIter; 291 KABC::Address::List::Iterator addressIter;
291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 292 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
292 ++addressIter ) { 293 ++addressIter ) {
293 t = (*addressIter).asList(); 294 t = (*addressIter).asList();
294 t.sort(); 295 t.sort();
295 for ( iii = 0; iii < t.count(); ++iii) 296 for ( iii = 0; iii < t.count(); ++iii)
296 l.append( t[iii] ); 297 l.append( t[iii] );
297 } 298 }
298 uint cs = getCsum4List(l); 299 uint cs = getCsum4List(l);
299 300
300#if 0 301#if 0
301 for ( iii = 0; iii < l.count(); ++iii) 302 for ( iii = 0; iii < l.count(); ++iii)
302 qDebug("%d***%s***",iii,l[iii].latin1()); 303 qDebug("%d***%s***",iii,l[iii].latin1());
303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 304 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
304#endif 305#endif
305 306
306 307
307 setCsum( dev, QString::number (cs )); 308 setCsum( dev, QString::number (cs ));
308} 309}
309 310
310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 311void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
311{ 312{
312 // merge all standard non-outlook fields. 313 // merge all standard non-outlook fields.
313 //if isSubSet (e.g. mobile phone sync) merge all fields 314 //if isSubSet (e.g. mobile phone sync) merge all fields
314 315
315 detach(); 316 detach();
316 if ( isSubSet ) { 317 if ( isSubSet ) {
317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 318 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 319 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 320 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 321 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 322 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
322 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 323 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
323 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 324 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
324 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 325 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
325 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 326 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
326 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 327 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
327 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 328 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
328 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 329 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
329 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 330 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
330 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 331 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
331 if ( !mData->birthday.isValid() ) 332 if ( !mData->birthday.isValid() )
332 if ( ad.mData->birthday.isValid()) 333 if ( ad.mData->birthday.isValid())
333 mData->birthday = ad.mData->birthday; 334 mData->birthday = ad.mData->birthday;
334 335
335 } 336 }
336 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 337 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
337 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 338 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
338 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 339 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
339 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 340 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
340 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 341 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
341 QStringList t; 342 QStringList t;
342 QStringList tAD; 343 QStringList tAD;
343 uint iii; 344 uint iii;
344 345
345 // ********** phone numbers 346 // ********** phone numbers
346 if ( isSubSet ) { 347 if ( isSubSet ) {
347 PhoneNumber::List phoneAD = ad.phoneNumbers(); 348 PhoneNumber::List phoneAD = ad.phoneNumbers();
348 PhoneNumber::List::Iterator phoneItAD; 349 PhoneNumber::List::Iterator phoneItAD;
349 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 350 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
350 bool found = false; 351 bool found = false;
351 PhoneNumber::List::Iterator it; 352 PhoneNumber::List::Iterator it;
352 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 353 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
353 if ( ( *phoneItAD ).contains( (*it) ) ) { 354 if ( ( *phoneItAD ).contains( (*it) ) ) {
354 found = true; 355 found = true;
355 (*it).setType( ( *phoneItAD ).type() ); 356 (*it).setType( ( *phoneItAD ).type() );
356 (*it).setNumber( ( *phoneItAD ).number() ); 357 (*it).setNumber( ( *phoneItAD ).number() );
357 break; 358 break;
358 } 359 }
359 } 360 }
360 // if ( isSubSet && ! found ) 361 // if ( isSubSet && ! found )
361 if ( ! found ) // LR try this one... 362 if ( ! found ) // LR try this one...
362 mData->phoneNumbers.append( *phoneItAD ); 363 mData->phoneNumbers.append( *phoneItAD );
363 } 364 }
364 } else { 365 } else {
365 PhoneNumber::List phoneAD = ad.phoneNumbers(); 366 PhoneNumber::List phoneAD = ad.phoneNumbers();
366 PhoneNumber::List::Iterator phoneItAD; 367 PhoneNumber::List::Iterator phoneItAD;
367 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 368 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
368 bool found = false; 369 bool found = false;
369 PhoneNumber::List::Iterator it; 370 PhoneNumber::List::Iterator it;
370 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 371 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
371 if ( ( *phoneItAD ).contains( (*it) ) ) { 372 if ( ( *phoneItAD ).contains( (*it) ) ) {
372 found = true; 373 found = true;
373 (*it).setType( ( *phoneItAD ).type() ); 374 (*it).setType( ( *phoneItAD ).type() );
374 (*it).setNumber( ( *phoneItAD ).number() ); 375 (*it).setNumber( ( *phoneItAD ).number() );
375 break; 376 break;
376 } 377 }
377 } 378 }
378 if ( ! found ) { // append numbers which do not have work or home type 379 if ( ! found ) { // append numbers which do not have work or home type
379 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 380 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
380 mData->phoneNumbers.append( *phoneItAD ); 381 mData->phoneNumbers.append( *phoneItAD );
381 } 382 }
382 } 383 }
383 } 384 }
384 if ( isSubSet ) { 385 if ( isSubSet ) {
385 // ************* emails; 386 // ************* emails;
386 t = mData->emails; 387 t = mData->emails;
387 tAD = ad.mData->emails; 388 tAD = ad.mData->emails;
388 for ( iii = 0; iii < tAD.count(); ++iii) 389 for ( iii = 0; iii < tAD.count(); ++iii)
389 if ( !t.contains(tAD[iii] ) ) 390 if ( !t.contains(tAD[iii] ) )
390 mData->emails.append( tAD[iii] ); 391 mData->emails.append( tAD[iii] );
391 } 392 }
392 393
393 // ************* categories; 394 // ************* categories;
394 if ( isSubSet ) { 395 if ( isSubSet ) {
395 t = mData->categories; 396 t = mData->categories;
396 tAD = ad.mData->categories; 397 tAD = ad.mData->categories;
397 for ( iii = 0; iii < tAD.count(); ++iii) 398 for ( iii = 0; iii < tAD.count(); ++iii)
398 if ( !t.contains(tAD[iii] ) ) 399 if ( !t.contains(tAD[iii] ) )
399 mData->categories.append( tAD[iii] ); 400 mData->categories.append( tAD[iii] );
400 } 401 }
401 QStringList::ConstIterator it; 402 QStringList::ConstIterator it;
402 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 403 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
403 QString qualifiedName = (*it).left( (*it).find( ":" )); 404 QString qualifiedName = (*it).left( (*it).find( ":" ));
404 bool found = false; 405 bool found = false;
405 QStringList::ConstIterator itL; 406 QStringList::ConstIterator itL;
406 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 407 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
407 if ( (*itL).startsWith( qualifiedName ) ) { 408 if ( (*itL).startsWith( qualifiedName ) ) {
408 found = true; 409 found = true;
409 break; 410 break;
410 } 411 }
411 } 412 }
412 if ( ! found ) { 413 if ( ! found ) {
413 mData->custom.append( *it ); 414 mData->custom.append( *it );
414 } 415 }
415 } 416 }
416 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 417 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
417 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 418 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
418 if ( !mData->sound.isIntern() ) { 419 if ( !mData->sound.isIntern() ) {
419 if ( mData->sound.url().isEmpty() ) { 420 if ( mData->sound.url().isEmpty() ) {
420 mData->sound = ad.mData->sound; 421 mData->sound = ad.mData->sound;
421 } 422 }
422 } 423 }
423 if ( !mData->agent.isIntern() ) { 424 if ( !mData->agent.isIntern() ) {
424 if ( mData->agent.url().isEmpty() ) { 425 if ( mData->agent.url().isEmpty() ) {
425 mData->agent = ad.mData->agent; 426 mData->agent = ad.mData->agent;
426 } 427 }
427 } 428 }
428 { 429 {
429 Key::List::Iterator itA; 430 Key::List::Iterator itA;
430 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 431 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
431 bool found = false; 432 bool found = false;
432 Key::List::Iterator it; 433 Key::List::Iterator it;
433 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 434 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
434 if ( (*it) == (*itA)) { 435 if ( (*it) == (*itA)) {
435 found = true; 436 found = true;
436 break; 437 break;
437 438
438 } 439 }
439 } 440 }
440 if ( ! found ) { 441 if ( ! found ) {
441 mData->keys.append( *itA ); 442 mData->keys.append( *itA );
442 } 443 }
443 } 444 }
444 } 445 }
445 if ( isSubSet ) { 446 if ( isSubSet ) {
446 KABC::Address::List::Iterator addressIterA; 447 KABC::Address::List::Iterator addressIterA;
447 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 448 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
448 bool found = false; 449 bool found = false;
449 KABC::Address::List::Iterator addressIter; 450 KABC::Address::List::Iterator addressIter;
450 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 451 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
451 ++addressIter ) { 452 ++addressIter ) {
452 if ( (*addressIter) == (*addressIterA)) { 453 if ( (*addressIter) == (*addressIterA)) {
453 found = true; 454 found = true;
454 (*addressIter).setType( (*addressIterA).type() ); 455 (*addressIter).setType( (*addressIterA).type() );
455 break; 456 break;
456 } 457 }
457 458
458 } 459 }
459 if ( isSubSet && ! found ) { 460 if ( isSubSet && ! found ) {
460 mData->addresses.append( *addressIterA ); 461 mData->addresses.append( *addressIterA );
461 } 462 }
462 } 463 }
463 } 464 }
464 //qDebug("merge contact %s ", ad.uid().latin1()); 465 //qDebug("merge contact %s ", ad.uid().latin1());
465 setUid( ad.uid() ); 466 setUid( ad.uid() );
466 setRevision( ad.revision() ); 467 setRevision( ad.revision() );
467} 468}
468 469
469bool Addressee::removeVoice() 470bool Addressee::removeVoice()
470{ 471{
471 PhoneNumber::List phoneN = phoneNumbers(); 472 PhoneNumber::List phoneN = phoneNumbers();
472 PhoneNumber::List::Iterator phoneIt; 473 PhoneNumber::List::Iterator phoneIt;
473 bool found = false; 474 bool found = false;
474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 475 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 476 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
476 if ((*phoneIt).type() - PhoneNumber::Voice ) { 477 if ((*phoneIt).type() - PhoneNumber::Voice ) {
477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 478 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
478 insertPhoneNumber( (*phoneIt) ); 479 insertPhoneNumber( (*phoneIt) );
479 found = true; 480 found = true;
480 } 481 }
481 } 482 }
482 483
483 } 484 }
484 return found; 485 return found;
485} 486}
486 487
487bool Addressee::containsAdr(const Addressee& ad ) 488bool Addressee::containsAdr(const Addressee& ad )
488{ 489{
489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 490 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 491 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 492 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 493 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 494 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 495 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 496 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
496 497
497 // compare phone numbers 498 // compare phone numbers
498 PhoneNumber::List phoneN = ad.phoneNumbers(); 499 PhoneNumber::List phoneN = ad.phoneNumbers();
499 PhoneNumber::List::Iterator phoneIt; 500 PhoneNumber::List::Iterator phoneIt;
500 bool found = false; 501 bool found = false;
501 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 502 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
502 bool found = false; 503 bool found = false;
503 PhoneNumber::List phoneL = ad.phoneNumbers(); 504 PhoneNumber::List phoneL = ad.phoneNumbers();
504 PhoneNumber::List::Iterator phoneItL; 505 PhoneNumber::List::Iterator phoneItL;
505 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 506 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
506 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 507 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
507 found = true; 508 found = true;
508 break; 509 break;
509 } 510 }
510 } 511 }
511 if ( ! found ) 512 if ( ! found )
512 return false; 513 return false;
513 } 514 }
514 return true; 515 return true;
515 516
516} 517}
517void Addressee::simplifyAddresses() 518void Addressee::simplifyAddresses()
518{ 519{
519 520
520 521
521 Address::List list; 522 Address::List list;
522 Address::List::Iterator it; 523 Address::List::Iterator it;
523 Address::List::Iterator it2; 524 Address::List::Iterator it2;
524 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 525 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
525 it2 = it; 526 it2 = it;
526 ++it2; 527 ++it2;
527 for( ; it2 != mData->addresses.end(); ++it2 ) { 528 for( ; it2 != mData->addresses.end(); ++it2 ) {
528 if ( (*it) == (*it2) ) { 529 if ( (*it) == (*it2) ) {
529 list.append( *it ); 530 list.append( *it );
530 break; 531 break;
531 } 532 }
532 } 533 }
533 } 534 }
534 for( it = list.begin(); it != list.end(); ++it ) { 535 for( it = list.begin(); it != list.end(); ++it ) {
535 removeAddress( (*it) ); 536 removeAddress( (*it) );
536 } 537 }
537 538
538 list.clear(); 539 list.clear();
539 int max = 2; 540 int max = 2;
540 if ( mData->url.isValid() ) 541 if ( mData->url.isValid() )
541 max = 1; 542 max = 1;
542 if ( mData->addresses.count() <= max ) return ; 543 if ( mData->addresses.count() <= max ) return ;
543 int count = 0; 544 int count = 0;
544 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 545 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
545 if ( count >= max ) 546 if ( count >= max )
546 list.append( *it ); 547 list.append( *it );
547 ++count; 548 ++count;
548 } 549 }
549 for( it = list.begin(); it != list.end(); ++it ) { 550 for( it = list.begin(); it != list.end(); ++it ) {
550 removeAddress( (*it) ); 551 removeAddress( (*it) );
551 } 552 }
552} 553}
553 554
554// removes all emails but the first 555// removes all emails but the first
555// needed by phone sync 556// needed by phone sync
556void Addressee::simplifyEmails() 557void Addressee::simplifyEmails()
557{ 558{
558 if ( mData->emails.count() == 0 ) return ; 559 if ( mData->emails.count() == 0 ) return ;
559 QString email = mData->emails.first(); 560 QString email = mData->emails.first();
560 detach(); 561 detach();
561 mData->emails.clear(); 562 mData->emails.clear();
562 mData->emails.append( email ); 563 mData->emails.append( email );
563} 564}
564 565
565void Addressee::simplifyPhoneNumbers() 566void Addressee::simplifyPhoneNumbers()
566{ 567{
567 int max = 4; 568 int max = 4;
568 int inList = mData->phoneNumbers.count(); 569 int inList = mData->phoneNumbers.count();
569 KABC::PhoneNumber::List removeNumbers; 570 KABC::PhoneNumber::List removeNumbers;
570 KABC::PhoneNumber::List::Iterator phoneIter; 571 KABC::PhoneNumber::List::Iterator phoneIter;
571 if ( inList > max ) { 572 if ( inList > max ) {
572 // delete non-preferred numbers 573 // delete non-preferred numbers
573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 574 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
574 ++phoneIter ) { 575 ++phoneIter ) {
575 if ( inList > max ) { 576 if ( inList > max ) {
576 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 577 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
577 removeNumbers.append( ( *phoneIter ) ); 578 removeNumbers.append( ( *phoneIter ) );
578 --inList; 579 --inList;
579 } 580 }
580 } else 581 } else
581 break; 582 break;
582 } 583 }
583 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 584 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
584 ++phoneIter ) { 585 ++phoneIter ) {
585 removePhoneNumber(( *phoneIter )); 586 removePhoneNumber(( *phoneIter ));
586 } 587 }
587 // delete preferred numbers 588 // delete preferred numbers
588 if ( inList > max ) { 589 if ( inList > max ) {
589 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 590 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
590 ++phoneIter ) { 591 ++phoneIter ) {
591 if ( inList > max ) { 592 if ( inList > max ) {
592 removeNumbers.append( ( *phoneIter ) ); 593 removeNumbers.append( ( *phoneIter ) );
593 --inList; 594 --inList;
594 } else 595 } else
595 break; 596 break;
596 } 597 }
597 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 598 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
598 ++phoneIter ) { 599 ++phoneIter ) {
599 removePhoneNumber(( *phoneIter )); 600 removePhoneNumber(( *phoneIter ));
600 } 601 }
601 } 602 }
602 } 603 }
603 // remove non-numeric characters 604 // remove non-numeric characters
604 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 605 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
605 ++phoneIter ) { 606 ++phoneIter ) {
606 if ( ! ( *phoneIter ).simplifyNumber() ) 607 if ( ! ( *phoneIter ).simplifyNumber() )
607 removeNumbers.append( ( *phoneIter ) ); 608 removeNumbers.append( ( *phoneIter ) );
608 } 609 }
609 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 610 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
610 ++phoneIter ) { 611 ++phoneIter ) {
611 removePhoneNumber(( *phoneIter )); 612 removePhoneNumber(( *phoneIter ));
612 } 613 }
613} 614}
614void Addressee::simplifyPhoneNumberTypes() 615void Addressee::simplifyPhoneNumberTypes()
615{ 616{
616 KABC::PhoneNumber::List::Iterator phoneIter; 617 KABC::PhoneNumber::List::Iterator phoneIter;
617 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 618 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
618 ++phoneIter ) 619 ++phoneIter )
619 ( *phoneIter ).simplifyType(); 620 ( *phoneIter ).simplifyType();
620} 621}
621void Addressee::removeID(const QString &prof) 622void Addressee::removeID(const QString &prof)
622{ 623{
623 detach(); 624 detach();
624 if ( prof.isEmpty() ) 625 if ( prof.isEmpty() )
625 mData->mExternalId = ":"; 626 mData->mExternalId = ":";
626 else 627 else
627 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 628 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
628 629
629} 630}
630void Addressee::setID( const QString & prof , const QString & id ) 631void Addressee::setID( const QString & prof , const QString & id )
631{ 632{
632 detach(); 633 detach();
633 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 634 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
634 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 635 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
635} 636}
636void Addressee::setTempSyncStat( int id ) 637void Addressee::setTempSyncStat( int id )
637{ 638{
638 if ( mData->mTempSyncStat == id ) return; 639 if ( mData->mTempSyncStat == id ) return;
639 detach(); 640 detach();
640 mData->mTempSyncStat = id; 641 mData->mTempSyncStat = id;
641} 642}
642int Addressee::tempSyncStat() const 643int Addressee::tempSyncStat() const
643{ 644{
644 return mData->mTempSyncStat; 645 return mData->mTempSyncStat;
645} 646}
646 647
647const QString Addressee::getID( const QString & prof) const 648const QString Addressee::getID( const QString & prof) const
648{ 649{
649 return KIdManager::getId ( mData->mExternalId, prof ); 650 return KIdManager::getId ( mData->mExternalId, prof );
650} 651}
651 652
652void Addressee::setCsum( const QString & prof , const QString & id ) 653void Addressee::setCsum( const QString & prof , const QString & id )
653{ 654{
654 detach(); 655 detach();
655 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 656 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
656 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 657 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
657 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 658 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
658} 659}
659 660
660const QString Addressee::getCsum( const QString & prof) const 661const QString Addressee::getCsum( const QString & prof) const
661{ 662{
662 return KIdManager::getCsum ( mData->mExternalId, prof ); 663 return KIdManager::getCsum ( mData->mExternalId, prof );
663} 664}
664 665
665void Addressee::setIDStr( const QString & s ) 666void Addressee::setIDStr( const QString & s )
666{ 667{
667 detach(); 668 detach();
668 mData->mExternalId = s; 669 mData->mExternalId = s;
669} 670}
670 671
671const QString Addressee::IDStr() const 672const QString Addressee::IDStr() const
672{ 673{
673 return mData->mExternalId; 674 return mData->mExternalId;
674} 675}
675 676
676void Addressee::setExternalUID( const QString &id ) 677void Addressee::setExternalUID( const QString &id )
677{ 678{
678 if ( id == mData->externalUID ) return; 679 if ( id == mData->externalUID ) return;
679 detach(); 680 detach();
680 mData->empty = false; 681 mData->empty = false;
681 mData->externalUID = id; 682 mData->externalUID = id;
682} 683}
683 684
684const QString Addressee::externalUID() const 685const QString Addressee::externalUID() const
685{ 686{
686 return mData->externalUID; 687 return mData->externalUID;
687} 688}
688void Addressee::setOriginalExternalUID( const QString &id ) 689void Addressee::setOriginalExternalUID( const QString &id )
689{ 690{
690 if ( id == mData->originalExternalUID ) return; 691 if ( id == mData->originalExternalUID ) return;
691 detach(); 692 detach();
692 mData->empty = false; 693 mData->empty = false;
693 //qDebug("*******Set orig uid %s ", id.latin1()); 694 //qDebug("*******Set orig uid %s ", id.latin1());
694 mData->originalExternalUID = id; 695 mData->originalExternalUID = id;
695} 696}
696 697
697QString Addressee::originalExternalUID() const 698QString Addressee::originalExternalUID() const
698{ 699{
699 return mData->originalExternalUID; 700 return mData->originalExternalUID;
700} 701}
701 702
702void Addressee::setUid( const QString &id ) 703void Addressee::setUid( const QString &id )
703{ 704{
704 if ( id == mData->uid ) return; 705 if ( id == mData->uid ) return;
705 detach(); 706 detach();
706 //qDebug("****setuid %s ", id.latin1()); 707 //qDebug("****setuid %s ", id.latin1());
707 mData->empty = false; 708 mData->empty = false;
708 mData->uid = id; 709 mData->uid = id;
709} 710}
710 711
711const QString Addressee::uid() const 712const QString Addressee::uid() const
712{ 713{
713 if ( mData->uid.isEmpty() ) 714 if ( mData->uid.isEmpty() )
714 mData->uid = KApplication::randomString( 10 ); 715 mData->uid = KApplication::randomString( 10 );
715 716
716 return mData->uid; 717 return mData->uid;
717} 718}
718 719
719QString Addressee::uidLabel() 720QString Addressee::uidLabel()
720{ 721{
721 return i18n("Unique Identifier"); 722 return i18n("Unique Identifier");
722} 723}
723 724
724void Addressee::setName( const QString &name ) 725void Addressee::setName( const QString &name )
725{ 726{
726 if ( name == mData->name ) return; 727 if ( name == mData->name ) return;
727 detach(); 728 detach();
728 mData->empty = false; 729 mData->empty = false;
729 mData->name = name; 730 mData->name = name;
730} 731}
731 732
732QString Addressee::name() const 733QString Addressee::name() const
733{ 734{
734 return mData->name; 735 return mData->name;
735} 736}
736 737
737QString Addressee::nameLabel() 738QString Addressee::nameLabel()
738{ 739{
739 return i18n("Name"); 740 return i18n("Name");
740} 741}
741 742
742 743
743void Addressee::setFormattedName( const QString &formattedName ) 744void Addressee::setFormattedName( const QString &formattedName )
744{ 745{
745 if ( formattedName == mData->formattedName ) return; 746 if ( formattedName == mData->formattedName ) return;
746 detach(); 747 detach();
747 mData->empty = false; 748 mData->empty = false;
748 mData->formattedName = formattedName; 749 mData->formattedName = formattedName;
749} 750}
751void Addressee::setDefaultFormattedName( const QString &formattedName )
752{
753 if ( formattedName == mData->defaultFormattedName ) return;
754 detach();
755 mData->empty = false;
756 mData->defaultFormattedName = formattedName;
757}
750 758
751QString Addressee::formattedName() const 759QString Addressee::formattedName() const
752{ 760{
753 return mData->formattedName; 761 return mData->formattedName;
754} 762}
763QString Addressee::defaultFormattedName() const
764{
765 return mData->defaultFormattedName;
766}
755 767
756QString Addressee::formattedNameLabel() 768QString Addressee::formattedNameLabel()
757{ 769{
758 return i18n("Formatted Name"); 770 return i18n("Formatted Name");
759} 771}
760 772
773QString Addressee::defaultFormattedNameLabel()
774{
775 return i18n("Def.Formatted Name");
776}
777
761 778
762void Addressee::setFamilyName( const QString &familyName ) 779void Addressee::setFamilyName( const QString &familyName )
763{ 780{
764 if ( familyName == mData->familyName ) return; 781 if ( familyName == mData->familyName ) return;
765 detach(); 782 detach();
766 mData->empty = false; 783 mData->empty = false;
767 mData->familyName = familyName; 784 mData->familyName = familyName;
768} 785}
769 786
770QString Addressee::familyName() const 787QString Addressee::familyName() const
771{ 788{
772 return mData->familyName; 789 return mData->familyName;
773} 790}
774 791
775QString Addressee::familyNameLabel() 792QString Addressee::familyNameLabel()
776{ 793{
777 return i18n("Family Name"); 794 return i18n("Family Name");
778} 795}
779 796
780 797
781void Addressee::setGivenName( const QString &givenName ) 798void Addressee::setGivenName( const QString &givenName )
782{ 799{
783 if ( givenName == mData->givenName ) return; 800 if ( givenName == mData->givenName ) return;
784 detach(); 801 detach();
785 mData->empty = false; 802 mData->empty = false;
786 mData->givenName = givenName; 803 mData->givenName = givenName;
787} 804}
788 805
789QString Addressee::givenName() const 806QString Addressee::givenName() const
790{ 807{
791 return mData->givenName; 808 return mData->givenName;
792} 809}
793 810
794QString Addressee::givenNameLabel() 811QString Addressee::givenNameLabel()
795{ 812{
796 return i18n("Given Name"); 813 return i18n("Given Name");
797} 814}
798 815
799 816
800void Addressee::setAdditionalName( const QString &additionalName ) 817void Addressee::setAdditionalName( const QString &additionalName )
801{ 818{
802 if ( additionalName == mData->additionalName ) return; 819 if ( additionalName == mData->additionalName ) return;
803 detach(); 820 detach();
804 mData->empty = false; 821 mData->empty = false;
805 mData->additionalName = additionalName; 822 mData->additionalName = additionalName;
806} 823}
807 824
808QString Addressee::additionalName() const 825QString Addressee::additionalName() const
809{ 826{
810 return mData->additionalName; 827 return mData->additionalName;
811} 828}
812 829
813QString Addressee::additionalNameLabel() 830QString Addressee::additionalNameLabel()
814{ 831{
815 return i18n("Additional Names"); 832 return i18n("Additional Names");
816} 833}
817 834
818 835
819void Addressee::setPrefix( const QString &prefix ) 836void Addressee::setPrefix( const QString &prefix )
820{ 837{
821 if ( prefix == mData->prefix ) return; 838 if ( prefix == mData->prefix ) return;
822 detach(); 839 detach();
823 mData->empty = false; 840 mData->empty = false;
824 mData->prefix = prefix; 841 mData->prefix = prefix;
825} 842}
826 843
827QString Addressee::prefix() const 844QString Addressee::prefix() const
828{ 845{
829 return mData->prefix; 846 return mData->prefix;
830} 847}
831 848
832QString Addressee::prefixLabel() 849QString Addressee::prefixLabel()
833{ 850{
834 return i18n("Honorific Prefixes"); 851 return i18n("Honorific Prefixes");
835} 852}
836 853
837 854
838void Addressee::setSuffix( const QString &suffix ) 855void Addressee::setSuffix( const QString &suffix )
839{ 856{
840 if ( suffix == mData->suffix ) return; 857 if ( suffix == mData->suffix ) return;
841 detach(); 858 detach();
842 mData->empty = false; 859 mData->empty = false;
843 mData->suffix = suffix; 860 mData->suffix = suffix;
844} 861}
845 862
846QString Addressee::suffix() const 863QString Addressee::suffix() const
847{ 864{
848 return mData->suffix; 865 return mData->suffix;
849} 866}
850 867
851QString Addressee::suffixLabel() 868QString Addressee::suffixLabel()
852{ 869{
853 return i18n("Honorific Suffixes"); 870 return i18n("Honorific Suffixes");
854} 871}
855 872
856 873
857void Addressee::setNickName( const QString &nickName ) 874void Addressee::setNickName( const QString &nickName )
858{ 875{
859 if ( nickName == mData->nickName ) return; 876 if ( nickName == mData->nickName ) return;
860 detach(); 877 detach();
861 mData->empty = false; 878 mData->empty = false;
862 mData->nickName = nickName; 879 mData->nickName = nickName;
863} 880}
864 881
865QString Addressee::nickName() const 882QString Addressee::nickName() const
866{ 883{
867 return mData->nickName; 884 return mData->nickName;
868} 885}
869 886
870QString Addressee::nickNameLabel() 887QString Addressee::nickNameLabel()
871{ 888{
872 return i18n("Nick Name"); 889 return i18n("Nick Name");
873} 890}
874 891
875 892
876void Addressee::setBirthday( const QDateTime &birthday ) 893void Addressee::setBirthday( const QDateTime &birthday )
877{ 894{
878 if ( birthday == mData->birthday ) return; 895 if ( birthday == mData->birthday ) return;
879 detach(); 896 detach();
880 mData->empty = false; 897 mData->empty = false;
881 mData->birthday = birthday; 898 mData->birthday = birthday;
882} 899}
883 900
884QDateTime Addressee::birthday() const 901QDateTime Addressee::birthday() const
885{ 902{
886 return mData->birthday; 903 return mData->birthday;
887} 904}
888 905
889QString Addressee::birthdayLabel() 906QString Addressee::birthdayLabel()
890{ 907{
891 return i18n("Birthday"); 908 return i18n("Birthday");
892} 909}
893 910
894 911
895QString Addressee::homeAddressStreetLabel() 912QString Addressee::homeAddressStreetLabel()
896{ 913{
897 return i18n("Home Address Street"); 914 return i18n("Home Address Street");
898} 915}
899 916
900 917
901QString Addressee::homeAddressLocalityLabel() 918QString Addressee::homeAddressLocalityLabel()
902{ 919{
903 return i18n("Home Address Locality"); 920 return i18n("Home Address Locality");
904} 921}
905 922
906 923
907QString Addressee::homeAddressRegionLabel() 924QString Addressee::homeAddressRegionLabel()
908{ 925{
909 return i18n("Home Address Region"); 926 return i18n("Home Address Region");
910} 927}
911 928
912 929
913QString Addressee::homeAddressPostalCodeLabel() 930QString Addressee::homeAddressPostalCodeLabel()
914{ 931{
915 return i18n("Home Address Postal Code"); 932 return i18n("Home Address Postal Code");
916} 933}
917 934
918 935
919QString Addressee::homeAddressCountryLabel() 936QString Addressee::homeAddressCountryLabel()
920{ 937{
921 return i18n("Home Address Country"); 938 return i18n("Home Address Country");
922} 939}
923 940
924 941
925QString Addressee::homeAddressLabelLabel() 942QString Addressee::homeAddressLabelLabel()
926{ 943{
927 return i18n("Home Address Label"); 944 return i18n("Home Address Label");
928} 945}
929 946
930 947
931QString Addressee::businessAddressStreetLabel() 948QString Addressee::businessAddressStreetLabel()
932{ 949{
933 return i18n("Business Address Street"); 950 return i18n("Business Address Street");
934} 951}
935 952
936 953
937QString Addressee::businessAddressLocalityLabel() 954QString Addressee::businessAddressLocalityLabel()
938{ 955{
939 return i18n("Business Address Locality"); 956 return i18n("Business Address Locality");
940} 957}
941 958
942 959
943QString Addressee::businessAddressRegionLabel() 960QString Addressee::businessAddressRegionLabel()
944{ 961{
945 return i18n("Business Address Region"); 962 return i18n("Business Address Region");
946} 963}
947 964
948 965
949QString Addressee::businessAddressPostalCodeLabel() 966QString Addressee::businessAddressPostalCodeLabel()
950{ 967{
951 return i18n("Business Address Postal Code"); 968 return i18n("Business Address Postal Code");
952} 969}
953 970
954 971
955QString Addressee::businessAddressCountryLabel() 972QString Addressee::businessAddressCountryLabel()
956{ 973{
957 return i18n("Business Address Country"); 974 return i18n("Business Address Country");
958} 975}
959 976
960 977
961QString Addressee::businessAddressLabelLabel() 978QString Addressee::businessAddressLabelLabel()
962{ 979{
963 return i18n("Business Address Label"); 980 return i18n("Business Address Label");
964} 981}
965 982
966 983
967QString Addressee::homePhoneLabel() 984QString Addressee::homePhoneLabel()
968{ 985{
969 return i18n("Home Phone"); 986 return i18n("Home Phone");
970} 987}
971 988
972 989
973QString Addressee::businessPhoneLabel() 990QString Addressee::businessPhoneLabel()
974{ 991{
975 return i18n("Business Phone"); 992 return i18n("Business Phone");
976} 993}
977 994
978 995
979QString Addressee::mobilePhoneLabel() 996QString Addressee::mobilePhoneLabel()
980{ 997{
981 return i18n("Mobile Phone"); 998 return i18n("Mobile Phone");
982} 999}
1000QString Addressee::mobileWorkPhoneLabel()
1001{
1002 return i18n("Mobile (work)");
1003}
1004QString Addressee::mobileHomePhoneLabel()
1005{
1006 return i18n("Mobile (home)");
1007}
983 1008
984 1009
985QString Addressee::homeFaxLabel() 1010QString Addressee::homeFaxLabel()
986{ 1011{
987 return i18n("Home Fax"); 1012 return i18n("Home Fax");
988} 1013}
989 1014
990 1015
991QString Addressee::businessFaxLabel() 1016QString Addressee::businessFaxLabel()
992{ 1017{
993 return i18n("Business Fax"); 1018 return i18n("Business Fax");
994} 1019}
995 1020
996 1021
997QString Addressee::carPhoneLabel() 1022QString Addressee::carPhoneLabel()
998{ 1023{
999 return i18n("Car Phone"); 1024 return i18n("Car Phone");
1000} 1025}
1001 1026
1002 1027
1003QString Addressee::isdnLabel() 1028QString Addressee::isdnLabel()
1004{ 1029{
1005 return i18n("ISDN"); 1030 return i18n("ISDN");
1006} 1031}
1007 1032
1008 1033
1009QString Addressee::pagerLabel() 1034QString Addressee::pagerLabel()
1010{ 1035{
1011 return i18n("Pager"); 1036 return i18n("Pager");
1012} 1037}
1013 1038
1014QString Addressee::sipLabel() 1039QString Addressee::sipLabel()
1015{ 1040{
1016 return i18n("SIP"); 1041 return i18n("SIP");
1017} 1042}
1018 1043
1019QString Addressee::emailLabel() 1044QString Addressee::emailLabel()
1020{ 1045{
1021 return i18n("Email Address"); 1046 return i18n("Email Address");
1022} 1047}
1023 1048
1024 1049
1025void Addressee::setMailer( const QString &mailer ) 1050void Addressee::setMailer( const QString &mailer )
1026{ 1051{
1027 if ( mailer == mData->mailer ) return; 1052 if ( mailer == mData->mailer ) return;
1028 detach(); 1053 detach();
1029 mData->empty = false; 1054 mData->empty = false;
1030 mData->mailer = mailer; 1055 mData->mailer = mailer;
1031} 1056}
1032 1057
1033QString Addressee::mailer() const 1058QString Addressee::mailer() const
1034{ 1059{
1035 return mData->mailer; 1060 return mData->mailer;
1036} 1061}
1037 1062
1038QString Addressee::mailerLabel() 1063QString Addressee::mailerLabel()
1039{ 1064{
1040 return i18n("Mail Client"); 1065 return i18n("Mail Client");
1041} 1066}
1042 1067
1043 1068
1044void Addressee::setTimeZone( const TimeZone &timeZone ) 1069void Addressee::setTimeZone( const TimeZone &timeZone )
1045{ 1070{
1046 if ( timeZone == mData->timeZone ) return; 1071 if ( timeZone == mData->timeZone ) return;
1047 detach(); 1072 detach();
1048 mData->empty = false; 1073 mData->empty = false;
1049 mData->timeZone = timeZone; 1074 mData->timeZone = timeZone;
1050} 1075}
1051 1076
1052TimeZone Addressee::timeZone() const 1077TimeZone Addressee::timeZone() const
1053{ 1078{
1054 return mData->timeZone; 1079 return mData->timeZone;
1055} 1080}
1056 1081
1057QString Addressee::timeZoneLabel() 1082QString Addressee::timeZoneLabel()
1058{ 1083{
1059 return i18n("Time Zone"); 1084 return i18n("Time Zone");
1060} 1085}
1061 1086
1062 1087
1063void Addressee::setGeo( const Geo &geo ) 1088void Addressee::setGeo( const Geo &geo )
1064{ 1089{
1065 if ( geo == mData->geo ) return; 1090 if ( geo == mData->geo ) return;
1066 detach(); 1091 detach();
1067 mData->empty = false; 1092 mData->empty = false;
1068 mData->geo = geo; 1093 mData->geo = geo;
1069} 1094}
1070 1095
1071Geo Addressee::geo() const 1096Geo Addressee::geo() const
1072{ 1097{
1073 return mData->geo; 1098 return mData->geo;
1074} 1099}
1075 1100
1076QString Addressee::geoLabel() 1101QString Addressee::geoLabel()
1077{ 1102{
1078 return i18n("Geographic Position"); 1103 return i18n("Geographic Position");
1079} 1104}
1080 1105
1081 1106
1082void Addressee::setTitle( const QString &title ) 1107void Addressee::setTitle( const QString &title )
1083{ 1108{
1084 if ( title == mData->title ) return; 1109 if ( title == mData->title ) return;
1085 detach(); 1110 detach();
1086 mData->empty = false; 1111 mData->empty = false;
1087 mData->title = title; 1112 mData->title = title;
1088} 1113}
1089 1114
1090QString Addressee::title() const 1115QString Addressee::title() const
1091{ 1116{
1092 return mData->title; 1117 return mData->title;
1093} 1118}
1094 1119
1095QString Addressee::titleLabel() 1120QString Addressee::titleLabel()
1096{ 1121{
1097 return i18n("Title"); 1122 return i18n("Title");
1098} 1123}
1099 1124
1100 1125
1101void Addressee::setRole( const QString &role ) 1126void Addressee::setRole( const QString &role )
1102{ 1127{
1103 if ( role == mData->role ) return; 1128 if ( role == mData->role ) return;
1104 detach(); 1129 detach();
1105 mData->empty = false; 1130 mData->empty = false;
1106 mData->role = role; 1131 mData->role = role;
1107} 1132}
1108 1133
1109QString Addressee::role() const 1134QString Addressee::role() const
1110{ 1135{
1111 return mData->role; 1136 return mData->role;
1112} 1137}
1113 1138
1114QString Addressee::roleLabel() 1139QString Addressee::roleLabel()
1115{ 1140{
1116 return i18n("Role"); 1141 return i18n("Role");
1117} 1142}
1118 1143
1119 1144
1120void Addressee::setOrganization( const QString &organization ) 1145void Addressee::setOrganization( const QString &organization )
1121{ 1146{
1122 if ( organization == mData->organization ) return; 1147 if ( organization == mData->organization ) return;
1123 detach(); 1148 detach();
1124 mData->empty = false; 1149 mData->empty = false;
1125 mData->organization = organization; 1150 mData->organization = organization;
1126} 1151}
1127 1152
1128QString Addressee::organization() const 1153QString Addressee::organization() const
1129{ 1154{
1130 return mData->organization; 1155 return mData->organization;
1131} 1156}
1132 1157
1133QString Addressee::organizationLabel() 1158QString Addressee::organizationLabel()
1134{ 1159{
1135 return i18n("Organization"); 1160 return i18n("Organization");
1136} 1161}
1137 1162
1138 1163
1139void Addressee::setNote( const QString &note ) 1164void Addressee::setNote( const QString &note )
1140{ 1165{
1141 if ( note == mData->note ) return; 1166 if ( note == mData->note ) return;
1142 detach(); 1167 detach();
1143 mData->empty = false; 1168 mData->empty = false;
1144 mData->note = note; 1169 mData->note = note;
1145} 1170}
1146 1171
1147QString Addressee::note() const 1172QString Addressee::note() const
1148{ 1173{
1149 return mData->note; 1174 return mData->note;
1150} 1175}
1151 1176
1152QString Addressee::noteLabel() 1177QString Addressee::noteLabel()
1153{ 1178{
1154 return i18n("Note"); 1179 return i18n("Note");
1155} 1180}
1156 1181
1157 1182
1158void Addressee::setProductId( const QString &productId ) 1183void Addressee::setProductId( const QString &productId )
1159{ 1184{
1160 if ( productId == mData->productId ) return; 1185 if ( productId == mData->productId ) return;
1161 detach(); 1186 detach();
1162 mData->empty = false; 1187 mData->empty = false;
1163 mData->productId = productId; 1188 mData->productId = productId;
1164} 1189}
1165 1190
1166QString Addressee::productId() const 1191QString Addressee::productId() const
1167{ 1192{
1168 return mData->productId; 1193 return mData->productId;
1169} 1194}
1170 1195
1171QString Addressee::productIdLabel() 1196QString Addressee::productIdLabel()
1172{ 1197{
1173 return i18n("Product Identifier"); 1198 return i18n("Product Identifier");
1174} 1199}
1175 1200
1176 1201
1177void Addressee::setRevision( const QDateTime &revision ) 1202void Addressee::setRevision( const QDateTime &revision )
1178{ 1203{
1179 if ( revision == mData->revision ) return; 1204 if ( revision == mData->revision ) return;
1180 detach(); 1205 detach();
1181 mData->empty = false; 1206 mData->empty = false;
1182 mData->revision = QDateTime( revision.date(), 1207 mData->revision = QDateTime( revision.date(),
1183 QTime (revision.time().hour(), 1208 QTime (revision.time().hour(),
1184 revision.time().minute(), 1209 revision.time().minute(),
1185 revision.time().second())); 1210 revision.time().second()));
1186} 1211}
1187 1212
1188QDateTime Addressee::revision() const 1213QDateTime Addressee::revision() const
1189{ 1214{
1190 return mData->revision; 1215 return mData->revision;
1191} 1216}
1192 1217
1193QString Addressee::revisionLabel() 1218QString Addressee::revisionLabel()
1194{ 1219{
1195 return i18n("Revision Date"); 1220 return i18n("Revision Date");
1196} 1221}
1197 1222
1198 1223
1199void Addressee::setSortString( const QString &sortString ) 1224void Addressee::setSortString( const QString &sortString )
1200{ 1225{
1201 if ( sortString == mData->sortString ) return; 1226 if ( sortString == mData->sortString ) return;
1202 detach(); 1227 detach();
1203 mData->empty = false; 1228 mData->empty = false;
1204 mData->sortString = sortString; 1229 mData->sortString = sortString;
1205} 1230}
1206 1231
1207QString Addressee::sortString() const 1232QString Addressee::sortString() const
1208{ 1233{
1209 return mData->sortString; 1234 return mData->sortString;
1210} 1235}
1211 1236
1212QString Addressee::sortStringLabel() 1237QString Addressee::sortStringLabel()
1213{ 1238{
1214 return i18n("Sort String"); 1239 return i18n("Sort String");
1215} 1240}
1216 1241
1217 1242
1218void Addressee::setUrl( const KURL &url ) 1243void Addressee::setUrl( const KURL &url )
1219{ 1244{
1220 if ( url == mData->url ) return; 1245 if ( url == mData->url ) return;
1221 detach(); 1246 detach();
1222 mData->empty = false; 1247 mData->empty = false;
1223 mData->url = url; 1248 mData->url = url;
1224} 1249}
1225 1250
1226KURL Addressee::url() const 1251KURL Addressee::url() const
1227{ 1252{
1228 return mData->url; 1253 return mData->url;
1229} 1254}
1230 1255
1231QString Addressee::urlLabel() 1256QString Addressee::urlLabel()
1232{ 1257{
1233 return i18n("URL"); 1258 return i18n("URL");
1234} 1259}
1235 1260
1236 1261
1237void Addressee::setSecrecy( const Secrecy &secrecy ) 1262void Addressee::setSecrecy( const Secrecy &secrecy )
1238{ 1263{
1239 if ( secrecy == mData->secrecy ) return; 1264 if ( secrecy == mData->secrecy ) return;
1240 detach(); 1265 detach();
1241 mData->empty = false; 1266 mData->empty = false;
1242 mData->secrecy = secrecy; 1267 mData->secrecy = secrecy;
1243} 1268}
1244 1269
1245Secrecy Addressee::secrecy() const 1270Secrecy Addressee::secrecy() const
1246{ 1271{
1247 return mData->secrecy; 1272 return mData->secrecy;
1248} 1273}
1249 1274
1250QString Addressee::secrecyLabel() 1275QString Addressee::secrecyLabel()
1251{ 1276{
1252 return i18n("Security Class"); 1277 return i18n("Security Class");
1253} 1278}
1254 1279
1255 1280
1256void Addressee::setLogo( const Picture &logo ) 1281void Addressee::setLogo( const Picture &logo )
1257{ 1282{
1258 if ( logo == mData->logo ) return; 1283 if ( logo == mData->logo ) return;
1259 detach(); 1284 detach();
1260 mData->empty = false; 1285 mData->empty = false;
1261 mData->logo = logo; 1286 mData->logo = logo;
1262} 1287}
1263 1288
1264Picture Addressee::logo() const 1289Picture Addressee::logo() const
1265{ 1290{
1266 return mData->logo; 1291 return mData->logo;
1267} 1292}
1268 1293
1269QString Addressee::logoLabel() 1294QString Addressee::logoLabel()
1270{ 1295{
1271 return i18n("Logo"); 1296 return i18n("Logo");
1272} 1297}
1273 1298
1274 1299
1275void Addressee::setPhoto( const Picture &photo ) 1300void Addressee::setPhoto( const Picture &photo )
1276{ 1301{
1277 if ( photo == mData->photo ) return; 1302 if ( photo == mData->photo ) return;
1278 detach(); 1303 detach();
1279 mData->empty = false; 1304 mData->empty = false;
1280 mData->photo = photo; 1305 mData->photo = photo;
1281} 1306}
1282 1307
1283Picture Addressee::photo() const 1308Picture Addressee::photo() const
1284{ 1309{
1285 return mData->photo; 1310 return mData->photo;
1286} 1311}
1287 1312
1288QString Addressee::photoLabel() 1313QString Addressee::photoLabel()
1289{ 1314{
1290 return i18n("Photo"); 1315 return i18n("Photo");
1291} 1316}
1292 1317
1293 1318
1294void Addressee::setSound( const Sound &sound ) 1319void Addressee::setSound( const Sound &sound )
1295{ 1320{
1296 if ( sound == mData->sound ) return; 1321 if ( sound == mData->sound ) return;
1297 detach(); 1322 detach();
1298 mData->empty = false; 1323 mData->empty = false;
1299 mData->sound = sound; 1324 mData->sound = sound;
1300} 1325}
1301 1326
1302Sound Addressee::sound() const 1327Sound Addressee::sound() const
1303{ 1328{
1304 return mData->sound; 1329 return mData->sound;
1305} 1330}
1306 1331
1307QString Addressee::soundLabel() 1332QString Addressee::soundLabel()
1308{ 1333{
1309 return i18n("Sound"); 1334 return i18n("Sound");
1310} 1335}
1311 1336
1312 1337
1313void Addressee::setAgent( const Agent &agent ) 1338void Addressee::setAgent( const Agent &agent )
1314{ 1339{
1315 if ( agent == mData->agent ) return; 1340 if ( agent == mData->agent ) return;
1316 detach(); 1341 detach();
1317 mData->empty = false; 1342 mData->empty = false;
1318 mData->agent = agent; 1343 mData->agent = agent;
1319} 1344}
1320 1345
1321Agent Addressee::agent() const 1346Agent Addressee::agent() const
1322{ 1347{
1323 return mData->agent; 1348 return mData->agent;
1324} 1349}
1325 1350
1326QString Addressee::agentLabel() 1351QString Addressee::agentLabel()
1327{ 1352{
1328 return i18n("Agent"); 1353 return i18n("Agent");
1329} 1354}
1330 1355
1331 1356
1332 1357
1333void Addressee::setNameFromString( const QString &str ) 1358void Addressee::setNameFromString( const QString &str )
1334{ 1359{
1335 setFormattedName( str ); 1360 setFormattedName( str );
1336 setName( str ); 1361 setName( str );
1337 1362
1338 static bool first = true; 1363 static bool first = true;
1339 static QStringList titles; 1364 static QStringList titles;
1340 static QStringList suffixes; 1365 static QStringList suffixes;
1341 static QStringList prefixes; 1366 static QStringList prefixes;
1342 1367
1343 if ( first ) { 1368 if ( first ) {
1344 first = false; 1369 first = false;
1345 titles += i18n( "Dr." ); 1370 titles += i18n( "Dr." );
1346 titles += i18n( "Miss" ); 1371 titles += i18n( "Miss" );
1347 titles += i18n( "Mr." ); 1372 titles += i18n( "Mr." );
1348 titles += i18n( "Mrs." ); 1373 titles += i18n( "Mrs." );
1349 titles += i18n( "Ms." ); 1374 titles += i18n( "Ms." );
1350 titles += i18n( "Prof." ); 1375 titles += i18n( "Prof." );
1351 1376
1352 suffixes += i18n( "I" ); 1377 suffixes += i18n( "I" );
1353 suffixes += i18n( "II" ); 1378 suffixes += i18n( "II" );
1354 suffixes += i18n( "III" ); 1379 suffixes += i18n( "III" );
1355 suffixes += i18n( "Jr." ); 1380 suffixes += i18n( "Jr." );
1356 suffixes += i18n( "Sr." ); 1381 suffixes += i18n( "Sr." );
1357 1382
1358 prefixes += "van"; 1383 prefixes += "van";
1359 prefixes += "von"; 1384 prefixes += "von";
1360 prefixes += "de"; 1385 prefixes += "de";
1361 1386
1362 KConfig config( locateLocal( "config", "kabcrc") ); 1387 KConfig config( locateLocal( "config", "kabcrc") );
1363 config.setGroup( "General" ); 1388 config.setGroup( "General" );
1364 titles += config.readListEntry( "Prefixes" ); 1389 titles += config.readListEntry( "Prefixes" );
1365 titles.remove( "" ); 1390 titles.remove( "" );
1366 prefixes += config.readListEntry( "Inclusions" ); 1391 prefixes += config.readListEntry( "Inclusions" );
1367 prefixes.remove( "" ); 1392 prefixes.remove( "" );
1368 suffixes += config.readListEntry( "Suffixes" ); 1393 suffixes += config.readListEntry( "Suffixes" );
1369 suffixes.remove( "" ); 1394 suffixes.remove( "" );
1370 } 1395 }
1371 1396
1372 // clear all name parts 1397 // clear all name parts
1373 setPrefix( "" ); 1398 setPrefix( "" );
1374 setGivenName( "" ); 1399 setGivenName( "" );
1375 setAdditionalName( "" ); 1400 setAdditionalName( "" );
1376 setFamilyName( "" ); 1401 setFamilyName( "" );
1377 setSuffix( "" ); 1402 setSuffix( "" );
1378 1403
1379 if ( str.isEmpty() ) 1404 if ( str.isEmpty() )
1380 return; 1405 return;
1381 1406
1382 int i = str.find(','); 1407 int i = str.find(',');
1383 if( i < 0 ) { 1408 if( i < 0 ) {
1384 QStringList parts = QStringList::split( " ", str ); 1409 QStringList parts = QStringList::split( " ", str );
1385 int leftOffset = 0; 1410 int leftOffset = 0;
1386 int rightOffset = parts.count() - 1; 1411 int rightOffset = parts.count() - 1;
1387 1412
1388 QString suffix; 1413 QString suffix;
1389 while ( rightOffset >= 0 ) { 1414 while ( rightOffset >= 0 ) {
1390 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1415 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1391 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1416 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1392 rightOffset--; 1417 rightOffset--;
1393 } else 1418 } else
1394 break; 1419 break;
1395 } 1420 }
1396 setSuffix( suffix ); 1421 setSuffix( suffix );
1397 1422
1398 if ( rightOffset < 0 ) 1423 if ( rightOffset < 0 )
1399 return; 1424 return;
1400 1425
1401 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1426 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1402 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1427 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1403 rightOffset--; 1428 rightOffset--;
1404 } else 1429 } else
1405 setFamilyName( parts[ rightOffset ] ); 1430 setFamilyName( parts[ rightOffset ] );
1406 1431
1407 QString prefix; 1432 QString prefix;
1408 while ( leftOffset < rightOffset ) { 1433 while ( leftOffset < rightOffset ) {
1409 if ( titles.contains( parts[ leftOffset ] ) ) { 1434 if ( titles.contains( parts[ leftOffset ] ) ) {
1410 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1435 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1411 leftOffset++; 1436 leftOffset++;
1412 } else 1437 } else
1413 break; 1438 break;
1414 } 1439 }
1415 setPrefix( prefix ); 1440 setPrefix( prefix );
1416 1441
1417 if ( leftOffset < rightOffset ) { 1442 if ( leftOffset < rightOffset ) {
1418 setGivenName( parts[ leftOffset ] ); 1443 setGivenName( parts[ leftOffset ] );
1419 leftOffset++; 1444 leftOffset++;
1420 } 1445 }
1421 1446
1422 QString additionalName; 1447 QString additionalName;
1423 while ( leftOffset < rightOffset ) { 1448 while ( leftOffset < rightOffset ) {
1424 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1449 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1425 leftOffset++; 1450 leftOffset++;
1426 } 1451 }
1427 setAdditionalName( additionalName ); 1452 setAdditionalName( additionalName );
1428 } else { 1453 } else {
1429 QString part1 = str.left( i ); 1454 QString part1 = str.left( i );
1430 QString part2 = str.mid( i + 1 ); 1455 QString part2 = str.mid( i + 1 );
1431 1456
1432 QStringList parts = QStringList::split( " ", part1 ); 1457 QStringList parts = QStringList::split( " ", part1 );
1433 int leftOffset = 0; 1458 int leftOffset = 0;
1434 int rightOffset = parts.count() - 1; 1459 int rightOffset = parts.count() - 1;
1435 1460
1436 QString suffix; 1461 QString suffix;
1437 while ( rightOffset >= 0 ) { 1462 while ( rightOffset >= 0 ) {
1438 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1463 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1439 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1464 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1440 rightOffset--; 1465 rightOffset--;
1441 } else 1466 } else
1442 break; 1467 break;
1443 } 1468 }
1444 setSuffix( suffix ); 1469 setSuffix( suffix );
1445 1470
1446 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1471 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1447 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1472 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1448 rightOffset--; 1473 rightOffset--;
1449 } else 1474 } else
1450 setFamilyName( parts[ rightOffset ] ); 1475 setFamilyName( parts[ rightOffset ] );
1451 1476
1452 QString prefix; 1477 QString prefix;
1453 while ( leftOffset < rightOffset ) { 1478 while ( leftOffset < rightOffset ) {
1454 if ( titles.contains( parts[ leftOffset ] ) ) { 1479 if ( titles.contains( parts[ leftOffset ] ) ) {
1455 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1480 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1456 leftOffset++; 1481 leftOffset++;
1457 } else 1482 } else
1458 break; 1483 break;
1459 } 1484 }
1460 1485
1461 parts = QStringList::split( " ", part2 ); 1486 parts = QStringList::split( " ", part2 );
1462 1487
1463 leftOffset = 0; 1488 leftOffset = 0;
1464 rightOffset = parts.count(); 1489 rightOffset = parts.count();
1465 1490
1466 while ( leftOffset < rightOffset ) { 1491 while ( leftOffset < rightOffset ) {
1467 if ( titles.contains( parts[ leftOffset ] ) ) { 1492 if ( titles.contains( parts[ leftOffset ] ) ) {
1468 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1493 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1469 leftOffset++; 1494 leftOffset++;
1470 } else 1495 } else
1471 break; 1496 break;
1472 } 1497 }
1473 setPrefix( prefix ); 1498 setPrefix( prefix );
1474 1499
1475 if ( leftOffset < rightOffset ) { 1500 if ( leftOffset < rightOffset ) {
1476 setGivenName( parts[ leftOffset ] ); 1501 setGivenName( parts[ leftOffset ] );
1477 leftOffset++; 1502 leftOffset++;
1478 } 1503 }
1479 1504
1480 QString additionalName; 1505 QString additionalName;
1481 while ( leftOffset < rightOffset ) { 1506 while ( leftOffset < rightOffset ) {
1482 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1507 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1483 leftOffset++; 1508 leftOffset++;
1484 } 1509 }
1485 setAdditionalName( additionalName ); 1510 setAdditionalName( additionalName );
1486 } 1511 }
1487} 1512}
1488 1513
1489QString Addressee::realName() const 1514QString Addressee::realName() const
1490{ 1515{
1491 if ( !formattedName().isEmpty() ) 1516 if ( !formattedName().isEmpty() )
1492 return formattedName(); 1517 return formattedName();
1493 1518
1494 QString n = assembledName(); 1519 QString n = assembledName();
1495 1520
1496 if ( n.isEmpty() ) 1521 if ( n.isEmpty() )
1497 n = name(); 1522 n = name();
1498 if ( n.isEmpty() ) 1523 if ( n.isEmpty() )
1499 n = organization(); 1524 n = organization();
1500 return n; 1525 return n;
1501} 1526}
1502 1527
1503QString Addressee::assembledName() const 1528QString Addressee::assembledName() const
1504{ 1529{
1505 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1530 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1506 familyName() + " " + suffix(); 1531 familyName() + " " + suffix();
1507 1532
1508 return name.simplifyWhiteSpace(); 1533 return name.simplifyWhiteSpace();
1509} 1534}
1510 1535
1511QString Addressee::fullEmail( const QString &email ) const 1536QString Addressee::fullEmail( const QString &email ) const
1512{ 1537{
1513 QString e; 1538 QString e;
1514 if ( email.isNull() ) { 1539 if ( email.isNull() ) {
1515 e = preferredEmail(); 1540 e = preferredEmail();
1516 } else { 1541 } else {
1517 e = email; 1542 e = email;
1518 } 1543 }
1519 if ( e.isEmpty() ) return QString::null; 1544 if ( e.isEmpty() ) return QString::null;
1520 1545
1521 QString text; 1546 QString text;
1522 if ( realName().isEmpty() ) 1547 if ( realName().isEmpty() )
1523 text = e; 1548 text = e;
1524 else 1549 else
1525 text = assembledName() + " <" + e + ">"; 1550 text = assembledName() + " <" + e + ">";
1526 1551
1527 return text; 1552 return text;
1528} 1553}
1529 1554
1530void Addressee::insertEmail( const QString &email, bool preferred ) 1555void Addressee::insertEmail( const QString &email, bool preferred )
1531{ 1556{
1532 detach(); 1557 detach();
1533 1558
1534 QStringList::Iterator it = mData->emails.find( email ); 1559 QStringList::Iterator it = mData->emails.find( email );
1535 1560
1536 if ( it != mData->emails.end() ) { 1561 if ( it != mData->emails.end() ) {
1537 if ( !preferred || it == mData->emails.begin() ) return; 1562 if ( !preferred || it == mData->emails.begin() ) return;
1538 mData->emails.remove( it ); 1563 mData->emails.remove( it );
1539 mData->emails.prepend( email ); 1564 mData->emails.prepend( email );
1540 } else { 1565 } else {
1541 if ( preferred ) { 1566 if ( preferred ) {
1542 mData->emails.prepend( email ); 1567 mData->emails.prepend( email );
1543 } else { 1568 } else {
1544 mData->emails.append( email ); 1569 mData->emails.append( email );
1545 } 1570 }
1546 } 1571 }
1547} 1572}
1548 1573
1549void Addressee::removeEmail( const QString &email ) 1574void Addressee::removeEmail( const QString &email )
1550{ 1575{
1551 detach(); 1576 detach();
1552 1577
1553 QStringList::Iterator it = mData->emails.find( email ); 1578 QStringList::Iterator it = mData->emails.find( email );
1554 if ( it == mData->emails.end() ) return; 1579 if ( it == mData->emails.end() ) return;
1555 1580
1556 mData->emails.remove( it ); 1581 mData->emails.remove( it );
1557} 1582}
1558 1583
1559QString Addressee::preferredEmail() const 1584QString Addressee::preferredEmail() const
1560{ 1585{
1561 if ( mData->emails.count() == 0 ) return QString::null; 1586 if ( mData->emails.count() == 0 ) return QString::null;
1562 else return mData->emails.first(); 1587 else return mData->emails.first();
1563} 1588}
1564 1589
1565QStringList Addressee::emails() const 1590QStringList Addressee::emails() const
1566{ 1591{
1567 return mData->emails; 1592 return mData->emails;
1568} 1593}
1569void Addressee::setEmails( const QStringList& emails ) { 1594void Addressee::setEmails( const QStringList& emails ) {
1570 detach(); 1595 detach();
1571 mData->emails = emails; 1596 mData->emails = emails;
1572} 1597}
1573void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1598void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1574{ 1599{
1575 detach(); 1600 detach();
1576 mData->empty = false; 1601 mData->empty = false;
1577 1602
1578 PhoneNumber::List::Iterator it; 1603 PhoneNumber::List::Iterator it;
1579 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1604 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1580 if ( (*it).id() == phoneNumber.id() ) { 1605 if ( (*it).id() == phoneNumber.id() ) {
1581 *it = phoneNumber; 1606 *it = phoneNumber;
1582 return; 1607 return;
1583 } 1608 }
1584 } 1609 }
1585 mData->phoneNumbers.append( phoneNumber ); 1610 mData->phoneNumbers.append( phoneNumber );
1586} 1611}
1587 1612
1588void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1613void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1589{ 1614{
1590 detach(); 1615 detach();
1591 1616
1592 PhoneNumber::List::Iterator it; 1617 PhoneNumber::List::Iterator it;
1593 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1618 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1594 if ( (*it).id() == phoneNumber.id() ) { 1619 if ( (*it).id() == phoneNumber.id() ) {
1595 mData->phoneNumbers.remove( it ); 1620 mData->phoneNumbers.remove( it );
1596 return; 1621 return;
1597 } 1622 }
1598 } 1623 }
1599} 1624}
1600 1625
1601PhoneNumber Addressee::phoneNumber( int type ) const 1626PhoneNumber Addressee::phoneNumber( int type ) const
1602{ 1627{
1603 PhoneNumber phoneNumber( "", type ); 1628 PhoneNumber phoneNumber( "", type );
1604 PhoneNumber::List::ConstIterator it; 1629 PhoneNumber::List::ConstIterator it;
1605 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1630 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1606 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1631 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1607 if ( (*it).type() & PhoneNumber::Pref ) 1632 if ( (*it).type() & PhoneNumber::Pref )
1608 return (*it); 1633 return (*it);
1609 else if ( phoneNumber.number().isEmpty() ) 1634 else if ( phoneNumber.number().isEmpty() )
1610 phoneNumber = (*it); 1635 phoneNumber = (*it);
1611 } 1636 }
1612 } 1637 }
1613 1638
1614 return phoneNumber; 1639 return phoneNumber;
1615} 1640}
1616 1641
1617PhoneNumber::List Addressee::phoneNumbers() const 1642PhoneNumber::List Addressee::phoneNumbers() const
1618{ 1643{
1619 return mData->phoneNumbers; 1644 return mData->phoneNumbers;
1620} 1645}
1621 1646
1622PhoneNumber::List Addressee::phoneNumbers( int type ) const 1647PhoneNumber::List Addressee::phoneNumbers( int type ) const
1623{ 1648{
1624 PhoneNumber::List list; 1649 PhoneNumber::List list;
1625 1650
1626 PhoneNumber::List::ConstIterator it; 1651 PhoneNumber::List::ConstIterator it;
1627 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1652 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1628 if ( matchBinaryPattern( (*it).type(), type ) ) { 1653 if ( matchBinaryPattern( (*it).type(), type ) ) {
1629 list.append( *it ); 1654 list.append( *it );
1630 } 1655 }
1631 } 1656 }
1632 return list; 1657 return list;
1633} 1658}
1634 1659
1635PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1660PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1636{ 1661{
1637 PhoneNumber::List::ConstIterator it; 1662 PhoneNumber::List::ConstIterator it;
1638 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1663 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1639 if ( (*it).id() == id ) { 1664 if ( (*it).id() == id ) {
1640 return *it; 1665 return *it;
1641 } 1666 }
1642 } 1667 }
1643 return PhoneNumber(); 1668 return PhoneNumber();
1644} 1669}
1645 1670
1646void Addressee::insertKey( const Key &key ) 1671void Addressee::insertKey( const Key &key )
1647{ 1672{
1648 detach(); 1673 detach();
1649 mData->empty = false; 1674 mData->empty = false;
1650 1675
1651 Key::List::Iterator it; 1676 Key::List::Iterator it;
1652 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1677 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1653 if ( (*it).id() == key.id() ) { 1678 if ( (*it).id() == key.id() ) {
1654 *it = key; 1679 *it = key;
1655 return; 1680 return;
1656 } 1681 }
1657 } 1682 }
1658 mData->keys.append( key ); 1683 mData->keys.append( key );
1659} 1684}
1660 1685
1661void Addressee::removeKey( const Key &key ) 1686void Addressee::removeKey( const Key &key )
1662{ 1687{
1663 detach(); 1688 detach();
1664 1689
1665 Key::List::Iterator it; 1690 Key::List::Iterator it;
1666 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1691 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1667 if ( (*it).id() == key.id() ) { 1692 if ( (*it).id() == key.id() ) {
1668 mData->keys.remove( key ); 1693 mData->keys.remove( key );
1669 return; 1694 return;
1670 } 1695 }
1671 } 1696 }
1672} 1697}
1673 1698
1674Key Addressee::key( int type, QString customTypeString ) const 1699Key Addressee::key( int type, QString customTypeString ) const
1675{ 1700{
1676 Key::List::ConstIterator it; 1701 Key::List::ConstIterator it;
1677 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1702 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1678 if ( (*it).type() == type ) { 1703 if ( (*it).type() == type ) {
1679 if ( type == Key::Custom ) { 1704 if ( type == Key::Custom ) {
1680 if ( customTypeString.isEmpty() ) { 1705 if ( customTypeString.isEmpty() ) {
1681 return *it; 1706 return *it;
1682 } else { 1707 } else {
1683 if ( (*it).customTypeString() == customTypeString ) 1708 if ( (*it).customTypeString() == customTypeString )
1684 return (*it); 1709 return (*it);
1685 } 1710 }
1686 } else { 1711 } else {
1687 return *it; 1712 return *it;
1688 } 1713 }
1689 } 1714 }
1690 } 1715 }
1691 return Key( QString(), type ); 1716 return Key( QString(), type );
1692} 1717}
1693void Addressee::setKeys( const Key::List& list ) { 1718void Addressee::setKeys( const Key::List& list ) {
1694 detach(); 1719 detach();
1695 mData->keys = list; 1720 mData->keys = list;
1696} 1721}
1697 1722
1698Key::List Addressee::keys() const 1723Key::List Addressee::keys() const
1699{ 1724{
1700 return mData->keys; 1725 return mData->keys;
1701} 1726}
1702 1727
1703Key::List Addressee::keys( int type, QString customTypeString ) const 1728Key::List Addressee::keys( int type, QString customTypeString ) const
1704{ 1729{
1705 Key::List list; 1730 Key::List list;
1706 1731
1707 Key::List::ConstIterator it; 1732 Key::List::ConstIterator it;
1708 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1733 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1709 if ( (*it).type() == type ) { 1734 if ( (*it).type() == type ) {
1710 if ( type == Key::Custom ) { 1735 if ( type == Key::Custom ) {
1711 if ( customTypeString.isEmpty() ) { 1736 if ( customTypeString.isEmpty() ) {
1712 list.append(*it); 1737 list.append(*it);
1713 } else { 1738 } else {
1714 if ( (*it).customTypeString() == customTypeString ) 1739 if ( (*it).customTypeString() == customTypeString )
1715 list.append(*it); 1740 list.append(*it);
1716 } 1741 }
1717 } else { 1742 } else {
1718 list.append(*it); 1743 list.append(*it);
1719 } 1744 }
1720 } 1745 }
1721 } 1746 }
1722 return list; 1747 return list;
1723} 1748}
1724 1749
1725Key Addressee::findKey( const QString &id ) const 1750Key Addressee::findKey( const QString &id ) const
1726{ 1751{
1727 Key::List::ConstIterator it; 1752 Key::List::ConstIterator it;
1728 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1753 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1729 if ( (*it).id() == id ) { 1754 if ( (*it).id() == id ) {
1730 return *it; 1755 return *it;
1731 } 1756 }
1732 } 1757 }
1733 return Key(); 1758 return Key();
1734} 1759}
1735 1760
1736QString Addressee::asString() const 1761QString Addressee::asString() const
1737{ 1762{
1738 return "Smith, agent Smith..."; 1763 return "Smith, agent Smith...";
1739} 1764}
1740 1765
1741void Addressee::dump() const 1766void Addressee::dump() const
1742{ 1767{
1743 return; 1768 return;
1744#if 0 1769#if 0
1745 kdDebug(5700) << "Addressee {" << endl; 1770 kdDebug(5700) << "Addressee {" << endl;
1746 1771
1747 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1772 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1748 1773
1749 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1774 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1750 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1775 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1751 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1776 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1752 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1777 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1753 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1778 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1754 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1779 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1755 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1780 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1756 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1781 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1757 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1782 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1758 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1783 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1759 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1784 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1760 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1785 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1761 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1786 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1762 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1787 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1763 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1788 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1764 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1789 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1765 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1790 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1766 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1791 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1767 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1792 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1768 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1793 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1769 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1794 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1770 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1795 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1771 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1796 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1772 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1797 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1773 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1798 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1774 1799
1775 kdDebug(5700) << " Emails {" << endl; 1800 kdDebug(5700) << " Emails {" << endl;
1776 QStringList e = emails(); 1801 QStringList e = emails();
1777 QStringList::ConstIterator it; 1802 QStringList::ConstIterator it;
1778 for( it = e.begin(); it != e.end(); ++it ) { 1803 for( it = e.begin(); it != e.end(); ++it ) {
1779 kdDebug(5700) << " " << (*it) << endl; 1804 kdDebug(5700) << " " << (*it) << endl;
1780 } 1805 }
1781 kdDebug(5700) << " }" << endl; 1806 kdDebug(5700) << " }" << endl;
1782 1807
1783 kdDebug(5700) << " PhoneNumbers {" << endl; 1808 kdDebug(5700) << " PhoneNumbers {" << endl;
1784 PhoneNumber::List p = phoneNumbers(); 1809 PhoneNumber::List p = phoneNumbers();
1785 PhoneNumber::List::ConstIterator it2; 1810 PhoneNumber::List::ConstIterator it2;
1786 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1811 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1787 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1812 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1788 } 1813 }
1789 kdDebug(5700) << " }" << endl; 1814 kdDebug(5700) << " }" << endl;
1790 1815
1791 Address::List a = addresses(); 1816 Address::List a = addresses();
1792 Address::List::ConstIterator it3; 1817 Address::List::ConstIterator it3;
1793 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1818 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1794 (*it3).dump(); 1819 (*it3).dump();
1795 } 1820 }
1796 1821
1797 kdDebug(5700) << " Keys {" << endl; 1822 kdDebug(5700) << " Keys {" << endl;
1798 Key::List k = keys(); 1823 Key::List k = keys();
1799 Key::List::ConstIterator it4; 1824 Key::List::ConstIterator it4;
1800 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1825 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1801 kdDebug(5700) << " Type: " << int((*it4).type()) << 1826 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1802 " Key: " << (*it4).textData() << 1827 " Key: " << (*it4).textData() <<
1803 " CustomString: " << (*it4).customTypeString() << endl; 1828 " CustomString: " << (*it4).customTypeString() << endl;
1804 } 1829 }
1805 kdDebug(5700) << " }" << endl; 1830 kdDebug(5700) << " }" << endl;
1806 1831
1807 kdDebug(5700) << "}" << endl; 1832 kdDebug(5700) << "}" << endl;
1808#endif 1833#endif
1809} 1834}
1810 1835
1811 1836
1812void Addressee::insertAddress( const Address &address ) 1837void Addressee::insertAddress( const Address &address )
1813{ 1838{
1814 detach(); 1839 detach();
1815 mData->empty = false; 1840 mData->empty = false;
1816 1841
1817 Address::List::Iterator it; 1842 Address::List::Iterator it;
1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1843 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1819 if ( (*it).id() == address.id() ) { 1844 if ( (*it).id() == address.id() ) {
1820 *it = address; 1845 *it = address;
1821 return; 1846 return;
1822 } 1847 }
1823 } 1848 }
1824 mData->addresses.append( address ); 1849 mData->addresses.append( address );
1825} 1850}
1826 1851
1827void Addressee::removeAddress( const Address &address ) 1852void Addressee::removeAddress( const Address &address )
1828{ 1853{
1829 detach(); 1854 detach();
1830 1855
1831 Address::List::Iterator it; 1856 Address::List::Iterator it;
1832 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1857 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1833 if ( (*it).id() == address.id() ) { 1858 if ( (*it).id() == address.id() ) {
1834 mData->addresses.remove( it ); 1859 mData->addresses.remove( it );
1835 return; 1860 return;
1836 } 1861 }
1837 } 1862 }
1838} 1863}
1839 1864
1840Address Addressee::address( int type ) const 1865Address Addressee::address( int type ) const
1841{ 1866{
1842 Address address( type ); 1867 Address address( type );
1843 Address::List::ConstIterator it; 1868 Address::List::ConstIterator it;
1844 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1869 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1845 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1870 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1846 if ( (*it).type() & Address::Pref ) 1871 if ( (*it).type() & Address::Pref )
1847 return (*it); 1872 return (*it);
1848 else if ( address.isEmpty() ) 1873 else if ( address.isEmpty() )
1849 address = (*it); 1874 address = (*it);
1850 } 1875 }
1851 } 1876 }
1852 1877
1853 return address; 1878 return address;
1854} 1879}
1855 1880
1856Address::List Addressee::addresses() const 1881Address::List Addressee::addresses() const
1857{ 1882{
1858 return mData->addresses; 1883 return mData->addresses;
1859} 1884}
1860 1885
1861Address::List Addressee::addresses( int type ) const 1886Address::List Addressee::addresses( int type ) const
1862{ 1887{
1863 Address::List list; 1888 Address::List list;
1864 1889
1865 Address::List::ConstIterator it; 1890 Address::List::ConstIterator it;
1866 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1891 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1867 if ( matchBinaryPattern( (*it).type(), type ) ) { 1892 if ( matchBinaryPattern( (*it).type(), type ) ) {
1868 list.append( *it ); 1893 list.append( *it );
1869 } 1894 }
1870 } 1895 }
1871 1896
1872 return list; 1897 return list;
1873} 1898}
1874 1899
1875Address Addressee::findAddress( const QString &id ) const 1900Address Addressee::findAddress( const QString &id ) const
1876{ 1901{
1877 Address::List::ConstIterator it; 1902 Address::List::ConstIterator it;
1878 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1903 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1879 if ( (*it).id() == id ) { 1904 if ( (*it).id() == id ) {
1880 return *it; 1905 return *it;
1881 } 1906 }
1882 } 1907 }
1883 return Address(); 1908 return Address();
1884} 1909}
1885 1910
1886void Addressee::insertCategory( const QString &c ) 1911void Addressee::insertCategory( const QString &c )
1887{ 1912{
1888 detach(); 1913 detach();
1889 mData->empty = false; 1914 mData->empty = false;
1890 1915
1891 if ( mData->categories.contains( c ) ) return; 1916 if ( mData->categories.contains( c ) ) return;
1892 1917
1893 mData->categories.append( c ); 1918 mData->categories.append( c );
1894} 1919}
1895 1920
1896void Addressee::removeCategory( const QString &c ) 1921void Addressee::removeCategory( const QString &c )
1897{ 1922{
1898 detach(); 1923 detach();
1899 1924
1900 QStringList::Iterator it = mData->categories.find( c ); 1925 QStringList::Iterator it = mData->categories.find( c );
1901 if ( it == mData->categories.end() ) return; 1926 if ( it == mData->categories.end() ) return;
1902 1927
1903 mData->categories.remove( it ); 1928 mData->categories.remove( it );
1904} 1929}
1905 1930
1906bool Addressee::hasCategory( const QString &c ) const 1931bool Addressee::hasCategory( const QString &c ) const
1907{ 1932{
1908 return ( mData->categories.contains( c ) ); 1933 return ( mData->categories.contains( c ) );
1909} 1934}
1910 1935
1911void Addressee::setCategories( const QStringList &c ) 1936void Addressee::setCategories( const QStringList &c )
1912{ 1937{
1913 detach(); 1938 detach();
1914 mData->empty = false; 1939 mData->empty = false;
1915 1940
1916 mData->categories = c; 1941 mData->categories = c;
1917} 1942}
1918 1943
1919QStringList Addressee::categories() const 1944QStringList Addressee::categories() const
1920{ 1945{
1921 return mData->categories; 1946 return mData->categories;
1922} 1947}
1923 1948
1924void Addressee::insertCustom( const QString &app, const QString &name, 1949void Addressee::insertCustom( const QString &app, const QString &name,
1925 const QString &value ) 1950 const QString &value )
1926{ 1951{
1927 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1952 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1928 1953
1929 detach(); 1954 detach();
1930 mData->empty = false; 1955 mData->empty = false;
1931 1956
1932 QString qualifiedName = app + "-" + name + ":"; 1957 QString qualifiedName = app + "-" + name + ":";
1933 1958
1934 QStringList::Iterator it; 1959 QStringList::Iterator it;
1935 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1960 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1936 if ( (*it).startsWith( qualifiedName ) ) { 1961 if ( (*it).startsWith( qualifiedName ) ) {
1937 (*it) = qualifiedName + value; 1962 (*it) = qualifiedName + value;
1938 return; 1963 return;
1939 } 1964 }
1940 } 1965 }
1941 mData->custom.append( qualifiedName + value ); 1966 mData->custom.append( qualifiedName + value );
1942} 1967}
1943 1968
1944void Addressee::removeCustom( const QString &app, const QString &name) 1969void Addressee::removeCustom( const QString &app, const QString &name)
1945{ 1970{
1946 detach(); 1971 detach();
1947 1972
1948 QString qualifiedName = app + "-" + name + ":"; 1973 QString qualifiedName = app + "-" + name + ":";
1949 1974
1950 QStringList::Iterator it; 1975 QStringList::Iterator it;
1951 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1976 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1952 if ( (*it).startsWith( qualifiedName ) ) { 1977 if ( (*it).startsWith( qualifiedName ) ) {
1953 mData->custom.remove( it ); 1978 mData->custom.remove( it );
1954 return; 1979 return;
1955 } 1980 }
1956 } 1981 }
1957} 1982}
1958 1983
1959QString Addressee::custom( const QString &app, const QString &name ) const 1984QString Addressee::custom( const QString &app, const QString &name ) const
1960{ 1985{
1961 QString qualifiedName = app + "-" + name + ":"; 1986 QString qualifiedName = app + "-" + name + ":";
1962 QString value; 1987 QString value;
1963 1988
1964 QStringList::ConstIterator it; 1989 QStringList::ConstIterator it;
1965 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1990 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1966 if ( (*it).startsWith( qualifiedName ) ) { 1991 if ( (*it).startsWith( qualifiedName ) ) {
1967 value = (*it).mid( (*it).find( ":" ) + 1 ); 1992 value = (*it).mid( (*it).find( ":" ) + 1 );
1968 break; 1993 break;
1969 } 1994 }
1970 } 1995 }
1971 1996
1972 return value; 1997 return value;
1973} 1998}
1974 1999
1975void Addressee::setCustoms( const QStringList &l ) 2000void Addressee::setCustoms( const QStringList &l )
1976{ 2001{
1977 detach(); 2002 detach();
1978 mData->empty = false; 2003 mData->empty = false;
1979 2004
1980 mData->custom = l; 2005 mData->custom = l;
1981} 2006}
1982 2007
1983QStringList Addressee::customs() const 2008QStringList Addressee::customs() const
1984{ 2009{
1985 return mData->custom; 2010 return mData->custom;
1986} 2011}
1987 2012
1988void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 2013void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1989 QString &email) 2014 QString &email)
1990{ 2015{
1991 int startPos, endPos, len; 2016 int startPos, endPos, len;
1992 QString partA, partB, result; 2017 QString partA, partB, result;
1993 char endCh = '>'; 2018 char endCh = '>';
1994 2019
1995 startPos = rawEmail.find('<'); 2020 startPos = rawEmail.find('<');
1996 if (startPos < 0) 2021 if (startPos < 0)
1997 { 2022 {
1998 startPos = rawEmail.find('('); 2023 startPos = rawEmail.find('(');
1999 endCh = ')'; 2024 endCh = ')';
2000 } 2025 }
2001 if (startPos < 0) 2026 if (startPos < 0)
2002 { 2027 {
2003 // We couldn't find any separators, so we assume the whole string 2028 // We couldn't find any separators, so we assume the whole string
2004 // is the email address 2029 // is the email address
2005 email = rawEmail; 2030 email = rawEmail;
2006 fullName = ""; 2031 fullName = "";
2007 } 2032 }
2008 else 2033 else
2009 { 2034 {
2010 // We have a start position, try to find an end 2035 // We have a start position, try to find an end
2011 endPos = rawEmail.find(endCh, startPos+1); 2036 endPos = rawEmail.find(endCh, startPos+1);
2012 2037
2013 if (endPos < 0) 2038 if (endPos < 0)
2014 { 2039 {
2015 // We couldn't find the end of the email address. We can only 2040 // We couldn't find the end of the email address. We can only
2016 // assume the entire string is the email address. 2041 // assume the entire string is the email address.
2017 email = rawEmail; 2042 email = rawEmail;
2018 fullName = ""; 2043 fullName = "";
2019 } 2044 }
2020 else 2045 else
2021 { 2046 {
2022 // We have a start and end to the email address 2047 // We have a start and end to the email address
2023 2048
2024 // Grab the name part 2049 // Grab the name part
2025 fullName = rawEmail.left(startPos).stripWhiteSpace(); 2050 fullName = rawEmail.left(startPos).stripWhiteSpace();
2026 2051
2027 // grab the email part 2052 // grab the email part
2028 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 2053 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
2029 2054
2030 // Check that we do not have any extra characters on the end of the 2055 // Check that we do not have any extra characters on the end of the
2031 // strings 2056 // strings
2032 len = fullName.length(); 2057 len = fullName.length();
2033 if (fullName[0]=='"' && fullName[len-1]=='"') 2058 if (fullName[0]=='"' && fullName[len-1]=='"')
2034 fullName = fullName.mid(1, len-2); 2059 fullName = fullName.mid(1, len-2);
2035 else if (fullName[0]=='<' && fullName[len-1]=='>') 2060 else if (fullName[0]=='<' && fullName[len-1]=='>')
2036 fullName = fullName.mid(1, len-2); 2061 fullName = fullName.mid(1, len-2);
2037 else if (fullName[0]=='(' && fullName[len-1]==')') 2062 else if (fullName[0]=='(' && fullName[len-1]==')')
2038 fullName = fullName.mid(1, len-2); 2063 fullName = fullName.mid(1, len-2);
2039 } 2064 }
2040 } 2065 }
2041} 2066}
2042 2067
2043void Addressee::setResource( Resource *resource ) 2068void Addressee::setResource( Resource *resource )
2044{ 2069{
2045 detach(); 2070 detach();
2046 mData->resource = resource; 2071 mData->resource = resource;
2047} 2072}
2048 2073
2049Resource *Addressee::resource() const 2074Resource *Addressee::resource() const
2050{ 2075{
2051 return mData->resource; 2076 return mData->resource;
2052} 2077}
2053 2078
2054//US 2079//US
2055QString Addressee::resourceLabel() 2080QString Addressee::resourceLabel()
2056{ 2081{
2057 return i18n("Resource"); 2082 return i18n("Resource");
2058} 2083}
2059QString Addressee::categoryLabel() 2084QString Addressee::categoryLabel()
2060{ 2085{
2061 return i18n("Category"); 2086 return i18n("Category");
2062} 2087}
2063 2088
2064void Addressee::setChanged( bool value ) 2089void Addressee::setChanged( bool value )
2065{ 2090{
2066 detach(); 2091 detach();
2067 mData->changed = value; 2092 mData->changed = value;
2068} 2093}
2069 2094
2070bool Addressee::changed() const 2095bool Addressee::changed() const
2071{ 2096{
2072 return mData->changed; 2097 return mData->changed;
2073} 2098}
2074 2099
2075void Addressee::setTagged( bool value ) 2100void Addressee::setTagged( bool value )
2076{ 2101{
2077 detach(); 2102 detach();
2078 mData->tagged = value; 2103 mData->tagged = value;
2079} 2104}
2080 2105
2081bool Addressee::tagged() const 2106bool Addressee::tagged() const
2082{ 2107{
2083 return mData->tagged; 2108 return mData->tagged;
2084} 2109}
2085 2110
2086QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2111QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2087{ 2112{
2088 if (!a.mData) return s; 2113 if (!a.mData) return s;
2089 2114
2090 s << a.uid(); 2115 s << a.uid();
2091 2116
2092 s << a.mData->name; 2117 s << a.mData->name;
2093 s << a.mData->formattedName; 2118 s << a.mData->formattedName;
2094 s << a.mData->familyName; 2119 s << a.mData->familyName;
2095 s << a.mData->givenName; 2120 s << a.mData->givenName;
2096 s << a.mData->additionalName; 2121 s << a.mData->additionalName;
2097 s << a.mData->prefix; 2122 s << a.mData->prefix;
2098 s << a.mData->suffix; 2123 s << a.mData->suffix;
2099 s << a.mData->nickName; 2124 s << a.mData->nickName;
2100 s << a.mData->birthday; 2125 s << a.mData->birthday;
2101 s << a.mData->mailer; 2126 s << a.mData->mailer;
2102 s << a.mData->timeZone; 2127 s << a.mData->timeZone;
2103 s << a.mData->geo; 2128 s << a.mData->geo;
2104 s << a.mData->title; 2129 s << a.mData->title;
2105 s << a.mData->role; 2130 s << a.mData->role;
2106 s << a.mData->organization; 2131 s << a.mData->organization;
2107 s << a.mData->note; 2132 s << a.mData->note;
2108 s << a.mData->productId; 2133 s << a.mData->productId;
2109 s << a.mData->revision; 2134 s << a.mData->revision;
2110 s << a.mData->sortString; 2135 s << a.mData->sortString;
2111 s << a.mData->url; 2136 s << a.mData->url;
2112 s << a.mData->secrecy; 2137 s << a.mData->secrecy;
2113 s << a.mData->logo; 2138 s << a.mData->logo;
2114 s << a.mData->photo; 2139 s << a.mData->photo;
2115 s << a.mData->sound; 2140 s << a.mData->sound;
2116 s << a.mData->agent; 2141 s << a.mData->agent;
2117 s << a.mData->phoneNumbers; 2142 s << a.mData->phoneNumbers;
2118 s << a.mData->addresses; 2143 s << a.mData->addresses;
2119 s << a.mData->emails; 2144 s << a.mData->emails;
2120 s << a.mData->categories; 2145 s << a.mData->categories;
2121 s << a.mData->custom; 2146 s << a.mData->custom;
2122 s << a.mData->keys; 2147 s << a.mData->keys;
2123 return s; 2148 return s;
2124} 2149}
2125 2150
2126QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2151QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2127{ 2152{
2128 if (!a.mData) return s; 2153 if (!a.mData) return s;
2129 2154
2130 s >> a.mData->uid; 2155 s >> a.mData->uid;
2131 2156
2132 s >> a.mData->name; 2157 s >> a.mData->name;
2133 s >> a.mData->formattedName; 2158 s >> a.mData->formattedName;
2134 s >> a.mData->familyName; 2159 s >> a.mData->familyName;
2135 s >> a.mData->givenName; 2160 s >> a.mData->givenName;
2136 s >> a.mData->additionalName; 2161 s >> a.mData->additionalName;
2137 s >> a.mData->prefix; 2162 s >> a.mData->prefix;
2138 s >> a.mData->suffix; 2163 s >> a.mData->suffix;
2139 s >> a.mData->nickName; 2164 s >> a.mData->nickName;
2140 s >> a.mData->birthday; 2165 s >> a.mData->birthday;
2141 s >> a.mData->mailer; 2166 s >> a.mData->mailer;
2142 s >> a.mData->timeZone; 2167 s >> a.mData->timeZone;
2143 s >> a.mData->geo; 2168 s >> a.mData->geo;
2144 s >> a.mData->title; 2169 s >> a.mData->title;
2145 s >> a.mData->role; 2170 s >> a.mData->role;
2146 s >> a.mData->organization; 2171 s >> a.mData->organization;
2147 s >> a.mData->note; 2172 s >> a.mData->note;
2148 s >> a.mData->productId; 2173 s >> a.mData->productId;
2149 s >> a.mData->revision; 2174 s >> a.mData->revision;
2150 s >> a.mData->sortString; 2175 s >> a.mData->sortString;
2151 s >> a.mData->url; 2176 s >> a.mData->url;
2152 s >> a.mData->secrecy; 2177 s >> a.mData->secrecy;
2153 s >> a.mData->logo; 2178 s >> a.mData->logo;
2154 s >> a.mData->photo; 2179 s >> a.mData->photo;
2155 s >> a.mData->sound; 2180 s >> a.mData->sound;
2156 s >> a.mData->agent; 2181 s >> a.mData->agent;
2157 s >> a.mData->phoneNumbers; 2182 s >> a.mData->phoneNumbers;
2158 s >> a.mData->addresses; 2183 s >> a.mData->addresses;
2159 s >> a.mData->emails; 2184 s >> a.mData->emails;
2160 s >> a.mData->categories; 2185 s >> a.mData->categories;
2161 s >> a.mData->custom; 2186 s >> a.mData->custom;
2162 s >> a.mData->keys; 2187 s >> a.mData->keys;
2163 2188
2164 a.mData->empty = false; 2189 a.mData->empty = false;
2165 2190
2166 return s; 2191 return s;
2167} 2192}
2168bool matchBinaryPattern( int value, int pattern ) 2193bool matchBinaryPattern( int value, int pattern )
2169{ 2194{
2170 /** 2195 /**
2171 We want to match all telephonnumbers/addresses which have the bits in the 2196 We want to match all telephonnumbers/addresses which have the bits in the
2172 pattern set. More are allowed. 2197 pattern set. More are allowed.
2173 if pattern == 0 we have a special handling, then we want only those with 2198 if pattern == 0 we have a special handling, then we want only those with
2174 exactly no bit set. 2199 exactly no bit set.
2175 */ 2200 */
2176 if ( pattern == 0 ) 2201 if ( pattern == 0 )
2177 return ( value == 0 ); 2202 return ( value == 0 );
2178 else 2203 else
2179 return ( pattern == ( pattern & value ) ); 2204 return ( pattern == ( pattern & value ) );
2180} 2205}
2181 2206
2182bool matchBinaryPatternP( int value, int pattern ) 2207bool matchBinaryPatternP( int value, int pattern )
2183{ 2208{
2184 2209
2185 if ( pattern == 0 ) 2210 if ( pattern == 0 )
2186 return ( value == 0 ); 2211 return ( value == 0 );
2187 else 2212 else
2188 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2213 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2189} 2214}
2190bool matchBinaryPatternA( int value, int pattern ) 2215bool matchBinaryPatternA( int value, int pattern )
2191{ 2216{
2192 2217
2193 if ( pattern == 0 ) 2218 if ( pattern == 0 )
2194 return ( value == 0 ); 2219 return ( value == 0 );
2195 else 2220 else
2196 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2221 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2197} 2222}