summaryrefslogtreecommitdiffabout
path: root/libkcal/phoneformat.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/phoneformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 6df639f..ef69bce 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -124,17 +124,20 @@ ulong PhoneFormat::getCsumTodo( Todo* todo )
QStringList attList;
if ( todo->hasDueDate() )
attList << PhoneParser::dtToString ( todo->dtDue() );
attList << todo->summary();
QString completedString = "no";
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 ) {
alarm = todo->alarms().first();
if ( alarm->enabled() ) {
alarmString = QString::number(alarm->startOffset().asSeconds() );
}
}
@@ -249,54 +252,57 @@ ulong PhoneFormat::getCsumEvent( Event* event )
attList << event->categoriesStr();
//qDebug("csum cat %s", event->categoriesStr().latin1());
attList << event->secrecyStr();
return PhoneFormat::getCsum(attList );
}
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();
for ( k = 0; k < j; ++k ) {
int mul = k +1;
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;
}
//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
#include <stdlib.h>
#define DEBUGMODE false
bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
{
QString fileName;
#ifdef _WIN32_
fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
#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);
return false;
}
qDebug("Command returned %d", ret);
VCalFormat vfload;
vfload.setLocalTime ( true );
@@ -339,16 +345,18 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
QStringList cat = ev->categories();
if ( cat.contains( "MeetingDEF" )) {
ev->setCategories( QStringList() );
}
int id = ev->pilotId();
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 );
calendar->addTodo( event);
}
else
event = ev;
uint cSum;
@@ -370,17 +378,18 @@ void PhoneFormat::copyEvent( Event* to, Event* from )
if ( !from->location().isEmpty() )
to->setLocation( from->location() );
if ( !from->description().isEmpty() )
to->setDescription( from->description() );
if ( !from->summary().isEmpty() )
to->setSummary( from->summary() );
QPtrListIterator<Alarm> it( from->alarms() );
- to->clearAlarms();
+ if ( it.current() )
+ to->clearAlarms();
const Alarm *a;
while( (a = it.current()) ) {
Alarm *b = new Alarm( *a );
b->setParent( to );
to->addAlarm( b );
++it;
}
QStringList cat = to->categories();
@@ -409,17 +418,18 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
if ( !from->location().isEmpty() )
to->setLocation( from->location() );
if ( !from->description().isEmpty() )
to->setDescription( from->description() );
if ( !from->summary().isEmpty() )
to->setSummary( from->summary() );
QPtrListIterator<Alarm> it( from->alarms() );
- to->clearAlarms();
+ if ( it.current() )
+ to->clearAlarms();
const Alarm *a;
while( (a = it.current()) ) {
Alarm *b = new Alarm( *a );
b->setParent( to );
to->addAlarm( b );
++it;
}
QStringList cat = to->categories();
@@ -438,30 +448,37 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
to->setCompleted( true );
if( from->completed().isValid() )
to->setCompleted( from->completed() );
} else {
// set percentcomplete only, if to->isCompleted()
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 <qcstring.h>
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 );
}
bool PhoneFormat::save( Calendar *calendar)
{
QLabel status ( i18n(" Opening device ..."), 0 );
int w = status.sizeHint().width()+20 ;
if ( w < 200 ) w = 230;
@@ -501,18 +518,17 @@ bool PhoneFormat::save( Calendar *calendar)
to = tl.next();
}
// 3 save file
VCalFormat vfsave;
vfsave.setLocalTime ( true );
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);
int retval = KMessageBox::warningContinueCancel(0,
i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
if ( retval != KMessageBox::Continue )
return false;
}