1 #define _GNU_SOURCE /* For strcasestr */
4 #include "../helper/locales.h"
10 #ifdef GSM_ENABLE_NOKIA_DCT3
11 # include "depend/nokia/dct3.h"
12 # include "depend/nokia/dct3trac/wmx.h"
14 #ifdef GSM_ENABLE_NOKIA_DCT4
15 # include "depend/nokia/dct4.h"
22 #include "../helper/formats.h"
23 #include "../helper/printing.h"
24 #include "../helper/string.h"
26 #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
27 void NokiaComposer(int argc UNUSED
, char *argv
[])
30 GSM_Ringtone ringtone
;
34 GSM_RingNoteDuration Duration
;
35 GSM_RingNoteDuration DefNoteDuration
= 32; /* 32 = Duration_1_4 */
36 unsigned int DefNoteScale
= Scale_880
;
39 error
=GSM_ReadRingtoneFile(argv
[2],&ringtone
);
42 if (ringtone
.Format
!= RING_NOTETONE
) {
43 printf("%s\n", _("It can be RTTL ringtone only used with this option"));
49 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
50 if (ringtone
.NoteTone
.Commands
[i
].Type
== RING_Note
) {
51 Note
= &ringtone
.NoteTone
.Commands
[i
].Note
;
53 if (Note
->Note
!= Note_Pause
) {
54 printf(_("Ringtone \"%s\" (tempo = %i Beats Per Minute)"),DecodeUnicodeConsole(ringtone
.Name
),GSM_RTTLGetTempo(Note
->Tempo
));
63 printf_warn(_("length=%i notes, but you will enter only first 50 tones."), j
);
66 printf("\n\n%s ", _("This ringtone in Nokia Composer in phone should look:"));
68 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
69 if (ringtone
.NoteTone
.Commands
[i
].Type
== RING_Note
) {
70 Note
= &ringtone
.NoteTone
.Commands
[i
].Note
;
72 if (Note
->Note
!= Note_Pause
) started
= TRUE
;
75 switch (Note
->Duration
) {
76 case Duration_Full
: printf("1"); break;
77 case Duration_1_2
: printf("2"); break;
78 case Duration_1_4
: printf("4"); break;
79 case Duration_1_8
: printf("8"); break;
80 case Duration_1_16
: printf("16");break;
81 case Duration_1_32
: printf("32");break;
83 if (Note
->DurationSpec
== DottedNote
) printf(".");
85 case Note_C
: printf("c"); break;
86 case Note_Cis
: printf("#c"); break;
87 case Note_D
:printf("d"); break;
88 case Note_Dis
: printf("#d"); break;
89 case Note_E
: printf("e"); break;
90 case Note_F
: printf("f"); break;
91 case Note_Fis
: printf("#f"); break;
92 case Note_G
: printf("g"); break;
93 case Note_Gis
: printf("#g"); break;
94 case Note_A
: printf("a"); break;
95 case Note_Ais
: printf("#a"); break;
96 case Note_H
: printf("h"); break;
97 case Note_Pause
: printf("-"); break;
99 if (Note
->Note
!= Note_Pause
) printf("%i",Note
->Scale
- 4);
105 printf("\n\n%s ", _("To enter it please press:"));
107 for (i
=0;i
<ringtone
.NoteTone
.NrCommands
;i
++) {
108 if (ringtone
.NoteTone
.Commands
[i
].Type
== RING_Note
) {
109 Note
= &ringtone
.NoteTone
.Commands
[i
].Note
;
111 if (Note
->Note
!= Note_Pause
) started
= TRUE
;
114 switch (Note
->Note
) {
115 case Note_C
: case Note_Cis
: printf("1");break;
116 case Note_D
: case Note_Dis
: printf("2");break;
117 case Note_E
: printf("3");break;
118 case Note_F
: case Note_Fis
: printf("4");break;
119 case Note_G
: case Note_Gis
: printf("5");break;
120 case Note_A
: case Note_Ais
: printf("6");break;
121 case Note_H
: printf("7");break;
122 default : printf("0");break;
124 if (Note
->DurationSpec
== DottedNote
) printf("%s", _("(longer)"));
125 switch (Note
->Note
) {
126 case Note_Cis
: case Note_Dis
:
127 case Note_Fis
: case Note_Gis
:
134 if (Note
->Note
!= Note_Pause
) {
135 if ((unsigned int)Note
->Scale
!= DefNoteScale
) {
136 while (DefNoteScale
!= (unsigned int)Note
->Scale
) {
139 if (DefNoteScale
==Scale_7040
) DefNoteScale
= Scale_880
;
144 switch (Note
->Duration
) {
145 case Duration_Full
: Duration
= 128; break;
146 case Duration_1_2
: Duration
= 64; break;
147 case Duration_1_4
: Duration
= 32; break;
148 case Duration_1_8
: Duration
= 16; break;
149 case Duration_1_16
: Duration
= 8; break;
150 case Duration_1_32
: Duration
= 4; break;
151 default : fprintf(stderr
, "error\n");break;
153 if (Duration
> DefNoteDuration
) {
154 while (DefNoteDuration
!= Duration
) {
156 DefNoteDuration
= DefNoteDuration
* 2;
159 if (Duration
< DefNoteDuration
) {
160 while (DefNoteDuration
!= Duration
) {
162 DefNoteDuration
= DefNoteDuration
/ 2;
174 void NokiaSecurityCode(int argc
, char *argv
[])
178 #ifdef GSM_ENABLE_NOKIA_DCT3
179 if (CheckDCT3Only() != ERR_NOTSUPPORTED
) {
180 DCT3GetSecurityCode(argc
,argv
);
183 #ifdef GSM_ENABLE_NOKIA_DCT4
184 if (CheckDCT4Only() != ERR_NOTSUPPORTED
) {
185 /* DCT4ResetSecurityCode(argc, argv); */
186 DCT4GetSecurityCode(argc
,argv
);
193 void NokiaSetPhoneMenus(int argc
, char *argv
[])
197 #ifdef GSM_ENABLE_NOKIA_DCT3
198 if (CheckDCT3Only() != ERR_NOTSUPPORTED
) {
199 DCT3SetPhoneMenus (argc
, argv
);
202 #ifdef GSM_ENABLE_NOKIA_DCT4
203 if (CheckDCT4Only() != ERR_NOTSUPPORTED
) {
204 DCT4SetPhoneMenus (argc
, argv
);
211 void NokiaSelfTests(int argc
, char *argv
[])
215 #ifdef GSM_ENABLE_NOKIA_DCT3
216 if (CheckDCT3Only() != ERR_NOTSUPPORTED
) {
217 DCT3SelfTests(argc
, argv
);
220 #ifdef GSM_ENABLE_NOKIA_DCT4
221 if (CheckDCT4Only() != ERR_NOTSUPPORTED
) {
222 DCT4SelfTests(argc
, argv
);
229 typedef struct _PlayListEntry PlayListEntry
;
231 struct _PlayListEntry
{
233 unsigned char *NameUP
;
237 void NokiaAddPlayLists2(unsigned char *ID
,unsigned char *Name
,unsigned char *IDFolder
)
240 gboolean Start
= TRUE
, Available
= FALSE
;
241 GSM_File Files
,Files2
,Files3
;
243 size_t i
, NamesPos
= 0;
244 unsigned char Buffer
[20],Buffer2
[500];
245 unsigned char *Names
,*Names2
,*Pointer
;
246 PlayListEntry
*First
,*Entry
=NULL
,*Prev
;
248 First
= NULL
; Names
=NULL
; Names2
=NULL
;
250 CopyUnicodeString(Files
.ID_FullName
,ID
);
252 printf(_("Checking %s\n"),DecodeUnicodeString(Name
));
253 /* looking into folder content (searching for mp3 and similiar) */
255 error
= GSM_GetFolderListing(gsm
,&Files
,Start
);
256 if (error
== ERR_FOLDERPART
) {
257 printf("%s\n", _(" Only part handled!"));
260 if (error
== ERR_EMPTY
) break;
261 if (error
== ERR_FILENOTEXIST
) return;
265 if (strcasestr(DecodeUnicodeConsole(Files
.Name
),".mp3")!=NULL
||
266 strcasestr(DecodeUnicodeConsole(Files
.Name
),".aac")!=NULL
) {
268 First
= malloc(sizeof(PlayListEntry
));
271 Entry
->Next
= malloc(sizeof(PlayListEntry
));
275 Entry
->Name
= malloc(strlen(DecodeUnicodeString(Files
.ID_FullName
))+1);
276 sprintf(Entry
->Name
,"%s",DecodeUnicodeString(Files
.ID_FullName
));
277 /* converting Gammu drives to phone drives */
278 if (Entry
->Name
[0]=='a' || Entry
->Name
[0]=='A') {
280 } else if (Entry
->Name
[0]=='d' || Entry
->Name
[0]=='D') {
284 Entry
->NameUP
= malloc(strlen(DecodeUnicodeString(Files
.ID_FullName
))+1);
285 for (i
= 0; i
< strlen(DecodeUnicodeString(Files
.ID_FullName
)) + 1; i
++) {
286 Entry
->NameUP
[i
] = tolower(Entry
->Name
[i
]);
290 Names
= (unsigned char *)realloc(Names
,NamesPos
+UnicodeLength(Files
.ID_FullName
)*2+2);
291 CopyUnicodeString(Names
+NamesPos
,Files
.ID_FullName
);
292 NamesPos
+=UnicodeLength(Files
.ID_FullName
)*2+2;
294 Names2
= (unsigned char *)realloc(Names2
,NamesPos2
+UnicodeLength(Files
.Name
)*2+2);
295 CopyUnicodeString(Names2
+NamesPos2
,Files
.Name
);
296 NamesPos2
+=UnicodeLength(Files
.Name
)*2+2;
302 /* sorting songs names */
304 while (Entry
->Next
!=NULL
) {
305 if (strcmp(Entry
->NameUP
,Entry
->Next
->NameUP
)>0) {
306 Pointer
=Entry
->Next
->Name
;
307 Entry
->Next
->Name
= Entry
->Name
;
308 Entry
->Name
= Pointer
;
310 Pointer
=Entry
->Next
->NameUP
;
311 Entry
->Next
->NameUP
= Entry
->NameUP
;
312 Entry
->NameUP
= Pointer
;
319 /* we checking, if file already exist.if yes, we look for another... */
321 Files3
.Buffer
= NULL
;
323 CopyUnicodeString(Files3
.ID_FullName
,IDFolder
);
324 CopyUnicodeString(Buffer2
,Name
);
326 sprintf(Buffer
, "%ld", (long)i
);
327 EncodeUnicode(Buffer2
+UnicodeLength(Buffer2
)*2,Buffer
,strlen(Buffer
));
329 EncodeUnicode(Buffer2
+UnicodeLength(Buffer2
)*2,".m3u",4);
334 error
= GSM_GetFolderListing(gsm
,&Files3
,Start
);
335 if (error
== ERR_FOLDERPART
) {
336 printf("%s\n", _(" Problem with adding playlist"));
339 if (error
== ERR_EMPTY
) break;
342 if (!Files3
.Folder
) {
343 if (mywstrncasecmp(Buffer2
,Files3
.Name
,-1)) {
350 if (!Available
) break;
354 /* preparing new playlist file date */
355 Files2
.System
= FALSE
;
356 Files2
.Folder
= FALSE
;
357 Files2
.ReadOnly
= FALSE
;
358 Files2
.Hidden
= FALSE
;
359 Files2
.Protected
= FALSE
;
360 Files2
.ModifiedEmpty
= FALSE
;
361 GSM_GetCurrentDateTime (&Files2
.Modified
);
362 CopyUnicodeString(Files2
.ID_FullName
,IDFolder
);
363 CopyUnicodeString(Files2
.Name
,Buffer2
);
365 /* preparing new playlist file content */
367 Files2
.Buffer
= (unsigned char *)realloc(Files2
.Buffer
,10);
368 sprintf(Files2
.Buffer
,"#EXTM3U%c%c",13,10);
371 while (Entry
!=NULL
) {
372 Files2
.Buffer
= (unsigned char *)realloc(Files2
.Buffer
,Files2
.Used
+strlen(Entry
->Name
)+2+1);
373 sprintf(Files2
.Buffer
+Files2
.Used
,"%s%c%c",Entry
->Name
,13,10);
374 Files2
.Used
+=strlen(Entry
->Name
)+2;
378 for (i
=0;i
<Files2
.Used
;i
++) {
379 if (Files2
.Buffer
[i
]=='/') Files2
.Buffer
[i
]='\\';
382 /* adding new playlist file */
383 sprintf(Buffer2
, _("Writing file %s:"), DecodeUnicodeString(Files2
.Name
));
384 AddOneFile(&Files2
, Buffer2
, FALSE
);
386 /* cleaning buffers */
389 while (Entry
!=NULL
) {
392 while (Entry
->Next
!=NULL
) {
400 if (Prev
!=NULL
) Prev
->Next
= NULL
;
404 /* going into subfolders */
407 while (i
!= NamesPos
) {
408 NokiaAddPlayLists2(Names
+i
,Names2
+j
,IDFolder
);
409 i
+=UnicodeLength(Names
+i
)*2+2;
410 j
+=UnicodeLength(Names2
+j
)*2+2;
417 void NokiaAddPlayLists(int argc UNUSED
, char *argv
[] UNUSED
)
420 gboolean Start
= TRUE
;
422 unsigned char buffer
[20],buffer2
[20],IDFolder
[100];
426 /* delete old playlists */
427 EncodeUnicode(IDFolder
,"d:\\predefplaylist",17);
428 CopyUnicodeString(Files
.ID_FullName
,IDFolder
);
429 error
= GSM_GetFolderListing(gsm
,&Files
,Start
);
430 if (error
== ERR_FILENOTEXIST
) {
431 EncodeUnicode(IDFolder
,"d:\\predefgallery\\predefplaylist",17+14);
432 CopyUnicodeString(Files
.ID_FullName
,IDFolder
);
433 error
= GSM_GetFolderListing(gsm
,&Files
,Start
);
434 } else if (error
!= ERR_EMPTY
) {
437 if (error
== ERR_FILENOTEXIST
) {
438 printf("%s\n", _("Your phone model is not supported. Please report it to authors (see <http://wammu.eu/support/bugs/>). Thank you."));
441 } else if (error
!= ERR_EMPTY
) {
446 if (strstr(DecodeUnicodeConsole(Files
.Name
),".m3u")!=NULL
) {
447 error
= GSM_DeleteFile(gsm
,Files
.ID_FullName
);
452 error
= GSM_GetFolderListing(gsm
,&Files
,Start
);
453 if (error
== ERR_FOLDERPART
) {
454 printf("%s\n", _("Problem with deleting playlist"));
457 if (error
== ERR_EMPTY
) break;
461 /* go over phone memory and add new one playlists */
462 EncodeUnicode(buffer
,"d:",2);
463 EncodeUnicode(buffer2
,"root",4);
464 NokiaAddPlayLists2(buffer
,buffer2
,IDFolder
);
465 /* go over memory card and add new one playlists */
466 EncodeUnicode(buffer
,"a:",2);
467 EncodeUnicode(buffer2
,"root",4);
468 NokiaAddPlayLists2(buffer
,buffer2
,IDFolder
);
473 struct NokiaFolderInfo
{
475 const char *parameter
;
480 struct NokiaFolderInfo Folder
[] = {
481 /* Language indepedent in DCT4 in filesystem 1 */
482 {"", "Application", "applications", "3"},
483 {"", "Game", "games", "3"},
484 /* Language indepedent in DCT4/TIKU/BB5 in filesystem 2 */
485 {"", "Gallery", "d:/predefgallery/predefgraphics", ""},
486 {"", "Gallery2", "d:/predefgallery/predefgraphics/predefcliparts", ""},
487 {"", "Camera", "d:/predefgallery/predefphotos", ""},
488 {"", "Tones", "d:/predefgallery/predeftones", ""},
489 {"", "Tones2", "d:/predefgallery/predefmusic", ""},
490 {"", "Records", "d:/predefgallery/predefrecordings", ""},
491 {"", "Video", "d:/predefgallery/predefvideos", ""},
492 {"", "Playlist", "d:/predefplaylist", ""},
493 {"", "MemoryCard", "a:", ""},
494 /* now values first seen in S40 3.0 */
495 {"", "Application", "d:/predefjava/predefcollections", ""},
496 {"", "Game", "d:/predefjava/predefgames", ""},
498 /* Language depedent in DCT4 filesystem 1 */
499 {"", "Gallery", "Clip-arts", "3"},
500 {"", "Gallery", "004F006200720061007A006B0069", "3"},/* obrazki PL 6220 */
501 {"", "Gallery", "Pictures", "2"},/* 3510 */
502 {"", "Gallery2", "Graphics", "3"},
503 {"", "Gallery2", "00470072006100660069006B0061", "3"},/* grafika PL 6220 */
504 {"", "Camera", "Images", "3"},
505 {"", "Camera", "005A0064006A0119006300690061", "3"},/* zdjecia PL 6220 */
506 {"", "Tones", "Tones", "3"},
507 {"", "Tones", "0044017A007700690119006B0069", "3"},/* dzwieki pl 6220 */
508 {"", "Records", "Recordings", "3"},
509 {"", "Records", "004E0061006700720061006E00690061", "3"},/* nagrania pl 6220 */
510 {"", "Video", "Video clips", "3"},
511 {"", "Video", "0057006900640065006F006B006C006900700079", "3"},/* wideoklipy pl 6220 */
513 /* Language indepedent in OBEX */
514 {"obex", "MMSUnreadInbox", "predefMessages\\predefINBOX", ""},
515 {"obex", "MMSReadInbox", "predefMessages\\predefINBOX", ""},
516 {"obex", "MMSOutbox", "predefMessages\\predefOUTBOX", ""},
517 {"obex", "MMSSent", "predefMessages\\predefSENT", ""},
518 {"obex", "MMSDrafts", "predefMessages\\predefDRAFTS", ""},
519 /* {"obex", "Application, "predefjava\\predefapplications", ""}, */
520 /* {"obex", "Game", "predefjava\\predefgames", ""}, */
521 {"obex", "Gallery", "predefgallery\\predefgraphics", ""},
522 {"obex", "Tones", "predefgallery\\predeftones", ""},
528 void NokiaAddFile(int argc
, char *argv
[])
531 GSM_File File
, Files
, File2
;
533 unsigned char buffer
[10000],JAR
[500],Vendor
[500],Name
[500],Version
[500],FileID
[400];
534 gboolean Start
= TRUE
, Found
= FALSE
, wasclr
;
535 gboolean ModEmpty
= FALSE
, Overwrite
= FALSE
, OverwriteAll
= FALSE
;
540 while (Folder
[i
].parameter
[0] != 0) {
541 if (strcasecmp(argv
[2],Folder
[i
].parameter
) == 0) {
548 printf(_("What folder type (\"%s\") ?\n"),argv
[2]);
552 if (strcasecmp(argv
[2],"Application") == 0 || strcasecmp(argv
[2],"Game") == 0) {
553 sprintf(buffer
, "%s.jad", argv
[3]);
554 file
= fopen(buffer
, "rb");
556 printf_err(_("Can not open file %s\n"), buffer
);
557 Print_Error(ERR_CANTOPENFILE
);
560 sprintf(buffer
, "%s.jar", argv
[3]);
561 file
= fopen(buffer
, "rb");
563 printf_err(_("Can not open file %s\n"), buffer
);
564 Print_Error(ERR_CANTOPENFILE
);
568 file
= fopen(argv
[3],"rb");
570 printf_err(_("Can not open file %s\n"), argv
[3]);
571 Print_Error(ERR_CANTOPENFILE
);
579 if (GSM_GetUsedConnection(gsm
) == GCT_IRDAOBEX
|| GSM_GetUsedConnection(gsm
) == GCT_BLUEOBEX
) {
581 while (Folder
[i
].parameter
[0] != 0) {
582 if (!strcmp("obex",Folder
[i
].model
) &&
583 strcasecmp(argv
[2],Folder
[i
].parameter
) == 0) {
584 EncodeUnicode(Files
.ID_FullName
,Folder
[i
].folder
,strlen(Folder
[i
].folder
));
591 printf("%s\n", _("Folder not found. Probably function not supported!"));
595 } else if (GSM_IsPhoneFeatureAvailable(GSM_GetModelInfo(gsm
), F_FILES2
)) {
597 while (Folder
[i
].parameter
[0] != 0) {
598 if ((Folder
[i
].folder
[0] == 'a' || Folder
[i
].folder
[0] == 'd') &&
599 Folder
[i
].level
[0] == 0x00 &&
600 strcasecmp(argv
[2],Folder
[i
].parameter
) == 0) {
601 if (strstr(Folder
[i
].folder
,"d:/predefjava/")!= NULL
&&
602 !GSM_IsPhoneFeatureAvailable(GSM_GetModelInfo(gsm
), F_SERIES40_30
)) {
606 EncodeUnicode(Files
.ID_FullName
,Folder
[i
].folder
,strlen(Folder
[i
].folder
));
614 fprintf(stderr
, "%s", _("Searching for phone folder: "));
616 error
= GSM_GetNextFileFolder(gsm
,&Files
,Start
);
617 if (error
== ERR_EMPTY
) break;
621 smprintf(gsm
, "folder %s level %i\n",DecodeUnicodeConsole(Files
.Name
),Files
.Level
);
624 while (Folder
[i
].parameter
[0] != 0) {
625 EncodeUnicode(buffer
,Folder
[i
].folder
,strlen(Folder
[i
].folder
));
626 smprintf(gsm
, "comparing \"%s\" \"%s\" \"%s\"\n",GSM_GetModelInfo(gsm
)->model
,DecodeUnicodeString(Files
.ID_FullName
),Folder
[i
].level
);
627 if (strcasecmp(argv
[2],Folder
[i
].parameter
) == 0 &&
628 mywstrncasecmp(Files
.Name
,buffer
,0) &&
629 Files
.Level
== atoi(Folder
[i
].level
)) {
630 smprintf(gsm
, "found 1\n");
634 if (strcasecmp(argv
[2],Folder
[i
].parameter
) == 0 &&
635 !strcmp(DecodeUnicodeString(Files
.ID_FullName
),Folder
[i
].folder
) &&
636 Folder
[i
].level
[0] == 0x00) {
638 smprintf(gsm
, "found 2\n");
641 if (Folder
[i
].folder
[0]>='0'&&Folder
[i
].folder
[0] <='9') {
642 DecodeHexUnicode (buffer
, Folder
[i
].folder
,strlen(Folder
[i
].folder
));
643 smprintf(gsm
, "comparing \"%s\"",DecodeUnicodeString(buffer
));
644 smprintf(gsm
, "and \"%s\"\n",DecodeUnicodeString(Files
.Name
));
645 if (strcasecmp(argv
[2],Folder
[i
].parameter
) == 0 &&
646 mywstrncasecmp(Files
.Name
,buffer
,0) &&
647 Files
.Level
== atoi(Folder
[i
].level
)) {
649 smprintf(gsm
, "found 3\n");
657 fprintf(stderr
, "*");
661 fprintf(stderr
, "\n");
665 printf("%s\n", _("Folder not found. Probably function not supported!"));
670 File
.Protected
= FALSE
;
671 File
.ReadOnly
= FALSE
;
675 if (strcasecmp(argv
[2],"Application") == 0 || strcasecmp(argv
[2],"Game") == 0) {
676 /* reading jar file */
677 sprintf(buffer
,"%s.jar",argv
[3]);
678 error
= GSM_ReadFile(buffer
, &File
);
682 /* reading jad file */
683 sprintf(buffer
,"%s.jad",argv
[3]);
684 error
= GSM_ReadFile(buffer
, &File
);
687 /* Getting values from JAD file */
688 error
= GSM_JADFindData(&File
, Vendor
, Name
, JAR
, Version
, &Size
);
689 if (error
== ERR_FILENOTSUPPORTED
) {
690 if (Vendor
[0] == 0x00) {
691 fprintf(stderr
, "%s\n", _("No vendor info in JAD file"));
695 if (Name
[0] == 0x00) {
696 fprintf(stderr
, "%s\n", _("No name info in JAD file"));
700 if (JAR
[0] == 0x00) {
701 fprintf(stderr
, "%s\n", _("No JAR URL info in JAD file"));
707 printf_info("%s\n", _("Declared JAR file size is different than real. Fixed by Gammu."));
708 for (i
=0;i
<File
.Used
;i
++) {
709 if (strncasecmp(File
.Buffer
+i
,"MIDlet-Jar-Size: ",17) == 0) {
715 if (Pos
==0 || File
.Buffer
[Pos
] == 13 || File
.Buffer
[Pos
] == 10) break;
720 if (i
== File
.Used
|| File
.Buffer
[i
] == 13 || File
.Buffer
[i
] == 10) break;
723 while (i
!= File
.Used
) {
724 File
.Buffer
[Pos
] = File
.Buffer
[i
];
728 File
.Used
= File
.Used
- (i
- Pos
);
729 File
.Buffer
= realloc(File
.Buffer
,File
.Used
);
730 } else if (Size
== -1) {
731 printf_info("%s\n", _("No JAR size info in JAD file. Added by Gammu."));
734 sprintf(buffer
,"\nMIDlet-Jar-Size: %i",Size2
);
735 File
.Buffer
= realloc(File
.Buffer
,File
.Used
+ strlen(buffer
));
736 memcpy(File
.Buffer
+File
.Used
,buffer
,strlen(buffer
));
737 File
.Used
+= strlen(buffer
);
740 fprintf(stderr
, _("Adding \"%s\""),Name
);
741 if (Version
[0] != 0x00) fprintf(stderr
, _(" version %s"),Version
);
742 fprintf(stderr
, _(" created by %s\n"),Vendor
);
744 /* Bostjan Muller 3200 RH-30 3.08 */
745 if (strstr(JAR
,"http://") != NULL
) {
747 while (JAR
[i
] != '/') i
--;
748 strcpy(buffer
,JAR
+i
+1);
750 smprintf(gsm
, "New file name is \"%s\"\n",JAR
);
753 /* Changing all #13 or #10 to #13#10 in JAD */
756 for (i
=0;i
<File
.Used
;i
++) {
757 switch (File
.Buffer
[i
]) {
761 buffer
[Pos
++] = 0x0D;
762 buffer
[Pos
++] = 0x0A;
764 } else wasclr
= FALSE
;
767 buffer
[Pos
++] = File
.Buffer
[i
];
771 File
.Buffer
= realloc(File
.Buffer
, Pos
);
773 memcpy(File
.Buffer
,buffer
,Pos
);
776 for (j
= 4; j
< argc
; j
++) {
777 if (strcasecmp(argv
[j
],"-overwrite") == 0) Overwrite
= TRUE
;
778 if (strcasecmp(argv
[j
],"-overwriteall") == 0) {
786 if (strstr(DecodeUnicodeString(Files
.ID_FullName
),"d:/predefjava/")== NULL
) {
787 strcpy(buffer
,Vendor
);
789 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
790 CopyUnicodeString(File
.ID_FullName
,Files
.ID_FullName
);
791 error
= GSM_AddFolder(gsm
,&File
);
792 if (Overwrite
&& (error
== ERR_FILEALREADYEXIST
)) {
793 printf_info("%s\n", _("Application already exists. Deleting by Gammu."));
796 CopyUnicodeString(File2
.ID_FullName
,Files
.ID_FullName
);
798 error
= GSM_GetFolderListing(gsm
,&File2
,Start
);
799 if (error
== ERR_EMPTY
) break;
802 if (File2
.Folder
&& !strcmp(DecodeUnicodeString(File2
.Name
),buffer
)) {
810 CopyUnicodeString(File
.ID_FullName
,File2
.ID_FullName
);
812 error
= GSM_GetFolderListing(gsm
,&File2
,Start
);
813 if (error
== ERR_EMPTY
) break;
816 strcpy(buffer
,DecodeUnicodeString(File2
.Name
));
824 strcmp(buffer
+ i
,".jad") == 0 ||
825 strcmp(buffer
+ i
,".jar") == 0) {
826 fprintf(stderr
, _(" Deleting %s\n"),buffer
);
827 error
= GSM_DeleteFile(gsm
,File2
.ID_FullName
);
830 CopyUnicodeString(File2
.ID_FullName
,File
.ID_FullName
);
839 CopyUnicodeString(FileID
,File
.ID_FullName
);
843 CopyUnicodeString(File2
.ID_FullName
,Files
.ID_FullName
);
845 printf_info("%s\n", _("Application already exists. Deleting by Gammu."));
848 error
= GSM_GetFolderListing(gsm
,&File2
,Start
);
849 if (error
== ERR_EMPTY
) break;
852 strcpy(buffer
,DecodeUnicodeString(File2
.Name
));
855 if (strncmp(buffer
,Name
,i
) == 0 &&
856 (strcmp(buffer
+ i
,".jad") == 0 ||
857 strcmp(buffer
+ i
,".jar") == 0 ||
858 (strncmp(buffer
+ i
,"\177_m_",4) == 0 && OverwriteAll
))) {
859 fprintf(stderr
, _(" Deleting %s\n"),buffer
);
860 error
= GSM_DeleteFile(gsm
,File2
.ID_FullName
);
863 CopyUnicodeString(File2
.ID_FullName
,Files
.ID_FullName
);
871 CopyUnicodeString(FileID
,Files
.ID_FullName
);
872 CopyUnicodeString(File
.ID_FullName
,Files
.ID_FullName
);
875 /* adding jad file */
877 buffer
[strlen(buffer
) - 1] = 'd';
878 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
879 File
.Type
= GSM_File_Other
;
880 File
.ModifiedEmpty
= TRUE
;
881 smprintf(gsm
, "file id is \"%s\"\n",DecodeUnicodeString(File
.ID_FullName
));
882 AddOneFile(&File
, _("Writing JAD file:"), FALSE
);
885 for (j
= 4; j
< argc
; j
++) {
886 if (strcasecmp(argv
[j
],"-readonly") == 0) File
.ReadOnly
= TRUE
;
890 /* reading jar file */
891 sprintf(buffer
,"%s.jar",argv
[3]);
892 error
= GSM_ReadFile(buffer
, &File
);
895 /* adding jar file */
896 CopyUnicodeString(File
.ID_FullName
,FileID
);
898 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
899 File
.Type
= GSM_File_Java_JAR
;
900 File
.ModifiedEmpty
= TRUE
;
901 AddOneFile(&File
, _("Writing JAR file:"), FALSE
);
907 if (strcasecmp(argv
[2],"Gallery" ) == 0 ||
908 strcasecmp(argv
[2],"Gallery2" ) == 0 ||
909 strcasecmp(argv
[2],"Camera" ) == 0 ||
910 strcasecmp(argv
[2],"Tones" ) == 0 ||
911 strcasecmp(argv
[2],"Tones2" ) == 0 ||
912 strcasecmp(argv
[2],"Records" ) == 0 ||
913 strcasecmp(argv
[2],"Video" ) == 0 ||
914 strcasecmp(argv
[2],"Playlist" ) == 0 ||
915 strcasecmp(argv
[2],"MemoryCard" ) == 0) {
916 strcpy(buffer
,argv
[3]);
919 for (j
= 4; j
< argc
; j
++) {
922 if (strcasecmp(argv
[j
],"-name") == 0) {
926 if (strcasecmp(argv
[j
],"-protected") == 0) {
927 File
.Protected
= TRUE
;
930 if (strcasecmp(argv
[j
],"-readonly") == 0) {
931 File
.ReadOnly
= TRUE
;
934 if (strcasecmp(argv
[j
],"-hidden") == 0) {
938 if (strcasecmp(argv
[j
],"-system") == 0) {
942 if (strcasecmp(argv
[j
],"-newtime") == 0) {
946 printf(_("Parameter \"%s\" unknown\n"),argv
[j
]);
949 strcpy(buffer
,argv
[j
]);
955 printf_err("%s\n", _("Parameter missing!"));
961 error
= GSM_ReadFile(argv
[3], &File
);
963 if (ModEmpty
) File
.ModifiedEmpty
= TRUE
;
965 CopyUnicodeString(File
.ID_FullName
,Files
.ID_FullName
);
966 EncodeUnicode(File
.Name
,buffer
,strlen(buffer
));
967 for (i
=strlen(buffer
)-1;i
>0;i
--) {
968 if (buffer
[i
] == '\\' || buffer
[i
] == '/') break;
970 if (buffer
[i
] == '\\' || buffer
[i
] == '/') {
971 EncodeUnicode(File
.Name
,buffer
+i
+1,strlen(buffer
)-i
-1);
974 GSM_IdentifyFileFormat(&File
);
976 AddOneFile(&File
, _("Writing file:"), FALSE
);
981 void NokiaGetADC(int argc
, char *argv
[])
985 #ifdef GSM_ENABLE_NOKIA_DCT3
986 if (CheckDCT3Only() != ERR_NOTSUPPORTED
) {
987 DCT3GetADC(argc
,argv
);
990 #ifdef GSM_ENABLE_NOKIA_DCT4
991 if (CheckDCT4Only() != ERR_NOTSUPPORTED
) {
992 DCT4GetADC(argc
, argv
);
999 void NokiaDisplayTest(int argc
, char *argv
[])
1003 #ifdef GSM_ENABLE_NOKIA_DCT3
1004 if (CheckDCT3Only() != ERR_NOTSUPPORTED
) {
1005 DCT3DisplayTest(argc
,argv
);
1008 #ifdef GSM_ENABLE_NOKIA_DCT4
1009 if (CheckDCT4Only() != ERR_NOTSUPPORTED
) {
1010 DCT4DisplayTest(argc
, argv
);
1017 void NokiaGetT9(int argc
, char *argv
[])
1021 #ifdef GSM_ENABLE_NOKIA_DCT3
1022 if (CheckDCT3Only() != ERR_NOTSUPPORTED
) {
1023 DCT3GetT9(argc
,argv
);
1026 #ifdef GSM_ENABLE_NOKIA_DCT4
1027 if (CheckDCT4Only() != ERR_NOTSUPPORTED
) {
1028 DCT4GetT9(argc
, argv
);
1035 void NokiaVibraTest(int argc
, char *argv
[])
1039 #ifdef GSM_ENABLE_NOKIA_DCT3
1040 if (CheckDCT3Only() != ERR_NOTSUPPORTED
) {
1041 DCT3VibraTest(argc
,argv
);
1044 #ifdef GSM_ENABLE_NOKIA_DCT4
1045 if (CheckDCT4Only() != ERR_NOTSUPPORTED
) {
1046 DCT4VibraTest(argc
, argv
);
1054 /* How should editor hadle tabs in this file? Add editor commands here.
1055 * vim: noexpandtab sw=8 ts=8 sts=8: