-rw-r--r-- | gammu/emb/gammu/gammu.c | 4 | ||||
-rw-r--r-- | gammu/gammu.tar.bz2 | bin | 612042 -> 0 bytes |
2 files changed, 2 insertions, 2 deletions
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c index f49ae36..c436b90 100644 --- a/gammu/emb/gammu/gammu.c +++ b/gammu/emb/gammu/gammu.c @@ -3754,2480 +3754,2480 @@ static void SendSaveDisplaySMS(int argc, char *argv[]) SMSCSet = 0; } s.User.SendSMSStatus = SendSMSStatus; signal(SIGINT, interrupt); printmsgerr("If you want break, press Ctrl+C...\n"); } for (i=0;i<sms.Number;i++) { printmsg("Saving SMS %i/%i\n",i+1,sms.Number); // sms.SMS[i].Location = 0; sms.SMS[i].Folder = Folder; sms.SMS[i].State = State; sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; sms.SMS[i].SMSC.Location = SMSCSet; if (SendSaved) { sms.SMS[i].PDU = SMS_Submit; if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report; if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity; } else { sms.SMS[i].PDU = SMS_Deliver; } CopyUnicodeString(sms.SMS[i].Number, Sender); CopyUnicodeString(sms.SMS[i].Name, Name); if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); error=Phone->AddSMS(&s, &sms.SMS[i]); Print_Error(error); printmsg("Saved in folder \"%s\", location %i\n", DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); if (SendSaved) { printmsg("Sending sms from folder \"%s\", location %i\n", DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); SMSStatus = ERR_TIMEOUT; error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location); Print_Error(error); printmsg("....waiting for network answer"); while (!gshutdown) { GSM_ReadDevice(&s,true); if (SMSStatus == ERR_UNKNOWN) { GSM_Terminate(); exit(-1); } if (SMSStatus == ERR_NONE) break; } } } } else { if (Validity.Format != 0 && SMSCSet != 0) { PhoneSMSC.Location = SMSCSet; error=Phone->GetSMSC(&s,&PhoneSMSC); Print_Error(error); CopyUnicodeString(SMSC,PhoneSMSC.Number); SMSCSet = 0; } signal(SIGINT, interrupt); printmsgerr("If you want break, press Ctrl+C...\n"); s.User.SendSMSStatus = SendSMSStatus; for (i=0;i<sms.Number;i++) { printmsg("Sending SMS %i/%i",i+1,sms.Number); sms.SMS[i].Location = 0; sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; sms.SMS[i].SMSC.Location = SMSCSet; sms.SMS[i].PDU = SMS_Submit; if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report; CopyUnicodeString(sms.SMS[i].Number, Sender); if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); SMSStatus = ERR_TIMEOUT; error=Phone->SendSMS(&s, &sms.SMS[i]); Print_Error(error); printmsg("....waiting for network answer"); while (!gshutdown) { GSM_ReadDevice(&s,true); if (SMSStatus == ERR_UNKNOWN) { GSM_Terminate(); exit(-1); } if (SMSStatus == ERR_NONE) break; } } } GSM_Terminate(); } #ifdef GSM_ENABLE_BACKUP static void SaveFile(int argc, char *argv[]) { GSM_Backup Backup; int i,j; FILE *file; unsigned char Buffer[10000]; GSM_MemoryEntry *pbk; if (mystrncasecmp(argv[2],"CALENDAR",0)) { if (argc<5) { printmsg("Where is backup filename and location ?\n"); exit(-1); } error=GSM_ReadBackupFile(argv[4],&Backup); if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); i = 0; while (Backup.Calendar[i]!=NULL) { if (i == atoi(argv[5])-1) break; i++; } if (i != atoi(argv[5])-1) { printmsg("Calendar note not found in file\n"); exit(-1); } j = 0; GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar); } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { if (argc<5) { printmsg("Where is backup filename and location ?\n"); exit(-1); } error=GSM_ReadBackupFile(argv[4],&Backup); if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); i = 0; while (Backup.WAPBookmark[i]!=NULL) { if (i == atoi(argv[5])-1) break; i++; } if (i != atoi(argv[5])-1) { printmsg("WAP bookmark not found in file\n"); exit(-1); } j = 0; GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]); } else if (mystrncasecmp(argv[2],"NOTE",0)) { if (argc<5) { printmsg("Where is backup filename and location ?\n"); exit(-1); } error=GSM_ReadBackupFile(argv[4],&Backup); if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); i = 0; while (Backup.Note[i]!=NULL) { if (i == atoi(argv[5])-1) break; i++; } if (i != atoi(argv[5])-1) { printmsg("Note not found in file\n"); exit(-1); } j = 0; GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]); } else if (mystrncasecmp(argv[2],"TODO",0)) { if (argc<5) { printmsg("Where is backup filename and location ?\n"); exit(-1); } error=GSM_ReadBackupFile(argv[4],&Backup); if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); i = 0; while (Backup.ToDo[i]!=NULL) { if (i == atoi(argv[5])-1) break; i++; } if (i != atoi(argv[5])-1) { printmsg("ToDo note not found in file\n"); exit(-1); } j = 0; GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo); } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { if (argc<6) { printmsg("Where is backup filename and location and memory type ?\n"); exit(-1); } error=GSM_ReadBackupFile(argv[4],&Backup); if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); i = 0; if (mystrncasecmp(argv[5],"SM",0)) { while (Backup.SIMPhonebook[i]!=NULL) { if (i == atoi(argv[6])-1) break; i++; } if (i != atoi(argv[6])-1) { printmsg("Phonebook entry not found in file\n"); exit(-1); } pbk = Backup.SIMPhonebook[i]; } else if (mystrncasecmp(argv[5],"ME",0)) { while (Backup.PhonePhonebook[i]!=NULL) { if (i == atoi(argv[6])-1) break; i++; } if (i != atoi(argv[6])-1) { printmsg("Phonebook entry not found in file\n"); exit(-1); } pbk = Backup.PhonePhonebook[i]; } else { printmsg("Unknown memory type: \"%s\"\n",argv[5]); exit(-1); } j = 0; if (mystrncasecmp(argv[2],"VCARD10",0)) { GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10); } else { GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21); } } else { printmsg("What format of file (\"%s\") ?\n",argv[2]); exit(-1); } file = fopen(argv[3],"wb"); fwrite(Buffer,1,j,file); fclose(file); } static void Backup(int argc, char *argv[]) { int i, used; GSM_MemoryStatus MemStatus; GSM_ToDoEntry ToDo; GSM_ToDoStatus ToDoStatus; GSM_MemoryEntry Pbk; GSM_CalendarEntry Calendar; GSM_Bitmap Bitmap; GSM_WAPBookmark Bookmark; GSM_Profile Profile; GSM_MultiWAPSettings Settings; GSM_SyncMLSettings SyncML; GSM_ChatSettings Chat; GSM_Ringtone Ringtone; GSM_SMSC SMSC; GSM_Backup Backup; GSM_NoteEntry Note; GSM_Backup_Info Info; GSM_FMStation FMStation; GSM_GPRSAccessPoint GPRSPoint; bool DoBackup; if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true; GSM_ClearBackup(&Backup); GSM_GetBackupFormatFeatures(argv[2],&Info); sprintf(Backup.Creator,"Gammu %s",VERSION); if (strlen(GetOS()) != 0) { strcat(Backup.Creator+strlen(Backup.Creator),", "); strcat(Backup.Creator+strlen(Backup.Creator),GetOS()); } if (strlen(GetCompiler()) != 0) { strcat(Backup.Creator+strlen(Backup.Creator),", "); strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler()); } signal(SIGINT, interrupt); printmsgerr("Press Ctrl+C to break...\n"); GSM_Init(true); if (Info.UseUnicode) { Info.UseUnicode=answer_yes("Use Unicode subformat of backup file"); } if (Info.DateTime) { GSM_GetCurrentDateTime (&Backup.DateTime); Backup.DateTimeAvailable=true; } if (Info.Model) { error=Phone->GetManufacturer(&s); Print_Error(error); sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer); if (s.Phone.Data.ModelInfo->model[0]!=0) { strcat(Backup.Model,s.Phone.Data.ModelInfo->model); } else { strcat(Backup.Model,s.Phone.Data.Model); } strcat(Backup.Model," "); strcat(Backup.Model,s.Phone.Data.Version); } if (Info.IMEI) { error=Phone->GetIMEI(&s); if (error != ERR_NOTSUPPORTED) { strcpy(Backup.IMEI, s.Phone.Data.IMEI); Print_Error(error); } else { Backup.IMEI[0] = 0; } } printf("\n"); DoBackup = false; if (Info.PhonePhonebook) { printmsg("Checking phone phonebook\n"); MemStatus.MemoryType = MEM_ME; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { if (answer_yes(" Backup phone phonebook")) DoBackup = true; } } if (DoBackup) { Pbk.MemoryType = MEM_ME; i = 1; used = 0; while (used != MemStatus.MemoryUsed) { Pbk.Location = i; error=Phone->GetMemory(&s, &Pbk); if (error != ERR_EMPTY) { Print_Error(error); if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) { Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.PhonePhonebook[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK"); GSM_Terminate(); exit(-1); } *Backup.PhonePhonebook[used]=Pbk; used++; } printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); i++; if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.SIMPhonebook) { printmsg("Checking SIM phonebook\n"); MemStatus.MemoryType = MEM_SM; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { if (answer_yes(" Backup SIM phonebook")) DoBackup=true; } } if (DoBackup) { Pbk.MemoryType = MEM_SM; i = 1; used = 0; while (used != MemStatus.MemoryUsed) { Pbk.Location = i; error=Phone->GetMemory(&s, &Pbk); if (error != ERR_EMPTY) { Print_Error(error); if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) { Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.SIMPhonebook[used + 1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK"); GSM_Terminate(); exit(-1); } *Backup.SIMPhonebook[used]=Pbk; used++; } printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); i++; if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.Calendar) { printmsg("Checking calendar\n"); error=Phone->GetNextCalendar(&s,&Calendar,true); if (error==ERR_NONE) { if (answer_yes(" Backup calendar notes")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading : "); while (error == ERR_NONE) { if (used < GSM_MAXCALENDARTODONOTES) { Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Calendar[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); GSM_Terminate(); exit(-1); } *Backup.Calendar[used]=Calendar; used ++; error=Phone->GetNextCalendar(&s,&Calendar,false); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.ToDo) { printmsg("Checking ToDo\n"); error=Phone->GetToDoStatus(&s,&ToDoStatus); if (error == ERR_NONE && ToDoStatus.Used != 0) { if (answer_yes(" Backup ToDo")) DoBackup = true; } } if (DoBackup) { used = 0; error=Phone->GetNextToDo(&s,&ToDo,true); while (error == ERR_NONE) { if (used < GSM_MAXCALENDARTODONOTES) { Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry)); if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.ToDo[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); GSM_Terminate(); exit(-1); } *Backup.ToDo[used]=ToDo; used ++; error=Phone->GetNextToDo(&s,&ToDo,false); printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.Note) { printmsg("Checking notes\n"); error=Phone->GetNextNote(&s,&Note,true); if (error==ERR_NONE) { if (answer_yes(" Backup notes")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading : "); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_NOTE) { Backup.Note[used] = malloc(sizeof(GSM_NoteEntry)); if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Note[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE"); GSM_Terminate(); exit(-1); } *Backup.Note[used]=Note; used ++; error=Phone->GetNextNote(&s,&Note,false); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.CallerLogos) { printmsg("Checking caller logos\n"); Bitmap.Type = GSM_CallerGroupLogo; Bitmap.Location = 1; error=Phone->GetBitmap(&s,&Bitmap); if (error == ERR_NONE) { if (answer_yes(" Backup caller groups and logos")) DoBackup = true; } } if (DoBackup) { printmsgerr(" Reading : "); error = ERR_NONE; used = 0; while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_CALLER) { Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap)); if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.CallerLogos[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER"); GSM_Terminate(); exit(-1); } *Backup.CallerLogos[used] = Bitmap; used ++; Bitmap.Location = used + 1; error=Phone->GetBitmap(&s,&Bitmap); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.SMSC) { printmsg("Checking SMS profiles\n"); if (answer_yes(" Backup SMS profiles")) DoBackup = true; } if (DoBackup) { used = 0; printmsgerr(" Reading: "); while (true) { SMSC.Location = used + 1; error = Phone->GetSMSC(&s,&SMSC); if (error != ERR_NONE) break; if (used < GSM_BACKUP_MAX_SMSC) { Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.SMSC[used + 1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC"); GSM_Terminate(); exit(-1); } *Backup.SMSC[used]=SMSC; used++; printmsgerr("*"); } printmsgerr("\n"); } DoBackup = false; if (Info.StartupLogo) { printmsg("Checking startup text\n"); Bitmap.Type = GSM_WelcomeNote_Text; error = Phone->GetBitmap(&s,&Bitmap); if (error == ERR_NONE) { if (answer_yes(" Backup startup logo/text")) DoBackup = true; } } if (DoBackup) { Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); *Backup.StartupLogo = Bitmap; if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { Bitmap.Type = GSM_StartupLogo; error = Phone->GetBitmap(&s,&Bitmap); if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; } } DoBackup = false; if (Info.OperatorLogo) { printmsg("Checking operator logo\n"); Bitmap.Type = GSM_OperatorLogo; error=Phone->GetBitmap(&s,&Bitmap); if (error == ERR_NONE) { if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { if (answer_yes(" Backup operator logo")) DoBackup = true; } } } if (DoBackup) { Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); *Backup.OperatorLogo = Bitmap; } DoBackup = false; if (Info.WAPBookmark) { printmsg("Checking WAP bookmarks\n"); Bookmark.Location = 1; error=Phone->GetWAPBookmark(&s,&Bookmark); if (error==ERR_NONE) { if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading : "); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.WAPBookmark[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); GSM_Terminate(); exit(-1); } *Backup.WAPBookmark[used]=Bookmark; used ++; Bookmark.Location = used+1; error=Phone->GetWAPBookmark(&s,&Bookmark); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.WAPSettings) { printmsg("Checking WAP settings\n"); Settings.Location = 1; error=Phone->GetWAPSettings(&s,&Settings); if (error==ERR_NONE) { if (answer_yes(" Backup WAP settings")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading : "); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_WAPSETTINGS) { Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.WAPSettings[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); GSM_Terminate(); exit(-1); } *Backup.WAPSettings[used]=Settings; used ++; Settings.Location = used+1; error=Phone->GetWAPSettings(&s,&Settings); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.MMSSettings) { printmsg("Checking MMS settings\n"); Settings.Location = 1; error=Phone->GetMMSSettings(&s,&Settings); if (error==ERR_NONE) { if (answer_yes(" Backup MMS settings")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading : "); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_MMSSETTINGS) { Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.MMSSettings[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS"); GSM_Terminate(); exit(-1); } *Backup.MMSSettings[used]=Settings; used ++; Settings.Location = used+1; error=Phone->GetMMSSettings(&s,&Settings); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.ChatSettings) { printmsg("Checking Chat settings\n"); Chat.Location = 1; error=Phone->GetChatSettings(&s,&Chat); if (error==ERR_NONE) { if (answer_yes(" Backup Chat settings")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading : "); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_CHATSETTINGS) { Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings)); if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.ChatSettings[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS"); GSM_Terminate(); exit(-1); } *Backup.ChatSettings[used]=Chat; used ++; Chat.Location = used+1; error=Phone->GetChatSettings(&s,&Chat); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.SyncMLSettings) { printmsg("Checking SyncML settings\n"); SyncML.Location = 1; error=Phone->GetSyncMLSettings(&s,&SyncML); if (error==ERR_NONE) { if (answer_yes(" Backup SyncML settings")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading : "); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) { Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings)); if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.SyncMLSettings[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS"); GSM_Terminate(); exit(-1); } *Backup.SyncMLSettings[used]=SyncML; used ++; SyncML.Location = used+1; error=Phone->GetSyncMLSettings(&s,&SyncML); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.Ringtone) { printmsg("Checking user ringtones\n"); Ringtone.Location = 1; Ringtone.Format = 0; error=Phone->GetRingtone(&s,&Ringtone,false); if (error==ERR_EMPTY || error == ERR_NONE) { if (answer_yes(" Backup user ringtones")) DoBackup = true; } } if (DoBackup) { used = 0; i = 1; printmsgerr(" Reading : "); while (error == ERR_NONE || error == ERR_EMPTY) { if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_RINGTONES) { Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Ringtone[used+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES"); GSM_Terminate(); exit(-1); } *Backup.Ringtone[used]=Ringtone; used ++; } i++; Ringtone.Location = i; Ringtone.Format = 0; error=Phone->GetRingtone(&s,&Ringtone,false); printmsgerr("*"); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoBackup = false; if (Info.Profiles) { printmsg("Checking phone profiles\n"); Profile.Location = 1; error = Phone->GetProfile(&s,&Profile); if (error == ERR_NONE) { if (answer_yes(" Backup phone profiles")) DoBackup = true; } } if (DoBackup) { used = 0; printmsgerr(" Reading: "); while (true) { Profile.Location = used + 1; error = Phone->GetProfile(&s,&Profile); if (error != ERR_NONE) break; if (used < GSM_BACKUP_MAX_PROFILES) { Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Profiles[used + 1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES"); GSM_Terminate(); exit(-1); } *Backup.Profiles[used]=Profile; used++; printmsgerr("*"); } printmsgerr("\n"); } DoBackup = false; if (Info.FMStation) { printmsg("Checking FM stations\n"); FMStation.Location = 1; error = Phone->GetFMStation(&s,&FMStation); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes(" Backup phone FM stations")) DoBackup=true; } } if (DoBackup) { used = 0; i = 1; printmsgerr(" Reading: "); while (error == ERR_NONE || error == ERR_EMPTY) { error = Phone->GetFMStation(&s,&FMStation); if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_FMSTATIONS) { Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.FMStation[used + 1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); GSM_Terminate(); exit(-1); } *Backup.FMStation[used]=FMStation; used++; } i++; FMStation.Location = i; printmsgerr("*"); } printmsgerr("\n"); } DoBackup = false; if (Info.GPRSPoint) { printmsg("Checking GPRS access points\n"); GPRSPoint.Location = 1; error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes(" Backup GPRS access points")) DoBackup = true; } } if (DoBackup) { used = 0; i = 1; printmsgerr(" Reading: "); while (error == ERR_NONE || error == ERR_EMPTY) { error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_GPRSPOINT) { Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.GPRSPoint[used + 1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT"); GSM_Terminate(); exit(-1); } *Backup.GPRSPoint[used]=GPRSPoint; used++; } i++; GPRSPoint.Location = i; printmsgerr("*"); } printmsgerr("\n"); } GSM_Terminate(); GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode); GSM_FreeBackup(&Backup); } static void Restore(int argc, char *argv[]) { GSM_Backup Backup; GSM_FMStation FMStation; GSM_DateTime date_time; GSM_CalendarEntry Calendar; GSM_Bitmap Bitmap; GSM_Ringtone Ringtone; GSM_MemoryEntry Pbk; GSM_MemoryStatus MemStatus; GSM_ToDoEntry ToDo; GSM_ToDoStatus ToDoStatus; GSM_Profile Profile; GSM_MultiWAPSettings Settings; GSM_GPRSAccessPoint GPRSPoint; GSM_WAPBookmark Bookmark; int i, used, max = 0; bool Past = true; bool Found, DoRestore; error=GSM_ReadBackupFile(argv[2],&Backup); if (error!=ERR_NOTIMPLEMENTED) { Print_Error(error); } else { printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n"); } signal(SIGINT, interrupt); printmsgerr("Press Ctrl+C to break...\n"); if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator); if (Backup.MD5Calculated[0]!=0) { dbgprintf("\"%s\"\n",Backup.MD5Original); dbgprintf("\"%s\"\n",Backup.MD5Calculated); if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) { if (!answer_yes("Checksum in backup file do not match. Continue")) return; } } GSM_Init(true); DoRestore = false; if (Backup.PhonePhonebook[0] != NULL) { MemStatus.MemoryType = MEM_ME; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE) { max = 0; while (Backup.PhonePhonebook[max]!=NULL) max++; printmsgerr("%i entries in backup file\n",max); if (answer_yes("Restore phone phonebook")) DoRestore = true; } } if (DoRestore) { used = 0; for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { Pbk.MemoryType = MEM_ME; Pbk.Location = i + 1; Pbk.EntriesNum = 0; if (used<max) { if (Backup.PhonePhonebook[used]->Location == Pbk.Location) { Pbk = *Backup.PhonePhonebook[used]; used++; dbgprintf("Location %i\n",Pbk.Location); if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); } } if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.SIMPhonebook[0] != NULL) { MemStatus.MemoryType = MEM_SM; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE) { max = 0; while (Backup.SIMPhonebook[max]!=NULL) max++; printmsgerr("%i entries in backup file\n",max); if (answer_yes("Restore SIM phonebook")) DoRestore = true; } } if (DoRestore) { used = 0; for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { Pbk.MemoryType = MEM_SM; Pbk.Location = i + 1; Pbk.EntriesNum = 0; if (used<max) { if (Backup.SIMPhonebook[used]->Location == Pbk.Location) { Pbk = *Backup.SIMPhonebook[used]; used++; dbgprintf("Location %i\n",Pbk.Location); if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); } } if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.CallerLogos[0] != NULL) { Bitmap.Type = GSM_CallerGroupLogo; Bitmap.Location = 1; error=Phone->GetBitmap(&s,&Bitmap); if (error == ERR_NONE) { if (answer_yes("Restore caller groups and logos")) DoRestore = true; } } if (DoRestore) { max = 0; while (Backup.CallerLogos[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { - 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)")) { + if ( true /*LRanswer_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)")*/) { GSM_GetCurrentDateTime(&date_time); error=Phone->SetDateTime(&s, &date_time); Print_Error(error); } } DoRestore = false; if (Backup.Calendar[0] != NULL) { /* N6110 doesn't support getting calendar status */ error = Phone->GetNextCalendar(&s,&Calendar,true); if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { max = 0; while (Backup.Calendar[max] != NULL) max++; printmsgerr("%i entries in backup file\n",max); // LR //if (answer_yes("Restore calendar notes")) { //Past = answer_yes("Restore notes from the past"); DoRestore = true; //} } } if (DoRestore) { printmsgerr("Deleting old notes: "); error = Phone->DeleteAllCalendar(&s); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { while (1) { error = Phone->GetNextCalendar(&s,&Calendar,true); if (error != ERR_NONE) break; error = Phone->DeleteCalendar(&s,&Calendar); Print_Error(error); printmsgerr("*"); } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } for (i=0;i<max;i++) { if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; Calendar = *Backup.Calendar[i]; error=Phone->AddCalendar(&s,&Calendar); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.ToDo[0] != NULL) { error = Phone->GetToDoStatus(&s,&ToDoStatus); if (error == ERR_NONE) { max = 0; while (Backup.ToDo[max]!=NULL) max++; printmsgerr("%i entries in backup file\n",max); //LR if (answer_yes("Restore ToDo")) DoRestore = true; } } if (DoRestore) { ToDo = *Backup.ToDo[0]; error = Phone->SetToDo(&s,&ToDo); } if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { printmsgerr("Deleting old ToDo: "); error=Phone->DeleteAllToDo(&s); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { while (1) { error = Phone->GetNextToDo(&s,&ToDo,true); if (error != ERR_NONE) break; error = Phone->DeleteToDo(&s,&ToDo); Print_Error(error); printmsgerr("*"); } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } for (i=0;i<max;i++) { ToDo = *Backup.ToDo[i]; ToDo.Location = 0; error=Phone->AddToDo(&s,&ToDo); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } else if (DoRestore) { /* At first delete entries, that were deleted */ used = 0; error = Phone->GetNextToDo(&s,&ToDo,true); while (error == ERR_NONE) { used++; Found = false; for (i=0;i<max;i++) { if (Backup.ToDo[i]->Location == ToDo.Location) { Found = true; break; } } if (!Found) { error=Phone->DeleteToDo(&s,&ToDo); Print_Error(error); } error = Phone->GetNextToDo(&s,&ToDo,false); printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); /* Now write modified/new entries */ for (i=0;i<max;i++) { ToDo = *Backup.ToDo[i]; error = Phone->SetToDo(&s,&ToDo); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { max = 0; while (Backup.SMSC[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetSMSC(&s,Backup.SMSC[i]); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { error=Phone->SetBitmap(&s,Backup.StartupLogo); Print_Error(error); } if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { error=Phone->SetBitmap(&s,Backup.OperatorLogo); Print_Error(error); } DoRestore = false; if (Backup.WAPBookmark[0] != NULL) { Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { if (answer_yes("Restore WAP bookmarks")) DoRestore = true; } } if (DoRestore) { printmsgerr("Deleting old bookmarks: "); /* One thing to explain: DCT4 phones seems to have bug here. * When delete for example first bookmark, phone change * numeration for getting frame, not for deleting. So, we try to * get 1'st bookmark. Inside frame is "correct" location. We use * it later */ while (error==ERR_NONE) { error = Phone->DeleteWAPBookmark(&s,&Bookmark); Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); printmsgerr("*"); } printmsgerr("\n"); max = 0; while (Backup.WAPBookmark[max]!=NULL) max++; for (i=0;i<max;i++) { Bookmark = *Backup.WAPBookmark[i]; Bookmark.Location = 0; error=Phone->SetWAPBookmark(&s,&Bookmark); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.WAPSettings[0] != NULL) { Settings.Location = 1; error = Phone->GetWAPSettings(&s,&Settings); if (error == ERR_NONE) { if (answer_yes("Restore WAP settings")) DoRestore = true; } } if (DoRestore) { max = 0; while (Backup.WAPSettings[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.MMSSettings[0] != NULL) { Settings.Location = 1; error = Phone->GetMMSSettings(&s,&Settings); if (error == ERR_NONE) { if (answer_yes("Restore MMS settings")) DoRestore = true; } } if (DoRestore) { max = 0; while (Backup.MMSSettings[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.Ringtone[0] != NULL) { Ringtone.Location = 1; Ringtone.Format = 0; error = Phone->GetRingtone(&s,&Ringtone,false); if (error == ERR_NONE || error ==ERR_EMPTY) { if (Phone->DeleteUserRingtones != NOTSUPPORTED) { if (answer_yes("Delete all user ringtones")) DoRestore = true; } } } if (DoRestore) { printmsgerr("Deleting: "); error=Phone->DeleteUserRingtones(&s); Print_Error(error); printmsgerr("Done\n"); DoRestore = false; if (answer_yes("Restore user ringtones")) DoRestore = true; } if (DoRestore) { max = 0; while (Backup.Ringtone[max]!=NULL) max++; for (i=0;i<max;i++) { error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format); Print_Error(error); error=Phone->SetRingtone(&s,&Ringtone,&i); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.Profiles[0] != NULL) { Profile.Location = 1; error = Phone->GetProfile(&s,&Profile); if (error == ERR_NONE) { if (answer_yes("Restore profiles")) DoRestore = true; } } if (DoRestore) { Profile.Location= 0; max = 0; while (Backup.Profiles[max]!=NULL) max++; for (i=0;i<max;i++) { Profile = *Backup.Profiles[i]; error=Phone->SetProfile(&s,&Profile); Print_Error(error); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.FMStation[0] != NULL) { FMStation.Location = 1; error = Phone->GetFMStation(&s,&FMStation); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes("Restore FM stations")) DoRestore = true; } } if (DoRestore) { printmsgerr("Deleting old FM stations: "); error=Phone->ClearFMStations(&s); Print_Error(error); printmsgerr("Done\n"); max = 0; while (Backup.FMStation[max]!=NULL) max++; for (i=0;i<max;i++) { FMStation = *Backup.FMStation[i]; error=Phone->SetFMStation(&s,&FMStation); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.GPRSPoint[0] != NULL) { GPRSPoint.Location = 1; error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes("Restore GPRS Points")) DoRestore = true; } } if (DoRestore) { max = 0; while (Backup.GPRSPoint[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } GSM_Terminate(); } static void AddNew(int argc, char *argv[]) { GSM_Backup Backup; GSM_DateTime date_time; GSM_MemoryEntry Pbk; GSM_MemoryStatus MemStatus; GSM_ToDoEntry ToDo; GSM_ToDoStatus ToDoStatus; GSM_CalendarEntry Calendar; GSM_WAPBookmark Bookmark; int i, max, j; error=GSM_ReadBackupFile(argv[2],&Backup); if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); signal(SIGINT, interrupt); printmsgerr("Press Ctrl+C to break...\n"); if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); GSM_Init(true); if (Backup.PhonePhonebook[0] != NULL) { MemStatus.MemoryType = MEM_ME; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE) { max = 0; while (Backup.PhonePhonebook[max]!=NULL) max++; printmsgerr("%i entries in backup file\n",max); if (MemStatus.MemoryFree < max) { printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); } else if (answer_yes("Add phone phonebook entries")) { for (i=0;i<max;i++) { Pbk = *Backup.PhonePhonebook[i]; Pbk.MemoryType = MEM_ME; error=Phone->AddMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } } } if (Backup.SIMPhonebook[0] != NULL) { MemStatus.MemoryType = MEM_SM; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE) { max = 0; while (Backup.SIMPhonebook[max]!=NULL) max++; printmsgerr("%i entries in backup file\n",max); if (MemStatus.MemoryFree < max) { printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); } else if (answer_yes("Add SIM phonebook entries")) { j = 1; for (i=0;i<max;i++) { Pbk = *Backup.SIMPhonebook[i]; Pbk.MemoryType = MEM_SM; error=Phone->AddMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } } } if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { - 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)")) { + if (true /*LRanswer_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)")*/) { GSM_GetCurrentDateTime(&date_time); error=Phone->SetDateTime(&s, &date_time); Print_Error(error); } } if (Backup.Calendar[0] != NULL) { error = Phone->GetNextCalendar(&s,&Calendar,true); if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { if (answer_yes("Add calendar notes")) { max = 0; while (Backup.Calendar[max]!=NULL) max++; for (i=0;i<max;i++) { Calendar = *Backup.Calendar[i]; error=Phone->AddCalendar(&s,&Calendar); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } } } if (Backup.ToDo[0] != NULL) { ToDo.Location = 1; error=Phone->GetToDoStatus(&s,&ToDoStatus); if (error == ERR_NONE) { if (answer_yes("Add ToDo")) { max = 0; while (Backup.ToDo[max]!=NULL) max++; for (i=0;i<max;i++) { ToDo = *Backup.ToDo[i]; error = Phone->AddToDo(&s,&ToDo); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } } } if (Backup.WAPBookmark[0] != NULL) { Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { if (answer_yes("Add WAP bookmarks")) { max = 0; while (Backup.WAPBookmark[max]!=NULL) max++; for (i=0;i<max;i++) { Bookmark = *Backup.WAPBookmark[i]; Bookmark.Location = 0; error=Phone->SetWAPBookmark(&s,&Bookmark); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } } } GSM_Terminate(); } #endif static void ClearAll(int argc, char *argv[]) { GSM_MemoryStatus MemStatus; GSM_ToDoStatus ToDoStatus; GSM_CalendarEntry Calendar; GSM_ToDoEntry ToDo; GSM_WAPBookmark Bookmark; GSM_FMStation Station; GSM_MemoryEntry Pbk; bool DoClear; GSM_Init(true); DoClear = false; MemStatus.MemoryType = MEM_ME; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { if (answer_yes("Delete phone phonebook")) DoClear = true; } if (DoClear) { error = Phone->DeleteAllMemory(&s,MEM_ME); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { Pbk.MemoryType = MEM_ME; Pbk.Location = i + 1; Pbk.EntriesNum = 0; error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } } DoClear = false; MemStatus.MemoryType = MEM_SM; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { if (answer_yes("Delete SIM phonebook")) DoClear = true; } if (DoClear) { error = Phone->DeleteAllMemory(&s,MEM_SM); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { Pbk.MemoryType = MEM_SM; Pbk.Location = i + 1; Pbk.EntriesNum = 0; error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } } DoClear = false; error = Phone->GetNextCalendar(&s,&Calendar,true); if (error == ERR_NONE) { if (answer_yes("Delete calendar notes")) DoClear = true; } if (DoClear) { printmsgerr("Deleting: "); error=Phone->DeleteAllCalendar(&s); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { while (1) { error = Phone->GetNextCalendar(&s,&Calendar,true); if (error != ERR_NONE) break; error = Phone->DeleteCalendar(&s,&Calendar); Print_Error(error); printmsgerr("*"); } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } } DoClear = false; error = Phone->GetToDoStatus(&s,&ToDoStatus); if (error == ERR_NONE && ToDoStatus.Used != 0) { if (answer_yes("Delete ToDo")) DoClear = true; } if (DoClear) { printmsgerr("Deleting: "); error=Phone->DeleteAllToDo(&s); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { while (1) { error = Phone->GetNextToDo(&s,&ToDo,true); if (error != ERR_NONE) break; error = Phone->DeleteToDo(&s,&ToDo); Print_Error(error); printmsgerr("*"); } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } } Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { if (answer_yes("Delete WAP bookmarks")) { printmsgerr("Deleting: "); /* One thing to explain: DCT4 phones seems to have bug here. * When delete for example first bookmark, phone change * numeration for getting frame, not for deleting. So, we try to * get 1'st bookmark. Inside frame is "correct" location. We use * it later */ while (error==ERR_NONE) { error = Phone->DeleteWAPBookmark(&s,&Bookmark); Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); printmsgerr("*"); } printmsgerr("\n"); } } if (Phone->DeleteUserRingtones != NOTSUPPORTED) { if (answer_yes("Delete all user ringtones")) { printmsgerr("Deleting: "); error=Phone->DeleteUserRingtones(&s); Print_Error(error); printmsgerr("Done\n"); } } Station.Location=i; error=Phone->GetFMStation(&s,&Station); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes("Delete all FM station")) { error=Phone->ClearFMStations(&s); Print_Error(error); } } GSM_Terminate(); } static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) { if (settings->Settings[j].IsContinuous) { printmsg("Connection type : Continuous\n"); } else { printmsg("Connection type : Temporary\n"); } if (settings->Settings[j].IsSecurity) { printmsg("Connection security : On\n"); } else { printmsg("Connection security : Off\n"); } printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); switch (settings->Settings[j].Bearer) { case WAPSETTINGS_BEARER_SMS: printmsg("Bearer : SMS"); if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); break; case WAPSETTINGS_BEARER_DATA: printmsg("Bearer : Data (CSD)"); if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); if (settings->Settings[j].ManualLogin) { printmsg("Login Type : Manual\n"); } else { printmsg("Login Type : Automatic\n"); } if (settings->Settings[j].IsNormalAuthentication) { printmsg("Authentication type : Normal\n"); } else { printmsg("Authentication type : Secure\n"); } if (settings->Settings[j].IsISDNCall) { printmsg("Data call type : ISDN\n"); } else { printmsg("Data call type : Analogue\n"); } switch (settings->Settings[j].Speed) { case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; } printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); break; case WAPSETTINGS_BEARER_USSD: printmsg("Bearer : USSD"); if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); if (settings->Settings[j].IsIP) { printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); } else { printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); } break; case WAPSETTINGS_BEARER_GPRS: printmsg("Bearer : GPRS"); if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); if (settings->Settings[j].ManualLogin) { printmsg("\nLogin Type : Manual\n"); } else { printmsg("\nLogin Type : Automatic\n"); } if (settings->Settings[j].IsNormalAuthentication) { printmsg("Authentication type : Normal\n"); } else { printmsg("Authentication type : Secure\n"); } printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); } } static void GetSyncMLSettings(int argc, char *argv[]) { GSM_SyncMLSettings settings; int start,stop,j; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { settings.Location=i; error=Phone->GetSyncMLSettings(&s,&settings); Print_Error(error); printmsg("%i. ",i); if (settings.Name[0]==0 && settings.Name[1]==0) { printmsg("Set %i",i); } else { printmsg("%s",DecodeUnicodeConsole(settings.Name)); } if (settings.Active) printmsg(" (active)"); // if (settings.ReadOnly) printmsg("\nRead only : yes"); printmsg("\n"); printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); printmsg("Sync. phonebook : "); if (settings.SyncPhonebook) printmsg("yes\n"); if (!settings.SyncPhonebook) printmsg("no\n"); printmsg("Sync. calendar : "); if (settings.SyncCalendar) printmsg("yes\n"); if (!settings.SyncCalendar) printmsg("no\n"); printmsg("\n"); for (j=0;j<settings.Connection.Number;j++) { if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { printmsg("Connection set name : Set %i\n",i); } else { printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); } DisplayConnectionSettings(&settings.Connection,j); printf("\n"); } } GSM_Terminate(); } static void GetChatSettings(int argc, char *argv[]) { GSM_ChatSettings settings; int start,stop,j; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { settings.Location=i; error=Phone->GetChatSettings(&s,&settings); Print_Error(error); printmsg("%i. ",i); if (settings.Name[0]==0 && settings.Name[1]==0) { printmsg("Set %i",i); } else { printmsg("%s",DecodeUnicodeConsole(settings.Name)); } if (settings.Active) printmsg(" (active)"); // if (settings.ReadOnly) printmsg("\nRead only : yes"); printmsg("\n"); printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); printmsg("\n"); for (j=0;j<settings.Connection.Number;j++) { if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { printmsg("Connection set name : Set %i\n",i); } else { printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); } DisplayConnectionSettings(&settings.Connection,j); printf("\n"); } } GSM_Terminate(); } static void GetWAPMMSSettings(int argc, char *argv[]) { GSM_MultiWAPSettings settings; int start,stop,j; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { settings.Location=i; if (mystrncasecmp(argv[1],"--getwapsettings",0)) { error=Phone->GetWAPSettings(&s,&settings); } else { error=Phone->GetMMSSettings(&s,&settings); } Print_Error(error); for (j=0;j<settings.Number;j++) { printmsg("%i. ",i); if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { printmsg("Set %i",i); } else { printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); } if (settings.Active) printmsg(" (active)"); if (settings.ReadOnly) printmsg("\nRead only : yes"); printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); DisplayConnectionSettings(&settings,j); printf("\n"); } } GSM_Terminate(); } #ifdef GSM_ENABLE_BACKUP static void BackupSMS(int argc, char *argv[]) { GSM_SMS_Backup Backup; GSM_MultiSMSMessage sms; GSM_SMSFolders folders; bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; bool start = true; bool DeleteAfter; int j, smsnum; char buffer[200]; /* We ignore return code, because (when file doesn't exist) we * will create new later */ GSM_ReadSMSBackupFile(argv[2], &Backup); smsnum = 0; while (Backup.SMS[smsnum]!=NULL) smsnum++; GSM_Init(true); error=Phone->GetSMSFolders(&s, &folders); Print_Error(error); DeleteAfter=answer_yes("Delete each sms after backup"); for (j=0;j<folders.Number;j++) { BackupFromFolder[j] = false; sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); if (answer_yes(buffer)) BackupFromFolder[j] = true; } while (error == ERR_NONE) { sms.SMS[0].Folder=0x00; error=Phone->GetNextSMS(&s, &sms, start); switch (error) { case ERR_EMPTY: break; default: Print_Error(error); for (j=0;j<sms.Number;j++) { if (BackupFromFolder[sms.SMS[j].Folder-1]) { switch (sms.SMS[j].PDU) { case SMS_Status_Report: break; case SMS_Submit: case SMS_Deliver: if (sms.SMS[j].Length == 0) break; if (smsnum < GSM_BACKUP_MAX_SMS) { Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); Backup.SMS[smsnum+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); GSM_Terminate(); exit(-1); } *Backup.SMS[smsnum] = sms.SMS[j]; smsnum++; break; } } } } start=false; } error = GSM_SaveSMSBackupFile(argv[2],&Backup); Print_Error(error); if (DeleteAfter) { for (j=0;j<smsnum;j++) { Backup.SMS[j]->Folder = 0; error=Phone->DeleteSMS(&s, Backup.SMS[j]); Print_Error(error); printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); } } GSM_Terminate(); } static void AddSMS(int argc, char *argv[]) { GSM_MultiSMSMessage SMS; GSM_SMS_Backup Backup; int smsnum = 0; int folder; folder = atoi(argv[2]); error = GSM_ReadSMSBackupFile(argv[3], &Backup); Print_Error(error); GSM_Init(true); while (Backup.SMS[smsnum] != NULL) { Backup.SMS[smsnum]->Folder = folder; Backup.SMS[smsnum]->SMSC.Location = 1; SMS.Number = 1; SMS.SMS[0] = *Backup.SMS[smsnum]; displaymultismsinfo(SMS,false,false); if (answer_yes("Restore sms")) { error=Phone->AddSMS(&s, Backup.SMS[smsnum]); Print_Error(error); } smsnum++; } GSM_Terminate(); } static void RestoreSMS(int argc, char *argv[]) { GSM_MultiSMSMessage SMS; GSM_SMS_Backup Backup; GSM_SMSFolders folders; int smsnum = 0; char buffer[200]; error=GSM_ReadSMSBackupFile(argv[2], &Backup); Print_Error(error); GSM_Init(true); error=Phone->GetSMSFolders(&s, &folders); Print_Error(error); while (Backup.SMS[smsnum] != NULL) { SMS.Number = 1; memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); displaymultismsinfo(SMS,false,false); sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); if (answer_yes(buffer)) { error=Phone->AddSMS(&s, Backup.SMS[smsnum]); Print_Error(error); } smsnum++; } GSM_Terminate(); } #endif static void CopyBitmap(int argc, char *argv[]) { GSM_MultiBitmap Bitmap; int i; Bitmap.Bitmap[0].Type = GSM_None; error=GSM_ReadBitmapFile(argv[2],&Bitmap); Print_Error(error); if (argc==3) { for (i=0;i<Bitmap.Number;i++) { switch (Bitmap.Bitmap[i].Type) { case GSM_StartupLogo : printmsg("Startup logo"); break; case GSM_OperatorLogo: printmsg("Operator logo"); break; case GSM_PictureImage: printmsg("Picture Image"); break; case GSM_CallerGroupLogo : printmsg("Caller group logo"); break; default : break; } printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight); GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]); } } else { if (argc == 5) { for (i=0;i<Bitmap.Number;i++) { if (mystrncasecmp(argv[4],"PICTURE",0)) { Bitmap.Bitmap[i].Type = GSM_PictureImage; } else if (mystrncasecmp(argv[4],"STARTUP",0)) { Bitmap.Bitmap[i].Type = GSM_StartupLogo; } else if (mystrncasecmp(argv[4],"CALLER",0)) { Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { Bitmap.Bitmap[i].Type = GSM_OperatorLogo; } else { printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); exit(-1); } } } error=GSM_SaveBitmapFile(argv[3],&Bitmap); Print_Error(error); } } static void NokiaComposer(int argc, char *argv[]) { GSM_Ringtone ringtone; bool started; int i,j; GSM_RingNote *Note; GSM_RingNoteDuration Duration; GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ unsigned int DefNoteScale = Scale_880; ringtone.Format = 0; error=GSM_ReadRingtoneFile(argv[2],&ringtone); if (ringtone.Format != RING_NOTETONE) { printmsg("It can be RTTL ringtone only used with this option\n"); exit(-1); } started = false; j = 0; for (i=0;i<ringtone.NoteTone.NrCommands;i++) { if (ringtone.NoteTone.Commands[i].Type == RING_Note) { Note = &ringtone.NoteTone.Commands[i].Note; if (!started) { if (Note->Note != Note_Pause) { printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); started = true; } } if (started) j++; } } if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); started = false; for (i=0;i<ringtone.NoteTone.NrCommands;i++) { if (ringtone.NoteTone.Commands[i].Type == RING_Note) { Note = &ringtone.NoteTone.Commands[i].Note; if (!started) { if (Note->Note != Note_Pause) started = true; } if (started) { switch (Note->Duration) { case Duration_Full: printmsg("1"); break; case Duration_1_2 : printmsg("2"); break; case Duration_1_4 : printmsg("4"); break; case Duration_1_8 : printmsg("8"); break; case Duration_1_16: printmsg("16");break; case Duration_1_32: printmsg("32");break; } if (Note->DurationSpec == DottedNote) printmsg("."); switch (Note->Note) { case Note_C : printmsg("c"); break; case Note_Cis : printmsg("#c"); break; case Note_D :printmsg("d"); break; case Note_Dis : printmsg("#d"); break; case Note_E : printmsg("e"); break; case Note_F : printmsg("f"); break; case Note_Fis : printmsg("#f"); break; case Note_G : printmsg("g"); break; case Note_Gis : printmsg("#g"); break; case Note_A : printmsg("a"); break; case Note_Ais : printmsg("#a"); break; case Note_H : printmsg("h"); break; case Note_Pause : printmsg("-"); break; } if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4); printmsg(" "); } } } printmsg("\n\nTo enter it please press: "); started = false; for (i=0;i<ringtone.NoteTone.NrCommands;i++) { if (ringtone.NoteTone.Commands[i].Type == RING_Note) { Note = &ringtone.NoteTone.Commands[i].Note; if (!started) { if (Note->Note != Note_Pause) started = true; } if (started) { switch (Note->Note) { case Note_C : case Note_Cis: printmsg("1");break; case Note_D : case Note_Dis: printmsg("2");break; case Note_E : printmsg("3");break; case Note_F : case Note_Fis: printmsg("4");break; case Note_G : case Note_Gis: printmsg("5");break; case Note_A : case Note_Ais: printmsg("6");break; case Note_H : printmsg("7");break; default : printmsg("0");break; } if (Note->DurationSpec == DottedNote) printmsg("(longer)"); switch (Note->Note) { case Note_Cis: case Note_Dis: case Note_Fis: case Note_Gis: case Note_Ais: printmsg("#"); break; default : break; } if (Note->Note != Note_Pause) { if ((unsigned int)Note->Scale != DefNoteScale) { while (DefNoteScale != (unsigned int)Note->Scale) { printmsg("*"); DefNoteScale++; if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880; } } } Duration = 0; switch (Note->Duration) { case Duration_Full : Duration = 128; break; case Duration_1_2 : Duration = 64; break; case Duration_1_4 : Duration = 32; break; case Duration_1_8 : Duration = 16; break; case Duration_1_16 : Duration = 8; break; case Duration_1_32 : Duration = 4; break; default : dbgprintf("error\n");break; } if (Duration > DefNoteDuration) { while (DefNoteDuration != Duration) { printmsg("9"); DefNoteDuration = DefNoteDuration * 2; } } if (Duration < DefNoteDuration) { while (DefNoteDuration != Duration) { printmsg("8"); DefNoteDuration = DefNoteDuration / 2; } } printmsg(" "); } } } printf("\n"); } static void CopyRingtone(int argc, char *argv[]) { GSM_Ringtone ringtone, ringtone2; GSM_RingtoneFormat Format; ringtone.Format = 0; error=GSM_ReadRingtoneFile(argv[2],&ringtone); Print_Error(error); Format = ringtone.Format; if (argc == 5) { if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; } else if (mystrncasecmp(argv[4],"BINARY",0)) { Format = RING_NOKIABINARY; } else { printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]); exit(-1); } } error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format); Print_Error(error); error=GSM_SaveRingtoneFile(argv[3],&ringtone2); Print_Error(error); } static void PressKeySequence(int argc, char *argv[]) { int i,Length; GSM_KeyCode KeyCode[500]; error = MakeKeySequence(argv[2], KeyCode, &Length); if (error == ERR_NOTSUPPORTED) { printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]); exit(-1); } GSM_Init(true); for (i=0;i<Length;i++) { error=Phone->PressKey(&s, KeyCode[i], true); Print_Error(error); error=Phone->PressKey(&s, KeyCode[i], false); Print_Error(error); } GSM_Terminate(); } static void GetAllCategories(int argc, char *argv[]) { GSM_Category Category; GSM_CategoryStatus Status; int j, count; if (mystrncasecmp(argv[2],"TODO",0)) { Category.Type = Category_ToDo; Status.Type = Category_ToDo; } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { Category.Type = Category_Phonebook; Status.Type = Category_Phonebook; } else { printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); exit(-1); } GSM_Init(true); error=Phone->GetCategoryStatus(&s, &Status); Print_Error(error); for (count=0,j=1;count<Status.Used;j++) { Category.Location=j; error=Phone->GetCategory(&s, &Category); if (error != ERR_EMPTY) { printmsg("Location: %i\n",j); Print_Error(error); printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); count++; } } GSM_Terminate(); } static void GetCategory(int argc, char *argv[]) { GSM_Category Category; int start,stop,j; if (mystrncasecmp(argv[2],"TODO",0)) { Category.Type = Category_ToDo; } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { Category.Type = Category_Phonebook; } else { printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); exit(-1); } GetStartStop(&start, &stop, 2, argc - 1, argv + 1); GSM_Init(true); for (j=start;j<=stop;j++) { printmsg("Location: %i\n",j); Category.Location=j; error=Phone->GetCategory(&s, &Category); if (error != ERR_EMPTY) Print_Error(error); if (error == ERR_EMPTY) { printmsg("Entry is empty\n\n"); } else { printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); } } GSM_Terminate(); } static void DeleteToDo(int argc, char *argv[]) { GSM_ToDoEntry ToDo; int i; int start,stop; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { ToDo.Location=i; printmsg("Location : %i\n",i); error=Phone->DeleteToDo(&s,&ToDo); if (error != ERR_EMPTY) Print_Error(error); if (error == ERR_EMPTY) { printmsg("Entry was empty\n"); } else { printmsg("Entry was deleted\n"); } printf("\n"); } GSM_Terminate(); } static void PrintToDo(GSM_ToDoEntry *ToDo) { int j; GSM_MemoryEntry entry; unsigned char *name; GSM_Category Category; printmsg("Location : %i\n",ToDo->Location); printmsg("Priority : "); switch (ToDo->Priority) { case GSM_Priority_Low : printmsg("Low\n"); break; case GSM_Priority_Medium : printmsg("Medium\n"); break; case GSM_Priority_High : printmsg("High\n"); break; default : printmsg("Unknown\n"); break; } for (j=0;j<ToDo->EntriesNum;j++) { switch (ToDo->Entries[j].EntryType) { case TODO_END_DATETIME: printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); break; case TODO_COMPLETED: printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); break; case TODO_ALARM_DATETIME: printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); break; case TODO_SILENT_ALARM_DATETIME: printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); break; case TODO_TEXT: printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); break; case TODO_PRIVATE: printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); break; case TODO_CATEGORY: Category.Location = ToDo->Entries[j].Number; Category.Type = Category_ToDo; error=Phone->GetCategory(&s, &Category); if (error == ERR_NONE) { printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number); } else { printmsg("Category : %i\n", ToDo->Entries[j].Number); } break; case TODO_CONTACTID: entry.Location = ToDo->Entries[j].Number; entry.MemoryType = MEM_ME; error=Phone->GetMemory(&s, &entry); if (error == ERR_NONE) { name = GSM_PhonebookGetEntryName(&entry); if (name != NULL) { printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); } else { printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); } } else { printmsg("Contact : %d\n",ToDo->Entries[j].Number); } break; case TODO_PHONE: printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); break; } } printf("\n"); } static void ListToDoCategoryEntries(int Category) { GSM_ToDoEntry Entry; bool start = true; int j; while (!gshutdown) { error = Phone->GetNextToDo(&s, &Entry, start); if (error == ERR_EMPTY) break; Print_Error(error); for (j=0;j<Entry.EntriesNum;j++) { if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category) PrintToDo(&Entry); } start = false; } } static void ListToDoCategory(int argc, char *argv[]) { GSM_Category Category; GSM_CategoryStatus Status; int j, count; unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; int Length; bool Number = true;; GSM_Init(true); signal(SIGINT, interrupt); printmsgerr("Press Ctrl+C to break...\n"); Length = strlen(argv[2]); for (j = 0; j < Length; j++) { if (!isdigit(argv[2][j])) { Number = false; break; } } if (Number) { j = atoi(argv[2]); if (j > 0) { ListToDoCategoryEntries(j); } diff --git a/gammu/gammu.tar.bz2 b/gammu/gammu.tar.bz2 Binary files differdeleted file mode 100644 index 7c921a7..0000000 --- a/gammu/gammu.tar.bz2 +++ b/dev/null |