summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service
Unidiff
Diffstat (limited to 'gammu/emb/common/service') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/backup/backgen.h4
-rw-r--r--gammu/emb/common/service/backup/backtext.c229
-rw-r--r--gammu/emb/common/service/backup/gsmback.c36
-rw-r--r--gammu/emb/common/service/backup/gsmback.h2
-rw-r--r--gammu/emb/common/service/gsmcal.h2
-rw-r--r--gammu/emb/common/service/gsmdata.c124
-rw-r--r--gammu/emb/common/service/gsmdata.h2
-rw-r--r--gammu/emb/common/service/gsmlogo.c47
-rw-r--r--gammu/emb/common/service/gsmlogo.h28
-rw-r--r--gammu/emb/common/service/gsmmisc.h7
-rw-r--r--gammu/emb/common/service/gsmring.c45
-rw-r--r--gammu/emb/common/service/gsmring.h8
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.c5
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.h11
-rw-r--r--gammu/emb/common/service/sms/gsmsms.c5
-rw-r--r--gammu/emb/common/service/sms/gsmsms.h5
16 files changed, 497 insertions, 63 deletions
diff --git a/gammu/emb/common/service/backup/backgen.h b/gammu/emb/common/service/backup/backgen.h
index 9d7d973..9a930fc 100644
--- a/gammu/emb/common/service/backup/backgen.h
+++ b/gammu/emb/common/service/backup/backgen.h
@@ -18,12 +18,14 @@
18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251 18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251
19 #define GSM_BACKUP_MAX_CALLER 6 19 #define GSM_BACKUP_MAX_CALLER 6
20 #define GSM_BACKUP_MAX_SMSC 10 20 #define GSM_BACKUP_MAX_SMSC 10
21 #define GSM_BACKUP_MAX_WAPBOOKMARK40 21 #define GSM_BACKUP_MAX_WAPBOOKMARK40
22 #define GSM_BACKUP_MAX_WAPSETTINGS30 22 #define GSM_BACKUP_MAX_WAPSETTINGS30
23 #define GSM_BACKUP_MAX_MMSSETTINGS30 23 #define GSM_BACKUP_MAX_MMSSETTINGS30
24 #define GSM_BACKUP_MAX_SYNCMLSETTINGS10
25 #define GSM_BACKUP_MAX_CHATSETTINGS10
24 #define GSM_BACKUP_MAX_RINGTONES30 26 #define GSM_BACKUP_MAX_RINGTONES30
25 #define GSM_BACKUP_MAX_PROFILES 10 27 #define GSM_BACKUP_MAX_PROFILES 10
26 #define GSM_BACKUP_MAX_FMSTATIONS20 28 #define GSM_BACKUP_MAX_FMSTATIONS20
27 #define GSM_BACKUP_MAX_GPRSPOINT10 29 #define GSM_BACKUP_MAX_GPRSPOINT10
28 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */ 30 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */
29 31
@@ -40,12 +42,14 @@ typedef struct {
40 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1]; 42 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1];
41 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1]; 43 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1];
42 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1]; 44 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1];
43 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1]; 45 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1];
44 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1]; 46 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1];
45 GSM_MultiWAPSettings *MMSSettings[GSM_BACKUP_MAX_MMSSETTINGS + 1]; 47 GSM_MultiWAPSettings *MMSSettings[GSM_BACKUP_MAX_MMSSETTINGS + 1];
48 GSM_SyncMLSettings*SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1];
49 GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
46 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1]; 50 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1];
47 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1]; 51 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1];
48 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1]; 52 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1];
49 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1]; 53 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1];
50 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1]; 54 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1];
51 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1]; 55 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1];
diff --git a/gammu/emb/common/service/backup/backtext.c b/gammu/emb/common/service/backup/backtext.c
index fee0f73..4cb1bb7 100644
--- a/gammu/emb/common/service/backup/backtext.c
+++ b/gammu/emb/common/service/backup/backtext.c
@@ -148,38 +148,39 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
148 } else { 148 } else {
149 if (UseUnicode) { 149 if (UseUnicode) {
150 sprintf(buffer,"%s = \"",myname); 150 sprintf(buffer,"%s = \"",myname);
151 EncodeUnicode(buffer2,buffer,strlen(buffer)); 151 EncodeUnicode(buffer2,buffer,strlen(buffer));
152 fwrite(buffer2,1,strlen(buffer)*2,file); 152 fwrite(buffer2,1,strlen(buffer)*2,file);
153 153
154 fwrite(myvalue,1,UnicodeLength(myvalue)*2,file); 154 fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
155 155
156 sprintf(buffer,"\"%c%c",13,10); 156 sprintf(buffer,"\"%c%c",13,10);
157 EncodeUnicode(buffer2,buffer,strlen(buffer)); 157 EncodeUnicode(buffer2,buffer,strlen(buffer));
158 fwrite(buffer2,1,strlen(buffer)*2,file); 158 fwrite(buffer2,1,strlen(buffer)*2,file);
159 } else { 159 } else {
160 sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10); 160 sprintf(buffer,"%s = \"%s\"%c%c",myname,EncodeSpecialChars(DecodeUnicodeString(myvalue)),13,10);
161 fprintf(file,"%s",buffer); 161 fprintf(file,"%s",buffer);
162 162
163 EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2); 163 EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2);
164 fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10); 164 fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10);
165 } 165 }
166 } 166 }
167} 167}
168 168
169static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) 169static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode)
170{ 170{
171 unsigned char paramname[10000],*readvalue; 171 unsigned char paramname[10000],*readvalue;
172 172
173 if (UseUnicode) { 173 if (UseUnicode) {
174 EncodeUnicode(paramname,myname,strlen(myname)); 174 EncodeUnicode(paramname,myname,strlen(myname));
175 readvalue = INI_GetValue(file_info, section, paramname, UseUnicode); 175 readvalue = INI_GetValue(file_info, section, paramname, UseUnicode);
176 if (readvalue!=NULL) { 176 if (readvalue!=NULL) {
177 CopyUnicodeString(myvalue,readvalue+2); 177 CopyUnicodeString(myvalue,DecodeUnicodeSpecialChars(readvalue+2));
178 myvalue[UnicodeLength(readvalue)*2-4]=0; 178 myvalue[UnicodeLength(myvalue)*2-2]=0;
179 myvalue[UnicodeLength(readvalue)*2-3]=0; 179 myvalue[UnicodeLength(myvalue)*2-1]=0;
180
180 dbgprintf("%s\n",DecodeUnicodeString(readvalue)); 181 dbgprintf("%s\n",DecodeUnicodeString(readvalue));
181 } else { 182 } else {
182 myvalue[0]=0; 183 myvalue[0]=0;
183 myvalue[1]=0; 184 myvalue[1]=0;
184 return false; 185 return false;
185 } 186 }
@@ -194,13 +195,13 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
194 myvalue[strlen(readvalue)/2+1]=0; 195 myvalue[strlen(readvalue)/2+1]=0;
195 dbgprintf("%s\n",DecodeUnicodeString(myvalue)); 196 dbgprintf("%s\n",DecodeUnicodeString(myvalue));
196 } else { 197 } else {
197 strcpy(paramname,myname); 198 strcpy(paramname,myname);
198 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); 199 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
199 if (readvalue!=NULL) { 200 if (readvalue!=NULL) {
200 EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2); 201 EncodeUnicode(myvalue,DecodeSpecialChars(readvalue+1),strlen(DecodeSpecialChars(readvalue+1))-1);
201 } else { 202 } else {
202 myvalue[0]=0; 203 myvalue[0]=0;
203 myvalue[1]=0; 204 myvalue[1]=0;
204 return false; 205 return false;
205 } 206 }
206 } 207 }
@@ -415,12 +416,23 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
415 } 416 }
416 } 417 }
417 sprintf(buffer,"%c%c",13,10); 418 sprintf(buffer,"%c%c",13,10);
418 SaveBackupText(file, "", buffer, UseUnicode); 419 SaveBackupText(file, "", buffer, UseUnicode);
419} 420}
420 421
422static void SaveNoteEntry(FILE *file, GSM_NoteEntry *Note, bool UseUnicode)
423{
424 char buffer[1000];
425
426 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
427 SaveBackupText(file, "", buffer, UseUnicode);
428 SaveBackupText(file, "Text", Note->Text, UseUnicode);
429 sprintf(buffer, "%c%c",13,10);
430 SaveBackupText(file, "", buffer, UseUnicode);
431}
432
421static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode) 433static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode)
422{ 434{
423 int i; 435 int i;
424 charbuffer[1000]; 436 charbuffer[1000];
425 437
426 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10); 438 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
@@ -430,15 +442,15 @@ static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnico
430 case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break; 442 case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break;
431 case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break; 443 case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break;
432 case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break; 444 case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break;
433 case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break; 445 case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break;
434 case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break; 446 case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break;
435 case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break; 447 case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break;
436 case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break; 448 case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
437 case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break; 449 case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break;
438 case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break; 450 case GSM_CAL_DAILY_ALARM: sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
439 case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break; 451 case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break;
440 case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break; 452 case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break;
441 case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break; 453 case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break;
442 case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break; 454 case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break;
443 case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break; 455 case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break;
444 case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break; 456 case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break;
@@ -654,12 +666,54 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
654 } 666 }
655 sprintf(buffer,"%c%c",13,10); 667 sprintf(buffer,"%c%c",13,10);
656 SaveBackupText(file, "", buffer, UseUnicode); 668 SaveBackupText(file, "", buffer, UseUnicode);
657 } 669 }
658} 670}
659 671
672static void SaveChatSettingsEntry(FILE *file, GSM_ChatSettings *settings, bool UseUnicode)
673{
674 char buffer[10000];
675
676 sprintf(buffer,"HomePage");
677 SaveBackupText(file, buffer, settings->HomePage, UseUnicode);
678 sprintf(buffer,"User");
679 SaveBackupText(file, buffer, settings->User, UseUnicode);
680 sprintf(buffer,"Password");
681 SaveBackupText(file, buffer, settings->Password, UseUnicode);
682 SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
683}
684
685static void SaveSyncMLSettingsEntry(FILE *file, GSM_SyncMLSettings *settings, bool UseUnicode)
686{
687 char buffer[10000];
688
689 sprintf(buffer,"User");
690 SaveBackupText(file, buffer, settings->User, UseUnicode);
691 sprintf(buffer,"Password");
692 SaveBackupText(file, buffer, settings->Password, UseUnicode);
693 sprintf(buffer,"PhonebookDB");
694 SaveBackupText(file, buffer, settings->PhonebookDataBase, UseUnicode);
695 sprintf(buffer,"CalendarDB");
696 SaveBackupText(file, buffer, settings->CalendarDataBase, UseUnicode);
697 sprintf(buffer,"Server");
698 SaveBackupText(file, buffer, settings->Server, UseUnicode);
699 if (settings->SyncPhonebook) {
700 sprintf(buffer,"SyncPhonebook = True%c%c",13,10);
701 } else {
702 sprintf(buffer,"SyncPhonebook = False%c%c",13,10);
703 }
704 SaveBackupText(file, "", buffer, UseUnicode);
705 if (settings->SyncCalendar) {
706 sprintf(buffer,"SyncCalendar = True%c%c",13,10);
707 } else {
708 sprintf(buffer,"SyncCalendar = False%c%c",13,10);
709 }
710 SaveBackupText(file, "", buffer, UseUnicode);
711 SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
712}
713
660static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) 714static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
661{ 715{
662 unsigned char buffer[10000],buffer2[10000]; 716 unsigned char buffer[10000],buffer2[10000];
663 int x,y; 717 int x,y;
664 718
665 sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10); 719 sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10);
@@ -761,29 +815,30 @@ static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode)
761 sprintf(buffer,"%c%c%c%c",13,10,13,10); 815 sprintf(buffer,"%c%c%c%c",13,10,13,10);
762 SaveBackupText(file, "", buffer, UseUnicode); 816 SaveBackupText(file, "", buffer, UseUnicode);
763} 817}
764 818
765static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode) 819static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode)
766{ 820{
767 unsigned char buffer[45000]; 821 unsigned char buffer[45000];
768 int i,j;
769 822
770 sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10); 823 sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10);
771 SaveBackupText(file, "", buffer, UseUnicode); 824 SaveBackupText(file, "", buffer, UseUnicode);
772 SaveBackupText(file, "Name", ringtone->Name, UseUnicode); 825 SaveBackupText(file, "Name", ringtone->Name, UseUnicode);
773 switch (ringtone->Format) { 826 switch (ringtone->Format) {
774 case RING_NOKIABINARY: 827 case RING_NOKIABINARY:
775 j = 0; i = 0;
776 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); 828 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
777 SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode); 829 SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode);
778 break; 830 break;
779 case RING_MIDI: 831 case RING_MIDI:
780 j = 0; i = 0;
781 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); 832 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
782 SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode); 833 SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode);
783 break; 834 break;
835 case RING_MMF:
836 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
837 SaveLinkedBackupText(file, "SMAF", buffer, UseUnicode);
838 break;
784 case RING_NOTETONE: 839 case RING_NOTETONE:
785 break; 840 break;
786 } 841 }
787 sprintf(buffer,"%c%c",13,10); 842 sprintf(buffer,"%c%c",13,10);
788 SaveBackupText(file, "", buffer, UseUnicode); 843 SaveBackupText(file, "", buffer, UseUnicode);
789} 844}
@@ -1072,12 +1127,19 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
1072 sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10); 1127 sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10);
1073 SaveBackupText(file, "", buffer, UseUnicode); 1128 SaveBackupText(file, "", buffer, UseUnicode);
1074 SaveCalendarEntry(file, backup->Calendar[i], UseUnicode); 1129 SaveCalendarEntry(file, backup->Calendar[i], UseUnicode);
1075 i++; 1130 i++;
1076 } 1131 }
1077 i=0; 1132 i=0;
1133 while (backup->Note[i]!=NULL) {
1134 sprintf(buffer,"[Note%03i]%c%c",i+1,13,10);
1135 SaveBackupText(file, "", buffer, UseUnicode);
1136 SaveNoteEntry(file, backup->Note[i], UseUnicode);
1137 i++;
1138 }
1139 i=0;
1078 while (backup->CallerLogos[i]!=NULL) { 1140 while (backup->CallerLogos[i]!=NULL) {
1079 sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10); 1141 sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10);
1080 SaveBackupText(file, "", buffer, UseUnicode); 1142 SaveBackupText(file, "", buffer, UseUnicode);
1081 SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode); 1143 SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode);
1082 i++; 1144 i++;
1083 } 1145 }
@@ -1107,12 +1169,26 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
1107 sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10); 1169 sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10);
1108 SaveBackupText(file, "", buffer, UseUnicode); 1170 SaveBackupText(file, "", buffer, UseUnicode);
1109 SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode); 1171 SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode);
1110 i++; 1172 i++;
1111 } 1173 }
1112 i=0; 1174 i=0;
1175 while (backup->SyncMLSettings[i]!=NULL) {
1176 sprintf(buffer,"[SyncMLSettings%03i]%c%c",i+1,13,10);
1177 SaveBackupText(file, "", buffer, UseUnicode);
1178 SaveSyncMLSettingsEntry(file, backup->SyncMLSettings[i], UseUnicode);
1179 i++;
1180 }
1181 i=0;
1182 while (backup->ChatSettings[i]!=NULL) {
1183 sprintf(buffer,"[ChatSettings%03i]%c%c",i+1,13,10);
1184 SaveBackupText(file, "", buffer, UseUnicode);
1185 SaveChatSettingsEntry(file, backup->ChatSettings[i], UseUnicode);
1186 i++;
1187 }
1188 i=0;
1113 while (backup->Ringtone[i]!=NULL) { 1189 while (backup->Ringtone[i]!=NULL) {
1114 sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10); 1190 sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10);
1115 SaveBackupText(file, "", buffer, UseUnicode); 1191 SaveBackupText(file, "", buffer, UseUnicode);
1116 SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode); 1192 SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode);
1117 i++; 1193 i++;
1118 } 1194 }
@@ -2653,13 +2729,138 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
2653 num++; 2729 num++;
2654 } 2730 }
2655 } 2731 }
2656 if (backup->MD5Original[0]!=0) { 2732 if (backup->MD5Original[0]!=0) {
2657 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated); 2733 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated);
2658 } 2734 }
2659 2735 for (h = file_info; h != NULL; h = h->Next) {
2736 found = false;
2737 if (UseUnicode) {
2738 EncodeUnicode(buffer,"Backup",4);
2739 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2740 } else {
2741 if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
2742 }
2743 if (UseUnicode) {
2744 EncodeUnicode(buffer,"Checksum",4);
2745 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2746 } else {
2747 if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
2748 }
2749 if (UseUnicode) {
2750 EncodeUnicode(buffer,"Profile",7);
2751 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2752 } else {
2753 if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
2754 }
2755 if (UseUnicode) {
2756 EncodeUnicode(buffer,"PhonePBK",8);
2757 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2758 } else {
2759 if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
2760 }
2761 if (UseUnicode) {
2762 EncodeUnicode(buffer,"SIMPBK",6);
2763 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2764 } else {
2765 if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
2766 }
2767 if (UseUnicode) {
2768 EncodeUnicode(buffer,"Calendar",8);
2769 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2770 } else {
2771 if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
2772 }
2773 if (UseUnicode) {
2774 EncodeUnicode(buffer,"Caller",6);
2775 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2776 } else {
2777 if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
2778 }
2779 if (UseUnicode) {
2780 EncodeUnicode(buffer,"SMSC",4);
2781 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2782 } else {
2783 if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
2784 }
2785 if (UseUnicode) {
2786 EncodeUnicode(buffer,"WAPBookmark",11);
2787 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2788 if (!found) {
2789 EncodeUnicode(buffer,"Bookmark",8);
2790 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2791 }
2792 } else {
2793 if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
2794 if (!found) {
2795 if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
2796 }
2797 }
2798 if (UseUnicode) {
2799 EncodeUnicode(buffer,"WAPSettings",11);
2800 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2801 if (!found) {
2802 EncodeUnicode(buffer,"Settings",8);
2803 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2804 }
2805 } else {
2806 if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
2807 if (!found) {
2808 if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
2809 }
2810 }
2811 if (UseUnicode) {
2812 EncodeUnicode(buffer,"MMSSettings",8);
2813 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2814 } else {
2815 if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
2816 }
2817 if (UseUnicode) {
2818 EncodeUnicode(buffer,"Ringtone",8);
2819 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2820 } else {
2821 if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
2822 }
2823 if (UseUnicode) {
2824 EncodeUnicode(buffer,"TODO",4);
2825 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2826 } else {
2827 if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
2828 }
2829 if (UseUnicode) {
2830 EncodeUnicode(buffer,"Startup",7);
2831 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2832 } else {
2833 if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
2834 }
2835 if (UseUnicode) {
2836 EncodeUnicode(buffer,"Operator",7);
2837 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2838 } else {
2839 if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
2840 }
2841 if (UseUnicode) {
2842 EncodeUnicode(buffer,"FMStation",9);
2843 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2844 } else {
2845 if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
2846 }
2847 if (UseUnicode) {
2848 EncodeUnicode(buffer,"GPRSPoint",9);
2849 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2850 } else {
2851 if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
2852 }
2853 if (UseUnicode) {
2854 EncodeUnicode(buffer,"Note",4);
2855 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2856 } else {
2857 if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
2858 }
2859 if (!found) return ERR_NOTIMPLEMENTED;
2860 }
2660 return ERR_NONE; 2861 return ERR_NONE;
2661} 2862}
2662 2863
2663/* ---------------------- backup files for SMS ----------------------------- */ 2864/* ---------------------- backup files for SMS ----------------------------- */
2664 2865
2665static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS) 2866static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS)
diff --git a/gammu/emb/common/service/backup/gsmback.c b/gammu/emb/common/service/backup/gsmback.c
index 91ac745..c94a4d2 100644
--- a/gammu/emb/common/service/backup/gsmback.c
+++ b/gammu/emb/common/service/backup/gsmback.c
@@ -70,12 +70,24 @@ void GSM_FreeBackup(GSM_Backup *backup)
70 while (backup->MMSSettings[i]!=NULL) { 70 while (backup->MMSSettings[i]!=NULL) {
71 free(backup->MMSSettings[i]); 71 free(backup->MMSSettings[i]);
72 backup->MMSSettings[i] = NULL; 72 backup->MMSSettings[i] = NULL;
73 i++; 73 i++;
74 } 74 }
75 i=0; 75 i=0;
76 while (backup->SyncMLSettings[i]!=NULL) {
77 free(backup->SyncMLSettings[i]);
78 backup->SyncMLSettings[i] = NULL;
79 i++;
80 }
81 i=0;
82 while (backup->ChatSettings[i]!=NULL) {
83 free(backup->ChatSettings[i]);
84 backup->ChatSettings[i] = NULL;
85 i++;
86 }
87 i=0;
76 while (backup->Ringtone[i]!=NULL) { 88 while (backup->Ringtone[i]!=NULL) {
77 free(backup->Ringtone[i]); 89 free(backup->Ringtone[i]);
78 backup->Ringtone[i] = NULL; 90 backup->Ringtone[i] = NULL;
79 i++; 91 i++;
80 } 92 }
81 i=0; 93 i=0;
@@ -117,21 +129,21 @@ void GSM_FreeBackup(GSM_Backup *backup)
117 i++; 129 i++;
118 } 130 }
119} 131}
120 132
121GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode) 133GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode)
122{ 134{
123 if (strstr(FileName,".lmb")) { 135 if (mystrcasestr(FileName,".lmb")) {
124 return SaveLMB(FileName,backup); 136 return SaveLMB(FileName,backup);
125 } else if (strstr(FileName,".vcs")) { 137 } else if (mystrcasestr(FileName,".vcs")) {
126 return SaveVCalendar(FileName,backup); 138 return SaveVCalendar(FileName,backup);
127 } else if (strstr(FileName,".vcf")) { 139 } else if (mystrcasestr(FileName,".vcf")) {
128 return SaveVCard(FileName,backup); 140 return SaveVCard(FileName,backup);
129 } else if (strstr(FileName,".ldif")) { 141 } else if (mystrcasestr(FileName,".ldif")) {
130 return SaveLDIF(FileName,backup); 142 return SaveLDIF(FileName,backup);
131 } else if (strstr(FileName,".ics")) { 143 } else if (mystrcasestr(FileName,".ics")) {
132 return SaveICS(FileName,backup); 144 return SaveICS(FileName,backup);
133 } else { 145 } else {
134 return SaveBackup(FileName,backup, UseUnicode); 146 return SaveBackup(FileName,backup, UseUnicode);
135 } 147 }
136} 148}
137 149
@@ -145,19 +157,19 @@ GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
145 fread(buffer, 1, 9, file); /* Read the header of the file. */ 157 fread(buffer, 1, 9, file); /* Read the header of the file. */
146 fclose(file); 158 fclose(file);
147 159
148 GSM_ClearBackup(backup); 160 GSM_ClearBackup(backup);
149 161
150 /* Attempt to identify filetype */ 162 /* Attempt to identify filetype */
151 if (strstr(FileName,".vcs")) { 163 if (mystrcasestr(FileName,".vcs")) {
152 return LoadVCalendar(FileName,backup); 164 return LoadVCalendar(FileName,backup);
153 } else if (strstr(FileName,".vcf")) { 165 } else if (mystrcasestr(FileName,".vcf")) {
154 return LoadVCard(FileName,backup); 166 return LoadVCard(FileName,backup);
155 } else if (strstr(FileName,".ldif")) { 167 } else if (mystrcasestr(FileName,".ldif")) {
156 return LoadLDIF(FileName,backup); 168 return LoadLDIF(FileName,backup);
157 } else if (strstr(FileName,".ics")) { 169 } else if (mystrcasestr(FileName,".ics")) {
158 return LoadICS(FileName,backup); 170 return LoadICS(FileName,backup);
159 } else if (memcmp(buffer, "LMB ",4)==0) { 171 } else if (memcmp(buffer, "LMB ",4)==0) {
160 return LoadLMB(FileName,backup); 172 return LoadLMB(FileName,backup);
161 } else if (buffer[0] == 0xFE && buffer[1] == 0xFF) { 173 } else if (buffer[0] == 0xFE && buffer[1] == 0xFF) {
162 return LoadBackup(FileName,backup,true); 174 return LoadBackup(FileName,backup,true);
163 } else if (buffer[0] == 0xFF && buffer[1] == 0xFE) { 175 } else if (buffer[0] == 0xFF && buffer[1] == 0xFE) {
@@ -174,12 +186,14 @@ void GSM_ClearBackup(GSM_Backup *backup)
174 backup->Calendar[0] = NULL; 186 backup->Calendar[0] = NULL;
175 backup->CallerLogos[0] = NULL; 187 backup->CallerLogos[0] = NULL;
176 backup->SMSC [0] = NULL; 188 backup->SMSC [0] = NULL;
177 backup->WAPBookmark[0] = NULL; 189 backup->WAPBookmark[0] = NULL;
178 backup->WAPSettings[0] = NULL; 190 backup->WAPSettings[0] = NULL;
179 backup->MMSSettings[0] = NULL; 191 backup->MMSSettings[0] = NULL;
192 backup->SyncMLSettings[0] = NULL;
193 backup->ChatSettings[0] = NULL;
180 backup->Ringtone[0] = NULL; 194 backup->Ringtone[0] = NULL;
181 backup->Profiles[0] = NULL; 195 backup->Profiles[0] = NULL;
182 backup->ToDo [0] = NULL; 196 backup->ToDo [0] = NULL;
183 backup->GPRSPoint[0] = NULL; 197 backup->GPRSPoint[0] = NULL;
184 backup->FMStation[0] = NULL; 198 backup->FMStation[0] = NULL;
185 backup->Note [0] = NULL; 199 backup->Note [0] = NULL;
@@ -206,12 +220,14 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
206 info->Calendar = false; 220 info->Calendar = false;
207 info->CallerLogos = false; 221 info->CallerLogos = false;
208 info->SMSC = false; 222 info->SMSC = false;
209 info->WAPBookmark = false; 223 info->WAPBookmark = false;
210 info->WAPSettings = false; 224 info->WAPSettings = false;
211 info->MMSSettings = false; 225 info->MMSSettings = false;
226 info->SyncMLSettings = false;
227 info->ChatSettings = false;
212 info->Ringtone = false; 228 info->Ringtone = false;
213 info->StartupLogo = false; 229 info->StartupLogo = false;
214 info->OperatorLogo = false; 230 info->OperatorLogo = false;
215 info->Profiles = false; 231 info->Profiles = false;
216 info->FMStation = false; 232 info->FMStation = false;
217 info->GPRSPoint = false; 233 info->GPRSPoint = false;
@@ -243,12 +259,14 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
243 info->Calendar = true; 259 info->Calendar = true;
244 info->CallerLogos = true; 260 info->CallerLogos = true;
245 info->SMSC = true; 261 info->SMSC = true;
246 info->WAPBookmark = true; 262 info->WAPBookmark = true;
247 info->WAPSettings = true; 263 info->WAPSettings = true;
248 info->MMSSettings = true; 264 info->MMSSettings = true;
265 info->SyncMLSettings = true;
266 info->ChatSettings = true;
249 info->Ringtone = true; 267 info->Ringtone = true;
250 info->StartupLogo = true; 268 info->StartupLogo = true;
251 info->OperatorLogo = true; 269 info->OperatorLogo = true;
252 info->Profiles = true; 270 info->Profiles = true;
253 info->FMStation = true; 271 info->FMStation = true;
254 info->GPRSPoint = true; 272 info->GPRSPoint = true;
diff --git a/gammu/emb/common/service/backup/gsmback.h b/gammu/emb/common/service/backup/gsmback.h
index 1fd99b0..791e81d 100644
--- a/gammu/emb/common/service/backup/gsmback.h
+++ b/gammu/emb/common/service/backup/gsmback.h
@@ -26,12 +26,14 @@ typedef struct {
26 bool CallerLogos; 26 bool CallerLogos;
27 bool SMSC; 27 bool SMSC;
28 bool WAPBookmark; 28 bool WAPBookmark;
29 bool Profiles; 29 bool Profiles;
30 bool WAPSettings; 30 bool WAPSettings;
31 bool MMSSettings; 31 bool MMSSettings;
32 bool SyncMLSettings;
33 bool ChatSettings;
32 bool Ringtone; 34 bool Ringtone;
33 bool StartupLogo; 35 bool StartupLogo;
34 bool OperatorLogo; 36 bool OperatorLogo;
35 bool FMStation; 37 bool FMStation;
36 bool GPRSPoint; 38 bool GPRSPoint;
37 bool Note; 39 bool Note;
diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h
index 067a4a4..0a41b7b 100644
--- a/gammu/emb/common/service/gsmcal.h
+++ b/gammu/emb/common/service/gsmcal.h
@@ -402,13 +402,13 @@ typedef struct {
402} GSM_ToDoStatus; 402} GSM_ToDoStatus;
403 403
404/* --------------------------- note ---------------------------------------- */ 404/* --------------------------- note ---------------------------------------- */
405 405
406typedef struct { 406typedef struct {
407 int Location; 407 int Location;
408 char Text[100]; 408 char Text[3000*2];
409} GSM_NoteEntry; 409} GSM_NoteEntry;
410 410
411GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); 411GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note);
412 412
413/* --------------------------- alarm --------------------------------------- */ 413/* --------------------------- alarm --------------------------------------- */
414 414
diff --git a/gammu/emb/common/service/gsmdata.c b/gammu/emb/common/service/gsmdata.c
index 94e9b7b..9303b57 100644
--- a/gammu/emb/common/service/gsmdata.c
+++ b/gammu/emb/common/service/gsmdata.c
@@ -243,59 +243,137 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W
243 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title)); 243 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title));
244 Buffer[(*Length)++] = 0x01; //END PARMeter 244 Buffer[(*Length)++] = 0x01; //END PARMeter
245 Buffer[(*Length)++] = 0x01; //END PARMeter 245 Buffer[(*Length)++] = 0x01; //END PARMeter
246} 246}
247 247
248/* http://forum.nokia.com: OTA Settings 7.0 */ 248/* http://forum.nokia.com: OTA Settings 7.0 */
249/* first it used default/ISO coding */
250/* Joergen Thomsen changed to UTF8 */
249void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark) 251void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark)
250{ 252{
251 unsigned charbuffer[100]; 253 unsigned charbuffer[100];
252 bool UnicodeCoding = false;
253 254
254 EncodeUTF8QuotedPrintable(buffer,bookmark->Title); 255 // bool UnicodeCoding = false;
255 if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true; 256 //EncodeUTF8QuotedPrintable(buffer,bookmark->Title);
257 //if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true;
256 258
257 Buffer[(*Length)++] = 0x01; //Push ID 259 Buffer[(*Length)++] = 0x01; //Push ID
258 Buffer[(*Length)++] = 0x06; //PDU Type (push) 260 Buffer[(*Length)++] = 0x06; //PDU Type (push)
259 Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers) 261 Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers)
260 strcpy(Buffer+(*Length),"\x1F\x2B"); 262 strcpy(Buffer+(*Length),"\x1F\x2B");
261 (*Length)=(*Length)+2; //Value length 263 (*Length)=(*Length)+2; //Value length
262 strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks"); 264 strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks");
263 (*Length)=(*Length)+40; //MIME-Type 265 (*Length)=(*Length)+40; //MIME-Type
264 Buffer[(*Length)++] = 0x00; //end inline string 266 Buffer[(*Length)++] = 0x00; //end inline string
265 strcpy(Buffer+(*Length),"\x81\xEA"); 267 strcpy(Buffer+(*Length),"\x81\xEA");
266 (*Length)=(*Length)+2; //charset UTF-8 short int. 268 (*Length)=(*Length)+2; //charset UTF-8 short int.
267 269
270 /* removed by Joergen Thomsen */
268 /* Block from sniffs. UNKNOWN */ 271 /* Block from sniffs. UNKNOWN */
269 if (!UnicodeCoding) { 272 //if (!UnicodeCoding) {
270 Buffer[(*Length)++] = 0x00; 273 // Buffer[(*Length)++] = 0x00;
271 Buffer[(*Length)++] = 0x01; 274 // Buffer[(*Length)++] = 0x01;
272 } else { 275 //} else {
273 strcpy(Buffer+(*Length),"\x01\x01\x87\x68"); 276 // strcpy(Buffer+(*Length),"\x01\x01\x87\x68");
274 (*Length)=(*Length)+4; 277 // (*Length)=(*Length)+4;
275 } 278 //}
276 Buffer[(*Length)++] = 0x00; 279 //Buffer[(*Length)++] = 0x00;
280
281 /* added by Joergen Thomsen */
282 Buffer[(*Length)++] = 0x01; // Version WBXML 1.1
283 Buffer[(*Length)++] = 0x01; // Unknown public identifier
284 Buffer[(*Length)++] = 0x6A; // charset UTF-8
285 Buffer[(*Length)++] = 0x00; // string table length
277 286
278 Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content 287 Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content
279 /* URL */ 288 /* URL */
280 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes 289 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes
281 Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK 290 Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK
282 Buffer[(*Length)++] = 0x01; //END PARMeter 291 Buffer[(*Length)++] = 0x01; //END PARMeter
283 if (!UnicodeCoding) { 292
284 /* TITLE */ 293 /* removed by Joergen Thomsen */
285 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title)); 294 // if (!UnicodeCoding) {
286 /* URL */ 295 // /* TITLE */
287 AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address)); 296 // AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title));
288 } else { 297 // /* URL */
289 /* TITLE */ 298 // AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address));
290 AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1); 299 // } else {
291 /* URL */ 300 // /* TITLE */
292 AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1); 301 // AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1);
302 // /* URL */
303 // AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1);
304 // }
305
306 /* added by Joergen Thomsen */
307 /* TITLE */
308 EncodeUTF8(buffer, bookmark->Title);
309 AddWAPSMSParameterText(Buffer, Length, 0x15, buffer, strlen(buffer));
310 /* URL */
311 EncodeUTF8(buffer, bookmark->Address);
312 AddWAPSMSParameterText(Buffer, Length, 0x17, buffer, strlen(buffer));
313
314 Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC)
315 Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC-LIST)
316}
317
318void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL)
319{
320 int i;
321
322 Buffer[(*Length)++] = 0x01; //Push ID
323 Buffer[(*Length)++] = 0x06; //PDU Type (push)
324 Buffer[(*Length)++] = 28; //Headers length (content type + headers)
325 strcpy(Buffer+(*Length),"\x1F\x23");
326 (*Length)=(*Length)+2; //Value length
327 strcpy(Buffer+(*Length),"application/vnd.wap.sic");
328 (*Length)=(*Length)+23; //MIME-Type
329 Buffer[(*Length)++] = 0x00; //end inline string
330 strcpy(Buffer+(*Length),"\x81\xEA");
331 (*Length)=(*Length)+2; //charset UTF-8 short int.
332
333 Buffer[(*Length)++] = 0x02; // WBXML 1.2
334 Buffer[(*Length)++] = 0x05; // SI 1.0 Public Identifier
335 Buffer[(*Length)++] = 0x6A; // charset UTF-8
336 Buffer[(*Length)++] = 0x00; // string table length
337 Buffer[(*Length)++] = 0x45; // SI with content
338 Buffer[(*Length)++] = 0xC6; // indication with content and attributes
339 Buffer[(*Length)++] = 0x0B;// address
340 Buffer[(*Length)++] = 0x03; // Inline string
341 for (i=0;i<(int)strlen(URL);i++) {
342 Buffer[(*Length)++] = URL[i];//Text
293 } 343 }
294 Buffer[(*Length)++] = 0x01; //END PARMeter 344 Buffer[(*Length)++] = 0x00; // END Inline string
295 Buffer[(*Length)++] = 0x01; //END PARMeter 345
346#ifdef XXX
347 Buffer[(*Length)++] = 0x0A;// created...
348 Buffer[(*Length)++] = 0xC3;// OPAQUE
349 Buffer[(*Length)++] = 0x07;// length
350 Buffer[(*Length)++] = 0x19;// year
351 Buffer[(*Length)++] = 0x80;// year
352 Buffer[(*Length)++] = 0x21;// month
353 Buffer[(*Length)++] = 0x12;// ..
354 Buffer[(*Length)++] = 0x00;// ..
355 Buffer[(*Length)++] = 0x00;// ..
356 Buffer[(*Length)++] = 0x00;// ..
357 Buffer[(*Length)++] = 0x10;// expires
358 Buffer[(*Length)++] = 0xC3;// OPAQUE
359 Buffer[(*Length)++] = 0x04;// length
360 Buffer[(*Length)++] = 0x20;// year
361 Buffer[(*Length)++] = 0x10;// year
362 Buffer[(*Length)++] = 0x06;// month
363 Buffer[(*Length)++] = 0x25;// day
364#endif
365
366 Buffer[(*Length)++] = 0x01; // END (indication)
367 Buffer[(*Length)++] = 0x03; // Inline string
368 for (i=0;i<(int)strlen(Text);i++) {
369 Buffer[(*Length)++] = Text[i];//Text
370 }
371 Buffer[(*Length)++] = 0x00; // END Inline string
372 Buffer[(*Length)++] = 0x01; // END (indication)
373 Buffer[(*Length)++] = 0x01; // END (SI)
296} 374}
297 375
298void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length) 376void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length)
299{ 377{
300 int i; 378 int i;
301 379
diff --git a/gammu/emb/common/service/gsmdata.h b/gammu/emb/common/service/gsmdata.h
index f5f8e07..e81589f 100644
--- a/gammu/emb/common/service/gsmdata.h
+++ b/gammu/emb/common/service/gsmdata.h
@@ -85,12 +85,14 @@ typedef struct {
85 unsigned char Title[200]; 85 unsigned char Title[200];
86 unsigned char Sender[200]; 86 unsigned char Sender[200];
87} GSM_MMSIndicator; 87} GSM_MMSIndicator;
88 88
89void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator); 89void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator);
90 90
91void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL);
92
91/* ------------------------------ MMS file --------------------------------- */ 93/* ------------------------------ MMS file --------------------------------- */
92 94
93#define MAX_MULTI_MMS 20 95#define MAX_MULTI_MMS 20
94 96
95typedef enum { 97typedef enum {
96 MMS_Text = 1, 98 MMS_Text = 1,
diff --git a/gammu/emb/common/service/gsmlogo.c b/gammu/emb/common/service/gsmlogo.c
index c992915..7c19967 100644
--- a/gammu/emb/common/service/gsmlogo.c
+++ b/gammu/emb/common/service/gsmlogo.c
@@ -1,10 +1,11 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2 2
3#include <string.h> 3#include <string.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <sys/stat.h>
5 6
6#include "../misc/misc.h" 7#include "../misc/misc.h"
7#include "../misc/coding/coding.h" 8#include "../misc/coding/coding.h"
8#include "gsmlogo.h" 9#include "gsmlogo.h"
9#include "gsmnet.h" 10#include "gsmnet.h"
10 11
@@ -158,12 +159,13 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B
158 Bitmap->DefaultRingtone = false; 159 Bitmap->DefaultRingtone = false;
159 Bitmap->RingtoneID = 0; 160 Bitmap->RingtoneID = 0;
160 Bitmap->NetworkCode[0] = 0; 161 Bitmap->NetworkCode[0] = 0;
161 Bitmap->Sender[0] = 0; 162 Bitmap->Sender[0] = 0;
162 Bitmap->Sender[1] = 0; 163 Bitmap->Sender[1] = 0;
163 Bitmap->ID = 0; 164 Bitmap->ID = 0;
165 Bitmap->Name = NULL;
164 166
165 GSM_ClearBitmap(Bitmap); 167 GSM_ClearBitmap(Bitmap);
166 for (x=0;x<Bitmap->BitmapWidth;x++) { 168 for (x=0;x<Bitmap->BitmapWidth;x++) {
167 for (y=0;y<Bitmap->BitmapHeight;y++) { 169 for (y=0;y<Bitmap->BitmapHeight;y++) {
168 if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) { 170 if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) {
169 GSM_SetPointBitmap(Bitmap,x,y); 171 GSM_SetPointBitmap(Bitmap,x,y);
@@ -623,23 +625,23 @@ GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
623 GSM_Error error=ERR_NONE; 625 GSM_Error error=ERR_NONE;
624 626
625 file = fopen(FileName, "wb"); 627 file = fopen(FileName, "wb");
626 if (file == NULL) return ERR_CANTOPENFILE; 628 if (file == NULL) return ERR_CANTOPENFILE;
627 629
628 /* Attempt to identify filetype */ 630 /* Attempt to identify filetype */
629 if (strstr(FileName,".nlm")) { 631 if (mystrcasestr(FileName,".nlm")) {
630 error=savenlm(file,bitmap); 632 error=savenlm(file,bitmap);
631 } else if (strstr(FileName,".ngg")) { 633 } else if (mystrcasestr(FileName,".ngg")) {
632 error=savengg(file,bitmap); 634 error=savengg(file,bitmap);
633 } else if (strstr(FileName,".nol")) { 635 } else if (mystrcasestr(FileName,".nol")) {
634 error=savenol(file,bitmap); 636 error=savenol(file,bitmap);
635 } else if (strstr(FileName,".xpm")) { 637 } else if (mystrcasestr(FileName,".xpm")) {
636 error=savexpm(file,bitmap); 638 error=savexpm(file,bitmap);
637 } else if (strstr(FileName,".nsl")) { 639 } else if (mystrcasestr(FileName,".nsl")) {
638 error=savensl(file,bitmap); 640 error=savensl(file,bitmap);
639 } else if (strstr(FileName,".wbmp")) { 641 } else if (mystrcasestr(FileName,".wbmp")) {
640 error=savewbmp(file,bitmap); 642 error=savewbmp(file,bitmap);
641 } else { 643 } else {
642 error=savebmp(file,bitmap); 644 error=savebmp(file,bitmap);
643 } 645 }
644 fclose(file); 646 fclose(file);
645 647
@@ -952,20 +954,51 @@ static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
952 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]); 954 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]);
953 GSM_ReverseBitmap(&bitmap->Bitmap[0]); 955 GSM_ReverseBitmap(&bitmap->Bitmap[0]);
954 956
955 return ERR_NONE; 957 return ERR_NONE;
956} 958}
957 959
960static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
961{
962 GSM_Bitmap *bmap = &bitmap->Bitmap[0];
963 char *buffer;
964 struct stat st;
965 int length;
966
967 dbgprintf("loading gif file\n");
968 fstat(fileno(file), &st);
969 bmap->BinaryPic.Length = length = st.st_size;
970 bmap->BinaryPic.Buffer = buffer = malloc(length);
971 if (bmap->BinaryPic.Buffer == NULL)
972 return ERR_MOREMEMORY;
973
974 fread(buffer, 1, length, file);
975 dbgprintf("Length %i name \"%s\"\n", length,
976 DecodeUnicodeString(bmap->Name));
977
978 bmap->Type = GSM_PictureBinary;
979 bmap->BinaryPic.Type = PICTURE_GIF;
980 bmap->BitmapWidth = 256 * buffer[7] + buffer[6];
981 bmap->BitmapHeight = 256 * buffer[9] + buffer[8];
982 bitmap->Number = 1;
983
984 return ERR_NONE;
985}
986
958GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) 987GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
959{ 988{
960 FILE *file; 989 FILE *file;
961 unsigned charbuffer[300]; 990 unsigned charbuffer[300];
962 991
963 file = fopen(FileName, "rb"); 992 file = fopen(FileName, "rb");
964 if (file == NULL) return ERR_CANTOPENFILE; 993 if (file == NULL) return ERR_CANTOPENFILE;
965 994
995 bitmap->Bitmap[0].Name = malloc((strlen(FileName) + 1) * 2);
996 if (bitmap->Bitmap[0].Name == NULL) return ERR_MOREMEMORY;
997 EncodeUnicode(bitmap->Bitmap[0].Name, FileName, strlen(FileName));
998
966 fread(buffer, 1, 9, file); /* Read the header of the file. */ 999 fread(buffer, 1, 9, file); /* Read the header of the file. */
967 rewind(file); 1000 rewind(file);
968 1001
969 bitmap->Bitmap[0].DefaultBitmap = false; 1002 bitmap->Bitmap[0].DefaultBitmap = false;
970 1003
971 /* Attempt to identify filetype */ 1004 /* Attempt to identify filetype */
@@ -978,12 +1011,14 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
978 } else if (memcmp(buffer, "NOL",3)==0) { 1011 } else if (memcmp(buffer, "NOL",3)==0) {
979 return loadnolngg(file,bitmap,true); 1012 return loadnolngg(file,bitmap,true);
980 } else if (memcmp(buffer, "NGG",3)==0) { 1013 } else if (memcmp(buffer, "NGG",3)==0) {
981 return loadnolngg(file,bitmap,false); 1014 return loadnolngg(file,bitmap,false);
982 } else if (memcmp(buffer, "FORM",4)==0) { 1015 } else if (memcmp(buffer, "FORM",4)==0) {
983 return loadnsl(file,bitmap); 1016 return loadnsl(file,bitmap);
1017 } else if (memcmp(buffer, "GIF",3)==0) {
1018 return loadgif(file,bitmap);
984 } 1019 }
985 return ERR_UNKNOWN; 1020 return ERR_UNKNOWN;
986} 1021}
987 1022
988void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length) 1023void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length)
989{ 1024{
diff --git a/gammu/emb/common/service/gsmlogo.h b/gammu/emb/common/service/gsmlogo.h
index b1b579d..6c6e2d8 100644
--- a/gammu/emb/common/service/gsmlogo.h
+++ b/gammu/emb/common/service/gsmlogo.h
@@ -2,12 +2,26 @@
2 2
3#ifndef __gsm_bitmaps_h 3#ifndef __gsm_bitmaps_h
4#define __gsm_bitmaps_h 4#define __gsm_bitmaps_h
5 5
6#include "../gsmcomon.h" 6#include "../gsmcomon.h"
7 7
8typedef enum {
9 PICTURE_BMP = 1,
10 PICTURE_GIF,
11 PICTURE_JPG,
12 PICTURE_ICN,
13 PICTURE_PNG
14} GSM_BinaryPicture_Types;
15
16typedef struct {
17 GSM_BinaryPicture_Types Type;
18 unsigned char *Buffer;
19 int Length;
20} GSM_BinaryPicture;
21
8/** 22/**
9 * Enum to handle all possible bitmaps, which are not saved in various filesystems. 23 * Enum to handle all possible bitmaps, which are not saved in various filesystems.
10 */ 24 */
11typedef enum { 25typedef enum {
12 GSM_None = 1, 26 GSM_None = 1,
13 /** 27 /**
@@ -42,13 +56,17 @@ typedef enum {
42 * Text displayed during startup 56 * Text displayed during startup
43 */ 57 */
44 GSM_WelcomeNote_Text, 58 GSM_WelcomeNote_Text,
45 /** 59 /**
46 * Image defined in Smart Messaging specification 60 * Image defined in Smart Messaging specification
47 */ 61 */
48 GSM_PictureImage 62 GSM_PictureImage,
63 /**
64 * Binary picture (BMP, GIF, etc.)
65 */
66 GSM_PictureBinary
49} GSM_Bitmap_Types; 67} GSM_Bitmap_Types;
50 68
51 #define GSM_BITMAP_SIZE(65+7)/8*96 69 #define GSM_BITMAP_SIZE(65+7)/8*96
52#define GSM_BITMAP_TEXT_LENGTH 128 70#define GSM_BITMAP_TEXT_LENGTH 128
53 71
54/** 72/**
@@ -112,12 +130,20 @@ typedef struct {
112 */ 130 */
113 unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)]; 131 unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)];
114 /** 132 /**
115 * For colour bitmaps: ID 133 * For colour bitmaps: ID
116 */ 134 */
117 unsigned char ID; 135 unsigned char ID;
136 /**
137 * For binary pictures (GIF, BMP, etc.): frame and length
138 */
139 GSM_BinaryPicture BinaryPic;
140 /**
141 * Bitmap name
142 */
143 char *Name;
118} GSM_Bitmap; 144} GSM_Bitmap;
119 145
120#define MAX_MULTI_BITMAP 6 146#define MAX_MULTI_BITMAP 6
121 147
122/** 148/**
123 * Structure to handle more than one bitmap 149 * Structure to handle more than one bitmap
diff --git a/gammu/emb/common/service/gsmmisc.h b/gammu/emb/common/service/gsmmisc.h
index 37501ad..793d3d1 100644
--- a/gammu/emb/common/service/gsmmisc.h
+++ b/gammu/emb/common/service/gsmmisc.h
@@ -289,13 +289,18 @@ typedef struct {
289 289
290/* ------------------------------------------------------------------------ */ 290/* ------------------------------------------------------------------------ */
291 291
292typedef enum { 292typedef enum {
293 GSM_Date_DDMMYYYY = 1, 293 GSM_Date_DDMMYYYY = 1,
294 GSM_Date_MMDDYYYY, 294 GSM_Date_MMDDYYYY,
295 GSM_Date_YYYYMMDD 295 GSM_Date_YYYYMMDD,
296 GSM_Date_DDMMMYY,
297 GSM_Date_MMDDYY,
298 GSM_Date_DDMMYY,
299 GSM_Date_YYMMDD,
300 GSM_Date_OFF
296} GSM_DateFormat; 301} GSM_DateFormat;
297 302
298typedef struct { 303typedef struct {
299 unsigned char DateSeparator; 304 unsigned char DateSeparator;
300 GSM_DateFormatDateFormat; 305 GSM_DateFormatDateFormat;
301 bool AMPMTime; 306 bool AMPMTime;
diff --git a/gammu/emb/common/service/gsmring.c b/gammu/emb/common/service/gsmring.c
index 7df46f1..dab028c 100644
--- a/gammu/emb/common/service/gsmring.c
+++ b/gammu/emb/common/service/gsmring.c
@@ -1,15 +1,18 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* Based on some work from Ralf Thelen (7110 ringtones), 2/* Based on some work from Ralf Thelen (7110 ringtones) and others */
3 * Gnokii (RTTL and SM) and others 3/* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
4 */ 6 */
5 7
6#include <stdlib.h> 8#include <stdlib.h>
7#include <string.h> 9#include <string.h>
8#include <ctype.h> 10#include <ctype.h>
9#include <math.h> 11#include <math.h>
12#include <sys/stat.h>
10#ifdef WIN32 13#ifdef WIN32
11# include <windows.h> 14# include <windows.h>
12#endif 15#endif
13 16
14#include "../gsmcomon.h" 17#include "../gsmcomon.h"
15#include "../misc/coding/coding.h" 18#include "../misc/coding/coding.h"
@@ -153,12 +156,18 @@ static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone)
153static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone) 156static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
154{ 157{
155 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); 158 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
156 return ERR_NONE; 159 return ERR_NONE;
157} 160}
158 161
162static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
163{
164 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
165 return ERR_NONE;
166}
167
159GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone) 168GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone)
160{ 169{
161 GSM_RingNoteScaleDefNoteScale; 170 GSM_RingNoteScaleDefNoteScale;
162 GSM_RingNoteDurationDefNoteDuration; 171 GSM_RingNoteDurationDefNoteDuration;
163 172
164 GSM_RingNoteStyleDefNoteStyle=0; 173 GSM_RingNoteStyleDefNoteStyle=0;
@@ -482,12 +491,15 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
482 case RING_NOKIABINARY: 491 case RING_NOKIABINARY:
483 savebin(file, ringtone); 492 savebin(file, ringtone);
484 break; 493 break;
485 case RING_MIDI: 494 case RING_MIDI:
486 savepuremidi(file, ringtone); 495 savepuremidi(file, ringtone);
487 break; 496 break;
497 case RING_MMF:
498 savemmf(file, ringtone);
499 break;
488 } 500 }
489 501
490 fclose(file); 502 fclose(file);
491 503
492 return ERR_NONE; 504 return ERR_NONE;
493} 505}
@@ -766,12 +778,32 @@ static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
766 ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file); 778 ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file);
767 memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length); 779 memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length);
768 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name)); 780 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name));
769 return ERR_NONE; 781 return ERR_NONE;
770} 782}
771 783
784static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
785{
786 struct stat st;
787 char *buffer;
788 int length;
789
790 dbgprintf("loading smaf file\n");
791 fstat(fileno(file), &st);
792 ringtone->BinaryTone.Length = length = st.st_size;
793 ringtone->BinaryTone.Buffer = buffer = malloc(length);
794 if (buffer == NULL)
795 return ERR_MOREMEMORY;
796 fread(buffer, 1, length, file);
797
798 dbgprintf("Length %i name \"%s\"\n", length,
799 DecodeUnicodeString(ringtone->Name));
800
801 return ERR_NONE;
802}
803
772static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone) 804static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
773{ 805{
774 unsigned char buffer[2000]; 806 unsigned char buffer[2000];
775 807
776 ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file); 808 ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file);
777 809
@@ -813,12 +845,16 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
813 ringtone->Format = RING_NOKIABINARY; 845 ringtone->Format = RING_NOKIABINARY;
814 } 846 }
815 if (buffer[0]==0x4D && buffer[1]==0x54 && 847 if (buffer[0]==0x4D && buffer[1]==0x54 &&
816 buffer[2]==0x68 && buffer[3]==0x64) { 848 buffer[2]==0x68 && buffer[3]==0x64) {
817 ringtone->Format = RING_MIDI; 849 ringtone->Format = RING_MIDI;
818 } 850 }
851 if (buffer[0]==0x4D && buffer[1]==0x4D &&
852 buffer[2]==0x4D && buffer[3]==0x44) {
853 ringtone->Format = RING_MMF;
854 }
819 } 855 }
820 rewind(file); 856 rewind(file);
821 switch (ringtone->Format) { 857 switch (ringtone->Format) {
822 case RING_NOTETONE: 858 case RING_NOTETONE:
823 if (buffer[0]==0x02 && buffer[1]==0x4A) { 859 if (buffer[0]==0x02 && buffer[1]==0x4A) {
824 error=loadott(file,ringtone); 860 error=loadott(file,ringtone);
@@ -839,12 +875,17 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
839 error=loadre(file,ringtone); 875 error=loadre(file,ringtone);
840 } 876 }
841 break; 877 break;
842 case RING_MIDI: 878 case RING_MIDI:
843 EncodeUnicode(ringtone->Name,FileName,strlen(FileName)); 879 EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
844 error = loadpuremidi(file,ringtone); 880 error = loadpuremidi(file,ringtone);
881 break;
882 case RING_MMF:
883 EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
884 error = loadmmf(file,ringtone);
885 break;
845 } 886 }
846 fclose(file); 887 fclose(file);
847 return(error); 888 return(error);
848} 889}
849 890
850/* -------------------------- required with Nokia & RTTL ------------------- */ 891/* -------------------------- required with Nokia & RTTL ------------------- */
diff --git a/gammu/emb/common/service/gsmring.h b/gammu/emb/common/service/gsmring.h
index 207cf31..2d2dd7a 100644
--- a/gammu/emb/common/service/gsmring.h
+++ b/gammu/emb/common/service/gsmring.h
@@ -117,27 +117,29 @@ typedef struct {
117typedef struct { 117typedef struct {
118 int NrCommands; 118 int NrCommands;
119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES]; 119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES];
120 bool AllNotesScale; 120 bool AllNotesScale;
121} GSM_NoteRingtone; 121} GSM_NoteRingtone;
122 122
123/* FIXME: should use BinaryTone instead? */
123/* Structure to hold Nokia binary ringtones. */ 124/* Structure to hold Nokia binary ringtones. */
124typedef struct { 125typedef struct {
125 unsigned char Frame[30000]; 126 unsigned char Frame[50000];
126 int Length; 127 int Length;
127} GSM_NokiaBinaryRingtone; 128} GSM_NokiaBinaryRingtone;
128 129
129typedef struct { 130typedef struct {
130 unsigned char *Frame; 131 unsigned char *Buffer;
131 int Length; 132 int Length;
132} GSM_BinaryTone; 133} GSM_BinaryTone;
133 134
134typedef enum { 135typedef enum {
135 RING_NOTETONE = 1, 136 RING_NOTETONE = 1,
136 RING_NOKIABINARY, 137 RING_NOKIABINARY,
137 RING_MIDI 138 RING_MIDI,
139 RING_MMF
138} GSM_RingtoneFormat; 140} GSM_RingtoneFormat;
139 141
140/** 142/**
141 * Structure for saving various ringtones formats 143 * Structure for saving various ringtones formats
142 */ 144 */
143typedef struct { 145typedef struct {
diff --git a/gammu/emb/common/service/sms/gsmmulti.c b/gammu/emb/common/service/sms/gsmmulti.c
index 6c1cdcd..bdb5ee9 100644
--- a/gammu/emb/common/service/sms/gsmmulti.c
+++ b/gammu/emb/common/service/sms/gsmmulti.c
@@ -484,12 +484,17 @@ GSM_Error GSM_EncodeMultiPartSMS(GSM_MultiPartSMSInfo *Info,
484 return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION); 484 return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION);
485 case SMS_MMSIndicatorLong: 485 case SMS_MMSIndicatorLong:
486 Class= 1; 486 Class= 1;
487 UDH= UDH_MMSIndicatorLong; 487 UDH= UDH_MMSIndicatorLong;
488 GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,*Info->Entries[0].MMSIndicator); 488 GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,*Info->Entries[0].MMSIndicator);
489 break; 489 break;
490 case SMS_WAPIndicatorLong:
491 Class= 1;
492 UDH= UDH_MMSIndicatorLong;
493 GSM_EncodeWAPIndicatorSMSText(Buffer,&Length,Info->Entries[0].MMSIndicator->Title,Info->Entries[0].MMSIndicator->Address);
494 break;
490 case SMS_NokiaRingtoneLong: 495 case SMS_NokiaRingtoneLong:
491 case SMS_NokiaRingtone: 496 case SMS_NokiaRingtone:
492 UDH= UDH_NokiaRingtone; 497 UDH= UDH_NokiaRingtone;
493 Class= 1; 498 Class= 1;
494 /* 7 = length of UDH_NokiaRingtone UDH header */ 499 /* 7 = length of UDH_NokiaRingtone UDH header */
495 Length = GSM_MAX_8BIT_SMS_LENGTH-7; 500 Length = GSM_MAX_8BIT_SMS_LENGTH-7;
diff --git a/gammu/emb/common/service/sms/gsmmulti.h b/gammu/emb/common/service/sms/gsmmulti.h
index c672261..3f70d81 100644
--- a/gammu/emb/common/service/sms/gsmmulti.h
+++ b/gammu/emb/common/service/sms/gsmmulti.h
@@ -1,11 +1,15 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_multi_h 3#ifndef __gsm_multi_h
4#define __gsm_multi_h 4#define __gsm_multi_h
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include "../../gsmcomon.h" 10#include "../../gsmcomon.h"
7#include "../gsmlogo.h" 11#include "../gsmlogo.h"
8#include "../gsmcal.h" 12#include "../gsmcal.h"
9#include "../gsmpbk.h" 13#include "../gsmpbk.h"
10#include "../gsmdata.h" 14#include "../gsmdata.h"
11#include "../gsmring.h" 15#include "../gsmring.h"
@@ -169,13 +173,13 @@ typedef enum {
169 */ 173 */
170 SMS_EMSSonyEricssonSound, 174 SMS_EMSSonyEricssonSound,
171 /** 175 /**
172 * IMelody 1.0 with UPI. 176 * IMelody 1.0 with UPI.
173 */ 177 */
174 SMS_EMSSound10Long, 178 SMS_EMSSound10Long,
175 /*** 179 /**
176 * IMelody 1.2 with UPI. 180 * IMelody 1.2 with UPI.
177 */ 181 */
178 SMS_EMSSound12Long, 182 SMS_EMSSound12Long,
179 /** 183 /**
180 * IMelody without header with UPI. 184 * IMelody without header with UPI.
181 */ 185 */
@@ -187,12 +191,13 @@ typedef enum {
187 * Fixed bitmap of size 16x16 or 32x32. 191 * Fixed bitmap of size 16x16 or 32x32.
188 */ 192 */
189 SMS_EMSFixedBitmap, 193 SMS_EMSFixedBitmap,
190 SMS_EMSVariableBitmap, 194 SMS_EMSVariableBitmap,
191 SMS_EMSVariableBitmapLong, 195 SMS_EMSVariableBitmapLong,
192 SMS_MMSIndicatorLong, 196 SMS_MMSIndicatorLong,
197 SMS_WAPIndicatorLong,
193 /** 198 /**
194 * Variable bitmap with black and white colors 199 * Variable bitmap with black and white colors
195 */ 200 */
196 SMS_AlcatelMonoBitmapLong, 201 SMS_AlcatelMonoBitmapLong,
197 /** 202 /**
198 * Variable animation with black and white colors 203 * Variable animation with black and white colors
@@ -261,11 +266,15 @@ void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info);
261 266
262/** 267/**
263 * Links SMS messages according to IDs. 268 * Links SMS messages according to IDs.
264 */ 269 */
265GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems); 270GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems);
266 271
272#if defined(_MSC_VER) && defined(__cplusplus)
273 }
274#endif
275
267#endif 276#endif
268 277
269/* How should editor hadle tabs in this file? Add editor commands here. 278/* How should editor hadle tabs in this file? Add editor commands here.
270 * vim: noexpandtab sw=8 ts=8 sts=8: 279 * vim: noexpandtab sw=8 ts=8 sts=8:
271 */ 280 */
diff --git a/gammu/emb/common/service/sms/gsmsms.c b/gammu/emb/common/service/sms/gsmsms.c
index 9920835..feceba4 100644
--- a/gammu/emb/common/service/sms/gsmsms.c
+++ b/gammu/emb/common/service/sms/gsmsms.c
@@ -1,8 +1,11 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Pawel Kot, others and Gnokii */ 2/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
4#include <ctype.h> 7#include <ctype.h>
5#include <string.h> 8#include <string.h>
6#include <time.h> 9#include <time.h>
7 10
8#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
diff --git a/gammu/emb/common/service/sms/gsmsms.h b/gammu/emb/common/service/sms/gsmsms.h
index d87ff60..0b950d3 100644
--- a/gammu/emb/common/service/sms/gsmsms.h
+++ b/gammu/emb/common/service/sms/gsmsms.h
@@ -1,8 +1,11 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Pawel Kot, others and Gnokii */ 2/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
4#ifndef __gsm_sms_h 7#ifndef __gsm_sms_h
5#define __gsm_sms_h 8#define __gsm_sms_h
6 9
7#include "../../gsmcomon.h" 10#include "../../gsmcomon.h"
8#include "../gsmlogo.h" 11#include "../gsmlogo.h"