summaryrefslogtreecommitdiffabout
path: root/gammu/emb
Unidiff
Diffstat (limited to 'gammu/emb') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/gammu/gammu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
index f49ae36..c436b90 100644
--- a/gammu/emb/gammu/gammu.c
+++ b/gammu/emb/gammu/gammu.c
@@ -1,8534 +1,8534 @@
1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ 1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
2/* FM stuff by Walek */ 2/* FM stuff by Walek */
3 3
4#include <string.h> 4#include <string.h>
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#include <stdarg.h> 7#include <stdarg.h>
8#include <locale.h> 8#include <locale.h>
9#include <signal.h> 9#include <signal.h>
10#include <ctype.h> 10#include <ctype.h>
11#include <wchar.h> 11#include <wchar.h>
12#ifdef WIN32 12#ifdef WIN32
13# include <windows.h> 13# include <windows.h>
14# include <process.h> 14# include <process.h>
15# ifdef _MSC_VER 15# ifdef _MSC_VER
16# include <sys/utime.h> 16# include <sys/utime.h>
17# else 17# else
18# include <utime.h> 18# include <utime.h>
19# endif 19# endif
20#else 20#else
21# include <utime.h> 21# include <utime.h>
22#endif 22#endif
23 23
24#include "../common/gammu.h" 24#include "../common/gammu.h"
25#include "gammu.h" 25#include "gammu.h"
26#include "smsd/smsdcore.h" 26#include "smsd/smsdcore.h"
27#ifdef DEBUG 27#ifdef DEBUG
28# include "sniff.h" 28# include "sniff.h"
29#endif 29#endif
30#ifdef GSM_ENABLE_NOKIA_DCT3 30#ifdef GSM_ENABLE_NOKIA_DCT3
31# include "depend/nokia/dct3.h" 31# include "depend/nokia/dct3.h"
32# include "depend/nokia/dct3trac/wmx.h" 32# include "depend/nokia/dct3trac/wmx.h"
33#endif 33#endif
34#ifdef GSM_ENABLE_NOKIA_DCT4 34#ifdef GSM_ENABLE_NOKIA_DCT4
35# include "depend/nokia/dct4.h" 35# include "depend/nokia/dct4.h"
36#endif 36#endif
37#ifdef GSM_ENABLE_ATGEN 37#ifdef GSM_ENABLE_ATGEN
38# include "depend/siemens/dsiemens.h" 38# include "depend/siemens/dsiemens.h"
39#endif 39#endif
40 40
41#ifdef HAVE_PTHREAD 41#ifdef HAVE_PTHREAD
42# include <pthread.h> 42# include <pthread.h>
43#endif 43#endif
44 44
45#ifdef HAVE_SYS_IOCTL_H 45#ifdef HAVE_SYS_IOCTL_H
46# include <sys/ioctl.h> 46# include <sys/ioctl.h>
47#endif 47#endif
48 48
49 49
50 GSM_StateMachine s; 50 GSM_StateMachine s;
51 GSM_Phone_Functions *Phone; 51 GSM_Phone_Functions *Phone;
52 static INI_Section *cfg = NULL; 52 static INI_Section *cfg = NULL;
53 53
54 GSM_Error error = ERR_NONE; 54 GSM_Error error = ERR_NONE;
55 static int i; 55 static int i;
56 56
57 volatile bool gshutdown = false; 57 volatile bool gshutdown = false;
58 58
59void interrupt(int sign) 59void interrupt(int sign)
60{ 60{
61 signal(sign, SIG_IGN); 61 signal(sign, SIG_IGN);
62 gshutdown = true; 62 gshutdown = true;
63} 63}
64 64
65#ifdef __GNUC__ 65#ifdef __GNUC__
66__attribute__((format(printf, 1, 2))) 66__attribute__((format(printf, 1, 2)))
67#endif 67#endif
68int printmsg(char *format, ...) 68int printmsg(char *format, ...)
69{ 69{
70 va_list argp; 70 va_list argp;
71 int result; 71 int result;
72 72
73 va_start(argp, format); 73 va_start(argp, format);
74 result = vfprintf(stdout,GetMsg(s.msg,format),argp); 74 result = vfprintf(stdout,GetMsg(s.msg,format),argp);
75 va_end(argp); 75 va_end(argp);
76 return result; 76 return result;
77} 77}
78 78
79#ifdef __GNUC__ 79#ifdef __GNUC__
80__attribute__((format(printf, 1, 2))) 80__attribute__((format(printf, 1, 2)))
81#endif 81#endif
82int printmsgerr(char *format, ...) 82int printmsgerr(char *format, ...)
83{ 83{
84 va_list argp; 84 va_list argp;
85 int result; 85 int result;
86 86
87 va_start(argp, format); 87 va_start(argp, format);
88 result = vfprintf(stderr,GetMsg(s.msg,format), argp); 88 result = vfprintf(stderr,GetMsg(s.msg,format), argp);
89 va_end(argp); 89 va_end(argp);
90 return result; 90 return result;
91} 91}
92 92
93static void PrintSecurityStatus() 93static void PrintSecurityStatus()
94{ 94{
95 GSM_SecurityCodeType Status; 95 GSM_SecurityCodeType Status;
96 96
97 error=Phone->GetSecurityStatus(&s,&Status); 97 error=Phone->GetSecurityStatus(&s,&Status);
98 Print_Error(error); 98 Print_Error(error);
99 switch(Status) { 99 switch(Status) {
100 case SEC_SecurityCode: 100 case SEC_SecurityCode:
101 printmsg("Waiting for Security Code.\n"); 101 printmsg("Waiting for Security Code.\n");
102 break; 102 break;
103 case SEC_Pin: 103 case SEC_Pin:
104 printmsg("Waiting for PIN.\n"); 104 printmsg("Waiting for PIN.\n");
105 break; 105 break;
106 case SEC_Pin2: 106 case SEC_Pin2:
107 printmsg("Waiting for PIN2.\n"); 107 printmsg("Waiting for PIN2.\n");
108 break; 108 break;
109 case SEC_Puk: 109 case SEC_Puk:
110 printmsg("Waiting for PUK.\n"); 110 printmsg("Waiting for PUK.\n");
111 break; 111 break;
112 case SEC_Puk2: 112 case SEC_Puk2:
113 printmsg("Waiting for PUK2.\n"); 113 printmsg("Waiting for PUK2.\n");
114 break; 114 break;
115 case SEC_None: 115 case SEC_None:
116 printmsg("Nothing to enter.\n"); 116 printmsg("Nothing to enter.\n");
117 break; 117 break;
118 default: 118 default:
119 printmsg("Unknown\n"); 119 printmsg("Unknown\n");
120 } 120 }
121} 121}
122 122
123void Print_Error(GSM_Error error) 123void Print_Error(GSM_Error error)
124{ 124{
125 if (error != ERR_NONE) { 125 if (error != ERR_NONE) {
126 printf("%s\n",print_error(error,s.di.df,s.msg)); 126 printf("%s\n",print_error(error,s.di.df,s.msg));
127 if (error == ERR_SECURITYERROR) { 127 if (error == ERR_SECURITYERROR) {
128 printmsg("Security status: "); 128 printmsg("Security status: ");
129 PrintSecurityStatus(); 129 PrintSecurityStatus();
130 } 130 }
131 if (s.opened) GSM_TerminateConnection(&s); 131 if (s.opened) GSM_TerminateConnection(&s);
132 exit (-1); 132 exit (-1);
133 } 133 }
134} 134}
135 135
136void GSM_Init(bool checkerror) 136void GSM_Init(bool checkerror)
137{ 137{
138 error=GSM_InitConnection(&s,3); 138 error=GSM_InitConnection(&s,3);
139 if (checkerror) Print_Error(error); 139 if (checkerror) Print_Error(error);
140 140
141 Phone=s.Phone.Functions; 141 Phone=s.Phone.Functions;
142} 142}
143 143
144void GSM_Terminate(void) 144void GSM_Terminate(void)
145{ 145{
146 error=GSM_TerminateConnection(&s); 146 error=GSM_TerminateConnection(&s);
147 Print_Error(error); 147 Print_Error(error);
148} 148}
149 149
150static void GetStartStop(int *start, int *stop, int num, int argc, char *argv[]) 150static void GetStartStop(int *start, int *stop, int num, int argc, char *argv[])
151{ 151{
152 *start=atoi(argv[num]); 152 *start=atoi(argv[num]);
153 if (*start==0) { 153 if (*start==0) {
154 printmsg("ERROR: enumerate locations from 1\n"); 154 printmsg("ERROR: enumerate locations from 1\n");
155 exit (-1); 155 exit (-1);
156 } 156 }
157 157
158 if (stop!=NULL) { 158 if (stop!=NULL) {
159 *stop=*start; 159 *stop=*start;
160 if (argc>=num+2) *stop=atoi(argv[num+1]); 160 if (argc>=num+2) *stop=atoi(argv[num+1]);
161 if (*stop==0) { 161 if (*stop==0) {
162 printmsg("ERROR: enumerate locations from 1\n"); 162 printmsg("ERROR: enumerate locations from 1\n");
163 exit (-1); 163 exit (-1);
164 } 164 }
165 } 165 }
166} 166}
167 167
168bool always_answer_yes = false; 168bool always_answer_yes = false;
169bool always_answer_no = false; 169bool always_answer_no = false;
170 170
171static bool answer_yes(char *text) 171static bool answer_yes(char *text)
172{ 172{
173 int len; 173 int len;
174 char ans[99]; 174 char ans[99];
175 175
176 while (1) { 176 while (1) {
177 printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text); 177 printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text);
178 if (always_answer_yes) { 178 if (always_answer_yes) {
179 printmsgerr("YES (always)\n"); 179 printmsgerr("YES (always)\n");
180 return true; 180 return true;
181 } 181 }
182 if (always_answer_no) { 182 if (always_answer_no) {
183 printmsgerr("NO (always)\n"); 183 printmsgerr("NO (always)\n");
184 return false; 184 return false;
185 } 185 }
186 len=GetLine(stdin, ans, 99); 186 len=GetLine(stdin, ans, 99);
187 if (len==-1) exit(-1); 187 if (len==-1) exit(-1);
188 if (!strcmp(ans, "NONE")) { 188 if (!strcmp(ans, "NONE")) {
189 always_answer_no = true; 189 always_answer_no = true;
190 return false; 190 return false;
191 } 191 }
192 if (!strcmp(ans, "ONLY")) { 192 if (!strcmp(ans, "ONLY")) {
193 always_answer_no = true; 193 always_answer_no = true;
194 return true; 194 return true;
195 } 195 }
196 if (!strcmp(ans, "ALL")) { 196 if (!strcmp(ans, "ALL")) {
197 always_answer_yes = true; 197 always_answer_yes = true;
198 return true; 198 return true;
199 } 199 }
200 if (mystrncasecmp(ans, "yes",0)) return true; 200 if (mystrncasecmp(ans, "yes",0)) return true;
201 if (mystrncasecmp(ans, "no" ,0)) return false; 201 if (mystrncasecmp(ans, "no" ,0)) return false;
202 } 202 }
203} 203}
204 204
205#ifdef GSM_ENABLE_BEEP 205#ifdef GSM_ENABLE_BEEP
206void GSM_PhoneBeep(void) 206void GSM_PhoneBeep(void)
207{ 207{
208 error = PHONE_Beep(&s); 208 error = PHONE_Beep(&s);
209 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error); 209 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error);
210} 210}
211#endif 211#endif
212 212
213static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone) 213static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
214{ 214{
215 int i; 215 int i;
216 bool first=true; 216 bool first=true;
217 GSM_Error error; 217 GSM_Error error;
218 218
219 signal(SIGINT, interrupt); 219 signal(SIGINT, interrupt);
220 printmsg("Press Ctrl+C to break...\n"); 220 printmsg("Press Ctrl+C to break...\n");
221 221
222 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 222 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
223 if (gshutdown) break; 223 if (gshutdown) break;
224 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue; 224 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue;
225 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first); 225 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first);
226 if (error!=ERR_NONE) return error; 226 if (error!=ERR_NONE) return error;
227 first = false; 227 first = false;
228 } 228 }
229 229
230 /* Disables buzzer */ 230 /* Disables buzzer */
231 return s.Phone.Functions->PlayTone(&s,255*255,0,false); 231 return s.Phone.Functions->PlayTone(&s,255*255,0,false);
232} 232}
233 233
234static void PlayRingtone(int argc, char *argv[]) 234static void PlayRingtone(int argc, char *argv[])
235{ 235{
236 GSM_Ringtone ringtone,ringtone2; 236 GSM_Ringtone ringtone,ringtone2;
237 237
238 ringtone.Format= 0; 238 ringtone.Format= 0;
239 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 239 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
240 Print_Error(error); 240 Print_Error(error);
241 241
242 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE); 242 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE);
243 Print_Error(error); 243 Print_Error(error);
244 244
245 GSM_Init(true); 245 GSM_Init(true);
246 246
247 error=GSM_PlayRingtone(ringtone2); 247 error=GSM_PlayRingtone(ringtone2);
248 Print_Error(error); 248 Print_Error(error);
249 249
250 GSM_Terminate(); 250 GSM_Terminate();
251} 251}
252 252
253static void Identify(int argc, char *argv[]) 253static void Identify(int argc, char *argv[])
254{ 254{
255 unsigned char buffer[100]; 255 unsigned char buffer[100];
256 256
257 GSM_Init(true); 257 GSM_Init(true);
258 258
259 error=Phone->GetManufacturer(&s); 259 error=Phone->GetManufacturer(&s);
260 Print_Error(error); 260 Print_Error(error);
261 printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer); 261 printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer);
262 error=Phone->GetModel(&s); 262 error=Phone->GetModel(&s);
263 Print_Error(error); 263 Print_Error(error);
264 printmsg("Model : %s (%s)\n", 264 printmsg("Model : %s (%s)\n",
265 s.Phone.Data.ModelInfo->model, 265 s.Phone.Data.ModelInfo->model,
266 s.Phone.Data.Model); 266 s.Phone.Data.Model);
267 267
268 error=Phone->GetFirmware(&s); 268 error=Phone->GetFirmware(&s);
269 Print_Error(error); 269 Print_Error(error);
270 printmsg("Firmware : %s",s.Phone.Data.Version); 270 printmsg("Firmware : %s",s.Phone.Data.Version);
271 error=Phone->GetPPM(&s, buffer); 271 error=Phone->GetPPM(&s, buffer);
272 if (error != ERR_NOTSUPPORTED) { 272 if (error != ERR_NOTSUPPORTED) {
273 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 273 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
274 if (error == ERR_NONE) printmsg(" %s",buffer); 274 if (error == ERR_NONE) printmsg(" %s",buffer);
275 } 275 }
276 if (s.Phone.Data.VerDate[0]!=0) printmsg(" (%s)",s.Phone.Data.VerDate); 276 if (s.Phone.Data.VerDate[0]!=0) printmsg(" (%s)",s.Phone.Data.VerDate);
277 printf("\n"); 277 printf("\n");
278 278
279 error=Phone->GetHardware(&s, buffer); 279 error=Phone->GetHardware(&s, buffer);
280 if (error != ERR_NOTSUPPORTED) { 280 if (error != ERR_NOTSUPPORTED) {
281 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 281 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
282 if (error == ERR_NONE) printmsg("Hardware : %s\n",buffer); 282 if (error == ERR_NONE) printmsg("Hardware : %s\n",buffer);
283 } 283 }
284 284
285 error=Phone->GetIMEI(&s); 285 error=Phone->GetIMEI(&s);
286 if (error != ERR_NOTSUPPORTED) { 286 if (error != ERR_NOTSUPPORTED) {
287 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 287 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
288 if (error == ERR_NONE) printmsg("IMEI : %s\n",s.Phone.Data.IMEI); 288 if (error == ERR_NONE) printmsg("IMEI : %s\n",s.Phone.Data.IMEI);
289 289
290 error=Phone->GetOriginalIMEI(&s, buffer); 290 error=Phone->GetOriginalIMEI(&s, buffer);
291 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) { 291 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
292 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 292 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
293 if (error == ERR_NONE) printmsg("Original IMEI : %s\n",buffer); 293 if (error == ERR_NONE) printmsg("Original IMEI : %s\n",buffer);
294 } 294 }
295 } 295 }
296 296
297 error=Phone->GetManufactureMonth(&s, buffer); 297 error=Phone->GetManufactureMonth(&s, buffer);
298 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) { 298 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
299 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 299 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
300 if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer); 300 if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer);
301 } 301 }
302 302
303 error=Phone->GetProductCode(&s, buffer); 303 error=Phone->GetProductCode(&s, buffer);
304 if (error != ERR_NOTSUPPORTED) { 304 if (error != ERR_NOTSUPPORTED) {
305 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 305 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
306 if (error == ERR_NONE) printmsg("Product code : %s\n",buffer); 306 if (error == ERR_NONE) printmsg("Product code : %s\n",buffer);
307 } 307 }
308 308
309 error=Phone->GetSIMIMSI(&s, buffer); 309 error=Phone->GetSIMIMSI(&s, buffer);
310 switch (error) { 310 switch (error) {
311 case ERR_SECURITYERROR: 311 case ERR_SECURITYERROR:
312 case ERR_NOTSUPPORTED: 312 case ERR_NOTSUPPORTED:
313 case ERR_NOTIMPLEMENTED: 313 case ERR_NOTIMPLEMENTED:
314 break; 314 break;
315 case ERR_NONE: 315 case ERR_NONE:
316 printmsg("SIM IMSI : %s\n",buffer); 316 printmsg("SIM IMSI : %s\n",buffer);
317 break; 317 break;
318 default: 318 default:
319 Print_Error(error); 319 Print_Error(error);
320 } 320 }
321 321
322#ifdef GSM_ENABLE_NOKIA_DCT3 322#ifdef GSM_ENABLE_NOKIA_DCT3
323 DCT3Info(argc, argv); 323 DCT3Info(argc, argv);
324#endif 324#endif
325#ifdef GSM_ENABLE_NOKIA_DCT4 325#ifdef GSM_ENABLE_NOKIA_DCT4
326 DCT4Info(argc, argv); 326 DCT4Info(argc, argv);
327#endif 327#endif
328 328
329 GSM_Terminate(); 329 GSM_Terminate();
330} 330}
331 331
332static void GetDateTime(int argc, char *argv[]) 332static void GetDateTime(int argc, char *argv[])
333{ 333{
334 GSM_DateTime date_time; 334 GSM_DateTime date_time;
335 GSM_Localelocale; 335 GSM_Localelocale;
336 336
337 GSM_Init(true); 337 GSM_Init(true);
338 338
339 error=Phone->GetDateTime(&s, &date_time); 339 error=Phone->GetDateTime(&s, &date_time);
340 switch (error) { 340 switch (error) {
341 case ERR_EMPTY: 341 case ERR_EMPTY:
342 printmsg("Date and time not set in phone\n"); 342 printmsg("Date and time not set in phone\n");
343 break; 343 break;
344 case ERR_NONE: 344 case ERR_NONE:
345 printmsg("Phone time is %s\n",OSDateTime(date_time,false)); 345 printmsg("Phone time is %s\n",OSDateTime(date_time,false));
346 break; 346 break;
347 default: 347 default:
348 Print_Error(error); 348 Print_Error(error);
349 } 349 }
350 350
351 error=Phone->GetLocale(&s, &locale); 351 error=Phone->GetLocale(&s, &locale);
352 switch (error) { 352 switch (error) {
353 case ERR_NOTSUPPORTED: 353 case ERR_NOTSUPPORTED:
354 case ERR_NOTIMPLEMENTED: 354 case ERR_NOTIMPLEMENTED:
355 break; 355 break;
356 default: 356 default:
357 Print_Error(error); 357 Print_Error(error);
358 printmsg("Time format is "); 358 printmsg("Time format is ");
359 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n"); 359 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n");
360 printmsg("Date format is "); 360 printmsg("Date format is ");
361 switch (locale.DateFormat) { 361 switch (locale.DateFormat) {
362 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break; 362 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break;
363 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break; 363 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break;
364 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD"); 364 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
365 default :break; 365 default :break;
366 } 366 }
367 printmsg(", date separator is %c\n",locale.DateSeparator); 367 printmsg(", date separator is %c\n",locale.DateSeparator);
368 } 368 }
369 369
370 GSM_Terminate(); 370 GSM_Terminate();
371} 371}
372 372
373static void SetDateTime(int argc, char *argv[]) 373static void SetDateTime(int argc, char *argv[])
374{ 374{
375 GSM_DateTime date_time; 375 GSM_DateTime date_time;
376 376
377 GSM_GetCurrentDateTime(&date_time); 377 GSM_GetCurrentDateTime(&date_time);
378 378
379 GSM_Init(true); 379 GSM_Init(true);
380 380
381 error=Phone->SetDateTime(&s, &date_time); 381 error=Phone->SetDateTime(&s, &date_time);
382 Print_Error(error); 382 Print_Error(error);
383 383
384 GSM_Terminate(); 384 GSM_Terminate();
385} 385}
386 386
387static void GetAlarm(int argc, char *argv[]) 387static void GetAlarm(int argc, char *argv[])
388{ 388{
389 GSM_Alarm alarm; 389 GSM_Alarm alarm;
390 390
391 GSM_Init(true); 391 GSM_Init(true);
392 392
393 alarm.Location = 1; 393 alarm.Location = 1;
394 error=Phone->GetAlarm(&s, &alarm); 394 error=Phone->GetAlarm(&s, &alarm);
395 switch (error) { 395 switch (error) {
396 case ERR_EMPTY: 396 case ERR_EMPTY:
397 printmsg("Alarm not set in phone\n"); 397 printmsg("Alarm not set in phone\n");
398 break; 398 break;
399 case ERR_NONE: 399 case ERR_NONE:
400 if (alarm.Repeating) { 400 if (alarm.Repeating) {
401 printmsg("Date: %s\n","Every day"); 401 printmsg("Date: %s\n","Every day");
402 } else { 402 } else {
403 printmsg("Date: %s\n",OSDate(alarm.DateTime)); 403 printmsg("Date: %s\n",OSDate(alarm.DateTime));
404 } 404 }
405 printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute); 405 printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute);
406 if (alarm.Text[0] != 0 || alarm.Text[1] != 0) { 406 if (alarm.Text[0] != 0 || alarm.Text[1] != 0) {
407 printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text)); 407 printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text));
408 } 408 }
409 break; 409 break;
410 default: 410 default:
411 Print_Error(error); 411 Print_Error(error);
412 } 412 }
413 413
414 GSM_Terminate(); 414 GSM_Terminate();
415} 415}
416 416
417static void SetAlarm(int argc, char *argv[]) 417static void SetAlarm(int argc, char *argv[])
418{ 418{
419 GSM_Alarm alarm; 419 GSM_Alarm alarm;
420 420
421 alarm.DateTime.Hour = atoi(argv[2]); 421 alarm.DateTime.Hour = atoi(argv[2]);
422 alarm.DateTime.Minute = atoi(argv[3]); 422 alarm.DateTime.Minute = atoi(argv[3]);
423 alarm.DateTime.Second = 0; 423 alarm.DateTime.Second = 0;
424 alarm.Location = 1; 424 alarm.Location = 1;
425 alarm.Repeating = true; 425 alarm.Repeating = true;
426 alarm.Text[0] = 0; 426 alarm.Text[0] = 0;
427 alarm.Text[1] = 0; 427 alarm.Text[1] = 0;
428 428
429 GSM_Init(true); 429 GSM_Init(true);
430 430
431 error=Phone->SetAlarm(&s, &alarm); 431 error=Phone->SetAlarm(&s, &alarm);
432 Print_Error(error); 432 Print_Error(error);
433 433
434 GSM_Terminate(); 434 GSM_Terminate();
435} 435}
436 436
437 GSM_Bitmap caller[5]; 437 GSM_Bitmap caller[5];
438 GSM_AllRingtonesInfo Info; 438 GSM_AllRingtonesInfo Info;
439 bool callerinit[5] = {false, false, false, false, false}; 439 bool callerinit[5] = {false, false, false, false, false};
440 bool ringinit = false; 440 bool ringinit = false;
441 441
442static void PrintMemoryEntry(GSM_MemoryEntry *entry) 442static void PrintMemoryEntry(GSM_MemoryEntry *entry)
443{ 443{
444 GSM_Category Category; 444 GSM_Category Category;
445 bool unknown; 445 bool unknown;
446 int z; 446 int z;
447 447
448 for (i=0;i<entry->EntriesNum;i++) { 448 for (i=0;i<entry->EntriesNum;i++) {
449 unknown = false; 449 unknown = false;
450 switch (entry->Entries[i].EntryType) { 450 switch (entry->Entries[i].EntryType) {
451 case PBK_Date: 451 case PBK_Date:
452 printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false)); 452 printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false));
453 continue; 453 continue;
454 case PBK_Category: 454 case PBK_Category:
455 Category.Location = entry->Entries[i].Number; 455 Category.Location = entry->Entries[i].Number;
456 Category.Type = Category_Phonebook; 456 Category.Type = Category_Phonebook;
457 error=Phone->GetCategory(&s, &Category); 457 error=Phone->GetCategory(&s, &Category);
458 if (error == ERR_NONE) { 458 if (error == ERR_NONE) {
459 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number); 459 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number);
460 } else { 460 } else {
461 printmsg("Category : %i\n", entry->Entries[i].Number); 461 printmsg("Category : %i\n", entry->Entries[i].Number);
462 } 462 }
463 continue; 463 continue;
464 case PBK_Private: 464 case PBK_Private:
465 printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No"); 465 printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No");
466 continue; 466 continue;
467 case PBK_Number_General : printmsg("General number "); break; 467 case PBK_Number_General : printmsg("General number "); break;
468 case PBK_Number_Mobile : printmsg("Mobile number "); break; 468 case PBK_Number_Mobile : printmsg("Mobile number "); break;
469 case PBK_Number_Work : printmsg("Work number "); break; 469 case PBK_Number_Work : printmsg("Work number "); break;
470 case PBK_Number_Fax : printmsg("Fax number "); break; 470 case PBK_Number_Fax : printmsg("Fax number "); break;
471 case PBK_Number_Home : printmsg("Home number "); break; 471 case PBK_Number_Home : printmsg("Home number "); break;
472 case PBK_Number_Pager : printmsg("Pager number "); break; 472 case PBK_Number_Pager : printmsg("Pager number "); break;
473 case PBK_Number_Other : printmsg("Other number "); break; 473 case PBK_Number_Other : printmsg("Other number "); break;
474 case PBK_Text_Note : printmsg("Text "); break; 474 case PBK_Text_Note : printmsg("Text "); break;
475 case PBK_Text_Postal : printmsg("Snail address "); break; 475 case PBK_Text_Postal : printmsg("Snail address "); break;
476 case PBK_Text_Email : printmsg("Email address 1 "); break; 476 case PBK_Text_Email : printmsg("Email address 1 "); break;
477 case PBK_Text_Email2 : printmsg("Email address 2 "); break; 477 case PBK_Text_Email2 : printmsg("Email address 2 "); break;
478 case PBK_Text_URL : printmsg("URL address "); break; 478 case PBK_Text_URL : printmsg("URL address "); break;
479 case PBK_Text_Name : printmsg("Name "); break; 479 case PBK_Text_Name : printmsg("Name "); break;
480 case PBK_Text_LastName : printmsg("Last name "); break; 480 case PBK_Text_LastName : printmsg("Last name "); break;
481 case PBK_Text_FirstName : printmsg("First name "); break; 481 case PBK_Text_FirstName : printmsg("First name "); break;
482 case PBK_Text_Company : printmsg("Company "); break; 482 case PBK_Text_Company : printmsg("Company "); break;
483 case PBK_Text_JobTitle : printmsg("Job title "); break; 483 case PBK_Text_JobTitle : printmsg("Job title "); break;
484 case PBK_Text_StreetAddress : printmsg("Street address "); break; 484 case PBK_Text_StreetAddress : printmsg("Street address "); break;
485 case PBK_Text_City : printmsg("City "); break; 485 case PBK_Text_City : printmsg("City "); break;
486 case PBK_Text_State : printmsg("State "); break; 486 case PBK_Text_State : printmsg("State "); break;
487 case PBK_Text_Zip : printmsg("Zip code "); break; 487 case PBK_Text_Zip : printmsg("Zip code "); break;
488 case PBK_Text_Country : printmsg("Country "); break; 488 case PBK_Text_Country : printmsg("Country "); break;
489 case PBK_Text_Custom1 : printmsg("Custom text 1 "); break; 489 case PBK_Text_Custom1 : printmsg("Custom text 1 "); break;
490 case PBK_Text_Custom2 : printmsg("Custom text 2 "); break; 490 case PBK_Text_Custom2 : printmsg("Custom text 2 "); break;
491 case PBK_Text_Custom3 : printmsg("Custom text 3 "); break; 491 case PBK_Text_Custom3 : printmsg("Custom text 3 "); break;
492 case PBK_Text_Custom4 : printmsg("Custom text 4 "); break; 492 case PBK_Text_Custom4 : printmsg("Custom text 4 "); break;
493 case PBK_Caller_Group : 493 case PBK_Caller_Group :
494 unknown = true; 494 unknown = true;
495 if (!callerinit[entry->Entries[i].Number]) { 495 if (!callerinit[entry->Entries[i].Number]) {
496 caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo; 496 caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo;
497 caller[entry->Entries[i].Number].Location = entry->Entries[i].Number; 497 caller[entry->Entries[i].Number].Location = entry->Entries[i].Number;
498 error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]); 498 error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]);
499 Print_Error(error); 499 Print_Error(error);
500 if (caller[entry->Entries[i].Number].DefaultName) { 500 if (caller[entry->Entries[i].Number].DefaultName) {
501 NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]); 501 NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]);
502 } 502 }
503 callerinit[entry->Entries[i].Number]=true; 503 callerinit[entry->Entries[i].Number]=true;
504 } 504 }
505 printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text)); 505 printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text));
506 break; 506 break;
507 case PBK_RingtoneID : 507 case PBK_RingtoneID :
508 unknown = true; 508 unknown = true;
509 if (!ringinit) { 509 if (!ringinit) {
510 error=Phone->GetRingtonesInfo(&s,&Info); 510 error=Phone->GetRingtonesInfo(&s,&Info);
511 if (error != ERR_NOTSUPPORTED) Print_Error(error); 511 if (error != ERR_NOTSUPPORTED) Print_Error(error);
512 if (error == ERR_NONE) ringinit = true; 512 if (error == ERR_NONE) ringinit = true;
513 } 513 }
514 if (ringinit) { 514 if (ringinit) {
515 for (z=0;z<Info.Number;z++) { 515 for (z=0;z<Info.Number;z++) {
516 if (Info.Ringtone[z].ID == entry->Entries[i].Number) { 516 if (Info.Ringtone[z].ID == entry->Entries[i].Number) {
517 printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name)); 517 printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name));
518 break; 518 break;
519 } 519 }
520 } 520 }
521 } else { 521 } else {
522 printmsg("Ringtone ID : %i\n",entry->Entries[i].Number); 522 printmsg("Ringtone ID : %i\n",entry->Entries[i].Number);
523 } 523 }
524 break; 524 break;
525 case PBK_PictureID : 525 case PBK_PictureID :
526 unknown = true; 526 unknown = true;
527 printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number); 527 printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number);
528 break; 528 break;
529 default : 529 default :
530 printmsg("UNKNOWN\n"); 530 printmsg("UNKNOWN\n");
531 unknown = true; 531 unknown = true;
532 break; 532 break;
533 } 533 }
534 if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text)); 534 if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text));
535 } 535 }
536 printf("\n"); 536 printf("\n");
537} 537}
538 538
539static void GetAllMemory(int argc, char *argv[]) 539static void GetAllMemory(int argc, char *argv[])
540{ 540{
541 GSM_MemoryEntry Entry; 541 GSM_MemoryEntry Entry;
542 bool start = true; 542 bool start = true;
543 543
544 signal(SIGINT, interrupt); 544 signal(SIGINT, interrupt);
545 printmsgerr("Press Ctrl+C to break...\n"); 545 printmsgerr("Press Ctrl+C to break...\n");
546 546
547 Entry.MemoryType = 0; 547 Entry.MemoryType = 0;
548 548
549 if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC; 549 if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC;
550 if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON; 550 if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON;
551 if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC; 551 if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC;
552 if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC; 552 if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC;
553 if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME; 553 if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME;
554 if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM; 554 if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM;
555 if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM; 555 if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM;
556 if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD; 556 if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD;
557 if (Entry.MemoryType==0) { 557 if (Entry.MemoryType==0) {
558 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]); 558 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
559 exit (-1); 559 exit (-1);
560 } 560 }
561 561
562 GSM_Init(true); 562 GSM_Init(true);
563 563
564 while (!gshutdown) { 564 while (!gshutdown) {
565 error = Phone->GetNextMemory(&s, &Entry, start); 565 error = Phone->GetNextMemory(&s, &Entry, start);
566 if (error == ERR_EMPTY) break; 566 if (error == ERR_EMPTY) break;
567 Print_Error(error); 567 Print_Error(error);
568 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location); 568 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location);
569 PrintMemoryEntry(&Entry); 569 PrintMemoryEntry(&Entry);
570 start = false; 570 start = false;
571 } 571 }
572 572
573 GSM_Terminate(); 573 GSM_Terminate();
574} 574}
575 575
576static void GetMemory(int argc, char *argv[]) 576static void GetMemory(int argc, char *argv[])
577{ 577{
578 int j, start, stop, emptynum = 0, fillednum = 0; 578 int j, start, stop, emptynum = 0, fillednum = 0;
579 GSM_MemoryEntry entry; 579 GSM_MemoryEntry entry;
580 bool empty = true; 580 bool empty = true;
581 581
582 entry.MemoryType=0; 582 entry.MemoryType=0;
583 583
584 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC; 584 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC;
585 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON; 585 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON;
586 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC; 586 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC;
587 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC; 587 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC;
588 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME; 588 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME;
589 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM; 589 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM;
590 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM; 590 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM;
591 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD; 591 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD;
592 if (entry.MemoryType==0) { 592 if (entry.MemoryType==0) {
593 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]); 593 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
594 exit (-1); 594 exit (-1);
595 } 595 }
596 596
597 GetStartStop(&start, &stop, 3, argc, argv); 597 GetStartStop(&start, &stop, 3, argc, argv);
598 598
599 if (argc > 5 && strcmp(argv[5],"")) { 599 if (argc > 5 && strcmp(argv[5],"")) {
600 if (mystrncasecmp(argv[5],"-nonempty",0)) { 600 if (mystrncasecmp(argv[5],"-nonempty",0)) {
601 empty = false; 601 empty = false;
602 } else { 602 } else {
603 printmsg("ERROR: unknown parameter \"%s\"\n",argv[5]); 603 printmsg("ERROR: unknown parameter \"%s\"\n",argv[5]);
604 exit (-1); 604 exit (-1);
605 } 605 }
606 } 606 }
607 607
608 GSM_Init(true); 608 GSM_Init(true);
609 609
610 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) { 610 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) {
611 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"); 611 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");
612 } 612 }
613 613
614 for (j=start;j<=stop;j++) { 614 for (j=start;j<=stop;j++) {
615 if (empty) printmsg("Memory %s, Location %i\n",argv[2],j); 615 if (empty) printmsg("Memory %s, Location %i\n",argv[2],j);
616 616
617 entry.Location=j; 617 entry.Location=j;
618 618
619 error=Phone->GetMemory(&s, &entry); 619 error=Phone->GetMemory(&s, &entry);
620 if (error != ERR_EMPTY) Print_Error(error); 620 if (error != ERR_EMPTY) Print_Error(error);
621 621
622 if (error == ERR_EMPTY) { 622 if (error == ERR_EMPTY) {
623 emptynum++; 623 emptynum++;
624 if (empty) { 624 if (empty) {
625 printmsg("Entry is empty\n"); 625 printmsg("Entry is empty\n");
626 printf("\n"); 626 printf("\n");
627 } 627 }
628 } else { 628 } else {
629 fillednum++; 629 fillednum++;
630 if (!empty) printmsg("Memory %s, Location %i\n",argv[2],j); 630 if (!empty) printmsg("Memory %s, Location %i\n",argv[2],j);
631 PrintMemoryEntry(&entry); 631 PrintMemoryEntry(&entry);
632 } 632 }
633 } 633 }
634 634
635 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum); 635 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum);
636 636
637 GSM_Terminate(); 637 GSM_Terminate();
638} 638}
639 639
640#define MemoryLocationToString(x) ( \ 640#define MemoryLocationToString(x) ( \
641 x == MEM_ON ? "ON" : \ 641 x == MEM_ON ? "ON" : \
642 x == MEM_RC ? "RC" : \ 642 x == MEM_RC ? "RC" : \
643 x == MEM_MC ? "MC" : \ 643 x == MEM_MC ? "MC" : \
644 x == MEM_ME ? "ME" : \ 644 x == MEM_ME ? "ME" : \
645 x == MEM_SM ? "SM" : \ 645 x == MEM_SM ? "SM" : \
646 x == MEM_VM ? "VM" : \ 646 x == MEM_VM ? "VM" : \
647 x == MEM_FD ? "FD" : "XX") 647 x == MEM_FD ? "FD" : "XX")
648 648
649static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text) 649static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
650{ 650{
651 int i; 651 int i;
652 652
653 for (i=0;i<Entry->EntriesNum;i++) { 653 for (i=0;i<Entry->EntriesNum;i++) {
654 switch (Entry->Entries[i].EntryType) { 654 switch (Entry->Entries[i].EntryType) {
655 case PBK_Number_General : 655 case PBK_Number_General :
656 case PBK_Number_Mobile : 656 case PBK_Number_Mobile :
657 case PBK_Number_Work : 657 case PBK_Number_Work :
658 case PBK_Number_Fax : 658 case PBK_Number_Fax :
659 case PBK_Number_Home : 659 case PBK_Number_Home :
660 case PBK_Number_Pager : 660 case PBK_Number_Pager :
661 case PBK_Number_Other : 661 case PBK_Number_Other :
662 case PBK_Text_Note : 662 case PBK_Text_Note :
663 case PBK_Text_Postal : 663 case PBK_Text_Postal :
664 case PBK_Text_Email : 664 case PBK_Text_Email :
665 case PBK_Text_Email2 : 665 case PBK_Text_Email2 :
666 case PBK_Text_URL : 666 case PBK_Text_URL :
667 case PBK_Text_Name : 667 case PBK_Text_Name :
668 case PBK_Text_LastName : 668 case PBK_Text_LastName :
669 case PBK_Text_FirstName : 669 case PBK_Text_FirstName :
670 case PBK_Text_Company : 670 case PBK_Text_Company :
671 case PBK_Text_JobTitle : 671 case PBK_Text_JobTitle :
672 case PBK_Text_StreetAddress : 672 case PBK_Text_StreetAddress :
673 case PBK_Text_City : 673 case PBK_Text_City :
674 case PBK_Text_State : 674 case PBK_Text_State :
675 case PBK_Text_Zip : 675 case PBK_Text_Zip :
676 case PBK_Text_Country : 676 case PBK_Text_Country :
677 case PBK_Text_Custom1 : 677 case PBK_Text_Custom1 :
678 case PBK_Text_Custom2 : 678 case PBK_Text_Custom2 :
679 case PBK_Text_Custom3 : 679 case PBK_Text_Custom3 :
680 case PBK_Text_Custom4 : 680 case PBK_Text_Custom4 :
681 case PBK_Caller_Group : 681 case PBK_Caller_Group :
682 if (mywstrstr(Entry->Entries[i].Text, Text) != NULL) { 682 if (mywstrstr(Entry->Entries[i].Text, Text) != NULL) {
683 fprintf(stderr,"\n"); 683 fprintf(stderr,"\n");
684 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location); 684 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location);
685 PrintMemoryEntry(Entry); 685 PrintMemoryEntry(Entry);
686 return; 686 return;
687 } 687 }
688 break; 688 break;
689 default: 689 default:
690 break; 690 break;
691 } 691 }
692 } 692 }
693 } 693 }
694 694
695static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text) 695static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text)
696{ 696{
697 GSM_MemoryEntry Entry; 697 GSM_MemoryEntry Entry;
698 GSM_MemoryStatusStatus; 698 GSM_MemoryStatusStatus;
699 int i = 0, l = 1; 699 int i = 0, l = 1;
700 bool start = true; 700 bool start = true;
701 701
702 Status.MemoryType = MemoryType; 702 Status.MemoryType = MemoryType;
703 Entry.MemoryType = MemoryType; 703 Entry.MemoryType = MemoryType;
704 704
705 if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) { 705 if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) {
706 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1)); 706 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
707 if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) { 707 if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) {
708 while (i < Status.MemoryUsed) { 708 while (i < Status.MemoryUsed) {
709 if (gshutdown) return; 709 if (gshutdown) return;
710 i++; 710 i++;
711 fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1)); 711 fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1));
712 error = Phone->GetNextMemory(&s, &Entry, start); 712 error = Phone->GetNextMemory(&s, &Entry, start);
713 if (error == ERR_EMPTY) break; 713 if (error == ERR_EMPTY) break;
714 Print_Error(error); 714 Print_Error(error);
715 SearchOneEntry(&Entry, Text); 715 SearchOneEntry(&Entry, Text);
716 start = false; 716 start = false;
717 } 717 }
718 } else { 718 } else {
719 while (i < Status.MemoryUsed) { 719 while (i < Status.MemoryUsed) {
720 Entry.Location = l; 720 Entry.Location = l;
721 error = Phone->GetMemory(&s, &Entry); 721 error = Phone->GetMemory(&s, &Entry);
722 if (error != ERR_EMPTY) { 722 if (error != ERR_EMPTY) {
723 Print_Error(error); 723 Print_Error(error);
724 i++; 724 i++;
725 SearchOneEntry(&Entry, Text); 725 SearchOneEntry(&Entry, Text);
726 } 726 }
727 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1)); 727 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
728 l++; 728 l++;
729 } 729 }
730 } 730 }
731 fprintf(stderr,"\n"); 731 fprintf(stderr,"\n");
732 } 732 }
733} 733}
734 734
735static void SearchMemory(int argc, char *argv[]) 735static void SearchMemory(int argc, char *argv[])
736{ 736{
737 unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2]; 737 unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2];
738 int Length; 738 int Length;
739 739
740 signal(SIGINT, interrupt); 740 signal(SIGINT, interrupt);
741 printmsgerr("Press Ctrl+C to break...\n"); 741 printmsgerr("Press Ctrl+C to break...\n");
742 742
743 Length = strlen(argv[2]); 743 Length = strlen(argv[2]);
744 if (Length > GSM_PHONEBOOK_TEXT_LENGTH) { 744 if (Length > GSM_PHONEBOOK_TEXT_LENGTH) {
745 printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH); 745 printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH);
746 Length = GSM_PHONEBOOK_TEXT_LENGTH; 746 Length = GSM_PHONEBOOK_TEXT_LENGTH;
747 } 747 }
748 EncodeUnicode(Text, argv[2], Length); 748 EncodeUnicode(Text, argv[2], Length);
749 749
750 GSM_Init(true); 750 GSM_Init(true);
751 751
752 if (!gshutdown) SearchOneMemory(MEM_ME, "Phone phonebook", Text); 752 if (!gshutdown) SearchOneMemory(MEM_ME, "Phone phonebook", Text);
753 if (!gshutdown) SearchOneMemory(MEM_SM, "SIM phonebook", Text); 753 if (!gshutdown) SearchOneMemory(MEM_SM, "SIM phonebook", Text);
754 if (!gshutdown) SearchOneMemory(MEM_ON, "Own numbers", Text); 754 if (!gshutdown) SearchOneMemory(MEM_ON, "Own numbers", Text);
755 if (!gshutdown) SearchOneMemory(MEM_DC, "Dialled numbers", Text); 755 if (!gshutdown) SearchOneMemory(MEM_DC, "Dialled numbers", Text);
756 if (!gshutdown) SearchOneMemory(MEM_RC, "Received numbers", Text); 756 if (!gshutdown) SearchOneMemory(MEM_RC, "Received numbers", Text);
757 if (!gshutdown) SearchOneMemory(MEM_MC, "Missed numbers", Text); 757 if (!gshutdown) SearchOneMemory(MEM_MC, "Missed numbers", Text);
758 if (!gshutdown) SearchOneMemory(MEM_FD, "Fix dialling", Text); 758 if (!gshutdown) SearchOneMemory(MEM_FD, "Fix dialling", Text);
759 if (!gshutdown) SearchOneMemory(MEM_VM, "Voice mailbox", Text); 759 if (!gshutdown) SearchOneMemory(MEM_VM, "Voice mailbox", Text);
760 760
761 GSM_Terminate(); 761 GSM_Terminate();
762} 762}
763 763
764static void ListMemoryCategoryEntries(int Category) 764static void ListMemoryCategoryEntries(int Category)
765{ 765{
766 GSM_MemoryEntry Entry; 766 GSM_MemoryEntry Entry;
767 bool start = true; 767 bool start = true;
768 int j; 768 int j;
769 769
770 /* Category can be only for ME stored entries */ 770 /* Category can be only for ME stored entries */
771 Entry.MemoryType = MEM_ME; 771 Entry.MemoryType = MEM_ME;
772 772
773 while (!gshutdown) { 773 while (!gshutdown) {
774 error = Phone->GetNextMemory(&s, &Entry, start); 774 error = Phone->GetNextMemory(&s, &Entry, start);
775 if (error == ERR_EMPTY) break; 775 if (error == ERR_EMPTY) break;
776 Print_Error(error); 776 Print_Error(error);
777 for (j=0;j<Entry.EntriesNum;j++) { 777 for (j=0;j<Entry.EntriesNum;j++) {
778 if (Entry.Entries[j].EntryType == PBK_Category && Entry.Entries[j].Number == Category) { 778 if (Entry.Entries[j].EntryType == PBK_Category && Entry.Entries[j].Number == Category) {
779 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry.MemoryType),Entry.Location); 779 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry.MemoryType),Entry.Location);
780 PrintMemoryEntry(&Entry); 780 PrintMemoryEntry(&Entry);
781 } 781 }
782 } 782 }
783 start = false; 783 start = false;
784 } 784 }
785} 785}
786 786
787static void ListMemoryCategory(int argc, char *argv[]) 787static void ListMemoryCategory(int argc, char *argv[])
788{ 788{
789 GSM_Category Category; 789 GSM_Category Category;
790 GSM_CategoryStatusStatus; 790 GSM_CategoryStatusStatus;
791 int j, count; 791 int j, count;
792 792
793 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; 793 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
794 int Length; 794 int Length;
795 bool Number = true;; 795 bool Number = true;;
796 796
797 GSM_Init(true); 797 GSM_Init(true);
798 798
799 signal(SIGINT, interrupt); 799 signal(SIGINT, interrupt);
800 printmsgerr("Press Ctrl+C to break...\n"); 800 printmsgerr("Press Ctrl+C to break...\n");
801 801
802 Length = strlen(argv[2]); 802 Length = strlen(argv[2]);
803 for (j = 0; j < Length; j++) { 803 for (j = 0; j < Length; j++) {
804 if (!isdigit(argv[2][j])) { 804 if (!isdigit(argv[2][j])) {
805 Number = false; 805 Number = false;
806 break; 806 break;
807 } 807 }
808 } 808 }
809 809
810 if (Number) { 810 if (Number) {
811 j = atoi(argv[2]); 811 j = atoi(argv[2]);
812 if (j > 0) { 812 if (j > 0) {
813 ListMemoryCategoryEntries(j); 813 ListMemoryCategoryEntries(j);
814 } 814 }
815 } else { 815 } else {
816 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { 816 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
817 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); 817 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
818 Length = GSM_MAX_CATEGORY_NAME_LENGTH; 818 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
819 } 819 }
820 EncodeUnicode(Text, argv[2], Length); 820 EncodeUnicode(Text, argv[2], Length);
821 821
822 Category.Type = Category_Phonebook; 822 Category.Type = Category_Phonebook;
823 Status.Type = Category_Phonebook; 823 Status.Type = Category_Phonebook;
824 824
825 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 825 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
826 for (count=0,j=1;count<Status.Used;j++) { 826 for (count=0,j=1;count<Status.Used;j++) {
827 Category.Location=j; 827 Category.Location=j;
828 error=Phone->GetCategory(&s, &Category); 828 error=Phone->GetCategory(&s, &Category);
829 829
830 if (error != ERR_EMPTY) { 830 if (error != ERR_EMPTY) {
831 count++; 831 count++;
832 if (mywstrstr(Category.Name, Text) != NULL) { 832 if (mywstrstr(Category.Name, Text) != NULL) {
833 ListMemoryCategoryEntries(j); 833 ListMemoryCategoryEntries(j);
834 } 834 }
835 } 835 }
836 } 836 }
837 } 837 }
838 } 838 }
839 GSM_Terminate(); 839 GSM_Terminate();
840} 840}
841 841
842static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh) 842static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh)
843{ 843{
844 switch (sms.PDU) { 844 switch (sms.PDU) {
845 case SMS_Status_Report: 845 case SMS_Status_Report:
846 printmsg("SMS status report\n"); 846 printmsg("SMS status report\n");
847 printmsg("Status : "); 847 printmsg("Status : ");
848 switch (sms.State) { 848 switch (sms.State) {
849 case SMS_Sent : printmsg("Sent");break; 849 case SMS_Sent : printmsg("Sent");break;
850 case SMS_Read : printmsg("Read");break; 850 case SMS_Read : printmsg("Read");break;
851 case SMS_UnRead : printmsg("UnRead");break; 851 case SMS_UnRead : printmsg("UnRead");break;
852 case SMS_UnSent : printmsg("UnSent");break; 852 case SMS_UnSent : printmsg("UnSent");break;
853 } 853 }
854 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number)); 854 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
855 printmsg("Reference number: %d\n",sms.MessageReference); 855 printmsg("Reference number: %d\n",sms.MessageReference);
856 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true)); 856 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true));
857 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number)); 857 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number));
858 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true)); 858 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true));
859 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text)); 859 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text));
860 printmsg("Details : "); 860 printmsg("Details : ");
861 if (sms.DeliveryStatus & 0x40) { 861 if (sms.DeliveryStatus & 0x40) {
862 if (sms.DeliveryStatus & 0x20) { 862 if (sms.DeliveryStatus & 0x20) {
863 printmsg("Temporary error, "); 863 printmsg("Temporary error, ");
864 } else { 864 } else {
865 printmsg("Permanent error, "); 865 printmsg("Permanent error, ");
866 } 866 }
867 } else if (sms.DeliveryStatus & 0x20) { 867 } else if (sms.DeliveryStatus & 0x20) {
868 printmsg("Temporary error, "); 868 printmsg("Temporary error, ");
869 } 869 }
870 switch (sms.DeliveryStatus) { 870 switch (sms.DeliveryStatus) {
871 case 0x00: printmsg("SM received by the SME"); break; 871 case 0x00: printmsg("SM received by the SME"); break;
872 case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break; 872 case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break;
873 case 0x02: printmsg("SM replaced by the SC"); break; 873 case 0x02: printmsg("SM replaced by the SC"); break;
874 case 0x20: printmsg("Congestion"); break; 874 case 0x20: printmsg("Congestion"); break;
875 case 0x21: printmsg("SME busy"); break; 875 case 0x21: printmsg("SME busy"); break;
876 case 0x22: printmsg("No response from SME"); break; 876 case 0x22: printmsg("No response from SME"); break;
877 case 0x23: printmsg("Service rejected"); break; 877 case 0x23: printmsg("Service rejected"); break;
878 case 0x24: printmsg("Quality of service not aviable"); break; 878 case 0x24: printmsg("Quality of service not aviable"); break;
879 case 0x25: printmsg("Error in SME"); break; 879 case 0x25: printmsg("Error in SME"); break;
880 case 0x40: printmsg("Remote procedure error"); break; 880 case 0x40: printmsg("Remote procedure error"); break;
881 case 0x41: printmsg("Incompatibile destination"); break; 881 case 0x41: printmsg("Incompatibile destination"); break;
882 case 0x42: printmsg("Connection rejected by SME"); break; 882 case 0x42: printmsg("Connection rejected by SME"); break;
883 case 0x43: printmsg("Not obtainable"); break; 883 case 0x43: printmsg("Not obtainable"); break;
884 case 0x44: printmsg("Quality of service not available"); break; 884 case 0x44: printmsg("Quality of service not available"); break;
885 case 0x45: printmsg("No internetworking available"); break; 885 case 0x45: printmsg("No internetworking available"); break;
886 case 0x46: printmsg("SM Validity Period Expired"); break; 886 case 0x46: printmsg("SM Validity Period Expired"); break;
887 case 0x47: printmsg("SM deleted by originating SME"); break; 887 case 0x47: printmsg("SM deleted by originating SME"); break;
888 case 0x48: printmsg("SM Deleted by SC Administration"); break; 888 case 0x48: printmsg("SM Deleted by SC Administration"); break;
889 case 0x49: printmsg("SM does not exist"); break; 889 case 0x49: printmsg("SM does not exist"); break;
890 case 0x60: printmsg("Congestion"); break; 890 case 0x60: printmsg("Congestion"); break;
891 case 0x61: printmsg("SME busy"); break; 891 case 0x61: printmsg("SME busy"); break;
892 case 0x62: printmsg("No response from SME"); break; 892 case 0x62: printmsg("No response from SME"); break;
893 case 0x63: printmsg("Service rejected"); break; 893 case 0x63: printmsg("Service rejected"); break;
894 case 0x64: printmsg("Quality of service not available"); break; 894 case 0x64: printmsg("Quality of service not available"); break;
895 case 0x65: printmsg("Error in SME"); break; 895 case 0x65: printmsg("Error in SME"); break;
896 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break; 896 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break;
897 } 897 }
898 printf("\n"); 898 printf("\n");
899 break; 899 break;
900 case SMS_Deliver: 900 case SMS_Deliver:
901 printmsg("SMS message\n"); 901 printmsg("SMS message\n");
902 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) { 902 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
903 printmsg("Saved : %s\n",OSDateTime(sms.DateTime,true)); 903 printmsg("Saved : %s\n",OSDateTime(sms.DateTime,true));
904 } else { 904 } else {
905 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number)); 905 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number));
906 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)"); 906 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)");
907 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true)); 907 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true));
908 } 908 }
909 /* No break. The only difference for SMS_Deliver and SMS_Submit is, 909 /* No break. The only difference for SMS_Deliver and SMS_Submit is,
910 * that SMS_Deliver contains additional data. We wrote them and then go 910 * that SMS_Deliver contains additional data. We wrote them and then go
911 * for data shared with SMS_Submit 911 * for data shared with SMS_Submit
912 */ 912 */
913 case SMS_Submit: 913 case SMS_Submit:
914 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage); 914 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage);
915 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */ 915 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */
916 if (sms.PDU==SMS_Submit) { 916 if (sms.PDU==SMS_Submit) {
917 printmsg("SMS message\n"); 917 printmsg("SMS message\n");
918 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) { 918 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
919 } else { 919 } else {
920 printmsg("Reference number : %d\n",sms.MessageReference); 920 printmsg("Reference number : %d\n",sms.MessageReference);
921 } 921 }
922 } 922 }
923 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) { 923 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) {
924 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name)); 924 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name));
925 } 925 }
926 if (sms.Class != -1) { 926 if (sms.Class != -1) {
927 printmsg("Class : %i\n",sms.Class); 927 printmsg("Class : %i\n",sms.Class);
928 } 928 }
929 printmsg("Coding : "); 929 printmsg("Coding : ");
930 switch (sms.Coding) { 930 switch (sms.Coding) {
931 case SMS_Coding_Unicode : printmsg("Unicode\n"); break; 931 case SMS_Coding_Unicode : printmsg("Unicode\n"); break;
932 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break; 932 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break;
933 case SMS_Coding_8bit : printmsg("8 bit\n"); break; 933 case SMS_Coding_8bit : printmsg("8 bit\n"); break;
934 } 934 }
935 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) { 935 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
936 } else { 936 } else {
937 printmsg("Remote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number)); 937 printmsg("Remote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
938 } 938 }
939 printmsg("Status : "); 939 printmsg("Status : ");
940 switch (sms.State) { 940 switch (sms.State) {
941 case SMS_Sent : printmsg("Sent\n");break; 941 case SMS_Sent : printmsg("Sent\n");break;
942 case SMS_Read : printmsg("Read\n");break; 942 case SMS_Read : printmsg("Read\n");break;
943 case SMS_UnRead : printmsg("UnRead\n");break; 943 case SMS_UnRead : printmsg("UnRead\n");break;
944 case SMS_UnSent : printmsg("UnSent\n");break; 944 case SMS_UnSent : printmsg("UnSent\n");break;
945 } 945 }
946 if (sms.UDH.Type != UDH_NoUDH) { 946 if (sms.UDH.Type != UDH_NoUDH) {
947 printmsg("User Data Header : "); 947 printmsg("User Data Header : ");
948 switch (sms.UDH.Type) { 948 switch (sms.UDH.Type) {
949 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break; 949 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break;
950 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break; 950 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break;
951 case UDH_DisableVoice : printmsg("Disables voice indicator"); break; 951 case UDH_DisableVoice : printmsg("Disables voice indicator"); break;
952 case UDH_EnableVoice : printmsg("Enables voice indicator"); break; 952 case UDH_EnableVoice : printmsg("Enables voice indicator"); break;
953 case UDH_DisableFax : printmsg("Disables fax indicator"); break; 953 case UDH_DisableFax : printmsg("Disables fax indicator"); break;
954 case UDH_EnableFax : printmsg("Enables fax indicator"); break; 954 case UDH_EnableFax : printmsg("Enables fax indicator"); break;
955 case UDH_DisableEmail : printmsg("Disables email indicator"); break; 955 case UDH_DisableEmail : printmsg("Disables email indicator"); break;
956 case UDH_EnableEmail : printmsg("Enables email indicator"); break; 956 case UDH_EnableEmail : printmsg("Enables email indicator"); break;
957 case UDH_VoidSMS : printmsg("Void SMS"); break; 957 case UDH_VoidSMS : printmsg("Void SMS"); break;
958 case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break; 958 case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break;
959 case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break; 959 case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break;
960 case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break; 960 case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break;
961 case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break; 961 case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break;
962 case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break; 962 case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break;
963 case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break; 963 case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break;
964 case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break; 964 case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break;
965 case UDH_NokiaProfileLong : printmsg("Nokia profile"); break; 965 case UDH_NokiaProfileLong : printmsg("Nokia profile"); break;
966 case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break; 966 case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break;
967 case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break; 967 case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break;
968 case UDH_UserUDH : printmsg("User UDH"); break; 968 case UDH_UserUDH : printmsg("User UDH"); break;
969 case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break; 969 case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break;
970 case UDH_NoUDH: break; 970 case UDH_NoUDH: break;
971 } 971 }
972 if (sms.UDH.Type != UDH_NoUDH) { 972 if (sms.UDH.Type != UDH_NoUDH) {
973 if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit); 973 if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit);
974 if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit); 974 if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit);
975 if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) { 975 if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) {
976 if (displayudh) { 976 if (displayudh) {
977 printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts); 977 printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts);
978 } else { 978 } else {
979 printmsg(", %i parts",sms.UDH.AllParts); 979 printmsg(", %i parts",sms.UDH.AllParts);
980 } 980 }
981 } 981 }
982 } 982 }
983 printf("\n"); 983 printf("\n");
984 } 984 }
985 if (displaytext) { 985 if (displaytext) {
986 printf("\n"); 986 printf("\n");
987 if (sms.Coding!=SMS_Coding_8bit) { 987 if (sms.Coding!=SMS_Coding_8bit) {
988 printmsg("%s\n",DecodeUnicodeConsole(sms.Text)); 988 printmsg("%s\n",DecodeUnicodeConsole(sms.Text));
989 } else { 989 } else {
990 printmsg("8 bit SMS, cannot be displayed here\n"); 990 printmsg("8 bit SMS, cannot be displayed here\n");
991 } 991 }
992 } 992 }
993 break; 993 break;
994 } 994 }
995} 995}
996 996
997static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems) 997static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems)
998{ 998{
999 GSM_MultiPartSMSInfoSMSInfo; 999 GSM_MultiPartSMSInfoSMSInfo;
1000 bool RetVal,udhinfo=true; 1000 bool RetVal,udhinfo=true;
1001 int j; 1001 int j;
1002 1002
1003 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */ 1003 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */
1004 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems); 1004 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems);
1005 1005
1006 if (eachsms) { 1006 if (eachsms) {
1007 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false; 1007 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false;
1008 if (RetVal && !udhinfo) { 1008 if (RetVal && !udhinfo) {
1009 displaysinglesmsinfo(sms.SMS[0],false,false); 1009 displaysinglesmsinfo(sms.SMS[0],false,false);
1010 printf("\n"); 1010 printf("\n");
1011 } else { 1011 } else {
1012 for (j=0;j<sms.Number;j++) { 1012 for (j=0;j<sms.Number;j++) {
1013 displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo); 1013 displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo);
1014 printf("\n"); 1014 printf("\n");
1015 } 1015 }
1016 } 1016 }
1017 } else { 1017 } else {
1018 for (j=0;j<sms.Number;j++) { 1018 for (j=0;j<sms.Number;j++) {
1019 displaysinglesmsinfo(sms.SMS[j],!RetVal,true); 1019 displaysinglesmsinfo(sms.SMS[j],!RetVal,true);
1020 printf("\n"); 1020 printf("\n");
1021 } 1021 }
1022 } 1022 }
1023 if (!RetVal) { 1023 if (!RetVal) {
1024 GSM_FreeMultiPartSMSInfo(&SMSInfo); 1024 GSM_FreeMultiPartSMSInfo(&SMSInfo);
1025 return; 1025 return;
1026 } 1026 }
1027 1027
1028 if (SMSInfo.Unknown) printmsg("Some details were ignored (unknown or not implemented in decoding functions)\n\n"); 1028 if (SMSInfo.Unknown) printmsg("Some details were ignored (unknown or not implemented in decoding functions)\n\n");
1029 1029
1030 for (i=0;i<SMSInfo.EntriesNum;i++) { 1030 for (i=0;i<SMSInfo.EntriesNum;i++) {
1031 switch (SMSInfo.Entries[i].ID) { 1031 switch (SMSInfo.Entries[i].ID) {
1032 case SMS_NokiaRingtone: 1032 case SMS_NokiaRingtone:
1033 printmsg("Ringtone \"%s\"\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Ringtone->Name)); 1033 printmsg("Ringtone \"%s\"\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Ringtone->Name));
1034 saverttl(stdout,SMSInfo.Entries[i].Ringtone); 1034 saverttl(stdout,SMSInfo.Entries[i].Ringtone);
1035 printf("\n"); 1035 printf("\n");
1036 if (s.Phone.Functions->PlayTone!=NOTSUPPORTED && 1036 if (s.Phone.Functions->PlayTone!=NOTSUPPORTED &&
1037 s.Phone.Functions->PlayTone!=NOTIMPLEMENTED) { 1037 s.Phone.Functions->PlayTone!=NOTIMPLEMENTED) {
1038 if (answer_yes("Do you want to play it")) GSM_PlayRingtone(*SMSInfo.Entries[i].Ringtone); 1038 if (answer_yes("Do you want to play it")) GSM_PlayRingtone(*SMSInfo.Entries[i].Ringtone);
1039 } 1039 }
1040 break; 1040 break;
1041 case SMS_NokiaCallerLogo: 1041 case SMS_NokiaCallerLogo:
1042 printmsg("Caller logo\n\n"); 1042 printmsg("Caller logo\n\n");
1043 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1043 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1044 break; 1044 break;
1045 case SMS_NokiaOperatorLogo: 1045 case SMS_NokiaOperatorLogo:
1046 printmsg("Operator logo for %s network (%s, %s)\n\n", 1046 printmsg("Operator logo for %s network (%s, %s)\n\n",
1047 SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode, 1047 SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode,
1048 DecodeUnicodeConsole(GSM_GetNetworkName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)), 1048 DecodeUnicodeConsole(GSM_GetNetworkName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)),
1049 DecodeUnicodeConsole(GSM_GetCountryName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode))); 1049 DecodeUnicodeConsole(GSM_GetCountryName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)));
1050 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1050 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1051 break; 1051 break;
1052 case SMS_NokiaScreenSaverLong: 1052 case SMS_NokiaScreenSaverLong:
1053 printmsg("Screen saver\n"); 1053 printmsg("Screen saver\n");
1054 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1054 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1055 break; 1055 break;
1056 case SMS_NokiaPictureImageLong: 1056 case SMS_NokiaPictureImageLong:
1057 printmsg("Picture Image\n"); 1057 printmsg("Picture Image\n");
1058 if (UnicodeLength(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text)!=0) printmsg("Text: \"%s\"\n\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text)); 1058 if (UnicodeLength(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text)!=0) printmsg("Text: \"%s\"\n\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text));
1059 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1059 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1060 break; 1060 break;
1061 case SMS_NokiaProfileLong: 1061 case SMS_NokiaProfileLong:
1062 printmsg("Profile\n"); 1062 printmsg("Profile\n");
1063 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1063 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1064 break; 1064 break;
1065 case SMS_ConcatenatedTextLong: 1065 case SMS_ConcatenatedTextLong:
1066 case SMS_ConcatenatedAutoTextLong: 1066 case SMS_ConcatenatedAutoTextLong:
1067 case SMS_ConcatenatedTextLong16bit: 1067 case SMS_ConcatenatedTextLong16bit:
1068 case SMS_ConcatenatedAutoTextLong16bit: 1068 case SMS_ConcatenatedAutoTextLong16bit:
1069 printmsg("%s\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Buffer)); 1069 printmsg("%s\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Buffer));
1070 break; 1070 break;
1071 case SMS_EMSFixedBitmap: 1071 case SMS_EMSFixedBitmap:
1072 case SMS_EMSVariableBitmap: 1072 case SMS_EMSVariableBitmap:
1073 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1073 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1074 break; 1074 break;
1075 case SMS_EMSAnimation: 1075 case SMS_EMSAnimation:
1076 /* Can't show animation, we show first frame */ 1076 /* Can't show animation, we show first frame */
1077 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1077 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1078 break; 1078 break;
1079 case SMS_EMSPredefinedSound: 1079 case SMS_EMSPredefinedSound:
1080 printmsg("\nEMS sound ID: %i\n",SMSInfo.Entries[i].Number); 1080 printmsg("\nEMS sound ID: %i\n",SMSInfo.Entries[i].Number);
1081 break; 1081 break;
1082 case SMS_EMSPredefinedAnimation: 1082 case SMS_EMSPredefinedAnimation:
1083 printmsg("\nEMS animation ID: %i\n",SMSInfo.Entries[i].Number); 1083 printmsg("\nEMS animation ID: %i\n",SMSInfo.Entries[i].Number);
1084 break; 1084 break;
1085 default: 1085 default:
1086 printf("Error\n"); 1086 printf("Error\n");
1087 break; 1087 break;
1088 } 1088 }
1089 } 1089 }
1090 printf("\n"); 1090 printf("\n");
1091 GSM_FreeMultiPartSMSInfo(&SMSInfo); 1091 GSM_FreeMultiPartSMSInfo(&SMSInfo);
1092} 1092}
1093 1093
1094static void NetworkInfo(int argc, char *argv[]) 1094static void NetworkInfo(int argc, char *argv[])
1095{ 1095{
1096 GSM_NetworkInfo NetInfo; 1096 GSM_NetworkInfo NetInfo;
1097 1097
1098 GSM_Init(true); 1098 GSM_Init(true);
1099 1099
1100 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) { 1100 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
1101 printmsg("Network state : "); 1101 printmsg("Network state : ");
1102 switch (NetInfo.State) { 1102 switch (NetInfo.State) {
1103 case GSM_HomeNetwork : printmsg("home network\n"); break; 1103 case GSM_HomeNetwork : printmsg("home network\n"); break;
1104 case GSM_RoamingNetwork : printmsg("roaming network\n"); break; 1104 case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
1105 case GSM_RequestingNetwork : printmsg("requesting network\n"); break; 1105 case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
1106 case GSM_NoNetwork : printmsg("not logged into network\n");break; 1106 case GSM_NoNetwork : printmsg("not logged into network\n");break;
1107 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break; 1107 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break;
1108 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break; 1108 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
1109 default : printmsg("unknown\n"); 1109 default : printmsg("unknown\n");
1110 } 1110 }
1111 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) { 1111 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
1112 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode))); 1112 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
1113 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode))); 1113 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
1114 printmsg(", LAC %s, CellID %s\n", NetInfo.LAC,NetInfo.CID); 1114 printmsg(", LAC %s, CellID %s\n", NetInfo.LAC,NetInfo.CID);
1115 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) { 1115 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
1116 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName)); 1116 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
1117 } 1117 }
1118 } 1118 }
1119 } 1119 }
1120 GSM_Terminate(); 1120 GSM_Terminate();
1121} 1121}
1122 1122
1123static void IncomingSMS(char *Device, GSM_SMSMessage sms) 1123static void IncomingSMS(char *Device, GSM_SMSMessage sms)
1124{ 1124{
1125 GSM_MultiSMSMessage SMS; 1125 GSM_MultiSMSMessage SMS;
1126 1126
1127 printmsg("SMS message received\n"); 1127 printmsg("SMS message received\n");
1128 SMS.Number = 1; 1128 SMS.Number = 1;
1129 memcpy(&SMS.SMS[0],&sms,sizeof(GSM_SMSMessage)); 1129 memcpy(&SMS.SMS[0],&sms,sizeof(GSM_SMSMessage));
1130 displaymultismsinfo(SMS,false,false); 1130 displaymultismsinfo(SMS,false,false);
1131} 1131}
1132 1132
1133static void IncomingCB(char *Device, GSM_CBMessage CB) 1133static void IncomingCB(char *Device, GSM_CBMessage CB)
1134{ 1134{
1135 printmsg("CB message received\n"); 1135 printmsg("CB message received\n");
1136 printmsg("Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeConsole(CB.Text)); 1136 printmsg("Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeConsole(CB.Text));
1137} 1137}
1138 1138
1139static void IncomingCall(char *Device, GSM_Call call) 1139static void IncomingCall(char *Device, GSM_Call call)
1140{ 1140{
1141 printmsg("Call info : "); 1141 printmsg("Call info : ");
1142 if (call.CallIDAvailable) printmsg("ID %i, ",call.CallID); 1142 if (call.CallIDAvailable) printmsg("ID %i, ",call.CallID);
1143 switch(call.Status) { 1143 switch(call.Status) {
1144 case GSM_CALL_IncomingCall : printmsg("incoming call from \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break; 1144 case GSM_CALL_IncomingCall : printmsg("incoming call from \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break;
1145 case GSM_CALL_OutgoingCall : printmsg("outgoing call to \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break; 1145 case GSM_CALL_OutgoingCall : printmsg("outgoing call to \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break;
1146 case GSM_CALL_CallStart : printmsg("call started\n"); break; 1146 case GSM_CALL_CallStart : printmsg("call started\n"); break;
1147 case GSM_CALL_CallEnd : printmsg("end of call (unknown side)\n"); break; 1147 case GSM_CALL_CallEnd : printmsg("end of call (unknown side)\n"); break;
1148 case GSM_CALL_CallLocalEnd : printmsg("call end from our side\n"); break; 1148 case GSM_CALL_CallLocalEnd : printmsg("call end from our side\n"); break;
1149 case GSM_CALL_CallRemoteEnd : printmsg("call end from remote side (code %i)\n",call.StatusCode); break; 1149 case GSM_CALL_CallRemoteEnd : printmsg("call end from remote side (code %i)\n",call.StatusCode); break;
1150 case GSM_CALL_CallEstablished : printmsg("call established. Waiting for answer\n"); break; 1150 case GSM_CALL_CallEstablished : printmsg("call established. Waiting for answer\n"); break;
1151 case GSM_CALL_CallHeld : printmsg("call held\n"); break; 1151 case GSM_CALL_CallHeld : printmsg("call held\n"); break;
1152 case GSM_CALL_CallResumed : printmsg("call resumed\n"); break; 1152 case GSM_CALL_CallResumed : printmsg("call resumed\n"); break;
1153 case GSM_CALL_CallSwitched : printmsg("call switched\n"); break; 1153 case GSM_CALL_CallSwitched : printmsg("call switched\n"); break;
1154 } 1154 }
1155} 1155}
1156 1156
1157static void IncomingUSSD(char *Device, char *Buffer) 1157static void IncomingUSSD(char *Device, char *Buffer)
1158{ 1158{
1159 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer)); 1159 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
1160} 1160}
1161 1161
1162 #define CHECKMEMORYSTATUS(x, m, a1, b1) { \ 1162 #define CHECKMEMORYSTATUS(x, m, a1, b1) { \
1163 x.MemoryType=m; \ 1163 x.MemoryType=m; \
1164 if (Phone->GetMemoryStatus(&s, &x) == ERR_NONE) \ 1164 if (Phone->GetMemoryStatus(&s, &x) == ERR_NONE) \
1165 printmsg("%s %03d, %s %03d\n", a1, x.MemoryUsed, b1, x.MemoryFree);\ 1165 printmsg("%s %03d, %s %03d\n", a1, x.MemoryUsed, b1, x.MemoryFree);\
1166} 1166}
1167 1167
1168static void Monitor(int argc, char *argv[]) 1168static void Monitor(int argc, char *argv[])
1169{ 1169{
1170 GSM_MemoryStatusMemStatus; 1170 GSM_MemoryStatusMemStatus;
1171 GSM_SMSMemoryStatusSMSStatus; 1171 GSM_SMSMemoryStatusSMSStatus;
1172 GSM_ToDoStatus ToDoStatus; 1172 GSM_ToDoStatus ToDoStatus;
1173 GSM_CalendarStatusCalendarStatus; 1173 GSM_CalendarStatusCalendarStatus;
1174 GSM_NetworkInfo NetInfo; 1174 GSM_NetworkInfo NetInfo;
1175 GSM_BatteryCharge BatteryCharge; 1175 GSM_BatteryCharge BatteryCharge;
1176 GSM_SignalQuality SignalQuality; 1176 GSM_SignalQuality SignalQuality;
1177 int count = -1; 1177 int count = -1;
1178 1178
1179 if (argc >= 3) { 1179 if (argc >= 3) {
1180 count = atoi(argv[2]); 1180 count = atoi(argv[2]);
1181 if (count <= 0) count = -1; 1181 if (count <= 0) count = -1;
1182 } 1182 }
1183 1183
1184 signal(SIGINT, interrupt); 1184 signal(SIGINT, interrupt);
1185 printmsgerr("Press Ctrl+C to break...\n"); 1185 printmsgerr("Press Ctrl+C to break...\n");
1186 printmsg("Entering monitor mode...\n\n"); 1186 printmsg("Entering monitor mode...\n\n");
1187 1187
1188 GSM_Init(true); 1188 GSM_Init(true);
1189 1189
1190 s.User.IncomingSMS = IncomingSMS; 1190 s.User.IncomingSMS = IncomingSMS;
1191 s.User.IncomingCB = IncomingCB; 1191 s.User.IncomingCB = IncomingCB;
1192 s.User.IncomingCall = IncomingCall; 1192 s.User.IncomingCall = IncomingCall;
1193 s.User.IncomingUSSD = IncomingUSSD; 1193 s.User.IncomingUSSD = IncomingUSSD;
1194 1194
1195 error=Phone->SetIncomingSMS (&s,true); 1195 error=Phone->SetIncomingSMS (&s,true);
1196 printmsg("Enabling info about incoming SMS : %s\n",print_error(error,NULL,s.msg)); 1196 printmsg("Enabling info about incoming SMS : %s\n",print_error(error,NULL,s.msg));
1197 error=Phone->SetIncomingCB (&s,true); 1197 error=Phone->SetIncomingCB (&s,true);
1198 printmsg("Enabling info about incoming CB : %s\n",print_error(error,NULL,s.msg)); 1198 printmsg("Enabling info about incoming CB : %s\n",print_error(error,NULL,s.msg));
1199 error=Phone->SetIncomingCall (&s,true); 1199 error=Phone->SetIncomingCall (&s,true);
1200 printmsg("Enabling info about calls : %s\n",print_error(error,NULL,s.msg)); 1200 printmsg("Enabling info about calls : %s\n",print_error(error,NULL,s.msg));
1201 error=Phone->SetIncomingUSSD (&s,true); 1201 error=Phone->SetIncomingUSSD (&s,true);
1202 printmsg("Enabling info about USSD : %s\n\n",print_error(error,NULL,s.msg)); 1202 printmsg("Enabling info about USSD : %s\n\n",print_error(error,NULL,s.msg));
1203 1203
1204 while (!gshutdown && count != 0) { 1204 while (!gshutdown && count != 0) {
1205 if (count > 0) count--; 1205 if (count > 0) count--;
1206 CHECKMEMORYSTATUS(MemStatus,MEM_SM,"SIM phonebook : Used","Free"); 1206 CHECKMEMORYSTATUS(MemStatus,MEM_SM,"SIM phonebook : Used","Free");
1207 if (gshutdown) break; 1207 if (gshutdown) break;
1208 CHECKMEMORYSTATUS(MemStatus,MEM_DC,"Dialled numbers : Used","Free"); 1208 CHECKMEMORYSTATUS(MemStatus,MEM_DC,"Dialled numbers : Used","Free");
1209 if (gshutdown) break; 1209 if (gshutdown) break;
1210 CHECKMEMORYSTATUS(MemStatus,MEM_RC,"Received numbers : Used","Free"); 1210 CHECKMEMORYSTATUS(MemStatus,MEM_RC,"Received numbers : Used","Free");
1211 if (gshutdown) break; 1211 if (gshutdown) break;
1212 CHECKMEMORYSTATUS(MemStatus,MEM_MC,"Missed numbers : Used","Free"); 1212 CHECKMEMORYSTATUS(MemStatus,MEM_MC,"Missed numbers : Used","Free");
1213 if (gshutdown) break; 1213 if (gshutdown) break;
1214 CHECKMEMORYSTATUS(MemStatus,MEM_ON,"Own numbers : Used","Free"); 1214 CHECKMEMORYSTATUS(MemStatus,MEM_ON,"Own numbers : Used","Free");
1215 if (gshutdown) break; 1215 if (gshutdown) break;
1216 CHECKMEMORYSTATUS(MemStatus,MEM_ME,"Phone phonebook : Used","Free"); 1216 CHECKMEMORYSTATUS(MemStatus,MEM_ME,"Phone phonebook : Used","Free");
1217 if (gshutdown) break; 1217 if (gshutdown) break;
1218 if (Phone->GetToDoStatus(&s, &ToDoStatus) == ERR_NONE) { 1218 if (Phone->GetToDoStatus(&s, &ToDoStatus) == ERR_NONE) {
1219 printmsg("ToDos : Used %d\n", ToDoStatus.Used); 1219 printmsg("ToDos : Used %d\n", ToDoStatus.Used);
1220 } 1220 }
1221 if (gshutdown) break; 1221 if (gshutdown) break;
1222 if (Phone->GetCalendarStatus(&s, &CalendarStatus) == ERR_NONE) { 1222 if (Phone->GetCalendarStatus(&s, &CalendarStatus) == ERR_NONE) {
1223 printmsg("Calendar : Used %d\n", CalendarStatus.Used); 1223 printmsg("Calendar : Used %d\n", CalendarStatus.Used);
1224 } 1224 }
1225 if (gshutdown) break; 1225 if (gshutdown) break;
1226 if (Phone->GetBatteryCharge(&s,&BatteryCharge)==ERR_NONE) { 1226 if (Phone->GetBatteryCharge(&s,&BatteryCharge)==ERR_NONE) {
1227 if (BatteryCharge.BatteryPercent != -1) printmsg("Battery level : %i percent\n", BatteryCharge.BatteryPercent); 1227 if (BatteryCharge.BatteryPercent != -1) printmsg("Battery level : %i percent\n", BatteryCharge.BatteryPercent);
1228 if (BatteryCharge.ChargeState != 0) { 1228 if (BatteryCharge.ChargeState != 0) {
1229 printmsg("Charge state : "); 1229 printmsg("Charge state : ");
1230 switch (BatteryCharge.ChargeState) { 1230 switch (BatteryCharge.ChargeState) {
1231 case GSM_BatteryPowered: 1231 case GSM_BatteryPowered:
1232 printmsg("powered from battery"); 1232 printmsg("powered from battery");
1233 break; 1233 break;
1234 case GSM_BatteryConnected: 1234 case GSM_BatteryConnected:
1235 printmsg("battery connected, but not powered from battery"); 1235 printmsg("battery connected, but not powered from battery");
1236 break; 1236 break;
1237 case GSM_BatteryNotConnected: 1237 case GSM_BatteryNotConnected:
1238 printmsg("battery not connected"); 1238 printmsg("battery not connected");
1239 break; 1239 break;
1240 case GSM_PowerFault: 1240 case GSM_PowerFault:
1241 printmsg("detected power failure"); 1241 printmsg("detected power failure");
1242 break; 1242 break;
1243 default: 1243 default:
1244 printmsg("unknown"); 1244 printmsg("unknown");
1245 break; 1245 break;
1246 } 1246 }
1247 printf("\n"); 1247 printf("\n");
1248 } 1248 }
1249 } 1249 }
1250 if (gshutdown) break; 1250 if (gshutdown) break;
1251 if (Phone->GetSignalQuality(&s,&SignalQuality)==ERR_NONE) { 1251 if (Phone->GetSignalQuality(&s,&SignalQuality)==ERR_NONE) {
1252 if (SignalQuality.SignalStrength != -1) printmsg("Signal strength : %i dBm\n", SignalQuality.SignalStrength); 1252 if (SignalQuality.SignalStrength != -1) printmsg("Signal strength : %i dBm\n", SignalQuality.SignalStrength);
1253 if (SignalQuality.SignalPercent != -1) printmsg("Network level : %i percent\n", SignalQuality.SignalPercent); 1253 if (SignalQuality.SignalPercent != -1) printmsg("Network level : %i percent\n", SignalQuality.SignalPercent);
1254 if (SignalQuality.BitErrorRate != -1) printmsg("Bit error rate : %i percent\n", SignalQuality.BitErrorRate); 1254 if (SignalQuality.BitErrorRate != -1) printmsg("Bit error rate : %i percent\n", SignalQuality.BitErrorRate);
1255 } 1255 }
1256 if (gshutdown) break; 1256 if (gshutdown) break;
1257 if (Phone->GetSMSStatus(&s,&SMSStatus)==ERR_NONE) { 1257 if (Phone->GetSMSStatus(&s,&SMSStatus)==ERR_NONE) {
1258 if (SMSStatus.SIMSize > 0) { 1258 if (SMSStatus.SIMSize > 0) {
1259 printmsg("SIM SMS status : %i used, %i unread, %i locations\n", 1259 printmsg("SIM SMS status : %i used, %i unread, %i locations\n",
1260 SMSStatus.SIMUsed, 1260 SMSStatus.SIMUsed,
1261 SMSStatus.SIMUnRead, 1261 SMSStatus.SIMUnRead,
1262 SMSStatus.SIMSize); 1262 SMSStatus.SIMSize);
1263 } 1263 }
1264 1264
1265 if (SMSStatus.PhoneSize > 0) { 1265 if (SMSStatus.PhoneSize > 0) {
1266 printmsg("Phone SMS status : %i used, %i unread, %i locations", 1266 printmsg("Phone SMS status : %i used, %i unread, %i locations",
1267 SMSStatus.PhoneUsed, 1267 SMSStatus.PhoneUsed,
1268 SMSStatus.PhoneUnRead, 1268 SMSStatus.PhoneUnRead,
1269 SMSStatus.PhoneSize); 1269 SMSStatus.PhoneSize);
1270 if (SMSStatus.TemplatesUsed!=0) printmsg(", %i templates", SMSStatus.TemplatesUsed); 1270 if (SMSStatus.TemplatesUsed!=0) printmsg(", %i templates", SMSStatus.TemplatesUsed);
1271 printf("\n"); 1271 printf("\n");
1272 } 1272 }
1273 } 1273 }
1274 if (gshutdown) break; 1274 if (gshutdown) break;
1275 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) { 1275 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
1276 printmsg("Network state : "); 1276 printmsg("Network state : ");
1277 switch (NetInfo.State) { 1277 switch (NetInfo.State) {
1278 case GSM_HomeNetwork : printmsg("home network\n"); break; 1278 case GSM_HomeNetwork : printmsg("home network\n"); break;
1279 case GSM_RoamingNetwork : printmsg("roaming network\n"); break; 1279 case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
1280 case GSM_RequestingNetwork : printmsg("requesting network\n"); break; 1280 case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
1281 case GSM_NoNetwork : printmsg("not logged into network\n"); break; 1281 case GSM_NoNetwork : printmsg("not logged into network\n"); break;
1282 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break; 1282 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break;
1283 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break; 1283 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
1284 default : printmsg("unknown\n"); 1284 default : printmsg("unknown\n");
1285 } 1285 }
1286 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) { 1286 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
1287 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode))); 1287 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
1288 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode))); 1288 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
1289 printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID); 1289 printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID);
1290 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) { 1290 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
1291 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName)); 1291 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
1292 } 1292 }
1293 } 1293 }
1294 } 1294 }
1295 printf("\n"); 1295 printf("\n");
1296 } 1296 }
1297 1297
1298 printmsg("Leaving monitor mode...\n"); 1298 printmsg("Leaving monitor mode...\n");
1299 1299
1300 GSM_Terminate(); 1300 GSM_Terminate();
1301} 1301}
1302 1302
1303static void IncomingUSSD2(char *Device, char *Buffer) 1303static void IncomingUSSD2(char *Device, char *Buffer)
1304{ 1304{
1305 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer)); 1305 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
1306 1306
1307 gshutdown = true; 1307 gshutdown = true;
1308} 1308}
1309 1309
1310static void GetUSSD(int argc, char *argv[]) 1310static void GetUSSD(int argc, char *argv[])
1311{ 1311{
1312 GSM_Init(true); 1312 GSM_Init(true);
1313 1313
1314 signal(SIGINT, interrupt); 1314 signal(SIGINT, interrupt);
1315 printmsgerr("Press Ctrl+C to break...\n"); 1315 printmsgerr("Press Ctrl+C to break...\n");
1316 1316
1317 s.User.IncomingUSSD = IncomingUSSD2; 1317 s.User.IncomingUSSD = IncomingUSSD2;
1318 1318
1319 error=Phone->SetIncomingUSSD(&s,true); 1319 error=Phone->SetIncomingUSSD(&s,true);
1320 Print_Error(error); 1320 Print_Error(error);
1321 1321
1322 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence); 1322 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence);
1323 Print_Error(error); 1323 Print_Error(error);
1324 1324
1325 while (!gshutdown) GSM_ReadDevice(&s,true); 1325 while (!gshutdown) GSM_ReadDevice(&s,true);
1326 1326
1327 GSM_Terminate(); 1327 GSM_Terminate();
1328} 1328}
1329 1329
1330static void GetSMSC(int argc, char *argv[]) 1330static void GetSMSC(int argc, char *argv[])
1331{ 1331{
1332 GSM_SMSC smsc; 1332 GSM_SMSC smsc;
1333 int start, stop; 1333 int start, stop;
1334 1334
1335 GetStartStop(&start, &stop, 2, argc, argv); 1335 GetStartStop(&start, &stop, 2, argc, argv);
1336 1336
1337 GSM_Init(true); 1337 GSM_Init(true);
1338 1338
1339 for (i=start;i<=stop;i++) { 1339 for (i=start;i<=stop;i++) {
1340 smsc.Location=i; 1340 smsc.Location=i;
1341 1341
1342 error=Phone->GetSMSC(&s, &smsc); 1342 error=Phone->GetSMSC(&s, &smsc);
1343 Print_Error(error); 1343 Print_Error(error);
1344 1344
1345 if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) { 1345 if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) {
1346 printmsg("%i. Set %i\n",smsc.Location, smsc.Location); 1346 printmsg("%i. Set %i\n",smsc.Location, smsc.Location);
1347 } else { 1347 } else {
1348 printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name)); 1348 printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name));
1349 } 1349 }
1350 printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number)); 1350 printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number));
1351 printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber)); 1351 printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber));
1352 1352
1353 printmsg("Format : "); 1353 printmsg("Format : ");
1354 switch (smsc.Format) { 1354 switch (smsc.Format) {
1355 case SMS_FORMAT_Text : printmsg("Text");break; 1355 case SMS_FORMAT_Text : printmsg("Text");break;
1356 case SMS_FORMAT_Fax : printmsg("Fax");break; 1356 case SMS_FORMAT_Fax : printmsg("Fax");break;
1357 case SMS_FORMAT_Email : printmsg("Email");break; 1357 case SMS_FORMAT_Email : printmsg("Email");break;
1358 case SMS_FORMAT_Pager : printmsg("Pager");break; 1358 case SMS_FORMAT_Pager : printmsg("Pager");break;
1359 } 1359 }
1360 printf("\n"); 1360 printf("\n");
1361 1361
1362 printmsg("Validity : "); 1362 printmsg("Validity : ");
1363 switch (smsc.Validity.Relative) { 1363 switch (smsc.Validity.Relative) {
1364 case SMS_VALID_1_Hour : printmsg("1 hour"); break; 1364 case SMS_VALID_1_Hour : printmsg("1 hour"); break;
1365 case SMS_VALID_6_Hours : printmsg("6 hours"); break; 1365 case SMS_VALID_6_Hours : printmsg("6 hours"); break;
1366 case SMS_VALID_1_Day : printmsg("24 hours"); break; 1366 case SMS_VALID_1_Day : printmsg("24 hours"); break;
1367 case SMS_VALID_3_Days : printmsg("72 hours"); break; 1367 case SMS_VALID_3_Days : printmsg("72 hours"); break;
1368 case SMS_VALID_1_Week : printmsg("1 week"); break; 1368 case SMS_VALID_1_Week : printmsg("1 week"); break;
1369 case SMS_VALID_Max_Time: printmsg("Maximum time"); break; 1369 case SMS_VALID_Max_Time: printmsg("Maximum time"); break;
1370 default : 1370 default :
1371 if (smsc.Validity.Relative >= 0 && smsc.Validity.Relative <= 143) { 1371 if (smsc.Validity.Relative >= 0 && smsc.Validity.Relative <= 143) {
1372 printmsg("%i minutes",(smsc.Validity.Relative+1)*5); 1372 printmsg("%i minutes",(smsc.Validity.Relative+1)*5);
1373 } else if (smsc.Validity.Relative >= 144 && smsc.Validity.Relative <= 167) { 1373 } else if (smsc.Validity.Relative >= 144 && smsc.Validity.Relative <= 167) {
1374 printmsg("%i minutes",12*60 + (smsc.Validity.Relative-143)*30); 1374 printmsg("%i minutes",12*60 + (smsc.Validity.Relative-143)*30);
1375 } else if (smsc.Validity.Relative >= 168 && smsc.Validity.Relative <= 196) { 1375 } else if (smsc.Validity.Relative >= 168 && smsc.Validity.Relative <= 196) {
1376 printmsg("%i days",smsc.Validity.Relative-166); 1376 printmsg("%i days",smsc.Validity.Relative-166);
1377 } else if (smsc.Validity.Relative >= 197 && smsc.Validity.Relative <= 255) { 1377 } else if (smsc.Validity.Relative >= 197 && smsc.Validity.Relative <= 255) {
1378 printmsg("%i weeks",smsc.Validity.Relative-192); 1378 printmsg("%i weeks",smsc.Validity.Relative-192);
1379 } 1379 }
1380 } 1380 }
1381 printf("\n"); 1381 printf("\n");
1382 } 1382 }
1383 1383
1384 GSM_Terminate(); 1384 GSM_Terminate();
1385} 1385}
1386 1386
1387static void GetSMS(int argc, char *argv[]) 1387static void GetSMS(int argc, char *argv[])
1388{ 1388{
1389 GSM_MultiSMSMessagesms; 1389 GSM_MultiSMSMessagesms;
1390 GSM_SMSFolders folders; 1390 GSM_SMSFolders folders;
1391 int start, stop; 1391 int start, stop;
1392 int j; 1392 int j;
1393 1393
1394 GetStartStop(&start, &stop, 3, argc, argv); 1394 GetStartStop(&start, &stop, 3, argc, argv);
1395 1395
1396 GSM_Init(true); 1396 GSM_Init(true);
1397 1397
1398 error=Phone->GetSMSFolders(&s, &folders); 1398 error=Phone->GetSMSFolders(&s, &folders);
1399 Print_Error(error); 1399 Print_Error(error);
1400 1400
1401 for (j = start; j <= stop; j++) { 1401 for (j = start; j <= stop; j++) {
1402 sms.SMS[0].Folder= atoi(argv[2]); 1402 sms.SMS[0].Folder= atoi(argv[2]);
1403 sms.SMS[0].Location= j; 1403 sms.SMS[0].Location= j;
1404 error=Phone->GetSMS(&s, &sms); 1404 error=Phone->GetSMS(&s, &sms);
1405 switch (error) { 1405 switch (error) {
1406 case ERR_EMPTY: 1406 case ERR_EMPTY:
1407 printmsg("Location %i\n",sms.SMS[0].Location); 1407 printmsg("Location %i\n",sms.SMS[0].Location);
1408 printmsg("Empty\n"); 1408 printmsg("Empty\n");
1409 break; 1409 break;
1410 default: 1410 default:
1411 Print_Error(error); 1411 Print_Error(error);
1412 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name)); 1412 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
1413 switch(sms.SMS[0].Memory) { 1413 switch(sms.SMS[0].Memory) {
1414 case MEM_SM: printmsg(", SIM memory"); break; 1414 case MEM_SM: printmsg(", SIM memory"); break;
1415 case MEM_ME: printmsg(", phone memory"); break; 1415 case MEM_ME: printmsg(", phone memory"); break;
1416 case MEM_MT: printmsg(", phone or SIM memory"); break; 1416 case MEM_MT: printmsg(", phone or SIM memory"); break;
1417 default : break; 1417 default : break;
1418 } 1418 }
1419 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder"); 1419 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
1420 printf("\n"); 1420 printf("\n");
1421 displaymultismsinfo(sms,false,false); 1421 displaymultismsinfo(sms,false,false);
1422 } 1422 }
1423 } 1423 }
1424 1424
1425 GSM_Terminate(); 1425 GSM_Terminate();
1426} 1426}
1427 1427
1428static void DeleteSMS(int argc, char *argv[]) 1428static void DeleteSMS(int argc, char *argv[])
1429{ 1429{
1430 GSM_SMSMessagesms; 1430 GSM_SMSMessagesms;
1431 int start, stop; 1431 int start, stop;
1432 1432
1433 sms.Folder=atoi(argv[2]); 1433 sms.Folder=atoi(argv[2]);
1434 1434
1435 GetStartStop(&start, &stop, 3, argc, argv); 1435 GetStartStop(&start, &stop, 3, argc, argv);
1436 1436
1437 GSM_Init(true); 1437 GSM_Init(true);
1438 1438
1439 for (i=start;i<=stop;i++) { 1439 for (i=start;i<=stop;i++) {
1440 sms.Folder= 0; 1440 sms.Folder= 0;
1441 sms.Location= i; 1441 sms.Location= i;
1442 error=Phone->DeleteSMS(&s, &sms); 1442 error=Phone->DeleteSMS(&s, &sms);
1443 Print_Error(error); 1443 Print_Error(error);
1444 } 1444 }
1445#ifdef GSM_ENABLE_BEEP 1445#ifdef GSM_ENABLE_BEEP
1446 GSM_PhoneBeep(); 1446 GSM_PhoneBeep();
1447#endif 1447#endif
1448 GSM_Terminate(); 1448 GSM_Terminate();
1449} 1449}
1450 1450
1451static void GetAllSMS(int argc, char *argv[]) 1451static void GetAllSMS(int argc, char *argv[])
1452{ 1452{
1453 GSM_MultiSMSMessage sms; 1453 GSM_MultiSMSMessage sms;
1454 GSM_SMSFolders folders; 1454 GSM_SMSFolders folders;
1455 bool start = true; 1455 bool start = true;
1456 1456
1457 GSM_Init(true); 1457 GSM_Init(true);
1458 1458
1459 error=Phone->GetSMSFolders(&s, &folders); 1459 error=Phone->GetSMSFolders(&s, &folders);
1460 Print_Error(error); 1460 Print_Error(error);
1461 1461
1462 while (error == ERR_NONE) { 1462 while (error == ERR_NONE) {
1463 sms.SMS[0].Folder=0x00; 1463 sms.SMS[0].Folder=0x00;
1464 error=Phone->GetNextSMS(&s, &sms, start); 1464 error=Phone->GetNextSMS(&s, &sms, start);
1465 switch (error) { 1465 switch (error) {
1466 case ERR_EMPTY: 1466 case ERR_EMPTY:
1467 break; 1467 break;
1468 default: 1468 default:
1469 Print_Error(error); 1469 Print_Error(error);
1470 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name)); 1470 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
1471 switch(sms.SMS[0].Memory) { 1471 switch(sms.SMS[0].Memory) {
1472 case MEM_SM: printmsg(", SIM memory"); break; 1472 case MEM_SM: printmsg(", SIM memory"); break;
1473 case MEM_ME: printmsg(", phone memory"); break; 1473 case MEM_ME: printmsg(", phone memory"); break;
1474 case MEM_MT: printmsg(", phone or SIM memory"); break; 1474 case MEM_MT: printmsg(", phone or SIM memory"); break;
1475 default : break; 1475 default : break;
1476 } 1476 }
1477 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder"); 1477 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
1478 printf("\n"); 1478 printf("\n");
1479 displaymultismsinfo(sms,false,false); 1479 displaymultismsinfo(sms,false,false);
1480 } 1480 }
1481 start=false; 1481 start=false;
1482 } 1482 }
1483 fprintf(stderr,"\n"); 1483 fprintf(stderr,"\n");
1484 1484
1485#ifdef GSM_ENABLE_BEEP 1485#ifdef GSM_ENABLE_BEEP
1486 GSM_PhoneBeep(); 1486 GSM_PhoneBeep();
1487#endif 1487#endif
1488 GSM_Terminate(); 1488 GSM_Terminate();
1489} 1489}
1490 1490
1491static void GetEachSMS(int argc, char *argv[]) 1491static void GetEachSMS(int argc, char *argv[])
1492{ 1492{
1493 GSM_MultiSMSMessage*GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms; 1493 GSM_MultiSMSMessage*GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms;
1494 int GetSMSNumber = 0,i,j; 1494 int GetSMSNumber = 0,i,j;
1495 GSM_SMSFolders folders; 1495 GSM_SMSFolders folders;
1496 bool start = true, ems = true; 1496 bool start = true, ems = true;
1497 1497
1498 GetSMS[0] = NULL; 1498 GetSMS[0] = NULL;
1499 1499
1500 GSM_Init(true); 1500 GSM_Init(true);
1501 1501
1502 error=Phone->GetSMSFolders(&s, &folders); 1502 error=Phone->GetSMSFolders(&s, &folders);
1503 Print_Error(error); 1503 Print_Error(error);
1504 1504
1505 fprintf(stderr,"Reading: "); 1505 fprintf(stderr,"Reading: ");
1506 while (error == ERR_NONE) { 1506 while (error == ERR_NONE) {
1507 sms.SMS[0].Folder=0x00; 1507 sms.SMS[0].Folder=0x00;
1508 error=Phone->GetNextSMS(&s, &sms, start); 1508 error=Phone->GetNextSMS(&s, &sms, start);
1509 switch (error) { 1509 switch (error) {
1510 case ERR_EMPTY: 1510 case ERR_EMPTY:
1511 break; 1511 break;
1512 default: 1512 default:
1513 Print_Error(error); 1513 Print_Error(error);
1514 GetSMS[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage)); 1514 GetSMS[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage));
1515 if (GetSMS[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY); 1515 if (GetSMS[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY);
1516 GetSMS[GetSMSNumber+1] = NULL; 1516 GetSMS[GetSMSNumber+1] = NULL;
1517 memcpy(GetSMS[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage)); 1517 memcpy(GetSMS[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage));
1518 GetSMSNumber++; 1518 GetSMSNumber++;
1519 if (GetSMSNumber==PHONE_MAXSMSINFOLDER) { 1519 if (GetSMSNumber==PHONE_MAXSMSINFOLDER) {
1520 fprintf(stderr,"SMS counter overflow\n"); 1520 fprintf(stderr,"SMS counter overflow\n");
1521 return; 1521 return;
1522 } 1522 }
1523 } 1523 }
1524 fprintf(stderr,"*"); 1524 fprintf(stderr,"*");
1525 start=false; 1525 start=false;
1526 } 1526 }
1527 fprintf(stderr,"\n"); 1527 fprintf(stderr,"\n");
1528 1528
1529#ifdef GSM_ENABLE_BEEP 1529#ifdef GSM_ENABLE_BEEP
1530 GSM_PhoneBeep(); 1530 GSM_PhoneBeep();
1531#endif 1531#endif
1532 1532
1533 error = GSM_LinkSMS(GetSMS, SortedSMS, ems); 1533 error = GSM_LinkSMS(GetSMS, SortedSMS, ems);
1534 Print_Error(error); 1534 Print_Error(error);
1535 1535
1536 i=0; 1536 i=0;
1537 while(GetSMS[i] != NULL) { 1537 while(GetSMS[i] != NULL) {
1538 free(GetSMS[i]); 1538 free(GetSMS[i]);
1539 GetSMS[i] = NULL; 1539 GetSMS[i] = NULL;
1540 i++; 1540 i++;
1541 } 1541 }
1542 1542
1543 i=0; 1543 i=0;
1544 while(SortedSMS[i] != NULL) { 1544 while(SortedSMS[i] != NULL) {
1545 for (j=0;j<SortedSMS[i]->Number;j++) { 1545 for (j=0;j<SortedSMS[i]->Number;j++) {
1546 if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) { 1546 if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) {
1547 printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name)); 1547 printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name));
1548 switch(SortedSMS[i]->SMS[j].Memory) { 1548 switch(SortedSMS[i]->SMS[j].Memory) {
1549 case MEM_SM: printmsg(", SIM memory"); break; 1549 case MEM_SM: printmsg(", SIM memory"); break;
1550 case MEM_ME: printmsg(", phone memory"); break; 1550 case MEM_ME: printmsg(", phone memory"); break;
1551 case MEM_MT: printmsg(", phone or SIM memory"); break; 1551 case MEM_MT: printmsg(", phone or SIM memory"); break;
1552 default : break; 1552 default : break;
1553 } 1553 }
1554 if (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder"); 1554 if (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder");
1555 printf("\n"); 1555 printf("\n");
1556 } 1556 }
1557 } 1557 }
1558 displaymultismsinfo(*SortedSMS[i],true,ems); 1558 displaymultismsinfo(*SortedSMS[i],true,ems);
1559 1559
1560 free(SortedSMS[i]); 1560 free(SortedSMS[i]);
1561 SortedSMS[i] = NULL; 1561 SortedSMS[i] = NULL;
1562 i++; 1562 i++;
1563 } 1563 }
1564 1564
1565 GSM_Terminate(); 1565 GSM_Terminate();
1566} 1566}
1567 1567
1568static void GetSMSFolders(int argc, char *argv[]) 1568static void GetSMSFolders(int argc, char *argv[])
1569{ 1569{
1570 GSM_SMSFolders folders; 1570 GSM_SMSFolders folders;
1571 1571
1572 GSM_Init(true); 1572 GSM_Init(true);
1573 1573
1574 error=Phone->GetSMSFolders(&s,&folders); 1574 error=Phone->GetSMSFolders(&s,&folders);
1575 Print_Error(error); 1575 Print_Error(error);
1576 1576
1577 for (i=0;i<folders.Number;i++) { 1577 for (i=0;i<folders.Number;i++) {
1578 printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name)); 1578 printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name));
1579 switch(folders.Folder[i].Memory) { 1579 switch(folders.Folder[i].Memory) {
1580 case MEM_SM: printmsg(", SIM memory"); break; 1580 case MEM_SM: printmsg(", SIM memory"); break;
1581 case MEM_ME: printmsg(", phone memory"); break; 1581 case MEM_ME: printmsg(", phone memory"); break;
1582 case MEM_MT: printmsg(", phone or SIM memory"); break; 1582 case MEM_MT: printmsg(", phone or SIM memory"); break;
1583 default : break; 1583 default : break;
1584 } 1584 }
1585 if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder"); 1585 if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder");
1586 printf("\n"); 1586 printf("\n");
1587 } 1587 }
1588 1588
1589 GSM_Terminate(); 1589 GSM_Terminate();
1590} 1590}
1591 1591
1592static void GetRingtone(int argc, char *argv[]) 1592static void GetRingtone(int argc, char *argv[])
1593{ 1593{
1594 GSM_Ringtone ringtone; 1594 GSM_Ringtone ringtone;
1595 bool PhoneRingtone = false; 1595 bool PhoneRingtone = false;
1596 1596
1597 if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true; 1597 if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true;
1598 1598
1599 GetStartStop(&ringtone.Location, NULL, 2, argc, argv); 1599 GetStartStop(&ringtone.Location, NULL, 2, argc, argv);
1600 1600
1601 GSM_Init(true); 1601 GSM_Init(true);
1602 1602
1603 ringtone.Format=0; 1603 ringtone.Format=0;
1604 1604
1605 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone); 1605 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone);
1606 Print_Error(error); 1606 Print_Error(error);
1607 1607
1608 switch (ringtone.Format) { 1608 switch (ringtone.Format) {
1609 case RING_NOTETONE : printmsg("Smart Messaging");break; 1609 case RING_NOTETONE : printmsg("Smart Messaging");break;
1610 case RING_NOKIABINARY : printmsg("Nokia binary");break; 1610 case RING_NOKIABINARY : printmsg("Nokia binary");break;
1611 case RING_MIDI : printmsg("MIDI"); break; 1611 case RING_MIDI : printmsg("MIDI"); break;
1612 case RING_MMF : printmsg("SMAF (MMF)");break; 1612 case RING_MMF : printmsg("SMAF (MMF)");break;
1613 } 1613 }
1614 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name)); 1614 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name));
1615 1615
1616 if (argc==4) { 1616 if (argc==4) {
1617 error=GSM_SaveRingtoneFile(argv[3], &ringtone); 1617 error=GSM_SaveRingtoneFile(argv[3], &ringtone);
1618 Print_Error(error); 1618 Print_Error(error);
1619 } 1619 }
1620 1620
1621 GSM_Terminate(); 1621 GSM_Terminate();
1622} 1622}
1623 1623
1624static void GetRingtonesList(int argc, char *argv[]) 1624static void GetRingtonesList(int argc, char *argv[])
1625{ 1625{
1626 GSM_AllRingtonesInfo Info; 1626 GSM_AllRingtonesInfo Info;
1627 int i; 1627 int i;
1628 1628
1629 GSM_Init(true); 1629 GSM_Init(true);
1630 1630
1631 error=Phone->GetRingtonesInfo(&s,&Info); 1631 error=Phone->GetRingtonesInfo(&s,&Info);
1632 Print_Error(error); 1632 Print_Error(error);
1633 1633
1634 GSM_Terminate(); 1634 GSM_Terminate();
1635 1635
1636 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); 1636 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name));
1637} 1637}
1638 1638
1639static void DialVoice(int argc, char *argv[]) 1639static void DialVoice(int argc, char *argv[])
1640{ 1640{
1641 GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence; 1641 GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence;
1642 1642
1643 if (argc > 3) { 1643 if (argc > 3) {
1644 if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber; 1644 if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber;
1645 } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber; 1645 } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber;
1646 } else { 1646 } else {
1647 printmsg("Unknown parameter (\"%s\")\n",argv[3]); 1647 printmsg("Unknown parameter (\"%s\")\n",argv[3]);
1648 exit(-1); 1648 exit(-1);
1649 } 1649 }
1650 } 1650 }
1651 1651
1652 GSM_Init(true); 1652 GSM_Init(true);
1653 1653
1654 error=Phone->DialVoice(&s, argv[2], ShowNumber); 1654 error=Phone->DialVoice(&s, argv[2], ShowNumber);
1655 Print_Error(error); 1655 Print_Error(error);
1656 1656
1657 GSM_Terminate(); 1657 GSM_Terminate();
1658} 1658}
1659 1659
1660static void CancelCall(int argc, char *argv[]) 1660static void CancelCall(int argc, char *argv[])
1661{ 1661{
1662 GSM_Init(true); 1662 GSM_Init(true);
1663 1663
1664 if (argc>2) { 1664 if (argc>2) {
1665 error=Phone->CancelCall(&s,atoi(argv[2]),false); 1665 error=Phone->CancelCall(&s,atoi(argv[2]),false);
1666 } else { 1666 } else {
1667 error=Phone->CancelCall(&s,0,true); 1667 error=Phone->CancelCall(&s,0,true);
1668 } 1668 }
1669 Print_Error(error); 1669 Print_Error(error);
1670 1670
1671 GSM_Terminate(); 1671 GSM_Terminate();
1672} 1672}
1673 1673
1674static void AnswerCall(int argc, char *argv[]) 1674static void AnswerCall(int argc, char *argv[])
1675{ 1675{
1676 GSM_Init(true); 1676 GSM_Init(true);
1677 1677
1678 if (argc>2) { 1678 if (argc>2) {
1679 error=Phone->AnswerCall(&s,atoi(argv[2]),false); 1679 error=Phone->AnswerCall(&s,atoi(argv[2]),false);
1680 } else { 1680 } else {
1681 error=Phone->AnswerCall(&s,0,true); 1681 error=Phone->AnswerCall(&s,0,true);
1682 } 1682 }
1683 Print_Error(error); 1683 Print_Error(error);
1684 1684
1685 GSM_Terminate(); 1685 GSM_Terminate();
1686} 1686}
1687 1687
1688static void UnholdCall(int argc, char *argv[]) 1688static void UnholdCall(int argc, char *argv[])
1689{ 1689{
1690 GSM_Init(true); 1690 GSM_Init(true);
1691 1691
1692 error=Phone->UnholdCall(&s,atoi(argv[2])); 1692 error=Phone->UnholdCall(&s,atoi(argv[2]));
1693 Print_Error(error); 1693 Print_Error(error);
1694 1694
1695 GSM_Terminate(); 1695 GSM_Terminate();
1696} 1696}
1697 1697
1698static void HoldCall(int argc, char *argv[]) 1698static void HoldCall(int argc, char *argv[])
1699{ 1699{
1700 GSM_Init(true); 1700 GSM_Init(true);
1701 1701
1702 error=Phone->HoldCall(&s,atoi(argv[2])); 1702 error=Phone->HoldCall(&s,atoi(argv[2]));
1703 Print_Error(error); 1703 Print_Error(error);
1704 1704
1705 GSM_Terminate(); 1705 GSM_Terminate();
1706} 1706}
1707 1707
1708static void ConferenceCall(int argc, char *argv[]) 1708static void ConferenceCall(int argc, char *argv[])
1709{ 1709{
1710 GSM_Init(true); 1710 GSM_Init(true);
1711 1711
1712 error=Phone->ConferenceCall(&s,atoi(argv[2])); 1712 error=Phone->ConferenceCall(&s,atoi(argv[2]));
1713 Print_Error(error); 1713 Print_Error(error);
1714 1714
1715 GSM_Terminate(); 1715 GSM_Terminate();
1716} 1716}
1717 1717
1718static void SplitCall(int argc, char *argv[]) 1718static void SplitCall(int argc, char *argv[])
1719{ 1719{
1720 GSM_Init(true); 1720 GSM_Init(true);
1721 1721
1722 error=Phone->SplitCall(&s,atoi(argv[2])); 1722 error=Phone->SplitCall(&s,atoi(argv[2]));
1723 Print_Error(error); 1723 Print_Error(error);
1724 1724
1725 GSM_Terminate(); 1725 GSM_Terminate();
1726} 1726}
1727 1727
1728static void SwitchCall(int argc, char *argv[]) 1728static void SwitchCall(int argc, char *argv[])
1729{ 1729{
1730 GSM_Init(true); 1730 GSM_Init(true);
1731 1731
1732 if (argc > 2) { 1732 if (argc > 2) {
1733 error=Phone->SwitchCall(&s,atoi(argv[2]),false); 1733 error=Phone->SwitchCall(&s,atoi(argv[2]),false);
1734 } else { 1734 } else {
1735 error=Phone->SwitchCall(&s,0,true); 1735 error=Phone->SwitchCall(&s,0,true);
1736 } 1736 }
1737 Print_Error(error); 1737 Print_Error(error);
1738 1738
1739 GSM_Terminate(); 1739 GSM_Terminate();
1740} 1740}
1741 1741
1742static void TransferCall(int argc, char *argv[]) 1742static void TransferCall(int argc, char *argv[])
1743{ 1743{
1744 GSM_Init(true); 1744 GSM_Init(true);
1745 1745
1746 if (argc > 2) { 1746 if (argc > 2) {
1747 error=Phone->TransferCall(&s,atoi(argv[2]),false); 1747 error=Phone->TransferCall(&s,atoi(argv[2]),false);
1748 } else { 1748 } else {
1749 error=Phone->TransferCall(&s,0,true); 1749 error=Phone->TransferCall(&s,0,true);
1750 } 1750 }
1751 Print_Error(error); 1751 Print_Error(error);
1752 1752
1753 GSM_Terminate(); 1753 GSM_Terminate();
1754} 1754}
1755 1755
1756static void AddSMSFolder(int argc, char *argv[]) 1756static void AddSMSFolder(int argc, char *argv[])
1757{ 1757{
1758 unsigned char buffer[200]; 1758 unsigned char buffer[200];
1759 1759
1760 GSM_Init(true); 1760 GSM_Init(true);
1761 1761
1762 EncodeUnicode(buffer,argv[2],strlen(argv[2])); 1762 EncodeUnicode(buffer,argv[2],strlen(argv[2]));
1763 error=Phone->AddSMSFolder(&s,buffer); 1763 error=Phone->AddSMSFolder(&s,buffer);
1764 Print_Error(error); 1764 Print_Error(error);
1765 1765
1766 GSM_Terminate(); 1766 GSM_Terminate();
1767} 1767}
1768 1768
1769static void Reset(int argc, char *argv[]) 1769static void Reset(int argc, char *argv[])
1770{ 1770{
1771 bool hard; 1771 bool hard;
1772 1772
1773 if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false; 1773 if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false;
1774 } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true; 1774 } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true;
1775 } else { 1775 } else {
1776 printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]); 1776 printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]);
1777 exit(-1); 1777 exit(-1);
1778 } 1778 }
1779 1779
1780 GSM_Init(true); 1780 GSM_Init(true);
1781 1781
1782 error=Phone->Reset(&s, hard); 1782 error=Phone->Reset(&s, hard);
1783 Print_Error(error); 1783 Print_Error(error);
1784 1784
1785 GSM_Terminate(); 1785 GSM_Terminate();
1786} 1786}
1787 1787
1788static void PrintCalendar(GSM_CalendarEntry *Note) 1788static void PrintCalendar(GSM_CalendarEntry *Note)
1789{ 1789{
1790 int i_age = 0,i; 1790 int i_age = 0,i;
1791 GSM_DateTime Alarm,DateTime; 1791 GSM_DateTime Alarm,DateTime;
1792 GSM_MemoryEntry entry; 1792 GSM_MemoryEntry entry;
1793 unsigned char *name; 1793 unsigned char *name;
1794 1794
1795 bool repeating = false; 1795 bool repeating = false;
1796 int repeat_dayofweek = -1; 1796 int repeat_dayofweek = -1;
1797 int repeat_day = -1; 1797 int repeat_day = -1;
1798 int repeat_weekofmonth = -1; 1798 int repeat_weekofmonth = -1;
1799 int repeat_month = -1; 1799 int repeat_month = -1;
1800 int repeat_frequency = -1; 1800 int repeat_frequency = -1;
1801 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 1801 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
1802 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 1802 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
1803 1803
1804 printmsg("Location : %d\n", Note->Location); 1804 printmsg("Location : %d\n", Note->Location);
1805 printmsg("Note type : "); 1805 printmsg("Note type : ");
1806 switch (Note->Type) { 1806 switch (Note->Type) {
1807 case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break; 1807 case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break;
1808 case GSM_CAL_CALL : printmsg("Call\n"); break; 1808 case GSM_CAL_CALL : printmsg("Call\n"); break;
1809 case GSM_CAL_MEETING : printmsg("Meeting\n"); break; 1809 case GSM_CAL_MEETING : printmsg("Meeting\n"); break;
1810 case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break; 1810 case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break;
1811 case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break; 1811 case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break;
1812 case GSM_CAL_TRAVEL : printmsg("Travel\n"); break; 1812 case GSM_CAL_TRAVEL : printmsg("Travel\n"); break;
1813 case GSM_CAL_VACATION : printmsg("Vacation\n"); break; 1813 case GSM_CAL_VACATION : printmsg("Vacation\n"); break;
1814 case GSM_CAL_ALARM : printmsg("Alarm\n"); break; 1814 case GSM_CAL_ALARM : printmsg("Alarm\n"); break;
1815 case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break; 1815 case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break;
1816 case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break; 1816 case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break;
1817 case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break; 1817 case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break;
1818 case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break; 1818 case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break;
1819 case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break; 1819 case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break;
1820 case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break; 1820 case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break;
1821 case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break; 1821 case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break;
1822 case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break; 1822 case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break;
1823 case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break; 1823 case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break;
1824 case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break; 1824 case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break;
1825 case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break; 1825 case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break;
1826 case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break; 1826 case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break;
1827 case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break; 1827 case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break;
1828 case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break; 1828 case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break;
1829 case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break; 1829 case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break;
1830 case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break; 1830 case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break;
1831 case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break; 1831 case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break;
1832 case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break; 1832 case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break;
1833 case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break; 1833 case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break;
1834 case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break; 1834 case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break;
1835 default : printmsg("UNKNOWN\n"); 1835 default : printmsg("UNKNOWN\n");
1836 } 1836 }
1837 Alarm.Year = 0; 1837 Alarm.Year = 0;
1838 1838
1839 repeating = false; 1839 repeating = false;
1840 repeat_dayofweek = -1; 1840 repeat_dayofweek = -1;
1841 repeat_day = -1; 1841 repeat_day = -1;
1842 repeat_weekofmonth = -1; 1842 repeat_weekofmonth = -1;
1843 repeat_month = -1; 1843 repeat_month = -1;
1844 repeat_frequency = -1; 1844 repeat_frequency = -1;
1845 repeat_startdate.Day= 0; 1845 repeat_startdate.Day= 0;
1846 repeat_stopdate.Day = 0; 1846 repeat_stopdate.Day = 0;
1847 1847
1848 for (i=0;i<Note->EntriesNum;i++) { 1848 for (i=0;i<Note->EntriesNum;i++) {
1849 switch (Note->Entries[i].EntryType) { 1849 switch (Note->Entries[i].EntryType) {
1850 case CAL_START_DATETIME: 1850 case CAL_START_DATETIME:
1851 printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1851 printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
1852 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1852 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1853 break; 1853 break;
1854 case CAL_END_DATETIME: 1854 case CAL_END_DATETIME:
1855 printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1855 printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
1856 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1856 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1857 break; 1857 break;
1858 case CAL_ALARM_DATETIME: 1858 case CAL_ALARM_DATETIME:
1859 printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1859 printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1860 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1860 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1861 break; 1861 break;
1862 case CAL_SILENT_ALARM_DATETIME: 1862 case CAL_SILENT_ALARM_DATETIME:
1863 printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1863 printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1864 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1864 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1865 break; 1865 break;
1866 case CAL_RECURRANCE: 1866 case CAL_RECURRANCE:
1867 printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24, 1867 printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,
1868 ((Note->Entries[i].Number/24)>1) ? "s":"" ); 1868 ((Note->Entries[i].Number/24)>1) ? "s":"" );
1869 break; 1869 break;
1870 case CAL_TEXT: 1870 case CAL_TEXT:
1871 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1871 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1872 break; 1872 break;
1873 case CAL_LOCATION: 1873 case CAL_LOCATION:
1874 printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1874 printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1875 break; 1875 break;
1876 case CAL_PHONE: 1876 case CAL_PHONE:
1877 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1877 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1878 break; 1878 break;
1879 case CAL_PRIVATE: 1879 case CAL_PRIVATE:
1880 printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); 1880 printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
1881 break; 1881 break;
1882 case CAL_CONTACTID: 1882 case CAL_CONTACTID:
1883 entry.Location = Note->Entries[i].Number; 1883 entry.Location = Note->Entries[i].Number;
1884 entry.MemoryType = MEM_ME; 1884 entry.MemoryType = MEM_ME;
1885 error=Phone->GetMemory(&s, &entry); 1885 error=Phone->GetMemory(&s, &entry);
1886 if (error == ERR_NONE) { 1886 if (error == ERR_NONE) {
1887 name = GSM_PhonebookGetEntryName(&entry); 1887 name = GSM_PhonebookGetEntryName(&entry);
1888 if (name != NULL) { 1888 if (name != NULL) {
1889 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 1889 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
1890 } else { 1890 } else {
1891 printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1891 printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1892 } 1892 }
1893 } else { 1893 } else {
1894 printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1894 printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1895 } 1895 }
1896 break; 1896 break;
1897 case CAL_REPEAT_DAYOFWEEK: 1897 case CAL_REPEAT_DAYOFWEEK:
1898 repeat_dayofweek = Note->Entries[i].Number; 1898 repeat_dayofweek = Note->Entries[i].Number;
1899 repeating = true; 1899 repeating = true;
1900 break; 1900 break;
1901 case CAL_REPEAT_DAY: 1901 case CAL_REPEAT_DAY:
1902 repeat_day = Note->Entries[i].Number; 1902 repeat_day = Note->Entries[i].Number;
1903 repeating = true; 1903 repeating = true;
1904 break; 1904 break;
1905 case CAL_REPEAT_WEEKOFMONTH: 1905 case CAL_REPEAT_WEEKOFMONTH:
1906 repeat_weekofmonth = Note->Entries[i].Number; 1906 repeat_weekofmonth = Note->Entries[i].Number;
1907 repeating = true; 1907 repeating = true;
1908 break; 1908 break;
1909 case CAL_REPEAT_MONTH: 1909 case CAL_REPEAT_MONTH:
1910 repeat_month = Note->Entries[i].Number; 1910 repeat_month = Note->Entries[i].Number;
1911 repeating = true; 1911 repeating = true;
1912 break; 1912 break;
1913 case CAL_REPEAT_FREQUENCY: 1913 case CAL_REPEAT_FREQUENCY:
1914 repeat_frequency = Note->Entries[i].Number; 1914 repeat_frequency = Note->Entries[i].Number;
1915 repeating = true; 1915 repeating = true;
1916 break; 1916 break;
1917 case CAL_REPEAT_STARTDATE: 1917 case CAL_REPEAT_STARTDATE:
1918 repeat_startdate = Note->Entries[i].Date; 1918 repeat_startdate = Note->Entries[i].Date;
1919 repeating = true; 1919 repeating = true;
1920 break; 1920 break;
1921 case CAL_REPEAT_STOPDATE: 1921 case CAL_REPEAT_STOPDATE:
1922 repeat_stopdate = Note->Entries[i].Date; 1922 repeat_stopdate = Note->Entries[i].Date;
1923 repeating = true; 1923 repeating = true;
1924 break; 1924 break;
1925 } 1925 }
1926 } 1926 }
1927 if (repeating) { 1927 if (repeating) {
1928 printmsg("Repeating : "); 1928 printmsg("Repeating : ");
1929 if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) { 1929 if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) {
1930 printmsg("Forever"); 1930 printmsg("Forever");
1931 } else if (repeat_startdate.Day == 0) { 1931 } else if (repeat_startdate.Day == 0) {
1932 printmsg("Till %s", OSDate(repeat_stopdate)); 1932 printmsg("Till %s", OSDate(repeat_stopdate));
1933 } else if (repeat_stopdate.Day == 0) { 1933 } else if (repeat_stopdate.Day == 0) {
1934 printmsg("Since %s", OSDate(repeat_startdate)); 1934 printmsg("Since %s", OSDate(repeat_startdate));
1935 } else { 1935 } else {
1936 printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate)); 1936 printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate));
1937 } 1937 }
1938 if (repeat_frequency != -1) { 1938 if (repeat_frequency != -1) {
1939 if (repeat_frequency == 1) { 1939 if (repeat_frequency == 1) {
1940 printmsg (" on each "); 1940 printmsg (" on each ");
1941 } else { 1941 } else {
1942 printmsg(" on each %d. ", repeat_frequency); 1942 printmsg(" on each %d. ", repeat_frequency);
1943 } 1943 }
1944 if (repeat_dayofweek > 0) { 1944 if (repeat_dayofweek > 0) {
1945 switch (repeat_dayofweek) { 1945 switch (repeat_dayofweek) {
1946 case 1 : printmsg("Monday"); break; 1946 case 1 : printmsg("Monday"); break;
1947 case 2 : printmsg("Tuesday"); break; 1947 case 2 : printmsg("Tuesday"); break;
1948 case 3 : printmsg("Wednesday"); break; 1948 case 3 : printmsg("Wednesday"); break;
1949 case 4 : printmsg("Thursday"); break; 1949 case 4 : printmsg("Thursday"); break;
1950 case 5 : printmsg("Friday"); break; 1950 case 5 : printmsg("Friday"); break;
1951 case 6 : printmsg("Saturday"); break; 1951 case 6 : printmsg("Saturday"); break;
1952 case 7 : printmsg("Sunday"); break; 1952 case 7 : printmsg("Sunday"); break;
1953 default: printmsg("Bad day!"); break; 1953 default: printmsg("Bad day!"); break;
1954 } 1954 }
1955 if (repeat_weekofmonth > 0) { 1955 if (repeat_weekofmonth > 0) {
1956 printmsg(" in %d. week of ", repeat_weekofmonth); 1956 printmsg(" in %d. week of ", repeat_weekofmonth);
1957 } else { 1957 } else {
1958 printmsg(" in "); 1958 printmsg(" in ");
1959 } 1959 }
1960 if (repeat_month > 0) { 1960 if (repeat_month > 0) {
1961 switch(repeat_month) { 1961 switch(repeat_month) {
1962 case 1 : printmsg("January"); break; 1962 case 1 : printmsg("January"); break;
1963 case 2 : printmsg("February"); break; 1963 case 2 : printmsg("February"); break;
1964 case 3 : printmsg("March"); break; 1964 case 3 : printmsg("March"); break;
1965 case 4 : printmsg("April"); break; 1965 case 4 : printmsg("April"); break;
1966 case 5 : printmsg("May"); break; 1966 case 5 : printmsg("May"); break;
1967 case 6 : printmsg("June"); break; 1967 case 6 : printmsg("June"); break;
1968 case 7 : printmsg("July"); break; 1968 case 7 : printmsg("July"); break;
1969 case 8 : printmsg("August"); break; 1969 case 8 : printmsg("August"); break;
1970 case 9 : printmsg("September"); break; 1970 case 9 : printmsg("September"); break;
1971 case 10: printmsg("October"); break; 1971 case 10: printmsg("October"); break;
1972 case 11: printmsg("November"); break; 1972 case 11: printmsg("November"); break;
1973 case 12: printmsg("December"); break; 1973 case 12: printmsg("December"); break;
1974 default: printmsg("Bad month!"); break; 1974 default: printmsg("Bad month!"); break;
1975 } 1975 }
1976 } else { 1976 } else {
1977 printmsg("each month"); 1977 printmsg("each month");
1978 } 1978 }
1979 } else if (repeat_day > 0) { 1979 } else if (repeat_day > 0) {
1980 printmsg("%d. day of ", repeat_day); 1980 printmsg("%d. day of ", repeat_day);
1981 if (repeat_month > 0) { 1981 if (repeat_month > 0) {
1982 switch(repeat_month) { 1982 switch(repeat_month) {
1983 case 1 : printmsg("January"); break; 1983 case 1 : printmsg("January"); break;
1984 case 2 : printmsg("February"); break; 1984 case 2 : printmsg("February"); break;
1985 case 3 : printmsg("March");break; 1985 case 3 : printmsg("March");break;
1986 case 4 : printmsg("April"); break; 1986 case 4 : printmsg("April"); break;
1987 case 5 : printmsg("May"); break; 1987 case 5 : printmsg("May"); break;
1988 case 6 : printmsg("June"); break; 1988 case 6 : printmsg("June"); break;
1989 case 7 : printmsg("July"); break; 1989 case 7 : printmsg("July"); break;
1990 case 8 : printmsg("August"); break; 1990 case 8 : printmsg("August"); break;
1991 case 9 : printmsg("September"); break; 1991 case 9 : printmsg("September"); break;
1992 case 10: printmsg("October"); break; 1992 case 10: printmsg("October"); break;
1993 case 11: printmsg("November"); break; 1993 case 11: printmsg("November"); break;
1994 case 12: printmsg("December"); break; 1994 case 12: printmsg("December"); break;
1995 default: printmsg("Bad month!");break; 1995 default: printmsg("Bad month!");break;
1996 } 1996 }
1997 } else { 1997 } else {
1998 printmsg("each month"); 1998 printmsg("each month");
1999 } 1999 }
2000 } else { 2000 } else {
2001 printmsg("day"); 2001 printmsg("day");
2002 } 2002 }
2003 } 2003 }
2004 printf("\n"); 2004 printf("\n");
2005 } 2005 }
2006 if (Note->Type == GSM_CAL_BIRTHDAY) { 2006 if (Note->Type == GSM_CAL_BIRTHDAY) {
2007 if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm); 2007 if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm);
2008 if (DateTime.Year != 0) { 2008 if (DateTime.Year != 0) {
2009 i_age = Alarm.Year - DateTime.Year; 2009 i_age = Alarm.Year - DateTime.Year;
2010 if (DateTime.Month < Alarm.Month) i_age++; 2010 if (DateTime.Month < Alarm.Month) i_age++;
2011 if (DateTime.Month == Alarm.Month && 2011 if (DateTime.Month == Alarm.Month &&
2012 DateTime.Day < Alarm.Day) { 2012 DateTime.Day < Alarm.Day) {
2013 i_age++; 2013 i_age++;
2014 } 2014 }
2015 printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years"); 2015 printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years");
2016 } 2016 }
2017 } 2017 }
2018 printf("\n"); 2018 printf("\n");
2019} 2019}
2020 2020
2021static void GetCalendar(int argc, char *argv[]) 2021static void GetCalendar(int argc, char *argv[])
2022{ 2022{
2023 GSM_CalendarEntryNote; 2023 GSM_CalendarEntryNote;
2024 int start,stop; 2024 int start,stop;
2025 2025
2026 GetStartStop(&start, &stop, 2, argc, argv); 2026 GetStartStop(&start, &stop, 2, argc, argv);
2027 2027
2028 GSM_Init(true); 2028 GSM_Init(true);
2029 2029
2030 for (i=start;i<=stop;i++) { 2030 for (i=start;i<=stop;i++) {
2031 Note.Location=i; 2031 Note.Location=i;
2032 error = Phone->GetCalendar(&s, &Note); 2032 error = Phone->GetCalendar(&s, &Note);
2033 if (error == ERR_EMPTY) continue; 2033 if (error == ERR_EMPTY) continue;
2034 Print_Error(error); 2034 Print_Error(error);
2035 PrintCalendar(&Note); 2035 PrintCalendar(&Note);
2036 } 2036 }
2037 2037
2038 GSM_Terminate(); 2038 GSM_Terminate();
2039} 2039}
2040 2040
2041static void DeleteCalendar(int argc, char *argv[]) 2041static void DeleteCalendar(int argc, char *argv[])
2042{ 2042{
2043 GSM_CalendarEntryNote; 2043 GSM_CalendarEntryNote;
2044 int start,stop; 2044 int start,stop;
2045 2045
2046 GetStartStop(&start, &stop, 2, argc, argv); 2046 GetStartStop(&start, &stop, 2, argc, argv);
2047 2047
2048 GSM_Init(true); 2048 GSM_Init(true);
2049 2049
2050 for (i=start;i<=stop;i++) { 2050 for (i=start;i<=stop;i++) {
2051 Note.Location=i; 2051 Note.Location=i;
2052 error = Phone->DeleteCalendar(&s, &Note); 2052 error = Phone->DeleteCalendar(&s, &Note);
2053 if (error == ERR_EMPTY) continue; 2053 if (error == ERR_EMPTY) continue;
2054 Print_Error(error); 2054 Print_Error(error);
2055 PrintCalendar(&Note); 2055 PrintCalendar(&Note);
2056 } 2056 }
2057 2057
2058 GSM_Terminate(); 2058 GSM_Terminate();
2059} 2059}
2060 2060
2061 2061
2062static void GetAllCalendar(int argc, char *argv[]) 2062static void GetAllCalendar(int argc, char *argv[])
2063{ 2063{
2064 GSM_CalendarEntryNote; 2064 GSM_CalendarEntryNote;
2065 bool refresh= true; 2065 bool refresh= true;
2066 2066
2067 signal(SIGINT, interrupt); 2067 signal(SIGINT, interrupt);
2068 printmsgerr("Press Ctrl+C to break...\n"); 2068 printmsgerr("Press Ctrl+C to break...\n");
2069 2069
2070 GSM_Init(true); 2070 GSM_Init(true);
2071 2071
2072 while (!gshutdown) { 2072 while (!gshutdown) {
2073 error=Phone->GetNextCalendar(&s,&Note,refresh); 2073 error=Phone->GetNextCalendar(&s,&Note,refresh);
2074 if (error == ERR_EMPTY) break; 2074 if (error == ERR_EMPTY) break;
2075 Print_Error(error); 2075 Print_Error(error);
2076 PrintCalendar(&Note); 2076 PrintCalendar(&Note);
2077 refresh=false; 2077 refresh=false;
2078 } 2078 }
2079 2079
2080 GSM_Terminate(); 2080 GSM_Terminate();
2081} 2081}
2082 2082
2083static void GetCalendarSettings(int argc, char *argv[]) 2083static void GetCalendarSettings(int argc, char *argv[])
2084{ 2084{
2085 GSM_CalendarSettings settings; 2085 GSM_CalendarSettings settings;
2086 2086
2087 GSM_Init(true); 2087 GSM_Init(true);
2088 2088
2089 error=Phone->GetCalendarSettings(&s,&settings); 2089 error=Phone->GetCalendarSettings(&s,&settings);
2090 Print_Error(error); 2090 Print_Error(error);
2091 2091
2092 if (settings.AutoDelete == 0) { 2092 if (settings.AutoDelete == 0) {
2093 printmsg("Auto deleting disabled"); 2093 printmsg("Auto deleting disabled");
2094 } else { 2094 } else {
2095 printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete); 2095 printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete);
2096 } 2096 }
2097 printmsg("\nWeek start on "); 2097 printmsg("\nWeek start on ");
2098 switch(settings.StartDay) { 2098 switch(settings.StartDay) {
2099 case 1: printmsg("Monday"); break; 2099 case 1: printmsg("Monday"); break;
2100 case 6: printmsg("Saturday"); break; 2100 case 6: printmsg("Saturday"); break;
2101 case 7: printmsg("Sunday"); break; 2101 case 7: printmsg("Sunday"); break;
2102 } 2102 }
2103 printf("\n"); 2103 printf("\n");
2104 2104
2105 GSM_Terminate(); 2105 GSM_Terminate();
2106} 2106}
2107 2107
2108static void GetWAPBookmark(int argc, char *argv[]) 2108static void GetWAPBookmark(int argc, char *argv[])
2109{ 2109{
2110 GSM_WAPBookmark bookmark; 2110 GSM_WAPBookmark bookmark;
2111 int start,stop; 2111 int start,stop;
2112 2112
2113 GetStartStop(&start, &stop, 2, argc, argv); 2113 GetStartStop(&start, &stop, 2, argc, argv);
2114 2114
2115 GSM_Init(true); 2115 GSM_Init(true);
2116 2116
2117 for (i=start;i<=stop;i++) { 2117 for (i=start;i<=stop;i++) {
2118 bookmark.Location=i; 2118 bookmark.Location=i;
2119 error=Phone->GetWAPBookmark(&s,&bookmark); 2119 error=Phone->GetWAPBookmark(&s,&bookmark);
2120 Print_Error(error); 2120 Print_Error(error);
2121 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title)); 2121 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title));
2122 printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address)); 2122 printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address));
2123 } 2123 }
2124 2124
2125 GSM_Terminate(); 2125 GSM_Terminate();
2126} 2126}
2127 2127
2128static void DeleteWAPBookmark(int argc, char *argv[]) 2128static void DeleteWAPBookmark(int argc, char *argv[])
2129{ 2129{
2130 GSM_WAPBookmarkbookmark; 2130 GSM_WAPBookmarkbookmark;
2131 int start, stop; 2131 int start, stop;
2132 2132
2133 GetStartStop(&start, &stop, 2, argc, argv); 2133 GetStartStop(&start, &stop, 2, argc, argv);
2134 2134
2135 GSM_Init(true); 2135 GSM_Init(true);
2136 2136
2137 for (i=start;i<=stop;i++) { 2137 for (i=start;i<=stop;i++) {
2138 bookmark.Location=i; 2138 bookmark.Location=i;
2139 error=Phone->DeleteWAPBookmark(&s, &bookmark); 2139 error=Phone->DeleteWAPBookmark(&s, &bookmark);
2140 Print_Error(error); 2140 Print_Error(error);
2141 } 2141 }
2142 2142
2143 GSM_Terminate(); 2143 GSM_Terminate();
2144} 2144}
2145 2145
2146static void GetGPRSPoint(int argc, char *argv[]) 2146static void GetGPRSPoint(int argc, char *argv[])
2147{ 2147{
2148 GSM_GPRSAccessPointpoint; 2148 GSM_GPRSAccessPointpoint;
2149 int start,stop; 2149 int start,stop;
2150 2150
2151 GetStartStop(&start, &stop, 2, argc, argv); 2151 GetStartStop(&start, &stop, 2, argc, argv);
2152 2152
2153 GSM_Init(true); 2153 GSM_Init(true);
2154 2154
2155 for (i=start;i<=stop;i++) { 2155 for (i=start;i<=stop;i++) {
2156 point.Location=i; 2156 point.Location=i;
2157 error=Phone->GetGPRSAccessPoint(&s,&point); 2157 error=Phone->GetGPRSAccessPoint(&s,&point);
2158 if (error != ERR_EMPTY) { 2158 if (error != ERR_EMPTY) {
2159 Print_Error(error); 2159 Print_Error(error);
2160 printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name)); 2160 printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name));
2161 } else { 2161 } else {
2162 printmsg("%i. Access point %i",point.Location,point.Location); 2162 printmsg("%i. Access point %i",point.Location,point.Location);
2163 } 2163 }
2164 if (point.Active) printmsg(" (active)"); 2164 if (point.Active) printmsg(" (active)");
2165 if (error != ERR_EMPTY) { 2165 if (error != ERR_EMPTY) {
2166 printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL)); 2166 printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL));
2167 } else { 2167 } else {
2168 printmsg("\n\n"); 2168 printmsg("\n\n");
2169 } 2169 }
2170 } 2170 }
2171 2171
2172 GSM_Terminate(); 2172 GSM_Terminate();
2173} 2173}
2174 2174
2175static void GetBitmap(int argc, char *argv[]) 2175static void GetBitmap(int argc, char *argv[])
2176{ 2176{
2177 GSM_File File; 2177 GSM_File File;
2178 GSM_MultiBitmap MultiBitmap; 2178 GSM_MultiBitmap MultiBitmap;
2179 int location=0; 2179 int location=0;
2180 GSM_AllRingtonesInfo Info; 2180 GSM_AllRingtonesInfo Info;
2181 2181
2182 if (mystrncasecmp(argv[2],"STARTUP",0)) { 2182 if (mystrncasecmp(argv[2],"STARTUP",0)) {
2183 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; 2183 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
2184 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2184 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2185 MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo; 2185 MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo;
2186 GetStartStop(&location, NULL, 3, argc, argv); 2186 GetStartStop(&location, NULL, 3, argc, argv);
2187 if (location>5) { 2187 if (location>5) {
2188 printmsg("Maximal location for caller logo can be 5\n"); 2188 printmsg("Maximal location for caller logo can be 5\n");
2189 exit (-1); 2189 exit (-1);
2190 } 2190 }
2191 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2191 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2192 MultiBitmap.Bitmap[0].Type=GSM_PictureImage; 2192 MultiBitmap.Bitmap[0].Type=GSM_PictureImage;
2193 GetStartStop(&location, NULL, 3, argc, argv); 2193 GetStartStop(&location, NULL, 3, argc, argv);
2194 } else if (mystrncasecmp(argv[2],"TEXT",0)) { 2194 } else if (mystrncasecmp(argv[2],"TEXT",0)) {
2195 MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text; 2195 MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text;
2196 } else if (mystrncasecmp(argv[2],"DEALER",0)) { 2196 } else if (mystrncasecmp(argv[2],"DEALER",0)) {
2197 MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text; 2197 MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text;
2198 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2198 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2199 MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo; 2199 MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo;
2200 } else { 2200 } else {
2201 printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]); 2201 printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]);
2202 exit(-1); 2202 exit(-1);
2203 } 2203 }
2204 MultiBitmap.Bitmap[0].Location=location; 2204 MultiBitmap.Bitmap[0].Location=location;
2205 2205
2206 GSM_Init(true); 2206 GSM_Init(true);
2207 2207
2208 error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]); 2208 error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]);
2209 Print_Error(error); 2209 Print_Error(error);
2210 2210
2211 MultiBitmap.Number = 1; 2211 MultiBitmap.Number = 1;
2212 2212
2213 error=ERR_NONE; 2213 error=ERR_NONE;
2214 switch (MultiBitmap.Bitmap[0].Type) { 2214 switch (MultiBitmap.Bitmap[0].Type) {
2215 case GSM_CallerGroupLogo: 2215 case GSM_CallerGroupLogo:
2216 if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2216 if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2217 printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2217 printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2218 if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)"); 2218 if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)");
2219 printf("\n"); 2219 printf("\n");
2220 if (MultiBitmap.Bitmap[0].DefaultRingtone) { 2220 if (MultiBitmap.Bitmap[0].DefaultRingtone) {
2221 printmsg("Ringtone : default\n"); 2221 printmsg("Ringtone : default\n");
2222 } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) { 2222 } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) {
2223 sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID); 2223 sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID);
2224 2224
2225 File.Buffer = NULL; 2225 File.Buffer = NULL;
2226 File.Used = 0; 2226 File.Used = 0;
2227 2227
2228 error = ERR_NONE; 2228 error = ERR_NONE;
2229 // while (error == ERR_NONE) { 2229 // while (error == ERR_NONE) {
2230 error = Phone->GetFilePart(&s,&File); 2230 error = Phone->GetFilePart(&s,&File);
2231 // } 2231 // }
2232 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 2232 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
2233 error = ERR_NONE; 2233 error = ERR_NONE;
2234 2234
2235 printmsg("Ringtone : \"%s\" (file with ID %i)\n", 2235 printmsg("Ringtone : \"%s\" (file with ID %i)\n",
2236 DecodeUnicodeString(File.Name), 2236 DecodeUnicodeString(File.Name),
2237 MultiBitmap.Bitmap[0].RingtoneID); 2237 MultiBitmap.Bitmap[0].RingtoneID);
2238 } else { 2238 } else {
2239 error = Phone->GetRingtonesInfo(&s,&Info); 2239 error = Phone->GetRingtonesInfo(&s,&Info);
2240 if (error != ERR_NONE) Info.Number = 0; 2240 if (error != ERR_NONE) Info.Number = 0;
2241 error = ERR_NONE; 2241 error = ERR_NONE;
2242 2242
2243 printmsg("Ringtone : "); 2243 printmsg("Ringtone : ");
2244 if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) { 2244 if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) {
2245 printmsg("\"%s\" (ID %i)\n", 2245 printmsg("\"%s\" (ID %i)\n",
2246 DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)), 2246 DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)),
2247 MultiBitmap.Bitmap[0].RingtoneID); 2247 MultiBitmap.Bitmap[0].RingtoneID);
2248 } else { 2248 } else {
2249 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID); 2249 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID);
2250 } 2250 }
2251 } 2251 }
2252 if (MultiBitmap.Bitmap[0].BitmapEnabled) { 2252 if (MultiBitmap.Bitmap[0].BitmapEnabled) {
2253 printmsg("Bitmap : enabled\n"); 2253 printmsg("Bitmap : enabled\n");
2254 } else { 2254 } else {
2255 printmsg("Bitmap : disabled\n"); 2255 printmsg("Bitmap : disabled\n");
2256 } 2256 }
2257 if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); 2257 if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
2258 break; 2258 break;
2259 case GSM_StartupLogo: 2259 case GSM_StartupLogo:
2260 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2260 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2261 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); 2261 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
2262 break; 2262 break;
2263 case GSM_OperatorLogo: 2263 case GSM_OperatorLogo:
2264 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) { 2264 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) {
2265 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2265 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2266 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); 2266 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
2267 } else { 2267 } else {
2268 printmsg("No operator logo in phone\n"); 2268 printmsg("No operator logo in phone\n");
2269 } 2269 }
2270 break; 2270 break;
2271 case GSM_PictureImage: 2271 case GSM_PictureImage:
2272 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2272 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2273 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2273 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2274 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender)); 2274 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender));
2275 if (MultiBitmap.Bitmap[0].Name) 2275 if (MultiBitmap.Bitmap[0].Name)
2276 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name)); 2276 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name));
2277 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); 2277 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
2278 break; 2278 break;
2279 case GSM_WelcomeNote_Text: 2279 case GSM_WelcomeNote_Text:
2280 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2280 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2281 break; 2281 break;
2282 case GSM_DealerNote_Text: 2282 case GSM_DealerNote_Text:
2283 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2283 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2284 break; 2284 break;
2285 default: 2285 default:
2286 break; 2286 break;
2287 } 2287 }
2288 Print_Error(error); 2288 Print_Error(error);
2289 2289
2290 GSM_Terminate(); 2290 GSM_Terminate();
2291} 2291}
2292 2292
2293static void SetBitmap(int argc, char *argv[]) 2293static void SetBitmap(int argc, char *argv[])
2294{ 2294{
2295 GSM_Bitmap Bitmap, NewBitmap; 2295 GSM_Bitmap Bitmap, NewBitmap;
2296 GSM_MultiBitmap MultiBitmap; 2296 GSM_MultiBitmap MultiBitmap;
2297 GSM_NetworkInfo NetInfo; 2297 GSM_NetworkInfo NetInfo;
2298 bool init = true; 2298 bool init = true;
2299 2299
2300 if (mystrncasecmp(argv[2],"STARTUP",0)) { 2300 if (mystrncasecmp(argv[2],"STARTUP",0)) {
2301 if (argc<4) { 2301 if (argc<4) {
2302 printmsg("More arguments required\n"); 2302 printmsg("More arguments required\n");
2303 exit(-1); 2303 exit(-1);
2304 } 2304 }
2305 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; 2305 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
2306 MultiBitmap.Bitmap[0].Location=1; 2306 MultiBitmap.Bitmap[0].Location=1;
2307 if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2; 2307 if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2;
2308 if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3; 2308 if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3;
2309 if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4; 2309 if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4;
2310 if (MultiBitmap.Bitmap[0].Location == 1) { 2310 if (MultiBitmap.Bitmap[0].Location == 1) {
2311 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2311 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2312 Print_Error(error); 2312 Print_Error(error);
2313 } 2313 }
2314 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2314 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2315 } else if (mystrncasecmp(argv[2],"TEXT",0)) { 2315 } else if (mystrncasecmp(argv[2],"TEXT",0)) {
2316 if (argc<4) { 2316 if (argc<4) {
2317 printmsg("More arguments required\n"); 2317 printmsg("More arguments required\n");
2318 exit(-1); 2318 exit(-1);
2319 } 2319 }
2320 Bitmap.Type=GSM_WelcomeNote_Text; 2320 Bitmap.Type=GSM_WelcomeNote_Text;
2321 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); 2321 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
2322 } else if (mystrncasecmp(argv[2],"DEALER",0)) { 2322 } else if (mystrncasecmp(argv[2],"DEALER",0)) {
2323 if (argc<4) { 2323 if (argc<4) {
2324 printmsg("More arguments required\n"); 2324 printmsg("More arguments required\n");
2325 exit(-1); 2325 exit(-1);
2326 } 2326 }
2327 Bitmap.Type=GSM_DealerNote_Text; 2327 Bitmap.Type=GSM_DealerNote_Text;
2328 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); 2328 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
2329 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2329 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2330 if (argc<4) { 2330 if (argc<4) {
2331 printmsg("More arguments required\n"); 2331 printmsg("More arguments required\n");
2332 exit(-1); 2332 exit(-1);
2333 } 2333 }
2334 GetStartStop(&i, NULL, 3, argc, argv); 2334 GetStartStop(&i, NULL, 3, argc, argv);
2335 if (i>5 && i!=255) { 2335 if (i>5 && i!=255) {
2336 printmsg("Maximal location for caller logo can be 5\n"); 2336 printmsg("Maximal location for caller logo can be 5\n");
2337 exit (-1); 2337 exit (-1);
2338 } 2338 }
2339 MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo; 2339 MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo;
2340 MultiBitmap.Bitmap[0].Location= i; 2340 MultiBitmap.Bitmap[0].Location= i;
2341 if (argc>4) { 2341 if (argc>4) {
2342 error=GSM_ReadBitmapFile(argv[4],&MultiBitmap); 2342 error=GSM_ReadBitmapFile(argv[4],&MultiBitmap);
2343 Print_Error(error); 2343 Print_Error(error);
2344 } 2344 }
2345 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2345 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2346 if (i!=255) { 2346 if (i!=255) {
2347 GSM_Init(true); 2347 GSM_Init(true);
2348 init = false; 2348 init = false;
2349 NewBitmap.Type = GSM_CallerGroupLogo; 2349 NewBitmap.Type = GSM_CallerGroupLogo;
2350 NewBitmap.Location = i; 2350 NewBitmap.Location = i;
2351 error=Phone->GetBitmap(&s,&NewBitmap); 2351 error=Phone->GetBitmap(&s,&NewBitmap);
2352 Print_Error(error); 2352 Print_Error(error);
2353 Bitmap.RingtoneID = NewBitmap.RingtoneID; 2353 Bitmap.RingtoneID = NewBitmap.RingtoneID;
2354 Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone; 2354 Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone;
2355 Bitmap.FileSystemRingtone = false; 2355 Bitmap.FileSystemRingtone = false;
2356 CopyUnicodeString(Bitmap.Text, NewBitmap.Text); 2356 CopyUnicodeString(Bitmap.Text, NewBitmap.Text);
2357 Bitmap.DefaultName = NewBitmap.DefaultName; 2357 Bitmap.DefaultName = NewBitmap.DefaultName;
2358 } 2358 }
2359 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2359 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2360 if (argc<5) { 2360 if (argc<5) {
2361 printmsg("More arguments required\n"); 2361 printmsg("More arguments required\n");
2362 exit(-1); 2362 exit(-1);
2363 } 2363 }
2364 MultiBitmap.Bitmap[0].Type = GSM_PictureImage; 2364 MultiBitmap.Bitmap[0].Type = GSM_PictureImage;
2365 MultiBitmap.Bitmap[0].Location = atoi(argv[4]); 2365 MultiBitmap.Bitmap[0].Location = atoi(argv[4]);
2366 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2366 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2367 Print_Error(error); 2367 Print_Error(error);
2368 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2368 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2369 Bitmap.Text[0]=0; 2369 Bitmap.Text[0]=0;
2370 Bitmap.Text[1]=0; 2370 Bitmap.Text[1]=0;
2371 if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5])); 2371 if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5]));
2372 Bitmap.Sender[0]=0; 2372 Bitmap.Sender[0]=0;
2373 Bitmap.Sender[1]=0; 2373 Bitmap.Sender[1]=0;
2374 } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) { 2374 } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) {
2375 Bitmap.Type = GSM_ColourOperatorLogo_ID; 2375 Bitmap.Type = GSM_ColourOperatorLogo_ID;
2376 strcpy(Bitmap.NetworkCode,"000 00"); 2376 strcpy(Bitmap.NetworkCode,"000 00");
2377 if (argc > 3) { 2377 if (argc > 3) {
2378 Bitmap.ID = atoi(argv[3]); 2378 Bitmap.ID = atoi(argv[3]);
2379 if (argc>4) { 2379 if (argc>4) {
2380 strncpy(Bitmap.NetworkCode,argv[4],6); 2380 strncpy(Bitmap.NetworkCode,argv[4],6);
2381 } else { 2381 } else {
2382 GSM_Init(true); 2382 GSM_Init(true);
2383 init = false; 2383 init = false;
2384 error=Phone->GetNetworkInfo(&s,&NetInfo); 2384 error=Phone->GetNetworkInfo(&s,&NetInfo);
2385 Print_Error(error); 2385 Print_Error(error);
2386 strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode); 2386 strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode);
2387 } 2387 }
2388 } 2388 }
2389 } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) { 2389 } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) {
2390 Bitmap.Type = GSM_ColourStartupLogo_ID; 2390 Bitmap.Type = GSM_ColourStartupLogo_ID;
2391 Bitmap.Location = 0; 2391 Bitmap.Location = 0;
2392 if (argc > 3) { 2392 if (argc > 3) {
2393 Bitmap.Location = 1; 2393 Bitmap.Location = 1;
2394 Bitmap.ID = atoi(argv[3]); 2394 Bitmap.ID = atoi(argv[3]);
2395 } 2395 }
2396 } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) { 2396 } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) {
2397 Bitmap.Type = GSM_ColourWallPaper_ID; 2397 Bitmap.Type = GSM_ColourWallPaper_ID;
2398 Bitmap.ID = 0; 2398 Bitmap.ID = 0;
2399 if (argc > 3) Bitmap.ID = atoi(argv[3]); 2399 if (argc > 3) Bitmap.ID = atoi(argv[3]);
2400 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2400 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2401 MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo; 2401 MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo;
2402 MultiBitmap.Bitmap[0].Location = 1; 2402 MultiBitmap.Bitmap[0].Location = 1;
2403 strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00"); 2403 strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00");
2404 if (argc>3) { 2404 if (argc>3) {
2405 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2405 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2406 Print_Error(error); 2406 Print_Error(error);
2407 if (argc>4) { 2407 if (argc>4) {
2408 strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6); 2408 strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6);
2409 } else { 2409 } else {
2410 GSM_Init(true); 2410 GSM_Init(true);
2411 init = false; 2411 init = false;
2412 error=Phone->GetNetworkInfo(&s,&NetInfo); 2412 error=Phone->GetNetworkInfo(&s,&NetInfo);
2413 Print_Error(error); 2413 Print_Error(error);
2414 strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode); 2414 strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode);
2415 } 2415 }
2416 } 2416 }
2417 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2417 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2418 } else { 2418 } else {
2419 printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]); 2419 printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]);
2420 exit(-1); 2420 exit(-1);
2421 } 2421 }
2422 2422
2423 if (init) GSM_Init(true); 2423 if (init) GSM_Init(true);
2424 2424
2425 error=Phone->SetBitmap(&s,&Bitmap); 2425 error=Phone->SetBitmap(&s,&Bitmap);
2426 Print_Error(error); 2426 Print_Error(error);
2427 2427
2428#ifdef GSM_ENABLE_BEEP 2428#ifdef GSM_ENABLE_BEEP
2429 GSM_PhoneBeep(); 2429 GSM_PhoneBeep();
2430#endif 2430#endif
2431 2431
2432 GSM_Terminate(); 2432 GSM_Terminate();
2433} 2433}
2434 2434
2435static void SetRingtone(int argc, char *argv[]) 2435static void SetRingtone(int argc, char *argv[])
2436{ 2436{
2437 GSM_Ringtone ringtone; 2437 GSM_Ringtone ringtone;
2438 int i,nextlong=0; 2438 int i,nextlong=0;
2439 2439
2440 ringtone.Format= 0; 2440 ringtone.Format= 0;
2441 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 2441 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
2442 Print_Error(error); 2442 Print_Error(error);
2443 ringtone.Location = 255; 2443 ringtone.Location = 255;
2444 for (i=3;i<argc;i++) { 2444 for (i=3;i<argc;i++) {
2445 switch (nextlong) { 2445 switch (nextlong) {
2446 case 0: 2446 case 0:
2447 if (mystrncasecmp(argv[i],"-scale",0)) { 2447 if (mystrncasecmp(argv[i],"-scale",0)) {
2448 ringtone.NoteTone.AllNotesScale = true; 2448 ringtone.NoteTone.AllNotesScale = true;
2449 break; 2449 break;
2450 } 2450 }
2451 if (mystrncasecmp(argv[i],"-location",0)) { 2451 if (mystrncasecmp(argv[i],"-location",0)) {
2452 nextlong = 1; 2452 nextlong = 1;
2453 break; 2453 break;
2454 } 2454 }
2455 if (mystrncasecmp(argv[i],"-name",0)) { 2455 if (mystrncasecmp(argv[i],"-name",0)) {
2456 nextlong = 2; 2456 nextlong = 2;
2457 break; 2457 break;
2458 } 2458 }
2459 printmsg("Unknown parameter \"%s\"",argv[i]); 2459 printmsg("Unknown parameter \"%s\"",argv[i]);
2460 exit(-1); 2460 exit(-1);
2461 case 1: 2461 case 1:
2462 ringtone.Location=atoi(argv[i]); 2462 ringtone.Location=atoi(argv[i]);
2463 nextlong = 0; 2463 nextlong = 0;
2464 break; 2464 break;
2465 case 2: 2465 case 2:
2466 EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i])); 2466 EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i]));
2467 nextlong = 0; 2467 nextlong = 0;
2468 break; 2468 break;
2469 } 2469 }
2470 } 2470 }
2471 if (nextlong!=0) { 2471 if (nextlong!=0) {
2472 printmsg("Parameter missed...\n"); 2472 printmsg("Parameter missed...\n");
2473 exit(-1); 2473 exit(-1);
2474 } 2474 }
2475 if (ringtone.Location==0) { 2475 if (ringtone.Location==0) {
2476 printmsg("ERROR: enumerate locations from 1\n"); 2476 printmsg("ERROR: enumerate locations from 1\n");
2477 exit (-1); 2477 exit (-1);
2478 } 2478 }
2479 2479
2480 GSM_Init(true); 2480 GSM_Init(true);
2481 error=Phone->SetRingtone(&s, &ringtone, &i); 2481 error=Phone->SetRingtone(&s, &ringtone, &i);
2482 Print_Error(error); 2482 Print_Error(error);
2483#ifdef GSM_ENABLE_BEEP 2483#ifdef GSM_ENABLE_BEEP
2484 GSM_PhoneBeep(); 2484 GSM_PhoneBeep();
2485#endif 2485#endif
2486 GSM_Terminate(); 2486 GSM_Terminate();
2487} 2487}
2488 2488
2489static void DisplaySMSFrame(GSM_SMSMessage *SMS) 2489static void DisplaySMSFrame(GSM_SMSMessage *SMS)
2490{ 2490{
2491 GSM_Error error; 2491 GSM_Error error;
2492 int i, length, current = 0; 2492 int i, length, current = 0;
2493 unsigned char req[1000], buffer[1000], hexreq[1000]; 2493 unsigned char req[1000], buffer[1000], hexreq[1000];
2494#ifdef OSCAR 2494#ifdef OSCAR
2495 unsigned char hexmsg[1000], hexudh[1000]; 2495 unsigned char hexmsg[1000], hexudh[1000];
2496#endif 2496#endif
2497 error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true); 2497 error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true);
2498 if (error != ERR_NONE) { 2498 if (error != ERR_NONE) {
2499 printmsg("Error\n"); 2499 printmsg("Error\n");
2500 exit(-1); 2500 exit(-1);
2501 } 2501 }
2502 length = length - PHONE_SMSSubmit.Text; 2502 length = length - PHONE_SMSSubmit.Text;
2503#ifdef OSCAR 2503#ifdef OSCAR
2504 for(i=SMS->UDH.Length;i<length;i++) { 2504 for(i=SMS->UDH.Length;i<length;i++) {
2505 req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i]; 2505 req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i];
2506 } 2506 }
2507 EncodeHexBin(hexmsg, req, length-SMS->UDH.Length); 2507 EncodeHexBin(hexmsg, req, length-SMS->UDH.Length);
2508 2508
2509 for(i=0;i<SMS->UDH.Length;i++) { 2509 for(i=0;i<SMS->UDH.Length;i++) {
2510 req[i]=buffer[PHONE_SMSSubmit.Text+i]; 2510 req[i]=buffer[PHONE_SMSSubmit.Text+i];
2511 } 2511 }
2512 EncodeHexBin(hexudh, req, SMS->UDH.Length); 2512 EncodeHexBin(hexudh, req, SMS->UDH.Length);
2513 2513
2514 printf("msg:%s nb:%i udh:%s\n", 2514 printf("msg:%s nb:%i udh:%s\n",
2515 hexmsg, 2515 hexmsg,
2516 (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8, 2516 (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8,
2517 hexudh); 2517 hexudh);
2518#else 2518#else
2519 for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) { 2519 for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) {
2520 req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i]; 2520 req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i];
2521 } 2521 }
2522 req[current++]=buffer[PHONE_SMSSubmit.firstbyte]; 2522 req[current++]=buffer[PHONE_SMSSubmit.firstbyte];
2523 req[current++]=buffer[PHONE_SMSSubmit.TPMR]; 2523 req[current++]=buffer[PHONE_SMSSubmit.TPMR];
2524 for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) { 2524 for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) {
2525 req[current++]=buffer[PHONE_SMSSubmit.Number+i]; 2525 req[current++]=buffer[PHONE_SMSSubmit.Number+i];
2526 } 2526 }
2527 req[current++]=buffer[PHONE_SMSSubmit.TPPID]; 2527 req[current++]=buffer[PHONE_SMSSubmit.TPPID];
2528 req[current++]=buffer[PHONE_SMSSubmit.TPDCS]; 2528 req[current++]=buffer[PHONE_SMSSubmit.TPDCS];
2529 req[current++]=buffer[PHONE_SMSSubmit.TPVP]; 2529 req[current++]=buffer[PHONE_SMSSubmit.TPVP];
2530 req[current++]=buffer[PHONE_SMSSubmit.TPUDL]; 2530 req[current++]=buffer[PHONE_SMSSubmit.TPUDL];
2531 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i]; 2531 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i];
2532 EncodeHexBin(hexreq, req, current); 2532 EncodeHexBin(hexreq, req, current);
2533 printmsg("%s\n\n",hexreq); 2533 printmsg("%s\n\n",hexreq);
2534#endif 2534#endif
2535} 2535}
2536 2536
2537#define SEND_SAVE_SMS_BUFFER_SIZE 10000 2537#define SEND_SAVE_SMS_BUFFER_SIZE 10000
2538 2538
2539static GSM_Error SMSStatus; 2539static GSM_Error SMSStatus;
2540 2540
2541static void SendSMSStatus (char *Device, int status, int MessageReference) 2541static void SendSMSStatus (char *Device, int status, int MessageReference)
2542{ 2542{
2543 dbgprintf("Sent SMS on device: \"%s\"\n",Device); 2543 dbgprintf("Sent SMS on device: \"%s\"\n",Device);
2544 if (status==0) { 2544 if (status==0) {
2545 printmsg("..OK"); 2545 printmsg("..OK");
2546 SMSStatus = ERR_NONE; 2546 SMSStatus = ERR_NONE;
2547 } else { 2547 } else {
2548 printmsg("..error %i",status); 2548 printmsg("..error %i",status);
2549 SMSStatus = ERR_UNKNOWN; 2549 SMSStatus = ERR_UNKNOWN;
2550 } 2550 }
2551 printmsg(", message reference=%d\n",MessageReference); 2551 printmsg(", message reference=%d\n",MessageReference);
2552} 2552}
2553 2553
2554static void SendSaveDisplaySMS(int argc, char *argv[]) 2554static void SendSaveDisplaySMS(int argc, char *argv[])
2555{ 2555{
2556#ifdef GSM_ENABLE_BACKUP 2556#ifdef GSM_ENABLE_BACKUP
2557 GSM_Backup Backup; 2557 GSM_Backup Backup;
2558#endif 2558#endif
2559 int i,j,z,FramesNum = 0; 2559 int i,j,z,FramesNum = 0;
2560 int Protected = 0; 2560 int Protected = 0;
2561 GSM_SMSFolders folders; 2561 GSM_SMSFolders folders;
2562 GSM_MultiSMSMessage sms; 2562 GSM_MultiSMSMessage sms;
2563 GSM_Ringtone ringtone[MAX_MULTI_SMS]; 2563 GSM_Ringtone ringtone[MAX_MULTI_SMS];
2564 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2; 2564 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2;
2565 GSM_MultiPartSMSInfo SMSInfo; 2565 GSM_MultiPartSMSInfo SMSInfo;
2566 GSM_NetworkInfo NetInfo; 2566 GSM_NetworkInfo NetInfo;
2567 GSM_MMSIndicator MMSInfo; 2567 GSM_MMSIndicator MMSInfo;
2568 FILE *ReplaceFile,*f; 2568 FILE *ReplaceFile,*f;
2569 char ReplaceBuffer2[200],ReplaceBuffer[200]; 2569 char ReplaceBuffer2[200],ReplaceBuffer[200];
2570 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1]; 2570 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1];
2571 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE]; 2571 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE];
2572 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2572 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2];
2573 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2573 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2];
2574 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2574 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2];
2575 int startarg = 0; 2575 int startarg = 0;
2576 int chars_read = 0; 2576 int chars_read = 0;
2577 int nextlong = 0; 2577 int nextlong = 0;
2578 bool ReplyViaSameSMSC = false; 2578 bool ReplyViaSameSMSC = false;
2579 int SMSCSet = 1; 2579 int SMSCSet = 1;
2580 int MaxSMS = -1; 2580 int MaxSMS = -1;
2581 bool EMS16Bit = false; 2581 bool EMS16Bit = false;
2582 bool SendSaved = false; 2582 bool SendSaved = false;
2583 2583
2584 /* Parameters required only during saving */ 2584 /* Parameters required only during saving */
2585 int Folder = 1; /*Inbox by default */ 2585 int Folder = 1; /*Inbox by default */
2586 GSM_SMS_State State = SMS_Sent; 2586 GSM_SMS_State State = SMS_Sent;
2587 2587
2588 /* Required only during sending */ 2588 /* Required only during sending */
2589 GSM_SMSValidity Validity; 2589 GSM_SMSValidity Validity;
2590 GSM_SMSC PhoneSMSC; 2590 GSM_SMSC PhoneSMSC;
2591 bool DeliveryReport = false; 2591 bool DeliveryReport = false;
2592 2592
2593 ReplaceBuffer[0] = 0; 2593 ReplaceBuffer[0] = 0;
2594 ReplaceBuffer[1] = 0; 2594 ReplaceBuffer[1] = 0;
2595 GSM_ClearMultiPartSMSInfo(&SMSInfo); 2595 GSM_ClearMultiPartSMSInfo(&SMSInfo);
2596 SMSInfo.ReplaceMessage = 0; 2596 SMSInfo.ReplaceMessage = 0;
2597 SMSInfo.EntriesNum = 1; 2597 SMSInfo.EntriesNum = 1;
2598 2598
2599 if (mystrncasecmp(argv[1],"--savesms",0)) { 2599 if (mystrncasecmp(argv[1],"--savesms",0)) {
2600 EncodeUnicode(Sender,"Gammu",5); 2600 EncodeUnicode(Sender,"Gammu",5);
2601 Name[0] = 0; 2601 Name[0] = 0;
2602 Name[1] = 0; 2602 Name[1] = 0;
2603 startarg = 0; 2603 startarg = 0;
2604 } else { 2604 } else {
2605 EncodeUnicode(Sender,argv[3],strlen(argv[3])); 2605 EncodeUnicode(Sender,argv[3],strlen(argv[3]));
2606 startarg = 1; 2606 startarg = 1;
2607 Validity.Format = 0; 2607 Validity.Format = 0;
2608 } 2608 }
2609 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { 2609 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
2610 startarg=startarg+2; 2610 startarg=startarg+2;
2611 EncodeUnicode(SMSC,"1234",4); 2611 EncodeUnicode(SMSC,"1234",4);
2612 SMSCSet= 0; 2612 SMSCSet= 0;
2613 } 2613 }
2614 2614
2615 if (mystrncasecmp(argv[2],"TEXT",0)) { 2615 if (mystrncasecmp(argv[2],"TEXT",0)) {
2616 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin); 2616 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin);
2617 if (chars_read == 0) printmsg("Warning: 0 chars read !\n"); 2617 if (chars_read == 0) printmsg("Warning: 0 chars read !\n");
2618 InputBuffer[chars_read] = 0x00; 2618 InputBuffer[chars_read] = 0x00;
2619 InputBuffer[chars_read+1] = 0x00; 2619 InputBuffer[chars_read+1] = 0x00;
2620 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer)); 2620 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer));
2621 SMSInfo.Entries[0].Buffer = Buffer[0]; 2621 SMSInfo.Entries[0].Buffer = Buffer[0];
2622 SMSInfo.Entries[0].ID = SMS_Text; 2622 SMSInfo.Entries[0].ID = SMS_Text;
2623 SMSInfo.UnicodeCoding = false; 2623 SMSInfo.UnicodeCoding = false;
2624 startarg += 3; 2624 startarg += 3;
2625 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { 2625 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
2626 SMSInfo.UnicodeCoding = false; 2626 SMSInfo.UnicodeCoding = false;
2627 SMSInfo.EntriesNum = 1; 2627 SMSInfo.EntriesNum = 1;
2628 Buffer[0][0] = 0x00; 2628 Buffer[0][0] = 0x00;
2629 Buffer[0][1] = 0x00; 2629 Buffer[0][1] = 0x00;
2630 SMSInfo.Entries[0].Buffer = Buffer[0]; 2630 SMSInfo.Entries[0].Buffer = Buffer[0];
2631 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName; 2631 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName;
2632 startarg += 3; 2632 startarg += 3;
2633 } else if (mystrncasecmp(argv[2],"EMS",0)) { 2633 } else if (mystrncasecmp(argv[2],"EMS",0)) {
2634 SMSInfo.UnicodeCoding = false; 2634 SMSInfo.UnicodeCoding = false;
2635 SMSInfo.EntriesNum = 0; 2635 SMSInfo.EntriesNum = 0;
2636 startarg += 3; 2636 startarg += 3;
2637 } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) { 2637 } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) {
2638 if (argc<6+startarg) { 2638 if (argc<6+startarg) {
2639 printmsg("Where are parameters ?\n"); 2639 printmsg("Where are parameters ?\n");
2640 exit(-1); 2640 exit(-1);
2641 } 2641 }
2642 SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong; 2642 SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong;
2643 SMSInfo.Entries[0].MMSIndicator = &MMSInfo; 2643 SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
2644 if (mystrncasecmp(argv[1],"--savesms",0)) { 2644 if (mystrncasecmp(argv[1],"--savesms",0)) {
2645 EncodeUnicode(Sender,"MMS Info",8); 2645 EncodeUnicode(Sender,"MMS Info",8);
2646 } 2646 }
2647 strcpy(MMSInfo.Address,argv[3+startarg]); 2647 strcpy(MMSInfo.Address,argv[3+startarg]);
2648 strcpy(MMSInfo.Title,argv[4+startarg]); 2648 strcpy(MMSInfo.Title,argv[4+startarg]);
2649 strcpy(MMSInfo.Sender,argv[5+startarg]); 2649 strcpy(MMSInfo.Sender,argv[5+startarg]);
2650 startarg += 6; 2650 startarg += 6;
2651 } else if (mystrncasecmp(argv[2],"WAPINDICATOR",0)) { 2651 } else if (mystrncasecmp(argv[2],"WAPINDICATOR",0)) {
2652 if (argc<5+startarg) { 2652 if (argc<5+startarg) {
2653 printmsg("Where are parameters ?\n"); 2653 printmsg("Where are parameters ?\n");
2654 exit(-1); 2654 exit(-1);
2655 } 2655 }
2656 SMSInfo.Entries[0].ID = SMS_WAPIndicatorLong; 2656 SMSInfo.Entries[0].ID = SMS_WAPIndicatorLong;
2657 SMSInfo.Entries[0].MMSIndicator = &MMSInfo; 2657 SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
2658 if (mystrncasecmp(argv[1],"--savesms",0)) { 2658 if (mystrncasecmp(argv[1],"--savesms",0)) {
2659 EncodeUnicode(Sender,"WAP Info",8); 2659 EncodeUnicode(Sender,"WAP Info",8);
2660 } 2660 }
2661 strcpy(MMSInfo.Address,argv[3+startarg]); 2661 strcpy(MMSInfo.Address,argv[3+startarg]);
2662 strcpy(MMSInfo.Title,argv[4+startarg]); 2662 strcpy(MMSInfo.Title,argv[4+startarg]);
2663 startarg += 5; 2663 startarg += 5;
2664 } else if (mystrncasecmp(argv[2],"RINGTONE",0)) { 2664 } else if (mystrncasecmp(argv[2],"RINGTONE",0)) {
2665 if (argc<4+startarg) { 2665 if (argc<4+startarg) {
2666 printmsg("Where is ringtone filename ?\n"); 2666 printmsg("Where is ringtone filename ?\n");
2667 exit(-1); 2667 exit(-1);
2668 } 2668 }
2669 ringtone[0].Format=RING_NOTETONE; 2669 ringtone[0].Format=RING_NOTETONE;
2670 error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]); 2670 error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]);
2671 Print_Error(error); 2671 Print_Error(error);
2672 SMSInfo.Entries[0].ID = SMS_NokiaRingtone; 2672 SMSInfo.Entries[0].ID = SMS_NokiaRingtone;
2673 SMSInfo.Entries[0].Ringtone = &ringtone[0]; 2673 SMSInfo.Entries[0].Ringtone = &ringtone[0];
2674 if (mystrncasecmp(argv[1],"--savesms",0)) { 2674 if (mystrncasecmp(argv[1],"--savesms",0)) {
2675 CopyUnicodeString(Sender, ringtone[0].Name); 2675 CopyUnicodeString(Sender, ringtone[0].Name);
2676 EncodeUnicode(Name,"Ringtone ",9); 2676 EncodeUnicode(Name,"Ringtone ",9);
2677 CopyUnicodeString(Name+9*2, ringtone[0].Name); 2677 CopyUnicodeString(Name+9*2, ringtone[0].Name);
2678 } 2678 }
2679 startarg += 4; 2679 startarg += 4;
2680 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2680 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2681 if (argc<4+startarg) { 2681 if (argc<4+startarg) {
2682 printmsg("Where is logo filename ?\n"); 2682 printmsg("Where is logo filename ?\n");
2683 exit(-1); 2683 exit(-1);
2684 } 2684 }
2685 bitmap[0].Bitmap[0].Type=GSM_OperatorLogo; 2685 bitmap[0].Bitmap[0].Type=GSM_OperatorLogo;
2686 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); 2686 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
2687 Print_Error(error); 2687 Print_Error(error);
2688 strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00"); 2688 strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00");
2689 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo; 2689 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo;
2690 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2690 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2691 if (mystrncasecmp(argv[1],"--savesms",0)) { 2691 if (mystrncasecmp(argv[1],"--savesms",0)) {
2692 EncodeUnicode(Sender, "OpLogo",6); 2692 EncodeUnicode(Sender, "OpLogo",6);
2693 EncodeUnicode(Name,"OpLogo ",7); 2693 EncodeUnicode(Name,"OpLogo ",7);
2694 } 2694 }
2695 startarg += 4; 2695 startarg += 4;
2696 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2696 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2697 if (argc<4+startarg) { 2697 if (argc<4+startarg) {
2698 printmsg("Where is logo filename ?\n"); 2698 printmsg("Where is logo filename ?\n");
2699 exit(-1); 2699 exit(-1);
2700 } 2700 }
2701 bitmap[0].Bitmap[0].Type=GSM_CallerGroupLogo; 2701 bitmap[0].Bitmap[0].Type=GSM_CallerGroupLogo;
2702 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); 2702 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
2703 Print_Error(error); 2703 Print_Error(error);
2704 SMSInfo.Entries[0].ID = SMS_NokiaCallerLogo; 2704 SMSInfo.Entries[0].ID = SMS_NokiaCallerLogo;
2705 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2705 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2706 if (mystrncasecmp(argv[1],"--savesms",0)) { 2706 if (mystrncasecmp(argv[1],"--savesms",0)) {
2707 EncodeUnicode(Sender, "Caller",6); 2707 EncodeUnicode(Sender, "Caller",6);
2708 } 2708 }
2709 startarg += 4; 2709 startarg += 4;
2710 } else if (mystrncasecmp(argv[2],"ANIMATION",0)) { 2710 } else if (mystrncasecmp(argv[2],"ANIMATION",0)) {
2711 SMSInfo.UnicodeCoding = false; 2711 SMSInfo.UnicodeCoding = false;
2712 SMSInfo.EntriesNum = 1; 2712 SMSInfo.EntriesNum = 1;
2713 if (argc<4+startarg) { 2713 if (argc<4+startarg) {
2714 printmsg("Where is number of frames ?\n"); 2714 printmsg("Where is number of frames ?\n");
2715 exit(-1); 2715 exit(-1);
2716 } 2716 }
2717 bitmap[0].Number = 0; 2717 bitmap[0].Number = 0;
2718 i = 1; 2718 i = 1;
2719 while (1) { 2719 while (1) {
2720 bitmap2.Bitmap[0].Type=GSM_StartupLogo; 2720 bitmap2.Bitmap[0].Type=GSM_StartupLogo;
2721 error=GSM_ReadBitmapFile(argv[3+startarg+i],&bitmap2); 2721 error=GSM_ReadBitmapFile(argv[3+startarg+i],&bitmap2);
2722 Print_Error(error); 2722 Print_Error(error);
2723 for (j=0;j<bitmap2.Number;j++) { 2723 for (j=0;j<bitmap2.Number;j++) {
2724 if (bitmap[0].Number == atoi(argv[3+startarg])) break; 2724 if (bitmap[0].Number == atoi(argv[3+startarg])) break;
2725 memcpy(&bitmap[0].Bitmap[bitmap[0].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); 2725 memcpy(&bitmap[0].Bitmap[bitmap[0].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap));
2726 bitmap[0].Number++; 2726 bitmap[0].Number++;
2727 } 2727 }
2728 if (bitmap[0].Number == atoi(argv[3+startarg])) break; 2728 if (bitmap[0].Number == atoi(argv[3+startarg])) break;
2729 i++; 2729 i++;
2730 } 2730 }
2731 SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong; 2731 SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong;
2732 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2732 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2733 bitmap[0].Bitmap[0].Text[0]= 0; 2733 bitmap[0].Bitmap[0].Text[0]= 0;
2734 bitmap[0].Bitmap[0].Text[1]= 0; 2734 bitmap[0].Bitmap[0].Text[1]= 0;
2735 startarg += 4 + atoi(argv[3+startarg]); 2735 startarg += 4 + atoi(argv[3+startarg]);
2736 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2736 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2737 if (argc<4+startarg) { 2737 if (argc<4+startarg) {
2738 printmsg("Where is logo filename ?\n"); 2738 printmsg("Where is logo filename ?\n");
2739 exit(-1); 2739 exit(-1);
2740 } 2740 }
2741 bitmap[0].Bitmap[0].Type=GSM_PictureImage; 2741 bitmap[0].Bitmap[0].Type=GSM_PictureImage;
2742 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); 2742 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
2743 printmsg("File \"%s\"\n",argv[3+startarg]); 2743 printmsg("File \"%s\"\n",argv[3+startarg]);
2744 Print_Error(error); 2744 Print_Error(error);
2745 SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong; 2745 SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong;
2746 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2746 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2747 SMSInfo.UnicodeCoding = false; 2747 SMSInfo.UnicodeCoding = false;
2748 bitmap[0].Bitmap[0].Text[0]= 0; 2748 bitmap[0].Bitmap[0].Text[0]= 0;
2749 bitmap[0].Bitmap[0].Text[1]= 0; 2749 bitmap[0].Bitmap[0].Text[1]= 0;
2750 if (mystrncasecmp(argv[1],"--savesms",0)) { 2750 if (mystrncasecmp(argv[1],"--savesms",0)) {
2751 EncodeUnicode(Sender, "Picture",7); 2751 EncodeUnicode(Sender, "Picture",7);
2752 EncodeUnicode(Name,"Picture Image",13); 2752 EncodeUnicode(Name,"Picture Image",13);
2753 } 2753 }
2754 startarg += 4; 2754 startarg += 4;
2755#ifdef GSM_ENABLE_BACKUP 2755#ifdef GSM_ENABLE_BACKUP
2756 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { 2756 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
2757 if (argc<5+startarg) { 2757 if (argc<5+startarg) {
2758 printmsg("Where is backup filename and location ?\n"); 2758 printmsg("Where is backup filename and location ?\n");
2759 exit(-1); 2759 exit(-1);
2760 } 2760 }
2761 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2761 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2762 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 2762 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2763 i = 0; 2763 i = 0;
2764 while (Backup.WAPBookmark[i]!=NULL) { 2764 while (Backup.WAPBookmark[i]!=NULL) {
2765 if (i == atoi(argv[4+startarg])-1) break; 2765 if (i == atoi(argv[4+startarg])-1) break;
2766 i++; 2766 i++;
2767 } 2767 }
2768 if (i != atoi(argv[4+startarg])-1) { 2768 if (i != atoi(argv[4+startarg])-1) {
2769 printmsg("Bookmark not found in file\n"); 2769 printmsg("Bookmark not found in file\n");
2770 exit(-1); 2770 exit(-1);
2771 } 2771 }
2772 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong; 2772 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
2773 SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i]; 2773 SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i];
2774 if (mystrncasecmp(argv[1],"--savesms",0)) { 2774 if (mystrncasecmp(argv[1],"--savesms",0)) {
2775 EncodeUnicode(Sender, "Bookmark",8); 2775 EncodeUnicode(Sender, "Bookmark",8);
2776 EncodeUnicode(Name,"WAP Bookmark",12); 2776 EncodeUnicode(Name,"WAP Bookmark",12);
2777 } 2777 }
2778 startarg += 5; 2778 startarg += 5;
2779 } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) { 2779 } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) {
2780 if (argc<6+startarg) { 2780 if (argc<6+startarg) {
2781 printmsg("Where is backup filename and location ?\n"); 2781 printmsg("Where is backup filename and location ?\n");
2782 exit(-1); 2782 exit(-1);
2783 } 2783 }
2784 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2784 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2785 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 2785 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2786 i = 0; 2786 i = 0;
2787 while (Backup.WAPSettings[i]!=NULL) { 2787 while (Backup.WAPSettings[i]!=NULL) {
2788 if (i == atoi(argv[4+startarg])-1) break; 2788 if (i == atoi(argv[4+startarg])-1) break;
2789 i++; 2789 i++;
2790 } 2790 }
2791 if (i != atoi(argv[4+startarg])-1) { 2791 if (i != atoi(argv[4+startarg])-1) {
2792 printmsg("WAP settings not found in file\n"); 2792 printmsg("WAP settings not found in file\n");
2793 exit(-1); 2793 exit(-1);
2794 } 2794 }
2795 SMSInfo.Entries[0].Settings = NULL; 2795 SMSInfo.Entries[0].Settings = NULL;
2796 for (j=0;j<Backup.WAPSettings[i]->Number;j++) { 2796 for (j=0;j<Backup.WAPSettings[i]->Number;j++) {
2797 switch (Backup.WAPSettings[i]->Settings[j].Bearer) { 2797 switch (Backup.WAPSettings[i]->Settings[j].Bearer) {
2798 case WAPSETTINGS_BEARER_GPRS: 2798 case WAPSETTINGS_BEARER_GPRS:
2799 if (mystrncasecmp(argv[5+startarg],"GPRS",0)) { 2799 if (mystrncasecmp(argv[5+startarg],"GPRS",0)) {
2800 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; 2800 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
2801 break; 2801 break;
2802 } 2802 }
2803 case WAPSETTINGS_BEARER_DATA: 2803 case WAPSETTINGS_BEARER_DATA:
2804 if (mystrncasecmp(argv[5+startarg],"DATA",0)) { 2804 if (mystrncasecmp(argv[5+startarg],"DATA",0)) {
2805 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; 2805 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
2806 break; 2806 break;
2807 } 2807 }
2808 default: 2808 default:
2809 break; 2809 break;
2810 } 2810 }
2811 } 2811 }
2812 if (SMSInfo.Entries[0].Settings == NULL) { 2812 if (SMSInfo.Entries[0].Settings == NULL) {
2813 printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n"); 2813 printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n");
2814 exit(-1); 2814 exit(-1);
2815 } 2815 }
2816 SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong; 2816 SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong;
2817 if (mystrncasecmp(argv[1],"--savesms",0)) { 2817 if (mystrncasecmp(argv[1],"--savesms",0)) {
2818 EncodeUnicode(Sender, "Settings",8); 2818 EncodeUnicode(Sender, "Settings",8);
2819 EncodeUnicode(Name,"WAP Settings",12); 2819 EncodeUnicode(Name,"WAP Settings",12);
2820 } 2820 }
2821 startarg += 6; 2821 startarg += 6;
2822 } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) { 2822 } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) {
2823 if (argc<5+startarg) { 2823 if (argc<5+startarg) {
2824 printmsg("Where is backup filename and location ?\n"); 2824 printmsg("Where is backup filename and location ?\n");
2825 exit(-1); 2825 exit(-1);
2826 } 2826 }
2827 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2827 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2828 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 2828 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2829 i = 0; 2829 i = 0;
2830 while (Backup.MMSSettings[i]!=NULL) { 2830 while (Backup.MMSSettings[i]!=NULL) {
2831 if (i == atoi(argv[4+startarg])-1) break; 2831 if (i == atoi(argv[4+startarg])-1) break;
2832 i++; 2832 i++;
2833 } 2833 }
2834 if (i != atoi(argv[4+startarg])-1) { 2834 if (i != atoi(argv[4+startarg])-1) {
2835 printmsg("MMS settings not found in file\n"); 2835 printmsg("MMS settings not found in file\n");
2836 exit(-1); 2836 exit(-1);
2837 } 2837 }
2838 SMSInfo.Entries[0].Settings = NULL; 2838 SMSInfo.Entries[0].Settings = NULL;
2839 for (j=0;j<Backup.MMSSettings[i]->Number;j++) { 2839 for (j=0;j<Backup.MMSSettings[i]->Number;j++) {
2840 switch (Backup.MMSSettings[i]->Settings[j].Bearer) { 2840 switch (Backup.MMSSettings[i]->Settings[j].Bearer) {
2841 case WAPSETTINGS_BEARER_GPRS: 2841 case WAPSETTINGS_BEARER_GPRS:
2842 SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j]; 2842 SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j];
2843 break; 2843 break;
2844 default: 2844 default:
2845 break; 2845 break;
2846 } 2846 }
2847 } 2847 }
2848 if (SMSInfo.Entries[0].Settings == NULL) { 2848 if (SMSInfo.Entries[0].Settings == NULL) {
2849 printmsg("Sorry. No GPRS bearer found in MMS settings\n"); 2849 printmsg("Sorry. No GPRS bearer found in MMS settings\n");
2850 exit(-1); 2850 exit(-1);
2851 } 2851 }
2852 SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong; 2852 SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong;
2853 if (mystrncasecmp(argv[1],"--savesms",0)) { 2853 if (mystrncasecmp(argv[1],"--savesms",0)) {
2854 EncodeUnicode(Sender, "Settings",8); 2854 EncodeUnicode(Sender, "Settings",8);
2855 EncodeUnicode(Name,"MMS Settings",12); 2855 EncodeUnicode(Name,"MMS Settings",12);
2856 } 2856 }
2857 startarg += 5; 2857 startarg += 5;
2858 } else if (mystrncasecmp(argv[2],"CALENDAR",0)) { 2858 } else if (mystrncasecmp(argv[2],"CALENDAR",0)) {
2859 if (argc<5+startarg) { 2859 if (argc<5+startarg) {
2860 printmsg("Where is backup filename and location ?\n"); 2860 printmsg("Where is backup filename and location ?\n");
2861 exit(-1); 2861 exit(-1);
2862 } 2862 }
2863 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2863 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2864 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 2864 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2865 i = 0; 2865 i = 0;
2866 while (Backup.Calendar[i]!=NULL) { 2866 while (Backup.Calendar[i]!=NULL) {
2867 if (i == atoi(argv[4+startarg])-1) break; 2867 if (i == atoi(argv[4+startarg])-1) break;
2868 i++; 2868 i++;
2869 } 2869 }
2870 if (i != atoi(argv[4+startarg])-1) { 2870 if (i != atoi(argv[4+startarg])-1) {
2871 printmsg("Calendar note not found in file\n"); 2871 printmsg("Calendar note not found in file\n");
2872 exit(-1); 2872 exit(-1);
2873 } 2873 }
2874 SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long; 2874 SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long;
2875 SMSInfo.Entries[0].Calendar = Backup.Calendar[i]; 2875 SMSInfo.Entries[0].Calendar = Backup.Calendar[i];
2876 if (mystrncasecmp(argv[1],"--savesms",0)) { 2876 if (mystrncasecmp(argv[1],"--savesms",0)) {
2877 EncodeUnicode(Sender, "Calendar",8); 2877 EncodeUnicode(Sender, "Calendar",8);
2878 } 2878 }
2879 startarg += 5; 2879 startarg += 5;
2880 } else if (mystrncasecmp(argv[2],"TODO",0)) { 2880 } else if (mystrncasecmp(argv[2],"TODO",0)) {
2881 if (argc<5+startarg) { 2881 if (argc<5+startarg) {
2882 printmsg("Where is backup filename and location ?\n"); 2882 printmsg("Where is backup filename and location ?\n");
2883 exit(-1); 2883 exit(-1);
2884 } 2884 }
2885 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2885 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2886 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 2886 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2887 i = 0; 2887 i = 0;
2888 while (Backup.ToDo[i]!=NULL) { 2888 while (Backup.ToDo[i]!=NULL) {
2889 if (i == atoi(argv[4+startarg])-1) break; 2889 if (i == atoi(argv[4+startarg])-1) break;
2890 i++; 2890 i++;
2891 } 2891 }
2892 if (i != atoi(argv[4+startarg])-1) { 2892 if (i != atoi(argv[4+startarg])-1) {
2893 printmsg("ToDo note not found in file\n"); 2893 printmsg("ToDo note not found in file\n");
2894 exit(-1); 2894 exit(-1);
2895 } 2895 }
2896 SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong; 2896 SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong;
2897 SMSInfo.Entries[0].ToDo = Backup.ToDo[i]; 2897 SMSInfo.Entries[0].ToDo = Backup.ToDo[i];
2898 if (mystrncasecmp(argv[1],"--savesms",0)) { 2898 if (mystrncasecmp(argv[1],"--savesms",0)) {
2899 EncodeUnicode(Sender, "ToDo",8); 2899 EncodeUnicode(Sender, "ToDo",8);
2900 } 2900 }
2901 startarg += 5; 2901 startarg += 5;
2902 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { 2902 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
2903 if (argc<6+startarg) { 2903 if (argc<6+startarg) {
2904 printmsg("Where is backup filename and location and memory type ?\n"); 2904 printmsg("Where is backup filename and location and memory type ?\n");
2905 exit(-1); 2905 exit(-1);
2906 } 2906 }
2907 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2907 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2908 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 2908 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2909 i = 0; 2909 i = 0;
2910 if (mystrncasecmp(argv[4+startarg],"SM",0)) { 2910 if (mystrncasecmp(argv[4+startarg],"SM",0)) {
2911 while (Backup.SIMPhonebook[i]!=NULL) { 2911 while (Backup.SIMPhonebook[i]!=NULL) {
2912 if (i == atoi(argv[5+startarg])-1) break; 2912 if (i == atoi(argv[5+startarg])-1) break;
2913 i++; 2913 i++;
2914 } 2914 }
2915 if (i != atoi(argv[5+startarg])-1) { 2915 if (i != atoi(argv[5+startarg])-1) {
2916 printmsg("Phonebook entry not found in file\n"); 2916 printmsg("Phonebook entry not found in file\n");
2917 exit(-1); 2917 exit(-1);
2918 } 2918 }
2919 SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i]; 2919 SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i];
2920 } else if (mystrncasecmp(argv[4+startarg],"ME",0)) { 2920 } else if (mystrncasecmp(argv[4+startarg],"ME",0)) {
2921 while (Backup.PhonePhonebook[i]!=NULL) { 2921 while (Backup.PhonePhonebook[i]!=NULL) {
2922 if (i == atoi(argv[5+startarg])-1) break; 2922 if (i == atoi(argv[5+startarg])-1) break;
2923 i++; 2923 i++;
2924 } 2924 }
2925 if (i != atoi(argv[5+startarg])-1) { 2925 if (i != atoi(argv[5+startarg])-1) {
2926 printmsg("Phonebook entry not found in file\n"); 2926 printmsg("Phonebook entry not found in file\n");
2927 exit(-1); 2927 exit(-1);
2928 } 2928 }
2929 SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i]; 2929 SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i];
2930 } else { 2930 } else {
2931 printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]); 2931 printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]);
2932 exit(-1); 2932 exit(-1);
2933 } 2933 }
2934 if (mystrncasecmp(argv[2],"VCARD10",0)) { 2934 if (mystrncasecmp(argv[2],"VCARD10",0)) {
2935 SMSInfo.Entries[0].ID = SMS_VCARD10Long; 2935 SMSInfo.Entries[0].ID = SMS_VCARD10Long;
2936 } else { 2936 } else {
2937 SMSInfo.Entries[0].ID = SMS_VCARD21Long; 2937 SMSInfo.Entries[0].ID = SMS_VCARD21Long;
2938 } 2938 }
2939 if (mystrncasecmp(argv[1],"--savesms",0)) { 2939 if (mystrncasecmp(argv[1],"--savesms",0)) {
2940 EncodeUnicode(Sender, "VCARD",5); 2940 EncodeUnicode(Sender, "VCARD",5);
2941 EncodeUnicode(Name, "Phonebook entry",15); 2941 EncodeUnicode(Name, "Phonebook entry",15);
2942 } 2942 }
2943 startarg += 6; 2943 startarg += 6;
2944#endif 2944#endif
2945 } else if (mystrncasecmp(argv[2],"PROFILE",0)) { 2945 } else if (mystrncasecmp(argv[2],"PROFILE",0)) {
2946 SMSInfo.Entries[0].ID = SMS_NokiaProfileLong; 2946 SMSInfo.Entries[0].ID = SMS_NokiaProfileLong;
2947 if (mystrncasecmp(argv[1],"--savesms",0)) { 2947 if (mystrncasecmp(argv[1],"--savesms",0)) {
2948 EncodeUnicode(Sender, "Profile",7); 2948 EncodeUnicode(Sender, "Profile",7);
2949 } 2949 }
2950 startarg += 3; 2950 startarg += 3;
2951 } else { 2951 } else {
2952 printmsg("What format of sms (\"%s\") ?\n",argv[2]); 2952 printmsg("What format of sms (\"%s\") ?\n",argv[2]);
2953 exit(-1); 2953 exit(-1);
2954 } 2954 }
2955 2955
2956 for (i=startarg;i<argc;i++) { 2956 for (i=startarg;i<argc;i++) {
2957 switch (nextlong) { 2957 switch (nextlong) {
2958 case 0: 2958 case 0:
2959 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { 2959 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) {
2960 if (mystrncasecmp(argv[i],"-folder",0)) { 2960 if (mystrncasecmp(argv[i],"-folder",0)) {
2961 nextlong=1; 2961 nextlong=1;
2962 continue; 2962 continue;
2963 } 2963 }
2964 } 2964 }
2965 if (mystrncasecmp(argv[1],"--savesms",0)) { 2965 if (mystrncasecmp(argv[1],"--savesms",0)) {
2966 if (mystrncasecmp(argv[i],"-unread",0)) { 2966 if (mystrncasecmp(argv[i],"-unread",0)) {
2967 State = SMS_UnRead; 2967 State = SMS_UnRead;
2968 continue; 2968 continue;
2969 } 2969 }
2970 if (mystrncasecmp(argv[i],"-read",0)) { 2970 if (mystrncasecmp(argv[i],"-read",0)) {
2971 State = SMS_Read; 2971 State = SMS_Read;
2972 continue; 2972 continue;
2973 } 2973 }
2974 if (mystrncasecmp(argv[i],"-unsent",0)) { 2974 if (mystrncasecmp(argv[i],"-unsent",0)) {
2975 State = SMS_UnSent; 2975 State = SMS_UnSent;
2976 continue; 2976 continue;
2977 } 2977 }
2978 if (mystrncasecmp(argv[i],"-sent",0)) { 2978 if (mystrncasecmp(argv[i],"-sent",0)) {
2979 State = SMS_Sent; 2979 State = SMS_Sent;
2980 continue; 2980 continue;
2981 } 2981 }
2982 if (mystrncasecmp(argv[i],"-sender",0)) { 2982 if (mystrncasecmp(argv[i],"-sender",0)) {
2983 nextlong=2; 2983 nextlong=2;
2984 continue; 2984 continue;
2985 } 2985 }
2986 } else { 2986 } else {
2987 if (mystrncasecmp(argv[i],"-save",0)) { 2987 if (mystrncasecmp(argv[i],"-save",0)) {
2988 SendSaved=true; 2988 SendSaved=true;
2989 continue; 2989 continue;
2990 } 2990 }
2991 if (mystrncasecmp(argv[i],"-report",0)) { 2991 if (mystrncasecmp(argv[i],"-report",0)) {
2992 DeliveryReport=true; 2992 DeliveryReport=true;
2993 continue; 2993 continue;
2994 } 2994 }
2995 if (mystrncasecmp(argv[i],"-validity",0)) { 2995 if (mystrncasecmp(argv[i],"-validity",0)) {
2996 nextlong=10; 2996 nextlong=10;
2997 continue; 2997 continue;
2998 } 2998 }
2999 } 2999 }
3000 if (mystrncasecmp(argv[i],"-smscset",0)) { 3000 if (mystrncasecmp(argv[i],"-smscset",0)) {
3001 nextlong=3; 3001 nextlong=3;
3002 continue; 3002 continue;
3003 } 3003 }
3004 if (mystrncasecmp(argv[i],"-smscnumber",0)) { 3004 if (mystrncasecmp(argv[i],"-smscnumber",0)) {
3005 nextlong=4; 3005 nextlong=4;
3006 continue; 3006 continue;
3007 } 3007 }
3008 if (mystrncasecmp(argv[i],"-protected",0)) { 3008 if (mystrncasecmp(argv[i],"-protected",0)) {
3009 nextlong=19; 3009 nextlong=19;
3010 continue; 3010 continue;
3011 } 3011 }
3012 if (mystrncasecmp(argv[i],"-reply",0)) { 3012 if (mystrncasecmp(argv[i],"-reply",0)) {
3013 ReplyViaSameSMSC=true; 3013 ReplyViaSameSMSC=true;
3014 continue; 3014 continue;
3015 } 3015 }
3016 if (mystrncasecmp(argv[i],"-maxsms",0)) { 3016 if (mystrncasecmp(argv[i],"-maxsms",0)) {
3017 nextlong=21; 3017 nextlong=21;
3018 continue; 3018 continue;
3019 } 3019 }
3020 if (mystrncasecmp(argv[2],"RINGTONE",0)) { 3020 if (mystrncasecmp(argv[2],"RINGTONE",0)) {
3021 if (mystrncasecmp(argv[i],"-long",0)) { 3021 if (mystrncasecmp(argv[i],"-long",0)) {
3022 SMSInfo.Entries[0].ID = SMS_NokiaRingtoneLong; 3022 SMSInfo.Entries[0].ID = SMS_NokiaRingtoneLong;
3023 break; 3023 break;
3024 } 3024 }
3025 if (mystrncasecmp(argv[i],"-scale",0)) { 3025 if (mystrncasecmp(argv[i],"-scale",0)) {
3026 ringtone[0].NoteTone.AllNotesScale=true; 3026 ringtone[0].NoteTone.AllNotesScale=true;
3027 break; 3027 break;
3028 } 3028 }
3029 } 3029 }
3030 if (mystrncasecmp(argv[2],"TEXT",0)) { 3030 if (mystrncasecmp(argv[2],"TEXT",0)) {
3031 if (mystrncasecmp(argv[i],"-inputunicode",0)) { 3031 if (mystrncasecmp(argv[i],"-inputunicode",0)) {
3032 ReadUnicodeFile(Buffer[0],InputBuffer); 3032 ReadUnicodeFile(Buffer[0],InputBuffer);
3033 break; 3033 break;
3034 } 3034 }
3035 if (mystrncasecmp(argv[i],"-16bit",0)) { 3035 if (mystrncasecmp(argv[i],"-16bit",0)) {
3036 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong16bit; 3036 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong16bit;
3037 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedAutoTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong16bit; 3037 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedAutoTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong16bit;
3038 break; 3038 break;
3039 } 3039 }
3040 if (mystrncasecmp(argv[i],"-flash",0)) { 3040 if (mystrncasecmp(argv[i],"-flash",0)) {
3041 SMSInfo.Class = 0; 3041 SMSInfo.Class = 0;
3042 break; 3042 break;
3043 } 3043 }
3044 if (mystrncasecmp(argv[i],"-len",0)) { 3044 if (mystrncasecmp(argv[i],"-len",0)) {
3045 nextlong = 5; 3045 nextlong = 5;
3046 break; 3046 break;
3047 } 3047 }
3048 if (mystrncasecmp(argv[i],"-autolen",0)) { 3048 if (mystrncasecmp(argv[i],"-autolen",0)) {
3049 nextlong = 5; 3049 nextlong = 5;
3050 break; 3050 break;
3051 } 3051 }
3052 if (mystrncasecmp(argv[i],"-unicode",0)) { 3052 if (mystrncasecmp(argv[i],"-unicode",0)) {
3053 SMSInfo.UnicodeCoding = true; 3053 SMSInfo.UnicodeCoding = true;
3054 break; 3054 break;
3055 } 3055 }
3056 if (mystrncasecmp(argv[i],"-enablevoice",0)) { 3056 if (mystrncasecmp(argv[i],"-enablevoice",0)) {
3057 SMSInfo.Entries[0].ID = SMS_EnableVoice; 3057 SMSInfo.Entries[0].ID = SMS_EnableVoice;
3058 break; 3058 break;
3059 } 3059 }
3060 if (mystrncasecmp(argv[i],"-disablevoice",0)) { 3060 if (mystrncasecmp(argv[i],"-disablevoice",0)) {
3061 SMSInfo.Entries[0].ID = SMS_DisableVoice; 3061 SMSInfo.Entries[0].ID = SMS_DisableVoice;
3062 break; 3062 break;
3063 } 3063 }
3064 if (mystrncasecmp(argv[i],"-enablefax",0)) { 3064 if (mystrncasecmp(argv[i],"-enablefax",0)) {
3065 SMSInfo.Entries[0].ID = SMS_EnableFax; 3065 SMSInfo.Entries[0].ID = SMS_EnableFax;
3066 break; 3066 break;
3067 } 3067 }
3068 if (mystrncasecmp(argv[i],"-disablefax",0)) { 3068 if (mystrncasecmp(argv[i],"-disablefax",0)) {
3069 SMSInfo.Entries[0].ID = SMS_DisableFax; 3069 SMSInfo.Entries[0].ID = SMS_DisableFax;
3070 break; 3070 break;
3071 } 3071 }
3072 if (mystrncasecmp(argv[i],"-enableemail",0)) { 3072 if (mystrncasecmp(argv[i],"-enableemail",0)) {
3073 SMSInfo.Entries[0].ID = SMS_EnableEmail; 3073 SMSInfo.Entries[0].ID = SMS_EnableEmail;
3074 break; 3074 break;
3075 } 3075 }
3076 if (mystrncasecmp(argv[i],"-disableemail",0)) { 3076 if (mystrncasecmp(argv[i],"-disableemail",0)) {
3077 SMSInfo.Entries[0].ID = SMS_DisableEmail; 3077 SMSInfo.Entries[0].ID = SMS_DisableEmail;
3078 break; 3078 break;
3079 } 3079 }
3080 if (mystrncasecmp(argv[i],"-voidsms",0)) { 3080 if (mystrncasecmp(argv[i],"-voidsms",0)) {
3081 SMSInfo.Entries[0].ID = SMS_VoidSMS; 3081 SMSInfo.Entries[0].ID = SMS_VoidSMS;
3082 break; 3082 break;
3083 } 3083 }
3084 if (mystrncasecmp(argv[i],"-replacemessages",0) && 3084 if (mystrncasecmp(argv[i],"-replacemessages",0) &&
3085 SMSInfo.Entries[0].ID != SMS_ConcatenatedTextLong) { 3085 SMSInfo.Entries[0].ID != SMS_ConcatenatedTextLong) {
3086 nextlong = 8; 3086 nextlong = 8;
3087 break; 3087 break;
3088 } 3088 }
3089 if (mystrncasecmp(argv[i],"-replacefile",0)) { 3089 if (mystrncasecmp(argv[i],"-replacefile",0)) {
3090 nextlong = 9; 3090 nextlong = 9;
3091 continue; 3091 continue;
3092 } 3092 }
3093 } 3093 }
3094 if (mystrncasecmp(argv[2],"PICTURE",0)) { 3094 if (mystrncasecmp(argv[2],"PICTURE",0)) {
3095 if (mystrncasecmp(argv[i],"-text",0)) { 3095 if (mystrncasecmp(argv[i],"-text",0)) {
3096 nextlong = 6; 3096 nextlong = 6;
3097 break; 3097 break;
3098 } 3098 }
3099 if (mystrncasecmp(argv[i],"-unicode",0)) { 3099 if (mystrncasecmp(argv[i],"-unicode",0)) {
3100 SMSInfo.UnicodeCoding = true; 3100 SMSInfo.UnicodeCoding = true;
3101 break; 3101 break;
3102 } 3102 }
3103 if (mystrncasecmp(argv[i],"-alcatelbmmi",0)) { 3103 if (mystrncasecmp(argv[i],"-alcatelbmmi",0)) {
3104 bitmap[0].Bitmap[0].Type=GSM_StartupLogo; 3104 bitmap[0].Bitmap[0].Type=GSM_StartupLogo;
3105 error=GSM_ReadBitmapFile(argv[startarg-1],&bitmap[0]); 3105 error=GSM_ReadBitmapFile(argv[startarg-1],&bitmap[0]);
3106 Print_Error(error); 3106 Print_Error(error);
3107 SMSInfo.UnicodeCoding = true; 3107 SMSInfo.UnicodeCoding = true;
3108 SMSInfo.Entries[0].ID = SMS_AlcatelMonoBitmapLong; 3108 SMSInfo.Entries[0].ID = SMS_AlcatelMonoBitmapLong;
3109 break; 3109 break;
3110 } 3110 }
3111 break; 3111 break;
3112 } 3112 }
3113 if (mystrncasecmp(argv[2],"VCARD10",0)) { 3113 if (mystrncasecmp(argv[2],"VCARD10",0)) {
3114 if (mystrncasecmp(argv[i],"-nokia",0)) { 3114 if (mystrncasecmp(argv[i],"-nokia",0)) {
3115 SMSInfo.Entries[0].ID = SMS_NokiaVCARD10Long; 3115 SMSInfo.Entries[0].ID = SMS_NokiaVCARD10Long;
3116 break; 3116 break;
3117 } 3117 }
3118 break; 3118 break;
3119 } 3119 }
3120 if (mystrncasecmp(argv[2],"VCARD21",0)) { 3120 if (mystrncasecmp(argv[2],"VCARD21",0)) {
3121 if (mystrncasecmp(argv[i],"-nokia",0)) { 3121 if (mystrncasecmp(argv[i],"-nokia",0)) {
3122 SMSInfo.Entries[0].ID = SMS_NokiaVCARD21Long; 3122 SMSInfo.Entries[0].ID = SMS_NokiaVCARD21Long;
3123 break; 3123 break;
3124 } 3124 }
3125 break; 3125 break;
3126 } 3126 }
3127 if (mystrncasecmp(argv[2],"PROFILE",0)) { 3127 if (mystrncasecmp(argv[2],"PROFILE",0)) {
3128 if (mystrncasecmp(argv[i],"-name",0)) { 3128 if (mystrncasecmp(argv[i],"-name",0)) {
3129 nextlong = 22; 3129 nextlong = 22;
3130 break; 3130 break;
3131 } 3131 }
3132 if (mystrncasecmp(argv[i],"-ringtone",0)) { 3132 if (mystrncasecmp(argv[i],"-ringtone",0)) {
3133 nextlong = 23; 3133 nextlong = 23;
3134 break; 3134 break;
3135 } 3135 }
3136 if (mystrncasecmp(argv[i],"-bitmap",0)) { 3136 if (mystrncasecmp(argv[i],"-bitmap",0)) {
3137 nextlong = 24; 3137 nextlong = 24;
3138 break; 3138 break;
3139 } 3139 }
3140 } 3140 }
3141 if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { 3141 if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
3142 if (mystrncasecmp(argv[i],"-unicode",0)) { 3142 if (mystrncasecmp(argv[i],"-unicode",0)) {
3143 SMSInfo.UnicodeCoding = true; 3143 SMSInfo.UnicodeCoding = true;
3144 break; 3144 break;
3145 } 3145 }
3146 if (mystrncasecmp(argv[i],"-text",0)) { 3146 if (mystrncasecmp(argv[i],"-text",0)) {
3147 nextlong = 11; 3147 nextlong = 11;
3148 break; 3148 break;
3149 } 3149 }
3150 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { 3150 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) {
3151 nextlong = 18; 3151 nextlong = 18;
3152 break; 3152 break;
3153 } 3153 }
3154 if (mystrncasecmp(argv[i],"-defsound",0)) { 3154 if (mystrncasecmp(argv[i],"-defsound",0)) {
3155 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; 3155 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound;
3156 nextlong = 12; 3156 nextlong = 12;
3157 break; 3157 break;
3158 } 3158 }
3159 if (mystrncasecmp(argv[i],"-defanimation",0)) { 3159 if (mystrncasecmp(argv[i],"-defanimation",0)) {
3160 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; 3160 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation;
3161 nextlong = 12; 3161 nextlong = 12;
3162 break; 3162 break;
3163 } 3163 }
3164 if (mystrncasecmp(argv[i],"-tone10",0)) { 3164 if (mystrncasecmp(argv[i],"-tone10",0)) {
3165 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; 3165 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10;
3166 if (Protected != 0) { 3166 if (Protected != 0) {
3167 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3167 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3168 Protected --; 3168 Protected --;
3169 } 3169 }
3170 nextlong = 14; 3170 nextlong = 14;
3171 break; 3171 break;
3172 } 3172 }
3173 if (mystrncasecmp(argv[i],"-tone10long",0)) { 3173 if (mystrncasecmp(argv[i],"-tone10long",0)) {
3174 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; 3174 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long;
3175 if (Protected != 0) { 3175 if (Protected != 0) {
3176 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3176 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3177 Protected --; 3177 Protected --;
3178 } 3178 }
3179 nextlong = 14; 3179 nextlong = 14;
3180 break; 3180 break;
3181 } 3181 }
3182 if (mystrncasecmp(argv[i],"-tone12",0)) { 3182 if (mystrncasecmp(argv[i],"-tone12",0)) {
3183 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; 3183 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12;
3184 if (Protected != 0) { 3184 if (Protected != 0) {
3185 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3185 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3186 Protected --; 3186 Protected --;
3187 } 3187 }
3188 nextlong = 14; 3188 nextlong = 14;
3189 break; 3189 break;
3190 } 3190 }
3191 if (mystrncasecmp(argv[i],"-tone12long",0)) { 3191 if (mystrncasecmp(argv[i],"-tone12long",0)) {
3192 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; 3192 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long;
3193 if (Protected != 0) { 3193 if (Protected != 0) {
3194 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3194 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3195 Protected --; 3195 Protected --;
3196 } 3196 }
3197 nextlong = 14; 3197 nextlong = 14;
3198 break; 3198 break;
3199 } 3199 }
3200 if (mystrncasecmp(argv[i],"-toneSE",0)) { 3200 if (mystrncasecmp(argv[i],"-toneSE",0)) {
3201 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; 3201 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound;
3202 if (Protected != 0) { 3202 if (Protected != 0) {
3203 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3203 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3204 Protected --; 3204 Protected --;
3205 } 3205 }
3206 nextlong = 14; 3206 nextlong = 14;
3207 break; 3207 break;
3208 } 3208 }
3209 if (mystrncasecmp(argv[i],"-toneSElong",0)) { 3209 if (mystrncasecmp(argv[i],"-toneSElong",0)) {
3210 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; 3210 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong;
3211 if (Protected != 0) { 3211 if (Protected != 0) {
3212 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3212 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3213 Protected --; 3213 Protected --;
3214 } 3214 }
3215 nextlong = 14; 3215 nextlong = 14;
3216 break; 3216 break;
3217 } 3217 }
3218 if (mystrncasecmp(argv[i],"-variablebitmap",0)) { 3218 if (mystrncasecmp(argv[i],"-variablebitmap",0)) {
3219 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; 3219 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap;
3220 if (Protected != 0) { 3220 if (Protected != 0) {
3221 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3221 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3222 Protected --; 3222 Protected --;
3223 } 3223 }
3224 nextlong = 15; 3224 nextlong = 15;
3225 break; 3225 break;
3226 } 3226 }
3227 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { 3227 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) {
3228 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; 3228 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong;
3229 if (Protected != 0) { 3229 if (Protected != 0) {
3230 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3230 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3231 Protected --; 3231 Protected --;
3232 } 3232 }
3233 nextlong = 15; 3233 nextlong = 15;
3234 break; 3234 break;
3235 } 3235 }
3236 if (mystrncasecmp(argv[i],"-animation",0)) { 3236 if (mystrncasecmp(argv[i],"-animation",0)) {
3237 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; 3237 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation;
3238 if (Protected != 0) { 3238 if (Protected != 0) {
3239 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3239 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3240 Protected --; 3240 Protected --;
3241 } 3241 }
3242 bitmap[SMSInfo.EntriesNum].Number = 0; 3242 bitmap[SMSInfo.EntriesNum].Number = 0;
3243 nextlong = 16; 3243 nextlong = 16;
3244 break; 3244 break;
3245 } 3245 }
3246 } 3246 }
3247 if (mystrncasecmp(argv[2],"EMS",0)) { 3247 if (mystrncasecmp(argv[2],"EMS",0)) {
3248 if (mystrncasecmp(argv[i],"-unicode",0)) { 3248 if (mystrncasecmp(argv[i],"-unicode",0)) {
3249 SMSInfo.UnicodeCoding = true; 3249 SMSInfo.UnicodeCoding = true;
3250 break; 3250 break;
3251 } 3251 }
3252 if (mystrncasecmp(argv[i],"-16bit",0)) { 3252 if (mystrncasecmp(argv[i],"-16bit",0)) {
3253 EMS16Bit = true; 3253 EMS16Bit = true;
3254 break; 3254 break;
3255 } 3255 }
3256 if (mystrncasecmp(argv[i],"-format",0)) { 3256 if (mystrncasecmp(argv[i],"-format",0)) {
3257 nextlong = 20; 3257 nextlong = 20;
3258 break; 3258 break;
3259 } 3259 }
3260 if (mystrncasecmp(argv[i],"-text",0)) { 3260 if (mystrncasecmp(argv[i],"-text",0)) {
3261 nextlong = 11; 3261 nextlong = 11;
3262 break; 3262 break;
3263 } 3263 }
3264 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { 3264 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) {
3265 nextlong = 18; 3265 nextlong = 18;
3266 break; 3266 break;
3267 } 3267 }
3268 if (mystrncasecmp(argv[i],"-defsound",0)) { 3268 if (mystrncasecmp(argv[i],"-defsound",0)) {
3269 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; 3269 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound;
3270 nextlong = 12; 3270 nextlong = 12;
3271 break; 3271 break;
3272 } 3272 }
3273 if (mystrncasecmp(argv[i],"-defanimation",0)) { 3273 if (mystrncasecmp(argv[i],"-defanimation",0)) {
3274 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; 3274 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation;
3275 nextlong = 12; 3275 nextlong = 12;
3276 break; 3276 break;
3277 } 3277 }
3278 if (mystrncasecmp(argv[i],"-tone10",0)) { 3278 if (mystrncasecmp(argv[i],"-tone10",0)) {
3279 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; 3279 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10;
3280 if (Protected != 0) { 3280 if (Protected != 0) {
3281 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3281 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3282 Protected --; 3282 Protected --;
3283 } 3283 }
3284 nextlong = 14; 3284 nextlong = 14;
3285 break; 3285 break;
3286 } 3286 }
3287 if (mystrncasecmp(argv[i],"-tone10long",0)) { 3287 if (mystrncasecmp(argv[i],"-tone10long",0)) {
3288 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; 3288 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long;
3289 if (Protected != 0) { 3289 if (Protected != 0) {
3290 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3290 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3291 Protected --; 3291 Protected --;
3292 } 3292 }
3293 nextlong = 14; 3293 nextlong = 14;
3294 break; 3294 break;
3295 } 3295 }
3296 if (mystrncasecmp(argv[i],"-tone12",0)) { 3296 if (mystrncasecmp(argv[i],"-tone12",0)) {
3297 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; 3297 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12;
3298 if (Protected != 0) { 3298 if (Protected != 0) {
3299 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3299 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3300 Protected --; 3300 Protected --;
3301 } 3301 }
3302 nextlong = 14; 3302 nextlong = 14;
3303 break; 3303 break;
3304 } 3304 }
3305 if (mystrncasecmp(argv[i],"-tone12long",0)) { 3305 if (mystrncasecmp(argv[i],"-tone12long",0)) {
3306 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; 3306 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long;
3307 if (Protected != 0) { 3307 if (Protected != 0) {
3308 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3308 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3309 Protected --; 3309 Protected --;
3310 } 3310 }
3311 nextlong = 14; 3311 nextlong = 14;
3312 break; 3312 break;
3313 } 3313 }
3314 if (mystrncasecmp(argv[i],"-toneSE",0)) { 3314 if (mystrncasecmp(argv[i],"-toneSE",0)) {
3315 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; 3315 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound;
3316 if (Protected != 0) { 3316 if (Protected != 0) {
3317 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3317 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3318 Protected --; 3318 Protected --;
3319 } 3319 }
3320 nextlong = 14; 3320 nextlong = 14;
3321 break; 3321 break;
3322 } 3322 }
3323 if (mystrncasecmp(argv[i],"-toneSElong",0)) { 3323 if (mystrncasecmp(argv[i],"-toneSElong",0)) {
3324 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; 3324 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong;
3325 if (Protected != 0) { 3325 if (Protected != 0) {
3326 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3326 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3327 Protected --; 3327 Protected --;
3328 } 3328 }
3329 nextlong = 14; 3329 nextlong = 14;
3330 break; 3330 break;
3331 } 3331 }
3332 if (mystrncasecmp(argv[i],"-fixedbitmap",0)) { 3332 if (mystrncasecmp(argv[i],"-fixedbitmap",0)) {
3333 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSFixedBitmap; 3333 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSFixedBitmap;
3334 if (Protected != 0) { 3334 if (Protected != 0) {
3335 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3335 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3336 Protected --; 3336 Protected --;
3337 } 3337 }
3338 nextlong = 15; 3338 nextlong = 15;
3339 break; 3339 break;
3340 } 3340 }
3341 if (mystrncasecmp(argv[i],"-variablebitmap",0)) { 3341 if (mystrncasecmp(argv[i],"-variablebitmap",0)) {
3342 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; 3342 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap;
3343 if (Protected != 0) { 3343 if (Protected != 0) {
3344 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3344 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3345 Protected --; 3345 Protected --;
3346 } 3346 }
3347 nextlong = 15; 3347 nextlong = 15;
3348 break; 3348 break;
3349 } 3349 }
3350 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { 3350 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) {
3351 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; 3351 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong;
3352 if (Protected != 0) { 3352 if (Protected != 0) {
3353 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3353 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3354 Protected --; 3354 Protected --;
3355 } 3355 }
3356 nextlong = 15; 3356 nextlong = 15;
3357 break; 3357 break;
3358 } 3358 }
3359 if (mystrncasecmp(argv[i],"-animation",0)) { 3359 if (mystrncasecmp(argv[i],"-animation",0)) {
3360 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; 3360 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation;
3361 if (Protected != 0) { 3361 if (Protected != 0) {
3362 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3362 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3363 Protected --; 3363 Protected --;
3364 } 3364 }
3365 bitmap[SMSInfo.EntriesNum].Number = 0; 3365 bitmap[SMSInfo.EntriesNum].Number = 0;
3366 nextlong = 16; 3366 nextlong = 16;
3367 break; 3367 break;
3368 } 3368 }
3369 } 3369 }
3370 if (mystrncasecmp(argv[2],"OPERATOR",0)) { 3370 if (mystrncasecmp(argv[2],"OPERATOR",0)) {
3371 if (mystrncasecmp(argv[i],"-netcode",0)) { 3371 if (mystrncasecmp(argv[i],"-netcode",0)) {
3372 nextlong = 7; 3372 nextlong = 7;
3373 break; 3373 break;
3374 } 3374 }
3375 if (mystrncasecmp(argv[i],"-biglogo",0)) { 3375 if (mystrncasecmp(argv[i],"-biglogo",0)) {
3376 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogoLong; 3376 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogoLong;
3377 break; 3377 break;
3378 } 3378 }
3379 break; 3379 break;
3380 } 3380 }
3381 printmsg("Unknown parameter (\"%s\")\n",argv[i]); 3381 printmsg("Unknown parameter (\"%s\")\n",argv[i]);
3382 exit(-1); 3382 exit(-1);
3383 break; 3383 break;
3384 case 1: /* SMS folder - only during saving SMS */ 3384 case 1: /* SMS folder - only during saving SMS */
3385 Folder = atoi(argv[i]); 3385 Folder = atoi(argv[i]);
3386 nextlong = 0; 3386 nextlong = 0;
3387 break; 3387 break;
3388 case 2: /* Sender number - only during saving SMS */ 3388 case 2: /* Sender number - only during saving SMS */
3389 EncodeUnicode(Sender,argv[i],strlen(argv[i])); 3389 EncodeUnicode(Sender,argv[i],strlen(argv[i]));
3390 nextlong = 0; 3390 nextlong = 0;
3391 break; 3391 break;
3392 case 3: /* SMSC set number */ 3392 case 3: /* SMSC set number */
3393 SMSCSet = atoi(argv[i]); 3393 SMSCSet = atoi(argv[i]);
3394 nextlong = 0; 3394 nextlong = 0;
3395 break; 3395 break;
3396 case 4: /* Number of SMSC */ 3396 case 4: /* Number of SMSC */
3397 EncodeUnicode(SMSC,argv[i],strlen(argv[i])); 3397 EncodeUnicode(SMSC,argv[i],strlen(argv[i]));
3398 SMSCSet = 0; 3398 SMSCSet = 0;
3399 nextlong= 0; 3399 nextlong= 0;
3400 break; 3400 break;
3401 case 5: /* Length of text SMS */ 3401 case 5: /* Length of text SMS */
3402 if (atoi(argv[i])<chars_read) 3402 if (atoi(argv[i])<chars_read)
3403 { 3403 {
3404 Buffer[0][atoi(argv[i])*2]= 0x00; 3404 Buffer[0][atoi(argv[i])*2]= 0x00;
3405 Buffer[0][atoi(argv[i])*2+1]= 0x00; 3405 Buffer[0][atoi(argv[i])*2+1]= 0x00;
3406 } 3406 }
3407 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; 3407 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
3408 if (mystrncasecmp(argv[i-1],"-autolen",0)) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong; 3408 if (mystrncasecmp(argv[i-1],"-autolen",0)) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong;
3409 nextlong = 0; 3409 nextlong = 0;
3410 break; 3410 break;
3411 case 6:/* Picture Images - text */ 3411 case 6:/* Picture Images - text */
3412 EncodeUnicode(bitmap[0].Bitmap[0].Text,argv[i],strlen(argv[i])); 3412 EncodeUnicode(bitmap[0].Bitmap[0].Text,argv[i],strlen(argv[i]));
3413 nextlong = 0; 3413 nextlong = 0;
3414 break; 3414 break;
3415 case 7:/* Operator Logo - network code */ 3415 case 7:/* Operator Logo - network code */
3416 strncpy(bitmap[0].Bitmap[0].NetworkCode,argv[i],7); 3416 strncpy(bitmap[0].Bitmap[0].NetworkCode,argv[i],7);
3417 if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)),"unknown")) { 3417 if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)),"unknown")) {
3418 printmsg("Unknown GSM network code (\"%s\")\n",argv[i]); 3418 printmsg("Unknown GSM network code (\"%s\")\n",argv[i]);
3419 exit(-1); 3419 exit(-1);
3420 } 3420 }
3421 if (mystrncasecmp(argv[1],"--savesms",0)) { 3421 if (mystrncasecmp(argv[1],"--savesms",0)) {
3422 EncodeUnicode(Sender, "OpLogo",6); 3422 EncodeUnicode(Sender, "OpLogo",6);
3423 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); 3423 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3);
3424 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); 3424 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2);
3425 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { 3425 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) {
3426 EncodeUnicode(Name,"OpLogo ",7); 3426 EncodeUnicode(Name,"OpLogo ",7);
3427 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); 3427 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode));
3428 } else { 3428 } else {
3429 CopyUnicodeString(Name,Sender); 3429 CopyUnicodeString(Name,Sender);
3430 } 3430 }
3431 } 3431 }
3432 nextlong = 0; 3432 nextlong = 0;
3433 break; 3433 break;
3434 case 8:/* Reject duplicates ID */ 3434 case 8:/* Reject duplicates ID */
3435 SMSInfo.ReplaceMessage = atoi(argv[i]); 3435 SMSInfo.ReplaceMessage = atoi(argv[i]);
3436 if (SMSInfo.ReplaceMessage < 1 || SMSInfo.ReplaceMessage > 7) { 3436 if (SMSInfo.ReplaceMessage < 1 || SMSInfo.ReplaceMessage > 7) {
3437 printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv[i]); 3437 printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv[i]);
3438 exit(-1); 3438 exit(-1);
3439 } 3439 }
3440 nextlong = 0; 3440 nextlong = 0;
3441 break; 3441 break;
3442 case 9:/* Replace file for text SMS */ 3442 case 9:/* Replace file for text SMS */
3443 ReplaceFile = fopen(argv[i], "rb"); 3443 ReplaceFile = fopen(argv[i], "rb");
3444 if (ReplaceFile == NULL) Print_Error(ERR_CANTOPENFILE); 3444 if (ReplaceFile == NULL) Print_Error(ERR_CANTOPENFILE);
3445 memset(ReplaceBuffer,0,sizeof(ReplaceBuffer)); 3445 memset(ReplaceBuffer,0,sizeof(ReplaceBuffer));
3446 fread(ReplaceBuffer,1,sizeof(ReplaceBuffer),ReplaceFile); 3446 fread(ReplaceBuffer,1,sizeof(ReplaceBuffer),ReplaceFile);
3447 fclose(ReplaceFile); 3447 fclose(ReplaceFile);
3448 ReadUnicodeFile(ReplaceBuffer2,ReplaceBuffer); 3448 ReadUnicodeFile(ReplaceBuffer2,ReplaceBuffer);
3449 for(j=0;j<(int)(UnicodeLength(Buffer[0]));j++) { 3449 for(j=0;j<(int)(UnicodeLength(Buffer[0]));j++) {
3450 for (z=0;z<(int)(UnicodeLength(ReplaceBuffer2)/2);z++) { 3450 for (z=0;z<(int)(UnicodeLength(ReplaceBuffer2)/2);z++) {
3451 if (ReplaceBuffer2[z*4] == Buffer[0][j] && 3451 if (ReplaceBuffer2[z*4] == Buffer[0][j] &&
3452 ReplaceBuffer2[z*4+1] == Buffer[0][j+1]) { 3452 ReplaceBuffer2[z*4+1] == Buffer[0][j+1]) {
3453 Buffer[0][j] = ReplaceBuffer2[z*4+2]; 3453 Buffer[0][j] = ReplaceBuffer2[z*4+2];
3454 Buffer[0][j+1] = ReplaceBuffer2[z*4+3]; 3454 Buffer[0][j+1] = ReplaceBuffer2[z*4+3];
3455 break; 3455 break;
3456 } 3456 }
3457 } 3457 }
3458 } 3458 }
3459 nextlong = 0; 3459 nextlong = 0;
3460 break; 3460 break;
3461 case 10: 3461 case 10:
3462 Validity.Format = SMS_Validity_RelativeFormat; 3462 Validity.Format = SMS_Validity_RelativeFormat;
3463 if (mystrncasecmp(argv[i],"HOUR",0)) Validity.Relative = SMS_VALID_1_Hour; 3463 if (mystrncasecmp(argv[i],"HOUR",0)) Validity.Relative = SMS_VALID_1_Hour;
3464 else if (mystrncasecmp(argv[i],"6HOURS",0))Validity.Relative = SMS_VALID_6_Hours; 3464 else if (mystrncasecmp(argv[i],"6HOURS",0))Validity.Relative = SMS_VALID_6_Hours;
3465 else if (mystrncasecmp(argv[i],"DAY",0)) Validity.Relative = SMS_VALID_1_Day; 3465 else if (mystrncasecmp(argv[i],"DAY",0)) Validity.Relative = SMS_VALID_1_Day;
3466 else if (mystrncasecmp(argv[i],"3DAYS",0)) Validity.Relative = SMS_VALID_3_Days; 3466 else if (mystrncasecmp(argv[i],"3DAYS",0)) Validity.Relative = SMS_VALID_3_Days;
3467 else if (mystrncasecmp(argv[i],"WEEK",0)) Validity.Relative = SMS_VALID_1_Week; 3467 else if (mystrncasecmp(argv[i],"WEEK",0)) Validity.Relative = SMS_VALID_1_Week;
3468 else if (mystrncasecmp(argv[i],"MAX",0)) Validity.Relative = SMS_VALID_Max_Time; 3468 else if (mystrncasecmp(argv[i],"MAX",0)) Validity.Relative = SMS_VALID_Max_Time;
3469 else { 3469 else {
3470 printmsg("Unknown validity string (\"%s\")\n",argv[i]); 3470 printmsg("Unknown validity string (\"%s\")\n",argv[i]);
3471 exit(-1); 3471 exit(-1);
3472 } 3472 }
3473 nextlong = 0; 3473 nextlong = 0;
3474 break; 3474 break;
3475 case 11:/* EMS text from parameter */ 3475 case 11:/* EMS text from parameter */
3476 EncodeUnicode(Buffer[SMSInfo.EntriesNum],argv[i],strlen(argv[i])); 3476 EncodeUnicode(Buffer[SMSInfo.EntriesNum],argv[i],strlen(argv[i]));
3477 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); 3477 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum]));
3478 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; 3478 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong;
3479 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; 3479 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum];
3480 SMSInfo.EntriesNum++; 3480 SMSInfo.EntriesNum++;
3481 nextlong = 0; 3481 nextlong = 0;
3482 break; 3482 break;
3483 case 12:/* EMS predefined sound/animation number */ 3483 case 12:/* EMS predefined sound/animation number */
3484 SMSInfo.Entries[SMSInfo.EntriesNum].Number = atoi(argv[i]); 3484 SMSInfo.Entries[SMSInfo.EntriesNum].Number = atoi(argv[i]);
3485 SMSInfo.EntriesNum++; 3485 SMSInfo.EntriesNum++;
3486 nextlong = 0; 3486 nextlong = 0;
3487 break; 3487 break;
3488 case 14: /* EMS ringtone - IMelody */ 3488 case 14: /* EMS ringtone - IMelody */
3489 ringtone[SMSInfo.EntriesNum].Format=RING_NOTETONE; 3489 ringtone[SMSInfo.EntriesNum].Format=RING_NOTETONE;
3490 error=GSM_ReadRingtoneFile(argv[i],&ringtone[SMSInfo.EntriesNum]); 3490 error=GSM_ReadRingtoneFile(argv[i],&ringtone[SMSInfo.EntriesNum]);
3491 Print_Error(error); 3491 Print_Error(error);
3492 SMSInfo.Entries[SMSInfo.EntriesNum].Ringtone = &ringtone[SMSInfo.EntriesNum]; 3492 SMSInfo.Entries[SMSInfo.EntriesNum].Ringtone = &ringtone[SMSInfo.EntriesNum];
3493 SMSInfo.EntriesNum++; 3493 SMSInfo.EntriesNum++;
3494 nextlong = 0; 3494 nextlong = 0;
3495 break; 3495 break;
3496 case 15:/* EMS bitmap file */ 3496 case 15:/* EMS bitmap file */
3497 bitmap[SMSInfo.EntriesNum].Bitmap[0].Type=GSM_StartupLogo; 3497 bitmap[SMSInfo.EntriesNum].Bitmap[0].Type=GSM_StartupLogo;
3498 error=GSM_ReadBitmapFile(argv[i],&bitmap[SMSInfo.EntriesNum]); 3498 error=GSM_ReadBitmapFile(argv[i],&bitmap[SMSInfo.EntriesNum]);
3499 Print_Error(error); 3499 Print_Error(error);
3500 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; 3500 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum];
3501 SMSInfo.EntriesNum++; 3501 SMSInfo.EntriesNum++;
3502 nextlong = 0; 3502 nextlong = 0;
3503 break; 3503 break;
3504 case 16:/* Number of frames for EMS animation */ 3504 case 16:/* Number of frames for EMS animation */
3505 FramesNum = atoi(argv[i]); 3505 FramesNum = atoi(argv[i]);
3506 if (FramesNum < 1 || FramesNum > 4) { 3506 if (FramesNum < 1 || FramesNum > 4) {
3507 printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv[i]); 3507 printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv[i]);
3508 exit(-1); 3508 exit(-1);
3509 } 3509 }
3510 bitmap[SMSInfo.EntriesNum].Number = 0; 3510 bitmap[SMSInfo.EntriesNum].Number = 0;
3511 nextlong = 17; 3511 nextlong = 17;
3512 break; 3512 break;
3513 case 17:/*File for EMS animation */ 3513 case 17:/*File for EMS animation */
3514 bitmap2.Bitmap[0].Type=GSM_StartupLogo; 3514 bitmap2.Bitmap[0].Type=GSM_StartupLogo;
3515 error=GSM_ReadBitmapFile(argv[i],&bitmap2); 3515 error=GSM_ReadBitmapFile(argv[i],&bitmap2);
3516 for (j=0;j<bitmap2.Number;j++) { 3516 for (j=0;j<bitmap2.Number;j++) {
3517 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) break; 3517 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) break;
3518 memcpy(&bitmap[SMSInfo.EntriesNum].Bitmap[bitmap[SMSInfo.EntriesNum].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); 3518 memcpy(&bitmap[SMSInfo.EntriesNum].Bitmap[bitmap[SMSInfo.EntriesNum].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap));
3519 bitmap[SMSInfo.EntriesNum].Number++; 3519 bitmap[SMSInfo.EntriesNum].Number++;
3520 } 3520 }
3521 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) { 3521 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) {
3522 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; 3522 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum];
3523 SMSInfo.EntriesNum++; 3523 SMSInfo.EntriesNum++;
3524 nextlong = 0; 3524 nextlong = 0;
3525 } 3525 }
3526 break; 3526 break;
3527 case 18:/* EMS text from Unicode file */ 3527 case 18:/* EMS text from Unicode file */
3528 f = fopen(argv[i],"rb"); 3528 f = fopen(argv[i],"rb");
3529 if (f == NULL) { 3529 if (f == NULL) {
3530 printmsg("Can't open file \"%s\"\n",argv[i]); 3530 printmsg("Can't open file \"%s\"\n",argv[i]);
3531 exit(-1); 3531 exit(-1);
3532 } 3532 }
3533 z=fread(InputBuffer,1,2000,f); 3533 z=fread(InputBuffer,1,2000,f);
3534 InputBuffer[z] = 0; 3534 InputBuffer[z] = 0;
3535 InputBuffer[z+1] = 0; 3535 InputBuffer[z+1] = 0;
3536 fclose(f); 3536 fclose(f);
3537 ReadUnicodeFile(Buffer[SMSInfo.EntriesNum],InputBuffer); 3537 ReadUnicodeFile(Buffer[SMSInfo.EntriesNum],InputBuffer);
3538 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); 3538 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum]));
3539 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; 3539 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong;
3540 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; 3540 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum];
3541 SMSInfo.EntriesNum++; 3541 SMSInfo.EntriesNum++;
3542 nextlong = 0; 3542 nextlong = 0;
3543 break; 3543 break;
3544 case 19:/* Number of protected items */ 3544 case 19:/* Number of protected items */
3545 Protected = atoi(argv[i]); 3545 Protected = atoi(argv[i]);
3546 nextlong = 0; 3546 nextlong = 0;
3547 break; 3547 break;
3548 case 20:/* Formatting text for EMS */ 3548 case 20:/* Formatting text for EMS */
3549 if (SMSInfo.Entries[SMSInfo.EntriesNum-1].ID == SMS_ConcatenatedTextLong) { 3549 if (SMSInfo.Entries[SMSInfo.EntriesNum-1].ID == SMS_ConcatenatedTextLong) {
3550 for(j=0;j<(int)strlen(argv[i]);j++) { 3550 for(j=0;j<(int)strlen(argv[i]);j++) {
3551 switch(argv[i][j]) { 3551 switch(argv[i][j]) {
3552 case 'l': case 'L': 3552 case 'l': case 'L':
3553 SMSInfo.Entries[SMSInfo.EntriesNum-1].Left = true; 3553 SMSInfo.Entries[SMSInfo.EntriesNum-1].Left = true;
3554 break; 3554 break;
3555 case 'c': case 'C': 3555 case 'c': case 'C':
3556 SMSInfo.Entries[SMSInfo.EntriesNum-1].Center = true; 3556 SMSInfo.Entries[SMSInfo.EntriesNum-1].Center = true;
3557 break; 3557 break;
3558 case 'r': case 'R': 3558 case 'r': case 'R':
3559 SMSInfo.Entries[SMSInfo.EntriesNum-1].Right = true; 3559 SMSInfo.Entries[SMSInfo.EntriesNum-1].Right = true;
3560 break; 3560 break;
3561 case 'a': case 'A': 3561 case 'a': case 'A':
3562 SMSInfo.Entries[SMSInfo.EntriesNum-1].Large = true; 3562 SMSInfo.Entries[SMSInfo.EntriesNum-1].Large = true;
3563 break; 3563 break;
3564 case 's': case 'S': 3564 case 's': case 'S':
3565 SMSInfo.Entries[SMSInfo.EntriesNum-1].Small = true; 3565 SMSInfo.Entries[SMSInfo.EntriesNum-1].Small = true;
3566 break; 3566 break;
3567 case 'b': case 'B': 3567 case 'b': case 'B':
3568 SMSInfo.Entries[SMSInfo.EntriesNum-1].Bold = true; 3568 SMSInfo.Entries[SMSInfo.EntriesNum-1].Bold = true;
3569 break; 3569 break;
3570 case 'i': case 'I': 3570 case 'i': case 'I':
3571 SMSInfo.Entries[SMSInfo.EntriesNum-1].Italic = true; 3571 SMSInfo.Entries[SMSInfo.EntriesNum-1].Italic = true;
3572 break; 3572 break;
3573 case 'u': case 'U': 3573 case 'u': case 'U':
3574 SMSInfo.Entries[SMSInfo.EntriesNum-1].Underlined = true; 3574 SMSInfo.Entries[SMSInfo.EntriesNum-1].Underlined = true;
3575 break; 3575 break;
3576 case 't': case 'T': 3576 case 't': case 'T':
3577 SMSInfo.Entries[SMSInfo.EntriesNum-1].Strikethrough = true; 3577 SMSInfo.Entries[SMSInfo.EntriesNum-1].Strikethrough = true;
3578 break; 3578 break;
3579 default: 3579 default:
3580 printmsg("Unknown parameter \"%c\"\n",argv[i][j]); 3580 printmsg("Unknown parameter \"%c\"\n",argv[i][j]);
3581 exit(-1); 3581 exit(-1);
3582 } 3582 }
3583 } 3583 }
3584 } else { 3584 } else {
3585 printmsg("Last parameter wasn't text\n"); 3585 printmsg("Last parameter wasn't text\n");
3586 exit(-1); 3586 exit(-1);
3587 } 3587 }
3588 nextlong = 0; 3588 nextlong = 0;
3589 break; 3589 break;
3590 case 21:/*MaxSMS*/ 3590 case 21:/*MaxSMS*/
3591 MaxSMS = atoi(argv[i]); 3591 MaxSMS = atoi(argv[i]);
3592 nextlong = 0; 3592 nextlong = 0;
3593 break; 3593 break;
3594 case 22:/* profile name */ 3594 case 22:/* profile name */
3595 EncodeUnicode(Buffer[0],argv[i],strlen(argv[i])); 3595 EncodeUnicode(Buffer[0],argv[i],strlen(argv[i]));
3596 SMSInfo.Entries[0].Buffer = Buffer[0]; 3596 SMSInfo.Entries[0].Buffer = Buffer[0];
3597 nextlong = 0; 3597 nextlong = 0;
3598 break; 3598 break;
3599 case 23:/* profile ringtone */ 3599 case 23:/* profile ringtone */
3600 ringtone[0].Format = RING_NOTETONE; 3600 ringtone[0].Format = RING_NOTETONE;
3601 error=GSM_ReadRingtoneFile(argv[i],&ringtone[0]); 3601 error=GSM_ReadRingtoneFile(argv[i],&ringtone[0]);
3602 Print_Error(error); 3602 Print_Error(error);
3603 SMSInfo.Entries[0].Ringtone = &ringtone[0]; 3603 SMSInfo.Entries[0].Ringtone = &ringtone[0];
3604 nextlong = 0; 3604 nextlong = 0;
3605 break; 3605 break;
3606 case 24:/* profile bitmap */ 3606 case 24:/* profile bitmap */
3607 bitmap[0].Bitmap[0].Type = GSM_PictureImage; 3607 bitmap[0].Bitmap[0].Type = GSM_PictureImage;
3608 error=GSM_ReadBitmapFile(argv[i],&bitmap[0]); 3608 error=GSM_ReadBitmapFile(argv[i],&bitmap[0]);
3609 Print_Error(error); 3609 Print_Error(error);
3610 bitmap[0].Bitmap[0].Text[0] = 0; 3610 bitmap[0].Bitmap[0].Text[0] = 0;
3611 bitmap[0].Bitmap[0].Text[1] = 0; 3611 bitmap[0].Bitmap[0].Text[1] = 0;
3612 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 3612 SMSInfo.Entries[0].Bitmap = &bitmap[0];
3613 nextlong = 0; 3613 nextlong = 0;
3614 break; 3614 break;
3615 } 3615 }
3616 } 3616 }
3617 if (nextlong!=0) { 3617 if (nextlong!=0) {
3618 printmsg("Parameter missed...\n"); 3618 printmsg("Parameter missed...\n");
3619 exit(-1); 3619 exit(-1);
3620 } 3620 }
3621 3621
3622 if (mystrncasecmp(argv[2],"EMS",0) && EMS16Bit) { 3622 if (mystrncasecmp(argv[2],"EMS",0) && EMS16Bit) {
3623 for (i=0;i<SMSInfo.EntriesNum;i++) { 3623 for (i=0;i<SMSInfo.EntriesNum;i++) {
3624 switch (SMSInfo.Entries[i].ID) { 3624 switch (SMSInfo.Entries[i].ID) {
3625 case SMS_ConcatenatedTextLong: 3625 case SMS_ConcatenatedTextLong:
3626 SMSInfo.Entries[i].ID = SMS_ConcatenatedTextLong16bit; 3626 SMSInfo.Entries[i].ID = SMS_ConcatenatedTextLong16bit;
3627 default: 3627 default:
3628 break; 3628 break;
3629 3629
3630 } 3630 }
3631 } 3631 }
3632 3632
3633 } 3633 }
3634 if (mystrncasecmp(argv[2],"TEXT",0)) { 3634 if (mystrncasecmp(argv[2],"TEXT",0)) {
3635 chars_read = UnicodeLength(Buffer[0]); 3635 chars_read = UnicodeLength(Buffer[0]);
3636 if (chars_read != 0) { 3636 if (chars_read != 0) {
3637 /* Trim \n at the end of string */ 3637 /* Trim \n at the end of string */
3638 if (Buffer[0][chars_read*2-1] == '\n' && Buffer[0][chars_read*2-2] == 0) 3638 if (Buffer[0][chars_read*2-1] == '\n' && Buffer[0][chars_read*2-2] == 0)
3639 { 3639 {
3640 Buffer[0][chars_read*2-1] = 0; 3640 Buffer[0][chars_read*2-1] = 0;
3641 } 3641 }
3642 } 3642 }
3643 } 3643 }
3644 3644
3645 if (mystrncasecmp(argv[1],"--displaysms",0) || mystrncasecmp(argv[1],"--sendsmsdsms",0)) { 3645 if (mystrncasecmp(argv[1],"--displaysms",0) || mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
3646 if (mystrncasecmp(argv[2],"OPERATOR",0)) { 3646 if (mystrncasecmp(argv[2],"OPERATOR",0)) {
3647 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { 3647 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) {
3648 printmsg("No network code\n"); 3648 printmsg("No network code\n");
3649 exit(-1); 3649 exit(-1);
3650 } 3650 }
3651 } 3651 }
3652 } else { 3652 } else {
3653 GSM_Init(true); 3653 GSM_Init(true);
3654 3654
3655 if (mystrncasecmp(argv[2],"OPERATOR",0)) { 3655 if (mystrncasecmp(argv[2],"OPERATOR",0)) {
3656 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { 3656 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) {
3657 error=Phone->GetNetworkInfo(&s,&NetInfo); 3657 error=Phone->GetNetworkInfo(&s,&NetInfo);
3658 Print_Error(error); 3658 Print_Error(error);
3659 strcpy(bitmap[0].Bitmap[0].NetworkCode,NetInfo.NetworkCode); 3659 strcpy(bitmap[0].Bitmap[0].NetworkCode,NetInfo.NetworkCode);
3660 if (mystrncasecmp(argv[1],"--savesms",0)) { 3660 if (mystrncasecmp(argv[1],"--savesms",0)) {
3661 EncodeUnicode(Sender, "OpLogo",6); 3661 EncodeUnicode(Sender, "OpLogo",6);
3662 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); 3662 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3);
3663 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); 3663 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2);
3664 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { 3664 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) {
3665 EncodeUnicode(Name,"OpLogo ",7); 3665 EncodeUnicode(Name,"OpLogo ",7);
3666 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); 3666 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode));
3667 } else { 3667 } else {
3668 CopyUnicodeString(Name,Sender); 3668 CopyUnicodeString(Name,Sender);
3669 } 3669 }
3670 } 3670 }
3671 } 3671 }
3672 } 3672 }
3673 } 3673 }
3674 3674
3675 error=GSM_EncodeMultiPartSMS(&SMSInfo,&sms); 3675 error=GSM_EncodeMultiPartSMS(&SMSInfo,&sms);
3676 Print_Error(error); 3676 Print_Error(error);
3677 3677
3678 for (i=0;i<SMSInfo.EntriesNum;i++) { 3678 for (i=0;i<SMSInfo.EntriesNum;i++) {
3679 switch (SMSInfo.Entries[i].ID) { 3679 switch (SMSInfo.Entries[i].ID) {
3680 case SMS_NokiaRingtone: 3680 case SMS_NokiaRingtone:
3681 case SMS_NokiaRingtoneLong: 3681 case SMS_NokiaRingtoneLong:
3682 case SMS_NokiaProfileLong: 3682 case SMS_NokiaProfileLong:
3683 case SMS_EMSSound10: 3683 case SMS_EMSSound10:
3684 case SMS_EMSSound12: 3684 case SMS_EMSSound12:
3685 case SMS_EMSSonyEricssonSound: 3685 case SMS_EMSSonyEricssonSound:
3686 case SMS_EMSSound10Long: 3686 case SMS_EMSSound10Long:
3687 case SMS_EMSSound12Long: 3687 case SMS_EMSSound12Long:
3688 case SMS_EMSSonyEricssonSoundLong: 3688 case SMS_EMSSonyEricssonSoundLong:
3689 if (SMSInfo.Entries[i].RingtoneNotes!=SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands) { 3689 if (SMSInfo.Entries[i].RingtoneNotes!=SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands) {
3690 printmsg("Warning: ringtone too long. %i percent part cut\n", 3690 printmsg("Warning: ringtone too long. %i percent part cut\n",
3691 (SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands-SMSInfo.Entries[i].RingtoneNotes)*100/SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands); 3691 (SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands-SMSInfo.Entries[i].RingtoneNotes)*100/SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands);
3692 } 3692 }
3693 default: 3693 default:
3694 break; 3694 break;
3695 3695
3696 } 3696 }
3697 } 3697 }
3698 if (MaxSMS != -1 && sms.Number > MaxSMS) { 3698 if (MaxSMS != -1 && sms.Number > MaxSMS) {
3699 printmsg("There is %i SMS packed and %i limit. Exiting\n",sms.Number,MaxSMS); 3699 printmsg("There is %i SMS packed and %i limit. Exiting\n",sms.Number,MaxSMS);
3700 if (!mystrncasecmp(argv[1],"--displaysms",0) && !mystrncasecmp(argv[1],"--sendsmsdsms",0)) GSM_Terminate(); 3700 if (!mystrncasecmp(argv[1],"--displaysms",0) && !mystrncasecmp(argv[1],"--sendsmsdsms",0)) GSM_Terminate();
3701 exit(-1); 3701 exit(-1);
3702 } 3702 }
3703 3703
3704 if (mystrncasecmp(argv[1],"--displaysms",0)) { 3704 if (mystrncasecmp(argv[1],"--displaysms",0)) {
3705 if (SMSCSet != 0) { 3705 if (SMSCSet != 0) {
3706 printmsg("Use -smscnumber option to give SMSC number\n"); 3706 printmsg("Use -smscnumber option to give SMSC number\n");
3707 exit(-1); 3707 exit(-1);
3708 } 3708 }
3709 3709
3710 for (i=0;i<sms.Number;i++) { 3710 for (i=0;i<sms.Number;i++) {
3711 sms.SMS[i].Location = 0; 3711 sms.SMS[i].Location = 0;
3712 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; 3712 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
3713 sms.SMS[i].SMSC.Location = 0; 3713 sms.SMS[i].SMSC.Location = 0;
3714 sms.SMS[i].PDU = SMS_Submit; 3714 sms.SMS[i].PDU = SMS_Submit;
3715 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; 3715 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report;
3716 CopyUnicodeString(sms.SMS[i].Number, Sender); 3716 CopyUnicodeString(sms.SMS[i].Number, Sender);
3717 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3717 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3718 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); 3718 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
3719 DisplaySMSFrame(&sms.SMS[i]); 3719 DisplaySMSFrame(&sms.SMS[i]);
3720 } 3720 }
3721 3721
3722 printmsg("\nNumber of SMS: %i\n",sms.Number); 3722 printmsg("\nNumber of SMS: %i\n",sms.Number);
3723 exit(sms.Number); 3723 exit(sms.Number);
3724 } 3724 }
3725 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { 3725 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
3726 if (SMSCSet != 0) { 3726 if (SMSCSet != 0) {
3727 printmsg("Use -smscnumber option to give SMSC number\n"); 3727 printmsg("Use -smscnumber option to give SMSC number\n");
3728 exit(-1); 3728 exit(-1);
3729 } 3729 }
3730 3730
3731 for (i=0;i<sms.Number;i++) { 3731 for (i=0;i<sms.Number;i++) {
3732 sms.SMS[i].Location = 0; 3732 sms.SMS[i].Location = 0;
3733 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; 3733 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
3734 sms.SMS[i].SMSC.Location = 0; 3734 sms.SMS[i].SMSC.Location = 0;
3735 sms.SMS[i].PDU = SMS_Submit; 3735 sms.SMS[i].PDU = SMS_Submit;
3736 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; 3736 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report;
3737 CopyUnicodeString(sms.SMS[i].Number, Sender); 3737 CopyUnicodeString(sms.SMS[i].Number, Sender);
3738 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3738 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3739 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); 3739 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
3740 } 3740 }
3741 SMSDaemonSendSMS(argv[4],argv[5],&sms); 3741 SMSDaemonSendSMS(argv[4],argv[5],&sms);
3742 exit(0); 3742 exit(0);
3743 } 3743 }
3744 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { 3744 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) {
3745 error=Phone->GetSMSFolders(&s, &folders); 3745 error=Phone->GetSMSFolders(&s, &folders);
3746 Print_Error(error); 3746 Print_Error(error);
3747 3747
3748 if (SendSaved){ 3748 if (SendSaved){
3749 if (Validity.Format != 0 && SMSCSet != 0) { 3749 if (Validity.Format != 0 && SMSCSet != 0) {
3750 PhoneSMSC.Location = SMSCSet; 3750 PhoneSMSC.Location = SMSCSet;
3751 error=Phone->GetSMSC(&s,&PhoneSMSC); 3751 error=Phone->GetSMSC(&s,&PhoneSMSC);
3752 Print_Error(error); 3752 Print_Error(error);
3753 CopyUnicodeString(SMSC,PhoneSMSC.Number); 3753 CopyUnicodeString(SMSC,PhoneSMSC.Number);
3754 SMSCSet = 0; 3754 SMSCSet = 0;
3755 } 3755 }
3756 3756
3757 s.User.SendSMSStatus = SendSMSStatus; 3757 s.User.SendSMSStatus = SendSMSStatus;
3758 3758
3759 signal(SIGINT, interrupt); 3759 signal(SIGINT, interrupt);
3760 printmsgerr("If you want break, press Ctrl+C...\n"); 3760 printmsgerr("If you want break, press Ctrl+C...\n");
3761 } 3761 }
3762 3762
3763 for (i=0;i<sms.Number;i++) { 3763 for (i=0;i<sms.Number;i++) {
3764 printmsg("Saving SMS %i/%i\n",i+1,sms.Number); 3764 printmsg("Saving SMS %i/%i\n",i+1,sms.Number);
3765 // sms.SMS[i].Location = 0; 3765 // sms.SMS[i].Location = 0;
3766 sms.SMS[i].Folder = Folder; 3766 sms.SMS[i].Folder = Folder;
3767 sms.SMS[i].State = State; 3767 sms.SMS[i].State = State;
3768 sms.SMS[i].ReplyViaSameSMSC= ReplyViaSameSMSC; 3768 sms.SMS[i].ReplyViaSameSMSC= ReplyViaSameSMSC;
3769 sms.SMS[i].SMSC.Location= SMSCSet; 3769 sms.SMS[i].SMSC.Location= SMSCSet;
3770 3770
3771 if (SendSaved){ 3771 if (SendSaved){
3772 sms.SMS[i].PDU= SMS_Submit; 3772 sms.SMS[i].PDU= SMS_Submit;
3773 if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report; 3773 if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report;
3774 if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity; 3774 if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity;
3775 } else { 3775 } else {
3776 sms.SMS[i].PDU= SMS_Deliver; 3776 sms.SMS[i].PDU= SMS_Deliver;
3777 } 3777 }
3778 3778
3779 CopyUnicodeString(sms.SMS[i].Number, Sender); 3779 CopyUnicodeString(sms.SMS[i].Number, Sender);
3780 CopyUnicodeString(sms.SMS[i].Name, Name); 3780 CopyUnicodeString(sms.SMS[i].Name, Name);
3781 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3781 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3782 error=Phone->AddSMS(&s, &sms.SMS[i]); 3782 error=Phone->AddSMS(&s, &sms.SMS[i]);
3783 Print_Error(error); 3783 Print_Error(error);
3784 printmsg("Saved in folder \"%s\", location %i\n", 3784 printmsg("Saved in folder \"%s\", location %i\n",
3785 DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); 3785 DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location);
3786 3786
3787 if (SendSaved) { 3787 if (SendSaved) {
3788 printmsg("Sending sms from folder \"%s\", location %i\n", 3788 printmsg("Sending sms from folder \"%s\", location %i\n",
3789 DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); 3789 DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location);
3790 SMSStatus = ERR_TIMEOUT; 3790 SMSStatus = ERR_TIMEOUT;
3791 error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location); 3791 error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location);
3792 Print_Error(error); 3792 Print_Error(error);
3793 printmsg("....waiting for network answer"); 3793 printmsg("....waiting for network answer");
3794 while (!gshutdown) { 3794 while (!gshutdown) {
3795 GSM_ReadDevice(&s,true); 3795 GSM_ReadDevice(&s,true);
3796 if (SMSStatus == ERR_UNKNOWN) { 3796 if (SMSStatus == ERR_UNKNOWN) {
3797 GSM_Terminate(); 3797 GSM_Terminate();
3798 exit(-1); 3798 exit(-1);
3799 } 3799 }
3800 if (SMSStatus == ERR_NONE) break; 3800 if (SMSStatus == ERR_NONE) break;
3801 } 3801 }
3802 } 3802 }
3803 } 3803 }
3804 } else { 3804 } else {
3805 if (Validity.Format != 0 && SMSCSet != 0) { 3805 if (Validity.Format != 0 && SMSCSet != 0) {
3806 PhoneSMSC.Location = SMSCSet; 3806 PhoneSMSC.Location = SMSCSet;
3807 error=Phone->GetSMSC(&s,&PhoneSMSC); 3807 error=Phone->GetSMSC(&s,&PhoneSMSC);
3808 Print_Error(error); 3808 Print_Error(error);
3809 CopyUnicodeString(SMSC,PhoneSMSC.Number); 3809 CopyUnicodeString(SMSC,PhoneSMSC.Number);
3810 SMSCSet = 0; 3810 SMSCSet = 0;
3811 } 3811 }
3812 3812
3813 signal(SIGINT, interrupt); 3813 signal(SIGINT, interrupt);
3814 printmsgerr("If you want break, press Ctrl+C...\n"); 3814 printmsgerr("If you want break, press Ctrl+C...\n");
3815 3815
3816 s.User.SendSMSStatus = SendSMSStatus; 3816 s.User.SendSMSStatus = SendSMSStatus;
3817 3817
3818 for (i=0;i<sms.Number;i++) { 3818 for (i=0;i<sms.Number;i++) {
3819 printmsg("Sending SMS %i/%i",i+1,sms.Number); 3819 printmsg("Sending SMS %i/%i",i+1,sms.Number);
3820 sms.SMS[i].Location = 0; 3820 sms.SMS[i].Location = 0;
3821 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; 3821 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
3822 sms.SMS[i].SMSC.Location = SMSCSet; 3822 sms.SMS[i].SMSC.Location = SMSCSet;
3823 sms.SMS[i].PDU = SMS_Submit; 3823 sms.SMS[i].PDU = SMS_Submit;
3824 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; 3824 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report;
3825 CopyUnicodeString(sms.SMS[i].Number, Sender); 3825 CopyUnicodeString(sms.SMS[i].Number, Sender);
3826 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3826 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3827 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); 3827 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
3828 SMSStatus = ERR_TIMEOUT; 3828 SMSStatus = ERR_TIMEOUT;
3829 error=Phone->SendSMS(&s, &sms.SMS[i]); 3829 error=Phone->SendSMS(&s, &sms.SMS[i]);
3830 Print_Error(error); 3830 Print_Error(error);
3831 printmsg("....waiting for network answer"); 3831 printmsg("....waiting for network answer");
3832 while (!gshutdown) { 3832 while (!gshutdown) {
3833 GSM_ReadDevice(&s,true); 3833 GSM_ReadDevice(&s,true);
3834 if (SMSStatus == ERR_UNKNOWN) { 3834 if (SMSStatus == ERR_UNKNOWN) {
3835 GSM_Terminate(); 3835 GSM_Terminate();
3836 exit(-1); 3836 exit(-1);
3837 } 3837 }
3838 if (SMSStatus == ERR_NONE) break; 3838 if (SMSStatus == ERR_NONE) break;
3839 } 3839 }
3840 } 3840 }
3841 } 3841 }
3842 3842
3843 GSM_Terminate(); 3843 GSM_Terminate();
3844} 3844}
3845 3845
3846#ifdef GSM_ENABLE_BACKUP 3846#ifdef GSM_ENABLE_BACKUP
3847static void SaveFile(int argc, char *argv[]) 3847static void SaveFile(int argc, char *argv[])
3848{ 3848{
3849 GSM_Backup Backup; 3849 GSM_Backup Backup;
3850 int i,j; 3850 int i,j;
3851 FILE *file; 3851 FILE *file;
3852 unsigned char Buffer[10000]; 3852 unsigned char Buffer[10000];
3853 GSM_MemoryEntry *pbk; 3853 GSM_MemoryEntry *pbk;
3854 3854
3855 if (mystrncasecmp(argv[2],"CALENDAR",0)) { 3855 if (mystrncasecmp(argv[2],"CALENDAR",0)) {
3856 if (argc<5) { 3856 if (argc<5) {
3857 printmsg("Where is backup filename and location ?\n"); 3857 printmsg("Where is backup filename and location ?\n");
3858 exit(-1); 3858 exit(-1);
3859 } 3859 }
3860 error=GSM_ReadBackupFile(argv[4],&Backup); 3860 error=GSM_ReadBackupFile(argv[4],&Backup);
3861 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 3861 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3862 i = 0; 3862 i = 0;
3863 while (Backup.Calendar[i]!=NULL) { 3863 while (Backup.Calendar[i]!=NULL) {
3864 if (i == atoi(argv[5])-1) break; 3864 if (i == atoi(argv[5])-1) break;
3865 i++; 3865 i++;
3866 } 3866 }
3867 if (i != atoi(argv[5])-1) { 3867 if (i != atoi(argv[5])-1) {
3868 printmsg("Calendar note not found in file\n"); 3868 printmsg("Calendar note not found in file\n");
3869 exit(-1); 3869 exit(-1);
3870 } 3870 }
3871 j = 0; 3871 j = 0;
3872 GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar); 3872 GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar);
3873 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { 3873 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
3874 if (argc<5) { 3874 if (argc<5) {
3875 printmsg("Where is backup filename and location ?\n"); 3875 printmsg("Where is backup filename and location ?\n");
3876 exit(-1); 3876 exit(-1);
3877 } 3877 }
3878 error=GSM_ReadBackupFile(argv[4],&Backup); 3878 error=GSM_ReadBackupFile(argv[4],&Backup);
3879 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 3879 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3880 i = 0; 3880 i = 0;
3881 while (Backup.WAPBookmark[i]!=NULL) { 3881 while (Backup.WAPBookmark[i]!=NULL) {
3882 if (i == atoi(argv[5])-1) break; 3882 if (i == atoi(argv[5])-1) break;
3883 i++; 3883 i++;
3884 } 3884 }
3885 if (i != atoi(argv[5])-1) { 3885 if (i != atoi(argv[5])-1) {
3886 printmsg("WAP bookmark not found in file\n"); 3886 printmsg("WAP bookmark not found in file\n");
3887 exit(-1); 3887 exit(-1);
3888 } 3888 }
3889 j = 0; 3889 j = 0;
3890 GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]); 3890 GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]);
3891 } else if (mystrncasecmp(argv[2],"NOTE",0)) { 3891 } else if (mystrncasecmp(argv[2],"NOTE",0)) {
3892 if (argc<5) { 3892 if (argc<5) {
3893 printmsg("Where is backup filename and location ?\n"); 3893 printmsg("Where is backup filename and location ?\n");
3894 exit(-1); 3894 exit(-1);
3895 } 3895 }
3896 error=GSM_ReadBackupFile(argv[4],&Backup); 3896 error=GSM_ReadBackupFile(argv[4],&Backup);
3897 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 3897 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3898 i = 0; 3898 i = 0;
3899 while (Backup.Note[i]!=NULL) { 3899 while (Backup.Note[i]!=NULL) {
3900 if (i == atoi(argv[5])-1) break; 3900 if (i == atoi(argv[5])-1) break;
3901 i++; 3901 i++;
3902 } 3902 }
3903 if (i != atoi(argv[5])-1) { 3903 if (i != atoi(argv[5])-1) {
3904 printmsg("Note not found in file\n"); 3904 printmsg("Note not found in file\n");
3905 exit(-1); 3905 exit(-1);
3906 } 3906 }
3907 j = 0; 3907 j = 0;
3908 GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]); 3908 GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]);
3909 } else if (mystrncasecmp(argv[2],"TODO",0)) { 3909 } else if (mystrncasecmp(argv[2],"TODO",0)) {
3910 if (argc<5) { 3910 if (argc<5) {
3911 printmsg("Where is backup filename and location ?\n"); 3911 printmsg("Where is backup filename and location ?\n");
3912 exit(-1); 3912 exit(-1);
3913 } 3913 }
3914 error=GSM_ReadBackupFile(argv[4],&Backup); 3914 error=GSM_ReadBackupFile(argv[4],&Backup);
3915 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 3915 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3916 i = 0; 3916 i = 0;
3917 while (Backup.ToDo[i]!=NULL) { 3917 while (Backup.ToDo[i]!=NULL) {
3918 if (i == atoi(argv[5])-1) break; 3918 if (i == atoi(argv[5])-1) break;
3919 i++; 3919 i++;
3920 } 3920 }
3921 if (i != atoi(argv[5])-1) { 3921 if (i != atoi(argv[5])-1) {
3922 printmsg("ToDo note not found in file\n"); 3922 printmsg("ToDo note not found in file\n");
3923 exit(-1); 3923 exit(-1);
3924 } 3924 }
3925 j = 0; 3925 j = 0;
3926 GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo); 3926 GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo);
3927 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { 3927 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
3928 if (argc<6) { 3928 if (argc<6) {
3929 printmsg("Where is backup filename and location and memory type ?\n"); 3929 printmsg("Where is backup filename and location and memory type ?\n");
3930 exit(-1); 3930 exit(-1);
3931 } 3931 }
3932 error=GSM_ReadBackupFile(argv[4],&Backup); 3932 error=GSM_ReadBackupFile(argv[4],&Backup);
3933 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 3933 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3934 i = 0; 3934 i = 0;
3935 if (mystrncasecmp(argv[5],"SM",0)) { 3935 if (mystrncasecmp(argv[5],"SM",0)) {
3936 while (Backup.SIMPhonebook[i]!=NULL) { 3936 while (Backup.SIMPhonebook[i]!=NULL) {
3937 if (i == atoi(argv[6])-1) break; 3937 if (i == atoi(argv[6])-1) break;
3938 i++; 3938 i++;
3939 } 3939 }
3940 if (i != atoi(argv[6])-1) { 3940 if (i != atoi(argv[6])-1) {
3941 printmsg("Phonebook entry not found in file\n"); 3941 printmsg("Phonebook entry not found in file\n");
3942 exit(-1); 3942 exit(-1);
3943 } 3943 }
3944 pbk = Backup.SIMPhonebook[i]; 3944 pbk = Backup.SIMPhonebook[i];
3945 } else if (mystrncasecmp(argv[5],"ME",0)) { 3945 } else if (mystrncasecmp(argv[5],"ME",0)) {
3946 while (Backup.PhonePhonebook[i]!=NULL) { 3946 while (Backup.PhonePhonebook[i]!=NULL) {
3947 if (i == atoi(argv[6])-1) break; 3947 if (i == atoi(argv[6])-1) break;
3948 i++; 3948 i++;
3949 } 3949 }
3950 if (i != atoi(argv[6])-1) { 3950 if (i != atoi(argv[6])-1) {
3951 printmsg("Phonebook entry not found in file\n"); 3951 printmsg("Phonebook entry not found in file\n");
3952 exit(-1); 3952 exit(-1);
3953 } 3953 }
3954 pbk = Backup.PhonePhonebook[i]; 3954 pbk = Backup.PhonePhonebook[i];
3955 } else { 3955 } else {
3956 printmsg("Unknown memory type: \"%s\"\n",argv[5]); 3956 printmsg("Unknown memory type: \"%s\"\n",argv[5]);
3957 exit(-1); 3957 exit(-1);
3958 } 3958 }
3959 j = 0; 3959 j = 0;
3960 if (mystrncasecmp(argv[2],"VCARD10",0)) { 3960 if (mystrncasecmp(argv[2],"VCARD10",0)) {
3961 GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10); 3961 GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10);
3962 } else { 3962 } else {
3963 GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21); 3963 GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21);
3964 } 3964 }
3965 } else { 3965 } else {
3966 printmsg("What format of file (\"%s\") ?\n",argv[2]); 3966 printmsg("What format of file (\"%s\") ?\n",argv[2]);
3967 exit(-1); 3967 exit(-1);
3968 } 3968 }
3969 3969
3970 file = fopen(argv[3],"wb"); 3970 file = fopen(argv[3],"wb");
3971 fwrite(Buffer,1,j,file); 3971 fwrite(Buffer,1,j,file);
3972 fclose(file); 3972 fclose(file);
3973} 3973}
3974 3974
3975static void Backup(int argc, char *argv[]) 3975static void Backup(int argc, char *argv[])
3976{ 3976{
3977 int i, used; 3977 int i, used;
3978 GSM_MemoryStatusMemStatus; 3978 GSM_MemoryStatusMemStatus;
3979 GSM_ToDoEntry ToDo; 3979 GSM_ToDoEntry ToDo;
3980 GSM_ToDoStatus ToDoStatus; 3980 GSM_ToDoStatus ToDoStatus;
3981 GSM_MemoryEntry Pbk; 3981 GSM_MemoryEntry Pbk;
3982 GSM_CalendarEntryCalendar; 3982 GSM_CalendarEntryCalendar;
3983 GSM_Bitmap Bitmap; 3983 GSM_Bitmap Bitmap;
3984 GSM_WAPBookmark Bookmark; 3984 GSM_WAPBookmark Bookmark;
3985 GSM_Profile Profile; 3985 GSM_Profile Profile;
3986 GSM_MultiWAPSettingsSettings; 3986 GSM_MultiWAPSettingsSettings;
3987 GSM_SyncMLSettingsSyncML; 3987 GSM_SyncMLSettingsSyncML;
3988 GSM_ChatSettingsChat; 3988 GSM_ChatSettingsChat;
3989 GSM_Ringtone Ringtone; 3989 GSM_Ringtone Ringtone;
3990 GSM_SMSC SMSC; 3990 GSM_SMSC SMSC;
3991 GSM_Backup Backup; 3991 GSM_Backup Backup;
3992 GSM_NoteEntry Note; 3992 GSM_NoteEntry Note;
3993 GSM_Backup_Info Info; 3993 GSM_Backup_Info Info;
3994 GSM_FMStation FMStation; 3994 GSM_FMStation FMStation;
3995 GSM_GPRSAccessPointGPRSPoint; 3995 GSM_GPRSAccessPointGPRSPoint;
3996 bool DoBackup; 3996 bool DoBackup;
3997 3997
3998 if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true; 3998 if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true;
3999 3999
4000 GSM_ClearBackup(&Backup); 4000 GSM_ClearBackup(&Backup);
4001 GSM_GetBackupFormatFeatures(argv[2],&Info); 4001 GSM_GetBackupFormatFeatures(argv[2],&Info);
4002 4002
4003 sprintf(Backup.Creator,"Gammu %s",VERSION); 4003 sprintf(Backup.Creator,"Gammu %s",VERSION);
4004 if (strlen(GetOS()) != 0) { 4004 if (strlen(GetOS()) != 0) {
4005 strcat(Backup.Creator+strlen(Backup.Creator),", "); 4005 strcat(Backup.Creator+strlen(Backup.Creator),", ");
4006 strcat(Backup.Creator+strlen(Backup.Creator),GetOS()); 4006 strcat(Backup.Creator+strlen(Backup.Creator),GetOS());
4007 } 4007 }
4008 if (strlen(GetCompiler()) != 0) { 4008 if (strlen(GetCompiler()) != 0) {
4009 strcat(Backup.Creator+strlen(Backup.Creator),", "); 4009 strcat(Backup.Creator+strlen(Backup.Creator),", ");
4010 strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler()); 4010 strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler());
4011 } 4011 }
4012 4012
4013 signal(SIGINT, interrupt); 4013 signal(SIGINT, interrupt);
4014 printmsgerr("Press Ctrl+C to break...\n"); 4014 printmsgerr("Press Ctrl+C to break...\n");
4015 4015
4016 GSM_Init(true); 4016 GSM_Init(true);
4017 4017
4018 if (Info.UseUnicode) { 4018 if (Info.UseUnicode) {
4019 Info.UseUnicode=answer_yes("Use Unicode subformat of backup file"); 4019 Info.UseUnicode=answer_yes("Use Unicode subformat of backup file");
4020 } 4020 }
4021 if (Info.DateTime) { 4021 if (Info.DateTime) {
4022 GSM_GetCurrentDateTime (&Backup.DateTime); 4022 GSM_GetCurrentDateTime (&Backup.DateTime);
4023 Backup.DateTimeAvailable=true; 4023 Backup.DateTimeAvailable=true;
4024 } 4024 }
4025 if (Info.Model) { 4025 if (Info.Model) {
4026 error=Phone->GetManufacturer(&s); 4026 error=Phone->GetManufacturer(&s);
4027 Print_Error(error); 4027 Print_Error(error);
4028 sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer); 4028 sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer);
4029 if (s.Phone.Data.ModelInfo->model[0]!=0) { 4029 if (s.Phone.Data.ModelInfo->model[0]!=0) {
4030 strcat(Backup.Model,s.Phone.Data.ModelInfo->model); 4030 strcat(Backup.Model,s.Phone.Data.ModelInfo->model);
4031 } else { 4031 } else {
4032 strcat(Backup.Model,s.Phone.Data.Model); 4032 strcat(Backup.Model,s.Phone.Data.Model);
4033 } 4033 }
4034 strcat(Backup.Model," "); 4034 strcat(Backup.Model," ");
4035 strcat(Backup.Model,s.Phone.Data.Version); 4035 strcat(Backup.Model,s.Phone.Data.Version);
4036 } 4036 }
4037 if (Info.IMEI) { 4037 if (Info.IMEI) {
4038 error=Phone->GetIMEI(&s); 4038 error=Phone->GetIMEI(&s);
4039 if (error != ERR_NOTSUPPORTED) { 4039 if (error != ERR_NOTSUPPORTED) {
4040 strcpy(Backup.IMEI, s.Phone.Data.IMEI); 4040 strcpy(Backup.IMEI, s.Phone.Data.IMEI);
4041 Print_Error(error); 4041 Print_Error(error);
4042 } else { 4042 } else {
4043 Backup.IMEI[0] = 0; 4043 Backup.IMEI[0] = 0;
4044 } 4044 }
4045 } 4045 }
4046 printf("\n"); 4046 printf("\n");
4047 4047
4048 DoBackup = false; 4048 DoBackup = false;
4049 if (Info.PhonePhonebook) { 4049 if (Info.PhonePhonebook) {
4050 printmsg("Checking phone phonebook\n"); 4050 printmsg("Checking phone phonebook\n");
4051 MemStatus.MemoryType = MEM_ME; 4051 MemStatus.MemoryType = MEM_ME;
4052 error=Phone->GetMemoryStatus(&s, &MemStatus); 4052 error=Phone->GetMemoryStatus(&s, &MemStatus);
4053 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { 4053 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
4054 if (answer_yes(" Backup phone phonebook")) DoBackup = true; 4054 if (answer_yes(" Backup phone phonebook")) DoBackup = true;
4055 } 4055 }
4056 } 4056 }
4057 if (DoBackup) { 4057 if (DoBackup) {
4058 Pbk.MemoryType = MEM_ME; 4058 Pbk.MemoryType = MEM_ME;
4059 i = 1; 4059 i = 1;
4060 used = 0; 4060 used = 0;
4061 while (used != MemStatus.MemoryUsed) { 4061 while (used != MemStatus.MemoryUsed) {
4062 Pbk.Location = i; 4062 Pbk.Location = i;
4063 error=Phone->GetMemory(&s, &Pbk); 4063 error=Phone->GetMemory(&s, &Pbk);
4064 if (error != ERR_EMPTY) { 4064 if (error != ERR_EMPTY) {
4065 Print_Error(error); 4065 Print_Error(error);
4066 if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) { 4066 if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) {
4067 Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); 4067 Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry));
4068 if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); 4068 if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY);
4069 Backup.PhonePhonebook[used+1] = NULL; 4069 Backup.PhonePhonebook[used+1] = NULL;
4070 } else { 4070 } else {
4071 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK"); 4071 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK");
4072 GSM_Terminate(); 4072 GSM_Terminate();
4073 exit(-1); 4073 exit(-1);
4074 } 4074 }
4075 *Backup.PhonePhonebook[used]=Pbk; 4075 *Backup.PhonePhonebook[used]=Pbk;
4076 used++; 4076 used++;
4077 } 4077 }
4078 printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); 4078 printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed);
4079 i++; 4079 i++;
4080 if (gshutdown) { 4080 if (gshutdown) {
4081 GSM_Terminate(); 4081 GSM_Terminate();
4082 exit(0); 4082 exit(0);
4083 } 4083 }
4084 } 4084 }
4085 printmsgerr("\n"); 4085 printmsgerr("\n");
4086 } 4086 }
4087 DoBackup = false; 4087 DoBackup = false;
4088 if (Info.SIMPhonebook) { 4088 if (Info.SIMPhonebook) {
4089 printmsg("Checking SIM phonebook\n"); 4089 printmsg("Checking SIM phonebook\n");
4090 MemStatus.MemoryType = MEM_SM; 4090 MemStatus.MemoryType = MEM_SM;
4091 error=Phone->GetMemoryStatus(&s, &MemStatus); 4091 error=Phone->GetMemoryStatus(&s, &MemStatus);
4092 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { 4092 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
4093 if (answer_yes(" Backup SIM phonebook")) DoBackup=true; 4093 if (answer_yes(" Backup SIM phonebook")) DoBackup=true;
4094 } 4094 }
4095 } 4095 }
4096 if (DoBackup) { 4096 if (DoBackup) {
4097 Pbk.MemoryType = MEM_SM; 4097 Pbk.MemoryType = MEM_SM;
4098 i = 1; 4098 i = 1;
4099 used = 0; 4099 used = 0;
4100 while (used != MemStatus.MemoryUsed) { 4100 while (used != MemStatus.MemoryUsed) {
4101 Pbk.Location = i; 4101 Pbk.Location = i;
4102 error=Phone->GetMemory(&s, &Pbk); 4102 error=Phone->GetMemory(&s, &Pbk);
4103 if (error != ERR_EMPTY) { 4103 if (error != ERR_EMPTY) {
4104 Print_Error(error); 4104 Print_Error(error);
4105 if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) { 4105 if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) {
4106 Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); 4106 Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry));
4107 if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); 4107 if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY);
4108 Backup.SIMPhonebook[used + 1] = NULL; 4108 Backup.SIMPhonebook[used + 1] = NULL;
4109 } else { 4109 } else {
4110 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK"); 4110 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK");
4111 GSM_Terminate(); 4111 GSM_Terminate();
4112 exit(-1); 4112 exit(-1);
4113 } 4113 }
4114 *Backup.SIMPhonebook[used]=Pbk; 4114 *Backup.SIMPhonebook[used]=Pbk;
4115 used++; 4115 used++;
4116 } 4116 }
4117 printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); 4117 printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed);
4118 i++; 4118 i++;
4119 if (gshutdown) { 4119 if (gshutdown) {
4120 GSM_Terminate(); 4120 GSM_Terminate();
4121 exit(0); 4121 exit(0);
4122 } 4122 }
4123 } 4123 }
4124 printmsgerr("\n"); 4124 printmsgerr("\n");
4125 } 4125 }
4126 DoBackup = false; 4126 DoBackup = false;
4127 if (Info.Calendar) { 4127 if (Info.Calendar) {
4128 printmsg("Checking calendar\n"); 4128 printmsg("Checking calendar\n");
4129 error=Phone->GetNextCalendar(&s,&Calendar,true); 4129 error=Phone->GetNextCalendar(&s,&Calendar,true);
4130 if (error==ERR_NONE) { 4130 if (error==ERR_NONE) {
4131 if (answer_yes(" Backup calendar notes")) DoBackup = true; 4131 if (answer_yes(" Backup calendar notes")) DoBackup = true;
4132 } 4132 }
4133 } 4133 }
4134 if (DoBackup) { 4134 if (DoBackup) {
4135 used = 0; 4135 used = 0;
4136 printmsgerr(" Reading : "); 4136 printmsgerr(" Reading : ");
4137 while (error == ERR_NONE) { 4137 while (error == ERR_NONE) {
4138 if (used < GSM_MAXCALENDARTODONOTES) { 4138 if (used < GSM_MAXCALENDARTODONOTES) {
4139 Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); 4139 Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry));
4140 if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); 4140 if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY);
4141 Backup.Calendar[used+1] = NULL; 4141 Backup.Calendar[used+1] = NULL;
4142 } else { 4142 } else {
4143 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); 4143 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
4144 GSM_Terminate(); 4144 GSM_Terminate();
4145 exit(-1); 4145 exit(-1);
4146 } 4146 }
4147 *Backup.Calendar[used]=Calendar; 4147 *Backup.Calendar[used]=Calendar;
4148 used ++; 4148 used ++;
4149 error=Phone->GetNextCalendar(&s,&Calendar,false); 4149 error=Phone->GetNextCalendar(&s,&Calendar,false);
4150 printmsgerr("*"); 4150 printmsgerr("*");
4151 if (gshutdown) { 4151 if (gshutdown) {
4152 GSM_Terminate(); 4152 GSM_Terminate();
4153 exit(0); 4153 exit(0);
4154 } 4154 }
4155 } 4155 }
4156 printmsgerr("\n"); 4156 printmsgerr("\n");
4157 } 4157 }
4158 DoBackup = false; 4158 DoBackup = false;
4159 if (Info.ToDo) { 4159 if (Info.ToDo) {
4160 printmsg("Checking ToDo\n"); 4160 printmsg("Checking ToDo\n");
4161 error=Phone->GetToDoStatus(&s,&ToDoStatus); 4161 error=Phone->GetToDoStatus(&s,&ToDoStatus);
4162 if (error == ERR_NONE && ToDoStatus.Used != 0) { 4162 if (error == ERR_NONE && ToDoStatus.Used != 0) {
4163 if (answer_yes(" Backup ToDo")) DoBackup = true; 4163 if (answer_yes(" Backup ToDo")) DoBackup = true;
4164 } 4164 }
4165 } 4165 }
4166 if (DoBackup) { 4166 if (DoBackup) {
4167 used = 0; 4167 used = 0;
4168 error=Phone->GetNextToDo(&s,&ToDo,true); 4168 error=Phone->GetNextToDo(&s,&ToDo,true);
4169 while (error == ERR_NONE) { 4169 while (error == ERR_NONE) {
4170 if (used < GSM_MAXCALENDARTODONOTES) { 4170 if (used < GSM_MAXCALENDARTODONOTES) {
4171 Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry)); 4171 Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry));
4172 if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY); 4172 if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY);
4173 Backup.ToDo[used+1] = NULL; 4173 Backup.ToDo[used+1] = NULL;
4174 } else { 4174 } else {
4175 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); 4175 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
4176 GSM_Terminate(); 4176 GSM_Terminate();
4177 exit(-1); 4177 exit(-1);
4178 } 4178 }
4179 *Backup.ToDo[used]=ToDo; 4179 *Backup.ToDo[used]=ToDo;
4180 used ++; 4180 used ++;
4181 error=Phone->GetNextToDo(&s,&ToDo,false); 4181 error=Phone->GetNextToDo(&s,&ToDo,false);
4182 printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used); 4182 printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used);
4183 if (gshutdown) { 4183 if (gshutdown) {
4184 GSM_Terminate(); 4184 GSM_Terminate();
4185 exit(0); 4185 exit(0);
4186 } 4186 }
4187 } 4187 }
4188 printmsgerr("\n"); 4188 printmsgerr("\n");
4189 } 4189 }
4190 DoBackup = false; 4190 DoBackup = false;
4191 if (Info.Note) { 4191 if (Info.Note) {
4192 printmsg("Checking notes\n"); 4192 printmsg("Checking notes\n");
4193 error=Phone->GetNextNote(&s,&Note,true); 4193 error=Phone->GetNextNote(&s,&Note,true);
4194 if (error==ERR_NONE) { 4194 if (error==ERR_NONE) {
4195 if (answer_yes(" Backup notes")) DoBackup = true; 4195 if (answer_yes(" Backup notes")) DoBackup = true;
4196 } 4196 }
4197 } 4197 }
4198 if (DoBackup) { 4198 if (DoBackup) {
4199 used = 0; 4199 used = 0;
4200 printmsgerr(" Reading : "); 4200 printmsgerr(" Reading : ");
4201 while (error == ERR_NONE) { 4201 while (error == ERR_NONE) {
4202 if (used < GSM_BACKUP_MAX_NOTE) { 4202 if (used < GSM_BACKUP_MAX_NOTE) {
4203 Backup.Note[used] = malloc(sizeof(GSM_NoteEntry)); 4203 Backup.Note[used] = malloc(sizeof(GSM_NoteEntry));
4204 if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY); 4204 if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY);
4205 Backup.Note[used+1] = NULL; 4205 Backup.Note[used+1] = NULL;
4206 } else { 4206 } else {
4207 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE"); 4207 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE");
4208 GSM_Terminate(); 4208 GSM_Terminate();
4209 exit(-1); 4209 exit(-1);
4210 } 4210 }
4211 *Backup.Note[used]=Note; 4211 *Backup.Note[used]=Note;
4212 used ++; 4212 used ++;
4213 error=Phone->GetNextNote(&s,&Note,false); 4213 error=Phone->GetNextNote(&s,&Note,false);
4214 printmsgerr("*"); 4214 printmsgerr("*");
4215 if (gshutdown) { 4215 if (gshutdown) {
4216 GSM_Terminate(); 4216 GSM_Terminate();
4217 exit(0); 4217 exit(0);
4218 } 4218 }
4219 } 4219 }
4220 printmsgerr("\n"); 4220 printmsgerr("\n");
4221 } 4221 }
4222 DoBackup = false; 4222 DoBackup = false;
4223 if (Info.CallerLogos) { 4223 if (Info.CallerLogos) {
4224 printmsg("Checking caller logos\n"); 4224 printmsg("Checking caller logos\n");
4225 Bitmap.Type = GSM_CallerGroupLogo; 4225 Bitmap.Type = GSM_CallerGroupLogo;
4226 Bitmap.Location = 1; 4226 Bitmap.Location = 1;
4227 error=Phone->GetBitmap(&s,&Bitmap); 4227 error=Phone->GetBitmap(&s,&Bitmap);
4228 if (error == ERR_NONE) { 4228 if (error == ERR_NONE) {
4229 if (answer_yes(" Backup caller groups and logos")) DoBackup = true; 4229 if (answer_yes(" Backup caller groups and logos")) DoBackup = true;
4230 } 4230 }
4231 } 4231 }
4232 if (DoBackup) { 4232 if (DoBackup) {
4233 printmsgerr(" Reading : "); 4233 printmsgerr(" Reading : ");
4234 error = ERR_NONE; 4234 error = ERR_NONE;
4235 used = 0; 4235 used = 0;
4236 while (error == ERR_NONE) { 4236 while (error == ERR_NONE) {
4237 if (used < GSM_BACKUP_MAX_CALLER) { 4237 if (used < GSM_BACKUP_MAX_CALLER) {
4238 Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap)); 4238 Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap));
4239 if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY); 4239 if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY);
4240 Backup.CallerLogos[used+1] = NULL; 4240 Backup.CallerLogos[used+1] = NULL;
4241 } else { 4241 } else {
4242 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER"); 4242 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER");
4243 GSM_Terminate(); 4243 GSM_Terminate();
4244 exit(-1); 4244 exit(-1);
4245 } 4245 }
4246 *Backup.CallerLogos[used] = Bitmap; 4246 *Backup.CallerLogos[used] = Bitmap;
4247 used ++; 4247 used ++;
4248 Bitmap.Location = used + 1; 4248 Bitmap.Location = used + 1;
4249 error=Phone->GetBitmap(&s,&Bitmap); 4249 error=Phone->GetBitmap(&s,&Bitmap);
4250 printmsgerr("*"); 4250 printmsgerr("*");
4251 if (gshutdown) { 4251 if (gshutdown) {
4252 GSM_Terminate(); 4252 GSM_Terminate();
4253 exit(0); 4253 exit(0);
4254 } 4254 }
4255 } 4255 }
4256 printmsgerr("\n"); 4256 printmsgerr("\n");
4257 } 4257 }
4258 DoBackup = false; 4258 DoBackup = false;
4259 if (Info.SMSC) { 4259 if (Info.SMSC) {
4260 printmsg("Checking SMS profiles\n"); 4260 printmsg("Checking SMS profiles\n");
4261 if (answer_yes(" Backup SMS profiles")) DoBackup = true; 4261 if (answer_yes(" Backup SMS profiles")) DoBackup = true;
4262 } 4262 }
4263 if (DoBackup) { 4263 if (DoBackup) {
4264 used = 0; 4264 used = 0;
4265 printmsgerr(" Reading: "); 4265 printmsgerr(" Reading: ");
4266 while (true) { 4266 while (true) {
4267 SMSC.Location = used + 1; 4267 SMSC.Location = used + 1;
4268 error = Phone->GetSMSC(&s,&SMSC); 4268 error = Phone->GetSMSC(&s,&SMSC);
4269 if (error != ERR_NONE) break; 4269 if (error != ERR_NONE) break;
4270 if (used < GSM_BACKUP_MAX_SMSC) { 4270 if (used < GSM_BACKUP_MAX_SMSC) {
4271 Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); 4271 Backup.SMSC[used] = malloc(sizeof(GSM_SMSC));
4272 if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); 4272 if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY);
4273 Backup.SMSC[used + 1] = NULL; 4273 Backup.SMSC[used + 1] = NULL;
4274 } else { 4274 } else {
4275 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC"); 4275 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC");
4276 GSM_Terminate(); 4276 GSM_Terminate();
4277 exit(-1); 4277 exit(-1);
4278 } 4278 }
4279 *Backup.SMSC[used]=SMSC; 4279 *Backup.SMSC[used]=SMSC;
4280 used++; 4280 used++;
4281 printmsgerr("*"); 4281 printmsgerr("*");
4282 } 4282 }
4283 printmsgerr("\n"); 4283 printmsgerr("\n");
4284 } 4284 }
4285 DoBackup = false; 4285 DoBackup = false;
4286 if (Info.StartupLogo) { 4286 if (Info.StartupLogo) {
4287 printmsg("Checking startup text\n"); 4287 printmsg("Checking startup text\n");
4288 Bitmap.Type = GSM_WelcomeNote_Text; 4288 Bitmap.Type = GSM_WelcomeNote_Text;
4289 error = Phone->GetBitmap(&s,&Bitmap); 4289 error = Phone->GetBitmap(&s,&Bitmap);
4290 if (error == ERR_NONE) { 4290 if (error == ERR_NONE) {
4291 if (answer_yes(" Backup startup logo/text")) DoBackup = true; 4291 if (answer_yes(" Backup startup logo/text")) DoBackup = true;
4292 } 4292 }
4293 } 4293 }
4294 if (DoBackup) { 4294 if (DoBackup) {
4295 Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); 4295 Backup.StartupLogo = malloc(sizeof(GSM_Bitmap));
4296 if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); 4296 if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY);
4297 *Backup.StartupLogo = Bitmap; 4297 *Backup.StartupLogo = Bitmap;
4298 if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { 4298 if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) {
4299 Bitmap.Type = GSM_StartupLogo; 4299 Bitmap.Type = GSM_StartupLogo;
4300 error = Phone->GetBitmap(&s,&Bitmap); 4300 error = Phone->GetBitmap(&s,&Bitmap);
4301 if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; 4301 if (error == ERR_NONE) *Backup.StartupLogo = Bitmap;
4302 } 4302 }
4303 } 4303 }
4304 DoBackup = false; 4304 DoBackup = false;
4305 if (Info.OperatorLogo) { 4305 if (Info.OperatorLogo) {
4306 printmsg("Checking operator logo\n"); 4306 printmsg("Checking operator logo\n");
4307 Bitmap.Type = GSM_OperatorLogo; 4307 Bitmap.Type = GSM_OperatorLogo;
4308 error=Phone->GetBitmap(&s,&Bitmap); 4308 error=Phone->GetBitmap(&s,&Bitmap);
4309 if (error == ERR_NONE) { 4309 if (error == ERR_NONE) {
4310 if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { 4310 if (strcmp(Bitmap.NetworkCode,"000 00")!=0) {
4311 if (answer_yes(" Backup operator logo")) DoBackup = true; 4311 if (answer_yes(" Backup operator logo")) DoBackup = true;
4312 } 4312 }
4313 } 4313 }
4314 } 4314 }
4315 if (DoBackup) { 4315 if (DoBackup) {
4316 Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); 4316 Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap));
4317 if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); 4317 if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY);
4318 *Backup.OperatorLogo = Bitmap; 4318 *Backup.OperatorLogo = Bitmap;
4319 } 4319 }
4320 DoBackup = false; 4320 DoBackup = false;
4321 if (Info.WAPBookmark) { 4321 if (Info.WAPBookmark) {
4322 printmsg("Checking WAP bookmarks\n"); 4322 printmsg("Checking WAP bookmarks\n");
4323 Bookmark.Location = 1; 4323 Bookmark.Location = 1;
4324 error=Phone->GetWAPBookmark(&s,&Bookmark); 4324 error=Phone->GetWAPBookmark(&s,&Bookmark);
4325 if (error==ERR_NONE) { 4325 if (error==ERR_NONE) {
4326 if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; 4326 if (answer_yes(" Backup WAP bookmarks")) DoBackup = true;
4327 } 4327 }
4328 } 4328 }
4329 if (DoBackup) { 4329 if (DoBackup) {
4330 used = 0; 4330 used = 0;
4331 printmsgerr(" Reading : "); 4331 printmsgerr(" Reading : ");
4332 while (error == ERR_NONE) { 4332 while (error == ERR_NONE) {
4333 if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { 4333 if (used < GSM_BACKUP_MAX_WAPBOOKMARK) {
4334 Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); 4334 Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark));
4335 if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); 4335 if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY);
4336 Backup.WAPBookmark[used+1] = NULL; 4336 Backup.WAPBookmark[used+1] = NULL;
4337 } else { 4337 } else {
4338 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); 4338 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
4339 GSM_Terminate(); 4339 GSM_Terminate();
4340 exit(-1); 4340 exit(-1);
4341 } 4341 }
4342 *Backup.WAPBookmark[used]=Bookmark; 4342 *Backup.WAPBookmark[used]=Bookmark;
4343 used ++; 4343 used ++;
4344 Bookmark.Location = used+1; 4344 Bookmark.Location = used+1;
4345 error=Phone->GetWAPBookmark(&s,&Bookmark); 4345 error=Phone->GetWAPBookmark(&s,&Bookmark);
4346 printmsgerr("*"); 4346 printmsgerr("*");
4347 if (gshutdown) { 4347 if (gshutdown) {
4348 GSM_Terminate(); 4348 GSM_Terminate();
4349 exit(0); 4349 exit(0);
4350 } 4350 }
4351 } 4351 }
4352 printmsgerr("\n"); 4352 printmsgerr("\n");
4353 } 4353 }
4354 DoBackup = false; 4354 DoBackup = false;
4355 if (Info.WAPSettings) { 4355 if (Info.WAPSettings) {
4356 printmsg("Checking WAP settings\n"); 4356 printmsg("Checking WAP settings\n");
4357 Settings.Location = 1; 4357 Settings.Location = 1;
4358 error=Phone->GetWAPSettings(&s,&Settings); 4358 error=Phone->GetWAPSettings(&s,&Settings);
4359 if (error==ERR_NONE) { 4359 if (error==ERR_NONE) {
4360 if (answer_yes(" Backup WAP settings")) DoBackup = true; 4360 if (answer_yes(" Backup WAP settings")) DoBackup = true;
4361 } 4361 }
4362 } 4362 }
4363 if (DoBackup) { 4363 if (DoBackup) {
4364 used = 0; 4364 used = 0;
4365 printmsgerr(" Reading : "); 4365 printmsgerr(" Reading : ");
4366 while (error == ERR_NONE) { 4366 while (error == ERR_NONE) {
4367 if (used < GSM_BACKUP_MAX_WAPSETTINGS) { 4367 if (used < GSM_BACKUP_MAX_WAPSETTINGS) {
4368 Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); 4368 Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
4369 if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4369 if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4370 Backup.WAPSettings[used+1] = NULL; 4370 Backup.WAPSettings[used+1] = NULL;
4371 } else { 4371 } else {
4372 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); 4372 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
4373 GSM_Terminate(); 4373 GSM_Terminate();
4374 exit(-1); 4374 exit(-1);
4375 } 4375 }
4376 *Backup.WAPSettings[used]=Settings; 4376 *Backup.WAPSettings[used]=Settings;
4377 used ++; 4377 used ++;
4378 Settings.Location = used+1; 4378 Settings.Location = used+1;
4379 error=Phone->GetWAPSettings(&s,&Settings); 4379 error=Phone->GetWAPSettings(&s,&Settings);
4380 printmsgerr("*"); 4380 printmsgerr("*");
4381 if (gshutdown) { 4381 if (gshutdown) {
4382 GSM_Terminate(); 4382 GSM_Terminate();
4383 exit(0); 4383 exit(0);
4384 } 4384 }
4385 } 4385 }
4386 printmsgerr("\n"); 4386 printmsgerr("\n");
4387 } 4387 }
4388 DoBackup = false; 4388 DoBackup = false;
4389 if (Info.MMSSettings) { 4389 if (Info.MMSSettings) {
4390 printmsg("Checking MMS settings\n"); 4390 printmsg("Checking MMS settings\n");
4391 Settings.Location = 1; 4391 Settings.Location = 1;
4392 error=Phone->GetMMSSettings(&s,&Settings); 4392 error=Phone->GetMMSSettings(&s,&Settings);
4393 if (error==ERR_NONE) { 4393 if (error==ERR_NONE) {
4394 if (answer_yes(" Backup MMS settings")) DoBackup = true; 4394 if (answer_yes(" Backup MMS settings")) DoBackup = true;
4395 } 4395 }
4396 } 4396 }
4397 if (DoBackup) { 4397 if (DoBackup) {
4398 used = 0; 4398 used = 0;
4399 printmsgerr(" Reading : "); 4399 printmsgerr(" Reading : ");
4400 while (error == ERR_NONE) { 4400 while (error == ERR_NONE) {
4401 if (used < GSM_BACKUP_MAX_MMSSETTINGS) { 4401 if (used < GSM_BACKUP_MAX_MMSSETTINGS) {
4402 Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); 4402 Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
4403 if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4403 if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4404 Backup.MMSSettings[used+1] = NULL; 4404 Backup.MMSSettings[used+1] = NULL;
4405 } else { 4405 } else {
4406 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS"); 4406 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS");
4407 GSM_Terminate(); 4407 GSM_Terminate();
4408 exit(-1); 4408 exit(-1);
4409 } 4409 }
4410 *Backup.MMSSettings[used]=Settings; 4410 *Backup.MMSSettings[used]=Settings;
4411 used ++; 4411 used ++;
4412 Settings.Location = used+1; 4412 Settings.Location = used+1;
4413 error=Phone->GetMMSSettings(&s,&Settings); 4413 error=Phone->GetMMSSettings(&s,&Settings);
4414 printmsgerr("*"); 4414 printmsgerr("*");
4415 if (gshutdown) { 4415 if (gshutdown) {
4416 GSM_Terminate(); 4416 GSM_Terminate();
4417 exit(0); 4417 exit(0);
4418 } 4418 }
4419 } 4419 }
4420 printmsgerr("\n"); 4420 printmsgerr("\n");
4421 } 4421 }
4422 DoBackup = false; 4422 DoBackup = false;
4423 if (Info.ChatSettings) { 4423 if (Info.ChatSettings) {
4424 printmsg("Checking Chat settings\n"); 4424 printmsg("Checking Chat settings\n");
4425 Chat.Location = 1; 4425 Chat.Location = 1;
4426 error=Phone->GetChatSettings(&s,&Chat); 4426 error=Phone->GetChatSettings(&s,&Chat);
4427 if (error==ERR_NONE) { 4427 if (error==ERR_NONE) {
4428 if (answer_yes(" Backup Chat settings")) DoBackup = true; 4428 if (answer_yes(" Backup Chat settings")) DoBackup = true;
4429 } 4429 }
4430 } 4430 }
4431 if (DoBackup) { 4431 if (DoBackup) {
4432 used = 0; 4432 used = 0;
4433 printmsgerr(" Reading : "); 4433 printmsgerr(" Reading : ");
4434 while (error == ERR_NONE) { 4434 while (error == ERR_NONE) {
4435 if (used < GSM_BACKUP_MAX_CHATSETTINGS) { 4435 if (used < GSM_BACKUP_MAX_CHATSETTINGS) {
4436 Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings)); 4436 Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings));
4437 if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4437 if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4438 Backup.ChatSettings[used+1] = NULL; 4438 Backup.ChatSettings[used+1] = NULL;
4439 } else { 4439 } else {
4440 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS"); 4440 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS");
4441 GSM_Terminate(); 4441 GSM_Terminate();
4442 exit(-1); 4442 exit(-1);
4443 } 4443 }
4444 *Backup.ChatSettings[used]=Chat; 4444 *Backup.ChatSettings[used]=Chat;
4445 used ++; 4445 used ++;
4446 Chat.Location = used+1; 4446 Chat.Location = used+1;
4447 error=Phone->GetChatSettings(&s,&Chat); 4447 error=Phone->GetChatSettings(&s,&Chat);
4448 printmsgerr("*"); 4448 printmsgerr("*");
4449 if (gshutdown) { 4449 if (gshutdown) {
4450 GSM_Terminate(); 4450 GSM_Terminate();
4451 exit(0); 4451 exit(0);
4452 } 4452 }
4453 } 4453 }
4454 printmsgerr("\n"); 4454 printmsgerr("\n");
4455 } 4455 }
4456 DoBackup = false; 4456 DoBackup = false;
4457 if (Info.SyncMLSettings) { 4457 if (Info.SyncMLSettings) {
4458 printmsg("Checking SyncML settings\n"); 4458 printmsg("Checking SyncML settings\n");
4459 SyncML.Location = 1; 4459 SyncML.Location = 1;
4460 error=Phone->GetSyncMLSettings(&s,&SyncML); 4460 error=Phone->GetSyncMLSettings(&s,&SyncML);
4461 if (error==ERR_NONE) { 4461 if (error==ERR_NONE) {
4462 if (answer_yes(" Backup SyncML settings")) DoBackup = true; 4462 if (answer_yes(" Backup SyncML settings")) DoBackup = true;
4463 } 4463 }
4464 } 4464 }
4465 if (DoBackup) { 4465 if (DoBackup) {
4466 used = 0; 4466 used = 0;
4467 printmsgerr(" Reading : "); 4467 printmsgerr(" Reading : ");
4468 while (error == ERR_NONE) { 4468 while (error == ERR_NONE) {
4469 if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) { 4469 if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) {
4470 Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings)); 4470 Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings));
4471 if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4471 if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4472 Backup.SyncMLSettings[used+1] = NULL; 4472 Backup.SyncMLSettings[used+1] = NULL;
4473 } else { 4473 } else {
4474 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS"); 4474 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS");
4475 GSM_Terminate(); 4475 GSM_Terminate();
4476 exit(-1); 4476 exit(-1);
4477 } 4477 }
4478 *Backup.SyncMLSettings[used]=SyncML; 4478 *Backup.SyncMLSettings[used]=SyncML;
4479 used ++; 4479 used ++;
4480 SyncML.Location = used+1; 4480 SyncML.Location = used+1;
4481 error=Phone->GetSyncMLSettings(&s,&SyncML); 4481 error=Phone->GetSyncMLSettings(&s,&SyncML);
4482 printmsgerr("*"); 4482 printmsgerr("*");
4483 if (gshutdown) { 4483 if (gshutdown) {
4484 GSM_Terminate(); 4484 GSM_Terminate();
4485 exit(0); 4485 exit(0);
4486 } 4486 }
4487 } 4487 }
4488 printmsgerr("\n"); 4488 printmsgerr("\n");
4489 } 4489 }
4490 DoBackup = false; 4490 DoBackup = false;
4491 if (Info.Ringtone) { 4491 if (Info.Ringtone) {
4492 printmsg("Checking user ringtones\n"); 4492 printmsg("Checking user ringtones\n");
4493 Ringtone.Location = 1; 4493 Ringtone.Location = 1;
4494 Ringtone.Format = 0; 4494 Ringtone.Format = 0;
4495 error=Phone->GetRingtone(&s,&Ringtone,false); 4495 error=Phone->GetRingtone(&s,&Ringtone,false);
4496 if (error==ERR_EMPTY || error == ERR_NONE) { 4496 if (error==ERR_EMPTY || error == ERR_NONE) {
4497 if (answer_yes(" Backup user ringtones")) DoBackup = true; 4497 if (answer_yes(" Backup user ringtones")) DoBackup = true;
4498 } 4498 }
4499 } 4499 }
4500 if (DoBackup) { 4500 if (DoBackup) {
4501 used = 0; 4501 used = 0;
4502 i= 1; 4502 i= 1;
4503 printmsgerr(" Reading : "); 4503 printmsgerr(" Reading : ");
4504 while (error == ERR_NONE || error == ERR_EMPTY) { 4504 while (error == ERR_NONE || error == ERR_EMPTY) {
4505 if (error == ERR_NONE) { 4505 if (error == ERR_NONE) {
4506 if (used < GSM_BACKUP_MAX_RINGTONES) { 4506 if (used < GSM_BACKUP_MAX_RINGTONES) {
4507 Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); 4507 Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone));
4508 if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); 4508 if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY);
4509 Backup.Ringtone[used+1] = NULL; 4509 Backup.Ringtone[used+1] = NULL;
4510 } else { 4510 } else {
4511 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES"); 4511 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES");
4512 GSM_Terminate(); 4512 GSM_Terminate();
4513 exit(-1); 4513 exit(-1);
4514 } 4514 }
4515 *Backup.Ringtone[used]=Ringtone; 4515 *Backup.Ringtone[used]=Ringtone;
4516 used ++; 4516 used ++;
4517 } 4517 }
4518 i++; 4518 i++;
4519 Ringtone.Location = i; 4519 Ringtone.Location = i;
4520 Ringtone.Format = 0; 4520 Ringtone.Format = 0;
4521 error=Phone->GetRingtone(&s,&Ringtone,false); 4521 error=Phone->GetRingtone(&s,&Ringtone,false);
4522 printmsgerr("*"); 4522 printmsgerr("*");
4523 if (gshutdown) { 4523 if (gshutdown) {
4524 GSM_Terminate(); 4524 GSM_Terminate();
4525 exit(0); 4525 exit(0);
4526 } 4526 }
4527 } 4527 }
4528 printmsgerr("\n"); 4528 printmsgerr("\n");
4529 } 4529 }
4530 DoBackup = false; 4530 DoBackup = false;
4531 if (Info.Profiles) { 4531 if (Info.Profiles) {
4532 printmsg("Checking phone profiles\n"); 4532 printmsg("Checking phone profiles\n");
4533 Profile.Location = 1; 4533 Profile.Location = 1;
4534 error = Phone->GetProfile(&s,&Profile); 4534 error = Phone->GetProfile(&s,&Profile);
4535 if (error == ERR_NONE) { 4535 if (error == ERR_NONE) {
4536 if (answer_yes(" Backup phone profiles")) DoBackup = true; 4536 if (answer_yes(" Backup phone profiles")) DoBackup = true;
4537 } 4537 }
4538 } 4538 }
4539 if (DoBackup) { 4539 if (DoBackup) {
4540 used = 0; 4540 used = 0;
4541 printmsgerr(" Reading: "); 4541 printmsgerr(" Reading: ");
4542 while (true) { 4542 while (true) {
4543 Profile.Location = used + 1; 4543 Profile.Location = used + 1;
4544 error = Phone->GetProfile(&s,&Profile); 4544 error = Phone->GetProfile(&s,&Profile);
4545 if (error != ERR_NONE) break; 4545 if (error != ERR_NONE) break;
4546 if (used < GSM_BACKUP_MAX_PROFILES) { 4546 if (used < GSM_BACKUP_MAX_PROFILES) {
4547 Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); 4547 Backup.Profiles[used] = malloc(sizeof(GSM_Profile));
4548 if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); 4548 if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY);
4549 Backup.Profiles[used + 1] = NULL; 4549 Backup.Profiles[used + 1] = NULL;
4550 } else { 4550 } else {
4551 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES"); 4551 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES");
4552 GSM_Terminate(); 4552 GSM_Terminate();
4553 exit(-1); 4553 exit(-1);
4554 } 4554 }
4555 *Backup.Profiles[used]=Profile; 4555 *Backup.Profiles[used]=Profile;
4556 used++; 4556 used++;
4557 printmsgerr("*"); 4557 printmsgerr("*");
4558 } 4558 }
4559 printmsgerr("\n"); 4559 printmsgerr("\n");
4560 } 4560 }
4561 DoBackup = false; 4561 DoBackup = false;
4562 if (Info.FMStation) { 4562 if (Info.FMStation) {
4563 printmsg("Checking FM stations\n"); 4563 printmsg("Checking FM stations\n");
4564 FMStation.Location = 1; 4564 FMStation.Location = 1;
4565 error = Phone->GetFMStation(&s,&FMStation); 4565 error = Phone->GetFMStation(&s,&FMStation);
4566 if (error == ERR_NONE || error == ERR_EMPTY) { 4566 if (error == ERR_NONE || error == ERR_EMPTY) {
4567 if (answer_yes(" Backup phone FM stations")) DoBackup=true; 4567 if (answer_yes(" Backup phone FM stations")) DoBackup=true;
4568 } 4568 }
4569 } 4569 }
4570 if (DoBackup) { 4570 if (DoBackup) {
4571 used= 0; 4571 used= 0;
4572 i = 1; 4572 i = 1;
4573 printmsgerr(" Reading: "); 4573 printmsgerr(" Reading: ");
4574 while (error == ERR_NONE || error == ERR_EMPTY) { 4574 while (error == ERR_NONE || error == ERR_EMPTY) {
4575 error = Phone->GetFMStation(&s,&FMStation); 4575 error = Phone->GetFMStation(&s,&FMStation);
4576 if (error == ERR_NONE) { 4576 if (error == ERR_NONE) {
4577 if (used < GSM_BACKUP_MAX_FMSTATIONS) { 4577 if (used < GSM_BACKUP_MAX_FMSTATIONS) {
4578 Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); 4578 Backup.FMStation[used] = malloc(sizeof(GSM_FMStation));
4579 if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); 4579 if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY);
4580 Backup.FMStation[used + 1] = NULL; 4580 Backup.FMStation[used + 1] = NULL;
4581 } else { 4581 } else {
4582 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); 4582 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS");
4583 GSM_Terminate(); 4583 GSM_Terminate();
4584 exit(-1); 4584 exit(-1);
4585 } 4585 }
4586 *Backup.FMStation[used]=FMStation; 4586 *Backup.FMStation[used]=FMStation;
4587 used++; 4587 used++;
4588 } 4588 }
4589 i++; 4589 i++;
4590 FMStation.Location = i; 4590 FMStation.Location = i;
4591 printmsgerr("*"); 4591 printmsgerr("*");
4592 } 4592 }
4593 printmsgerr("\n"); 4593 printmsgerr("\n");
4594 } 4594 }
4595 DoBackup = false; 4595 DoBackup = false;
4596 if (Info.GPRSPoint) { 4596 if (Info.GPRSPoint) {
4597 printmsg("Checking GPRS access points\n"); 4597 printmsg("Checking GPRS access points\n");
4598 GPRSPoint.Location = 1; 4598 GPRSPoint.Location = 1;
4599 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 4599 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
4600 if (error == ERR_NONE || error == ERR_EMPTY) { 4600 if (error == ERR_NONE || error == ERR_EMPTY) {
4601 if (answer_yes(" Backup GPRS access points")) DoBackup = true; 4601 if (answer_yes(" Backup GPRS access points")) DoBackup = true;
4602 } 4602 }
4603 } 4603 }
4604 if (DoBackup) { 4604 if (DoBackup) {
4605 used= 0; 4605 used= 0;
4606 i = 1; 4606 i = 1;
4607 printmsgerr(" Reading: "); 4607 printmsgerr(" Reading: ");
4608 while (error == ERR_NONE || error == ERR_EMPTY) { 4608 while (error == ERR_NONE || error == ERR_EMPTY) {
4609 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 4609 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
4610 if (error == ERR_NONE) { 4610 if (error == ERR_NONE) {
4611 if (used < GSM_BACKUP_MAX_GPRSPOINT) { 4611 if (used < GSM_BACKUP_MAX_GPRSPOINT) {
4612 Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); 4612 Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint));
4613 if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); 4613 if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY);
4614 Backup.GPRSPoint[used + 1] = NULL; 4614 Backup.GPRSPoint[used + 1] = NULL;
4615 } else { 4615 } else {
4616 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT"); 4616 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT");
4617 GSM_Terminate(); 4617 GSM_Terminate();
4618 exit(-1); 4618 exit(-1);
4619 } 4619 }
4620 *Backup.GPRSPoint[used]=GPRSPoint; 4620 *Backup.GPRSPoint[used]=GPRSPoint;
4621 used++; 4621 used++;
4622 } 4622 }
4623 i++; 4623 i++;
4624 GPRSPoint.Location = i; 4624 GPRSPoint.Location = i;
4625 printmsgerr("*"); 4625 printmsgerr("*");
4626 } 4626 }
4627 printmsgerr("\n"); 4627 printmsgerr("\n");
4628 } 4628 }
4629 4629
4630 GSM_Terminate(); 4630 GSM_Terminate();
4631 4631
4632 GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode); 4632 GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode);
4633 GSM_FreeBackup(&Backup); 4633 GSM_FreeBackup(&Backup);
4634} 4634}
4635 4635
4636static void Restore(int argc, char *argv[]) 4636static void Restore(int argc, char *argv[])
4637{ 4637{
4638 GSM_Backup Backup; 4638 GSM_Backup Backup;
4639 GSM_FMStation FMStation; 4639 GSM_FMStation FMStation;
4640 GSM_DateTime date_time; 4640 GSM_DateTime date_time;
4641 GSM_CalendarEntryCalendar; 4641 GSM_CalendarEntryCalendar;
4642 GSM_Bitmap Bitmap; 4642 GSM_Bitmap Bitmap;
4643 GSM_Ringtone Ringtone; 4643 GSM_Ringtone Ringtone;
4644 GSM_MemoryEntry Pbk; 4644 GSM_MemoryEntry Pbk;
4645 GSM_MemoryStatusMemStatus; 4645 GSM_MemoryStatusMemStatus;
4646 GSM_ToDoEntry ToDo; 4646 GSM_ToDoEntry ToDo;
4647 GSM_ToDoStatus ToDoStatus; 4647 GSM_ToDoStatus ToDoStatus;
4648 GSM_Profile Profile; 4648 GSM_Profile Profile;
4649 GSM_MultiWAPSettingsSettings; 4649 GSM_MultiWAPSettingsSettings;
4650 GSM_GPRSAccessPointGPRSPoint; 4650 GSM_GPRSAccessPointGPRSPoint;
4651 GSM_WAPBookmark Bookmark; 4651 GSM_WAPBookmark Bookmark;
4652 int i, used, max = 0; 4652 int i, used, max = 0;
4653 bool Past = true; 4653 bool Past = true;
4654 bool Found, DoRestore; 4654 bool Found, DoRestore;
4655 4655
4656 error=GSM_ReadBackupFile(argv[2],&Backup); 4656 error=GSM_ReadBackupFile(argv[2],&Backup);
4657 if (error!=ERR_NOTIMPLEMENTED) { 4657 if (error!=ERR_NOTIMPLEMENTED) {
4658 Print_Error(error); 4658 Print_Error(error);
4659 } else { 4659 } else {
4660 printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n"); 4660 printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n");
4661 } 4661 }
4662 4662
4663 signal(SIGINT, interrupt); 4663 signal(SIGINT, interrupt);
4664 printmsgerr("Press Ctrl+C to break...\n"); 4664 printmsgerr("Press Ctrl+C to break...\n");
4665 4665
4666 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); 4666 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
4667 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); 4667 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
4668 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); 4668 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
4669 if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator); 4669 if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator);
4670 4670
4671 if (Backup.MD5Calculated[0]!=0) { 4671 if (Backup.MD5Calculated[0]!=0) {
4672 dbgprintf("\"%s\"\n",Backup.MD5Original); 4672 dbgprintf("\"%s\"\n",Backup.MD5Original);
4673 dbgprintf("\"%s\"\n",Backup.MD5Calculated); 4673 dbgprintf("\"%s\"\n",Backup.MD5Calculated);
4674 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) { 4674 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) {
4675 if (!answer_yes("Checksum in backup file do not match. Continue")) return; 4675 if (!answer_yes("Checksum in backup file do not match. Continue")) return;
4676 } 4676 }
4677 } 4677 }
4678 4678
4679 GSM_Init(true); 4679 GSM_Init(true);
4680 4680
4681 DoRestore = false; 4681 DoRestore = false;
4682 if (Backup.PhonePhonebook[0] != NULL) { 4682 if (Backup.PhonePhonebook[0] != NULL) {
4683 MemStatus.MemoryType = MEM_ME; 4683 MemStatus.MemoryType = MEM_ME;
4684 error=Phone->GetMemoryStatus(&s, &MemStatus); 4684 error=Phone->GetMemoryStatus(&s, &MemStatus);
4685 if (error==ERR_NONE) { 4685 if (error==ERR_NONE) {
4686 max = 0; 4686 max = 0;
4687 while (Backup.PhonePhonebook[max]!=NULL) max++; 4687 while (Backup.PhonePhonebook[max]!=NULL) max++;
4688 printmsgerr("%i entries in backup file\n",max); 4688 printmsgerr("%i entries in backup file\n",max);
4689 if (answer_yes("Restore phone phonebook")) DoRestore = true; 4689 if (answer_yes("Restore phone phonebook")) DoRestore = true;
4690 } 4690 }
4691 } 4691 }
4692 if (DoRestore) { 4692 if (DoRestore) {
4693 used = 0; 4693 used = 0;
4694 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 4694 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
4695 Pbk.MemoryType = MEM_ME; 4695 Pbk.MemoryType = MEM_ME;
4696 Pbk.Location= i + 1; 4696 Pbk.Location= i + 1;
4697 Pbk.EntriesNum= 0; 4697 Pbk.EntriesNum= 0;
4698 if (used<max) { 4698 if (used<max) {
4699 if (Backup.PhonePhonebook[used]->Location == Pbk.Location) { 4699 if (Backup.PhonePhonebook[used]->Location == Pbk.Location) {
4700 Pbk = *Backup.PhonePhonebook[used]; 4700 Pbk = *Backup.PhonePhonebook[used];
4701 used++; 4701 used++;
4702 dbgprintf("Location %i\n",Pbk.Location); 4702 dbgprintf("Location %i\n",Pbk.Location);
4703 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); 4703 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
4704 } 4704 }
4705 } 4705 }
4706 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); 4706 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
4707 Print_Error(error); 4707 Print_Error(error);
4708 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 4708 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
4709 if (gshutdown) { 4709 if (gshutdown) {
4710 GSM_Terminate(); 4710 GSM_Terminate();
4711 exit(0); 4711 exit(0);
4712 } 4712 }
4713 } 4713 }
4714 printmsgerr("\n"); 4714 printmsgerr("\n");
4715 } 4715 }
4716 4716
4717 DoRestore = false; 4717 DoRestore = false;
4718 if (Backup.SIMPhonebook[0] != NULL) { 4718 if (Backup.SIMPhonebook[0] != NULL) {
4719 MemStatus.MemoryType = MEM_SM; 4719 MemStatus.MemoryType = MEM_SM;
4720 error=Phone->GetMemoryStatus(&s, &MemStatus); 4720 error=Phone->GetMemoryStatus(&s, &MemStatus);
4721 if (error==ERR_NONE) { 4721 if (error==ERR_NONE) {
4722 max = 0; 4722 max = 0;
4723 while (Backup.SIMPhonebook[max]!=NULL) max++; 4723 while (Backup.SIMPhonebook[max]!=NULL) max++;
4724 printmsgerr("%i entries in backup file\n",max); 4724 printmsgerr("%i entries in backup file\n",max);
4725 if (answer_yes("Restore SIM phonebook")) DoRestore = true; 4725 if (answer_yes("Restore SIM phonebook")) DoRestore = true;
4726 } 4726 }
4727 } 4727 }
4728 if (DoRestore) { 4728 if (DoRestore) {
4729 used = 0; 4729 used = 0;
4730 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 4730 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
4731 Pbk.MemoryType = MEM_SM; 4731 Pbk.MemoryType = MEM_SM;
4732 Pbk.Location= i + 1; 4732 Pbk.Location= i + 1;
4733 Pbk.EntriesNum= 0; 4733 Pbk.EntriesNum= 0;
4734 if (used<max) { 4734 if (used<max) {
4735 if (Backup.SIMPhonebook[used]->Location == Pbk.Location) { 4735 if (Backup.SIMPhonebook[used]->Location == Pbk.Location) {
4736 Pbk = *Backup.SIMPhonebook[used]; 4736 Pbk = *Backup.SIMPhonebook[used];
4737 used++; 4737 used++;
4738 dbgprintf("Location %i\n",Pbk.Location); 4738 dbgprintf("Location %i\n",Pbk.Location);
4739 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); 4739 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
4740 } 4740 }
4741 } 4741 }
4742 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); 4742 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
4743 Print_Error(error); 4743 Print_Error(error);
4744 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 4744 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
4745 if (gshutdown) { 4745 if (gshutdown) {
4746 GSM_Terminate(); 4746 GSM_Terminate();
4747 exit(0); 4747 exit(0);
4748 } 4748 }
4749 } 4749 }
4750 printmsgerr("\n"); 4750 printmsgerr("\n");
4751 } 4751 }
4752 4752
4753 DoRestore = false; 4753 DoRestore = false;
4754 if (Backup.CallerLogos[0] != NULL) { 4754 if (Backup.CallerLogos[0] != NULL) {
4755 Bitmap.Type = GSM_CallerGroupLogo; 4755 Bitmap.Type = GSM_CallerGroupLogo;
4756 Bitmap.Location = 1; 4756 Bitmap.Location = 1;
4757 error=Phone->GetBitmap(&s,&Bitmap); 4757 error=Phone->GetBitmap(&s,&Bitmap);
4758 if (error == ERR_NONE) { 4758 if (error == ERR_NONE) {
4759 if (answer_yes("Restore caller groups and logos")) DoRestore = true; 4759 if (answer_yes("Restore caller groups and logos")) DoRestore = true;
4760 } 4760 }
4761 } 4761 }
4762 if (DoRestore) { 4762 if (DoRestore) {
4763 max = 0; 4763 max = 0;
4764 while (Backup.CallerLogos[max]!=NULL) max++; 4764 while (Backup.CallerLogos[max]!=NULL) max++;
4765 for (i=0;i<max;i++) { 4765 for (i=0;i<max;i++) {
4766 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); 4766 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]);
4767 Print_Error(error); 4767 Print_Error(error);
4768 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4768 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4769 if (gshutdown) { 4769 if (gshutdown) {
4770 GSM_Terminate(); 4770 GSM_Terminate();
4771 exit(0); 4771 exit(0);
4772 } 4772 }
4773 } 4773 }
4774 printmsgerr("\n"); 4774 printmsgerr("\n");
4775 } 4775 }
4776 4776
4777 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { 4777 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
4778 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)")) { 4778 if ( true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) {
4779 GSM_GetCurrentDateTime(&date_time); 4779 GSM_GetCurrentDateTime(&date_time);
4780 4780
4781 error=Phone->SetDateTime(&s, &date_time); 4781 error=Phone->SetDateTime(&s, &date_time);
4782 Print_Error(error); 4782 Print_Error(error);
4783 } 4783 }
4784 } 4784 }
4785 DoRestore = false; 4785 DoRestore = false;
4786 if (Backup.Calendar[0] != NULL) { 4786 if (Backup.Calendar[0] != NULL) {
4787 /* N6110 doesn't support getting calendar status */ 4787 /* N6110 doesn't support getting calendar status */
4788 error = Phone->GetNextCalendar(&s,&Calendar,true); 4788 error = Phone->GetNextCalendar(&s,&Calendar,true);
4789 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { 4789 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
4790 max = 0; 4790 max = 0;
4791 while (Backup.Calendar[max] != NULL) max++; 4791 while (Backup.Calendar[max] != NULL) max++;
4792 printmsgerr("%i entries in backup file\n",max); 4792 printmsgerr("%i entries in backup file\n",max);
4793 // LR 4793 // LR
4794 //if (answer_yes("Restore calendar notes")) { 4794 //if (answer_yes("Restore calendar notes")) {
4795 //Past = answer_yes("Restore notes from the past"); 4795 //Past = answer_yes("Restore notes from the past");
4796 DoRestore = true; 4796 DoRestore = true;
4797 //} 4797 //}
4798 } 4798 }
4799 } 4799 }
4800 if (DoRestore) { 4800 if (DoRestore) {
4801 printmsgerr("Deleting old notes: "); 4801 printmsgerr("Deleting old notes: ");
4802 error = Phone->DeleteAllCalendar(&s); 4802 error = Phone->DeleteAllCalendar(&s);
4803 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 4803 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
4804 while (1) { 4804 while (1) {
4805 error = Phone->GetNextCalendar(&s,&Calendar,true); 4805 error = Phone->GetNextCalendar(&s,&Calendar,true);
4806 if (error != ERR_NONE) break; 4806 if (error != ERR_NONE) break;
4807 error = Phone->DeleteCalendar(&s,&Calendar); 4807 error = Phone->DeleteCalendar(&s,&Calendar);
4808 Print_Error(error); 4808 Print_Error(error);
4809 printmsgerr("*"); 4809 printmsgerr("*");
4810 } 4810 }
4811 printmsgerr("\n"); 4811 printmsgerr("\n");
4812 } else { 4812 } else {
4813 printmsgerr("Done\n"); 4813 printmsgerr("Done\n");
4814 Print_Error(error); 4814 Print_Error(error);
4815 } 4815 }
4816 4816
4817 for (i=0;i<max;i++) { 4817 for (i=0;i<max;i++) {
4818 if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; 4818 if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue;
4819 4819
4820 Calendar = *Backup.Calendar[i]; 4820 Calendar = *Backup.Calendar[i];
4821 error=Phone->AddCalendar(&s,&Calendar); 4821 error=Phone->AddCalendar(&s,&Calendar);
4822 Print_Error(error); 4822 Print_Error(error);
4823 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4823 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4824 if (gshutdown) { 4824 if (gshutdown) {
4825 GSM_Terminate(); 4825 GSM_Terminate();
4826 exit(0); 4826 exit(0);
4827 } 4827 }
4828 } 4828 }
4829 printmsgerr("\n"); 4829 printmsgerr("\n");
4830 } 4830 }
4831 4831
4832 DoRestore = false; 4832 DoRestore = false;
4833 if (Backup.ToDo[0] != NULL) { 4833 if (Backup.ToDo[0] != NULL) {
4834 error = Phone->GetToDoStatus(&s,&ToDoStatus); 4834 error = Phone->GetToDoStatus(&s,&ToDoStatus);
4835 if (error == ERR_NONE) { 4835 if (error == ERR_NONE) {
4836 max = 0; 4836 max = 0;
4837 while (Backup.ToDo[max]!=NULL) max++; 4837 while (Backup.ToDo[max]!=NULL) max++;
4838 printmsgerr("%i entries in backup file\n",max); 4838 printmsgerr("%i entries in backup file\n",max);
4839 4839
4840 //LR if (answer_yes("Restore ToDo")) 4840 //LR if (answer_yes("Restore ToDo"))
4841 DoRestore = true; 4841 DoRestore = true;
4842 } 4842 }
4843 } 4843 }
4844 if (DoRestore) { 4844 if (DoRestore) {
4845 ToDo = *Backup.ToDo[0]; 4845 ToDo = *Backup.ToDo[0];
4846 error = Phone->SetToDo(&s,&ToDo); 4846 error = Phone->SetToDo(&s,&ToDo);
4847 } 4847 }
4848 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { 4848 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) {
4849 printmsgerr("Deleting old ToDo: "); 4849 printmsgerr("Deleting old ToDo: ");
4850 error=Phone->DeleteAllToDo(&s); 4850 error=Phone->DeleteAllToDo(&s);
4851 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 4851 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
4852 while (1) { 4852 while (1) {
4853 error = Phone->GetNextToDo(&s,&ToDo,true); 4853 error = Phone->GetNextToDo(&s,&ToDo,true);
4854 if (error != ERR_NONE) break; 4854 if (error != ERR_NONE) break;
4855 error = Phone->DeleteToDo(&s,&ToDo); 4855 error = Phone->DeleteToDo(&s,&ToDo);
4856 Print_Error(error); 4856 Print_Error(error);
4857 printmsgerr("*"); 4857 printmsgerr("*");
4858 } 4858 }
4859 printmsgerr("\n"); 4859 printmsgerr("\n");
4860 } else { 4860 } else {
4861 printmsgerr("Done\n"); 4861 printmsgerr("Done\n");
4862 Print_Error(error); 4862 Print_Error(error);
4863 } 4863 }
4864 4864
4865 for (i=0;i<max;i++) { 4865 for (i=0;i<max;i++) {
4866 ToDo = *Backup.ToDo[i]; 4866 ToDo = *Backup.ToDo[i];
4867 ToDo.Location = 0; 4867 ToDo.Location = 0;
4868 error=Phone->AddToDo(&s,&ToDo); 4868 error=Phone->AddToDo(&s,&ToDo);
4869 Print_Error(error); 4869 Print_Error(error);
4870 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4870 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4871 if (gshutdown) { 4871 if (gshutdown) {
4872 GSM_Terminate(); 4872 GSM_Terminate();
4873 exit(0); 4873 exit(0);
4874 } 4874 }
4875 } 4875 }
4876 printmsgerr("\n"); 4876 printmsgerr("\n");
4877 } else if (DoRestore) { 4877 } else if (DoRestore) {
4878 /* At first delete entries, that were deleted */ 4878 /* At first delete entries, that were deleted */
4879 used = 0; 4879 used = 0;
4880 error = Phone->GetNextToDo(&s,&ToDo,true); 4880 error = Phone->GetNextToDo(&s,&ToDo,true);
4881 while (error == ERR_NONE) { 4881 while (error == ERR_NONE) {
4882 used++; 4882 used++;
4883 Found = false; 4883 Found = false;
4884 for (i=0;i<max;i++) { 4884 for (i=0;i<max;i++) {
4885 if (Backup.ToDo[i]->Location == ToDo.Location) { 4885 if (Backup.ToDo[i]->Location == ToDo.Location) {
4886 Found = true; 4886 Found = true;
4887 break; 4887 break;
4888 } 4888 }
4889 } 4889 }
4890 if (!Found) { 4890 if (!Found) {
4891 error=Phone->DeleteToDo(&s,&ToDo); 4891 error=Phone->DeleteToDo(&s,&ToDo);
4892 Print_Error(error); 4892 Print_Error(error);
4893 } 4893 }
4894 error = Phone->GetNextToDo(&s,&ToDo,false); 4894 error = Phone->GetNextToDo(&s,&ToDo,false);
4895 printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); 4895 printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used);
4896 if (gshutdown) { 4896 if (gshutdown) {
4897 GSM_Terminate(); 4897 GSM_Terminate();
4898 exit(0); 4898 exit(0);
4899 } 4899 }
4900 } 4900 }
4901 printmsgerr("\n"); 4901 printmsgerr("\n");
4902 4902
4903 /* Now write modified/new entries */ 4903 /* Now write modified/new entries */
4904 for (i=0;i<max;i++) { 4904 for (i=0;i<max;i++) {
4905 ToDo = *Backup.ToDo[i]; 4905 ToDo = *Backup.ToDo[i];
4906 error = Phone->SetToDo(&s,&ToDo); 4906 error = Phone->SetToDo(&s,&ToDo);
4907 Print_Error(error); 4907 Print_Error(error);
4908 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4908 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4909 if (gshutdown) { 4909 if (gshutdown) {
4910 GSM_Terminate(); 4910 GSM_Terminate();
4911 exit(0); 4911 exit(0);
4912 } 4912 }
4913 } 4913 }
4914 printmsgerr("\n"); 4914 printmsgerr("\n");
4915 } 4915 }
4916 4916
4917 if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { 4917 if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) {
4918 max = 0; 4918 max = 0;
4919 while (Backup.SMSC[max]!=NULL) max++; 4919 while (Backup.SMSC[max]!=NULL) max++;
4920 for (i=0;i<max;i++) { 4920 for (i=0;i<max;i++) {
4921 error=Phone->SetSMSC(&s,Backup.SMSC[i]); 4921 error=Phone->SetSMSC(&s,Backup.SMSC[i]);
4922 Print_Error(error); 4922 Print_Error(error);
4923 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4923 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4924 if (gshutdown) { 4924 if (gshutdown) {
4925 GSM_Terminate(); 4925 GSM_Terminate();
4926 exit(0); 4926 exit(0);
4927 } 4927 }
4928 } 4928 }
4929 printmsgerr("\n"); 4929 printmsgerr("\n");
4930 } 4930 }
4931 if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { 4931 if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) {
4932 error=Phone->SetBitmap(&s,Backup.StartupLogo); 4932 error=Phone->SetBitmap(&s,Backup.StartupLogo);
4933 Print_Error(error); 4933 Print_Error(error);
4934 } 4934 }
4935 if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { 4935 if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) {
4936 error=Phone->SetBitmap(&s,Backup.OperatorLogo); 4936 error=Phone->SetBitmap(&s,Backup.OperatorLogo);
4937 Print_Error(error); 4937 Print_Error(error);
4938 } 4938 }
4939 DoRestore = false; 4939 DoRestore = false;
4940 if (Backup.WAPBookmark[0] != NULL) { 4940 if (Backup.WAPBookmark[0] != NULL) {
4941 Bookmark.Location = 1; 4941 Bookmark.Location = 1;
4942 error = Phone->GetWAPBookmark(&s,&Bookmark); 4942 error = Phone->GetWAPBookmark(&s,&Bookmark);
4943 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 4943 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
4944 if (answer_yes("Restore WAP bookmarks")) DoRestore = true; 4944 if (answer_yes("Restore WAP bookmarks")) DoRestore = true;
4945 } 4945 }
4946 } 4946 }
4947 if (DoRestore) { 4947 if (DoRestore) {
4948 printmsgerr("Deleting old bookmarks: "); 4948 printmsgerr("Deleting old bookmarks: ");
4949 /* One thing to explain: DCT4 phones seems to have bug here. 4949 /* One thing to explain: DCT4 phones seems to have bug here.
4950 * When delete for example first bookmark, phone change 4950 * When delete for example first bookmark, phone change
4951 * numeration for getting frame, not for deleting. So, we try to 4951 * numeration for getting frame, not for deleting. So, we try to
4952 * get 1'st bookmark. Inside frame is "correct" location. We use 4952 * get 1'st bookmark. Inside frame is "correct" location. We use
4953 * it later 4953 * it later
4954 */ 4954 */
4955 while (error==ERR_NONE) { 4955 while (error==ERR_NONE) {
4956 error = Phone->DeleteWAPBookmark(&s,&Bookmark); 4956 error = Phone->DeleteWAPBookmark(&s,&Bookmark);
4957 Bookmark.Location = 1; 4957 Bookmark.Location = 1;
4958 error = Phone->GetWAPBookmark(&s,&Bookmark); 4958 error = Phone->GetWAPBookmark(&s,&Bookmark);
4959 printmsgerr("*"); 4959 printmsgerr("*");
4960 } 4960 }
4961 printmsgerr("\n"); 4961 printmsgerr("\n");
4962 max = 0; 4962 max = 0;
4963 while (Backup.WAPBookmark[max]!=NULL) max++; 4963 while (Backup.WAPBookmark[max]!=NULL) max++;
4964 for (i=0;i<max;i++) { 4964 for (i=0;i<max;i++) {
4965 Bookmark = *Backup.WAPBookmark[i]; 4965 Bookmark = *Backup.WAPBookmark[i];
4966 Bookmark.Location = 0; 4966 Bookmark.Location = 0;
4967 error=Phone->SetWAPBookmark(&s,&Bookmark); 4967 error=Phone->SetWAPBookmark(&s,&Bookmark);
4968 Print_Error(error); 4968 Print_Error(error);
4969 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4969 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4970 if (gshutdown) { 4970 if (gshutdown) {
4971 GSM_Terminate(); 4971 GSM_Terminate();
4972 exit(0); 4972 exit(0);
4973 } 4973 }
4974 } 4974 }
4975 printmsgerr("\n"); 4975 printmsgerr("\n");
4976 } 4976 }
4977 DoRestore = false; 4977 DoRestore = false;
4978 if (Backup.WAPSettings[0] != NULL) { 4978 if (Backup.WAPSettings[0] != NULL) {
4979 Settings.Location = 1; 4979 Settings.Location = 1;
4980 error = Phone->GetWAPSettings(&s,&Settings); 4980 error = Phone->GetWAPSettings(&s,&Settings);
4981 if (error == ERR_NONE) { 4981 if (error == ERR_NONE) {
4982 if (answer_yes("Restore WAP settings")) DoRestore = true; 4982 if (answer_yes("Restore WAP settings")) DoRestore = true;
4983 } 4983 }
4984 } 4984 }
4985 if (DoRestore) { 4985 if (DoRestore) {
4986 max = 0; 4986 max = 0;
4987 while (Backup.WAPSettings[max]!=NULL) max++; 4987 while (Backup.WAPSettings[max]!=NULL) max++;
4988 for (i=0;i<max;i++) { 4988 for (i=0;i<max;i++) {
4989 error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); 4989 error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]);
4990 Print_Error(error); 4990 Print_Error(error);
4991 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4991 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4992 if (gshutdown) { 4992 if (gshutdown) {
4993 GSM_Terminate(); 4993 GSM_Terminate();
4994 exit(0); 4994 exit(0);
4995 } 4995 }
4996 } 4996 }
4997 printmsgerr("\n"); 4997 printmsgerr("\n");
4998 } 4998 }
4999 DoRestore = false; 4999 DoRestore = false;
5000 if (Backup.MMSSettings[0] != NULL) { 5000 if (Backup.MMSSettings[0] != NULL) {
5001 Settings.Location = 1; 5001 Settings.Location = 1;
5002 error = Phone->GetMMSSettings(&s,&Settings); 5002 error = Phone->GetMMSSettings(&s,&Settings);
5003 if (error == ERR_NONE) { 5003 if (error == ERR_NONE) {
5004 if (answer_yes("Restore MMS settings")) DoRestore = true; 5004 if (answer_yes("Restore MMS settings")) DoRestore = true;
5005 } 5005 }
5006 } 5006 }
5007 if (DoRestore) { 5007 if (DoRestore) {
5008 max = 0; 5008 max = 0;
5009 while (Backup.MMSSettings[max]!=NULL) max++; 5009 while (Backup.MMSSettings[max]!=NULL) max++;
5010 for (i=0;i<max;i++) { 5010 for (i=0;i<max;i++) {
5011 error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); 5011 error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]);
5012 Print_Error(error); 5012 Print_Error(error);
5013 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5013 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5014 if (gshutdown) { 5014 if (gshutdown) {
5015 GSM_Terminate(); 5015 GSM_Terminate();
5016 exit(0); 5016 exit(0);
5017 } 5017 }
5018 } 5018 }
5019 printmsgerr("\n"); 5019 printmsgerr("\n");
5020 } 5020 }
5021 DoRestore = false; 5021 DoRestore = false;
5022 if (Backup.Ringtone[0] != NULL) { 5022 if (Backup.Ringtone[0] != NULL) {
5023 Ringtone.Location = 1; 5023 Ringtone.Location = 1;
5024 Ringtone.Format = 0; 5024 Ringtone.Format = 0;
5025 error = Phone->GetRingtone(&s,&Ringtone,false); 5025 error = Phone->GetRingtone(&s,&Ringtone,false);
5026 if (error == ERR_NONE || error ==ERR_EMPTY) { 5026 if (error == ERR_NONE || error ==ERR_EMPTY) {
5027 if (Phone->DeleteUserRingtones != NOTSUPPORTED) { 5027 if (Phone->DeleteUserRingtones != NOTSUPPORTED) {
5028 if (answer_yes("Delete all user ringtones")) DoRestore = true; 5028 if (answer_yes("Delete all user ringtones")) DoRestore = true;
5029 } 5029 }
5030 } 5030 }
5031 } 5031 }
5032 if (DoRestore) { 5032 if (DoRestore) {
5033 printmsgerr("Deleting: "); 5033 printmsgerr("Deleting: ");
5034 error=Phone->DeleteUserRingtones(&s); 5034 error=Phone->DeleteUserRingtones(&s);
5035 Print_Error(error); 5035 Print_Error(error);
5036 printmsgerr("Done\n"); 5036 printmsgerr("Done\n");
5037 DoRestore = false; 5037 DoRestore = false;
5038 if (answer_yes("Restore user ringtones")) DoRestore = true; 5038 if (answer_yes("Restore user ringtones")) DoRestore = true;
5039 } 5039 }
5040 if (DoRestore) { 5040 if (DoRestore) {
5041 max = 0; 5041 max = 0;
5042 while (Backup.Ringtone[max]!=NULL) max++; 5042 while (Backup.Ringtone[max]!=NULL) max++;
5043 for (i=0;i<max;i++) { 5043 for (i=0;i<max;i++) {
5044 error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format); 5044 error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format);
5045 Print_Error(error); 5045 Print_Error(error);
5046 error=Phone->SetRingtone(&s,&Ringtone,&i); 5046 error=Phone->SetRingtone(&s,&Ringtone,&i);
5047 Print_Error(error); 5047 Print_Error(error);
5048 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5048 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5049 if (gshutdown) { 5049 if (gshutdown) {
5050 GSM_Terminate(); 5050 GSM_Terminate();
5051 exit(0); 5051 exit(0);
5052 } 5052 }
5053 } 5053 }
5054 printmsgerr("\n"); 5054 printmsgerr("\n");
5055 } 5055 }
5056 DoRestore = false; 5056 DoRestore = false;
5057 if (Backup.Profiles[0] != NULL) { 5057 if (Backup.Profiles[0] != NULL) {
5058 Profile.Location = 1; 5058 Profile.Location = 1;
5059 error = Phone->GetProfile(&s,&Profile); 5059 error = Phone->GetProfile(&s,&Profile);
5060 if (error == ERR_NONE) { 5060 if (error == ERR_NONE) {
5061 if (answer_yes("Restore profiles")) DoRestore = true; 5061 if (answer_yes("Restore profiles")) DoRestore = true;
5062 } 5062 }
5063 } 5063 }
5064 if (DoRestore) { 5064 if (DoRestore) {
5065 Profile.Location= 0; 5065 Profile.Location= 0;
5066 max = 0; 5066 max = 0;
5067 while (Backup.Profiles[max]!=NULL) max++; 5067 while (Backup.Profiles[max]!=NULL) max++;
5068 for (i=0;i<max;i++) { 5068 for (i=0;i<max;i++) {
5069 Profile= *Backup.Profiles[i]; 5069 Profile= *Backup.Profiles[i];
5070 error=Phone->SetProfile(&s,&Profile); 5070 error=Phone->SetProfile(&s,&Profile);
5071 Print_Error(error); 5071 Print_Error(error);
5072 if (gshutdown) { 5072 if (gshutdown) {
5073 GSM_Terminate(); 5073 GSM_Terminate();
5074 exit(0); 5074 exit(0);
5075 } 5075 }
5076 } 5076 }
5077 printmsgerr("\n"); 5077 printmsgerr("\n");
5078 } 5078 }
5079 DoRestore = false; 5079 DoRestore = false;
5080 if (Backup.FMStation[0] != NULL) { 5080 if (Backup.FMStation[0] != NULL) {
5081 FMStation.Location = 1; 5081 FMStation.Location = 1;
5082 error = Phone->GetFMStation(&s,&FMStation); 5082 error = Phone->GetFMStation(&s,&FMStation);
5083 if (error == ERR_NONE || error == ERR_EMPTY) { 5083 if (error == ERR_NONE || error == ERR_EMPTY) {
5084 if (answer_yes("Restore FM stations")) DoRestore = true; 5084 if (answer_yes("Restore FM stations")) DoRestore = true;
5085 } 5085 }
5086 } 5086 }
5087 if (DoRestore) { 5087 if (DoRestore) {
5088 printmsgerr("Deleting old FM stations: "); 5088 printmsgerr("Deleting old FM stations: ");
5089 error=Phone->ClearFMStations(&s); 5089 error=Phone->ClearFMStations(&s);
5090 Print_Error(error); 5090 Print_Error(error);
5091 printmsgerr("Done\n"); 5091 printmsgerr("Done\n");
5092 max = 0; 5092 max = 0;
5093 while (Backup.FMStation[max]!=NULL) max++; 5093 while (Backup.FMStation[max]!=NULL) max++;
5094 for (i=0;i<max;i++) { 5094 for (i=0;i<max;i++) {
5095 FMStation = *Backup.FMStation[i]; 5095 FMStation = *Backup.FMStation[i];
5096 error=Phone->SetFMStation(&s,&FMStation); 5096 error=Phone->SetFMStation(&s,&FMStation);
5097 Print_Error(error); 5097 Print_Error(error);
5098 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5098 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5099 if (gshutdown) { 5099 if (gshutdown) {
5100 GSM_Terminate(); 5100 GSM_Terminate();
5101 exit(0); 5101 exit(0);
5102 } 5102 }
5103 } 5103 }
5104 printmsgerr("\n"); 5104 printmsgerr("\n");
5105 } 5105 }
5106 DoRestore = false; 5106 DoRestore = false;
5107 if (Backup.GPRSPoint[0] != NULL) { 5107 if (Backup.GPRSPoint[0] != NULL) {
5108 GPRSPoint.Location = 1; 5108 GPRSPoint.Location = 1;
5109 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 5109 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
5110 if (error == ERR_NONE || error == ERR_EMPTY) { 5110 if (error == ERR_NONE || error == ERR_EMPTY) {
5111 if (answer_yes("Restore GPRS Points")) DoRestore = true; 5111 if (answer_yes("Restore GPRS Points")) DoRestore = true;
5112 } 5112 }
5113 } 5113 }
5114 if (DoRestore) { 5114 if (DoRestore) {
5115 max = 0; 5115 max = 0;
5116 while (Backup.GPRSPoint[max]!=NULL) max++; 5116 while (Backup.GPRSPoint[max]!=NULL) max++;
5117 for (i=0;i<max;i++) { 5117 for (i=0;i<max;i++) {
5118 error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]); 5118 error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]);
5119 Print_Error(error); 5119 Print_Error(error);
5120 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5120 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5121 if (gshutdown) { 5121 if (gshutdown) {
5122 GSM_Terminate(); 5122 GSM_Terminate();
5123 exit(0); 5123 exit(0);
5124 } 5124 }
5125 } 5125 }
5126 printmsgerr("\n"); 5126 printmsgerr("\n");
5127 } 5127 }
5128 5128
5129 GSM_Terminate(); 5129 GSM_Terminate();
5130} 5130}
5131 5131
5132static void AddNew(int argc, char *argv[]) 5132static void AddNew(int argc, char *argv[])
5133{ 5133{
5134 GSM_Backup Backup; 5134 GSM_Backup Backup;
5135 GSM_DateTime date_time; 5135 GSM_DateTime date_time;
5136 GSM_MemoryEntry Pbk; 5136 GSM_MemoryEntry Pbk;
5137 GSM_MemoryStatusMemStatus; 5137 GSM_MemoryStatusMemStatus;
5138 GSM_ToDoEntry ToDo; 5138 GSM_ToDoEntry ToDo;
5139 GSM_ToDoStatus ToDoStatus; 5139 GSM_ToDoStatus ToDoStatus;
5140 GSM_CalendarEntryCalendar; 5140 GSM_CalendarEntryCalendar;
5141 GSM_WAPBookmark Bookmark; 5141 GSM_WAPBookmark Bookmark;
5142 int i, max, j; 5142 int i, max, j;
5143 5143
5144 error=GSM_ReadBackupFile(argv[2],&Backup); 5144 error=GSM_ReadBackupFile(argv[2],&Backup);
5145 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 5145 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
5146 5146
5147 signal(SIGINT, interrupt); 5147 signal(SIGINT, interrupt);
5148 printmsgerr("Press Ctrl+C to break...\n"); 5148 printmsgerr("Press Ctrl+C to break...\n");
5149 5149
5150 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); 5150 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
5151 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); 5151 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
5152 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); 5152 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
5153 5153
5154 GSM_Init(true); 5154 GSM_Init(true);
5155 5155
5156 if (Backup.PhonePhonebook[0] != NULL) { 5156 if (Backup.PhonePhonebook[0] != NULL) {
5157 MemStatus.MemoryType = MEM_ME; 5157 MemStatus.MemoryType = MEM_ME;
5158 error=Phone->GetMemoryStatus(&s, &MemStatus); 5158 error=Phone->GetMemoryStatus(&s, &MemStatus);
5159 if (error==ERR_NONE) { 5159 if (error==ERR_NONE) {
5160 max = 0; 5160 max = 0;
5161 while (Backup.PhonePhonebook[max]!=NULL) max++; 5161 while (Backup.PhonePhonebook[max]!=NULL) max++;
5162 printmsgerr("%i entries in backup file\n",max); 5162 printmsgerr("%i entries in backup file\n",max);
5163 if (MemStatus.MemoryFree < max) { 5163 if (MemStatus.MemoryFree < max) {
5164 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); 5164 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree);
5165 } else if (answer_yes("Add phone phonebook entries")) { 5165 } else if (answer_yes("Add phone phonebook entries")) {
5166 for (i=0;i<max;i++) { 5166 for (i=0;i<max;i++) {
5167 Pbk = *Backup.PhonePhonebook[i]; 5167 Pbk = *Backup.PhonePhonebook[i];
5168 Pbk.MemoryType = MEM_ME; 5168 Pbk.MemoryType = MEM_ME;
5169 error=Phone->AddMemory(&s, &Pbk); 5169 error=Phone->AddMemory(&s, &Pbk);
5170 Print_Error(error); 5170 Print_Error(error);
5171 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5171 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5172 if (gshutdown) { 5172 if (gshutdown) {
5173 GSM_Terminate(); 5173 GSM_Terminate();
5174 exit(0); 5174 exit(0);
5175 } 5175 }
5176 } 5176 }
5177 printmsgerr("\n"); 5177 printmsgerr("\n");
5178 } 5178 }
5179 } 5179 }
5180 } 5180 }
5181 if (Backup.SIMPhonebook[0] != NULL) { 5181 if (Backup.SIMPhonebook[0] != NULL) {
5182 MemStatus.MemoryType = MEM_SM; 5182 MemStatus.MemoryType = MEM_SM;
5183 error=Phone->GetMemoryStatus(&s, &MemStatus); 5183 error=Phone->GetMemoryStatus(&s, &MemStatus);
5184 if (error==ERR_NONE) { 5184 if (error==ERR_NONE) {
5185 max = 0; 5185 max = 0;
5186 while (Backup.SIMPhonebook[max]!=NULL) max++; 5186 while (Backup.SIMPhonebook[max]!=NULL) max++;
5187 printmsgerr("%i entries in backup file\n",max); 5187 printmsgerr("%i entries in backup file\n",max);
5188 if (MemStatus.MemoryFree < max) { 5188 if (MemStatus.MemoryFree < max) {
5189 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); 5189 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree);
5190 } else if (answer_yes("Add SIM phonebook entries")) { 5190 } else if (answer_yes("Add SIM phonebook entries")) {
5191 j = 1; 5191 j = 1;
5192 for (i=0;i<max;i++) { 5192 for (i=0;i<max;i++) {
5193 Pbk = *Backup.SIMPhonebook[i]; 5193 Pbk = *Backup.SIMPhonebook[i];
5194 Pbk.MemoryType = MEM_SM; 5194 Pbk.MemoryType = MEM_SM;
5195 error=Phone->AddMemory(&s, &Pbk); 5195 error=Phone->AddMemory(&s, &Pbk);
5196 Print_Error(error); 5196 Print_Error(error);
5197 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5197 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5198 if (gshutdown) { 5198 if (gshutdown) {
5199 GSM_Terminate(); 5199 GSM_Terminate();
5200 exit(0); 5200 exit(0);
5201 } 5201 }
5202 } 5202 }
5203 printmsgerr("\n"); 5203 printmsgerr("\n");
5204 } 5204 }
5205 } 5205 }
5206 } 5206 }
5207 5207
5208 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { 5208 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
5209 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)")) { 5209 if (true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) {
5210 GSM_GetCurrentDateTime(&date_time); 5210 GSM_GetCurrentDateTime(&date_time);
5211 5211
5212 error=Phone->SetDateTime(&s, &date_time); 5212 error=Phone->SetDateTime(&s, &date_time);
5213 Print_Error(error); 5213 Print_Error(error);
5214 } 5214 }
5215 } 5215 }
5216 if (Backup.Calendar[0] != NULL) { 5216 if (Backup.Calendar[0] != NULL) {
5217 error = Phone->GetNextCalendar(&s,&Calendar,true); 5217 error = Phone->GetNextCalendar(&s,&Calendar,true);
5218 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { 5218 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
5219 if (answer_yes("Add calendar notes")) { 5219 if (answer_yes("Add calendar notes")) {
5220 max = 0; 5220 max = 0;
5221 while (Backup.Calendar[max]!=NULL) max++; 5221 while (Backup.Calendar[max]!=NULL) max++;
5222 for (i=0;i<max;i++) { 5222 for (i=0;i<max;i++) {
5223 Calendar = *Backup.Calendar[i]; 5223 Calendar = *Backup.Calendar[i];
5224 error=Phone->AddCalendar(&s,&Calendar); 5224 error=Phone->AddCalendar(&s,&Calendar);
5225 Print_Error(error); 5225 Print_Error(error);
5226 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5226 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5227 if (gshutdown) { 5227 if (gshutdown) {
5228 GSM_Terminate(); 5228 GSM_Terminate();
5229 exit(0); 5229 exit(0);
5230 } 5230 }
5231 } 5231 }
5232 printmsgerr("\n"); 5232 printmsgerr("\n");
5233 } 5233 }
5234 } 5234 }
5235 } 5235 }
5236 if (Backup.ToDo[0] != NULL) { 5236 if (Backup.ToDo[0] != NULL) {
5237 ToDo.Location = 1; 5237 ToDo.Location = 1;
5238 error=Phone->GetToDoStatus(&s,&ToDoStatus); 5238 error=Phone->GetToDoStatus(&s,&ToDoStatus);
5239 if (error == ERR_NONE) { 5239 if (error == ERR_NONE) {
5240 if (answer_yes("Add ToDo")) { 5240 if (answer_yes("Add ToDo")) {
5241 max = 0; 5241 max = 0;
5242 while (Backup.ToDo[max]!=NULL) max++; 5242 while (Backup.ToDo[max]!=NULL) max++;
5243 for (i=0;i<max;i++) { 5243 for (i=0;i<max;i++) {
5244 ToDo = *Backup.ToDo[i]; 5244 ToDo = *Backup.ToDo[i];
5245 error = Phone->AddToDo(&s,&ToDo); 5245 error = Phone->AddToDo(&s,&ToDo);
5246 Print_Error(error); 5246 Print_Error(error);
5247 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5247 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5248 if (gshutdown) { 5248 if (gshutdown) {
5249 GSM_Terminate(); 5249 GSM_Terminate();
5250 exit(0); 5250 exit(0);
5251 } 5251 }
5252 } 5252 }
5253 printmsgerr("\n"); 5253 printmsgerr("\n");
5254 } 5254 }
5255 } 5255 }
5256 } 5256 }
5257 if (Backup.WAPBookmark[0] != NULL) { 5257 if (Backup.WAPBookmark[0] != NULL) {
5258 Bookmark.Location = 1; 5258 Bookmark.Location = 1;
5259 error = Phone->GetWAPBookmark(&s,&Bookmark); 5259 error = Phone->GetWAPBookmark(&s,&Bookmark);
5260 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 5260 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
5261 if (answer_yes("Add WAP bookmarks")) { 5261 if (answer_yes("Add WAP bookmarks")) {
5262 max = 0; 5262 max = 0;
5263 while (Backup.WAPBookmark[max]!=NULL) max++; 5263 while (Backup.WAPBookmark[max]!=NULL) max++;
5264 for (i=0;i<max;i++) { 5264 for (i=0;i<max;i++) {
5265 Bookmark = *Backup.WAPBookmark[i]; 5265 Bookmark = *Backup.WAPBookmark[i];
5266 Bookmark.Location = 0; 5266 Bookmark.Location = 0;
5267 error=Phone->SetWAPBookmark(&s,&Bookmark); 5267 error=Phone->SetWAPBookmark(&s,&Bookmark);
5268 Print_Error(error); 5268 Print_Error(error);
5269 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5269 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5270 if (gshutdown) { 5270 if (gshutdown) {
5271 GSM_Terminate(); 5271 GSM_Terminate();
5272 exit(0); 5272 exit(0);
5273 } 5273 }
5274 } 5274 }
5275 printmsgerr("\n"); 5275 printmsgerr("\n");
5276 } 5276 }
5277 } 5277 }
5278 } 5278 }
5279 5279
5280 GSM_Terminate(); 5280 GSM_Terminate();
5281} 5281}
5282#endif 5282#endif
5283 5283
5284static void ClearAll(int argc, char *argv[]) 5284static void ClearAll(int argc, char *argv[])
5285{ 5285{
5286 GSM_MemoryStatusMemStatus; 5286 GSM_MemoryStatusMemStatus;
5287 GSM_ToDoStatus ToDoStatus; 5287 GSM_ToDoStatus ToDoStatus;
5288 GSM_CalendarEntryCalendar; 5288 GSM_CalendarEntryCalendar;
5289 GSM_ToDoEntry ToDo; 5289 GSM_ToDoEntry ToDo;
5290 GSM_WAPBookmark Bookmark; 5290 GSM_WAPBookmark Bookmark;
5291 GSM_FMStation Station; 5291 GSM_FMStation Station;
5292 GSM_MemoryEntry Pbk; 5292 GSM_MemoryEntry Pbk;
5293 bool DoClear; 5293 bool DoClear;
5294 5294
5295 GSM_Init(true); 5295 GSM_Init(true);
5296 5296
5297 DoClear = false; 5297 DoClear = false;
5298 MemStatus.MemoryType = MEM_ME; 5298 MemStatus.MemoryType = MEM_ME;
5299 error=Phone->GetMemoryStatus(&s, &MemStatus); 5299 error=Phone->GetMemoryStatus(&s, &MemStatus);
5300 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { 5300 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) {
5301 if (answer_yes("Delete phone phonebook")) DoClear = true; 5301 if (answer_yes("Delete phone phonebook")) DoClear = true;
5302 } 5302 }
5303 if (DoClear) { 5303 if (DoClear) {
5304 error = Phone->DeleteAllMemory(&s,MEM_ME); 5304 error = Phone->DeleteAllMemory(&s,MEM_ME);
5305 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5305 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5306 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 5306 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
5307 Pbk.MemoryType = MEM_ME; 5307 Pbk.MemoryType = MEM_ME;
5308 Pbk.Location= i + 1; 5308 Pbk.Location= i + 1;
5309 Pbk.EntriesNum= 0; 5309 Pbk.EntriesNum= 0;
5310 error=Phone->DeleteMemory(&s, &Pbk); 5310 error=Phone->DeleteMemory(&s, &Pbk);
5311 Print_Error(error); 5311 Print_Error(error);
5312 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 5312 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
5313 if (gshutdown) { 5313 if (gshutdown) {
5314 GSM_Terminate(); 5314 GSM_Terminate();
5315 exit(0); 5315 exit(0);
5316 } 5316 }
5317 } 5317 }
5318 printmsgerr("\n"); 5318 printmsgerr("\n");
5319 } else { 5319 } else {
5320 printmsgerr("Done\n"); 5320 printmsgerr("Done\n");
5321 Print_Error(error); 5321 Print_Error(error);
5322 } 5322 }
5323 } 5323 }
5324 5324
5325 DoClear = false; 5325 DoClear = false;
5326 MemStatus.MemoryType = MEM_SM; 5326 MemStatus.MemoryType = MEM_SM;
5327 error=Phone->GetMemoryStatus(&s, &MemStatus); 5327 error=Phone->GetMemoryStatus(&s, &MemStatus);
5328 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { 5328 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) {
5329 if (answer_yes("Delete SIM phonebook")) DoClear = true; 5329 if (answer_yes("Delete SIM phonebook")) DoClear = true;
5330 } 5330 }
5331 if (DoClear) { 5331 if (DoClear) {
5332 error = Phone->DeleteAllMemory(&s,MEM_SM); 5332 error = Phone->DeleteAllMemory(&s,MEM_SM);
5333 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5333 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5334 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 5334 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
5335 Pbk.MemoryType = MEM_SM; 5335 Pbk.MemoryType = MEM_SM;
5336 Pbk.Location= i + 1; 5336 Pbk.Location= i + 1;
5337 Pbk.EntriesNum= 0; 5337 Pbk.EntriesNum= 0;
5338 error=Phone->DeleteMemory(&s, &Pbk); 5338 error=Phone->DeleteMemory(&s, &Pbk);
5339 Print_Error(error); 5339 Print_Error(error);
5340 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 5340 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
5341 if (gshutdown) { 5341 if (gshutdown) {
5342 GSM_Terminate(); 5342 GSM_Terminate();
5343 exit(0); 5343 exit(0);
5344 } 5344 }
5345 } 5345 }
5346 printmsgerr("\n"); 5346 printmsgerr("\n");
5347 } else { 5347 } else {
5348 printmsgerr("Done\n"); 5348 printmsgerr("Done\n");
5349 Print_Error(error); 5349 Print_Error(error);
5350 } 5350 }
5351 } 5351 }
5352 5352
5353 DoClear = false; 5353 DoClear = false;
5354 error = Phone->GetNextCalendar(&s,&Calendar,true); 5354 error = Phone->GetNextCalendar(&s,&Calendar,true);
5355 if (error == ERR_NONE) { 5355 if (error == ERR_NONE) {
5356 if (answer_yes("Delete calendar notes")) DoClear = true; 5356 if (answer_yes("Delete calendar notes")) DoClear = true;
5357 } 5357 }
5358 if (DoClear) { 5358 if (DoClear) {
5359 printmsgerr("Deleting: "); 5359 printmsgerr("Deleting: ");
5360 error=Phone->DeleteAllCalendar(&s); 5360 error=Phone->DeleteAllCalendar(&s);
5361 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5361 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5362 while (1) { 5362 while (1) {
5363 error = Phone->GetNextCalendar(&s,&Calendar,true); 5363 error = Phone->GetNextCalendar(&s,&Calendar,true);
5364 if (error != ERR_NONE) break; 5364 if (error != ERR_NONE) break;
5365 error = Phone->DeleteCalendar(&s,&Calendar); 5365 error = Phone->DeleteCalendar(&s,&Calendar);
5366 Print_Error(error); 5366 Print_Error(error);
5367 printmsgerr("*"); 5367 printmsgerr("*");
5368 } 5368 }
5369 printmsgerr("\n"); 5369 printmsgerr("\n");
5370 } else { 5370 } else {
5371 printmsgerr("Done\n"); 5371 printmsgerr("Done\n");
5372 Print_Error(error); 5372 Print_Error(error);
5373 } 5373 }
5374 } 5374 }
5375 5375
5376 DoClear = false; 5376 DoClear = false;
5377 error = Phone->GetToDoStatus(&s,&ToDoStatus); 5377 error = Phone->GetToDoStatus(&s,&ToDoStatus);
5378 if (error == ERR_NONE && ToDoStatus.Used != 0) { 5378 if (error == ERR_NONE && ToDoStatus.Used != 0) {
5379 if (answer_yes("Delete ToDo")) DoClear = true; 5379 if (answer_yes("Delete ToDo")) DoClear = true;
5380 } 5380 }
5381 if (DoClear) { 5381 if (DoClear) {
5382 printmsgerr("Deleting: "); 5382 printmsgerr("Deleting: ");
5383 error=Phone->DeleteAllToDo(&s); 5383 error=Phone->DeleteAllToDo(&s);
5384 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5384 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5385 while (1) { 5385 while (1) {
5386 error = Phone->GetNextToDo(&s,&ToDo,true); 5386 error = Phone->GetNextToDo(&s,&ToDo,true);
5387 if (error != ERR_NONE) break; 5387 if (error != ERR_NONE) break;
5388 error = Phone->DeleteToDo(&s,&ToDo); 5388 error = Phone->DeleteToDo(&s,&ToDo);
5389 Print_Error(error); 5389 Print_Error(error);
5390 printmsgerr("*"); 5390 printmsgerr("*");
5391 } 5391 }
5392 printmsgerr("\n"); 5392 printmsgerr("\n");
5393 } else { 5393 } else {
5394 printmsgerr("Done\n"); 5394 printmsgerr("Done\n");
5395 Print_Error(error); 5395 Print_Error(error);
5396 } 5396 }
5397 } 5397 }
5398 5398
5399 Bookmark.Location = 1; 5399 Bookmark.Location = 1;
5400 error = Phone->GetWAPBookmark(&s,&Bookmark); 5400 error = Phone->GetWAPBookmark(&s,&Bookmark);
5401 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 5401 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
5402 if (answer_yes("Delete WAP bookmarks")) { 5402 if (answer_yes("Delete WAP bookmarks")) {
5403 printmsgerr("Deleting: "); 5403 printmsgerr("Deleting: ");
5404 /* One thing to explain: DCT4 phones seems to have bug here. 5404 /* One thing to explain: DCT4 phones seems to have bug here.
5405 * When delete for example first bookmark, phone change 5405 * When delete for example first bookmark, phone change
5406 * numeration for getting frame, not for deleting. So, we try to 5406 * numeration for getting frame, not for deleting. So, we try to
5407 * get 1'st bookmark. Inside frame is "correct" location. We use 5407 * get 1'st bookmark. Inside frame is "correct" location. We use
5408 * it later 5408 * it later
5409 */ 5409 */
5410 while (error==ERR_NONE) { 5410 while (error==ERR_NONE) {
5411 error = Phone->DeleteWAPBookmark(&s,&Bookmark); 5411 error = Phone->DeleteWAPBookmark(&s,&Bookmark);
5412 Bookmark.Location = 1; 5412 Bookmark.Location = 1;
5413 error = Phone->GetWAPBookmark(&s,&Bookmark); 5413 error = Phone->GetWAPBookmark(&s,&Bookmark);
5414 printmsgerr("*"); 5414 printmsgerr("*");
5415 } 5415 }
5416 printmsgerr("\n"); 5416 printmsgerr("\n");
5417 } 5417 }
5418 } 5418 }
5419 if (Phone->DeleteUserRingtones != NOTSUPPORTED) { 5419 if (Phone->DeleteUserRingtones != NOTSUPPORTED) {
5420 if (answer_yes("Delete all user ringtones")) { 5420 if (answer_yes("Delete all user ringtones")) {
5421 printmsgerr("Deleting: "); 5421 printmsgerr("Deleting: ");
5422 error=Phone->DeleteUserRingtones(&s); 5422 error=Phone->DeleteUserRingtones(&s);
5423 Print_Error(error); 5423 Print_Error(error);
5424 printmsgerr("Done\n"); 5424 printmsgerr("Done\n");
5425 } 5425 }
5426 } 5426 }
5427 Station.Location=i; 5427 Station.Location=i;
5428 error=Phone->GetFMStation(&s,&Station); 5428 error=Phone->GetFMStation(&s,&Station);
5429 if (error == ERR_NONE || error == ERR_EMPTY) { 5429 if (error == ERR_NONE || error == ERR_EMPTY) {
5430 if (answer_yes("Delete all FM station")) { 5430 if (answer_yes("Delete all FM station")) {
5431 error=Phone->ClearFMStations(&s); 5431 error=Phone->ClearFMStations(&s);
5432 Print_Error(error); 5432 Print_Error(error);
5433 } 5433 }
5434 } 5434 }
5435 5435
5436 GSM_Terminate(); 5436 GSM_Terminate();
5437} 5437}
5438 5438
5439static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) 5439static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j)
5440{ 5440{
5441 if (settings->Settings[j].IsContinuous) { 5441 if (settings->Settings[j].IsContinuous) {
5442 printmsg("Connection type : Continuous\n"); 5442 printmsg("Connection type : Continuous\n");
5443 } else { 5443 } else {
5444 printmsg("Connection type : Temporary\n"); 5444 printmsg("Connection type : Temporary\n");
5445 } 5445 }
5446 if (settings->Settings[j].IsSecurity) { 5446 if (settings->Settings[j].IsSecurity) {
5447 printmsg("Connection security : On\n"); 5447 printmsg("Connection security : On\n");
5448 } else { 5448 } else {
5449 printmsg("Connection security : Off\n"); 5449 printmsg("Connection security : Off\n");
5450 } 5450 }
5451 printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); 5451 printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort);
5452 printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); 5452 printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port);
5453 switch (settings->Settings[j].Bearer) { 5453 switch (settings->Settings[j].Bearer) {
5454 case WAPSETTINGS_BEARER_SMS: 5454 case WAPSETTINGS_BEARER_SMS:
5455 printmsg("Bearer : SMS"); 5455 printmsg("Bearer : SMS");
5456 if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); 5456 if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)");
5457 printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); 5457 printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server));
5458 printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5458 printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5459 break; 5459 break;
5460 case WAPSETTINGS_BEARER_DATA: 5460 case WAPSETTINGS_BEARER_DATA:
5461 printmsg("Bearer : Data (CSD)"); 5461 printmsg("Bearer : Data (CSD)");
5462 if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); 5462 if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)");
5463 printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); 5463 printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
5464 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); 5464 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
5465 if (settings->Settings[j].ManualLogin) { 5465 if (settings->Settings[j].ManualLogin) {
5466 printmsg("Login Type : Manual\n"); 5466 printmsg("Login Type : Manual\n");
5467 } else { 5467 } else {
5468 printmsg("Login Type : Automatic\n"); 5468 printmsg("Login Type : Automatic\n");
5469 } 5469 }
5470 if (settings->Settings[j].IsNormalAuthentication) { 5470 if (settings->Settings[j].IsNormalAuthentication) {
5471 printmsg("Authentication type : Normal\n"); 5471 printmsg("Authentication type : Normal\n");
5472 } else { 5472 } else {
5473 printmsg("Authentication type : Secure\n"); 5473 printmsg("Authentication type : Secure\n");
5474 } 5474 }
5475 if (settings->Settings[j].IsISDNCall) { 5475 if (settings->Settings[j].IsISDNCall) {
5476 printmsg("Data call type : ISDN\n"); 5476 printmsg("Data call type : ISDN\n");
5477 } else { 5477 } else {
5478 printmsg("Data call type : Analogue\n"); 5478 printmsg("Data call type : Analogue\n");
5479 } 5479 }
5480 switch (settings->Settings[j].Speed) { 5480 switch (settings->Settings[j].Speed) {
5481 case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; 5481 case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break;
5482 case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; 5482 case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break;
5483 case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; 5483 case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break;
5484 } 5484 }
5485 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); 5485 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
5486 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); 5486 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
5487 break; 5487 break;
5488 case WAPSETTINGS_BEARER_USSD: 5488 case WAPSETTINGS_BEARER_USSD:
5489 printmsg("Bearer : USSD"); 5489 printmsg("Bearer : USSD");
5490 if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); 5490 if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)");
5491 printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); 5491 printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code));
5492 if (settings->Settings[j].IsIP) { 5492 if (settings->Settings[j].IsIP) {
5493 printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5493 printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5494 } else { 5494 } else {
5495 printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5495 printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5496 } 5496 }
5497 break; 5497 break;
5498 case WAPSETTINGS_BEARER_GPRS: 5498 case WAPSETTINGS_BEARER_GPRS:
5499 printmsg("Bearer : GPRS"); 5499 printmsg("Bearer : GPRS");
5500 if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); 5500 if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)");
5501 if (settings->Settings[j].ManualLogin) { 5501 if (settings->Settings[j].ManualLogin) {
5502 printmsg("\nLogin Type : Manual\n"); 5502 printmsg("\nLogin Type : Manual\n");
5503 } else { 5503 } else {
5504 printmsg("\nLogin Type : Automatic\n"); 5504 printmsg("\nLogin Type : Automatic\n");
5505 } 5505 }
5506 if (settings->Settings[j].IsNormalAuthentication) { 5506 if (settings->Settings[j].IsNormalAuthentication) {
5507 printmsg("Authentication type : Normal\n"); 5507 printmsg("Authentication type : Normal\n");
5508 } else { 5508 } else {
5509 printmsg("Authentication type : Secure\n"); 5509 printmsg("Authentication type : Secure\n");
5510 } 5510 }
5511 printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); 5511 printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
5512 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); 5512 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
5513 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); 5513 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
5514 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); 5514 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
5515 } 5515 }
5516} 5516}
5517 5517
5518static void GetSyncMLSettings(int argc, char *argv[]) 5518static void GetSyncMLSettings(int argc, char *argv[])
5519{ 5519{
5520 GSM_SyncMLSettingssettings; 5520 GSM_SyncMLSettingssettings;
5521 int start,stop,j; 5521 int start,stop,j;
5522 5522
5523 GetStartStop(&start, &stop, 2, argc, argv); 5523 GetStartStop(&start, &stop, 2, argc, argv);
5524 5524
5525 GSM_Init(true); 5525 GSM_Init(true);
5526 5526
5527 for (i=start;i<=stop;i++) { 5527 for (i=start;i<=stop;i++) {
5528 settings.Location=i; 5528 settings.Location=i;
5529 error=Phone->GetSyncMLSettings(&s,&settings); 5529 error=Phone->GetSyncMLSettings(&s,&settings);
5530 Print_Error(error); 5530 Print_Error(error);
5531 printmsg("%i. ",i); 5531 printmsg("%i. ",i);
5532 if (settings.Name[0]==0 && settings.Name[1]==0) { 5532 if (settings.Name[0]==0 && settings.Name[1]==0) {
5533 printmsg("Set %i",i); 5533 printmsg("Set %i",i);
5534 } else { 5534 } else {
5535 printmsg("%s",DecodeUnicodeConsole(settings.Name)); 5535 printmsg("%s",DecodeUnicodeConsole(settings.Name));
5536 } 5536 }
5537 if (settings.Active) printmsg(" (active)"); 5537 if (settings.Active) printmsg(" (active)");
5538 // if (settings.ReadOnly) printmsg("\nRead only : yes"); 5538 // if (settings.ReadOnly) printmsg("\nRead only : yes");
5539 printmsg("\n"); 5539 printmsg("\n");
5540 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); 5540 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
5541 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); 5541 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
5542 printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); 5542 printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase));
5543 printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); 5543 printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase));
5544 printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); 5544 printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server));
5545 printmsg("Sync. phonebook : "); 5545 printmsg("Sync. phonebook : ");
5546 if (settings.SyncPhonebook) printmsg("yes\n"); 5546 if (settings.SyncPhonebook) printmsg("yes\n");
5547 if (!settings.SyncPhonebook) printmsg("no\n"); 5547 if (!settings.SyncPhonebook) printmsg("no\n");
5548 printmsg("Sync. calendar : "); 5548 printmsg("Sync. calendar : ");
5549 if (settings.SyncCalendar) printmsg("yes\n"); 5549 if (settings.SyncCalendar) printmsg("yes\n");
5550 if (!settings.SyncCalendar) printmsg("no\n"); 5550 if (!settings.SyncCalendar) printmsg("no\n");
5551 printmsg("\n"); 5551 printmsg("\n");
5552 for (j=0;j<settings.Connection.Number;j++) { 5552 for (j=0;j<settings.Connection.Number;j++) {
5553 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { 5553 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
5554 printmsg("Connection set name : Set %i\n",i); 5554 printmsg("Connection set name : Set %i\n",i);
5555 } else { 5555 } else {
5556 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); 5556 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
5557 } 5557 }
5558 DisplayConnectionSettings(&settings.Connection,j); 5558 DisplayConnectionSettings(&settings.Connection,j);
5559 printf("\n"); 5559 printf("\n");
5560 } 5560 }
5561 } 5561 }
5562 GSM_Terminate(); 5562 GSM_Terminate();
5563} 5563}
5564 5564
5565static void GetChatSettings(int argc, char *argv[]) 5565static void GetChatSettings(int argc, char *argv[])
5566{ 5566{
5567 GSM_ChatSettingssettings; 5567 GSM_ChatSettingssettings;
5568 int start,stop,j; 5568 int start,stop,j;
5569 5569
5570 GetStartStop(&start, &stop, 2, argc, argv); 5570 GetStartStop(&start, &stop, 2, argc, argv);
5571 5571
5572 GSM_Init(true); 5572 GSM_Init(true);
5573 5573
5574 for (i=start;i<=stop;i++) { 5574 for (i=start;i<=stop;i++) {
5575 settings.Location=i; 5575 settings.Location=i;
5576 error=Phone->GetChatSettings(&s,&settings); 5576 error=Phone->GetChatSettings(&s,&settings);
5577 Print_Error(error); 5577 Print_Error(error);
5578 printmsg("%i. ",i); 5578 printmsg("%i. ",i);
5579 if (settings.Name[0]==0 && settings.Name[1]==0) { 5579 if (settings.Name[0]==0 && settings.Name[1]==0) {
5580 printmsg("Set %i",i); 5580 printmsg("Set %i",i);
5581 } else { 5581 } else {
5582 printmsg("%s",DecodeUnicodeConsole(settings.Name)); 5582 printmsg("%s",DecodeUnicodeConsole(settings.Name));
5583 } 5583 }
5584 if (settings.Active) printmsg(" (active)"); 5584 if (settings.Active) printmsg(" (active)");
5585 // if (settings.ReadOnly) printmsg("\nRead only : yes"); 5585 // if (settings.ReadOnly) printmsg("\nRead only : yes");
5586 printmsg("\n"); 5586 printmsg("\n");
5587 printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); 5587 printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage));
5588 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); 5588 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
5589 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); 5589 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
5590 printmsg("\n"); 5590 printmsg("\n");
5591 for (j=0;j<settings.Connection.Number;j++) { 5591 for (j=0;j<settings.Connection.Number;j++) {
5592 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { 5592 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
5593 printmsg("Connection set name : Set %i\n",i); 5593 printmsg("Connection set name : Set %i\n",i);
5594 } else { 5594 } else {
5595 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); 5595 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
5596 } 5596 }
5597 DisplayConnectionSettings(&settings.Connection,j); 5597 DisplayConnectionSettings(&settings.Connection,j);
5598 printf("\n"); 5598 printf("\n");
5599 } 5599 }
5600 } 5600 }
5601 GSM_Terminate(); 5601 GSM_Terminate();
5602} 5602}
5603 5603
5604static void GetWAPMMSSettings(int argc, char *argv[]) 5604static void GetWAPMMSSettings(int argc, char *argv[])
5605{ 5605{
5606 GSM_MultiWAPSettingssettings; 5606 GSM_MultiWAPSettingssettings;
5607 int start,stop,j; 5607 int start,stop,j;
5608 5608
5609 GetStartStop(&start, &stop, 2, argc, argv); 5609 GetStartStop(&start, &stop, 2, argc, argv);
5610 5610
5611 GSM_Init(true); 5611 GSM_Init(true);
5612 5612
5613 for (i=start;i<=stop;i++) { 5613 for (i=start;i<=stop;i++) {
5614 settings.Location=i; 5614 settings.Location=i;
5615 if (mystrncasecmp(argv[1],"--getwapsettings",0)) { 5615 if (mystrncasecmp(argv[1],"--getwapsettings",0)) {
5616 error=Phone->GetWAPSettings(&s,&settings); 5616 error=Phone->GetWAPSettings(&s,&settings);
5617 } else { 5617 } else {
5618 error=Phone->GetMMSSettings(&s,&settings); 5618 error=Phone->GetMMSSettings(&s,&settings);
5619 } 5619 }
5620 Print_Error(error); 5620 Print_Error(error);
5621 for (j=0;j<settings.Number;j++) { 5621 for (j=0;j<settings.Number;j++) {
5622 printmsg("%i. ",i); 5622 printmsg("%i. ",i);
5623 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { 5623 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) {
5624 printmsg("Set %i",i); 5624 printmsg("Set %i",i);
5625 } else { 5625 } else {
5626 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); 5626 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title));
5627 } 5627 }
5628 if (settings.Active) printmsg(" (active)"); 5628 if (settings.Active) printmsg(" (active)");
5629 if (settings.ReadOnly) printmsg("\nRead only : yes"); 5629 if (settings.ReadOnly) printmsg("\nRead only : yes");
5630 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); 5630 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage));
5631 DisplayConnectionSettings(&settings,j); 5631 DisplayConnectionSettings(&settings,j);
5632 printf("\n"); 5632 printf("\n");
5633 } 5633 }
5634 } 5634 }
5635 GSM_Terminate(); 5635 GSM_Terminate();
5636} 5636}
5637 5637
5638#ifdef GSM_ENABLE_BACKUP 5638#ifdef GSM_ENABLE_BACKUP
5639static void BackupSMS(int argc, char *argv[]) 5639static void BackupSMS(int argc, char *argv[])
5640{ 5640{
5641 GSM_SMS_Backup Backup; 5641 GSM_SMS_Backup Backup;
5642 GSM_MultiSMSMessage sms; 5642 GSM_MultiSMSMessage sms;
5643 GSM_SMSFolders folders; 5643 GSM_SMSFolders folders;
5644 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; 5644 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS];
5645 bool start = true; 5645 bool start = true;
5646 bool DeleteAfter; 5646 bool DeleteAfter;
5647 int j, smsnum; 5647 int j, smsnum;
5648 char buffer[200]; 5648 char buffer[200];
5649 5649
5650 /* We ignore return code, because (when file doesn't exist) we 5650 /* We ignore return code, because (when file doesn't exist) we
5651 * will create new later 5651 * will create new later
5652 */ 5652 */
5653 GSM_ReadSMSBackupFile(argv[2], &Backup); 5653 GSM_ReadSMSBackupFile(argv[2], &Backup);
5654 smsnum = 0; 5654 smsnum = 0;
5655 while (Backup.SMS[smsnum]!=NULL) smsnum++; 5655 while (Backup.SMS[smsnum]!=NULL) smsnum++;
5656 5656
5657 GSM_Init(true); 5657 GSM_Init(true);
5658 5658
5659 error=Phone->GetSMSFolders(&s, &folders); 5659 error=Phone->GetSMSFolders(&s, &folders);
5660 Print_Error(error); 5660 Print_Error(error);
5661 5661
5662 DeleteAfter=answer_yes("Delete each sms after backup"); 5662 DeleteAfter=answer_yes("Delete each sms after backup");
5663 5663
5664 for (j=0;j<folders.Number;j++) { 5664 for (j=0;j<folders.Number;j++) {
5665 BackupFromFolder[j] = false; 5665 BackupFromFolder[j] = false;
5666 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); 5666 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name));
5667 if (answer_yes(buffer)) BackupFromFolder[j] = true; 5667 if (answer_yes(buffer)) BackupFromFolder[j] = true;
5668 } 5668 }
5669 5669
5670 while (error == ERR_NONE) { 5670 while (error == ERR_NONE) {
5671 sms.SMS[0].Folder=0x00; 5671 sms.SMS[0].Folder=0x00;
5672 error=Phone->GetNextSMS(&s, &sms, start); 5672 error=Phone->GetNextSMS(&s, &sms, start);
5673 switch (error) { 5673 switch (error) {
5674 case ERR_EMPTY: 5674 case ERR_EMPTY:
5675 break; 5675 break;
5676 default: 5676 default:
5677 Print_Error(error); 5677 Print_Error(error);
5678 for (j=0;j<sms.Number;j++) { 5678 for (j=0;j<sms.Number;j++) {
5679 if (BackupFromFolder[sms.SMS[j].Folder-1]) { 5679 if (BackupFromFolder[sms.SMS[j].Folder-1]) {
5680 switch (sms.SMS[j].PDU) { 5680 switch (sms.SMS[j].PDU) {
5681 case SMS_Status_Report: 5681 case SMS_Status_Report:
5682 break; 5682 break;
5683 case SMS_Submit: 5683 case SMS_Submit:
5684 case SMS_Deliver: 5684 case SMS_Deliver:
5685 if (sms.SMS[j].Length == 0) break; 5685 if (sms.SMS[j].Length == 0) break;
5686 if (smsnum < GSM_BACKUP_MAX_SMS) { 5686 if (smsnum < GSM_BACKUP_MAX_SMS) {
5687 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); 5687 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage));
5688 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); 5688 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY);
5689 Backup.SMS[smsnum+1] = NULL; 5689 Backup.SMS[smsnum+1] = NULL;
5690 } else { 5690 } else {
5691 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); 5691 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS");
5692 GSM_Terminate(); 5692 GSM_Terminate();
5693 exit(-1); 5693 exit(-1);
5694 } 5694 }
5695 *Backup.SMS[smsnum] = sms.SMS[j]; 5695 *Backup.SMS[smsnum] = sms.SMS[j];
5696 smsnum++; 5696 smsnum++;
5697 break; 5697 break;
5698 } 5698 }
5699 } 5699 }
5700 } 5700 }
5701 } 5701 }
5702 start=false; 5702 start=false;
5703 } 5703 }
5704 5704
5705 error = GSM_SaveSMSBackupFile(argv[2],&Backup); 5705 error = GSM_SaveSMSBackupFile(argv[2],&Backup);
5706 Print_Error(error); 5706 Print_Error(error);
5707 5707
5708 if (DeleteAfter) { 5708 if (DeleteAfter) {
5709 for (j=0;j<smsnum;j++) { 5709 for (j=0;j<smsnum;j++) {
5710 Backup.SMS[j]->Folder = 0; 5710 Backup.SMS[j]->Folder = 0;
5711 error=Phone->DeleteSMS(&s, Backup.SMS[j]); 5711 error=Phone->DeleteSMS(&s, Backup.SMS[j]);
5712 Print_Error(error); 5712 Print_Error(error);
5713 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); 5713 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum);
5714 } 5714 }
5715 } 5715 }
5716 5716
5717 GSM_Terminate(); 5717 GSM_Terminate();
5718} 5718}
5719 5719
5720static void AddSMS(int argc, char *argv[]) 5720static void AddSMS(int argc, char *argv[])
5721{ 5721{
5722 GSM_MultiSMSMessage SMS; 5722 GSM_MultiSMSMessage SMS;
5723 GSM_SMS_Backup Backup; 5723 GSM_SMS_Backup Backup;
5724 int smsnum = 0; 5724 int smsnum = 0;
5725 int folder; 5725 int folder;
5726 5726
5727 folder = atoi(argv[2]); 5727 folder = atoi(argv[2]);
5728 5728
5729 error = GSM_ReadSMSBackupFile(argv[3], &Backup); 5729 error = GSM_ReadSMSBackupFile(argv[3], &Backup);
5730 Print_Error(error); 5730 Print_Error(error);
5731 5731
5732 GSM_Init(true); 5732 GSM_Init(true);
5733 5733
5734 while (Backup.SMS[smsnum] != NULL) { 5734 while (Backup.SMS[smsnum] != NULL) {
5735 Backup.SMS[smsnum]->Folder = folder; 5735 Backup.SMS[smsnum]->Folder = folder;
5736 Backup.SMS[smsnum]->SMSC.Location = 1; 5736 Backup.SMS[smsnum]->SMSC.Location = 1;
5737 SMS.Number = 1; 5737 SMS.Number = 1;
5738 SMS.SMS[0] = *Backup.SMS[smsnum]; 5738 SMS.SMS[0] = *Backup.SMS[smsnum];
5739 displaymultismsinfo(SMS,false,false); 5739 displaymultismsinfo(SMS,false,false);
5740 if (answer_yes("Restore sms")) { 5740 if (answer_yes("Restore sms")) {
5741 error=Phone->AddSMS(&s, Backup.SMS[smsnum]); 5741 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5742 Print_Error(error); 5742 Print_Error(error);
5743 } 5743 }
5744 smsnum++; 5744 smsnum++;
5745 } 5745 }
5746 5746
5747 GSM_Terminate(); 5747 GSM_Terminate();
5748} 5748}
5749 5749
5750static void RestoreSMS(int argc, char *argv[]) 5750static void RestoreSMS(int argc, char *argv[])
5751{ 5751{
5752 GSM_MultiSMSMessage SMS; 5752 GSM_MultiSMSMessage SMS;
5753 GSM_SMS_Backup Backup; 5753 GSM_SMS_Backup Backup;
5754 GSM_SMSFolders folders; 5754 GSM_SMSFolders folders;
5755 int smsnum = 0; 5755 int smsnum = 0;
5756 char buffer[200]; 5756 char buffer[200];
5757 5757
5758 error=GSM_ReadSMSBackupFile(argv[2], &Backup); 5758 error=GSM_ReadSMSBackupFile(argv[2], &Backup);
5759 Print_Error(error); 5759 Print_Error(error);
5760 5760
5761 GSM_Init(true); 5761 GSM_Init(true);
5762 5762
5763 error=Phone->GetSMSFolders(&s, &folders); 5763 error=Phone->GetSMSFolders(&s, &folders);
5764 Print_Error(error); 5764 Print_Error(error);
5765 5765
5766 while (Backup.SMS[smsnum] != NULL) { 5766 while (Backup.SMS[smsnum] != NULL) {
5767 SMS.Number = 1; 5767 SMS.Number = 1;
5768 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); 5768 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
5769 displaymultismsinfo(SMS,false,false); 5769 displaymultismsinfo(SMS,false,false);
5770 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); 5770 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
5771 if (answer_yes(buffer)) { 5771 if (answer_yes(buffer)) {
5772 error=Phone->AddSMS(&s, Backup.SMS[smsnum]); 5772 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5773 Print_Error(error); 5773 Print_Error(error);
5774 } 5774 }
5775 smsnum++; 5775 smsnum++;
5776 } 5776 }
5777 5777
5778 GSM_Terminate(); 5778 GSM_Terminate();
5779} 5779}
5780#endif 5780#endif
5781 5781
5782static void CopyBitmap(int argc, char *argv[]) 5782static void CopyBitmap(int argc, char *argv[])
5783{ 5783{
5784 GSM_MultiBitmap Bitmap; 5784 GSM_MultiBitmap Bitmap;
5785 int i; 5785 int i;
5786 5786
5787 Bitmap.Bitmap[0].Type = GSM_None; 5787 Bitmap.Bitmap[0].Type = GSM_None;
5788 5788
5789 error=GSM_ReadBitmapFile(argv[2],&Bitmap); 5789 error=GSM_ReadBitmapFile(argv[2],&Bitmap);
5790 Print_Error(error); 5790 Print_Error(error);
5791 5791
5792 if (argc==3) { 5792 if (argc==3) {
5793 for (i=0;i<Bitmap.Number;i++) { 5793 for (i=0;i<Bitmap.Number;i++) {
5794 switch (Bitmap.Bitmap[i].Type) { 5794 switch (Bitmap.Bitmap[i].Type) {
5795 case GSM_StartupLogo : printmsg("Startup logo"); break; 5795 case GSM_StartupLogo : printmsg("Startup logo"); break;
5796 case GSM_OperatorLogo: printmsg("Operator logo"); break; 5796 case GSM_OperatorLogo: printmsg("Operator logo"); break;
5797 case GSM_PictureImage: printmsg("Picture Image"); break; 5797 case GSM_PictureImage: printmsg("Picture Image"); break;
5798 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break; 5798 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break;
5799 default : break; 5799 default : break;
5800 } 5800 }
5801 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight); 5801 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight);
5802 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]); 5802 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]);
5803 } 5803 }
5804 } else { 5804 } else {
5805 if (argc == 5) { 5805 if (argc == 5) {
5806 for (i=0;i<Bitmap.Number;i++) { 5806 for (i=0;i<Bitmap.Number;i++) {
5807 if (mystrncasecmp(argv[4],"PICTURE",0)) { 5807 if (mystrncasecmp(argv[4],"PICTURE",0)) {
5808 Bitmap.Bitmap[i].Type = GSM_PictureImage; 5808 Bitmap.Bitmap[i].Type = GSM_PictureImage;
5809 } else if (mystrncasecmp(argv[4],"STARTUP",0)) { 5809 } else if (mystrncasecmp(argv[4],"STARTUP",0)) {
5810 Bitmap.Bitmap[i].Type = GSM_StartupLogo; 5810 Bitmap.Bitmap[i].Type = GSM_StartupLogo;
5811 } else if (mystrncasecmp(argv[4],"CALLER",0)) { 5811 } else if (mystrncasecmp(argv[4],"CALLER",0)) {
5812 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; 5812 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo;
5813 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { 5813 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) {
5814 Bitmap.Bitmap[i].Type = GSM_OperatorLogo; 5814 Bitmap.Bitmap[i].Type = GSM_OperatorLogo;
5815 } else { 5815 } else {
5816 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); 5816 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]);
5817 exit(-1); 5817 exit(-1);
5818 } 5818 }
5819 } 5819 }
5820 } 5820 }
5821 error=GSM_SaveBitmapFile(argv[3],&Bitmap); 5821 error=GSM_SaveBitmapFile(argv[3],&Bitmap);
5822 Print_Error(error); 5822 Print_Error(error);
5823 } 5823 }
5824} 5824}
5825 5825
5826static void NokiaComposer(int argc, char *argv[]) 5826static void NokiaComposer(int argc, char *argv[])
5827{ 5827{
5828 GSM_Ringtone ringtone; 5828 GSM_Ringtone ringtone;
5829 bool started; 5829 bool started;
5830 int i,j; 5830 int i,j;
5831 GSM_RingNote *Note; 5831 GSM_RingNote *Note;
5832 GSM_RingNoteDuration Duration; 5832 GSM_RingNoteDuration Duration;
5833 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ 5833 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */
5834 unsigned int DefNoteScale = Scale_880; 5834 unsigned int DefNoteScale = Scale_880;
5835 5835
5836 ringtone.Format= 0; 5836 ringtone.Format= 0;
5837 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5837 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5838 5838
5839 if (ringtone.Format != RING_NOTETONE) { 5839 if (ringtone.Format != RING_NOTETONE) {
5840 printmsg("It can be RTTL ringtone only used with this option\n"); 5840 printmsg("It can be RTTL ringtone only used with this option\n");
5841 exit(-1); 5841 exit(-1);
5842 } 5842 }
5843 5843
5844 started = false; 5844 started = false;
5845 j= 0; 5845 j= 0;
5846 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5846 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5847 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5847 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5848 Note = &ringtone.NoteTone.Commands[i].Note; 5848 Note = &ringtone.NoteTone.Commands[i].Note;
5849 if (!started) { 5849 if (!started) {
5850 if (Note->Note != Note_Pause) { 5850 if (Note->Note != Note_Pause) {
5851 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); 5851 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo));
5852 started = true; 5852 started = true;
5853 } 5853 }
5854 } 5854 }
5855 if (started) j++; 5855 if (started) j++;
5856 } 5856 }
5857 } 5857 }
5858 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); 5858 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j);
5859 5859
5860 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); 5860 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: ");
5861 started = false; 5861 started = false;
5862 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5862 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5863 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5863 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5864 Note = &ringtone.NoteTone.Commands[i].Note; 5864 Note = &ringtone.NoteTone.Commands[i].Note;
5865 if (!started) { 5865 if (!started) {
5866 if (Note->Note != Note_Pause) started = true; 5866 if (Note->Note != Note_Pause) started = true;
5867 } 5867 }
5868 if (started) { 5868 if (started) {
5869 switch (Note->Duration) { 5869 switch (Note->Duration) {
5870 case Duration_Full: printmsg("1"); break; 5870 case Duration_Full: printmsg("1"); break;
5871 case Duration_1_2 : printmsg("2"); break; 5871 case Duration_1_2 : printmsg("2"); break;
5872 case Duration_1_4 : printmsg("4"); break; 5872 case Duration_1_4 : printmsg("4"); break;
5873 case Duration_1_8 : printmsg("8"); break; 5873 case Duration_1_8 : printmsg("8"); break;
5874 case Duration_1_16: printmsg("16");break; 5874 case Duration_1_16: printmsg("16");break;
5875 case Duration_1_32: printmsg("32");break; 5875 case Duration_1_32: printmsg("32");break;
5876 } 5876 }
5877 if (Note->DurationSpec == DottedNote) printmsg("."); 5877 if (Note->DurationSpec == DottedNote) printmsg(".");
5878 switch (Note->Note) { 5878 switch (Note->Note) {
5879 case Note_C : printmsg("c");break; 5879 case Note_C : printmsg("c");break;
5880 case Note_Cis : printmsg("#c");break; 5880 case Note_Cis : printmsg("#c");break;
5881 case Note_D :printmsg("d");break; 5881 case Note_D :printmsg("d");break;
5882 case Note_Dis : printmsg("#d");break; 5882 case Note_Dis : printmsg("#d");break;
5883 case Note_E : printmsg("e");break; 5883 case Note_E : printmsg("e");break;
5884 case Note_F : printmsg("f");break; 5884 case Note_F : printmsg("f");break;
5885 case Note_Fis : printmsg("#f");break; 5885 case Note_Fis : printmsg("#f");break;
5886 case Note_G : printmsg("g");break; 5886 case Note_G : printmsg("g");break;
5887 case Note_Gis : printmsg("#g");break; 5887 case Note_Gis : printmsg("#g");break;
5888 case Note_A : printmsg("a");break; 5888 case Note_A : printmsg("a");break;
5889 case Note_Ais : printmsg("#a");break; 5889 case Note_Ais : printmsg("#a");break;
5890 case Note_H : printmsg("h");break; 5890 case Note_H : printmsg("h");break;
5891 case Note_Pause : printmsg("-");break; 5891 case Note_Pause : printmsg("-");break;
5892 } 5892 }
5893 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4); 5893 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4);
5894 printmsg(" "); 5894 printmsg(" ");
5895 } 5895 }
5896 } 5896 }
5897 } 5897 }
5898 5898
5899 printmsg("\n\nTo enter it please press: "); 5899 printmsg("\n\nTo enter it please press: ");
5900 started = false; 5900 started = false;
5901 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5901 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5902 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5902 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5903 Note = &ringtone.NoteTone.Commands[i].Note; 5903 Note = &ringtone.NoteTone.Commands[i].Note;
5904 if (!started) { 5904 if (!started) {
5905 if (Note->Note != Note_Pause) started = true; 5905 if (Note->Note != Note_Pause) started = true;
5906 } 5906 }
5907 if (started) { 5907 if (started) {
5908 switch (Note->Note) { 5908 switch (Note->Note) {
5909 case Note_C : case Note_Cis:printmsg("1");break; 5909 case Note_C : case Note_Cis:printmsg("1");break;
5910 case Note_D : case Note_Dis:printmsg("2");break; 5910 case Note_D : case Note_Dis:printmsg("2");break;
5911 case Note_E : printmsg("3");break; 5911 case Note_E : printmsg("3");break;
5912 case Note_F : case Note_Fis:printmsg("4");break; 5912 case Note_F : case Note_Fis:printmsg("4");break;
5913 case Note_G : case Note_Gis:printmsg("5");break; 5913 case Note_G : case Note_Gis:printmsg("5");break;
5914 case Note_A : case Note_Ais:printmsg("6");break; 5914 case Note_A : case Note_Ais:printmsg("6");break;
5915 case Note_H : printmsg("7");break; 5915 case Note_H : printmsg("7");break;
5916 default : printmsg("0");break; 5916 default : printmsg("0");break;
5917 } 5917 }
5918 if (Note->DurationSpec == DottedNote) printmsg("(longer)"); 5918 if (Note->DurationSpec == DottedNote) printmsg("(longer)");
5919 switch (Note->Note) { 5919 switch (Note->Note) {
5920 case Note_Cis: case Note_Dis: 5920 case Note_Cis: case Note_Dis:
5921 case Note_Fis: case Note_Gis: 5921 case Note_Fis: case Note_Gis:
5922 case Note_Ais: 5922 case Note_Ais:
5923 printmsg("#"); 5923 printmsg("#");
5924 break; 5924 break;
5925 default : 5925 default :
5926 break; 5926 break;
5927 } 5927 }
5928 if (Note->Note != Note_Pause) { 5928 if (Note->Note != Note_Pause) {
5929 if ((unsigned int)Note->Scale != DefNoteScale) { 5929 if ((unsigned int)Note->Scale != DefNoteScale) {
5930 while (DefNoteScale != (unsigned int)Note->Scale) { 5930 while (DefNoteScale != (unsigned int)Note->Scale) {
5931 printmsg("*"); 5931 printmsg("*");
5932 DefNoteScale++; 5932 DefNoteScale++;
5933 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880; 5933 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880;
5934 } 5934 }
5935 } 5935 }
5936 } 5936 }
5937 Duration = 0; 5937 Duration = 0;
5938 switch (Note->Duration) { 5938 switch (Note->Duration) {
5939 case Duration_Full : Duration = 128;break; 5939 case Duration_Full : Duration = 128;break;
5940 case Duration_1_2 : Duration = 64;break; 5940 case Duration_1_2 : Duration = 64;break;
5941 case Duration_1_4 : Duration = 32;break; 5941 case Duration_1_4 : Duration = 32;break;
5942 case Duration_1_8 : Duration = 16;break; 5942 case Duration_1_8 : Duration = 16;break;
5943 case Duration_1_16 : Duration = 8;break; 5943 case Duration_1_16 : Duration = 8;break;
5944 case Duration_1_32 : Duration = 4;break; 5944 case Duration_1_32 : Duration = 4;break;
5945 default : dbgprintf("error\n");break; 5945 default : dbgprintf("error\n");break;
5946 } 5946 }
5947 if (Duration > DefNoteDuration) { 5947 if (Duration > DefNoteDuration) {
5948 while (DefNoteDuration != Duration) { 5948 while (DefNoteDuration != Duration) {
5949 printmsg("9"); 5949 printmsg("9");
5950 DefNoteDuration = DefNoteDuration * 2; 5950 DefNoteDuration = DefNoteDuration * 2;
5951 } 5951 }
5952 } 5952 }
5953 if (Duration < DefNoteDuration) { 5953 if (Duration < DefNoteDuration) {
5954 while (DefNoteDuration != Duration) { 5954 while (DefNoteDuration != Duration) {
5955 printmsg("8"); 5955 printmsg("8");
5956 DefNoteDuration = DefNoteDuration / 2; 5956 DefNoteDuration = DefNoteDuration / 2;
5957 } 5957 }
5958 } 5958 }
5959 printmsg(" "); 5959 printmsg(" ");
5960 } 5960 }
5961 } 5961 }
5962 } 5962 }
5963 5963
5964 printf("\n"); 5964 printf("\n");
5965} 5965}
5966 5966
5967static void CopyRingtone(int argc, char *argv[]) 5967static void CopyRingtone(int argc, char *argv[])
5968{ 5968{
5969 GSM_Ringtone ringtone, ringtone2; 5969 GSM_Ringtone ringtone, ringtone2;
5970 GSM_RingtoneFormatFormat; 5970 GSM_RingtoneFormatFormat;
5971 5971
5972 ringtone.Format= 0; 5972 ringtone.Format= 0;
5973 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5973 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5974 Print_Error(error); 5974 Print_Error(error);
5975 5975
5976 Format = ringtone.Format; 5976 Format = ringtone.Format;
5977 if (argc == 5) { 5977 if (argc == 5) {
5978 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; 5978 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE;
5979 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY; 5979 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY;
5980 } else { 5980 } else {
5981 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]); 5981 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]);
5982 exit(-1); 5982 exit(-1);
5983 } 5983 }
5984 } 5984 }
5985 5985
5986 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format); 5986 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format);
5987 Print_Error(error); 5987 Print_Error(error);
5988 5988
5989 error=GSM_SaveRingtoneFile(argv[3],&ringtone2); 5989 error=GSM_SaveRingtoneFile(argv[3],&ringtone2);
5990 Print_Error(error); 5990 Print_Error(error);
5991} 5991}
5992 5992
5993static void PressKeySequence(int argc, char *argv[]) 5993static void PressKeySequence(int argc, char *argv[])
5994{ 5994{
5995 int i,Length; 5995 int i,Length;
5996 GSM_KeyCodeKeyCode[500]; 5996 GSM_KeyCodeKeyCode[500];
5997 5997
5998 error = MakeKeySequence(argv[2], KeyCode, &Length); 5998 error = MakeKeySequence(argv[2], KeyCode, &Length);
5999 if (error == ERR_NOTSUPPORTED) { 5999 if (error == ERR_NOTSUPPORTED) {
6000 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]); 6000 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]);
6001 exit(-1); 6001 exit(-1);
6002 } 6002 }
6003 6003
6004 GSM_Init(true); 6004 GSM_Init(true);
6005 6005
6006 for (i=0;i<Length;i++) { 6006 for (i=0;i<Length;i++) {
6007 error=Phone->PressKey(&s, KeyCode[i], true); 6007 error=Phone->PressKey(&s, KeyCode[i], true);
6008 Print_Error(error); 6008 Print_Error(error);
6009 error=Phone->PressKey(&s, KeyCode[i], false); 6009 error=Phone->PressKey(&s, KeyCode[i], false);
6010 Print_Error(error); 6010 Print_Error(error);
6011 } 6011 }
6012 6012
6013 GSM_Terminate(); 6013 GSM_Terminate();
6014} 6014}
6015 6015
6016static void GetAllCategories(int argc, char *argv[]) 6016static void GetAllCategories(int argc, char *argv[])
6017{ 6017{
6018 GSM_Category Category; 6018 GSM_Category Category;
6019 GSM_CategoryStatusStatus; 6019 GSM_CategoryStatusStatus;
6020 int j, count; 6020 int j, count;
6021 6021
6022 if (mystrncasecmp(argv[2],"TODO",0)) { 6022 if (mystrncasecmp(argv[2],"TODO",0)) {
6023 Category.Type = Category_ToDo; 6023 Category.Type = Category_ToDo;
6024 Status.Type = Category_ToDo; 6024 Status.Type = Category_ToDo;
6025 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 6025 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
6026 Category.Type = Category_Phonebook; 6026 Category.Type = Category_Phonebook;
6027 Status.Type = Category_Phonebook; 6027 Status.Type = Category_Phonebook;
6028 } else { 6028 } else {
6029 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 6029 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
6030 exit(-1); 6030 exit(-1);
6031 } 6031 }
6032 6032
6033 GSM_Init(true); 6033 GSM_Init(true);
6034 6034
6035 error=Phone->GetCategoryStatus(&s, &Status); 6035 error=Phone->GetCategoryStatus(&s, &Status);
6036 Print_Error(error); 6036 Print_Error(error);
6037 6037
6038 for (count=0,j=1;count<Status.Used;j++) 6038 for (count=0,j=1;count<Status.Used;j++)
6039 { 6039 {
6040 Category.Location=j; 6040 Category.Location=j;
6041 error=Phone->GetCategory(&s, &Category); 6041 error=Phone->GetCategory(&s, &Category);
6042 6042
6043 if (error != ERR_EMPTY) { 6043 if (error != ERR_EMPTY) {
6044 printmsg("Location: %i\n",j); 6044 printmsg("Location: %i\n",j);
6045 6045
6046 Print_Error(error); 6046 Print_Error(error);
6047 6047
6048 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 6048 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
6049 count++; 6049 count++;
6050 } 6050 }
6051 } 6051 }
6052 6052
6053 GSM_Terminate(); 6053 GSM_Terminate();
6054} 6054}
6055 6055
6056static void GetCategory(int argc, char *argv[]) 6056static void GetCategory(int argc, char *argv[])
6057{ 6057{
6058 GSM_CategoryCategory; 6058 GSM_CategoryCategory;
6059 int start,stop,j; 6059 int start,stop,j;
6060 6060
6061 if (mystrncasecmp(argv[2],"TODO",0)) { 6061 if (mystrncasecmp(argv[2],"TODO",0)) {
6062 Category.Type = Category_ToDo; 6062 Category.Type = Category_ToDo;
6063 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 6063 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
6064 Category.Type = Category_Phonebook; 6064 Category.Type = Category_Phonebook;
6065 } else { 6065 } else {
6066 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 6066 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
6067 exit(-1); 6067 exit(-1);
6068 } 6068 }
6069 6069
6070 GetStartStop(&start, &stop, 2, argc - 1, argv + 1); 6070 GetStartStop(&start, &stop, 2, argc - 1, argv + 1);
6071 6071
6072 GSM_Init(true); 6072 GSM_Init(true);
6073 6073
6074 for (j=start;j<=stop;j++) 6074 for (j=start;j<=stop;j++)
6075 { 6075 {
6076 printmsg("Location: %i\n",j); 6076 printmsg("Location: %i\n",j);
6077 6077
6078 Category.Location=j; 6078 Category.Location=j;
6079 6079
6080 error=Phone->GetCategory(&s, &Category); 6080 error=Phone->GetCategory(&s, &Category);
6081 if (error != ERR_EMPTY) Print_Error(error); 6081 if (error != ERR_EMPTY) Print_Error(error);
6082 6082
6083 if (error == ERR_EMPTY) { 6083 if (error == ERR_EMPTY) {
6084 printmsg("Entry is empty\n\n"); 6084 printmsg("Entry is empty\n\n");
6085 } else { 6085 } else {
6086 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 6086 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
6087 } 6087 }
6088 } 6088 }
6089 6089
6090 GSM_Terminate(); 6090 GSM_Terminate();
6091} 6091}
6092 6092
6093static void DeleteToDo(int argc, char *argv[]) 6093static void DeleteToDo(int argc, char *argv[])
6094{ 6094{
6095 GSM_ToDoEntryToDo; 6095 GSM_ToDoEntryToDo;
6096 int i; 6096 int i;
6097 int start,stop; 6097 int start,stop;
6098 6098
6099 GetStartStop(&start, &stop, 2, argc, argv); 6099 GetStartStop(&start, &stop, 2, argc, argv);
6100 6100
6101 GSM_Init(true); 6101 GSM_Init(true);
6102 6102
6103 for (i=start;i<=stop;i++) { 6103 for (i=start;i<=stop;i++) {
6104 ToDo.Location=i; 6104 ToDo.Location=i;
6105 printmsg("Location : %i\n",i); 6105 printmsg("Location : %i\n",i);
6106 error=Phone->DeleteToDo(&s,&ToDo); 6106 error=Phone->DeleteToDo(&s,&ToDo);
6107 if (error != ERR_EMPTY) Print_Error(error); 6107 if (error != ERR_EMPTY) Print_Error(error);
6108 6108
6109 if (error == ERR_EMPTY) { 6109 if (error == ERR_EMPTY) {
6110 printmsg("Entry was empty\n"); 6110 printmsg("Entry was empty\n");
6111 } else { 6111 } else {
6112 printmsg("Entry was deleted\n"); 6112 printmsg("Entry was deleted\n");
6113 } 6113 }
6114 printf("\n"); 6114 printf("\n");
6115 } 6115 }
6116 6116
6117 GSM_Terminate(); 6117 GSM_Terminate();
6118} 6118}
6119 6119
6120static void PrintToDo(GSM_ToDoEntry *ToDo) 6120static void PrintToDo(GSM_ToDoEntry *ToDo)
6121{ 6121{
6122 int j; 6122 int j;
6123 GSM_MemoryEntry entry; 6123 GSM_MemoryEntry entry;
6124 unsigned char *name; 6124 unsigned char *name;
6125 GSM_Category Category; 6125 GSM_Category Category;
6126 6126
6127 printmsg("Location : %i\n",ToDo->Location); 6127 printmsg("Location : %i\n",ToDo->Location);
6128 printmsg("Priority : "); 6128 printmsg("Priority : ");
6129 switch (ToDo->Priority) { 6129 switch (ToDo->Priority) {
6130 case GSM_Priority_Low : printmsg("Low\n"); break; 6130 case GSM_Priority_Low : printmsg("Low\n"); break;
6131 case GSM_Priority_Medium : printmsg("Medium\n"); break; 6131 case GSM_Priority_Medium : printmsg("Medium\n"); break;
6132 case GSM_Priority_High : printmsg("High\n"); break; 6132 case GSM_Priority_High : printmsg("High\n"); break;
6133 default : printmsg("Unknown\n");break; 6133 default : printmsg("Unknown\n");break;
6134 } 6134 }
6135 for (j=0;j<ToDo->EntriesNum;j++) { 6135 for (j=0;j<ToDo->EntriesNum;j++) {
6136 switch (ToDo->Entries[j].EntryType) { 6136 switch (ToDo->Entries[j].EntryType) {
6137 case TODO_END_DATETIME: 6137 case TODO_END_DATETIME:
6138 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 6138 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
6139 break; 6139 break;
6140 case TODO_COMPLETED: 6140 case TODO_COMPLETED:
6141 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 6141 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
6142 break; 6142 break;
6143 case TODO_ALARM_DATETIME: 6143 case TODO_ALARM_DATETIME:
6144 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 6144 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
6145 break; 6145 break;
6146 case TODO_SILENT_ALARM_DATETIME: 6146 case TODO_SILENT_ALARM_DATETIME:
6147 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 6147 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
6148 break; 6148 break;
6149 case TODO_TEXT: 6149 case TODO_TEXT:
6150 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 6150 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
6151 break; 6151 break;
6152 case TODO_PRIVATE: 6152 case TODO_PRIVATE:
6153 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 6153 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
6154 break; 6154 break;
6155 case TODO_CATEGORY: 6155 case TODO_CATEGORY:
6156 Category.Location = ToDo->Entries[j].Number; 6156 Category.Location = ToDo->Entries[j].Number;
6157 Category.Type = Category_ToDo; 6157 Category.Type = Category_ToDo;
6158 error=Phone->GetCategory(&s, &Category); 6158 error=Phone->GetCategory(&s, &Category);
6159 if (error == ERR_NONE) { 6159 if (error == ERR_NONE) {
6160 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number); 6160 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number);
6161 } else { 6161 } else {
6162 printmsg("Category : %i\n", ToDo->Entries[j].Number); 6162 printmsg("Category : %i\n", ToDo->Entries[j].Number);
6163 } 6163 }
6164 break; 6164 break;
6165 case TODO_CONTACTID: 6165 case TODO_CONTACTID:
6166 entry.Location = ToDo->Entries[j].Number; 6166 entry.Location = ToDo->Entries[j].Number;
6167 entry.MemoryType = MEM_ME; 6167 entry.MemoryType = MEM_ME;
6168 error=Phone->GetMemory(&s, &entry); 6168 error=Phone->GetMemory(&s, &entry);
6169 if (error == ERR_NONE) { 6169 if (error == ERR_NONE) {
6170 name = GSM_PhonebookGetEntryName(&entry); 6170 name = GSM_PhonebookGetEntryName(&entry);
6171 if (name != NULL) { 6171 if (name != NULL) {
6172 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 6172 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
6173 } else { 6173 } else {
6174 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 6174 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
6175 } 6175 }
6176 } else { 6176 } else {
6177 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 6177 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
6178 } 6178 }
6179 break; 6179 break;
6180 case TODO_PHONE: 6180 case TODO_PHONE:
6181 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 6181 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
6182 break; 6182 break;
6183 } 6183 }
6184 } 6184 }
6185 printf("\n"); 6185 printf("\n");
6186} 6186}
6187 6187
6188static void ListToDoCategoryEntries(int Category) 6188static void ListToDoCategoryEntries(int Category)
6189{ 6189{
6190 GSM_ToDoEntry Entry; 6190 GSM_ToDoEntry Entry;
6191 bool start = true; 6191 bool start = true;
6192 int j; 6192 int j;
6193 6193
6194 while (!gshutdown) { 6194 while (!gshutdown) {
6195 error = Phone->GetNextToDo(&s, &Entry, start); 6195 error = Phone->GetNextToDo(&s, &Entry, start);
6196 if (error == ERR_EMPTY) break; 6196 if (error == ERR_EMPTY) break;
6197 Print_Error(error); 6197 Print_Error(error);
6198 for (j=0;j<Entry.EntriesNum;j++) { 6198 for (j=0;j<Entry.EntriesNum;j++) {
6199 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category) 6199 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category)
6200 PrintToDo(&Entry); 6200 PrintToDo(&Entry);
6201 } 6201 }
6202 start = false; 6202 start = false;
6203 } 6203 }
6204} 6204}
6205 6205
6206static void ListToDoCategory(int argc, char *argv[]) 6206static void ListToDoCategory(int argc, char *argv[])
6207{ 6207{
6208 GSM_Category Category; 6208 GSM_Category Category;
6209 GSM_CategoryStatusStatus; 6209 GSM_CategoryStatusStatus;
6210 int j, count; 6210 int j, count;
6211 6211
6212 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; 6212 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
6213 int Length; 6213 int Length;
6214 bool Number = true;; 6214 bool Number = true;;
6215 6215
6216 GSM_Init(true); 6216 GSM_Init(true);
6217 6217
6218 signal(SIGINT, interrupt); 6218 signal(SIGINT, interrupt);
6219 printmsgerr("Press Ctrl+C to break...\n"); 6219 printmsgerr("Press Ctrl+C to break...\n");
6220 6220
6221 Length = strlen(argv[2]); 6221 Length = strlen(argv[2]);
6222 for (j = 0; j < Length; j++) { 6222 for (j = 0; j < Length; j++) {
6223 if (!isdigit(argv[2][j])) { 6223 if (!isdigit(argv[2][j])) {
6224 Number = false; 6224 Number = false;
6225 break; 6225 break;
6226 } 6226 }
6227 } 6227 }
6228 6228
6229 if (Number) { 6229 if (Number) {
6230 j = atoi(argv[2]); 6230 j = atoi(argv[2]);
6231 if (j > 0) { 6231 if (j > 0) {
6232 ListToDoCategoryEntries(j); 6232 ListToDoCategoryEntries(j);
6233 } 6233 }
6234 } else { 6234 } else {
6235 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { 6235 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
6236 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); 6236 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
6237 Length = GSM_MAX_CATEGORY_NAME_LENGTH; 6237 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
6238 } 6238 }
6239 EncodeUnicode(Text, argv[2], Length); 6239 EncodeUnicode(Text, argv[2], Length);
6240 6240
6241 Category.Type = Category_ToDo; 6241 Category.Type = Category_ToDo;
6242 Status.Type = Category_ToDo; 6242 Status.Type = Category_ToDo;
6243 6243
6244 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 6244 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
6245 for (count=0,j=1;count<Status.Used;j++) { 6245 for (count=0,j=1;count<Status.Used;j++) {
6246 Category.Location=j; 6246 Category.Location=j;
6247 error=Phone->GetCategory(&s, &Category); 6247 error=Phone->GetCategory(&s, &Category);
6248 6248
6249 if (error != ERR_EMPTY) { 6249 if (error != ERR_EMPTY) {
6250 count++; 6250 count++;
6251 if (mywstrstr(Category.Name, Text) != NULL) { 6251 if (mywstrstr(Category.Name, Text) != NULL) {
6252 ListToDoCategoryEntries(j); 6252 ListToDoCategoryEntries(j);
6253 } 6253 }
6254 } 6254 }
6255 } 6255 }
6256 } 6256 }
6257 } 6257 }
6258 GSM_Terminate(); 6258 GSM_Terminate();
6259} 6259}
6260 6260
6261 6261
6262static void GetToDo(int argc, char *argv[]) 6262static void GetToDo(int argc, char *argv[])
6263{ 6263{
6264 GSM_ToDoEntryToDo; 6264 GSM_ToDoEntryToDo;
6265 int i; 6265 int i;
6266 int start,stop; 6266 int start,stop;
6267 6267
6268 GetStartStop(&start, &stop, 2, argc, argv); 6268 GetStartStop(&start, &stop, 2, argc, argv);
6269 6269
6270 GSM_Init(true); 6270 GSM_Init(true);
6271 6271
6272 for (i=start;i<=stop;i++) { 6272 for (i=start;i<=stop;i++) {
6273 ToDo.Location=i; 6273 ToDo.Location=i;
6274 error = Phone->GetToDo(&s,&ToDo); 6274 error = Phone->GetToDo(&s,&ToDo);
6275 if (error == ERR_EMPTY) continue; 6275 if (error == ERR_EMPTY) continue;
6276 Print_Error(error); 6276 Print_Error(error);
6277 PrintToDo(&ToDo); 6277 PrintToDo(&ToDo);
6278 } 6278 }
6279 6279
6280 GSM_Terminate(); 6280 GSM_Terminate();
6281} 6281}
6282 6282
6283static void GetAllToDo(int argc, char *argv[]) 6283static void GetAllToDo(int argc, char *argv[])
6284{ 6284{
6285 GSM_ToDoEntry ToDo; 6285 GSM_ToDoEntry ToDo;
6286 bool start = true; 6286 bool start = true;
6287 6287
6288 signal(SIGINT, interrupt); 6288 signal(SIGINT, interrupt);
6289 printmsgerr("Press Ctrl+C to break...\n"); 6289 printmsgerr("Press Ctrl+C to break...\n");
6290 6290
6291 GSM_Init(true); 6291 GSM_Init(true);
6292 6292
6293 while (!gshutdown) { 6293 while (!gshutdown) {
6294 error = Phone->GetNextToDo(&s, &ToDo, start); 6294 error = Phone->GetNextToDo(&s, &ToDo, start);
6295 if (error == ERR_EMPTY) break; 6295 if (error == ERR_EMPTY) break;
6296 Print_Error(error); 6296 Print_Error(error);
6297 PrintToDo(&ToDo); 6297 PrintToDo(&ToDo);
6298 start = false; 6298 start = false;
6299 } 6299 }
6300 6300
6301 GSM_Terminate(); 6301 GSM_Terminate();
6302} 6302}
6303 6303
6304static void GetAllNotes(int argc, char *argv[]) 6304static void GetAllNotes(int argc, char *argv[])
6305{ 6305{
6306 GSM_NoteEntry Note; 6306 GSM_NoteEntry Note;
6307 bool start = true; 6307 bool start = true;
6308 6308
6309 signal(SIGINT, interrupt); 6309 signal(SIGINT, interrupt);
6310 printmsgerr("Press Ctrl+C to break...\n"); 6310 printmsgerr("Press Ctrl+C to break...\n");
6311 6311
6312 GSM_Init(true); 6312 GSM_Init(true);
6313 6313
6314 while (!gshutdown) { 6314 while (!gshutdown) {
6315 error = Phone->GetNextNote(&s, &Note, start); 6315 error = Phone->GetNextNote(&s, &Note, start);
6316 if (error == ERR_EMPTY) break; 6316 if (error == ERR_EMPTY) break;
6317 Print_Error(error); 6317 Print_Error(error);
6318 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text)); 6318 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
6319 printf("\n"); 6319 printf("\n");
6320 start = false; 6320 start = false;
6321 } 6321 }
6322 GSM_Terminate(); 6322 GSM_Terminate();
6323} 6323}
6324 6324
6325static void GetSecurityStatus(int argc, char *argv[]) 6325static void GetSecurityStatus(int argc, char *argv[])
6326{ 6326{
6327 GSM_Init(true); 6327 GSM_Init(true);
6328 6328
6329 PrintSecurityStatus(); 6329 PrintSecurityStatus();
6330 6330
6331 GSM_Terminate(); 6331 GSM_Terminate();
6332} 6332}
6333 6333
6334static void EnterSecurityCode(int argc, char *argv[]) 6334static void EnterSecurityCode(int argc, char *argv[])
6335{ 6335{
6336 GSM_SecurityCode Code; 6336 GSM_SecurityCode Code;
6337 6337
6338 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin; 6338 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin;
6339 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk; 6339 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk;
6340 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2; 6340 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2;
6341 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2; 6341 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2;
6342 } else { 6342 } else {
6343 printmsg("What security code (\"%s\") ?\n",argv[2]); 6343 printmsg("What security code (\"%s\") ?\n",argv[2]);
6344 exit(-1); 6344 exit(-1);
6345 } 6345 }
6346 6346
6347 strcpy(Code.Code,argv[3]); 6347 strcpy(Code.Code,argv[3]);
6348 6348
6349 GSM_Init(true); 6349 GSM_Init(true);
6350 6350
6351 error=Phone->EnterSecurityCode(&s,Code); 6351 error=Phone->EnterSecurityCode(&s,Code);
6352 Print_Error(error); 6352 Print_Error(error);
6353 6353
6354 GSM_Terminate(); 6354 GSM_Terminate();
6355} 6355}
6356 6356
6357static void GetProfile(int argc, char *argv[]) 6357static void GetProfile(int argc, char *argv[])
6358{ 6358{
6359 GSM_Profile Profile; 6359 GSM_Profile Profile;
6360 int start,stop,j,k; 6360 int start,stop,j,k;
6361 GSM_Bitmap caller[5]; 6361 GSM_Bitmap caller[5];
6362 bool callerinit[5],special; 6362 bool callerinit[5],special;
6363 GSM_AllRingtonesInfo Info; 6363 GSM_AllRingtonesInfo Info;
6364 6364
6365 GetStartStop(&start, &stop, 2, argc, argv); 6365 GetStartStop(&start, &stop, 2, argc, argv);
6366 6366
6367 for (i=0;i<5;i++) callerinit[i] = false; 6367 for (i=0;i<5;i++) callerinit[i] = false;
6368 6368
6369 GSM_Init(true); 6369 GSM_Init(true);
6370 6370
6371 error=Phone->GetRingtonesInfo(&s,&Info); 6371 error=Phone->GetRingtonesInfo(&s,&Info);
6372 if (error != ERR_NONE) Info.Number = 0; 6372 if (error != ERR_NONE) Info.Number = 0;
6373 6373
6374 for (i=start;i<=stop;i++) { 6374 for (i=start;i<=stop;i++) {
6375 Profile.Location=i; 6375 Profile.Location=i;
6376 error=Phone->GetProfile(&s,&Profile); 6376 error=Phone->GetProfile(&s,&Profile);
6377 Print_Error(error); 6377 Print_Error(error);
6378 6378
6379 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); 6379 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name));
6380 if (Profile.Active) printmsg(" (active)"); 6380 if (Profile.Active) printmsg(" (active)");
6381 if (Profile.DefaultName) printmsg(" (default name)"); 6381 if (Profile.DefaultName) printmsg(" (default name)");
6382 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); 6382 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)");
6383 if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); 6383 if (Profile.CarKitProfile) printmsg(" (CarKit profile)");
6384 printf("\n"); 6384 printf("\n");
6385 for (j=0;j<Profile.FeaturesNumber;j++) { 6385 for (j=0;j<Profile.FeaturesNumber;j++) {
6386 special = false; 6386 special = false;
6387 switch (Profile.FeatureID[j]) { 6387 switch (Profile.FeatureID[j]) {
6388 case Profile_MessageToneID: 6388 case Profile_MessageToneID:
6389 case Profile_RingtoneID: 6389 case Profile_RingtoneID:
6390 special = true; 6390 special = true;
6391 if (Profile.FeatureID[j] == Profile_RingtoneID) { 6391 if (Profile.FeatureID[j] == Profile_RingtoneID) {
6392 printmsg("Ringtone ID : "); 6392 printmsg("Ringtone ID : ");
6393 } else { 6393 } else {
6394 printmsg("Message alert tone ID : "); 6394 printmsg("Message alert tone ID : ");
6395 } 6395 }
6396 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { 6396 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) {
6397 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); 6397 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j])));
6398 } else { 6398 } else {
6399 printmsg("%i\n",Profile.FeatureValue[j]); 6399 printmsg("%i\n",Profile.FeatureValue[j]);
6400 } 6400 }
6401 break; 6401 break;
6402 case Profile_CallerGroups: 6402 case Profile_CallerGroups:
6403 special = true; 6403 special = true;
6404 printmsg("Call alert for :"); 6404 printmsg("Call alert for :");
6405 for (k=0;k<5;k++) { 6405 for (k=0;k<5;k++) {
6406 if (Profile.CallerGroups[k]) { 6406 if (Profile.CallerGroups[k]) {
6407 if (!callerinit[k]) { 6407 if (!callerinit[k]) {
6408 caller[k].Type = GSM_CallerGroupLogo; 6408 caller[k].Type = GSM_CallerGroupLogo;
6409 caller[k].Location = k + 1; 6409 caller[k].Location = k + 1;
6410 error=Phone->GetBitmap(&s,&caller[k]); 6410 error=Phone->GetBitmap(&s,&caller[k]);
6411 if (error == ERR_SECURITYERROR) { 6411 if (error == ERR_SECURITYERROR) {
6412 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); 6412 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]);
6413 } else { 6413 } else {
6414 Print_Error(error); 6414 Print_Error(error);
6415 } 6415 }
6416 callerinit[k]= true; 6416 callerinit[k]= true;
6417 } 6417 }
6418 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); 6418 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text));
6419 } 6419 }
6420 } 6420 }
6421 printf("\n"); 6421 printf("\n");
6422 break; 6422 break;
6423 case Profile_ScreenSaverNumber: 6423 case Profile_ScreenSaverNumber:
6424 special = true; 6424 special = true;
6425 printmsg("Screen saver number : "); 6425 printmsg("Screen saver number : ");
6426 printmsg("%i\n",Profile.FeatureValue[j]); 6426 printmsg("%i\n",Profile.FeatureValue[j]);
6427 break; 6427 break;
6428 case Profile_CallAlert : printmsg("Incoming call alert : "); break; 6428 case Profile_CallAlert : printmsg("Incoming call alert : "); break;
6429 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; 6429 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break;
6430 case Profile_Vibration : printmsg("Vibrating alert : "); break; 6430 case Profile_Vibration : printmsg("Vibrating alert : "); break;
6431 case Profile_MessageTone: printmsg("Message alert tone : "); break; 6431 case Profile_MessageTone: printmsg("Message alert tone : "); break;
6432 case Profile_KeypadTone : printmsg("Keypad tones : "); break; 6432 case Profile_KeypadTone : printmsg("Keypad tones : "); break;
6433 case Profile_WarningTone: printmsg("Warning (games) tones : "); break; 6433 case Profile_WarningTone: printmsg("Warning (games) tones : "); break;
6434 case Profile_ScreenSaver: printmsg("Screen saver : "); break; 6434 case Profile_ScreenSaver: printmsg("Screen saver : "); break;
6435 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break; 6435 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break;
6436 case Profile_AutoAnswer : printmsg("Automatic answer : "); break; 6436 case Profile_AutoAnswer : printmsg("Automatic answer : "); break;
6437 case Profile_Lights : printmsg("Lights : "); break; 6437 case Profile_Lights : printmsg("Lights : "); break;
6438 default: 6438 default:
6439 printmsg("Unknown\n"); 6439 printmsg("Unknown\n");
6440 special = true; 6440 special = true;
6441 } 6441 }
6442 if (!special) { 6442 if (!special) {
6443 switch (Profile.FeatureValue[j]) { 6443 switch (Profile.FeatureValue[j]) {
6444 case PROFILE_VOLUME_LEVEL1 : 6444 case PROFILE_VOLUME_LEVEL1 :
6445 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; 6445 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break;
6446 case PROFILE_VOLUME_LEVEL2 : 6446 case PROFILE_VOLUME_LEVEL2 :
6447 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; 6447 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break;
6448 case PROFILE_VOLUME_LEVEL3 : 6448 case PROFILE_VOLUME_LEVEL3 :
6449 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; 6449 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break;
6450 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; 6450 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break;
6451 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; 6451 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break;
6452 case PROFILE_MESSAGE_NOTONE : 6452 case PROFILE_MESSAGE_NOTONE :
6453 case PROFILE_AUTOANSWER_OFF : 6453 case PROFILE_AUTOANSWER_OFF :
6454 case PROFILE_LIGHTS_OFF : 6454 case PROFILE_LIGHTS_OFF :
6455 case PROFILE_SAVER_OFF : 6455 case PROFILE_SAVER_OFF :
6456 case PROFILE_WARNING_OFF : 6456 case PROFILE_WARNING_OFF :
6457 case PROFILE_CALLALERT_OFF : 6457 case PROFILE_CALLALERT_OFF :
6458 case PROFILE_VIBRATION_OFF : 6458 case PROFILE_VIBRATION_OFF :
6459 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; 6459 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break;
6460 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; 6460 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break;
6461 case PROFILE_CALLALERT_BEEPONCE : 6461 case PROFILE_CALLALERT_BEEPONCE :
6462 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; 6462 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break;
6463 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break; 6463 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break;
6464 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; 6464 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break;
6465 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break; 6465 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break;
6466 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; 6466 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break;
6467 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; 6467 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break;
6468 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; 6468 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break;
6469 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; 6469 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break;
6470 case PROFILE_AUTOANSWER_ON : 6470 case PROFILE_AUTOANSWER_ON :
6471 case PROFILE_WARNING_ON : 6471 case PROFILE_WARNING_ON :
6472 case PROFILE_SAVER_ON : 6472 case PROFILE_SAVER_ON :
6473 case PROFILE_VIBRATION_ON : printmsg("On\n"); break; 6473 case PROFILE_VIBRATION_ON : printmsg("On\n"); break;
6474 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break; 6474 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break;
6475 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; 6475 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break;
6476 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; 6476 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break;
6477 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; 6477 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break;
6478 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; 6478 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break;
6479 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break; 6479 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break;
6480 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break; 6480 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break;
6481 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break; 6481 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break;
6482 default : printmsg("UNKNOWN\n"); 6482 default : printmsg("UNKNOWN\n");
6483 } 6483 }
6484 } 6484 }
6485 } 6485 }
6486 printf("\n"); 6486 printf("\n");
6487 } 6487 }
6488 6488
6489 GSM_Terminate(); 6489 GSM_Terminate();
6490} 6490}
6491 6491
6492static void GetSpeedDial(int argc, char *argv[]) 6492static void GetSpeedDial(int argc, char *argv[])
6493{ 6493{
6494 GSM_SpeedDial SpeedDial; 6494 GSM_SpeedDial SpeedDial;
6495 GSM_MemoryEntry Phonebook; 6495 GSM_MemoryEntry Phonebook;
6496 int start,stop,Name,Number,Group; 6496 int start,stop,Name,Number,Group;
6497 6497
6498 GetStartStop(&start, &stop, 2, argc, argv); 6498 GetStartStop(&start, &stop, 2, argc, argv);
6499 6499
6500 GSM_Init(true); 6500 GSM_Init(true);
6501 6501
6502 for (i=start;i<=stop;i++) { 6502 for (i=start;i<=stop;i++) {
6503 SpeedDial.Location=i; 6503 SpeedDial.Location=i;
6504 error=Phone->GetSpeedDial(&s,&SpeedDial); 6504 error=Phone->GetSpeedDial(&s,&SpeedDial);
6505 printmsg("%i.",i); 6505 printmsg("%i.",i);
6506 switch (error) { 6506 switch (error) {
6507 case ERR_EMPTY: 6507 case ERR_EMPTY:
6508 printmsg(" speed dial not assigned\n"); 6508 printmsg(" speed dial not assigned\n");
6509 break; 6509 break;
6510 default: 6510 default:
6511 Print_Error(error); 6511 Print_Error(error);
6512 6512
6513 Phonebook.Location= SpeedDial.MemoryLocation; 6513 Phonebook.Location= SpeedDial.MemoryLocation;
6514 Phonebook.MemoryType = SpeedDial.MemoryType; 6514 Phonebook.MemoryType = SpeedDial.MemoryType;
6515 error=Phone->GetMemory(&s,&Phonebook); 6515 error=Phone->GetMemory(&s,&Phonebook);
6516 6516
6517 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); 6517 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group);
6518 6518
6519 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); 6519 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text));
6520 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); 6520 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text));
6521 } 6521 }
6522 printf("\n"); 6522 printf("\n");
6523 } 6523 }
6524 6524
6525 GSM_Terminate(); 6525 GSM_Terminate();
6526} 6526}
6527 6527
6528static void ResetPhoneSettings(int argc, char *argv[]) 6528static void ResetPhoneSettings(int argc, char *argv[])
6529{ 6529{
6530 GSM_ResetSettingsType Type; 6530 GSM_ResetSettingsType Type;
6531 6531
6532 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; 6532 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS;
6533 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; 6533 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE;
6534 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; 6534 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS;
6535 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; 6535 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE;
6536 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; 6536 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY;
6537 } else { 6537 } else {
6538 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); 6538 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]);
6539 exit(-1); 6539 exit(-1);
6540 } 6540 }
6541 6541
6542 GSM_Init(true); 6542 GSM_Init(true);
6543 6543
6544 error=Phone->ResetPhoneSettings(&s,Type); 6544 error=Phone->ResetPhoneSettings(&s,Type);
6545 Print_Error(error); 6545 Print_Error(error);
6546 6546
6547 GSM_Terminate(); 6547 GSM_Terminate();
6548} 6548}
6549 6549
6550#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 6550#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
6551static void NokiaSecurityCode(int argc, char *argv[]) 6551static void NokiaSecurityCode(int argc, char *argv[])
6552{ 6552{
6553 GSM_Init(true); 6553 GSM_Init(true);
6554 6554
6555#ifdef GSM_ENABLE_NOKIA_DCT3 6555#ifdef GSM_ENABLE_NOKIA_DCT3
6556 DCT3GetSecurityCode(argc,argv); 6556 DCT3GetSecurityCode(argc,argv);
6557#endif 6557#endif
6558#ifdef GSM_ENABLE_NOKIA_DCT4 6558#ifdef GSM_ENABLE_NOKIA_DCT4
6559 //DCT4ResetSecurityCode(argc, argv); 6559 //DCT4ResetSecurityCode(argc, argv);
6560 DCT4GetSecurityCode(argc,argv); 6560 DCT4GetSecurityCode(argc,argv);
6561#endif 6561#endif
6562 6562
6563 GSM_Terminate(); 6563 GSM_Terminate();
6564} 6564}
6565 6565
6566static void NokiaSetPhoneMenus(int argc, char *argv[]) 6566static void NokiaSetPhoneMenus(int argc, char *argv[])
6567{ 6567{
6568 GSM_Init(true); 6568 GSM_Init(true);
6569 6569
6570#ifdef GSM_ENABLE_NOKIA_DCT3 6570#ifdef GSM_ENABLE_NOKIA_DCT3
6571 DCT3SetPhoneMenus (argc, argv); 6571 DCT3SetPhoneMenus (argc, argv);
6572#endif 6572#endif
6573#ifdef GSM_ENABLE_NOKIA_DCT4 6573#ifdef GSM_ENABLE_NOKIA_DCT4
6574 DCT4SetPhoneMenus (argc, argv); 6574 DCT4SetPhoneMenus (argc, argv);
6575#endif 6575#endif
6576 6576
6577 GSM_Terminate(); 6577 GSM_Terminate();
6578} 6578}
6579 6579
6580static void NokiaSelfTests(int argc, char *argv[]) 6580static void NokiaSelfTests(int argc, char *argv[])
6581{ 6581{
6582 GSM_Init(true); 6582 GSM_Init(true);
6583 6583
6584#ifdef GSM_ENABLE_NOKIA_DCT3 6584#ifdef GSM_ENABLE_NOKIA_DCT3
6585 DCT3SelfTests(argc, argv); 6585 DCT3SelfTests(argc, argv);
6586#endif 6586#endif
6587#ifdef GSM_ENABLE_NOKIA_DCT4 6587#ifdef GSM_ENABLE_NOKIA_DCT4
6588 DCT4SelfTests(argc, argv); 6588 DCT4SelfTests(argc, argv);
6589#endif 6589#endif
6590 6590
6591 GSM_Terminate(); 6591 GSM_Terminate();
6592} 6592}
6593#endif 6593#endif
6594 6594
6595static void DeleteAllSMS(int argc, char *argv[]) 6595static void DeleteAllSMS(int argc, char *argv[])
6596{ 6596{
6597 GSM_MultiSMSMessage sms; 6597 GSM_MultiSMSMessage sms;
6598 GSM_SMSFolders folders; 6598 GSM_SMSFolders folders;
6599 int foldernum; 6599 int foldernum;
6600 bool start = true; 6600 bool start = true;
6601 6601
6602 GSM_Init(true); 6602 GSM_Init(true);
6603 6603
6604 error=Phone->GetSMSFolders(&s, &folders); 6604 error=Phone->GetSMSFolders(&s, &folders);
6605 Print_Error(error); 6605 Print_Error(error);
6606 6606
6607 GetStartStop(&foldernum, NULL, 2, argc, argv); 6607 GetStartStop(&foldernum, NULL, 2, argc, argv);
6608 if (foldernum > folders.Number) { 6608 if (foldernum > folders.Number) {
6609 printmsg("Too high folder number (max. %i)\n",folders.Number); 6609 printmsg("Too high folder number (max. %i)\n",folders.Number);
6610 GSM_Terminate(); 6610 GSM_Terminate();
6611 exit(-1); 6611 exit(-1);
6612 } 6612 }
6613 6613
6614 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name)); 6614 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name));
6615 6615
6616 while (error == ERR_NONE) { 6616 while (error == ERR_NONE) {
6617 sms.SMS[0].Folder=0x00; 6617 sms.SMS[0].Folder=0x00;
6618 error=Phone->GetNextSMS(&s, &sms, start); 6618 error=Phone->GetNextSMS(&s, &sms, start);
6619 switch (error) { 6619 switch (error) {
6620 case ERR_EMPTY: 6620 case ERR_EMPTY:
6621 break; 6621 break;
6622 default: 6622 default:
6623 Print_Error(error); 6623 Print_Error(error);
6624 if (sms.SMS[0].Folder == foldernum) { 6624 if (sms.SMS[0].Folder == foldernum) {
6625 sms.SMS[0].Folder=0x00; 6625 sms.SMS[0].Folder=0x00;
6626 error=Phone->DeleteSMS(&s, &sms.SMS[0]); 6626 error=Phone->DeleteSMS(&s, &sms.SMS[0]);
6627 Print_Error(error); 6627 Print_Error(error);
6628 printmsg("*"); 6628 printmsg("*");
6629 } 6629 }
6630 } 6630 }
6631 start=false; 6631 start=false;
6632 } 6632 }
6633 6633
6634 printf("\n"); 6634 printf("\n");
6635 6635
6636 GSM_Terminate(); 6636 GSM_Terminate();
6637} 6637}
6638 6638
6639static void SendDTMF(int argc, char *argv[]) 6639static void SendDTMF(int argc, char *argv[])
6640{ 6640{
6641 GSM_Init(true); 6641 GSM_Init(true);
6642 6642
6643 error=Phone->SendDTMF(&s,argv[2]); 6643 error=Phone->SendDTMF(&s,argv[2]);
6644 Print_Error(error); 6644 Print_Error(error);
6645 6645
6646 GSM_Terminate(); 6646 GSM_Terminate();
6647} 6647}
6648 6648
6649static void GetDisplayStatus(int argc, char *argv[]) 6649static void GetDisplayStatus(int argc, char *argv[])
6650{ 6650{
6651 GSM_DisplayFeatures Features; 6651 GSM_DisplayFeatures Features;
6652 int i; 6652 int i;
6653 6653
6654 GSM_Init(true); 6654 GSM_Init(true);
6655 6655
6656 error=Phone->GetDisplayStatus(&s,&Features); 6656 error=Phone->GetDisplayStatus(&s,&Features);
6657 Print_Error(error); 6657 Print_Error(error);
6658 6658
6659 printmsg("Current display features :\n"); 6659 printmsg("Current display features :\n");
6660 6660
6661 for (i=0;i<Features.Number;i++) { 6661 for (i=0;i<Features.Number;i++) {
6662 switch(Features.Feature[i]) { 6662 switch(Features.Feature[i]) {
6663 case GSM_CallActive : printmsg("Call active\n");break; 6663 case GSM_CallActive : printmsg("Call active\n");break;
6664 case GSM_UnreadSMS : printmsg("Unread SMS\n");break; 6664 case GSM_UnreadSMS : printmsg("Unread SMS\n");break;
6665 case GSM_VoiceCall : printmsg("Voice call\n");break; 6665 case GSM_VoiceCall : printmsg("Voice call\n");break;
6666 case GSM_FaxCall : printmsg("Fax call\n");break; 6666 case GSM_FaxCall : printmsg("Fax call\n");break;
6667 case GSM_DataCall : printmsg("Data call\n");break; 6667 case GSM_DataCall : printmsg("Data call\n");break;
6668 case GSM_KeypadLocked : printmsg("Keypad locked\n");break; 6668 case GSM_KeypadLocked : printmsg("Keypad locked\n");break;
6669 case GSM_SMSMemoryFull: printmsg("SMS memory full\n"); 6669 case GSM_SMSMemoryFull: printmsg("SMS memory full\n");
6670 } 6670 }
6671 } 6671 }
6672 6672
6673 GSM_Terminate(); 6673 GSM_Terminate();
6674} 6674}
6675 6675
6676static void SetAutoNetworkLogin(int argc, char *argv[]) 6676static void SetAutoNetworkLogin(int argc, char *argv[])
6677{ 6677{
6678 GSM_Init(true); 6678 GSM_Init(true);
6679 6679
6680 error=Phone->SetAutoNetworkLogin(&s); 6680 error=Phone->SetAutoNetworkLogin(&s);
6681 Print_Error(error); 6681 Print_Error(error);
6682 6682
6683 GSM_Terminate(); 6683 GSM_Terminate();
6684} 6684}
6685 6685
6686#ifdef DEBUG 6686#ifdef DEBUG
6687static void MakeConvertTable(int argc, char *argv[]) 6687static void MakeConvertTable(int argc, char *argv[])
6688{ 6688{
6689 unsigned char InputBuffer[10000], Buffer[10000]; 6689 unsigned char InputBuffer[10000], Buffer[10000];
6690 FILE *file; 6690 FILE *file;
6691 int size,i,j=0; 6691 int size,i,j=0;
6692 6692
6693 file = fopen(argv[2], "rb"); 6693 file = fopen(argv[2], "rb");
6694 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 6694 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
6695 size=fread(InputBuffer, 1, 10000-1, file); 6695 size=fread(InputBuffer, 1, 10000-1, file);
6696 fclose(file); 6696 fclose(file);
6697 InputBuffer[size] = 0; 6697 InputBuffer[size] = 0;
6698 InputBuffer[size+1] = 0; 6698 InputBuffer[size+1] = 0;
6699 6699
6700 ReadUnicodeFile(Buffer,InputBuffer); 6700 ReadUnicodeFile(Buffer,InputBuffer);
6701 6701
6702 for(i=0;i<((int)UnicodeLength(Buffer));i++) { 6702 for(i=0;i<((int)UnicodeLength(Buffer));i++) {
6703 j++; 6703 j++;
6704 if (j==100) { 6704 if (j==100) {
6705 printf("\"\\\n\""); 6705 printf("\"\\\n\"");
6706 j=0; 6706 j=0;
6707 } 6707 }
6708 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); 6708 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]);
6709 } 6709 }
6710 printf("\\x00\\x00"); 6710 printf("\\x00\\x00");
6711} 6711}
6712#endif 6712#endif
6713 6713
6714static void ListNetworks(int argc, char *argv[]) 6714static void ListNetworks(int argc, char *argv[])
6715{ 6715{
6716 extern unsigned char *GSM_Networks[]; 6716 extern unsigned char *GSM_Networks[];
6717 extern unsigned char *GSM_Countries[]; 6717 extern unsigned char *GSM_Countries[];
6718 int i=0; 6718 int i=0;
6719 char country[4]=""; 6719 char country[4]="";
6720 6720
6721 if (argc>2) { 6721 if (argc>2) {
6722 while (GSM_Countries[i*2]!=NULL) { 6722 while (GSM_Countries[i*2]!=NULL) {
6723 if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) { 6723 if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) {
6724 strcpy(country,GSM_Countries[i*2]); 6724 strcpy(country,GSM_Countries[i*2]);
6725 printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]); 6725 printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]);
6726 break; 6726 break;
6727 } 6727 }
6728 i++; 6728 i++;
6729 } 6729 }
6730 if (!*country) { 6730 if (!*country) {
6731 printmsg("Unknown country name."); 6731 printmsg("Unknown country name.");
6732 exit(-1); 6732 exit(-1);
6733 } 6733 }
6734 } 6734 }
6735 printmsg("Network Name\n"); 6735 printmsg("Network Name\n");
6736 i=0; 6736 i=0;
6737 while (GSM_Networks[i*2]!=NULL) { 6737 while (GSM_Networks[i*2]!=NULL) {
6738 if (argc>2) { 6738 if (argc>2) {
6739 if (!strncmp(GSM_Networks[i*2],country,strlen(country))) { 6739 if (!strncmp(GSM_Networks[i*2],country,strlen(country))) {
6740 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); 6740 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6741 } 6741 }
6742 } else { 6742 } else {
6743 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); 6743 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6744 } 6744 }
6745 i++; 6745 i++;
6746 } 6746 }
6747} 6747}
6748 6748
6749static void Version(int argc, char *argv[]) 6749static void Version(int argc, char *argv[])
6750{ 6750{
6751 // unsigned char buff[10]; 6751 // unsigned char buff[10];
6752 // int len; 6752 // int len;
6753 6753
6754 printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__); 6754 printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__);
6755 if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler()); 6755 if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler());
6756 printmsg("]\n\n"); 6756 printmsg("]\n\n");
6757 6757
6758#ifdef DEBUG 6758#ifdef DEBUG
6759 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); 6759 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage));
6760 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); 6760 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC));
6761 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); 6761 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State));
6762 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); 6762 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader));
6763 printf("bool - %i\n",sizeof(bool)); 6763 printf("bool - %i\n",sizeof(bool));
6764 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); 6764 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime));
6765 printf("int - %i\n",sizeof(int)); 6765 printf("int - %i\n",sizeof(int));
6766 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); 6766 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo));
6767#endif 6767#endif
6768 6768
6769 //len=DecodeBASE64("AXw", buff, 3); 6769 //len=DecodeBASE64("AXw", buff, 3);
6770 //DumpMessage(stdout, buff, len); 6770 //DumpMessage(stdout, buff, len);
6771} 6771}
6772 6772
6773static void GetFMStation(int argc, char *argv[]) 6773static void GetFMStation(int argc, char *argv[])
6774{ 6774{
6775 GSM_FMStation Station; 6775 GSM_FMStation Station;
6776 int start,stop; 6776 int start,stop;
6777 6777
6778 GetStartStop(&start, &stop, 2, argc, argv); 6778 GetStartStop(&start, &stop, 2, argc, argv);
6779 6779
6780 GSM_Init(true); 6780 GSM_Init(true);
6781 6781
6782 for (i=start;i<=stop;i++) { 6782 for (i=start;i<=stop;i++) {
6783 Station.Location=i; 6783 Station.Location=i;
6784 error=Phone->GetFMStation(&s,&Station); 6784 error=Phone->GetFMStation(&s,&Station);
6785 switch (error) { 6785 switch (error) {
6786 case ERR_EMPTY: 6786 case ERR_EMPTY:
6787 printmsg("Entry number %i is empty\n",i); 6787 printmsg("Entry number %i is empty\n",i);
6788 break; 6788 break;
6789 case ERR_NONE: 6789 case ERR_NONE:
6790 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n", 6790 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n",
6791 i,DecodeUnicodeConsole(Station.StationName), 6791 i,DecodeUnicodeConsole(Station.StationName),
6792 Station.Frequency); 6792 Station.Frequency);
6793 break; 6793 break;
6794 default: 6794 default:
6795 Print_Error(error); 6795 Print_Error(error);
6796 } 6796 }
6797 } 6797 }
6798 GSM_Terminate(); 6798 GSM_Terminate();
6799} 6799}
6800 6800
6801static void GetFileSystemStatus(int argc, char *argv[]) 6801static void GetFileSystemStatus(int argc, char *argv[])
6802{ 6802{
6803 GSM_FileSystemStatusStatus; 6803 GSM_FileSystemStatusStatus;
6804 6804
6805 GSM_Init(true); 6805 GSM_Init(true);
6806 6806
6807 error = Phone->GetFileSystemStatus(&s,&Status); 6807 error = Phone->GetFileSystemStatus(&s,&Status);
6808 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6808 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6809 Print_Error(error); 6809 Print_Error(error);
6810 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6810 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6811 } 6811 }
6812 6812
6813 GSM_Terminate(); 6813 GSM_Terminate();
6814} 6814}
6815 6815
6816static void GetFileSystem(int argc, char *argv[]) 6816static void GetFileSystem(int argc, char *argv[])
6817{ 6817{
6818 bool Start = true; 6818 bool Start = true;
6819 GSM_File Files; 6819 GSM_File Files;
6820 int j; 6820 int j;
6821 GSM_FileSystemStatusStatus; 6821 GSM_FileSystemStatusStatus;
6822 char FolderName[256]; 6822 char FolderName[256];
6823 6823
6824 GSM_Init(true); 6824 GSM_Init(true);
6825 6825
6826 while (1) { 6826 while (1) {
6827 error = Phone->GetNextFileFolder(&s,&Files,Start); 6827 error = Phone->GetNextFileFolder(&s,&Files,Start);
6828 if (error == ERR_EMPTY) break; 6828 if (error == ERR_EMPTY) break;
6829 Print_Error(error); 6829 Print_Error(error);
6830 6830
6831 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) { 6831 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) {
6832 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) { 6832 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) {
6833 printf("%5s.",Files.ID_FullName); 6833 printf("%5s.",Files.ID_FullName);
6834 } 6834 }
6835 if (Files.Protected) { 6835 if (Files.Protected) {
6836 printf("P"); 6836 printf("P");
6837 } else { 6837 } else {
6838 printf(" "); 6838 printf(" ");
6839 } 6839 }
6840 if (Files.ReadOnly) { 6840 if (Files.ReadOnly) {
6841 printf("R"); 6841 printf("R");
6842 } else { 6842 } else {
6843 printf(" "); 6843 printf(" ");
6844 } 6844 }
6845 if (Files.Hidden) { 6845 if (Files.Hidden) {
6846 printf("H"); 6846 printf("H");
6847 } else { 6847 } else {
6848 printf(" "); 6848 printf(" ");
6849 } 6849 }
6850 if (Files.System) { 6850 if (Files.System) {
6851 printf("S"); 6851 printf("S");
6852 } else { 6852 } else {
6853 printf(" "); 6853 printf(" ");
6854 } 6854 }
6855 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) { 6855 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) {
6856 if (!Files.Folder) { 6856 if (!Files.Folder) {
6857 if (mystrncasecmp(argv[2],"-flatall",0)) { 6857 if (mystrncasecmp(argv[2],"-flatall",0)) {
6858 if (!Files.ModifiedEmpty) { 6858 if (!Files.ModifiedEmpty) {
6859 printf(" %30s",OSDateTime(Files.Modified,false)); 6859 printf(" %30s",OSDateTime(Files.Modified,false));
6860 } else printf(" %30c",0x20); 6860 } else printf(" %30c",0x20);
6861 printf(" %9i",Files.Used); 6861 printf(" %9i",Files.Used);
6862 printf(" "); 6862 printf(" ");
6863 } else printf("|-- "); 6863 } else printf("|-- ");
6864 } else printf("Folder "); 6864 } else printf("Folder ");
6865 } else { 6865 } else {
6866 if (Files.Level != 1) { 6866 if (Files.Level != 1) {
6867 for (j=0;j<Files.Level-2;j++) printf(" | "); 6867 for (j=0;j<Files.Level-2;j++) printf(" | ");
6868 printf(" |-- "); 6868 printf(" |-- ");
6869 } 6869 }
6870 if (Files.Folder) printf("Folder "); 6870 if (Files.Folder) printf("Folder ");
6871 } 6871 }
6872 printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); 6872 printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
6873 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { 6873 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
6874 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS] 6874 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS]
6875 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */ 6875 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */
6876 if (!Files.Folder) { 6876 if (!Files.Folder) {
6877 printf("%s;File;",Files.ID_FullName); 6877 printf("%s;File;",Files.ID_FullName);
6878 printf("\"%s\";",FolderName); 6878 printf("\"%s\";",FolderName);
6879 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6879 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6880 if (!Files.ModifiedEmpty) { 6880 if (!Files.ModifiedEmpty) {
6881 printf("\"%s\";",OSDateTime(Files.Modified,false)); 6881 printf("\"%s\";",OSDateTime(Files.Modified,false));
6882 } else printf("\"%c\";",0x20); 6882 } else printf("\"%c\";",0x20);
6883 printf("%i;",Files.Used); 6883 printf("%i;",Files.Used);
6884 } else { 6884 } else {
6885 printf("%s;Folder;",Files.ID_FullName); 6885 printf("%s;Folder;",Files.ID_FullName);
6886 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6886 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6887 strcpy(FolderName,DecodeUnicodeConsole(Files.Name)); 6887 strcpy(FolderName,DecodeUnicodeConsole(Files.Name));
6888 } 6888 }
6889 6889
6890 if (Files.Protected) printf("P"); 6890 if (Files.Protected) printf("P");
6891 if (Files.ReadOnly) printf("R"); 6891 if (Files.ReadOnly) printf("R");
6892 if (Files.Hidden) printf("H"); 6892 if (Files.Hidden) printf("H");
6893 if (Files.System) printf("S"); 6893 if (Files.System) printf("S");
6894 } 6894 }
6895 Start = false; 6895 Start = false;
6896 } 6896 }
6897 6897
6898 error = Phone->GetFileSystemStatus(&s,&Status); 6898 error = Phone->GetFileSystemStatus(&s,&Status);
6899 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6899 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6900 Print_Error(error); 6900 Print_Error(error);
6901 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6901 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6902 } 6902 }
6903 6903
6904 GSM_Terminate(); 6904 GSM_Terminate();
6905} 6905}
6906 6906
6907static void GetOneFile(GSM_File *File, bool newtime, int i) 6907static void GetOneFile(GSM_File *File, bool newtime, int i)
6908{ 6908{
6909 FILE *file; 6909 FILE *file;
6910 bool start; 6910 bool start;
6911 unsigned char buffer[5000]; 6911 unsigned char buffer[5000];
6912 struct utimbuf filedate; 6912 struct utimbuf filedate;
6913 6913
6914 if (File->Buffer != NULL) { 6914 if (File->Buffer != NULL) {
6915 free(File->Buffer); 6915 free(File->Buffer);
6916 File->Buffer = NULL; 6916 File->Buffer = NULL;
6917 } 6917 }
6918 File->Used = 0; 6918 File->Used = 0;
6919 start = true; 6919 start = true;
6920 6920
6921 error = ERR_NONE; 6921 error = ERR_NONE;
6922 while (error == ERR_NONE) { 6922 while (error == ERR_NONE) {
6923 error = Phone->GetFilePart(&s,File); 6923 error = Phone->GetFilePart(&s,File);
6924 if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) { 6924 if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) {
6925 if (start) { 6925 if (start) {
6926 printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name)); 6926 printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name));
6927 start = false; 6927 start = false;
6928 } 6928 }
6929 if (File->Folder) { 6929 if (File->Folder) {
6930 free(File->Buffer); 6930 free(File->Buffer);
6931 GSM_Terminate(); 6931 GSM_Terminate();
6932 printmsg("it's folder. Please give only file names\n"); 6932 printmsg("it's folder. Please give only file names\n");
6933 exit(-1); 6933 exit(-1);
6934 } 6934 }
6935 printmsg("*"); 6935 printmsg("*");
6936 if (error == ERR_EMPTY) break; 6936 if (error == ERR_EMPTY) break;
6937 if (error == ERR_WRONGCRC) { 6937 if (error == ERR_WRONGCRC) {
6938 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 6938 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6939 break; 6939 break;
6940 } 6940 }
6941 } 6941 }
6942 Print_Error(error); 6942 Print_Error(error);
6943 } 6943 }
6944 printf("\n"); 6944 printf("\n");
6945 if (File->Used != 0) { 6945 if (File->Used != 0) {
6946 sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name)); 6946 sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name));
6947 file = fopen(buffer,"wb"); 6947 file = fopen(buffer,"wb");
6948 if (file == NULL) { 6948 if (file == NULL) {
6949 sprintf(buffer,"file%s",File->ID_FullName); 6949 sprintf(buffer,"file%s",File->ID_FullName);
6950 file = fopen(buffer,"wb"); 6950 file = fopen(buffer,"wb");
6951 } 6951 }
6952 if (file == NULL) { 6952 if (file == NULL) {
6953 sprintf(buffer,"file%i",i); 6953 sprintf(buffer,"file%i",i);
6954 file = fopen(buffer,"wb"); 6954 file = fopen(buffer,"wb");
6955 } 6955 }
6956 printmsg(" Saving to %s\n",buffer); 6956 printmsg(" Saving to %s\n",buffer);
6957 if (!file) Print_Error(ERR_CANTOPENFILE); 6957 if (!file) Print_Error(ERR_CANTOPENFILE);
6958 fwrite(File->Buffer,1,File->Used,file); 6958 fwrite(File->Buffer,1,File->Used,file);
6959 fclose(file); 6959 fclose(file);
6960 if (!newtime && !File->ModifiedEmpty) { 6960 if (!newtime && !File->ModifiedEmpty) {
6961 /* access time */ 6961 /* access time */
6962 filedate.actime = Fill_Time_T(File->Modified, 8); 6962 filedate.actime = Fill_Time_T(File->Modified, 8);
6963 /* modification time */ 6963 /* modification time */
6964 filedate.modtime = Fill_Time_T(File->Modified, 8); 6964 filedate.modtime = Fill_Time_T(File->Modified, 8);
6965 dbgprintf("Setting date of %s\n",buffer); 6965 dbgprintf("Setting date of %s\n",buffer);
6966 utime(buffer,&filedate); 6966 utime(buffer,&filedate);
6967 } 6967 }
6968 } 6968 }
6969} 6969}
6970 6970
6971static void GetFiles(int argc, char *argv[]) 6971static void GetFiles(int argc, char *argv[])
6972{ 6972{
6973 GSM_File File; 6973 GSM_File File;
6974 int i; 6974 int i;
6975 bool newtime = false; 6975 bool newtime = false;
6976 6976
6977 File.Buffer = NULL; 6977 File.Buffer = NULL;
6978 6978
6979 GSM_Init(true); 6979 GSM_Init(true);
6980 6980
6981 for (i=2;i<argc;i++) { 6981 for (i=2;i<argc;i++) {
6982 if (mystrncasecmp(argv[i],"-newtime",0)) { 6982 if (mystrncasecmp(argv[i],"-newtime",0)) {
6983 newtime = true; 6983 newtime = true;
6984 continue; 6984 continue;
6985 } 6985 }
6986 6986
6987 strcpy(File.ID_FullName,argv[i]); 6987 strcpy(File.ID_FullName,argv[i]);
6988 GetOneFile(&File, newtime, i); 6988 GetOneFile(&File, newtime, i);
6989 } 6989 }
6990 6990
6991 free(File.Buffer); 6991 free(File.Buffer);
6992 GSM_Terminate(); 6992 GSM_Terminate();
6993} 6993}
6994 6994
6995static void GetFileFolder(int argc, char *argv[]) 6995static void GetFileFolder(int argc, char *argv[])
6996{ 6996{
6997 bool Start = true; 6997 bool Start = true;
6998 GSM_File File; 6998 GSM_File File;
6999 int level=0,allnum=0,num=0,filelevel=0; 6999 int level=0,allnum=0,num=0,filelevel=0;
7000 bool newtime = false, found; 7000 bool newtime = false, found;
7001 7001
7002 File.Buffer = NULL; 7002 File.Buffer = NULL;
7003 7003
7004 GSM_Init(true); 7004 GSM_Init(true);
7005 7005
7006 for (i=2;i<argc;i++) { 7006 for (i=2;i<argc;i++) {
7007 if (mystrncasecmp(argv[i],"-newtime",0)) { 7007 if (mystrncasecmp(argv[i],"-newtime",0)) {
7008 newtime = true; 7008 newtime = true;
7009 continue; 7009 continue;
7010 } 7010 }
7011 allnum++; 7011 allnum++;
7012 } 7012 }
7013 7013
7014 while (allnum != num) { 7014 while (allnum != num) {
7015 error = Phone->GetNextFileFolder(&s,&File,Start); 7015 error = Phone->GetNextFileFolder(&s,&File,Start);
7016 if (error == ERR_EMPTY) break; 7016 if (error == ERR_EMPTY) break;
7017 Print_Error(error); 7017 Print_Error(error);
7018 7018
7019 if (level == 0) { 7019 if (level == 0) {
7020 /* We search for file or folder */ 7020 /* We search for file or folder */
7021 found = false; 7021 found = false;
7022 for (i=2;i<argc;i++) { 7022 for (i=2;i<argc;i++) {
7023 if (mystrncasecmp(argv[i],"-newtime",0)) { 7023 if (mystrncasecmp(argv[i],"-newtime",0)) {
7024 continue; 7024 continue;
7025 } 7025 }
7026 if (!strcmp(File.ID_FullName,argv[i])) { 7026 if (!strcmp(File.ID_FullName,argv[i])) {
7027 found = true; 7027 found = true;
7028 if (File.Folder) { 7028 if (File.Folder) {
7029 level = 1; 7029 level = 1;
7030 filelevel = File.Level + 1; 7030 filelevel = File.Level + 1;
7031 Start = false; 7031 Start = false;
7032 } else { 7032 } else {
7033 level = 2; 7033 level = 2;
7034 } 7034 }
7035 break; 7035 break;
7036 } 7036 }
7037 } 7037 }
7038 if (found && File.Folder) continue; 7038 if (found && File.Folder) continue;
7039 } 7039 }
7040 if (level == 1) { 7040 if (level == 1) {
7041 /* We have folder */ 7041 /* We have folder */
7042 dbgprintf("%i %i\n",File.Level,filelevel); 7042 dbgprintf("%i %i\n",File.Level,filelevel);
7043 if (File.Level != filelevel) { 7043 if (File.Level != filelevel) {
7044 level = 0; 7044 level = 0;
7045 num++; 7045 num++;
7046 } 7046 }
7047 } 7047 }
7048 7048
7049 if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num); 7049 if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num);
7050 7050
7051 if (level == 2) { 7051 if (level == 2) {
7052 level = 0; 7052 level = 0;
7053 num++; 7053 num++;
7054 } 7054 }
7055 7055
7056 Start = false; 7056 Start = false;
7057 } 7057 }
7058 7058
7059 free(File.Buffer); 7059 free(File.Buffer);
7060 GSM_Terminate(); 7060 GSM_Terminate();
7061} 7061}
7062 7062
7063static void AddFile(int argc, char *argv[]) 7063static void AddFile(int argc, char *argv[])
7064{ 7064{
7065 GSM_File File; 7065 GSM_File File;
7066 int Pos = 0,i,nextlong; 7066 int Pos = 0,i,nextlong;
7067 7067
7068 File.Buffer = NULL; 7068 File.Buffer = NULL;
7069 strcpy(File.ID_FullName,argv[2]); 7069 strcpy(File.ID_FullName,argv[2]);
7070 error = GSM_ReadFile(argv[3], &File); 7070 error = GSM_ReadFile(argv[3], &File);
7071 Print_Error(error); 7071 Print_Error(error);
7072 EncodeUnicode(File.Name,argv[3],strlen(argv[3])); 7072 EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
7073 GSM_IdentifyFileFormat(&File); 7073 GSM_IdentifyFileFormat(&File);
7074 7074
7075 File.Protected = false; 7075 File.Protected = false;
7076 File.ReadOnly= false; 7076 File.ReadOnly= false;
7077 File.Hidden= false; 7077 File.Hidden= false;
7078 File.System= false; 7078 File.System= false;
7079 7079
7080 if (argc > 4) { 7080 if (argc > 4) {
7081 nextlong = 0; 7081 nextlong = 0;
7082 for (i=4;i<argc;i++) { 7082 for (i=4;i<argc;i++) {
7083 switch(nextlong) { 7083 switch(nextlong) {
7084 case 0: 7084 case 0:
7085 if (mystrncasecmp(argv[i],"-type",0)) { 7085 if (mystrncasecmp(argv[i],"-type",0)) {
7086 nextlong = 1; 7086 nextlong = 1;
7087 continue; 7087 continue;
7088 } 7088 }
7089 if (mystrncasecmp(argv[i],"-protected",0)) { 7089 if (mystrncasecmp(argv[i],"-protected",0)) {
7090 File.Protected = true; 7090 File.Protected = true;
7091 continue; 7091 continue;
7092 } 7092 }
7093 if (mystrncasecmp(argv[i],"-readonly",0)) { 7093 if (mystrncasecmp(argv[i],"-readonly",0)) {
7094 File.ReadOnly = true; 7094 File.ReadOnly = true;
7095 continue; 7095 continue;
7096 } 7096 }
7097 if (mystrncasecmp(argv[i],"-hidden",0)) { 7097 if (mystrncasecmp(argv[i],"-hidden",0)) {
7098 File.Hidden = true; 7098 File.Hidden = true;
7099 continue; 7099 continue;
7100 } 7100 }
7101 if (mystrncasecmp(argv[i],"-system",0)) { 7101 if (mystrncasecmp(argv[i],"-system",0)) {
7102 File.System = true; 7102 File.System = true;
7103 continue; 7103 continue;
7104 } 7104 }
7105 if (mystrncasecmp(argv[i],"-newtime",0)) { 7105 if (mystrncasecmp(argv[i],"-newtime",0)) {
7106 File.ModifiedEmpty = true; 7106 File.ModifiedEmpty = true;
7107 continue; 7107 continue;
7108 } 7108 }
7109 printmsg("Parameter \"%s\" unknown\n",argv[i]); 7109 printmsg("Parameter \"%s\" unknown\n",argv[i]);
7110 exit(-1); 7110 exit(-1);
7111 case 1: 7111 case 1:
7112 if (mystrncasecmp(argv[i],"JAR",0)) { 7112 if (mystrncasecmp(argv[i],"JAR",0)) {
7113 File.Type = GSM_File_Java_JAR; 7113 File.Type = GSM_File_Java_JAR;
7114 } else if (mystrncasecmp(argv[i],"JPG",0)) { 7114 } else if (mystrncasecmp(argv[i],"JPG",0)) {
7115 File.Type = GSM_File_Image_JPG; 7115 File.Type = GSM_File_Image_JPG;
7116 } else if (mystrncasecmp(argv[i],"BMP",0)) { 7116 } else if (mystrncasecmp(argv[i],"BMP",0)) {
7117 File.Type = GSM_File_Image_BMP; 7117 File.Type = GSM_File_Image_BMP;
7118 } else if (mystrncasecmp(argv[i],"WBMP",0)) { 7118 } else if (mystrncasecmp(argv[i],"WBMP",0)) {
7119 File.Type = GSM_File_Image_WBMP; 7119 File.Type = GSM_File_Image_WBMP;
7120 } else if (mystrncasecmp(argv[i],"GIF",0)) { 7120 } else if (mystrncasecmp(argv[i],"GIF",0)) {
7121 File.Type = GSM_File_Image_GIF; 7121 File.Type = GSM_File_Image_GIF;
7122 } else if (mystrncasecmp(argv[i],"PNG",0)) { 7122 } else if (mystrncasecmp(argv[i],"PNG",0)) {
7123 File.Type = GSM_File_Image_PNG; 7123 File.Type = GSM_File_Image_PNG;
7124 } else if (mystrncasecmp(argv[i],"MIDI",0)) { 7124 } else if (mystrncasecmp(argv[i],"MIDI",0)) {
7125 File.Type = GSM_File_Sound_MIDI; 7125 File.Type = GSM_File_Sound_MIDI;
7126 } else if (mystrncasecmp(argv[i],"AMR",0)) { 7126 } else if (mystrncasecmp(argv[i],"AMR",0)) {
7127 File.Type = GSM_File_Sound_AMR; 7127 File.Type = GSM_File_Sound_AMR;
7128 } else if (mystrncasecmp(argv[i],"NRT",0)) { 7128 } else if (mystrncasecmp(argv[i],"NRT",0)) {
7129 File.Type = GSM_File_Sound_NRT; 7129 File.Type = GSM_File_Sound_NRT;
7130 } else if (mystrncasecmp(argv[i],"3GP",0)) { 7130 } else if (mystrncasecmp(argv[i],"3GP",0)) {
7131 File.Type = GSM_File_Video_3GP; 7131 File.Type = GSM_File_Video_3GP;
7132 } else { 7132 } else {
7133 printmsg("What file type (\"%s\") ?\n",argv[i]); 7133 printmsg("What file type (\"%s\") ?\n",argv[i]);
7134 exit(-1); 7134 exit(-1);
7135 } 7135 }
7136 nextlong = 0; 7136 nextlong = 0;
7137 break; 7137 break;
7138 } 7138 }
7139 } 7139 }
7140 if (nextlong!=0) { 7140 if (nextlong!=0) {
7141 printmsg("Parameter missed...\n"); 7141 printmsg("Parameter missed...\n");
7142 exit(-1); 7142 exit(-1);
7143 } 7143 }
7144 } 7144 }
7145 7145
7146 GSM_Init(true); 7146 GSM_Init(true);
7147 7147
7148 error = ERR_NONE; 7148 error = ERR_NONE;
7149 while (error == ERR_NONE) { 7149 while (error == ERR_NONE) {
7150 error = Phone->AddFilePart(&s,&File,&Pos); 7150 error = Phone->AddFilePart(&s,&File,&Pos);
7151 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7151 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7152 printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used); 7152 printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used);
7153 } 7153 }
7154 printmsgerr("\n"); 7154 printmsgerr("\n");
7155 if (error == ERR_WRONGCRC) { 7155 if (error == ERR_WRONGCRC) {
7156 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7156 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7157 } 7157 }
7158 7158
7159 free(File.Buffer); 7159 free(File.Buffer);
7160 GSM_Terminate(); 7160 GSM_Terminate();
7161} 7161}
7162 7162
7163static void AddFolder(int argc, char *argv[]) 7163static void AddFolder(int argc, char *argv[])
7164{ 7164{
7165 GSM_File File; 7165 GSM_File File;
7166 7166
7167 strcpy(File.ID_FullName,argv[2]); 7167 strcpy(File.ID_FullName,argv[2]);
7168 EncodeUnicode(File.Name,argv[3],strlen(argv[3])); 7168 EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
7169 File.ReadOnly = false; 7169 File.ReadOnly = false;
7170 7170
7171 GSM_Init(true); 7171 GSM_Init(true);
7172 7172
7173 error = Phone->AddFolder(&s,&File); 7173 error = Phone->AddFolder(&s,&File);
7174 Print_Error(error); 7174 Print_Error(error);
7175 7175
7176 GSM_Terminate(); 7176 GSM_Terminate();
7177} 7177}
7178 7178
7179struct NokiaFolderInfo { 7179struct NokiaFolderInfo {
7180 char*model; 7180 char*model;
7181 char *parameter; 7181 char *parameter;
7182 char*folder; 7182 char*folder;
7183 char *level; 7183 char *level;
7184}; 7184};
7185 7185
7186static struct NokiaFolderInfo Folder[] = { 7186static struct NokiaFolderInfo Folder[] = {
7187 /* Language indepedent in DCT4 */ 7187 /* Language indepedent in DCT4 */
7188 {"", "MMSUnreadInbox", "INBOX","3"}, 7188 {"", "MMSUnreadInbox", "INBOX","3"},
7189 {"", "MMSReadInbox", "INBOX","3"}, 7189 {"", "MMSReadInbox", "INBOX","3"},
7190 {"", "MMSOutbox", "OUTBOX","3"}, 7190 {"", "MMSOutbox", "OUTBOX","3"},
7191 {"", "MMSSent", "SENT", "3"}, 7191 {"", "MMSSent", "SENT", "3"},
7192 {"", "MMSDrafts", "DRAFTS","3"}, 7192 {"", "MMSDrafts", "DRAFTS","3"},
7193 {"", "Application", "applications","3"}, 7193 {"", "Application", "applications","3"},
7194 {"", "Game", "games","3"}, 7194 {"", "Game", "games","3"},
7195 /* Language depedent in DCT4 */ 7195 /* Language depedent in DCT4 */
7196 {"", "Gallery", "Pictures","2"}, /* 3510 */ 7196 {"", "Gallery", "Pictures","2"}, /* 3510 */
7197 {"", "Gallery", "Graphics","3"}, /* 3510i */ 7197 {"", "Gallery", "Graphics","3"}, /* 3510i */
7198 {"", "Gallery", "Images","3"}, /* 6610 */ 7198 {"", "Gallery", "Images","3"}, /* 6610 */
7199 {"3510", "Gallery", "", "8"}, 7199 {"3510", "Gallery", "", "8"},
7200 {"3510i","Gallery", "", "3"}, 7200 {"3510i","Gallery", "", "3"},
7201 {"5100", "Gallery", "", "3"}, 7201 {"5100", "Gallery", "", "3"},
7202 {"6220", "Gallery", "", "5"}, 7202 {"6220", "Gallery", "", "5"},
7203 {"6610", "Gallery", "", "2"}, 7203 {"6610", "Gallery", "", "2"},
7204 {"7210", "Gallery", "", "2"}, 7204 {"7210", "Gallery", "", "2"},
7205 {"", "Tones", "Tones","3"}, 7205 {"", "Tones", "Tones","3"},
7206 {"3510i","Tones", "", "4"}, 7206 {"3510i","Tones", "", "4"},
7207 {"5100", "Tones", "", "4"}, 7207 {"5100", "Tones", "", "4"},
7208 {"6220", "Tones", "", "6"}, 7208 {"6220", "Tones", "", "6"},
7209 {"6610", "Tones", "", "4"}, 7209 {"6610", "Tones", "", "4"},
7210 {"7210", "Tones", "", "4"}, 7210 {"7210", "Tones", "", "4"},
7211 /* Language indepedent in OBEX */ 7211 /* Language indepedent in OBEX */
7212 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"}, 7212 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"},
7213 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"}, 7213 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"},
7214 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"}, 7214 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"},
7215 {"obex", "MMSSent", "", "predefMessages\\predefSENT" }, 7215 {"obex", "MMSSent", "", "predefMessages\\predefSENT" },
7216 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"}, 7216 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"},
7217 // {"obex", "Application, "", "predefjava\\predefapplications"}, 7217 // {"obex", "Application, "", "predefjava\\predefapplications"},
7218 // {"obex", "Game", "", "predefjava\\predefgames"}, 7218 // {"obex", "Game", "", "predefjava\\predefgames"},
7219 {"obex", "Gallery", "", "predefgallery\\predefgraphics"}, 7219 {"obex", "Gallery", "", "predefgallery\\predefgraphics"},
7220 {"obex", "Tones", "", "predefgallery\\predeftones"}, 7220 {"obex", "Tones", "", "predefgallery\\predeftones"},
7221 7221
7222 /* End of list */ 7222 /* End of list */
7223 {"", "", "", ""} 7223 {"", "", "", ""}
7224}; 7224};
7225 7225
7226static void NokiaAddFile(int argc, char *argv[]) 7226static void NokiaAddFile(int argc, char *argv[])
7227{ 7227{
7228 GSM_File File, Files; 7228 GSM_File File, Files;
7229 FILE *file; 7229 FILE *file;
7230 GSM_DateTime DT,DT2; 7230 GSM_DateTime DT,DT2;
7231 time_t t_time1,t_time2; 7231 time_t t_time1,t_time2;
7232 unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400]; 7232 unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400];
7233 bool Start = true, Found = false, wasclr; 7233 bool Start = true, Found = false, wasclr;
7234 bool ModEmpty = false; 7234 bool ModEmpty = false;
7235 int i = 0, Pos, Size, Size2, nextlong; 7235 int i = 0, Pos, Size, Size2, nextlong;
7236 7236
7237 while (Folder[i].level[0] != 0) { 7237 while (Folder[i].level[0] != 0) {
7238 if (mystrncasecmp(argv[2],Folder[i].parameter,0)) { 7238 if (mystrncasecmp(argv[2],Folder[i].parameter,0)) {
7239 Found = true; 7239 Found = true;
7240 break; 7240 break;
7241 } 7241 }
7242 i++; 7242 i++;
7243 } 7243 }
7244 if (!Found) { 7244 if (!Found) {
7245 printmsg("What folder type (\"%s\") ?\n",argv[2]); 7245 printmsg("What folder type (\"%s\") ?\n",argv[2]);
7246 exit(-1); 7246 exit(-1);
7247 } 7247 }
7248 7248
7249 GSM_Init(true); 7249 GSM_Init(true);
7250 7250
7251 if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) { 7251 if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) {
7252 Found = false; 7252 Found = false;
7253 i = 0; 7253 i = 0;
7254 while (Folder[i].level[0] != 0) { 7254 while (Folder[i].level[0] != 0) {
7255 if (!strcmp("obex",Folder[i].model) && 7255 if (!strcmp("obex",Folder[i].model) &&
7256 mystrncasecmp(argv[2],Folder[i].parameter,0)) { 7256 mystrncasecmp(argv[2],Folder[i].parameter,0)) {
7257 strcpy(Files.ID_FullName,Folder[i].level); 7257 strcpy(Files.ID_FullName,Folder[i].level);
7258 Found = true; 7258 Found = true;
7259 break; 7259 break;
7260 } 7260 }
7261 i++; 7261 i++;
7262 } 7262 }
7263 } else { 7263 } else {
7264 printmsgerr("Searching for phone folder: "); 7264 printmsgerr("Searching for phone folder: ");
7265 while (1) { 7265 while (1) {
7266 error = Phone->GetNextFileFolder(&s,&Files,Start); 7266 error = Phone->GetNextFileFolder(&s,&Files,Start);
7267 if (error == ERR_EMPTY) break; 7267 if (error == ERR_EMPTY) break;
7268 Print_Error(error); 7268 Print_Error(error);
7269 7269
7270 if (Files.Folder) { 7270 if (Files.Folder) {
7271 dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level); 7271 dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level);
7272 Found = false; 7272 Found = false;
7273 i = 0; 7273 i = 0;
7274 while (Folder[i].level[0] != 0) { 7274 while (Folder[i].level[0] != 0) {
7275 EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder)); 7275 EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder));
7276 dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level); 7276 dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level);
7277 if (mystrncasecmp(argv[2],Folder[i].parameter,0) && 7277 if (mystrncasecmp(argv[2],Folder[i].parameter,0) &&
7278 mywstrncasecmp(Files.Name,buffer,0) && 7278 mywstrncasecmp(Files.Name,buffer,0) &&
7279 Files.Level == atoi(Folder[i].level)) { 7279 Files.Level == atoi(Folder[i].level)) {
7280 Found = true; 7280 Found = true;
7281 break; 7281 break;
7282 } 7282 }
7283 if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) && 7283 if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) &&
7284 mystrncasecmp(argv[2],Folder[i].parameter,0) && 7284 mystrncasecmp(argv[2],Folder[i].parameter,0) &&
7285 !strcmp(Files.ID_FullName,Folder[i].level)) { 7285 !strcmp(Files.ID_FullName,Folder[i].level)) {
7286 Found = true; 7286 Found = true;
7287 break; 7287 break;
7288 } 7288 }
7289 i++; 7289 i++;
7290 } 7290 }
7291 if (Found) break; 7291 if (Found) break;
7292 } 7292 }
7293 printmsgerr("*"); 7293 printmsgerr("*");
7294 7294
7295 Start = false; 7295 Start = false;
7296 } 7296 }
7297 printmsgerr("\n"); 7297 printmsgerr("\n");
7298 } 7298 }
7299 if (!Found) { 7299 if (!Found) {
7300 printmsg("Folder not found. Probably function not supported !\n"); 7300 printmsg("Folder not found. Probably function not supported !\n");
7301 GSM_Terminate(); 7301 GSM_Terminate();
7302 exit(-1); 7302 exit(-1);
7303 } 7303 }
7304 File.Buffer = NULL; 7304 File.Buffer = NULL;
7305 File.Protected = false; 7305 File.Protected = false;
7306 File.ReadOnly = false; 7306 File.ReadOnly = false;
7307 File.Hidden= false; 7307 File.Hidden= false;
7308 File.System= false; 7308 File.System= false;
7309 7309
7310 if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) { 7310 if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) {
7311 sprintf(buffer,"%s.jad",argv[3]); 7311 sprintf(buffer,"%s.jad",argv[3]);
7312 file = fopen(buffer,"rb"); 7312 file = fopen(buffer,"rb");
7313 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7313 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7314 fclose(file); 7314 fclose(file);
7315 sprintf(buffer,"%s.jar",argv[3]); 7315 sprintf(buffer,"%s.jar",argv[3]);
7316 file = fopen(buffer,"rb"); 7316 file = fopen(buffer,"rb");
7317 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7317 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7318 fclose(file); 7318 fclose(file);
7319 7319
7320 /* reading jar file */ 7320 /* reading jar file */
7321 sprintf(buffer,"%s.jar",argv[3]); 7321 sprintf(buffer,"%s.jar",argv[3]);
7322 error = GSM_ReadFile(buffer, &File); 7322 error = GSM_ReadFile(buffer, &File);
7323 Print_Error(error); 7323 Print_Error(error);
7324 Size2 = File.Used; 7324 Size2 = File.Used;
7325 7325
7326 /* reading jad file */ 7326 /* reading jad file */
7327 sprintf(buffer,"%s.jad",argv[3]); 7327 sprintf(buffer,"%s.jad",argv[3]);
7328 error = GSM_ReadFile(buffer, &File); 7328 error = GSM_ReadFile(buffer, &File);
7329 Print_Error(error); 7329 Print_Error(error);
7330 7330
7331 /* Getting values from JAD file */ 7331 /* Getting values from JAD file */
7332 error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size); 7332 error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size);
7333 if (error == ERR_FILENOTSUPPORTED) { 7333 if (error == ERR_FILENOTSUPPORTED) {
7334 if (Vendor[0] == 0x00) { 7334 if (Vendor[0] == 0x00) {
7335 printmsgerr("No vendor info in JAD file\n"); 7335 printmsgerr("No vendor info in JAD file\n");
7336 GSM_Terminate(); 7336 GSM_Terminate();
7337 return; 7337 return;
7338 } 7338 }
7339 if (Name[0] == 0x00) { 7339 if (Name[0] == 0x00) {
7340 printmsgerr("No name info in JAD file\n"); 7340 printmsgerr("No name info in JAD file\n");
7341 GSM_Terminate(); 7341 GSM_Terminate();
7342 return; 7342 return;
7343 } 7343 }
7344 if (JAR[0] == 0x00) { 7344 if (JAR[0] == 0x00) {
7345 printmsgerr("No JAR URL info in JAD file\n"); 7345 printmsgerr("No JAR URL info in JAD file\n");
7346 GSM_Terminate(); 7346 GSM_Terminate();
7347 return; 7347 return;
7348 } 7348 }
7349 if (Size == -1) { 7349 if (Size == -1) {
7350 printmsgerr("No JAR size info in JAD file\n"); 7350 printmsgerr("No JAR size info in JAD file\n");
7351 GSM_Terminate(); 7351 GSM_Terminate();
7352 return; 7352 return;
7353 } 7353 }
7354 } 7354 }
7355 if (Size != Size2) { 7355 if (Size != Size2) {
7356 printmsgerr("Declared JAR file size is different than real\n"); 7356 printmsgerr("Declared JAR file size is different than real\n");
7357 GSM_Terminate(); 7357 GSM_Terminate();
7358 return; 7358 return;
7359 } 7359 }
7360 printmsgerr("Adding \"%s\"",Name); 7360 printmsgerr("Adding \"%s\"",Name);
7361 if (Version[0] != 0x00) printmsgerr(" version %s",Version); 7361 if (Version[0] != 0x00) printmsgerr(" version %s",Version);
7362 printmsgerr(" created by %s\n",Vendor); 7362 printmsgerr(" created by %s\n",Vendor);
7363 7363
7364 /* Bostjan Muller 3200 RH-30 3.08 */ 7364 /* Bostjan Muller 3200 RH-30 3.08 */
7365 if (strstr(JAR,"http://") != NULL) { 7365 if (strstr(JAR,"http://") != NULL) {
7366 i = strlen(JAR)-1; 7366 i = strlen(JAR)-1;
7367 while (JAR[i] != '/') i--; 7367 while (JAR[i] != '/') i--;
7368 strcpy(buffer,JAR+i+1); 7368 strcpy(buffer,JAR+i+1);
7369 strcpy(JAR,buffer); 7369 strcpy(JAR,buffer);
7370 dbgprintf("New file name is \"%s\"\n",JAR); 7370 dbgprintf("New file name is \"%s\"\n",JAR);
7371 } 7371 }
7372 7372
7373 /* Changing all #13 or #10 to #13#10 in JAD */ 7373 /* Changing all #13 or #10 to #13#10 in JAD */
7374 Pos = 0; 7374 Pos = 0;
7375 wasclr = false; 7375 wasclr = false;
7376 for (i=0;i<File.Used;i++) { 7376 for (i=0;i<File.Used;i++) {
7377 switch (File.Buffer[i]) { 7377 switch (File.Buffer[i]) {
7378 case 0x0D: 7378 case 0x0D:
7379 case 0x0A: 7379 case 0x0A:
7380 if (!wasclr) { 7380 if (!wasclr) {
7381 buffer[Pos++] = 0x0D; 7381 buffer[Pos++] = 0x0D;
7382 buffer[Pos++] = 0x0A; 7382 buffer[Pos++] = 0x0A;
7383 wasclr = true; 7383 wasclr = true;
7384 } else wasclr = false; 7384 } else wasclr = false;
7385 break; 7385 break;
7386 default: 7386 default:
7387 buffer[Pos++] = File.Buffer[i]; 7387 buffer[Pos++] = File.Buffer[i];
7388 wasclr = false; 7388 wasclr = false;
7389 } 7389 }
7390 } 7390 }
7391 File.Buffer = realloc(File.Buffer, Pos); 7391 File.Buffer = realloc(File.Buffer, Pos);
7392 File.Used = Pos; 7392 File.Used = Pos;
7393 memcpy(File.Buffer,buffer,Pos); 7393 memcpy(File.Buffer,buffer,Pos);
7394 7394
7395 /* adding folder */ 7395 /* adding folder */
7396 strcpy(buffer,Vendor); 7396 strcpy(buffer,Vendor);
7397 strcat(buffer,Name); 7397 strcat(buffer,Name);
7398 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7398 EncodeUnicode(File.Name,buffer,strlen(buffer));
7399 strcpy(File.ID_FullName,Files.ID_FullName); 7399 strcpy(File.ID_FullName,Files.ID_FullName);
7400 error = Phone->AddFolder(&s,&File); 7400 error = Phone->AddFolder(&s,&File);
7401 Print_Error(error); 7401 Print_Error(error);
7402 strcpy(FileID,File.ID_FullName); 7402 strcpy(FileID,File.ID_FullName);
7403 7403
7404 /* adding jad file */ 7404 /* adding jad file */
7405 strcpy(buffer,JAR); 7405 strcpy(buffer,JAR);
7406 buffer[strlen(buffer) - 1] = 'd'; 7406 buffer[strlen(buffer) - 1] = 'd';
7407 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7407 EncodeUnicode(File.Name,buffer,strlen(buffer));
7408 File.Type = GSM_File_Other; 7408 File.Type = GSM_File_Other;
7409 File.ModifiedEmpty = true; 7409 File.ModifiedEmpty = true;
7410 error = ERR_NONE; 7410 error = ERR_NONE;
7411 Pos = 0; 7411 Pos = 0;
7412 while (error == ERR_NONE) { 7412 while (error == ERR_NONE) {
7413 error = Phone->AddFilePart(&s,&File,&Pos); 7413 error = Phone->AddFilePart(&s,&File,&Pos);
7414 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7414 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7415 printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used); 7415 printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used);
7416 } 7416 }
7417 printmsgerr("\n"); 7417 printmsgerr("\n");
7418 if (error == ERR_WRONGCRC) { 7418 if (error == ERR_WRONGCRC) {
7419 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7419 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7420 } 7420 }
7421 7421
7422 if (argc > 4) { 7422 if (argc > 4) {
7423 if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true; 7423 if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true;
7424 } 7424 }
7425 7425
7426 /* reading jar file */ 7426 /* reading jar file */
7427 sprintf(buffer,"%s.jar",argv[3]); 7427 sprintf(buffer,"%s.jar",argv[3]);
7428 error = GSM_ReadFile(buffer, &File); 7428 error = GSM_ReadFile(buffer, &File);
7429 Print_Error(error); 7429 Print_Error(error);
7430 7430
7431 /* adding jar file */ 7431 /* adding jar file */
7432 strcpy(File.ID_FullName,FileID); 7432 strcpy(File.ID_FullName,FileID);
7433 strcpy(buffer,JAR); 7433 strcpy(buffer,JAR);
7434 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7434 EncodeUnicode(File.Name,buffer,strlen(buffer));
7435 File.Type = GSM_File_Java_JAR; 7435 File.Type = GSM_File_Java_JAR;
7436 File.ModifiedEmpty = true; 7436 File.ModifiedEmpty = true;
7437 error = ERR_NONE; 7437 error = ERR_NONE;
7438 Pos = 0; 7438 Pos = 0;
7439 while (error == ERR_NONE) { 7439 while (error == ERR_NONE) {
7440 error = Phone->AddFilePart(&s,&File,&Pos); 7440 error = Phone->AddFilePart(&s,&File,&Pos);
7441 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7441 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7442 printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used); 7442 printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used);
7443 } 7443 }
7444 printmsgerr("\n"); 7444 printmsgerr("\n");
7445 if (error == ERR_WRONGCRC) { 7445 if (error == ERR_WRONGCRC) {
7446 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7446 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7447 } 7447 }
7448 7448
7449 free(File.Buffer); 7449 free(File.Buffer);
7450 GSM_Terminate(); 7450 GSM_Terminate();
7451 return; 7451 return;
7452 } 7452 }
7453 7453
7454 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { 7454 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
7455 strcpy(buffer,argv[3]); 7455 strcpy(buffer,argv[3]);
7456 if (argc > 4) { 7456 if (argc > 4) {
7457 nextlong = 0; 7457 nextlong = 0;
7458 for (i=4;i<argc;i++) { 7458 for (i=4;i<argc;i++) {
7459 switch(nextlong) { 7459 switch(nextlong) {
7460 case 0: 7460 case 0:
7461 if (mystrncasecmp(argv[i],"-name",0)) { 7461 if (mystrncasecmp(argv[i],"-name",0)) {
7462 nextlong = 1; 7462 nextlong = 1;
7463 continue; 7463 continue;
7464 } 7464 }
7465 if (mystrncasecmp(argv[i],"-protected",0)) { 7465 if (mystrncasecmp(argv[i],"-protected",0)) {
7466 File.Protected = true; 7466 File.Protected = true;
7467 continue; 7467 continue;
7468 } 7468 }
7469 if (mystrncasecmp(argv[i],"-readonly",0)) { 7469 if (mystrncasecmp(argv[i],"-readonly",0)) {
7470 File.ReadOnly = true; 7470 File.ReadOnly = true;
7471 continue; 7471 continue;
7472 } 7472 }
7473 if (mystrncasecmp(argv[i],"-hidden",0)) { 7473 if (mystrncasecmp(argv[i],"-hidden",0)) {
7474 File.Hidden = true; 7474 File.Hidden = true;
7475 continue; 7475 continue;
7476 } 7476 }
7477 if (mystrncasecmp(argv[i],"-system",0)) { 7477 if (mystrncasecmp(argv[i],"-system",0)) {
7478 File.System = true; 7478 File.System = true;
7479 continue; 7479 continue;
7480 } 7480 }
7481 if (mystrncasecmp(argv[i],"-newtime",0)) { 7481 if (mystrncasecmp(argv[i],"-newtime",0)) {
7482 ModEmpty = true; 7482 ModEmpty = true;
7483 continue; 7483 continue;
7484 } 7484 }
7485 printmsg("Parameter \"%s\" unknown\n",argv[i]); 7485 printmsg("Parameter \"%s\" unknown\n",argv[i]);
7486 exit(-1); 7486 exit(-1);
7487 case 1: 7487 case 1:
7488 strcpy(buffer,argv[i]); 7488 strcpy(buffer,argv[i]);
7489 nextlong = 0; 7489 nextlong = 0;
7490 break; 7490 break;
7491 } 7491 }
7492 } 7492 }
7493 if (nextlong!=0) { 7493 if (nextlong!=0) {
7494 printmsg("Parameter missed...\n"); 7494 printmsg("Parameter missed...\n");
7495 exit(-1); 7495 exit(-1);
7496 } 7496 }
7497 } 7497 }
7498 } else { /* MMS things */ 7498 } else { /* MMS things */
7499 DT2.Year = 2001; 7499 DT2.Year = 2001;
7500 DT2.Month = 12; 7500 DT2.Month = 12;
7501 DT2.Day = 31; 7501 DT2.Day = 31;
7502 DT2.Hour = 14; 7502 DT2.Hour = 14;
7503 DT2.Minute = 00; 7503 DT2.Minute = 00;
7504 DT2.Second = 00; 7504 DT2.Second = 00;
7505 t_time2 = Fill_Time_T(DT2,8); 7505 t_time2 = Fill_Time_T(DT2,8);
7506 7506
7507 GSM_GetCurrentDateTime(&DT); 7507 GSM_GetCurrentDateTime(&DT);
7508 t_time1 = Fill_Time_T(DT,8); 7508 t_time1 = Fill_Time_T(DT,8);
7509 7509
7510 sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40)); 7510 sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40));
7511#ifdef DEVELOP 7511#ifdef DEVELOP
7512 sprintf(buffer,"2A947BD 2A947DB "); 7512 sprintf(buffer,"2A947BD 2A947DB ");
7513#endif 7513#endif
7514 /* 40 = inbox "multimedia message received" message */ 7514 /* 40 = inbox "multimedia message received" message */
7515 /* 30 = outbox sending failed */ 7515 /* 30 = outbox sending failed */
7516 if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 "); 7516 if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 ");
7517 else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 "); 7517 else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 ");
7518 else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 "); 7518 else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 ");
7519 else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 "); 7519 else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 ");
7520 else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 "); 7520 else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 ");
7521 if (argc > 4) { 7521 if (argc > 4) {
7522 if (!mystrncasecmp(argv[2],"MMSOutbox",0) && 7522 if (!mystrncasecmp(argv[2],"MMSOutbox",0) &&
7523 !mystrncasecmp(argv[2],"MMSSent",0)) { 7523 !mystrncasecmp(argv[2],"MMSSent",0)) {
7524 sprintf(Name,"%s",argv[4]); 7524 sprintf(Name,"%s",argv[4]);
7525 strcat(buffer,Name); 7525 strcat(buffer,Name);
7526 } 7526 }
7527 if (argc > 5) { 7527 if (argc > 5) {
7528 sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]); 7528 sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]);
7529 strcat(buffer,Name); 7529 strcat(buffer,Name);
7530 } 7530 }
7531 } 7531 }
7532 ModEmpty = true; 7532 ModEmpty = true;
7533 } 7533 }
7534 7534
7535 error = GSM_ReadFile(argv[3], &File); 7535 error = GSM_ReadFile(argv[3], &File);
7536 Print_Error(error); 7536 Print_Error(error);
7537 if (ModEmpty) File.ModifiedEmpty = true; 7537 if (ModEmpty) File.ModifiedEmpty = true;
7538 7538
7539 strcpy(File.ID_FullName,Files.ID_FullName); 7539 strcpy(File.ID_FullName,Files.ID_FullName);
7540 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7540 EncodeUnicode(File.Name,buffer,strlen(buffer));
7541 GSM_IdentifyFileFormat(&File); 7541 GSM_IdentifyFileFormat(&File);
7542#ifdef DEVELOP 7542#ifdef DEVELOP
7543 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { 7543 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
7544 } else { /* MMS things */ 7544 } else { /* MMS things */
7545 File.Type = GSM_File_MMS; 7545 File.Type = GSM_File_MMS;
7546 } 7546 }
7547#endif 7547#endif
7548 7548
7549 dbgprintf("Adding file to filesystem now\n"); 7549 dbgprintf("Adding file to filesystem now\n");
7550 error = ERR_NONE; 7550 error = ERR_NONE;
7551 Pos= 0; 7551 Pos= 0;
7552 while (error == ERR_NONE) { 7552 while (error == ERR_NONE) {
7553 error = Phone->AddFilePart(&s,&File,&Pos); 7553 error = Phone->AddFilePart(&s,&File,&Pos);
7554 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7554 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7555 if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used); 7555 if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used);
7556 } 7556 }
7557 printmsgerr("\n"); 7557 printmsgerr("\n");
7558 if (error == ERR_WRONGCRC) { 7558 if (error == ERR_WRONGCRC) {
7559 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7559 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7560 } 7560 }
7561 7561
7562 free(File.Buffer); 7562 free(File.Buffer);
7563 GSM_Terminate(); 7563 GSM_Terminate();
7564} 7564}
7565 7565
7566static void DeleteFiles(int argc, char *argv[]) 7566static void DeleteFiles(int argc, char *argv[])
7567{ 7567{
7568 int i; 7568 int i;
7569 7569
7570 GSM_Init(true); 7570 GSM_Init(true);
7571 7571
7572 for (i=2;i<argc;i++) { 7572 for (i=2;i<argc;i++) {
7573 error = Phone->DeleteFile(&s,argv[i]); 7573 error = Phone->DeleteFile(&s,argv[i]);
7574 Print_Error(error); 7574 Print_Error(error);
7575 } 7575 }
7576 7576
7577 GSM_Terminate(); 7577 GSM_Terminate();
7578} 7578}
7579 7579
7580static void SaveMMSFile(int argc, char *argv[]) 7580static void SaveMMSFile(int argc, char *argv[])
7581{ 7581{
7582 FILE *file; 7582 FILE *file;
7583 unsigned char Buffer[50000],Buffer2[20][2010]; 7583 unsigned char Buffer[50000],Buffer2[20][2010];
7584 int i,nextlong = 0,len = 0; 7584 int i,nextlong = 0,len = 0;
7585 GSM_EncodeMultiPartMMSInfo Info; 7585 GSM_EncodeMultiPartMMSInfo Info;
7586 7586
7587 GSM_ClearMultiPartMMSInfo(&Info); 7587 GSM_ClearMultiPartMMSInfo(&Info);
7588 7588
7589 for (i=3;i<argc;i++) { 7589 for (i=3;i<argc;i++) {
7590 switch (nextlong) { 7590 switch (nextlong) {
7591 case 0: 7591 case 0:
7592 if (mystrncasecmp(argv[i],"-subject",0)) { 7592 if (mystrncasecmp(argv[i],"-subject",0)) {
7593 nextlong=1; 7593 nextlong=1;
7594 continue; 7594 continue;
7595 } 7595 }
7596 if (mystrncasecmp(argv[i],"-text",0)) { 7596 if (mystrncasecmp(argv[i],"-text",0)) {
7597 nextlong=2; 7597 nextlong=2;
7598 continue; 7598 continue;
7599 } 7599 }
7600 if (mystrncasecmp(argv[i],"-from",0)) { 7600 if (mystrncasecmp(argv[i],"-from",0)) {
7601 nextlong=3; 7601 nextlong=3;
7602 continue; 7602 continue;
7603 } 7603 }
7604 if (mystrncasecmp(argv[i],"-to",0)) { 7604 if (mystrncasecmp(argv[i],"-to",0)) {
7605 nextlong=4; 7605 nextlong=4;
7606 continue; 7606 continue;
7607 } 7607 }
7608 printmsg("Unknown parameter (\"%s\")\n",argv[i]); 7608 printmsg("Unknown parameter (\"%s\")\n",argv[i]);
7609 exit(-1); 7609 exit(-1);
7610 break; 7610 break;
7611 case 1: /* Subject */ 7611 case 1: /* Subject */
7612 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i])); 7612 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i]));
7613 nextlong = 0; 7613 nextlong = 0;
7614 break; 7614 break;
7615 case 2: /* Text */ 7615 case 2: /* Text */
7616 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i])); 7616 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i]));
7617 Info.Entries[Info.EntriesNum].ID = MMS_Text; 7617 Info.Entries[Info.EntriesNum].ID = MMS_Text;
7618 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum]; 7618 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum];
7619 Info.EntriesNum++; 7619 Info.EntriesNum++;
7620 nextlong = 0; 7620 nextlong = 0;
7621 break; 7621 break;
7622 case 3: /* From */ 7622 case 3: /* From */
7623 EncodeUnicode(Info.Source,argv[i],strlen(argv[i])); 7623 EncodeUnicode(Info.Source,argv[i],strlen(argv[i]));
7624 nextlong = 0; 7624 nextlong = 0;
7625 break; 7625 break;
7626 case 4: /* To */ 7626 case 4: /* To */
7627 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i])); 7627 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i]));
7628 nextlong = 0; 7628 nextlong = 0;
7629 break; 7629 break;
7630 } 7630 }
7631 } 7631 }
7632 if (nextlong!=0) { 7632 if (nextlong!=0) {
7633 printmsg("Parameter missed...\n"); 7633 printmsg("Parameter missed...\n");
7634 exit(-1); 7634 exit(-1);
7635 } 7635 }
7636 7636
7637 GSM_EncodeMMSFile(&Info,Buffer,&len); 7637 GSM_EncodeMMSFile(&Info,Buffer,&len);
7638 7638
7639 file = fopen(argv[2],"wb"); 7639 file = fopen(argv[2],"wb");
7640 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7640 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7641 fwrite(Buffer,1,len,file); 7641 fwrite(Buffer,1,len,file);
7642 fclose(file); 7642 fclose(file);
7643} 7643}
7644 7644
7645static void CallDivert(int argc, char *argv[]) 7645static void CallDivert(int argc, char *argv[])
7646{ 7646{
7647 GSM_MultiCallDivert cd; 7647 GSM_MultiCallDivert cd;
7648 7648
7649 if (mystrncasecmp("get",argv[2],0)) {} 7649 if (mystrncasecmp("get",argv[2],0)) {}
7650 else if (mystrncasecmp("set",argv[2],0)) {} 7650 else if (mystrncasecmp("set",argv[2],0)) {}
7651 else { 7651 else {
7652 printmsg("Unknown divert action (\"%s\")\n",argv[2]); 7652 printmsg("Unknown divert action (\"%s\")\n",argv[2]);
7653 exit(-1); 7653 exit(-1);
7654 } 7654 }
7655 7655
7656 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;} 7656 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;}
7657 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;} 7657 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;}
7658 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;} 7658 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;}
7659 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;} 7659 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;}
7660 else { 7660 else {
7661 printmsg("Unknown divert type (\"%s\")\n",argv[3]); 7661 printmsg("Unknown divert type (\"%s\")\n",argv[3]);
7662 exit(-1); 7662 exit(-1);
7663 } 7663 }
7664 7664
7665 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;} 7665 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;}
7666 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;} 7666 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;}
7667 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;} 7667 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;}
7668 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;} 7668 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;}
7669 else { 7669 else {
7670 printmsg("Unknown call type (\"%s\")\n",argv[4]); 7670 printmsg("Unknown call type (\"%s\")\n",argv[4]);
7671 exit(-1); 7671 exit(-1);
7672 } 7672 }
7673 7673
7674 GSM_Init(true); 7674 GSM_Init(true);
7675 7675
7676 if (mystrncasecmp("get", argv[2],0)) { 7676 if (mystrncasecmp("get", argv[2],0)) {
7677 error = Phone->GetCallDivert(&s,&cd); 7677 error = Phone->GetCallDivert(&s,&cd);
7678 Print_Error(error); 7678 Print_Error(error);
7679 printmsg("Query:\n Divert type: "); 7679 printmsg("Query:\n Divert type: ");
7680 } else { 7680 } else {
7681 cd.Request.Number[0] = 0; 7681 cd.Request.Number[0] = 0;
7682 cd.Request.Number[1] = 0; 7682 cd.Request.Number[1] = 0;
7683 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5])); 7683 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5]));
7684 7684
7685 cd.Request.Timeout = 0; 7685 cd.Request.Timeout = 0;
7686 if (argc > 6) cd.Request.Timeout = atoi(argv[6]); 7686 if (argc > 6) cd.Request.Timeout = atoi(argv[6]);
7687 7687
7688 error = Phone->SetCallDivert(&s,&cd); 7688 error = Phone->SetCallDivert(&s,&cd);
7689 Print_Error(error); 7689 Print_Error(error);
7690 printmsg("Changed:\n Divert type: "); 7690 printmsg("Changed:\n Divert type: ");
7691 } 7691 }
7692 7692
7693 switch (cd.Request.DivertType) { 7693 switch (cd.Request.DivertType) {
7694 case GSM_DIVERT_Busy : printmsg("when busy"); break; 7694 case GSM_DIVERT_Busy : printmsg("when busy"); break;
7695 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break; 7695 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break;
7696 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break; 7696 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break;
7697 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break; 7697 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break;
7698 default : printmsg("unknown %i",cd.Request.DivertType); break; 7698 default : printmsg("unknown %i",cd.Request.DivertType); break;
7699 } 7699 }
7700 printmsg("\n Calls type : "); 7700 printmsg("\n Calls type : ");
7701 switch (cd.Request.CallType) { 7701 switch (cd.Request.CallType) {
7702 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7702 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7703 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7703 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7704 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7704 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7705 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break; 7705 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break;
7706 default : printmsg("unknown %i",cd.Request.CallType); break; 7706 default : printmsg("unknown %i",cd.Request.CallType); break;
7707 } 7707 }
7708 printmsg("\nResponse:"); 7708 printmsg("\nResponse:");
7709 7709
7710 for (i=0;i<cd.Response.EntriesNum;i++) { 7710 for (i=0;i<cd.Response.EntriesNum;i++) {
7711 printmsg("\n Calls type : "); 7711 printmsg("\n Calls type : ");
7712 switch (cd.Response.Entries[i].CallType) { 7712 switch (cd.Response.Entries[i].CallType) {
7713 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7713 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7714 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7714 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7715 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7715 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7716 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; 7716 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break;
7717 } 7717 }
7718 printf("\n"); 7718 printf("\n");
7719 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); 7719 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout);
7720 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); 7720 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number));
7721 } 7721 }
7722 printf("\n"); 7722 printf("\n");
7723 7723
7724 GSM_Terminate(); 7724 GSM_Terminate();
7725} 7725}
7726 7726
7727static void CancelAllDiverts(int argc, char *argv[]) 7727static void CancelAllDiverts(int argc, char *argv[])
7728{ 7728{
7729 GSM_Init(true); 7729 GSM_Init(true);
7730 7730
7731 error = Phone->CancelAllDiverts(&s); 7731 error = Phone->CancelAllDiverts(&s);
7732 Print_Error(error); 7732 Print_Error(error);
7733 7733
7734 GSM_Terminate(); 7734 GSM_Terminate();
7735} 7735}
7736 7736
7737typedef struct { 7737typedef struct {
7738 unsigned char Connection[50]; 7738 unsigned char Connection[50];
7739} OneConnectionInfo; 7739} OneConnectionInfo;
7740 7740
7741typedef struct { 7741typedef struct {
7742 unsigned char Device[50]; 7742 unsigned char Device[50];
7743 OneConnectionInfo Connections[4]; 7743 OneConnectionInfo Connections[4];
7744} OneDeviceInfo; 7744} OneDeviceInfo;
7745 7745
7746 int num; 7746 int num;
7747 bool SearchOutput; 7747 bool SearchOutput;
7748 7748
7749void SearchPhoneThread(OneDeviceInfo *Info) 7749void SearchPhoneThread(OneDeviceInfo *Info)
7750{ 7750{
7751 //LR 7751 //LR
7752#if 0 7752#if 0
7753 int j; 7753 int j;
7754 GSM_Error error; 7754 GSM_Error error;
7755 GSM_StateMachiness; 7755 GSM_StateMachiness;
7756 7756
7757 j = 0; 7757 j = 0;
7758 while(strlen(Info->Connections[j].Connection) != 0) { 7758 while(strlen(Info->Connections[j].Connection) != 0) {
7759 memcpy(&ss.di,&s.di,sizeof(Debug_Info)); 7759 memcpy(&ss.di,&s.di,sizeof(Debug_Info));
7760 ss.msg = s.msg; 7760 ss.msg = s.msg;
7761 ss.ConfigNum = 1; 7761 ss.ConfigNum = 1;
7762 ss.opened = false; 7762 ss.opened = false;
7763 ss.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile; 7763 ss.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
7764 ss.Config[0].Localize = s.Config[0].Localize; 7764 ss.Config[0].Localize = s.Config[0].Localize;
7765 ss.Config[0].Device = Info->Device; 7765 ss.Config[0].Device = Info->Device;
7766 ss.Config[0].Connection = Info->Connections[j].Connection; 7766 ss.Config[0].Connection = Info->Connections[j].Connection;
7767 ss.Config[0].SyncTime = "no"; 7767 ss.Config[0].SyncTime = "no";
7768 ss.Config[0].DebugFile = s.Config[0].DebugFile; 7768 ss.Config[0].DebugFile = s.Config[0].DebugFile;
7769 ss.Config[0].Model[0] = 0; 7769 ss.Config[0].Model[0] = 0;
7770 strcpy(ss.Config[0].DebugLevel,s.Config[0].DebugLevel); 7770 strcpy(ss.Config[0].DebugLevel,s.Config[0].DebugLevel);
7771 ss.Config[0].LockDevice = "no"; 7771 ss.Config[0].LockDevice = "no";
7772 ss.Config[0].StartInfo = "no"; 7772 ss.Config[0].StartInfo = "no";
7773 7773
7774 error = GSM_InitConnection(&ss,1); 7774 error = GSM_InitConnection(&ss,1);
7775 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7775 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7776 if (error == ERR_NONE) { 7776 if (error == ERR_NONE) {
7777 error=ss.Phone.Functions->GetManufacturer(&ss); 7777 error=ss.Phone.Functions->GetManufacturer(&ss);
7778 if (error == ERR_NONE) { 7778 if (error == ERR_NONE) {
7779 error=ss.Phone.Functions->GetModel(&ss); 7779 error=ss.Phone.Functions->GetModel(&ss);
7780 if (error == ERR_NONE) { 7780 if (error == ERR_NONE) {
7781 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7781 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7782 printmsg(" Manufacturer : %s\n", 7782 printmsg(" Manufacturer : %s\n",
7783 ss.Phone.Data.Manufacturer); 7783 ss.Phone.Data.Manufacturer);
7784 printmsg(" Model : %s (%s)\n", 7784 printmsg(" Model : %s (%s)\n",
7785 ss.Phone.Data.ModelInfo->model, 7785 ss.Phone.Data.ModelInfo->model,
7786 ss.Phone.Data.Model); 7786 ss.Phone.Data.Model);
7787 } else { 7787 } else {
7788 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg)); 7788 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7789 } 7789 }
7790 } else { 7790 } else {
7791 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg)); 7791 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7792 } 7792 }
7793 } else { 7793 } else {
7794 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg)); 7794 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7795 } 7795 }
7796 if (error != ERR_DEVICEOPENERROR) { 7796 if (error != ERR_DEVICEOPENERROR) {
7797 GSM_TerminateConnection(&ss); 7797 GSM_TerminateConnection(&ss);
7798 dbgprintf("Closing done\n"); 7798 dbgprintf("Closing done\n");
7799 } 7799 }
7800 if (error == ERR_DEVICEOPENERROR) break; 7800 if (error == ERR_DEVICEOPENERROR) break;
7801 j++; 7801 j++;
7802 } 7802 }
7803 num--; 7803 num--;
7804#endif 7804#endif
7805} 7805}
7806 7806
7807#if defined(WIN32) || defined(HAVE_PTHREAD) 7807#if defined(WIN32) || defined(HAVE_PTHREAD)
7808#ifdef HAVE_PTHREAD 7808#ifdef HAVE_PTHREAD
7809 pthread_t Thread[100]; 7809 pthread_t Thread[100];
7810#endif 7810#endif
7811 7811
7812OneDeviceInfo SearchDevices[60]; 7812OneDeviceInfo SearchDevices[60];
7813 7813
7814void MakeSearchThread(int i) 7814void MakeSearchThread(int i)
7815{ 7815{
7816 num++; 7816 num++;
7817#ifdef HAVE_PTHREAD 7817#ifdef HAVE_PTHREAD
7818 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) { 7818 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) {
7819 dbgprintf("Error creating thread\n"); 7819 dbgprintf("Error creating thread\n");
7820 } 7820 }
7821#else 7821#else
7822 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, 7822 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0,
7823 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i], 7823 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i],
7824 0,NULL)==NULL) { 7824 0,NULL)==NULL) {
7825 dbgprintf("Error creating thread\n"); 7825 dbgprintf("Error creating thread\n");
7826 } 7826 }
7827#endif 7827#endif
7828} 7828}
7829 7829
7830static void SearchPhone(int argc, char *argv[]) 7830static void SearchPhone(int argc, char *argv[])
7831{ 7831{
7832 int i,dev = 0, dev2 = 0; 7832 int i,dev = 0, dev2 = 0;
7833 7833
7834 SearchOutput = false; 7834 SearchOutput = false;
7835 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true; 7835 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true;
7836 7836
7837 num = 0; 7837 num = 0;
7838#ifdef WIN32 7838#ifdef WIN32
7839# ifdef GSM_ENABLE_IRDADEVICE 7839# ifdef GSM_ENABLE_IRDADEVICE
7840 sprintf(SearchDevices[dev].Device,""); 7840 sprintf(SearchDevices[dev].Device,"");
7841 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); 7841 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
7842 sprintf(SearchDevices[dev].Connections[1].Connection,"irdaat"); 7842 sprintf(SearchDevices[dev].Connections[1].Connection,"irdaat");
7843 SearchDevices[dev].Connections[2].Connection[0] = 0; 7843 SearchDevices[dev].Connections[2].Connection[0] = 0;
7844 dev++; 7844 dev++;
7845# endif 7845# endif
7846# ifdef GSM_ENABLE_SERIALDEVICE 7846# ifdef GSM_ENABLE_SERIALDEVICE
7847 dev2 = dev; 7847 dev2 = dev;
7848 for(i=0;i<20;i++) { 7848 for(i=0;i<20;i++) {
7849 sprintf(SearchDevices[dev2].Device,"com%i:",i+1); 7849 sprintf(SearchDevices[dev2].Device,"com%i:",i+1);
7850 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7850 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7851 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7851 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7852 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7852 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7853 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7853 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7854 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7854 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7855 dev2++; 7855 dev2++;
7856 } 7856 }
7857# endif 7857# endif
7858#endif 7858#endif
7859#ifdef __linux__ 7859#ifdef __linux__
7860# ifdef GSM_ENABLE_IRDADEVICE 7860# ifdef GSM_ENABLE_IRDADEVICE
7861 for(i=0;i<6;i++) { 7861 for(i=0;i<6;i++) {
7862 sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i); 7862 sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i);
7863 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); 7863 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
7864 sprintf(SearchDevices[dev].Connections[1].Connection,"at19200"); 7864 sprintf(SearchDevices[dev].Connections[1].Connection,"at19200");
7865 SearchDevices[dev].Connections[2].Connection[0] = 0; 7865 SearchDevices[dev].Connections[2].Connection[0] = 0;
7866 dev++; 7866 dev++;
7867 } 7867 }
7868# endif 7868# endif
7869# ifdef GSM_ENABLE_SERIALDEVICE 7869# ifdef GSM_ENABLE_SERIALDEVICE
7870 dev2 = dev; 7870 dev2 = dev;
7871 for(i=0;i<10;i++) { 7871 for(i=0;i<10;i++) {
7872 sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i); 7872 sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i);
7873 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7873 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7874 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7874 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7875 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7875 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7876 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7876 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7877 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7877 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7878 dev2++; 7878 dev2++;
7879 } 7879 }
7880 for(i=0;i<8;i++) { 7880 for(i=0;i<8;i++) {
7881 sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i); 7881 sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i);
7882 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7882 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7883 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7883 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7884 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7884 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7885 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7885 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7886 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7886 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7887 dev2++; 7887 dev2++;
7888 } 7888 }
7889 for(i=0;i<4;i++) { 7889 for(i=0;i<4;i++) {
7890 sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i); 7890 sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i);
7891 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7891 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7892 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7892 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7893 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7893 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7894 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7894 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7895 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7895 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7896 dev2++; 7896 dev2++;
7897 } 7897 }
7898# endif 7898# endif
7899#endif 7899#endif
7900 for(i=0;i<dev;i++) MakeSearchThread(i); 7900 for(i=0;i<dev;i++) MakeSearchThread(i);
7901 while (num != 0) my_sleep(5); 7901 while (num != 0) my_sleep(5);
7902 for(i=dev;i<dev2;i++) MakeSearchThread(i); 7902 for(i=dev;i<dev2;i++) MakeSearchThread(i);
7903 while (num != 0) my_sleep(5); 7903 while (num != 0) my_sleep(5);
7904} 7904}
7905#endif /*Support for threads */ 7905#endif /*Support for threads */
7906 7906
7907static void NokiaGetADC(int argc, char *argv[]) 7907static void NokiaGetADC(int argc, char *argv[])
7908{ 7908{
7909 GSM_Init(true); 7909 GSM_Init(true);
7910 7910
7911#ifdef GSM_ENABLE_NOKIA_DCT3 7911#ifdef GSM_ENABLE_NOKIA_DCT3
7912 DCT3GetADC(argc,argv); 7912 DCT3GetADC(argc,argv);
7913#endif 7913#endif
7914#ifdef GSM_ENABLE_NOKIA_DCT4 7914#ifdef GSM_ENABLE_NOKIA_DCT4
7915 DCT4GetADC(argc, argv); 7915 DCT4GetADC(argc, argv);
7916#endif 7916#endif
7917 7917
7918 GSM_Terminate(); 7918 GSM_Terminate();
7919} 7919}
7920 7920
7921static void NokiaDisplayTest(int argc, char *argv[]) 7921static void NokiaDisplayTest(int argc, char *argv[])
7922{ 7922{
7923 GSM_Init(true); 7923 GSM_Init(true);
7924 7924
7925#ifdef GSM_ENABLE_NOKIA_DCT3 7925#ifdef GSM_ENABLE_NOKIA_DCT3
7926 DCT3DisplayTest(argc,argv); 7926 DCT3DisplayTest(argc,argv);
7927#endif 7927#endif
7928#ifdef GSM_ENABLE_NOKIA_DCT4 7928#ifdef GSM_ENABLE_NOKIA_DCT4
7929 DCT4DisplayTest(argc, argv); 7929 DCT4DisplayTest(argc, argv);
7930#endif 7930#endif
7931 7931
7932 GSM_Terminate(); 7932 GSM_Terminate();
7933} 7933}
7934 7934
7935static void NokiaGetT9(int argc, char *argv[]) 7935static void NokiaGetT9(int argc, char *argv[])
7936{ 7936{
7937 GSM_Init(true); 7937 GSM_Init(true);
7938 7938
7939#ifdef GSM_ENABLE_NOKIA_DCT3 7939#ifdef GSM_ENABLE_NOKIA_DCT3
7940 DCT3GetT9(argc,argv); 7940 DCT3GetT9(argc,argv);
7941#endif 7941#endif
7942#ifdef GSM_ENABLE_NOKIA_DCT4 7942#ifdef GSM_ENABLE_NOKIA_DCT4
7943 DCT4GetT9(argc, argv); 7943 DCT4GetT9(argc, argv);
7944#endif 7944#endif
7945 7945
7946 GSM_Terminate(); 7946 GSM_Terminate();
7947} 7947}
7948 7948
7949static void NokiaVibraTest(int argc, char *argv[]) 7949static void NokiaVibraTest(int argc, char *argv[])
7950{ 7950{
7951 GSM_Init(true); 7951 GSM_Init(true);
7952 7952
7953#ifdef GSM_ENABLE_NOKIA_DCT3 7953#ifdef GSM_ENABLE_NOKIA_DCT3
7954 DCT3VibraTest(argc,argv); 7954 DCT3VibraTest(argc,argv);
7955#endif 7955#endif
7956#ifdef GSM_ENABLE_NOKIA_DCT4 7956#ifdef GSM_ENABLE_NOKIA_DCT4
7957 DCT4VibraTest(argc, argv); 7957 DCT4VibraTest(argc, argv);
7958#endif 7958#endif
7959 7959
7960 GSM_Terminate(); 7960 GSM_Terminate();
7961} 7961}
7962 7962
7963static GSM_Parameters Parameters[] = { 7963static GSM_Parameters Parameters[] = {
7964 {"--identify", 0, 0, Identify, {H_Info,0}, ""}, 7964 {"--identify", 0, 0, Identify, {H_Info,0}, ""},
7965 {"--version", 0, 0, Version, {H_Other,0}, ""}, 7965 {"--version", 0, 0, Version, {H_Other,0}, ""},
7966 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""}, 7966 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""},
7967 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"}, 7967 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"},
7968 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""}, 7968 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
7969 {"--listnetworks", 0, 1, ListNetworks, {H_Network,0}, "[country]"}, 7969 {"--listnetworks", 0, 1, ListNetworks, {H_Network,0}, "[country]"},
7970 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"}, 7970 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"},
7971 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"}, 7971 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"},
7972 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"}, 7972 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"},
7973 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""}, 7973 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""},
7974 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."}, 7974 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."},
7975 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."}, 7975 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."},
7976 {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"}, 7976 {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"},
7977 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"}, 7977 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"},
7978 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"}, 7978 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"},
7979 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, 7979 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
7980 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, 7980 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"},
7981 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, 7981 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"},
7982 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, 7982 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""},
7983 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, 7983 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""},
7984 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, 7984 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""},
7985 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, 7985 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""},
7986 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"}, 7986 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"},
7987 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"}, 7987 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"},
7988 {"--getmemory", 2, 4, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop [-nonempty]]"}, 7988 {"--getmemory", 2, 4, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop [-nonempty]]"},
7989 {"--getallmemory", 1, 2, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"}, 7989 {"--getallmemory", 1, 2, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
7990 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"}, 7990 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"},
7991 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"}, 7991 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"},
7992 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"}, 7992 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"},
7993 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"}, 7993 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"},
7994 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"}, 7994 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"},
7995 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"}, 7995 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"},
7996 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"}, 7996 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"},
7997 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""}, 7997 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""},
7998 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""}, 7998 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""},
7999 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""}, 7999 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""},
8000 8000
8001 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]" 8001 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]"
8002 #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]" 8002 #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]"
8003 #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]" 8003 #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]"
8004 #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]" 8004 #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]"
8005 #define SMS_SMSTEMPLATE_OPTIONS"[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]" 8005 #define SMS_SMSTEMPLATE_OPTIONS"[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]"
8006 #define SMS_ANIMATION_OPTIONS"" 8006 #define SMS_ANIMATION_OPTIONS""
8007 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]" 8007 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]"
8008 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]" 8008 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]"
8009 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]" 8009 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]"
8010 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]" 8010 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]"
8011 8011
8012 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 8012 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
8013 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8013 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8014 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 8014 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
8015 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8015 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8016 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 8016 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
8017 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 8017 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
8018 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8018 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8019 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR URL Title " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8019 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR URL Title " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8020#ifdef GSM_ENABLE_BACKUP 8020#ifdef GSM_ENABLE_BACKUP
8021 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8021 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8022 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8022 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8023 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8023 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8024 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8024 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8025 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8025 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8026 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8026 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8027#endif 8027#endif
8028 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS}, 8028 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS},
8029 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 8029 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
8030 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 8030 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
8031 8031
8032 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 8032 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
8033 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8033 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8034 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 8034 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
8035 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8035 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8036 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 8036 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
8037 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 8037 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
8038 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8038 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8039 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR destination URL Title " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8039 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR destination URL Title " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8040#ifdef GSM_ENABLE_BACKUP 8040#ifdef GSM_ENABLE_BACKUP
8041 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8041 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8042 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8042 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8043 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8043 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8044 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8044 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8045 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8045 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8046 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8046 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8047#endif 8047#endif
8048 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS}, 8048 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS},
8049 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 8049 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
8050 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 8050 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
8051 8051
8052 {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"}, 8052 {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"},
8053 8053
8054 {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"}, 8054 {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"},
8055#ifdef HAVE_MYSQL_MYSQL_H 8055#ifdef HAVE_MYSQL_MYSQL_H
8056 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"}, 8056 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"},
8057#endif 8057#endif
8058 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"}, 8058 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"},
8059 {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"}, 8059 {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"},
8060 {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, 8060 {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
8061 {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, 8061 {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
8062 {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""}, 8062 {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""},
8063 {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"}, 8063 {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"},
8064 {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"}, 8064 {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"},
8065 {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"}, 8065 {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"},
8066 {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"}, 8066 {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"},
8067 {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"}, 8067 {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"},
8068 {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"}, 8068 {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"},
8069 {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"}, 8069 {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"},
8070 {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"}, 8070 {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"},
8071 {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"}, 8071 {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"},
8072 {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"}, 8072 {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"},
8073 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"}, 8073 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"},
8074 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"}, 8074 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"},
8075 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"}, 8075 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"},
8076 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"}, 8076 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"},
8077 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"}, 8077 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"},
8078 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""}, 8078 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""},
8079 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"}, 8079 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"},
8080 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""}, 8080 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""},
8081 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""}, 8081 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""},
8082 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"}, 8082 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"},
8083 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"}, 8083 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"},
8084 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"}, 8084 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"},
8085 {"--getallnotes", 0, 0, GetAllNotes, {H_Note,0}, ""}, 8085 {"--getallnotes", 0, 0, GetAllNotes, {H_Note,0}, ""},
8086 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"}, 8086 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"},
8087 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""}, 8087 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""},
8088 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"}, 8088 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"},
8089 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"}, 8089 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"},
8090 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"}, 8090 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"},
8091 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"}, 8091 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"},
8092 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"}, 8092 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"},
8093 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""}, 8093 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""},
8094 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"}, 8094 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"},
8095 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"}, 8095 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"},
8096 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"}, 8096 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"},
8097 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"}, 8097 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"},
8098 {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"}, 8098 {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"},
8099 {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"}, 8099 {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"},
8100 {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"}, 8100 {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"},
8101 {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"}, 8101 {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"},
8102 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"}, 8102 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"},
8103 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"}, 8103 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"},
8104 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"}, 8104 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"},
8105 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"}, 8105 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"},
8106 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"}, 8106 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"},
8107 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"}, 8107 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"},
8108 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"}, 8108 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"},
8109 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"}, 8109 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"},
8110 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"}, 8110 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"},
8111 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"}, 8111 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"},
8112 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"}, 8112 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"},
8113 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"}, 8113 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"},
8114 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"}, 8114 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"},
8115 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"}, 8115 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"},
8116 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"}, 8116 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"},
8117 {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"}, 8117 {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"},
8118 {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"}, 8118 {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"},
8119#if defined(WIN32) || defined(HAVE_PTHREAD) 8119#if defined(WIN32) || defined(HAVE_PTHREAD)
8120 {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"}, 8120 {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"},
8121#endif 8121#endif
8122#ifdef GSM_ENABLE_BACKUP 8122#ifdef GSM_ENABLE_BACKUP
8123 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"}, 8123 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"},
8124 {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"}, 8124 {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"},
8125 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"}, 8125 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"},
8126 {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"}, 8126 {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"},
8127 {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"}, 8127 {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"},
8128 {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"}, 8128 {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"},
8129 {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, 8129 {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
8130 {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, 8130 {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
8131 {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"}, 8131 {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"},
8132 {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"}, 8132 {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"},
8133#endif 8133#endif
8134 {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""}, 8134 {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""},
8135 {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""}, 8135 {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""},
8136 #ifdef GSM_ENABLE_AT 8136 #ifdef GSM_ENABLE_AT
8137 {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""}, 8137 {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""},
8138 {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"}, 8138 {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"},
8139 {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"}, 8139 {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"},
8140 #endif 8140 #endif
8141#ifdef GSM_ENABLE_NOKIA6110 8141#ifdef GSM_ENABLE_NOKIA6110
8142 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""}, 8142 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""},
8143 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"}, 8143 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"},
8144 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""}, 8144 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""},
8145#endif 8145#endif
8146#ifdef GSM_ENABLE_NOKIA_DCT3 8146#ifdef GSM_ENABLE_NOKIA_DCT3
8147 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"}, 8147 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"},
8148 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""}, 8148 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""},
8149 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"}, 8149 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"},
8150#endif 8150#endif
8151#ifdef GSM_ENABLE_NOKIA_DCT4 8151#ifdef GSM_ENABLE_NOKIA_DCT4
8152 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"}, 8152 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"},
8153 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"}, 8153 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"},
8154#ifdef GSM_ENABLE_NOKIA6510 8154#ifdef GSM_ENABLE_NOKIA6510
8155 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"}, 8155 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"},
8156 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""}, 8156 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""},
8157#endif 8157#endif
8158 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""}, 8158 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""},
8159 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""}, 8159 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""},
8160#endif 8160#endif
8161#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 8161#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
8162 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""}, 8162 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""},
8163 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""}, 8163 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""},
8164 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"}, 8164 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"},
8165 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""}, 8165 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""},
8166 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""}, 8166 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""},
8167 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""}, 8167 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""},
8168 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""}, 8168 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""},
8169#endif 8169#endif
8170#ifdef DEBUG 8170#ifdef DEBUG
8171 {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"}, 8171 {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"},
8172 {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"}, 8172 {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"},
8173 {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"}, 8173 {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"},
8174#endif 8174#endif
8175 {"", 0, 0, NULL } 8175 {"", 0, 0, NULL }
8176}; 8176};
8177 8177
8178static HelpCategoryDescriptions HelpDescriptions[] = { 8178static HelpCategoryDescriptions HelpDescriptions[] = {
8179 {H_Call, "call", "Calls",}, 8179 {H_Call, "call", "Calls",},
8180 {H_SMS, "sms", "SMS and EMS"}, 8180 {H_SMS, "sms", "SMS and EMS"},
8181 {H_Memory, "memory","Memory (phonebooks and calls)"}, 8181 {H_Memory, "memory","Memory (phonebooks and calls)"},
8182 {H_Filesystem, "filesystem","Filesystem"}, 8182 {H_Filesystem, "filesystem","Filesystem"},
8183 {H_Logo, "logo", "Logo and pictures"}, 8183 {H_Logo, "logo", "Logo and pictures"},
8184 {H_Ringtone, "ringtone","Ringtones"}, 8184 {H_Ringtone, "ringtone","Ringtones"},
8185 {H_Calendar, "calendar","Calendar notes"}, 8185 {H_Calendar, "calendar","Calendar notes"},
8186 {H_ToDo, "todo", "To do lists"}, 8186 {H_ToDo, "todo", "To do lists"},
8187 {H_Note, "note", "Notes"}, 8187 {H_Note, "note", "Notes"},
8188 {H_DateTime, "datetime","Date, time and alarms"}, 8188 {H_DateTime, "datetime","Date, time and alarms"},
8189 {H_Category, "category","Categories"}, 8189 {H_Category, "category","Categories"},
8190#ifdef GSM_ENABLE_BACKUP 8190#ifdef GSM_ENABLE_BACKUP
8191 {H_Backup, "backup","Backing up and restoring"}, 8191 {H_Backup, "backup","Backing up and restoring"},
8192#endif 8192#endif
8193#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 8193#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
8194 {H_Nokia, "nokia","Nokia specific"}, 8194 {H_Nokia, "nokia","Nokia specific"},
8195#endif 8195#endif
8196#ifdef GSM_ENABLE_AT 8196#ifdef GSM_ENABLE_AT
8197 {H_Siemens, "siemens","Siemens specific"}, 8197 {H_Siemens, "siemens","Siemens specific"},
8198#endif 8198#endif
8199 {H_Network, "network","Network"}, 8199 {H_Network, "network","Network"},
8200 {H_WAP, "wap", "WAP settings and bookmarks"}, 8200 {H_WAP, "wap", "WAP settings and bookmarks"},
8201 {H_MMS, "mms", "MMS and MMS settings"}, 8201 {H_MMS, "mms", "MMS and MMS settings"},
8202 {H_Tests, "tests","Phone tests"}, 8202 {H_Tests, "tests","Phone tests"},
8203 {H_FM, "fm", "FM radio"}, 8203 {H_FM, "fm", "FM radio"},
8204 {H_Info, "info", "Phone information"}, 8204 {H_Info, "info", "Phone information"},
8205 {H_Settings, "settings","Phone settings"}, 8205 {H_Settings, "settings","Phone settings"},
8206#ifdef DEBUG 8206#ifdef DEBUG
8207 {H_Decode, "decode","Dumps decoding"}, 8207 {H_Decode, "decode","Dumps decoding"},
8208#endif 8208#endif
8209 {H_Other, "other","Functions that don't fit elsewhere"}, 8209 {H_Other, "other","Functions that don't fit elsewhere"},
8210 {0, NULL, NULL} 8210 {0, NULL, NULL}
8211}; 8211};
8212 8212
8213 8213
8214void HelpHeader(void) 8214void HelpHeader(void)
8215{ 8215{
8216 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); 8216 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
8217} 8217}
8218 8218
8219static void HelpGeneral(void) 8219static void HelpGeneral(void)
8220{ 8220{
8221 inti=0; 8221 inti=0;
8222 8222
8223 HelpHeader(); 8223 HelpHeader();
8224 8224
8225 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n"); 8225 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n");
8226 printmsg("First parameter optionally specifies which config section to use (all are probed by default).\n"); 8226 printmsg("First parameter optionally specifies which config section to use (all are probed by default).\n");
8227 printmsg("Second parameter optionally controls debug level, next one specifies actions.\n\n"); 8227 printmsg("Second parameter optionally controls debug level, next one specifies actions.\n\n");
8228 8228
8229 /* We might want to put here some most used commands */ 8229 /* We might want to put here some most used commands */
8230 printmsg("For more details, call help on specific topic (gammu --help topic). Topics are:\n\n"); 8230 printmsg("For more details, call help on specific topic (gammu --help topic). Topics are:\n\n");
8231 8231
8232 while (HelpDescriptions[i].category != 0) { 8232 while (HelpDescriptions[i].category != 0) {
8233 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description); 8233 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description);
8234 i++; 8234 i++;
8235 } 8235 }
8236 printf("\n"); 8236 printf("\n");
8237} 8237}
8238 8238
8239static void HelpSplit(int cols, int len, unsigned char *buff) 8239static void HelpSplit(int cols, int len, unsigned char *buff)
8240{ 8240{
8241 int l, len2, pos, split; 8241 int l, len2, pos, split;
8242 bool in_opt,first=true; 8242 bool in_opt,first=true;
8243 char *remain, spaces[50], buffer[500]; 8243 char *remain, spaces[50], buffer[500];
8244 8244
8245 if (cols == 0) { 8245 if (cols == 0) {
8246 printf(" %s\n", buff); 8246 printf(" %s\n", buff);
8247 } else { 8247 } else {
8248 printf(" "); 8248 printf(" ");
8249 spaces[0] = 0; 8249 spaces[0] = 0;
8250 len2 = strlen(buff); 8250 len2 = strlen(buff);
8251 if (len + len2 < cols) { 8251 if (len + len2 < cols) {
8252 printf("%s\n", buff); 8252 printf("%s\n", buff);
8253 } else { 8253 } else {
8254 for(l = 0; l < len; l++) strcat(spaces, " "); 8254 for(l = 0; l < len; l++) strcat(spaces, " ");
8255 8255
8256 remain = buff; 8256 remain = buff;
8257 8257
8258 while (strlen(remain) > 0) { 8258 while (strlen(remain) > 0) {
8259 split= 0; 8259 split= 0;
8260 pos= 0; 8260 pos= 0;
8261 in_opt= false; 8261 in_opt= false;
8262 if (!first) printf(spaces); 8262 if (!first) printf(spaces);
8263 while (pos < cols - len && remain[pos] != 0) { 8263 while (pos < cols - len && remain[pos] != 0) {
8264 if (in_opt && remain[pos] == ']') { 8264 if (in_opt && remain[pos] == ']') {
8265 in_opt = false; 8265 in_opt = false;
8266 split = pos; 8266 split = pos;
8267 } else if (remain[pos] == '[') { 8267 } else if (remain[pos] == '[') {
8268 in_opt = true; 8268 in_opt = true;
8269 } else if (!in_opt && remain[pos] == ' ') { 8269 } else if (!in_opt && remain[pos] == ' ') {
8270 split = pos - 1; 8270 split = pos - 1;
8271 } 8271 }
8272 pos++; 8272 pos++;
8273 } 8273 }
8274 /* Can not be split */ 8274 /* Can not be split */
8275 if (split == 0) { 8275 if (split == 0) {
8276 printf("%s\n", remain); 8276 printf("%s\n", remain);
8277 remain += strlen(remain); 8277 remain += strlen(remain);
8278 } else { 8278 } else {
8279 first = false; 8279 first = false;
8280 split++; 8280 split++;
8281 strncpy(buffer, remain, split); 8281 strncpy(buffer, remain, split);
8282 buffer[split] = 0; 8282 buffer[split] = 0;
8283 printf("%s\n", buffer); 8283 printf("%s\n", buffer);
8284 remain += split; 8284 remain += split;
8285 if (remain[0] == ' ') remain++; 8285 if (remain[0] == ' ') remain++;
8286 } 8286 }
8287 } 8287 }
8288 } 8288 }
8289 } 8289 }
8290} 8290}
8291 8291
8292static void Help(int argc, char *argv[]) 8292static void Help(int argc, char *argv[])
8293{ 8293{
8294 int i = 0, j = 0, k, cols; 8294 int i = 0, j = 0, k, cols;
8295 bool disp; 8295 bool disp;
8296#ifdef TIOCGWINSZ 8296#ifdef TIOCGWINSZ
8297 struct winsize w; 8297 struct winsize w;
8298#endif 8298#endif
8299#if defined(WIN32) || defined(DJGPP) 8299#if defined(WIN32) || defined(DJGPP)
8300#else 8300#else
8301 char *columns; 8301 char *columns;
8302#endif 8302#endif
8303 8303
8304 /* Just --help */ 8304 /* Just --help */
8305 if (argc == 2) { 8305 if (argc == 2) {
8306 HelpGeneral(); 8306 HelpGeneral();
8307 return; 8307 return;
8308 } 8308 }
8309 8309
8310 if (!strcmp(argv[2],"all")) { 8310 if (!strcmp(argv[2],"all")) {
8311 HelpHeader(); 8311 HelpHeader();
8312 } else { 8312 } else {
8313 while (HelpDescriptions[i].category != 0) { 8313 while (HelpDescriptions[i].category != 0) {
8314 if (mystrncasecmp(argv[2], HelpDescriptions[i].option,strlen(argv[2]))) break; 8314 if (mystrncasecmp(argv[2], HelpDescriptions[i].option,strlen(argv[2]))) break;
8315 i++; 8315 i++;
8316 } 8316 }
8317 if (HelpDescriptions[i].category == 0) { 8317 if (HelpDescriptions[i].category == 0) {
8318 HelpGeneral(); 8318 HelpGeneral();
8319 printmsg("Unknown help topic specified!\n"); 8319 printmsg("Unknown help topic specified!\n");
8320 return; 8320 return;
8321 } 8321 }
8322 HelpHeader(); 8322 HelpHeader();
8323 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description); 8323 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description);
8324 } 8324 }
8325 8325
8326#if defined(WIN32) || defined(DJGPP) 8326#if defined(WIN32) || defined(DJGPP)
8327 cols = 80; 8327 cols = 80;
8328#else 8328#else
8329 cols = 0; 8329 cols = 0;
8330 /* If stdout is a tty, we will wrap to columns it has */ 8330 /* If stdout is a tty, we will wrap to columns it has */
8331 if (isatty(1)) { 8331 if (isatty(1)) {
8332#ifdef TIOCGWINSZ 8332#ifdef TIOCGWINSZ
8333 if (ioctl(2, TIOCGWINSZ, &w) == 0) { 8333 if (ioctl(2, TIOCGWINSZ, &w) == 0) {
8334 if (w.ws_col > 0) cols = w.ws_col; 8334 if (w.ws_col > 0) cols = w.ws_col;
8335 } 8335 }
8336#endif 8336#endif
8337 if (cols == 0) { 8337 if (cols == 0) {
8338 columns = getenv("COLUMNS"); 8338 columns = getenv("COLUMNS");
8339 if (columns != NULL) { 8339 if (columns != NULL) {
8340 cols = atoi(columns); 8340 cols = atoi(columns);
8341 if (cols <= 0) cols = 0; 8341 if (cols <= 0) cols = 0;
8342 } 8342 }
8343 } 8343 }
8344 8344
8345 if (cols == 0) { 8345 if (cols == 0) {
8346 /* Fallback */ 8346 /* Fallback */
8347 cols = 80; 8347 cols = 80;
8348 } 8348 }
8349 } 8349 }
8350#endif 8350#endif
8351 8351
8352 while (Parameters[j].Function != NULL) { 8352 while (Parameters[j].Function != NULL) {
8353 k = 0; 8353 k = 0;
8354 disp = false; 8354 disp = false;
8355 if (!strcmp(argv[2],"all")) { 8355 if (!strcmp(argv[2],"all")) {
8356 if (j==0) disp = true; 8356 if (j==0) disp = true;
8357 if (j!=0) { 8357 if (j!=0) {
8358 if (strcmp(Parameters[j].help,Parameters[j-1].help)) { 8358 if (strcmp(Parameters[j].help,Parameters[j-1].help)) {
8359 disp = true; 8359 disp = true;
8360 } else { 8360 } else {
8361 if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) { 8361 if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) {
8362 disp = true; 8362 disp = true;
8363 } 8363 }
8364 } 8364 }
8365 } 8365 }
8366 } else { 8366 } else {
8367 while (Parameters[j].help_cat[k] != 0) { 8367 while (Parameters[j].help_cat[k] != 0) {
8368 if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) { 8368 if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) {
8369 disp = true; 8369 disp = true;
8370 break; 8370 break;
8371 } 8371 }
8372 k++; 8372 k++;
8373 } 8373 }
8374 } 8374 }
8375 if (disp) { 8375 if (disp) {
8376 printf("%s", Parameters[j].parameter); 8376 printf("%s", Parameters[j].parameter);
8377 if (Parameters[j].help[0] == 0) { 8377 if (Parameters[j].help[0] == 0) {
8378 printf("\n"); 8378 printf("\n");
8379 } else { 8379 } else {
8380 HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help); 8380 HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help);
8381 } 8381 }
8382 } 8382 }
8383 j++; 8383 j++;
8384 } 8384 }
8385} 8385}
8386 8386
8387int main(int argc, char *argv[]) 8387int main(int argc, char *argv[])
8388{ 8388{
8389 int z = 0,start=0,i; 8389 int z = 0,start=0,i;
8390 intonly_config = -1; 8390 intonly_config = -1;
8391#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH) 8391#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
8392 char*locale, locale_file[201]; 8392 char*locale, locale_file[201];
8393#endif 8393#endif
8394 char*cp; 8394 char*cp;
8395 boolcount_failed = false; 8395 boolcount_failed = false;
8396 8396
8397 s.opened = false; 8397 s.opened = false;
8398 s.msg = NULL; 8398 s.msg = NULL;
8399 s.ConfigNum = 0; 8399 s.ConfigNum = 0;
8400 8400
8401 setlocale(LC_ALL, ""); 8401 setlocale(LC_ALL, "");
8402#ifdef DEBUG 8402#ifdef DEBUG
8403 di.dl = DL_TEXTALL; 8403 di.dl = DL_TEXTALL;
8404 di.df = stdout; 8404 di.df = stdout;
8405#endif 8405#endif
8406 8406
8407 /* Any parameters? */ 8407 /* Any parameters? */
8408 if (argc == 1) { 8408 if (argc == 1) {
8409 HelpGeneral(); 8409 HelpGeneral();
8410 printmsg("Too few parameters!\n"); 8410 printmsg("Too few parameters!\n");
8411 exit(1); 8411 exit(1);
8412 } 8412 }
8413 8413
8414 /* Help? */ 8414 /* Help? */
8415 if (strncmp(argv[1 + start], "--help", 6) == 0) { 8415 if (strncmp(argv[1 + start], "--help", 6) == 0) {
8416 Help(argc - start, argv + start); 8416 Help(argc - start, argv + start);
8417 exit(1); 8417 exit(1);
8418 } 8418 }
8419 8419
8420 /* Is first parameter numeric? If so treat it as config that should be loaded. */ 8420 /* Is first parameter numeric? If so treat it as config that should be loaded. */
8421 if (isdigit(argv[1][0])) { 8421 if (isdigit(argv[1][0])) {
8422 only_config = atoi(argv[1]); 8422 only_config = atoi(argv[1]);
8423 if (only_config >= 0) start++; else only_config = -1; 8423 if (only_config >= 0) start++; else only_config = -1;
8424 } 8424 }
8425 8425
8426 cfg = GSM_FindGammuRC(); 8426 cfg = GSM_FindGammuRC();
8427 if (cfg == NULL) printmsg("Warning: No configuration file found!\n"); 8427 if (cfg == NULL) printmsg("Warning: No configuration file found!\n");
8428 8428
8429 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 8429 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
8430 if (cfg!=NULL) { 8430 if (cfg!=NULL) {
8431 cp = INI_GetValue(cfg, "gammu", "gammucoding", false); 8431 cp = INI_GetValue(cfg, "gammu", "gammucoding", false);
8432 if (cp) di.coding = cp; 8432 if (cp) di.coding = cp;
8433 8433
8434 s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); 8434 s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false);
8435 if (s.Config[i].Localize) { 8435 if (s.Config[i].Localize) {
8436 s.msg=INI_ReadFile(s.Config[i].Localize, true); 8436 s.msg=INI_ReadFile(s.Config[i].Localize, true);
8437 } else { 8437 } else {
8438#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH) 8438#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
8439 locale = setlocale(LC_MESSAGES, NULL); 8439 locale = setlocale(LC_MESSAGES, NULL);
8440 if (locale != NULL) { 8440 if (locale != NULL) {
8441 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 8441 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
8442 LOCALE_PATH, 8442 LOCALE_PATH,
8443 tolower(locale[0]), 8443 tolower(locale[0]),
8444 tolower(locale[1])); 8444 tolower(locale[1]));
8445 s.msg = INI_ReadFile(locale_file, true); 8445 s.msg = INI_ReadFile(locale_file, true);
8446 } 8446 }
8447#endif 8447#endif
8448 } 8448 }
8449 } 8449 }
8450 8450
8451 /* Wanted user specific configuration? */ 8451 /* Wanted user specific configuration? */
8452 if (only_config != -1) { 8452 if (only_config != -1) {
8453 /* Here we get only in first for loop */ 8453 /* Here we get only in first for loop */
8454 if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; 8454 if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break;
8455 } else { 8455 } else {
8456 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 8456 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
8457 } 8457 }
8458 s.ConfigNum++; 8458 s.ConfigNum++;
8459 8459
8460 /* We want to use only one file descriptor for global and state machine debug output */ 8460 /* We want to use only one file descriptor for global and state machine debug output */
8461 s.Config[i].UseGlobalDebugFile = true; 8461 s.Config[i].UseGlobalDebugFile = true;
8462 8462
8463 /* It makes no sense to open several debug logs... */ 8463 /* It makes no sense to open several debug logs... */
8464 if (i != 0) { 8464 if (i != 0) {
8465 strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); 8465 strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel);
8466 free(s.Config[i].DebugFile); 8466 free(s.Config[i].DebugFile);
8467 s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); 8467 s.Config[i].DebugFile = strdup(s.Config[0].DebugFile);
8468 } else { 8468 } else {
8469 /* Just for first config */ 8469 /* Just for first config */
8470 /* When user gave debug level on command line */ 8470 /* When user gave debug level on command line */
8471 if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { 8471 if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) {
8472 /* Debug level from command line will be used with phone too */ 8472 /* Debug level from command line will be used with phone too */
8473 strcpy(s.Config[i].DebugLevel,argv[1 + start]); 8473 strcpy(s.Config[i].DebugLevel,argv[1 + start]);
8474 start++; 8474 start++;
8475 } else { 8475 } else {
8476 /* Try to set debug level from config file */ 8476 /* Try to set debug level from config file */
8477 GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); 8477 GSM_SetDebugLevel(s.Config[i].DebugLevel, &di);
8478 } 8478 }
8479 /* If user gave debug file in gammurc, we will use it */ 8479 /* If user gave debug file in gammurc, we will use it */
8480 error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); 8480 error=GSM_SetDebugFile(s.Config[i].DebugFile, &di);
8481 Print_Error(error); 8481 Print_Error(error);
8482 } 8482 }
8483 8483
8484 /* We wanted to read just user specified configuration. */ 8484 /* We wanted to read just user specified configuration. */
8485 if (only_config != -1) {break;} 8485 if (only_config != -1) {break;}
8486 } 8486 }
8487 8487
8488 /* Do we have enough parameters? */ 8488 /* Do we have enough parameters? */
8489 if (argc == 1 + start) { 8489 if (argc == 1 + start) {
8490 HelpGeneral(); 8490 HelpGeneral();
8491 printmsg("Too few parameters!\n"); 8491 printmsg("Too few parameters!\n");
8492 exit(-2); 8492 exit(-2);
8493 } 8493 }
8494 8494
8495 /* Check used version vs. compiled */ 8495 /* Check used version vs. compiled */
8496 if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { 8496 if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) {
8497 printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", 8497 printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n",
8498 GetGammuVersion(),VERSION); 8498 GetGammuVersion(),VERSION);
8499 exit(-1); 8499 exit(-1);
8500 } 8500 }
8501 8501
8502 /* Check parameters */ 8502 /* Check parameters */
8503 while (Parameters[z].Function != NULL) { 8503 while (Parameters[z].Function != NULL) {
8504 if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { 8504 if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) {
8505 if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { 8505 if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) {
8506 Parameters[z].Function(argc - start, argv + start); 8506 Parameters[z].Function(argc - start, argv + start);
8507 break; 8507 break;
8508 } else { 8508 } else {
8509 count_failed = true; 8509 count_failed = true;
8510 } 8510 }
8511 } 8511 }
8512 z++; 8512 z++;
8513 } 8513 }
8514 8514
8515 /* Tell user when we did nothing */ 8515 /* Tell user when we did nothing */
8516 if (Parameters[z].Function == NULL) { 8516 if (Parameters[z].Function == NULL) {
8517 HelpGeneral(); 8517 HelpGeneral();
8518 if (count_failed) { 8518 if (count_failed) {
8519 printmsg("Bad parameter count!\n"); 8519 printmsg("Bad parameter count!\n");
8520 } else { 8520 } else {
8521 printmsg("Bad option!\n"); 8521 printmsg("Bad option!\n");
8522 } 8522 }
8523 } 8523 }
8524 8524
8525 /* Close debug output if opened */ 8525 /* Close debug output if opened */
8526 if (di.df!=stdout) fclose(di.df); 8526 if (di.df!=stdout) fclose(di.df);
8527 8527
8528 exit(0); 8528 exit(0);
8529} 8529}
8530 8530
8531/* How should editor hadle tabs in this file? Add editor commands here. 8531/* How should editor hadle tabs in this file? Add editor commands here.
8532 * vim: noexpandtab sw=8 ts=8 sts=8: 8532 * vim: noexpandtab sw=8 ts=8 sts=8:
8533 */ 8533 */
8534 8534