summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmcal.c4
-rw-r--r--gammu/emb/gammu/gammu.c6
-rw-r--r--libkcal/phoneformat.cpp42
3 files changed, 36 insertions, 16 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c
index ddf9790..0ea8e06 100644
--- a/gammu/emb/common/service/gsmcal.c
+++ b/gammu/emb/common/service/gsmcal.c
@@ -471,18 +471,18 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda
471 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; 471 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT;
472 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); 472 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff);
473 ToDo->EntriesNum++; 473 ToDo->EntriesNum++;
474 } 474 }
475 if (ReadVCALText(Line, "PRIORITY", Buff)) { 475 if (ReadVCALText(Line, "PRIORITY", Buff)) {
476 if (ToDoVer == SonyEricsson_VToDo) { 476 if (ToDoVer == SonyEricsson_VToDo) {
477 ToDo->Priority = GSM_Priority_Low; 477 ToDo->Priority = GSM_Priority_Medium;
478 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; 478 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
479 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; 479 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
480 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); 480 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff));
481 } else if (ToDoVer == Nokia_VToDo) { 481 } else if (ToDoVer == Nokia_VToDo) {
482 ToDo->Priority = GSM_Priority_Low; 482 ToDo->Priority = GSM_Priority_Medium;
483 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; 483 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
484 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; 484 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
485 } 485 }
486 } 486 }
487 if (strstr(Line,"PERCENT-COMPLETE:100")) { 487 if (strstr(Line,"PERCENT-COMPLETE:100")) {
488 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; 488 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED;
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
index a3b93a8..997485a 100644
--- a/gammu/emb/gammu/gammu.c
+++ b/gammu/emb/gammu/gammu.c
@@ -4624,12 +4624,13 @@ static void Restore(int argc, char *argv[])
4624 error=Phone->SetDateTime(&s, &date_time); 4624 error=Phone->SetDateTime(&s, &date_time);
4625 Print_Error(error); 4625 Print_Error(error);
4626 } 4626 }
4627 } 4627 }
4628 DoRestore = false; 4628 DoRestore = false;
4629 if (Backup.Calendar[0] != NULL) { 4629 if (Backup.Calendar[0] != NULL) {
4630 DoRestore = true;
4630 /* N6110 doesn't support getting calendar status */ 4631 /* N6110 doesn't support getting calendar status */
4631 error = Phone->GetNextCalendar(&s,&Calendar,true); 4632 error = Phone->GetNextCalendar(&s,&Calendar,true);
4632 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { 4633 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
4633 max = 0; 4634 max = 0;
4634 while (Backup.Calendar[max] != NULL) max++; 4635 while (Backup.Calendar[max] != NULL) max++;
4635 printmsgerr("%i entries in backup file\n",max); 4636 printmsgerr("%i entries in backup file\n",max);
@@ -4675,22 +4676,26 @@ static void Restore(int argc, char *argv[])
4675 } 4676 }
4676 4677
4677 DoRestore = false; 4678 DoRestore = false;
4678 if (Backup.ToDo[0] != NULL) { 4679 if (Backup.ToDo[0] != NULL) {
4679 error = Phone->GetToDoStatus(&s,&ToDoStatus); 4680 error = Phone->GetToDoStatus(&s,&ToDoStatus);
4680 if (error == ERR_NONE) { 4681 if (error == ERR_NONE) {
4682 error == ERR_NOTSUPPORTED;
4683 DoRestore = true;
4681 max = 0; 4684 max = 0;
4682 while (Backup.ToDo[max]!=NULL) max++; 4685 while (Backup.ToDo[max]!=NULL) max++;
4683 printmsgerr("%i entries in backup file\n",max); 4686 printmsgerr("%i entries in backup file\n",max);
4684 4687
4685 /*if (answer_yes("Restore ToDo")) */DoRestore = true; 4688 /*if (answer_yes("Restore ToDo")) */DoRestore = true;
4686 } 4689 }
4687 } 4690 }
4688 if (DoRestore) { 4691 if (DoRestore) {
4692 if ( max > 0 ) {
4689 ToDo = *Backup.ToDo[0]; 4693 ToDo = *Backup.ToDo[0];
4690 error = Phone->SetToDo(&s,&ToDo); 4694 error = Phone->SetToDo(&s,&ToDo);
4695 }
4691 } 4696 }
4692 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { 4697 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) {
4693 printmsgerr("Deleting old ToDo: "); 4698 printmsgerr("Deleting old ToDo: ");
4694 error=Phone->DeleteAllToDo(&s); 4699 error=Phone->DeleteAllToDo(&s);
4695 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 4700 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
4696 while (1) { 4701 while (1) {
@@ -8371,13 +8376,12 @@ int main(int argc, char *argv[])
8371 if ( *tempC != 0 ) { 8376 if ( *tempC != 0 ) {
8372 fprintf(stderr,"Using connection %s \n",tempC); 8377 fprintf(stderr,"Using connection %s \n",tempC);
8373 con->Connection = strdup(tempC); 8378 con->Connection = strdup(tempC);
8374 con->DefaultConnection = false; 8379 con->DefaultConnection = false;
8375 } 8380 }
8376#endif 8381#endif
8377 argc = argc-3;
8378 8382
8379 8383
8380 /* Do we have enough parameters? */ 8384 /* Do we have enough parameters? */
8381 if (argc == 1 + start) { 8385 if (argc == 1 + start) {
8382 HelpGeneral(); 8386 HelpGeneral();
8383 printmsg("Too few parameters!\n"); 8387 printmsg("Too few parameters!\n");
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 6df639f..ef69bce 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -126,13 +126,16 @@ ulong PhoneFormat::getCsumTodo( Todo* todo )
126 attList << PhoneParser::dtToString ( todo->dtDue() ); 126 attList << PhoneParser::dtToString ( todo->dtDue() );
127 attList << todo->summary(); 127 attList << todo->summary();
128 QString completedString = "no"; 128 QString completedString = "no";
129 if ( todo->isCompleted() ) 129 if ( todo->isCompleted() )
130 completedString = "yes"; 130 completedString = "yes";
131 attList << completedString; 131 attList << completedString;
132 attList << QString::number( todo->priority() ); 132 int prio = todo->priority();
133 if( prio == 2 ) prio = 1;
134 if (prio == 4 ) prio = 5 ;
135 attList << QString::number( prio );
133 QString alarmString = "na"; 136 QString alarmString = "na";
134 Alarm *alarm; 137 Alarm *alarm;
135 if ( todo->alarms().count() > 0 ) { 138 if ( todo->alarms().count() > 0 ) {
136 alarm = todo->alarms().first(); 139 alarm = todo->alarms().first();
137 if ( alarm->enabled() ) { 140 if ( alarm->enabled() ) {
138 alarmString = QString::number(alarm->startOffset().asSeconds() ); 141 alarmString = QString::number(alarm->startOffset().asSeconds() );
@@ -251,32 +254,36 @@ ulong PhoneFormat::getCsumEvent( Event* event )
251 254
252 attList << event->secrecyStr(); 255 attList << event->secrecyStr();
253 return PhoneFormat::getCsum(attList ); 256 return PhoneFormat::getCsum(attList );
254} 257}
255ulong PhoneFormat::getCsum( const QStringList & attList) 258ulong PhoneFormat::getCsum( const QStringList & attList)
256{ 259{
257 int max = attList.count() -1; 260 int max = attList.count();
258 ulong cSum = 0; 261 ulong cSum = 0;
259 int j,k,i; 262 int j,k,i;
260 int add; 263 int add;
261 for ( i = 1; i < max ; ++i ) { 264 for ( i = 0; i < max ; ++i ) {
262 QString s = attList[i]; 265 QString s = attList[i];
263 if ( ! s.isEmpty() ){ 266 if ( ! s.isEmpty() ){
264 j = s.length(); 267 j = s.length();
265 for ( k = 0; k < j; ++k ) { 268 for ( k = 0; k < j; ++k ) {
266 int mul = k +1; 269 int mul = k +1;
267 add = s[k].unicode (); 270 add = s[k].unicode ();
268 if ( k < 16 ) 271 if ( k < 16 )
269 mul = mul * mul; 272 mul = mul * mul;
270 add = add * mul *i*i*i; 273 int ii = i+1;
274 add = add * mul *ii*ii*ii;
271 cSum += add; 275 cSum += add;
272 } 276 }
273 } 277 }
278 if ( i == 0 )
279 qDebug("csum: i == 0 %d ", cSum);
280
274 } 281 }
275 //QString dump = attList.join(","); 282 QString dump = attList.join(",");
276 //qDebug("csum: %s", dump.latin1()); 283 qDebug("csum: %d %s", cSum,dump.latin1());
277 284
278 return cSum; 285 return cSum;
279 286
280} 287}
281//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 288//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
282#include <stdlib.h> 289#include <stdlib.h>
@@ -287,14 +294,13 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
287 QString fileName; 294 QString fileName;
288#ifdef _WIN32_ 295#ifdef _WIN32_
289 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 296 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
290#else 297#else
291 fileName = "/tmp/kdepimtemp.vcs"; 298 fileName = "/tmp/kdepimtemp.vcs";
292#endif 299#endif
293 QString command ="./kammu --backup " + fileName + " -yes -C" + 300 QString command ="./kammu --backup " + fileName + " -yes" ;
294 mConnection +" -D" + mDevice +" -M" + mModel;
295 int ret = system ( command.latin1() ); 301 int ret = system ( command.latin1() );
296 if ( ret != 0 ) { 302 if ( ret != 0 ) {
297 qDebug("Error::command returned %d", ret); 303 qDebug("Error::command returned %d", ret);
298 return false; 304 return false;
299 } 305 }
300 qDebug("Command returned %d", ret); 306 qDebug("Command returned %d", ret);
@@ -341,12 +347,14 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
341 ev->setCategories( QStringList() ); 347 ev->setCategories( QStringList() );
342 } 348 }
343 int id = ev->pilotId(); 349 int id = ev->pilotId();
344 Todo *event; 350 Todo *event;
345 event = existingCal->todo( mProfileName ,QString::number( id ) ); 351 event = existingCal->todo( mProfileName ,QString::number( id ) );
346 if ( event ) { 352 if ( event ) {
353 qDebug("copy todo %s ", event->summary().latin1());
354
347 event = (Todo*)event->clone(); 355 event = (Todo*)event->clone();
348 copyTodo( event, ev ); 356 copyTodo( event, ev );
349 calendar->deleteTodo( ev ); 357 calendar->deleteTodo( ev );
350 calendar->addTodo( event); 358 calendar->addTodo( event);
351 } 359 }
352 else 360 else
@@ -372,13 +380,14 @@ void PhoneFormat::copyEvent( Event* to, Event* from )
372 if ( !from->description().isEmpty() ) 380 if ( !from->description().isEmpty() )
373 to->setDescription( from->description() ); 381 to->setDescription( from->description() );
374 if ( !from->summary().isEmpty() ) 382 if ( !from->summary().isEmpty() )
375 to->setSummary( from->summary() ); 383 to->setSummary( from->summary() );
376 384
377 QPtrListIterator<Alarm> it( from->alarms() ); 385 QPtrListIterator<Alarm> it( from->alarms() );
378 to->clearAlarms(); 386 if ( it.current() )
387 to->clearAlarms();
379 const Alarm *a; 388 const Alarm *a;
380 while( (a = it.current()) ) { 389 while( (a = it.current()) ) {
381 Alarm *b = new Alarm( *a ); 390 Alarm *b = new Alarm( *a );
382 b->setParent( to ); 391 b->setParent( to );
383 to->addAlarm( b ); 392 to->addAlarm( b );
384 ++it; 393 ++it;
@@ -411,13 +420,14 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
411 if ( !from->description().isEmpty() ) 420 if ( !from->description().isEmpty() )
412 to->setDescription( from->description() ); 421 to->setDescription( from->description() );
413 if ( !from->summary().isEmpty() ) 422 if ( !from->summary().isEmpty() )
414 to->setSummary( from->summary() ); 423 to->setSummary( from->summary() );
415 424
416 QPtrListIterator<Alarm> it( from->alarms() ); 425 QPtrListIterator<Alarm> it( from->alarms() );
417 to->clearAlarms(); 426 if ( it.current() )
427 to->clearAlarms();
418 const Alarm *a; 428 const Alarm *a;
419 while( (a = it.current()) ) { 429 while( (a = it.current()) ) {
420 Alarm *b = new Alarm( *a ); 430 Alarm *b = new Alarm( *a );
421 b->setParent( to ); 431 b->setParent( to );
422 to->addAlarm( b ); 432 to->addAlarm( b );
423 ++it; 433 ++it;
@@ -440,26 +450,33 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
440 to->setCompleted( from->completed() ); 450 to->setCompleted( from->completed() );
441 } else { 451 } else {
442 // set percentcomplete only, if to->isCompleted() 452 // set percentcomplete only, if to->isCompleted()
443 if ( to->isCompleted() ) 453 if ( to->isCompleted() )
444 to->setPercentComplete(from->percentComplete()); 454 to->setPercentComplete(from->percentComplete());
445 } 455 }
446 to->setPriority(from->priority()); 456 if( to->priority() == 2 && from->priority() == 1 )
457 ; //skip
458 else if (to->priority() == 4 && from->priority() == 5 )
459 ;
460 else
461 to->setPriority(from->priority());
447 462
448} 463}
449#include <qcstring.h> 464#include <qcstring.h>
450 465
451void PhoneFormat::afterSave( Incidence* inc) 466void PhoneFormat::afterSave( Incidence* inc)
452{ 467{
453 uint csum; 468 uint csum;
454 inc->removeID( mProfileName ); 469 inc->removeID( mProfileName );
470#if 0
455 if ( inc->type() == "Event") 471 if ( inc->type() == "Event")
456 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 472 csum = PhoneFormat::getCsumEvent( (Event*) inc );
457 else 473 else
458 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 474 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
459 inc->setCsum( mProfileName, QString::number( csum )); 475 inc->setCsum( mProfileName, QString::number( csum ));
476#endif
460 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 477 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
461 478
462} 479}
463bool PhoneFormat::save( Calendar *calendar) 480bool PhoneFormat::save( Calendar *calendar)
464{ 481{
465 QLabel status ( i18n(" Opening device ..."), 0 ); 482 QLabel status ( i18n(" Opening device ..."), 0 );
@@ -503,14 +520,13 @@ bool PhoneFormat::save( Calendar *calendar)
503 // 3 save file 520 // 3 save file
504 VCalFormat vfsave; 521 VCalFormat vfsave;
505 vfsave.setLocalTime ( true ); 522 vfsave.setLocalTime ( true );
506 if ( ! vfsave.save( calendar, fileName ) ) 523 if ( ! vfsave.save( calendar, fileName ) )
507 return false; 524 return false;
508 // 4 call kammu 525 // 4 call kammu
509 QString command ="./kammu --restore " + fileName + " -C" + 526 QString command ="./kammu --restore " + fileName ;
510 mConnection +" -D" + mDevice +" -M" + mModel;
511 int ret; 527 int ret;
512 while ( (ret = system ( command.latin1())) != 0 ) { 528 while ( (ret = system ( command.latin1())) != 0 ) {
513 qDebug("Error S::command returned %d. asking users", ret); 529 qDebug("Error S::command returned %d. asking users", ret);
514 int retval = KMessageBox::warningContinueCancel(0, 530 int retval = KMessageBox::warningContinueCancel(0,
515 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); 531 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
516 if ( retval != KMessageBox::Continue ) 532 if ( retval != KMessageBox::Continue )