author | zautrix <zautrix> | 2004-09-21 07:09:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-21 07:09:09 (UTC) |
commit | 1cf4cc6e7bf25ee309852c7c97155de86917289f (patch) (side-by-side diff) | |
tree | 721dd83559c3c7635d132b8a95cd6fdc4cdcc351 /kabc | |
parent | 434ddaa08e0a650422ef271332a1d11879028095 (diff) | |
download | kdepimpi-1cf4cc6e7bf25ee309852c7c97155de86917289f.zip kdepimpi-1cf4cc6e7bf25ee309852c7c97155de86917289f.tar.gz kdepimpi-1cf4cc6e7bf25ee309852c7c97155de86917289f.tar.bz2 |
qtopia format changes
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 135 |
1 files changed, 26 insertions, 109 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 1f90fcb..f9cabcb 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp @@ -31,50 +31,48 @@ $Id$ #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include <qregexp.h> //US #include <qtimer.h> #include <kapplication.h> #include <kconfig.h> #include <kdebug.h> #include <klocale.h> //US #include <ksavefile.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <qpe/pim/addressbookaccess.h> #include "resourceqtopiaconfig.h" #include "stdaddressbook.h" #include "qtopiaconverter.h" #include "syncprefwidget.h" #include "resourceqtopia.h" -#include <libkdepim/ksyncprofile.h> -#include <qpe/quuid.h> using namespace KABC; extern "C" { void *init_microkabc_qtopia() { return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); } } ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) : Resource( config, syncable ), mConverter (0) { // we can not choose the filename. Therefore use the default to display QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; init( fileName ); } ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable ) : Resource( 0, syncable ) { init( fileName ); } @@ -170,161 +168,80 @@ bool ResourceQtopia::load() AddressBookIterator it(*mAccess); const PimContact* contact; bool res; for (contact=it.toFirst(); it.current(); ++it) { contact = it.current(); KABC::Addressee addressee; res = mConverter->qtopiaToAddressee( (*contact), addressee ); if ( !addressee.isEmpty() && res ) { addressee.setResource( this ); addressBook()->insertAddressee( addressee ); } } return true; } bool ResourceQtopia::save( Ticket *ticket ) { - qDebug("ResourceQtopia::save: %s", fileName().latin1()); - - mDirWatch.stopScan(); - - KABC::AddressBook::Iterator it; - bool res; - KABC::Addressee::List changedAddressees; - QStringList addedUID; - for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { - //KABC::Addressee addressee = (*it); - // qDebug("AAAfor uid %s ", (*it).originalExternalUID().latin1() ); - if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { - QUuid uid( (*it).originalExternalUID() ); - bool ok; - PimContact c = mAccess->contactForId( uid, &ok ); - qDebug("ResourceQtopia::save:Found %d for uid %s ", ok,(*it).originalExternalUID().latin1() ); - res = mConverter->addresseeToQtopia( *it, c ); - if (res == true) { - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { - qDebug("skipping adding of contact "); - continue; - PimContact e; - AddressBookAccess Access2; - Access2.addContact(e); - const PimContact* contact; - bool res; - QString uid2, Ouid; - AddressBookIterator itt(Access2); - for (contact=itt.toFirst(); itt.current(); ++itt) - { - contact = itt.current(); - QString exuid = contact->uid().toString(); - Ouid =exuid; - int ente = exuid.find( "-0000"); - if ( exuid.left(1) == "{" ) - exuid = exuid.mid(1); - if ( ente > -1 ) - exuid = exuid.left( ente-1 ); - uid2 = exuid; - qDebug("trying find uid "); - if ( !addressBook()->containsExternalUid( uid2 ) ) { - qDebug("ab not contains "); - if ( !addedUID.contains( uid2 )) { - qDebug("list not contains "); - break; - } - } - - } - if ( !itt.current()) { - qDebug("ERROR uid "); - continue; - } - else - qDebug("ADD uid detected "); - - - QUuid uid3( Ouid); - PimContact d = Access2.contactForId( uid3, &ok ); - if ( ! ok ) { - qDebug("ADD: Error getting new uid "); - } else { - qDebug("NEW UID found "); - PimContact g = mAccess->contactForId( c.uid(), &ok ); - KABC::Addressee addressee; - mConverter->qtopiaToAddressee( g, addressee ); - addressee.setUid((*it).uid() ); - addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); - changedAddressees.append( addressee ); - addedUID.append( uid2 ); - } - - - } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { - qDebug("Remove contact "); - if ( ok ) - mAccess->removeContact(c); - else - qDebug("Error remove contact from qtopia "); - } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { - if ( ok ) { - qDebug("Update contact "); - mAccess->updateContact(c); - PimContact g = mAccess->contactForId( c.uid(), &ok ); - KABC::Addressee addressee; - mConverter->qtopiaToAddressee( g, addressee ); - addressee.setUid((*it).uid() ); - addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); - changedAddressees.append( addressee ); - } - else - qDebug("Error update contact from qtopia "); - - } - - } else { - qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); - } - } - } + qDebug("ResourceQtopia::save: %s", fileName().latin1()); - KABC::Addressee::List::Iterator it2; - for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) - addressBook()->insertAddressee((*it2)); + mDirWatch.stopScan(); + KABC::AddressBook::Iterator it; + bool res; + for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { + PimContact c; + KABC::Addressee addressee = (*it); - mDirWatch.startScan(); + res = mConverter->addresseeToQtopia( *it, c ); + if (res == true) + { + mAccess->addContact(c); +// if (res == false) +// qDebug("Unable to append Contact %s", c.fullName().latin1()); + } + else + { + qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); + } + } - delete ticket; - unlock( fileName() ); +// mAccess->addressBookUpdated(); - return true; + mDirWatch.startScan(); + + delete ticket; + unlock( fileName() ); + + return true; } bool ResourceQtopia::lock( const QString &lockfileName ) { qDebug("ResourceQtopia::lock: %s", fileName().latin1()); kdDebug(5700) << "ResourceQtopia::lock()" << endl; QString fn = lockfileName; KURL url(fn); QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); kdDebug(5700) << "-- lock name: " << lockName << endl; if (QFile::exists( lockName )) { qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); return false; } QString lockUniqueName; lockUniqueName = fn + KApplication::randomString( 8 ); |