1 #define _GNU_SOURCE /* For strcasestr */
4 #include "../helper/locales.h"
20 #include "../helper/formats.h"
21 #include "../helper/printing.h"
22 #include "../helper/string.h"
23 #include "../helper/cmdline.h"
25 #ifdef GSM_ENABLE_NOKIA_DCT3
26 # include "depend/nokia/dct3.h"
27 # include "depend/nokia/dct3trac/wmx.h"
29 #ifdef GSM_ENABLE_NOKIA_DCT4
30 # include "depend/nokia/dct4.h"
33 void PrintNetworkInfo(GSM_NetworkInfo NetInfo
)
35 printf(LISTFORMAT
, _("Network state"));
36 switch (NetInfo
.State
) {
37 case GSM_HomeNetwork
: printf("%s\n", _("home network")); break;
38 case GSM_RoamingNetwork
: printf("%s\n", _("roaming network")); break;
39 case GSM_RequestingNetwork
: printf("%s\n", _("requesting network")); break;
40 case GSM_NoNetwork
: printf("%s\n", _("not logged into network")); break;
41 case GSM_RegistrationDenied
: printf("%s\n", _("registration to network denied")); break;
42 case GSM_NetworkStatusUnknown
: printf("%s\n", _("unknown")); break;
44 default : printf("%s\n", _("unknown"));
47 if (NetInfo
.State
== GSM_HomeNetwork
|| NetInfo
.State
== GSM_RoamingNetwork
) {
48 printf(LISTFORMAT
, _("Network"));
51 DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo
.NetworkCode
)));
53 DecodeUnicodeConsole(GSM_GetCountryName(NetInfo
.NetworkCode
)));
54 printf(", LAC %s, CID %s\n",
55 NetInfo
.LAC
,NetInfo
.CID
);
56 if (NetInfo
.NetworkName
[0] != 0x00 || NetInfo
.NetworkName
[1] != 0x00) {
57 printf(LISTFORMAT
"\"%s\"\n",
59 DecodeUnicodeConsole(NetInfo
.NetworkName
));
62 printf(LISTFORMAT
, _("Packet network state"));
63 switch (NetInfo
.PacketState
) {
64 case GSM_HomeNetwork
: printf("%s\n", _("home network")); break;
65 case GSM_RoamingNetwork
: printf("%s\n", _("roaming network")); break;
66 case GSM_RequestingNetwork
: printf("%s\n", _("requesting network")); break;
67 case GSM_NoNetwork
: printf("%s\n", _("not logged into network")); break;
68 case GSM_RegistrationDenied
: printf("%s\n", _("registration to network denied")); break;
69 case GSM_NetworkStatusUnknown
: printf("%s\n", _("unknown")); break;
71 default : printf("%s\n", _("unknown"));
74 if (NetInfo
.PacketState
== GSM_HomeNetwork
|| NetInfo
.PacketState
== GSM_RoamingNetwork
) {
75 printf(LISTFORMAT
, _("Packet network"));
78 DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo
.NetworkCode
)));
80 DecodeUnicodeConsole(GSM_GetCountryName(NetInfo
.NetworkCode
)));
81 printf(", LAC %s, CID %s\n",
82 NetInfo
.PacketLAC
, NetInfo
.PacketCID
);
83 if (NetInfo
.NetworkName
[0] != 0x00 || NetInfo
.NetworkName
[1] != 0x00) {
84 printf(LISTFORMAT
"\"%s\"\n",
86 DecodeUnicodeConsole(NetInfo
.NetworkName
));
89 if (NetInfo
.GPRS
!= 0) {
90 printf(LISTFORMAT
, _("GPRS"));
91 switch (NetInfo
.GPRS
) {
92 case GSM_GPRS_Attached
:
93 printf("%s", _("attached"));
95 case GSM_GPRS_Detached
:
96 printf("%s", _("detached"));
103 void PrintBatteryCharge(GSM_BatteryCharge
*BatteryCharge
)
105 if (BatteryCharge
->BatteryPercent
!= -1) {
106 printf(LISTFORMAT
, _("Battery level"));
107 printf(_("%i percent"), BatteryCharge
->BatteryPercent
);
110 if (BatteryCharge
->BatteryCapacity
!= -1) {
111 printf(LISTFORMAT
, _("Battery capacity"));
112 printf(_("%i mAh"), BatteryCharge
->BatteryCapacity
);
115 if (BatteryCharge
->BatteryTemperature
!= -1) {
116 printf(LISTFORMAT
, _("Battery temperature"));
117 /* l10n: This means degrees Celsius */
118 printf(_("%i C"), BatteryCharge
->BatteryTemperature
);
121 if (BatteryCharge
->PhoneTemperature
!= -1) {
122 printf(LISTFORMAT
, _("Phone temperature"));
123 printf(_("%i C"), BatteryCharge
->PhoneTemperature
);
126 if (BatteryCharge
->BatteryVoltage
!= -1) {
127 printf(LISTFORMAT
, _("Battery voltage"));
128 printf(_("%i mV"), BatteryCharge
->BatteryVoltage
);
131 if (BatteryCharge
->ChargeVoltage
!= -1) {
132 printf(LISTFORMAT
, _("Charge voltage"));
133 printf(_("%i mV"), BatteryCharge
->ChargeVoltage
);
136 if (BatteryCharge
->ChargeCurrent
!= -1) {
137 printf(LISTFORMAT
, _("Charge current"));
138 printf(_("%i mA"), BatteryCharge
->ChargeCurrent
);
141 if (BatteryCharge
->PhoneCurrent
!= -1) {
142 printf(LISTFORMAT
, _("Phone current"));
143 printf(_("%i mA"), BatteryCharge
->PhoneCurrent
);
146 if (BatteryCharge
->ChargeState
!= 0) {
147 printf(LISTFORMAT
, _("Charge state"));
148 switch (BatteryCharge
->ChargeState
) {
149 case GSM_BatteryPowered
:
150 printf("%s", _("powered from battery"));
152 case GSM_BatteryConnected
:
153 printf("%s", _("battery connected, but not powered from battery"));
155 case GSM_BatteryCharging
:
156 printf("%s", _("battery connected and is being charged"));
158 case GSM_BatteryFull
:
159 printf("%s", _("battery connected and is fully charged"));
161 case GSM_BatteryNotConnected
:
162 printf("%s", _("battery not connected"));
165 printf("%s", _("detected power failure"));
169 printf("%s", _("unknown"));
175 if (BatteryCharge
->BatteryType
!= 0) {
176 printf(LISTFORMAT
, _("Battery type"));
177 switch (BatteryCharge
->BatteryType
) {
178 case GSM_BatteryLiIon
:
179 printf("%s", _("Lithium Ion"));
181 case GSM_BatteryLiPol
:
182 printf("%s", _("Lithium Polymer"));
184 case GSM_BatteryNiMH
:
185 printf("%s", _("NiMH"));
187 case GSM_BatteryUnknown
:
191 printf("%s", _("unknown"));
198 GSM_Error
GSM_PlayRingtone(GSM_Ringtone ringtone
)
204 signal(SIGINT
, interrupt
);
205 printf("%s\n", _("Press Ctrl+C to break..."));
207 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
208 if (gshutdown
) break;
209 if (ringtone
.NoteTone
.Commands
[i
].Type
!= RING_Note
) continue;
210 error
=PHONE_RTTLPlayOneNote(gsm
,ringtone
.NoteTone
.Commands
[i
].Note
,first
);
211 if (error
!=ERR_NONE
) return error
;
215 /* Disables buzzer */
216 return GSM_PlayTone(gsm
,255*255,0,FALSE
);
219 void PlayRingtone(int argc UNUSED
, char *argv
[])
221 GSM_Ringtone ringtone
,ringtone2
;
225 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
228 error
=GSM_RingtoneConvert(&ringtone2
,&ringtone
,RING_NOTETONE
);
233 error
=GSM_PlayRingtone(ringtone2
);
240 * Get's location from OpenCellID.
242 void GetLocation(int argc UNUSED
, char *argv
[]UNUSED
)
245 char url
[70 + GSM_MAX_MODEL_LENGTH
];
248 GSM_NetworkInfo netinfo
;
249 float latitude
, longitude
;
250 long int mnc
, mcc
, lac
, cellid
, nbSamples
, range
;
251 char *ret
, *old_locale
= NULL
;
252 gboolean failure
= FALSE
;
256 /* Get model information */
257 error
= GSM_GetNetworkInfo(gsm
, &netinfo
);
260 if (netinfo
.State
== GSM_NoNetwork
) {
261 printf_err("%s", _("Not logged to network!\n"));
266 /* We need decimal numbers */
267 lac
= strtol(netinfo
.LAC
, NULL
, 16);
268 cellid
= strtol(netinfo
.CID
, NULL
, 16);
270 /* Split code to country and network (beware ncc+nmc without space) */
271 if (sscanf(netinfo
.NetworkCode
, "%3ld%ld", &mcc
, &mnc
) != 2) {
272 printf_err("%s", _("Wrong network code from phone!\n"));
277 /* Request information from OpenCellID */
278 sprintf(url
, "http://www.opencellid.org/cell/get?key=%s&mnc=%ld&mcc=%ld&lac=%ld&cellid=%ld",
280 mnc
, mcc
, lac
, cellid
);
282 OpenCell
.Buffer
= NULL
;
284 error
= GSM_ReadHTTPFile(url
, &OpenCell
);
287 /* We need to reset numeric locales because we parse floats with . as decimal separator */
288 ret
= setlocale(LC_NUMERIC
, "C");
290 old_locale
= strdup(ret
);
294 <?xml version="1.0" encoding="UTF-8"?>
296 <cell range="6000" lac="0" lat="54.4910893937777" nbSamples="46" lon="27.9390742994699" cellId="29513" mcc="250" mnc="99"/>
299 if (strstr(OpenCell
.Buffer
, "stat=\"ok\"") == NULL
) {
300 printf_err("%s", _("Request for information from OpenCellID failed!\n"));
304 pos
= strstr(OpenCell
.Buffer
, "lat=\"");
306 printf_err("%s", _("Failed to find latitude in OpenCellID reply!\n"));
310 if (sscanf(pos
, "lat=\"%f\"", &latitude
) == 0) {
311 printf_err("%s", _("Failed to parse latitude from OpenCellID reply!\n"));
315 pos
= strstr(OpenCell
.Buffer
, "lon=\"");
317 printf_err("%s", _("Failed to find longitude in OpenCellID reply!\n"));
321 if (sscanf(pos
, "lon=\"%f\"", &longitude
) == 0) {
322 printf_err("%s", _("Failed to parse longitude from OpenCellID reply!\n"));
326 pos
= strstr(OpenCell
.Buffer
, "range=\"");
328 printf_err("%s", _("Failed to find range in OpenCellID reply!\n"));
332 if (sscanf(pos
, "range=\"%ld\"", &range
) == 0) {
333 printf_err("%s", _("Failed to parse range from OpenCellID reply!\n"));
337 pos
= strstr(OpenCell
.Buffer
, "nbSamples=\"");
339 printf_err("%s", _("Failed to find nbSamples in OpenCellID reply!\n"));
343 if (sscanf(pos
, "nbSamples=\"%ld\"", &nbSamples
) == 0) {
344 printf_err("%s", _("Failed to parse nbSamples from OpenCellID reply!\n"));
350 if (old_locale
!= NULL
) {
351 setlocale(LC_NUMERIC
, old_locale
);
355 printf(LISTFORMAT
"%f\n", _("Latitude"), latitude
);
356 printf(LISTFORMAT
"%f\n", _("Longitude"), longitude
);
357 printf(LISTFORMAT
"%ld\n", _("Range"), range
);
358 printf(LISTFORMAT
"%ld\n", _("Number of samples"), nbSamples
);
361 free(OpenCell
.Buffer
);
367 void Identify(int argc
, char *argv
[])
369 char buffer
[GSM_MAX_INFO_LENGTH
];
370 char date
[GSM_MAX_VERSION_DATE_LENGTH
];
377 /* Read current configuration */
378 curcfg
= GSM_GetConfig(gsm
, -1);
379 printf(LISTFORMAT
"%s\n", _("Device"), curcfg
->Device
);
381 error
=GSM_GetManufacturer(gsm
, buffer
);
383 printf(LISTFORMAT
"%s\n", _("Manufacturer"), buffer
);
384 error
=GSM_GetModel(gsm
, buffer
);
386 printf(LISTFORMAT
"%s (%s)\n", _("Model"),
387 GSM_GetModelInfo(gsm
)->model
,
390 error
=GSM_GetFirmware(gsm
, buffer
, date
, &num
);
392 printf(LISTFORMAT
"%s", _("Firmware"), buffer
);
393 error
=GSM_GetPPM(gsm
, buffer
);
394 if (error
!= ERR_NOTSUPPORTED
) {
395 if (error
!= ERR_NOTIMPLEMENTED
) Print_Error(error
);
396 if (error
== ERR_NONE
) printf(" %s", buffer
);
398 if (date
[0] != 0) printf(" (%s)", date
);
401 error
=GSM_GetHardware(gsm
, buffer
);
402 if (error
!= ERR_NOTSUPPORTED
) {
403 if (error
!= ERR_NOTIMPLEMENTED
) Print_Error(error
);
404 if (error
== ERR_NONE
) printf(LISTFORMAT
"%s\n", _("Hardware"),buffer
);
407 error
=GSM_GetIMEI(gsm
, buffer
);
408 if (error
!= ERR_NOTSUPPORTED
) {
409 if (error
!= ERR_NOTIMPLEMENTED
) Print_Error(error
);
410 if (error
== ERR_NONE
) printf(LISTFORMAT
"%s\n", _("IMEI"), buffer
);
412 error
=GSM_GetOriginalIMEI(gsm
, buffer
);
413 if (error
!= ERR_NOTSUPPORTED
&& error
!= ERR_SECURITYERROR
) {
414 if (error
!= ERR_NOTIMPLEMENTED
) Print_Error(error
);
415 if (error
== ERR_NONE
) printf(LISTFORMAT
"%s\n", _("Original IMEI"), buffer
);
419 error
=GSM_GetManufactureMonth(gsm
, buffer
);
420 if (error
!= ERR_NOTSUPPORTED
&& error
!= ERR_SECURITYERROR
) {
421 if (error
!= ERR_NOTIMPLEMENTED
) Print_Error(error
);
422 if (error
== ERR_NONE
) printf(LISTFORMAT
"%s\n", _("Manufactured"),buffer
);
425 error
=GSM_GetProductCode(gsm
, buffer
);
426 if (error
!= ERR_NOTSUPPORTED
) {
427 if (error
!= ERR_NOTIMPLEMENTED
) Print_Error(error
);
428 if (error
== ERR_NONE
) printf(LISTFORMAT
"%s\n", _("Product code"),buffer
);
431 error
=GSM_GetSIMIMSI(gsm
, buffer
);
433 case ERR_SECURITYERROR
:
434 case ERR_NOTSUPPORTED
:
435 case ERR_NOTIMPLEMENTED
:
438 printf(LISTFORMAT
"%s\n", _("SIM IMSI"),buffer
);
444 #ifdef GSM_ENABLE_NOKIA_DCT3
447 #ifdef GSM_ENABLE_NOKIA_DCT4
454 void NetworkInfo(int argc UNUSED
, char *argv
[] UNUSED
)
456 GSM_NetworkInfo NetInfo
;
461 error
= GSM_GetNetworkInfo(gsm
,&NetInfo
);
464 PrintNetworkInfo(NetInfo
);
469 void Battery(int argc UNUSED
, char *argv
[] UNUSED
)
471 GSM_BatteryCharge BatteryCharge
;
476 error
= GSM_GetBatteryCharge(gsm
, &BatteryCharge
);
479 PrintBatteryCharge(&BatteryCharge
);
484 void Screenshot(int argc UNUSED
, char *argv
[])
486 GSM_BinaryPicture pic
;
487 const char *ext
= NULL
;
496 error
= GSM_GetScreenshot(gsm
, &pic
);
517 printf_err("Unknown file type: %d\n", pic
.Type
);
521 fname
= (char *)malloc(strlen(argv
[2]) + strlen(ext
) + 1);
522 strcpy(fname
, argv
[2]);
525 f
= fopen(fname
, "w");
527 printf_err("Failed to open file: %s\n", fname
);
530 written
= fwrite(pic
.Buffer
, 1, pic
.Length
, f
);
532 if (ret
!= 0 || written
!= pic
.Length
) {
533 printf_err("Failed to write file: %s\n", fname
);
537 printf_info("File saved as %s\n", fname
);
545 void IncomingCall(GSM_StateMachine
*sm UNUSED
, GSM_Call
*call
, void *user_data
)
547 printf(LISTFORMAT
, _("Call info"));
549 if (call
->CallIDAvailable
) {
550 printf(_("ID %i, "),call
->CallID
);
552 switch(call
->Status
) {
553 case GSM_CALL_IncomingCall
: printf(_("incoming call from \"%s\"\n"),DecodeUnicodeConsole(call
->PhoneNumber
)); break;
554 case GSM_CALL_OutgoingCall
: printf(_("outgoing call to \"%s\"\n"),DecodeUnicodeConsole(call
->PhoneNumber
)); break;
555 case GSM_CALL_CallStart
: printf("%s\n", _("call started")); break;
556 case GSM_CALL_CallEnd
: printf("%s\n", _("end of call (unknown side)")); break;
557 case GSM_CALL_CallLocalEnd
: printf("%s\n", _("call end from our side")); break;
558 case GSM_CALL_CallRemoteEnd
: printf(_("call end from remote side (code %i)\n"),call
->StatusCode
); break;
559 case GSM_CALL_CallEstablished
: printf("%s\n", _("call established. Waiting for answer")); break;
560 case GSM_CALL_CallHeld
: printf("%s\n", _("call held")); break;
561 case GSM_CALL_CallResumed
: printf("%s\n", _("call resumed")); break;
562 case GSM_CALL_CallSwitched
: printf("%s\n", _("call switched")); break;
566 #define PRINTUSED(name, used, free) \
568 printf(LISTFORMAT, name); \
569 printf(_("%3d used"), used); \
571 printf(_("%3d free"), free); \
575 #define CHECKMEMORYSTATUS(x, m, name) \
578 if ( (error = GSM_GetMemoryStatus(gsm, &x)) == ERR_NONE) \
579 PRINTUSED(name, x.MemoryUsed, x.MemoryFree); \
584 if (gshutdown) break; \
585 if (error != ERR_NONE && error != ERR_UNKNOWN && error != ERR_NOTSUPPORTED && error != ERR_MEMORY && error != ERR_EMPTY && error != ERR_SOURCENOTAVAILABLE && error != ERR_NOTIMPLEMENTED) break; \
588 void Monitor(int argc
, char *argv
[])
590 GSM_MemoryStatus MemStatus
;
591 GSM_SMSMemoryStatus SMSStatus
;
592 GSM_ToDoStatus ToDoStatus
;
593 GSM_CalendarStatus CalendarStatus
;
594 GSM_NetworkInfo NetInfo
;
595 GSM_BatteryCharge BatteryCharge
;
596 GSM_SignalQuality SignalQuality
;
601 count
= GetInt(argv
[2]);
602 if (count
<= 0) count
= -1;
605 signal(SIGINT
, interrupt
);
606 fprintf(stderr
, "%s\n", _("Press Ctrl+C to break..."));
607 printf("%s\n\n", _("Entering monitor mode..."));
611 GSM_SetIncomingSMSCallback(gsm
, IncomingSMS
, NULL
);
612 GSM_SetIncomingCBCallback(gsm
, IncomingCB
, NULL
);
613 GSM_SetIncomingCallCallback(gsm
, IncomingCall
, NULL
);
614 GSM_SetIncomingUSSDCallback(gsm
, IncomingUSSD
, NULL
);
616 error
=GSM_SetIncomingSMS (gsm
,TRUE
);
617 printf("%-35s : %s\n", _("Enabling info about incoming SMS"), GSM_ErrorString(error
));
618 error
=GSM_SetIncomingCB (gsm
,TRUE
);
619 printf("%-35s : %s\n", _("Enabling info about incoming CB"), GSM_ErrorString(error
));
620 error
=GSM_SetIncomingCall (gsm
,TRUE
);
621 printf("%-35s : %s\n", _("Enabling info about calls"), GSM_ErrorString(error
));
622 error
=GSM_SetIncomingUSSD (gsm
,TRUE
);
623 printf("%-35s : %s\n", _("Enabling info about USSD"), GSM_ErrorString(error
));
625 while (!gshutdown
&& count
!= 0) {
626 if (count
> 0) count
--;
627 CHECKMEMORYSTATUS(MemStatus
,MEM_SM
,"SIM phonebook");
629 CHECKMEMORYSTATUS(MemStatus
,MEM_DC
,"Dialled numbers");
631 CHECKMEMORYSTATUS(MemStatus
,MEM_RC
,"Received numbers");
633 CHECKMEMORYSTATUS(MemStatus
,MEM_MC
,"Missed numbers");
635 CHECKMEMORYSTATUS(MemStatus
,MEM_ON
,"Own numbers");
637 CHECKMEMORYSTATUS(MemStatus
,MEM_ME
,"Phone phonebook");
639 if ( (error
= GSM_GetToDoStatus(gsm
, &ToDoStatus
)) == ERR_NONE
) {
640 PRINTUSED(_("Todos"), ToDoStatus
.Used
, ToDoStatus
.Free
);
643 if ( (error
= GSM_GetCalendarStatus(gsm
, &CalendarStatus
)) == ERR_NONE
) {
644 PRINTUSED(_("Calendar"), CalendarStatus
.Used
, CalendarStatus
.Free
);
647 if ( (error
= GSM_GetBatteryCharge(gsm
,&BatteryCharge
)) == ERR_NONE
) {
648 PrintBatteryCharge(&BatteryCharge
);
651 if ( (error
= GSM_GetSignalQuality(gsm
,&SignalQuality
)) == ERR_NONE
) {
652 if (SignalQuality
.SignalStrength
!= -1) {
653 printf(LISTFORMAT
, _("Signal strength"));
654 printf(_("%i dBm"), SignalQuality
.SignalStrength
);
657 if (SignalQuality
.SignalPercent
!= -1) {
658 printf(LISTFORMAT
, _("Network level"));
659 printf(_("%i percent"), SignalQuality
.SignalPercent
);
662 if (SignalQuality
.BitErrorRate
!= -1) {
663 printf(LISTFORMAT
, _("Bit error rate"));
664 printf(_("%i percent"), SignalQuality
.BitErrorRate
);
669 if ( (error
= GSM_GetSMSStatus(gsm
,&SMSStatus
)) == ERR_NONE
) {
670 if (SMSStatus
.SIMSize
> 0) {
671 printf(LISTFORMAT
, _("SIM SMS status"));
672 printf(_("%i used"), SMSStatus
.SIMUsed
);
674 printf(_("%i unread"), SMSStatus
.SIMUnRead
);
676 printf(_("%i locations"), SMSStatus
.SIMSize
);
680 if (SMSStatus
.PhoneSize
> 0) {
681 printf(LISTFORMAT
, _("Phone SMS status"));
682 printf(_("%i used"), SMSStatus
.PhoneUsed
);
684 printf(_("%i unread"), SMSStatus
.PhoneUnRead
);
686 printf(_("%i locations"), SMSStatus
.PhoneSize
);
687 if (SMSStatus
.TemplatesUsed
!= 0) {
689 printf(_("%i templates"), SMSStatus
.TemplatesUsed
);
695 if ( (error
= GSM_GetNetworkInfo(gsm
,&NetInfo
)) == ERR_NONE
) {
696 PrintNetworkInfo(NetInfo
);
698 if (wasincomingsms
) DisplayIncomingSMS();
702 printf("%s\n", _("Leaving monitor mode..."));
704 /* Report if we failed because of an error */
710 void GetRingtone(int argc
, char *argv
[])
712 GSM_Ringtone ringtone
;
713 gboolean PhoneRingtone
= FALSE
;
716 if (strcasestr(argv
[1], "getphoneringtone") != NULL
) {
717 PhoneRingtone
= TRUE
;
720 GetStartStop(&ringtone
.Location
, NULL
, 2, argc
, argv
);
726 error
=GSM_GetRingtone(gsm
,&ringtone
,PhoneRingtone
);
729 switch (ringtone
.Format
) {
730 case RING_NOTETONE
: printf("%s", _("Smart Messaging")); break;
731 case RING_NOKIABINARY
: printf("%s", _("Nokia binary")); break;
732 case RING_MIDI
: printf("%s", _("MIDI")); break;
733 case RING_MMF
: printf("%s", _("SMAF (MMF)")); break;
735 printf(_(" format, ringtone \"%s\"\n"),DecodeUnicodeConsole(ringtone
.Name
));
738 error
=GSM_SaveRingtoneFile(argv
[3], &ringtone
);
745 void GetRingtonesList(int argc UNUSED
, char *argv
[] UNUSED
)
747 GSM_AllRingtonesInfo Info
= {0, NULL
};
753 error
=GSM_GetRingtonesInfo(gsm
,&Info
);
754 if (error
!= ERR_NONE
&& Info
.Ringtone
) free(Info
.Ringtone
);
759 for (i
=0;i
<Info
.Number
;i
++) printf("%i. \"%s\"\n",i
+1,DecodeUnicodeConsole(Info
.Ringtone
[i
].Name
));
761 if (Info
.Ringtone
) free(Info
.Ringtone
);
764 void DialVoice(int argc
, char *argv
[])
766 GSM_CallShowNumber ShowNumber
= GSM_CALL_DefaultNumberPresence
;
770 if (strcasecmp(argv
[3],"show") == 0) { ShowNumber
= GSM_CALL_ShowNumber
;
771 } else if (strcasecmp(argv
[3],"hide") == 0) { ShowNumber
= GSM_CALL_HideNumber
;
773 printf(_("Unknown parameter (\"%s\")\n"),argv
[3]);
780 error
=GSM_DialVoice(gsm
, argv
[2], ShowNumber
);
786 volatile int TerminateID
= -1;
788 void IncomingCall0(GSM_StateMachine
*sm UNUSED
, GSM_Call
*call
, void * user_data
)
790 if (call
->CallIDAvailable
) {
791 TerminateID
= call
->CallID
;
795 void MakeTerminatedCall(int argc
, char *argv
[])
797 GSM_CallShowNumber ShowNumber
= GSM_CALL_DefaultNumberPresence
;
801 if (strcasecmp(argv
[4], "show") == 0) {
802 ShowNumber
= GSM_CALL_ShowNumber
;
803 } else if (strcasecmp(argv
[4], "hide") == 0) {
804 ShowNumber
= GSM_CALL_HideNumber
;
806 printf(_("Unknown parameter (\"%s\")\n"), argv
[4]);
814 GSM_SetIncomingCallCallback(gsm
, IncomingCall0
, NULL
);
816 error
= GSM_SetIncomingCall(gsm
, TRUE
);
819 error
= GSM_DialVoice(gsm
, argv
[2], ShowNumber
);
822 sleep(GetInt(argv
[3]));
823 GSM_ReadDevice(gsm
, TRUE
);
825 if (TerminateID
!= -1) {
826 error
= GSM_CancelCall(gsm
, TerminateID
, FALSE
);
829 error
= GSM_CancelCall(gsm
, 0, TRUE
);
837 void CancelCall(int argc
, char *argv
[])
843 error
=GSM_CancelCall(gsm
,GetInt(argv
[2]),FALSE
);
845 error
=GSM_CancelCall(gsm
,0,TRUE
);
852 void AnswerCall(int argc
, char *argv
[])
858 error
=GSM_AnswerCall(gsm
,GetInt(argv
[2]),FALSE
);
860 error
=GSM_AnswerCall(gsm
,0,TRUE
);
867 void UnholdCall(int argc UNUSED
, char *argv
[])
872 error
=GSM_UnholdCall(gsm
,GetInt(argv
[2]));
878 void HoldCall(int argc UNUSED
, char *argv
[])
883 error
=GSM_HoldCall(gsm
,GetInt(argv
[2]));
889 void ConferenceCall(int argc UNUSED
, char *argv
[])
894 error
=GSM_ConferenceCall(gsm
,GetInt(argv
[2]));
900 void SplitCall(int argc UNUSED
, char *argv
[])
905 error
=GSM_SplitCall(gsm
,GetInt(argv
[2]));
911 void SwitchCall(int argc
, char *argv
[])
917 error
=GSM_SwitchCall(gsm
,GetInt(argv
[2]),FALSE
);
919 error
=GSM_SwitchCall(gsm
,0,TRUE
);
926 void TransferCall(int argc
, char *argv
[])
932 error
=GSM_TransferCall(gsm
,GetInt(argv
[2]),FALSE
);
934 error
=GSM_TransferCall(gsm
,0,TRUE
);
941 void Reset(int argc UNUSED
, char *argv
[])
946 if (strcasecmp(argv
[2],"SOFT") == 0) { hard
=FALSE
;
947 } else if (strcasecmp(argv
[2],"HARD") == 0) { hard
=TRUE
;
949 printf(_("What type of reset do you want (\"%s\") ?\n"),argv
[2]);
955 error
=GSM_Reset(gsm
, hard
);
961 void GetWAPBookmark(int argc
, char *argv
[])
963 GSM_WAPBookmark bookmark
;
967 GetStartStop(&start
, &stop
, 2, argc
, argv
);
971 for (i
=start
;i
<=stop
;i
++) {
973 error
=GSM_GetWAPBookmark(gsm
,&bookmark
);
975 printf(LISTFORMAT
"\"%s\"\n", _("Name"),DecodeUnicodeConsole(bookmark
.Title
));
976 printf(LISTFORMAT
"\"%s\"\n", _("Address"),DecodeUnicodeConsole(bookmark
.Address
));
982 void DeleteWAPBookmark(int argc
, char *argv
[])
984 GSM_WAPBookmark bookmark
;
988 GetStartStop(&start
, &stop
, 2, argc
, argv
);
992 for (i
=start
;i
<=stop
;i
++) {
994 error
=GSM_DeleteWAPBookmark(gsm
, &bookmark
);
1001 void GetGPRSPoint(int argc
, char *argv
[])
1003 GSM_GPRSAccessPoint point
;
1007 GetStartStop(&start
, &stop
, 2, argc
, argv
);
1011 for (i
=start
;i
<=stop
;i
++) {
1013 error
=GSM_GetGPRSAccessPoint(gsm
,&point
);
1014 if (error
!= ERR_EMPTY
) {
1016 printf("%i. \"%s\"",point
.Location
,DecodeUnicodeConsole(point
.Name
));
1018 printf(_("%i. Access point %i"),point
.Location
,point
.Location
);
1020 if (point
.Active
) printf("%s", _(" (active)"));
1022 if (error
!= ERR_EMPTY
) {
1023 printf(LISTFORMAT
"\"%s\"\n\n", _("Address"),DecodeUnicodeConsole(point
.URL
));
1032 void GetBitmap(int argc
, char *argv
[])
1035 GSM_MultiBitmap MultiBitmap
;
1036 int location
=0, Handle
, Size
;
1037 GSM_AllRingtonesInfo Info
= {0, NULL
};
1038 unsigned char buffer
[10];
1039 const unsigned char *ringtonename
;
1042 if (strcasecmp(argv
[2],"STARTUP") == 0) {
1043 MultiBitmap
.Bitmap
[0].Type
=GSM_StartupLogo
;
1044 } else if (strcasecmp(argv
[2],"CALLER") == 0) {
1045 MultiBitmap
.Bitmap
[0].Type
=GSM_CallerGroupLogo
;
1046 GetStartStop(&location
, NULL
, 3, argc
, argv
);
1048 printf("%s\n", _("Maximal location for caller logo can be 5"));
1051 } else if (strcasecmp(argv
[2],"PICTURE") == 0) {
1052 MultiBitmap
.Bitmap
[0].Type
=GSM_PictureImage
;
1053 GetStartStop(&location
, NULL
, 3, argc
, argv
);
1054 } else if (strcasecmp(argv
[2],"TEXT") == 0) {
1055 MultiBitmap
.Bitmap
[0].Type
=GSM_WelcomeNote_Text
;
1056 } else if (strcasecmp(argv
[2],"DEALER") == 0) {
1057 MultiBitmap
.Bitmap
[0].Type
=GSM_DealerNote_Text
;
1058 } else if (strcasecmp(argv
[2],"OPERATOR") == 0) {
1059 MultiBitmap
.Bitmap
[0].Type
=GSM_OperatorLogo
;
1061 printf(_("What type of logo do you want to get (\"%s\") ?\n"),argv
[2]);
1064 MultiBitmap
.Bitmap
[0].Location
=location
;
1068 error
=GSM_GetBitmap(gsm
,&MultiBitmap
.Bitmap
[0]);
1071 MultiBitmap
.Number
= 1;
1074 switch (MultiBitmap
.Bitmap
[0].Type
) {
1075 case GSM_CallerGroupLogo
:
1076 if (!MultiBitmap
.Bitmap
[0].DefaultBitmap
) GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
1077 printf(LISTFORMAT
"\"%s\"", _("Group name"),DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
1078 if (MultiBitmap
.Bitmap
[0].DefaultName
) printf(" (%s)", _("default"));
1080 if (MultiBitmap
.Bitmap
[0].DefaultRingtone
) {
1081 printf(LISTFORMAT
"%s\n", _("Ringtone"), _("default"));
1082 } else if (GSM_IsPhoneFeatureAvailable(GSM_GetModelInfo(gsm
), F_6230iCALLER
)) {
1083 printf(LISTFORMAT
"%i\n", _("Ringtone"),MultiBitmap
.Bitmap
[0].RingtoneID
);
1084 } else if (MultiBitmap
.Bitmap
[0].FileSystemRingtone
) {
1085 sprintf(buffer
,"%i",MultiBitmap
.Bitmap
[0].RingtoneID
);
1086 EncodeUnicode(File
.ID_FullName
,buffer
,strlen(buffer
));
1091 error
= GSM_GetFilePart(gsm
,&File
,&Handle
,&Size
);
1093 if (error
!= ERR_EMPTY
&& error
!= ERR_WRONGCRC
) Print_Error(error
);
1096 printf(LISTFORMAT
"\"%s\" ", _("Ringtone"), DecodeUnicodeString(File
.Name
));
1097 printf(_("(file with ID %i)\n"), MultiBitmap
.Bitmap
[0].RingtoneID
);
1099 error
= GSM_GetRingtonesInfo(gsm
,&Info
);
1100 if (error
!= ERR_NONE
) Info
.Number
= 0;
1103 printf(LISTFORMAT
, _("Ringtone"));
1104 ringtonename
= GSM_GetRingtoneName(&Info
, MultiBitmap
.Bitmap
[0].RingtoneID
);
1105 if (ringtonename
!= NULL
) {
1106 /* l10n: Ringtone name and ID format */
1107 printf(_("\"%s\" (ID %i)\n"), DecodeUnicodeConsole(ringtonename
), MultiBitmap
.Bitmap
[0].RingtoneID
);
1109 /* l10n: Ringtone ID format */
1110 printf(_("ID %i\n"), MultiBitmap
.Bitmap
[0].RingtoneID
);
1113 if (Info
.Ringtone
) free(Info
.Ringtone
);
1115 if (MultiBitmap
.Bitmap
[0].BitmapEnabled
) {
1116 printf(LISTFORMAT
"%s\n", _("Bitmap"), _("enabled"));
1118 printf(LISTFORMAT
"%s\n", _("Bitmap"), _("disabled"));
1120 if (MultiBitmap
.Bitmap
[0].FileSystemPicture
) {
1121 printf(LISTFORMAT
"%i\n", _("Bitmap ID"),MultiBitmap
.Bitmap
[0].PictureID
);
1123 if (argc
>4 && !MultiBitmap
.Bitmap
[0].DefaultBitmap
) error
=GSM_SaveBitmapFile(argv
[4],&MultiBitmap
);
1125 case GSM_StartupLogo
:
1126 GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
1127 if (argc
>3) error
=GSM_SaveBitmapFile(argv
[3],&MultiBitmap
);
1129 case GSM_OperatorLogo
:
1130 if (strcmp(MultiBitmap
.Bitmap
[0].NetworkCode
,"000 00")!=0) {
1131 GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
1132 if (argc
>3) error
=GSM_SaveBitmapFile(argv
[3],&MultiBitmap
);
1134 printf("%s\n", _("No operator logo in phone"));
1137 case GSM_PictureImage
:
1138 GSM_PrintBitmap(stdout
,&MultiBitmap
.Bitmap
[0]);
1139 printf(LISTFORMAT
"\"%s\"\n", _("Text"),DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
1140 printf(LISTFORMAT
"\"%s\"\n", _("Sender"),DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Sender
));
1141 if (MultiBitmap
.Bitmap
[0].Name
)
1142 printf(LISTFORMAT
"\"%s\"\n", _("Name"),DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Name
));
1143 if (argc
>4) error
=GSM_SaveBitmapFile(argv
[4],&MultiBitmap
);
1145 case GSM_WelcomeNote_Text
:
1146 printf(_("Welcome note text is \"%s\"\n"),DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
1148 case GSM_DealerNote_Text
:
1149 printf(_("Dealer note text is \"%s\"\n"),DecodeUnicodeConsole(MultiBitmap
.Bitmap
[0].Text
));
1159 void SetBitmap(int argc
, char *argv
[])
1161 GSM_Bitmap Bitmap
, NewBitmap
;
1162 GSM_MultiBitmap MultiBitmap
;
1163 GSM_NetworkInfo NetInfo
;
1164 gboolean init
= TRUE
;
1168 if (strcasecmp(argv
[2],"STARTUP") == 0) {
1170 printf("%s\n", _("More parameters required!"));
1173 MultiBitmap
.Bitmap
[0].Type
=GSM_StartupLogo
;
1174 MultiBitmap
.Bitmap
[0].Location
=1;
1175 if (!strcmp(argv
[3],"1")) MultiBitmap
.Bitmap
[0].Location
= 2;
1176 if (!strcmp(argv
[3],"2")) MultiBitmap
.Bitmap
[0].Location
= 3;
1177 if (!strcmp(argv
[3],"3")) MultiBitmap
.Bitmap
[0].Location
= 4;
1178 if (MultiBitmap
.Bitmap
[0].Location
== 1) {
1179 error
=GSM_ReadBitmapFile(argv
[3],&MultiBitmap
);
1182 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
1183 } else if (strcasecmp(argv
[2],"TEXT") == 0) {
1185 printf("%s\n", _("More parameters required!"));
1188 Bitmap
.Type
=GSM_WelcomeNote_Text
;
1189 EncodeUnicode(Bitmap
.Text
,argv
[3],strlen(argv
[3]));
1190 } else if (strcasecmp(argv
[2],"DEALER") == 0) {
1192 printf("%s\n", _("More parameters required!"));
1195 Bitmap
.Type
=GSM_DealerNote_Text
;
1196 EncodeUnicode(Bitmap
.Text
,argv
[3],strlen(argv
[3]));
1197 } else if (strcasecmp(argv
[2],"CALLER") == 0) {
1199 printf("%s\n", _("More parameters required!"));
1202 GetStartStop(&i
, NULL
, 3, argc
, argv
);
1203 if (i
>5 && i
!=255) {
1204 printf("%s\n", _("Maximal location for caller logo can be 5"));
1207 MultiBitmap
.Bitmap
[0].Type
= GSM_CallerGroupLogo
;
1208 MultiBitmap
.Bitmap
[0].Location
= i
;
1210 error
=GSM_ReadBitmapFile(argv
[4],&MultiBitmap
);
1213 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
1217 NewBitmap
.Type
= GSM_CallerGroupLogo
;
1218 NewBitmap
.Location
= i
;
1219 error
=GSM_GetBitmap(gsm
,&NewBitmap
);
1221 Bitmap
.RingtoneID
= NewBitmap
.RingtoneID
;
1222 Bitmap
.DefaultRingtone
= NewBitmap
.DefaultRingtone
;
1223 Bitmap
.FileSystemRingtone
= FALSE
;
1224 CopyUnicodeString(Bitmap
.Text
, NewBitmap
.Text
);
1225 Bitmap
.DefaultName
= NewBitmap
.DefaultName
;
1227 } else if (strcasecmp(argv
[2],"PICTURE") == 0) {
1229 printf("%s\n", _("More parameters required!"));
1232 MultiBitmap
.Bitmap
[0].Type
= GSM_PictureImage
;
1233 MultiBitmap
.Bitmap
[0].Location
= GetInt(argv
[4]);
1234 error
=GSM_ReadBitmapFile(argv
[3],&MultiBitmap
);
1236 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
1239 if (argc
== 6) EncodeUnicode(Bitmap
.Text
,argv
[5],strlen(argv
[5]));
1242 } else if (strcasecmp(argv
[2],"COLOUROPERATOR") == 0) {
1243 Bitmap
.Type
= GSM_ColourOperatorLogo_ID
;
1244 strcpy(Bitmap
.NetworkCode
,"000 00");
1246 Bitmap
.ID
= GetInt(argv
[3]);
1248 strncpy(Bitmap
.NetworkCode
,argv
[4],6);
1252 error
=GSM_GetNetworkInfo(gsm
,&NetInfo
);
1254 strcpy(Bitmap
.NetworkCode
,NetInfo
.NetworkCode
);
1257 } else if (strcasecmp(argv
[2],"COLOURSTARTUP") == 0) {
1258 Bitmap
.Type
= GSM_ColourStartupLogo_ID
;
1259 Bitmap
.Location
= 0;
1261 Bitmap
.Location
= 1;
1262 Bitmap
.ID
= GetInt(argv
[3]);
1264 } else if (strcasecmp(argv
[2],"WALLPAPER") == 0) {
1265 Bitmap
.Type
= GSM_ColourWallPaper_ID
;
1267 if (argc
> 3) Bitmap
.ID
= GetInt(argv
[3]);
1268 } else if (strcasecmp(argv
[2],"OPERATOR") == 0) {
1269 MultiBitmap
.Bitmap
[0].Type
= GSM_OperatorLogo
;
1270 MultiBitmap
.Bitmap
[0].Location
= 1;
1271 strcpy(MultiBitmap
.Bitmap
[0].NetworkCode
,"000 00");
1273 error
=GSM_ReadBitmapFile(argv
[3],&MultiBitmap
);
1276 strncpy(MultiBitmap
.Bitmap
[0].NetworkCode
,argv
[4],6);
1280 error
=GSM_GetNetworkInfo(gsm
,&NetInfo
);
1282 strcpy(MultiBitmap
.Bitmap
[0].NetworkCode
,NetInfo
.NetworkCode
);
1285 memcpy(&Bitmap
,&MultiBitmap
.Bitmap
[0],sizeof(GSM_Bitmap
));
1287 printf(_("What type of logo do you want to set (\"%s\") ?\n"),argv
[2]);
1291 if (init
) GSM_Init(TRUE
);
1293 error
=GSM_SetBitmap(gsm
,&Bitmap
);
1299 void SetRingtone(int argc
, char *argv
[])
1302 GSM_Ringtone ringtone
;
1305 ringtone
.Format
= 0;
1306 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
1308 ringtone
.Location
= 255;
1309 for (i
=3;i
<argc
;i
++) {
1312 if (strcasecmp(argv
[i
],"-scale") == 0) {
1313 ringtone
.NoteTone
.AllNotesScale
= TRUE
;
1316 if (strcasecmp(argv
[i
],"-location") == 0) {
1320 if (strcasecmp(argv
[i
],"-name") == 0) {
1324 printf(_("Unknown parameter (\"%s\")"),argv
[i
]);
1327 ringtone
.Location
=GetInt(argv
[i
]);
1331 EncodeUnicode(ringtone
.Name
,argv
[i
],strlen(argv
[i
]));
1337 printf_err("%s\n", _("Parameter missing!"));
1340 if (ringtone
.Location
==0) {
1341 printf_err("%s\n", _("Please enumerate locations from 1"));
1346 error
=GSM_SetRingtone(gsm
, &ringtone
, &i
);
1351 void ClearMemory(GSM_MemoryType type
, const char *question
)
1354 GSM_MemoryStatus MemStatus
;
1355 GSM_MemoryEntry Pbk
;
1360 MemStatus
.MemoryType
= type
;
1361 error
= GSM_GetMemoryStatus(gsm
, &MemStatus
);
1362 if (error
== ERR_NONE
&& MemStatus
.MemoryUsed
!=0) {
1363 if (answer_yes("%s", question
)) DoClear
= TRUE
;
1366 error
= GSM_DeleteAllMemory(gsm
, type
);
1367 if (error
== ERR_NOTSUPPORTED
|| error
== ERR_NOTIMPLEMENTED
) {
1368 for (i
= 0; i
< MemStatus
.MemoryUsed
+ MemStatus
.MemoryFree
; i
++) {
1369 Pbk
.MemoryType
= type
;
1370 Pbk
.Location
= i
+ 1;
1372 error
=GSM_DeleteMemory(gsm
, &Pbk
);
1374 fprintf(stderr
, "\r");
1375 fprintf(stderr
, "%s ", _("Deleting:"));
1376 fprintf(stderr
, _("%i percent"),
1377 (i
+ 1) * 100 / (MemStatus
.MemoryUsed
+ MemStatus
.MemoryFree
));
1383 fprintf(stderr
, "\n");
1385 fprintf(stderr
, "%s\n", _("Done"));
1392 void ClearAll(int argc UNUSED
, char *argv
[] UNUSED
)
1394 GSM_ToDoStatus ToDoStatus
;
1395 GSM_CalendarEntry Calendar
;
1398 GSM_WAPBookmark Bookmark
;
1399 GSM_FMStation Station
;
1405 ClearMemory(MEM_ME
, _("Delete phone phonebook?"));
1406 ClearMemory(MEM_SM
, _("Delete SIM phonebook?"));
1407 ClearMemory(MEM_MC
, _("Delete missed calls?"));
1408 ClearMemory(MEM_DC
, _("Delete dialled calls?"));
1409 ClearMemory(MEM_RC
, _("Delete received calls?"));
1412 error
= GSM_GetNextCalendar(gsm
,&Calendar
,TRUE
);
1413 if (error
== ERR_NONE
) {
1414 if (answer_yes("%s", _("Delete phone calendar notes?"))) DoClear
= TRUE
;
1417 fprintf(stderr
, LISTFORMAT
, _("Deleting"));
1418 error
=GSM_DeleteAllCalendar(gsm
);
1419 if (error
== ERR_NOTSUPPORTED
|| error
== ERR_NOTIMPLEMENTED
) {
1421 error
= GSM_GetNextCalendar(gsm
,&Calendar
,TRUE
);
1422 if (error
!= ERR_NONE
) break;
1423 error
= GSM_DeleteCalendar(gsm
,&Calendar
);
1425 fprintf(stderr
, "*");
1427 fprintf(stderr
, "\n");
1430 fprintf(stderr
, "%s\n", _("Done"));
1436 error
= GSM_GetToDoStatus(gsm
,&ToDoStatus
);
1437 if (error
== ERR_NONE
&& ToDoStatus
.Used
!= 0) {
1438 if (answer_yes("%s", _("Delete phone todos?"))) DoClear
= TRUE
;
1441 fprintf(stderr
, LISTFORMAT
, _("Deleting"));
1442 error
=GSM_DeleteAllToDo(gsm
);
1443 if (error
== ERR_NOTSUPPORTED
|| error
== ERR_NOTIMPLEMENTED
) {
1445 error
= GSM_GetNextToDo(gsm
,&ToDo
,TRUE
);
1446 if (error
!= ERR_NONE
) break;
1447 error
= GSM_DeleteToDo(gsm
,&ToDo
);
1449 fprintf(stderr
, "*");
1451 fprintf(stderr
, "\n");
1454 fprintf(stderr
, "%s\n", _("Done"));
1460 error
= GSM_GetNotesStatus(gsm
,&ToDoStatus
);
1461 if (error
== ERR_NONE
&& ToDoStatus
.Used
!= 0) {
1462 if (answer_yes("%s", _("Delete phone notes?"))) DoClear
= TRUE
;
1465 fprintf(stderr
, LISTFORMAT
, _("Deleting"));
1467 error
= GSM_GetNextNote(gsm
,&Note
,TRUE
);
1468 if (error
!= ERR_NONE
) break;
1469 error
= GSM_DeleteNote(gsm
,&Note
);
1471 fprintf(stderr
, "*");
1473 fprintf(stderr
, "\n");
1477 Bookmark
.Location
= 1;
1478 error
= GSM_GetWAPBookmark(gsm
,&Bookmark
);
1479 if (error
== ERR_NONE
|| error
== ERR_INVALIDLOCATION
) {
1480 if (answer_yes("%s", _("Delete phone WAP bookmarks?"))) {
1481 fprintf(stderr
, LISTFORMAT
, _("Deleting"));
1482 /* One thing to explain: DCT4 phones seems to have bug here.
1483 * When delete for example first bookmark, phone change
1484 * numeration for getting frame, not for deleting. So, we try to
1485 * get 1'st bookmark. Inside frame is "correct" location. We use
1488 while (error
==ERR_NONE
) {
1489 error
= GSM_DeleteWAPBookmark(gsm
,&Bookmark
);
1490 Bookmark
.Location
= 1;
1491 error
= GSM_GetWAPBookmark(gsm
,&Bookmark
);
1492 fprintf(stderr
, "*");
1494 fprintf(stderr
, "\n");
1498 if (answer_yes("%s", _("Delete all phone user ringtones?"))) {
1499 fprintf(stderr
, LISTFORMAT
, _("Deleting"));
1500 error
=GSM_DeleteUserRingtones(gsm
);
1502 fprintf(stderr
, "%s\n", _("Done"));
1504 Station
.Location
= 1;
1505 error
=GSM_GetFMStation(gsm
,&Station
);
1506 if (error
== ERR_NONE
|| error
== ERR_EMPTY
) {
1507 if (answer_yes("%s", _("Delete all phone FM radio stations?"))) {
1508 error
=GSM_ClearFMStations(gsm
);
1516 void DisplayConnectionSettings(GSM_MultiWAPSettings
*settings
,int j
)
1518 if (settings
->Settings
[j
].IsContinuous
) {
1519 printf(LISTFORMAT
"%s\n", _("Connection type"), _("Continuous"));
1521 printf(LISTFORMAT
"%s\n", _("Connection type"), _("Temporary"));
1523 if (settings
->Settings
[j
].IsSecurity
) {
1524 printf(LISTFORMAT
"%s\n", _("Connection security"), _("On"));
1526 printf(LISTFORMAT
"%s\n", _("Connection security"), _("Off"));
1528 printf(LISTFORMAT
, _("Proxy"));
1529 printf(_("address \"%s\", port %i"), DecodeUnicodeConsole(settings
->Proxy
), settings
->ProxyPort
);
1531 printf(LISTFORMAT
, _("Second proxy"));
1532 printf(_("address \"%s\", port %i"), DecodeUnicodeConsole(settings
->Proxy2
), settings
->Proxy2Port
);
1534 switch (settings
->Settings
[j
].Bearer
) {
1535 case WAPSETTINGS_BEARER_SMS
:
1536 printf(LISTFORMAT
"%s", _("Bearer"), _("SMS"));
1537 if (settings
->ActiveBearer
== WAPSETTINGS_BEARER_SMS
) printf("%s", _(" (active)"));
1539 printf(LISTFORMAT
"\"%s\"\n", _("Server number"),DecodeUnicodeConsole(settings
->Settings
[j
].Server
));
1540 printf(LISTFORMAT
"\"%s\"\n", _("Service number"),DecodeUnicodeConsole(settings
->Settings
[j
].Service
));
1542 case WAPSETTINGS_BEARER_DATA
:
1543 printf(LISTFORMAT
"%s", _("Bearer"), _("Data (CSD)"));
1544 if (settings
->ActiveBearer
== WAPSETTINGS_BEARER_DATA
) printf("%s", _(" (active)"));
1546 printf(LISTFORMAT
"\"%s\"\n", _("Dial-up number"),DecodeUnicodeConsole(settings
->Settings
[j
].DialUp
));
1547 printf(LISTFORMAT
"\"%s\"\n", _("IP address"),DecodeUnicodeConsole(settings
->Settings
[j
].IPAddress
));
1548 if (settings
->Settings
[j
].ManualLogin
) {
1549 printf(LISTFORMAT
"%s\n", _("Login type"), _("Manual"));
1551 printf(LISTFORMAT
"%s\n", _("Login type"), _("Automatic"));
1553 if (settings
->Settings
[j
].IsNormalAuthentication
) {
1554 printf(LISTFORMAT
"%s\n", _("Authentication type"), _("Normal"));
1556 printf(LISTFORMAT
"%s\n", _("Authentication type"), _("Secure"));
1558 if (settings
->Settings
[j
].IsISDNCall
) {
1559 printf(LISTFORMAT
"%s\n", _("Data call type"), _("ISDN"));
1561 printf(LISTFORMAT
"%s\n", _("Data call type"), _("Analogue"));
1563 switch (settings
->Settings
[j
].Speed
) {
1564 case WAPSETTINGS_SPEED_9600
:
1565 printf(LISTFORMAT
"%s\n", _("Data call speed"), "9600");
1567 case WAPSETTINGS_SPEED_14400
:
1568 printf(LISTFORMAT
"%s\n", _("Data call speed"), "14400");
1570 case WAPSETTINGS_SPEED_AUTO
:
1571 printf(LISTFORMAT
"%s\n", _("Data call speed"), _("Auto"));
1574 printf(LISTFORMAT
"\"%s\"\n", _("User name"),DecodeUnicodeConsole(settings
->Settings
[j
].User
));
1575 printf(LISTFORMAT
"\"%s\"\n", _("Password"),DecodeUnicodeConsole(settings
->Settings
[j
].Password
));
1577 case WAPSETTINGS_BEARER_USSD
:
1578 printf(LISTFORMAT
"%s", _("Bearer"), _("USSD"));
1579 if (settings
->ActiveBearer
== WAPSETTINGS_BEARER_USSD
) printf("%s", _(" (active)"));
1581 printf(LISTFORMAT
"\"%s\"\n", _("Service code"),DecodeUnicodeConsole(settings
->Settings
[j
].Code
));
1582 if (settings
->Settings
[j
].IsIP
) {
1583 printf(LISTFORMAT
"%s\n", _("Address type"), _("IP address"));
1584 printf(LISTFORMAT
"%s\n", _("IP address"), DecodeUnicodeConsole(settings
->Settings
[j
].Service
));
1586 printf(LISTFORMAT
"%s\n", _("Address type"), _("Service number"));
1587 printf(LISTFORMAT
"%s\n", _("Service number"), DecodeUnicodeConsole(settings
->Settings
[j
].Service
));
1590 case WAPSETTINGS_BEARER_GPRS
:
1591 printf(LISTFORMAT
"%s", _("Bearer"), _("GPRS"));
1592 if (settings
->ActiveBearer
== WAPSETTINGS_BEARER_GPRS
) printf("%s", _(" (active)"));
1594 if (settings
->Settings
[j
].ManualLogin
) {
1595 printf(LISTFORMAT
"%s\n", _("Login type"), _("Manual"));
1597 printf(LISTFORMAT
"%s\n", _("Login type"), _("Automatic"));
1599 if (settings
->Settings
[j
].IsNormalAuthentication
) {
1600 printf(LISTFORMAT
"%s\n", _("Authentication type"), _("Normal"));
1602 printf(LISTFORMAT
"%s\n", _("Authentication type"), _("Secure"));
1604 printf(LISTFORMAT
"\"%s\"\n", _("Access point"),DecodeUnicodeConsole(settings
->Settings
[j
].DialUp
));
1605 printf(LISTFORMAT
"\"%s\"\n", _("IP address"),DecodeUnicodeConsole(settings
->Settings
[j
].IPAddress
));
1606 printf(LISTFORMAT
"\"%s\"\n", _("User name"),DecodeUnicodeConsole(settings
->Settings
[j
].User
));
1607 printf(LISTFORMAT
"\"%s\"\n", _("Password"),DecodeUnicodeConsole(settings
->Settings
[j
].Password
));
1611 void GetSyncMLSettings(int argc
, char *argv
[])
1613 GSM_SyncMLSettings settings
;
1617 GetStartStop(&start
, &stop
, 2, argc
, argv
);
1621 for (i
=start
;i
<=stop
;i
++) {
1622 settings
.Location
=i
;
1623 error
=GSM_GetSyncMLSettings(gsm
,&settings
);
1626 if (settings
.Name
[0]==0 && settings
.Name
[1]==0) {
1627 printf(_("Set %i"),i
);
1629 printf("%s", DecodeUnicodeConsole(settings
.Name
));
1631 if (settings
.Active
) printf("%s", _(" (active)"));
1633 printf(LISTFORMAT
"\"%s\"\n", _("User"),DecodeUnicodeConsole(settings
.User
));
1634 printf(LISTFORMAT
"\"%s\"\n", _("Password"),DecodeUnicodeConsole(settings
.Password
));
1635 printf(LISTFORMAT
"\"%s\"\n", _("Phonebook database"),DecodeUnicodeConsole(settings
.PhonebookDataBase
));
1636 printf(LISTFORMAT
"\"%s\"\n", _("Calendar database"),DecodeUnicodeConsole(settings
.CalendarDataBase
));
1637 printf(LISTFORMAT
"\"%s\"\n", _("Server"),DecodeUnicodeConsole(settings
.Server
));
1638 printf(LISTFORMAT
, _("Sync. phonebook"));
1639 if (settings
.SyncPhonebook
) printf("%s\n", _("enabled"));
1640 if (!settings
.SyncPhonebook
) printf("%s\n", _("disabled"));
1641 printf(LISTFORMAT
, _("Sync. calendar"));
1642 if (settings
.SyncCalendar
) printf("%s\n", _("enabled"));
1643 if (!settings
.SyncCalendar
) printf("%s\n", _("disabled"));
1645 for (j
=0;j
<settings
.Connection
.Number
;j
++) {
1646 printf(LISTFORMAT
, _("Connection set name"));
1647 if (settings
.Connection
.Settings
[j
].Title
[0]==0 && settings
.Connection
.Settings
[j
].Title
[1]==0) {
1648 printf(_("Set %i"),i
);
1650 printf("%s",DecodeUnicodeConsole(settings
.Connection
.Settings
[j
].Title
));
1653 DisplayConnectionSettings(&settings
.Connection
,j
);
1660 void GetChatSettings(int argc
, char *argv
[])
1662 GSM_ChatSettings settings
;
1666 GetStartStop(&start
, &stop
, 2, argc
, argv
);
1670 for (i
=start
;i
<=stop
;i
++) {
1671 settings
.Location
=i
;
1672 error
=GSM_GetChatSettings(gsm
,&settings
);
1675 if (settings
.Name
[0]==0 && settings
.Name
[1]==0) {
1676 printf(_("Set %i"),i
);
1678 printf("%s", DecodeUnicodeConsole(settings
.Name
));
1680 if (settings
.Active
) printf("%s", _(" (active)"));
1682 printf(LISTFORMAT
"\"%s\"\n", _("Homepage"),DecodeUnicodeConsole(settings
.HomePage
));
1683 printf(LISTFORMAT
"\"%s\"\n", _("User"),DecodeUnicodeConsole(settings
.User
));
1684 printf(LISTFORMAT
"\"%s\"\n", _("Password"),DecodeUnicodeConsole(settings
.Password
));
1686 for (j
=0;j
<settings
.Connection
.Number
;j
++) {
1687 printf(LISTFORMAT
, _("Connection set name"));
1688 if (settings
.Connection
.Settings
[j
].Title
[0]==0 && settings
.Connection
.Settings
[j
].Title
[1]==0) {
1689 printf(_("Set %i"),i
);
1691 printf("%s",DecodeUnicodeConsole(settings
.Connection
.Settings
[j
].Title
));
1693 DisplayConnectionSettings(&settings
.Connection
,j
);
1700 void GetWAPMMSSettings(int argc
, char *argv
[])
1702 GSM_MultiWAPSettings settings
;
1703 int start
,stop
,j
, i
;
1706 GetStartStop(&start
, &stop
, 2, argc
, argv
);
1710 for (i
=start
;i
<=stop
;i
++) {
1711 settings
.Location
=i
;
1712 if (strcasestr(argv
[1], "getwapsettings") != NULL
) {
1713 error
=GSM_GetWAPSettings(gsm
,&settings
);
1715 error
=GSM_GetMMSSettings(gsm
,&settings
);
1718 for (j
=0;j
<settings
.Number
;j
++) {
1720 if (settings
.Settings
[j
].Title
[0]==0 && settings
.Settings
[j
].Title
[1]==0) {
1721 printf(_("Set %i"),i
);
1723 printf("%s", DecodeUnicodeConsole(settings
.Settings
[j
].Title
));
1725 if (settings
.Active
) {
1726 printf(" (%s)", _("active"));
1729 if (settings
.ReadOnly
) {
1730 printf(LISTFORMAT
"%s\n", _("Read only"), _("yes"));
1732 printf(LISTFORMAT
"\"%s\"\n", _("Homepage"),
1733 DecodeUnicodeConsole(settings
.Settings
[j
].HomePage
));
1734 DisplayConnectionSettings(&settings
,j
);
1741 void CopyBitmap(int argc
, char *argv
[])
1743 GSM_MultiBitmap Bitmap
;
1747 Bitmap
.Bitmap
[0].Type
= GSM_None
;
1749 error
=GSM_ReadBitmapFile(argv
[2],&Bitmap
);
1753 for (i
=0;i
<Bitmap
.Number
;i
++) {
1754 switch (Bitmap
.Bitmap
[i
].Type
) {
1755 case GSM_StartupLogo
: printf("%s", _("Startup logo")); break;
1756 case GSM_OperatorLogo
: printf("%s", _("Operator logo")); break;
1757 case GSM_PictureImage
: printf("%s", _("Picture")); break;
1758 case GSM_CallerGroupLogo
: printf("%s", _("Caller group logo")); break;
1761 printf(_(", width %i, height %i\n"),
1762 (int)Bitmap
.Bitmap
[i
].BitmapWidth
,
1763 (int)Bitmap
.Bitmap
[i
].BitmapHeight
);
1764 GSM_PrintBitmap(stdout
,&Bitmap
.Bitmap
[i
]);
1768 for (i
=0;i
<Bitmap
.Number
;i
++) {
1769 if (strcasecmp(argv
[4],"PICTURE") == 0) {
1770 Bitmap
.Bitmap
[i
].Type
= GSM_PictureImage
;
1771 } else if (strcasecmp(argv
[4],"STARTUP") == 0) {
1772 Bitmap
.Bitmap
[i
].Type
= GSM_StartupLogo
;
1773 } else if (strcasecmp(argv
[4],"CALLER") == 0) {
1774 Bitmap
.Bitmap
[i
].Type
= GSM_CallerGroupLogo
;
1775 } else if (strcasecmp(argv
[4],"OPERATOR") == 0) {
1776 Bitmap
.Bitmap
[i
].Type
= GSM_OperatorLogo
;
1778 printf(_("What format of output file logo (\"%s\") ?\n"),argv
[4]);
1783 error
=GSM_SaveBitmapFile(argv
[3],&Bitmap
);
1788 void CopyRingtone(int argc
, char *argv
[])
1790 GSM_Ringtone ringtone
, ringtone2
;
1791 GSM_RingtoneFormat Format
;
1794 ringtone
.Format
= 0;
1795 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
1798 Format
= ringtone
.Format
;
1800 if (strcasecmp(argv
[4],"RTTL") == 0) { Format
= RING_NOTETONE
;
1801 } else if (strcasecmp(argv
[4],"BINARY") == 0) { Format
= RING_NOKIABINARY
;
1803 printf(_("What format of output ringtone file (\"%s\") ?\n"),argv
[4]);
1808 error
=GSM_RingtoneConvert(&ringtone2
,&ringtone
,Format
);
1811 error
=GSM_SaveRingtoneFile(argv
[3],&ringtone2
);
1815 void PressKeySequence(int argc UNUSED
, char *argv
[])
1818 GSM_KeyCode KeyCode
[500];
1821 error
= MakeKeySequence(argv
[2], KeyCode
, &Length
);
1822 if (error
== ERR_NOTSUPPORTED
) {
1823 printf(_("Unknown key/function name: \"%c\"\n"),argv
[2][Length
]);
1829 for (i
=0;i
<Length
;i
++) {
1830 error
=GSM_PressKey(gsm
, KeyCode
[i
], TRUE
);
1832 error
=GSM_PressKey(gsm
, KeyCode
[i
], FALSE
);
1839 void GetAllCategories(int argc UNUSED
, char *argv
[])
1841 GSM_Category Category
;
1842 GSM_CategoryStatus Status
;
1846 if (strcasecmp(argv
[2],"TODO") == 0) {
1847 Category
.Type
= Category_ToDo
;
1848 Status
.Type
= Category_ToDo
;
1849 } else if (strcasecmp(argv
[2],"PHONEBOOK") == 0) {
1850 Category
.Type
= Category_Phonebook
;
1851 Status
.Type
= Category_Phonebook
;
1853 printf(_("What type of categories do you want to get (\"%s\") ?\n"),argv
[2]);
1859 error
=GSM_GetCategoryStatus(gsm
, &Status
);
1862 for (count
=0,j
=1;count
<Status
.Used
;j
++)
1864 Category
.Location
=j
;
1865 error
=GSM_GetCategory(gsm
, &Category
);
1867 if (error
!= ERR_EMPTY
) {
1868 printf(LISTFORMAT
"%i\n", _("Location"),j
);
1872 printf(LISTFORMAT
"\"%s\"\n\n", _("Name"),DecodeUnicodeConsole(Category
.Name
));
1880 void GetCategory(int argc
, char *argv
[])
1882 GSM_Category Category
;
1886 if (strcasecmp(argv
[2],"TODO") == 0) {
1887 Category
.Type
= Category_ToDo
;
1888 } else if (strcasecmp(argv
[2],"PHONEBOOK") == 0) {
1889 Category
.Type
= Category_Phonebook
;
1891 printf(_("What type of categories do you want to get (\"%s\") ?\n"),argv
[2]);
1895 GetStartStop(&start
, &stop
, 2, argc
- 1, argv
+ 1);
1899 for (j
=start
;j
<=stop
;j
++)
1901 printf(LISTFORMAT
"%i\n", _("Location"),j
);
1903 Category
.Location
=j
;
1905 error
=GSM_GetCategory(gsm
, &Category
);
1906 if (error
!= ERR_EMPTY
) Print_Error(error
);
1908 if (error
== ERR_EMPTY
) {
1909 printf("%s\n", _("Entry is empty"));
1911 printf(LISTFORMAT
"\"%s\"\n\n", _("Name"),DecodeUnicodeConsole(Category
.Name
));
1918 void AddCategory(int argc UNUSED
, char *argv
[])
1920 GSM_Category Category
;
1924 if (strcasecmp(argv
[2],"TODO") == 0) {
1925 Category
.Type
= Category_ToDo
;
1926 } else if (strcasecmp(argv
[2],"PHONEBOOK") == 0) {
1927 Category
.Type
= Category_Phonebook
;
1929 printf(_("What type of category do you want to add (\"%s\") ?\n"),argv
[2]);
1935 Length
= strlen(argv
[3]);
1936 if (Length
> GSM_MAX_CATEGORY_NAME_LENGTH
) {
1937 printf(_("Text too long, truncating to %d chars!\n"), GSM_MAX_CATEGORY_NAME_LENGTH
);
1938 Length
= GSM_MAX_CATEGORY_NAME_LENGTH
;
1940 EncodeUnicode(Category
.Name
, argv
[3], Length
);
1942 Category
.Location
= 0;
1944 error
= GSM_AddCategory(gsm
, &Category
);
1951 void GetSecurityStatus(int argc UNUSED
, char *argv
[] UNUSED
)
1955 PrintSecurityStatus();
1960 void EnterSecurityCode(int argc UNUSED
, char *argv
[])
1962 GSM_SecurityCode Code
;
1969 if (strcasecmp(argv
[2],"PIN") == 0) { Code
.Type
= SEC_Pin
;
1970 } else if (strcasecmp(argv
[2],"PUK") == 0) { Code
.Type
= SEC_Puk
;
1971 } else if (strcasecmp(argv
[2],"PIN2") == 0) { Code
.Type
= SEC_Pin2
;
1972 } else if (strcasecmp(argv
[2],"PUK2") == 0) { Code
.Type
= SEC_Puk2
;
1973 } else if (strcasecmp(argv
[2],"PHONE") == 0) { Code
.Type
= SEC_Phone
;
1974 } else if (strcasecmp(argv
[2],"NETWORK") == 0) { Code
.Type
= SEC_Network
;
1976 printf_err("%s: %s\n", _("Invalid security code type"), argv
[2]);
1980 if (strcmp(argv
[3], "-") == 0) {
1981 sprintf(message
, _("Enter %s code: "), argv
[2]);
1983 pass
= getpass(message
);
1984 strcpy(Code
.Code
, pass
);
1986 /* Read code from stdin */
1987 #ifdef HAVE_UNISTD_H
1988 if (isatty(fileno(stdin
))) {
1989 printf("%s", message
);
1992 if (fscanf(stdin
, "%15s", Code
.Code
) != 1) {
1993 printf_err("%s\n", _("No PIN code entered!"));
1998 strcpy(Code
.Code
,argv
[3]);
2002 if (strcmp(argv
[4], "-") == 0) {
2003 sprintf(message
, _("Enter new PIN code: "));
2005 pass
= getpass(message
);
2006 strcpy(Code
.Code
, pass
);
2008 /* Read code from stdin */
2009 #ifdef HAVE_UNISTD_H
2010 if (isatty(fileno(stdin
))) {
2011 printf("%s", message
);
2014 if (fscanf(stdin
, "%15s", Code
.Code
) != 1) {
2015 printf_err("%s\n", _("No PIN code entered!"));
2020 strcpy(Code
.NewPIN
, argv
[4]);
2028 error
=GSM_EnterSecurityCode(gsm
, &Code
);
2034 void GetProfile(int argc
, char *argv
[])
2036 GSM_Profile Profile
;
2037 int start
,stop
,i
,j
,k
;
2038 GSM_Bitmap caller
[5];
2039 gboolean callerinit
[5],special
;
2040 GSM_AllRingtonesInfo Info
= {0, NULL
};
2041 const unsigned char *ringtonename
;
2044 GetStartStop(&start
, &stop
, 2, argc
, argv
);
2046 for (i
=0;i
<5;i
++) callerinit
[i
] = FALSE
;
2050 error
=GSM_GetRingtonesInfo(gsm
,&Info
);
2051 if (error
!= ERR_NONE
) Info
.Number
= 0;
2053 for (i
=start
;i
<=stop
;i
++) {
2055 error
=GSM_GetProfile(gsm
,&Profile
);
2056 if (error
!= ERR_NONE
&& Info
.Ringtone
) free(Info
.Ringtone
);
2059 printf("%i. \"%s\"",i
,DecodeUnicodeConsole(Profile
.Name
));
2060 if (Profile
.Active
) printf("%s", _(" (active)"));
2061 if (Profile
.DefaultName
) printf("%s", _(" (default name)"));
2062 if (Profile
.HeadSetProfile
) printf("%s", _(" (Head set profile)"));
2063 if (Profile
.CarKitProfile
) printf("%s", _(" (Car kit profile)"));
2065 for (j
=0;j
<Profile
.FeaturesNumber
;j
++) {
2067 switch (Profile
.FeatureID
[j
]) {
2068 case Profile_MessageToneID
:
2069 case Profile_RingtoneID
:
2071 if (Profile
.FeatureID
[j
] == Profile_RingtoneID
) {
2072 printf(LISTFORMAT
, _("Ringtone ID"));
2074 printf(LISTFORMAT
, _("Message alert tone ID"));
2076 ringtonename
= GSM_GetRingtoneName(&Info
, Profile
.FeatureValue
[j
]);
2077 if (ringtonename
!= NULL
) {
2078 /* l10n: Ringtone name and ID format */
2079 printf(_("\"%s\" (ID %i)\n"), DecodeUnicodeConsole(ringtonename
), Profile
.FeatureValue
[j
]);
2081 /* l10n: Ringtone ID format */
2082 printf(_("ID %i\n"), Profile
.FeatureValue
[j
]);
2085 case Profile_CallerGroups
:
2087 printf(LISTFORMAT
, _("Call alert for"));
2089 if (Profile
.CallerGroups
[k
]) {
2090 if (!callerinit
[k
]) {
2091 caller
[k
].Type
= GSM_CallerGroupLogo
;
2092 caller
[k
].Location
= k
+ 1;
2093 error
=GSM_GetBitmap(gsm
,&caller
[k
]);
2094 if (error
== ERR_SECURITYERROR
) {
2095 NOKIA_GetDefaultCallerGroupName(&caller
[k
]);
2099 callerinit
[k
] = TRUE
;
2101 printf(" \"%s\"",DecodeUnicodeConsole(caller
[k
].Text
));
2106 case Profile_ScreenSaverNumber
:
2108 printf(LISTFORMAT
, _("Screen saver number"));
2109 printf("%i\n",Profile
.FeatureValue
[j
]);
2111 case Profile_CallAlert
: printf(LISTFORMAT
, _("Incoming call alert")); break;
2112 case Profile_RingtoneVolume
: printf(LISTFORMAT
, _("Ringtone volume")); break;
2113 case Profile_Vibration
: printf(LISTFORMAT
, _("Vibrating alert")); break;
2114 case Profile_MessageTone
: printf(LISTFORMAT
, _("Message alert tone")); break;
2115 case Profile_KeypadTone
: printf(LISTFORMAT
, _("Keypad tones")); break;
2116 case Profile_WarningTone
: printf(LISTFORMAT
, _("Warning (games) tones")); break;
2117 case Profile_ScreenSaver
: printf(LISTFORMAT
, _("Screen saver")); break;
2118 case Profile_ScreenSaverTime
: printf(LISTFORMAT
, _("Screen saver timeout")); break;
2119 case Profile_AutoAnswer
: printf(LISTFORMAT
, _("Automatic answer")); break;
2120 case Profile_Lights
: printf(LISTFORMAT
, _("Lights")); break;
2122 printf("%s\n", _("Unknown"));
2126 switch (Profile
.FeatureValue
[j
]) {
2127 case PROFILE_VOLUME_LEVEL1
:
2128 case PROFILE_KEYPAD_LEVEL1
: printf("%s\n", _("Level 1")); break;
2129 case PROFILE_VOLUME_LEVEL2
:
2130 case PROFILE_KEYPAD_LEVEL2
: printf("%s\n", _("Level 2")); break;
2131 case PROFILE_VOLUME_LEVEL3
:
2132 case PROFILE_KEYPAD_LEVEL3
: printf("%s\n", _("Level 3")); break;
2133 case PROFILE_VOLUME_LEVEL4
: printf("%s\n", _("Level 4")); break;
2134 case PROFILE_VOLUME_LEVEL5
: printf("%s\n", _("Level 5")); break;
2135 case PROFILE_MESSAGE_NOTONE
:
2136 case PROFILE_AUTOANSWER_OFF
:
2137 case PROFILE_LIGHTS_OFF
:
2138 case PROFILE_SAVER_OFF
:
2139 case PROFILE_WARNING_OFF
:
2140 case PROFILE_CALLALERT_OFF
:
2141 case PROFILE_VIBRATION_OFF
:
2142 case PROFILE_KEYPAD_OFF
: printf("%s\n", _("Off")); break;
2143 case PROFILE_CALLALERT_RINGING
: printf("%s\n", _("Ringing")); break;
2144 case PROFILE_CALLALERT_BEEPONCE
:
2145 case PROFILE_MESSAGE_BEEPONCE
: printf("%s\n", _("Beep once")); break;
2146 case PROFILE_CALLALERT_RINGONCE
: printf("%s\n", _("Ring once")); break;
2147 case PROFILE_CALLALERT_ASCENDING
: printf("%s\n", _("Ascending")); break;
2148 case PROFILE_CALLALERT_CALLERGROUPS
: printf("%s\n", _("Caller groups")); break;
2149 case PROFILE_MESSAGE_STANDARD
: printf("%s\n", _("Standard")); break;
2150 case PROFILE_MESSAGE_SPECIAL
: printf("%s\n", _("Special")); break;
2151 case PROFILE_MESSAGE_ASCENDING
: printf("%s\n", _("Ascending")); break;
2152 case PROFILE_MESSAGE_PERSONAL
: printf("%s\n", _("Personal")); break;
2153 case PROFILE_AUTOANSWER_ON
:
2154 case PROFILE_WARNING_ON
:
2155 case PROFILE_SAVER_ON
:
2156 case PROFILE_VIBRATION_ON
: printf("%s\n", _("On")); break;
2157 case PROFILE_VIBRATION_FIRST
: printf("%s\n", _("Vibrate first")); break;
2158 case PROFILE_LIGHTS_AUTO
: printf("%s\n", _("Auto")); break;
2159 case PROFILE_SAVER_TIMEOUT_5SEC
: PRINTSECONDS(5); printf("\n"); break;
2160 case PROFILE_SAVER_TIMEOUT_20SEC
: PRINTSECONDS(20); printf("\n"); break;
2161 case PROFILE_SAVER_TIMEOUT_1MIN
: PRINTMINUTES(1); printf("\n"); break;
2162 case PROFILE_SAVER_TIMEOUT_2MIN
: PRINTMINUTES(2); printf("\n"); break;
2163 case PROFILE_SAVER_TIMEOUT_5MIN
: PRINTMINUTES(5); printf("\n"); break;
2164 case PROFILE_SAVER_TIMEOUT_10MIN
: PRINTMINUTES(10); printf("\n"); break;
2165 default : printf("%s\n", _("Unknown"));
2174 if (Info
.Ringtone
) free(Info
.Ringtone
);
2177 void GetSpeedDial(int argc
, char *argv
[])
2179 GSM_SpeedDial SpeedDial
;
2180 GSM_MemoryEntry Phonebook
;
2181 int start
,stop
,Name
,Number
,Group
,i
;
2184 GetStartStop(&start
, &stop
, 2, argc
, argv
);
2188 for (i
=start
;i
<=stop
;i
++) {
2189 SpeedDial
.Location
=i
;
2190 error
=GSM_GetSpeedDial(gsm
,&SpeedDial
);
2191 printf(LISTFORMAT
"%i\n", _("Location"), i
);
2194 printf("%s\n", _(" speed dial not assigned"));
2199 Phonebook
.Location
= SpeedDial
.MemoryLocation
;
2200 Phonebook
.MemoryType
= SpeedDial
.MemoryType
;
2201 error
= GSM_GetMemory(gsm
,&Phonebook
);
2204 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook
, &Name
, &Number
, &Group
);
2206 if (Name
!= -1) printf(LISTFORMAT
"\"%s\"\n", _("Name"), DecodeUnicodeConsole(Phonebook
.Entries
[Name
].Text
));
2207 printf(LISTFORMAT
"\"%s\"\"", _("Number"), DecodeUnicodeConsole(Phonebook
.Entries
[SpeedDial
.MemoryNumberID
-1].Text
));
2215 void ResetPhoneSettings(int argc UNUSED
, char *argv
[])
2217 GSM_ResetSettingsType Type
;
2220 if (strcasecmp(argv
[2],"PHONE") == 0) { Type
= GSM_RESET_PHONESETTINGS
;
2221 } else if (strcasecmp(argv
[2],"UIF") == 0) { Type
= GSM_RESET_USERINTERFACE
;
2222 } else if (strcasecmp(argv
[2],"ALL") == 0) { Type
= GSM_RESET_USERINTERFACE_PHONESETTINGS
;
2223 } else if (strcasecmp(argv
[2],"DEV") == 0) { Type
= GSM_RESET_DEVICE
;
2224 } else if (strcasecmp(argv
[2],"FACTORY") == 0) { Type
= GSM_RESET_FULLFACTORY
;
2226 printf(_("What type of reset phone settings (\"%s\") ?\n"),argv
[2]);
2232 error
=GSM_ResetPhoneSettings(gsm
,Type
);
2238 void SendDTMF(int argc UNUSED
, char *argv
[])
2243 error
=GSM_SendDTMF(gsm
,argv
[2]);
2249 void GetDisplayStatus(int argc UNUSED
, char *argv
[] UNUSED
)
2252 GSM_DisplayFeatures Features
;
2257 error
=GSM_GetDisplayStatus(gsm
,&Features
);
2260 printf(LISTFORMAT
"\n", _("Currently shown on the display"));
2262 for (i
= 0; i
< Features
.Number
; i
++) {
2263 switch(Features
.Feature
[i
]) {
2264 case GSM_CallActive
:
2265 printf("%s\n", _("Call active"));
2268 printf("%s\n", _("Unread SMS"));
2271 printf("%s\n", _("Voice call"));
2274 printf("%s\n", _("Fax call"));
2277 printf("%s\n", _("Data call"));
2279 case GSM_KeypadLocked
:
2280 printf("%s\n", _("Keypad locked"));
2282 case GSM_SMSMemoryFull
:
2283 printf("%s\n", _("SMS memory full"));
2291 void SetAutoNetworkLogin(int argc UNUSED
, char *argv
[] UNUSED
)
2296 error
=GSM_SetAutoNetworkLogin(gsm
);
2302 void GetFMStation(int argc
, char *argv
[])
2304 GSM_FMStation Station
;
2308 GetStartStop(&start
, &stop
, 2, argc
, argv
);
2312 for (i
=start
;i
<=stop
;i
++) {
2314 error
=GSM_GetFMStation(gsm
,&Station
);
2315 printf(LISTFORMAT
"%i\n", _("Location"), i
);
2318 printf("%s\n", _("Entry is empty"));
2321 printf(LISTFORMAT
"\"%s\"\n", _("Station name"), DecodeUnicodeConsole(Station
.StationName
));
2322 printf(LISTFORMAT
"%.1f MHz\n", _("Frequency"), Station
.Frequency
);
2331 void CallDivert(int argc
, char *argv
[])
2334 GSM_MultiCallDivert cd
;
2335 GSM_CallDivert request
;
2336 gboolean get
= FALSE
;
2339 if (strcasecmp("get", argv
[2]) == 0) {
2341 } else if (strcasecmp("set", argv
[2]) == 0) {
2344 printf(_("Unknown divert action (\"%s\")\n"), argv
[2]);
2348 if (strcasecmp("all", argv
[3]) == 0) {
2349 request
.DivertType
= GSM_DIVERT_AllTypes
;
2350 } else if (strcasecmp("busy", argv
[3]) == 0) {
2351 request
.DivertType
= GSM_DIVERT_Busy
;
2352 } else if (strcasecmp("noans", argv
[3]) == 0) {
2353 request
.DivertType
= GSM_DIVERT_NoAnswer
;
2354 } else if (strcasecmp("outofreach", argv
[3]) == 0) {
2355 request
.DivertType
= GSM_DIVERT_OutOfReach
;
2357 printf(_("Unknown divert type (\"%s\")\n"), argv
[3]);
2361 if (strcasecmp("all", argv
[4]) == 0) {
2362 request
.CallType
= GSM_DIVERT_AllCalls
;
2363 } else if (strcasecmp("voice", argv
[4]) == 0) {
2364 request
.CallType
= GSM_DIVERT_VoiceCalls
;
2365 } else if (strcasecmp("fax", argv
[4]) == 0) {
2366 request
.CallType
= GSM_DIVERT_FaxCalls
;
2367 } else if (strcasecmp("data", argv
[4]) == 0) {
2368 request
.CallType
= GSM_DIVERT_DataCalls
;
2370 printf(_("Unknown call type (\"%s\")\n"), argv
[4]);
2377 error
= GSM_GetCallDivert(gsm
, &request
, &cd
);
2379 printf("%s", _("Query:"));
2382 request
.Number
[0] = 0;
2383 request
.Number
[1] = 0;
2385 EncodeUnicode(request
.Number
,argv
[5],strlen(argv
[5]));
2388 request
.Timeout
= 0;
2390 request
.Timeout
= GetInt(argv
[6]);
2393 error
= GSM_SetCallDivert(gsm
, &request
);
2395 printf("%s", _("Changed:"));
2398 printf(" " LISTFORMAT
, _("Divert type"));
2400 switch (request
.DivertType
) {
2401 case GSM_DIVERT_Busy
:
2402 printf("%s", _("when busy"));
2404 case GSM_DIVERT_NoAnswer
:
2405 printf("%s", _("when not answered"));
2407 case GSM_DIVERT_OutOfReach
:
2408 printf("%s", _("when phone off or no coverage"));
2410 case GSM_DIVERT_AllTypes
:
2411 printf("%s", _("all types of diverts"));
2414 printf(_("unknown %i"),request
.DivertType
);
2419 printf(" " LISTFORMAT
, _("Call type"));
2420 switch (request
.CallType
) {
2421 case GSM_DIVERT_VoiceCalls
:
2422 printf("%s", _("voice"));
2424 case GSM_DIVERT_FaxCalls
:
2425 printf("%s", _("fax"));
2427 case GSM_DIVERT_DataCalls
:
2428 printf("%s", _("data"));
2430 case GSM_DIVERT_AllCalls
:
2431 printf("%s", _("data & fax & voice"));
2434 printf(_("unknown %i"),request
.CallType
);
2440 printf("%s", _("Response:"));
2443 for (i
= 0; i
< cd
.EntriesNum
; i
++) {
2445 printf(" " LISTFORMAT
, _("Divert type"));
2447 switch (cd
.Entries
[i
].DivertType
) {
2448 case GSM_DIVERT_Busy
:
2449 printf("%s", _("when busy"));
2451 case GSM_DIVERT_NoAnswer
:
2452 printf("%s", _("when not answered"));
2454 case GSM_DIVERT_OutOfReach
:
2455 printf("%s", _("when phone off or no coverage"));
2457 case GSM_DIVERT_AllTypes
:
2458 printf("%s", _("all types of diverts"));
2461 printf(_("unknown %i"),cd
.Entries
[i
].DivertType
);
2465 printf(" " LISTFORMAT
, _("Call type"));
2466 switch (cd
.Entries
[i
].CallType
) {
2467 case GSM_DIVERT_VoiceCalls
:
2468 printf("%s", _("voice"));
2470 case GSM_DIVERT_FaxCalls
:
2471 printf("%s", _("fax"));
2473 case GSM_DIVERT_DataCalls
:
2474 printf("%s", _("data"));
2477 printf(_("unknown %i"),cd
.Entries
[i
].CallType
);
2482 printf(" " LISTFORMAT
, _("Timeout"));
2483 PRINTSECONDS(cd
.Entries
[i
].Timeout
);
2486 printf(" " LISTFORMAT
"%s\n", _("Number"), DecodeUnicodeString(cd
.Entries
[i
].Number
));
2494 void CancelAllDiverts(int argc UNUSED
, char *argv
[] UNUSED
)
2499 error
= GSM_CancelAllDiverts(gsm
);
2505 void Install(int argc
, char *argv
[])
2508 gboolean Minimal
= FALSE
;
2510 if (argc
== 3 && strcasecmp(argv
[2], "-minimal") == 0) {
2516 /* TODO: make search path configurable */
2517 error
= GSM_Install(gsm
, INI_GetValue(cfg
, "gammu", "datapath", FALSE
), Minimal
);
2520 printf("%s\n", _("The application has been successfully sent to the phone."));
2521 printf("%s\n", _("Please find received files in Inbox and install them."));
2526 /* How should editor hadle tabs in this file? Add editor commands here.
2527 * vim: noexpandtab sw=8 ts=8 sts=8: