5 #include "../helper/locales.h"
9 #include "../helper/formats.h"
12 #include "../helper/memory-display.h"
13 #include "../helper/printing.h"
14 #include "../helper/string.h"
17 void GetMMSFolders(int argc UNUSED
, char *argv
[] UNUSED
)
20 GSM_MMSFolders folders
;
25 error
=GSM_GetMMSFolders(gsm
,&folders
);
28 for (i
=0;i
<folders
.Number
;i
++) {
29 printf("%i. \"%s\"",i
+1,DecodeUnicodeConsole(folders
.Folder
[i
].Name
));
30 if (folders
.Folder
[i
].InboxFolder
) printf("%s", _(", Inbox folder"));
37 void DecodeMMSFile(GSM_File
*file
, int num
)
42 GSM_EncodedMultiPartMMSInfo info
;
46 GSM_CalendarEntry Calendar
;
49 if (num
!= -1 && answer_yes("%s", _("Do you want to save this MMS file?"))) {
50 sprintf(buff
,"%i_0",num
);
51 file2
= fopen(buff
,"wb");
52 if (fwrite(file
->Buffer
, 1, file
->Used
, file2
) != file
->Used
) {
53 printf_err(_("Error while saving to file %s!\n"), buff
);
55 printf(_("Saved to file %s\n"),buff
);
60 for (i
=0;i
<GSM_MAX_MULTI_MMS
;i
++) info
.Entries
[i
].File
.Buffer
= NULL
;
61 GSM_ClearMMSMultiPart(&info
);
63 error
= GSM_DecodeMMSFileToMultiPart(GSM_GetDebug(gsm
), file
, &info
);
64 if (error
== ERR_FILENOTSUPPORTED
) {
65 printf_warn("%s\n", _("Some MMS file features unknown for Gammu decoder"));
70 if (UnicodeLength(info
.Source
) != 0) {
71 printf(LISTFORMAT
, _("Sender"));
72 switch (info
.SourceType
) {
73 case MMSADDRESS_PHONE
: printf("%s", _("phone ")); break;
76 printf("%s\n",DecodeUnicodeString(info
.Source
));
78 if (UnicodeLength(info
.Destination
) != 0) {
79 printf(LISTFORMAT
, _("Recipient"));
80 switch (info
.DestinationType
) {
81 case MMSADDRESS_PHONE
: printf("%s", _("phone ")); break;
84 printf("%s\n",DecodeUnicodeString(info
.Destination
));
86 if (UnicodeLength(info
.CC
) != 0) {
87 printf(LISTFORMAT
, _("CC"));
88 switch (info
.CCType
) {
89 case MMSADDRESS_PHONE
: printf("%s", _("phone ")); break;
92 printf("%s\n",DecodeUnicodeString(info
.CC
));
94 printf(LISTFORMAT
"%s\n", _("Message type"), info
.MSGType
);
95 if (info
.DateTimeAvailable
) printf(LISTFORMAT
"%s\n", _("Date"), OSDateTime(info
.DateTime
,0));
96 if (UnicodeLength(info
.Subject
) != 0) {
97 printf(LISTFORMAT
"%s\n", _("Subject"),DecodeUnicodeString(info
.Subject
));
99 if (info
.MMSReportAvailable
) {
100 printf(LISTFORMAT
, _("Delivery report"));
101 if (info
.MMSReport
) {
102 printf("%s\n", _("enabled"));
104 printf("%s\n", _("disabled"));
107 printf(LISTFORMAT
"%s\n", _("Content type"), DecodeUnicodeString(info
.ContentType
));
109 for (i
=0;i
<info
.EntriesNum
;i
++) {
110 printf(LISTFORMAT
"%s\n", _("Content type"), DecodeUnicodeString(info
.Entries
[i
].ContentType
));
111 if (UnicodeLength(info
.Entries
[i
].File
.Name
) != 0) {
112 printf(LISTFORMAT
"%s", _("Name"),DecodeUnicodeString(info
.Entries
[i
].File
.Name
));
113 if (UnicodeLength(info
.Entries
[i
].SMIL
) != 0) {
114 printf(_(" (%s in SMIL)"),DecodeUnicodeString(info
.Entries
[i
].SMIL
));
118 if (!strcmp(DecodeUnicodeString(info
.Entries
[i
].ContentType
),"text/x-vCard")) {
121 error
= GSM_DecodeVCARD(GSM_GetDebug(gsm
), info
.Entries
[i
].File
.Buffer
, &Pos
, &pbk
, Nokia_VCard21
);
122 if (error
== ERR_NONE
) PrintMemoryEntry(&pbk
, gsm
);
124 if (!strcmp(DecodeUnicodeString(info
.Entries
[i
].ContentType
),"text/x-vCalendar")) {
127 error
= GSM_DecodeVCALENDAR_VTODO(GSM_GetDebug(gsm
), info
.Entries
[i
].File
.Buffer
, &Pos
, &Calendar
, &ToDo
, Nokia_VCalendar
, Nokia_VToDo
);
128 if (error
== ERR_NONE
) PrintCalendar(&Calendar
);
130 if (num
!= -1 && answer_yes("%s", _("Do you want to save this attachment?"))) {
131 sprintf(buff
,"%i_%i_%s",num
,i
+1,DecodeUnicodeString(info
.Entries
[i
].File
.Name
));
132 file2
= fopen(buff
,"wb");
133 if (fwrite(info
.Entries
[i
].File
.Buffer
, 1, info
.Entries
[i
].File
.Used
, file2
) != info
.Entries
[i
].File
.Used
) {
134 printf_err(_("Error while saving to file %s!\n"), buff
);
136 printf(_("Saved to file %s\n"),buff
);
143 GSM_ClearMMSMultiPart(&info
);
146 void GetEachMMS(int argc
, char *argv
[])
150 gboolean start
= TRUE
;
151 GSM_MMSFolders folders
;
152 int Handle
,Size
,num
= -1;
155 if (argc
>2 && strcasecmp(argv
[2],"-save") == 0) num
=0;
159 error
=GSM_GetMMSFolders(gsm
,&folders
);
165 error
= GSM_GetNextMMSFileInfo(gsm
,File
.ID_FullName
,&FileFolder
,start
);
166 if (error
== ERR_EMPTY
) break;
170 printf(_("Folder %s\n"),DecodeUnicodeConsole(folders
.Folder
[FileFolder
-1].Name
));
171 printf(LISTFORMAT
"\"%s\"\n", _(" File filesystem ID"),DecodeUnicodeConsole(File
.ID_FullName
));
172 if (File
.Buffer
!= NULL
) {
178 error
= GSM_GetFilePart(gsm
,&File
,&Handle
,&Size
);
179 if (error
== ERR_EMPTY
) break;
181 fprintf(stderr
, "\r");
182 fprintf(stderr
, "%s ", _("Reading:"));
183 fprintf(stderr
, _("%i percent"),
184 (int)(File
.Used
* 100 / Size
));
186 fprintf(stderr
, "%c",13);
188 if (GSM_IsPhoneFeatureAvailable(GSM_GetModelInfo(gsm
), F_SERIES40_30
)) {
189 memmove(File
.Buffer
,File
.Buffer
+176,File
.Used
-176);
191 File
.Buffer
= realloc(File
.Buffer
,File
.Used
);
194 DecodeMMSFile(&File
,num
);
195 if (num
!= -1) num
++;
198 if (File
.Buffer
!= NULL
) free(File
.Buffer
);
203 void ReadMMSFile(int argc
, char *argv
[])
210 error
= GSM_ReadFile(argv
[2], &File
);
213 if (argc
>3 && strcasecmp(argv
[3],"-save") == 0) num
=0;
215 DecodeMMSFile(&File
,num
);
220 /* How should editor hadle tabs in this file? Add editor commands here.
221 * vim: noexpandtab sw=8 ts=8 sts=8: