summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index fda62f1..e241281 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1847 +1,1851 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46 46
47struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 QString externalUID; 69 QString externalUID;
70 QString originalExternalUID; 70 QString originalExternalUID;
71 KURL url; 71 KURL url;
72 Secrecy secrecy; 72 Secrecy secrecy;
73 Picture logo; 73 Picture logo;
74 Picture photo; 74 Picture photo;
75 Sound sound; 75 Sound sound;
76 Agent agent; 76 Agent agent;
77 QString mExternalId; 77 QString mExternalId;
78 PhoneNumber::List phoneNumbers; 78 PhoneNumber::List phoneNumbers;
79 Address::List addresses; 79 Address::List addresses;
80 Key::List keys; 80 Key::List keys;
81 QStringList emails; 81 QStringList emails;
82 QStringList categories; 82 QStringList categories;
83 QStringList custom; 83 QStringList custom;
84 int mTempSyncStat; 84 int mTempSyncStat;
85 Resource *resource; 85 Resource *resource;
86 86
87 bool empty :1; 87 bool empty :1;
88 bool changed :1; 88 bool changed :1;
89}; 89};
90 90
91Addressee::Addressee() 91Addressee::Addressee()
92{ 92{
93 mData = new AddresseeData; 93 mData = new AddresseeData;
94 mData->empty = true; 94 mData->empty = true;
95 mData->changed = false; 95 mData->changed = false;
96 mData->resource = 0; 96 mData->resource = 0;
97 mData->mExternalId = ":"; 97 mData->mExternalId = ":";
98 mData->revision = QDateTime ( QDate( 2004,1,1)); 98 mData->revision = QDateTime ( QDate( 2003,1,1));
99 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 99 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
100} 100}
101 101
102Addressee::~Addressee() 102Addressee::~Addressee()
103{ 103{
104} 104}
105 105
106Addressee::Addressee( const Addressee &a ) 106Addressee::Addressee( const Addressee &a )
107{ 107{
108 mData = a.mData; 108 mData = a.mData;
109} 109}
110 110
111Addressee &Addressee::operator=( const Addressee &a ) 111Addressee &Addressee::operator=( const Addressee &a )
112{ 112{
113 mData = a.mData; 113 mData = a.mData;
114 return (*this); 114 return (*this);
115} 115}
116 116
117Addressee Addressee::copy() 117Addressee Addressee::copy()
118{ 118{
119 Addressee a; 119 Addressee a;
120 *(a.mData) = *mData; 120 *(a.mData) = *mData;
121 return a; 121 return a;
122} 122}
123 123
124void Addressee::detach() 124void Addressee::detach()
125{ 125{
126 if ( mData.count() == 1 ) return; 126 if ( mData.count() == 1 ) return;
127 *this = copy(); 127 *this = copy();
128} 128}
129 129
130bool Addressee::operator==( const Addressee &a ) const 130bool Addressee::operator==( const Addressee &a ) const
131{ 131{
132 if ( uid() != a.uid() ) return false; 132 if ( uid() != a.uid() ) return false;
133 if ( mData->name != a.mData->name ) return false; 133 if ( mData->name != a.mData->name ) return false;
134 if ( mData->formattedName != a.mData->formattedName ) return false; 134 if ( mData->formattedName != a.mData->formattedName ) return false;
135 if ( mData->familyName != a.mData->familyName ) return false; 135 if ( mData->familyName != a.mData->familyName ) return false;
136 if ( mData->givenName != a.mData->givenName ) return false; 136 if ( mData->givenName != a.mData->givenName ) return false;
137 if ( mData->additionalName != a.mData->additionalName ) return false; 137 if ( mData->additionalName != a.mData->additionalName ) return false;
138 if ( mData->prefix != a.mData->prefix ) return false; 138 if ( mData->prefix != a.mData->prefix ) return false;
139 if ( mData->suffix != a.mData->suffix ) return false; 139 if ( mData->suffix != a.mData->suffix ) return false;
140 if ( mData->nickName != a.mData->nickName ) return false; 140 if ( mData->nickName != a.mData->nickName ) return false;
141 if ( mData->birthday != a.mData->birthday ) return false; 141 if ( mData->birthday != a.mData->birthday ) return false;
142 if ( mData->mailer != a.mData->mailer ) return false; 142 if ( mData->mailer != a.mData->mailer ) return false;
143 if ( mData->timeZone != a.mData->timeZone ) return false; 143 if ( mData->timeZone != a.mData->timeZone ) return false;
144 if ( mData->geo != a.mData->geo ) return false; 144 if ( mData->geo != a.mData->geo ) return false;
145 if ( mData->title != a.mData->title ) return false; 145 if ( mData->title != a.mData->title ) return false;
146 if ( mData->role != a.mData->role ) return false; 146 if ( mData->role != a.mData->role ) return false;
147 if ( mData->organization != a.mData->organization ) return false; 147 if ( mData->organization != a.mData->organization ) return false;
148 if ( mData->note != a.mData->note ) return false; 148 if ( mData->note != a.mData->note ) return false;
149 if ( mData->productId != a.mData->productId ) return false; 149 if ( mData->productId != a.mData->productId ) return false;
150 //if ( mData->revision != a.mData->revision ) return false; 150 //if ( mData->revision != a.mData->revision ) return false;
151 if ( mData->sortString != a.mData->sortString ) return false; 151 if ( mData->sortString != a.mData->sortString ) return false;
152 if ( mData->secrecy != a.mData->secrecy ) return false; 152 if ( mData->secrecy != a.mData->secrecy ) return false;
153 if ( mData->logo != a.mData->logo ) return false; 153 if ( mData->logo != a.mData->logo ) return false;
154 if ( mData->photo != a.mData->photo ) return false; 154 if ( mData->photo != a.mData->photo ) return false;
155 if ( mData->sound != a.mData->sound ) return false; 155 if ( mData->sound != a.mData->sound ) return false;
156 if ( mData->agent != a.mData->agent ) return false; 156 if ( mData->agent != a.mData->agent ) return false;
157 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 157 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
158 ( mData->url != a.mData->url ) ) return false; 158 ( mData->url != a.mData->url ) ) return false;
159 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 159 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
160 if ( mData->addresses != a.mData->addresses ) return false; 160 if ( mData->addresses != a.mData->addresses ) return false;
161 if ( mData->keys != a.mData->keys ) return false; 161 if ( mData->keys != a.mData->keys ) return false;
162 if ( mData->emails != a.mData->emails ) return false; 162 if ( mData->emails != a.mData->emails ) return false;
163 if ( mData->categories != a.mData->categories ) return false; 163 if ( mData->categories != a.mData->categories ) return false;
164 if ( mData->custom != a.mData->custom ) return false; 164 if ( mData->custom != a.mData->custom ) return false;
165 165
166 return true; 166 return true;
167} 167}
168 168
169bool Addressee::operator!=( const Addressee &a ) const 169bool Addressee::operator!=( const Addressee &a ) const
170{ 170{
171 return !( a == *this ); 171 return !( a == *this );
172} 172}
173 173
174bool Addressee::isEmpty() const 174bool Addressee::isEmpty() const
175{ 175{
176 return mData->empty; 176 return mData->empty;
177} 177}
178ulong Addressee::getCsum4List( const QStringList & attList) 178ulong Addressee::getCsum4List( const QStringList & attList)
179{ 179{
180 int max = attList.count(); 180 int max = attList.count();
181 ulong cSum = 0; 181 ulong cSum = 0;
182 int j,k,i; 182 int j,k,i;
183 int add; 183 int add;
184 for ( i = 0; i < max ; ++i ) { 184 for ( i = 0; i < max ; ++i ) {
185 QString s = attList[i]; 185 QString s = attList[i];
186 if ( ! s.isEmpty() ){ 186 if ( ! s.isEmpty() ){
187 j = s.length(); 187 j = s.length();
188 for ( k = 0; k < j; ++k ) { 188 for ( k = 0; k < j; ++k ) {
189 int mul = k +1; 189 int mul = k +1;
190 add = s[k].unicode (); 190 add = s[k].unicode ();
191 if ( k < 16 ) 191 if ( k < 16 )
192 mul = mul * mul; 192 mul = mul * mul;
193 int ii = i+1; 193 int ii = i+1;
194 add = add * mul *ii*ii*ii; 194 add = add * mul *ii*ii*ii;
195 cSum += add; 195 cSum += add;
196 } 196 }
197 } 197 }
198 198
199 } 199 }
200 //QString dump = attList.join(","); 200 //QString dump = attList.join(",");
201 //qDebug("csum: %d %s", cSum,dump.latin1()); 201 //qDebug("csum: %d %s", cSum,dump.latin1());
202 202
203 return cSum; 203 return cSum;
204 204
205} 205}
206void Addressee::computeCsum(const QString &dev) 206void Addressee::computeCsum(const QString &dev)
207{ 207{
208 QStringList l; 208 QStringList l;
209 if ( !mData->name.isEmpty() ) l.append(mData->name); 209 if ( !mData->name.isEmpty() ) l.append(mData->name);
210 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 210 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
211 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 211 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
212 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 212 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
213 if ( !mData->additionalName ) l.append( mData->additionalName ); 213 if ( !mData->additionalName ) l.append( mData->additionalName );
214 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 214 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
215 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 215 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
216 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 216 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
217 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 217 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
218 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 218 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
219 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 219 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
220 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 220 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
221 if ( !mData->title .isEmpty() ) l.append( mData->title ); 221 if ( !mData->title .isEmpty() ) l.append( mData->title );
222 if ( !mData->role.isEmpty() ) l.append( mData->role ); 222 if ( !mData->role.isEmpty() ) l.append( mData->role );
223 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 223 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
224 if ( !mData->note.isEmpty() ) l.append( mData->note ); 224 if ( !mData->note.isEmpty() ) l.append( mData->note );
225 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 225 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
226 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 226 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
227 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 227 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
228 // if ( !mData->logo.isEmpty() ) l.append( ); 228 // if ( !mData->logo.isEmpty() ) l.append( );
229 //if ( !mData->photo.isEmpty() ) l.append( ); 229 //if ( !mData->photo.isEmpty() ) l.append( );
230 //if ( !mData->sound.isEmpty() ) l.append( ); 230 //if ( !mData->sound.isEmpty() ) l.append( );
231 //if ( !mData->agent.isEmpty() ) l.append( ); 231 //if ( !mData->agent.isEmpty() ) l.append( );
232 //if ( mData->url.isValid() ) l.append( ); 232 //if ( mData->url.isValid() ) l.append( );
233#if 0 233#if 0
234 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 234 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
235 if ( !mData->addresses.isEmpty() ) l.append( ); 235 if ( !mData->addresses.isEmpty() ) l.append( );
236 //if ( !mData->keys.isEmpty() ) l.append( ); 236 //if ( !mData->keys.isEmpty() ) l.append( );
237 if ( !mData->emails.isEmpty() ) l.append( ); 237 if ( !mData->emails.isEmpty() ) l.append( );
238 if ( !mData->categories .isEmpty() ) l.append( ); 238 if ( !mData->categories .isEmpty() ) l.append( );
239 if ( !mData->custom.isEmpty() ) l.append( ); 239 if ( !mData->custom.isEmpty() ) l.append( );
240#endif 240#endif
241 KABC::PhoneNumber::List phoneNumbers; 241 KABC::PhoneNumber::List phoneNumbers;
242 KABC::PhoneNumber::List::Iterator phoneIter; 242 KABC::PhoneNumber::List::Iterator phoneIter;
243 243
244 QStringList t; 244 QStringList t;
245 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 245 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
246 ++phoneIter ) 246 ++phoneIter )
247 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 247 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
248 t.sort(); 248 t.sort();
249 uint iii; 249 uint iii;
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->emails; 252 t = mData->emails;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->categories; 256 t = mData->categories;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 l.append( t[iii] ); 259 l.append( t[iii] );
260 t = mData->custom; 260 t = mData->custom;
261 t.sort(); 261 t.sort();
262 for ( iii = 0; iii < t.count(); ++iii) 262 for ( iii = 0; iii < t.count(); ++iii)
263 l.append( t[iii] ); 263 l.append( t[iii] );
264 KABC::Address::List::Iterator addressIter; 264 KABC::Address::List::Iterator addressIter;
265 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 265 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
266 ++addressIter ) { 266 ++addressIter ) {
267 t = (*addressIter).asList(); 267 t = (*addressIter).asList();
268 t.sort(); 268 t.sort();
269 for ( iii = 0; iii < t.count(); ++iii) 269 for ( iii = 0; iii < t.count(); ++iii)
270 l.append( t[iii] ); 270 l.append( t[iii] );
271 } 271 }
272 uint cs = getCsum4List(l); 272 uint cs = getCsum4List(l);
273 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 273 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
274 setCsum( dev, QString::number (cs )); 274 setCsum( dev, QString::number (cs ));
275} 275}
276 276
277void Addressee::mergeContact( const Addressee& ad ) 277void Addressee::mergeContact( const Addressee& ad )
278{ 278{
279 279
280 detach(); 280 detach();
281 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 281 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
282 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 282 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
283 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 283 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
284 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 284 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
285 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 285 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
286 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 286 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
287 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 287 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
288 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 288 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
289 if ( !mData->birthday.isValid() ) 289 if ( !mData->birthday.isValid() )
290 if ( ad.mData->birthday.isValid()) 290 if ( ad.mData->birthday.isValid())
291 mData->birthday = ad.mData->birthday; 291 mData->birthday = ad.mData->birthday;
292 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 292 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
293 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 293 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
294 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 294 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
295 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 295 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
296 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 296 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
297 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 297 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
298 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 298 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
299 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 299 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
300 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 300 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
301 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 301 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
302 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 302 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
303 303
304 // pending: 304 // pending:
305 // merging phonenumbers 305 // merging phonenumbers
306 // merging addresses 306 // merging addresses
307 // merging emails; 307 // merging emails;
308 // merging categories; 308 // merging categories;
309 // merging custom; 309 // merging custom;
310 // merging keys 310 // merging keys
311 qDebug("merge contact %s ", ad.uid().latin1());
312 setUid( ad.uid() );
311} 313}
312 314
313void Addressee::removeID(const QString &prof) 315void Addressee::removeID(const QString &prof)
314{ 316{
315 detach(); 317 detach();
316 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 318 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
317 319
318} 320}
319void Addressee::setID( const QString & prof , const QString & id ) 321void Addressee::setID( const QString & prof , const QString & id )
320{ 322{
321 detach(); 323 detach();
322 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 324 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
323 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 325 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
324} 326}
325void Addressee::setTempSyncStat( int id ) 327void Addressee::setTempSyncStat( int id )
326{ 328{
327 if ( mData->mTempSyncStat == id ) return; 329 if ( mData->mTempSyncStat == id ) return;
328 detach(); 330 detach();
329 mData->mTempSyncStat = id; 331 mData->mTempSyncStat = id;
330} 332}
331int Addressee::tempSyncStat() const 333int Addressee::tempSyncStat() const
332{ 334{
333 return mData->mTempSyncStat; 335 return mData->mTempSyncStat;
334} 336}
335 337
336QString Addressee::getID( const QString & prof) 338QString Addressee::getID( const QString & prof)
337{ 339{
338 return KIdManager::getId ( mData->mExternalId, prof ); 340 return KIdManager::getId ( mData->mExternalId, prof );
339} 341}
340 342
341void Addressee::setCsum( const QString & prof , const QString & id ) 343void Addressee::setCsum( const QString & prof , const QString & id )
342{ 344{
343 detach(); 345 detach();
344 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 346 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
345 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 347 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
346 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 348 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
347} 349}
348 350
349QString Addressee::getCsum( const QString & prof) 351QString Addressee::getCsum( const QString & prof)
350{ 352{
351 return KIdManager::getCsum ( mData->mExternalId, prof ); 353 return KIdManager::getCsum ( mData->mExternalId, prof );
352} 354}
353 355
354void Addressee::setIDStr( const QString & s ) 356void Addressee::setIDStr( const QString & s )
355{ 357{
356 detach(); 358 detach();
357 mData->mExternalId = s; 359 mData->mExternalId = s;
358} 360}
359 361
360QString Addressee::IDStr() const 362QString Addressee::IDStr() const
361{ 363{
362 return mData->mExternalId; 364 return mData->mExternalId;
363} 365}
364 366
365void Addressee::setExternalUID( const QString &id ) 367void Addressee::setExternalUID( const QString &id )
366{ 368{
367 if ( id == mData->externalUID ) return; 369 if ( id == mData->externalUID ) return;
368 detach(); 370 detach();
369 mData->empty = false; 371 mData->empty = false;
370 mData->externalUID = id; 372 mData->externalUID = id;
371} 373}
372 374
373QString Addressee::externalUID() const 375QString Addressee::externalUID() const
374{ 376{
375 return mData->externalUID; 377 return mData->externalUID;
376} 378}
377void Addressee::setOriginalExternalUID( const QString &id ) 379void Addressee::setOriginalExternalUID( const QString &id )
378{ 380{
379 if ( id == mData->originalExternalUID ) return; 381 if ( id == mData->originalExternalUID ) return;
380 detach(); 382 detach();
381 mData->empty = false; 383 mData->empty = false;
384 qDebug("*******Set orig uid %s ", id.latin1());
382 mData->originalExternalUID = id; 385 mData->originalExternalUID = id;
383} 386}
384 387
385QString Addressee::originalExternalUID() const 388QString Addressee::originalExternalUID() const
386{ 389{
387 return mData->originalExternalUID; 390 return mData->originalExternalUID;
388} 391}
389 392
390void Addressee::setUid( const QString &id ) 393void Addressee::setUid( const QString &id )
391{ 394{
392 if ( id == mData->uid ) return; 395 if ( id == mData->uid ) return;
393 detach(); 396 detach();
397 qDebug("****setuid %s ", id.latin1());
394 mData->empty = false; 398 mData->empty = false;
395 mData->uid = id; 399 mData->uid = id;
396} 400}
397 401
398QString Addressee::uid() const 402QString Addressee::uid() const
399{ 403{
400 if ( mData->uid.isEmpty() ) 404 if ( mData->uid.isEmpty() )
401 mData->uid = KApplication::randomString( 10 ); 405 mData->uid = KApplication::randomString( 10 );
402 406
403 return mData->uid; 407 return mData->uid;
404} 408}
405 409
406QString Addressee::uidLabel() 410QString Addressee::uidLabel()
407{ 411{
408 return i18n("Unique Identifier"); 412 return i18n("Unique Identifier");
409} 413}
410 414
411void Addressee::setName( const QString &name ) 415void Addressee::setName( const QString &name )
412{ 416{
413 if ( name == mData->name ) return; 417 if ( name == mData->name ) return;
414 detach(); 418 detach();
415 mData->empty = false; 419 mData->empty = false;
416 mData->name = name; 420 mData->name = name;
417} 421}
418 422
419QString Addressee::name() const 423QString Addressee::name() const
420{ 424{
421 return mData->name; 425 return mData->name;
422} 426}
423 427
424QString Addressee::nameLabel() 428QString Addressee::nameLabel()
425{ 429{
426 return i18n("Name"); 430 return i18n("Name");
427} 431}
428 432
429 433
430void Addressee::setFormattedName( const QString &formattedName ) 434void Addressee::setFormattedName( const QString &formattedName )
431{ 435{
432 if ( formattedName == mData->formattedName ) return; 436 if ( formattedName == mData->formattedName ) return;
433 detach(); 437 detach();
434 mData->empty = false; 438 mData->empty = false;
435 mData->formattedName = formattedName; 439 mData->formattedName = formattedName;
436} 440}
437 441
438QString Addressee::formattedName() const 442QString Addressee::formattedName() const
439{ 443{
440 return mData->formattedName; 444 return mData->formattedName;
441} 445}
442 446
443QString Addressee::formattedNameLabel() 447QString Addressee::formattedNameLabel()
444{ 448{
445 return i18n("Formatted Name"); 449 return i18n("Formatted Name");
446} 450}
447 451
448 452
449void Addressee::setFamilyName( const QString &familyName ) 453void Addressee::setFamilyName( const QString &familyName )
450{ 454{
451 if ( familyName == mData->familyName ) return; 455 if ( familyName == mData->familyName ) return;
452 detach(); 456 detach();
453 mData->empty = false; 457 mData->empty = false;
454 mData->familyName = familyName; 458 mData->familyName = familyName;
455} 459}
456 460
457QString Addressee::familyName() const 461QString Addressee::familyName() const
458{ 462{
459 return mData->familyName; 463 return mData->familyName;
460} 464}
461 465
462QString Addressee::familyNameLabel() 466QString Addressee::familyNameLabel()
463{ 467{
464 return i18n("Family Name"); 468 return i18n("Family Name");
465} 469}
466 470
467 471
468void Addressee::setGivenName( const QString &givenName ) 472void Addressee::setGivenName( const QString &givenName )
469{ 473{
470 if ( givenName == mData->givenName ) return; 474 if ( givenName == mData->givenName ) return;
471 detach(); 475 detach();
472 mData->empty = false; 476 mData->empty = false;
473 mData->givenName = givenName; 477 mData->givenName = givenName;
474} 478}
475 479
476QString Addressee::givenName() const 480QString Addressee::givenName() const
477{ 481{
478 return mData->givenName; 482 return mData->givenName;
479} 483}
480 484
481QString Addressee::givenNameLabel() 485QString Addressee::givenNameLabel()
482{ 486{
483 return i18n("Given Name"); 487 return i18n("Given Name");
484} 488}
485 489
486 490
487void Addressee::setAdditionalName( const QString &additionalName ) 491void Addressee::setAdditionalName( const QString &additionalName )
488{ 492{
489 if ( additionalName == mData->additionalName ) return; 493 if ( additionalName == mData->additionalName ) return;
490 detach(); 494 detach();
491 mData->empty = false; 495 mData->empty = false;
492 mData->additionalName = additionalName; 496 mData->additionalName = additionalName;
493} 497}
494 498
495QString Addressee::additionalName() const 499QString Addressee::additionalName() const
496{ 500{
497 return mData->additionalName; 501 return mData->additionalName;
498} 502}
499 503
500QString Addressee::additionalNameLabel() 504QString Addressee::additionalNameLabel()
501{ 505{
502 return i18n("Additional Names"); 506 return i18n("Additional Names");
503} 507}
504 508
505 509
506void Addressee::setPrefix( const QString &prefix ) 510void Addressee::setPrefix( const QString &prefix )
507{ 511{
508 if ( prefix == mData->prefix ) return; 512 if ( prefix == mData->prefix ) return;
509 detach(); 513 detach();
510 mData->empty = false; 514 mData->empty = false;
511 mData->prefix = prefix; 515 mData->prefix = prefix;
512} 516}
513 517
514QString Addressee::prefix() const 518QString Addressee::prefix() const
515{ 519{
516 return mData->prefix; 520 return mData->prefix;
517} 521}
518 522
519QString Addressee::prefixLabel() 523QString Addressee::prefixLabel()
520{ 524{
521 return i18n("Honorific Prefixes"); 525 return i18n("Honorific Prefixes");
522} 526}
523 527
524 528
525void Addressee::setSuffix( const QString &suffix ) 529void Addressee::setSuffix( const QString &suffix )
526{ 530{
527 if ( suffix == mData->suffix ) return; 531 if ( suffix == mData->suffix ) return;
528 detach(); 532 detach();
529 mData->empty = false; 533 mData->empty = false;
530 mData->suffix = suffix; 534 mData->suffix = suffix;
531} 535}
532 536
533QString Addressee::suffix() const 537QString Addressee::suffix() const
534{ 538{
535 return mData->suffix; 539 return mData->suffix;
536} 540}
537 541
538QString Addressee::suffixLabel() 542QString Addressee::suffixLabel()
539{ 543{
540 return i18n("Honorific Suffixes"); 544 return i18n("Honorific Suffixes");
541} 545}
542 546
543 547
544void Addressee::setNickName( const QString &nickName ) 548void Addressee::setNickName( const QString &nickName )
545{ 549{
546 if ( nickName == mData->nickName ) return; 550 if ( nickName == mData->nickName ) return;
547 detach(); 551 detach();
548 mData->empty = false; 552 mData->empty = false;
549 mData->nickName = nickName; 553 mData->nickName = nickName;
550} 554}
551 555
552QString Addressee::nickName() const 556QString Addressee::nickName() const
553{ 557{
554 return mData->nickName; 558 return mData->nickName;
555} 559}
556 560
557QString Addressee::nickNameLabel() 561QString Addressee::nickNameLabel()
558{ 562{
559 return i18n("Nick Name"); 563 return i18n("Nick Name");
560} 564}
561 565
562 566
563void Addressee::setBirthday( const QDateTime &birthday ) 567void Addressee::setBirthday( const QDateTime &birthday )
564{ 568{
565 if ( birthday == mData->birthday ) return; 569 if ( birthday == mData->birthday ) return;
566 detach(); 570 detach();
567 mData->empty = false; 571 mData->empty = false;
568 mData->birthday = birthday; 572 mData->birthday = birthday;
569} 573}
570 574
571QDateTime Addressee::birthday() const 575QDateTime Addressee::birthday() const
572{ 576{
573 return mData->birthday; 577 return mData->birthday;
574} 578}
575 579
576QString Addressee::birthdayLabel() 580QString Addressee::birthdayLabel()
577{ 581{
578 return i18n("Birthday"); 582 return i18n("Birthday");
579} 583}
580 584
581 585
582QString Addressee::homeAddressStreetLabel() 586QString Addressee::homeAddressStreetLabel()
583{ 587{
584 return i18n("Home Address Street"); 588 return i18n("Home Address Street");
585} 589}
586 590
587 591
588QString Addressee::homeAddressLocalityLabel() 592QString Addressee::homeAddressLocalityLabel()
589{ 593{
590 return i18n("Home Address Locality"); 594 return i18n("Home Address Locality");
591} 595}
592 596
593 597
594QString Addressee::homeAddressRegionLabel() 598QString Addressee::homeAddressRegionLabel()
595{ 599{
596 return i18n("Home Address Region"); 600 return i18n("Home Address Region");
597} 601}
598 602
599 603
600QString Addressee::homeAddressPostalCodeLabel() 604QString Addressee::homeAddressPostalCodeLabel()
601{ 605{
602 return i18n("Home Address Postal Code"); 606 return i18n("Home Address Postal Code");
603} 607}
604 608
605 609
606QString Addressee::homeAddressCountryLabel() 610QString Addressee::homeAddressCountryLabel()
607{ 611{
608 return i18n("Home Address Country"); 612 return i18n("Home Address Country");
609} 613}
610 614
611 615
612QString Addressee::homeAddressLabelLabel() 616QString Addressee::homeAddressLabelLabel()
613{ 617{
614 return i18n("Home Address Label"); 618 return i18n("Home Address Label");
615} 619}
616 620
617 621
618QString Addressee::businessAddressStreetLabel() 622QString Addressee::businessAddressStreetLabel()
619{ 623{
620 return i18n("Business Address Street"); 624 return i18n("Business Address Street");
621} 625}
622 626
623 627
624QString Addressee::businessAddressLocalityLabel() 628QString Addressee::businessAddressLocalityLabel()
625{ 629{
626 return i18n("Business Address Locality"); 630 return i18n("Business Address Locality");
627} 631}
628 632
629 633
630QString Addressee::businessAddressRegionLabel() 634QString Addressee::businessAddressRegionLabel()
631{ 635{
632 return i18n("Business Address Region"); 636 return i18n("Business Address Region");
633} 637}
634 638
635 639
636QString Addressee::businessAddressPostalCodeLabel() 640QString Addressee::businessAddressPostalCodeLabel()
637{ 641{
638 return i18n("Business Address Postal Code"); 642 return i18n("Business Address Postal Code");
639} 643}
640 644
641 645
642QString Addressee::businessAddressCountryLabel() 646QString Addressee::businessAddressCountryLabel()
643{ 647{
644 return i18n("Business Address Country"); 648 return i18n("Business Address Country");
645} 649}
646 650
647 651
648QString Addressee::businessAddressLabelLabel() 652QString Addressee::businessAddressLabelLabel()
649{ 653{
650 return i18n("Business Address Label"); 654 return i18n("Business Address Label");
651} 655}
652 656
653 657
654QString Addressee::homePhoneLabel() 658QString Addressee::homePhoneLabel()
655{ 659{
656 return i18n("Home Phone"); 660 return i18n("Home Phone");
657} 661}
658 662
659 663
660QString Addressee::businessPhoneLabel() 664QString Addressee::businessPhoneLabel()
661{ 665{
662 return i18n("Business Phone"); 666 return i18n("Business Phone");
663} 667}
664 668
665 669
666QString Addressee::mobilePhoneLabel() 670QString Addressee::mobilePhoneLabel()
667{ 671{
668 return i18n("Mobile Phone"); 672 return i18n("Mobile Phone");
669} 673}
670 674
671 675
672QString Addressee::homeFaxLabel() 676QString Addressee::homeFaxLabel()
673{ 677{
674 return i18n("Home Fax"); 678 return i18n("Home Fax");
675} 679}
676 680
677 681
678QString Addressee::businessFaxLabel() 682QString Addressee::businessFaxLabel()
679{ 683{
680 return i18n("Business Fax"); 684 return i18n("Business Fax");
681} 685}
682 686
683 687
684QString Addressee::carPhoneLabel() 688QString Addressee::carPhoneLabel()
685{ 689{
686 return i18n("Car Phone"); 690 return i18n("Car Phone");
687} 691}
688 692
689 693
690QString Addressee::isdnLabel() 694QString Addressee::isdnLabel()
691{ 695{
692 return i18n("ISDN"); 696 return i18n("ISDN");
693} 697}
694 698
695 699
696QString Addressee::pagerLabel() 700QString Addressee::pagerLabel()
697{ 701{
698 return i18n("Pager"); 702 return i18n("Pager");
699} 703}
700 704
701QString Addressee::sipLabel() 705QString Addressee::sipLabel()
702{ 706{
703 return i18n("SIP"); 707 return i18n("SIP");
704} 708}
705 709
706QString Addressee::emailLabel() 710QString Addressee::emailLabel()
707{ 711{
708 return i18n("Email Address"); 712 return i18n("Email Address");
709} 713}
710 714
711 715
712void Addressee::setMailer( const QString &mailer ) 716void Addressee::setMailer( const QString &mailer )
713{ 717{
714 if ( mailer == mData->mailer ) return; 718 if ( mailer == mData->mailer ) return;
715 detach(); 719 detach();
716 mData->empty = false; 720 mData->empty = false;
717 mData->mailer = mailer; 721 mData->mailer = mailer;
718} 722}
719 723
720QString Addressee::mailer() const 724QString Addressee::mailer() const
721{ 725{
722 return mData->mailer; 726 return mData->mailer;
723} 727}
724 728
725QString Addressee::mailerLabel() 729QString Addressee::mailerLabel()
726{ 730{
727 return i18n("Mail Client"); 731 return i18n("Mail Client");
728} 732}
729 733
730 734
731void Addressee::setTimeZone( const TimeZone &timeZone ) 735void Addressee::setTimeZone( const TimeZone &timeZone )
732{ 736{
733 if ( timeZone == mData->timeZone ) return; 737 if ( timeZone == mData->timeZone ) return;
734 detach(); 738 detach();
735 mData->empty = false; 739 mData->empty = false;
736 mData->timeZone = timeZone; 740 mData->timeZone = timeZone;
737} 741}
738 742
739TimeZone Addressee::timeZone() const 743TimeZone Addressee::timeZone() const
740{ 744{
741 return mData->timeZone; 745 return mData->timeZone;
742} 746}
743 747
744QString Addressee::timeZoneLabel() 748QString Addressee::timeZoneLabel()
745{ 749{
746 return i18n("Time Zone"); 750 return i18n("Time Zone");
747} 751}
748 752
749 753
750void Addressee::setGeo( const Geo &geo ) 754void Addressee::setGeo( const Geo &geo )
751{ 755{
752 if ( geo == mData->geo ) return; 756 if ( geo == mData->geo ) return;
753 detach(); 757 detach();
754 mData->empty = false; 758 mData->empty = false;
755 mData->geo = geo; 759 mData->geo = geo;
756} 760}
757 761
758Geo Addressee::geo() const 762Geo Addressee::geo() const
759{ 763{
760 return mData->geo; 764 return mData->geo;
761} 765}
762 766
763QString Addressee::geoLabel() 767QString Addressee::geoLabel()
764{ 768{
765 return i18n("Geographic Position"); 769 return i18n("Geographic Position");
766} 770}
767 771
768 772
769void Addressee::setTitle( const QString &title ) 773void Addressee::setTitle( const QString &title )
770{ 774{
771 if ( title == mData->title ) return; 775 if ( title == mData->title ) return;
772 detach(); 776 detach();
773 mData->empty = false; 777 mData->empty = false;
774 mData->title = title; 778 mData->title = title;
775} 779}
776 780
777QString Addressee::title() const 781QString Addressee::title() const
778{ 782{
779 return mData->title; 783 return mData->title;
780} 784}
781 785
782QString Addressee::titleLabel() 786QString Addressee::titleLabel()
783{ 787{
784 return i18n("Title"); 788 return i18n("Title");
785} 789}
786 790
787 791
788void Addressee::setRole( const QString &role ) 792void Addressee::setRole( const QString &role )
789{ 793{
790 if ( role == mData->role ) return; 794 if ( role == mData->role ) return;
791 detach(); 795 detach();
792 mData->empty = false; 796 mData->empty = false;
793 mData->role = role; 797 mData->role = role;
794} 798}
795 799
796QString Addressee::role() const 800QString Addressee::role() const
797{ 801{
798 return mData->role; 802 return mData->role;
799} 803}
800 804
801QString Addressee::roleLabel() 805QString Addressee::roleLabel()
802{ 806{
803 return i18n("Role"); 807 return i18n("Role");
804} 808}
805 809
806 810
807void Addressee::setOrganization( const QString &organization ) 811void Addressee::setOrganization( const QString &organization )
808{ 812{
809 if ( organization == mData->organization ) return; 813 if ( organization == mData->organization ) return;
810 detach(); 814 detach();
811 mData->empty = false; 815 mData->empty = false;
812 mData->organization = organization; 816 mData->organization = organization;
813} 817}
814 818
815QString Addressee::organization() const 819QString Addressee::organization() const
816{ 820{
817 return mData->organization; 821 return mData->organization;
818} 822}
819 823
820QString Addressee::organizationLabel() 824QString Addressee::organizationLabel()
821{ 825{
822 return i18n("Organization"); 826 return i18n("Organization");
823} 827}
824 828
825 829
826void Addressee::setNote( const QString &note ) 830void Addressee::setNote( const QString &note )
827{ 831{
828 if ( note == mData->note ) return; 832 if ( note == mData->note ) return;
829 detach(); 833 detach();
830 mData->empty = false; 834 mData->empty = false;
831 mData->note = note; 835 mData->note = note;
832} 836}
833 837
834QString Addressee::note() const 838QString Addressee::note() const
835{ 839{
836 return mData->note; 840 return mData->note;
837} 841}
838 842
839QString Addressee::noteLabel() 843QString Addressee::noteLabel()
840{ 844{
841 return i18n("Note"); 845 return i18n("Note");
842} 846}
843 847
844 848
845void Addressee::setProductId( const QString &productId ) 849void Addressee::setProductId( const QString &productId )
846{ 850{
847 if ( productId == mData->productId ) return; 851 if ( productId == mData->productId ) return;
848 detach(); 852 detach();
849 mData->empty = false; 853 mData->empty = false;
850 mData->productId = productId; 854 mData->productId = productId;
851} 855}
852 856
853QString Addressee::productId() const 857QString Addressee::productId() const
854{ 858{
855 return mData->productId; 859 return mData->productId;
856} 860}
857 861
858QString Addressee::productIdLabel() 862QString Addressee::productIdLabel()
859{ 863{
860 return i18n("Product Identifier"); 864 return i18n("Product Identifier");
861} 865}
862 866
863 867
864void Addressee::setRevision( const QDateTime &revision ) 868void Addressee::setRevision( const QDateTime &revision )
865{ 869{
866 if ( revision == mData->revision ) return; 870 if ( revision == mData->revision ) return;
867 detach(); 871 detach();
868 mData->empty = false; 872 mData->empty = false;
869 mData->revision = revision; 873 mData->revision = revision;
870} 874}
871 875
872QDateTime Addressee::revision() const 876QDateTime Addressee::revision() const
873{ 877{
874 return mData->revision; 878 return mData->revision;
875} 879}
876 880
877QString Addressee::revisionLabel() 881QString Addressee::revisionLabel()
878{ 882{
879 return i18n("Revision Date"); 883 return i18n("Revision Date");
880} 884}
881 885
882 886
883void Addressee::setSortString( const QString &sortString ) 887void Addressee::setSortString( const QString &sortString )
884{ 888{
885 if ( sortString == mData->sortString ) return; 889 if ( sortString == mData->sortString ) return;
886 detach(); 890 detach();
887 mData->empty = false; 891 mData->empty = false;
888 mData->sortString = sortString; 892 mData->sortString = sortString;
889} 893}
890 894
891QString Addressee::sortString() const 895QString Addressee::sortString() const
892{ 896{
893 return mData->sortString; 897 return mData->sortString;
894} 898}
895 899
896QString Addressee::sortStringLabel() 900QString Addressee::sortStringLabel()
897{ 901{
898 return i18n("Sort String"); 902 return i18n("Sort String");
899} 903}
900 904
901 905
902void Addressee::setUrl( const KURL &url ) 906void Addressee::setUrl( const KURL &url )
903{ 907{
904 if ( url == mData->url ) return; 908 if ( url == mData->url ) return;
905 detach(); 909 detach();
906 mData->empty = false; 910 mData->empty = false;
907 mData->url = url; 911 mData->url = url;
908} 912}
909 913
910KURL Addressee::url() const 914KURL Addressee::url() const
911{ 915{
912 return mData->url; 916 return mData->url;
913} 917}
914 918
915QString Addressee::urlLabel() 919QString Addressee::urlLabel()
916{ 920{
917 return i18n("URL"); 921 return i18n("URL");
918} 922}
919 923
920 924
921void Addressee::setSecrecy( const Secrecy &secrecy ) 925void Addressee::setSecrecy( const Secrecy &secrecy )
922{ 926{
923 if ( secrecy == mData->secrecy ) return; 927 if ( secrecy == mData->secrecy ) return;
924 detach(); 928 detach();
925 mData->empty = false; 929 mData->empty = false;
926 mData->secrecy = secrecy; 930 mData->secrecy = secrecy;
927} 931}
928 932
929Secrecy Addressee::secrecy() const 933Secrecy Addressee::secrecy() const
930{ 934{
931 return mData->secrecy; 935 return mData->secrecy;
932} 936}
933 937
934QString Addressee::secrecyLabel() 938QString Addressee::secrecyLabel()
935{ 939{
936 return i18n("Security Class"); 940 return i18n("Security Class");
937} 941}
938 942
939 943
940void Addressee::setLogo( const Picture &logo ) 944void Addressee::setLogo( const Picture &logo )
941{ 945{
942 if ( logo == mData->logo ) return; 946 if ( logo == mData->logo ) return;
943 detach(); 947 detach();
944 mData->empty = false; 948 mData->empty = false;
945 mData->logo = logo; 949 mData->logo = logo;
946} 950}
947 951
948Picture Addressee::logo() const 952Picture Addressee::logo() const
949{ 953{
950 return mData->logo; 954 return mData->logo;
951} 955}
952 956
953QString Addressee::logoLabel() 957QString Addressee::logoLabel()
954{ 958{
955 return i18n("Logo"); 959 return i18n("Logo");
956} 960}
957 961
958 962
959void Addressee::setPhoto( const Picture &photo ) 963void Addressee::setPhoto( const Picture &photo )
960{ 964{
961 if ( photo == mData->photo ) return; 965 if ( photo == mData->photo ) return;
962 detach(); 966 detach();
963 mData->empty = false; 967 mData->empty = false;
964 mData->photo = photo; 968 mData->photo = photo;
965} 969}
966 970
967Picture Addressee::photo() const 971Picture Addressee::photo() const
968{ 972{
969 return mData->photo; 973 return mData->photo;
970} 974}
971 975
972QString Addressee::photoLabel() 976QString Addressee::photoLabel()
973{ 977{
974 return i18n("Photo"); 978 return i18n("Photo");
975} 979}
976 980
977 981
978void Addressee::setSound( const Sound &sound ) 982void Addressee::setSound( const Sound &sound )
979{ 983{
980 if ( sound == mData->sound ) return; 984 if ( sound == mData->sound ) return;
981 detach(); 985 detach();
982 mData->empty = false; 986 mData->empty = false;
983 mData->sound = sound; 987 mData->sound = sound;
984} 988}
985 989
986Sound Addressee::sound() const 990Sound Addressee::sound() const
987{ 991{
988 return mData->sound; 992 return mData->sound;
989} 993}
990 994
991QString Addressee::soundLabel() 995QString Addressee::soundLabel()
992{ 996{
993 return i18n("Sound"); 997 return i18n("Sound");
994} 998}
995 999
996 1000
997void Addressee::setAgent( const Agent &agent ) 1001void Addressee::setAgent( const Agent &agent )
998{ 1002{
999 if ( agent == mData->agent ) return; 1003 if ( agent == mData->agent ) return;
1000 detach(); 1004 detach();
1001 mData->empty = false; 1005 mData->empty = false;
1002 mData->agent = agent; 1006 mData->agent = agent;
1003} 1007}
1004 1008
1005Agent Addressee::agent() const 1009Agent Addressee::agent() const
1006{ 1010{
1007 return mData->agent; 1011 return mData->agent;
1008} 1012}
1009 1013
1010QString Addressee::agentLabel() 1014QString Addressee::agentLabel()
1011{ 1015{
1012 return i18n("Agent"); 1016 return i18n("Agent");
1013} 1017}
1014 1018
1015 1019
1016 1020
1017void Addressee::setNameFromString( const QString &str ) 1021void Addressee::setNameFromString( const QString &str )
1018{ 1022{
1019 setFormattedName( str ); 1023 setFormattedName( str );
1020 setName( str ); 1024 setName( str );
1021 1025
1022 static bool first = true; 1026 static bool first = true;
1023 static QStringList titles; 1027 static QStringList titles;
1024 static QStringList suffixes; 1028 static QStringList suffixes;
1025 static QStringList prefixes; 1029 static QStringList prefixes;
1026 1030
1027 if ( first ) { 1031 if ( first ) {
1028 first = false; 1032 first = false;
1029 titles += i18n( "Dr." ); 1033 titles += i18n( "Dr." );
1030 titles += i18n( "Miss" ); 1034 titles += i18n( "Miss" );
1031 titles += i18n( "Mr." ); 1035 titles += i18n( "Mr." );
1032 titles += i18n( "Mrs." ); 1036 titles += i18n( "Mrs." );
1033 titles += i18n( "Ms." ); 1037 titles += i18n( "Ms." );
1034 titles += i18n( "Prof." ); 1038 titles += i18n( "Prof." );
1035 1039
1036 suffixes += i18n( "I" ); 1040 suffixes += i18n( "I" );
1037 suffixes += i18n( "II" ); 1041 suffixes += i18n( "II" );
1038 suffixes += i18n( "III" ); 1042 suffixes += i18n( "III" );
1039 suffixes += i18n( "Jr." ); 1043 suffixes += i18n( "Jr." );
1040 suffixes += i18n( "Sr." ); 1044 suffixes += i18n( "Sr." );
1041 1045
1042 prefixes += "van"; 1046 prefixes += "van";
1043 prefixes += "von"; 1047 prefixes += "von";
1044 prefixes += "de"; 1048 prefixes += "de";
1045 1049
1046 KConfig config( locateLocal( "config", "kabcrc") ); 1050 KConfig config( locateLocal( "config", "kabcrc") );
1047 config.setGroup( "General" ); 1051 config.setGroup( "General" );
1048 titles += config.readListEntry( "Prefixes" ); 1052 titles += config.readListEntry( "Prefixes" );
1049 titles.remove( "" ); 1053 titles.remove( "" );
1050 prefixes += config.readListEntry( "Inclusions" ); 1054 prefixes += config.readListEntry( "Inclusions" );
1051 prefixes.remove( "" ); 1055 prefixes.remove( "" );
1052 suffixes += config.readListEntry( "Suffixes" ); 1056 suffixes += config.readListEntry( "Suffixes" );
1053 suffixes.remove( "" ); 1057 suffixes.remove( "" );
1054 } 1058 }
1055 1059
1056 // clear all name parts 1060 // clear all name parts
1057 setPrefix( "" ); 1061 setPrefix( "" );
1058 setGivenName( "" ); 1062 setGivenName( "" );
1059 setAdditionalName( "" ); 1063 setAdditionalName( "" );
1060 setFamilyName( "" ); 1064 setFamilyName( "" );
1061 setSuffix( "" ); 1065 setSuffix( "" );
1062 1066
1063 if ( str.isEmpty() ) 1067 if ( str.isEmpty() )
1064 return; 1068 return;
1065 1069
1066 int i = str.find(','); 1070 int i = str.find(',');
1067 if( i < 0 ) { 1071 if( i < 0 ) {
1068 QStringList parts = QStringList::split( " ", str ); 1072 QStringList parts = QStringList::split( " ", str );
1069 int leftOffset = 0; 1073 int leftOffset = 0;
1070 int rightOffset = parts.count() - 1; 1074 int rightOffset = parts.count() - 1;
1071 1075
1072 QString suffix; 1076 QString suffix;
1073 while ( rightOffset >= 0 ) { 1077 while ( rightOffset >= 0 ) {
1074 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1078 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1075 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1079 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1076 rightOffset--; 1080 rightOffset--;
1077 } else 1081 } else
1078 break; 1082 break;
1079 } 1083 }
1080 setSuffix( suffix ); 1084 setSuffix( suffix );
1081 1085
1082 if ( rightOffset < 0 ) 1086 if ( rightOffset < 0 )
1083 return; 1087 return;
1084 1088
1085 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1089 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1086 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1090 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1087 rightOffset--; 1091 rightOffset--;
1088 } else 1092 } else
1089 setFamilyName( parts[ rightOffset ] ); 1093 setFamilyName( parts[ rightOffset ] );
1090 1094
1091 QString prefix; 1095 QString prefix;
1092 while ( leftOffset < rightOffset ) { 1096 while ( leftOffset < rightOffset ) {
1093 if ( titles.contains( parts[ leftOffset ] ) ) { 1097 if ( titles.contains( parts[ leftOffset ] ) ) {
1094 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1098 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1095 leftOffset++; 1099 leftOffset++;
1096 } else 1100 } else
1097 break; 1101 break;
1098 } 1102 }
1099 setPrefix( prefix ); 1103 setPrefix( prefix );
1100 1104
1101 if ( leftOffset < rightOffset ) { 1105 if ( leftOffset < rightOffset ) {
1102 setGivenName( parts[ leftOffset ] ); 1106 setGivenName( parts[ leftOffset ] );
1103 leftOffset++; 1107 leftOffset++;
1104 } 1108 }
1105 1109
1106 QString additionalName; 1110 QString additionalName;
1107 while ( leftOffset < rightOffset ) { 1111 while ( leftOffset < rightOffset ) {
1108 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1112 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1109 leftOffset++; 1113 leftOffset++;
1110 } 1114 }
1111 setAdditionalName( additionalName ); 1115 setAdditionalName( additionalName );
1112 } else { 1116 } else {
1113 QString part1 = str.left( i ); 1117 QString part1 = str.left( i );
1114 QString part2 = str.mid( i + 1 ); 1118 QString part2 = str.mid( i + 1 );
1115 1119
1116 QStringList parts = QStringList::split( " ", part1 ); 1120 QStringList parts = QStringList::split( " ", part1 );
1117 int leftOffset = 0; 1121 int leftOffset = 0;
1118 int rightOffset = parts.count() - 1; 1122 int rightOffset = parts.count() - 1;
1119 1123
1120 QString suffix; 1124 QString suffix;
1121 while ( rightOffset >= 0 ) { 1125 while ( rightOffset >= 0 ) {
1122 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1126 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1123 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1127 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1124 rightOffset--; 1128 rightOffset--;
1125 } else 1129 } else
1126 break; 1130 break;
1127 } 1131 }
1128 setSuffix( suffix ); 1132 setSuffix( suffix );
1129 1133
1130 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1134 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1131 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1135 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1132 rightOffset--; 1136 rightOffset--;
1133 } else 1137 } else
1134 setFamilyName( parts[ rightOffset ] ); 1138 setFamilyName( parts[ rightOffset ] );
1135 1139
1136 QString prefix; 1140 QString prefix;
1137 while ( leftOffset < rightOffset ) { 1141 while ( leftOffset < rightOffset ) {
1138 if ( titles.contains( parts[ leftOffset ] ) ) { 1142 if ( titles.contains( parts[ leftOffset ] ) ) {
1139 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1143 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1140 leftOffset++; 1144 leftOffset++;
1141 } else 1145 } else
1142 break; 1146 break;
1143 } 1147 }
1144 1148
1145 parts = QStringList::split( " ", part2 ); 1149 parts = QStringList::split( " ", part2 );
1146 1150
1147 leftOffset = 0; 1151 leftOffset = 0;
1148 rightOffset = parts.count(); 1152 rightOffset = parts.count();
1149 1153
1150 while ( leftOffset < rightOffset ) { 1154 while ( leftOffset < rightOffset ) {
1151 if ( titles.contains( parts[ leftOffset ] ) ) { 1155 if ( titles.contains( parts[ leftOffset ] ) ) {
1152 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1156 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1153 leftOffset++; 1157 leftOffset++;
1154 } else 1158 } else
1155 break; 1159 break;
1156 } 1160 }
1157 setPrefix( prefix ); 1161 setPrefix( prefix );
1158 1162
1159 if ( leftOffset < rightOffset ) { 1163 if ( leftOffset < rightOffset ) {
1160 setGivenName( parts[ leftOffset ] ); 1164 setGivenName( parts[ leftOffset ] );
1161 leftOffset++; 1165 leftOffset++;
1162 } 1166 }
1163 1167
1164 QString additionalName; 1168 QString additionalName;
1165 while ( leftOffset < rightOffset ) { 1169 while ( leftOffset < rightOffset ) {
1166 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1170 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1167 leftOffset++; 1171 leftOffset++;
1168 } 1172 }
1169 setAdditionalName( additionalName ); 1173 setAdditionalName( additionalName );
1170 } 1174 }
1171} 1175}
1172 1176
1173QString Addressee::realName() const 1177QString Addressee::realName() const
1174{ 1178{
1175 if ( !formattedName().isEmpty() ) 1179 if ( !formattedName().isEmpty() )
1176 return formattedName(); 1180 return formattedName();
1177 1181
1178 QString n = assembledName(); 1182 QString n = assembledName();
1179 1183
1180 if ( n.isEmpty() ) 1184 if ( n.isEmpty() )
1181 n = name(); 1185 n = name();
1182 1186
1183 return n; 1187 return n;
1184} 1188}
1185 1189
1186QString Addressee::assembledName() const 1190QString Addressee::assembledName() const
1187{ 1191{
1188 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1192 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1189 familyName() + " " + suffix(); 1193 familyName() + " " + suffix();
1190 1194
1191 return name.simplifyWhiteSpace(); 1195 return name.simplifyWhiteSpace();
1192} 1196}
1193 1197
1194QString Addressee::fullEmail( const QString &email ) const 1198QString Addressee::fullEmail( const QString &email ) const
1195{ 1199{
1196 QString e; 1200 QString e;
1197 if ( email.isNull() ) { 1201 if ( email.isNull() ) {
1198 e = preferredEmail(); 1202 e = preferredEmail();
1199 } else { 1203 } else {
1200 e = email; 1204 e = email;
1201 } 1205 }
1202 if ( e.isEmpty() ) return QString::null; 1206 if ( e.isEmpty() ) return QString::null;
1203 1207
1204 QString text; 1208 QString text;
1205 if ( realName().isEmpty() ) 1209 if ( realName().isEmpty() )
1206 text = e; 1210 text = e;
1207 else 1211 else
1208 text = assembledName() + " <" + e + ">"; 1212 text = assembledName() + " <" + e + ">";
1209 1213
1210 return text; 1214 return text;
1211} 1215}
1212 1216
1213void Addressee::insertEmail( const QString &email, bool preferred ) 1217void Addressee::insertEmail( const QString &email, bool preferred )
1214{ 1218{
1215 detach(); 1219 detach();
1216 1220
1217 QStringList::Iterator it = mData->emails.find( email ); 1221 QStringList::Iterator it = mData->emails.find( email );
1218 1222
1219 if ( it != mData->emails.end() ) { 1223 if ( it != mData->emails.end() ) {
1220 if ( !preferred || it == mData->emails.begin() ) return; 1224 if ( !preferred || it == mData->emails.begin() ) return;
1221 mData->emails.remove( it ); 1225 mData->emails.remove( it );
1222 mData->emails.prepend( email ); 1226 mData->emails.prepend( email );
1223 } else { 1227 } else {
1224 if ( preferred ) { 1228 if ( preferred ) {
1225 mData->emails.prepend( email ); 1229 mData->emails.prepend( email );
1226 } else { 1230 } else {
1227 mData->emails.append( email ); 1231 mData->emails.append( email );
1228 } 1232 }
1229 } 1233 }
1230} 1234}
1231 1235
1232void Addressee::removeEmail( const QString &email ) 1236void Addressee::removeEmail( const QString &email )
1233{ 1237{
1234 detach(); 1238 detach();
1235 1239
1236 QStringList::Iterator it = mData->emails.find( email ); 1240 QStringList::Iterator it = mData->emails.find( email );
1237 if ( it == mData->emails.end() ) return; 1241 if ( it == mData->emails.end() ) return;
1238 1242
1239 mData->emails.remove( it ); 1243 mData->emails.remove( it );
1240} 1244}
1241 1245
1242QString Addressee::preferredEmail() const 1246QString Addressee::preferredEmail() const
1243{ 1247{
1244 if ( mData->emails.count() == 0 ) return QString::null; 1248 if ( mData->emails.count() == 0 ) return QString::null;
1245 else return mData->emails.first(); 1249 else return mData->emails.first();
1246} 1250}
1247 1251
1248QStringList Addressee::emails() const 1252QStringList Addressee::emails() const
1249{ 1253{
1250 return mData->emails; 1254 return mData->emails;
1251} 1255}
1252void Addressee::setEmails( const QStringList& emails ) { 1256void Addressee::setEmails( const QStringList& emails ) {
1253 detach(); 1257 detach();
1254 mData->emails = emails; 1258 mData->emails = emails;
1255} 1259}
1256void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1260void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1257{ 1261{
1258 detach(); 1262 detach();
1259 mData->empty = false; 1263 mData->empty = false;
1260 1264
1261 PhoneNumber::List::Iterator it; 1265 PhoneNumber::List::Iterator it;
1262 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1266 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1263 if ( (*it).id() == phoneNumber.id() ) { 1267 if ( (*it).id() == phoneNumber.id() ) {
1264 *it = phoneNumber; 1268 *it = phoneNumber;
1265 return; 1269 return;
1266 } 1270 }
1267 } 1271 }
1268 mData->phoneNumbers.append( phoneNumber ); 1272 mData->phoneNumbers.append( phoneNumber );
1269} 1273}
1270 1274
1271void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1275void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1272{ 1276{
1273 detach(); 1277 detach();
1274 1278
1275 PhoneNumber::List::Iterator it; 1279 PhoneNumber::List::Iterator it;
1276 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1280 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1277 if ( (*it).id() == phoneNumber.id() ) { 1281 if ( (*it).id() == phoneNumber.id() ) {
1278 mData->phoneNumbers.remove( it ); 1282 mData->phoneNumbers.remove( it );
1279 return; 1283 return;
1280 } 1284 }
1281 } 1285 }
1282} 1286}
1283 1287
1284PhoneNumber Addressee::phoneNumber( int type ) const 1288PhoneNumber Addressee::phoneNumber( int type ) const
1285{ 1289{
1286 PhoneNumber phoneNumber( "", type ); 1290 PhoneNumber phoneNumber( "", type );
1287 PhoneNumber::List::ConstIterator it; 1291 PhoneNumber::List::ConstIterator it;
1288 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1292 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1289 if ( matchBinaryPattern( (*it).type(), type ) ) { 1293 if ( matchBinaryPattern( (*it).type(), type ) ) {
1290 if ( (*it).type() & PhoneNumber::Pref ) 1294 if ( (*it).type() & PhoneNumber::Pref )
1291 return (*it); 1295 return (*it);
1292 else if ( phoneNumber.number().isEmpty() ) 1296 else if ( phoneNumber.number().isEmpty() )
1293 phoneNumber = (*it); 1297 phoneNumber = (*it);
1294 } 1298 }
1295 } 1299 }
1296 1300
1297 return phoneNumber; 1301 return phoneNumber;
1298} 1302}
1299 1303
1300PhoneNumber::List Addressee::phoneNumbers() const 1304PhoneNumber::List Addressee::phoneNumbers() const
1301{ 1305{
1302 return mData->phoneNumbers; 1306 return mData->phoneNumbers;
1303} 1307}
1304 1308
1305PhoneNumber::List Addressee::phoneNumbers( int type ) const 1309PhoneNumber::List Addressee::phoneNumbers( int type ) const
1306{ 1310{
1307 PhoneNumber::List list; 1311 PhoneNumber::List list;
1308 1312
1309 PhoneNumber::List::ConstIterator it; 1313 PhoneNumber::List::ConstIterator it;
1310 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1314 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1311 if ( matchBinaryPattern( (*it).type(), type ) ) { 1315 if ( matchBinaryPattern( (*it).type(), type ) ) {
1312 list.append( *it ); 1316 list.append( *it );
1313 } 1317 }
1314 } 1318 }
1315 return list; 1319 return list;
1316} 1320}
1317 1321
1318PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1322PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1319{ 1323{
1320 PhoneNumber::List::ConstIterator it; 1324 PhoneNumber::List::ConstIterator it;
1321 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1325 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1322 if ( (*it).id() == id ) { 1326 if ( (*it).id() == id ) {
1323 return *it; 1327 return *it;
1324 } 1328 }
1325 } 1329 }
1326 return PhoneNumber(); 1330 return PhoneNumber();
1327} 1331}
1328 1332
1329void Addressee::insertKey( const Key &key ) 1333void Addressee::insertKey( const Key &key )
1330{ 1334{
1331 detach(); 1335 detach();
1332 mData->empty = false; 1336 mData->empty = false;
1333 1337
1334 Key::List::Iterator it; 1338 Key::List::Iterator it;
1335 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1339 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1336 if ( (*it).id() == key.id() ) { 1340 if ( (*it).id() == key.id() ) {
1337 *it = key; 1341 *it = key;
1338 return; 1342 return;
1339 } 1343 }
1340 } 1344 }
1341 mData->keys.append( key ); 1345 mData->keys.append( key );
1342} 1346}
1343 1347
1344void Addressee::removeKey( const Key &key ) 1348void Addressee::removeKey( const Key &key )
1345{ 1349{
1346 detach(); 1350 detach();
1347 1351
1348 Key::List::Iterator it; 1352 Key::List::Iterator it;
1349 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1353 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1350 if ( (*it).id() == key.id() ) { 1354 if ( (*it).id() == key.id() ) {
1351 mData->keys.remove( key ); 1355 mData->keys.remove( key );
1352 return; 1356 return;
1353 } 1357 }
1354 } 1358 }
1355} 1359}
1356 1360
1357Key Addressee::key( int type, QString customTypeString ) const 1361Key Addressee::key( int type, QString customTypeString ) const
1358{ 1362{
1359 Key::List::ConstIterator it; 1363 Key::List::ConstIterator it;
1360 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1364 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1361 if ( (*it).type() == type ) { 1365 if ( (*it).type() == type ) {
1362 if ( type == Key::Custom ) { 1366 if ( type == Key::Custom ) {
1363 if ( customTypeString.isEmpty() ) { 1367 if ( customTypeString.isEmpty() ) {
1364 return *it; 1368 return *it;
1365 } else { 1369 } else {
1366 if ( (*it).customTypeString() == customTypeString ) 1370 if ( (*it).customTypeString() == customTypeString )
1367 return (*it); 1371 return (*it);
1368 } 1372 }
1369 } else { 1373 } else {
1370 return *it; 1374 return *it;
1371 } 1375 }
1372 } 1376 }
1373 } 1377 }
1374 return Key( QString(), type ); 1378 return Key( QString(), type );
1375} 1379}
1376void Addressee::setKeys( const Key::List& list ) { 1380void Addressee::setKeys( const Key::List& list ) {
1377 detach(); 1381 detach();
1378 mData->keys = list; 1382 mData->keys = list;
1379} 1383}
1380 1384
1381Key::List Addressee::keys() const 1385Key::List Addressee::keys() const
1382{ 1386{
1383 return mData->keys; 1387 return mData->keys;
1384} 1388}
1385 1389
1386Key::List Addressee::keys( int type, QString customTypeString ) const 1390Key::List Addressee::keys( int type, QString customTypeString ) const
1387{ 1391{
1388 Key::List list; 1392 Key::List list;
1389 1393
1390 Key::List::ConstIterator it; 1394 Key::List::ConstIterator it;
1391 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1395 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1392 if ( (*it).type() == type ) { 1396 if ( (*it).type() == type ) {
1393 if ( type == Key::Custom ) { 1397 if ( type == Key::Custom ) {
1394 if ( customTypeString.isEmpty() ) { 1398 if ( customTypeString.isEmpty() ) {
1395 list.append(*it); 1399 list.append(*it);
1396 } else { 1400 } else {
1397 if ( (*it).customTypeString() == customTypeString ) 1401 if ( (*it).customTypeString() == customTypeString )
1398 list.append(*it); 1402 list.append(*it);
1399 } 1403 }
1400 } else { 1404 } else {
1401 list.append(*it); 1405 list.append(*it);
1402 } 1406 }
1403 } 1407 }
1404 } 1408 }
1405 return list; 1409 return list;
1406} 1410}
1407 1411
1408Key Addressee::findKey( const QString &id ) const 1412Key Addressee::findKey( const QString &id ) const
1409{ 1413{
1410 Key::List::ConstIterator it; 1414 Key::List::ConstIterator it;
1411 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1415 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1412 if ( (*it).id() == id ) { 1416 if ( (*it).id() == id ) {
1413 return *it; 1417 return *it;
1414 } 1418 }
1415 } 1419 }
1416 return Key(); 1420 return Key();
1417} 1421}
1418 1422
1419QString Addressee::asString() const 1423QString Addressee::asString() const
1420{ 1424{
1421 return "Smith, agent Smith..."; 1425 return "Smith, agent Smith...";
1422} 1426}
1423 1427
1424void Addressee::dump() const 1428void Addressee::dump() const
1425{ 1429{
1426 return; 1430 return;
1427 kdDebug(5700) << "Addressee {" << endl; 1431 kdDebug(5700) << "Addressee {" << endl;
1428 1432
1429 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1433 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1430 1434
1431 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1435 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1432 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1436 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1433 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1437 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1434 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1438 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1435 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1439 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1436 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1440 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1437 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1441 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1438 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1442 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1439 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1443 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1440 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1444 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1441 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1445 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1442 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1446 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1443 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1447 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1444 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1448 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1445 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1449 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1446 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1450 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1447 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1451 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1448 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1452 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1449 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1453 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1450 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1454 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1451 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1455 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1452 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1456 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1453 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1457 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1454 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1458 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1455 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1459 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1456 1460
1457 kdDebug(5700) << " Emails {" << endl; 1461 kdDebug(5700) << " Emails {" << endl;
1458 QStringList e = emails(); 1462 QStringList e = emails();
1459 QStringList::ConstIterator it; 1463 QStringList::ConstIterator it;
1460 for( it = e.begin(); it != e.end(); ++it ) { 1464 for( it = e.begin(); it != e.end(); ++it ) {
1461 kdDebug(5700) << " " << (*it) << endl; 1465 kdDebug(5700) << " " << (*it) << endl;
1462 } 1466 }
1463 kdDebug(5700) << " }" << endl; 1467 kdDebug(5700) << " }" << endl;
1464 1468
1465 kdDebug(5700) << " PhoneNumbers {" << endl; 1469 kdDebug(5700) << " PhoneNumbers {" << endl;
1466 PhoneNumber::List p = phoneNumbers(); 1470 PhoneNumber::List p = phoneNumbers();
1467 PhoneNumber::List::ConstIterator it2; 1471 PhoneNumber::List::ConstIterator it2;
1468 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1472 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1469 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1473 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1470 } 1474 }
1471 kdDebug(5700) << " }" << endl; 1475 kdDebug(5700) << " }" << endl;
1472 1476
1473 Address::List a = addresses(); 1477 Address::List a = addresses();
1474 Address::List::ConstIterator it3; 1478 Address::List::ConstIterator it3;
1475 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1479 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1476 (*it3).dump(); 1480 (*it3).dump();
1477 } 1481 }
1478 1482
1479 kdDebug(5700) << " Keys {" << endl; 1483 kdDebug(5700) << " Keys {" << endl;
1480 Key::List k = keys(); 1484 Key::List k = keys();
1481 Key::List::ConstIterator it4; 1485 Key::List::ConstIterator it4;
1482 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1486 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1483 kdDebug(5700) << " Type: " << int((*it4).type()) << 1487 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1484 " Key: " << (*it4).textData() << 1488 " Key: " << (*it4).textData() <<
1485 " CustomString: " << (*it4).customTypeString() << endl; 1489 " CustomString: " << (*it4).customTypeString() << endl;
1486 } 1490 }
1487 kdDebug(5700) << " }" << endl; 1491 kdDebug(5700) << " }" << endl;
1488 1492
1489 kdDebug(5700) << "}" << endl; 1493 kdDebug(5700) << "}" << endl;
1490} 1494}
1491 1495
1492 1496
1493void Addressee::insertAddress( const Address &address ) 1497void Addressee::insertAddress( const Address &address )
1494{ 1498{
1495 detach(); 1499 detach();
1496 mData->empty = false; 1500 mData->empty = false;
1497 1501
1498 Address::List::Iterator it; 1502 Address::List::Iterator it;
1499 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1503 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1500 if ( (*it).id() == address.id() ) { 1504 if ( (*it).id() == address.id() ) {
1501 *it = address; 1505 *it = address;
1502 return; 1506 return;
1503 } 1507 }
1504 } 1508 }
1505 mData->addresses.append( address ); 1509 mData->addresses.append( address );
1506} 1510}
1507 1511
1508void Addressee::removeAddress( const Address &address ) 1512void Addressee::removeAddress( const Address &address )
1509{ 1513{
1510 detach(); 1514 detach();
1511 1515
1512 Address::List::Iterator it; 1516 Address::List::Iterator it;
1513 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1517 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1514 if ( (*it).id() == address.id() ) { 1518 if ( (*it).id() == address.id() ) {
1515 mData->addresses.remove( it ); 1519 mData->addresses.remove( it );
1516 return; 1520 return;
1517 } 1521 }
1518 } 1522 }
1519} 1523}
1520 1524
1521Address Addressee::address( int type ) const 1525Address Addressee::address( int type ) const
1522{ 1526{
1523 Address address( type ); 1527 Address address( type );
1524 Address::List::ConstIterator it; 1528 Address::List::ConstIterator it;
1525 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1529 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1526 if ( matchBinaryPattern( (*it).type(), type ) ) { 1530 if ( matchBinaryPattern( (*it).type(), type ) ) {
1527 if ( (*it).type() & Address::Pref ) 1531 if ( (*it).type() & Address::Pref )
1528 return (*it); 1532 return (*it);
1529 else if ( address.isEmpty() ) 1533 else if ( address.isEmpty() )
1530 address = (*it); 1534 address = (*it);
1531 } 1535 }
1532 } 1536 }
1533 1537
1534 return address; 1538 return address;
1535} 1539}
1536 1540
1537Address::List Addressee::addresses() const 1541Address::List Addressee::addresses() const
1538{ 1542{
1539 return mData->addresses; 1543 return mData->addresses;
1540} 1544}
1541 1545
1542Address::List Addressee::addresses( int type ) const 1546Address::List Addressee::addresses( int type ) const
1543{ 1547{
1544 Address::List list; 1548 Address::List list;
1545 1549
1546 Address::List::ConstIterator it; 1550 Address::List::ConstIterator it;
1547 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1551 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1548 if ( matchBinaryPattern( (*it).type(), type ) ) { 1552 if ( matchBinaryPattern( (*it).type(), type ) ) {
1549 list.append( *it ); 1553 list.append( *it );
1550 } 1554 }
1551 } 1555 }
1552 1556
1553 return list; 1557 return list;
1554} 1558}
1555 1559
1556Address Addressee::findAddress( const QString &id ) const 1560Address Addressee::findAddress( const QString &id ) const
1557{ 1561{
1558 Address::List::ConstIterator it; 1562 Address::List::ConstIterator it;
1559 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1563 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1560 if ( (*it).id() == id ) { 1564 if ( (*it).id() == id ) {
1561 return *it; 1565 return *it;
1562 } 1566 }
1563 } 1567 }
1564 return Address(); 1568 return Address();
1565} 1569}
1566 1570
1567void Addressee::insertCategory( const QString &c ) 1571void Addressee::insertCategory( const QString &c )
1568{ 1572{
1569 detach(); 1573 detach();
1570 mData->empty = false; 1574 mData->empty = false;
1571 1575
1572 if ( mData->categories.contains( c ) ) return; 1576 if ( mData->categories.contains( c ) ) return;
1573 1577
1574 mData->categories.append( c ); 1578 mData->categories.append( c );
1575} 1579}
1576 1580
1577void Addressee::removeCategory( const QString &c ) 1581void Addressee::removeCategory( const QString &c )
1578{ 1582{
1579 detach(); 1583 detach();
1580 1584
1581 QStringList::Iterator it = mData->categories.find( c ); 1585 QStringList::Iterator it = mData->categories.find( c );
1582 if ( it == mData->categories.end() ) return; 1586 if ( it == mData->categories.end() ) return;
1583 1587
1584 mData->categories.remove( it ); 1588 mData->categories.remove( it );
1585} 1589}
1586 1590
1587bool Addressee::hasCategory( const QString &c ) const 1591bool Addressee::hasCategory( const QString &c ) const
1588{ 1592{
1589 return ( mData->categories.contains( c ) ); 1593 return ( mData->categories.contains( c ) );
1590} 1594}
1591 1595
1592void Addressee::setCategories( const QStringList &c ) 1596void Addressee::setCategories( const QStringList &c )
1593{ 1597{
1594 detach(); 1598 detach();
1595 mData->empty = false; 1599 mData->empty = false;
1596 1600
1597 mData->categories = c; 1601 mData->categories = c;
1598} 1602}
1599 1603
1600QStringList Addressee::categories() const 1604QStringList Addressee::categories() const
1601{ 1605{
1602 return mData->categories; 1606 return mData->categories;
1603} 1607}
1604 1608
1605void Addressee::insertCustom( const QString &app, const QString &name, 1609void Addressee::insertCustom( const QString &app, const QString &name,
1606 const QString &value ) 1610 const QString &value )
1607{ 1611{
1608 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1612 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1609 1613
1610 detach(); 1614 detach();
1611 mData->empty = false; 1615 mData->empty = false;
1612 1616
1613 QString qualifiedName = app + "-" + name + ":"; 1617 QString qualifiedName = app + "-" + name + ":";
1614 1618
1615 QStringList::Iterator it; 1619 QStringList::Iterator it;
1616 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1620 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1617 if ( (*it).startsWith( qualifiedName ) ) { 1621 if ( (*it).startsWith( qualifiedName ) ) {
1618 (*it) = qualifiedName + value; 1622 (*it) = qualifiedName + value;
1619 return; 1623 return;
1620 } 1624 }
1621 } 1625 }
1622 mData->custom.append( qualifiedName + value ); 1626 mData->custom.append( qualifiedName + value );
1623} 1627}
1624 1628
1625void Addressee::removeCustom( const QString &app, const QString &name) 1629void Addressee::removeCustom( const QString &app, const QString &name)
1626{ 1630{
1627 detach(); 1631 detach();
1628 1632
1629 QString qualifiedName = app + "-" + name + ":"; 1633 QString qualifiedName = app + "-" + name + ":";
1630 1634
1631 QStringList::Iterator it; 1635 QStringList::Iterator it;
1632 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1636 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1633 if ( (*it).startsWith( qualifiedName ) ) { 1637 if ( (*it).startsWith( qualifiedName ) ) {
1634 mData->custom.remove( it ); 1638 mData->custom.remove( it );
1635 return; 1639 return;
1636 } 1640 }
1637 } 1641 }
1638} 1642}
1639 1643
1640QString Addressee::custom( const QString &app, const QString &name ) const 1644QString Addressee::custom( const QString &app, const QString &name ) const
1641{ 1645{
1642 QString qualifiedName = app + "-" + name + ":"; 1646 QString qualifiedName = app + "-" + name + ":";
1643 QString value; 1647 QString value;
1644 1648
1645 QStringList::ConstIterator it; 1649 QStringList::ConstIterator it;
1646 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1650 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1647 if ( (*it).startsWith( qualifiedName ) ) { 1651 if ( (*it).startsWith( qualifiedName ) ) {
1648 value = (*it).mid( (*it).find( ":" ) + 1 ); 1652 value = (*it).mid( (*it).find( ":" ) + 1 );
1649 break; 1653 break;
1650 } 1654 }
1651 } 1655 }
1652 1656
1653 return value; 1657 return value;
1654} 1658}
1655 1659
1656void Addressee::setCustoms( const QStringList &l ) 1660void Addressee::setCustoms( const QStringList &l )
1657{ 1661{
1658 detach(); 1662 detach();
1659 mData->empty = false; 1663 mData->empty = false;
1660 1664
1661 mData->custom = l; 1665 mData->custom = l;
1662} 1666}
1663 1667
1664QStringList Addressee::customs() const 1668QStringList Addressee::customs() const
1665{ 1669{
1666 return mData->custom; 1670 return mData->custom;
1667} 1671}
1668 1672
1669void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1673void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1670 QString &email) 1674 QString &email)
1671{ 1675{
1672 int startPos, endPos, len; 1676 int startPos, endPos, len;
1673 QString partA, partB, result; 1677 QString partA, partB, result;
1674 char endCh = '>'; 1678 char endCh = '>';
1675 1679
1676 startPos = rawEmail.find('<'); 1680 startPos = rawEmail.find('<');
1677 if (startPos < 0) 1681 if (startPos < 0)
1678 { 1682 {
1679 startPos = rawEmail.find('('); 1683 startPos = rawEmail.find('(');
1680 endCh = ')'; 1684 endCh = ')';
1681 } 1685 }
1682 if (startPos < 0) 1686 if (startPos < 0)
1683 { 1687 {
1684 // We couldn't find any separators, so we assume the whole string 1688 // We couldn't find any separators, so we assume the whole string
1685 // is the email address 1689 // is the email address
1686 email = rawEmail; 1690 email = rawEmail;
1687 fullName = ""; 1691 fullName = "";
1688 } 1692 }
1689 else 1693 else
1690 { 1694 {
1691 // We have a start position, try to find an end 1695 // We have a start position, try to find an end
1692 endPos = rawEmail.find(endCh, startPos+1); 1696 endPos = rawEmail.find(endCh, startPos+1);
1693 1697
1694 if (endPos < 0) 1698 if (endPos < 0)
1695 { 1699 {
1696 // We couldn't find the end of the email address. We can only 1700 // We couldn't find the end of the email address. We can only
1697 // assume the entire string is the email address. 1701 // assume the entire string is the email address.
1698 email = rawEmail; 1702 email = rawEmail;
1699 fullName = ""; 1703 fullName = "";
1700 } 1704 }
1701 else 1705 else
1702 { 1706 {
1703 // We have a start and end to the email address 1707 // We have a start and end to the email address
1704 1708
1705 // Grab the name part 1709 // Grab the name part
1706 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1710 fullName = rawEmail.left(startPos).stripWhiteSpace();
1707 1711
1708 // grab the email part 1712 // grab the email part
1709 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1713 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1710 1714
1711 // Check that we do not have any extra characters on the end of the 1715 // Check that we do not have any extra characters on the end of the
1712 // strings 1716 // strings
1713 len = fullName.length(); 1717 len = fullName.length();
1714 if (fullName[0]=='"' && fullName[len-1]=='"') 1718 if (fullName[0]=='"' && fullName[len-1]=='"')
1715 fullName = fullName.mid(1, len-2); 1719 fullName = fullName.mid(1, len-2);
1716 else if (fullName[0]=='<' && fullName[len-1]=='>') 1720 else if (fullName[0]=='<' && fullName[len-1]=='>')
1717 fullName = fullName.mid(1, len-2); 1721 fullName = fullName.mid(1, len-2);
1718 else if (fullName[0]=='(' && fullName[len-1]==')') 1722 else if (fullName[0]=='(' && fullName[len-1]==')')
1719 fullName = fullName.mid(1, len-2); 1723 fullName = fullName.mid(1, len-2);
1720 } 1724 }
1721 } 1725 }
1722} 1726}
1723 1727
1724void Addressee::setResource( Resource *resource ) 1728void Addressee::setResource( Resource *resource )
1725{ 1729{
1726 detach(); 1730 detach();
1727 mData->resource = resource; 1731 mData->resource = resource;
1728} 1732}
1729 1733
1730Resource *Addressee::resource() const 1734Resource *Addressee::resource() const
1731{ 1735{
1732 return mData->resource; 1736 return mData->resource;
1733} 1737}
1734 1738
1735//US 1739//US
1736QString Addressee::resourceLabel() 1740QString Addressee::resourceLabel()
1737{ 1741{
1738 return i18n("Resource"); 1742 return i18n("Resource");
1739} 1743}
1740 1744
1741void Addressee::setChanged( bool value ) 1745void Addressee::setChanged( bool value )
1742{ 1746{
1743 detach(); 1747 detach();
1744 mData->changed = value; 1748 mData->changed = value;
1745} 1749}
1746 1750
1747bool Addressee::changed() const 1751bool Addressee::changed() const
1748{ 1752{
1749 return mData->changed; 1753 return mData->changed;
1750} 1754}
1751 1755
1752QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 1756QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1753{ 1757{
1754 if (!a.mData) return s; 1758 if (!a.mData) return s;
1755 1759
1756 s << a.uid(); 1760 s << a.uid();
1757 1761
1758 s << a.mData->name; 1762 s << a.mData->name;
1759 s << a.mData->formattedName; 1763 s << a.mData->formattedName;
1760 s << a.mData->familyName; 1764 s << a.mData->familyName;
1761 s << a.mData->givenName; 1765 s << a.mData->givenName;
1762 s << a.mData->additionalName; 1766 s << a.mData->additionalName;
1763 s << a.mData->prefix; 1767 s << a.mData->prefix;
1764 s << a.mData->suffix; 1768 s << a.mData->suffix;
1765 s << a.mData->nickName; 1769 s << a.mData->nickName;
1766 s << a.mData->birthday; 1770 s << a.mData->birthday;
1767 s << a.mData->mailer; 1771 s << a.mData->mailer;
1768 s << a.mData->timeZone; 1772 s << a.mData->timeZone;
1769 s << a.mData->geo; 1773 s << a.mData->geo;
1770 s << a.mData->title; 1774 s << a.mData->title;
1771 s << a.mData->role; 1775 s << a.mData->role;
1772 s << a.mData->organization; 1776 s << a.mData->organization;
1773 s << a.mData->note; 1777 s << a.mData->note;
1774 s << a.mData->productId; 1778 s << a.mData->productId;
1775 s << a.mData->revision; 1779 s << a.mData->revision;
1776 s << a.mData->sortString; 1780 s << a.mData->sortString;
1777 s << a.mData->url; 1781 s << a.mData->url;
1778 s << a.mData->secrecy; 1782 s << a.mData->secrecy;
1779 s << a.mData->logo; 1783 s << a.mData->logo;
1780 s << a.mData->photo; 1784 s << a.mData->photo;
1781 s << a.mData->sound; 1785 s << a.mData->sound;
1782 s << a.mData->agent; 1786 s << a.mData->agent;
1783 s << a.mData->phoneNumbers; 1787 s << a.mData->phoneNumbers;
1784 s << a.mData->addresses; 1788 s << a.mData->addresses;
1785 s << a.mData->emails; 1789 s << a.mData->emails;
1786 s << a.mData->categories; 1790 s << a.mData->categories;
1787 s << a.mData->custom; 1791 s << a.mData->custom;
1788 s << a.mData->keys; 1792 s << a.mData->keys;
1789 return s; 1793 return s;
1790} 1794}
1791 1795
1792QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 1796QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1793{ 1797{
1794 if (!a.mData) return s; 1798 if (!a.mData) return s;
1795 1799
1796 s >> a.mData->uid; 1800 s >> a.mData->uid;
1797 1801
1798 s >> a.mData->name; 1802 s >> a.mData->name;
1799 s >> a.mData->formattedName; 1803 s >> a.mData->formattedName;
1800 s >> a.mData->familyName; 1804 s >> a.mData->familyName;
1801 s >> a.mData->givenName; 1805 s >> a.mData->givenName;
1802 s >> a.mData->additionalName; 1806 s >> a.mData->additionalName;
1803 s >> a.mData->prefix; 1807 s >> a.mData->prefix;
1804 s >> a.mData->suffix; 1808 s >> a.mData->suffix;
1805 s >> a.mData->nickName; 1809 s >> a.mData->nickName;
1806 s >> a.mData->birthday; 1810 s >> a.mData->birthday;
1807 s >> a.mData->mailer; 1811 s >> a.mData->mailer;
1808 s >> a.mData->timeZone; 1812 s >> a.mData->timeZone;
1809 s >> a.mData->geo; 1813 s >> a.mData->geo;
1810 s >> a.mData->title; 1814 s >> a.mData->title;
1811 s >> a.mData->role; 1815 s >> a.mData->role;
1812 s >> a.mData->organization; 1816 s >> a.mData->organization;
1813 s >> a.mData->note; 1817 s >> a.mData->note;
1814 s >> a.mData->productId; 1818 s >> a.mData->productId;
1815 s >> a.mData->revision; 1819 s >> a.mData->revision;
1816 s >> a.mData->sortString; 1820 s >> a.mData->sortString;
1817 s >> a.mData->url; 1821 s >> a.mData->url;
1818 s >> a.mData->secrecy; 1822 s >> a.mData->secrecy;
1819 s >> a.mData->logo; 1823 s >> a.mData->logo;
1820 s >> a.mData->photo; 1824 s >> a.mData->photo;
1821 s >> a.mData->sound; 1825 s >> a.mData->sound;
1822 s >> a.mData->agent; 1826 s >> a.mData->agent;
1823 s >> a.mData->phoneNumbers; 1827 s >> a.mData->phoneNumbers;
1824 s >> a.mData->addresses; 1828 s >> a.mData->addresses;
1825 s >> a.mData->emails; 1829 s >> a.mData->emails;
1826 s >> a.mData->categories; 1830 s >> a.mData->categories;
1827 s >> a.mData->custom; 1831 s >> a.mData->custom;
1828 s >> a.mData->keys; 1832 s >> a.mData->keys;
1829 1833
1830 a.mData->empty = false; 1834 a.mData->empty = false;
1831 1835
1832 return s; 1836 return s;
1833} 1837}
1834 1838
1835bool matchBinaryPattern( int value, int pattern ) 1839bool matchBinaryPattern( int value, int pattern )
1836{ 1840{
1837 /** 1841 /**
1838 We want to match all telephonnumbers/addresses which have the bits in the 1842 We want to match all telephonnumbers/addresses which have the bits in the
1839 pattern set. More are allowed. 1843 pattern set. More are allowed.
1840 if pattern == 0 we have a special handling, then we want only those with 1844 if pattern == 0 we have a special handling, then we want only those with
1841 exactly no bit set. 1845 exactly no bit set.
1842 */ 1846 */
1843 if ( pattern == 0 ) 1847 if ( pattern == 0 )
1844 return ( value == 0 ); 1848 return ( value == 0 );
1845 else 1849 else
1846 return ( pattern == ( pattern & value ) ); 1850 return ( pattern == ( pattern & value ) );
1847} 1851}