summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp111
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.cpp20
-rw-r--r--kaddressbook/kabcore.cpp32
3 files changed, 94 insertions, 69 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3b238f5..82b4b9b 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -95,504 +95,515 @@ Addressee::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.
288 //if isSubSet (e.g. mobile phone sync) merge all fields
287 289
288 detach(); 290 detach();
289 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 291 if ( isSubSet ) {
290 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 292 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
291 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 293 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
292 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 294 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
293 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 295 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
294 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 296 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
295 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 297 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
296 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 298 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
297 if ( !mData->birthday.isValid() ) 299 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( ad.mData->birthday.isValid()) 300 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 mData->birthday = ad.mData->birthday; 301 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
302 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
303 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 if ( !mData->birthday.isValid() )
307 if ( ad.mData->birthday.isValid())
308 mData->birthday = ad.mData->birthday;
309
310 }
300 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 311 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
301 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 312 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
302 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 313 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
303 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
304 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
305 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
306 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
307 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 314 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
308 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 315 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
309 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
310 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
311 QStringList t; 316 QStringList t;
312 QStringList tAD; 317 QStringList tAD;
313 uint iii; 318 uint iii;
314 319
315 // ********** phone numbers 320 // ********** phone numbers
316 PhoneNumber::List phoneAD = ad.phoneNumbers(); 321 if ( isSubSet ) {
317 PhoneNumber::List::Iterator phoneItAD; 322 PhoneNumber::List phoneAD = ad.phoneNumbers();
318 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 323 PhoneNumber::List::Iterator phoneItAD;
319 bool found = false; 324 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
320 PhoneNumber::List::Iterator it; 325 bool found = false;
321 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 326 PhoneNumber::List::Iterator it;
322 if ( ( *phoneItAD ).contains( (*it) ) ) { 327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
323 found = true; 328 if ( ( *phoneItAD ).contains( (*it) ) ) {
324 (*it).setType( ( *phoneItAD ).type() ); 329 found = true;
325 (*it).setNumber( ( *phoneItAD ).number() ); 330 (*it).setType( ( *phoneItAD ).type() );
326 break; 331 (*it).setNumber( ( *phoneItAD ).number() );
332 break;
333 }
327 } 334 }
335 // if ( isSubSet && ! found )
336 if ( ! found ) // LR try this one...
337 mData->phoneNumbers.append( *phoneItAD );
328 } 338 }
329 // if ( isSubSet && ! found )
330 if ( ! found ) // LR try this one...
331 mData->phoneNumbers.append( *phoneItAD );
332 } 339 }
333 if ( isSubSet ) { 340 if ( isSubSet ) {
334 // ************* emails; 341 // ************* emails;
335 t = mData->emails; 342 t = mData->emails;
336 tAD = ad.mData->emails; 343 tAD = ad.mData->emails;
337 for ( iii = 0; iii < tAD.count(); ++iii) 344 for ( iii = 0; iii < tAD.count(); ++iii)
338 if ( !t.contains(tAD[iii] ) ) 345 if ( !t.contains(tAD[iii] ) )
339 mData->emails.append( tAD[iii] ); 346 mData->emails.append( tAD[iii] );
340 } 347 }
341 348
342 // ************* categories; 349 // ************* categories;
343 t = mData->categories; 350 if ( isSubSet ) {
344 tAD = ad.mData->categories; 351 t = mData->categories;
345 for ( iii = 0; iii < tAD.count(); ++iii) 352 tAD = ad.mData->categories;
346 if ( !t.contains(tAD[iii] ) ) 353 for ( iii = 0; iii < tAD.count(); ++iii)
347 mData->categories.append( tAD[iii] ); 354 if ( !t.contains(tAD[iii] ) )
355 mData->categories.append( tAD[iii] );
356 }
348 QStringList::ConstIterator it; 357 QStringList::ConstIterator it;
349 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 358 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
350 QString qualifiedName = (*it).left( (*it).find( ":" )); 359 QString qualifiedName = (*it).left( (*it).find( ":" ));
351 bool found = false; 360 bool found = false;
352 QStringList::ConstIterator itL; 361 QStringList::ConstIterator itL;
353 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 362 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
354 if ( (*itL).startsWith( qualifiedName ) ) { 363 if ( (*itL).startsWith( qualifiedName ) ) {
355 found = true; 364 found = true;
356 break; 365 break;
357 } 366 }
358 } 367 }
359 if ( ! found ) { 368 if ( ! found ) {
360 mData->custom.append( *it ); 369 mData->custom.append( *it );
361 } 370 }
362 } 371 }
363 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 372 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
364 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 373 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
365 if ( !mData->sound.isIntern() ) { 374 if ( !mData->sound.isIntern() ) {
366 if ( mData->sound.url().isEmpty() ) { 375 if ( mData->sound.url().isEmpty() ) {
367 mData->sound = ad.mData->sound; 376 mData->sound = ad.mData->sound;
368 } 377 }
369 } 378 }
370 if ( !mData->agent.isIntern() ) { 379 if ( !mData->agent.isIntern() ) {
371 if ( mData->agent.url().isEmpty() ) { 380 if ( mData->agent.url().isEmpty() ) {
372 mData->agent = ad.mData->agent; 381 mData->agent = ad.mData->agent;
373 } 382 }
374 } 383 }
375 { 384 {
376 Key::List::Iterator itA; 385 Key::List::Iterator itA;
377 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 386 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
378 bool found = false; 387 bool found = false;
379 Key::List::Iterator it; 388 Key::List::Iterator it;
380 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 389 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
381 if ( (*it) == (*itA)) { 390 if ( (*it) == (*itA)) {
382 found = true; 391 found = true;
383 break; 392 break;
384 393
385 } 394 }
386 } 395 }
387 if ( ! found ) { 396 if ( ! found ) {
388 mData->keys.append( *itA ); 397 mData->keys.append( *itA );
389 } 398 }
390 } 399 }
391 } 400 }
392 KABC::Address::List::Iterator addressIterA; 401 if ( isSubSet ) {
393 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 402 KABC::Address::List::Iterator addressIterA;
394 bool found = false; 403 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
395 KABC::Address::List::Iterator addressIter; 404 bool found = false;
396 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 405 KABC::Address::List::Iterator addressIter;
397 ++addressIter ) { 406 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
398 if ( (*addressIter) == (*addressIterA)) { 407 ++addressIter ) {
399 found = true; 408 if ( (*addressIter) == (*addressIterA)) {
400 (*addressIter).setType( (*addressIterA).type() ); 409 found = true;
401 break; 410 (*addressIter).setType( (*addressIterA).type() );
402 } 411 break;
412 }
403 413
404 } 414 }
405 if ( isSubSet && ! found ) { 415 if ( isSubSet && ! found ) {
406 mData->addresses.append( *addressIterA ); 416 mData->addresses.append( *addressIterA );
417 }
407 } 418 }
408 } 419 }
409 //qDebug("merge contact %s ", ad.uid().latin1()); 420 //qDebug("merge contact %s ", ad.uid().latin1());
410 setUid( ad.uid() ); 421 setUid( ad.uid() );
411 setRevision( ad.revision() ); 422 setRevision( ad.revision() );
412} 423}
413 424
414bool Addressee::removeVoice() 425bool Addressee::removeVoice()
415{ 426{
416 PhoneNumber::List phoneN = phoneNumbers(); 427 PhoneNumber::List phoneN = phoneNumbers();
417 PhoneNumber::List::Iterator phoneIt; 428 PhoneNumber::List::Iterator phoneIt;
418 bool found = false; 429 bool found = false;
419 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 430 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
420 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 431 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
421 if ((*phoneIt).type() - PhoneNumber::Voice ) { 432 if ((*phoneIt).type() - PhoneNumber::Voice ) {
422 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 433 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
423 insertPhoneNumber( (*phoneIt) ); 434 insertPhoneNumber( (*phoneIt) );
424 found = true; 435 found = true;
425 } 436 }
426 } 437 }
427 438
428 } 439 }
429 return found; 440 return found;
430} 441}
431 442
432bool Addressee::containsAdr(const Addressee& ad ) 443bool Addressee::containsAdr(const Addressee& ad )
433{ 444{
434 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 445 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
435 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 446 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
436 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 447 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
437 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 448 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
438 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 449 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
439 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 450 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
440 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 451 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
441 452
442 // compare phone numbers 453 // compare phone numbers
443 PhoneNumber::List phoneN = ad.phoneNumbers(); 454 PhoneNumber::List phoneN = ad.phoneNumbers();
444 PhoneNumber::List::Iterator phoneIt; 455 PhoneNumber::List::Iterator phoneIt;
445 bool found = false; 456 bool found = false;
446 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 457 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
447 bool found = false; 458 bool found = false;
448 PhoneNumber::List phoneL = ad.phoneNumbers(); 459 PhoneNumber::List phoneL = ad.phoneNumbers();
449 PhoneNumber::List::Iterator phoneItL; 460 PhoneNumber::List::Iterator phoneItL;
450 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 461 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
451 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 462 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
452 found = true; 463 found = true;
453 break; 464 break;
454 } 465 }
455 } 466 }
456 if ( ! found ) 467 if ( ! found )
457 return false; 468 return false;
458 } 469 }
459 return true; 470 return true;
460 471
461} 472}
462void Addressee::simplifyAddresses() 473void Addressee::simplifyAddresses()
463{ 474{
464 475
465 476
466 Address::List list; 477 Address::List list;
467 Address::List::Iterator it; 478 Address::List::Iterator it;
468 Address::List::Iterator it2; 479 Address::List::Iterator it2;
469 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 480 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
470 it2 = it; 481 it2 = it;
471 ++it2; 482 ++it2;
472 for( ; it2 != mData->addresses.end(); ++it2 ) { 483 for( ; it2 != mData->addresses.end(); ++it2 ) {
473 if ( (*it) == (*it2) ) { 484 if ( (*it) == (*it2) ) {
474 list.append( *it ); 485 list.append( *it );
475 break; 486 break;
476 } 487 }
477 } 488 }
478 } 489 }
479 for( it = list.begin(); it != list.end(); ++it ) { 490 for( it = list.begin(); it != list.end(); ++it ) {
480 removeAddress( (*it) ); 491 removeAddress( (*it) );
481 } 492 }
482 493
483 list.clear(); 494 list.clear();
484 int max = 2; 495 int max = 2;
485 if ( mData->url.isValid() ) 496 if ( mData->url.isValid() )
486 max = 1; 497 max = 1;
487 if ( mData->addresses.count() <= max ) return ; 498 if ( mData->addresses.count() <= max ) return ;
488 int count = 0; 499 int count = 0;
489 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 500 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
490 if ( count >= max ) 501 if ( count >= max )
491 list.append( *it ); 502 list.append( *it );
492 ++count; 503 ++count;
493 } 504 }
494 for( it = list.begin(); it != list.end(); ++it ) { 505 for( it = list.begin(); it != list.end(); ++it ) {
495 removeAddress( (*it) ); 506 removeAddress( (*it) );
496 } 507 }
497} 508}
498 509
499// removes all emails but the first 510// removes all emails but the first
500// needed by phone sync 511// needed by phone sync
501void Addressee::simplifyEmails() 512void Addressee::simplifyEmails()
502{ 513{
503 if ( mData->emails.count() == 0 ) return ; 514 if ( mData->emails.count() == 0 ) return ;
504 QString email = mData->emails.first(); 515 QString email = mData->emails.first();
505 detach(); 516 detach();
506 mData->emails.clear(); 517 mData->emails.clear();
507 mData->emails.append( email ); 518 mData->emails.append( email );
508} 519}
509 520
510void Addressee::simplifyPhoneNumbers() 521void Addressee::simplifyPhoneNumbers()
511{ 522{
512 int max = 4; 523 int max = 4;
513 int inList = mData->phoneNumbers.count(); 524 int inList = mData->phoneNumbers.count();
514 KABC::PhoneNumber::List removeNumbers; 525 KABC::PhoneNumber::List removeNumbers;
515 KABC::PhoneNumber::List::Iterator phoneIter; 526 KABC::PhoneNumber::List::Iterator phoneIter;
516 if ( inList > max ) { 527 if ( inList > max ) {
517 // delete non-preferred numbers 528 // delete non-preferred numbers
518 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 529 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
519 ++phoneIter ) { 530 ++phoneIter ) {
520 if ( inList > max ) { 531 if ( inList > max ) {
521 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 532 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
522 removeNumbers.append( ( *phoneIter ) ); 533 removeNumbers.append( ( *phoneIter ) );
523 --inList; 534 --inList;
524 } 535 }
525 } else 536 } else
526 break; 537 break;
527 } 538 }
528 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 539 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
529 ++phoneIter ) { 540 ++phoneIter ) {
530 removePhoneNumber(( *phoneIter )); 541 removePhoneNumber(( *phoneIter ));
531 } 542 }
532 // delete preferred numbers 543 // delete preferred numbers
533 if ( inList > max ) { 544 if ( inList > max ) {
534 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 545 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
535 ++phoneIter ) { 546 ++phoneIter ) {
536 if ( inList > max ) { 547 if ( inList > max ) {
537 removeNumbers.append( ( *phoneIter ) ); 548 removeNumbers.append( ( *phoneIter ) );
538 --inList; 549 --inList;
539 } else 550 } else
540 break; 551 break;
541 } 552 }
542 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 553 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
543 ++phoneIter ) { 554 ++phoneIter ) {
544 removePhoneNumber(( *phoneIter )); 555 removePhoneNumber(( *phoneIter ));
545 } 556 }
546 } 557 }
547 } 558 }
548 // remove non-numeric characters 559 // remove non-numeric characters
549 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 560 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
550 ++phoneIter ) { 561 ++phoneIter ) {
551 if ( ! ( *phoneIter ).simplifyNumber() ) 562 if ( ! ( *phoneIter ).simplifyNumber() )
552 removeNumbers.append( ( *phoneIter ) ); 563 removeNumbers.append( ( *phoneIter ) );
553 } 564 }
554 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 565 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
555 ++phoneIter ) { 566 ++phoneIter ) {
556 removePhoneNumber(( *phoneIter )); 567 removePhoneNumber(( *phoneIter ));
557 } 568 }
558} 569}
559void Addressee::simplifyPhoneNumberTypes() 570void Addressee::simplifyPhoneNumberTypes()
560{ 571{
561 KABC::PhoneNumber::List::Iterator phoneIter; 572 KABC::PhoneNumber::List::Iterator phoneIter;
562 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
563 ++phoneIter ) 574 ++phoneIter )
564 ( *phoneIter ).simplifyType(); 575 ( *phoneIter ).simplifyType();
565} 576}
566void Addressee::removeID(const QString &prof) 577void Addressee::removeID(const QString &prof)
567{ 578{
568 detach(); 579 detach();
569 if ( prof.isEmpty() ) 580 if ( prof.isEmpty() )
570 mData->mExternalId = ":"; 581 mData->mExternalId = ":";
571 else 582 else
572 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 583 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
573 584
574} 585}
575void Addressee::setID( const QString & prof , const QString & id ) 586void Addressee::setID( const QString & prof , const QString & id )
576{ 587{
577 detach(); 588 detach();
578 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 589 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
579 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 590 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
580} 591}
581void Addressee::setTempSyncStat( int id ) 592void Addressee::setTempSyncStat( int id )
582{ 593{
583 if ( mData->mTempSyncStat == id ) return; 594 if ( mData->mTempSyncStat == id ) return;
584 detach(); 595 detach();
585 mData->mTempSyncStat = id; 596 mData->mTempSyncStat = id;
586} 597}
587int Addressee::tempSyncStat() const 598int Addressee::tempSyncStat() const
588{ 599{
589 return mData->mTempSyncStat; 600 return mData->mTempSyncStat;
590} 601}
591 602
592const QString Addressee::getID( const QString & prof) const 603const QString Addressee::getID( const QString & prof) const
593{ 604{
594 return KIdManager::getId ( mData->mExternalId, prof ); 605 return KIdManager::getId ( mData->mExternalId, prof );
595} 606}
596 607
597void Addressee::setCsum( const QString & prof , const QString & id ) 608void Addressee::setCsum( const QString & prof , const QString & id )
598{ 609{
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
index ae4cfbb..8165b4c 100644
--- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
@@ -1,482 +1,486 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include "kglobal.h" 28#include "kglobal.h"
29#include <qregexp.h> 29#include <qregexp.h>
30 30
31 31
32#include "sharpdtmconverter.h" 32#include "sharpdtmconverter.h"
33 33
34#include <sl/slcategories.h> 34#include <sl/slcategories.h>
35#include <libkdepim/ksyncprofile.h> 35#include <libkdepim/ksyncprofile.h>
36//US #include <qpe/categoryselect.h> 36//US #include <qpe/categoryselect.h>
37 37
38 38
39using namespace KABC; 39using namespace KABC;
40using namespace SlCategory; 40using namespace SlCategory;
41 41
42SharpDTMConverter::SharpDTMConverter() : catDB(0) 42SharpDTMConverter::SharpDTMConverter() : catDB(0)
43{ 43{
44} 44}
45 45
46SharpDTMConverter::~SharpDTMConverter() 46SharpDTMConverter::~SharpDTMConverter()
47{ 47{
48 deinit(); 48 deinit();
49} 49}
50 50
51bool SharpDTMConverter::init() 51bool SharpDTMConverter::init()
52{ 52{
53 catDB = new SlCategory::SlCategories(); 53 catDB = new SlCategory::SlCategories();
54 54
55 if (!catDB) 55 if (!catDB)
56 return false; 56 return false;
57 57
58// catDB->load( categoryFileName() ); 58// catDB->load( categoryFileName() );
59 return true; 59 return true;
60} 60}
61 61
62void SharpDTMConverter::deinit() 62void SharpDTMConverter::deinit()
63{ 63{
64 if (catDB) 64 if (catDB)
65 { 65 {
66 delete catDB; 66 delete catDB;
67 catDB = 0; 67 catDB = 0;
68 } 68 }
69} 69}
70 70
71bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) 71bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr )
72{ 72{
73 SlZDataBase* db = (SlZDataBase*)database; 73 SlZDataBase* db = (SlZDataBase*)database;
74 74
75 // for syncing: we need setting of the two fields 75 // for syncing: we need setting of the two fields
76 addr.setExternalUID( QString::number( contact ) ); 76 addr.setExternalUID( QString::number( contact ) );
77 addr.setOriginalExternalUID( QString::number( contact ) ); 77 addr.setOriginalExternalUID( QString::number( contact ) );
78 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 78 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
79 79
80 80
81 // name 81 // name
82 //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); 82 //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!");
83 addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix 83 addr.setFormattedName(db->readField(ZdbAdrs::FileAs));
84 addr.setName(db->readField(ZdbAdrs::FullName));
84 85
85 addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); 86 addr.setFamilyName( db->readField(ZdbAdrs::LastName) );
86 addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); 87 addr.setGivenName( db->readField(ZdbAdrs::FirstName) );
87 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); 88 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) );
88 addr.setPrefix( db->readField(ZdbAdrs::Title) ); 89 addr.setPrefix( db->readField(ZdbAdrs::Title) );
89 addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); 90 addr.setSuffix( db->readField(ZdbAdrs::Suffix) );
90 91
91 92
92 QString emailstr = db->readField(ZdbAdrs::Emails); 93 QString emailstr = db->readField(ZdbAdrs::Emails);
93 emailstr.replace( QRegExp(","), " " ); 94 emailstr.replace( QRegExp(","), " " );
94 emailstr.replace( QRegExp(";"), " " ); 95 emailstr.replace( QRegExp(";"), " " );
95 emailstr.replace( QRegExp(":"), " " ); 96 emailstr.replace( QRegExp(":"), " " );
96 //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); 97 //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1());
97 QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); 98 QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace());
98 bool defE = false; 99 bool defE = false;
99 bool found = false; 100 bool found = false;
100 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 101 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
101 if (found ) 102 if (found )
102 defE = false; 103 defE = false;
103 else 104 else
104 found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); 105 found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower());
105 addr.insertEmail( *it, defE ); 106 addr.insertEmail( *it, defE );
106 } 107 }
107 if ( ! found ) 108 if ( ! found )
108 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) 109 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty())
109 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); 110 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true);
110 111
111 // home 112 // home
112 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || 113 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) ||
113 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || 114 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) ||
114 (!db->readField(ZdbAdrs::HomeState).isEmpty()) || 115 (!db->readField(ZdbAdrs::HomeState).isEmpty()) ||
115 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || 116 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) ||
116 (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) 117 (!db->readField(ZdbAdrs::HomeCountry).isEmpty()))
117 { 118 {
118 Address homeaddress; 119 Address homeaddress;
119 homeaddress.setType(Address::Home); 120 homeaddress.setType(Address::Home);
120//US homeaddress.setPostOfficeBox( "" ); 121//US homeaddress.setPostOfficeBox( "" );
121//US homeaddress.setExtended( "" ); 122//US homeaddress.setExtended( "" );
122 homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), "")); 123 homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), ""));
123 homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); 124 homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) );
124 homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); 125 homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) );
125 homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); 126 homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) );
126 homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); 127 homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) );
127 128
128 addr.insertAddress( homeaddress ); 129 addr.insertAddress( homeaddress );
129 } 130 }
130 131
131 if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) 132 if (!db->readField(ZdbAdrs::HomePhone).isEmpty())
132 { 133 {
133 PhoneNumber homephone; 134 PhoneNumber homephone;
134 homephone.setType( PhoneNumber::Home ); 135 homephone.setType( PhoneNumber::Home );
135 homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); 136 homephone.setNumber( db->readField(ZdbAdrs::HomePhone) );
136 addr.insertPhoneNumber( homephone ); 137 addr.insertPhoneNumber( homephone );
137 } 138 }
138 139
139 if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) 140 if (!db->readField(ZdbAdrs::HomeFax).isEmpty())
140 { 141 {
141 PhoneNumber homefax; 142 PhoneNumber homefax;
142 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 143 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
143 homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); 144 homefax.setNumber( db->readField(ZdbAdrs::HomeFax) );
144 addr.insertPhoneNumber( homefax ); 145 addr.insertPhoneNumber( homefax );
145 } 146 }
146 147
147 if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) 148 if (!db->readField(ZdbAdrs::HomeMobile).isEmpty())
148 { 149 {
149 PhoneNumber homemobile; 150 PhoneNumber homemobile;
150 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 151 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
151 homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); 152 homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) );
152 addr.insertPhoneNumber( homemobile ); 153 addr.insertPhoneNumber( homemobile );
153 } 154 }
154 155
155 addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); 156 addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) );
156 157
157 158
158 // business 159 // business
159 if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || 160 if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) ||
160 (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || 161 (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) ||
161 (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || 162 (!db->readField(ZdbAdrs::BusinessState).isEmpty()) ||
162 (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || 163 (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) ||
163 (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) 164 (!db->readField(ZdbAdrs::BusinessCountry).isEmpty()))
164 { 165 {
165 Address businessaddress; 166 Address businessaddress;
166 businessaddress.setType(Address::Work); 167 businessaddress.setType(Address::Work);
167//US businessaddress.setPostOfficeBox( "" ); 168//US businessaddress.setPostOfficeBox( "" );
168//US businessaddress.setExtended( "" ); 169//US businessaddress.setExtended( "" );
169 businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet).replace( QRegExp("\\r"), "") ); 170 businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet).replace( QRegExp("\\r"), "") );
170 businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); 171 businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) );
171 businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); 172 businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) );
172 businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); 173 businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) );
173 businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); 174 businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) );
174 175
175 addr.insertAddress( businessaddress ); 176 addr.insertAddress( businessaddress );
176 } 177 }
177 178
178 179
179 if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) 180 if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty())
180 { 181 {
181 PhoneNumber businessphone; 182 PhoneNumber businessphone;
182 businessphone.setType( PhoneNumber::Work ); 183 businessphone.setType( PhoneNumber::Work );
183 businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); 184 businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) );
184 addr.insertPhoneNumber( businessphone ); 185 addr.insertPhoneNumber( businessphone );
185 } 186 }
186 187
187 if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) 188 if (!db->readField(ZdbAdrs::BusinessFax).isEmpty())
188 { 189 {
189 PhoneNumber businessfax; 190 PhoneNumber businessfax;
190 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 191 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
191 businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); 192 businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) );
192 addr.insertPhoneNumber( businessfax ); 193 addr.insertPhoneNumber( businessfax );
193 } 194 }
194 195
195 if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) 196 if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty())
196 { 197 {
197 PhoneNumber businessmobile; 198 PhoneNumber businessmobile;
198 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 199 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
199 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); 200 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) );
200 addr.insertPhoneNumber( businessmobile ); 201 addr.insertPhoneNumber( businessmobile );
201 } 202 }
202 203
203 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) 204 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty())
204 { 205 {
205 PhoneNumber businesspager; 206 PhoneNumber businesspager;
206 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 207 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
207 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); 208 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) );
208 addr.insertPhoneNumber( businesspager ); 209 addr.insertPhoneNumber( businesspager );
209 } 210 }
210 211
211 addr.setRole( db->readField(ZdbAdrs::JobTitle) ); 212 addr.setRole( db->readField(ZdbAdrs::JobTitle) );
212 addr.setOrganization( db->readField(ZdbAdrs::Company) ); 213 addr.setOrganization( db->readField(ZdbAdrs::Company) );
213 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); 214 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) );
214 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); 215 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) );
215 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); 216 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) );
216 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); 217 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) );
217 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); 218 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) );
218 219
219 //personal 220 //personal
220 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); 221 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) );
221 222
222 QString gen = db->readField(ZdbAdrs::Gender); 223 QString gen = db->readField(ZdbAdrs::Gender);
223 //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); 224 //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1());
224 //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); 225 //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited");
225 226 if (gen == "1")
226 if (gen == "male")
227 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 227 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
228 else if (gen == "female") 228 else if (gen == "2")
229 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 229 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
230 else
231 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef");
230 232
231 233
232 QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); 234 QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) );
233 if (ann.isValid()) { 235 if (ann.isValid()) {
234 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); 236 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
235 //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); 237 //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1());
236 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 238 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
237 } 239 } else
240 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " ");
241
238 242
239 243
240 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); 244 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) );
241 245
242 246
243 QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); 247 QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) );
244 //qDebug("birtd %s ", birthd.toString().latin1()); 248 //qDebug("birtd %s ", birthd.toString().latin1());
245 if (birthd.isValid()) 249 if (birthd.isValid())
246 addr.setBirthday( birthd ); 250 addr.setBirthday( birthd );
247 251
248 addr.setNickName( db->readField(ZdbAdrs::Nickname) ); 252 addr.setNickName( db->readField(ZdbAdrs::Nickname) );
249 253
250 // others 254 // others
251 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 255 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
252 //QString notes = db->readField(ZdbAdrs::Notes); 256 //QString notes = db->readField(ZdbAdrs::Notes);
253 //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; 257 //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n";
254 if ( addr.url().isEmpty() ) 258 if ( addr.url().isEmpty() )
255 addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); 259 addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) );
256 addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); 260 addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), ""));
257 261
258 262
259 263
260//US QString groups() const { return find( Qtopia::Groups ); } 264//US QString groups() const { return find( Qtopia::Groups ); }
261//US QStringList groupList() const; 265//US QStringList groupList() const;
262 266
263 //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); 267 //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" );
264 QArray<int> catArray = db->readCategories(); 268 QArray<int> catArray = db->readCategories();
265 QString cat; 269 QString cat;
266 270
267 for ( unsigned int i=0; i < catArray.size(); i++ ) { 271 for ( unsigned int i=0; i < catArray.size(); i++ ) {
268 cat = catDB->label(catArray[i]); 272 cat = catDB->label(catArray[i]);
269 if ( cat.isEmpty() ) 273 if ( cat.isEmpty() )
270 addr.insertCategory(QString::number(catArray[i])); 274 addr.insertCategory(QString::number(catArray[i]));
271 else 275 else
272 addr.insertCategory( cat ); 276 addr.insertCategory( cat );
273 } 277 }
274 278
275 return true; 279 return true;
276} 280}
277 281
278bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) 282bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact )
279{ 283{
280 bool cellHome = false, cellWork = false; 284 bool cellHome = false, cellWork = false;
281 // name 285 // name
282 database->writeField(ZdbAdrs::LastName, addr.familyName()); 286 database->writeField(ZdbAdrs::LastName, addr.familyName());
283 database->writeField(ZdbAdrs::FirstName, addr.givenName()); 287 database->writeField(ZdbAdrs::FirstName, addr.givenName());
284 database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); 288 database->writeField(ZdbAdrs::MiddleName, addr.additionalName());
285 database->writeField(ZdbAdrs::Title, addr.prefix()); 289 database->writeField(ZdbAdrs::Title, addr.prefix());
286 database->writeField(ZdbAdrs::Suffix, addr.suffix()); 290 database->writeField(ZdbAdrs::Suffix, addr.suffix());
287 291
288 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); 292 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() );
289 QString formattedName = addr.formattedName(); 293 QString formattedName = addr.formattedName();
290 if ( formattedName.isEmpty() ) { 294 if ( formattedName.isEmpty() ) {
291 if ( !addr.familyName().isEmpty() ) { 295 if ( !addr.familyName().isEmpty() ) {
292 formattedName = addr.familyName(); 296 formattedName = addr.familyName();
293 if ( !addr.givenName().isEmpty() ) { 297 if ( !addr.givenName().isEmpty() ) {
294 formattedName += ", "; 298 formattedName += ", ";
295 formattedName += addr.givenName(); 299 formattedName += addr.givenName();
296 } 300 }
297 } else 301 } else
298 formattedName = addr.givenName(); 302 formattedName = addr.givenName();
299 } 303 }
300 database->writeField(ZdbAdrs::FileAs, formattedName); 304 database->writeField(ZdbAdrs::FileAs, formattedName);
301 database->writeField(ZdbAdrs::FullName, formattedName); 305 database->writeField(ZdbAdrs::FullName, addr.name());
302 306
303 // email 307 // email
304 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); 308 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
305 //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); 309 //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee");
306 QString emails = addr.emails().join(" "); 310 QString emails = addr.emails().join(" ");
307 database->writeField(ZdbAdrs::Emails, emails ); 311 database->writeField(ZdbAdrs::Emails, emails );
308 312
309 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); 313 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() );
310 // home 314 // home
311 const Address homeaddress = addr.address(Address::Home); 315 const Address homeaddress = addr.address(Address::Home);
312 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); 316 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street());
313 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); 317 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality());
314 database->writeField(ZdbAdrs::HomeState, homeaddress.region()); 318 database->writeField(ZdbAdrs::HomeState, homeaddress.region());
315 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); 319 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode());
316 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); 320 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country());
317 321
318 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 322 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
319 database->writeField(ZdbAdrs::HomePhone, homephone.number()); 323 database->writeField(ZdbAdrs::HomePhone, homephone.number());
320 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 324 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
321 database->writeField(ZdbAdrs::HomeFax, homefax.number()); 325 database->writeField(ZdbAdrs::HomeFax, homefax.number());
322 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 326 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
323 database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); 327 database->writeField(ZdbAdrs::HomeMobile, homemobile.number());
324 if (!homemobile.number().isEmpty()) { 328 if (!homemobile.number().isEmpty()) {
325 cellHome = true; 329 cellHome = true;
326 } 330 }
327 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); 331 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url());
328 // business 332 // business
329 const Address businessaddress = addr.address(Address::Work); 333 const Address businessaddress = addr.address(Address::Work);
330 //qDebug("write business address "); 334 //qDebug("write business address ");
331 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); 335 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street());
332 database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); 336 database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality());
333 database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); 337 database->writeField(ZdbAdrs::BusinessState, businessaddress.region());
334 database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); 338 database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode());
335 database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); 339 database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country());
336 340
337 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 341 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
338 database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); 342 database->writeField(ZdbAdrs::BusinessPhone, businessphone.number());
339 343
340 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 344 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
341 database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); 345 database->writeField(ZdbAdrs::BusinessFax, businessfax.number());
342 346
343 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 347 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
344 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); 348 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number());
345 if (!businessmobile.number().isEmpty()) { 349 if (!businessmobile.number().isEmpty()) {
346 cellWork = true; 350 cellWork = true;
347 } 351 }
348 PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); 352 PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell );
349 if (! mobile.number().isEmpty()) { 353 if (! mobile.number().isEmpty()) {
350 if ( ! cellHome ) 354 if ( ! cellHome )
351 database->writeField(ZdbAdrs::HomeMobile, mobile.number()); 355 database->writeField(ZdbAdrs::HomeMobile, mobile.number());
352 else if (! cellWork ) 356 else if (! cellWork )
353 database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); 357 database->writeField(ZdbAdrs::BusinessMobile, mobile.number());
354 } 358 }
355 359
356 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 360 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
357 database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); 361 database->writeField(ZdbAdrs::BusinessPager, businesspager.number());
358 362
359 database->writeField(ZdbAdrs::JobTitle, addr.role()); 363 database->writeField(ZdbAdrs::JobTitle, addr.role());
360 database->writeField(ZdbAdrs::Company, addr.organization()); 364 database->writeField(ZdbAdrs::Company, addr.organization());
361 365
362 database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); 366 database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" ));
363 database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 367 database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
364 database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); 368 database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" ));
365 database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 369 database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
366 database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); 370 database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" ));
367 371
368 //personal 372 //personal
369 database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); 373 database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" ));
370 374
371 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); 375 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
372 //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); 376 //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1());
373 //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); 377 //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?");
374 //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); 378 //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee");
375 if (gt == "male") 379 if (gt == "male")
376 database->writeField(ZdbAdrs::Gender, "male"); 380 database->writeField(ZdbAdrs::Gender, "1");
377 else if (gt == "female") 381 else if (gt == "female")
378 database->writeField(ZdbAdrs::Gender, "female"); 382 database->writeField(ZdbAdrs::Gender, "2");
379 else 383 else
380 database->writeField(ZdbAdrs::Gender, ""); 384 database->writeField(ZdbAdrs::Gender, "");
381 385
382 QString dateS ; 386 QString dateS ;
383 QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 387 QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
384 if ( dt.isValid() ) { 388 if ( dt.isValid() ) {
385 dateS = KGlobal::locale()->formatDate(dt, true ); 389 dateS = KGlobal::locale()->formatDate(dt, true );
386 } 390 }
387 database->writeField(ZdbAdrs::Anniversary, dateS ); 391 database->writeField(ZdbAdrs::Anniversary, dateS );
388 database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); 392 database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" ));
389 dt = addr.birthday().date(); 393 dt = addr.birthday().date();
390 dateS = ""; 394 dateS = "";
391 if ( dt.isValid() ) { 395 if ( dt.isValid() ) {
392 dateS = KGlobal::locale()->formatDate(dt, true ); 396 dateS = KGlobal::locale()->formatDate(dt, true );
393 } 397 }
394 database->writeField(ZdbAdrs::Birthday, dateS); 398 database->writeField(ZdbAdrs::Birthday, dateS);
395 database->writeField(ZdbAdrs::Nickname, addr.nickName()); 399 database->writeField(ZdbAdrs::Nickname, addr.nickName());
396 400
397 // other 401 // other
398 database->writeField(ZdbAdrs::Notes, addr.note()); 402 database->writeField(ZdbAdrs::Notes, addr.note());
399 403
400//US QString groups() const { return find( Qtopia::Groups ); } 404//US QString groups() const { return find( Qtopia::Groups ); }
401//US QStringList groupList() const; 405//US QStringList groupList() const;
402 406
403 407
404 //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); 408 //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works");
405 409
406 return true; 410 return true;
407} 411}
408 412
409 413
410bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) 414bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact )
411{ 415{
412 QStringList list = addr.categories(); 416 QStringList list = addr.categories();
413 417
414 QArray<int> ids(list.count()); 418 QArray<int> ids(list.count());
415 uint index = 0; 419 uint index = 0;
416 for(uint i=0; i<ids.size(); i++){ 420 for(uint i=0; i<ids.size(); i++){
417 if(catDB->exists(list[i])){ 421 if(catDB->exists(list[i])){
418 ids[index] = catDB->id(list[i]); 422 ids[index] = catDB->id(list[i]);
419 qDebug("set ex cat %d %s ",ids[index] , list[i].latin1()); 423 qDebug("set ex cat %d %s ",ids[index] , list[i].latin1());
420 index++; 424 index++;
421 } else { 425 } else {
422 ids[index] = catDB->addCategory(list[i]); 426 ids[index] = catDB->addCategory(list[i]);
423 qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); 427 qDebug("add new cat %d %s ",ids[index] , list[i].latin1());
424 index++; 428 index++;
425 } 429 }
426 } 430 }
427 bool res ; 431 bool res ;
428 if ( res = database->updateCategories(contact, ids) ) 432 if ( res = database->updateCategories(contact, ids) )
429 qDebug("cat updated "); 433 qDebug("cat updated ");
430 else 434 else
431 qDebug("error cat updating "); 435 qDebug("error cat updating ");
432 436
433 return res; 437 return res;
434} 438}
435 439
436#if 0 440#if 0
437 m_pCategories = new SlCategories; 441 m_pCategories = new SlCategories;
438catDB 442catDB
439 443
440 if(categories == QString::null) return true; 444 if(categories == QString::null) return true;
441 QStringList list = CSVParser::parse(categories); 445 QStringList list = CSVParser::parse(categories);
442 QArray<int> ids(list.count()); 446 QArray<int> ids(list.count());
443 uint index = 0; 447 uint index = 0;
444 for(uint i=0; i<ids.size(); i++){ 448 for(uint i=0; i<ids.size(); i++){
445#if 0 449#if 0
446 bool ok; 450 bool ok;
447 ids[index] = list[i].toInt(&ok); 451 ids[index] = list[i].toInt(&ok);
448 if(ok){ 452 if(ok){
449 index++; 453 index++;
450 } else { 454 } else {
451 if(m_pCategories->exists(list[i])){ 455 if(m_pCategories->exists(list[i])){
452 ids[index] = m_pCategories->id(list[i]); 456 ids[index] = m_pCategories->id(list[i]);
453 index++; 457 index++;
454 } 458 }
455 } 459 }
456#else 460#else
457 if(m_pCategories->exists(list[i])){ 461 if(m_pCategories->exists(list[i])){
458 ids[index] = m_pCategories->id(list[i]); 462 ids[index] = m_pCategories->id(list[i]);
459 index++; 463 index++;
460 } else if(m_addCategory){ 464 } else if(m_addCategory){
461 ids[index] = m_pCategories->addCategory(list[i]); 465 ids[index] = m_pCategories->addCategory(list[i]);
462 index++; 466 index++;
463 } 467 }
464#endif 468#endif
465 } 469 }
466 if(ids.size() > 0 && index == 0){ 470 if(ids.size() > 0 && index == 0){
467 return true; 471 return true;
468 } else if(index != ids.size()){ 472 } else if(index != ids.size()){
469 ids.resize(index); 473 ids.resize(index);
470 } 474 }
471 if(!m_pZdb->updateCategories(id, ids)){ 475 if(!m_pZdb->updateCategories(id, ids)){
472 return false; 476 return false;
473 } 477 }
474 return true; 478 return true;
475#endif 479#endif
476 480
477QDate SharpDTMConverter::convertDate( QString s) 481QDate SharpDTMConverter::convertDate( QString s)
478{ 482{
479 QDate dt = KGlobal::locale()->readDate( s ); 483 QDate dt = KGlobal::locale()->readDate( s );
480 return dt; 484 return dt;
481 return QDate (); 485 return QDate ();
482} 486}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 42e147f..d970ff1 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2164,395 +2164,405 @@ void KABCore::addActionsManually()
2164#endif 2164#endif
2165#if 0 2165#if 0
2166 // PENDING fix MailVCard 2166 // PENDING fix MailVCard
2167 fileMenu->insertSeparator(); 2167 fileMenu->insertSeparator();
2168 mActionMailVCard->plug( fileMenu ); 2168 mActionMailVCard->plug( fileMenu );
2169#endif 2169#endif
2170#ifndef DESKTOP_VERSION 2170#ifndef DESKTOP_VERSION
2171 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2171 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2174#endif 2174#endif
2175 fileMenu->insertSeparator(); 2175 fileMenu->insertSeparator();
2176 mActionQuit->plug( fileMenu ); 2176 mActionQuit->plug( fileMenu );
2177#ifdef _WIN32_ 2177#ifdef _WIN32_
2178 mActionImportOL->plug( ImportMenu ); 2178 mActionImportOL->plug( ImportMenu );
2179#endif 2179#endif
2180 // edit menu 2180 // edit menu
2181 mActionUndo->plug( editMenu ); 2181 mActionUndo->plug( editMenu );
2182 mActionRedo->plug( editMenu ); 2182 mActionRedo->plug( editMenu );
2183 editMenu->insertSeparator(); 2183 editMenu->insertSeparator();
2184 mActionCut->plug( editMenu ); 2184 mActionCut->plug( editMenu );
2185 mActionCopy->plug( editMenu ); 2185 mActionCopy->plug( editMenu );
2186 mActionPaste->plug( editMenu ); 2186 mActionPaste->plug( editMenu );
2187 mActionDelete->plug( editMenu ); 2187 mActionDelete->plug( editMenu );
2188 editMenu->insertSeparator(); 2188 editMenu->insertSeparator();
2189 mActionSelectAll->plug( editMenu ); 2189 mActionSelectAll->plug( editMenu );
2190 2190
2191 mActionSetFormattedName->plug( changeMenu ); 2191 mActionSetFormattedName->plug( changeMenu );
2192 mActionRemoveVoice->plug( changeMenu ); 2192 mActionRemoveVoice->plug( changeMenu );
2193 // settings menu 2193 // settings menu
2194//US special menuentry to configure the addressbook resources. On KDE 2194//US special menuentry to configure the addressbook resources. On KDE
2195// you do that through the control center !!! 2195// you do that through the control center !!!
2196 mActionConfigResources->plug( settingsMenu ); 2196 mActionConfigResources->plug( settingsMenu );
2197 settingsMenu->insertSeparator(); 2197 settingsMenu->insertSeparator();
2198 2198
2199 mActionConfigKAddressbook->plug( settingsMenu ); 2199 mActionConfigKAddressbook->plug( settingsMenu );
2200 2200
2201 if ( mIsPart ) { 2201 if ( mIsPart ) {
2202 //US not implemented yet 2202 //US not implemented yet
2203 //mActionConfigShortcuts->plug( settingsMenu ); 2203 //mActionConfigShortcuts->plug( settingsMenu );
2204 //mActionConfigureToolbars->plug( settingsMenu ); 2204 //mActionConfigureToolbars->plug( settingsMenu );
2205 2205
2206 } else { 2206 } else {
2207 //US not implemented yet 2207 //US not implemented yet
2208 //mActionKeyBindings->plug( settingsMenu ); 2208 //mActionKeyBindings->plug( settingsMenu );
2209 } 2209 }
2210 2210
2211 settingsMenu->insertSeparator(); 2211 settingsMenu->insertSeparator();
2212 2212
2213 mActionJumpBar->plug( settingsMenu ); 2213 mActionJumpBar->plug( settingsMenu );
2214 mActionDetails->plug( settingsMenu ); 2214 mActionDetails->plug( settingsMenu );
2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2216 mActionDetails->plug( tb ); 2216 mActionDetails->plug( tb );
2217 settingsMenu->insertSeparator(); 2217 settingsMenu->insertSeparator();
2218#ifndef DESKTOP_VERSION 2218#ifndef DESKTOP_VERSION
2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2220#endif 2220#endif
2221 settingsMenu->insertSeparator(); 2221 settingsMenu->insertSeparator();
2222 2222
2223 mActionWhoAmI->plug( settingsMenu ); 2223 mActionWhoAmI->plug( settingsMenu );
2224 mActionEditCategories->plug( settingsMenu ); 2224 mActionEditCategories->plug( settingsMenu );
2225 mActionEditCategories->plug( changeMenu ); 2225 mActionEditCategories->plug( changeMenu );
2226 mActionCategories->plug( changeMenu ); 2226 mActionCategories->plug( changeMenu );
2227 mActionManageCategories->plug( changeMenu ); 2227 mActionManageCategories->plug( changeMenu );
2228 2228
2229 mActionCategories->plug( settingsMenu ); 2229 mActionCategories->plug( settingsMenu );
2230 mActionManageCategories->plug( settingsMenu ); 2230 mActionManageCategories->plug( settingsMenu );
2231 2231
2232 2232
2233 mActionWN->plug( helpMenu ); 2233 mActionWN->plug( helpMenu );
2234 mActionSyncHowto->plug( helpMenu ); 2234 mActionSyncHowto->plug( helpMenu );
2235 mActionKdeSyncHowto->plug( helpMenu ); 2235 mActionKdeSyncHowto->plug( helpMenu );
2236 mActionMultiSyncHowto->plug( helpMenu ); 2236 mActionMultiSyncHowto->plug( helpMenu );
2237 mActionFaq->plug( helpMenu ); 2237 mActionFaq->plug( helpMenu );
2238 mActionLicence->plug( helpMenu ); 2238 mActionLicence->plug( helpMenu );
2239 mActionAboutKAddressbook->plug( helpMenu ); 2239 mActionAboutKAddressbook->plug( helpMenu );
2240 2240
2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2242 2242
2243 mActionSave->plug( tb ); 2243 mActionSave->plug( tb );
2244 mViewManager->getFilterAction()->plug ( tb); 2244 mViewManager->getFilterAction()->plug ( tb);
2245 //LR hide filteraction on started in 480x640 2245 //LR hide filteraction on started in 480x640
2246 if (QApplication::desktop()->width() == 480 ) { 2246 if (QApplication::desktop()->width() == 480 ) {
2247 mViewManager->getFilterAction()->setComboWidth( 0 ); 2247 mViewManager->getFilterAction()->setComboWidth( 0 );
2248 } 2248 }
2249 mActionUndo->plug( tb ); 2249 mActionUndo->plug( tb );
2250 mActionDelete->plug( tb ); 2250 mActionDelete->plug( tb );
2251 mActionRedo->plug( tb ); 2251 mActionRedo->plug( tb );
2252 } else { 2252 } else {
2253 mActionSave->plug( tb ); 2253 mActionSave->plug( tb );
2254 tb->enableMoving(false); 2254 tb->enableMoving(false);
2255 } 2255 }
2256 //mActionQuit->plug ( tb ); 2256 //mActionQuit->plug ( tb );
2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2258 2258
2259 //US link the searchwidget first to this. 2259 //US link the searchwidget first to this.
2260 // The real linkage to the toolbar happens later. 2260 // The real linkage to the toolbar happens later.
2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2262//US tb->insertItem( mIncSearchWidget ); 2262//US tb->insertItem( mIncSearchWidget );
2263/*US 2263/*US
2264 mIncSearchWidget = new IncSearchWidget( tb ); 2264 mIncSearchWidget = new IncSearchWidget( tb );
2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2266 SLOT( incrementalSearch( const QString& ) ) ); 2266 SLOT( incrementalSearch( const QString& ) ) );
2267 2267
2268 mJumpButtonBar = new JumpButtonBar( this, this ); 2268 mJumpButtonBar = new JumpButtonBar( this, this );
2269 2269
2270//US topLayout->addWidget( mJumpButtonBar ); 2270//US topLayout->addWidget( mJumpButtonBar );
2271 this->layout()->add( mJumpButtonBar ); 2271 this->layout()->add( mJumpButtonBar );
2272*/ 2272*/
2273 2273
2274#endif //KAB_EMBEDDED 2274#endif //KAB_EMBEDDED
2275 2275
2276 mActionExport2phone->plug( ExportMenu ); 2276 mActionExport2phone->plug( ExportMenu );
2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2278 syncManager->fillSyncMenu(); 2278 syncManager->fillSyncMenu();
2279 2279
2280} 2280}
2281void KABCore::showLicence() 2281void KABCore::showLicence()
2282{ 2282{
2283 KApplication::showLicence(); 2283 KApplication::showLicence();
2284} 2284}
2285 2285
2286void KABCore::manageCategories( ) 2286void KABCore::manageCategories( )
2287{ 2287{
2288 KABCatPrefs* cp = new KABCatPrefs(); 2288 KABCatPrefs* cp = new KABCatPrefs();
2289 cp->show(); 2289 cp->show();
2290 int w =cp->sizeHint().width() ; 2290 int w =cp->sizeHint().width() ;
2291 int h = cp->sizeHint().height() ; 2291 int h = cp->sizeHint().height() ;
2292 int dw = QApplication::desktop()->width(); 2292 int dw = QApplication::desktop()->width();
2293 int dh = QApplication::desktop()->height(); 2293 int dh = QApplication::desktop()->height();
2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2295 if ( !cp->exec() ) { 2295 if ( !cp->exec() ) {
2296 delete cp; 2296 delete cp;
2297 return; 2297 return;
2298 } 2298 }
2299 int count = 0; 2299 int count = 0;
2300 int cc = 0; 2300 int cc = 0;
2301 message( i18n("Please wait, processing categories...")); 2301 message( i18n("Please wait, processing categories..."));
2302 if ( cp->addCat() ) { 2302 if ( cp->addCat() ) {
2303 KABC::AddressBook::Iterator it; 2303 KABC::AddressBook::Iterator it;
2304 QStringList catList = KABPrefs::instance()->mCustomCategories; 2304 QStringList catList = KABPrefs::instance()->mCustomCategories;
2305 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2305 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2306 ++cc; 2306 ++cc;
2307 if ( cc %10 == 0) 2307 if ( cc %10 == 0)
2308 message(i18n("Processing contact #%1").arg(cc)); 2308 message(i18n("Processing contact #%1").arg(cc));
2309 QStringList catIncList = (*it).categories(); 2309 QStringList catIncList = (*it).categories();
2310 int i; 2310 int i;
2311 for( i = 0; i< catIncList.count(); ++i ) { 2311 for( i = 0; i< catIncList.count(); ++i ) {
2312 if ( !catList.contains (catIncList[i])) { 2312 if ( !catList.contains (catIncList[i])) {
2313 catList.append( catIncList[i] ); 2313 catList.append( catIncList[i] );
2314 //qDebug("add cat %s ", catIncList[i].latin1()); 2314 //qDebug("add cat %s ", catIncList[i].latin1());
2315 ++count; 2315 ++count;
2316 } 2316 }
2317 } 2317 }
2318 } 2318 }
2319 catList.sort(); 2319 catList.sort();
2320 KABPrefs::instance()->mCustomCategories = catList; 2320 KABPrefs::instance()->mCustomCategories = catList;
2321 KABPrefs::instance()->writeConfig(); 2321 KABPrefs::instance()->writeConfig();
2322 message(QString::number( count )+ i18n(" categories added to list! ")); 2322 message(QString::number( count )+ i18n(" categories added to list! "));
2323 } else { 2323 } else {
2324 QStringList catList = KABPrefs::instance()->mCustomCategories; 2324 QStringList catList = KABPrefs::instance()->mCustomCategories;
2325 QStringList catIncList; 2325 QStringList catIncList;
2326 QStringList newCatList; 2326 QStringList newCatList;
2327 KABC::AddressBook::Iterator it; 2327 KABC::AddressBook::Iterator it;
2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2329 ++cc; 2329 ++cc;
2330 if ( cc %10 == 0) 2330 if ( cc %10 == 0)
2331 message(i18n("Processing contact #%1").arg(cc)); 2331 message(i18n("Processing contact #%1").arg(cc));
2332 QStringList catIncList = (*it).categories(); 2332 QStringList catIncList = (*it).categories();
2333 int i; 2333 int i;
2334 if ( catIncList.count() ) { 2334 if ( catIncList.count() ) {
2335 newCatList.clear(); 2335 newCatList.clear();
2336 for( i = 0; i< catIncList.count(); ++i ) { 2336 for( i = 0; i< catIncList.count(); ++i ) {
2337 if ( catList.contains (catIncList[i])) { 2337 if ( catList.contains (catIncList[i])) {
2338 newCatList.append( catIncList[i] ); 2338 newCatList.append( catIncList[i] );
2339 } 2339 }
2340 } 2340 }
2341 newCatList.sort(); 2341 newCatList.sort();
2342 (*it).setCategories( newCatList ); 2342 (*it).setCategories( newCatList );
2343 mAddressBook->insertAddressee( (*it) ); 2343 mAddressBook->insertAddressee( (*it) );
2344 } 2344 }
2345 } 2345 }
2346 setModified( true ); 2346 setModified( true );
2347 mViewManager->refreshView(); 2347 mViewManager->refreshView();
2348 message( i18n("Removing categories done!")); 2348 message( i18n("Removing categories done!"));
2349 } 2349 }
2350 delete cp; 2350 delete cp;
2351} 2351}
2352void KABCore::removeVoice() 2352void KABCore::removeVoice()
2353{ 2353{
2354 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2354 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2355 return; 2355 return;
2356 KABC::Addressee::List list;
2357 XXPortSelectDialog dlg( this, false, this ); 2356 XXPortSelectDialog dlg( this, false, this );
2358 if ( dlg.exec() ) 2357 if ( !dlg.exec() )
2359 list = dlg.contacts();
2360 else
2361 return; 2358 return;
2362 KABC::Addressee::List::Iterator it; 2359 mAddressBook->setUntagged();
2363 for ( it = list.begin(); it != list.end(); ++it ) { 2360 dlg.tagSelected();
2364 if ( (*it).removeVoice() ) 2361 message(i18n("Removing voice..."), false );
2365 addrModified((*it), false ); 2362 KABC::AddressBook::Iterator it;
2363 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2364 if ( (*it).tagged() ) {
2365 (*it).removeVoice();
2366 }
2366 } 2367 }
2368 message(i18n("Refreshing view...") );
2369 qApp->processEvents();
2370 mViewManager->refreshView( "" );
2371 Addressee add;
2372 mDetails->setAddressee( add );
2373 message(i18n("Remove voice completed!") );
2374
2375
2376
2367} 2377}
2368 2378
2369void KABCore::setFormattedName() 2379void KABCore::setFormattedName()
2370{ 2380{
2371 KABFormatPrefs setpref; 2381 KABFormatPrefs setpref;
2372 if ( !setpref.exec() ) { 2382 if ( !setpref.exec() ) {
2373 return; 2383 return;
2374 } 2384 }
2375 XXPortSelectDialog dlg( this, false, this ); 2385 XXPortSelectDialog dlg( this, false, this );
2376 if ( !dlg.exec() ) 2386 if ( !dlg.exec() )
2377 return; 2387 return;
2378 mAddressBook->setUntagged(); 2388 mAddressBook->setUntagged();
2379 dlg.tagSelected(); 2389 dlg.tagSelected();
2380 int count = 0; 2390 int count = 0;
2381 KABC::AddressBook::Iterator it; 2391 KABC::AddressBook::Iterator it;
2382 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2392 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2383 if ( (*it).tagged() ) { 2393 if ( (*it).tagged() ) {
2384 ++count; 2394 ++count;
2385 if ( count %10 == 0 ) 2395 if ( count %10 == 0 )
2386 message(i18n("Changing contact #%1").arg( count ) ); 2396 message(i18n("Changing contact #%1").arg( count ) );
2387 qApp->processEvents(); 2397 qApp->processEvents();
2388 QString fName; 2398 QString fName;
2389 if ( setpref.simple->isChecked() ) 2399 if ( setpref.simple->isChecked() )
2390 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2400 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2391 else if ( setpref.full->isChecked() ) 2401 else if ( setpref.full->isChecked() )
2392 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2402 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2393 else if ( setpref.reverse->isChecked() ) 2403 else if ( setpref.reverse->isChecked() )
2394 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2404 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2395 else 2405 else
2396 fName = (*it).organization(); 2406 fName = (*it).organization();
2397 if ( setpref.setCompany->isChecked() ) 2407 if ( setpref.setCompany->isChecked() )
2398 if ( fName.isEmpty() || fName =="," ) 2408 if ( fName.isEmpty() || fName =="," )
2399 fName = (*it).organization(); 2409 fName = (*it).organization();
2400 (*it).setFormattedName( fName ); 2410 (*it).setFormattedName( fName );
2401 } 2411 }
2402 } 2412 }
2403 message(i18n("Refreshing view...") ); 2413 message(i18n("Refreshing view...") );
2404 qApp->processEvents(); 2414 qApp->processEvents();
2405 mViewManager->refreshView( "" ); 2415 mViewManager->refreshView( "" );
2406 Addressee add; 2416 Addressee add;
2407 mDetails->setAddressee( add ); 2417 mDetails->setAddressee( add );
2408 message(i18n("Setting formatted name completed!") ); 2418 message(i18n("Setting formatted name completed!") );
2409} 2419}
2410 2420
2411void KABCore::clipboardDataChanged() 2421void KABCore::clipboardDataChanged()
2412{ 2422{
2413 2423
2414 if ( mReadWrite ) 2424 if ( mReadWrite )
2415 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2425 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2416 2426
2417} 2427}
2418 2428
2419void KABCore::updateActionMenu() 2429void KABCore::updateActionMenu()
2420{ 2430{
2421 UndoStack *undo = UndoStack::instance(); 2431 UndoStack *undo = UndoStack::instance();
2422 RedoStack *redo = RedoStack::instance(); 2432 RedoStack *redo = RedoStack::instance();
2423 2433
2424 if ( undo->isEmpty() ) 2434 if ( undo->isEmpty() )
2425 mActionUndo->setText( i18n( "Undo" ) ); 2435 mActionUndo->setText( i18n( "Undo" ) );
2426 else 2436 else
2427 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2437 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2428 2438
2429 mActionUndo->setEnabled( !undo->isEmpty() ); 2439 mActionUndo->setEnabled( !undo->isEmpty() );
2430 2440
2431 if ( !redo->top() ) 2441 if ( !redo->top() )
2432 mActionRedo->setText( i18n( "Redo" ) ); 2442 mActionRedo->setText( i18n( "Redo" ) );
2433 else 2443 else
2434 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2444 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2435 2445
2436 mActionRedo->setEnabled( !redo->isEmpty() ); 2446 mActionRedo->setEnabled( !redo->isEmpty() );
2437} 2447}
2438 2448
2439void KABCore::configureKeyBindings() 2449void KABCore::configureKeyBindings()
2440{ 2450{
2441#ifndef KAB_EMBEDDED 2451#ifndef KAB_EMBEDDED
2442 KKeyDialog::configure( actionCollection(), true ); 2452 KKeyDialog::configure( actionCollection(), true );
2443#else //KAB_EMBEDDED 2453#else //KAB_EMBEDDED
2444 qDebug("KABCore::configureKeyBindings() not implemented"); 2454 qDebug("KABCore::configureKeyBindings() not implemented");
2445#endif //KAB_EMBEDDED 2455#endif //KAB_EMBEDDED
2446} 2456}
2447 2457
2448#ifdef KAB_EMBEDDED 2458#ifdef KAB_EMBEDDED
2449void KABCore::configureResources() 2459void KABCore::configureResources()
2450{ 2460{
2451 KRES::KCMKResources dlg( this, "" , 0 ); 2461 KRES::KCMKResources dlg( this, "" , 0 );
2452 2462
2453 if ( !dlg.exec() ) 2463 if ( !dlg.exec() )
2454 return; 2464 return;
2455 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2465 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2456} 2466}
2457#endif //KAB_EMBEDDED 2467#endif //KAB_EMBEDDED
2458 2468
2459 2469
2460/* this method will be called through the QCop interface from Ko/Pi to select addresses 2470/* this method will be called through the QCop interface from Ko/Pi to select addresses
2461 * for the attendees list of an event. 2471 * for the attendees list of an event.
2462 */ 2472 */
2463void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2473void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2464{ 2474{
2465 QStringList nameList; 2475 QStringList nameList;
2466 QStringList emailList; 2476 QStringList emailList;
2467 QStringList uidList; 2477 QStringList uidList;
2468 2478
2469 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2479 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2470 uint i=0; 2480 uint i=0;
2471 for (i=0; i < list.count(); i++) 2481 for (i=0; i < list.count(); i++)
2472 { 2482 {
2473 nameList.append(list[i].realName()); 2483 nameList.append(list[i].realName());
2474 emailList.append(list[i].preferredEmail()); 2484 emailList.append(list[i].preferredEmail());
2475 uidList.append(list[i].uid()); 2485 uidList.append(list[i].uid());
2476 } 2486 }
2477 2487
2478 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2488 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2479 2489
2480} 2490}
2481 2491
2482/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2492/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2483 * to put them into the calendar. 2493 * to put them into the calendar.
2484 */ 2494 */
2485void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2495void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2486{ 2496{
2487 // qDebug("KABCore::requestForBirthdayList"); 2497 // qDebug("KABCore::requestForBirthdayList");
2488 QStringList birthdayList; 2498 QStringList birthdayList;
2489 QStringList anniversaryList; 2499 QStringList anniversaryList;
2490 QStringList realNameList; 2500 QStringList realNameList;
2491 QStringList preferredEmailList; 2501 QStringList preferredEmailList;
2492 QStringList assembledNameList; 2502 QStringList assembledNameList;
2493 QStringList uidList; 2503 QStringList uidList;
2494 2504
2495 KABC::AddressBook::Iterator it; 2505 KABC::AddressBook::Iterator it;
2496 2506
2497 int count = 0; 2507 int count = 0;
2498 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2508 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2499 ++count; 2509 ++count;
2500 } 2510 }
2501 QProgressBar bar(count,0 ); 2511 QProgressBar bar(count,0 );
2502 int w = 300; 2512 int w = 300;
2503 if ( QApplication::desktop()->width() < 320 ) 2513 if ( QApplication::desktop()->width() < 320 )
2504 w = 220; 2514 w = 220;
2505 int h = bar.sizeHint().height() ; 2515 int h = bar.sizeHint().height() ;
2506 int dw = QApplication::desktop()->width(); 2516 int dw = QApplication::desktop()->width();
2507 int dh = QApplication::desktop()->height(); 2517 int dh = QApplication::desktop()->height();
2508 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2518 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2509 bar.show(); 2519 bar.show();
2510 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2520 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2511 qApp->processEvents(); 2521 qApp->processEvents();
2512 2522
2513 QDate bday; 2523 QDate bday;
2514 QString anni; 2524 QString anni;
2515 QString formattedbday; 2525 QString formattedbday;
2516 2526
2517 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2527 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2518 { 2528 {
2519 if ( ! bar.isVisible() ) 2529 if ( ! bar.isVisible() )
2520 return; 2530 return;
2521 bar.setProgress( count++ ); 2531 bar.setProgress( count++ );
2522 qApp->processEvents(); 2532 qApp->processEvents();
2523 bday = (*it).birthday().date(); 2533 bday = (*it).birthday().date();
2524 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2534 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2525 2535
2526 if ( bday.isValid() || !anni.isEmpty()) 2536 if ( bday.isValid() || !anni.isEmpty())
2527 { 2537 {
2528 if (bday.isValid()) 2538 if (bday.isValid())
2529 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2539 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2530 else 2540 else
2531 formattedbday = "NOTVALID"; 2541 formattedbday = "NOTVALID";
2532 if (anni.isEmpty()) 2542 if (anni.isEmpty())
2533 anni = "INVALID"; 2543 anni = "INVALID";
2534 2544
2535 birthdayList.append(formattedbday); 2545 birthdayList.append(formattedbday);
2536 anniversaryList.append(anni); //should be ISODate 2546 anniversaryList.append(anni); //should be ISODate
2537 realNameList.append((*it).realName()); 2547 realNameList.append((*it).realName());
2538 preferredEmailList.append((*it).preferredEmail()); 2548 preferredEmailList.append((*it).preferredEmail());
2539 assembledNameList.append((*it).assembledName()); 2549 assembledNameList.append((*it).assembledName());
2540 uidList.append((*it).uid()); 2550 uidList.append((*it).uid());
2541 2551
2542 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2552 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2543 } 2553 }
2544 } 2554 }
2545 2555
2546 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2556 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2547 2557
2548} 2558}
2549 2559
2550/* this method will be called through the QCop interface from other apps to show details of a contact. 2560/* this method will be called through the QCop interface from other apps to show details of a contact.
2551 */ 2561 */
2552void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2562void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2553{ 2563{
2554 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2564 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2555 2565
2556 QString foundUid = QString::null; 2566 QString foundUid = QString::null;
2557 if ( ! uid.isEmpty() ) { 2567 if ( ! uid.isEmpty() ) {
2558 Addressee adrr = mAddressBook->findByUid( uid ); 2568 Addressee adrr = mAddressBook->findByUid( uid );
@@ -2942,364 +2952,364 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2942 } 2952 }
2943 else 2953 else
2944 idS = inR.IDStr(); 2954 idS = inR.IDStr();
2945 remote->removeAddressee( inR ); 2955 remote->removeAddressee( inR );
2946 inR = inL; 2956 inR = inL;
2947 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2957 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2948 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2958 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2949 inR.setOriginalExternalUID( OidS ); 2959 inR.setOriginalExternalUID( OidS );
2950 inR.setExternalUID( idS ); 2960 inR.setExternalUID( idS );
2951 if ( syncManager->syncWithDesktop() ) { 2961 if ( syncManager->syncWithDesktop() ) {
2952 inR.setIDStr("changed" ); 2962 inR.setIDStr("changed" );
2953 } 2963 }
2954 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2964 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2955 } else { 2965 } else {
2956 inR.setIDStr( idS ); 2966 inR.setIDStr( idS );
2957 } 2967 }
2958 inR.setResource( 0 ); 2968 inR.setResource( 0 );
2959 remote->insertAddressee( inR , false); 2969 remote->insertAddressee( inR , false);
2960 ++changedRemote; 2970 ++changedRemote;
2961 } else { // take == 2 take remote ********************** 2971 } else { // take == 2 take remote **********************
2962 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2972 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2963 if ( inR.revision().date().year() < 2004 ) 2973 if ( inR.revision().date().year() < 2004 )
2964 inR.setRevision( modifiedCalendar ); 2974 inR.setRevision( modifiedCalendar );
2965 } 2975 }
2966 idS = inL.IDStr(); 2976 idS = inL.IDStr();
2967 local->removeAddressee( inL ); 2977 local->removeAddressee( inL );
2968 inL = inR; 2978 inL = inR;
2969 inL.setIDStr( idS ); 2979 inL.setIDStr( idS );
2970 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2980 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2971 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2981 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2972 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2982 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2973 } 2983 }
2974 inL.setResource( 0 ); 2984 inL.setResource( 0 );
2975 local->insertAddressee( inL , false ); 2985 local->insertAddressee( inL , false );
2976 ++changedLocal; 2986 ++changedLocal;
2977 } 2987 }
2978 } 2988 }
2979 } 2989 }
2980 } else { // no conflict ********** add or delete remote 2990 } else { // no conflict ********** add or delete remote
2981 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2991 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2982 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2992 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2983 QString des = addresseeLSync.note(); 2993 QString des = addresseeLSync.note();
2984 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2994 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2985 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2995 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2986 remote->insertAddressee( inR, false ); 2996 remote->insertAddressee( inR, false );
2987 ++deletedAddresseeR; 2997 ++deletedAddresseeR;
2988 } else { 2998 } else {
2989 inR.setRevision( modifiedCalendar ); 2999 inR.setRevision( modifiedCalendar );
2990 remote->insertAddressee( inR, false ); 3000 remote->insertAddressee( inR, false );
2991 inL = inR; 3001 inL = inR;
2992 inL.setIDStr( ":" ); 3002 inL.setIDStr( ":" );
2993 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3003 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2994 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3004 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2995 inL.setResource( 0 ); 3005 inL.setResource( 0 );
2996 local->insertAddressee( inL , false); 3006 local->insertAddressee( inL , false);
2997 ++addedAddressee; 3007 ++addedAddressee;
2998 } 3008 }
2999 } else { 3009 } else {
3000 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3010 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3001 inR.setRevision( modifiedCalendar ); 3011 inR.setRevision( modifiedCalendar );
3002 remote->insertAddressee( inR, false ); 3012 remote->insertAddressee( inR, false );
3003 inR.setResource( 0 ); 3013 inR.setResource( 0 );
3004 local->insertAddressee( inR, false ); 3014 local->insertAddressee( inR, false );
3005 ++addedAddressee; 3015 ++addedAddressee;
3006 } else { 3016 } else {
3007 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3017 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3008 remote->removeAddressee( inR ); 3018 remote->removeAddressee( inR );
3009 ++deletedAddresseeR; 3019 ++deletedAddresseeR;
3010 } 3020 }
3011 } 3021 }
3012 } else { 3022 } else {
3013 ++filteredIN; 3023 ++filteredIN;
3014 } 3024 }
3015 } 3025 }
3016 } 3026 }
3017 ++incCounter; 3027 ++incCounter;
3018 } 3028 }
3019 er.clear(); 3029 er.clear();
3020 QStringList el = local->uidList(); 3030 QStringList el = local->uidList();
3021 modulo = (el.count()/10)+1; 3031 modulo = (el.count()/10)+1;
3022 3032
3023 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3033 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3024 incCounter = 0; 3034 incCounter = 0;
3025 while ( incCounter < el.count()) { 3035 while ( incCounter < el.count()) {
3026 qApp->processEvents(); 3036 qApp->processEvents();
3027 if (syncManager->isProgressBarCanceled()) 3037 if (syncManager->isProgressBarCanceled())
3028 return false; 3038 return false;
3029 if ( incCounter % modulo == 0 ) 3039 if ( incCounter % modulo == 0 )
3030 syncManager->showProgressBar(incCounter); 3040 syncManager->showProgressBar(incCounter);
3031 uid = el[ incCounter ]; 3041 uid = el[ incCounter ];
3032 bool skipIncidence = false; 3042 bool skipIncidence = false;
3033 if ( uid.left(19) == QString("last-syncAddressee-") ) 3043 if ( uid.left(19) == QString("last-syncAddressee-") )
3034 skipIncidence = true; 3044 skipIncidence = true;
3035 if ( !skipIncidence ) { 3045 if ( !skipIncidence ) {
3036 inL = local->findByUid( uid ); 3046 inL = local->findByUid( uid );
3037 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3047 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3038 inR = remote->findByUid( uid ); 3048 inR = remote->findByUid( uid );
3039 if ( inR.isEmpty() ){ 3049 if ( inR.isEmpty() ){
3040 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3050 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3041 // no conflict ********** add or delete local 3051 // no conflict ********** add or delete local
3042 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3043 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3053 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3044 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3054 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3045 local->removeAddressee( inL ); 3055 local->removeAddressee( inL );
3046 ++deletedAddresseeL; 3056 ++deletedAddresseeL;
3047 } else { 3057 } else {
3048 if ( ! syncManager->mWriteBackExistingOnly ) { 3058 if ( ! syncManager->mWriteBackExistingOnly ) {
3049 inL.removeID(mCurrentSyncDevice ); 3059 inL.removeID(mCurrentSyncDevice );
3050 ++addedAddresseeR; 3060 ++addedAddresseeR;
3051 inL.setRevision( modifiedCalendar ); 3061 inL.setRevision( modifiedCalendar );
3052 local->insertAddressee( inL, false ); 3062 local->insertAddressee( inL, false );
3053 inR = inL; 3063 inR = inL;
3054 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3064 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3055 inR.setResource( 0 ); 3065 inR.setResource( 0 );
3056 remote->insertAddressee( inR, false ); 3066 remote->insertAddressee( inR, false );
3057 } 3067 }
3058 } 3068 }
3059 } else { 3069 } else {
3060 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3070 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3061 //qDebug("data %s ", inL.revision().toString().latin1()); 3071 //qDebug("data %s ", inL.revision().toString().latin1());
3062 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3072 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3063 local->removeAddressee( inL ); 3073 local->removeAddressee( inL );
3064 ++deletedAddresseeL; 3074 ++deletedAddresseeL;
3065 } else { 3075 } else {
3066 if ( ! syncManager->mWriteBackExistingOnly ) { 3076 if ( ! syncManager->mWriteBackExistingOnly ) {
3067 ++addedAddresseeR; 3077 ++addedAddresseeR;
3068 inL.setRevision( modifiedCalendar ); 3078 inL.setRevision( modifiedCalendar );
3069 local->insertAddressee( inL, false ); 3079 local->insertAddressee( inL, false );
3070 inR = inL; 3080 inR = inL;
3071 inR.setIDStr( ":" ); 3081 inR.setIDStr( ":" );
3072 inR.setResource( 0 ); 3082 inR.setResource( 0 );
3073 remote->insertAddressee( inR, false ); 3083 remote->insertAddressee( inR, false );
3074 } 3084 }
3075 } 3085 }
3076 } 3086 }
3077 } else { 3087 } else {
3078 ++filteredOUT; 3088 ++filteredOUT;
3079 } 3089 }
3080 } 3090 }
3081 } 3091 }
3082 } 3092 }
3083 ++incCounter; 3093 ++incCounter;
3084 } 3094 }
3085 el.clear(); 3095 el.clear();
3086 syncManager->hideProgressBar(); 3096 syncManager->hideProgressBar();
3087 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3097 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3088 // get rid of micro seconds 3098 // get rid of micro seconds
3089 QTime t = mLastAddressbookSync.time(); 3099 QTime t = mLastAddressbookSync.time();
3090 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3100 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3091 addresseeLSync.setRevision( mLastAddressbookSync ); 3101 addresseeLSync.setRevision( mLastAddressbookSync );
3092 addresseeRSync.setRevision( mLastAddressbookSync ); 3102 addresseeRSync.setRevision( mLastAddressbookSync );
3093 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3103 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3094 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3104 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3095 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3105 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3096 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3106 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3097 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3107 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3098 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3108 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3099 addresseeRSync.setNote( "" ) ; 3109 addresseeRSync.setNote( "" ) ;
3100 addresseeLSync.setNote( "" ); 3110 addresseeLSync.setNote( "" );
3101 3111
3102 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3112 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3103 remote->insertAddressee( addresseeRSync, false ); 3113 remote->insertAddressee( addresseeRSync, false );
3104 local->insertAddressee( addresseeLSync, false ); 3114 local->insertAddressee( addresseeLSync, false );
3105 QString mes; 3115 QString mes;
3106 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3116 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3107 qDebug( mes ); 3117 qDebug( mes );
3108 mes = i18n("Local addressbook changed!\n") +mes; 3118 mes = i18n("Local addressbook changed!\n") +mes;
3109 if ( syncManager->mShowSyncSummary ) { 3119 if ( syncManager->mShowSyncSummary ) {
3110 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3120 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3111 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3121 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3112 qDebug("cancelled "); 3122 qDebug("cancelled ");
3113 return false; 3123 return false;
3114 } 3124 }
3115 } 3125 }
3116 return syncOK; 3126 return syncOK;
3117} 3127}
3118 3128
3119 3129
3120//this is a overwritten callbackmethods from the syncinterface 3130//this is a overwritten callbackmethods from the syncinterface
3121bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3131bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3122{ 3132{
3123 3133
3124 //pending prepare addresseeview for output 3134 //pending prepare addresseeview for output
3125 //pending detect, if remote file has REV field. if not switch to external sync 3135 //pending detect, if remote file has REV field. if not switch to external sync
3126 mGlobalSyncMode = SYNC_MODE_NORMAL; 3136 mGlobalSyncMode = SYNC_MODE_NORMAL;
3127 if ( manager != syncManager ) 3137 if ( manager != syncManager )
3128 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3138 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3129 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3139 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3130 3140
3131 AddressBook abLocal(filename,"syncContact"); 3141 AddressBook abLocal(filename,"syncContact");
3132 bool syncOK = false; 3142 bool syncOK = false;
3133 if ( abLocal.load() ) { 3143 if ( abLocal.load() ) {
3134 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3144 qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode );
3135 bool external = false; 3145 bool external = false;
3136 bool isXML = false; 3146 bool isXML = false;
3137 if ( filename.right(4) == ".xml") { 3147 if ( filename.right(4) == ".xml") {
3138 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3148 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3139 isXML = true; 3149 isXML = true;
3140 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3150 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3141 } else { 3151 } else {
3142 external = !manager->mIsKapiFile; 3152 external = !manager->mIsKapiFile;
3143 if ( external ) { 3153 if ( external ) {
3144 qDebug("Setting vcf mode to external "); 3154 qDebug("Sync:Setting vcf mode to external ");
3145 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3155 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3146 AddressBook::Iterator it; 3156 AddressBook::Iterator it;
3147 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3157 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3148 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3158 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3149 (*it).computeCsum( mCurrentSyncDevice ); 3159 (*it).computeCsum( mCurrentSyncDevice );
3150 } 3160 }
3151 } 3161 }
3152 } 3162 }
3153 //AddressBook::Iterator it; 3163 //AddressBook::Iterator it;
3154 //QStringList vcards; 3164 //QStringList vcards;
3155 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3165 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3156 // qDebug("Name %s ", (*it).familyName().latin1()); 3166 // qDebug("Name %s ", (*it).familyName().latin1());
3157 //} 3167 //}
3158 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3168 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3159 if ( syncOK ) { 3169 if ( syncOK ) {
3160 if ( syncManager->mWriteBackFile ) 3170 if ( syncManager->mWriteBackFile )
3161 { 3171 {
3162 if ( external ) 3172 if ( external )
3163 abLocal.removeSyncAddressees( !isXML); 3173 abLocal.removeSyncAddressees( !isXML);
3164 qDebug("Saving remote AB "); 3174 qDebug("Sync:Saving remote AB ");
3165 if ( ! abLocal.saveAB()) 3175 if ( ! abLocal.saveAB())
3166 qDebug("Error writing back AB to file "); 3176 qDebug("Error writing back AB to file ");
3167 if ( external ) { 3177 if ( external ) {
3168 // afterwrite processing 3178 // afterwrite processing
3169 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3179 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3170 } 3180 }
3171 } 3181 }
3172 } 3182 }
3173 setModified(); 3183 setModified();
3174 3184
3175 } 3185 }
3176 abLocal.removeResources(); 3186 abLocal.removeResources();
3177 if ( syncOK ) 3187 if ( syncOK )
3178 mViewManager->refreshView(); 3188 mViewManager->refreshView();
3179 return syncOK; 3189 return syncOK;
3180 3190
3181} 3191}
3182void KABCore::removeSyncInfo( QString syncProfile) 3192void KABCore::removeSyncInfo( QString syncProfile)
3183{ 3193{
3184 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3194 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3185 mAddressBook->removeSyncInfo( syncProfile ); 3195 mAddressBook->removeSyncInfo( syncProfile );
3186 setModified(); 3196 setModified();
3187} 3197}
3188 3198
3189 3199
3190//this is a overwritten callbackmethods from the syncinterface 3200//this is a overwritten callbackmethods from the syncinterface
3191bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3201bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3192{ 3202{
3193 if ( resource == "phone" ) 3203 if ( resource == "phone" )
3194 return syncPhone(); 3204 return syncPhone();
3195 disableBR( true ); 3205 disableBR( true );
3196 if ( manager != syncManager ) 3206 if ( manager != syncManager )
3197 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3207 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3198 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3208 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3199 3209
3200 AddressBook abLocal( resource,"syncContact"); 3210 AddressBook abLocal( resource,"syncContact");
3201 bool syncOK = false; 3211 bool syncOK = false;
3202 message(i18n("Loading DTM address data..."), false); 3212 message(i18n("Loading DTM address data..."), false);
3203 if ( abLocal.load() ) { 3213 if ( abLocal.load() ) {
3204 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3214 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3205 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3215 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3206 message(i18n("Sync preprocessing..."),false); 3216 message(i18n("Sync preprocessing..."),false);
3207 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3217 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3208 message(i18n("Synchronizing..."),false); 3218 message(i18n("Synchronizing..."),false);
3209 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3219 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3210 if ( syncOK ) { 3220 if ( syncOK ) {
3211 if ( syncManager->mWriteBackFile ) { 3221 if ( syncManager->mWriteBackFile ) {
3212 abLocal.removeSyncAddressees( false ); 3222 abLocal.removeSyncAddressees( false );
3213 message(i18n("Saving DTM address data..."),false); 3223 message(i18n("Saving DTM address data..."),false);
3214 abLocal.saveAB(); 3224 abLocal.saveAB();
3215 message(i18n("Sync postprocessing..."),false); 3225 message(i18n("Sync postprocessing..."),false);
3216 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3226 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3217 } 3227 }
3218 } else 3228 } else
3219 message( i18n("Sync cancelled or failed.") ); 3229 message( i18n("Sync cancelled or failed.") );
3220 setModified(); 3230 setModified();
3221 } 3231 }
3222 abLocal.removeResources(); 3232 abLocal.removeResources();
3223 if ( syncOK ) { 3233 if ( syncOK ) {
3224 mViewManager->refreshView(); 3234 mViewManager->refreshView();
3225 message(i18n("DTM syncing finished.")); 3235 message(i18n("DTM syncing finished."));
3226 } 3236 }
3227 disableBR( false ); 3237 disableBR( false );
3228 return syncOK; 3238 return syncOK;
3229 3239
3230} 3240}
3231void KABCore::message( QString m, bool startTimer) 3241void KABCore::message( QString m, bool startTimer)
3232{ 3242{
3233 topLevelWidget()->setCaption( m ); 3243 topLevelWidget()->setCaption( m );
3234 qApp->processEvents(); 3244 qApp->processEvents();
3235 if ( startTimer ) 3245 if ( startTimer )
3236 mMessageTimer->start( 15000, true ); 3246 mMessageTimer->start( 15000, true );
3237 else 3247 else
3238 mMessageTimer->stop(); 3248 mMessageTimer->stop();
3239} 3249}
3240bool KABCore::syncPhone() 3250bool KABCore::syncPhone()
3241{ 3251{
3242 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3252 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3243 QString fileName = getPhoneFile(); 3253 QString fileName = getPhoneFile();
3244 if ( !PhoneAccess::readFromPhone( fileName) ) { 3254 if ( !PhoneAccess::readFromPhone( fileName) ) {
3245 message(i18n("Phone access failed!")); 3255 message(i18n("Phone access failed!"));
3246 return false; 3256 return false;
3247 } 3257 }
3248 AddressBook abLocal( fileName,"syncContact"); 3258 AddressBook abLocal( fileName,"syncContact");
3249 bool syncOK = false; 3259 bool syncOK = false;
3250 { 3260 {
3251 abLocal.importFromFile( fileName ); 3261 abLocal.importFromFile( fileName );
3252 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3262 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3253 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3263 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3254 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3264 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3255 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3265 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3256 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3266 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3257 if ( syncOK ) { 3267 if ( syncOK ) {
3258 if ( syncManager->mWriteBackFile ) { 3268 if ( syncManager->mWriteBackFile ) {
3259 abLocal.removeSyncAddressees( true ); 3269 abLocal.removeSyncAddressees( true );
3260 abLocal.saveABphone( fileName ); 3270 abLocal.saveABphone( fileName );
3261 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3271 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3262 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3272 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3263 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3273 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3264 } 3274 }
3265 } 3275 }
3266 setModified(); 3276 setModified();
3267 } 3277 }
3268 abLocal.removeResources(); 3278 abLocal.removeResources();
3269 if ( syncOK ) 3279 if ( syncOK )
3270 mViewManager->refreshView(); 3280 mViewManager->refreshView();
3271 return syncOK; 3281 return syncOK;
3272} 3282}
3273void KABCore::getFile( bool success ) 3283void KABCore::getFile( bool success )
3274{ 3284{
3275 if ( ! success ) { 3285 if ( ! success ) {
3276 message( i18n("Error receiving file. Nothing changed!") ); 3286 message( i18n("Error receiving file. Nothing changed!") );
3277 return; 3287 return;
3278 } 3288 }
3279 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3289 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3280 if ( count ) 3290 if ( count )
3281 setModified( true ); 3291 setModified( true );
3282 message( i18n("Pi-Sync successful!") ); 3292 message( i18n("Pi-Sync successful!") );
3283 mViewManager->refreshView(); 3293 mViewManager->refreshView();
3284} 3294}
3285void KABCore::syncFileRequest() 3295void KABCore::syncFileRequest()
3286{ 3296{
3287 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3297 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3288 syncManager->slotSyncMenu( 999 ); 3298 syncManager->slotSyncMenu( 999 );
3289 } 3299 }
3290 mAddressBook->export2File( sentSyncFile() ); 3300 mAddressBook->export2File( sentSyncFile() );
3291} 3301}
3292QString KABCore::sentSyncFile() 3302QString KABCore::sentSyncFile()
3293{ 3303{
3294#ifdef DESKTOP_VERSION 3304#ifdef DESKTOP_VERSION
3295 return locateLocal( "tmp", "copysyncab.vcf" ); 3305 return locateLocal( "tmp", "copysyncab.vcf" );
3296#else 3306#else
3297 return QString( "/tmp/copysyncab.vcf" ); 3307 return QString( "/tmp/copysyncab.vcf" );
3298#endif 3308#endif
3299} 3309}
3300 3310
3301void KABCore::setCaptionBack() 3311void KABCore::setCaptionBack()
3302{ 3312{
3303 mMessageTimer->stop(); 3313 mMessageTimer->stop();
3304 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3314 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3305} 3315}