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