summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2004-09-21 07:05:01 (UTC)
committer zautrix <zautrix>2004-09-21 07:05:01 (UTC)
commit434ddaa08e0a650422ef271332a1d11879028095 (patch) (unidiff)
treee4f229120d8bfa9febb7ab123b1311329f0e6aa4 /kabc
parented49c55dac215ac2ed9286ebfc36e5a19417f0bb (diff)
downloadkdepimpi-434ddaa08e0a650422ef271332a1d11879028095.zip
kdepimpi-434ddaa08e0a650422ef271332a1d11879028095.tar.gz
kdepimpi-434ddaa08e0a650422ef271332a1d11879028095.tar.bz2
DTM sync fixes
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp8
-rw-r--r--kabc/addressee.cpp28
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp57
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.cpp119
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.h1
5 files changed, 117 insertions, 96 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index adb451f..5fb49eb 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -192,99 +192,97 @@ AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
192 return *this; 192 return *this;
193} 193}
194 194
195AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 195AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
196{ 196{
197 (d->mIt)--; 197 (d->mIt)--;
198 return *this; 198 return *this;
199} 199}
200 200
201AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 201AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
202{ 202{
203 (d->mIt)--; 203 (d->mIt)--;
204 return *this; 204 return *this;
205} 205}
206 206
207bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 207bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
208{ 208{
209 return ( d->mIt == it.d->mIt ); 209 return ( d->mIt == it.d->mIt );
210} 210}
211 211
212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
213{ 213{
214 return ( d->mIt != it.d->mIt ); 214 return ( d->mIt != it.d->mIt );
215} 215}
216 216
217 217
218AddressBook::AddressBook() 218AddressBook::AddressBook()
219{ 219{
220 init(0, "contact"); 220 init(0, "contact");
221} 221}
222 222
223AddressBook::AddressBook( const QString &config ) 223AddressBook::AddressBook( const QString &config )
224{ 224{
225 init(config, "contact"); 225 init(config, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config, const QString &family ) 228AddressBook::AddressBook( const QString &config, const QString &family )
229{ 229{
230 init(config, family); 230 init(config, family);
231 231
232} 232}
233 233
234// the default family is "contact" 234// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 235void AddressBook::init(const QString &config, const QString &family )
236{ 236{
237 blockLSEchange = false; 237 blockLSEchange = false;
238 d = new AddressBookData; 238 d = new AddressBookData;
239 QString fami = family; 239 QString fami = family;
240 qDebug("new ab ");
241 if (config != 0) { 240 if (config != 0) {
242 qDebug("config != 0 ");
243 if ( family == "syncContact" ) { 241 if ( family == "syncContact" ) {
244 qDebug("creating sync config "); 242 qDebug("creating sync config ");
245 fami = "contact"; 243 fami = "contact";
246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 244 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
247 con->setGroup( "General" ); 245 con->setGroup( "General" );
248 con->writeEntry( "ResourceKeys", QString("sync") ); 246 con->writeEntry( "ResourceKeys", QString("sync") );
249 con->writeEntry( "Standard", QString("sync") ); 247 con->writeEntry( "Standard", QString("sync") );
250 con->setGroup( "Resource_sync" ); 248 con->setGroup( "Resource_sync" );
251 con->writeEntry( "FileName", config ); 249 con->writeEntry( "FileName", config );
252 con->writeEntry( "FileFormat", QString("vcard") ); 250 con->writeEntry( "FileFormat", QString("vcard") );
253 con->writeEntry( "ResourceIdentifier", QString("sync") ); 251 con->writeEntry( "ResourceIdentifier", QString("sync") );
254 con->writeEntry( "ResourceName", QString("sync_res") ); 252 con->writeEntry( "ResourceName", QString("sync_res") );
255 if ( config.right(4) == ".xml" ) 253 if ( config.right(4) == ".xml" )
256 con->writeEntry( "ResourceType", QString("qtopia") ); 254 con->writeEntry( "ResourceType", QString("qtopia") );
257 else if ( config == "sharp" ) { 255 else if ( config == "sharp" ) {
258 con->writeEntry( "ResourceType", QString("sharp") ); 256 con->writeEntry( "ResourceType", QString("sharp") );
259 } else { 257 } else {
260 con->writeEntry( "ResourceType", QString("file") ); 258 con->writeEntry( "ResourceType", QString("file") );
261 } 259 }
262 //con->sync(); 260 //con->sync();
263 d->mConfig = con; 261 d->mConfig = con;
264 } 262 }
265 else 263 else
266 d->mConfig = new KConfig( locateLocal("config", config) ); 264 d->mConfig = new KConfig( locateLocal("config", config) );
267// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 265// qDebug("AddressBook::init 1 config=%s",config.latin1() );
268 } 266 }
269 else { 267 else {
270 d->mConfig = 0; 268 d->mConfig = 0;
271// qDebug("AddressBook::init 1 config=0"); 269// qDebug("AddressBook::init 1 config=0");
272 } 270 }
273 271
274//US d->mErrorHandler = 0; 272//US d->mErrorHandler = 0;
275 d->mManager = new KRES::Manager<Resource>( fami, false ); 273 d->mManager = new KRES::Manager<Resource>( fami, false );
276 d->mManager->readConfig( d->mConfig ); 274 d->mManager->readConfig( d->mConfig );
277 if ( family == "syncContact" ) { 275 if ( family == "syncContact" ) {
278 KRES::Manager<Resource> *manager = d->mManager; 276 KRES::Manager<Resource> *manager = d->mManager;
279 KRES::Manager<Resource>::ActiveIterator it; 277 KRES::Manager<Resource>::ActiveIterator it;
280 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 278 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
281 (*it)->setAddressBook( this ); 279 (*it)->setAddressBook( this );
282 if ( !(*it)->open() ) 280 if ( !(*it)->open() )
283 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 281 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
284 } 282 }
285 Resource *res = standardResource(); 283 Resource *res = standardResource();
286 if ( !res ) { 284 if ( !res ) {
287 qDebug("ERROR: no standard resource"); 285 qDebug("ERROR: no standard resource");
288 res = manager->createResource( "file" ); 286 res = manager->createResource( "file" );
289 if ( res ) 287 if ( res )
290 { 288 {
@@ -561,110 +559,110 @@ void AddressBook::removeSyncAddressees( bool removeDeleted )
561 Iterator it2 ; 559 Iterator it2 ;
562 QDateTime dt ( QDate( 2004,1,1) ); 560 QDateTime dt ( QDate( 2004,1,1) );
563 while ( it != end() ) { 561 while ( it != end() ) {
564 (*it).setRevision( dt ); 562 (*it).setRevision( dt );
565 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 563 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
566 (*it).setIDStr(""); 564 (*it).setIDStr("");
567 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 565 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
568 it2 = it; 566 it2 = it;
569 //qDebug("removing %s ",(*it).uid().latin1() ); 567 //qDebug("removing %s ",(*it).uid().latin1() );
570 ++it; 568 ++it;
571 removeAddressee( it2 ); 569 removeAddressee( it2 );
572 } else { 570 } else {
573 //qDebug("skipping %s ",(*it).uid().latin1() ); 571 //qDebug("skipping %s ",(*it).uid().latin1() );
574 ++it; 572 ++it;
575 } 573 }
576 } 574 }
577 deleteRemovedAddressees(); 575 deleteRemovedAddressees();
578} 576}
579 577
580void AddressBook::removeAddressee( const Iterator &it ) 578void AddressBook::removeAddressee( const Iterator &it )
581{ 579{
582 d->mRemovedAddressees.append( (*it) ); 580 d->mRemovedAddressees.append( (*it) );
583 d->mAddressees.remove( it.d->mIt ); 581 d->mAddressees.remove( it.d->mIt );
584} 582}
585 583
586AddressBook::Iterator AddressBook::find( const Addressee &a ) 584AddressBook::Iterator AddressBook::find( const Addressee &a )
587{ 585{
588 Iterator it; 586 Iterator it;
589 for ( it = begin(); it != end(); ++it ) { 587 for ( it = begin(); it != end(); ++it ) {
590 if ( a.uid() == (*it).uid() ) { 588 if ( a.uid() == (*it).uid() ) {
591 return it; 589 return it;
592 } 590 }
593 } 591 }
594 return end(); 592 return end();
595} 593}
596 594
597Addressee AddressBook::findByUid( const QString &uid ) 595Addressee AddressBook::findByUid( const QString &uid )
598{ 596{
599 Iterator it; 597 Iterator it;
600 for ( it = begin(); it != end(); ++it ) { 598 for ( it = begin(); it != end(); ++it ) {
601 if ( uid == (*it).uid() ) { 599 if ( uid == (*it).uid() ) {
602 return *it; 600 return *it;
603 } 601 }
604 } 602 }
605 return Addressee(); 603 return Addressee();
606} 604}
607void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 605void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
608{ 606{
609 qDebug("AddressBook::preExternSync "); 607 //qDebug("AddressBook::preExternSync ");
610 AddressBook::Iterator it; 608 AddressBook::Iterator it;
611 for ( it = begin(); it != end(); ++it ) { 609 for ( it = begin(); it != end(); ++it ) {
612 (*it).setID( csd, (*it).externalUID() ); 610 (*it).setID( csd, (*it).externalUID() );
613 (*it).computeCsum( csd ); 611 (*it).computeCsum( csd );
614 } 612 }
615 mergeAB( aBook ,csd ); 613 mergeAB( aBook ,csd );
616} 614}
617void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 615void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
618{ 616{
619 qDebug("AddressBook::postExternSync "); 617 //qDebug("AddressBook::postExternSync ");
620 AddressBook::Iterator it; 618 AddressBook::Iterator it;
621 for ( it = begin(); it != end(); ++it ) { 619 for ( it = begin(); it != end(); ++it ) {
622 qDebug("check uid %s ", (*it).uid().latin1() ); 620 // qDebug("check uid %s ", (*it).uid().latin1() );
623 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 621 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
624 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 622 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
625 Addressee ad = aBook->findByUid( ( (*it).uid() )); 623 Addressee ad = aBook->findByUid( ( (*it).uid() ));
626 if ( ad.isEmpty() ) { 624 if ( ad.isEmpty() ) {
627 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 625 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
628 } else { 626 } else {
629 (*it).computeCsum( csd ); 627 (*it).computeCsum( csd );
630 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 628 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
631 ad.setID( csd, (*it).externalUID() ); 629 ad.setID( csd, (*it).externalUID() );
632 ad.setCsum( csd, (*it).getCsum( csd ) ); 630 ad.setCsum( csd, (*it).getCsum( csd ) );
633 aBook->insertAddressee( ad ); 631 aBook->insertAddressee( ad );
634 } 632 }
635 } 633 }
636 } 634 }
637} 635}
638 636
639bool AddressBook::containsExternalUid( const QString& uid ) 637bool AddressBook::containsExternalUid( const QString& uid )
640{ 638{
641 Iterator it; 639 Iterator it;
642 for ( it = begin(); it != end(); ++it ) { 640 for ( it = begin(); it != end(); ++it ) {
643 if ( uid == (*it).externalUID( ) ) 641 if ( uid == (*it).externalUID( ) )
644 return true; 642 return true;
645 } 643 }
646 return false; 644 return false;
647} 645}
648Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 646Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
649{ 647{
650 Iterator it; 648 Iterator it;
651 for ( it = begin(); it != end(); ++it ) { 649 for ( it = begin(); it != end(); ++it ) {
652 if ( uid == (*it).getID( profile ) ) 650 if ( uid == (*it).getID( profile ) )
653 return (*it); 651 return (*it);
654 } 652 }
655 return Addressee(); 653 return Addressee();
656} 654}
657void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 655void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
658{ 656{
659 Iterator it; 657 Iterator it;
660 Addressee ad; 658 Addressee ad;
661 for ( it = begin(); it != end(); ++it ) { 659 for ( it = begin(); it != end(); ++it ) {
662 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 660 ad = aBook->findByExternUid( (*it).externalUID(), profile );
663 if ( !ad.isEmpty() ) { 661 if ( !ad.isEmpty() ) {
664 (*it).mergeContact( ad ); 662 (*it).mergeContact( ad );
665 } 663 }
666 } 664 }
667#if 0 665#if 0
668 // test only 666 // test only
669 for ( it = begin(); it != end(); ++it ) { 667 for ( it = begin(); it != end(); ++it ) {
670 668
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index e241281..31ce1d6 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,93 +1,95 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern );
46 48
47struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
48{ 50{
49 QString uid; 51 QString uid;
50 QString name; 52 QString name;
51 QString formattedName; 53 QString formattedName;
52 QString familyName; 54 QString familyName;
53 QString givenName; 55 QString givenName;
54 QString additionalName; 56 QString additionalName;
55 QString prefix; 57 QString prefix;
56 QString suffix; 58 QString suffix;
57 QString nickName; 59 QString nickName;
58 QDateTime birthday; 60 QDateTime birthday;
59 QString mailer; 61 QString mailer;
60 TimeZone timeZone; 62 TimeZone timeZone;
61 Geo geo; 63 Geo geo;
62 QString title; 64 QString title;
63 QString role; 65 QString role;
64 QString organization; 66 QString organization;
65 QString note; 67 QString note;
66 QString productId; 68 QString productId;
67 QDateTime revision; 69 QDateTime revision;
68 QString sortString; 70 QString sortString;
69 QString externalUID; 71 QString externalUID;
70 QString originalExternalUID; 72 QString originalExternalUID;
71 KURL url; 73 KURL url;
72 Secrecy secrecy; 74 Secrecy secrecy;
73 Picture logo; 75 Picture logo;
74 Picture photo; 76 Picture photo;
75 Sound sound; 77 Sound sound;
76 Agent agent; 78 Agent agent;
77 QString mExternalId; 79 QString mExternalId;
78 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
79 Address::List addresses; 81 Address::List addresses;
80 Key::List keys; 82 Key::List keys;
81 QStringList emails; 83 QStringList emails;
82 QStringList categories; 84 QStringList categories;
83 QStringList custom; 85 QStringList custom;
84 int mTempSyncStat; 86 int mTempSyncStat;
85 Resource *resource; 87 Resource *resource;
86 88
87 bool empty :1; 89 bool empty :1;
88 bool changed :1; 90 bool changed :1;
89}; 91};
90 92
91Addressee::Addressee() 93Addressee::Addressee()
92{ 94{
93 mData = new AddresseeData; 95 mData = new AddresseeData;
@@ -336,110 +338,110 @@ int Addressee::tempSyncStat() const
336} 338}
337 339
338QString Addressee::getID( const QString & prof) 340QString Addressee::getID( const QString & prof)
339{ 341{
340 return KIdManager::getId ( mData->mExternalId, prof ); 342 return KIdManager::getId ( mData->mExternalId, prof );
341} 343}
342 344
343void Addressee::setCsum( const QString & prof , const QString & id ) 345void Addressee::setCsum( const QString & prof , const QString & id )
344{ 346{
345 detach(); 347 detach();
346 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 348 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
347 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 349 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
348 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 350 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
349} 351}
350 352
351QString Addressee::getCsum( const QString & prof) 353QString Addressee::getCsum( const QString & prof)
352{ 354{
353 return KIdManager::getCsum ( mData->mExternalId, prof ); 355 return KIdManager::getCsum ( mData->mExternalId, prof );
354} 356}
355 357
356void Addressee::setIDStr( const QString & s ) 358void Addressee::setIDStr( const QString & s )
357{ 359{
358 detach(); 360 detach();
359 mData->mExternalId = s; 361 mData->mExternalId = s;
360} 362}
361 363
362QString Addressee::IDStr() const 364QString Addressee::IDStr() const
363{ 365{
364 return mData->mExternalId; 366 return mData->mExternalId;
365} 367}
366 368
367void Addressee::setExternalUID( const QString &id ) 369void Addressee::setExternalUID( const QString &id )
368{ 370{
369 if ( id == mData->externalUID ) return; 371 if ( id == mData->externalUID ) return;
370 detach(); 372 detach();
371 mData->empty = false; 373 mData->empty = false;
372 mData->externalUID = id; 374 mData->externalUID = id;
373} 375}
374 376
375QString Addressee::externalUID() const 377QString Addressee::externalUID() const
376{ 378{
377 return mData->externalUID; 379 return mData->externalUID;
378} 380}
379void Addressee::setOriginalExternalUID( const QString &id ) 381void Addressee::setOriginalExternalUID( const QString &id )
380{ 382{
381 if ( id == mData->originalExternalUID ) return; 383 if ( id == mData->originalExternalUID ) return;
382 detach(); 384 detach();
383 mData->empty = false; 385 mData->empty = false;
384 qDebug("*******Set orig uid %s ", id.latin1()); 386 //qDebug("*******Set orig uid %s ", id.latin1());
385 mData->originalExternalUID = id; 387 mData->originalExternalUID = id;
386} 388}
387 389
388QString Addressee::originalExternalUID() const 390QString Addressee::originalExternalUID() const
389{ 391{
390 return mData->originalExternalUID; 392 return mData->originalExternalUID;
391} 393}
392 394
393void Addressee::setUid( const QString &id ) 395void Addressee::setUid( const QString &id )
394{ 396{
395 if ( id == mData->uid ) return; 397 if ( id == mData->uid ) return;
396 detach(); 398 detach();
397 qDebug("****setuid %s ", id.latin1()); 399 //qDebug("****setuid %s ", id.latin1());
398 mData->empty = false; 400 mData->empty = false;
399 mData->uid = id; 401 mData->uid = id;
400} 402}
401 403
402QString Addressee::uid() const 404QString Addressee::uid() const
403{ 405{
404 if ( mData->uid.isEmpty() ) 406 if ( mData->uid.isEmpty() )
405 mData->uid = KApplication::randomString( 10 ); 407 mData->uid = KApplication::randomString( 10 );
406 408
407 return mData->uid; 409 return mData->uid;
408} 410}
409 411
410QString Addressee::uidLabel() 412QString Addressee::uidLabel()
411{ 413{
412 return i18n("Unique Identifier"); 414 return i18n("Unique Identifier");
413} 415}
414 416
415void Addressee::setName( const QString &name ) 417void Addressee::setName( const QString &name )
416{ 418{
417 if ( name == mData->name ) return; 419 if ( name == mData->name ) return;
418 detach(); 420 detach();
419 mData->empty = false; 421 mData->empty = false;
420 mData->name = name; 422 mData->name = name;
421} 423}
422 424
423QString Addressee::name() const 425QString Addressee::name() const
424{ 426{
425 return mData->name; 427 return mData->name;
426} 428}
427 429
428QString Addressee::nameLabel() 430QString Addressee::nameLabel()
429{ 431{
430 return i18n("Name"); 432 return i18n("Name");
431} 433}
432 434
433 435
434void Addressee::setFormattedName( const QString &formattedName ) 436void Addressee::setFormattedName( const QString &formattedName )
435{ 437{
436 if ( formattedName == mData->formattedName ) return; 438 if ( formattedName == mData->formattedName ) return;
437 detach(); 439 detach();
438 mData->empty = false; 440 mData->empty = false;
439 mData->formattedName = formattedName; 441 mData->formattedName = formattedName;
440} 442}
441 443
442QString Addressee::formattedName() const 444QString Addressee::formattedName() const
443{ 445{
444 return mData->formattedName; 446 return mData->formattedName;
445} 447}
@@ -1245,97 +1247,97 @@ void Addressee::removeEmail( const QString &email )
1245 1247
1246QString Addressee::preferredEmail() const 1248QString Addressee::preferredEmail() const
1247{ 1249{
1248 if ( mData->emails.count() == 0 ) return QString::null; 1250 if ( mData->emails.count() == 0 ) return QString::null;
1249 else return mData->emails.first(); 1251 else return mData->emails.first();
1250} 1252}
1251 1253
1252QStringList Addressee::emails() const 1254QStringList Addressee::emails() const
1253{ 1255{
1254 return mData->emails; 1256 return mData->emails;
1255} 1257}
1256void Addressee::setEmails( const QStringList& emails ) { 1258void Addressee::setEmails( const QStringList& emails ) {
1257 detach(); 1259 detach();
1258 mData->emails = emails; 1260 mData->emails = emails;
1259} 1261}
1260void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1262void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1261{ 1263{
1262 detach(); 1264 detach();
1263 mData->empty = false; 1265 mData->empty = false;
1264 1266
1265 PhoneNumber::List::Iterator it; 1267 PhoneNumber::List::Iterator it;
1266 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1268 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1267 if ( (*it).id() == phoneNumber.id() ) { 1269 if ( (*it).id() == phoneNumber.id() ) {
1268 *it = phoneNumber; 1270 *it = phoneNumber;
1269 return; 1271 return;
1270 } 1272 }
1271 } 1273 }
1272 mData->phoneNumbers.append( phoneNumber ); 1274 mData->phoneNumbers.append( phoneNumber );
1273} 1275}
1274 1276
1275void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1277void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1276{ 1278{
1277 detach(); 1279 detach();
1278 1280
1279 PhoneNumber::List::Iterator it; 1281 PhoneNumber::List::Iterator it;
1280 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1282 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1281 if ( (*it).id() == phoneNumber.id() ) { 1283 if ( (*it).id() == phoneNumber.id() ) {
1282 mData->phoneNumbers.remove( it ); 1284 mData->phoneNumbers.remove( it );
1283 return; 1285 return;
1284 } 1286 }
1285 } 1287 }
1286} 1288}
1287 1289
1288PhoneNumber Addressee::phoneNumber( int type ) const 1290PhoneNumber Addressee::phoneNumber( int type ) const
1289{ 1291{
1290 PhoneNumber phoneNumber( "", type ); 1292 PhoneNumber phoneNumber( "", type );
1291 PhoneNumber::List::ConstIterator it; 1293 PhoneNumber::List::ConstIterator it;
1292 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1294 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1293 if ( matchBinaryPattern( (*it).type(), type ) ) { 1295 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1294 if ( (*it).type() & PhoneNumber::Pref ) 1296 if ( (*it).type() & PhoneNumber::Pref )
1295 return (*it); 1297 return (*it);
1296 else if ( phoneNumber.number().isEmpty() ) 1298 else if ( phoneNumber.number().isEmpty() )
1297 phoneNumber = (*it); 1299 phoneNumber = (*it);
1298 } 1300 }
1299 } 1301 }
1300 1302
1301 return phoneNumber; 1303 return phoneNumber;
1302} 1304}
1303 1305
1304PhoneNumber::List Addressee::phoneNumbers() const 1306PhoneNumber::List Addressee::phoneNumbers() const
1305{ 1307{
1306 return mData->phoneNumbers; 1308 return mData->phoneNumbers;
1307} 1309}
1308 1310
1309PhoneNumber::List Addressee::phoneNumbers( int type ) const 1311PhoneNumber::List Addressee::phoneNumbers( int type ) const
1310{ 1312{
1311 PhoneNumber::List list; 1313 PhoneNumber::List list;
1312 1314
1313 PhoneNumber::List::ConstIterator it; 1315 PhoneNumber::List::ConstIterator it;
1314 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1316 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1315 if ( matchBinaryPattern( (*it).type(), type ) ) { 1317 if ( matchBinaryPattern( (*it).type(), type ) ) {
1316 list.append( *it ); 1318 list.append( *it );
1317 } 1319 }
1318 } 1320 }
1319 return list; 1321 return list;
1320} 1322}
1321 1323
1322PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1324PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1323{ 1325{
1324 PhoneNumber::List::ConstIterator it; 1326 PhoneNumber::List::ConstIterator it;
1325 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1326 if ( (*it).id() == id ) { 1328 if ( (*it).id() == id ) {
1327 return *it; 1329 return *it;
1328 } 1330 }
1329 } 1331 }
1330 return PhoneNumber(); 1332 return PhoneNumber();
1331} 1333}
1332 1334
1333void Addressee::insertKey( const Key &key ) 1335void Addressee::insertKey( const Key &key )
1334{ 1336{
1335 detach(); 1337 detach();
1336 mData->empty = false; 1338 mData->empty = false;
1337 1339
1338 Key::List::Iterator it; 1340 Key::List::Iterator it;
1339 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1341 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1340 if ( (*it).id() == key.id() ) { 1342 if ( (*it).id() == key.id() ) {
1341 *it = key; 1343 *it = key;
@@ -1482,97 +1484,97 @@ void Addressee::dump() const
1482 1484
1483 kdDebug(5700) << " Keys {" << endl; 1485 kdDebug(5700) << " Keys {" << endl;
1484 Key::List k = keys(); 1486 Key::List k = keys();
1485 Key::List::ConstIterator it4; 1487 Key::List::ConstIterator it4;
1486 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1488 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1487 kdDebug(5700) << " Type: " << int((*it4).type()) << 1489 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1488 " Key: " << (*it4).textData() << 1490 " Key: " << (*it4).textData() <<
1489 " CustomString: " << (*it4).customTypeString() << endl; 1491 " CustomString: " << (*it4).customTypeString() << endl;
1490 } 1492 }
1491 kdDebug(5700) << " }" << endl; 1493 kdDebug(5700) << " }" << endl;
1492 1494
1493 kdDebug(5700) << "}" << endl; 1495 kdDebug(5700) << "}" << endl;
1494} 1496}
1495 1497
1496 1498
1497void Addressee::insertAddress( const Address &address ) 1499void Addressee::insertAddress( const Address &address )
1498{ 1500{
1499 detach(); 1501 detach();
1500 mData->empty = false; 1502 mData->empty = false;
1501 1503
1502 Address::List::Iterator it; 1504 Address::List::Iterator it;
1503 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1505 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1504 if ( (*it).id() == address.id() ) { 1506 if ( (*it).id() == address.id() ) {
1505 *it = address; 1507 *it = address;
1506 return; 1508 return;
1507 } 1509 }
1508 } 1510 }
1509 mData->addresses.append( address ); 1511 mData->addresses.append( address );
1510} 1512}
1511 1513
1512void Addressee::removeAddress( const Address &address ) 1514void Addressee::removeAddress( const Address &address )
1513{ 1515{
1514 detach(); 1516 detach();
1515 1517
1516 Address::List::Iterator it; 1518 Address::List::Iterator it;
1517 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1519 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1518 if ( (*it).id() == address.id() ) { 1520 if ( (*it).id() == address.id() ) {
1519 mData->addresses.remove( it ); 1521 mData->addresses.remove( it );
1520 return; 1522 return;
1521 } 1523 }
1522 } 1524 }
1523} 1525}
1524 1526
1525Address Addressee::address( int type ) const 1527Address Addressee::address( int type ) const
1526{ 1528{
1527 Address address( type ); 1529 Address address( type );
1528 Address::List::ConstIterator it; 1530 Address::List::ConstIterator it;
1529 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1531 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1530 if ( matchBinaryPattern( (*it).type(), type ) ) { 1532 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1531 if ( (*it).type() & Address::Pref ) 1533 if ( (*it).type() & Address::Pref )
1532 return (*it); 1534 return (*it);
1533 else if ( address.isEmpty() ) 1535 else if ( address.isEmpty() )
1534 address = (*it); 1536 address = (*it);
1535 } 1537 }
1536 } 1538 }
1537 1539
1538 return address; 1540 return address;
1539} 1541}
1540 1542
1541Address::List Addressee::addresses() const 1543Address::List Addressee::addresses() const
1542{ 1544{
1543 return mData->addresses; 1545 return mData->addresses;
1544} 1546}
1545 1547
1546Address::List Addressee::addresses( int type ) const 1548Address::List Addressee::addresses( int type ) const
1547{ 1549{
1548 Address::List list; 1550 Address::List list;
1549 1551
1550 Address::List::ConstIterator it; 1552 Address::List::ConstIterator it;
1551 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1553 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1552 if ( matchBinaryPattern( (*it).type(), type ) ) { 1554 if ( matchBinaryPattern( (*it).type(), type ) ) {
1553 list.append( *it ); 1555 list.append( *it );
1554 } 1556 }
1555 } 1557 }
1556 1558
1557 return list; 1559 return list;
1558} 1560}
1559 1561
1560Address Addressee::findAddress( const QString &id ) const 1562Address Addressee::findAddress( const QString &id ) const
1561{ 1563{
1562 Address::List::ConstIterator it; 1564 Address::List::ConstIterator it;
1563 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1565 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1564 if ( (*it).id() == id ) { 1566 if ( (*it).id() == id ) {
1565 return *it; 1567 return *it;
1566 } 1568 }
1567 } 1569 }
1568 return Address(); 1570 return Address();
1569} 1571}
1570 1572
1571void Addressee::insertCategory( const QString &c ) 1573void Addressee::insertCategory( const QString &c )
1572{ 1574{
1573 detach(); 1575 detach();
1574 mData->empty = false; 1576 mData->empty = false;
1575 1577
1576 if ( mData->categories.contains( c ) ) return; 1578 if ( mData->categories.contains( c ) ) return;
1577 1579
1578 mData->categories.append( c ); 1580 mData->categories.append( c );
@@ -1790,62 +1792,78 @@ QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1790 s << a.mData->categories; 1792 s << a.mData->categories;
1791 s << a.mData->custom; 1793 s << a.mData->custom;
1792 s << a.mData->keys; 1794 s << a.mData->keys;
1793 return s; 1795 return s;
1794} 1796}
1795 1797
1796QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 1798QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1797{ 1799{
1798 if (!a.mData) return s; 1800 if (!a.mData) return s;
1799 1801
1800 s >> a.mData->uid; 1802 s >> a.mData->uid;
1801 1803
1802 s >> a.mData->name; 1804 s >> a.mData->name;
1803 s >> a.mData->formattedName; 1805 s >> a.mData->formattedName;
1804 s >> a.mData->familyName; 1806 s >> a.mData->familyName;
1805 s >> a.mData->givenName; 1807 s >> a.mData->givenName;
1806 s >> a.mData->additionalName; 1808 s >> a.mData->additionalName;
1807 s >> a.mData->prefix; 1809 s >> a.mData->prefix;
1808 s >> a.mData->suffix; 1810 s >> a.mData->suffix;
1809 s >> a.mData->nickName; 1811 s >> a.mData->nickName;
1810 s >> a.mData->birthday; 1812 s >> a.mData->birthday;
1811 s >> a.mData->mailer; 1813 s >> a.mData->mailer;
1812 s >> a.mData->timeZone; 1814 s >> a.mData->timeZone;
1813 s >> a.mData->geo; 1815 s >> a.mData->geo;
1814 s >> a.mData->title; 1816 s >> a.mData->title;
1815 s >> a.mData->role; 1817 s >> a.mData->role;
1816 s >> a.mData->organization; 1818 s >> a.mData->organization;
1817 s >> a.mData->note; 1819 s >> a.mData->note;
1818 s >> a.mData->productId; 1820 s >> a.mData->productId;
1819 s >> a.mData->revision; 1821 s >> a.mData->revision;
1820 s >> a.mData->sortString; 1822 s >> a.mData->sortString;
1821 s >> a.mData->url; 1823 s >> a.mData->url;
1822 s >> a.mData->secrecy; 1824 s >> a.mData->secrecy;
1823 s >> a.mData->logo; 1825 s >> a.mData->logo;
1824 s >> a.mData->photo; 1826 s >> a.mData->photo;
1825 s >> a.mData->sound; 1827 s >> a.mData->sound;
1826 s >> a.mData->agent; 1828 s >> a.mData->agent;
1827 s >> a.mData->phoneNumbers; 1829 s >> a.mData->phoneNumbers;
1828 s >> a.mData->addresses; 1830 s >> a.mData->addresses;
1829 s >> a.mData->emails; 1831 s >> a.mData->emails;
1830 s >> a.mData->categories; 1832 s >> a.mData->categories;
1831 s >> a.mData->custom; 1833 s >> a.mData->custom;
1832 s >> a.mData->keys; 1834 s >> a.mData->keys;
1833 1835
1834 a.mData->empty = false; 1836 a.mData->empty = false;
1835 1837
1836 return s; 1838 return s;
1837} 1839}
1838
1839bool matchBinaryPattern( int value, int pattern ) 1840bool matchBinaryPattern( int value, int pattern )
1840{ 1841{
1841 /** 1842 /**
1842 We want to match all telephonnumbers/addresses which have the bits in the 1843 We want to match all telephonnumbers/addresses which have the bits in the
1843 pattern set. More are allowed. 1844 pattern set. More are allowed.
1844 if pattern == 0 we have a special handling, then we want only those with 1845 if pattern == 0 we have a special handling, then we want only those with
1845 exactly no bit set. 1846 exactly no bit set.
1846 */ 1847 */
1847 if ( pattern == 0 ) 1848 if ( pattern == 0 )
1848 return ( value == 0 ); 1849 return ( value == 0 );
1849 else 1850 else
1850 return ( pattern == ( pattern & value ) ); 1851 return ( pattern == ( pattern & value ) );
1851} 1852}
1853
1854bool matchBinaryPatternP( int value, int pattern )
1855{
1856
1857 if ( pattern == 0 )
1858 return ( value == 0 );
1859 else
1860 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
1861}
1862bool matchBinaryPatternA( int value, int pattern )
1863{
1864
1865 if ( pattern == 0 )
1866 return ( value == 0 );
1867 else
1868 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
1869}
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index bba5f9a..48d3985 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -84,283 +84,246 @@ void ResourceSharpDTM::init( const QString &fileName )
84{ 84{
85 85
86 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 86 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
87 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 87 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
88 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 88 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
89 89
90 setFileName( fileName ); 90 setFileName( fileName );
91} 91}
92 92
93ResourceSharpDTM::~ResourceSharpDTM() 93ResourceSharpDTM::~ResourceSharpDTM()
94{ 94{
95 if (mConverter != 0) 95 if (mConverter != 0)
96 delete mConverter; 96 delete mConverter;
97 97
98 if(mAccess != 0) 98 if(mAccess != 0)
99 delete mAccess; 99 delete mAccess;
100} 100}
101 101
102void ResourceSharpDTM::writeConfig( KConfig *config ) 102void ResourceSharpDTM::writeConfig( KConfig *config )
103{ 103{
104 Resource::writeConfig( config ); 104 Resource::writeConfig( config );
105} 105}
106 106
107Ticket *ResourceSharpDTM::requestSaveTicket() 107Ticket *ResourceSharpDTM::requestSaveTicket()
108{ 108{
109 109
110 110
111 qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); 111 qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1());
112 112
113 if ( !addressBook() ) return 0; 113 if ( !addressBook() ) return 0;
114 114
115#ifdef ALLOW_LOCKING 115#ifdef ALLOW_LOCKING
116 if ( !lock( fileName() ) ) { 116 if ( !lock( fileName() ) ) {
117 qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); 117 qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file ");
118 return 0; 118 return 0;
119 } 119 }
120#endif 120#endif
121 return createTicket( this ); 121 return createTicket( this );
122} 122}
123 123
124 124
125bool ResourceSharpDTM::doOpen() 125bool ResourceSharpDTM::doOpen()
126{ 126{
127 qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); 127 qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1());
128 128
129 // the last parameter in the SlZDataBase constructor means "readonly" 129 // the last parameter in the SlZDataBase constructor means "readonly"
130 mAccess = new SlZDataBase(fileName(), 130 mAccess = new SlZDataBase(fileName(),
131 SlZDataBase::addressbookItems(), 131 SlZDataBase::addressbookItems(),
132 NULL, true); 132 NULL, false);
133 133
134 if ( !mAccess ) { 134 if ( !mAccess ) {
135 qDebug("Unable to load file() %s", fileName().latin1()); 135 qDebug("Unable to load file() %s", fileName().latin1());
136 return false; 136 return false;
137 } 137 }
138 138
139 if (mConverter == 0) 139 if (mConverter == 0)
140 { 140 {
141 mConverter = new SharpDTMConverter(); 141 mConverter = new SharpDTMConverter();
142 bool res = mConverter->init(); 142 bool res = mConverter->init();
143 if ( !res ) 143 if ( !res )
144 { 144 {
145 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); 145 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file");
146 146
147 qDebug(msg); 147 qDebug(msg);
148 delete mAccess; 148 delete mAccess;
149 mAccess = 0; 149 mAccess = 0;
150 return false; 150 return false;
151 } 151 }
152 } 152 }
153 153
154 return true; 154 return true;
155} 155}
156 156
157void ResourceSharpDTM::doClose() 157void ResourceSharpDTM::doClose()
158{ 158{
159 qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); 159 qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1());
160 160
161 if(mAccess) 161 if(mAccess)
162 { 162 {
163 delete mAccess; 163 delete mAccess;
164 mAccess = 0; 164 mAccess = 0;
165 } 165 }
166 // it seems so, that deletion of access deletes backend as well 166 // it seems so, that deletion of access deletes backend as well
167 //delete backend; 167 //delete backend;
168 168
169 return; 169 return;
170} 170}
171 171
172bool ResourceSharpDTM::load() 172bool ResourceSharpDTM::load()
173{ 173{
174 qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); 174 qDebug("ResourceSharpDTM::load: %s", fileName().latin1());
175 175
176 bool res = false; 176 bool res = false;
177 177
178 CardId id; 178 CardId id;
179 179
180 for (bool res=mAccess->first(); res == true; res=mAccess->next()) 180 for (bool res=mAccess->first(); res == true; res=mAccess->next())
181 { 181 {
182 id = mAccess->cardId(); 182 id = mAccess->cardId();
183 183
184 KABC::Addressee addressee; 184 KABC::Addressee addressee;
185 185
186 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 186 res = mConverter->sharpToAddressee( id, mAccess, addressee );
187 187
188 if ( !addressee.isEmpty() && res ) 188 if ( !addressee.isEmpty() && res )
189 { 189 {
190 addressee.setResource( this ); 190 addressee.setResource( this );
191 addressBook()->insertAddressee( addressee ); 191 addressBook()->insertAddressee( addressee );
192 } 192 }
193 } 193 }
194 194
195 return true; 195 return true;
196} 196}
197 197
198bool ResourceSharpDTM::save( Ticket *ticket ) 198bool ResourceSharpDTM::save( Ticket *ticket )
199{ 199{
200 qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); 200 qDebug("ResourceSharpDTM::save: %s", fileName().latin1());
201 201
202 mDirWatch.stopScan(); 202 mDirWatch.stopScan();
203 203
204 KABC::AddressBook::Iterator it; 204 KABC::AddressBook::Iterator it;
205 bool res; 205 bool res;
206 KABC::Addressee::List changedAddressees; 206 KABC::Addressee::List changedAddressees;
207 207
208 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 208 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
209 209
210 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 210 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
211 QString uid = (*it).originalExternalUID(); 211 QString uid = (*it).originalExternalUID();
212 CardId id ; 212 CardId id ;
213 bool res; 213 bool res;
214 if ( uid.isEmpty() ) 214 if ( uid.isEmpty() )
215 id = 0; 215 id = 0;
216 else 216 else
217 id = uid.toUInt(); 217 id = uid.toUInt();
218 KABC::Addressee addressee = (*it); 218 KABC::Addressee addressee = (*it);
219 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { 219 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
220 res = mAccess->startEditCard(id); 220 res = mAccess->startEditCard(id);
221 if (res == true) 221 if (res == true)
222 { 222 {
223 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 223 res = mConverter->addresseeToSharp( (*it), mAccess, id );
224 if (res == true) 224 if (res == true)
225 { 225 {
226 KABC::Addressee addressee; 226 KABC::Addressee addressee;
227 qDebug("1NEW id is %d", id);
228 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 227 res = mConverter->sharpToAddressee( id, mAccess, addressee );
229 addressee.setUid((*it).uid() ); 228 addressee.setUid((*it).uid() );
230 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); 229 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
231 changedAddressees.append( addressee );
232 res = mAccess->finishEditCard(&id); 230 res = mAccess->finishEditCard(&id);
233 qDebug("2NEW id is %d", id); 231 //qDebug("2NEW id is %d", id);
232 addressee.setExternalUID( QString::number( id ) );
233 addressee.setOriginalExternalUID( QString::number( id ) );
234 changedAddressees.append( addressee );
234 235
235 if (res == false) 236 if (res == false)
236 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 237 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
237 else { 238
238 qDebug("added card success ");
239 }
240 } 239 }
241 else 240 else
242 { 241 {
243 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); 242 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
244 mAccess->cancelEditCard(); 243 mAccess->cancelEditCard();
245 } 244 }
246 } 245 }
247 246
248 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 247 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
249 res = mAccess->deleteCard(&id); 248 res = mAccess->deleteCard(&id);
250 if ( res ) 249 if ( res )
251 qDebug("delete success "); 250 qDebug("delete success ");
252 else 251 else
253 qDebug("delete error "); 252 qDebug("delete error ");
254 253
255 254
256 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 255 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
257 //changed 256 //changed
257 qDebug("changed ****");
258 res = mAccess->startEditCard(id); 258 res = mAccess->startEditCard(id);
259 if (res == true) 259 if (res == true)
260 { 260 {
261 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 261 res = mConverter->addresseeToSharp( (*it), mAccess, id );
262 if (res == true) 262 if (res == true)
263 { 263 {
264 KABC::Addressee addressee; 264 KABC::Addressee addressee;
265 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 265 res = mConverter->sharpToAddressee( id, mAccess, addressee );
266 addressee.setUid((*it).uid() ); 266 addressee.setUid((*it).uid() );
267 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); 267 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
268 changedAddressees.append( addressee ); 268 changedAddressees.append( addressee );
269 res = mAccess->finishEditCard(&id); 269 res = mAccess->finishEditCard(&id);
270 if (res == false) 270 if (res == false)
271 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 271 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
272 else { 272
273 qDebug("change card succes ");
274 }
275 } 273 }
276 else 274 else
277 { 275 {
278 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); 276 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
279 mAccess->cancelEditCard(); 277 mAccess->cancelEditCard();
280 } 278 }
281 } 279 }
282 } 280 }
283
284
285
286
287
288
289
290
291 }
292
293#if 0
294 // old code
295 CardId id = 0;// 0 means new card
296 KABC::Addressee addressee = (*it);
297
298 res = mAccess->startEditCard(id);
299 if (res == true)
300 {
301 res = mConverter->addresseeToSharp( *it, mAccess, id );
302 if (res == true)
303 {
304 res = mAccess->finishEditCard(&id);
305 if (res == false)
306 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
307 } 281 }
308 else
309 {
310 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
311 mAccess->cancelEditCard();
312 }
313 }
314 else
315 {
316 qDebug("Unable to add new card. Addressee: %s", addressee.formattedName().latin1());
317 }
318#endif
319 282
320 } 283 }
321 KABC::Addressee::List::Iterator it2; 284 KABC::Addressee::List::Iterator it2;
322 for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) 285 for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 )
323 addressBook()->insertAddressee((*it2)); 286 addressBook()->insertAddressee((*it2));
324 //US mAccess->save(); 287 //US mAccess->save();
325 288
326 mDirWatch.startScan(); 289 mDirWatch.startScan();
327 delete ticket; 290 delete ticket;
328 unlock( fileName() ); 291 unlock( fileName() );
329 292
330 return true; 293 return true;
331} 294}
332 295
333bool ResourceSharpDTM::lock( const QString &lockfileName ) 296bool ResourceSharpDTM::lock( const QString &lockfileName )
334{ 297{
335#ifdef ALLOW_LOCKING 298#ifdef ALLOW_LOCKING
336 qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); 299 qDebug("ResourceSharpDTM::lock: %s", fileName().latin1());
337 300
338 kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; 301 kdDebug(5700) << "ResourceSharpDTM::lock()" << endl;
339 302
340 QString fn = lockfileName; 303 QString fn = lockfileName;
341 304
342 KURL url(fn); 305 KURL url(fn);
343 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 306 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
344 307
345 kdDebug(5700) << "-- lock name: " << lockName << endl; 308 kdDebug(5700) << "-- lock name: " << lockName << endl;
346 309
347 if (QFile::exists( lockName )) 310 if (QFile::exists( lockName ))
348 { 311 {
349 qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); 312 qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName());
350 return false; 313 return false;
351 } 314 }
352 315
353 316
354 QString lockUniqueName; 317 QString lockUniqueName;
355 lockUniqueName = fn + KApplication::randomString( 8 ); 318 lockUniqueName = fn + KApplication::randomString( 8 );
356 319
357 url = lockUniqueName; 320 url = lockUniqueName;
358//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 321//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
359 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 322 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
360 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 323 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
361 324
362 // Create unique file 325 // Create unique file
363 QFile file( mLockUniqueName ); 326 QFile file( mLockUniqueName );
364 file.open( IO_WriteOnly ); 327 file.open( IO_WriteOnly );
365 file.close(); 328 file.close();
366 329
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
index b065bf3..f3bf2c5 100644
--- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
@@ -1,147 +1,157 @@
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 30
30 31
31#include "sharpdtmconverter.h" 32#include "sharpdtmconverter.h"
32 33
33#include <sl/slcategories.h> 34#include <sl/slcategories.h>
35#include <libkdepim/ksyncprofile.h>
34//US #include <qpe/categoryselect.h> 36//US #include <qpe/categoryselect.h>
35 37
36 38
37using namespace KABC; 39using namespace KABC;
38using namespace SlCategory; 40using namespace SlCategory;
39 41
40SharpDTMConverter::SharpDTMConverter() : catDB(0) 42SharpDTMConverter::SharpDTMConverter() : catDB(0)
41{ 43{
42} 44}
43 45
44SharpDTMConverter::~SharpDTMConverter() 46SharpDTMConverter::~SharpDTMConverter()
45{ 47{
46 deinit(); 48 deinit();
47} 49}
48 50
49bool SharpDTMConverter::init() 51bool SharpDTMConverter::init()
50{ 52{
51 catDB = new SlCategory::SlCategories(); 53 catDB = new SlCategory::SlCategories();
52 54
53 if (!catDB) 55 if (!catDB)
54 return false; 56 return false;
55 57
56// catDB->load( categoryFileName() ); 58// catDB->load( categoryFileName() );
57 return true; 59 return true;
58} 60}
59 61
60void SharpDTMConverter::deinit() 62void SharpDTMConverter::deinit()
61{ 63{
62 if (catDB) 64 if (catDB)
63 { 65 {
64 delete catDB; 66 delete catDB;
65 catDB = 0; 67 catDB = 0;
66 } 68 }
67} 69}
68 70
69bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) 71bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr )
70{ 72{
71 SlZDataBase* db = (SlZDataBase*)database; 73 SlZDataBase* db = (SlZDataBase*)database;
72 74
73 // for syncing: we need setting of the two fields 75 // for syncing: we need setting of the two fields
74 addr.setExternalUID( QString::number( contact ) ); 76 addr.setExternalUID( QString::number( contact ) );
75 addr.setOriginalExternalUID( QString::number( contact ) ); 77 addr.setOriginalExternalUID( QString::number( contact ) );
78 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
76 79
77 80
78 // name 81 // name
79 qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); 82 //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!");
80 addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); 83 addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix
81 84
82 addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); 85 addr.setFamilyName( db->readField(ZdbAdrs::LastName) );
83 addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); 86 addr.setGivenName( db->readField(ZdbAdrs::FirstName) );
84 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); 87 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) );
85 addr.setPrefix( db->readField(ZdbAdrs::Title) ); 88 addr.setPrefix( db->readField(ZdbAdrs::Title) );
86 addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); 89 addr.setSuffix( db->readField(ZdbAdrs::Suffix) );
87 90
88 91
89 // email
90 QString emailstr = db->readField(ZdbAdrs::Emails); 92 QString emailstr = db->readField(ZdbAdrs::Emails);
91 qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); 93 emailstr.replace( QRegExp(","), " " );
92 QStringList emails = QStringList::split(",", emailstr); 94 emailstr.replace( QRegExp(";"), " " );
93 95 emailstr.replace( QRegExp(":"), " " );
96 //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1());
97 QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace());
98 bool defE = false;
99 bool found = false;
94 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 100 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
95 addr.insertEmail( *it, ((*it) == db->readField(ZdbAdrs::DefaultEmail)) ); 101 if (found )
102 defE = false;
103 else
104 found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower());
105 addr.insertEmail( *it, defE );
96 } 106 }
97 107 if ( ! found )
98 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) 108 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty())
99 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); 109 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true);
100 110
101 // home 111 // home
102 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || 112 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) ||
103 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || 113 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) ||
104 (!db->readField(ZdbAdrs::HomeState).isEmpty()) || 114 (!db->readField(ZdbAdrs::HomeState).isEmpty()) ||
105 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || 115 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) ||
106 (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) 116 (!db->readField(ZdbAdrs::HomeCountry).isEmpty()))
107 { 117 {
108 Address homeaddress; 118 Address homeaddress;
109 homeaddress.setType(Address::Home); 119 homeaddress.setType(Address::Home);
110//US homeaddress.setPostOfficeBox( "" ); 120//US homeaddress.setPostOfficeBox( "" );
111//US homeaddress.setExtended( "" ); 121//US homeaddress.setExtended( "" );
112 homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet) ); 122 homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet) );
113 homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); 123 homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) );
114 homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); 124 homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) );
115 homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); 125 homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) );
116 homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); 126 homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) );
117 127
118 addr.insertAddress( homeaddress ); 128 addr.insertAddress( homeaddress );
119 } 129 }
120 130
121 if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) 131 if (!db->readField(ZdbAdrs::HomePhone).isEmpty())
122 { 132 {
123 PhoneNumber homephone; 133 PhoneNumber homephone;
124 homephone.setType( PhoneNumber::Home ); 134 homephone.setType( PhoneNumber::Home );
125 homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); 135 homephone.setNumber( db->readField(ZdbAdrs::HomePhone) );
126 addr.insertPhoneNumber( homephone ); 136 addr.insertPhoneNumber( homephone );
127 } 137 }
128 138
129 if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) 139 if (!db->readField(ZdbAdrs::HomeFax).isEmpty())
130 { 140 {
131 PhoneNumber homefax; 141 PhoneNumber homefax;
132 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 142 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
133 homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); 143 homefax.setNumber( db->readField(ZdbAdrs::HomeFax) );
134 addr.insertPhoneNumber( homefax ); 144 addr.insertPhoneNumber( homefax );
135 } 145 }
136 146
137 if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) 147 if (!db->readField(ZdbAdrs::HomeMobile).isEmpty())
138 { 148 {
139 PhoneNumber homemobile; 149 PhoneNumber homemobile;
140 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 150 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
141 homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); 151 homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) );
142 addr.insertPhoneNumber( homemobile ); 152 addr.insertPhoneNumber( homemobile );
143 } 153 }
144 154
145 addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); 155 addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) );
146 156
147 157
@@ -153,238 +163,269 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa
153 (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) 163 (!db->readField(ZdbAdrs::BusinessCountry).isEmpty()))
154 { 164 {
155 Address businessaddress; 165 Address businessaddress;
156 businessaddress.setType(Address::Work); 166 businessaddress.setType(Address::Work);
157//US businessaddress.setPostOfficeBox( "" ); 167//US businessaddress.setPostOfficeBox( "" );
158//US businessaddress.setExtended( "" ); 168//US businessaddress.setExtended( "" );
159 businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet) ); 169 businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet) );
160 businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); 170 businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) );
161 businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); 171 businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) );
162 businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); 172 businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) );
163 businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); 173 businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) );
164 174
165 addr.insertAddress( businessaddress ); 175 addr.insertAddress( businessaddress );
166 } 176 }
167 177
168 178
169 if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) 179 if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty())
170 { 180 {
171 PhoneNumber businessphone; 181 PhoneNumber businessphone;
172 businessphone.setType( PhoneNumber::Work ); 182 businessphone.setType( PhoneNumber::Work );
173 businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); 183 businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) );
174 addr.insertPhoneNumber( businessphone ); 184 addr.insertPhoneNumber( businessphone );
175 } 185 }
176 186
177 if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) 187 if (!db->readField(ZdbAdrs::BusinessFax).isEmpty())
178 { 188 {
179 PhoneNumber businessfax; 189 PhoneNumber businessfax;
180 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 190 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
181 businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); 191 businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) );
182 addr.insertPhoneNumber( businessfax ); 192 addr.insertPhoneNumber( businessfax );
183 } 193 }
184 194
185 if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) 195 if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty())
186 { 196 {
187 PhoneNumber businessmobile; 197 PhoneNumber businessmobile;
188 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 198 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
189 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); 199 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) );
190 addr.insertPhoneNumber( businessmobile ); 200 addr.insertPhoneNumber( businessmobile );
191 } 201 }
192 202
193 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) 203 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty())
194 { 204 {
195 PhoneNumber businesspager; 205 PhoneNumber businesspager;
196 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 206 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
197 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); 207 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) );
198 addr.insertPhoneNumber( businesspager ); 208 addr.insertPhoneNumber( businesspager );
199 } 209 }
200 210
201 addr.setRole( db->readField(ZdbAdrs::JobTitle) ); //? 211 addr.setRole( db->readField(ZdbAdrs::JobTitle) );
202 addr.setOrganization( db->readField(ZdbAdrs::Company) ); 212 addr.setOrganization( db->readField(ZdbAdrs::Company) );
203 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); 213 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) );
204 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); 214 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) );
205 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); 215 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) );
206 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); 216 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) );
207 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); 217 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) );
208 218
209 //personal 219 //personal
210 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); 220 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) );
211 221
212 QString gen = db->readField(ZdbAdrs::Gender); 222 QString gen = db->readField(ZdbAdrs::Gender);
213 qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); 223 //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1());
214 qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); 224 //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited");
215 225
216 if (gen == "male") 226 if (gen == "male")
217 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 227 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
218 else if (gen == "female") 228 else if (gen == "female")
219 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 229 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
220 230
221 231
222 QDate ann = db->readDateField(ZdbAdrs::Anniversary); 232 QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) );
223
224 if (ann.isValid()) { 233 if (ann.isValid()) {
225 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); 234 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
226//US 235 //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1());
227// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
228 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 236 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
229 } 237 }
238
230 239
231 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); 240 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) );
232 241
233 242
234 QDate birthd = db->readDateField(ZdbAdrs::Birthday); 243 QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) );
244 //qDebug("birtd %s ", birthd.toString().latin1());
235 if (birthd.isValid()) 245 if (birthd.isValid())
236 addr.setBirthday( birthd ); 246 addr.setBirthday( birthd );
237 247
238 addr.setNickName( db->readField(ZdbAdrs::Nickname) ); 248 addr.setNickName( db->readField(ZdbAdrs::Nickname) );
239 249
240 // others 250 // others
241 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 251 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
242 QString notes = db->readField(ZdbAdrs::Notes); 252 QString notes = db->readField(ZdbAdrs::Notes);
243 notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; 253 //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n";
244 254 if ( addr.url().isEmpty() )
255 addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) );
245 addr.setNote( db->readField(ZdbAdrs::Notes) ); 256 addr.setNote( db->readField(ZdbAdrs::Notes) );
246 257
247 258
248 259
249//US QString groups() const { return find( Qtopia::Groups ); } 260//US QString groups() const { return find( Qtopia::Groups ); }
250//US QStringList groupList() const; 261//US QStringList groupList() const;
251 262
252 qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); 263 //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" );
253 QArray<int> catArray = db->readCategories(); 264 QArray<int> catArray = db->readCategories();
254 QString cat; 265 QString cat;
255 266
256 for ( unsigned int i=0; i < catArray.size(); i++ ) { 267 for ( unsigned int i=0; i < catArray.size(); i++ ) {
257 cat = catDB->label(catArray[i]); 268 cat = catDB->label(catArray[i]);
258 if ( cat.isEmpty() ) 269 if ( cat.isEmpty() )
259 addr.insertCategory(QString::number(catArray[i])); 270 addr.insertCategory(QString::number(catArray[i]));
260 else 271 else
261 addr.insertCategory( cat ); 272 addr.insertCategory( cat );
262 } 273 }
263 274
264 return true; 275 return true;
265} 276}
266 277
267bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) 278bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact )
268{ 279{
280 bool cellHome = false, cellWork = false;
269 // name 281 // name
270 database->writeField(ZdbAdrs::LastName, addr.familyName()); 282 database->writeField(ZdbAdrs::LastName, addr.familyName());
271 database->writeField(ZdbAdrs::FirstName, addr.givenName()); 283 database->writeField(ZdbAdrs::FirstName, addr.givenName());
272 database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); 284 database->writeField(ZdbAdrs::MiddleName, addr.additionalName());
273 database->writeField(ZdbAdrs::Title, addr.prefix()); 285 database->writeField(ZdbAdrs::Title, addr.prefix());
274 database->writeField(ZdbAdrs::Suffix, addr.suffix()); 286 database->writeField(ZdbAdrs::Suffix, addr.suffix());
275 287
276 qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!"); 288 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() );
277 database->writeField(ZdbAdrs::FileAs, addr.formattedName()); 289 database->writeField(ZdbAdrs::FileAs, addr.formattedName());
278 290 database->writeField(ZdbAdrs::FullName, addr.formattedName());
279 291
280 // email 292 // email
281 qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); 293 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
282 qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); 294 //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee");
283 QString emails = addr.emails().join(","); 295 QString emails = addr.emails().join(" ");
284 database->writeField(ZdbAdrs::Emails, emails ); 296 database->writeField(ZdbAdrs::Emails, emails );
285 297
286 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); 298 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() );
287 299
288 300
289 // home 301 // home
290 const Address homeaddress = addr.address(Address::Home); 302 const Address homeaddress = addr.address(Address::Home);
291 if (!homeaddress.isEmpty()) { 303 if (!homeaddress.isEmpty()) {
292 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); 304 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street());
293 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); 305 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality());
294 database->writeField(ZdbAdrs::HomeState, homeaddress.region()); 306 database->writeField(ZdbAdrs::HomeState, homeaddress.region());
295 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); 307 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode());
296 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); 308 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country());
297 } 309 }
298 310
299 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 311 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
300 if (!homephone.number().isEmpty()) 312 if (!homephone.number().isEmpty())
301 database->writeField(ZdbAdrs::HomePhone, homephone.number()); 313 database->writeField(ZdbAdrs::HomePhone, homephone.number());
302 314
303 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 315 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
304 if (!homefax.number().isEmpty()) 316 if (!homefax.number().isEmpty())
305 database->writeField(ZdbAdrs::HomeFax, homefax.number()); 317 database->writeField(ZdbAdrs::HomeFax, homefax.number());
306 318
307 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 319 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
308 if (!homemobile.number().isEmpty()) 320 if (!homemobile.number().isEmpty()) {
309 database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); 321 database->writeField(ZdbAdrs::HomeMobile, homemobile.number());
322 cellHome = true;
323 }
310 324
311 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); 325 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url());
312 326
313 327
314 // business 328 // business
315 const Address businessaddress = addr.address(Address::Work); 329 const Address businessaddress = addr.address(Address::Work);
316 if (!businessaddress.isEmpty()) { 330 if (!businessaddress.isEmpty()) {
317 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); 331 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street());
318 database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); 332 database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality());
319 database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); 333 database->writeField(ZdbAdrs::BusinessState, businessaddress.region());
320 database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); 334 database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode());
321 database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); 335 database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country());
322 } 336 }
323 337
324 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 338 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
325 if (!businessphone.number().isEmpty()) 339 if (!businessphone.number().isEmpty())
326 database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); 340 database->writeField(ZdbAdrs::BusinessPhone, businessphone.number());
327 341
328 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 342 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
329 if (!businessfax.number().isEmpty()) 343 if (!businessfax.number().isEmpty())
330 database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); 344 database->writeField(ZdbAdrs::BusinessFax, businessfax.number());
331 345
332 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 346 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
333 if (!businessmobile.number().isEmpty()) 347 if (!businessmobile.number().isEmpty()) {
334 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); 348 cellWork = true;
349 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number());
350 }
351 PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell );
352 if (!businessmobile.number().isEmpty()) {
353 if ( ! cellHome )
354 database->writeField(ZdbAdrs::HomeMobile, mobile.number());
355 else if (! cellWork )
356 database->writeField(ZdbAdrs::BusinessMobile, mobile.number());
357 }
335 358
336 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 359 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
337 if (!businesspager.number().isEmpty()) 360 if (!businesspager.number().isEmpty())
338 database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); 361 database->writeField(ZdbAdrs::BusinessPager, businesspager.number());
339 362
340 database->writeField(ZdbAdrs::JobTitle, addr.role()); 363 database->writeField(ZdbAdrs::JobTitle, addr.role());
341 database->writeField(ZdbAdrs::Company, addr.organization()); 364 database->writeField(ZdbAdrs::Company, addr.organization());
342 365
343 database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); 366 database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" ));
344 database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 367 database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
345 database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); 368 database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" ));
346 database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 369 database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
347 database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); 370 database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" ));
348 371
349 //personal 372 //personal
350 database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); 373 database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" ));
351 374
352 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); 375 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
353 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());
354 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?");
355 qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); 378 //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee");
356 if (gt = "male") 379 if (gt == "male")
357 database->writeField(ZdbAdrs::Gender, "male"); 380 database->writeField(ZdbAdrs::Gender, "male");
358 else if (gt = "female") 381 else if (gt == "female")
359 database->writeField(ZdbAdrs::Gender, "female"); 382 database->writeField(ZdbAdrs::Gender, "female");
360 else 383 else
361 database->writeField(ZdbAdrs::Gender, ""); 384 database->writeField(ZdbAdrs::Gender, "");
362 385
363 386
364 QDate dt = KGlobal::locale()->readDate( 387 QDate dt = KGlobal::locale()->readDate(
365 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 388 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
366 database->writeField(ZdbAdrs::Anniversary, dt ); 389 if ( dt.isValid() ) {
367 390 QString dateS = KGlobal::locale()->formatDate(dt, true );
391 database->writeField(ZdbAdrs::Anniversary, dateS );
392 }
368 database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); 393 database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" ));
369 394 dt = addr.birthday().date();
370 database->writeField(ZdbAdrs::Birthday, addr.birthday().date()); 395 if ( dt.isValid() ) {
396 QString dateS = KGlobal::locale()->formatDate(dt, true );
397 database->writeField(ZdbAdrs::Birthday, dateS);
398 }
371 database->writeField(ZdbAdrs::Nickname, addr.nickName()); 399 database->writeField(ZdbAdrs::Nickname, addr.nickName());
372 400
373 // other 401 // other
374 database->writeField(ZdbAdrs::Notes, addr.note()); 402 database->writeField(ZdbAdrs::Notes, addr.note());
375 403
376//US QString groups() const { return find( Qtopia::Groups ); } 404//US QString groups() const { return find( Qtopia::Groups ); }
377//US QStringList groupList() const; 405//US QStringList groupList() const;
378 406
379 407
380 qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); 408 //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works");
381 409
382 QStringList cats = addr.categories(); 410 QStringList cats = addr.categories();
411 int ii;
412 for ( ii = 0; ii < cats.count() ;++ii ) {
413 if ( !catDB->exists( cats[ii] ))
414 catDB->addCategory(cats[ii]);
415 }
383 QArray<int> iar; 416 QArray<int> iar;
384 if ( !cats.isEmpty() ) { 417 if ( !cats.isEmpty() ) {
385 QArray<int> iar = catDB->ids(cats); 418 QArray<int> iar = catDB->ids(cats);
419 qDebug("***cat count is %d ", iar.count());
386 database->updateCategories(contact, iar); 420 database->updateCategories(contact, iar);
387 } 421 }
388 422
389 return true; 423 return true;
390} 424}
425
426QDate SharpDTMConverter::convertDate( QString s)
427{
428 QDate dt = KGlobal::locale()->readDate( s );
429 return dt;
430 return QDate ();
431}
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.h b/kabc/plugins/sharpdtm/sharpdtmconverter.h
index 99e0413..a04083e 100644
--- a/kabc/plugins/sharpdtm/sharpdtmconverter.h
+++ b/kabc/plugins/sharpdtm/sharpdtmconverter.h
@@ -33,54 +33,55 @@ $Id$
33 33
34#include "addressee.h" 34#include "addressee.h"
35 35
36namespace SlCategory { 36namespace SlCategory {
37 class SlCategories; 37 class SlCategories;
38} 38}
39 39
40class SlZDataBase; 40class SlZDataBase;
41 41
42namespace KABC { 42namespace KABC {
43 43
44class SharpDTMConverter 44class SharpDTMConverter
45{ 45{
46public: 46public:
47 47
48 /** 48 /**
49 * Constructor. 49 * Constructor.
50 */ 50 */
51 SharpDTMConverter(); 51 SharpDTMConverter();
52 52
53 /** 53 /**
54 * Destructor. 54 * Destructor.
55 */ 55 */
56 virtual ~SharpDTMConverter(); 56 virtual ~SharpDTMConverter();
57 57
58 bool init(); 58 bool init();
59 void deinit(); 59 void deinit();
60 60
61 /** 61 /**
62 * Converts a given sharp card to an addressee. 62 * Converts a given sharp card to an addressee.
63 * 63 *
64 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one. 64 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one.
65 * @param database The sharp database pointer we use for the conversion 65 * @param database The sharp database pointer we use for the conversion
66 * @param addr The addressee. 66 * @param addr The addressee.
67 */ 67 */
68 bool sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ); 68 bool sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr );
69 69
70 /** 70 /**
71 * Converts an addressee to a sharp dtm contact. 71 * Converts an addressee to a sharp dtm contact.
72 * 72 *
73 * @param addr The addressee. 73 * @param addr The addressee.
74 * @param database The sharp database pointer we use for the conversion 74 * @param database The sharp database pointer we use for the conversion
75 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one. 75 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one.
76 */ 76 */
77 bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ); 77 bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact );
78 78
79 private: 79 private:
80 SlCategory::SlCategories* catDB; 80 SlCategory::SlCategories* catDB;
81 QDate convertDate( QString );
81 82
82 83
83}; 84};
84 85
85} 86}
86#endif 87#endif