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 | |||
@@ -429,84 +429,84 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda | |||
429 | if (ReadVCALText(Line, "DTSTART", Buff)) { | 429 | if (ReadVCALText(Line, "DTSTART", Buff)) { |
430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; | 430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; |
431 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 431 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
432 | Calendar->EntriesNum++; | 432 | Calendar->EntriesNum++; |
433 | } | 433 | } |
434 | if (ReadVCALText(Line, "DTEND", Buff)) { | 434 | if (ReadVCALText(Line, "DTEND", Buff)) { |
435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; | 435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; |
436 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 436 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
437 | Calendar->EntriesNum++; | 437 | Calendar->EntriesNum++; |
438 | } | 438 | } |
439 | if (ReadVCALText(Line, "DALARM", Buff)) { | 439 | if (ReadVCALText(Line, "DALARM", Buff)) { |
440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; | 440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; |
441 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 441 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
442 | Calendar->EntriesNum++; | 442 | Calendar->EntriesNum++; |
443 | } | 443 | } |
444 | if (ReadVCALText(Line, "AALARM", Buff)) { | 444 | if (ReadVCALText(Line, "AALARM", Buff)) { |
445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; | 445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; |
446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
447 | Calendar->EntriesNum++; | 447 | Calendar->EntriesNum++; |
448 | } | 448 | } |
449 | break; | 449 | break; |
450 | case 2: /* ToDo note */ | 450 | case 2: /* ToDo note */ |
451 | if (strstr(Line,"END:VTODO")) { | 451 | if (strstr(Line,"END:VTODO")) { |
452 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; | 452 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; |
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 | ||
507 | return ERR_NONE; | 507 | return ERR_NONE; |
508 | } | 508 | } |
509 | 509 | ||
510 | /* How should editor hadle tabs in this file? Add editor commands here. | 510 | /* How should editor hadle tabs in this file? Add editor commands here. |
511 | * vim: noexpandtab sw=8 ts=8 sts=8: | 511 | * vim: noexpandtab sw=8 ts=8 sts=8: |
512 | */ | 512 | */ |
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 | |||
@@ -4582,157 +4582,162 @@ static void Restore(int argc, char *argv[]) | |||
4582 | if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); | 4582 | if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); |
4583 | } | 4583 | } |
4584 | } | 4584 | } |
4585 | if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); | 4585 | if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); |
4586 | Print_Error(error); | 4586 | Print_Error(error); |
4587 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); | 4587 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); |
4588 | if (gshutdown) { | 4588 | if (gshutdown) { |
4589 | GSM_Terminate(); | 4589 | GSM_Terminate(); |
4590 | exit(0); | 4590 | exit(0); |
4591 | } | 4591 | } |
4592 | } | 4592 | } |
4593 | printmsgerr("\n"); | 4593 | printmsgerr("\n"); |
4594 | } | 4594 | } |
4595 | 4595 | ||
4596 | DoRestore = false; | 4596 | DoRestore = false; |
4597 | if (Backup.CallerLogos[0] != NULL) { | 4597 | if (Backup.CallerLogos[0] != NULL) { |
4598 | Bitmap.Type = GSM_CallerGroupLogo; | 4598 | Bitmap.Type = GSM_CallerGroupLogo; |
4599 | Bitmap.Location = 1; | 4599 | Bitmap.Location = 1; |
4600 | error=Phone->GetBitmap(&s,&Bitmap); | 4600 | error=Phone->GetBitmap(&s,&Bitmap); |
4601 | if (error == ERR_NONE) { | 4601 | if (error == ERR_NONE) { |
4602 | if (answer_yes("Restore caller groups and logos")) DoRestore = true; | 4602 | if (answer_yes("Restore caller groups and logos")) DoRestore = true; |
4603 | } | 4603 | } |
4604 | } | 4604 | } |
4605 | if (DoRestore) { | 4605 | if (DoRestore) { |
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); |
4654 | printmsgerr("*"); | 4655 | printmsgerr("*"); |
4655 | } | 4656 | } |
4656 | printmsgerr("\n"); | 4657 | printmsgerr("\n"); |
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); |
4715 | if (gshutdown) { | 4720 | if (gshutdown) { |
4716 | GSM_Terminate(); | 4721 | GSM_Terminate(); |
4717 | exit(0); | 4722 | exit(0); |
4718 | } | 4723 | } |
4719 | } | 4724 | } |
4720 | printmsgerr("\n"); | 4725 | printmsgerr("\n"); |
4721 | } else if (DoRestore) { | 4726 | } else if (DoRestore) { |
4722 | /* At first delete entries, that were deleted */ | 4727 | /* At first delete entries, that were deleted */ |
4723 | used = 0; | 4728 | used = 0; |
4724 | error = Phone->GetNextToDo(&s,&ToDo,true); | 4729 | error = Phone->GetNextToDo(&s,&ToDo,true); |
4725 | while (error == ERR_NONE) { | 4730 | while (error == ERR_NONE) { |
4726 | used++; | 4731 | used++; |
4727 | Found = false; | 4732 | Found = false; |
4728 | for (i=0;i<max;i++) { | 4733 | for (i=0;i<max;i++) { |
4729 | if (Backup.ToDo[i]->Location == ToDo.Location) { | 4734 | if (Backup.ToDo[i]->Location == ToDo.Location) { |
4730 | Found = true; | 4735 | Found = true; |
4731 | break; | 4736 | break; |
4732 | } | 4737 | } |
4733 | } | 4738 | } |
4734 | if (!Found) { | 4739 | if (!Found) { |
4735 | error=Phone->DeleteToDo(&s,&ToDo); | 4740 | error=Phone->DeleteToDo(&s,&ToDo); |
4736 | Print_Error(error); | 4741 | Print_Error(error); |
4737 | } | 4742 | } |
4738 | error = Phone->GetNextToDo(&s,&ToDo,false); | 4743 | error = Phone->GetNextToDo(&s,&ToDo,false); |
@@ -8329,97 +8334,96 @@ int main(int argc, char *argv[]) | |||
8329 | s.Config[i].UseGlobalDebugFile = true; | 8334 | s.Config[i].UseGlobalDebugFile = true; |
8330 | 8335 | ||
8331 | /* It makes no sense to open several debug logs... */ | 8336 | /* It makes no sense to open several debug logs... */ |
8332 | if (i != 0) { | 8337 | if (i != 0) { |
8333 | strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); | 8338 | strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); |
8334 | free(s.Config[i].DebugFile); | 8339 | free(s.Config[i].DebugFile); |
8335 | s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); | 8340 | s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); |
8336 | } else { | 8341 | } else { |
8337 | /* Just for first config */ | 8342 | /* Just for first config */ |
8338 | /* When user gave debug level on command line */ | 8343 | /* When user gave debug level on command line */ |
8339 | if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { | 8344 | if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { |
8340 | /* Debug level from command line will be used with phone too */ | 8345 | /* Debug level from command line will be used with phone too */ |
8341 | strcpy(s.Config[i].DebugLevel,argv[1 + start]); | 8346 | strcpy(s.Config[i].DebugLevel,argv[1 + start]); |
8342 | start++; | 8347 | start++; |
8343 | } else { | 8348 | } else { |
8344 | /* Try to set debug level from config file */ | 8349 | /* Try to set debug level from config file */ |
8345 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); | 8350 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); |
8346 | } | 8351 | } |
8347 | /* If user gave debug file in gammurc, we will use it */ | 8352 | /* If user gave debug file in gammurc, we will use it */ |
8348 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); | 8353 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); |
8349 | Print_Error(error); | 8354 | Print_Error(error); |
8350 | } | 8355 | } |
8351 | 8356 | ||
8352 | /* We wanted to read just user specified configuration. */ | 8357 | /* We wanted to read just user specified configuration. */ |
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 { |
8402 | count_failed = true; | 8406 | count_failed = true; |
8403 | } | 8407 | } |
8404 | } | 8408 | } |
8405 | z++; | 8409 | z++; |
8406 | } | 8410 | } |
8407 | 8411 | ||
8408 | /* Tell user when we did nothing */ | 8412 | /* Tell user when we did nothing */ |
8409 | if (Parameters[z].Function == NULL) { | 8413 | if (Parameters[z].Function == NULL) { |
8410 | HelpGeneral(); | 8414 | HelpGeneral(); |
8411 | if (count_failed) { | 8415 | if (count_failed) { |
8412 | printmsg("Bad parameter count!\n"); | 8416 | printmsg("Bad parameter count!\n"); |
8413 | } else { | 8417 | } else { |
8414 | printmsg("Bad option!\n"); | 8418 | printmsg("Bad option!\n"); |
8415 | } | 8419 | } |
8416 | } | 8420 | } |
8417 | 8421 | ||
8418 | /* Close debug output if opened */ | 8422 | /* Close debug output if opened */ |
8419 | if (di.df!=stdout) fclose(di.df); | 8423 | if (di.df!=stdout) fclose(di.df); |
8420 | //#endif // 0 | 8424 | //#endif // 0 |
8421 | fprintf(stderr,"kammu: Success. End. \n"); | 8425 | fprintf(stderr,"kammu: Success. End. \n"); |
8422 | exit(0); | 8426 | exit(0); |
8423 | } | 8427 | } |
8424 | 8428 | ||
8425 | /* How should editor hadle tabs in this file? Add editor commands here. | 8429 | /* How should editor hadle tabs in this file? Add editor commands here. |