summaryrefslogtreecommitdiffabout
path: root/gammu/emb/gammu/gammu.c
Unidiff
Diffstat (limited to 'gammu/emb/gammu/gammu.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/gammu/gammu.c121
1 files changed, 98 insertions, 23 deletions
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
index 684e67c..4c6486d 100644
--- a/gammu/emb/gammu/gammu.c
+++ b/gammu/emb/gammu/gammu.c
@@ -435,7 +435,7 @@ static void SetAlarm(int argc, char *argv[])
435} 435}
436 436
437 GSM_Bitmap caller[5]; 437 GSM_Bitmap caller[5];
438 GSM_AllRingtonesInfo Info; 438 GSM_AllRingtonesInfo Info = {0, NULL};
439 bool callerinit[5] = {false, false, false, false, false}; 439 bool callerinit[5] = {false, false, false, false, false};
440 bool ringinit = false; 440 bool ringinit = false;
441 441
@@ -564,12 +564,15 @@ static void GetAllMemory(int argc, char *argv[])
564 while (!gshutdown) { 564 while (!gshutdown) {
565 error = Phone->GetNextMemory(&s, &Entry, start); 565 error = Phone->GetNextMemory(&s, &Entry, start);
566 if (error == ERR_EMPTY) break; 566 if (error == ERR_EMPTY) break;
567 if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone);
567 Print_Error(error); 568 Print_Error(error);
568 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location); 569 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location);
569 PrintMemoryEntry(&Entry); 570 PrintMemoryEntry(&Entry);
570 start = false; 571 start = false;
571 } 572 }
572 573
574 if (Info.Ringtone) free(Info.Ringtone);
575
573 GSM_Terminate(); 576 GSM_Terminate();
574} 577}
575 578
@@ -617,7 +620,10 @@ static void GetMemory(int argc, char *argv[])
617 entry.Location=j; 620 entry.Location=j;
618 621
619 error=Phone->GetMemory(&s, &entry); 622 error=Phone->GetMemory(&s, &entry);
620 if (error != ERR_EMPTY) Print_Error(error); 623 if (error != ERR_EMPTY) {
624 if (Info.Ringtone) free(Info.Ringtone);
625 Print_Error(error);
626 }
621 627
622 if (error == ERR_EMPTY) { 628 if (error == ERR_EMPTY) {
623 emptynum++; 629 emptynum++;
@@ -633,6 +639,8 @@ static void GetMemory(int argc, char *argv[])
633 } 639 }
634 640
635 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum); 641 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum);
642
643 if (Info.Ringtone) free(Info.Ringtone);
636 644
637 GSM_Terminate(); 645 GSM_Terminate();
638} 646}
@@ -1623,17 +1631,20 @@ static void GetRingtone(int argc, char *argv[])
1623 1631
1624static void GetRingtonesList(int argc, char *argv[]) 1632static void GetRingtonesList(int argc, char *argv[])
1625{ 1633{
1626 GSM_AllRingtonesInfo Info; 1634 GSM_AllRingtonesInfo Info = {0, NULL};
1627 int i; 1635 int i;
1628 1636
1629 GSM_Init(true); 1637 GSM_Init(true);
1630 1638
1631 error=Phone->GetRingtonesInfo(&s,&Info); 1639 error=Phone->GetRingtonesInfo(&s,&Info);
1640 if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone);
1632 Print_Error(error); 1641 Print_Error(error);
1633 1642
1634 GSM_Terminate(); 1643 GSM_Terminate();
1635 1644
1636 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); 1645 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name));
1646
1647 if (Info.Ringtone) free(Info.Ringtone);
1637} 1648}
1638 1649
1639static void DialVoice(int argc, char *argv[]) 1650static void DialVoice(int argc, char *argv[])
@@ -2177,7 +2188,7 @@ static void GetBitmap(int argc, char *argv[])
2177 GSM_File File; 2188 GSM_File File;
2178 GSM_MultiBitmap MultiBitmap; 2189 GSM_MultiBitmap MultiBitmap;
2179 int location=0; 2190 int location=0;
2180 GSM_AllRingtonesInfo Info; 2191 GSM_AllRingtonesInfo Info = {0, NULL};
2181 2192
2182 if (mystrncasecmp(argv[2],"STARTUP",0)) { 2193 if (mystrncasecmp(argv[2],"STARTUP",0)) {
2183 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; 2194 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
@@ -2248,6 +2259,8 @@ static void GetBitmap(int argc, char *argv[])
2248 } else { 2259 } else {
2249 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID); 2260 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID);
2250 } 2261 }
2262
2263 if (Info.Ringtone) free(Info.Ringtone);
2251 } 2264 }
2252 if (MultiBitmap.Bitmap[0].BitmapEnabled) { 2265 if (MultiBitmap.Bitmap[0].BitmapEnabled) {
2253 printmsg("Bitmap : enabled\n"); 2266 printmsg("Bitmap : enabled\n");
@@ -4645,6 +4658,7 @@ static void Restore(int argc, char *argv[])
4645 GSM_MemoryStatusMemStatus; 4658 GSM_MemoryStatusMemStatus;
4646 GSM_ToDoEntry ToDo; 4659 GSM_ToDoEntry ToDo;
4647 GSM_ToDoStatus ToDoStatus; 4660 GSM_ToDoStatus ToDoStatus;
4661 GSM_NoteEntry Note;
4648 GSM_Profile Profile; 4662 GSM_Profile Profile;
4649 GSM_MultiWAPSettingsSettings; 4663 GSM_MultiWAPSettingsSettings;
4650 GSM_GPRSAccessPointGPRSPoint; 4664 GSM_GPRSAccessPointGPRSPoint;
@@ -4914,6 +4928,42 @@ static void Restore(int argc, char *argv[])
4914 printmsgerr("\n"); 4928 printmsgerr("\n");
4915 } 4929 }
4916 4930
4931 DoRestore = false;
4932 if (Backup.ToDo[0] != NULL) {
4933 error = Phone->GetNotesStatus(&s,&ToDoStatus);
4934 if (error == ERR_NONE) {
4935 max = 0;
4936 while (Backup.Note[max]!=NULL) max++;
4937 printmsgerr("%i entries in backup file\n",max);
4938
4939 if (answer_yes("Restore Notes")) DoRestore = true;
4940 }
4941 }
4942 if (DoRestore) {
4943 printmsgerr("Deleting old Notes: ");
4944 while (1) {
4945 error = Phone->GetNextNote(&s,&Note,true);
4946 if (error != ERR_NONE) break;
4947 error = Phone->DeleteNote(&s,&Note);
4948 Print_Error(error);
4949 printmsgerr("*");
4950 }
4951 printmsgerr("\n");
4952
4953 for (i=0;i<max;i++) {
4954 Note = *Backup.Note[i];
4955 Note.Location = 0;
4956 error=Phone->AddNote(&s,&Note);
4957 Print_Error(error);
4958 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4959 if (gshutdown) {
4960 GSM_Terminate();
4961 exit(0);
4962 }
4963 }
4964 printmsgerr("\n");
4965 }
4966
4917 if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { 4967 if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) {
4918 max = 0; 4968 max = 0;
4919 while (Backup.SMSC[max]!=NULL) max++; 4969 while (Backup.SMSC[max]!=NULL) max++;
@@ -5287,6 +5337,7 @@ static void ClearAll(int argc, char *argv[])
5287 GSM_ToDoStatus ToDoStatus; 5337 GSM_ToDoStatus ToDoStatus;
5288 GSM_CalendarEntryCalendar; 5338 GSM_CalendarEntryCalendar;
5289 GSM_ToDoEntry ToDo; 5339 GSM_ToDoEntry ToDo;
5340 GSM_NoteEntry Note;
5290 GSM_WAPBookmark Bookmark; 5341 GSM_WAPBookmark Bookmark;
5291 GSM_FMStation Station; 5342 GSM_FMStation Station;
5292 GSM_MemoryEntry Pbk; 5343 GSM_MemoryEntry Pbk;
@@ -5396,6 +5447,23 @@ static void ClearAll(int argc, char *argv[])
5396 } 5447 }
5397 } 5448 }
5398 5449
5450 DoClear = false;
5451 error = Phone->GetNotesStatus(&s,&ToDoStatus);
5452 if (error == ERR_NONE && ToDoStatus.Used != 0) {
5453 if (answer_yes("Delete Notes")) DoClear = true;
5454 }
5455 if (DoClear) {
5456 printmsgerr("Deleting: ");
5457 while (1) {
5458 error = Phone->GetNextNote(&s,&Note,true);
5459 if (error != ERR_NONE) break;
5460 error = Phone->DeleteNote(&s,&Note);
5461 Print_Error(error);
5462 printmsgerr("*");
5463 }
5464 printmsgerr("\n");
5465 }
5466
5399 Bookmark.Location = 1; 5467 Bookmark.Location = 1;
5400 error = Phone->GetWAPBookmark(&s,&Bookmark); 5468 error = Phone->GetWAPBookmark(&s,&Bookmark);
5401 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 5469 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
@@ -5642,18 +5710,11 @@ static void BackupSMS(int argc, char *argv[])
5642 GSM_MultiSMSMessage sms; 5710 GSM_MultiSMSMessage sms;
5643 GSM_SMSFolders folders; 5711 GSM_SMSFolders folders;
5644 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; 5712 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS];
5645 bool start = true; 5713 bool start = true;
5646 bool DeleteAfter; 5714 bool DeleteAfter;
5647 int j, smsnum; 5715 int j, smsnum = 0;
5648 char buffer[200]; 5716 char buffer[200];
5649 5717
5650 /* We ignore return code, because (when file doesn't exist) we
5651 * will create new later
5652 */
5653 GSM_ReadSMSBackupFile(argv[2], &Backup);
5654 smsnum = 0;
5655 while (Backup.SMS[smsnum]!=NULL) smsnum++;
5656
5657 GSM_Init(true); 5718 GSM_Init(true);
5658 5719
5659 error=Phone->GetSMSFolders(&s, &folders); 5720 error=Phone->GetSMSFolders(&s, &folders);
@@ -5664,6 +5725,7 @@ static void BackupSMS(int argc, char *argv[])
5664 for (j=0;j<folders.Number;j++) { 5725 for (j=0;j<folders.Number;j++) {
5665 BackupFromFolder[j] = false; 5726 BackupFromFolder[j] = false;
5666 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); 5727 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name));
5728 if (folders.Folder[j].Memory == MEM_SM) strcat(buffer," (SIM)");
5667 if (answer_yes(buffer)) BackupFromFolder[j] = true; 5729 if (answer_yes(buffer)) BackupFromFolder[j] = true;
5668 } 5730 }
5669 5731
@@ -5702,7 +5764,7 @@ static void BackupSMS(int argc, char *argv[])
5702 start=false; 5764 start=false;
5703 } 5765 }
5704 5766
5705 error = GSM_SaveSMSBackupFile(argv[2],&Backup); 5767 error = GSM_AddSMSBackupFile(argv[2],&Backup);
5706 Print_Error(error); 5768 Print_Error(error);
5707 5769
5708 if (DeleteAfter) { 5770 if (DeleteAfter) {
@@ -5754,23 +5816,33 @@ static void RestoreSMS(int argc, char *argv[])
5754 GSM_SMSFolders folders; 5816 GSM_SMSFolders folders;
5755 int smsnum = 0; 5817 int smsnum = 0;
5756 char buffer[200]; 5818 char buffer[200];
5819 bool restore8bit,doit;
5757 5820
5758 error=GSM_ReadSMSBackupFile(argv[2], &Backup); 5821 error=GSM_ReadSMSBackupFile(argv[2], &Backup);
5759 Print_Error(error); 5822 Print_Error(error);
5760 5823
5824 sprintf(buffer,"Do you want to restore binary SMS");
5825 restore8bit = answer_yes(buffer);
5826
5761 GSM_Init(true); 5827 GSM_Init(true);
5762 5828
5763 error=Phone->GetSMSFolders(&s, &folders); 5829 error=Phone->GetSMSFolders(&s, &folders);
5764 Print_Error(error); 5830 Print_Error(error);
5765 5831
5766 while (Backup.SMS[smsnum] != NULL) { 5832 while (Backup.SMS[smsnum] != NULL) {
5767 SMS.Number = 1; 5833 doit = true;
5768 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); 5834 if (!restore8bit && Backup.SMS[smsnum]->Coding == SMS_Coding_8bit) doit = false;
5769 displaymultismsinfo(SMS,false,false); 5835 if (doit) {
5770 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); 5836 SMS.Number = 1;
5771 if (answer_yes(buffer)) { 5837 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
5772 error=Phone->AddSMS(&s, Backup.SMS[smsnum]); 5838 displaymultismsinfo(SMS,false,false);
5773 Print_Error(error); 5839 sprintf(buffer,"Restore %03i sms to folder \"%s\"",smsnum+1,DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
5840 if (folders.Folder[Backup.SMS[smsnum]->Folder-1].Memory == MEM_SM) strcat(buffer," (SIM)");
5841 if (answer_yes(buffer)) {
5842 smprintf(&s,"saving %i SMS\n",smsnum);
5843 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5844 Print_Error(error);
5845 }
5774 } 5846 }
5775 smsnum++; 5847 smsnum++;
5776 } 5848 }
@@ -6360,7 +6432,7 @@ static void GetProfile(int argc, char *argv[])
6360 int start,stop,j,k; 6432 int start,stop,j,k;
6361 GSM_Bitmap caller[5]; 6433 GSM_Bitmap caller[5];
6362 bool callerinit[5],special; 6434 bool callerinit[5],special;
6363 GSM_AllRingtonesInfo Info; 6435 GSM_AllRingtonesInfo Info = {0, NULL};
6364 6436
6365 GetStartStop(&start, &stop, 2, argc, argv); 6437 GetStartStop(&start, &stop, 2, argc, argv);
6366 6438
@@ -6374,6 +6446,7 @@ static void GetProfile(int argc, char *argv[])
6374 for (i=start;i<=stop;i++) { 6446 for (i=start;i<=stop;i++) {
6375 Profile.Location=i; 6447 Profile.Location=i;
6376 error=Phone->GetProfile(&s,&Profile); 6448 error=Phone->GetProfile(&s,&Profile);
6449 if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone);
6377 Print_Error(error); 6450 Print_Error(error);
6378 6451
6379 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); 6452 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name));
@@ -6487,6 +6560,8 @@ static void GetProfile(int argc, char *argv[])
6487 } 6560 }
6488 6561
6489 GSM_Terminate(); 6562 GSM_Terminate();
6563
6564 if (Info.Ringtone) free(Info.Ringtone);
6490} 6565}
6491 6566
6492static void GetSpeedDial(int argc, char *argv[]) 6567static void GetSpeedDial(int argc, char *argv[])
@@ -7979,7 +8054,7 @@ static GSM_Parameters Parameters[] = {
7979 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, 8054 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
7980 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, 8055 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"},
7981 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, 8056 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"},
7982 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, 8057 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, "number"},
7983 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, 8058 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""},
7984 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, 8059 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""},
7985 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, 8060 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""},