-rw-r--r-- | kabc/addressbook.cpp | 10 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 4 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 52 |
3 files changed, 12 insertions, 54 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 9e61261..f3744bc 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -643,84 +643,84 @@ bool AddressBook::saveABphone( QString fileName ) | |||
643 | { | 643 | { |
644 | //smplifyAddressees(); | 644 | //smplifyAddressees(); |
645 | qDebug("saveABphone:: saving AB... "); | 645 | qDebug("saveABphone:: saving AB... "); |
646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
647 | return false; | 647 | return false; |
648 | qDebug("saveABphone:: writing to phone... "); | 648 | qDebug("saveABphone:: writing to phone... "); |
649 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 649 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
650 | return false; | 650 | return false; |
651 | } | 651 | } |
652 | qDebug("saveABphone:: re-reading from phone... "); | 652 | qDebug("saveABphone:: re-reading from phone... "); |
653 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 653 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
654 | return false; | 654 | return false; |
655 | } | 655 | } |
656 | return true; | 656 | return true; |
657 | } | 657 | } |
658 | bool AddressBook::saveAB() | 658 | bool AddressBook::saveAB() |
659 | { | 659 | { |
660 | bool ok = true; | 660 | bool ok = true; |
661 | 661 | ||
662 | deleteRemovedAddressees(); | 662 | deleteRemovedAddressees(); |
663 | Iterator ait; | 663 | Iterator ait; |
664 | for ( ait = begin(); ait != end(); ++ait ) { | 664 | for ( ait = begin(); ait != end(); ++ait ) { |
665 | if ( !(*ait).IDStr().isEmpty() ) { | 665 | if ( !(*ait).IDStr().isEmpty() ) { |
666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
667 | } | 667 | } |
668 | } | 668 | } |
669 | KRES::Manager<Resource>::ActiveIterator it; | 669 | KRES::Manager<Resource>::ActiveIterator it; |
670 | KRES::Manager<Resource> *manager = d->mManager; | 670 | KRES::Manager<Resource> *manager = d->mManager; |
671 | qDebug("SaveAB::saving..." ); | 671 | qDebug("SaveAB::saving..." ); |
672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
673 | qDebug("SaveAB::checking resource..." ); | 673 | qDebug("SaveAB::checking resource..." ); |
674 | if ( (*it)->readOnly() ) | 674 | if ( (*it)->readOnly() ) |
675 | qDebug("resource is readonly." ); | 675 | qDebug("SaveAB::resource is readonly." ); |
676 | if ( (*it)->isOpen() ) | 676 | if ( (*it)->isOpen() ) |
677 | qDebug("resource is open" ); | 677 | qDebug("SaveAB::resource is open" ); |
678 | 678 | ||
679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
680 | Ticket *ticket = requestSaveTicket( *it ); | 680 | Ticket *ticket = requestSaveTicket( *it ); |
681 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 681 | qDebug("SaveAB::StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
682 | if ( !ticket ) { | 682 | if ( !ticket ) { |
683 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) | 683 | qDebug( i18n( "SaveAB::Unable to save to resource '%1'. It is locked." ) |
684 | .arg( (*it)->resourceName() ) ); | 684 | .arg( (*it)->resourceName() ) ); |
685 | return false; | 685 | return false; |
686 | } | 686 | } |
687 | 687 | ||
688 | //if ( !save( ticket ) ) | 688 | //if ( !save( ticket ) ) |
689 | if ( ticket->resource() ) { | 689 | if ( ticket->resource() ) { |
690 | QString name = ticket->resource()->resourceName(); | 690 | QString name = ticket->resource()->resourceName(); |
691 | if ( ! ticket->resource()->save( ticket ) ) | 691 | if ( ! ticket->resource()->save( ticket ) ) |
692 | ok = false; | 692 | ok = false; |
693 | else | 693 | else |
694 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); | 694 | qDebug("SaveAB::resource saved '%s'", name.latin1() ); |
695 | 695 | ||
696 | } else | 696 | } else |
697 | ok = false; | 697 | ok = false; |
698 | 698 | ||
699 | } | 699 | } |
700 | } | 700 | } |
701 | return ok; | 701 | return ok; |
702 | } | 702 | } |
703 | 703 | ||
704 | AddressBook::Iterator AddressBook::begin() | 704 | AddressBook::Iterator AddressBook::begin() |
705 | { | 705 | { |
706 | Iterator it = Iterator(); | 706 | Iterator it = Iterator(); |
707 | it.d->mIt = d->mAddressees.begin(); | 707 | it.d->mIt = d->mAddressees.begin(); |
708 | return it; | 708 | return it; |
709 | } | 709 | } |
710 | 710 | ||
711 | AddressBook::ConstIterator AddressBook::begin() const | 711 | AddressBook::ConstIterator AddressBook::begin() const |
712 | { | 712 | { |
713 | ConstIterator it = ConstIterator(); | 713 | ConstIterator it = ConstIterator(); |
714 | it.d->mIt = d->mAddressees.begin(); | 714 | it.d->mIt = d->mAddressees.begin(); |
715 | return it; | 715 | return it; |
716 | } | 716 | } |
717 | 717 | ||
718 | AddressBook::Iterator AddressBook::end() | 718 | AddressBook::Iterator AddressBook::end() |
719 | { | 719 | { |
720 | Iterator it = Iterator(); | 720 | Iterator it = Iterator(); |
721 | it.d->mIt = d->mAddressees.end(); | 721 | it.d->mIt = d->mAddressees.end(); |
722 | return it; | 722 | return it; |
723 | } | 723 | } |
724 | 724 | ||
725 | AddressBook::ConstIterator AddressBook::end() const | 725 | AddressBook::ConstIterator AddressBook::end() const |
726 | { | 726 | { |
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 6413b42..e8f8bdd 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -109,70 +109,70 @@ void ResourceSharpDTM::writeConfig( KConfig *config ) | |||
109 | } | 109 | } |
110 | 110 | ||
111 | Ticket *ResourceSharpDTM::requestSaveTicket() | 111 | Ticket *ResourceSharpDTM::requestSaveTicket() |
112 | { | 112 | { |
113 | 113 | ||
114 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); | 114 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); |
115 | 115 | ||
116 | if ( !addressBook() ) return 0; | 116 | if ( !addressBook() ) return 0; |
117 | return createTicket( this ); | 117 | return createTicket( this ); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | bool ResourceSharpDTM::doOpen() | 121 | bool ResourceSharpDTM::doOpen() |
122 | { | 122 | { |
123 | if (!mConverter) | 123 | if (!mConverter) |
124 | return false; | 124 | return false; |
125 | return true; | 125 | return true; |
126 | } | 126 | } |
127 | 127 | ||
128 | void ResourceSharpDTM::doClose() | 128 | void ResourceSharpDTM::doClose() |
129 | { | 129 | { |
130 | return; | 130 | return; |
131 | } | 131 | } |
132 | 132 | ||
133 | bool ResourceSharpDTM::load() | 133 | bool ResourceSharpDTM::load() |
134 | { | 134 | { |
135 | if (!mConverter) | 135 | if (!mConverter) |
136 | return false; | 136 | return false; |
137 | QString fileN = SlZDataBase::addressbookFileName(); | 137 | QString fileN = SlZDataBase::addressbookFileName(); |
138 | if ( ! mAccess ) { | 138 | if ( ! mAccess ) { |
139 | mAccess = new SlZDataBase(fileN, | 139 | mAccess = new SlZDataBase(fileN, |
140 | SlZDataBase::addressbookItems(), | 140 | SlZDataBase::addressbookItems(), |
141 | 0, false); | 141 | 0, true); |
142 | } | 142 | } |
143 | if(mAccess == 0) | 143 | if(mAccess == 0) |
144 | return false; | 144 | return false; |
145 | 145 | ||
146 | qDebug("%xResourceSharpDTM::load: %s",this, fileName().latin1()); | 146 | qDebug("ResourceSharpDTM:: %x load: %s",this, fileName().latin1()); |
147 | bool res = false; | 147 | bool res = false; |
148 | CardId id; | 148 | CardId id; |
149 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) | 149 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) |
150 | { | 150 | { |
151 | id = mAccess->cardId(); | 151 | id = mAccess->cardId(); |
152 | KABC::Addressee addressee; | 152 | KABC::Addressee addressee; |
153 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 153 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
154 | if ( !addressee.isEmpty() && res ) | 154 | if ( !addressee.isEmpty() && res ) |
155 | { | 155 | { |
156 | addressee.setResource( this ); | 156 | addressee.setResource( this ); |
157 | addressBook()->insertAddressee( addressee ); | 157 | addressBook()->insertAddressee( addressee ); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | if(mAccess != 0) | 160 | if(mAccess != 0) |
161 | delete mAccess; | 161 | delete mAccess; |
162 | mAccess = 0; | 162 | mAccess = 0; |
163 | 163 | ||
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | 166 | ||
167 | bool ResourceSharpDTM::save( Ticket *ticket ) | 167 | bool ResourceSharpDTM::save( Ticket *ticket ) |
168 | { | 168 | { |
169 | if (!mConverter) | 169 | if (!mConverter) |
170 | return false; | 170 | return false; |
171 | QString fileN = SlZDataBase::addressbookFileName(); | 171 | QString fileN = SlZDataBase::addressbookFileName(); |
172 | if ( ! mAccess ) { | 172 | if ( ! mAccess ) { |
173 | mAccess = new SlZDataBase(fileN, | 173 | mAccess = new SlZDataBase(fileN, |
174 | SlZDataBase::addressbookItems(), | 174 | SlZDataBase::addressbookItems(), |
175 | 0, false); | 175 | 0, false); |
176 | } | 176 | } |
177 | if(mAccess == 0) | 177 | if(mAccess == 0) |
178 | return false; | 178 | return false; |
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index 95e16b6..4adcae4 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -391,96 +391,54 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
391 | database->writeField(ZdbAdrs::Anniversary, dateS ); | 391 | database->writeField(ZdbAdrs::Anniversary, dateS ); |
392 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | 392 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); |
393 | dt = addr.birthday().date(); | 393 | dt = addr.birthday().date(); |
394 | dateS = ""; | 394 | dateS = ""; |
395 | if ( dt.isValid() ) { | 395 | if ( dt.isValid() ) { |
396 | dateS = KGlobal::locale()->formatDate(dt, true ); | 396 | dateS = KGlobal::locale()->formatDate(dt, true ); |
397 | } | 397 | } |
398 | database->writeField(ZdbAdrs::Birthday, dateS); | 398 | database->writeField(ZdbAdrs::Birthday, dateS); |
399 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | 399 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); |
400 | 400 | ||
401 | // other | 401 | // other |
402 | database->writeField(ZdbAdrs::Notes, addr.note()); | 402 | database->writeField(ZdbAdrs::Notes, addr.note()); |
403 | 403 | ||
404 | //US QString groups() const { return find( Qtopia::Groups ); } | 404 | //US QString groups() const { return find( Qtopia::Groups ); } |
405 | //US QStringList groupList() const; | 405 | //US QStringList groupList() const; |
406 | 406 | ||
407 | 407 | ||
408 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | 408 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); |
409 | 409 | ||
410 | return true; | 410 | return true; |
411 | } | 411 | } |
412 | 412 | ||
413 | 413 | ||
414 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 414 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
415 | { | 415 | { |
416 | QStringList list = addr.categories(); | 416 | QStringList list = addr.categories(); |
417 | 417 | ||
418 | QArray<int> ids(list.count()); | 418 | QArray<int> ids(list.count()); |
419 | uint index = 0; | 419 | uint index = 0; |
420 | for(uint i=0; i<ids.size(); i++){ | 420 | for(uint i=0; i<ids.size(); i++){ |
421 | if(catDB->exists(list[i])){ | 421 | if(catDB->exists(list[i])){ |
422 | ids[index] = catDB->id(list[i]); | 422 | ids[index] = catDB->id(list[i]); |
423 | qDebug("set ex cat %d %s ",ids[index] , list[i].latin1()); | 423 | //qDebug("set exist cat %d %s ",ids[index] , list[i].latin1()); |
424 | index++; | 424 | index++; |
425 | } else { | 425 | } else { |
426 | ids[index] = catDB->addCategory(list[i]); | 426 | ids[index] = catDB->addCategory(list[i]); |
427 | qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); | 427 | //qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); |
428 | index++; | 428 | index++; |
429 | } | 429 | } |
430 | } | 430 | } |
431 | bool res ; | 431 | bool res ; |
432 | if ( res = database->updateCategories(contact, ids) ) | 432 | |
433 | qDebug("cat updated "); | 433 | if ( !(res = database->updateCategories(contact, ids) )) |
434 | else | 434 | qDebug("SharpDTMConverter::Error updating categories"); |
435 | qDebug("error cat updating "); | ||
436 | 435 | ||
437 | return res; | 436 | return res; |
438 | } | 437 | } |
439 | 438 | ||
440 | #if 0 | ||
441 | m_pCategories = new SlCategories; | ||
442 | catDB | ||
443 | |||
444 | if(categories == QString::null) return true; | ||
445 | QStringList list = CSVParser::parse(categories); | ||
446 | QArray<int> ids(list.count()); | ||
447 | uint index = 0; | ||
448 | for(uint i=0; i<ids.size(); i++){ | ||
449 | #if 0 | ||
450 | bool ok; | ||
451 | ids[index] = list[i].toInt(&ok); | ||
452 | if(ok){ | ||
453 | index++; | ||
454 | } else { | ||
455 | if(m_pCategories->exists(list[i])){ | ||
456 | ids[index] = m_pCategories->id(list[i]); | ||
457 | index++; | ||
458 | } | ||
459 | } | ||
460 | #else | ||
461 | if(m_pCategories->exists(list[i])){ | ||
462 | ids[index] = m_pCategories->id(list[i]); | ||
463 | index++; | ||
464 | } else if(m_addCategory){ | ||
465 | ids[index] = m_pCategories->addCategory(list[i]); | ||
466 | index++; | ||
467 | } | ||
468 | #endif | ||
469 | } | ||
470 | if(ids.size() > 0 && index == 0){ | ||
471 | return true; | ||
472 | } else if(index != ids.size()){ | ||
473 | ids.resize(index); | ||
474 | } | ||
475 | if(!m_pZdb->updateCategories(id, ids)){ | ||
476 | return false; | ||
477 | } | ||
478 | return true; | ||
479 | #endif | ||
480 | |||
481 | QDate SharpDTMConverter::convertDate( QString s) | 439 | QDate SharpDTMConverter::convertDate( QString s) |
482 | { | 440 | { |
483 | QDate dt = KGlobal::locale()->readDate( s ); | 441 | QDate dt = KGlobal::locale()->readDate( s ); |
484 | return dt; | 442 | return dt; |
485 | return QDate (); | 443 | return QDate (); |
486 | } | 444 | } |