author | zautrix <zautrix> | 2004-09-12 15:24:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 15:24:11 (UTC) |
commit | a222c2f7369eeefd19454c973c0cc48300f72bec (patch) (unidiff) | |
tree | 6f01a5922ea622add6960f3fad703e8e8f099caa /gammu | |
parent | b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26 (diff) | |
download | kdepimpi-a222c2f7369eeefd19454c973c0cc48300f72bec.zip kdepimpi-a222c2f7369eeefd19454c973c0cc48300f72bec.tar.gz kdepimpi-a222c2f7369eeefd19454c973c0cc48300f72bec.tar.bz2 |
many phone sync fixes
-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 4 | ||||
-rw-r--r-- | gammu/emb/gammu/gammu.c | 6 |
2 files changed, 7 insertions, 3 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 | |||
@@ -453,54 +453,54 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda | |||
453 | return ERR_NONE; | 453 | return ERR_NONE; |
454 | } | 454 | } |
455 | if (ReadVCALText(Line, "DUE", Buff)) { | 455 | if (ReadVCALText(Line, "DUE", Buff)) { |
456 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; | 456 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; |
457 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 457 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
458 | ToDo->EntriesNum++; | 458 | ToDo->EntriesNum++; |
459 | } | 459 | } |
460 | if (ReadVCALText(Line, "DALARM", Buff)) { | 460 | if (ReadVCALText(Line, "DALARM", Buff)) { |
461 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; | 461 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; |
462 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 462 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
463 | ToDo->EntriesNum++; | 463 | ToDo->EntriesNum++; |
464 | } | 464 | } |
465 | if (ReadVCALText(Line, "AALARM", Buff)) { | 465 | if (ReadVCALText(Line, "AALARM", Buff)) { |
466 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | 466 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; |
467 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 467 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
468 | ToDo->EntriesNum++; | 468 | ToDo->EntriesNum++; |
469 | } | 469 | } |
470 | if (ReadVCALText(Line, "SUMMARY", Buff)) { | 470 | if (ReadVCALText(Line, "SUMMARY", Buff)) { |
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; |
489 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | 489 | ToDo->Entries[ToDo->EntriesNum].Number = 1; |
490 | ToDo->EntriesNum++; | 490 | ToDo->EntriesNum++; |
491 | } | 491 | } |
492 | break; | 492 | break; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||
496 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; | 496 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; |
497 | return ERR_NONE; | 497 | return ERR_NONE; |
498 | } | 498 | } |
499 | 499 | ||
500 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 500 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) |
501 | { | 501 | { |
502 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); | 502 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); |
503 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); | 503 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); |
504 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); | 504 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); |
505 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); | 505 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); |
506 | 506 | ||
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 | |||
@@ -4606,48 +4606,49 @@ static void Restore(int argc, char *argv[]) | |||
4606 | max = 0; | 4606 | max = 0; |
4607 | while (Backup.CallerLogos[max]!=NULL) max++; | 4607 | while (Backup.CallerLogos[max]!=NULL) max++; |
4608 | for (i=0;i<max;i++) { | 4608 | for (i=0;i<max;i++) { |
4609 | error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); | 4609 | error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); |
4610 | Print_Error(error); | 4610 | Print_Error(error); |
4611 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4611 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4612 | if (gshutdown) { | 4612 | if (gshutdown) { |
4613 | GSM_Terminate(); | 4613 | GSM_Terminate(); |
4614 | exit(0); | 4614 | exit(0); |
4615 | } | 4615 | } |
4616 | } | 4616 | } |
4617 | printmsgerr("\n"); | 4617 | printmsgerr("\n"); |
4618 | } | 4618 | } |
4619 | 4619 | ||
4620 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { | 4620 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { |
4621 | if (/*answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/ true ) { | 4621 | if (/*answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/ true ) { |
4622 | GSM_GetCurrentDateTime(&date_time); | 4622 | GSM_GetCurrentDateTime(&date_time); |
4623 | 4623 | ||
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); |
4636 | DoRestore = true; | 4637 | DoRestore = true; |
4637 | /* | 4638 | /* |
4638 | if (answer_yes("Restore calendar notes")) { | 4639 | if (answer_yes("Restore calendar notes")) { |
4639 | Past = answer_yes("Restore notes from the past"); | 4640 | Past = answer_yes("Restore notes from the past"); |
4640 | DoRestore = true; | 4641 | DoRestore = true; |
4641 | } | 4642 | } |
4642 | */ | 4643 | */ |
4643 | } | 4644 | } |
4644 | } | 4645 | } |
4645 | if (DoRestore) { | 4646 | if (DoRestore) { |
4646 | printmsgerr("Deleting old notes: "); | 4647 | printmsgerr("Deleting old notes: "); |
4647 | error = Phone->DeleteAllCalendar(&s); | 4648 | error = Phone->DeleteAllCalendar(&s); |
4648 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 4649 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
4649 | while (1) { | 4650 | while (1) { |
4650 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 4651 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
4651 | if (error != ERR_NONE) break; | 4652 | if (error != ERR_NONE) break; |
4652 | error = Phone->DeleteCalendar(&s,&Calendar); | 4653 | error = Phone->DeleteCalendar(&s,&Calendar); |
4653 | Print_Error(error); | 4654 | Print_Error(error); |
@@ -4657,58 +4658,62 @@ static void Restore(int argc, char *argv[]) | |||
4657 | } else { | 4658 | } else { |
4658 | printmsgerr("Done\n"); | 4659 | printmsgerr("Done\n"); |
4659 | Print_Error(error); | 4660 | Print_Error(error); |
4660 | } | 4661 | } |
4661 | 4662 | ||
4662 | for (i=0;i<max;i++) { | 4663 | for (i=0;i<max;i++) { |
4663 | if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; | 4664 | if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; |
4664 | 4665 | ||
4665 | Calendar = *Backup.Calendar[i]; | 4666 | Calendar = *Backup.Calendar[i]; |
4666 | error=Phone->AddCalendar(&s,&Calendar); | 4667 | error=Phone->AddCalendar(&s,&Calendar); |
4667 | Print_Error(error); | 4668 | Print_Error(error); |
4668 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4669 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4669 | if (gshutdown) { | 4670 | if (gshutdown) { |
4670 | GSM_Terminate(); | 4671 | GSM_Terminate(); |
4671 | exit(0); | 4672 | exit(0); |
4672 | } | 4673 | } |
4673 | } | 4674 | } |
4674 | printmsgerr("\n"); | 4675 | printmsgerr("\n"); |
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) { |
4697 | error = Phone->GetNextToDo(&s,&ToDo,true); | 4702 | error = Phone->GetNextToDo(&s,&ToDo,true); |
4698 | if (error != ERR_NONE) break; | 4703 | if (error != ERR_NONE) break; |
4699 | error = Phone->DeleteToDo(&s,&ToDo); | 4704 | error = Phone->DeleteToDo(&s,&ToDo); |
4700 | Print_Error(error); | 4705 | Print_Error(error); |
4701 | printmsgerr("*"); | 4706 | printmsgerr("*"); |
4702 | } | 4707 | } |
4703 | printmsgerr("\n"); | 4708 | printmsgerr("\n"); |
4704 | } else { | 4709 | } else { |
4705 | printmsgerr("Done\n"); | 4710 | printmsgerr("Done\n"); |
4706 | Print_Error(error); | 4711 | Print_Error(error); |
4707 | } | 4712 | } |
4708 | 4713 | ||
4709 | for (i=0;i<max;i++) { | 4714 | for (i=0;i<max;i++) { |
4710 | ToDo = *Backup.ToDo[i]; | 4715 | ToDo = *Backup.ToDo[i]; |
4711 | ToDo.Location = 0; | 4716 | ToDo.Location = 0; |
4712 | error=Phone->AddToDo(&s,&ToDo); | 4717 | error=Phone->AddToDo(&s,&ToDo); |
4713 | Print_Error(error); | 4718 | Print_Error(error); |
4714 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4719 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
@@ -8353,49 +8358,48 @@ int main(int argc, char *argv[]) | |||
8353 | if (only_config != -1) {break;} | 8358 | if (only_config != -1) {break;} |
8354 | } | 8359 | } |
8355 | #if 0 | 8360 | #if 0 |
8356 | GSM_Config *con = &s.Config[0]; | 8361 | GSM_Config *con = &s.Config[0]; |
8357 | 8362 | ||
8358 | char* tempC; | 8363 | char* tempC; |
8359 | tempC = argv[argc-1]+2; | 8364 | tempC = argv[argc-1]+2; |
8360 | if ( *tempC != 0 ) { | 8365 | if ( *tempC != 0 ) { |
8361 | fprintf(stderr,"Using model %s \n",tempC); | 8366 | fprintf(stderr,"Using model %s \n",tempC); |
8362 | strcpy(con->Model,tempC ); | 8367 | strcpy(con->Model,tempC ); |
8363 | } | 8368 | } |
8364 | tempC = argv[argc-2]+2; | 8369 | tempC = argv[argc-2]+2; |
8365 | if ( *tempC != 0 ) { | 8370 | if ( *tempC != 0 ) { |
8366 | fprintf(stderr,"Using device %s \n",tempC); | 8371 | fprintf(stderr,"Using device %s \n",tempC); |
8367 | con->Device = strdup(tempC); | 8372 | con->Device = strdup(tempC); |
8368 | con->DefaultDevice = false; | 8373 | con->DefaultDevice = false; |
8369 | } | 8374 | } |
8370 | tempC = argv[argc-3]+2; | 8375 | tempC = argv[argc-3]+2; |
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"); |
8384 | exit(-2); | 8388 | exit(-2); |
8385 | } | 8389 | } |
8386 | 8390 | ||
8387 | /* Check used version vs. compiled */ | 8391 | /* Check used version vs. compiled */ |
8388 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { | 8392 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { |
8389 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", | 8393 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", |
8390 | GetGammuVersion(),VERSION); | 8394 | GetGammuVersion(),VERSION); |
8391 | exit(-1); | 8395 | exit(-1); |
8392 | } | 8396 | } |
8393 | 8397 | ||
8394 | /* Check parameters */ | 8398 | /* Check parameters */ |
8395 | while (Parameters[z].Function != NULL) { | 8399 | while (Parameters[z].Function != NULL) { |
8396 | if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { | 8400 | if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { |
8397 | if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { | 8401 | if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { |
8398 | fprintf(stderr,"Executing \n"); | 8402 | fprintf(stderr,"Executing \n"); |
8399 | Parameters[z].Function(argc - start, argv + start); | 8403 | Parameters[z].Function(argc - start, argv + start); |
8400 | break; | 8404 | break; |
8401 | } else { | 8405 | } else { |