summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
authorzautrix <zautrix>2004-10-09 02:17:06 (UTC)
committer zautrix <zautrix>2004-10-09 02:17:06 (UTC)
commitc2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (patch) (unidiff)
treeb83f7cfe5d4bb681b756fe95446e5e3fc193bc36 /kabc/addressee.cpp
parent07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (diff)
downloadkdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.zip
kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.gz
kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.bz2
import ir fixes
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 19a1845..3f3d5c0 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,701 +1,718 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91}; 91};
92 92
93Addressee::Addressee() 93Addressee::Addressee()
94{ 94{
95 mData = new AddresseeData; 95 mData = new AddresseeData;
96 mData->empty = true; 96 mData->empty = true;
97 mData->changed = false; 97 mData->changed = false;
98 mData->resource = 0; 98 mData->resource = 0;
99 mData->mExternalId = ":"; 99 mData->mExternalId = ":";
100 mData->revision = QDateTime ( QDate( 2003,1,1)); 100 mData->revision = QDateTime ( QDate( 2003,1,1));
101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 102}
103 103
104Addressee::~Addressee() 104Addressee::~Addressee()
105{ 105{
106} 106}
107 107
108Addressee::Addressee( const Addressee &a ) 108Addressee::Addressee( const Addressee &a )
109{ 109{
110 mData = a.mData; 110 mData = a.mData;
111} 111}
112 112
113Addressee &Addressee::operator=( const Addressee &a ) 113Addressee &Addressee::operator=( const Addressee &a )
114{ 114{
115 mData = a.mData; 115 mData = a.mData;
116 return (*this); 116 return (*this);
117} 117}
118 118
119Addressee Addressee::copy() 119Addressee Addressee::copy()
120{ 120{
121 Addressee a; 121 Addressee a;
122 *(a.mData) = *mData; 122 *(a.mData) = *mData;
123 return a; 123 return a;
124} 124}
125 125
126void Addressee::detach() 126void Addressee::detach()
127{ 127{
128 if ( mData.count() == 1 ) return; 128 if ( mData.count() == 1 ) return;
129 *this = copy(); 129 *this = copy();
130} 130}
131 131
132bool Addressee::operator==( const Addressee &a ) const 132bool Addressee::operator==( const Addressee &a ) const
133{ 133{
134 if ( uid() != a.uid() ) return false; 134 if ( uid() != a.uid() ) return false;
135 if ( mData->name != a.mData->name ) return false; 135 if ( mData->name != a.mData->name ) return false;
136 if ( mData->formattedName != a.mData->formattedName ) return false; 136 if ( mData->formattedName != a.mData->formattedName ) return false;
137 if ( mData->familyName != a.mData->familyName ) return false; 137 if ( mData->familyName != a.mData->familyName ) return false;
138 if ( mData->givenName != a.mData->givenName ) return false; 138 if ( mData->givenName != a.mData->givenName ) return false;
139 if ( mData->additionalName != a.mData->additionalName ) return false; 139 if ( mData->additionalName != a.mData->additionalName ) return false;
140 if ( mData->prefix != a.mData->prefix ) return false; 140 if ( mData->prefix != a.mData->prefix ) return false;
141 if ( mData->suffix != a.mData->suffix ) return false; 141 if ( mData->suffix != a.mData->suffix ) return false;
142 if ( mData->nickName != a.mData->nickName ) return false; 142 if ( mData->nickName != a.mData->nickName ) return false;
143 if ( mData->birthday != a.mData->birthday ) return false; 143 if ( mData->birthday != a.mData->birthday ) return false;
144 if ( mData->mailer != a.mData->mailer ) return false; 144 if ( mData->mailer != a.mData->mailer ) return false;
145 if ( mData->timeZone != a.mData->timeZone ) return false; 145 if ( mData->timeZone != a.mData->timeZone ) return false;
146 if ( mData->geo != a.mData->geo ) return false; 146 if ( mData->geo != a.mData->geo ) return false;
147 if ( mData->title != a.mData->title ) return false; 147 if ( mData->title != a.mData->title ) return false;
148 if ( mData->role != a.mData->role ) return false; 148 if ( mData->role != a.mData->role ) return false;
149 if ( mData->organization != a.mData->organization ) return false; 149 if ( mData->organization != a.mData->organization ) return false;
150 if ( mData->note != a.mData->note ) return false; 150 if ( mData->note != a.mData->note ) return false;
151 if ( mData->productId != a.mData->productId ) return false; 151 if ( mData->productId != a.mData->productId ) return false;
152 //if ( mData->revision != a.mData->revision ) return false; 152 //if ( mData->revision != a.mData->revision ) return false;
153 if ( mData->sortString != a.mData->sortString ) return false; 153 if ( mData->sortString != a.mData->sortString ) return false;
154 if ( mData->secrecy != a.mData->secrecy ) return false; 154 if ( mData->secrecy != a.mData->secrecy ) return false;
155 if ( mData->logo != a.mData->logo ) return false; 155 if ( mData->logo != a.mData->logo ) return false;
156 if ( mData->photo != a.mData->photo ) return false; 156 if ( mData->photo != a.mData->photo ) return false;
157 if ( mData->sound != a.mData->sound ) return false; 157 if ( mData->sound != a.mData->sound ) return false;
158 if ( mData->agent != a.mData->agent ) return false; 158 if ( mData->agent != a.mData->agent ) return false;
159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
160 ( mData->url != a.mData->url ) ) return false; 160 ( mData->url != a.mData->url ) ) return false;
161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
162 if ( mData->addresses != a.mData->addresses ) return false; 162 if ( mData->addresses != a.mData->addresses ) return false;
163 if ( mData->keys != a.mData->keys ) return false; 163 if ( mData->keys != a.mData->keys ) return false;
164 if ( mData->emails != a.mData->emails ) return false; 164 if ( mData->emails != a.mData->emails ) return false;
165 if ( mData->categories != a.mData->categories ) return false; 165 if ( mData->categories != a.mData->categories ) return false;
166 if ( mData->custom != a.mData->custom ) return false; 166 if ( mData->custom != a.mData->custom ) return false;
167 167
168 return true; 168 return true;
169} 169}
170 170
171bool Addressee::operator!=( const Addressee &a ) const 171bool Addressee::operator!=( const Addressee &a ) const
172{ 172{
173 return !( a == *this ); 173 return !( a == *this );
174} 174}
175 175
176bool Addressee::isEmpty() const 176bool Addressee::isEmpty() const
177{ 177{
178 return mData->empty; 178 return mData->empty;
179} 179}
180ulong Addressee::getCsum4List( const QStringList & attList) 180ulong Addressee::getCsum4List( const QStringList & attList)
181{ 181{
182 int max = attList.count(); 182 int max = attList.count();
183 ulong cSum = 0; 183 ulong cSum = 0;
184 int j,k,i; 184 int j,k,i;
185 int add; 185 int add;
186 for ( i = 0; i < max ; ++i ) { 186 for ( i = 0; i < max ; ++i ) {
187 QString s = attList[i]; 187 QString s = attList[i];
188 if ( ! s.isEmpty() ){ 188 if ( ! s.isEmpty() ){
189 j = s.length(); 189 j = s.length();
190 for ( k = 0; k < j; ++k ) { 190 for ( k = 0; k < j; ++k ) {
191 int mul = k +1; 191 int mul = k +1;
192 add = s[k].unicode (); 192 add = s[k].unicode ();
193 if ( k < 16 ) 193 if ( k < 16 )
194 mul = mul * mul; 194 mul = mul * mul;
195 int ii = i+1; 195 int ii = i+1;
196 add = add * mul *ii*ii*ii; 196 add = add * mul *ii*ii*ii;
197 cSum += add; 197 cSum += add;
198 } 198 }
199 } 199 }
200 200
201 } 201 }
202 //QString dump = attList.join(","); 202 //QString dump = attList.join(",");
203 //qDebug("csum: %d %s", cSum,dump.latin1()); 203 //qDebug("csum: %d %s", cSum,dump.latin1());
204 204
205 return cSum; 205 return cSum;
206 206
207} 207}
208void Addressee::computeCsum(const QString &dev) 208void Addressee::computeCsum(const QString &dev)
209{ 209{
210 QStringList l; 210 QStringList l;
211 if ( !mData->name.isEmpty() ) l.append(mData->name); 211 if ( !mData->name.isEmpty() ) l.append(mData->name);
212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
215 if ( !mData->additionalName ) l.append( mData->additionalName ); 215 if ( !mData->additionalName ) l.append( mData->additionalName );
216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
223 if ( !mData->title .isEmpty() ) l.append( mData->title ); 223 if ( !mData->title .isEmpty() ) l.append( mData->title );
224 if ( !mData->role.isEmpty() ) l.append( mData->role ); 224 if ( !mData->role.isEmpty() ) l.append( mData->role );
225 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 225 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
226 if ( !mData->note.isEmpty() ) l.append( mData->note ); 226 if ( !mData->note.isEmpty() ) l.append( mData->note );
227 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 227 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
230 // if ( !mData->logo.isEmpty() ) l.append( ); 230 // if ( !mData->logo.isEmpty() ) l.append( );
231 //if ( !mData->photo.isEmpty() ) l.append( ); 231 //if ( !mData->photo.isEmpty() ) l.append( );
232 //if ( !mData->sound.isEmpty() ) l.append( ); 232 //if ( !mData->sound.isEmpty() ) l.append( );
233 //if ( !mData->agent.isEmpty() ) l.append( ); 233 //if ( !mData->agent.isEmpty() ) l.append( );
234 //if ( mData->url.isValid() ) l.append( ); 234 //if ( mData->url.isValid() ) l.append( );
235#if 0 235#if 0
236 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 236 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
237 if ( !mData->addresses.isEmpty() ) l.append( ); 237 if ( !mData->addresses.isEmpty() ) l.append( );
238 //if ( !mData->keys.isEmpty() ) l.append( ); 238 //if ( !mData->keys.isEmpty() ) l.append( );
239 if ( !mData->emails.isEmpty() ) l.append( ); 239 if ( !mData->emails.isEmpty() ) l.append( );
240 if ( !mData->categories .isEmpty() ) l.append( ); 240 if ( !mData->categories .isEmpty() ) l.append( );
241 if ( !mData->custom.isEmpty() ) l.append( ); 241 if ( !mData->custom.isEmpty() ) l.append( );
242#endif 242#endif
243 KABC::PhoneNumber::List phoneNumbers; 243 KABC::PhoneNumber::List phoneNumbers;
244 KABC::PhoneNumber::List::Iterator phoneIter; 244 KABC::PhoneNumber::List::Iterator phoneIter;
245 245
246 QStringList t; 246 QStringList t;
247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
248 ++phoneIter ) 248 ++phoneIter )
249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
250 t.sort(); 250 t.sort();
251 uint iii; 251 uint iii;
252 for ( iii = 0; iii < t.count(); ++iii) 252 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 253 l.append( t[iii] );
254 t = mData->emails; 254 t = mData->emails;
255 t.sort(); 255 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 256 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 257 l.append( t[iii] );
258 t = mData->categories; 258 t = mData->categories;
259 t.sort(); 259 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 260 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 261 l.append( t[iii] );
262 t = mData->custom; 262 t = mData->custom;
263 t.sort(); 263 t.sort();
264 for ( iii = 0; iii < t.count(); ++iii) 264 for ( iii = 0; iii < t.count(); ++iii)
265 l.append( t[iii] ); 265 l.append( t[iii] );
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
276 setCsum( dev, QString::number (cs )); 276 setCsum( dev, QString::number (cs ));
277} 277}
278 278
279void Addressee::mergeContact( const Addressee& ad ) 279void Addressee::mergeContact( const Addressee& ad )
280{ 280{
281 281
282 detach(); 282 detach();
283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
291 if ( !mData->birthday.isValid() ) 291 if ( !mData->birthday.isValid() )
292 if ( ad.mData->birthday.isValid()) 292 if ( ad.mData->birthday.isValid())
293 mData->birthday = ad.mData->birthday; 293 mData->birthday = ad.mData->birthday;
294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
305 305
306 // pending: 306 // pending:
307 // merging phonenumbers 307 // merging phonenumbers
308 // merging addresses 308 // merging addresses
309 // merging emails; 309 // merging emails;
310 // merging categories; 310 // merging categories;
311 // merging custom; 311 // merging custom;
312 // merging keys 312 // merging keys
313 qDebug("merge contact %s ", ad.uid().latin1()); 313 qDebug("merge contact %s ", ad.uid().latin1());
314 setUid( ad.uid() ); 314 setUid( ad.uid() );
315 setRevision( ad.revision() ); 315 setRevision( ad.revision() );
316} 316}
317 317
318bool Addressee::removeVoice()
319{
320 PhoneNumber::List phoneN = phoneNumbers();
321 PhoneNumber::List::Iterator phoneIt;
322 bool found = false;
323 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
324 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
325 if ((*phoneIt).type() - PhoneNumber::Voice ) {
326 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
327 insertPhoneNumber( (*phoneIt) );
328 found = true;
329 }
330 }
331
332 }
333 return found;
334}
318void Addressee::simplifyAddresses() 335void Addressee::simplifyAddresses()
319{ 336{
320 if ( mData->addresses.count() < 3 ) return ; 337 if ( mData->addresses.count() < 3 ) return ;
321 int count = 0; 338 int count = 0;
322 Address::List list; 339 Address::List list;
323 Address::List::Iterator it; 340 Address::List::Iterator it;
324 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 341 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
325 if ( count > 1 ) 342 if ( count > 1 )
326 list.append( *it ); 343 list.append( *it );
327 ++count; 344 ++count;
328 } 345 }
329 for( it = list.begin(); it != list.end(); ++it ) { 346 for( it = list.begin(); it != list.end(); ++it ) {
330 removeAddress( (*it) ); 347 removeAddress( (*it) );
331 } 348 }
332} 349}
333 350
334// removes all emails but the first 351// removes all emails but the first
335// needed by phone sync 352// needed by phone sync
336void Addressee::simplifyEmails() 353void Addressee::simplifyEmails()
337{ 354{
338 if ( mData->emails.count() == 0 ) return ; 355 if ( mData->emails.count() == 0 ) return ;
339 QString email = mData->emails.first(); 356 QString email = mData->emails.first();
340 detach(); 357 detach();
341 mData->emails.clear(); 358 mData->emails.clear();
342 mData->emails.append( email ); 359 mData->emails.append( email );
343} 360}
344 361
345void Addressee::simplifyPhoneNumbers() 362void Addressee::simplifyPhoneNumbers()
346{ 363{
347 KABC::PhoneNumber::List removeNumbers; 364 KABC::PhoneNumber::List removeNumbers;
348 KABC::PhoneNumber::List::Iterator phoneIter; 365 KABC::PhoneNumber::List::Iterator phoneIter;
349 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 366 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
350 ++phoneIter ) { 367 ++phoneIter ) {
351 if ( ! ( *phoneIter ).simplifyNumber() ) 368 if ( ! ( *phoneIter ).simplifyNumber() )
352 removeNumbers.append( ( *phoneIter ) ); 369 removeNumbers.append( ( *phoneIter ) );
353 } 370 }
354 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 371 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
355 ++phoneIter ) { 372 ++phoneIter ) {
356 removePhoneNumber(( *phoneIter )); 373 removePhoneNumber(( *phoneIter ));
357 } 374 }
358} 375}
359void Addressee::simplifyPhoneNumberTypes() 376void Addressee::simplifyPhoneNumberTypes()
360{ 377{
361 KABC::PhoneNumber::List::Iterator phoneIter; 378 KABC::PhoneNumber::List::Iterator phoneIter;
362 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 379 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
363 ++phoneIter ) 380 ++phoneIter )
364 ( *phoneIter ).simplifyType(); 381 ( *phoneIter ).simplifyType();
365} 382}
366void Addressee::removeID(const QString &prof) 383void Addressee::removeID(const QString &prof)
367{ 384{
368 detach(); 385 detach();
369 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 386 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
370 387
371} 388}
372void Addressee::setID( const QString & prof , const QString & id ) 389void Addressee::setID( const QString & prof , const QString & id )
373{ 390{
374 detach(); 391 detach();
375 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 392 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
376 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 393 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
377} 394}
378void Addressee::setTempSyncStat( int id ) 395void Addressee::setTempSyncStat( int id )
379{ 396{
380 if ( mData->mTempSyncStat == id ) return; 397 if ( mData->mTempSyncStat == id ) return;
381 detach(); 398 detach();
382 mData->mTempSyncStat = id; 399 mData->mTempSyncStat = id;
383} 400}
384int Addressee::tempSyncStat() const 401int Addressee::tempSyncStat() const
385{ 402{
386 return mData->mTempSyncStat; 403 return mData->mTempSyncStat;
387} 404}
388 405
389QString Addressee::getID( const QString & prof) 406QString Addressee::getID( const QString & prof)
390{ 407{
391 return KIdManager::getId ( mData->mExternalId, prof ); 408 return KIdManager::getId ( mData->mExternalId, prof );
392} 409}
393 410
394void Addressee::setCsum( const QString & prof , const QString & id ) 411void Addressee::setCsum( const QString & prof , const QString & id )
395{ 412{
396 detach(); 413 detach();
397 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 414 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
398 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 415 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
399 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 416 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
400} 417}
401 418
402QString Addressee::getCsum( const QString & prof) 419QString Addressee::getCsum( const QString & prof)
403{ 420{
404 return KIdManager::getCsum ( mData->mExternalId, prof ); 421 return KIdManager::getCsum ( mData->mExternalId, prof );
405} 422}
406 423
407void Addressee::setIDStr( const QString & s ) 424void Addressee::setIDStr( const QString & s )
408{ 425{
409 detach(); 426 detach();
410 mData->mExternalId = s; 427 mData->mExternalId = s;
411} 428}
412 429
413QString Addressee::IDStr() const 430QString Addressee::IDStr() const
414{ 431{
415 return mData->mExternalId; 432 return mData->mExternalId;
416} 433}
417 434
418void Addressee::setExternalUID( const QString &id ) 435void Addressee::setExternalUID( const QString &id )
419{ 436{
420 if ( id == mData->externalUID ) return; 437 if ( id == mData->externalUID ) return;
421 detach(); 438 detach();
422 mData->empty = false; 439 mData->empty = false;
423 mData->externalUID = id; 440 mData->externalUID = id;
424} 441}
425 442
426QString Addressee::externalUID() const 443QString Addressee::externalUID() const
427{ 444{
428 return mData->externalUID; 445 return mData->externalUID;
429} 446}
430void Addressee::setOriginalExternalUID( const QString &id ) 447void Addressee::setOriginalExternalUID( const QString &id )
431{ 448{
432 if ( id == mData->originalExternalUID ) return; 449 if ( id == mData->originalExternalUID ) return;
433 detach(); 450 detach();
434 mData->empty = false; 451 mData->empty = false;
435 //qDebug("*******Set orig uid %s ", id.latin1()); 452 //qDebug("*******Set orig uid %s ", id.latin1());
436 mData->originalExternalUID = id; 453 mData->originalExternalUID = id;
437} 454}
438 455
439QString Addressee::originalExternalUID() const 456QString Addressee::originalExternalUID() const
440{ 457{
441 return mData->originalExternalUID; 458 return mData->originalExternalUID;
442} 459}
443 460
444void Addressee::setUid( const QString &id ) 461void Addressee::setUid( const QString &id )
445{ 462{
446 if ( id == mData->uid ) return; 463 if ( id == mData->uid ) return;
447 detach(); 464 detach();
448 //qDebug("****setuid %s ", id.latin1()); 465 //qDebug("****setuid %s ", id.latin1());
449 mData->empty = false; 466 mData->empty = false;
450 mData->uid = id; 467 mData->uid = id;
451} 468}
452 469
453QString Addressee::uid() const 470QString Addressee::uid() const
454{ 471{
455 if ( mData->uid.isEmpty() ) 472 if ( mData->uid.isEmpty() )
456 mData->uid = KApplication::randomString( 10 ); 473 mData->uid = KApplication::randomString( 10 );
457 474
458 return mData->uid; 475 return mData->uid;
459} 476}
460 477
461QString Addressee::uidLabel() 478QString Addressee::uidLabel()
462{ 479{
463 return i18n("Unique Identifier"); 480 return i18n("Unique Identifier");
464} 481}
465 482
466void Addressee::setName( const QString &name ) 483void Addressee::setName( const QString &name )
467{ 484{
468 if ( name == mData->name ) return; 485 if ( name == mData->name ) return;
469 detach(); 486 detach();
470 mData->empty = false; 487 mData->empty = false;
471 mData->name = name; 488 mData->name = name;
472} 489}
473 490
474QString Addressee::name() const 491QString Addressee::name() const
475{ 492{
476 return mData->name; 493 return mData->name;
477} 494}
478 495
479QString Addressee::nameLabel() 496QString Addressee::nameLabel()
480{ 497{
481 return i18n("Name"); 498 return i18n("Name");
482} 499}
483 500
484 501
485void Addressee::setFormattedName( const QString &formattedName ) 502void Addressee::setFormattedName( const QString &formattedName )
486{ 503{
487 if ( formattedName == mData->formattedName ) return; 504 if ( formattedName == mData->formattedName ) return;
488 detach(); 505 detach();
489 mData->empty = false; 506 mData->empty = false;
490 mData->formattedName = formattedName; 507 mData->formattedName = formattedName;
491} 508}
492 509
493QString Addressee::formattedName() const 510QString Addressee::formattedName() const
494{ 511{
495 return mData->formattedName; 512 return mData->formattedName;
496} 513}
497 514
498QString Addressee::formattedNameLabel() 515QString Addressee::formattedNameLabel()
499{ 516{
500 return i18n("Formatted Name"); 517 return i18n("Formatted Name");
501} 518}
502 519
503 520
504void Addressee::setFamilyName( const QString &familyName ) 521void Addressee::setFamilyName( const QString &familyName )
505{ 522{
506 if ( familyName == mData->familyName ) return; 523 if ( familyName == mData->familyName ) return;
507 detach(); 524 detach();
508 mData->empty = false; 525 mData->empty = false;
509 mData->familyName = familyName; 526 mData->familyName = familyName;
510} 527}
511 528
512QString Addressee::familyName() const 529QString Addressee::familyName() const
513{ 530{
514 return mData->familyName; 531 return mData->familyName;
515} 532}
516 533
517QString Addressee::familyNameLabel() 534QString Addressee::familyNameLabel()
518{ 535{
519 return i18n("Family Name"); 536 return i18n("Family Name");
520} 537}
521 538
522 539
523void Addressee::setGivenName( const QString &givenName ) 540void Addressee::setGivenName( const QString &givenName )
524{ 541{
525 if ( givenName == mData->givenName ) return; 542 if ( givenName == mData->givenName ) return;
526 detach(); 543 detach();
527 mData->empty = false; 544 mData->empty = false;
528 mData->givenName = givenName; 545 mData->givenName = givenName;
529} 546}
530 547
531QString Addressee::givenName() const 548QString Addressee::givenName() const
532{ 549{
533 return mData->givenName; 550 return mData->givenName;
534} 551}
535 552
536QString Addressee::givenNameLabel() 553QString Addressee::givenNameLabel()
537{ 554{
538 return i18n("Given Name"); 555 return i18n("Given Name");
539} 556}
540 557
541 558
542void Addressee::setAdditionalName( const QString &additionalName ) 559void Addressee::setAdditionalName( const QString &additionalName )
543{ 560{
544 if ( additionalName == mData->additionalName ) return; 561 if ( additionalName == mData->additionalName ) return;
545 detach(); 562 detach();
546 mData->empty = false; 563 mData->empty = false;
547 mData->additionalName = additionalName; 564 mData->additionalName = additionalName;
548} 565}
549 566
550QString Addressee::additionalName() const 567QString Addressee::additionalName() const
551{ 568{
552 return mData->additionalName; 569 return mData->additionalName;
553} 570}
554 571
555QString Addressee::additionalNameLabel() 572QString Addressee::additionalNameLabel()
556{ 573{
557 return i18n("Additional Names"); 574 return i18n("Additional Names");
558} 575}
559 576
560 577
561void Addressee::setPrefix( const QString &prefix ) 578void Addressee::setPrefix( const QString &prefix )
562{ 579{
563 if ( prefix == mData->prefix ) return; 580 if ( prefix == mData->prefix ) return;
564 detach(); 581 detach();
565 mData->empty = false; 582 mData->empty = false;
566 mData->prefix = prefix; 583 mData->prefix = prefix;
567} 584}
568 585
569QString Addressee::prefix() const 586QString Addressee::prefix() const
570{ 587{
571 return mData->prefix; 588 return mData->prefix;
572} 589}
573 590
574QString Addressee::prefixLabel() 591QString Addressee::prefixLabel()
575{ 592{
576 return i18n("Honorific Prefixes"); 593 return i18n("Honorific Prefixes");
577} 594}
578 595
579 596
580void Addressee::setSuffix( const QString &suffix ) 597void Addressee::setSuffix( const QString &suffix )
581{ 598{
582 if ( suffix == mData->suffix ) return; 599 if ( suffix == mData->suffix ) return;
583 detach(); 600 detach();
584 mData->empty = false; 601 mData->empty = false;
585 mData->suffix = suffix; 602 mData->suffix = suffix;
586} 603}
587 604
588QString Addressee::suffix() const 605QString Addressee::suffix() const
589{ 606{
590 return mData->suffix; 607 return mData->suffix;
591} 608}
592 609
593QString Addressee::suffixLabel() 610QString Addressee::suffixLabel()
594{ 611{
595 return i18n("Honorific Suffixes"); 612 return i18n("Honorific Suffixes");
596} 613}
597 614
598 615
599void Addressee::setNickName( const QString &nickName ) 616void Addressee::setNickName( const QString &nickName )
600{ 617{
601 if ( nickName == mData->nickName ) return; 618 if ( nickName == mData->nickName ) return;
602 detach(); 619 detach();
603 mData->empty = false; 620 mData->empty = false;
604 mData->nickName = nickName; 621 mData->nickName = nickName;
605} 622}
606 623
607QString Addressee::nickName() const 624QString Addressee::nickName() const
608{ 625{
609 return mData->nickName; 626 return mData->nickName;
610} 627}
611 628
612QString Addressee::nickNameLabel() 629QString Addressee::nickNameLabel()
613{ 630{
614 return i18n("Nick Name"); 631 return i18n("Nick Name");
615} 632}
616 633
617 634
618void Addressee::setBirthday( const QDateTime &birthday ) 635void Addressee::setBirthday( const QDateTime &birthday )
619{ 636{
620 if ( birthday == mData->birthday ) return; 637 if ( birthday == mData->birthday ) return;
621 detach(); 638 detach();
622 mData->empty = false; 639 mData->empty = false;
623 mData->birthday = birthday; 640 mData->birthday = birthday;
624} 641}
625 642
626QDateTime Addressee::birthday() const 643QDateTime Addressee::birthday() const
627{ 644{
628 return mData->birthday; 645 return mData->birthday;
629} 646}
630 647
631QString Addressee::birthdayLabel() 648QString Addressee::birthdayLabel()
632{ 649{
633 return i18n("Birthday"); 650 return i18n("Birthday");
634} 651}
635 652
636 653
637QString Addressee::homeAddressStreetLabel() 654QString Addressee::homeAddressStreetLabel()
638{ 655{
639 return i18n("Home Address Street"); 656 return i18n("Home Address Street");
640} 657}
641 658
642 659
643QString Addressee::homeAddressLocalityLabel() 660QString Addressee::homeAddressLocalityLabel()
644{ 661{
645 return i18n("Home Address Locality"); 662 return i18n("Home Address Locality");
646} 663}
647 664
648 665
649QString Addressee::homeAddressRegionLabel() 666QString Addressee::homeAddressRegionLabel()
650{ 667{
651 return i18n("Home Address Region"); 668 return i18n("Home Address Region");
652} 669}
653 670
654 671
655QString Addressee::homeAddressPostalCodeLabel() 672QString Addressee::homeAddressPostalCodeLabel()
656{ 673{
657 return i18n("Home Address Postal Code"); 674 return i18n("Home Address Postal Code");
658} 675}
659 676
660 677
661QString Addressee::homeAddressCountryLabel() 678QString Addressee::homeAddressCountryLabel()
662{ 679{
663 return i18n("Home Address Country"); 680 return i18n("Home Address Country");
664} 681}
665 682
666 683
667QString Addressee::homeAddressLabelLabel() 684QString Addressee::homeAddressLabelLabel()
668{ 685{
669 return i18n("Home Address Label"); 686 return i18n("Home Address Label");
670} 687}
671 688
672 689
673QString Addressee::businessAddressStreetLabel() 690QString Addressee::businessAddressStreetLabel()
674{ 691{
675 return i18n("Business Address Street"); 692 return i18n("Business Address Street");
676} 693}
677 694
678 695
679QString Addressee::businessAddressLocalityLabel() 696QString Addressee::businessAddressLocalityLabel()
680{ 697{
681 return i18n("Business Address Locality"); 698 return i18n("Business Address Locality");
682} 699}
683 700
684 701
685QString Addressee::businessAddressRegionLabel() 702QString Addressee::businessAddressRegionLabel()
686{ 703{
687 return i18n("Business Address Region"); 704 return i18n("Business Address Region");
688} 705}
689 706
690 707
691QString Addressee::businessAddressPostalCodeLabel() 708QString Addressee::businessAddressPostalCodeLabel()
692{ 709{
693 return i18n("Business Address Postal Code"); 710 return i18n("Business Address Postal Code");
694} 711}
695 712
696 713
697QString Addressee::businessAddressCountryLabel() 714QString Addressee::businessAddressCountryLabel()
698{ 715{
699 return i18n("Business Address Country"); 716 return i18n("Business Address Country");
700} 717}
701 718