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