From a222c2f7369eeefd19454c973c0cc48300f72bec Mon Sep 17 00:00:00 2001 From: zautrix Date: Sun, 12 Sep 2004 15:24:11 +0000 Subject: many phone sync fixes --- (limited to 'libkcal/phoneformat.cpp') diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 6df639f..ef69bce 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -129,7 +129,10 @@ ulong PhoneFormat::getCsumTodo( Todo* todo ) if ( todo->isCompleted() ) completedString = "yes"; attList << completedString; - attList << QString::number( todo->priority() ); + int prio = todo->priority(); + if( prio == 2 ) prio = 1; + if (prio == 4 ) prio = 5 ; + attList << QString::number( prio ); QString alarmString = "na"; Alarm *alarm; if ( todo->alarms().count() > 0 ) { @@ -254,11 +257,11 @@ ulong PhoneFormat::getCsumEvent( Event* event ) } ulong PhoneFormat::getCsum( const QStringList & attList) { - int max = attList.count() -1; + int max = attList.count(); ulong cSum = 0; int j,k,i; int add; - for ( i = 1; i < max ; ++i ) { + for ( i = 0; i < max ; ++i ) { QString s = attList[i]; if ( ! s.isEmpty() ){ j = s.length(); @@ -267,13 +270,17 @@ ulong PhoneFormat::getCsum( const QStringList & attList) add = s[k].unicode (); if ( k < 16 ) mul = mul * mul; - add = add * mul *i*i*i; + int ii = i+1; + add = add * mul *ii*ii*ii; cSum += add; } } + if ( i == 0 ) + qDebug("csum: i == 0 %d ", cSum); + } - //QString dump = attList.join(","); - //qDebug("csum: %s", dump.latin1()); + QString dump = attList.join(","); + qDebug("csum: %d %s", cSum,dump.latin1()); return cSum; @@ -290,8 +297,7 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) #else fileName = "/tmp/kdepimtemp.vcs"; #endif - QString command ="./kammu --backup " + fileName + " -yes -C" + - mConnection +" -D" + mDevice +" -M" + mModel; + QString command ="./kammu --backup " + fileName + " -yes" ; int ret = system ( command.latin1() ); if ( ret != 0 ) { qDebug("Error::command returned %d", ret); @@ -344,6 +350,8 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) Todo *event; event = existingCal->todo( mProfileName ,QString::number( id ) ); if ( event ) { + qDebug("copy todo %s ", event->summary().latin1()); + event = (Todo*)event->clone(); copyTodo( event, ev ); calendar->deleteTodo( ev ); @@ -375,7 +383,8 @@ void PhoneFormat::copyEvent( Event* to, Event* from ) to->setSummary( from->summary() ); QPtrListIterator it( from->alarms() ); - to->clearAlarms(); + if ( it.current() ) + to->clearAlarms(); const Alarm *a; while( (a = it.current()) ) { Alarm *b = new Alarm( *a ); @@ -414,7 +423,8 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) to->setSummary( from->summary() ); QPtrListIterator it( from->alarms() ); - to->clearAlarms(); + if ( it.current() ) + to->clearAlarms(); const Alarm *a; while( (a = it.current()) ) { Alarm *b = new Alarm( *a ); @@ -443,7 +453,12 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) if ( to->isCompleted() ) to->setPercentComplete(from->percentComplete()); } - to->setPriority(from->priority()); + if( to->priority() == 2 && from->priority() == 1 ) + ; //skip + else if (to->priority() == 4 && from->priority() == 5 ) + ; + else + to->setPriority(from->priority()); } #include @@ -452,11 +467,13 @@ void PhoneFormat::afterSave( Incidence* inc) { uint csum; inc->removeID( mProfileName ); +#if 0 if ( inc->type() == "Event") csum = PhoneFormat::getCsumEvent( (Event*) inc ); else csum = PhoneFormat::getCsumTodo( (Todo*) inc ); inc->setCsum( mProfileName, QString::number( csum )); +#endif inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); } @@ -506,8 +523,7 @@ bool PhoneFormat::save( Calendar *calendar) if ( ! vfsave.save( calendar, fileName ) ) return false; // 4 call kammu - QString command ="./kammu --restore " + fileName + " -C" + - mConnection +" -D" + mDevice +" -M" + mModel; + QString command ="./kammu --restore " + fileName ; int ret; while ( (ret = system ( command.latin1())) != 0 ) { qDebug("Error S::command returned %d. asking users", ret); -- cgit v0.9.0.2