14 # include <sys/utime.h>
22 #include "../common/gammu.h"
24 #include "smsd/smsdcore.h"
28 #ifdef GSM_ENABLE_NOKIA_DCT3
29 # include "depend/dct3.h"
30 # include "depend/dct3trac/wmx.h"
32 #ifdef GSM_ENABLE_NOKIA_DCT4
33 # include "depend/dct4.h"
35 #ifdef GSM_ENABLE_ATGEN
36 # include "depend/dsiemens.h"
43 #ifdef HAVE_SYS_IOCTL_H
44 # include <sys/ioctl.h>
49 GSM_Phone_Functions
*Phone
;
50 static INI_Section
*cfg
= NULL
;
52 GSM_Error error
= GE_NONE
;
55 volatile bool bshutdown
= false;
57 void interrupted(int sig
)
63 int printmsg(char *format
, ...)
68 va_start(argp
, format
);
69 result
= vfprintf(stdout
,GetMsg(s
.msg
,format
),argp
);
74 int printmsgerr(char *format
, ...)
79 va_start(argp
, format
);
80 result
= vfprintf(stderr
,GetMsg(s
.msg
,format
), argp
);
85 static void PrintSecurityStatus()
87 GSM_SecurityCodeType Status
;
89 error
=Phone
->GetSecurityStatus(&s
,&Status
);
92 case GSCT_SecurityCode
:
93 printmsg("Waiting for Security Code.\n");
96 printmsg("Waiting for PIN.\n");
99 printmsg("Waiting for PIN2.\n");
102 printmsg("Waiting for PUK.\n");
105 printmsg("Waiting for PUK2.\n");
108 printmsg("Nothing to enter.\n");
111 printmsg("Unknown\n");
115 void Print_Error(GSM_Error error
)
117 if (error
!= GE_NONE
) {
118 printf("%s\n",print_error(error
,s
.di
.df
,s
.msg
));
119 if (error
== GE_SECURITYERROR
) {
120 printmsg("Security status: ");
121 PrintSecurityStatus();
123 if (s
.opened
) GSM_TerminateConnection(&s
);
128 void GSM_Init(bool checkerror
)
130 error
=GSM_InitConnection(&s
,3);
131 if (checkerror
) Print_Error(error
);
133 Phone
=s
.Phone
.Functions
;
136 void GSM_Terminate(void)
138 error
=GSM_TerminateConnection(&s
);
142 static void GetStartStop(int *start
, int *stop
, int num
, int argc
, char *argv
[])
144 *start
=atoi(argv
[num
]);
146 printmsg("ERROR: enumerate locations from 1\n");
152 if (argc
>=num
+2) *stop
=atoi(argv
[num
+1]);
154 printmsg("ERROR: enumerate locations from 1\n");
160 static bool answer_yes(char *text
)
164 static bool always_answer_yes
= false;
165 static bool always_answer_no
= false;
168 printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text
);
169 if (always_answer_yes
) {
170 printmsgerr("YES (always)\n");
173 if (always_answer_no
) {
174 printmsgerr("NO (always)\n");
177 len
=GetLine(stdin
, ans
, 99);
178 if (len
==-1) exit(-1);
179 if (!strcmp(ans
, "NONE")) {
180 always_answer_no
= true;
183 if (!strcmp(ans
, "ONLY")) {
184 always_answer_no
= true;
187 if (!strcmp(ans
, "ALL")) {
188 always_answer_yes
= true;
191 if (mystrncasecmp(ans
, "yes",0)) return true;
192 if (mystrncasecmp(ans
, "no" ,0)) return false;
196 #ifdef GSM_ENABLE_BEEP
197 void GSM_PhoneBeep(void)
199 error
= PHONE_Beep(&s
);
200 if (error
!= GE_NOTSUPPORTED
&& error
!= GE_NOTIMPLEMENTED
) Print_Error(error
);
204 static GSM_Error
GSM_PlayRingtone(GSM_Ringtone ringtone
)
210 /* We do not want to make it forever -
211 * press Ctrl+C to stop the monitoring mode.
213 signal(SIGINT
, interrupted
);
214 printmsg("If you want break, press Ctrl+C...\n");
216 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
217 if (bshutdown
) break;
218 if (ringtone
.NoteTone
.Commands
[i
].Type
== RING_NOTETONE
) {
219 error
=PHONE_RTTLPlayOneNote(&s
,ringtone
.NoteTone
.Commands
[i
].Note
,first
);
220 if (error
!=GE_NONE
) return error
;
225 /* Disables buzzer */
226 return s
.Phone
.Functions
->PlayTone(&s
,255*255,0,false);
229 static void PlayRingtone(int argc
, char *argv
[])
231 GSM_Ringtone ringtone
,ringtone2
;
234 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
237 error
=GSM_RingtoneConvert(&ringtone2
,&ringtone
,RING_NOTETONE
);
242 error
=GSM_PlayRingtone(ringtone2
);
248 static void Identify(int argc
, char *argv
[])
250 unsigned char buffer
[100];
254 error
=Phone
->GetManufacturer(&s
);
256 printmsg("Manufacturer : %s\n", s
.Phone
.Data
.Manufacturer
);
257 error
=Phone
->GetModel(&s
);
259 printmsg("Model : %s (%s)\n",
260 s
.Phone
.Data
.ModelInfo
->model
,
263 error
=Phone
->GetFirmware(&s
);
265 printmsg("Firmware : %s",s
.Phone
.Data
.Version
);
266 error
=Phone
->GetPPM(&s
, buffer
);
267 if (error
!= GE_NOTSUPPORTED
) {
268 if (error
!= GE_NOTIMPLEMENTED
) Print_Error(error
);
269 if (error
== GE_NONE
) printmsg(" %s",buffer
);
271 if (s
.Phone
.Data
.VerDate
[0]!=0) printmsg(" (%s)",s
.Phone
.Data
.VerDate
);
274 error
=Phone
->GetHardware(&s
, buffer
);
275 if (error
!= GE_NOTSUPPORTED
) {
276 if (error
!= GE_NOTIMPLEMENTED
) Print_Error(error
);
277 if (error
== GE_NONE
) printmsg("Hardware : %s\n",buffer
);
280 error
=Phone
->GetIMEI(&s
);
281 if (error
!= GE_NOTSUPPORTED
) {
282 if (error
!= GE_NOTIMPLEMENTED
) Print_Error(error
);
283 if (error
== GE_NONE
) printmsg("IMEI : %s\n",s
.Phone
.Data
.IMEI
);
285 error
=Phone
->GetOriginalIMEI(&s
, buffer
);
286 if (error
!= GE_NOTSUPPORTED
&& error
!= GE_SECURITYERROR
) {
287 if (error
!= GE_NOTIMPLEMENTED
) Print_Error(error
);
288 if (error
== GE_NONE
) printmsg("Original IMEI : %s\n",buffer
);
292 error
=Phone
->GetManufactureMonth(&s
, buffer
);
293 if (error
!= GE_NOTSUPPORTED
&& error
!= GE_SECURITYERROR
) {
294 if (error
!= GE_NOTIMPLEMENTED
) Print_Error(error
);
295 if (error
== GE_NONE
) printmsg("Manufactured : %s\n",buffer
);
298 error
=Phone
->GetProductCode(&s
, buffer
);
299 if (error
!= GE_NOTSUPPORTED
) {
300 if (error
!= GE_NOTIMPLEMENTED
) Print_Error(error
);
301 if (error
== GE_NONE
) printmsg("Product code : %s\n",buffer
);
304 error
=Phone
->GetSIMIMSI(&s
, buffer
);
306 case GE_SECURITYERROR
:
307 case GE_NOTSUPPORTED
:
308 case GE_NOTIMPLEMENTED
:
311 printmsg("SIM IMSI : %s\n",buffer
);
317 #ifdef GSM_ENABLE_NOKIA_DCT3
318 DCT3Info(argc
, argv
);
320 #ifdef GSM_ENABLE_NOKIA_DCT4
321 DCT4Info(argc
, argv
);
327 static void GetDateTime(int argc
, char *argv
[])
329 GSM_DateTime date_time
;
334 error
=Phone
->GetDateTime(&s
, &date_time
);
337 printmsg("Date and time not set in phone\n");
340 printmsg("Phone time is %s\n",OSDateTime(date_time
,false));
346 error
=Phone
->GetLocale(&s
, &locale
);
348 case GE_NOTSUPPORTED
:
349 case GE_NOTIMPLEMENTED
:
353 printmsg("Time format is ");
354 if (locale
.AMPMTime
) printmsg("12 hours\n"); else printmsg("24 hours\n");
355 printmsg("Date format is ");
356 switch (locale
.DateFormat
) {
357 case GSM_Date_DDMMYYYY
:printmsg("DD MM YYYY");break;
358 case GSM_Date_MMDDYYYY
:printmsg("MM DD YYYY");break;
359 case GSM_Date_YYYYMMDD
:printmsg("YYYY MM DD");
361 printmsg(", date separator is %c\n",locale
.DateSeparator
);
367 static void SetDateTime(int argc
, char *argv
[])
369 GSM_DateTime date_time
;
371 GSM_GetCurrentDateTime(&date_time
);
375 error
=Phone
->SetDateTime(&s
, &date_time
);
381 static void GetAlarm(int argc
, char *argv
[])
388 error
=Phone
->GetAlarm(&s
, &alarm
);
391 printmsg("Alarm not set in phone\n");
394 if (alarm
.Repeating
) {
395 printmsg("Date: %s\n","Every day");
397 printmsg("Date: %s\n",OSDate(alarm
.DateTime
));
399 printmsg("Time: %02d:%02d\n",alarm
.DateTime
.Hour
, alarm
.DateTime
.Minute
);
400 if (alarm
.Text
[0] != 0 || alarm
.Text
[1] != 0) {
401 printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm
.Text
));
411 static void SetAlarm(int argc
, char *argv
[])
415 alarm
.DateTime
.Hour
= atoi(argv
[2]);
416 alarm
.DateTime
.Minute
= atoi(argv
[3]);
417 alarm
.DateTime
.Second
= 0;
419 alarm
.Repeating
= true;
425 error
=Phone
->SetAlarm(&s
, &alarm
);
431 GSM_Bitmap caller
[5];
432 GSM_AllRingtonesInfo Info
;
433 bool callerinit
[5] = {false, false, false, false, false};
434 bool ringinit
= false;
436 static void PrintMemoryEntry(GSM_MemoryEntry
*entry
)
438 GSM_Category Category
;
442 for (i
=0;i
<entry
->EntriesNum
;i
++) {
444 switch (entry
->Entries
[i
].EntryType
) {
446 printmsg("Date and time : %s\n",OSDateTime(entry
->Entries
[i
].Date
,false));
449 Category
.Location
= entry
->Entries
[i
].Number
;
450 Category
.Type
= Category_Phonebook
;
451 error
=Phone
->GetCategory(&s
, &Category
);
452 if (error
== GE_NONE
) {
453 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category
.Name
), entry
->Entries
[i
].Number
);
455 printmsg("Category : %i\n", entry
->Entries
[i
].Number
);
459 printmsg("Private : %s\n", entry
->Entries
[i
].Number
== 1 ? "Yes" : "No");
461 case PBK_Number_General
: printmsg("General number "); break;
462 case PBK_Number_Mobile
: printmsg("Mobile number "); break;
463 case PBK_Number_Work
: printmsg("Work number "); break;
464 case PBK_Number_Fax
: printmsg("Fax number "); break;
465 case PBK_Number_Home
: printmsg("Home number "); break;
466 case PBK_Number_Pager
: printmsg("Pager number "); break;
467 case PBK_Number_Other
: printmsg("Other number "); break;
468 case PBK_Text_Note
: printmsg("Text "); break;
469 case PBK_Text_Postal
: printmsg("Snail address "); break;
470 case PBK_Text_Email
: printmsg("Email address 1 "); break;
471 case PBK_Text_Email2
: printmsg("Email address 2 "); break;
472 case PBK_Text_URL
: printmsg("URL address "); break;
473 case PBK_Text_Name
: printmsg("Name "); break;
474 case PBK_Text_LastName
: printmsg("Last name "); break;
475 case PBK_Text_FirstName
: printmsg("First name "); break;
476 case PBK_Text_Company
: printmsg("Company "); break;
477 case PBK_Text_JobTitle
: printmsg("Job title "); break;
478 case PBK_Text_StreetAddress
: printmsg("Street address "); break;
479 case PBK_Text_City
: printmsg("City "); break;
480 case PBK_Text_State
: printmsg("State "); break;
481 case PBK_Text_Zip
: printmsg("Zip code "); break;
482 case PBK_Text_Country
: printmsg("Country "); break;
483 case PBK_Text_Custom1
: printmsg("Custom text 1 "); break;
484 case PBK_Text_Custom2
: printmsg("Custom text 2 "); break;
485 case PBK_Text_Custom3
: printmsg("Custom text 3 "); break;
486 case PBK_Text_Custom4
: printmsg("Custom text 4 "); break;
487 case PBK_Caller_Group
:
489 if (!callerinit
[entry
->Entries
[i
].Number
]) {
490 caller
[entry
->Entries
[i
].Number
].Type
= GSM_CallerLogo
;
491 caller
[entry
->Entries
[i
].Number
].Location
= entry
->Entries
[i
].Number
;
492 error
=Phone
->GetBitmap(&s
,&caller
[entry
->Entries
[i
].Number
]);
494 if (caller
[entry
->Entries
[i
].Number
].DefaultName
) {
495 NOKIA_GetDefaultCallerGroupName(&s
,&caller
[entry
->Entries
[i
].Number
]);
497 callerinit
[entry
->Entries
[i
].Number
]=true;
499 printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller
[entry
->Entries
[i
].Number
].Text
));
501 case PBK_RingtoneID
:
504 error
=Phone
->GetRingtonesInfo(&s
,&Info
);
505 if (error
!= GE_NOTSUPPORTED
) Print_Error(error
);
506 if (error
== GE_NONE
) ringinit
= true;
509 for (z
=0;z
<Info
.Number
;z
++) {
510 if (Info
.Ringtone
[z
].ID
== entry
->Entries
[i
].Number
) {
511 printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info
.Ringtone
[z
].Name
));
516 printmsg("Ringtone ID : %i\n",entry
->Entries
[i
].Number
);
521 printmsg("Picture ID : 0x%x\n",entry
->Entries
[i
].Number
);
524 printmsg("UNKNOWN\n");
528 if (!unknown
) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry
->Entries
[i
].Text
));
533 static void GetAllMemory(int argc
, char *argv
[])
535 GSM_MemoryEntry Entry
;
538 signal(SIGINT
, interrupted
);
539 printmsgerr("If you want break, press Ctrl+C...\n");
541 Entry
.MemoryType
= 0;
543 if (mystrncasecmp(argv
[2],"DC",0)) Entry
.MemoryType
=GMT_DC
;
544 if (mystrncasecmp(argv
[2],"ON",0)) Entry
.MemoryType
=GMT_ON
;
545 if (mystrncasecmp(argv
[2],"RC",0)) Entry
.MemoryType
=GMT_RC
;
546 if (mystrncasecmp(argv
[2],"MC",0)) Entry
.MemoryType
=GMT_MC
;
547 if (mystrncasecmp(argv
[2],"ME",0)) Entry
.MemoryType
=GMT_ME
;
548 if (mystrncasecmp(argv
[2],"SM",0)) Entry
.MemoryType
=GMT_SM
;
549 if (mystrncasecmp(argv
[2],"VM",0)) Entry
.MemoryType
=GMT_VM
;
550 if (mystrncasecmp(argv
[2],"FD",0)) Entry
.MemoryType
=GMT_FD
;
551 if (Entry
.MemoryType
==0) {
552 printmsg("ERROR: unknown memory type (\"%s\")\n",argv
[2]);
559 if (bshutdown
) break;
560 error
= Phone
->GetNextMemory(&s
, &Entry
, start
);
561 if (error
== GE_EMPTY
) break;
563 printmsg("Memory %s, Location %i\n",argv
[2],Entry
.Location
);
564 PrintMemoryEntry(&Entry
);
571 static void GetMemory(int argc
, char *argv
[])
574 GSM_MemoryEntry entry
;
578 if (mystrncasecmp(argv
[2],"DC",0)) entry
.MemoryType
=GMT_DC
;
579 if (mystrncasecmp(argv
[2],"ON",0)) entry
.MemoryType
=GMT_ON
;
580 if (mystrncasecmp(argv
[2],"RC",0)) entry
.MemoryType
=GMT_RC
;
581 if (mystrncasecmp(argv
[2],"MC",0)) entry
.MemoryType
=GMT_MC
;
582 if (mystrncasecmp(argv
[2],"ME",0)) entry
.MemoryType
=GMT_ME
;
583 if (mystrncasecmp(argv
[2],"SM",0)) entry
.MemoryType
=GMT_SM
;
584 if (mystrncasecmp(argv
[2],"VM",0)) entry
.MemoryType
=GMT_VM
;
585 if (mystrncasecmp(argv
[2],"FD",0)) entry
.MemoryType
=GMT_FD
;
586 if (entry
.MemoryType
==0) {
587 printmsg("ERROR: unknown memory type (\"%s\")\n",argv
[2]);
591 GetStartStop(&start
, &stop
, 3, argc
, argv
);
595 if (!strcmp(s
.Phone
.Data
.ModelInfo
->model
,"3310")) {
596 if (s
.Phone
.Data
.VerNum
<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n");
599 for (j
=start
;j
<=stop
;j
++) {
600 printmsg("Memory %s, Location %i\n",argv
[2],j
);
604 error
=Phone
->GetMemory(&s
, &entry
);
605 if (error
!= GE_EMPTY
) Print_Error(error
);
607 if (error
== GE_EMPTY
) {
608 printmsg("Entry is empty\n");
611 PrintMemoryEntry(&entry
);
618 #define MemoryLocationToString(x) ( \
619 x == GMT_ON ? "ON" : \
620 x == GMT_RC ? "RC" : \
621 x == GMT_MC ? "MC" : \
622 x == GMT_ME ? "ME" : \
623 x == GMT_SM ? "SM" : \
624 x == GMT_VM ? "VM" : \
625 x == GMT_FD ? "FD" : "XX")
627 static void SearchOneEntry(GSM_MemoryEntry
*Entry
, unsigned char *Text
)
631 for (i
=0;i
<Entry
->EntriesNum
;i
++) {
632 switch (Entry
->Entries
[i
].EntryType
) {
633 case PBK_Number_General
:
634 case PBK_Number_Mobile
:
635 case PBK_Number_Work
:
636 case PBK_Number_Fax
:
637 case PBK_Number_Home
:
638 case PBK_Number_Pager
:
639 case PBK_Number_Other
:
641 case PBK_Text_Postal
:
642 case PBK_Text_Email
:
643 case PBK_Text_Email2
:
646 case PBK_Text_LastName
:
647 case PBK_Text_FirstName
:
648 case PBK_Text_Company
:
649 case PBK_Text_JobTitle
:
650 case PBK_Text_StreetAddress
:
652 case PBK_Text_State
:
654 case PBK_Text_Country
:
655 case PBK_Text_Custom1
:
656 case PBK_Text_Custom2
:
657 case PBK_Text_Custom3
:
658 case PBK_Text_Custom4
:
659 case PBK_Caller_Group
:
660 if (mystrstr(Entry
->Entries
[i
].Text
, Text
) != NULL
) {
661 fprintf(stderr
,"\n");
662 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry
->MemoryType
),Entry
->Location
);
663 PrintMemoryEntry(Entry
);
673 static void SearchOneMemory(GSM_MemoryType MemoryType
, char *Title
, unsigned char *Text
)
675 GSM_MemoryEntry Entry
;
676 GSM_MemoryStatus Status
;
680 Status
.MemoryType
= MemoryType
;
681 Entry
.MemoryType
= MemoryType
;
683 if (Phone
->GetMemoryStatus(&s
, &Status
) == GE_NONE
) {
684 fprintf(stderr
,"%c%s: %i%%", 13, Title
, (i
+1)*100/(Status
.Used
+1));
685 if (Phone
->GetNextMemory
!= NOTSUPPORTED
&& Phone
->GetNextMemory
!= NOTIMPLEMENTED
) {
686 while (i
< Status
.Used
) {
687 if (bshutdown
) return;
689 fprintf(stderr
,"\r%s: %i%%", Title
, (i
+1)*100/(Status
.Used
+1));
690 error
= Phone
->GetNextMemory(&s
, &Entry
, start
);
691 if (error
== GE_EMPTY
) break;
693 SearchOneEntry(&Entry
, Text
);
697 while (i
< Status
.Used
) {
699 error
= Phone
->GetMemory(&s
, &Entry
);
700 if (error
!= GE_EMPTY
) {
703 SearchOneEntry(&Entry
, Text
);
705 fprintf(stderr
,"%c%s: %i%%", 13, Title
, (i
+1)*100/(Status
.Used
+1));
709 fprintf(stderr
,"\n");
713 static void SearchMemory(int argc
, char *argv
[])
715 unsigned char Text
[(GSM_PHONEBOOK_TEXT_LENGTH
+1)*2];
718 signal(SIGINT
, interrupted
);
719 printmsgerr("If you want break, press Ctrl+C...\n");
721 Length
= strlen(argv
[2]);
722 if (Length
> GSM_PHONEBOOK_TEXT_LENGTH
) {
723 printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH
);
724 Length
= GSM_PHONEBOOK_TEXT_LENGTH
;
726 EncodeUnicode(Text
, argv
[2], Length
);
730 if (!bshutdown
) SearchOneMemory(GMT_ME
, "Phone phonebook", Text
);
731 if (!bshutdown
) SearchOneMemory(GMT_SM
, "SIM phonebook", Text
);
732 if (!bshutdown
) SearchOneMemory(GMT_ON
, "Own numbers", Text
);
733 if (!bshutdown
) SearchOneMemory(GMT_DC
, "Dialled numbers", Text
);
734 if (!bshutdown
) SearchOneMemory(GMT_RC
, "Received numbers", Text
);
735 if (!bshutdown
) SearchOneMemory(GMT_MC
, "Missed numbers", Text
);
736 if (!bshutdown
) SearchOneMemory(GMT_FD
, "Fix dialling", Text
);
737 if (!bshutdown
) SearchOneMemory(GMT_VM
, "Voice mailbox", Text
);
742 static void ListMemoryCategoryEntries(int Category
)
744 GSM_MemoryEntry Entry
;
748 /* Category can be only for ME stored entries */
749 Entry
.MemoryType
= GMT_ME
;
752 if (bshutdown
) break;
753 error
= Phone
->GetNextMemory(&s
, &Entry
, start
);
754 if (error
== GE_EMPTY
) break;
756 for (j
=0;j
<Entry
.EntriesNum
;j
++) {
757 if (Entry
.Entries
[j
].EntryType
== PBK_Category
&& Entry
.Entries
[j
].Number
== Category
) {
758 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry
.MemoryType
),Entry
.Location
);
759 PrintMemoryEntry(&Entry
);
766 static void ListMemoryCategory(int argc
, char *argv
[])
768 GSM_Category Category
;
769 GSM_CategoryStatus Status
;
772 unsigned char Text
[(GSM_MAX_CATEGORY_NAME_LENGTH
+1)*2];
778 signal(SIGINT
, interrupted
);
779 printmsgerr("If you want break, press Ctrl+C...\n");
781 Length
= strlen(argv
[2]);
782 for (j
= 0; j
< Length
; j
++) {
783 if (!isdigit(argv
[2][j
])) {
792 ListMemoryCategoryEntries(j
);
795 if (Length
> GSM_MAX_CATEGORY_NAME_LENGTH
) {
796 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH
);
797 Length
= GSM_MAX_CATEGORY_NAME_LENGTH
;
799 EncodeUnicode(Text
, argv
[2], Length
);
801 Category
.Type
= Category_Phonebook
;
802 Status
.Type
= Category_Phonebook
;
804 if (Phone
->GetCategoryStatus(&s
, &Status
) == GE_NONE
) {
805 for (count
=0,j
=1;count
<Status
.Used
;j
++) {
807 error
=Phone
->GetCategory(&s
, &Category
);
809 if (error
!= GE_EMPTY
) {
811 if (mystrstr(Category
.Name
, Text
) != NULL
) {
812 ListMemoryCategoryEntries(j
);
821 static void displaysinglesmsinfo(GSM_SMSMessage sms
, bool displaytext
, bool displayudh
)
824 case SMS_Status_Report
:
825 printmsg("SMS status report\n");
826 printmsg("Status : ");
828 case GSM_Sent
: printmsg("Sent"); break;
829 case GSM_Read
: printmsg("Read"); break;
830 case GSM_UnRead
: printmsg("UnRead"); break;
831 case GSM_UnSent
: printmsg("UnSent"); break;
833 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms
.Number
));
834 printmsg("Sent : %s\n",OSDateTime(sms
.DateTime
,true));
835 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms
.SMSC
.Number
));
836 printmsg("SMSC response : %s\n",OSDateTime(sms
.SMSCTime
,true));
837 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms
.Text
));
838 printmsg("Details : ");
839 if (sms
.DeliveryStatus
& 0x40) {
840 if (sms
.DeliveryStatus
& 0x20) {
841 printmsg("Temporary error, ");
843 printmsg("Permanent error, ");
845 } else if (sms
.DeliveryStatus
& 0x20) {
846 printmsg("Temporary error, ");
848 switch (sms
.DeliveryStatus
) {
849 case 0x00: printmsg("SM received by the SME"); break;
850 case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break;
851 case 0x02: printmsg("SM replaced by the SC"); break;
852 case 0x20: printmsg("Congestion"); break;
853 case 0x21: printmsg("SME busy"); break;
854 case 0x22: printmsg("No response from SME"); break;
855 case 0x23: printmsg("Service rejected"); break;
856 case 0x24: printmsg("Quality of service not aviable"); break;
857 case 0x25: printmsg("Error in SME"); break;
858 case 0x40: printmsg("Remote procedure error"); break;
859 case 0x41: printmsg("Incompatibile destination"); break;
860 case 0x42: printmsg("Connection rejected by SME"); break;
861 case 0x43: printmsg("Not obtainable"); break;
862 case 0x44: printmsg("Quality of service not available"); break;
863 case 0x45: printmsg("No internetworking available"); break;
864 case 0x46: printmsg("SM Validity Period Expired"); break;
865 case 0x47: printmsg("SM deleted by originating SME"); break;
866 case 0x48: printmsg("SM Deleted by SC Administration"); break;
867 case 0x49: printmsg("SM does not exist"); break;
868 case 0x60: printmsg("Congestion"); break;
869 case 0x61: printmsg("SME busy"); break;
870 case 0x62: printmsg("No response from SME"); break;
871 case 0x63: printmsg("Service rejected"); break;
872 case 0x64: printmsg("Quality of service not available"); break;
873 case 0x65: printmsg("Error in SME"); break;
874 default : printmsg("Reserved/Specific to SC: %x",sms
.DeliveryStatus
); break;
879 printmsg("SMS message\n");
880 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms
.SMSC
.Number
));
881 if (sms
.ReplyViaSameSMSC
) printmsg(" (set for reply)");
882 printmsg("\nSent : %s\n",OSDateTime(sms
.DateTime
,true));
883 /* No break. The only difference for SMS_Deliver and SMS_Submit is,
884 * that SMS_Deliver contains additional data. We wrote them and then go
885 * for data shared with SMS_Submit
888 if (sms
.ReplaceMessage
!= 0) printmsg("SMS replacing ID : %i\n",sms
.ReplaceMessage
);
889 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */
890 if (sms
.PDU
==SMS_Submit
) printmsg("SMS message\n");
891 if (sms
.Name
[0] != 0x00 || sms
.Name
[1] != 0x00) {
892 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms
.Name
));
894 if (sms
.Class
!= -1) {
895 printmsg("Class : %i\n",sms
.Class
);
897 printmsg("Coding : ");
898 switch (sms
.Coding
) {
899 case GSM_Coding_Unicode
: printmsg("Unicode\n"); break;
900 case GSM_Coding_Default
: printmsg("Default GSM alphabet\n"); break;
901 case GSM_Coding_8bit
: printmsg("8 bit\n"); break;
903 printmsg("Status : ");
905 case GSM_Sent
: printmsg("Sent"); break;
906 case GSM_Read
: printmsg("Read"); break;
907 case GSM_UnRead
: printmsg("UnRead"); break;
908 case GSM_UnSent
: printmsg("UnSent"); break;
910 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms
.Number
));
911 if (sms
.UDH
.Type
!= UDH_NoUDH
) {
912 printmsg("User Data Header : ");
913 switch (sms
.UDH
.Type
) {
914 case UDH_ConcatenatedMessages
: printmsg("Concatenated (linked) message"); break;
915 case UDH_ConcatenatedMessages16bit
: printmsg("Concatenated (linked) message"); break;
916 case UDH_DisableVoice
: printmsg("Disables voice indicator"); break;
917 case UDH_EnableVoice
: printmsg("Enables voice indicator"); break;
918 case UDH_DisableFax
: printmsg("Disables fax indicator"); break;
919 case UDH_EnableFax
: printmsg("Enables fax indicator"); break;
920 case UDH_DisableEmail
: printmsg("Disables email indicator"); break;
921 case UDH_EnableEmail
: printmsg("Enables email indicator"); break;
922 case UDH_VoidSMS
: printmsg("Void SMS"); break;
923 case UDH_NokiaWAP
: printmsg("Nokia WAP bookmark"); break;
924 case UDH_NokiaOperatorLogoLong
: printmsg("Nokia operator logo"); break;
925 case UDH_NokiaWAPLong
: printmsg("Nokia WAP bookmark or WAP/MMS settings"); break;
926 case UDH_NokiaRingtone
: printmsg("Nokia ringtone"); break;
927 case UDH_NokiaRingtoneLong
: printmsg("Nokia ringtone"); break;
928 case UDH_NokiaOperatorLogo
: printmsg("Nokia GSM operator logo"); break;
929 case UDH_NokiaCallerLogo
: printmsg("Nokia caller logo"); break;
930 case UDH_NokiaProfileLong
: printmsg("Nokia profile"); break;
931 case UDH_NokiaCalendarLong
: printmsg("Nokia calendar note"); break;
932 case UDH_NokiaPhonebookLong
: printmsg("Nokia phonebook entry"); break;
933 case UDH_UserUDH
: printmsg("User UDH"); break;
934 case UDH_MMSIndicatorLong
: printmsg("MMS indicator"); break;
935 case UDH_NoUDH
: break;
937 if (sms
.UDH
.Type
!= UDH_NoUDH
) {
938 if (sms
.UDH
.ID8bit
!= -1) printmsg(", ID (8 bit) %i",sms
.UDH
.ID8bit
);
939 if (sms
.UDH
.ID16bit
!= -1) printmsg(", ID (16 bit) %i",sms
.UDH
.ID16bit
);
940 if (sms
.UDH
.PartNumber
!= -1 && sms
.UDH
.AllParts
!= -1) {
942 printmsg(", part %i of %i",sms
.UDH
.PartNumber
,sms
.UDH
.AllParts
);
944 printmsg(", %i parts",sms
.UDH
.AllParts
);
952 if (sms
.Coding
!=GSM_Coding_8bit
) {
953 printmsg("%s\n",DecodeUnicodeConsole(sms
.Text
));
955 printmsg("8 bit SMS, cannot be displayed here\n");
963 GSM_MultiBitmap Bitmap
;
964 GSM_Ringtone Ringtone
;
968 static void displaymultismsinfo (GSM_MultiSMSMessage sms
, bool eachsms
, bool ems
)
970 GSM_EncodeMultiPartSMSInfo SMSInfo
;
971 SMSValues Values
[MAX_MULTI_SMS
];
972 bool RetVal
,udhinfo
=true;
975 for (i
=0;i
<MAX_MULTI_SMS
;i
++) {
976 SMSInfo
.Entries
[i
].Bitmap
= &Values
[i
].Bitmap
;
977 SMSInfo
.Entries
[i
].Ringtone
= &Values
[i
].Ringtone
;
978 SMSInfo
.Entries
[i
].Buffer
= Values
[i
].Buffer
;
980 SMSInfo
.Unknown
= false;
982 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */
983 RetVal
= GSM_DecodeMultiPartSMS(&SMSInfo
,&sms
,ems
);
986 if (sms
.SMS
[0].UDH
.Type
!= UDH_NoUDH
&& sms
.SMS
[0].UDH
.AllParts
== sms
.Number
) udhinfo
= false;
987 if (RetVal
&& !udhinfo
) {
988 displaysinglesmsinfo(sms
.SMS
[0],false,false);
991 for (j
=0;j
<sms
.Number
;j
++) {
992 displaysinglesmsinfo(sms
.SMS
[j
],!RetVal
,udhinfo
);
997 for (j
=0;j
<sms
.Number
;j
++) {
998 displaysinglesmsinfo(sms
.SMS
[j
],!RetVal
,true);
1002 if (!RetVal
) return;
1004 if (SMSInfo
.Unknown
) printmsg("Some details were ignored (unknown or not implemented in decoding functions)\n\n");
1006 for (i
=0;i
<SMSInfo
.EntriesNum
;i
++) {
1007 switch (SMSInfo
.Entries
[i
].ID
) {
1008 case SMS_NokiaRingtone
:
1009 printmsg("Ringtone \"%s\"\n",DecodeUnicodeConsole(SMSInfo
.Entries
[i
].Ringtone
->Name
));
1010 saverttl(stdout
,SMSInfo
.Entries
[i
].Ringtone
);
1012 if (s
.Phone
.Functions
->PlayTone
!=NOTSUPPORTED
&&
1013 s
.Phone
.Functions
->PlayTone
!=NOTIMPLEMENTED
) {
1014 if (answer_yes("Do you want to play it")) GSM_PlayRingtone(*SMSInfo
.Entries
[i
].Ringtone
);
1017 case SMS_NokiaCallerLogo
:
1018 printmsg("Caller logo\n\n");
1019 GSM_PrintBitmap(stdout
,&SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0]);
1021 case SMS_NokiaOperatorLogo
:
1022 printmsg("Operator logo for %s network (%s, %s)\n\n",
1023 SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0].NetworkCode
,
1024 DecodeUnicodeConsole(GSM_GetNetworkName(SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0].NetworkCode
)),
1025 DecodeUnicodeConsole(GSM_GetCountryName(SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0].NetworkCode
)));
1026 GSM_PrintBitmap(stdout
,&SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0]);
1028 case SMS_NokiaScreenSaverLong
:
1029 printmsg("Screen saver\n");
1030 GSM_PrintBitmap(stdout
,&SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0]);
1032 case SMS_NokiaPictureImageLong
:
1033 printmsg("Picture Image\n");
1034 if (UnicodeLength(SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0].Text
)!=0) printmsg("Text: \"%s\"\n\n",DecodeUnicodeConsole(SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0].Text
));
1035 GSM_PrintBitmap(stdout
,&SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0]);
1037 case SMS_NokiaProfileLong
:
1038 printmsg("Profile\n");
1039 GSM_PrintBitmap(stdout
,&SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0]);
1041 case SMS_ConcatenatedTextLong
:
1042 case SMS_ConcatenatedAutoTextLong
:
1043 case SMS_ConcatenatedTextLong16bit
:
1044 case SMS_ConcatenatedAutoTextLong16bit
:
1045 printmsg("%s\n",DecodeUnicodeConsole(SMSInfo
.Entries
[i
].Buffer
));
1047 case SMS_EMSFixedBitmap
:
1048 case SMS_EMSVariableBitmap
:
1049 GSM_PrintBitmap(stdout
,&SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0]);
1051 case SMS_EMSAnimation
:
1052 /* Can't show animation, we show first frame */
1053 GSM_PrintBitmap(stdout
,&SMSInfo
.Entries
[i
].Bitmap
->Bitmap
[0]);
1055 case SMS_EMSPredefinedSound
:
1056 printmsg("\nEMS sound ID: %i\n",SMSInfo
.Entries
[i
].Number
);
1058 case SMS_EMSPredefinedAnimation
:
1059 printmsg("\nEMS animation ID: %i\n",SMSInfo
.Entries
[i
].Number
);
1069 static void IncomingSMS(char *Device
, GSM_SMSMessage sms
)
1071 GSM_MultiSMSMessage SMS
;
1073 printmsg("SMS message received\n");
1075 memcpy(&SMS
.SMS
[0],&sms
,sizeof(GSM_SMSMessage
));
1076 displaymultismsinfo(SMS
,false,false);
1079 static void IncomingCB(char *Device
, GSM_CBMessage CB
)
1081 printmsg("CB message received\n");
1082 printmsg("Channel %i, text \"%s\"\n",CB
.Channel
,DecodeUnicodeConsole(CB
.Text
));
1085 static void IncomingCall(char *Device
, GSM_Call call
)
1087 printmsg("Call info : ");
1088 if (call
.CallIDAvailable
) printmsg("ID %i, ",call
.CallID
);
1089 switch(call
.Status
) {
1090 case GN_CALL_IncomingCall
: printmsg("incoming call from \"%s\"\n",DecodeUnicodeConsole(call
.PhoneNumber
)); break;
1091 case GN_CALL_OutgoingCall
: printmsg("outgoing call to \"%s\"\n",DecodeUnicodeConsole(call
.PhoneNumber
)); break;
1092 case GN_CALL_CallStart
: printmsg("call started\n"); break;
1093 case GN_CALL_CallEnd
: printmsg("end of call (unknown side)\n"); break;
1094 case GN_CALL_CallLocalEnd
: printmsg("call end from our side\n"); break;
1095 case GN_CALL_CallRemoteEnd
: printmsg("call end from remote side (code %i)\n",call
.StatusCode
); break;
1096 case GN_CALL_CallEstablished
: printmsg("call established. Waiting for answer\n"); break;
1097 case GN_CALL_CallHeld
: printmsg("call held\n"); break;
1098 case GN_CALL_CallResumed
: printmsg("call resumed\n"); break;
1099 case GN_CALL_CallSwitched
: printmsg("call switched\n"); break;
1103 static void IncomingUSSD(char *Device
, char *Buffer
)
1105 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer
));
1108 #define CHECKMEMORYSTATUS(x, m, a1, b1) { \
1110 if (Phone->GetMemoryStatus(&s, &x) == GE_NONE) \
1111 printmsg("%s %03d, %s %03d\n", a1, x.Used, b1, x.Free); \
1114 static void Monitor(int argc
, char *argv
[])
1116 GSM_MemoryStatus MemStatus
;
1117 GSM_SMSMemoryStatus SMSStatus
;
1118 GSM_ToDoStatus ToDoStatus
;
1119 GSM_CalendarStatus CalendarStatus
;
1120 GSM_NetworkInfo NetInfo
;
1121 GSM_BatteryCharge BatteryCharge
;
1122 GSM_SignalQuality SignalQuality
;
1126 count
= atoi(argv
[2]);
1127 if (count
<= 0) count
= -1;
1130 /* We do not want to monitor serial line forever -
1131 * press Ctrl+C to stop the monitoring mode.
1133 signal(SIGINT
, interrupted
);
1134 printmsgerr("If you want break, press Ctrl+C...\n");
1135 printmsg("Entering monitor mode...\n\n");
1139 s
.User
.IncomingSMS
= IncomingSMS
;
1140 s
.User
.IncomingCB
= IncomingCB
;
1141 s
.User
.IncomingCall
= IncomingCall
;
1142 s
.User
.IncomingUSSD
= IncomingUSSD
;
1144 error
=Phone
->SetIncomingSMS (&s
,true);
1145 printmsg("Enabling info about incoming SMS : %s\n",print_error(error
,NULL
,s
.msg
));
1146 error
=Phone
->SetIncomingCB (&s
,true);
1147 printmsg("Enabling info about incoming CB : %s\n",print_error(error
,NULL
,s
.msg
));
1148 error
=Phone
->SetIncomingCall (&s
,true);
1149 printmsg("Enabling info about calls : %s\n",print_error(error
,NULL
,s
.msg
));
1150 error
=Phone
->SetIncomingUSSD (&s
,true);
1151 printmsg("Enabling info about USSD : %s\n\n",print_error(error
,NULL
,s
.msg
));
1153 /* Loop here indefinitely -
1154 * allows you to see messages from GSM code in
1155 * response to unknown messages etc.
1156 * The loops ends after pressing the Ctrl+C.
1158 while (!bshutdown
&& count
!= 0) {
1159 if (count
> 0) count
--;
1160 CHECKMEMORYSTATUS(MemStatus
,GMT_SM
,"SIM phonebook : Used","Free");
1161 CHECKMEMORYSTATUS(MemStatus
,GMT_DC
,"Dialled numbers : Used","Free");
1162 CHECKMEMORYSTATUS(MemStatus
,GMT_RC
,"Received numbers : Used","Free");
1163 CHECKMEMORYSTATUS(MemStatus
,GMT_MC
,"Missed numbers : Used","Free");
1164 CHECKMEMORYSTATUS(MemStatus
,GMT_ON
,"Own numbers : Used","Free");
1165 CHECKMEMORYSTATUS(MemStatus
,GMT_ME
,"Phone phonebook : Used","Free");
1166 if (Phone
->GetToDoStatus(&s
, &ToDoStatus
) == GE_NONE
) {
1167 printmsg("ToDos : Used %d\n", ToDoStatus
.Used
);
1169 if (Phone
->GetCalendarStatus(&s
, &CalendarStatus
) == GE_NONE
) {
1170 printmsg("Calendar : Used %d\n", CalendarStatus
.Used
);
1172 if (Phone
->GetBatteryCharge(&s
,&BatteryCharge
)==GE_NONE
) {
1173 if (BatteryCharge
.BatteryPercent
!= -1) printmsg("Battery level : %i percent\n", BatteryCharge
.BatteryPercent
);
1174 if (BatteryCharge
.ChargeState
!= 0) {
1175 printmsg("Charge state : ");
1176 switch (BatteryCharge
.ChargeState
) {
1177 case GSM_BatteryPowered
:
1178 printmsg("powered from battery");
1180 case GSM_BatteryConnected
:
1181 printmsg("battery connected, but not powered from battery");
1183 case GSM_BatteryNotConnected
:
1184 printmsg("battery not connected");
1186 case GSM_PowerFault
:
1187 printmsg("detected power failure");
1190 printmsg("unknown");
1196 if (Phone
->GetSignalQuality(&s
,&SignalQuality
)==GE_NONE
) {
1197 if (SignalQuality
.SignalStrength
!= -1) printmsg("Signal strength : %i dBm\n", SignalQuality
.SignalStrength
);
1198 if (SignalQuality
.SignalPercent
!= -1) printmsg("Network level : %i percent\n", SignalQuality
.SignalPercent
);
1199 if (SignalQuality
.BitErrorRate
!= -1) printmsg("Bit error rate : %i percent\n", SignalQuality
.BitErrorRate
);
1201 if (Phone
->GetSMSStatus(&s
,&SMSStatus
)==GE_NONE
) {
1202 if (SMSStatus
.SIMSize
> 0) {
1203 printmsg("SIM SMS status : %i used, %i unread, %i locations\n",
1205 SMSStatus
.SIMUnRead
,
1209 if (SMSStatus
.PhoneSize
> 0) {
1210 printmsg("Phone SMS status : %i used, %i unread, %i locations",
1211 SMSStatus
.PhoneUsed
,
1212 SMSStatus
.PhoneUnRead
,
1213 SMSStatus
.PhoneSize
);
1214 if (SMSStatus
.TemplatesUsed
!=0) printmsg(", %i templates", SMSStatus
.TemplatesUsed
);
1218 if (Phone
->GetNetworkInfo(&s
,&NetInfo
)==GE_NONE
) {
1219 printmsg("Network state : ");
1220 switch (NetInfo
.State
) {
1221 case GSM_HomeNetwork
: printmsg("home network\n"); break;
1222 case GSM_RoamingNetwork
: printmsg("roaming network\n"); break;
1223 case GSM_RequestingNetwork
: printmsg("requesting network\n"); break;
1224 case GSM_NoNetwork
: printmsg("not logged into network\n"); break;
1225 case GSM_RegistrationDenied
: printmsg("registration to network denied\n"); break;
1226 case GSM_NetworkStatusUnknown
: printmsg("unknown\n"); break;
1227 default : printmsg("unknown\n");
1229 if (NetInfo
.State
== GSM_HomeNetwork
|| NetInfo
.State
== GSM_RoamingNetwork
) {
1230 printmsg("Network : %s (%s", NetInfo
.NetworkCode
,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo
.NetworkCode
)));
1231 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo
.NetworkCode
)));
1232 printmsg(", LAC %s, CellID %s\n", NetInfo
.LAC
,NetInfo
.CellID
);
1233 if (NetInfo
.NetworkName
[0] != 0x00 || NetInfo
.NetworkName
[1] != 0x00) {
1234 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo
.NetworkName
));
1241 printmsg("Leaving monitor mode...\n");
1246 static void GetSMSC(int argc
, char *argv
[])
1251 GetStartStop(&start
, &stop
, 2, argc
, argv
);
1255 for (i
=start
;i
<=stop
;i
++) {
1258 error
=Phone
->GetSMSC(&s
, &smsc
);
1261 if (!strcmp(DecodeUnicodeConsole(smsc
.Name
),"")) {
1262 printmsg("%i. Set %i\n",smsc
.Location
, smsc
.Location
);
1264 printmsg("%i. \"%s\"\n",smsc
.Location
, DecodeUnicodeConsole(smsc
.Name
));
1266 printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc
.Number
));
1267 printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc
.DefaultNumber
));
1269 printmsg("Format : ");
1270 switch (smsc
.Format
) {
1271 case GSMF_Text
: printmsg("Text"); break;
1272 case GSMF_Fax
: printmsg("Fax"); break;
1273 case GSMF_Email
: printmsg("Email"); break;
1274 case GSMF_Pager
: printmsg("Pager"); break;
1278 printmsg("Validity : ");
1279 switch (smsc
.Validity
.Relative
) {
1280 case GSMV_1_Hour
: printmsg("1 hour"); break;
1281 case GSMV_6_Hours
: printmsg("6 hours"); break;
1282 case GSMV_24_Hours
: printmsg("24 hours"); break;
1283 case GSMV_72_Hours
: printmsg("72 hours"); break;
1284 case GSMV_1_Week
: printmsg("1 week"); break;
1285 case GSMV_Max_Time
: printmsg("Maximum time"); break;
1286 default : printmsg("Unknown");
1294 static void GetSMS(int argc
, char *argv
[])
1296 GSM_MultiSMSMessage sms
;
1297 GSM_SMSFolders folders
;
1300 GetStartStop(&start
, &stop
, 3, argc
, argv
);
1304 error
=Phone
->GetSMSFolders(&s
, &folders
);
1307 for (i
=start
;i
<=stop
;i
++) {
1308 sms
.SMS
[0].Folder
= atoi(argv
[2]);
1309 sms
.SMS
[0].Location
= i
;
1310 error
=Phone
->GetSMS(&s
, &sms
);
1313 printmsg("Location %i\n",sms
.SMS
[0].Location
);
1314 printmsg("Empty\n");
1318 printmsg("Location %i, folder \"%s\"",sms
.SMS
[0].Location
,DecodeUnicodeConsole(folders
.Folder
[sms
.SMS
[0].Folder
-1].Name
));
1319 switch(sms
.SMS
[0].Memory
) {
1320 case GMT_SM
: printmsg(", SIM memory"); break;
1321 case GMT_ME
: printmsg(", phone memory"); break;
1322 case GMT_MT
: printmsg(", phone or SIM memory"); break;
1325 if (sms
.SMS
[0].InboxFolder
) printmsg(", Inbox folder");
1327 displaymultismsinfo(sms
,false,false);
1334 static void DeleteSMS(int argc
, char *argv
[])
1339 sms
.Folder
=atoi(argv
[2]);
1341 GetStartStop(&start
, &stop
, 3, argc
, argv
);
1345 for (i
=start
;i
<=stop
;i
++) {
1348 error
=Phone
->DeleteSMS(&s
, &sms
);
1351 #ifdef GSM_ENABLE_BEEP
1357 static void GetAllSMS(int argc
, char *argv
[])
1359 GSM_MultiSMSMessage sms
;
1360 GSM_SMSFolders folders
;
1365 error
=Phone
->GetSMSFolders(&s
, &folders
);
1368 fprintf(stderr
,"Reading: ");
1369 while (error
== GE_NONE
) {
1370 sms
.SMS
[0].Folder
=0x00;
1371 error
=Phone
->GetNextSMS(&s
, &sms
, start
);
1377 printmsg("Location %i, folder \"%s\"",sms
.SMS
[0].Location
,DecodeUnicodeConsole(folders
.Folder
[sms
.SMS
[0].Folder
-1].Name
));
1378 switch(sms
.SMS
[0].Memory
) {
1379 case GMT_SM
: printmsg(", SIM memory"); break;
1380 case GMT_ME
: printmsg(", phone memory"); break;
1381 case GMT_MT
: printmsg(", phone or SIM memory"); break;
1384 if (sms
.SMS
[0].InboxFolder
) printmsg(", Inbox folder");
1386 displaymultismsinfo(sms
,false,false);
1388 fprintf(stderr
,"*");
1391 fprintf(stderr
,"\n");
1393 #ifdef GSM_ENABLE_BEEP
1399 static void GetEachSMS(int argc
, char *argv
[])
1401 GSM_MultiSMSMessage
*GetSMS
[PHONE_MAXSMSINFOLDER
],*SortedSMS
[PHONE_MAXSMSINFOLDER
],sms
;
1402 int GetSMSNumber
= 0,i
,j
;
1403 GSM_SMSFolders folders
;
1404 bool start
= true, ems
= true;
1410 error
=Phone
->GetSMSFolders(&s
, &folders
);
1413 fprintf(stderr
,"Reading: ");
1414 while (error
== GE_NONE
) {
1415 sms
.SMS
[0].Folder
=0x00;
1416 error
=Phone
->GetNextSMS(&s
, &sms
, start
);
1422 GetSMS
[GetSMSNumber
] = malloc(sizeof(GSM_MultiSMSMessage
));
1423 if (GetSMS
[GetSMSNumber
] == NULL
) Print_Error(GE_MOREMEMORY
);
1424 GetSMS
[GetSMSNumber
+1] = NULL
;
1425 memcpy(GetSMS
[GetSMSNumber
],&sms
,sizeof(GSM_MultiSMSMessage
));
1427 if (GetSMSNumber
==PHONE_MAXSMSINFOLDER
) {
1428 fprintf(stderr
,"SMS counter overflow\n");
1432 fprintf(stderr
,"*");
1435 fprintf(stderr
,"\n");
1437 #ifdef GSM_ENABLE_BEEP
1443 error
= GSM_LinkSMS(GetSMS
, SortedSMS
, ems
);
1447 while(SortedSMS
[i
] != NULL
) {
1448 if (SortedSMS
[i
] != NULL
) {
1449 for (j
=0;j
<SortedSMS
[i
]->Number
;j
++) {
1450 if ((j
==0) || (j
!=0 && SortedSMS
[i
]->SMS
[j
].Location
!= SortedSMS
[i
]->SMS
[j
-1].Location
)) {
1451 printmsg("Location %i, folder \"%s\"",SortedSMS
[i
]->SMS
[j
].Location
,DecodeUnicodeConsole(folders
.Folder
[SortedSMS
[i
]->SMS
[j
].Folder
-1].Name
));
1452 switch(SortedSMS
[i
]->SMS
[j
].Memory
) {
1453 case GMT_SM
: printmsg(", SIM memory"); break;
1454 case GMT_ME
: printmsg(", phone memory"); break;
1455 case GMT_MT
: printmsg(", phone or SIM memory"); break;
1458 if (SortedSMS
[i
]->SMS
[j
].InboxFolder
) printmsg(", Inbox folder");
1462 displaymultismsinfo(*SortedSMS
[i
],true,ems
);
1468 static void GetSMSFolders(int argc
, char *argv
[])
1470 GSM_SMSFolders folders
;
1474 error
=Phone
->GetSMSFolders(&s
,&folders
);
1477 for (i
=0;i
<folders
.Number
;i
++) {
1478 printmsg("%i. \"%30s\"",i
+1,DecodeUnicodeConsole(folders
.Folder
[i
].Name
));
1479 switch(folders
.Folder
[i
].Memory
) {
1480 case GMT_SM
: printmsg(", SIM memory"); break;
1481 case GMT_ME
: printmsg(", phone memory"); break;
1482 case GMT_MT
: printmsg(", phone or SIM memory"); break;
1485 if (folders
.Folder
[i
].InboxFolder
) printmsg(", Inbox folder");
1492 static void GetRingtone(int argc
, char *argv
[])
1494 GSM_Ringtone ringtone
;
1495 bool PhoneRingtone
= false;
1497 if (mystrncasecmp(argv
[1],"--getphoneringtone",0)) PhoneRingtone
= true;
1499 GetStartStop(&ringtone
.Location
, NULL
, 2, argc
, argv
);
1505 error
=Phone
->GetRingtone(&s
,&ringtone
,PhoneRingtone
);
1508 switch (ringtone
.Format
) {
1509 case RING_NOTETONE
: printmsg("Smart Messaging"); break;
1510 case RING_NOKIABINARY
: printmsg("Nokia binary"); break;
1511 case RING_MIDI
: printmsg("Midi format"); break;
1513 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone
.Name
));
1516 error
=GSM_SaveRingtoneFile(argv
[3], &ringtone
);
1523 static void GetRingtonesList(int argc
, char *argv
[])
1525 GSM_AllRingtonesInfo Info
;
1530 error
=Phone
->GetRingtonesInfo(&s
,&Info
);
1535 for (i
=0;i
<Info
.Number
;i
++) printmsg("%i. \"%s\"\n",i
,DecodeUnicodeConsole(Info
.Ringtone
[i
].Name
));
1538 static void DialVoice(int argc
, char *argv
[])
1540 GSM_CallShowNumber ShowNumber
= GN_CALL_Default
;
1543 if (mystrncasecmp(argv
[3],"show",0)) { ShowNumber
= GN_CALL_ShowNumber
;
1544 } else if (mystrncasecmp(argv
[3],"hide",0)) { ShowNumber
= GN_CALL_HideNumber
;
1546 printmsg("Unknown parameter (\"%s\")\n",argv
[3]);
1553 error
=Phone
->DialVoice(&s
, argv
[2], ShowNumber
);
1559 static void CancelCall(int argc
, char *argv
[])
1564 error
=Phone
->CancelCall(&s
,atoi(argv
[2]),false);
1566 error
=Phone
->CancelCall(&s
,0,true);
1573 static void AnswerCall(int argc
, char *argv
[])
1578 error
=Phone
->AnswerCall(&s
,atoi(argv
[2]),false);
1580 error
=Phone
->AnswerCall(&s
,0,true);
1587 static void UnholdCall(int argc
, char *argv
[])
1591 error
=Phone
->UnholdCall(&s
,atoi(argv
[2]));
1597 static void HoldCall(int argc
, char *argv
[])
1601 error
=Phone
->HoldCall(&s
,atoi(argv
[2]));
1607 static void ConferenceCall(int argc
, char *argv
[])
1611 error
=Phone
->ConferenceCall(&s
,atoi(argv
[2]));
1617 static void SplitCall(int argc
, char *argv
[])
1621 error
=Phone
->SplitCall(&s
,atoi(argv
[2]));
1627 static void SwitchCall(int argc
, char *argv
[])
1632 error
=Phone
->SwitchCall(&s
,atoi(argv
[2]),false);
1634 error
=Phone
->SwitchCall(&s
,0,true);
1641 static void TransferCall(int argc
, char *argv
[])
1646 error
=Phone
->TransferCall(&s
,atoi(argv
[2]),false);
1648 error
=Phone
->TransferCall(&s
,0,true);
1655 static void AddSMSFolder(int argc
, char *argv
[])
1657 unsigned char buffer
[200];
1661 EncodeUnicode(buffer
,argv
[2],strlen(argv
[2]));
1662 error
=Phone
->AddSMSFolder(&s
,buffer
);
1668 static void Reset(int argc
, char *argv
[])
1672 if (mystrncasecmp(argv
[2],"SOFT",0)) { hard
=false;
1673 } else if (mystrncasecmp(argv
[2],"HARD",0)) { hard
=true;
1675 printmsg("What type of reset do you want (\"%s\") ?\n",argv
[2]);
1681 error
=Phone
->Reset(&s
, hard
);
1687 static void PrintCalendar(GSM_CalendarEntry
*Note
)
1690 GSM_DateTime Alarm
,DateTime
;
1691 GSM_MemoryEntry entry
;
1692 unsigned char *name
;
1694 bool repeating
= false;
1695 int repeat_dayofweek
= -1;
1696 int repeat_day
= -1;
1697 int repeat_weekofmonth
= -1;
1698 int repeat_month
= -1;
1699 int repeat_frequency
= -1;
1700 GSM_DateTime repeat_startdate
= {0,0,0,0,0,0,0};
1701 GSM_DateTime repeat_stopdate
= {0,0,0,0,0,0,0};
1704 printmsg("Location : %d\n", Note
->Location
);
1705 printmsg("Note type : ");
1706 switch (Note
->Type
) {
1707 case GCN_REMINDER
: printmsg("Reminder (Date)\n"); break;
1708 case GCN_CALL
: printmsg("Call\n"); break;
1709 case GCN_MEETING
: printmsg("Meeting\n"); break;
1710 case GCN_BIRTHDAY
: printmsg("Birthday (Anniversary)\n"); break;
1711 case GCN_MEMO
: printmsg("Memo (Miscellaneous)\n"); break;
1712 case GCN_TRAVEL
: printmsg("Travel\n"); break;
1713 case GCN_VACATION
: printmsg("Vacation\n"); break;
1714 case GCN_ALARM
: printmsg("Alarm\n"); break;
1715 case GCN_DAILY_ALARM
: printmsg("Daily alarm\n"); break;
1716 case GCN_T_ATHL
: printmsg("Training/Athletism\n"); break;
1717 case GCN_T_BALL
: printmsg("Training/Ball Games\n"); break;
1718 case GCN_T_CYCL
: printmsg("Training/Cycling\n"); break;
1719 case GCN_T_BUDO
: printmsg("Training/Budo\n"); break;
1720 case GCN_T_DANC
: printmsg("Training/Dance\n"); break;
1721 case GCN_T_EXTR
: printmsg("Training/Extreme Sports\n"); break;
1722 case GCN_T_FOOT
: printmsg("Training/Football\n"); break;
1723 case GCN_T_GOLF
: printmsg("Training/Golf\n"); break;
1724 case GCN_T_GYM
: printmsg("Training/Gym\n"); break;
1725 case GCN_T_HORS
: printmsg("Training/Horse Races\n"); break;
1726 case GCN_T_HOCK
: printmsg("Training/Hockey\n"); break;
1727 case GCN_T_RACE
: printmsg("Training/Races\n"); break;
1728 case GCN_T_RUGB
: printmsg("Training/Rugby\n"); break;
1729 case GCN_T_SAIL
: printmsg("Training/Sailing\n"); break;
1730 case GCN_T_STRE
: printmsg("Training/Street Games\n"); break;
1731 case GCN_T_SWIM
: printmsg("Training/Swimming\n"); break;
1732 case GCN_T_TENN
: printmsg("Training/Tennis\n"); break;
1733 case GCN_T_TRAV
: printmsg("Training/Travels\n"); break;
1734 case GCN_T_WINT
: printmsg("Training/Winter Games\n"); break;
1735 default : printmsg("UNKNOWN\n");
1740 repeat_dayofweek
= -1;
1742 repeat_weekofmonth
= -1;
1744 repeat_frequency
= -1;
1745 repeat_startdate
.Day
= 0;
1746 repeat_stopdate
.Day
= 0;
1748 for (i
=0;i
<Note
->EntriesNum
;i
++) {
1749 switch (Note
->Entries
[i
].EntryType
) {
1750 case CAL_START_DATETIME
:
1751 printmsg("Start : %s\n",OSDateTime(Note
->Entries
[i
].Date
,false));
1752 memcpy(&DateTime
,&Note
->Entries
[i
].Date
,sizeof(GSM_DateTime
));
1754 case CAL_END_DATETIME
:
1755 printmsg("Stop : %s\n",OSDateTime(Note
->Entries
[i
].Date
,false));
1756 memcpy(&DateTime
,&Note
->Entries
[i
].Date
,sizeof(GSM_DateTime
));
1758 case CAL_ALARM_DATETIME
:
1759 printmsg("Tone alarm : %s\n",OSDateTime(Note
->Entries
[i
].Date
,false));
1760 memcpy(&Alarm
,&Note
->Entries
[i
].Date
,sizeof(GSM_DateTime
));
1762 case CAL_SILENT_ALARM_DATETIME
:
1763 printmsg("Silent alarm : %s\n",OSDateTime(Note
->Entries
[i
].Date
,false));
1764 memcpy(&Alarm
,&Note
->Entries
[i
].Date
,sizeof(GSM_DateTime
));
1766 case CAL_RECURRANCE
:
1767 printmsg("Repeat : %d day%s\n",Note
->Entries
[i
].Number
/24,
1768 ((Note
->Entries
[i
].Number
/24)>1) ? "s":"" );
1771 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note
->Entries
[i
].Text
));
1774 printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note
->Entries
[i
].Text
));
1777 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note
->Entries
[i
].Text
));
1780 printmsg("Private : %s\n",Note
->Entries
[i
].Number
== 1 ? "Yes" : "No");
1783 entry
.Location
= Note
->Entries
[i
].Number
;
1784 entry
.MemoryType
= GMT_ME
;
1785 error
=Phone
->GetMemory(&s
, &entry
);
1786 if (error
== GE_NONE
) {
1787 name
= GSM_PhonebookGetEntryName(&entry
);
1789 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name
), Note
->Entries
[i
].Number
);
1791 printmsg("Contact ID : %d\n",Note
->Entries
[i
].Number
);
1794 printmsg("Contact ID : %d\n",Note
->Entries
[i
].Number
);
1797 case CAL_REPEAT_DAYOFWEEK
:
1798 repeat_dayofweek
= Note
->Entries
[i
].Number
;
1801 case CAL_REPEAT_DAY
:
1802 repeat_day
= Note
->Entries
[i
].Number
;
1805 case CAL_REPEAT_WEEKOFMONTH
:
1806 repeat_weekofmonth
= Note
->Entries
[i
].Number
;
1809 case CAL_REPEAT_MONTH
:
1810 repeat_month
= Note
->Entries
[i
].Number
;
1813 case CAL_REPEAT_FREQUENCY
:
1814 repeat_frequency
= Note
->Entries
[i
].Number
;
1817 case CAL_REPEAT_STARTDATE
:
1818 repeat_startdate
= Note
->Entries
[i
].Date
;
1821 case CAL_REPEAT_STOPDATE
:
1822 repeat_stopdate
= Note
->Entries
[i
].Date
;
1828 printmsg("Repeating : ");
1829 if ((repeat_startdate
.Day
== 0) && (repeat_stopdate
.Day
== 0)) {
1830 printmsg("Forever");
1831 } else if (repeat_startdate
.Day
== 0) {
1832 printmsg("Till %s", OSDate(repeat_stopdate
));
1833 } else if (repeat_stopdate
.Day
== 0) {
1834 printmsg("Since %s", OSDate(repeat_startdate
));
1836 printmsg("Since %s till %s", OSDate(repeat_startdate
), OSDate(repeat_stopdate
));
1838 if (repeat_frequency
!= -1) {
1839 if (repeat_frequency
== 1) {
1840 printmsg (" on each ");
1842 printmsg(" on each %d. ", repeat_frequency
);
1844 if (repeat_dayofweek
> 0) {
1845 switch (repeat_dayofweek
) {
1846 case 1 : printmsg("Monday"); break;
1847 case 2 : printmsg("Tuesday"); break;
1848 case 3 : printmsg("Wednesday"); break;
1849 case 4 : printmsg("Thursday"); break;
1850 case 5 : printmsg("Friday"); break;
1851 case 6 : printmsg("Saturday"); break;
1852 case 7 : printmsg("Sunday"); break;
1853 default: printmsg("Bad day!"); break;
1855 if (repeat_weekofmonth
> 0) {
1856 printmsg(" in %d. week of ", repeat_weekofmonth
);
1860 if (repeat_month
> 0) {
1861 switch(repeat_month
) {
1862 case 1 : printmsg("January"); break;
1863 case 2 : printmsg("February"); break;
1864 case 3 : printmsg("March"); break;
1865 case 4 : printmsg("April"); break;
1866 case 5 : printmsg("May"); break;
1867 case 6 : printmsg("June"); break;
1868 case 7 : printmsg("July"); break;
1869 case 8 : printmsg("August"); break;
1870 case 9 : printmsg("September"); break;
1871 case 10: printmsg("October"); break;
1872 case 11: printmsg("November"); break;
1873 case 12: printmsg("December"); break;
1874 default: printmsg("Bad month!"); break;
1877 printmsg("each month");
1879 } else if (repeat_day
> 0) {
1880 printmsg("%d. day of ", repeat_day
);
1881 if (repeat_month
> 0) {
1882 switch(repeat_month
) {
1883 case 1 : printmsg("January"); break;
1884 case 2 : printmsg("February"); break;
1885 case 3 : printmsg("March"); break;
1886 case 4 : printmsg("April"); break;
1887 case 5 : printmsg("May"); break;
1888 case 6 : printmsg("June"); break;
1889 case 7 : printmsg("July"); break;
1890 case 8 : printmsg("August"); break;
1891 case 9 : printmsg("September"); break;
1892 case 10: printmsg("October"); break;
1893 case 11: printmsg("November"); break;
1894 case 12: printmsg("December"); break;
1895 default: printmsg("Bad month!");break;
1898 printmsg("each month");
1906 if (Note
->Type
== GCN_BIRTHDAY
) {
1907 if (Alarm
.Year
== 0x00) GSM_GetCurrentDateTime (&Alarm
);
1908 if (DateTime
.Year
!= 0) {
1909 i_age
= Alarm
.Year
- DateTime
.Year
;
1910 if (DateTime
.Month
< Alarm
.Month
) i_age
++;
1911 if (DateTime
.Month
== Alarm
.Month
&&
1912 DateTime
.Day
< Alarm
.Day
) {
1915 printmsg("Age : %d %s\n",i_age
, (i_age
==1)?"year":"years");
1921 static void GetCalendar(int argc
, char *argv
[])
1923 GSM_CalendarEntry Note
;
1926 GetStartStop(&start
, &stop
, 2, argc
, argv
);
1930 for (i
=start
;i
<=stop
;i
++) {
1932 error
= Phone
->GetCalendar(&s
, &Note
);
1933 if (error
== GE_EMPTY
) continue;
1935 PrintCalendar(&Note
);
1941 static void DeleteCalendar(int argc
, char *argv
[])
1943 GSM_CalendarEntry Note
;
1946 GetStartStop(&start
, &stop
, 2, argc
, argv
);
1950 for (i
=start
;i
<=stop
;i
++) {
1952 error
= Phone
->DeleteCalendar(&s
, &Note
);
1953 if (error
== GE_EMPTY
) continue;
1955 PrintCalendar(&Note
);
1962 static void GetAllCalendar(int argc
, char *argv
[])
1964 GSM_CalendarEntry Note
;
1965 bool refresh
= true;
1970 error
=Phone
->GetNextCalendar(&s
,&Note
,refresh
);
1971 if (error
== GE_EMPTY
) break;
1972 PrintCalendar(&Note
);
1980 static void GetCalendarSettings(int argc
, char *argv
[])
1982 GSM_CalendarSettings settings
;
1986 error
=Phone
->GetCalendarSettings(&s
,&settings
);
1989 if (settings
.AutoDelete
== 0) {
1990 printmsg("Auto deleting disabled");
1992 printmsg("Auto deleting notes after %i day(s)",settings
.AutoDelete
);
1994 printmsg("\nWeek start on ");
1995 switch(settings
.StartDay
) {
1996 case 1: printmsg("Monday"); break;
1997 case 6: printmsg("Saturday"); break;
1998 case 7: printmsg("Sunday"); break;
2005 static void GetWAPBookmark(int argc
, char *argv
[])
2007 GSM_WAPBookmark bookmark
;
2010 GetStartStop(&start
, &stop
, 2, argc
, argv
);
2014 for (i
=start
;i
<=stop
;i
++) {
2015 bookmark
.Location
=i
;
2016 error
=Phone
->GetWAPBookmark(&s
,&bookmark
);
2018 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark
.Title
));
2019 printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark
.Address
));
2025 static void DeleteWAPBookmark(int argc
, char *argv
[])
2027 GSM_WAPBookmark bookmark
;
2030 GetStartStop(&start
, &stop
, 2, argc
, argv
);
2034 for (i
=start
;i
<=stop
;i
++) {
2035 bookmark
.Location
=i
;
2036 error
=Phone
->DeleteWAPBookmark(&s
, &bookmark
);
2043 static void GetGPRSPoint(int argc
, char *argv
[])
2045 GSM_GPRSAccessPoint point
;
2048 GetStartStop(&start
, &stop
, 2, argc
, argv
);
2052 for (i
=start
;i
<=stop
;i
++) {
2054 error
=Phone
->GetGPRSAccessPoint(&s
,&point
);
2055 if (error
!= GE_EMPTY
) {
2057 printmsg("%i. \"%s\"",point
.Location
,DecodeUnicodeConsole(point
.Name
));
2059 printmsg("%i. Access point %i",point
.Location
,point
.Location
);
2061 if (point
.Active
) printmsg(" (active)");
2062 if (error
!= GE_EMPTY
) {
2063 printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point
.URL
));
2072 static void GetBitmap(int argc
, char *argv
[])
2074 GSM_MultiBitmap MultiBitmap
;
2076 GSM_AllRingtonesInfo Info
;
2078 if (mystrncasecmp(argv
[2],"STARTUP",0)) {
2079 MultiBitmap
.Bitmap
[0].Type
=GSM_StartupLogo
;
2080 } else if (mystrncasecmp(argv
[2],"CALLER",0)) {
2081 MultiBitmap
.Bitmap
[0].Type
=GSM_CallerLogo
;
2082 GetStartStop(&location
, NULL
, 3, argc
, argv
);
2084 printmsg("Maximal location for caller logo can be 5\n");
2087 } else if (mystrncasecmp(argv
[2],"PICTURE",0)) {
2088 MultiBitmap
.Bitmap
[0].Type
=GSM_PictureImage
;
2089 GetStartStop(&location
, NULL
, 3, argc
, argv
);
2090 } else if (mystrncasecmp(argv
[2],"TEXT",0)) {
2091 MultiBitmap
.Bitmap
[0].Type
=GSM_WelcomeNoteText
;
2092 } else if (mystrncasecmp(argv
[2],"DEALER",0)) {
2093 MultiBitmap
.Bitmap
[0].Type
=GSM_DealerNoteText
;
2094 } else if (mystrncasecmp(argv
[2],"OPERATOR",0)) {
2095 MultiBitmap
.Bitmap
[0].Type
=GSM_OperatorLogo
;
2097 printmsg("What type of logo do you want to get (\"%s\") ?\n",argv
[2]);
2100 MultiBitmap
.Bitmap
[0].Location
=location
;
2104 error
=Phone
->GetBitmap(&s
,&MultiBitmap
.Bitmap
[0]);
2107 MultiBitmap
.Number
= 1;
2110 switch (MultiBitmap
.Bitmap
[0].Type
) {
2111 case GSM_CallerLogo
:
2112 if (!MultiBitmap
.Bitmap
[0].DefaultBitmap
) GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
2113 printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
2114 if (MultiBitmap
.Bitmap
[0].DefaultName
) printmsg(" (default)");
2116 if (MultiBitmap
.Bitmap
[0].DefaultRingtone
) {
2117 printmsg("Ringtone : default\n");
2119 error
= Phone
->GetRingtonesInfo(&s
,&Info
);
2120 if (error
!= GE_NONE
) Info
.Number
= 0;
2123 printmsg("Ringtone : ");
2124 if (UnicodeLength(GSM_GetRingtoneName(&Info
,MultiBitmap
.Bitmap
[0].Ringtone
))!=0) {
2125 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info
,MultiBitmap
.Bitmap
[0].Ringtone
)));
2127 printmsg("%i\n",MultiBitmap
.Bitmap
[0].Ringtone
);
2130 if (MultiBitmap
.Bitmap
[0].Enabled
) {
2131 printmsg("Bitmap : enabled\n");
2133 printmsg("Bitmap : disabled\n");
2135 if (argc
>4 && !MultiBitmap
.Bitmap
[0].DefaultBitmap
) error
=GSM_SaveBitmapFile(argv
[4],&MultiBitmap
);
2137 case GSM_StartupLogo
:
2138 GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
2139 if (argc
>3) error
=GSM_SaveBitmapFile(argv
[3],&MultiBitmap
);
2141 case GSM_OperatorLogo
:
2142 if (strcmp(MultiBitmap
.Bitmap
[0].NetworkCode
,"000 00")!=0) {
2143 GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
2144 if (argc
>3) error
=GSM_SaveBitmapFile(argv
[3],&MultiBitmap
);
2146 printmsg("No operator logo in phone\n");
2149 case GSM_PictureImage
:
2150 GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
2151 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
2152 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Sender
));
2153 if (argc
>4) error
=GSM_SaveBitmapFile(argv
[4],&MultiBitmap
);
2155 case GSM_WelcomeNoteText
:
2156 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
2158 case GSM_DealerNoteText
:
2159 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
2169 static void SetBitmap(int argc
, char *argv
[])
2171 GSM_Bitmap Bitmap
, NewBitmap
;
2172 GSM_MultiBitmap MultiBitmap
;
2173 GSM_NetworkInfo NetInfo
;
2176 if (mystrncasecmp(argv
[2],"STARTUP",0)) {
2178 printmsg("More arguments required\n");
2181 MultiBitmap
.Bitmap
[0].Type
=GSM_StartupLogo
;
2182 MultiBitmap
.Bitmap
[0].Location
=1;
2183 if (!strcmp(argv
[3],"1")) MultiBitmap
.Bitmap
[0].Location
= 2;
2184 if (!strcmp(argv
[3],"2")) MultiBitmap
.Bitmap
[0].Location
= 3;
2185 if (!strcmp(argv
[3],"3")) MultiBitmap
.Bitmap
[0].Location
= 4;
2186 if (MultiBitmap
.Bitmap
[0].Location
== 1) {
2187 error
=GSM_ReadBitmapFile(argv
[3],&MultiBitmap
);
2190 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
2191 } else if (mystrncasecmp(argv
[2],"TEXT",0)) {
2193 printmsg("More arguments required\n");
2196 Bitmap
.Type
=GSM_WelcomeNoteText
;
2197 EncodeUnicode(Bitmap
.Text
,argv
[3],strlen(argv
[3]));
2198 } else if (mystrncasecmp(argv
[2],"DEALER",0)) {
2200 printmsg("More arguments required\n");
2203 Bitmap
.Type
=GSM_DealerNoteText
;
2204 EncodeUnicode(Bitmap
.Text
,argv
[3],strlen(argv
[3]));
2205 } else if (mystrncasecmp(argv
[2],"CALLER",0)) {
2207 printmsg("More arguments required\n");
2210 GetStartStop(&i
, NULL
, 3, argc
, argv
);
2211 if (i
>5 && i
!=255) {
2212 printmsg("Maximal location for caller logo can be 5\n");
2215 MultiBitmap
.Bitmap
[0].Type
= GSM_CallerLogo
;
2216 MultiBitmap
.Bitmap
[0].Location
= i
;
2218 error
=GSM_ReadBitmapFile(argv
[4],&MultiBitmap
);
2221 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
2225 NewBitmap
.Type
= GSM_CallerLogo
;
2226 NewBitmap
.Location
= i
;
2227 error
=Phone
->GetBitmap(&s
,&NewBitmap
);
2229 Bitmap
.Ringtone
= NewBitmap
.Ringtone
;
2230 Bitmap
.DefaultRingtone
= NewBitmap
.DefaultRingtone
;
2231 CopyUnicodeString(Bitmap
.Text
, NewBitmap
.Text
);
2232 Bitmap
.DefaultName
= NewBitmap
.DefaultName
;
2234 } else if (mystrncasecmp(argv
[2],"PICTURE",0)) {
2236 printmsg("More arguments required\n");
2239 MultiBitmap
.Bitmap
[0].Type
= GSM_PictureImage
;
2240 MultiBitmap
.Bitmap
[0].Location
= atoi(argv
[4]);
2241 error
=GSM_ReadBitmapFile(argv
[3],&MultiBitmap
);
2243 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
2246 if (argc
== 6) EncodeUnicode(Bitmap
.Text
,argv
[5],strlen(argv
[5]));
2249 } else if (mystrncasecmp(argv
[2],"COLOUROPERATOR",0)) {
2250 Bitmap
.Type
= GSM_ColourOperatorLogo
;
2251 strcpy(Bitmap
.NetworkCode
,"000 00");
2253 Bitmap
.ID
= atoi(argv
[3]);
2255 strncpy(Bitmap
.NetworkCode
,argv
[4],6);
2259 error
=Phone
->GetNetworkInfo(&s
,&NetInfo
);
2261 strcpy(Bitmap
.NetworkCode
,NetInfo
.NetworkCode
);
2264 } else if (mystrncasecmp(argv
[2],"COLOURSTARTUP",0)) {
2265 Bitmap
.Type
= GSM_ColourStartupLogo
;
2266 Bitmap
.Location
= 0;
2268 Bitmap
.Location
= 1;
2269 Bitmap
.ID
= atoi(argv
[3]);
2271 } else if (mystrncasecmp(argv
[2],"WALLPAPER",0)) {
2272 Bitmap
.Type
= GSM_ColourWallPaper
;
2274 if (argc
> 3) Bitmap
.ID
= atoi(argv
[3]);
2275 } else if (mystrncasecmp(argv
[2],"OPERATOR",0)) {
2276 MultiBitmap
.Bitmap
[0].Type
= GSM_OperatorLogo
;
2277 MultiBitmap
.Bitmap
[0].Location
= 1;
2278 strcpy(MultiBitmap
.Bitmap
[0].NetworkCode
,"000 00");
2280 error
=GSM_ReadBitmapFile(argv
[3],&MultiBitmap
);
2283 strncpy(MultiBitmap
.Bitmap
[0].NetworkCode
,argv
[4],6);
2287 error
=Phone
->GetNetworkInfo(&s
,&NetInfo
);
2289 strcpy(MultiBitmap
.Bitmap
[0].NetworkCode
,NetInfo
.NetworkCode
);
2292 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
2294 printmsg("What type of logo do you want to set (\"%s\") ?\n",argv
[2]);
2298 if (init
) GSM_Init(true);
2300 error
=Phone
->SetBitmap(&s
,&Bitmap
);
2303 #ifdef GSM_ENABLE_BEEP
2310 static void SetRingtone(int argc
, char *argv
[])
2312 GSM_Ringtone ringtone
;
2315 ringtone
.Format
= 0;
2316 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
2318 ringtone
.Location
= 255;
2319 for (i
=3;i
<argc
;i
++) {
2322 if (mystrncasecmp(argv
[i
],"-scale",0)) {
2323 ringtone
.NoteTone
.AllNotesScale
= true;
2326 if (mystrncasecmp(argv
[i
],"-location",0)) {
2330 if (mystrncasecmp(argv
[i
],"-name",0)) {
2334 printmsg("Unknown parameter \"%s\"",argv
[i
]);
2337 ringtone
.Location
=atoi(argv
[i
]);
2341 EncodeUnicode(ringtone
.Name
,argv
[i
],strlen(argv
[i
]));
2347 printmsg("Parameter missed...\n");
2350 if (ringtone
.Location
==0) {
2351 printmsg("ERROR: enumerate locations from 1\n");
2356 error
=Phone
->SetRingtone(&s
, &ringtone
, &i
);
2358 #ifdef GSM_ENABLE_BEEP
2364 static void DisplaySMSFrame(GSM_SMSMessage
*SMS
)
2367 int i
, length
, current
= 0;
2368 unsigned char req
[1000], buffer
[1000], hexreq
[1000];
2370 error
=PHONE_EncodeSMSFrame(&s
,SMS
,buffer
,PHONE_SMSSubmit
,&length
,true);
2371 if (error
!= GE_NONE
) {
2372 printmsg("Error\n");
2376 length
= length
- PHONE_SMSSubmit
.Text
;
2378 printf("<?xml version=\"1.0\"?>\n");
2379 printf("<msgbatch batchid=\"10014\">\n");
2380 /*?*/ printf("<message id=\"235\" commit=\"ACK\" ");
2381 /*?*/ printf("prio=\"0\" rn=\"NO\" ");
2382 /*?*/ printf("type=\"MT\" ver=\"1.0\" ttl=\"100\">\n");
2386 printf("<shortCodeAddress sc=\"%s\"/>\n",DecodeUnicodeString(SMS
->SMSC
.Number
));
2387 printf("</from>\n");
2391 printf("<msisdnAddress msisdn=\"%s\" />\n",DecodeUnicodeString(SMS
->Number
));
2394 printf("<content type=\"SMS\">\n");
2395 /*?*/ printf("<ucp51 trn=\"10\">\n");
2397 /* SMS Text (without UDH) */
2398 for(i
=SMS
->UDH
.Length
;i
<length
;i
++) req
[i
-SMS
->UDH
.Length
]=buffer
[PHONE_SMSSubmit
.Text
+i
];
2399 EncodeHexBin(hexreq
, req
, length
-SMS
->UDH
.Length
);
2400 printf("<msg mt=\"TD\">%s</msg>\n",hexreq
);
2402 /*?*/ printf("<mcls>1</mcls>\n");
2404 /* Length of SMS Text (without UDH) in bits */
2405 printf("<nb>%i</nb>\n",(buffer
[PHONE_SMSSubmit
.TPUDL
]-SMS
->UDH
.Length
)*8);
2409 printf("<dcs>1</dcs>\n");
2410 for(i
=0;i
<SMS
->UDH
.Length
;i
++) req
[i
]=buffer
[PHONE_SMSSubmit
.Text
+i
];
2411 EncodeHexBin(hexreq
, req
, SMS
->UDH
.Length
);
2412 printf("<udh>%s</udh>\n",hexreq
);
2414 printf("</xser>\n");
2415 printf("</ucp51>\n");
2416 printf("</content>\n");
2417 printf("</message>\n");
2418 printf("</msgbatch>\n");
2420 length
= length
- PHONE_SMSSubmit
.Text
;
2421 for (i
=0;i
<buffer
[PHONE_SMSSubmit
.SMSCNumber
]+1;i
++) {
2422 req
[current
++]=buffer
[PHONE_SMSSubmit
.SMSCNumber
+i
];
2424 req
[current
++]=buffer
[PHONE_SMSSubmit
.firstbyte
];
2425 req
[current
++]=buffer
[PHONE_SMSSubmit
.TPMR
];
2426 for (i
=0;i
<((buffer
[PHONE_SMSSubmit
.Number
]+1)/2+1)+1;i
++) {
2427 req
[current
++]=buffer
[PHONE_SMSSubmit
.Number
+i
];
2429 req
[current
++]=buffer
[PHONE_SMSSubmit
.TPPID
];
2430 req
[current
++]=buffer
[PHONE_SMSSubmit
.TPDCS
];
2431 req
[current
++]=buffer
[PHONE_SMSSubmit
.TPVP
];
2432 req
[current
++]=buffer
[PHONE_SMSSubmit
.TPUDL
];
2433 for(i
=0;i
<length
;i
++) req
[current
++]=buffer
[PHONE_SMSSubmit
.Text
+i
];
2434 EncodeHexBin(hexreq
, req
, current
);
2435 printmsg("%s\n\n",hexreq
);
2439 #define SEND_SAVE_SMS_BUFFER_SIZE 10000
2441 static GSM_Error SMSStatus
;
2443 static void SendSMSStatus (char *Device
, int status
)
2445 dbgprintf("Incoming SMS device: \"%s\"\n",Device
);
2448 SMSStatus
= GE_NONE
;
2450 printmsg("..error %i\n",status
);
2451 SMSStatus
= GE_UNKNOWN
;
2455 static void SendSaveDisplaySMS(int argc
, char *argv
[])
2457 #ifdef GSM_ENABLE_BACKUP
2460 int i
,j
,z
,FramesNum
= 0;
2462 GSM_SMSFolders folders
;
2463 GSM_MultiSMSMessage sms
;
2464 GSM_Ringtone ringtone
[MAX_MULTI_SMS
];
2465 GSM_MultiBitmap bitmap
[MAX_MULTI_SMS
],bitmap2
;
2466 GSM_EncodeMultiPartSMSInfo SMSInfo
;
2467 GSM_NetworkInfo NetInfo
;
2468 GSM_MMSIndicator MMSInfo
;
2469 FILE *ReplaceFile
,*f
;
2470 char ReplaceBuffer2
[200],ReplaceBuffer
[200];
2471 char InputBuffer
[SEND_SAVE_SMS_BUFFER_SIZE
/2+1];
2472 char Buffer
[MAX_MULTI_SMS
][SEND_SAVE_SMS_BUFFER_SIZE
];
2473 char Sender
[(GSM_MAX_NUMBER_LENGTH
+1)*2];
2474 char Name
[(GSM_MAX_NUMBER_LENGTH
+1)*2];
2475 char SMSC
[(GSM_MAX_NUMBER_LENGTH
+1)*2];
2479 bool ReplyViaSameSMSC
= false;
2482 bool EMS16Bit
= false;
2484 /* Parameters required only during saving */
2485 int Folder
= 1; /*Inbox by default */
2486 GSM_SMS_State State
= GSM_Sent
;
2488 /* Required only during sending */
2489 GSM_SMSValidity Validity
;
2491 bool DeliveryReport
= false;
2493 ReplaceBuffer
[0] = 0;
2494 ReplaceBuffer
[1] = 0;
2495 GSM_ClearMultiPartSMSInfo(&SMSInfo
);
2496 SMSInfo
.ReplaceMessage
= 0;
2497 SMSInfo
.EntriesNum
= 1;
2499 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2500 EncodeUnicode(Sender
,"Gammu",5);
2505 EncodeUnicode(Sender
,argv
[3],strlen(argv
[3]));
2510 if (mystrncasecmp(argv
[2],"TEXT",0)) {
2511 chars_read
= fread(InputBuffer
, 1, SEND_SAVE_SMS_BUFFER_SIZE
/2, stdin
);
2512 if (chars_read
== 0) printmsg("Warning: 0 chars read !\n");
2513 InputBuffer
[chars_read
] = 0x00;
2514 InputBuffer
[chars_read
+1] = 0x00;
2515 EncodeUnicode(Buffer
[0],InputBuffer
,strlen(InputBuffer
));
2516 SMSInfo
.Entries
[0].Buffer
= Buffer
[0];
2517 SMSInfo
.Entries
[0].ID
= SMS_Text
;
2518 SMSInfo
.UnicodeCoding
= false;
2521 } else if (mystrncasecmp(argv
[2],"EMS",0)) {
2522 SMSInfo
.UnicodeCoding
= false;
2523 SMSInfo
.EntriesNum
= 0;
2525 } else if (mystrncasecmp(argv
[2],"MMSINDICATOR",0)) {
2526 if (argc
<6+startarg
) {
2527 printmsg("Where is ringtone filename ?\n");
2530 SMSInfo
.Entries
[0].ID
= SMS_MMSIndicatorLong
;
2531 SMSInfo
.Entries
[0].MMSIndicator
= &MMSInfo
;
2532 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2533 EncodeUnicode(Sender
,"MMS Info",8);
2535 strcpy(MMSInfo
.Address
, argv
[3+startarg
]);
2536 strcpy(MMSInfo
.Title
, argv
[4+startarg
]);
2537 strcpy(MMSInfo
.Sender
, argv
[5+startarg
]);
2539 } else if (mystrncasecmp(argv
[2],"RINGTONE",0)) {
2540 if (argc
<4+startarg
) {
2541 printmsg("Where is ringtone filename ?\n");
2544 ringtone
[0].Format
=RING_NOTETONE
;
2545 error
=GSM_ReadRingtoneFile(argv
[3+startarg
],&ringtone
[0]);
2547 SMSInfo
.Entries
[0].ID
= SMS_NokiaRingtone
;
2548 SMSInfo
.Entries
[0].Ringtone
= &ringtone
[0];
2549 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2550 CopyUnicodeString(Sender
, ringtone
[0].Name
);
2551 EncodeUnicode(Name
,"Ringtone ",9);
2552 CopyUnicodeString(Name
+9*2, ringtone
[0].Name
);
2555 } else if (mystrncasecmp(argv
[2],"OPERATOR",0)) {
2556 if (argc
<4+startarg
) {
2557 printmsg("Where is logo filename ?\n");
2560 bitmap
[0].Bitmap
[0].Type
=GSM_OperatorLogo
;
2561 error
=GSM_ReadBitmapFile(argv
[3+startarg
],&bitmap
[0]);
2563 strcpy(bitmap
[0].Bitmap
[0].NetworkCode
,"000 00");
2564 SMSInfo
.Entries
[0].ID
= SMS_NokiaOperatorLogo
;
2565 SMSInfo
.Entries
[0].Bitmap
= &bitmap
[0];
2566 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2567 EncodeUnicode(Sender
, "OpLogo",6);
2568 EncodeUnicode(Name
,"OpLogo ",7);
2571 } else if (mystrncasecmp(argv
[2],"CALLER",0)) {
2572 if (argc
<4+startarg
) {
2573 printmsg("Where is logo filename ?\n");
2576 bitmap
[0].Bitmap
[0].Type
=GSM_CallerLogo
;
2577 error
=GSM_ReadBitmapFile(argv
[3+startarg
],&bitmap
[0]);
2579 SMSInfo
.Entries
[0].ID
= SMS_NokiaCallerLogo
;
2580 SMSInfo
.Entries
[0].Bitmap
= &bitmap
[0];
2581 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2582 EncodeUnicode(Sender
, "Caller",6);
2585 } else if (mystrncasecmp(argv
[2],"PICTURE",0)) {
2586 if (argc
<4+startarg
) {
2587 printmsg("Where is logo filename ?\n");
2590 bitmap
[0].Bitmap
[0].Type
=GSM_PictureImage
;
2591 error
=GSM_ReadBitmapFile(argv
[3+startarg
],&bitmap
[0]);
2593 SMSInfo
.Entries
[0].ID
= SMS_NokiaPictureImageLong
;
2594 SMSInfo
.Entries
[0].Bitmap
= &bitmap
[0];
2595 SMSInfo
.UnicodeCoding
= false;
2596 bitmap
[0].Bitmap
[0].Text
[0] = 0;
2597 bitmap
[0].Bitmap
[0].Text
[1] = 0;
2598 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2599 EncodeUnicode(Sender
, "Picture",7);
2600 EncodeUnicode(Name
,"Picture Image",13);
2603 #ifdef GSM_ENABLE_BACKUP
2604 } else if (mystrncasecmp(argv
[2],"BOOKMARK",0)) {
2605 if (argc
<5+startarg
) {
2606 printmsg("Where is backup filename and location ?\n");
2609 error
=GSM_ReadBackupFile(argv
[3+startarg
],&Backup
);
2612 while (Backup
.WAPBookmark
[i
]!=NULL
) {
2613 if (i
== atoi(argv
[4+startarg
])-1) break;
2616 if (i
!= atoi(argv
[4+startarg
])-1) {
2617 printmsg("Bookmark not found in file\n");
2620 SMSInfo
.Entries
[0].ID
= SMS_NokiaWAPBookmarkLong
;
2621 SMSInfo
.Entries
[0].Bookmark
= Backup
.WAPBookmark
[i
];
2622 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2623 EncodeUnicode(Sender
, "Bookmark",8);
2624 EncodeUnicode(Name
,"WAP Bookmark",12);
2627 } else if (mystrncasecmp(argv
[2],"WAPSETTINGS",0)) {
2628 if (argc
<6+startarg
) {
2629 printmsg("Where is backup filename and location ?\n");
2632 error
=GSM_ReadBackupFile(argv
[3+startarg
],&Backup
);
2635 while (Backup
.WAPSettings
[i
]!=NULL
) {
2636 if (i
== atoi(argv
[4+startarg
])-1) break;
2639 if (i
!= atoi(argv
[4+startarg
])-1) {
2640 printmsg("WAP settings not found in file\n");
2643 SMSInfo
.Entries
[0].Settings
= NULL
;
2644 for (j
=0;j
<Backup
.WAPSettings
[i
]->Number
;j
++) {
2645 switch (Backup
.WAPSettings
[i
]->Settings
[j
].Bearer
) {
2646 case WAPSETTINGS_BEARER_GPRS
:
2647 if (mystrncasecmp(argv
[5+startarg
],"GPRS",0)) {
2648 SMSInfo
.Entries
[0].Settings
= &Backup
.WAPSettings
[i
]->Settings
[j
];
2651 case WAPSETTINGS_BEARER_DATA
:
2652 if (mystrncasecmp(argv
[5+startarg
],"DATA",0)) {
2653 SMSInfo
.Entries
[0].Settings
= &Backup
.WAPSettings
[i
]->Settings
[j
];
2660 if (SMSInfo
.Entries
[0].Settings
== NULL
) {
2661 printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n");
2664 SMSInfo
.Entries
[0].ID
= SMS_NokiaWAPSettingsLong
;
2665 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2666 EncodeUnicode(Sender
, "Settings",8);
2667 EncodeUnicode(Name
,"WAP Settings",12);
2670 } else if (mystrncasecmp(argv
[2],"MMSSETTINGS",0)) {
2671 if (argc
<5+startarg
) {
2672 printmsg("Where is backup filename and location ?\n");
2675 error
=GSM_ReadBackupFile(argv
[3+startarg
],&Backup
);
2678 while (Backup
.MMSSettings
[i
]!=NULL
) {
2679 if (i
== atoi(argv
[4+startarg
])-1) break;
2682 if (i
!= atoi(argv
[4+startarg
])-1) {
2683 printmsg("MMS settings not found in file\n");
2686 SMSInfo
.Entries
[0].Settings
= NULL
;
2687 for (j
=0;j
<Backup
.MMSSettings
[i
]->Number
;j
++) {
2688 switch (Backup
.MMSSettings
[i
]->Settings
[j
].Bearer
) {
2689 case WAPSETTINGS_BEARER_GPRS
:
2690 SMSInfo
.Entries
[0].Settings
= &Backup
.MMSSettings
[i
]->Settings
[j
];
2696 if (SMSInfo
.Entries
[0].Settings
== NULL
) {
2697 printmsg("Sorry. No GPRS bearer found in MMS settings\n");
2700 SMSInfo
.Entries
[0].ID
= SMS_NokiaMMSSettingsLong
;
2701 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2702 EncodeUnicode(Sender
, "Settings",8);
2703 EncodeUnicode(Name
,"MMS Settings",12);
2706 } else if (mystrncasecmp(argv
[2],"CALENDAR",0)) {
2707 if (argc
<5+startarg
) {
2708 printmsg("Where is backup filename and location ?\n");
2711 error
=GSM_ReadBackupFile(argv
[3+startarg
],&Backup
);
2714 while (Backup
.Calendar
[i
]!=NULL
) {
2715 if (i
== atoi(argv
[4+startarg
])-1) break;
2718 if (i
!= atoi(argv
[4+startarg
])-1) {
2719 printmsg("Calendar note not found in file\n");
2722 SMSInfo
.Entries
[0].ID
= SMS_NokiaVCALENDAR10Long
;
2723 SMSInfo
.Entries
[0].Calendar
= Backup
.Calendar
[i
];
2724 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2725 EncodeUnicode(Sender
, "Calendar",8);
2728 } else if (mystrncasecmp(argv
[2],"TODO",0)) {
2729 if (argc
<5+startarg
) {
2730 printmsg("Where is backup filename and location ?\n");
2733 error
=GSM_ReadBackupFile(argv
[3+startarg
],&Backup
);
2736 while (Backup
.ToDo
[i
]!=NULL
) {
2737 if (i
== atoi(argv
[4+startarg
])-1) break;
2740 if (i
!= atoi(argv
[4+startarg
])-1) {
2741 printmsg("ToDo note not found in file\n");
2744 SMSInfo
.Entries
[0].ID
= SMS_NokiaVTODOLong
;
2745 SMSInfo
.Entries
[0].ToDo
= Backup
.ToDo
[i
];
2746 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2747 EncodeUnicode(Sender
, "ToDo",8);
2750 } else if (mystrncasecmp(argv
[2],"VCARD10",0) || mystrncasecmp(argv
[2],"VCARD21",0)) {
2751 if (argc
<6+startarg
) {
2752 printmsg("Where is backup filename and location and memory type ?\n");
2755 error
=GSM_ReadBackupFile(argv
[3+startarg
],&Backup
);
2758 if (mystrncasecmp(argv
[4+startarg
],"SM",0)) {
2759 while (Backup
.SIMPhonebook
[i
]!=NULL
) {
2760 if (i
== atoi(argv
[5+startarg
])-1) break;
2763 if (i
!= atoi(argv
[5+startarg
])-1) {
2764 printmsg("Phonebook entry not found in file\n");
2767 SMSInfo
.Entries
[0].Phonebook
= Backup
.SIMPhonebook
[i
];
2768 } else if (mystrncasecmp(argv
[4+startarg
],"ME",0)) {
2769 while (Backup
.PhonePhonebook
[i
]!=NULL
) {
2770 if (i
== atoi(argv
[5+startarg
])-1) break;
2773 if (i
!= atoi(argv
[5+startarg
])-1) {
2774 printmsg("Phonebook entry not found in file\n");
2777 SMSInfo
.Entries
[0].Phonebook
= Backup
.PhonePhonebook
[i
];
2779 printmsg("Unknown memory type: \"%s\"\n",argv
[4+startarg
]);
2782 if (mystrncasecmp(argv
[2],"VCARD10",0)) {
2783 SMSInfo
.Entries
[0].ID
= SMS_VCARD10Long
;
2785 SMSInfo
.Entries
[0].ID
= SMS_VCARD21Long
;
2787 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2788 EncodeUnicode(Sender
, "VCARD",5);
2789 EncodeUnicode(Name
, "Phonebook entry",15);
2793 } else if (mystrncasecmp(argv
[2],"PROFILE",0)) {
2794 SMSInfo
.Entries
[0].ID
= SMS_NokiaProfileLong
;
2795 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2796 EncodeUnicode(Sender
, "Profile",7);
2800 printmsg("What format of sms (\"%s\") ?\n",argv
[2]);
2804 for (i
=startarg
;i
<argc
;i
++) {
2807 if (mystrncasecmp(argv
[1],"--savesms",0)) {
2808 if (mystrncasecmp(argv
[i
],"-folder",0)) {
2812 if (mystrncasecmp(argv
[i
],"-unread",0)) {
2816 if (mystrncasecmp(argv
[i
],"-read",0)) {
2820 if (mystrncasecmp(argv
[i
],"-unsent",0)) {
2824 if (mystrncasecmp(argv
[i
],"-sent",0)) {
2828 if (mystrncasecmp(argv
[i
],"-sender",0)) {
2833 if (mystrncasecmp(argv
[i
],"-report",0)) {
2834 DeliveryReport
=true;
2837 if (mystrncasecmp(argv
[i
],"-validity",0)) {
2842 if (mystrncasecmp(argv
[i
],"-smscset",0)) {
2846 if (mystrncasecmp(argv
[i
],"-smscnumber",0)) {
2850 if (mystrncasecmp(argv
[i
],"-protected",0)) {
2854 if (mystrncasecmp(argv
[i
],"-reply",0)) {
2855 ReplyViaSameSMSC
=true;
2858 if (mystrncasecmp(argv
[i
],"-maxsms",0)) {
2862 if (mystrncasecmp(argv
[2],"RINGTONE",0)) {
2863 if (mystrncasecmp(argv
[i
],"-long",0)) {
2864 SMSInfo
.Entries
[0].ID
= SMS_NokiaRingtoneLong
;
2867 if (mystrncasecmp(argv
[i
],"-scale",0)) {
2868 ringtone
[0].NoteTone
.AllNotesScale
=true;
2872 if (mystrncasecmp(argv
[2],"TEXT",0)) {
2873 if (mystrncasecmp(argv
[i
],"-inputunicode",0)) {
2874 ReadUnicodeFile(Buffer
[0],InputBuffer
);
2877 if (mystrncasecmp(argv
[i
],"-16bit",0)) {
2878 if (SMSInfo
.Entries
[0].ID
== SMS_ConcatenatedTextLong
) SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedTextLong16bit
;
2879 if (SMSInfo
.Entries
[0].ID
== SMS_ConcatenatedAutoTextLong
) SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedAutoTextLong16bit
;
2882 if (mystrncasecmp(argv
[i
],"-flash",0)) {
2886 if (mystrncasecmp(argv
[i
],"-len",0)) {
2890 if (mystrncasecmp(argv
[i
],"-autolen",0)) {
2894 if (mystrncasecmp(argv
[i
],"-unicode",0)) {
2895 SMSInfo
.UnicodeCoding
= true;
2898 if (mystrncasecmp(argv
[i
],"-enablevoice",0)) {
2899 SMSInfo
.Entries
[0].ID
= SMS_EnableVoice
;
2902 if (mystrncasecmp(argv
[i
],"-disablevoice",0)) {
2903 SMSInfo
.Entries
[0].ID
= SMS_DisableVoice
;
2906 if (mystrncasecmp(argv
[i
],"-enablefax",0)) {
2907 SMSInfo
.Entries
[0].ID
= SMS_EnableFax
;
2910 if (mystrncasecmp(argv
[i
],"-disablefax",0)) {
2911 SMSInfo
.Entries
[0].ID
= SMS_DisableFax
;
2914 if (mystrncasecmp(argv
[i
],"-enableemail",0)) {
2915 SMSInfo
.Entries
[0].ID
= SMS_EnableEmail
;
2918 if (mystrncasecmp(argv
[i
],"-disableemail",0)) {
2919 SMSInfo
.Entries
[0].ID
= SMS_DisableEmail
;
2922 if (mystrncasecmp(argv
[i
],"-voidsms",0)) {
2923 SMSInfo
.Entries
[0].ID
= SMS_VoidSMS
;
2926 if (mystrncasecmp(argv
[i
],"-replacemessages",0) &&
2927 SMSInfo
.Entries
[0].ID
!= SMS_ConcatenatedTextLong
) {
2931 if (mystrncasecmp(argv
[i
],"-replacefile",0)) {
2936 if (mystrncasecmp(argv
[2],"PICTURE",0)) {
2937 if (mystrncasecmp(argv
[i
],"-text",0)) {
2941 if (mystrncasecmp(argv
[i
],"-unicode",0)) {
2942 SMSInfo
.UnicodeCoding
= true;
2947 if (mystrncasecmp(argv
[2],"VCARD10",0)) {
2948 if (mystrncasecmp(argv
[i
],"-nokia",0)) {
2949 SMSInfo
.Entries
[0].ID
= SMS_NokiaVCARD10Long
;
2954 if (mystrncasecmp(argv
[2],"VCARD21",0)) {
2955 if (mystrncasecmp(argv
[i
],"-nokia",0)) {
2956 SMSInfo
.Entries
[0].ID
= SMS_NokiaVCARD21Long
;
2961 if (mystrncasecmp(argv
[2],"PROFILE",0)) {
2962 if (mystrncasecmp(argv
[i
],"-name",0)) {
2966 if (mystrncasecmp(argv
[i
],"-ringtone",0)) {
2970 if (mystrncasecmp(argv
[i
],"-bitmap",0)) {
2975 if (mystrncasecmp(argv
[2],"EMS",0)) {
2976 if (mystrncasecmp(argv
[i
],"-unicode",0)) {
2977 SMSInfo
.UnicodeCoding
= true;
2980 if (mystrncasecmp(argv
[i
],"-16bit",0)) {
2984 if (mystrncasecmp(argv
[i
],"-format",0)) {
2988 if (mystrncasecmp(argv
[i
],"-text",0)) {
2992 if (mystrncasecmp(argv
[i
],"-unicodefiletext",0)) {
2996 if (mystrncasecmp(argv
[i
],"-defsound",0)) {
2997 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSPredefinedSound
;
3001 if (mystrncasecmp(argv
[i
],"-defanimation",0)) {
3002 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSPredefinedAnimation
;
3006 if (mystrncasecmp(argv
[i
],"-tone10",0)) {
3007 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound10
;
3008 if (Protected
!= 0) {
3009 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3015 if (mystrncasecmp(argv
[i
],"-tone10long",0)) {
3016 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound10Long
;
3017 if (Protected
!= 0) {
3018 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3024 if (mystrncasecmp(argv
[i
],"-tone12",0)) {
3025 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound12
;
3026 if (Protected
!= 0) {
3027 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3033 if (mystrncasecmp(argv
[i
],"-tone12long",0)) {
3034 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSound12Long
;
3035 if (Protected
!= 0) {
3036 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3042 if (mystrncasecmp(argv
[i
],"-toneSE",0)) {
3043 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSonyEricssonSound
;
3044 if (Protected
!= 0) {
3045 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3051 if (mystrncasecmp(argv
[i
],"-toneSElong",0)) {
3052 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSSonyEricssonSoundLong
;
3053 if (Protected
!= 0) {
3054 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3060 if (mystrncasecmp(argv
[i
],"-fixedbitmap",0)) {
3061 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSFixedBitmap
;
3062 if (Protected
!= 0) {
3063 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3069 if (mystrncasecmp(argv
[i
],"-variablebitmap",0)) {
3070 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSVariableBitmap
;
3071 if (Protected
!= 0) {
3072 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3078 if (mystrncasecmp(argv
[i
],"-variablebitmaplong",0)) {
3079 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSVariableBitmapLong
;
3080 if (Protected
!= 0) {
3081 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3087 if (mystrncasecmp(argv
[i
],"-animation",0)) {
3088 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_EMSAnimation
;
3089 if (Protected
!= 0) {
3090 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Protected
= true;
3093 bitmap
[SMSInfo
.EntriesNum
].Number
= 0;
3098 if (mystrncasecmp(argv
[2],"OPERATOR",0)) {
3099 if (mystrncasecmp(argv
[i
],"-netcode",0)) {
3103 if (mystrncasecmp(argv
[i
],"-biglogo",0)) {
3104 SMSInfo
.Entries
[0].ID
= SMS_NokiaOperatorLogoLong
;
3109 printmsg("Unknown parameter (\"%s\")\n",argv
[i
]);
3112 case 1: /* SMS folder - only during saving SMS */
3113 Folder
= atoi(argv
[i
]);
3116 case 2: /* Sender number - only during saving SMS */
3117 EncodeUnicode(Sender
,argv
[i
],strlen(argv
[i
]));
3120 case 3: /* SMSC set number */
3121 SMSCSet
= atoi(argv
[i
]);
3124 case 4: /* Number of SMSC */
3125 EncodeUnicode(SMSC
,argv
[i
],strlen(argv
[i
]));
3129 case 5: /* Length of text SMS */
3130 if (atoi(argv
[i
])<chars_read
)
3132 Buffer
[0][atoi(argv
[i
])*2] = 0x00;
3133 Buffer
[0][atoi(argv
[i
])*2+1] = 0x00;
3135 SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedTextLong
;
3136 if (mystrncasecmp(argv
[i
-1],"-autolen",0)) SMSInfo
.Entries
[0].ID
= SMS_ConcatenatedAutoTextLong
;
3139 case 6: /* Picture Images - text */
3140 EncodeUnicode(bitmap
[0].Bitmap
[0].Text
,argv
[i
],strlen(argv
[i
]));
3143 case 7: /* Operator Logo - network code */
3144 strncpy(bitmap
[0].Bitmap
[0].NetworkCode
,argv
[i
],7);
3145 if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap
[0].Bitmap
[0].NetworkCode
)),"unknown")) {
3146 printmsg("Unknown GSM network code (\"%s\")\n",argv
[i
]);
3149 if (mystrncasecmp(argv
[1],"--savesms",0)) {
3150 EncodeUnicode(Sender
, "OpLogo",6);
3151 EncodeUnicode(Sender
+6*2,bitmap
[0].Bitmap
[0].NetworkCode
,3);
3152 EncodeUnicode(Sender
+6*2+3*2,bitmap
[0].Bitmap
[0].NetworkCode
+4,2);
3153 if (UnicodeLength(GSM_GetNetworkName(bitmap
[0].Bitmap
[0].NetworkCode
))<GSM_MAX_SMS_NAME_LENGTH
-7) {
3154 EncodeUnicode(Name
,"OpLogo ",7);
3155 CopyUnicodeString(Name
+7*2,GSM_GetNetworkName(bitmap
[0].Bitmap
[0].NetworkCode
));
3157 CopyUnicodeString(Name
,Sender
);
3162 case 8:/* Reject duplicates ID */
3163 SMSInfo
.ReplaceMessage
= atoi(argv
[i
]);
3164 if (SMSInfo
.ReplaceMessage
< 1 || SMSInfo
.ReplaceMessage
> 7) {
3165 printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv
[i
]);
3170 case 9:/* Replace file for text SMS */
3171 ReplaceFile
= fopen(argv
[i
], "rb");
3172 if (ReplaceFile
== NULL
) Print_Error(GE_CANTOPENFILE
);
3173 memset(ReplaceBuffer
,0,sizeof(ReplaceBuffer
));
3174 fread(ReplaceBuffer
,1,sizeof(ReplaceBuffer
),ReplaceFile
);
3175 fclose(ReplaceFile
);
3176 ReadUnicodeFile(ReplaceBuffer2
,ReplaceBuffer
);
3177 for(j
=0;j
<(int)(UnicodeLength(Buffer
[0]));j
++) {
3178 for (z
=0;z
<(int)(UnicodeLength(ReplaceBuffer2
)/2);z
++) {
3179 if (ReplaceBuffer2
[z
*4] == Buffer
[0][j
] &&
3180 ReplaceBuffer2
[z
*4+1] == Buffer
[0][j
+1]) {
3181 Buffer
[0][j
] = ReplaceBuffer2
[z
*4+2];
3182 Buffer
[0][j
+1] = ReplaceBuffer2
[z
*4+3];
3190 Validity
.VPF
= GSM_RelativeFormat
;
3191 if (mystrncasecmp(argv
[i
],"HOUR",0)) Validity
.Relative
= GSMV_1_Hour
;
3192 else if (mystrncasecmp(argv
[i
],"6HOURS",0)) Validity
.Relative
= GSMV_6_Hours
;
3193 else if (mystrncasecmp(argv
[i
],"DAY",0)) Validity
.Relative
= GSMV_24_Hours
;
3194 else if (mystrncasecmp(argv
[i
],"3DAYS",0)) Validity
.Relative
= GSMV_72_Hours
;
3195 else if (mystrncasecmp(argv
[i
],"WEEK",0)) Validity
.Relative
= GSMV_1_Week
;
3196 else if (mystrncasecmp(argv
[i
],"MAX",0)) Validity
.Relative
= GSMV_Max_Time
;
3198 printmsg("Unknown validity string (\"%s\")\n",argv
[i
]);
3203 case 11:/* EMS text from parameter */
3204 EncodeUnicode(Buffer
[SMSInfo
.EntriesNum
],argv
[i
],strlen(argv
[i
]));
3205 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer
[SMSInfo
.EntriesNum
]));
3206 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_ConcatenatedTextLong
;
3207 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Buffer
= Buffer
[SMSInfo
.EntriesNum
];
3208 SMSInfo
.EntriesNum
++;
3211 case 12:/* EMS predefined sound/animation number */
3212 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Number
= atoi(argv
[i
]);
3213 SMSInfo
.EntriesNum
++;
3216 case 14: /* EMS ringtone - IMelody */
3217 ringtone
[SMSInfo
.EntriesNum
].Format
=RING_NOTETONE
;
3218 error
=GSM_ReadRingtoneFile(argv
[i
],&ringtone
[SMSInfo
.EntriesNum
]);
3220 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Ringtone
= &ringtone
[SMSInfo
.EntriesNum
];
3221 SMSInfo
.EntriesNum
++;
3224 case 15:/* EMS bitmap file */
3225 bitmap
[SMSInfo
.EntriesNum
].Bitmap
[0].Type
=GSM_StartupLogo
;
3226 error
=GSM_ReadBitmapFile(argv
[i
],&bitmap
[SMSInfo
.EntriesNum
]);
3228 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Bitmap
= &bitmap
[SMSInfo
.EntriesNum
];
3229 SMSInfo
.EntriesNum
++;
3232 case 16:/* Number of frames for EMS animation */
3233 FramesNum
= atoi(argv
[i
]);
3234 if (FramesNum
< 1 || FramesNum
> 4) {
3235 printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv
[i
]);
3238 bitmap
[SMSInfo
.EntriesNum
].Number
= 0;
3241 case 17:/*File for EMS animation */
3242 bitmap2
.Bitmap
[0].Type
=GSM_StartupLogo
;
3243 error
=GSM_ReadBitmapFile(argv
[i
],&bitmap2
);
3244 for (j
=0;j
<bitmap2
.Number
;j
++) {
3245 if (bitmap
[SMSInfo
.EntriesNum
].Number
== FramesNum
) break;
3246 memcpy(&bitmap
[SMSInfo
.EntriesNum
].Bitmap
[bitmap
[SMSInfo
.EntriesNum
].Number
],&bitmap2
.Bitmap
[j
],sizeof(GSM_Bitmap
));
3247 bitmap
[SMSInfo
.EntriesNum
].Number
++;
3249 if (bitmap
[SMSInfo
.EntriesNum
].Number
== FramesNum
) {
3250 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Bitmap
= &bitmap
[SMSInfo
.EntriesNum
];
3251 SMSInfo
.EntriesNum
++;
3255 case 18:/* EMS text from Unicode file */
3256 f
= fopen(argv
[i
],"rb");
3258 printmsg("Can't open file \"%s\"\n",argv
[i
]);
3261 z
=fread(InputBuffer
,1,2000,f
);
3263 InputBuffer
[z
+1] = 0;
3265 ReadUnicodeFile(Buffer
[SMSInfo
.EntriesNum
],InputBuffer
);
3266 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer
[SMSInfo
.EntriesNum
]));
3267 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].ID
= SMS_ConcatenatedTextLong
;
3268 SMSInfo
.Entries
[SMSInfo
.EntriesNum
].Buffer
= Buffer
[SMSInfo
.EntriesNum
];
3269 SMSInfo
.EntriesNum
++;
3272 case 19:/* Number of protected items */
3273 Protected
= atoi(argv
[i
]);
3276 case 20:/* Formatting text for EMS */
3277 if (SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].ID
== SMS_ConcatenatedTextLong
) {
3278 for(j
=0;j
<(int)strlen(argv
[i
]);j
++) {
3279 switch(argv
[i
][j
]) {
3281 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Left
= true;
3284 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Center
= true;
3287 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Right
= true;
3290 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Large
= true;
3293 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Small
= true;
3296 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Bold
= true;
3299 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Italic
= true;
3302 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Underlined
= true;
3305 SMSInfo
.Entries
[SMSInfo
.EntriesNum
-1].Strikethrough
= true;
3308 printmsg("Unknown parameter \"%c\"\n",argv
[i
][j
]);
3313 printmsg("Last parameter wasn't text\n");
3319 MaxSMS
= atoi(argv
[i
]);
3322 case 22:/* profile name */
3323 EncodeUnicode(Buffer
[0],argv
[i
],strlen(argv
[i
]));
3324 SMSInfo
.Entries
[0].Buffer
= Buffer
[0];
3327 case 23:/* profile ringtone */
3328 ringtone
[0].Format
= RING_NOTETONE
;
3329 error
=GSM_ReadRingtoneFile(argv
[i
],&ringtone
[0]);
3331 SMSInfo
.Entries
[0].Ringtone
= &ringtone
[0];
3334 case 24:/* profile bitmap */
3335 bitmap
[0].Bitmap
[0].Type
= GSM_PictureImage
;
3336 error
=GSM_ReadBitmapFile(argv
[i
],&bitmap
[0]);
3338 bitmap
[0].Bitmap
[0].Text
[0] = 0;
3339 bitmap
[0].Bitmap
[0].Text
[1] = 0;
3340 SMSInfo
.Entries
[0].Bitmap
= &bitmap
[0];
3346 printmsg("Parameter missed...\n");
3350 if (mystrncasecmp(argv
[2],"EMS",0) && EMS16Bit
) {
3351 for (i
=0;i
<SMSInfo
.EntriesNum
;i
++) {
3352 switch (SMSInfo
.Entries
[i
].ID
) {
3353 case SMS_ConcatenatedTextLong
:
3354 SMSInfo
.Entries
[i
].ID
= SMS_ConcatenatedTextLong16bit
;
3362 if (mystrncasecmp(argv
[2],"TEXT",0)) {
3363 chars_read
= UnicodeLength(Buffer
[0]);
3364 if (chars_read
!= 0) {
3365 /* Trim \n at the end of string */
3366 if (Buffer
[0][chars_read
*2-1] == '\n' && Buffer
[0][chars_read
*2-2] == 0)
3368 Buffer
[0][chars_read
*2-1] = 0;
3373 if (mystrncasecmp(argv
[1],"--displaysms",0)) {
3374 if (mystrncasecmp(argv
[2],"OPERATOR",0)) {
3375 if (bitmap
[0].Bitmap
[0].Type
==GSM_OperatorLogo
&& strcmp(bitmap
[0].Bitmap
[0].NetworkCode
,"000 00")==0) {
3376 printmsg("No network code\n");
3383 if (mystrncasecmp(argv
[2],"OPERATOR",0)) {
3384 if (bitmap
[0].Bitmap
[0].Type
==GSM_OperatorLogo
&& strcmp(bitmap
[0].Bitmap
[0].NetworkCode
,"000 00")==0) {
3385 error
=Phone
->GetNetworkInfo(&s
,&NetInfo
);
3387 strcpy(bitmap
[0].Bitmap
[0].NetworkCode
,NetInfo
.NetworkCode
);
3388 if (mystrncasecmp(argv
[1],"--savesms",0)) {
3389 EncodeUnicode(Sender
, "OpLogo",6);
3390 EncodeUnicode(Sender
+6*2,bitmap
[0].Bitmap
[0].NetworkCode
,3);
3391 EncodeUnicode(Sender
+6*2+3*2,bitmap
[0].Bitmap
[0].NetworkCode
+4,2);
3392 if (UnicodeLength(GSM_GetNetworkName(bitmap
[0].Bitmap
[0].NetworkCode
))<GSM_MAX_SMS_NAME_LENGTH
-7) {
3393 EncodeUnicode(Name
,"OpLogo ",7);
3394 CopyUnicodeString(Name
+7*2,GSM_GetNetworkName(bitmap
[0].Bitmap
[0].NetworkCode
));
3396 CopyUnicodeString(Name
,Sender
);
3403 error
=GSM_EncodeMultiPartSMS(&SMSInfo
,&sms
);
3406 for (i
=0;i
<SMSInfo
.EntriesNum
;i
++) {
3407 switch (SMSInfo
.Entries
[i
].ID
) {
3408 case SMS_NokiaRingtone
:
3409 case SMS_NokiaRingtoneLong
:
3410 case SMS_NokiaProfileLong
:
3411 case SMS_EMSSound10
:
3412 case SMS_EMSSound12
:
3413 case SMS_EMSSonyEricssonSound
:
3414 case SMS_EMSSound10Long
:
3415 case SMS_EMSSound12Long
:
3416 case SMS_EMSSonyEricssonSoundLong
:
3417 if (SMSInfo
.Entries
[i
].RingtoneNotes
!=SMSInfo
.Entries
[i
].Ringtone
->NoteTone
.NrCommands
) {
3418 printmsg("Warning: ringtone too long. %i percent part cut\n",
3419 (SMSInfo
.Entries
[i
].Ringtone
->NoteTone
.NrCommands
-SMSInfo
.Entries
[i
].RingtoneNotes
)*100/SMSInfo
.Entries
[i
].Ringtone
->NoteTone
.NrCommands
);
3426 if (MaxSMS
!= -1 && sms
.Number
> MaxSMS
) {
3427 printmsg("There is %i SMS packed and %i limit. Exiting\n",sms
.Number
,MaxSMS
);
3428 if (!mystrncasecmp(argv
[1],"--displaysms",0)) GSM_Terminate();
3432 if (mystrncasecmp(argv
[1],"--displaysms",0)) {
3434 printmsg("Use -smscnumber option to give SMSC number\n");
3438 for (i
=0;i
<sms
.Number
;i
++) {
3439 sms
.SMS
[i
].Location
= 0;
3440 sms
.SMS
[i
].ReplyViaSameSMSC
= ReplyViaSameSMSC
;
3441 sms
.SMS
[i
].SMSC
.Location
= 0;
3442 sms
.SMS
[i
].PDU
= SMS_Submit
;
3443 if (DeliveryReport
) sms
.SMS
[i
].PDU
= SMS_Status_Report
;
3444 CopyUnicodeString(sms
.SMS
[i
].Number
, Sender
);
3445 CopyUnicodeString(sms
.SMS
[i
].SMSC
.Number
, SMSC
);
3446 if (Validity
.VPF
!= 0) memcpy(&sms
.SMS
[i
].SMSC
.Validity
,&Validity
,sizeof(GSM_SMSValidity
));
3447 DisplaySMSFrame(&sms
.SMS
[i
]);
3450 printmsg("\nNumber of SMS: %i\n",sms
.Number
);
3453 if (mystrncasecmp(argv
[1],"--savesms",0)) {
3454 error
=Phone
->GetSMSFolders(&s
, &folders
);
3457 for (i
=0;i
<sms
.Number
;i
++) {
3458 printmsg("Saving SMS %i/%i\n",i
+1,sms
.Number
);
3459 // sms.SMS[i].Location = 0;
3460 sms
.SMS
[i
].Folder
= Folder
;
3461 sms
.SMS
[i
].State
= State
;
3462 sms
.SMS
[i
].ReplyViaSameSMSC
= ReplyViaSameSMSC
;
3463 sms
.SMS
[i
].SMSC
.Location
= SMSCSet
;
3464 sms
.SMS
[i
].PDU
= SMS_Deliver
;
3465 CopyUnicodeString(sms
.SMS
[i
].Number
, Sender
);
3466 CopyUnicodeString(sms
.SMS
[i
].Name
, Name
);
3467 if (SMSCSet
==0) CopyUnicodeString(sms
.SMS
[i
].SMSC
.Number
, SMSC
);
3468 error
=Phone
->AddSMS(&s
, &sms
.SMS
[i
]);
3470 printmsg("Saved in folder \"%s\", location %i\n",
3471 DecodeUnicodeConsole(folders
.Folder
[sms
.SMS
[i
].Folder
-1].Name
),sms
.SMS
[i
].Location
);
3474 if (Validity
.VPF
!= 0 && SMSCSet
!= 0) {
3475 PhoneSMSC
.Location
= SMSCSet
;
3476 error
=Phone
->GetSMSC(&s
,&PhoneSMSC
);
3478 CopyUnicodeString(SMSC
,PhoneSMSC
.Number
);
3482 /* We do not want to make it forever - press Ctrl+C to stop */
3483 signal(SIGINT
, interrupted
);
3484 printmsgerr("If you want break, press Ctrl+C...\n");
3486 s
.User
.SendSMSStatus
= SendSMSStatus
;
3488 for (i
=0;i
<sms
.Number
;i
++) {
3489 printmsg("Sending SMS %i/%i",i
+1,sms
.Number
);
3490 sms
.SMS
[i
].Location
= 0;
3491 sms
.SMS
[i
].ReplyViaSameSMSC
= ReplyViaSameSMSC
;
3492 sms
.SMS
[i
].SMSC
.Location
= SMSCSet
;
3493 sms
.SMS
[i
].PDU
= SMS_Submit
;
3494 if (DeliveryReport
) sms
.SMS
[i
].PDU
= SMS_Status_Report
;
3495 CopyUnicodeString(sms
.SMS
[i
].Number
, Sender
);
3496 if (SMSCSet
==0) CopyUnicodeString(sms
.SMS
[i
].SMSC
.Number
, SMSC
);
3497 if (Validity
.VPF
!= 0) memcpy(&sms
.SMS
[i
].SMSC
.Validity
,&Validity
,sizeof(GSM_SMSValidity
));
3498 SMSStatus
= GE_TIMEOUT
;
3499 error
=Phone
->SendSMS(&s
, &sms
.SMS
[i
]);
3501 printmsg("....waiting for network answer");
3502 while (!bshutdown
) {
3503 GSM_ReadDevice(&s
,true);
3504 if (SMSStatus
== GE_UNKNOWN
) {
3508 if (SMSStatus
== GE_NONE
) break;
3516 #ifdef GSM_ENABLE_BACKUP
3517 static void SaveFile(int argc
, char *argv
[])
3522 unsigned char Buffer
[10000];
3523 GSM_MemoryEntry
*pbk
;
3525 if (mystrncasecmp(argv
[2],"CALENDAR",0)) {
3527 printmsg("Where is backup filename and location ?\n");
3530 error
=GSM_ReadBackupFile(argv
[4],&Backup
);
3533 while (Backup
.Calendar
[i
]!=NULL
) {
3534 if (i
== atoi(argv
[5])-1) break;
3537 if (i
!= atoi(argv
[5])-1) {
3538 printmsg("Calendar note not found in file\n");
3542 GSM_EncodeVCALENDAR(Buffer
, &j
, Backup
.Calendar
[i
],true,Nokia_VCalendar
);
3543 } else if (mystrncasecmp(argv
[2],"BOOKMARK",0)) {
3545 printmsg("Where is backup filename and location ?\n");
3548 error
=GSM_ReadBackupFile(argv
[4],&Backup
);
3551 while (Backup
.WAPBookmark
[i
]!=NULL
) {
3552 if (i
== atoi(argv
[5])-1) break;
3555 if (i
!= atoi(argv
[5])-1) {
3556 printmsg("WAP bookmark not found in file\n");
3560 GSM_EncodeURLFile(Buffer
, &j
, Backup
.WAPBookmark
[i
]);
3561 } else if (mystrncasecmp(argv
[2],"NOTE",0)) {
3563 printmsg("Where is backup filename and location ?\n");
3566 error
=GSM_ReadBackupFile(argv
[4],&Backup
);
3569 while (Backup
.Note
[i
]!=NULL
) {
3570 if (i
== atoi(argv
[5])-1) break;
3573 if (i
!= atoi(argv
[5])-1) {
3574 printmsg("Note not found in file\n");
3578 GSM_EncodeVNTFile(Buffer
, &j
, Backup
.Note
[i
]);
3579 } else if (mystrncasecmp(argv
[2],"TODO",0)) {
3581 printmsg("Where is backup filename and location ?\n");
3584 error
=GSM_ReadBackupFile(argv
[4],&Backup
);
3587 while (Backup
.ToDo
[i
]!=NULL
) {
3588 if (i
== atoi(argv
[5])-1) break;
3591 if (i
!= atoi(argv
[5])-1) {
3592 printmsg("ToDo note not found in file\n");
3596 GSM_EncodeVTODO(Buffer
, &j
, Backup
.ToDo
[i
], true, Nokia_VToDo
);
3597 } else if (mystrncasecmp(argv
[2],"VCARD10",0) || mystrncasecmp(argv
[2],"VCARD21",0)) {
3599 printmsg("Where is backup filename and location and memory type ?\n");
3602 error
=GSM_ReadBackupFile(argv
[4],&Backup
);
3605 if (mystrncasecmp(argv
[5],"SM",0)) {
3606 while (Backup
.SIMPhonebook
[i
]!=NULL
) {
3607 if (i
== atoi(argv
[6])-1) break;
3610 if (i
!= atoi(argv
[6])-1) {
3611 printmsg("Phonebook entry not found in file\n");
3614 pbk
= Backup
.SIMPhonebook
[i
];
3615 } else if (mystrncasecmp(argv
[5],"ME",0)) {
3616 while (Backup
.PhonePhonebook
[i
]!=NULL
) {
3617 if (i
== atoi(argv
[6])-1) break;
3620 if (i
!= atoi(argv
[6])-1) {
3621 printmsg("Phonebook entry not found in file\n");
3624 pbk
= Backup
.PhonePhonebook
[i
];
3626 printmsg("Unknown memory type: \"%s\"\n",argv
[5]);
3630 if (mystrncasecmp(argv
[2],"VCARD10",0)) {
3631 GSM_EncodeVCARD(Buffer
,&j
,pbk
,true,Nokia_VCard10
);
3633 GSM_EncodeVCARD(Buffer
,&j
,pbk
,true,Nokia_VCard21
);
3636 printmsg("What format of file (\"%s\") ?\n",argv
[2]);
3640 file
= fopen(argv
[3],"wb");
3641 fwrite(Buffer
,1,j
,file
);
3645 static void Backup(int argc
, char *argv
[])
3648 GSM_MemoryStatus MemStatus
;
3650 GSM_ToDoStatus ToDoStatus
;
3651 GSM_MemoryEntry Pbk
;
3652 GSM_CalendarEntry Note
;
3654 GSM_WAPBookmark Bookmark
;
3655 GSM_Profile Profile
;
3656 GSM_MultiWAPSettings Settings
;
3657 GSM_Ringtone Ringtone
;
3660 GSM_Backup_Info Info
;
3661 GSM_FMStation FMStation
;
3662 GSM_GPRSAccessPoint GPRSPoint
;
3665 GSM_ClearBackup(&Backup
);
3666 GSM_GetBackupFeatures(argv
[2],&Info
);
3668 /* We do not want to make it forever - press Ctrl+C to stop */
3669 signal(SIGINT
, interrupted
);
3670 printmsgerr("If you want break, press Ctrl+C...\n");
3674 if (Info
.UseUnicode
) {
3675 Info
.UseUnicode
=answer_yes("Use Unicode subformat of backup file");
3677 if (Info
.DateTime
) {
3678 GSM_GetCurrentDateTime (&Backup
.DateTime
);
3679 Backup
.DateTimeAvailable
=true;
3682 error
=Phone
->GetManufacturer(&s
);
3684 sprintf(Backup
.Model
,"%s ",s
.Phone
.Data
.Manufacturer
);
3685 if (s
.Phone
.Data
.ModelInfo
->model
[0]!=0) {
3686 strcat(Backup
.Model
,s
.Phone
.Data
.ModelInfo
->model
);
3688 strcat(Backup
.Model
,s
.Phone
.Data
.Model
);
3690 strcat(Backup
.Model
," ");
3691 strcat(Backup
.Model
,s
.Phone
.Data
.Version
);
3694 error
=Phone
->GetIMEI(&s
);
3695 strcpy(Backup
.IMEI
, s
.Phone
.Data
.IMEI
);
3701 if (Info
.PhonePhonebook
) {
3702 printmsg("Checking phone phonebook\n");
3703 MemStatus
.MemoryType
= GMT_ME
;
3704 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
3705 if (error
==GE_NONE
&& MemStatus
.Used
!= 0) {
3706 if (answer_yes(" Backup phone phonebook")) DoBackup
= true;
3710 Pbk
.MemoryType
= GMT_ME
;
3713 while (used
!= MemStatus
.Used
) {
3715 error
=Phone
->GetMemory(&s
, &Pbk
);
3716 if (error
!= GE_EMPTY
) {
3718 if (used
< GSM_BACKUP_MAX_PHONEPHONEBOOK
) {
3719 Backup
.PhonePhonebook
[used
] = malloc(sizeof(GSM_MemoryEntry
));
3720 if (Backup
.PhonePhonebook
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3721 Backup
.PhonePhonebook
[used
+1] = NULL
;
3723 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK");
3727 *Backup
.PhonePhonebook
[used
]=Pbk
;
3730 printmsgerr("%c Reading: %i percent",13,used
*100/MemStatus
.Used
);
3740 if (Info
.SIMPhonebook
) {
3741 printmsg("Checking SIM phonebook\n");
3742 MemStatus
.MemoryType
= GMT_SM
;
3743 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
3744 if (error
==GE_NONE
&& MemStatus
.Used
!= 0) {
3745 if (answer_yes(" Backup SIM phonebook")) DoBackup
=true;
3749 Pbk
.MemoryType
= GMT_SM
;
3752 while (used
!= MemStatus
.Used
) {
3754 error
=Phone
->GetMemory(&s
, &Pbk
);
3755 if (error
!= GE_EMPTY
) {
3757 if (used
< GSM_BACKUP_MAX_SIMPHONEBOOK
) {
3758 Backup
.SIMPhonebook
[used
] = malloc(sizeof(GSM_MemoryEntry
));
3759 if (Backup
.SIMPhonebook
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3760 Backup
.SIMPhonebook
[used
+ 1] = NULL
;
3762 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK");
3766 *Backup
.SIMPhonebook
[used
]=Pbk
;
3769 printmsgerr("%c Reading: %i percent",13,used
*100/MemStatus
.Used
);
3779 if (Info
.Calendar
) {
3780 printmsg("Checking calendar\n");
3781 error
=Phone
->GetNextCalendar(&s
,&Note
,true);
3782 if (error
==GE_NONE
) {
3783 if (answer_yes(" Backup calendar notes")) DoBackup
= true;
3788 printmsgerr(" Reading : ");
3789 while (error
== GE_NONE
) {
3790 if (used
< GSM_MAXCALENDARTODONOTES
) {
3791 Backup
.Calendar
[used
] = malloc(sizeof(GSM_CalendarEntry
));
3792 if (Backup
.Calendar
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3793 Backup
.Calendar
[used
+1] = NULL
;
3795 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
3799 *Backup
.Calendar
[used
]=Note
;
3801 error
=Phone
->GetNextCalendar(&s
,&Note
,false);
3812 printmsg("Checking ToDo\n");
3813 error
=Phone
->GetToDoStatus(&s
,&ToDoStatus
);
3814 if (error
== GE_NONE
&& ToDoStatus
.Used
!= 0) {
3815 if (answer_yes(" Backup ToDo")) DoBackup
= true;
3820 error
=Phone
->GetNextToDo(&s
,&ToDo
,true);
3821 while (error
== GE_NONE
) {
3822 if (used
< GSM_MAXCALENDARTODONOTES
) {
3823 Backup
.ToDo
[used
] = malloc(sizeof(GSM_ToDoEntry
));
3824 if (Backup
.ToDo
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3825 Backup
.ToDo
[used
+1] = NULL
;
3827 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
3831 *Backup
.ToDo
[used
]=ToDo
;
3833 error
=Phone
->GetNextToDo(&s
,&ToDo
,false);
3834 printmsgerr("%c Reading: %i percent",13,used
*100/ToDoStatus
.Used
);
3843 if (Info
.CallerLogos
) {
3844 printmsg("Checking caller logos\n");
3845 Bitmap
.Type
= GSM_CallerLogo
;
3846 Bitmap
.Location
= 1;
3847 error
=Phone
->GetBitmap(&s
,&Bitmap
);
3848 if (error
== GE_NONE
) {
3849 if (answer_yes(" Backup caller groups and logos")) DoBackup
= true;
3853 printmsgerr(" Reading : ");
3856 while (error
== GE_NONE
) {
3857 if (used
< GSM_BACKUP_MAX_CALLER
) {
3858 Backup
.CallerLogos
[used
] = malloc(sizeof(GSM_Bitmap
));
3859 if (Backup
.CallerLogos
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3860 Backup
.CallerLogos
[used
+1] = NULL
;
3862 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER");
3866 *Backup
.CallerLogos
[used
] = Bitmap
;
3868 Bitmap
.Location
= used
+ 1;
3869 error
=Phone
->GetBitmap(&s
,&Bitmap
);
3880 printmsg("Checking SMS profiles\n");
3881 if (answer_yes(" Backup SMS profiles")) DoBackup
= true;
3885 printmsgerr(" Reading: ");
3887 SMSC
.Location
= used
+ 1;
3888 error
= Phone
->GetSMSC(&s
,&SMSC
);
3889 if (error
!= GE_NONE
) break;
3890 if (used
< GSM_BACKUP_MAX_SMSC
) {
3891 Backup
.SMSC
[used
] = malloc(sizeof(GSM_SMSC
));
3892 if (Backup
.SMSC
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3893 Backup
.SMSC
[used
+ 1] = NULL
;
3895 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC");
3899 *Backup
.SMSC
[used
]=SMSC
;
3906 if (Info
.StartupLogo
) {
3907 printmsg("Checking startup text\n");
3908 Bitmap
.Type
= GSM_WelcomeNoteText
;
3909 error
= Phone
->GetBitmap(&s
,&Bitmap
);
3910 if (error
== GE_NONE
) {
3911 if (answer_yes(" Backup startup logo/text")) DoBackup
= true;
3915 Backup
.StartupLogo
= malloc(sizeof(GSM_Bitmap
));
3916 if (Backup
.StartupLogo
== NULL
) Print_Error(GE_MOREMEMORY
);
3917 *Backup
.StartupLogo
= Bitmap
;
3918 if (Bitmap
.Text
[0]==0 && Bitmap
.Text
[1]==0) {
3919 Bitmap
.Type
= GSM_StartupLogo
;
3920 error
= Phone
->GetBitmap(&s
,&Bitmap
);
3921 if (error
== GE_NONE
) *Backup
.StartupLogo
= Bitmap
;
3925 if (Info
.OperatorLogo
) {
3926 printmsg("Checking operator logo\n");
3927 Bitmap
.Type
= GSM_OperatorLogo
;
3928 error
=Phone
->GetBitmap(&s
,&Bitmap
);
3929 if (error
== GE_NONE
) {
3930 if (strcmp(Bitmap
.NetworkCode
,"000 00")!=0) {
3931 if (answer_yes(" Backup operator logo")) DoBackup
= true;
3936 Backup
.OperatorLogo
= malloc(sizeof(GSM_Bitmap
));
3937 if (Backup
.OperatorLogo
== NULL
) Print_Error(GE_MOREMEMORY
);
3938 *Backup
.OperatorLogo
= Bitmap
;
3941 if (Info
.WAPBookmark
) {
3942 printmsg("Checking WAP bookmarks\n");
3943 Bookmark
.Location
= 1;
3944 error
=Phone
->GetWAPBookmark(&s
,&Bookmark
);
3945 if (error
==GE_NONE
) {
3946 if (answer_yes(" Backup WAP bookmarks")) DoBackup
= true;
3951 printmsgerr(" Reading : ");
3952 while (error
== GE_NONE
) {
3953 if (used
< GSM_BACKUP_MAX_WAPBOOKMARK
) {
3954 Backup
.WAPBookmark
[used
] = malloc(sizeof(GSM_WAPBookmark
));
3955 if (Backup
.WAPBookmark
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3956 Backup
.WAPBookmark
[used
+1] = NULL
;
3958 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
3962 *Backup
.WAPBookmark
[used
]=Bookmark
;
3964 Bookmark
.Location
= used
+1;
3965 error
=Phone
->GetWAPBookmark(&s
,&Bookmark
);
3975 if (Info
.WAPSettings
) {
3976 printmsg("Checking WAP settings\n");
3977 Settings
.Location
= 1;
3978 error
=Phone
->GetWAPSettings(&s
,&Settings
);
3979 if (error
==GE_NONE
) {
3980 if (answer_yes(" Backup WAP settings")) DoBackup
= true;
3985 printmsgerr(" Reading : ");
3986 while (error
== GE_NONE
) {
3987 if (used
< GSM_BACKUP_MAX_WAPSETTINGS
) {
3988 Backup
.WAPSettings
[used
] = malloc(sizeof(GSM_MultiWAPSettings
));
3989 if (Backup
.WAPSettings
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
3990 Backup
.WAPSettings
[used
+1] = NULL
;
3992 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
3996 *Backup
.WAPSettings
[used
]=Settings
;
3998 Settings
.Location
= used
+1;
3999 error
=Phone
->GetWAPSettings(&s
,&Settings
);
4009 if (Info
.MMSSettings
) {
4010 printmsg("Checking MMS settings\n");
4011 Settings
.Location
= 1;
4012 error
=Phone
->GetMMSSettings(&s
,&Settings
);
4013 if (error
==GE_NONE
) {
4014 if (answer_yes(" Backup MMS settings")) DoBackup
= true;
4019 printmsgerr(" Reading : ");
4020 while (error
== GE_NONE
) {
4021 if (used
< GSM_BACKUP_MAX_MMSSETTINGS
) {
4022 Backup
.MMSSettings
[used
] = malloc(sizeof(GSM_MultiWAPSettings
));
4023 if (Backup
.MMSSettings
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
4024 Backup
.MMSSettings
[used
+1] = NULL
;
4026 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS");
4030 *Backup
.MMSSettings
[used
]=Settings
;
4032 Settings
.Location
= used
+1;
4033 error
=Phone
->GetMMSSettings(&s
,&Settings
);
4043 if (Info
.Ringtone
) {
4044 printmsg("Checking user ringtones\n");
4045 Ringtone
.Location
= 1;
4046 Ringtone
.Format
= 0;
4047 error
=Phone
->GetRingtone(&s
,&Ringtone
,false);
4048 if (error
==GE_EMPTY
|| error
== GE_NONE
) {
4049 if (answer_yes(" Backup user ringtones")) DoBackup
= true;
4055 printmsgerr(" Reading : ");
4056 while (error
== GE_NONE
|| error
== GE_EMPTY
) {
4057 if (error
== GE_NONE
) {
4058 if (used
< GSM_BACKUP_MAX_RINGTONES
) {
4059 Backup
.Ringtone
[used
] = malloc(sizeof(GSM_Ringtone
));
4060 if (Backup
.Ringtone
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
4061 Backup
.Ringtone
[used
+1] = NULL
;
4063 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES");
4067 *Backup
.Ringtone
[used
]=Ringtone
;
4071 Ringtone
.Location
= i
;
4072 Ringtone
.Format
= 0;
4073 error
=Phone
->GetRingtone(&s
,&Ringtone
,false);
4083 if (Info
.Profiles
) {
4084 printmsg("Checking phone profiles\n");
4085 Profile
.Location
= 1;
4086 error
= Phone
->GetProfile(&s
,&Profile
);
4087 if (error
== GE_NONE
) {
4088 if (answer_yes(" Backup phone profiles")) DoBackup
= true;
4093 printmsgerr(" Reading: ");
4095 Profile
.Location
= used
+ 1;
4096 error
= Phone
->GetProfile(&s
,&Profile
);
4097 if (error
!= GE_NONE
) break;
4098 if (used
< GSM_BACKUP_MAX_PROFILES
) {
4099 Backup
.Profiles
[used
] = malloc(sizeof(GSM_Profile
));
4100 if (Backup
.Profiles
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
4101 Backup
.Profiles
[used
+ 1] = NULL
;
4103 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES");
4107 *Backup
.Profiles
[used
]=Profile
;
4114 if (Info
.FMStation
) {
4115 printmsg("Checking FM stations\n");
4116 FMStation
.Location
= 1;
4117 error
= Phone
->GetFMStation(&s
,&FMStation
);
4118 if (error
== GE_NONE
|| error
== GE_EMPTY
) {
4119 if (answer_yes(" Backup phone FM stations")) DoBackup
=true;
4125 printmsgerr(" Reading: ");
4126 while (error
== GE_NONE
|| error
== GE_EMPTY
) {
4127 error
= Phone
->GetFMStation(&s
,&FMStation
);
4128 if (error
== GE_NONE
) {
4129 if (used
< GSM_BACKUP_MAX_FMSTATIONS
) {
4130 Backup
.FMStation
[used
] = malloc(sizeof(GSM_FMStation
));
4131 if (Backup
.FMStation
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
4132 Backup
.FMStation
[used
+ 1] = NULL
;
4134 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS");
4138 *Backup
.FMStation
[used
]=FMStation
;
4142 FMStation
.Location
= i
;
4148 if (Info
.GPRSPoint
) {
4149 printmsg("Checking GPRS access points\n");
4150 GPRSPoint
.Location
= 1;
4151 error
= Phone
->GetGPRSAccessPoint(&s
,&GPRSPoint
);
4152 if (error
== GE_NONE
|| error
== GE_EMPTY
) {
4153 if (answer_yes(" Backup GPRS access points")) DoBackup
= true;
4159 printmsgerr(" Reading: ");
4160 while (error
== GE_NONE
|| error
== GE_EMPTY
) {
4161 error
= Phone
->GetGPRSAccessPoint(&s
,&GPRSPoint
);
4162 if (error
== GE_NONE
) {
4163 if (used
< GSM_BACKUP_MAX_GPRSPOINT
) {
4164 Backup
.GPRSPoint
[used
] = malloc(sizeof(GSM_GPRSAccessPoint
));
4165 if (Backup
.GPRSPoint
[used
] == NULL
) Print_Error(GE_MOREMEMORY
);
4166 Backup
.GPRSPoint
[used
+ 1] = NULL
;
4168 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT");
4172 *Backup
.GPRSPoint
[used
]=GPRSPoint
;
4176 GPRSPoint
.Location
= i
;
4184 GSM_SaveBackupFile(argv
[2],&Backup
, Info
.UseUnicode
);
4185 GSM_FreeBackup(&Backup
);
4188 static void Restore(int argc
, char *argv
[])
4191 GSM_FMStation FMStation
;
4192 GSM_DateTime date_time
;
4193 GSM_CalendarEntry Calendar
;
4195 GSM_Ringtone Ringtone
;
4196 GSM_MemoryEntry Pbk
;
4197 GSM_MemoryStatus MemStatus
;
4199 GSM_ToDoStatus ToDoStatus
;
4200 GSM_Profile Profile
;
4201 GSM_MultiWAPSettings Settings
;
4202 GSM_GPRSAccessPoint GPRSPoint
;
4203 GSM_WAPBookmark Bookmark
;
4204 int i
, used
, max
= 0;
4206 bool Found
, DoRestore
;
4208 error
=GSM_ReadBackupFile(argv
[2],&Backup
);
4211 /* We do not want to make it forever - press Ctrl+C to stop */
4212 signal(SIGINT
, interrupted
);
4213 printmsgerr("If you want break, press Ctrl+C...\n");
4215 if (Backup
.DateTimeAvailable
) printmsgerr("Time of backup : %s\n",OSDateTime(Backup
.DateTime
,false));
4216 if (Backup
.Model
[0]!=0) printmsgerr("Phone : %s\n",Backup
.Model
);
4217 if (Backup
.IMEI
[0]!=0) printmsgerr("IMEI : %s\n",Backup
.IMEI
);
4219 if (Backup
.MD5Calculated
[0]!=0) {
4220 dbgprintf("\"%s\"\n",Backup
.MD5Original
);
4221 dbgprintf("\"%s\"\n",Backup
.MD5Calculated
);
4222 if (strcmp(Backup
.MD5Original
,Backup
.MD5Calculated
)) {
4223 if (!answer_yes("Checksum in backup file do not match. Continue")) return;
4230 if (Backup
.PhonePhonebook
[0] != NULL
) {
4231 MemStatus
.MemoryType
= GMT_ME
;
4232 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
4233 if (error
==GE_NONE
) {
4235 while (Backup
.PhonePhonebook
[max
]!=NULL
) max
++;
4236 printmsgerr("%i entries in backup file\n",max
);
4237 if (answer_yes("Restore phone phonebook")) DoRestore
= true;
4242 for (i
=0;i
<MemStatus
.Used
+MemStatus
.Free
;i
++) {
4243 Pbk
.MemoryType
= GMT_ME
;
4244 Pbk
.Location
= i
+ 1;
4247 if (Backup
.PhonePhonebook
[used
]->Location
== Pbk
.Location
) {
4248 Pbk
= *Backup
.PhonePhonebook
[used
];
4250 dbgprintf("Location %i\n",Pbk
.Location
);
4251 if (Pbk
.EntriesNum
!= 0) error
=Phone
->SetMemory(&s
, &Pbk
);
4254 if (Pbk
.EntriesNum
== 0) error
=Phone
->DeleteMemory(&s
, &Pbk
);
4256 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/(MemStatus
.Used
+MemStatus
.Free
));
4266 if (Backup
.SIMPhonebook
[0] != NULL
) {
4267 MemStatus
.MemoryType
= GMT_SM
;
4268 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
4269 if (error
==GE_NONE
) {
4271 while (Backup
.SIMPhonebook
[max
]!=NULL
) max
++;
4272 printmsgerr("%i entries in backup file\n",max
);
4273 if (answer_yes("Restore SIM phonebook")) DoRestore
= true;
4278 for (i
=0;i
<MemStatus
.Used
+MemStatus
.Free
;i
++) {
4279 Pbk
.MemoryType
= GMT_SM
;
4280 Pbk
.Location
= i
+ 1;
4283 if (Backup
.SIMPhonebook
[used
]->Location
== Pbk
.Location
) {
4284 Pbk
= *Backup
.SIMPhonebook
[used
];
4286 dbgprintf("Location %i\n",Pbk
.Location
);
4287 if (Pbk
.EntriesNum
!= 0) error
=Phone
->SetMemory(&s
, &Pbk
);
4290 if (Pbk
.EntriesNum
== 0) error
=Phone
->DeleteMemory(&s
, &Pbk
);
4292 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/(MemStatus
.Used
+MemStatus
.Free
));
4302 if (Backup
.CallerLogos
[0] != NULL
) {
4303 Bitmap
.Type
= GSM_CallerLogo
;
4304 Bitmap
.Location
= 1;
4305 error
=Phone
->GetBitmap(&s
,&Bitmap
);
4306 if (error
== GE_NONE
) {
4307 if (answer_yes("Restore caller groups and logos")) DoRestore
= true;
4312 while (Backup
.CallerLogos
[max
]!=NULL
) max
++;
4313 for (i
=0;i
<max
;i
++) {
4314 error
=Phone
->SetBitmap(&s
,Backup
.CallerLogos
[i
]);
4316 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4325 if (!mystrncasecmp(s
.CurrentConfig
->SyncTime
,"yes",0)) {
4326 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)")) {
4327 GSM_GetCurrentDateTime(&date_time
);
4329 error
=Phone
->SetDateTime(&s
, &date_time
);
4334 if (Backup
.Calendar
[0] != NULL
) {
4335 /* N6110 doesn't support getting calendar status */
4336 error
= Phone
->GetNextCalendar(&s
,&Calendar
,true);
4337 if (error
== GE_NONE
|| error
== GE_INVALIDLOCATION
|| error
== GE_EMPTY
) {
4339 while (Backup
.Calendar
[max
] != NULL
) max
++;
4340 printmsgerr("%i entries in backup file\n",max
);
4341 if (answer_yes("Restore calendar notes")) {
4342 Past
= answer_yes("Restore notes from the past");
4348 printmsgerr("Deleting old notes: ");
4349 error
= Phone
->DeleteAllCalendar(&s
);
4350 if (error
== GE_NOTSUPPORTED
|| error
== GE_NOTIMPLEMENTED
) {
4352 error
= Phone
->GetNextCalendar(&s
,&Calendar
,true);
4353 if (error
!= GE_NONE
) break;
4354 error
= Phone
->DeleteCalendar(&s
,&Calendar
);
4360 printmsgerr("Done\n");
4364 for (i
=0;i
<max
;i
++) {
4365 if (!Past
&& IsCalendarNoteFromThePast(Backup
.Calendar
[i
])) continue;
4367 Calendar
= *Backup
.Calendar
[i
];
4368 error
=Phone
->AddCalendar(&s
,&Calendar
);
4370 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4380 if (Backup
.ToDo
[0] != NULL
) {
4381 error
= Phone
->GetToDoStatus(&s
,&ToDoStatus
);
4382 if (error
== GE_NONE
) {
4384 while (Backup
.ToDo
[max
]!=NULL
) max
++;
4385 printmsgerr("%i entries in backup file\n",max
);
4387 if (answer_yes("Restore ToDo")) DoRestore
= true;
4391 ToDo
= *Backup
.ToDo
[0];
4392 error
= Phone
->SetToDo(&s
,&ToDo
);
4394 if (DoRestore
&& (error
== GE_NOTSUPPORTED
|| error
== GE_NOTIMPLEMENTED
)) {
4395 printmsgerr("Deleting old ToDo: ");
4396 error
=Phone
->DeleteAllToDo(&s
);
4397 if (error
== GE_NOTSUPPORTED
|| error
== GE_NOTIMPLEMENTED
) {
4399 error
= Phone
->GetNextToDo(&s
,&ToDo
,true);
4400 if (error
!= GE_NONE
) break;
4401 error
= Phone
->DeleteToDo(&s
,&ToDo
);
4407 printmsgerr("Done\n");
4411 for (i
=0;i
<max
;i
++) {
4412 ToDo
= *Backup
.ToDo
[i
];
4414 error
=Phone
->AddToDo(&s
,&ToDo
);
4416 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4423 } else if (DoRestore
) {
4424 /* At first delete entries, that were deleted */
4426 error
= Phone
->GetNextToDo(&s
,&ToDo
,true);
4427 while (error
== GE_NONE
) {
4430 for (i
=0;i
<max
;i
++) {
4431 if (Backup
.ToDo
[i
]->Location
== ToDo
.Location
) {
4437 error
=Phone
->DeleteToDo(&s
,&ToDo
);
4440 error
= Phone
->GetNextToDo(&s
,&ToDo
,false);
4441 printmsgerr("%cCleaning: %i percent",13,used
*100/ToDoStatus
.Used
);
4449 /* Now write modified/new entries */
4450 for (i
=0;i
<max
;i
++) {
4451 ToDo
= *Backup
.ToDo
[i
];
4452 error
= Phone
->SetToDo(&s
,&ToDo
);
4454 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4463 if (Backup
.SMSC
[0] != NULL
&& answer_yes("Restore SMSC profiles")) {
4465 while (Backup
.SMSC
[max
]!=NULL
) max
++;
4466 for (i
=0;i
<max
;i
++) {
4467 error
=Phone
->SetSMSC(&s
,Backup
.SMSC
[i
]);
4469 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4477 if (Backup
.StartupLogo
!= NULL
&& answer_yes("Restore startup logo/text")) {
4478 error
=Phone
->SetBitmap(&s
,Backup
.StartupLogo
);
4481 if (Backup
.OperatorLogo
!= NULL
&& answer_yes("Restore operator logo")) {
4482 error
=Phone
->SetBitmap(&s
,Backup
.OperatorLogo
);
4486 if (Backup
.WAPBookmark
[0] != NULL
) {
4487 Bookmark
.Location
= 1;
4488 error
= Phone
->GetWAPBookmark(&s
,&Bookmark
);
4489 if (error
== GE_NONE
|| error
== GE_INVALIDLOCATION
) {
4490 if (answer_yes("Restore WAP bookmarks")) DoRestore
= true;
4494 printmsgerr("Deleting old bookmarks: ");
4495 /* One thing to explain: DCT4 phones seems to have bug here.
4496 * When delete for example first bookmark, phone change
4497 * numeration for getting frame, not for deleting. So, we try to
4498 * get 1'st bookmark. Inside frame is "correct" location. We use
4501 while (error
==GE_NONE
) {
4502 error
= Phone
->DeleteWAPBookmark(&s
,&Bookmark
);
4503 Bookmark
.Location
= 1;
4504 error
= Phone
->GetWAPBookmark(&s
,&Bookmark
);
4509 while (Backup
.WAPBookmark
[max
]!=NULL
) max
++;
4510 for (i
=0;i
<max
;i
++) {
4511 Bookmark
= *Backup
.WAPBookmark
[i
];
4512 Bookmark
.Location
= 0;
4513 error
=Phone
->SetWAPBookmark(&s
,&Bookmark
);
4515 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4524 if (Backup
.WAPSettings
[0] != NULL
) {
4525 Settings
.Location
= 1;
4526 error
= Phone
->GetWAPSettings(&s
,&Settings
);
4527 if (error
== GE_NONE
) {
4528 if (answer_yes("Restore WAP settings")) DoRestore
= true;
4533 while (Backup
.WAPSettings
[max
]!=NULL
) max
++;
4534 for (i
=0;i
<max
;i
++) {
4535 error
=Phone
->SetWAPSettings(&s
,Backup
.WAPSettings
[i
]);
4537 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4546 if (Backup
.MMSSettings
[0] != NULL
) {
4547 Settings
.Location
= 1;
4548 error
= Phone
->GetMMSSettings(&s
,&Settings
);
4549 if (error
== GE_NONE
) {
4550 if (answer_yes("Restore MMS settings")) DoRestore
= true;
4555 while (Backup
.MMSSettings
[max
]!=NULL
) max
++;
4556 for (i
=0;i
<max
;i
++) {
4557 error
=Phone
->SetMMSSettings(&s
,Backup
.MMSSettings
[i
]);
4559 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4568 if (Backup
.Ringtone
[0] != NULL
) {
4569 Ringtone
.Location
= 1;
4570 Ringtone
.Format
= 0;
4571 error
= Phone
->GetRingtone(&s
,&Ringtone
,false);
4572 if (error
== GE_NONE
|| error
==GE_EMPTY
) {
4573 if (Phone
->DeleteUserRingtones
!= NOTSUPPORTED
) {
4574 if (answer_yes("Delete all user ringtones")) DoRestore
= true;
4579 printmsgerr("Deleting: ");
4580 error
=Phone
->DeleteUserRingtones(&s
);
4582 printmsgerr("Done\n");
4584 if (answer_yes("Restore user ringtones")) DoRestore
= true;
4588 while (Backup
.Ringtone
[max
]!=NULL
) max
++;
4589 for (i
=0;i
<max
;i
++) {
4590 error
=GSM_RingtoneConvert(&Ringtone
, Backup
.Ringtone
[i
], Ringtone
.Format
);
4592 error
=Phone
->SetRingtone(&s
,&Ringtone
,&i
);
4594 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4603 if (Backup
.Profiles
[0] != NULL
) {
4604 Profile
.Location
= 1;
4605 error
= Phone
->GetProfile(&s
,&Profile
);
4606 if (error
== GE_NONE
) {
4607 if (answer_yes("Restore profiles")) DoRestore
= true;
4611 Profile
.Location
= 0;
4613 while (Backup
.Profiles
[max
]!=NULL
) max
++;
4614 for (i
=0;i
<max
;i
++) {
4615 Profile
= *Backup
.Profiles
[i
];
4616 error
=Phone
->SetProfile(&s
,&Profile
);
4626 if (Backup
.FMStation
[0] != NULL
) {
4627 FMStation
.Location
= 1;
4628 error
= Phone
->GetFMStation(&s
,&FMStation
);
4629 if (error
== GE_NONE
|| error
== GE_EMPTY
) {
4630 if (answer_yes("Restore FM stations")) DoRestore
= true;
4634 printmsgerr("Deleting old FM stations: ");
4635 error
=Phone
->ClearFMStations(&s
);
4637 printmsgerr("Done\n");
4639 while (Backup
.FMStation
[max
]!=NULL
) max
++;
4640 for (i
=0;i
<max
;i
++) {
4641 FMStation
= *Backup
.FMStation
[i
];
4642 error
=Phone
->SetFMStation(&s
,&FMStation
);
4644 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4653 if (Backup
.GPRSPoint
[0] != NULL
) {
4654 GPRSPoint
.Location
= 1;
4655 error
= Phone
->GetGPRSAccessPoint(&s
,&GPRSPoint
);
4656 if (error
== GE_NONE
|| error
== GE_EMPTY
) {
4657 if (answer_yes("Restore GPRS Points")) DoRestore
= true;
4662 while (Backup
.GPRSPoint
[max
]!=NULL
) max
++;
4663 for (i
=0;i
<max
;i
++) {
4664 error
=Phone
->SetGPRSAccessPoint(&s
,Backup
.GPRSPoint
[i
]);
4666 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4678 static void AddNew(int argc
, char *argv
[])
4681 GSM_DateTime date_time
;
4682 GSM_MemoryEntry Pbk
;
4683 GSM_MemoryStatus MemStatus
;
4685 GSM_ToDoStatus ToDoStatus
;
4686 GSM_CalendarEntry Calendar
;
4687 GSM_WAPBookmark Bookmark
;
4690 error
=GSM_ReadBackupFile(argv
[2],&Backup
);
4693 /* We do not want to make it forever - press Ctrl+C to stop */
4694 signal(SIGINT
, interrupted
);
4695 printmsgerr("If you want break, press Ctrl+C...\n");
4697 if (Backup
.DateTimeAvailable
) printmsgerr("Time of backup : %s\n",OSDateTime(Backup
.DateTime
,false));
4698 if (Backup
.Model
[0]!=0) printmsgerr("Phone : %s\n",Backup
.Model
);
4699 if (Backup
.IMEI
[0]!=0) printmsgerr("IMEI : %s\n",Backup
.IMEI
);
4703 if (Backup
.PhonePhonebook
[0] != NULL
) {
4704 MemStatus
.MemoryType
= GMT_ME
;
4705 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
4706 if (error
==GE_NONE
) {
4708 while (Backup
.PhonePhonebook
[max
]!=NULL
) max
++;
4709 printmsgerr("%i entries in backup file\n",max
);
4710 if (MemStatus
.Free
< max
) {
4711 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus
.Free
);
4712 } else if (answer_yes("Add phone phonebook entries")) {
4713 for (i
=0;i
<max
;i
++) {
4714 Pbk
= *Backup
.PhonePhonebook
[i
];
4715 Pbk
.MemoryType
= GMT_ME
;
4716 error
=Phone
->AddMemory(&s
, &Pbk
);
4718 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4728 if (Backup
.SIMPhonebook
[0] != NULL
) {
4729 MemStatus
.MemoryType
= GMT_SM
;
4730 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
4731 if (error
==GE_NONE
) {
4733 while (Backup
.SIMPhonebook
[max
]!=NULL
) max
++;
4734 printmsgerr("%i entries in backup file\n",max
);
4735 if (MemStatus
.Free
< max
) {
4736 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus
.Free
);
4737 } else if (answer_yes("Add SIM phonebook entries")) {
4739 for (i
=0;i
<max
;i
++) {
4740 Pbk
= *Backup
.SIMPhonebook
[i
];
4741 Pbk
.MemoryType
= GMT_SM
;
4742 error
=Phone
->AddMemory(&s
, &Pbk
);
4744 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4755 if (!mystrncasecmp(s
.CurrentConfig
->SyncTime
,"yes",0)) {
4756 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)")) {
4757 GSM_GetCurrentDateTime(&date_time
);
4759 error
=Phone
->SetDateTime(&s
, &date_time
);
4763 if (Backup
.Calendar
[0] != NULL
) {
4764 error
= Phone
->GetNextCalendar(&s
,&Calendar
,true);
4765 if (error
== GE_NONE
|| error
== GE_INVALIDLOCATION
|| error
== GE_EMPTY
) {
4766 if (answer_yes("Add calendar notes")) {
4768 while (Backup
.Calendar
[max
]!=NULL
) max
++;
4769 for (i
=0;i
<max
;i
++) {
4770 Calendar
= *Backup
.Calendar
[i
];
4771 error
=Phone
->AddCalendar(&s
,&Calendar
);
4773 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4783 if (Backup
.ToDo
[0] != NULL
) {
4785 error
=Phone
->GetToDoStatus(&s
,&ToDoStatus
);
4786 if (error
== GE_NONE
) {
4787 if (answer_yes("Add ToDo")) {
4789 while (Backup
.ToDo
[max
]!=NULL
) max
++;
4790 for (i
=0;i
<max
;i
++) {
4791 ToDo
= *Backup
.ToDo
[i
];
4792 error
= Phone
->AddToDo(&s
,&ToDo
);
4794 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4804 if (Backup
.WAPBookmark
[0] != NULL
) {
4805 Bookmark
.Location
= 1;
4806 error
= Phone
->GetWAPBookmark(&s
,&Bookmark
);
4807 if (error
== GE_NONE
|| error
== GE_INVALIDLOCATION
) {
4808 if (answer_yes("Add WAP bookmarks")) {
4810 while (Backup
.WAPBookmark
[max
]!=NULL
) max
++;
4811 for (i
=0;i
<max
;i
++) {
4812 Bookmark
= *Backup
.WAPBookmark
[i
];
4813 Bookmark
.Location
= 0;
4814 error
=Phone
->SetWAPBookmark(&s
,&Bookmark
);
4816 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/max
);
4831 static void ClearAll(int argc
, char *argv
[])
4833 GSM_MemoryStatus MemStatus
;
4834 GSM_ToDoStatus ToDoStatus
;
4835 GSM_CalendarEntry Calendar
;
4837 GSM_WAPBookmark Bookmark
;
4838 GSM_FMStation Station
;
4839 GSM_MemoryEntry Pbk
;
4845 MemStatus
.MemoryType
= GMT_ME
;
4846 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
4847 if (error
==GE_NONE
&& MemStatus
.Used
!=0) {
4848 if (answer_yes("Delete phone phonebook")) DoClear
= true;
4851 error
= Phone
->DeleteAllMemory(&s
,GMT_ME
);
4852 if (error
== GE_NOTSUPPORTED
|| error
== GE_NOTIMPLEMENTED
) {
4853 for (i
=0;i
<MemStatus
.Used
+MemStatus
.Free
;i
++) {
4854 Pbk
.MemoryType
= GMT_ME
;
4855 Pbk
.Location
= i
+ 1;
4857 error
=Phone
->DeleteMemory(&s
, &Pbk
);
4859 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/(MemStatus
.Used
+MemStatus
.Free
));
4867 printmsgerr("Done\n");
4873 MemStatus
.MemoryType
= GMT_SM
;
4874 error
=Phone
->GetMemoryStatus(&s
, &MemStatus
);
4875 if (error
==GE_NONE
&& MemStatus
.Used
!=0) {
4876 if (answer_yes("Delete SIM phonebook")) DoClear
= true;
4879 error
= Phone
->DeleteAllMemory(&s
,GMT_SM
);
4880 if (error
== GE_NOTSUPPORTED
|| error
== GE_NOTIMPLEMENTED
) {
4881 for (i
=0;i
<MemStatus
.Used
+MemStatus
.Free
;i
++) {
4882 Pbk
.MemoryType
= GMT_SM
;
4883 Pbk
.Location
= i
+ 1;
4885 error
=Phone
->DeleteMemory(&s
, &Pbk
);
4887 printmsgerr("%cWriting: %i percent",13,(i
+1)*100/(MemStatus
.Used
+MemStatus
.Free
));
4895 printmsgerr("Done\n");
4901 error
= Phone
->GetNextCalendar(&s
,&Calendar
,true);
4902 if (error
== GE_NONE
) {
4903 if (answer_yes("Delete calendar notes")) DoClear
= true;
4906 printmsgerr("Deleting: ");
4907 error
=Phone
->DeleteAllCalendar(&s
);
4908 if (error
== GE_NOTSUPPORTED
|| error
== GE_NOTIMPLEMENTED
) {
4910 error
= Phone
->GetNextCalendar(&s
,&Calendar
,true);
4911 if (error
!= GE_NONE
) break;
4912 error
= Phone
->DeleteCalendar(&s
,&Calendar
);
4918 printmsgerr("Done\n");
4924 error
= Phone
->GetToDoStatus(&s
,&ToDoStatus
);
4925 if (error
== GE_NONE
&& ToDoStatus
.Used
!= 0) {
4926 if (answer_yes("Delete ToDo")) DoClear
= true;
4929 printmsgerr("Deleting: ");
4930 error
=Phone
->DeleteAllToDo(&s
);
4931 if (error
== GE_NOTSUPPORTED
|| error
== GE_NOTIMPLEMENTED
) {
4933 error
= Phone
->GetNextToDo(&s
,&ToDo
,true);
4934 if (error
!= GE_NONE
) break;
4935 error
= Phone
->DeleteToDo(&s
,&ToDo
);
4941 printmsgerr("Done\n");
4946 Bookmark
.Location
= 1;
4947 error
= Phone
->GetWAPBookmark(&s
,&Bookmark
);
4948 if (error
== GE_NONE
|| error
== GE_INVALIDLOCATION
) {
4949 if (answer_yes("Delete WAP bookmarks")) {
4950 printmsgerr("Deleting: ");
4951 /* One thing to explain: DCT4 phones seems to have bug here.
4952 * When delete for example first bookmark, phone change
4953 * numeration for getting frame, not for deleting. So, we try to
4954 * get 1'st bookmark. Inside frame is "correct" location. We use
4957 while (error
==GE_NONE
) {
4958 error
= Phone
->DeleteWAPBookmark(&s
,&Bookmark
);
4959 Bookmark
.Location
= 1;
4960 error
= Phone
->GetWAPBookmark(&s
,&Bookmark
);
4966 if (Phone
->DeleteUserRingtones
!= NOTSUPPORTED
) {
4967 if (answer_yes("Delete all user ringtones")) {
4968 printmsgerr("Deleting: ");
4969 error
=Phone
->DeleteUserRingtones(&s
);
4971 printmsgerr("Done\n");
4975 error
=Phone
->GetFMStation(&s
,&Station
);
4976 if (error
== GE_NONE
|| error
== GE_EMPTY
) {
4977 if (answer_yes("Delete all FM station")) {
4978 error
=Phone
->ClearFMStations(&s
);
4986 static void GetWAPMMSSettings(int argc
, char *argv
[])
4988 GSM_MultiWAPSettings settings
;
4991 GetStartStop(&start
, &stop
, 2, argc
, argv
);
4995 for (i
=start
;i
<=stop
;i
++) {
4996 settings
.Location
=i
;
4997 if (mystrncasecmp(argv
[1],"--getwapsettings",0)) {
4998 error
=Phone
->GetWAPSettings(&s
,&settings
);
5000 error
=Phone
->GetMMSSettings(&s
,&settings
);
5003 for (j
=0;j
<settings
.Number
;j
++) {
5005 if (settings
.Settings
[j
].Title
[0]==0 && settings
.Settings
[j
].Title
[1]==0)
5007 printmsg("Set %i",i
);
5009 printmsg("%s",DecodeUnicodeConsole(settings
.Settings
[j
].Title
));
5011 if (settings
.Active
) printmsg(" (active)");
5012 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].HomePage
));
5013 if (settings
.Settings
[j
].IsContinuous
) {
5014 printmsg("Connection type : Continuous\n");
5016 printmsg("Connection type : Temporary\n");
5018 if (settings
.Settings
[j
].IsSecurity
) {
5019 printmsg("Connection security : On\n");
5021 printmsg("Connection security : Off\n");
5023 switch (settings
.Settings
[j
].Bearer
) {
5024 case WAPSETTINGS_BEARER_SMS
:
5025 printmsg("Bearer : SMS");
5026 if (settings
.ActiveBearer
== WAPSETTINGS_BEARER_SMS
) printf(" (active)");
5027 printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].Server
));
5028 printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].Service
));
5030 case WAPSETTINGS_BEARER_DATA
:
5031 printmsg("Bearer : Data (CSD)");
5032 if (settings
.ActiveBearer
== WAPSETTINGS_BEARER_DATA
) printf(" (active)");
5033 printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].DialUp
));
5034 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].IPAddress
));
5035 if (settings
.Settings
[j
].ManualLogin
) {
5036 printmsg("Login Type : Manual\n");
5038 printmsg("Login Type : Automatic\n");
5040 if (settings
.Settings
[j
].IsNormalAuthentication
) {
5041 printmsg("Authentication type : Normal\n");
5043 printmsg("Authentication type : Secure\n");
5045 if (settings
.Settings
[j
].IsISDNCall
) {
5046 printmsg("Data call type : ISDN\n");
5048 printmsg("Data call type : Analogue\n");
5050 switch (settings
.Settings
[j
].Speed
) {
5051 case WAPSETTINGS_SPEED_9600
: printmsg("Data call speed : 9600\n"); break;
5052 case WAPSETTINGS_SPEED_14400
: printmsg("Data call speed : 14400\n"); break;
5053 case WAPSETTINGS_SPEED_AUTO
: printmsg("Data call speed : Auto\n"); break;
5055 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].User
));
5056 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].Password
));
5058 case WAPSETTINGS_BEARER_USSD
:
5059 printmsg("Bearer : USSD");
5060 if (settings
.ActiveBearer
== WAPSETTINGS_BEARER_USSD
) printf(" (active)");
5061 printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].Code
));
5062 if (settings
.Settings
[j
].IsIP
) {
5063 printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].Service
));
5065 printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].Service
));
5068 case WAPSETTINGS_BEARER_GPRS
:
5069 printmsg("Bearer : GPRS");
5070 if (settings
.ActiveBearer
== WAPSETTINGS_BEARER_GPRS
) printf(" (active)");
5071 if (settings
.Settings
[j
].ManualLogin
) {
5072 printmsg("\nLogin Type : Manual\n");
5074 printmsg("\nLogin Type : Automatic\n");
5076 if (settings
.Settings
[j
].IsNormalAuthentication
) {
5077 printmsg("Authentication type : Normal\n");
5079 printmsg("Authentication type : Secure\n");
5081 printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].DialUp
));
5082 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].IPAddress
));
5083 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].User
));
5084 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings
.Settings
[j
].Password
));
5092 #ifdef GSM_ENABLE_BACKUP
5093 static void BackupSMS(int argc
, char *argv
[])
5095 GSM_SMS_Backup Backup
;
5096 GSM_MultiSMSMessage sms
;
5097 GSM_SMSFolders folders
;
5098 bool BackupFromFolder
[GSM_MAX_SMS_FOLDERS
];
5104 /* We ignore return code, because (when file doesn't exist) we
5105 * will create new later
5107 GSM_ReadSMSBackupFile(argv
[2], &Backup
);
5109 while (Backup
.SMS
[smsnum
]!=NULL
) smsnum
++;
5113 error
=Phone
->GetSMSFolders(&s
, &folders
);
5116 DeleteAfter
=answer_yes("Delete each sms after backup");
5118 for (j
=0;j
<folders
.Number
;j
++) {
5119 BackupFromFolder
[j
] = false;
5120 sprintf(buffer
,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders
.Folder
[j
].Name
));
5121 if (answer_yes(buffer
)) BackupFromFolder
[j
] = true;
5124 while (error
== GE_NONE
) {
5125 sms
.SMS
[0].Folder
=0x00;
5126 error
=Phone
->GetNextSMS(&s
, &sms
, start
);
5132 for (j
=0;j
<sms
.Number
;j
++) {
5133 if (BackupFromFolder
[sms
.SMS
[j
].Folder
-1]) {
5134 switch (sms
.SMS
[j
].PDU
) {
5135 case SMS_Status_Report
:
5139 if (sms
.SMS
[j
].Length
== 0) break;
5140 if (smsnum
< GSM_BACKUP_MAX_SMS
) {
5141 Backup
.SMS
[smsnum
] = malloc(sizeof(GSM_SMSMessage
));
5142 if (Backup
.SMS
[smsnum
] == NULL
) Print_Error(GE_MOREMEMORY
);
5143 Backup
.SMS
[smsnum
+1] = NULL
;
5145 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS");
5149 *Backup
.SMS
[smsnum
] = sms
.SMS
[j
];
5159 error
= GSM_SaveSMSBackupFile(argv
[2],&Backup
);
5163 for (j
=0;j
<smsnum
;j
++) {
5164 Backup
.SMS
[j
]->Folder
= 0;
5165 error
=Phone
->DeleteSMS(&s
, Backup
.SMS
[j
]);
5167 printmsgerr("%cDeleting: %i percent",13,(j
+1)*100/smsnum
);
5174 static void RestoreSMS(int argc
, char *argv
[])
5176 GSM_MultiSMSMessage SMS
;
5177 GSM_SMS_Backup Backup
;
5178 GSM_SMSFolders folders
;
5182 error
=GSM_ReadSMSBackupFile(argv
[2], &Backup
);
5187 error
=Phone
->GetSMSFolders(&s
, &folders
);
5190 while (Backup
.SMS
[smsnum
] != NULL
) {
5192 memcpy(&SMS
.SMS
[0],Backup
.SMS
[smsnum
],sizeof(GSM_SMSMessage
));
5193 displaymultismsinfo(SMS
,false,false);
5194 sprintf(buffer
,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders
.Folder
[Backup
.SMS
[smsnum
]->Folder
-1].Name
));
5195 if (answer_yes(buffer
)) {
5196 Backup
.SMS
[smsnum
]->Location
= 0;
5197 error
=Phone
->SetSMS(&s
, Backup
.SMS
[smsnum
]);
5207 static void CopyBitmap(int argc
, char *argv
[])
5209 GSM_MultiBitmap Bitmap
;
5212 Bitmap
.Bitmap
[0].Type
= GSM_None
;
5214 error
=GSM_ReadBitmapFile(argv
[2],&Bitmap
);
5218 for (i
=0;i
<Bitmap
.Number
;i
++) {
5219 switch (Bitmap
.Bitmap
[i
].Type
) {
5220 case GSM_StartupLogo
: printmsg("Startup logo"); break;
5221 case GSM_OperatorLogo
: printmsg("Operator logo"); break;
5222 case GSM_PictureImage
: printmsg("Picture Image"); break;
5223 case GSM_CallerLogo
: printmsg("Caller group logo"); break;
5226 printmsg(", width %i, height %i\n",Bitmap
.Bitmap
[i
].Width
,Bitmap
.Bitmap
[i
].Height
);
5227 GSM_PrintBitmap(stdout
,&Bitmap
.Bitmap
[i
]);
5231 for (i
=0;i
<Bitmap
.Number
;i
++) {
5232 if (mystrncasecmp(argv
[4],"PICTURE",0)) {
5233 Bitmap
.Bitmap
[i
].Type
= GSM_PictureImage
;
5234 } else if (mystrncasecmp(argv
[4],"STARTUP",0)) {
5235 Bitmap
.Bitmap
[i
].Type
= GSM_StartupLogo
;
5236 } else if (mystrncasecmp(argv
[4],"CALLER",0)) {
5237 Bitmap
.Bitmap
[i
].Type
= GSM_CallerLogo
;
5238 } else if (mystrncasecmp(argv
[4],"OPERATOR",0)) {
5239 Bitmap
.Bitmap
[i
].Type
= GSM_OperatorLogo
;
5241 printmsg("What format of output file logo (\"%s\") ?\n",argv
[4]);
5246 error
=GSM_SaveBitmapFile(argv
[3],&Bitmap
);
5251 static void NokiaComposer(int argc
, char *argv
[])
5253 GSM_Ringtone ringtone
;
5257 GSM_RingNoteDuration Duration
;
5258 GSM_RingNoteDuration DefNoteDuration
= 32; /* 32 = Duration_1_4 */
5259 unsigned int DefNoteScale
= Scale_880
;
5261 ringtone
.Format
= 0;
5262 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
5264 if (ringtone
.Format
!= RING_NOTETONE
) {
5265 printmsg("It can be RTTL ringtone only used with this option\n");
5271 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
5272 if (ringtone
.NoteTone
.Commands
[i
].Type
== RING_Note
) {
5273 Note
= &ringtone
.NoteTone
.Commands
[i
].Note
;
5275 if (Note
->Note
!= Note_Pause
) {
5276 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone
.Name
),GSM_RTTLGetTempo(Note
->Tempo
));
5283 if (j
>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j
);
5285 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: ");
5287 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
5288 if (ringtone
.NoteTone
.Commands
[i
].Type
== RING_Note
) {
5289 Note
= &ringtone
.NoteTone
.Commands
[i
].Note
;
5291 if (Note
->Note
!= Note_Pause
) started
= true;
5294 switch (Note
->Duration
) {
5295 case Duration_Full
: printmsg("1"); break;
5296 case Duration_1_2
: printmsg("2"); break;
5297 case Duration_1_4
: printmsg("4"); break;
5298 case Duration_1_8
: printmsg("8"); break;
5299 case Duration_1_16
: printmsg("16");break;
5300 case Duration_1_32
: printmsg("32");break;
5302 if (Note
->DurationSpec
== DottedNote
) printmsg(".");
5303 switch (Note
->Note
) {
5304 case Note_C
: printmsg("c"); break;
5305 case Note_Cis
: printmsg("#c"); break;
5306 case Note_D
:printmsg("d"); break;
5307 case Note_Dis
: printmsg("#d"); break;
5308 case Note_E
: printmsg("e"); break;
5309 case Note_F
: printmsg("f"); break;
5310 case Note_Fis
: printmsg("#f"); break;
5311 case Note_G
: printmsg("g"); break;
5312 case Note_Gis
: printmsg("#g"); break;
5313 case Note_A
: printmsg("a"); break;
5314 case Note_Ais
: printmsg("#a"); break;
5315 case Note_H
: printmsg("h"); break;
5316 case Note_Pause
: printmsg("-"); break;
5318 if (Note
->Note
!= Note_Pause
) printmsg("%i",Note
->Scale
- 4);
5324 printmsg("\n\nTo enter it please press: ");
5326 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
5327 if (ringtone
.NoteTone
.Commands
[i
].Type
== RING_Note
) {
5328 Note
= &ringtone
.NoteTone
.Commands
[i
].Note
;
5330 if (Note
->Note
!= Note_Pause
) started
= true;
5333 switch (Note
->Note
) {
5334 case Note_C
: case Note_Cis
: printmsg("1");break;
5335 case Note_D
: case Note_Dis
: printmsg("2");break;
5336 case Note_E
: printmsg("3");break;
5337 case Note_F
: case Note_Fis
: printmsg("4");break;
5338 case Note_G
: case Note_Gis
: printmsg("5");break;
5339 case Note_A
: case Note_Ais
: printmsg("6");break;
5340 case Note_H
: printmsg("7");break;
5341 default : printmsg("0");break;
5343 if (Note
->DurationSpec
== DottedNote
) printmsg("(longer)");
5344 switch (Note
->Note
) {
5345 case Note_Cis
: case Note_Dis
:
5346 case Note_Fis
: case Note_Gis
:
5353 if (Note
->Note
!= Note_Pause
) {
5354 if ((unsigned int)Note
->Scale
!= DefNoteScale
) {
5355 while (DefNoteScale
!= (unsigned int)Note
->Scale
) {
5358 if (DefNoteScale
==Scale_7040
) DefNoteScale
= Scale_880
;
5363 switch (Note
->Duration
) {
5364 case Duration_Full
: Duration
= 128; break;
5365 case Duration_1_2
: Duration
= 64; break;
5366 case Duration_1_4
: Duration
= 32; break;
5367 case Duration_1_8
: Duration
= 16; break;
5368 case Duration_1_16
: Duration
= 8; break;
5369 case Duration_1_32
: Duration
= 4; break;
5370 default : dbgprintf("error\n");break;
5372 if (Duration
> DefNoteDuration
) {
5373 while (DefNoteDuration
!= Duration
) {
5375 DefNoteDuration
= DefNoteDuration
* 2;
5378 if (Duration
< DefNoteDuration
) {
5379 while (DefNoteDuration
!= Duration
) {
5381 DefNoteDuration
= DefNoteDuration
/ 2;
5392 static void CopyRingtone(int argc
, char *argv
[])
5394 GSM_Ringtone ringtone
, ringtone2
;
5395 GSM_RingtoneFormat Format
;
5397 ringtone
.Format
= 0;
5398 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
5401 Format
= ringtone
.Format
;
5403 if (mystrncasecmp(argv
[4],"RTTL",0)) { Format
= RING_NOTETONE
;
5404 } else if (mystrncasecmp(argv
[4],"BINARY",0)) { Format
= RING_NOKIABINARY
;
5406 printmsg("What format of output ringtone file (\"%s\") ?\n",argv
[4]);
5411 error
=GSM_RingtoneConvert(&ringtone2
,&ringtone
,Format
);
5414 error
=GSM_SaveRingtoneFile(argv
[3],&ringtone2
);
5418 static void PressKeySequence(int argc
, char *argv
[])
5421 GSM_KeyCode KeyCode
[500];
5423 error
= MakeKeySequence(argv
[2], KeyCode
, &Length
);
5424 if (error
== GE_NOTSUPPORTED
) {
5425 printmsg("Unknown key/function name: \"%c\"\n",argv
[2][Length
]);
5431 for (i
=0;i
<Length
;i
++) {
5432 error
=Phone
->PressKey(&s
, KeyCode
[i
], true);
5434 error
=Phone
->PressKey(&s
, KeyCode
[i
], false);
5441 static void GetAllCategories(int argc
, char *argv
[])
5443 GSM_Category Category
;
5444 GSM_CategoryStatus Status
;
5447 if (mystrncasecmp(argv
[2],"TODO",0)) {
5448 Category
.Type
= Category_ToDo
;
5449 Status
.Type
= Category_ToDo
;
5450 } else if (mystrncasecmp(argv
[2],"PHONEBOOK",0)) {
5451 Category
.Type
= Category_Phonebook
;
5452 Status
.Type
= Category_Phonebook
;
5454 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv
[2]);
5460 error
=Phone
->GetCategoryStatus(&s
, &Status
);
5463 for (count
=0,j
=1;count
<Status
.Used
;j
++)
5465 Category
.Location
=j
;
5466 error
=Phone
->GetCategory(&s
, &Category
);
5468 if (error
!= GE_EMPTY
) {
5469 printmsg("Location: %i\n",j
);
5473 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category
.Name
));
5481 static void GetCategory(int argc
, char *argv
[])
5483 GSM_Category Category
;
5486 if (mystrncasecmp(argv
[2],"TODO",0)) {
5487 Category
.Type
= Category_ToDo
;
5488 } else if (mystrncasecmp(argv
[2],"PHONEBOOK",0)) {
5489 Category
.Type
= Category_Phonebook
;
5491 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv
[2]);
5495 GetStartStop(&start
, &stop
, 2, argc
- 1, argv
+ 1);
5499 for (j
=start
;j
<=stop
;j
++)
5501 printmsg("Location: %i\n",j
);
5503 Category
.Location
=j
;
5505 error
=Phone
->GetCategory(&s
, &Category
);
5506 if (error
!= GE_EMPTY
) Print_Error(error
);
5508 if (error
== GE_EMPTY
) {
5509 printmsg("Entry is empty\n\n");
5511 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category
.Name
));
5518 static void DeleteToDo(int argc
, char *argv
[])
5524 GetStartStop(&start
, &stop
, 2, argc
, argv
);
5528 for (i
=start
;i
<=stop
;i
++) {
5530 printmsg("Location : %i\n",i
);
5531 error
=Phone
->DeleteToDo(&s
,&ToDo
);
5532 if (error
!= GE_EMPTY
) Print_Error(error
);
5534 if (error
== GE_EMPTY
) {
5535 printmsg("Entry was empty\n");
5537 printmsg("Entry was deleted\n");
5545 static void PrintToDo(GSM_ToDoEntry
*ToDo
)
5548 GSM_MemoryEntry entry
;
5549 unsigned char *name
;
5550 GSM_Category Category
;
5552 printmsg("Location : %i\n",ToDo
->Location
);
5553 printmsg("Priority : ");
5554 switch (ToDo
->Priority
) {
5555 case GSM_Priority_Low
: printmsg("Low\n"); break;
5556 case GSM_Priority_Medium
: printmsg("Medium\n"); break;
5557 case GSM_Priority_High
: printmsg("High\n"); break;
5558 default : printmsg("Unknown\n"); break;
5560 for (j
=0;j
<ToDo
->EntriesNum
;j
++) {
5561 switch (ToDo
->Entries
[j
].EntryType
) {
5562 case TODO_END_DATETIME
:
5563 printmsg("DueTime : %s\n",OSDateTime(ToDo
->Entries
[j
].Date
,false));
5565 case TODO_COMPLETED
:
5566 printmsg("Completed : %s\n",ToDo
->Entries
[j
].Number
== 1 ? "Yes" : "No");
5568 case TODO_ALARM_DATETIME
:
5569 printmsg("Alarm : %s\n",OSDateTime(ToDo
->Entries
[j
].Date
,false));
5571 case TODO_SILENT_ALARM_DATETIME
:
5572 printmsg("Silent alarm : %s\n",OSDateTime(ToDo
->Entries
[j
].Date
,false));
5575 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo
->Entries
[j
].Text
));
5578 printmsg("Private : %s\n",ToDo
->Entries
[j
].Number
== 1 ? "Yes" : "No");
5581 Category
.Location
= ToDo
->Entries
[j
].Number
;
5582 Category
.Type
= Category_ToDo
;
5583 error
=Phone
->GetCategory(&s
, &Category
);
5584 if (error
== GE_NONE
) {
5585 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category
.Name
), ToDo
->Entries
[j
].Number
);
5587 printmsg("Category : %i\n", ToDo
->Entries
[j
].Number
);
5590 case TODO_CONTACTID
:
5591 entry
.Location
= ToDo
->Entries
[j
].Number
;
5592 entry
.MemoryType
= GMT_ME
;
5593 error
=Phone
->GetMemory(&s
, &entry
);
5594 if (error
== GE_NONE
) {
5595 name
= GSM_PhonebookGetEntryName(&entry
);
5597 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name
), ToDo
->Entries
[j
].Number
);
5599 printmsg("Contact ID : %d\n",ToDo
->Entries
[j
].Number
);
5602 printmsg("Contact : %d\n",ToDo
->Entries
[j
].Number
);
5606 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo
->Entries
[j
].Text
));
5613 static void ListToDoCategoryEntries(int Category
)
5615 GSM_ToDoEntry Entry
;
5620 if (bshutdown
) break;
5621 error
= Phone
->GetNextToDo(&s
, &Entry
, start
);
5622 if (error
== GE_EMPTY
) break;
5624 for (j
=0;j
<Entry
.EntriesNum
;j
++) {
5625 if (Entry
.Entries
[j
].EntryType
== TODO_CATEGORY
&& Entry
.Entries
[j
].Number
== Category
)
5632 static void ListToDoCategory(int argc
, char *argv
[])
5634 GSM_Category Category
;
5635 GSM_CategoryStatus Status
;
5638 unsigned char Text
[(GSM_MAX_CATEGORY_NAME_LENGTH
+1)*2];
5640 bool Number
= true;;
5644 signal(SIGINT
, interrupted
);
5645 printmsgerr("If you want break, press Ctrl+C...\n");
5647 Length
= strlen(argv
[2]);
5648 for (j
= 0; j
< Length
; j
++) {
5649 if (!isdigit(argv
[2][j
])) {
5658 ListToDoCategoryEntries(j
);
5661 if (Length
> GSM_MAX_CATEGORY_NAME_LENGTH
) {
5662 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH
);
5663 Length
= GSM_MAX_CATEGORY_NAME_LENGTH
;
5665 EncodeUnicode(Text
, argv
[2], Length
);
5667 Category
.Type
= Category_ToDo
;
5668 Status
.Type
= Category_ToDo
;
5670 if (Phone
->GetCategoryStatus(&s
, &Status
) == GE_NONE
) {
5671 for (count
=0,j
=1;count
<Status
.Used
;j
++) {
5672 Category
.Location
=j
;
5673 error
=Phone
->GetCategory(&s
, &Category
);
5675 if (error
!= GE_EMPTY
) {
5677 if (mystrstr(Category
.Name
, Text
) != NULL
) {
5678 ListToDoCategoryEntries(j
);
5688 static void GetToDo(int argc
, char *argv
[])
5694 GetStartStop(&start
, &stop
, 2, argc
, argv
);
5698 for (i
=start
;i
<=stop
;i
++) {
5700 error
= Phone
->GetToDo(&s
,&ToDo
);
5701 if (error
== GE_EMPTY
) continue;
5709 static void GetAllToDo(int argc
, char *argv
[])
5717 error
= Phone
->GetNextToDo(&s
, &ToDo
, start
);
5718 if (error
== GE_EMPTY
) break;
5727 static void GetNote(int argc
, char *argv
[])
5733 GetStartStop(&start
, &stop
, 2, argc
, argv
);
5737 for (i
=start
;i
<=stop
;i
++) {
5739 printmsg("Location : %i\n",i
);
5740 error
=Phone
->GetNote(&s
,&Note
,refresh
);
5741 if (error
!= GE_EMPTY
) Print_Error(error
);
5743 if (error
== GE_EMPTY
) {
5744 printmsg("Entry is empty\n\n");
5746 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note
.Text
));
5755 static void GetSecurityStatus(int argc
, char *argv
[])
5759 PrintSecurityStatus();
5764 static void EnterSecurityCode(int argc
, char *argv
[])
5766 GSM_SecurityCode Code
;
5768 if (mystrncasecmp(argv
[2],"PIN",0)) { Code
.Type
= GSCT_Pin
;
5769 } else if (mystrncasecmp(argv
[2],"PUK",0)) { Code
.Type
= GSCT_Puk
;
5770 } else if (mystrncasecmp(argv
[2],"PIN2",0)) { Code
.Type
= GSCT_Pin2
;
5771 } else if (mystrncasecmp(argv
[2],"PUK2",0)) { Code
.Type
= GSCT_Puk2
;
5773 printmsg("What security code (\"%s\") ?\n",argv
[2]);
5777 strcpy(Code
.Code
,argv
[3]);
5781 error
=Phone
->EnterSecurityCode(&s
,Code
);
5787 static void GetProfile(int argc
, char *argv
[])
5789 GSM_Profile Profile
;
5791 GSM_Bitmap caller
[5];
5792 bool callerinit
[5],special
;
5793 GSM_AllRingtonesInfo Info
;
5795 GetStartStop(&start
, &stop
, 2, argc
, argv
);
5797 for (i
=0;i
<5;i
++) callerinit
[i
] = false;
5801 error
=Phone
->GetRingtonesInfo(&s
,&Info
);
5802 if (error
!= GE_NONE
) Info
.Number
= 0;
5804 for (i
=start
;i
<=stop
;i
++) {
5806 error
=Phone
->GetProfile(&s
,&Profile
);
5809 printmsg("%i. \"%s\"",i
,DecodeUnicodeConsole(Profile
.Name
));
5810 if (Profile
.Active
) printmsg(" (active)");
5811 if (Profile
.DefaultName
) printmsg(" (default name)");
5812 if (Profile
.HeadSetProfile
) printmsg(" (HeadSet profile)");
5813 if (Profile
.CarKitProfile
) printmsg(" (CarKit profile)");
5815 for (j
=0;j
<Profile
.FeaturesNumber
;j
++) {
5817 switch (Profile
.FeatureID
[j
]) {
5818 case Profile_MessageToneID
:
5819 case Profile_RingtoneID
:
5821 if (Profile
.FeatureID
[j
] == Profile_RingtoneID
) {
5822 printmsg("Ringtone ID : ");
5824 printmsg("Message alert tone ID : ");
5826 if (UnicodeLength(GSM_GetRingtoneName(&Info
,Profile
.FeatureValue
[j
]))!=0) {
5827 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info
,Profile
.FeatureValue
[j
])));
5829 printmsg("%i\n",Profile
.FeatureValue
[j
]);
5832 case Profile_CallerGroups
:
5834 printmsg("Call alert for :");
5836 if (Profile
.CallerGroups
[k
]) {
5837 if (!callerinit
[k
]) {
5838 caller
[k
].Type
= GSM_CallerLogo
;
5839 caller
[k
].Location
= k
+ 1;
5840 error
=Phone
->GetBitmap(&s
,&caller
[k
]);
5841 if (error
== GE_SECURITYERROR
) {
5842 NOKIA_GetDefaultCallerGroupName(&s
,&caller
[k
]);
5846 callerinit
[k
] = true;
5848 printmsg(" \"%s\"",DecodeUnicodeConsole(caller
[k
].Text
));
5853 case Profile_ScreenSaverNumber
:
5855 printmsg("Screen saver number : ");
5856 printmsg("%i\n",Profile
.FeatureValue
[j
]);
5858 case Profile_CallAlert
: printmsg("Incoming call alert : "); break;
5859 case Profile_RingtoneVolume
: printmsg("Ringtone volume : "); break;
5860 case Profile_Vibration
: printmsg("Vibrating alert : "); break;
5861 case Profile_MessageTone
: printmsg("Message alert tone : "); break;
5862 case Profile_KeypadTone
: printmsg("Keypad tones : "); break;
5863 case Profile_WarningTone
: printmsg("Warning (games) tones : "); break;
5864 case Profile_ScreenSaver
: printmsg("Screen saver : "); break;
5865 case Profile_ScreenSaverTime
: printmsg("Screen saver timeout : "); break;
5866 case Profile_AutoAnswer
: printmsg("Automatic answer : "); break;
5867 case Profile_Lights
: printmsg("Lights : "); break;
5869 printmsg("Unknown\n");
5873 switch (Profile
.FeatureValue
[j
]) {
5874 case PROFILE_VOLUME_LEVEL1
:
5875 case PROFILE_KEYPAD_LEVEL1
: printmsg("Level 1\n"); break;
5876 case PROFILE_VOLUME_LEVEL2
:
5877 case PROFILE_KEYPAD_LEVEL2
: printmsg("Level 2\n"); break;
5878 case PROFILE_VOLUME_LEVEL3
:
5879 case PROFILE_KEYPAD_LEVEL3
: printmsg("Level 3\n"); break;
5880 case PROFILE_VOLUME_LEVEL4
: printmsg("Level 4\n"); break;
5881 case PROFILE_VOLUME_LEVEL5
: printmsg("Level 5\n"); break;
5882 case PROFILE_MESSAGE_NOTONE
:
5883 case PROFILE_AUTOANSWER_OFF
:
5884 case PROFILE_LIGHTS_OFF
:
5885 case PROFILE_SAVER_OFF
:
5886 case PROFILE_WARNING_OFF
:
5887 case PROFILE_CALLALERT_OFF
:
5888 case PROFILE_VIBRATION_OFF
:
5889 case PROFILE_KEYPAD_OFF
: printmsg("Off\n"); break;
5890 case PROFILE_CALLALERT_RINGING
: printmsg("Ringing\n"); break;
5891 case PROFILE_CALLALERT_BEEPONCE
:
5892 case PROFILE_MESSAGE_BEEPONCE
: printmsg("Beep once\n"); break;
5893 case PROFILE_CALLALERT_RINGONCE
: printmsg("Ring once\n"); break;
5894 case PROFILE_CALLALERT_ASCENDING
: printmsg("Ascending\n"); break;
5895 case PROFILE_CALLALERT_CALLERGROUPS
: printmsg("Caller groups\n"); break;
5896 case PROFILE_MESSAGE_STANDARD
: printmsg("Standard\n"); break;
5897 case PROFILE_MESSAGE_SPECIAL
: printmsg("Special\n"); break;
5898 case PROFILE_MESSAGE_ASCENDING
: printmsg("Ascending\n"); break;
5899 case PROFILE_MESSAGE_PERSONAL
: printmsg("Personal\n"); break;
5900 case PROFILE_AUTOANSWER_ON
:
5901 case PROFILE_WARNING_ON
:
5902 case PROFILE_SAVER_ON
:
5903 case PROFILE_VIBRATION_ON
: printmsg("On\n"); break;
5904 case PROFILE_VIBRATION_FIRST
: printmsg("Vibrate first\n"); break;
5905 case PROFILE_LIGHTS_AUTO
: printmsg("Auto\n"); break;
5906 case PROFILE_SAVER_TIMEOUT_5SEC
: printmsg("5 seconds\n"); break;
5907 case PROFILE_SAVER_TIMEOUT_20SEC
: printmsg("20 seconds\n"); break;
5908 case PROFILE_SAVER_TIMEOUT_1MIN
: printmsg("1 minute\n"); break;
5909 case PROFILE_SAVER_TIMEOUT_2MIN
: printmsg("2 minutes\n"); break;
5910 case PROFILE_SAVER_TIMEOUT_5MIN
: printmsg("5 minutes\n"); break;
5911 case PROFILE_SAVER_TIMEOUT_10MIN
: printmsg("10 minutes\n"); break;
5912 default : printmsg("UNKNOWN\n");
5922 static void GetSpeedDial(int argc
, char *argv
[])
5924 GSM_SpeedDial SpeedDial
;
5925 GSM_MemoryEntry Phonebook
;
5926 int start
,stop
,Name
,Number
,Group
;
5928 GetStartStop(&start
, &stop
, 2, argc
, argv
);
5932 for (i
=start
;i
<=stop
;i
++) {
5933 SpeedDial
.Location
=i
;
5934 error
=Phone
->GetSpeedDial(&s
,&SpeedDial
);
5938 printmsg(" speed dial not assigned\n");
5943 Phonebook
.Location
= SpeedDial
.MemoryLocation
;
5944 Phonebook
.MemoryType
= SpeedDial
.MemoryType
;
5945 error
=Phone
->GetMemory(&s
,&Phonebook
);
5947 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook
, &Name
, &Number
, &Group
);
5949 if (Name
!= -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook
.Entries
[Name
].Text
));
5950 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook
.Entries
[SpeedDial
.MemoryNumberID
-1].Text
));
5958 static void ResetPhoneSettings(int argc
, char *argv
[])
5960 GSM_ResetSettingsType Type
;
5962 if (mystrncasecmp(argv
[2],"PHONE",0)) { Type
= GSM_RESET_PHONESETTINGS
;
5963 } else if (mystrncasecmp(argv
[2],"UIF",0)) { Type
= GSM_RESET_USERINTERFACE
;
5964 } else if (mystrncasecmp(argv
[2],"ALL",0)) { Type
= GSM_RESET_USERINTERFACE_PHONESETTINGS
;
5965 } else if (mystrncasecmp(argv
[2],"DEV",0)) { Type
= GSM_RESET_DEVICE
;
5966 } else if (mystrncasecmp(argv
[2],"FACTORY",0)) { Type
= GSM_RESET_FULLFACTORY
;
5968 printmsg("What type of reset phone settings (\"%s\") ?\n",argv
[2]);
5974 error
=Phone
->ResetPhoneSettings(&s
,Type
);
5980 #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
5981 static void NokiaSecurityCode(int argc
, char *argv
[])
5985 #ifdef GSM_ENABLE_NOKIA_DCT3
5986 DCT3GetSecurityCode(argc
,argv
);
5988 #ifdef GSM_ENABLE_NOKIA_DCT4
5989 // DCT4ResetSecurityCode(argc, argv);
5990 DCT4GetSecurityCode(argc
,argv
);
5996 static void NokiaSetPhoneMenus(int argc
, char *argv
[])
6000 #ifdef GSM_ENABLE_NOKIA_DCT3
6001 DCT3SetPhoneMenus (argc
, argv
);
6003 #ifdef GSM_ENABLE_NOKIA_DCT4
6004 DCT4SetPhoneMenus (argc
, argv
);
6010 static void NokiaSelfTests(int argc
, char *argv
[])
6014 #ifdef GSM_ENABLE_NOKIA_DCT3
6015 DCT3SelfTests(argc
, argv
);
6017 #ifdef GSM_ENABLE_NOKIA_DCT4
6018 DCT4SelfTests(argc
, argv
);
6025 static void DeleteAllSMS(int argc
, char *argv
[])
6027 GSM_MultiSMSMessage sms
;
6028 GSM_SMSFolders folders
;
6034 error
=Phone
->GetSMSFolders(&s
, &folders
);
6037 GetStartStop(&foldernum
, NULL
, 2, argc
, argv
);
6038 if (foldernum
> folders
.Number
) {
6039 printmsg("Too high folder number (max. %i)\n",folders
.Number
);
6044 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders
.Folder
[foldernum
-1].Name
));
6046 while (error
== GE_NONE
) {
6047 sms
.SMS
[0].Folder
=0x00;
6048 error
=Phone
->GetNextSMS(&s
, &sms
, start
);
6054 if (sms
.SMS
[0].Folder
== foldernum
) {
6055 sms
.SMS
[0].Folder
=0x00;
6056 error
=Phone
->DeleteSMS(&s
, &sms
.SMS
[0]);
6069 static void SendDTMF(int argc
, char *argv
[])
6073 error
=Phone
->SendDTMF(&s
,argv
[2]);
6079 static void GetDisplayStatus(int argc
, char *argv
[])
6081 GSM_DisplayFeatures Features
;
6086 error
=Phone
->GetDisplayStatus(&s
,&Features
);
6089 printmsg("Current display features :\n");
6091 for (i
=0;i
<Features
.Number
;i
++) {
6092 switch(Features
.Feature
[i
]) {
6093 case GSM_CallActive
: printmsg("Call active\n"); break;
6094 case GSM_UnreadSMS
: printmsg("Unread SMS\n"); break;
6095 case GSM_VoiceCall
: printmsg("Voice call\n"); break;
6096 case GSM_FaxCall
: printmsg("Fax call\n"); break;
6097 case GSM_DataCall
: printmsg("Data call\n"); break;
6098 case GSM_KeypadLocked
: printmsg("Keypad locked\n"); break;
6099 case GSM_SMSMemoryFull
: printmsg("SMS memory full\n");
6106 static void SetAutoNetworkLogin(int argc
, char *argv
[])
6110 error
=Phone
->SetAutoNetworkLogin(&s
);
6117 static void MakeConvertTable(int argc
, char *argv
[])
6119 unsigned char InputBuffer
[10000], Buffer
[10000];
6123 file
= fopen(argv
[2], "rb");
6124 if (file
== NULL
) Print_Error(GE_CANTOPENFILE
);
6125 size
=fread(InputBuffer
, 1, 10000-1, file
);
6127 InputBuffer
[size
] = 0;
6128 InputBuffer
[size
+1] = 0;
6130 ReadUnicodeFile(Buffer
,InputBuffer
);
6132 for(i
=0;i
<((int)UnicodeLength(Buffer
));i
++) {
6138 printf("\\x%02x\\x%02x",Buffer
[i
*2],Buffer
[i
*2+1]);
6140 printf("\\x00\\x00");
6144 static void ListNetworks(int argc
, char *argv
[])
6146 extern unsigned char *GSM_Networks
[];
6149 printmsg("Network Name\n");
6150 printmsg("-----------------------------------------\n");
6151 while (GSM_Networks
[i
*2]!=NULL
) {
6152 printmsg("%-7s %s\n", GSM_Networks
[i
*2], GSM_Networks
[i
*2+1]);
6157 static void Version(int argc
, char *argv
[])
6159 // unsigned char buff[10];
6162 printmsg("[Gammu version %s built %s %s]\n\n",VERSION
,__TIME__
,__DATE__
);
6165 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage
));
6166 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC
));
6167 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State
));
6168 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader
));
6169 printf("bool - %i\n",sizeof(bool));
6170 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime
));
6171 printf("int - %i\n",sizeof(int));
6172 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo
));
6175 // len=DecodeBASE64("AXw", buff, 3);
6176 // DumpMessage(stdout, buff, len);
6179 static void GetFMStation(int argc
, char *argv
[])
6181 GSM_FMStation Station
;
6184 GetStartStop(&start
, &stop
, 2, argc
, argv
);
6188 for (i
=start
;i
<=stop
;i
++) {
6190 error
=Phone
->GetFMStation(&s
,&Station
);
6193 printmsg("Entry number %i is empty\n",i
);
6196 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n",
6197 i
,DecodeUnicodeConsole(Station
.StationName
),
6207 static void GetFileSystemStatus(int argc
, char *argv
[])
6209 GSM_FileSystemStatus Status
;
6213 error
= Phone
->GetFileSystemStatus(&s
,&Status
);
6214 if (error
!= GE_NOTSUPPORTED
&& error
!= GE_NOTIMPLEMENTED
) {
6216 printmsg("\nFree memory: %i, total memory: %i\n",Status
.Free
,Status
.Free
+Status
.Used
);
6222 static void GetFileSystem(int argc
, char *argv
[])
6227 GSM_FileSystemStatus Status
;
6232 error
= Phone
->GetNextFileFolder(&s
,&Files
,Start
);
6233 if (error
== GE_EMPTY
) break;
6236 if (strlen(Files
.ID_FullName
) < 5 && strlen(Files
.ID_FullName
) != 0) {
6237 printf("%5s.",Files
.ID_FullName
);
6239 if (Files
.Protected
) {
6244 if (Files
.ReadOnly
) {
6259 if (argc
> 2 && (mystrncasecmp(argv
[2],"-flatall",0) || mystrncasecmp(argv
[2],"-flat",0))) {
6260 if (!Files
.Folder
) {
6261 if (mystrncasecmp(argv
[2],"-flatall",0)) {
6262 if (!Files
.ModifiedEmpty
) {
6263 printf(" %30s",OSDateTime(Files
.Modified
,false));
6264 } else printf(" %30c",0x20);
6265 printf(" %9i",Files
.Used
);
6267 } else printf("|-- ");
6268 } else printf("Folder ");
6270 if (Files
.Level
!= 1) {
6271 for (j
=0;j
<Files
.Level
-2;j
++) printf(" | ");
6274 if (Files
.Folder
) printf("Folder ");
6276 printf("\"%s\"",DecodeUnicodeConsole(Files
.Name
));
6282 error
= Phone
->GetFileSystemStatus(&s
,&Status
);
6283 if (error
!= GE_NOTSUPPORTED
&& error
!= GE_NOTIMPLEMENTED
) {
6285 printmsg("\nFree memory: %i, total memory: %i\n",Status
.Free
,Status
.Free
+Status
.Used
);
6291 static void GetFiles(int argc
, char *argv
[])
6296 bool start
,newtime
= false;
6297 unsigned char buffer
[5000];
6298 struct utimbuf filedate
;
6304 for (i
=2;i
<argc
;i
++) {
6305 if (mystrncasecmp(argv
[i
],"-newtime",0)) {
6310 if (File
.Buffer
!= NULL
) {
6315 strcpy(File
.ID_FullName
,argv
[i
]);
6319 while (error
== GE_NONE
) {
6320 error
= Phone
->GetFilePart(&s
,&File
);
6321 if (error
== GE_NONE
|| error
== GE_EMPTY
|| error
== GE_WRONGCRC
) {
6323 printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File
.Name
));
6329 printmsg("it's folder. Please give only file names\n");
6333 if (error
== GE_EMPTY
) break;
6334 if (error
== GE_WRONGCRC
) {
6335 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6343 if (File
.Used
!= 0) {
6344 sprintf(buffer
,"%s",DecodeUnicodeConsole(File
.Name
));
6345 file
= fopen(buffer
,"wb");
6347 sprintf(buffer
,"file%s",File
.ID_FullName
);
6348 file
= fopen(buffer
,"wb");
6351 sprintf(buffer
,"file%i",i
);
6352 file
= fopen(buffer
,"wb");
6354 printmsg(" Saving to %s\n",buffer
);
6355 if (!file
) Print_Error(GE_CANTOPENFILE
);
6356 fwrite(File
.Buffer
,1,File
.Used
,file
);
6358 if (!newtime
&& !File
.ModifiedEmpty
) {
6360 filedate
.actime
= Fill_Time_T(File
.Modified
, 8);
6361 /* modification time */
6362 filedate
.modtime
= Fill_Time_T(File
.Modified
, 8);
6363 dbgprintf("Setting date of %s\n",buffer
);
6364 utime(buffer
,&filedate
);
6373 static void AddFile(int argc
, char *argv
[])
6376 int Pos
= 0,i
,nextlong
;
6379 strcpy(File
.ID_FullName
,argv
[2]);
6380 error
= GSM_ReadFile(argv
[3], &File
);
6382 EncodeUnicode(File
.Name
,argv
[3],strlen(argv
[3]));
6383 GSM_IdentifyFileFormat(&File
);
6385 File
.Protected
= false;
6386 File
.ReadOnly
= false;
6387 File
.Hidden
= false;
6388 File
.System
= false;
6392 for (i
=4;i
<argc
;i
++) {
6395 if (mystrncasecmp(argv
[i
],"-type",0)) {
6399 if (mystrncasecmp(argv
[i
],"-protected",0)) {
6400 File
.Protected
= true;
6403 if (mystrncasecmp(argv
[i
],"-readonly",0)) {
6404 File
.ReadOnly
= true;
6407 if (mystrncasecmp(argv
[i
],"-hidden",0)) {
6411 if (mystrncasecmp(argv
[i
],"-system",0)) {
6415 if (mystrncasecmp(argv
[i
],"-newtime",0)) {
6416 File
.ModifiedEmpty
= true;
6419 printmsg("Parameter \"%s\" unknown\n",argv
[i
]);
6422 if (mystrncasecmp(argv
[i
],"JAR",0)) {
6423 File
.Type
= GSM_File_Java_JAR
;
6424 } else if (mystrncasecmp(argv
[i
],"JPG",0)) {
6425 File
.Type
= GSM_File_Image_JPG
;
6426 } else if (mystrncasecmp(argv
[i
],"BMP",0)) {
6427 File
.Type
= GSM_File_Image_BMP
;
6428 } else if (mystrncasecmp(argv
[i
],"WBMP",0)) {
6429 File
.Type
= GSM_File_Image_WBMP
;
6430 } else if (mystrncasecmp(argv
[i
],"GIF",0)) {
6431 File
.Type
= GSM_File_Image_GIF
;
6432 } else if (mystrncasecmp(argv
[i
],"PNG",0)) {
6433 File
.Type
= GSM_File_Image_PNG
;
6434 } else if (mystrncasecmp(argv
[i
],"MIDI",0)) {
6435 File
.Type
= GSM_File_Ringtone_MIDI
;
6437 printmsg("What file type (\"%s\") ?\n",argv
[i
]);
6445 printmsg("Parameter missed...\n");
6453 while (error
== GE_NONE
) {
6454 error
= Phone
->AddFilePart(&s
,&File
,&Pos
);
6455 if (error
!= GE_EMPTY
&& error
!= GE_WRONGCRC
) Print_Error(error
);
6456 printmsgerr("%cWriting: %i percent",13,Pos
*100/File
.Used
);
6459 if (error
== GE_WRONGCRC
) {
6460 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6467 static void AddFolder(int argc
, char *argv
[])
6471 strcpy(File
.ID_FullName
,argv
[2]);
6472 EncodeUnicode(File
.Name
,argv
[3],strlen(argv
[3]));
6473 File
.ReadOnly
= false;
6477 error
= Phone
->AddFolder(&s
,&File
);
6483 struct NokiaFolderInfo
{
6490 static struct NokiaFolderInfo Folder
[] = {
6491 /* Language indepedent in DCT4 */
6492 {"", "MMSUnreadInbox", "INBOX", "3"},
6493 {"", "MMSReadInbox", "INBOX", "3"},
6494 {"", "MMSOutbox", "OUTBOX", "3"},
6495 {"", "MMSSent", "SENT", "3"},
6496 {"", "MMSDrafts", "DRAFTS", "3"},
6497 {"", "Application", "applications", "3"},
6498 {"", "Game", "games", "3"},
6499 /* Language depedent in DCT4 */
6500 {"", "Gallery", "Pictures", "2"}, /* 3510 */
6501 {"", "Gallery", "Graphics", "3"}, /* 3510i */
6502 {"", "Gallery", "Images", "3"}, /* 6610 */
6503 {"3510", "Gallery", "", "8"},
6504 {"3510i","Gallery", "", "3"},
6505 {"5100", "Gallery", "", "3"},
6506 {"", "Tones", "Tones", "3"},
6507 {"3510i","Tones", "", "4"},
6508 {"5100", "Tones", "", "4"},
6509 /* Language indepedent in OBEX */
6510 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX" },
6511 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX" },
6512 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX" },
6513 {"obex", "MMSSent", "", "predefMessages\\predefSENT" },
6514 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS" },
6515 // {"obex", "Application, "", "predefjava\\predefapplications"},
6516 // {"obex", "Game", "", "predefjava\\predefgames" },
6517 {"obex", "Gallery", "", "predefgallery\\predefgraphics" },
6518 {"obex", "Tones", "", "predefgallery\\predeftones" },
6524 static void NokiaAddFile(int argc
, char *argv
[])
6526 GSM_File File
, Files
;
6528 GSM_DateTime DT
,DT2
;
6529 time_t t_time1
,t_time2
;
6530 unsigned char buffer
[10000],JAR
[500],Vendor
[500],Name
[500],Version
[500],FileID
[400];
6531 bool Start
= true, Found
= false, wasclr
;
6532 bool ModEmpty
= false;
6533 int i
= 0, Pos
, Size
, Size2
, nextlong
;
6535 while (Folder
[i
].level
[0] != 0) {
6536 if (mystrncasecmp(argv
[2],Folder
[i
].parameter
,0)) {
6543 printmsg("What folder type (\"%s\") ?\n",argv
[2]);
6549 if (s
.ConnectionType
== GCT_IRDAOBEX
|| s
.ConnectionType
== GCT_BLUEOBEX
) {
6552 while (Folder
[i
].level
[0] != 0) {
6553 if (!strcmp("obex",Folder
[i
].model
) &&
6554 mystrncasecmp(argv
[2],Folder
[i
].parameter
,0)) {
6555 strcpy(Files
.ID_FullName
,Folder
[i
].level
);
6562 printmsgerr("Searching for phone folder: ");
6564 error
= Phone
->GetNextFileFolder(&s
,&Files
,Start
);
6565 if (error
== GE_EMPTY
) break;
6569 dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files
.Name
),Files
.Level
);
6572 while (Folder
[i
].level
[0] != 0) {
6573 EncodeUnicode(buffer
,Folder
[i
].folder
,strlen(Folder
[i
].folder
));
6574 if (mystrncasecmp(argv
[2],Folder
[i
].parameter
,0) &&
6575 mywstrncasecmp(Files
.Name
,buffer
,0) &&
6576 Files
.Level
== atoi(Folder
[i
].level
)) {
6580 if (!strcmp(s
.Phone
.Data
.ModelInfo
->model
,Folder
[i
].model
) &&
6581 mystrncasecmp(argv
[2],Folder
[i
].parameter
,0) &&
6582 !strcmp(Files
.ID_FullName
,Folder
[i
].level
)) {
6586 dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s
.Phone
.Data
.ModelInfo
->model
,Files
.ID_FullName
,Folder
[i
].level
);
6598 printmsg("Folder not found. Probably function not supported !\n");
6603 File
.Protected
= false;
6604 File
.ReadOnly
= false;
6605 File
.Hidden
= false;
6606 File
.System
= false;
6608 if (mystrncasecmp(argv
[2],"Application",0) || mystrncasecmp(argv
[2],"Game",0)) {
6609 sprintf(buffer
,"%s.jad",argv
[3]);
6610 file
= fopen(buffer
,"rb");
6611 if (file
== NULL
) Print_Error(GE_CANTOPENFILE
);
6613 sprintf(buffer
,"%s.jar",argv
[3]);
6614 file
= fopen(buffer
,"rb");
6615 if (file
== NULL
) Print_Error(GE_CANTOPENFILE
);
6618 /* reading jar file */
6619 sprintf(buffer
,"%s.jar",argv
[3]);
6620 error
= GSM_ReadFile(buffer
, &File
);
6624 /* reading jad file */
6625 sprintf(buffer
,"%s.jad",argv
[3]);
6626 error
= GSM_ReadFile(buffer
, &File
);
6629 /* Getting values from JAD file */
6630 error
= GSM_JADFindData(File
, Vendor
, Name
, JAR
, Version
, &Size
);
6631 if (error
== GE_FILENOTSUPPORTED
) {
6632 if (Vendor
[0] == 0x00) {
6633 printmsgerr("No vendor info in JAD file\n");
6637 if (Name
[0] == 0x00) {
6638 printmsgerr("No name info in JAD file\n");
6642 if (JAR
[0] == 0x00) {
6643 printmsgerr("No JAR URL info in JAD file\n");
6648 printmsgerr("No JAR size info in JAD file\n");
6653 if (Size
!= Size2
) {
6654 printmsgerr("Declared JAR file size is different than real\n");
6658 printmsgerr("Adding \"%s\"",Name
);
6659 if (Version
[0] != 0x00) printmsgerr(" version %s",Version
);
6660 printmsgerr(" created by %s\n",Vendor
);
6662 /* Changing all #13 or #10 to #13#10 in JAD */
6665 for (i
=0;i
<File
.Used
;i
++) {
6666 switch (File
.Buffer
[i
]) {
6670 buffer
[Pos
++] = 0x0D;
6671 buffer
[Pos
++] = 0x0A;
6673 } else wasclr
= false;
6676 buffer
[Pos
++] = File
.Buffer
[i
];
6680 File
.Buffer
= realloc(File
.Buffer
, Pos
);
6682 memcpy(File
.Buffer
,buffer
,Pos
);
6685 strcpy(buffer
,Vendor
);
6686 strcat(buffer
,Name
);
6687 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
6688 strcpy(File
.ID_FullName
,Files
.ID_FullName
);
6689 error
= Phone
->AddFolder(&s
,&File
);
6691 strcpy(FileID
,File
.ID_FullName
);
6693 /* adding jad file */
6695 buffer
[strlen(buffer
) - 1] = 'd';
6696 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
6697 File
.Type
= GSM_File_Other
;
6698 File
.ModifiedEmpty
= true;
6701 while (error
== GE_NONE
) {
6702 error
= Phone
->AddFilePart(&s
,&File
,&Pos
);
6703 if (error
!= GE_EMPTY
&& error
!= GE_WRONGCRC
) Print_Error(error
);
6704 printmsgerr("%cWriting JAD file: %i percent",13,Pos
*100/File
.Used
);
6707 if (error
== GE_WRONGCRC
) {
6708 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6712 if (mystrncasecmp(argv
[4],"-readonly",0)) File
.ReadOnly
= true;
6715 /* reading jar file */
6716 sprintf(buffer
,"%s.jar",argv
[3]);
6717 error
= GSM_ReadFile(buffer
, &File
);
6720 /* adding jar file */
6721 strcpy(File
.ID_FullName
,FileID
);
6723 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
6724 File
.Type
= GSM_File_Java_JAR
;
6725 File
.ModifiedEmpty
= true;
6728 while (error
== GE_NONE
) {
6729 error
= Phone
->AddFilePart(&s
,&File
,&Pos
);
6730 if (error
!= GE_EMPTY
&& error
!= GE_WRONGCRC
) Print_Error(error
);
6731 printmsgerr("%cWriting JAR file: %i percent",13,Pos
*100/File
.Used
);
6734 if (error
== GE_WRONGCRC
) {
6735 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6743 if (mystrncasecmp(argv
[2],"Gallery",0) || mystrncasecmp(argv
[2],"Tones",0)) {
6744 strcpy(buffer
,argv
[3]);
6747 for (i
=4;i
<argc
;i
++) {
6750 if (mystrncasecmp(argv
[i
],"-name",0)) {
6754 if (mystrncasecmp(argv
[i
],"-protected",0)) {
6755 File
.Protected
= true;
6758 if (mystrncasecmp(argv
[i
],"-readonly",0)) {
6759 File
.ReadOnly
= true;
6762 if (mystrncasecmp(argv
[i
],"-hidden",0)) {
6766 if (mystrncasecmp(argv
[i
],"-system",0)) {
6770 if (mystrncasecmp(argv
[i
],"-newtime",0)) {
6774 printmsg("Parameter \"%s\" unknown\n",argv
[i
]);
6777 strcpy(buffer
,argv
[i
]);
6783 printmsg("Parameter missed...\n");
6787 } else { /* MMS things */
6794 t_time2
= Fill_Time_T(DT2
,8);
6796 GSM_GetCurrentDateTime(&DT
);
6797 t_time1
= Fill_Time_T(DT
,8);
6799 sprintf(buffer
,"%07X %07X ",(int)(t_time1
-t_time2
-40),(int)(t_time1
-t_time2
-40));
6801 sprintf(buffer
,"2A947BD 2A947DB ");
6803 /* 40 = inbox "multimedia message received" message */
6804 /* 30 = outbox sending failed */
6805 if (mystrncasecmp(argv
[2],"MMSUnreadInbox",0)) strcat(buffer
,"43 ");
6806 else if (mystrncasecmp(argv
[2],"MMSReadInbox",0)) strcat(buffer
,"50 ");
6807 else if (mystrncasecmp(argv
[2],"MMSOutbox",0)) strcat(buffer
,"10 ");
6808 else if (mystrncasecmp(argv
[2],"MMSSent",0)) strcat(buffer
,"20 ");
6809 else if (mystrncasecmp(argv
[2],"MMSDrafts",0)) strcat(buffer
,"61 ");
6811 if (!mystrncasecmp(argv
[2],"MMSOutbox",0) &&
6812 !mystrncasecmp(argv
[2],"MMSSent",0)) {
6813 sprintf(Name
,"%s",argv
[4]);
6814 strcat(buffer
,Name
);
6817 sprintf(Name
,"%zd%s/TYPE=PLMN",strlen(argv
[5])+10,argv
[5]);
6818 strcat(buffer
,Name
);
6824 error
= GSM_ReadFile(argv
[3], &File
);
6826 if (ModEmpty
) File
.ModifiedEmpty
= true;
6828 strcpy(File
.ID_FullName
,Files
.ID_FullName
);
6829 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
6830 GSM_IdentifyFileFormat(&File
);
6832 if (mystrncasecmp(argv
[2],"Gallery",0) || mystrncasecmp(argv
[2],"Tones",0)) {
6833 } else { /* MMS things */
6834 File
.Type
= GSM_File_MMS
;
6838 dbgprintf("Adding file to filesystem now\n");
6841 while (error
== GE_NONE
) {
6842 error
= Phone
->AddFilePart(&s
,&File
,&Pos
);
6843 if (error
!= GE_EMPTY
&& error
!= GE_WRONGCRC
) Print_Error(error
);
6844 if (File
.Used
!= 0) printmsgerr("%cWriting file: %i percent",13,Pos
*100/File
.Used
);
6847 if (error
== GE_WRONGCRC
) {
6848 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6855 static void DeleteFiles(int argc
, char *argv
[])
6861 for (i
=2;i
<argc
;i
++) {
6862 error
= Phone
->DeleteFile(&s
,argv
[i
]);
6869 static void SaveMMSFile(int argc
, char *argv
[])
6872 unsigned char Buffer
[50000],Buffer2
[20][2010];
6873 int i
,nextlong
= 0,len
= 0;
6874 GSM_EncodeMultiPartMMSInfo Info
;
6876 GSM_ClearMultiPartMMSInfo(&Info
);
6878 for (i
=3;i
<argc
;i
++) {
6881 if (mystrncasecmp(argv
[i
],"-subject",0)) {
6885 if (mystrncasecmp(argv
[i
],"-text",0)) {
6889 if (mystrncasecmp(argv
[i
],"-from",0)) {
6893 if (mystrncasecmp(argv
[i
],"-to",0)) {
6897 printmsg("Unknown parameter (\"%s\")\n",argv
[i
]);
6900 case 1: /* Subject */
6901 EncodeUnicode(Info
.Subject
,argv
[i
],strlen(argv
[i
]));
6905 EncodeUnicode(Buffer2
[Info
.EntriesNum
],argv
[i
],strlen(argv
[i
]));
6906 Info
.Entries
[Info
.EntriesNum
].ID
= MMS_Text
;
6907 Info
.Entries
[Info
.EntriesNum
].Buffer
= Buffer2
[Info
.EntriesNum
];
6912 EncodeUnicode(Info
.Source
,argv
[i
],strlen(argv
[i
]));
6916 EncodeUnicode(Info
.Destination
,argv
[i
],strlen(argv
[i
]));
6922 printmsg("Parameter missed...\n");
6926 GSM_EncodeMMSFile(&Info
,Buffer
,&len
);
6928 file
= fopen(argv
[2],"wb");
6929 if (file
== NULL
) Print_Error(GE_CANTOPENFILE
);
6930 fwrite(Buffer
,1,len
,file
);
6934 static void CallDivert(int argc
, char *argv
[])
6936 GSM_MultiCallDivert cd
;
6938 if (mystrncasecmp("get", argv
[2],0)) {}
6939 else if (mystrncasecmp("set", argv
[2],0)) {}
6941 printmsg("Unknown divert action (\"%s\")\n",argv
[2]);
6945 if (mystrncasecmp("all" , argv
[3],0)) {cd
.Request
.DType
= GSM_CDV_AllTypes
;}
6946 else if (mystrncasecmp("busy" , argv
[3],0)) {cd
.Request
.DType
= GSM_CDV_Busy
;}
6947 else if (mystrncasecmp("noans" , argv
[3],0)) {cd
.Request
.DType
= GSM_CDV_NoAnswer
;}
6948 else if (mystrncasecmp("outofreach", argv
[3],0)) {cd
.Request
.DType
= GSM_CDV_OutOfReach
;}
6950 printmsg("Unknown divert type (\"%s\")\n",argv
[3]);
6954 if (mystrncasecmp("all" , argv
[4],0)) {cd
.Request
.CType
= GSM_CDV_AllCalls
;}
6955 else if (mystrncasecmp("voice", argv
[4],0)) {cd
.Request
.CType
= GSM_CDV_VoiceCalls
;}
6956 else if (mystrncasecmp("fax" , argv
[4],0)) {cd
.Request
.CType
= GSM_CDV_FaxCalls
;}
6957 else if (mystrncasecmp("data" , argv
[4],0)) {cd
.Request
.CType
= GSM_CDV_DataCalls
;}
6959 printmsg("Unknown call type (\"%s\")\n",argv
[4]);
6965 if (mystrncasecmp("get", argv
[2],0)) {
6966 error
= Phone
->GetCallDivert(&s
,&cd
);
6968 printmsg("Query:\n Divert type: ");
6970 cd
.Request
.Number
[0] = 0;
6971 cd
.Request
.Number
[1] = 0;
6972 if (argc
> 5) EncodeUnicode(cd
.Request
.Number
,argv
[5],strlen(argv
[5]));
6974 cd
.Request
.Timeout
= 0;
6975 if (argc
> 6) cd
.Request
.Timeout
= atoi(argv
[6]);
6977 error
= Phone
->SetCallDivert(&s
,&cd
);
6979 printmsg("Changed:\n Divert type: ");
6982 switch (cd
.Request
.DType
) {
6983 case GSM_CDV_Busy
: printmsg("when busy"); break;
6984 case GSM_CDV_NoAnswer
: printmsg("when not answered"); break;
6985 case GSM_CDV_OutOfReach
: printmsg("when phone off or no coverage"); break;
6986 case GSM_CDV_AllTypes
: printmsg("all types of diverts"); break;
6987 default : printmsg("unknown %i",cd
.Request
.DType
); break;
6989 printmsg("\n Calls type : ");
6990 switch (cd
.Request
.CType
) {
6991 case GSM_CDV_VoiceCalls
: printmsg("voice"); break;
6992 case GSM_CDV_FaxCalls
: printmsg("fax"); break;
6993 case GSM_CDV_DataCalls
: printmsg("data"); break;
6994 case GSM_CDV_AllCalls
: printmsg("data & fax & voice"); break;
6995 default : printmsg("unknown %i",cd
.Request
.CType
); break;
6997 printmsg("\nResponse:");
6999 for (i
=0;i
<cd
.Response
.EntriesNum
;i
++) {
7000 printmsg("\n Calls type : ");
7001 switch (cd
.Response
.Entries
[i
].CType
) {
7002 case GSM_CDV_VoiceCalls
: printmsg("voice"); break;
7003 case GSM_CDV_FaxCalls
: printmsg("fax"); break;
7004 case GSM_CDV_DataCalls
: printmsg("data"); break;
7005 default : printmsg("unknown %i",cd
.Response
.Entries
[i
].CType
);break;
7008 printmsg(" Timeout : %i seconds\n",cd
.Response
.Entries
[i
].Timeout
);
7009 printmsg(" Number : %s\n",DecodeUnicodeString(cd
.Response
.Entries
[i
].Number
));
7016 static void CancelAllDiverts(int argc
, char *argv
[])
7020 error
= Phone
->CancelAllDiverts(&s
);
7027 unsigned char Connection
[50];
7028 } OneConnectionInfo
;
7031 unsigned char Device
[50];
7032 OneConnectionInfo Connections
[6];
7037 OneDeviceInfo SearchDevices
[100];
7040 void SearchPhoneThread(OneDeviceInfo
*Info
)
7046 while(strlen(Info
->Connections
[j
].Connection
) != 0) {
7047 memcpy(&Info
->s
.di
,&s
.di
,sizeof(Debug_Info
));
7048 Info
->s
.msg
= s
.msg
;
7049 Info
->s
.ConfigNum
= 1;
7050 Info
->s
.opened
= false;
7051 Info
->s
.Config
[0].UseGlobalDebugFile
= s
.Config
[0].UseGlobalDebugFile
;
7052 Info
->s
.Config
[0].Localize
= s
.Config
[0].Localize
;
7053 Info
->s
.Config
[0].Device
= Info
->Device
;
7054 Info
->s
.Config
[0].Connection
= Info
->Connections
[j
].Connection
;
7055 Info
->s
.Config
[0].SyncTime
= "no";
7056 Info
->s
.Config
[0].DebugFile
= s
.Config
[0].DebugFile
;
7057 Info
->s
.Config
[0].Model
[0] = 0;
7058 strcpy(Info
->s
.Config
[0].DebugLevel
,s
.Config
[0].DebugLevel
);
7059 Info
->s
.Config
[0].LockDevice
= "no";
7060 Info
->s
.Config
[0].StartInfo
= "no";
7062 error
= GSM_InitConnection(&Info
->s
,1);
7063 if (SearchOutput
) printf("Connection \"%s\" on device \"%s\"\n",Info
->Connections
[j
].Connection
,Info
->Device
);
7064 if (error
== GE_NONE
) {
7065 error
=Info
->s
.Phone
.Functions
->GetManufacturer(&Info
->s
);
7066 if (error
== GE_NONE
) {
7067 error
=Info
->s
.Phone
.Functions
->GetModel(&Info
->s
);
7068 if (error
== GE_NONE
) {
7069 if (!SearchOutput
) printf("Connection \"%s\" on device \"%s\"\n",Info
->Connections
[j
].Connection
,Info
->Device
);
7070 printmsg(" Manufacturer : %s\n",
7071 Info
->s
.Phone
.Data
.Manufacturer
);
7072 printmsg(" Model : %s (%s)\n",
7073 Info
->s
.Phone
.Data
.ModelInfo
->model
,
7074 Info
->s
.Phone
.Data
.Model
);
7076 if (SearchOutput
) printf(" %s\n",print_error(error
,Info
->s
.di
.df
,Info
->s
.msg
));
7079 if (SearchOutput
) printf(" %s\n",print_error(error
,Info
->s
.di
.df
,Info
->s
.msg
));
7082 if (SearchOutput
) printf(" %s\n",print_error(error
,Info
->s
.di
.df
,Info
->s
.msg
));
7084 if (error
!= GE_DEVICEOPENERROR
) {
7085 GSM_TerminateConnection(&Info
->s
);
7086 dbgprintf("Closing done\n");
7088 if (error
== GE_DEVICEOPENERROR
|| error
== GE_NONE
) break;
7094 #if defined(WIN32) || defined(HAVE_PTHREAD)
7096 pthread_t Thread
[100];
7099 void MakeSearchThread(int i
)
7103 if (pthread_create(&Thread
[i
],NULL
,(void *)SearchPhoneThread
,&SearchDevices
[i
])!=0) {
7104 dbgprintf("Error creating thread\n");
7107 if (CreateThread((LPSECURITY_ATTRIBUTES
)NULL
,0,
7108 (LPTHREAD_START_ROUTINE
)SearchPhoneThread
,&SearchDevices
[i
],
7110 dbgprintf("Error creating thread\n");
7115 static void SearchPhone(int argc
, char *argv
[])
7117 int i
,dev
= 0, dev2
= 0;
7119 SearchOutput
= false;
7120 if (argc
== 3 && mystrncasecmp(argv
[2], "-debug",0)) SearchOutput
= true;
7124 # ifdef GSM_ENABLE_IRDADEVICE
7125 sprintf(SearchDevices
[dev
].Device
,"");
7126 sprintf(SearchDevices
[dev
].Connections
[0].Connection
,"irdaphonet");
7127 SearchDevices
[dev
].Connections
[1].Connection
[0] = 0;
7130 # ifdef GSM_ENABLE_SERIALDEVICE
7133 sprintf(SearchDevices
[dev2
].Device
,"com%i:",i
+1);
7134 sprintf(SearchDevices
[dev2
].Connections
[0].Connection
,"fbusdlr3");
7135 sprintf(SearchDevices
[dev2
].Connections
[1].Connection
,"fbus");
7136 sprintf(SearchDevices
[dev2
].Connections
[2].Connection
,"at19200");
7137 sprintf(SearchDevices
[dev2
].Connections
[3].Connection
,"mbus");
7138 SearchDevices
[dev2
].Connections
[4].Connection
[0] = 0;
7144 # ifdef GSM_ENABLE_IRDADEVICE
7146 sprintf(SearchDevices
[dev
].Device
,"/dev/ircomm%i",i
);
7147 sprintf(SearchDevices
[dev
].Connections
[0].Connection
,"irdaphonet");
7148 sprintf(SearchDevices
[dev
].Connections
[1].Connection
,"at19200");
7149 SearchDevices
[dev
].Connections
[2].Connection
[0] = 0;
7153 # ifdef GSM_ENABLE_SERIALDEVICE
7156 sprintf(SearchDevices
[dev2
].Device
,"/dev/ttyS%i",i
);
7157 sprintf(SearchDevices
[dev2
].Connections
[0].Connection
,"fbusdlr3");
7158 sprintf(SearchDevices
[dev2
].Connections
[1].Connection
,"fbus");
7159 sprintf(SearchDevices
[dev2
].Connections
[2].Connection
,"at19200");
7160 sprintf(SearchDevices
[dev2
].Connections
[3].Connection
,"mbus");
7161 SearchDevices
[dev2
].Connections
[4].Connection
[0] = 0;
7165 sprintf(SearchDevices
[dev2
].Device
,"/dev/ttyD00%i",i
);
7166 sprintf(SearchDevices
[dev2
].Connections
[0].Connection
,"fbusdlr3");
7167 sprintf(SearchDevices
[dev2
].Connections
[1].Connection
,"fbus");
7168 sprintf(SearchDevices
[dev2
].Connections
[2].Connection
,"at19200");
7169 sprintf(SearchDevices
[dev2
].Connections
[3].Connection
,"mbus");
7170 SearchDevices
[dev2
].Connections
[4].Connection
[0] = 0;
7174 sprintf(SearchDevices
[dev2
].Device
,"/dev/usb/tts/%i",i
);
7175 sprintf(SearchDevices
[dev2
].Connections
[0].Connection
,"fbusdlr3");
7176 sprintf(SearchDevices
[dev2
].Connections
[1].Connection
,"fbus");
7177 sprintf(SearchDevices
[dev2
].Connections
[2].Connection
,"at19200");
7178 sprintf(SearchDevices
[dev2
].Connections
[3].Connection
,"mbus");
7179 SearchDevices
[dev2
].Connections
[4].Connection
[0] = 0;
7184 for(i
=0;i
<dev
;i
++) MakeSearchThread(i
);
7185 while (1) {if (num
== 0) break;my_sleep(5);}
7186 for(i
=dev
;i
<dev2
;i
++) MakeSearchThread(i
);
7187 while (1) {if (num
== 0) break;my_sleep(5);}
7189 #endif /*Support for threads */
7191 static void NokiaGetADC(int argc
, char *argv
[])
7195 #ifdef GSM_ENABLE_NOKIA_DCT3
7196 DCT3GetADC(argc
,argv
);
7198 #ifdef GSM_ENABLE_NOKIA_DCT4
7199 DCT4GetADC(argc
, argv
);
7205 static void NokiaDisplayTest(int argc
, char *argv
[])
7209 #ifdef GSM_ENABLE_NOKIA_DCT3
7210 DCT3DisplayTest(argc
,argv
);
7212 #ifdef GSM_ENABLE_NOKIA_DCT4
7213 DCT4DisplayTest(argc
, argv
);
7219 static void NokiaGetT9(int argc
, char *argv
[])
7223 #ifdef GSM_ENABLE_NOKIA_DCT3
7224 DCT3GetT9(argc
,argv
);
7226 #ifdef GSM_ENABLE_NOKIA_DCT4
7227 DCT4GetT9(argc
, argv
);
7233 static void NokiaVibraTest(int argc
, char *argv
[])
7237 #ifdef GSM_ENABLE_NOKIA_DCT3
7238 DCT3VibraTest(argc
,argv
);
7240 #ifdef GSM_ENABLE_NOKIA_DCT4
7241 DCT4VibraTest(argc
, argv
);
7247 static GSM_Parameters Parameters
[] = {
7248 {"--identify", 0, 0, Identify
, {H_Info
,0}, ""},
7249 {"--version", 0, 0, Version
, {H_Other
,0}, ""},
7250 {"--getdisplaystatus", 0, 0, GetDisplayStatus
, {H_Info
,0}, ""},
7251 {"--monitor", 0, 1, Monitor
, {H_Info
,H_Network
,H_Call
,0}, "[times]"},
7252 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin
, {H_Network
,0}, ""},
7253 {"--listnetworks", 0, 0, ListNetworks
, {H_Network
,0}, ""},
7254 {"--getgprspoint", 1, 2, GetGPRSPoint
, {H_Nokia
,H_Network
,0}, "start [stop]"},
7255 {"--addfolder", 2, 2, AddFolder
, {H_Filesystem
,0}, "parentfolderID name"},
7256 {"--getfilesystem", 0, 1, GetFileSystem
, {H_Filesystem
,0}, "[-flatall|-flat]"},
7257 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus
, {H_Filesystem
,0}, ""},
7258 {"--getfiles", 1,40, GetFiles
, {H_Filesystem
,0}, ""},
7259 {"--addfile", 2, 6, AddFile
, {H_Filesystem
,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP][-readonly][-protected][-system][-hidden][-newtime]"},
7260 {"--nokiaaddfile", 2, 5, NokiaAddFile
, {H_Filesystem
,H_Nokia
,0}, "MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"},
7261 {"--nokiaaddfile", 2, 5, NokiaAddFile
, {H_Filesystem
,H_Nokia
,0}, "Application|Game file [-readonly]"},
7262 {"--nokiaaddfile", 2, 5, NokiaAddFile
, {H_Filesystem
,H_Nokia
,0}, "Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
7263 {"--deletefiles", 1,20, DeleteFiles
, {H_Filesystem
,0}, "fileID"},
7264 {"--playringtone", 1, 1, PlayRingtone
, {H_Ringtone
,0}, "file"},
7265 {"--getdatetime", 0, 0, GetDateTime
, {H_DateTime
,0}, ""},
7266 {"--setdatetime", 0, 0, SetDateTime
, {H_DateTime
,0}, ""},
7267 {"--getalarm", 0, 0, GetAlarm
, {H_DateTime
,0}, ""},
7268 {"--setalarm", 2, 2, SetAlarm
, {H_DateTime
,0}, "hour minute"},
7269 {"--resetphonesettings", 1, 1, ResetPhoneSettings
, {H_Settings
,0}, "PHONE|DEV|UIF|ALL|FACTORY"},
7270 {"--getmemory", 2, 3, GetMemory
, {H_Memory
,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"},
7271 {"--getallmemory", 1, 1, GetAllMemory
, {H_Memory
,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
7272 {"--searchmemory", 1, 1, SearchMemory
, {H_Memory
,0}, "text"},
7273 {"--listmemorycategory", 1, 1, ListMemoryCategory
, {H_Memory
, H_Category
,0}, "text|number"},
7274 {"--getfmstation", 1, 2, GetFMStation
, {H_FM
,0}, "start [stop]"},
7275 {"--getsmsc", 1, 2, GetSMSC
, {H_SMS
,0}, "start [stop]"},
7276 {"--getsms", 2, 3, GetSMS
, {H_SMS
,0}, "folder start [stop]"},
7277 {"--deletesms", 2, 3, DeleteSMS
, {H_SMS
,0}, "folder start [stop]"},
7278 {"--deleteallsms", 1, 1, DeleteAllSMS
, {H_SMS
,0}, "folder"},
7279 {"--getsmsfolders", 0, 0, GetSMSFolders
, {H_SMS
,0}, ""},
7280 {"--getallsms", 0, 0, GetAllSMS
, {H_SMS
,0}, ""},
7281 {"--geteachsms", 0, 0, GetEachSMS
, {H_SMS
,0}, ""},
7283 #define SMS_TEXT_OPTIONS "[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]"
7284 #define SMS_PICTURE_OPTIONS "[-text text][-unicode]"
7285 #define SMS_PROFILE_OPTIONS "[-name name][-bitmap bitmap][-ringtone ringtone]"
7286 #define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]"
7287 #define SMS_OPERATOR_OPTIONS "[-netcode netcode][-biglogo]"
7288 #define SMS_SAVE_OPTIONS "[-folder id][-unread][-read][-unsent][-sent][-sender number]"
7289 #define SMS_SEND_OPTIONS "[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX]"
7290 #define SMS_COMMON_OPTIONS "[-smscset number][-smscnumber number][-reply][-maxsms num]"
7292 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS
},
7293 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_Ringtone
,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7294 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_Logo
,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS
},
7295 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_Logo
,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7296 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_Logo
,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS
},
7297 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_MMS
,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7298 #ifdef GSM_ENABLE_BACKUP
7299 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_WAP
,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7300 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_WAP
,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7301 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_MMS
,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7302 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_Calendar
,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7303 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_ToDo
,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7304 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_Memory
,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS
},
7306 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,H_Settings
,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS
},
7307 {"--savesms", 1,30, SendSaveDisplaySMS
, {H_SMS
,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS
},
7309 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS
},
7310 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_Ringtone
,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7311 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_Logo
,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS
},
7312 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_Logo
,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7313 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_Logo
,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS
},
7314 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_MMS
,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7315 #ifdef GSM_ENABLE_BACKUP
7316 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_WAP
,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7317 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_WAP
,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7318 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_MMS
,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7319 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_Calendar
,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7320 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_ToDo
,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7321 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_Memory
,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
},
7323 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,H_Settings
,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS
""SMS_PROFILE_OPTIONS
},
7324 {"--sendsms", 2,30, SendSaveDisplaySMS
, {H_SMS
,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS
},
7326 {"--displaysms", 2,30, SendSaveDisplaySMS
, {H_SMS
,0}, ""},
7328 {"--addsmsfolder", 1, 1, AddSMSFolder
, {H_SMS
,0}, "name"},
7329 {"--smsd", 2, 2, SMSDaemon
, {H_SMS
,H_Other
,0}, "FILES configfile"},
7330 {"--getringtone", 1, 2, GetRingtone
, {H_Ringtone
,0}, "location [file]"},
7331 {"--getphoneringtone", 1, 2, GetRingtone
, {H_Ringtone
,0}, "location [file]"},
7332 {"--getringtoneslist", 0, 0, GetRingtonesList
, {H_Ringtone
,0}, ""},
7333 {"--setringtone", 1, 6, SetRingtone
, {H_Ringtone
,0}, "file [-location location][-scale][-name name]"},
7334 {"--nokiacomposer", 1, 1, NokiaComposer
, {H_Ringtone
,H_Nokia
,0}, "file"},
7335 {"--copyringtone", 2, 3, CopyRingtone
, {H_Ringtone
,0}, "source destination [RTTL|BINARY]"},
7336 {"--dialvoice", 1, 2, DialVoice
, {H_Call
,0}, "number [show|hide]"},
7337 {"--getspeeddial", 1, 2, GetSpeedDial
, {H_Call
,H_Memory
,0}, "start [stop]"},
7338 {"--cancelcall", 0, 1, CancelCall
, {H_Call
,0}, "[ID]"},
7339 {"--answercall", 0, 1, AnswerCall
, {H_Call
,0}, "[ID]"},
7340 {"--unholdcall", 1, 1, UnholdCall
, {H_Call
,0}, "ID"},
7341 {"--holdcall", 1, 1, HoldCall
, {H_Call
,0}, "ID"},
7342 {"--conferencecall", 1, 1, ConferenceCall
, {H_Call
,0}, "ID"},
7343 {"--splitcall", 1, 1, SplitCall
, {H_Call
,0}, "ID"},
7344 {"--switchcall", 0, 1, SwitchCall
, {H_Call
,0}, "[ID]"},
7345 {"--transfercall", 0, 1, TransferCall
, {H_Call
,0}, "[ID]"},
7346 {"--divert", 3, 5, CallDivert
, {H_Call
,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"},
7347 {"--canceldiverts", 0, 0, CancelAllDiverts
, {H_Call
,0}, ""},
7348 {"--senddtmf", 1, 1, SendDTMF
, {H_Call
,0}, "sequence"},
7349 {"--getcalendarsettings", 0, 0, GetCalendarSettings
, {H_Calendar
,H_Settings
,0}, ""},
7350 {"--getalltodo", 0, 0, GetAllToDo
, {H_ToDo
,0}, ""},
7351 {"--listtodocategory", 1, 1, ListToDoCategory
, {H_ToDo
, H_Category
,0}, "text|number"},
7352 {"--gettodo", 1, 2, GetToDo
, {H_ToDo
,0}, "start [stop]"},
7353 {"--deletetodo", 1, 2, DeleteToDo
, {H_ToDo
,0}, "start [stop]"},
7354 {"--getnote", 1, 2, GetNote
, {H_Note
,0}, "start [stop]"},
7355 {"--deletecalendar", 1, 2, DeleteCalendar
, {H_Calendar
,0}, "start [stop]"},
7356 {"--getallcalendar", 0, 0, GetAllCalendar
, {H_Calendar
,0}, ""},
7357 {"--getcalendar", 1, 2, GetCalendar
, {H_Calendar
,0}, "start [stop]"},
7358 {"--getcategory", 2, 3, GetCategory
, {H_Category
,H_ToDo
,H_Memory
,0}, "TODO|PHONEBOOK start [stop]"},
7359 {"--getallcategory", 1, 1, GetAllCategories
, {H_Category
,H_ToDo
,H_Memory
,0}, "TODO|PHONEBOOK"},
7360 {"--reset", 1, 1, Reset
, {H_Other
,0}, "SOFT|HARD"},
7361 {"--getprofile", 1, 2, GetProfile
, {H_Settings
,0}, "start [stop]"},
7362 {"--getsecuritystatus", 0, 0, GetSecurityStatus
, {H_Info
,0}, ""},
7363 {"--entersecuritycode", 2, 2, EnterSecurityCode
, {H_Other
,0}, "PIN|PUK|PIN2|PUK2 code"},
7364 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark
, {H_WAP
,0}, "start [stop]"},
7365 {"--getwapbookmark", 1, 2, GetWAPBookmark
, {H_WAP
,0}, "start [stop]"},
7366 {"--getwapsettings", 1, 2, GetWAPMMSSettings
, {H_WAP
,0}, "start [stop]"},
7367 {"--getmmssettings", 1, 2, GetWAPMMSSettings
, {H_MMS
,0}, "start [stop]"},
7368 {"--savemmsfile", 3, 15,SaveMMSFile
, {H_MMS
,0}, "file [-subject text][-text text]"},
7369 {"--getbitmap", 1, 3, GetBitmap
, {H_Logo
,0}, "STARTUP [file]"},
7370 {"--getbitmap", 1, 3, GetBitmap
, {H_Logo
,0}, "CALLER location [file]"},
7371 {"--getbitmap", 1, 3, GetBitmap
, {H_Logo
,0}, "OPERATOR [file]"},
7372 {"--getbitmap", 1, 3, GetBitmap
, {H_Logo
,0}, "PICTURE location [file]"},
7373 {"--getbitmap", 1, 3, GetBitmap
, {H_Logo
,0}, "TEXT"},
7374 {"--getbitmap", 1, 3, GetBitmap
, {H_Logo
,0}, "DEALER"},
7375 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "STARTUP file|1|2|3"},
7376 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "COLOURSTARTUP [fileID]"},
7377 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "WALLPAPER fileID"},
7378 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "CALLER location [file]"},
7379 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "OPERATOR [file [netcode]]"},
7380 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "COLOUROPERATOR [fileID [netcode]]"},
7381 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "PICTURE file location [text]"},
7382 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "TEXT text"},
7383 {"--setbitmap", 1, 4, SetBitmap
, {H_Logo
,0}, "DEALER text"},
7384 {"--copybitmap", 1, 3, CopyBitmap
, {H_Logo
,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"},
7385 {"--presskeysequence", 1, 1, PressKeySequence
, {H_Other
,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"},
7386 #if defined(WIN32) || defined(HAVE_PTHREAD)
7387 {"--searchphone", 0, 1, SearchPhone
, {H_Other
,0}, "[-debug]"},
7389 #ifdef GSM_ENABLE_BACKUP
7390 {"--savefile", 4, 5, SaveFile
, {H_Backup
,H_Calendar
,0}, "CALENDAR target.vcs file location"},
7391 {"--savefile", 4, 5, SaveFile
, {H_Backup
,H_ToDo
,0}, "TODO target.vcs file location"},
7392 {"--savefile", 4, 5, SaveFile
, {H_Backup
,H_Memory
,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"},
7393 {"--savefile", 4, 5, SaveFile
, {H_Backup
,H_WAP
,0}, "BOOKMARK target.url file location"},
7394 {"--backup", 1, 1, Backup
, {H_Backup
,H_Memory
,H_Calendar
,H_ToDo
,H_Category
,H_Ringtone
,H_WAP
,H_FM
,0}, "file"},
7395 {"--backupsms", 1, 1, BackupSMS
, {H_Backup
,H_SMS
,0}, "file"},
7396 {"--restore", 1, 1, Restore
, {H_Backup
,H_Memory
,H_Calendar
,H_ToDo
,H_Category
,H_Ringtone
,H_WAP
,H_FM
,0}, "file"},
7397 {"--addnew", 1, 1, AddNew
, {H_Backup
,H_Memory
,H_Calendar
,H_ToDo
,H_Category
,H_Ringtone
,H_WAP
,H_FM
,0}, "file"},
7398 {"--restoresms", 1, 1, RestoreSMS
, {H_Backup
,H_SMS
,0}, "file"},
7400 {"--clearall", 0, 0, ClearAll
, {H_Memory
,H_Calendar
,H_ToDo
,H_Category
,H_Ringtone
,H_WAP
,H_FM
,0}, ""},
7401 #ifdef GSM_ENABLE_AT
7402 {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon
, {H_Siemens
,H_Network
,0}, ""},
7403 {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor
, {H_Siemens
,H_Network
,0}, "test"},
7405 #ifdef GSM_ENABLE_NOKIA6110
7406 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName
, {H_Nokia
,H_Network
,0}, ""},
7407 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName
, {H_Nokia
,H_Network
,0}, "[networkcode name]"},
7408 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput
, {H_Nokia
,0}, ""},
7410 #ifdef GSM_ENABLE_NOKIA_DCT3
7411 {"--nokianetmonitor", 1, 1, DCT3netmonitor
, {H_Nokia
,H_Network
,0}, "test"},
7412 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36
, {H_Nokia
,0}, ""},
7413 {"--nokiadebug", 1, 2, DCT3SetDebug
, {H_Nokia
,H_Network
,0}, "filename [[v11-22][,v33-44]...]"},
7415 #ifdef GSM_ENABLE_NOKIA_DCT4
7416 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel
, {H_Nokia
,H_Other
,0}, "level"},
7417 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord
, {H_Nokia
,H_Other
,0}, "location"},
7418 {"--nokiasetlights", 2, 2, DCT4SetLight
, {H_Nokia
,H_Tests
,0}, "keypad|display|torch on|off"},
7419 {"--nokiatuneradio", 0, 0, DCT4TuneRadio
, {H_Nokia
,H_FM
,0}, ""},
7421 #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
7422 {"--nokiavibratest", 0, 0, NokiaVibraTest
, {H_Nokia
,H_Tests
,0}, ""},
7423 {"--nokiagett9", 0, 0, NokiaGetT9
, {H_Nokia
,H_SMS
,0}, ""},
7424 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest
, {H_Nokia
,H_Tests
,0}, "number"},
7425 {"--nokiagetadc", 0, 0, NokiaGetADC
, {H_Nokia
,H_Tests
,0}, ""},
7426 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode
, {H_Nokia
,H_Info
,0}, ""},
7427 {"--nokiaselftests", 0, 0, NokiaSelfTests
, {H_Nokia
,H_Tests
,0}, ""},
7428 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus
, {H_Nokia
,H_Other
,0}, ""},
7431 {"--decodesniff", 2, 3, decodesniff
, {H_Decode
,0}, "MBUS2|IRDA file [phonemodel]"},
7432 {"--decodebinarydump", 1, 2, decodebinarydump
, {H_Decode
,0}, "file [phonemodel]"},
7433 {"--makeconverttable", 1, 1, MakeConvertTable
, {H_Decode
,0}, "file"},
7438 static HelpCategoryDescriptions HelpDescriptions
[] = {
7439 {H_Call
, "call", "Calls",},
7440 {H_SMS
, "sms", "SMS and EMS"},
7441 {H_Memory
, "memory", "Memory (phonebooks and calls)"},
7442 {H_Filesystem
, "filesystem", "Filesystem"},
7443 {H_Logo
, "logo", "Logo and pictures"},
7444 {H_Ringtone
, "ringtone", "Ringtones"},
7445 {H_Calendar
, "calendar", "Calendar notes"},
7446 {H_ToDo
, "todo", "To do lists"},
7447 {H_Note
, "note", "Notes"},
7448 {H_DateTime
, "datetime", "Date, time and alarms"},
7449 {H_Category
, "category", "Categories"},
7450 #ifdef GSM_ENABLE_BACKUP
7451 {H_Backup
, "backup", "Backing up and restoring"},
7453 #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
7454 {H_Nokia
, "nokia", "Nokia specific"},
7456 #ifdef GSM_ENABLE_AT
7457 {H_Siemens
, "siemens", "Siemens specific"},
7459 {H_Network
, "network", "Network"},
7460 {H_WAP
, "wap", "WAP settings and bookmarks"},
7461 {H_MMS
, "mms", "MMS and MMS settings"},
7462 {H_Tests
, "tests", "Phone tests"},
7463 {H_FM
, "fm", "FM radio"},
7464 {H_Info
, "info", "Phone information"},
7465 {H_Settings
, "settings", "Phone settings"},
7467 {H_Decode
, "decode", "Dumps decoding"},
7469 {H_Other
, "other", "Functions that don't fit elsewhere"},
7474 void HelpHeader(void)
7476 printmsg("[Gammu version %s built %s %s]\n\n",VERSION
,__TIME__
,__DATE__
);
7479 static void HelpGeneral(void)
7485 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n");
7486 printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n");
7487 printmsg("Second parameter optionally controls debug level, next specify actions.\n\n");
7489 /* We might want to put here some most used commands */
7490 printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n");
7492 while (HelpDescriptions
[i
].category
!= 0) {
7493 printf("%11s - %s\n", HelpDescriptions
[i
].option
, HelpDescriptions
[i
].description
);
7499 static void HelpSplit(int cols
, int len
, unsigned char *buff
)
7501 int l
, len2
, pos
, split
;
7502 bool in_opt
,first
=true;
7503 char *remain
, spaces
[50], buffer
[500];
7506 printf(" %s\n", buff
);
7510 len2
= strlen(buff
);
7511 if (len
+ len2
< cols
) {
7512 printf("%s\n", buff
);
7514 for(l
= 0; l
< len
; l
++) strcat(spaces
, " ");
7518 while (strlen(remain
) > 0) {
7522 if (!first
) printf(spaces
);
7523 while (pos
< cols
- len
&& remain
[pos
] != 0) {
7524 if (in_opt
&& remain
[pos
] == ']') {
7527 } else if (remain
[pos
] == '[') {
7529 } else if (!in_opt
&& remain
[pos
] == ' ') {
7534 /* Can not be split */
7536 printf("%s\n", remain
);
7537 remain
+= strlen(remain
);
7541 strncpy(buffer
, remain
, split
);
7543 printf("%s\n", buffer
);
7545 if (remain
[0] == ' ') remain
++;
7552 static void Help(int argc
, char *argv
[])
7554 int i
= 0, j
= 0, k
, cols
;
7559 #if defined(WIN32) || defined(DJGPP)
7570 if (!strcmp(argv
[2],"all")) {
7573 while (HelpDescriptions
[i
].category
!= 0) {
7574 if (strcmp(argv
[2], HelpDescriptions
[i
].option
) == 0) break;
7577 if (HelpDescriptions
[i
].category
== 0) {
7579 printmsg("Unknown help topic specified!\n");
7583 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions
[i
].description
);
7586 #if defined(WIN32) || defined(DJGPP)
7590 /* If stdout is a tty, we will wrap to columns it has */
7593 if (ioctl(2, TIOCGWINSZ
, &w
) == 0) {
7594 if (w
.ws_col
> 0) cols
= w
.ws_col
;
7598 columns
= getenv("COLUMNS");
7599 if (columns
!= NULL
) {
7600 cols
= atoi(columns
);
7601 if (cols
<= 0) cols
= 0;
7612 while (Parameters
[j
].Function
!= NULL
) {
7615 if (!strcmp(argv
[2],"all")) {
7616 if (j
==0) disp
= true;
7618 if (strcmp(Parameters
[j
].help
,Parameters
[j
-1].help
)) {
7621 if (strcmp(Parameters
[j
].parameter
,Parameters
[j
-1].parameter
)) {
7627 while (Parameters
[j
].help_cat
[k
] != 0) {
7628 if (Parameters
[j
].help_cat
[k
] == HelpDescriptions
[i
].category
) {
7636 printf("%s", Parameters
[j
].parameter
);
7637 if (Parameters
[j
].help
[0] == 0) {
7640 HelpSplit(cols
- 1, strlen(Parameters
[j
].parameter
) + 1, Parameters
[j
].help
);
7647 int main(int argc
, char *argv
[])
7649 int z
= 0,start
=0,i
;
7650 int only_config
= -1;
7651 #if !defined(WIN32) && defined(LOCALE_PATH)
7652 char *locale
, locale_file
[201];
7655 bool count_failed
= false;
7661 setlocale(LC_ALL
, "");
7667 /* Any parameters? */
7670 printmsg("Too few parameters!\n");
7675 if (strncmp(argv
[1 + start
], "--help", 6) == 0) {
7676 Help(argc
- start
, argv
+ start
);
7680 /* Is first parameter numeric? If so treat it as config that should be loaded. */
7681 if (isdigit(argv
[1][0])) {
7682 only_config
= atoi(argv
[1]);
7683 if (only_config
>= 0) start
++;
7684 else only_config
= -1;
7687 cfg
=GSM_FindGammuRC();
7690 cp
= INI_GetValue(cfg
, "gammu", "gammucoding", false);
7691 if (cp
) di
.coding
= cp
;
7693 s
.Config
[i
].Localize
= INI_GetValue(cfg
, "gammu", "gammuloc", false);
7694 if (s
.Config
[i
].Localize
) {
7695 s
.msg
=INI_ReadFile(s
.Config
[i
].Localize
, true);
7697 #if !defined(WIN32) && defined(LOCALE_PATH)
7698 locale
= setlocale(LC_MESSAGES
, NULL
);
7699 if (locale
!= NULL
) {
7700 snprintf(locale_file
, 200, "%s/gammu_%c%c.txt",
7703 tolower(locale
[1]));
7704 s
.msg
= INI_ReadFile(locale_file
, true);
7710 /* Wanted user specific configuration? */
7711 if (only_config
!= -1) {
7712 /* Here we get only in first for loop */
7713 if (!GSM_ReadConfig(cfg
, &s
.Config
[0], only_config
)) break;
7715 if (!GSM_ReadConfig(cfg
, &s
.Config
[i
], i
) && i
!= 0) break;
7719 /* We want to use only one file descriptor for global and state machine debug output */
7720 s
.Config
[i
].UseGlobalDebugFile
= true;
7722 /* It makes no sense to open several debug logs... */
7724 strcpy(s
.Config
[i
].DebugLevel
, s
.Config
[0].DebugLevel
);
7725 // free(s.Config[i].DebugFile);
7726 s
.Config
[i
].DebugFile
= s
.Config
[0].DebugFile
;
7728 /* Just for first config */
7729 /* When user gave debug level on command line */
7730 if (argc
> 1 + start
&& GSM_SetDebugLevel(argv
[1 + start
], &di
)) {
7731 /* Debug level from command line will be used with phone too */
7732 strcpy(s
.Config
[i
].DebugLevel
,argv
[1 + start
]);
7735 /* Try to set debug level from config file */
7736 GSM_SetDebugLevel(s
.Config
[i
].DebugLevel
, &di
);
7738 /* If user gave debug file in gammurc, we will use it */
7739 error
=GSM_SetDebugFile(s
.Config
[i
].DebugFile
, &di
);
7743 /* We wanted to read just user specified configuration. */
7744 if (only_config
!= -1) {break;}
7747 /* Do we have enough parameters? */
7748 if (argc
== 1 + start
) {
7750 printmsg("Too few parameters!\n");
7754 /* Check used version vs. compiled */
7755 if (!mystrncasecmp(GetGammuVersion(),VERSION
,0)) {
7756 printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n",
7757 GetGammuVersion(),VERSION
);
7761 /* Check parameters */
7762 while (Parameters
[z
].Function
!= NULL
) {
7763 if (mystrncasecmp(Parameters
[z
].parameter
,argv
[1+start
], 0)) {
7764 if (argc
-2-start
>= Parameters
[z
].min_arg
&& argc
-2-start
<= Parameters
[z
].max_arg
) {
7765 Parameters
[z
].Function(argc
- start
, argv
+ start
);
7768 count_failed
= true;
7774 /* Tell user when we did nothing */
7775 if (Parameters
[z
].Function
== NULL
) {
7778 printmsg("Bad parameter count!\n");
7780 printmsg("Bad option!\n");
7784 /* Close debug output if opened */
7785 if (di
.df
!=stdout
) fclose(di
.df
);
7790 /* How should editor hadle tabs in this file? Add editor commands here.
7791 * vim: noexpandtab sw=8 ts=8 sts=8: