summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-21 10:08:57 (UTC)
committer zautrix <zautrix>2004-09-21 10:08:57 (UTC)
commit19f445f0b6e7d4591db46b89e877ed9f4332ecd4 (patch) (side-by-side diff)
treefd21a5dc32332060197d792552ef1eb469e92175
parent1cf4cc6e7bf25ee309852c7c97155de86917289f (diff)
downloadkdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.zip
kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.tar.gz
kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.tar.bz2
more sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/file/resourcefile.cpp3
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp48
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.cpp17
-rw-r--r--kaddressbook/kabcore.cpp5
-rw-r--r--korganizer/calendarview.cpp4
5 files changed, 70 insertions, 7 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index b8c32d5..6cd63fd 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -158,16 +158,17 @@ Ticket *ResourceFile::requestSaveTicket()
#endif
return createTicket( this );
}
bool ResourceFile::doOpen()
{
QFile file( mFileName );
+ qDebug("ResourceFile::openfile %s ", mFileName.latin1());
if ( !file.exists() ) {
// try to create the file
bool ok = file.open( IO_WriteOnly );
if ( ok )
file.close();
return ok;
@@ -189,17 +190,17 @@ bool ResourceFile::doOpen()
void ResourceFile::doClose()
{
}
bool ResourceFile::load()
{
-
+ qDebug("ResourceFile::loadfile %s ", mFileName.latin1());
QFile file( mFileName );
if ( !file.open( IO_ReadOnly ) ) {
addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) );
return false;
}
// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 48d3985..437bda8 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -199,44 +199,54 @@ bool ResourceSharpDTM::save( Ticket *ticket )
{
qDebug("ResourceSharpDTM::save: %s", fileName().latin1());
mDirWatch.stopScan();
KABC::AddressBook::Iterator it;
bool res;
KABC::Addressee::List changedAddressees;
+ typedef QMap<int,QString> AddresseeMap;
+ AddresseeMap map;
+ CardId id ;
for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
QString uid = (*it).originalExternalUID();
- CardId id ;
bool res;
if ( uid.isEmpty() )
id = 0;
else
id = uid.toUInt();
KABC::Addressee addressee = (*it);
if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
res = mAccess->startEditCard(id);
if (res == true)
{
res = mConverter->addresseeToSharp( (*it), mAccess, id );
if (res == true)
{
+ res = mAccess->finishEditCard(&id);
+ //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
+ //(*it).setExternalUID( QString::number( id ) );
+ //(*it).setOriginalExternalUID( QString::number( id ) );
+ map.insert(id,(*it).uid());
+
+#if 0
KABC::Addressee addressee;
res = mConverter->sharpToAddressee( id, mAccess, addressee );
addressee.setUid((*it).uid() );
- addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
+ (it*).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
res = mAccess->finishEditCard(&id);
//qDebug("2NEW id is %d", id);
addressee.setExternalUID( QString::number( id ) );
addressee.setOriginalExternalUID( QString::number( id ) );
changedAddressees.append( addressee );
+#endif
if (res == false)
qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
}
else
{
qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
@@ -256,39 +266,71 @@ bool ResourceSharpDTM::save( Ticket *ticket )
//changed
qDebug("changed ****");
res = mAccess->startEditCard(id);
if (res == true)
{
res = mConverter->addresseeToSharp( (*it), mAccess, id );
if (res == true)
{
+ res = mAccess->finishEditCard(&id);
+ //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
+ map.insert(id,(*it).uid());
+
+#if 0
KABC::Addressee addressee;
res = mConverter->sharpToAddressee( id, mAccess, addressee );
addressee.setUid((*it).uid() );
addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
changedAddressees.append( addressee );
res = mAccess->finishEditCard(&id);
+#endif
if (res == false)
qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
}
else
{
qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
mAccess->cancelEditCard();
}
}
}
}
}
+ AddresseeMap::Iterator itam;
+ res;
+ for ( res=mAccess->first(); res == true; res=mAccess->next())
+ {
+ id = mAccess->cardId();
+ int idint = id;
+ itam = map.find( idint );
+ if ( itam != map.end() ) {
+ KABC::Addressee addressee;
+ qDebug("found change %d %s ", idint, itam.data().latin1());
+ res = mConverter->sharpToAddressee( id, mAccess, addressee );
+
+ if ( !addressee.isEmpty() && res )
+ {
+ addressee.setResource( this );
+ addressee.setUid( itam.data() );
+ addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
+ addressBook()->insertAddressee( addressee , false );
+ }
+ }
+ }
+#if 0
KABC::Addressee::List::Iterator it2;
- for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 )
+ for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) {
+ (*it2).computeCsum( "Sharp_DTM" );
+ qDebug("CSUM: %s ",(*it2).getCsum( "Sharp_DTM" ).latin1() );
addressBook()->insertAddressee((*it2));
+ }
+#endif
//US mAccess->save();
mDirWatch.startScan();
delete ticket;
unlock( fileName() );
return true;
}
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
index f3bf2c5..fccf625 100644
--- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
@@ -281,18 +281,29 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da
// name
database->writeField(ZdbAdrs::LastName, addr.familyName());
database->writeField(ZdbAdrs::FirstName, addr.givenName());
database->writeField(ZdbAdrs::MiddleName, addr.additionalName());
database->writeField(ZdbAdrs::Title, addr.prefix());
database->writeField(ZdbAdrs::Suffix, addr.suffix());
//qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() );
- database->writeField(ZdbAdrs::FileAs, addr.formattedName());
- database->writeField(ZdbAdrs::FullName, addr.formattedName());
+ QString formattedName = addr.formattedName();
+ if ( formattedName.isEmpty() ) {
+ if ( !addr.familyName().isEmpty() ) {
+ formattedName = addr.familyName();
+ if ( !addr.givenName().isEmpty() ) {
+ formattedName += ", ";
+ formattedName += addr.givenName();
+ }
+ } else
+ formattedName = addr.givenName();
+ }
+ database->writeField(ZdbAdrs::FileAs, formattedName);
+ database->writeField(ZdbAdrs::FullName, formattedName);
// email
//qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
//qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee");
QString emails = addr.emails().join(" ");
database->writeField(ZdbAdrs::Emails, emails );
database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() );
@@ -344,17 +355,17 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da
database->writeField(ZdbAdrs::BusinessFax, businessfax.number());
PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
if (!businessmobile.number().isEmpty()) {
cellWork = true;
database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number());
}
PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell );
- if (!businessmobile.number().isEmpty()) {
+ if (! mobile.number().isEmpty()) {
if ( ! cellHome )
database->writeField(ZdbAdrs::HomeMobile, mobile.number());
else if (! cellWork )
database->writeField(ZdbAdrs::BusinessMobile, mobile.number());
}
PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
if (!businesspager.number().isEmpty())
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c1ead9d..c2f031a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2764,16 +2764,17 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
//qDebug("take %d %s ", take, inL.summary().latin1());
if ( take == 3 )
return false;
if ( take == 1 ) {// take local
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
+ inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
local->insertAddressee( inL, false );
idS = inR.externalUID();
OidS = inR.originalExternalUID();
}
else
idS = inR.IDStr();
remote->removeAddressee( inR );
inR = inL;
@@ -2791,16 +2792,20 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( inR.revision().date().year() < 2004 )
inR.setRevision( modifiedCalendar );
}
idS = inL.IDStr();
local->removeAddressee( inL );
inL = inR;
inL.setIDStr( idS );
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
+ inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
+ inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
+ }
inL.setResource( 0 );
local->insertAddressee( inL , false );
++changedLocal;
}
}
} else { // no conflict
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = addresseeLSync.note();
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bbed05b..7fae4a9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1044,16 +1044,20 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
++changedRemote;
} else {
if ( inR->revision() < maxrev )
inR->setRevision( maxrev );
idS = inL->IDStr();
local->deleteIncidence( inL );
inL = inR->clone();
inL->setIDStr( idS );
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
+ inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
+ inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
+ }
local->addIncidence( inL );
++changedLocal;
}
}
} else { // no conflict
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = eventLSync->description();
QString pref = "e";