-rw-r--r-- | gammu/emb/common/service/backup/backgen.h | 4 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backtext.c | 229 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/gsmback.c | 36 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/gsmback.h | 2 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmcal.h | 2 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmdata.c | 124 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmdata.h | 2 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmlogo.c | 47 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmlogo.h | 28 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmmisc.h | 7 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmring.c | 45 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmring.h | 8 | ||||
-rw-r--r-- | gammu/emb/common/service/sms/gsmmulti.c | 5 | ||||
-rw-r--r-- | gammu/emb/common/service/sms/gsmmulti.h | 11 | ||||
-rw-r--r-- | gammu/emb/common/service/sms/gsmsms.c | 5 | ||||
-rw-r--r-- | gammu/emb/common/service/sms/gsmsms.h | 5 |
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 | |||
@@ -1,69 +1,73 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
2 | 2 | ||
3 | #ifndef __gsm_backgen_h | 3 | #ifndef __gsm_backgen_h |
4 | #define __gsm_backgen_h | 4 | #define __gsm_backgen_h |
5 | 5 | ||
6 | #include "../../config.h" | 6 | #include "../../config.h" |
7 | #include "../../misc/misc.h" | 7 | #include "../../misc/misc.h" |
8 | #include "../gsmpbk.h" | 8 | #include "../gsmpbk.h" |
9 | #include "../gsmcal.h" | 9 | #include "../gsmcal.h" |
10 | #include "../gsmlogo.h" | 10 | #include "../gsmlogo.h" |
11 | #include "../gsmring.h" | 11 | #include "../gsmring.h" |
12 | #include "../gsmdata.h" | 12 | #include "../gsmdata.h" |
13 | #include "../gsmprof.h" | 13 | #include "../gsmprof.h" |
14 | #include "../gsmmisc.h" | 14 | #include "../gsmmisc.h" |
15 | #include "../sms/gsmsms.h" | 15 | #include "../sms/gsmsms.h" |
16 | 16 | ||
17 | #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501 | 17 | #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501 |
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 | ||
30 | typedef struct { | 32 | typedef struct { |
31 | char IMEI [MAX_IMEI_LENGTH]; | 33 | char IMEI [MAX_IMEI_LENGTH]; |
32 | char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH]; | 34 | char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH]; |
33 | char Creator [80]; | 35 | char Creator [80]; |
34 | GSM_DateTime DateTime; | 36 | GSM_DateTime DateTime; |
35 | bool DateTimeAvailable; | 37 | bool DateTimeAvailable; |
36 | char MD5Original[100]; | 38 | char MD5Original[100]; |
37 | char MD5Calculated[100]; | 39 | char MD5Calculated[100]; |
38 | GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1]; | 40 | GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1]; |
39 | GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1]; | 41 | GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1]; |
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]; |
52 | GSM_Bitmap *StartupLogo; | 56 | GSM_Bitmap *StartupLogo; |
53 | GSM_Bitmap *OperatorLogo; | 57 | GSM_Bitmap *OperatorLogo; |
54 | } GSM_Backup; | 58 | } GSM_Backup; |
55 | 59 | ||
56 | #define GSM_BACKUP_MAX_SMS500 | 60 | #define GSM_BACKUP_MAX_SMS500 |
57 | 61 | ||
58 | typedef struct { | 62 | typedef struct { |
59 | GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS]; | 63 | GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS]; |
60 | } GSM_SMS_Backup; | 64 | } GSM_SMS_Backup; |
61 | 65 | ||
62 | extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); | 66 | extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); |
63 | extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); | 67 | extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); |
64 | 68 | ||
65 | #endif | 69 | #endif |
66 | 70 | ||
67 | /* How should editor hadle tabs in this file? Add editor commands here. | 71 | /* How should editor hadle tabs in this file? Add editor commands here. |
68 | * vim: noexpandtab sw=8 ts=8 sts=8: | 72 | * vim: noexpandtab sw=8 ts=8 sts=8: |
69 | */ | 73 | */ |
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 | |||
@@ -106,143 +106,144 @@ static void SaveLinkedBackupText(FILE *file, char *myname, char *myvalue, bool U | |||
106 | current = 0; | 106 | current = 0; |
107 | } | 107 | } |
108 | if (UseUnicode) { | 108 | if (UseUnicode) { |
109 | sprintf(buffer3,"%s%02i = %s%c%c",myname,w,buffer2,13,10); | 109 | sprintf(buffer3,"%s%02i = %s%c%c",myname,w,buffer2,13,10); |
110 | EncodeUnicode(buffer2,buffer3,strlen(buffer3)); | 110 | EncodeUnicode(buffer2,buffer3,strlen(buffer3)); |
111 | fwrite(buffer2,1,strlen(buffer3)*2,file); | 111 | fwrite(buffer2,1,strlen(buffer3)*2,file); |
112 | } else { | 112 | } else { |
113 | fprintf(file,"%s%02i = %s%c%c",myname,w,buffer2,13,10); | 113 | fprintf(file,"%s%02i = %s%c%c",myname,w,buffer2,13,10); |
114 | } | 114 | } |
115 | if (current == 0) break; | 115 | if (current == 0) break; |
116 | w++; | 116 | w++; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | static void ReadLinkedBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) | 120 | static void ReadLinkedBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) |
121 | { | 121 | { |
122 | unsigned char buffer2[300]; | 122 | unsigned char buffer2[300]; |
123 | char *readvalue; | 123 | char *readvalue; |
124 | int i; | 124 | int i; |
125 | 125 | ||
126 | i=0; | 126 | i=0; |
127 | myvalue[0] = 0; | 127 | myvalue[0] = 0; |
128 | while (true) { | 128 | while (true) { |
129 | sprintf(buffer2,"%s%02i",myname,i); | 129 | sprintf(buffer2,"%s%02i",myname,i); |
130 | readvalue = ReadCFGText(file_info, section, buffer2, UseUnicode); | 130 | readvalue = ReadCFGText(file_info, section, buffer2, UseUnicode); |
131 | if (readvalue!=NULL) { | 131 | if (readvalue!=NULL) { |
132 | myvalue[strlen(myvalue)+strlen(readvalue)]=0; | 132 | myvalue[strlen(myvalue)+strlen(readvalue)]=0; |
133 | memcpy(myvalue+strlen(myvalue),readvalue,strlen(readvalue)); | 133 | memcpy(myvalue+strlen(myvalue),readvalue,strlen(readvalue)); |
134 | } else break; | 134 | } else break; |
135 | i++; | 135 | i++; |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode) | 139 | static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode) |
140 | { | 140 | { |
141 | unsigned char buffer[10000], buffer2[10000]; | 141 | unsigned char buffer[10000], buffer2[10000]; |
142 | 142 | ||
143 | if (myname[0] == 0x00) { | 143 | if (myname[0] == 0x00) { |
144 | if (UseUnicode) { | 144 | if (UseUnicode) { |
145 | EncodeUnicode(buffer,myvalue,strlen(myvalue)); | 145 | EncodeUnicode(buffer,myvalue,strlen(myvalue)); |
146 | fwrite(buffer,1,strlen(myvalue)*2,file); | 146 | fwrite(buffer,1,strlen(myvalue)*2,file); |
147 | } else fprintf(file,"%s",myvalue); | 147 | } else fprintf(file,"%s",myvalue); |
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 | ||
169 | static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) | 169 | static 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 | } |
186 | } else { | 187 | } else { |
187 | strcpy(paramname,myname); | 188 | strcpy(paramname,myname); |
188 | strcat(paramname,"Unicode"); | 189 | strcat(paramname,"Unicode"); |
189 | readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); | 190 | readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); |
190 | if (readvalue!=NULL) { | 191 | if (readvalue!=NULL) { |
191 | dbgprintf("%s %i\n",readvalue,strlen(readvalue)); | 192 | dbgprintf("%s %i\n",readvalue,strlen(readvalue)); |
192 | DecodeHexBin (myvalue, readvalue, strlen(readvalue)); | 193 | DecodeHexBin (myvalue, readvalue, strlen(readvalue)); |
193 | myvalue[strlen(readvalue)/2]=0; | 194 | myvalue[strlen(readvalue)/2]=0; |
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 | } |
207 | } | 208 | } |
208 | return true; | 209 | return true; |
209 | } | 210 | } |
210 | 211 | ||
211 | static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode) | 212 | static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode) |
212 | { | 213 | { |
213 | unsigned char buffer[100]; | 214 | unsigned char buffer[100]; |
214 | int Length = 3; | 215 | int Length = 3; |
215 | 216 | ||
216 | sprintf(buffer, " = "); | 217 | sprintf(buffer, " = "); |
217 | SaveVCALDateTime(buffer, &Length, dt, NULL); | 218 | SaveVCALDateTime(buffer, &Length, dt, NULL); |
218 | SaveBackupText(file, "", buffer, UseUnicode); | 219 | SaveBackupText(file, "", buffer, UseUnicode); |
219 | } | 220 | } |
220 | 221 | ||
221 | static void SaveVCalDate(FILE *file, GSM_DateTime *dt, bool UseUnicode) | 222 | static void SaveVCalDate(FILE *file, GSM_DateTime *dt, bool UseUnicode) |
222 | { | 223 | { |
223 | unsigned char buffer[100]; | 224 | unsigned char buffer[100]; |
224 | 225 | ||
225 | sprintf(buffer, " = %04d%02d%02d%c%c", dt->Year, dt->Month, dt->Day,13,10); | 226 | sprintf(buffer, " = %04d%02d%02d%c%c", dt->Year, dt->Month, dt->Day,13,10); |
226 | SaveBackupText(file, "", buffer, UseUnicode); | 227 | SaveBackupText(file, "", buffer, UseUnicode); |
227 | } | 228 | } |
228 | 229 | ||
229 | /* ---------------------- backup files ------------------------------------- */ | 230 | /* ---------------------- backup files ------------------------------------- */ |
230 | 231 | ||
231 | static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode) | 232 | static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode) |
232 | { | 233 | { |
233 | booltext; | 234 | booltext; |
234 | charbuffer[1000]; | 235 | charbuffer[1000]; |
235 | intj, i; | 236 | intj, i; |
236 | 237 | ||
237 | sprintf(buffer,"Location = %03i%c%c",Pbk->Location,13,10); | 238 | sprintf(buffer,"Location = %03i%c%c",Pbk->Location,13,10); |
238 | SaveBackupText(file, "", buffer, UseUnicode); | 239 | SaveBackupText(file, "", buffer, UseUnicode); |
239 | for (j=0;j<Pbk->EntriesNum;j++) { | 240 | for (j=0;j<Pbk->EntriesNum;j++) { |
240 | text = true; | 241 | text = true; |
241 | switch (Pbk->Entries[j].EntryType) { | 242 | switch (Pbk->Entries[j].EntryType) { |
242 | case PBK_Number_General: | 243 | case PBK_Number_General: |
243 | sprintf(buffer,"Entry%02iType = NumberGeneral%c%c",j,13,10); | 244 | sprintf(buffer,"Entry%02iType = NumberGeneral%c%c",j,13,10); |
244 | SaveBackupText(file, "", buffer, UseUnicode); | 245 | SaveBackupText(file, "", buffer, UseUnicode); |
245 | break; | 246 | break; |
246 | case PBK_Number_Mobile: | 247 | case PBK_Number_Mobile: |
247 | sprintf(buffer,"Entry%02iType = NumberMobile%c%c",j,13,10); | 248 | sprintf(buffer,"Entry%02iType = NumberMobile%c%c",j,13,10); |
248 | SaveBackupText(file, "", buffer, UseUnicode); | 249 | SaveBackupText(file, "", buffer, UseUnicode); |
@@ -373,114 +374,125 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode) | |||
373 | case PBK_Text_Custom2: | 374 | case PBK_Text_Custom2: |
374 | sprintf(buffer,"Entry%02iType = Custom2%c%c",j,13,10); | 375 | sprintf(buffer,"Entry%02iType = Custom2%c%c",j,13,10); |
375 | SaveBackupText(file, "", buffer, UseUnicode); | 376 | SaveBackupText(file, "", buffer, UseUnicode); |
376 | break; | 377 | break; |
377 | case PBK_Text_Custom3: | 378 | case PBK_Text_Custom3: |
378 | sprintf(buffer,"Entry%02iType = Custom3%c%c",j,13,10); | 379 | sprintf(buffer,"Entry%02iType = Custom3%c%c",j,13,10); |
379 | SaveBackupText(file, "", buffer, UseUnicode); | 380 | SaveBackupText(file, "", buffer, UseUnicode); |
380 | break; | 381 | break; |
381 | case PBK_Text_Custom4: | 382 | case PBK_Text_Custom4: |
382 | sprintf(buffer,"Entry%02iType = Custom4%c%c",j,13,10); | 383 | sprintf(buffer,"Entry%02iType = Custom4%c%c",j,13,10); |
383 | SaveBackupText(file, "", buffer, UseUnicode); | 384 | SaveBackupText(file, "", buffer, UseUnicode); |
384 | break; | 385 | break; |
385 | case PBK_SMSListID: | 386 | case PBK_SMSListID: |
386 | case PBK_RingtoneFileSystemID: | 387 | case PBK_RingtoneFileSystemID: |
387 | case PBK_Date: | 388 | case PBK_Date: |
388 | break; | 389 | break; |
389 | } | 390 | } |
390 | if (text) { | 391 | if (text) { |
391 | sprintf(buffer,"Entry%02iText",j); | 392 | sprintf(buffer,"Entry%02iText",j); |
392 | SaveBackupText(file,buffer,Pbk->Entries[j].Text, UseUnicode); | 393 | SaveBackupText(file,buffer,Pbk->Entries[j].Text, UseUnicode); |
393 | } | 394 | } |
394 | switch (Pbk->Entries[j].EntryType) { | 395 | switch (Pbk->Entries[j].EntryType) { |
395 | case PBK_Number_General: | 396 | case PBK_Number_General: |
396 | case PBK_Number_Mobile: | 397 | case PBK_Number_Mobile: |
397 | case PBK_Number_Work: | 398 | case PBK_Number_Work: |
398 | case PBK_Number_Fax: | 399 | case PBK_Number_Fax: |
399 | case PBK_Number_Home: | 400 | case PBK_Number_Home: |
400 | case PBK_Number_Other: | 401 | case PBK_Number_Other: |
401 | case PBK_Number_Pager: | 402 | case PBK_Number_Pager: |
402 | if (Pbk->Entries[j].VoiceTag!=0) { | 403 | if (Pbk->Entries[j].VoiceTag!=0) { |
403 | sprintf(buffer,"Entry%02iVoiceTag = %i%c%c",j,Pbk->Entries[j].VoiceTag,13,10); | 404 | sprintf(buffer,"Entry%02iVoiceTag = %i%c%c",j,Pbk->Entries[j].VoiceTag,13,10); |
404 | SaveBackupText(file, "", buffer, UseUnicode); | 405 | SaveBackupText(file, "", buffer, UseUnicode); |
405 | } | 406 | } |
406 | i = 0; | 407 | i = 0; |
407 | while (Pbk->Entries[j].SMSList[i]!=0) { | 408 | while (Pbk->Entries[j].SMSList[i]!=0) { |
408 | sprintf(buffer,"Entry%02iSMSList%02i = %i%c%c",j,i,Pbk->Entries[j].SMSList[i],13,10); | 409 | sprintf(buffer,"Entry%02iSMSList%02i = %i%c%c",j,i,Pbk->Entries[j].SMSList[i],13,10); |
409 | SaveBackupText(file, "", buffer, UseUnicode); | 410 | SaveBackupText(file, "", buffer, UseUnicode); |
410 | i++; | 411 | i++; |
411 | } | 412 | } |
412 | break; | 413 | break; |
413 | default: | 414 | default: |
414 | break; | 415 | break; |
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 | ||
422 | static 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 | |||
421 | static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode) | 433 | static 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); |
427 | SaveBackupText(file, "", buffer, UseUnicode); | 439 | SaveBackupText(file, "", buffer, UseUnicode); |
428 | SaveBackupText(file, "", "Type = ", UseUnicode); | 440 | SaveBackupText(file, "", "Type = ", UseUnicode); |
429 | switch (Note->Type) { | 441 | switch (Note->Type) { |
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; |
445 | case GSM_CAL_T_FOOT : sprintf(buffer,"Training/Football%c%c", 13,10); break; | 457 | case GSM_CAL_T_FOOT : sprintf(buffer,"Training/Football%c%c", 13,10); break; |
446 | case GSM_CAL_T_GOLF : sprintf(buffer,"Training/Golf%c%c", 13,10); break; | 458 | case GSM_CAL_T_GOLF : sprintf(buffer,"Training/Golf%c%c", 13,10); break; |
447 | case GSM_CAL_T_GYM : sprintf(buffer,"Training/Gym%c%c", 13,10); break; | 459 | case GSM_CAL_T_GYM : sprintf(buffer,"Training/Gym%c%c", 13,10); break; |
448 | case GSM_CAL_T_HORS : sprintf(buffer,"Training/HorseRaces%c%c", 13,10); break; | 460 | case GSM_CAL_T_HORS : sprintf(buffer,"Training/HorseRaces%c%c", 13,10); break; |
449 | case GSM_CAL_T_HOCK : sprintf(buffer,"Training/Hockey%c%c", 13,10); break; | 461 | case GSM_CAL_T_HOCK : sprintf(buffer,"Training/Hockey%c%c", 13,10); break; |
450 | case GSM_CAL_T_RACE : sprintf(buffer,"Training/Races%c%c", 13,10); break; | 462 | case GSM_CAL_T_RACE : sprintf(buffer,"Training/Races%c%c", 13,10); break; |
451 | case GSM_CAL_T_RUGB : sprintf(buffer,"Training/Rugby%c%c", 13,10); break; | 463 | case GSM_CAL_T_RUGB : sprintf(buffer,"Training/Rugby%c%c", 13,10); break; |
452 | case GSM_CAL_T_SAIL : sprintf(buffer,"Training/Sailing%c%c", 13,10); break; | 464 | case GSM_CAL_T_SAIL : sprintf(buffer,"Training/Sailing%c%c", 13,10); break; |
453 | case GSM_CAL_T_STRE : sprintf(buffer,"Training/StreetGames%c%c",13,10); break; | 465 | case GSM_CAL_T_STRE : sprintf(buffer,"Training/StreetGames%c%c",13,10); break; |
454 | case GSM_CAL_T_SWIM : sprintf(buffer,"Training/Swimming%c%c", 13,10); break; | 466 | case GSM_CAL_T_SWIM : sprintf(buffer,"Training/Swimming%c%c", 13,10); break; |
455 | case GSM_CAL_T_TENN : sprintf(buffer,"Training/Tennis%c%c", 13,10); break; | 467 | case GSM_CAL_T_TENN : sprintf(buffer,"Training/Tennis%c%c", 13,10); break; |
456 | case GSM_CAL_T_TRAV : sprintf(buffer,"Training/Travels%c%c", 13,10); break; | 468 | case GSM_CAL_T_TRAV : sprintf(buffer,"Training/Travels%c%c", 13,10); break; |
457 | case GSM_CAL_T_WINT : sprintf(buffer,"Training/WinterGames%c%c", 13,10); break; | 469 | case GSM_CAL_T_WINT : sprintf(buffer,"Training/WinterGames%c%c", 13,10); break; |
458 | } | 470 | } |
459 | SaveBackupText(file, "", buffer, UseUnicode); | 471 | SaveBackupText(file, "", buffer, UseUnicode); |
460 | for (i=0;i<Note->EntriesNum;i++) { | 472 | for (i=0;i<Note->EntriesNum;i++) { |
461 | switch (Note->Entries[i].EntryType) { | 473 | switch (Note->Entries[i].EntryType) { |
462 | case CAL_START_DATETIME: | 474 | case CAL_START_DATETIME: |
463 | SaveBackupText(file, "", "StartTime", UseUnicode); | 475 | SaveBackupText(file, "", "StartTime", UseUnicode); |
464 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | 476 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); |
465 | break; | 477 | break; |
466 | case CAL_END_DATETIME: | 478 | case CAL_END_DATETIME: |
467 | SaveBackupText(file, "", "StopTime", UseUnicode); | 479 | SaveBackupText(file, "", "StopTime", UseUnicode); |
468 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | 480 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); |
469 | break; | 481 | break; |
470 | case CAL_ALARM_DATETIME: | 482 | case CAL_ALARM_DATETIME: |
471 | SaveBackupText(file, "", "Alarm", UseUnicode); | 483 | SaveBackupText(file, "", "Alarm", UseUnicode); |
472 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | 484 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); |
473 | sprintf(buffer,"AlarmType = Tone%c%c",13,10); | 485 | sprintf(buffer,"AlarmType = Tone%c%c",13,10); |
474 | SaveBackupText(file, "", buffer, UseUnicode); | 486 | SaveBackupText(file, "", buffer, UseUnicode); |
475 | break; | 487 | break; |
476 | case CAL_SILENT_ALARM_DATETIME: | 488 | case CAL_SILENT_ALARM_DATETIME: |
477 | SaveBackupText(file, "", "Alarm", UseUnicode); | 489 | SaveBackupText(file, "", "Alarm", UseUnicode); |
478 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | 490 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); |
479 | sprintf(buffer,"AlarmType = Silent%c%c",13,10); | 491 | sprintf(buffer,"AlarmType = Silent%c%c",13,10); |
480 | SaveBackupText(file, "", buffer, UseUnicode); | 492 | SaveBackupText(file, "", buffer, UseUnicode); |
481 | break; | 493 | break; |
482 | case CAL_PRIVATE: | 494 | case CAL_PRIVATE: |
483 | sprintf(buffer, "Private = %d%c%c",Note->Entries[i].Number,13,10); | 495 | sprintf(buffer, "Private = %d%c%c",Note->Entries[i].Number,13,10); |
484 | SaveBackupText(file, "", buffer, UseUnicode); | 496 | SaveBackupText(file, "", buffer, UseUnicode); |
485 | break; | 497 | break; |
486 | case CAL_LOCATION: | 498 | case CAL_LOCATION: |
@@ -612,96 +624,138 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo | |||
612 | SaveBackupText(file, buffer, settings->Settings[i].DialUp, UseUnicode); | 624 | SaveBackupText(file, buffer, settings->Settings[i].DialUp, UseUnicode); |
613 | if (settings->Settings[i].ManualLogin) { | 625 | if (settings->Settings[i].ManualLogin) { |
614 | sprintf(buffer,"Login%02i = Manual%c%c",i,13,10); | 626 | sprintf(buffer,"Login%02i = Manual%c%c",i,13,10); |
615 | } else { | 627 | } else { |
616 | sprintf(buffer,"Login%02i = Automatic%c%c",i,13,10); | 628 | sprintf(buffer,"Login%02i = Automatic%c%c",i,13,10); |
617 | } | 629 | } |
618 | SaveBackupText(file, "", buffer, UseUnicode); | 630 | SaveBackupText(file, "", buffer, UseUnicode); |
619 | if (settings->Settings[i].IsNormalAuthentication) { | 631 | if (settings->Settings[i].IsNormalAuthentication) { |
620 | sprintf(buffer,"Authentication%02i = Normal%c%c",i,13,10); | 632 | sprintf(buffer,"Authentication%02i = Normal%c%c",i,13,10); |
621 | } else { | 633 | } else { |
622 | sprintf(buffer,"Authentication%02i = Secure%c%c",i,13,10); | 634 | sprintf(buffer,"Authentication%02i = Secure%c%c",i,13,10); |
623 | } | 635 | } |
624 | SaveBackupText(file, "", buffer, UseUnicode); | 636 | SaveBackupText(file, "", buffer, UseUnicode); |
625 | switch (settings->Settings[i].Speed) { | 637 | switch (settings->Settings[i].Speed) { |
626 | case WAPSETTINGS_SPEED_9600 : sprintf(buffer,"CallSpeed%02i = 9600%c%c" ,i,13,10); break; | 638 | case WAPSETTINGS_SPEED_9600 : sprintf(buffer,"CallSpeed%02i = 9600%c%c" ,i,13,10); break; |
627 | case WAPSETTINGS_SPEED_14400: sprintf(buffer,"CallSpeed%02i = 14400%c%c",i,13,10); break; | 639 | case WAPSETTINGS_SPEED_14400: sprintf(buffer,"CallSpeed%02i = 14400%c%c",i,13,10); break; |
628 | case WAPSETTINGS_SPEED_AUTO : sprintf(buffer,"CallSpeed%02i = auto%c%c" ,i,13,10); break; | 640 | case WAPSETTINGS_SPEED_AUTO : sprintf(buffer,"CallSpeed%02i = auto%c%c" ,i,13,10); break; |
629 | } | 641 | } |
630 | switch (settings->Settings[i].Speed) { | 642 | switch (settings->Settings[i].Speed) { |
631 | case WAPSETTINGS_SPEED_9600 : | 643 | case WAPSETTINGS_SPEED_9600 : |
632 | case WAPSETTINGS_SPEED_14400: | 644 | case WAPSETTINGS_SPEED_14400: |
633 | case WAPSETTINGS_SPEED_AUTO : | 645 | case WAPSETTINGS_SPEED_AUTO : |
634 | SaveBackupText(file, "", buffer, UseUnicode); | 646 | SaveBackupText(file, "", buffer, UseUnicode); |
635 | default: | 647 | default: |
636 | break; | 648 | break; |
637 | } | 649 | } |
638 | sprintf(buffer,"User%02i",i); | 650 | sprintf(buffer,"User%02i",i); |
639 | SaveBackupText(file, buffer, settings->Settings[i].User, UseUnicode); | 651 | SaveBackupText(file, buffer, settings->Settings[i].User, UseUnicode); |
640 | sprintf(buffer,"Password%02i",i); | 652 | sprintf(buffer,"Password%02i",i); |
641 | SaveBackupText(file, buffer, settings->Settings[i].Password, UseUnicode); | 653 | SaveBackupText(file, buffer, settings->Settings[i].Password, UseUnicode); |
642 | break; | 654 | break; |
643 | case WAPSETTINGS_BEARER_USSD: | 655 | case WAPSETTINGS_BEARER_USSD: |
644 | sprintf(buffer,"Bearer%02i = USSD%c%c",i,13,10); | 656 | sprintf(buffer,"Bearer%02i = USSD%c%c",i,13,10); |
645 | SaveBackupText(file, "", buffer, UseUnicode); | 657 | SaveBackupText(file, "", buffer, UseUnicode); |
646 | sprintf(buffer,"ServiceCode%02i",i); | 658 | sprintf(buffer,"ServiceCode%02i",i); |
647 | SaveBackupText(file, buffer, settings->Settings[i].Code, UseUnicode); | 659 | SaveBackupText(file, buffer, settings->Settings[i].Code, UseUnicode); |
648 | if (settings->Settings[i].IsIP) { | 660 | if (settings->Settings[i].IsIP) { |
649 | sprintf(buffer,"IP%02i",i); | 661 | sprintf(buffer,"IP%02i",i); |
650 | } else { | 662 | } else { |
651 | sprintf(buffer,"Number%02i",i); | 663 | sprintf(buffer,"Number%02i",i); |
652 | } | 664 | } |
653 | SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode); | 665 | SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode); |
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 | ||
672 | static 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 | |||
685 | static 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 | |||
660 | static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | 714 | static 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); |
666 | SaveBackupText(file, "", buffer, UseUnicode); | 720 | SaveBackupText(file, "", buffer, UseUnicode); |
667 | sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10); | 721 | sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10); |
668 | SaveBackupText(file, "", buffer, UseUnicode); | 722 | SaveBackupText(file, "", buffer, UseUnicode); |
669 | for (y=0;y<bitmap->BitmapHeight;y++) { | 723 | for (y=0;y<bitmap->BitmapHeight;y++) { |
670 | for (x=0;x<bitmap->BitmapWidth;x++) { | 724 | for (x=0;x<bitmap->BitmapWidth;x++) { |
671 | buffer[x] = ' '; | 725 | buffer[x] = ' '; |
672 | if (GSM_IsPointBitmap(bitmap,x,y)) buffer[x]='#'; | 726 | if (GSM_IsPointBitmap(bitmap,x,y)) buffer[x]='#'; |
673 | } | 727 | } |
674 | buffer[bitmap->BitmapWidth] = 0; | 728 | buffer[bitmap->BitmapWidth] = 0; |
675 | sprintf(buffer2,"Bitmap%02i = \"%s\"%c%c",y,buffer,13,10); | 729 | sprintf(buffer2,"Bitmap%02i = \"%s\"%c%c",y,buffer,13,10); |
676 | SaveBackupText(file, "", buffer2, UseUnicode); | 730 | SaveBackupText(file, "", buffer2, UseUnicode); |
677 | } | 731 | } |
678 | } | 732 | } |
679 | 733 | ||
680 | static void SaveCallerEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | 734 | static void SaveCallerEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) |
681 | { | 735 | { |
682 | unsigned char buffer[1000]; | 736 | unsigned char buffer[1000]; |
683 | 737 | ||
684 | sprintf(buffer,"Location = %03i%c%c",bitmap->Location,13,10); | 738 | sprintf(buffer,"Location = %03i%c%c",bitmap->Location,13,10); |
685 | SaveBackupText(file, "", buffer, UseUnicode); | 739 | SaveBackupText(file, "", buffer, UseUnicode); |
686 | if (!bitmap->DefaultName) SaveBackupText(file, "Name", bitmap->Text, UseUnicode); | 740 | if (!bitmap->DefaultName) SaveBackupText(file, "Name", bitmap->Text, UseUnicode); |
687 | if (!bitmap->DefaultRingtone) { | 741 | if (!bitmap->DefaultRingtone) { |
688 | if (bitmap->FileSystemRingtone) { | 742 | if (bitmap->FileSystemRingtone) { |
689 | sprintf(buffer,"FileRingtone = %02x%c%c",bitmap->RingtoneID,13,10); | 743 | sprintf(buffer,"FileRingtone = %02x%c%c",bitmap->RingtoneID,13,10); |
690 | } else { | 744 | } else { |
691 | sprintf(buffer,"Ringtone = %02x%c%c",bitmap->RingtoneID,13,10); | 745 | sprintf(buffer,"Ringtone = %02x%c%c",bitmap->RingtoneID,13,10); |
692 | } | 746 | } |
693 | SaveBackupText(file, "", buffer, UseUnicode); | 747 | SaveBackupText(file, "", buffer, UseUnicode); |
694 | } | 748 | } |
695 | if (bitmap->BitmapEnabled) { | 749 | if (bitmap->BitmapEnabled) { |
696 | sprintf(buffer,"Enabled = True%c%c",13,10); | 750 | sprintf(buffer,"Enabled = True%c%c",13,10); |
697 | } else { | 751 | } else { |
698 | sprintf(buffer,"Enabled = False%c%c",13,10); | 752 | sprintf(buffer,"Enabled = False%c%c",13,10); |
699 | } | 753 | } |
700 | SaveBackupText(file, "", buffer, UseUnicode); | 754 | SaveBackupText(file, "", buffer, UseUnicode); |
701 | if (!bitmap->DefaultBitmap) SaveBitmapEntry(file, bitmap, UseUnicode); | 755 | if (!bitmap->DefaultBitmap) SaveBitmapEntry(file, bitmap, UseUnicode); |
702 | sprintf(buffer,"%c%c",13,10); | 756 | sprintf(buffer,"%c%c",13,10); |
703 | SaveBackupText(file, "", buffer, UseUnicode); | 757 | SaveBackupText(file, "", buffer, UseUnicode); |
704 | } | 758 | } |
705 | 759 | ||
706 | static void SaveWAPBookmarkEntry(FILE *file, GSM_WAPBookmark *bookmark, bool UseUnicode) | 760 | static void SaveWAPBookmarkEntry(FILE *file, GSM_WAPBookmark *bookmark, bool UseUnicode) |
707 | { | 761 | { |
@@ -719,113 +773,114 @@ static void SaveStartupEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | |||
719 | 773 | ||
720 | sprintf(buffer,"[Startup]%c%c",13,10); | 774 | sprintf(buffer,"[Startup]%c%c",13,10); |
721 | SaveBackupText(file, "", buffer, UseUnicode); | 775 | SaveBackupText(file, "", buffer, UseUnicode); |
722 | if (bitmap->Type == GSM_WelcomeNote_Text) { | 776 | if (bitmap->Type == GSM_WelcomeNote_Text) { |
723 | SaveBackupText(file, "Text", bitmap->Text, UseUnicode); | 777 | SaveBackupText(file, "Text", bitmap->Text, UseUnicode); |
724 | } | 778 | } |
725 | if (bitmap->Type == GSM_StartupLogo) { | 779 | if (bitmap->Type == GSM_StartupLogo) { |
726 | SaveBitmapEntry(file, bitmap, UseUnicode); | 780 | SaveBitmapEntry(file, bitmap, UseUnicode); |
727 | } | 781 | } |
728 | sprintf(buffer,"%c%c",13,10); | 782 | sprintf(buffer,"%c%c",13,10); |
729 | SaveBackupText(file, "", buffer, UseUnicode); | 783 | SaveBackupText(file, "", buffer, UseUnicode); |
730 | } | 784 | } |
731 | 785 | ||
732 | static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode) | 786 | static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode) |
733 | { | 787 | { |
734 | unsigned char buffer[1000]; | 788 | unsigned char buffer[1000]; |
735 | 789 | ||
736 | sprintf(buffer,"Location = %03i%c%c",SMSC->Location,13,10); | 790 | sprintf(buffer,"Location = %03i%c%c",SMSC->Location,13,10); |
737 | SaveBackupText(file, "", buffer, UseUnicode); | 791 | SaveBackupText(file, "", buffer, UseUnicode); |
738 | SaveBackupText(file, "Name", SMSC->Name, UseUnicode); | 792 | SaveBackupText(file, "Name", SMSC->Name, UseUnicode); |
739 | SaveBackupText(file, "Number", SMSC->Number, UseUnicode); | 793 | SaveBackupText(file, "Number", SMSC->Number, UseUnicode); |
740 | SaveBackupText(file, "DefaultNumber", SMSC->DefaultNumber, UseUnicode); | 794 | SaveBackupText(file, "DefaultNumber", SMSC->DefaultNumber, UseUnicode); |
741 | SaveBackupText(file, "", "Format = ", UseUnicode); | 795 | SaveBackupText(file, "", "Format = ", UseUnicode); |
742 | switch (SMSC->Format) { | 796 | switch (SMSC->Format) { |
743 | case SMS_FORMAT_Text: sprintf(buffer,"Text"); break; | 797 | case SMS_FORMAT_Text: sprintf(buffer,"Text"); break; |
744 | case SMS_FORMAT_Fax: sprintf(buffer,"Fax"); break; | 798 | case SMS_FORMAT_Fax: sprintf(buffer,"Fax"); break; |
745 | case SMS_FORMAT_Email: sprintf(buffer,"Email"); break; | 799 | case SMS_FORMAT_Email: sprintf(buffer,"Email"); break; |
746 | case SMS_FORMAT_Pager: sprintf(buffer,"Pager"); break; | 800 | case SMS_FORMAT_Pager: sprintf(buffer,"Pager"); break; |
747 | } | 801 | } |
748 | SaveBackupText(file, "", buffer, UseUnicode); | 802 | SaveBackupText(file, "", buffer, UseUnicode); |
749 | sprintf(buffer,"%c%cValidity = ",13,10); | 803 | sprintf(buffer,"%c%cValidity = ",13,10); |
750 | SaveBackupText(file, "", buffer, UseUnicode); | 804 | SaveBackupText(file, "", buffer, UseUnicode); |
751 | switch (SMSC->Validity.Relative) { | 805 | switch (SMSC->Validity.Relative) { |
752 | case SMS_VALID_1_Hour : sprintf(buffer, "1hour"); break; | 806 | case SMS_VALID_1_Hour : sprintf(buffer, "1hour"); break; |
753 | case SMS_VALID_6_Hours : sprintf(buffer, "6hours"); break; | 807 | case SMS_VALID_6_Hours : sprintf(buffer, "6hours"); break; |
754 | case SMS_VALID_1_Day : sprintf(buffer, "24hours"); break; | 808 | case SMS_VALID_1_Day : sprintf(buffer, "24hours"); break; |
755 | case SMS_VALID_3_Days : sprintf(buffer, "72hours"); break; | 809 | case SMS_VALID_3_Days : sprintf(buffer, "72hours"); break; |
756 | case SMS_VALID_1_Week : sprintf(buffer, "1week"); break; | 810 | case SMS_VALID_1_Week : sprintf(buffer, "1week"); break; |
757 | case SMS_VALID_Max_Time: | 811 | case SMS_VALID_Max_Time: |
758 | default : sprintf(buffer,"MaximumTime"); break; | 812 | default : sprintf(buffer,"MaximumTime"); break; |
759 | } | 813 | } |
760 | SaveBackupText(file, "", buffer, UseUnicode); | 814 | SaveBackupText(file, "", buffer, 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 | ||
765 | static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode) | 819 | static 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 | } |
790 | 845 | ||
791 | static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | 846 | static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) |
792 | { | 847 | { |
793 | unsigned char buffer[1000]; | 848 | unsigned char buffer[1000]; |
794 | 849 | ||
795 | sprintf(buffer,"[Operator]%c%c",13,10); | 850 | sprintf(buffer,"[Operator]%c%c",13,10); |
796 | SaveBackupText(file, "", buffer, UseUnicode); | 851 | SaveBackupText(file, "", buffer, UseUnicode); |
797 | sprintf(buffer,"Network = \"%s\"%c%c", bitmap->NetworkCode,13,10); | 852 | sprintf(buffer,"Network = \"%s\"%c%c", bitmap->NetworkCode,13,10); |
798 | SaveBackupText(file, "", buffer, UseUnicode); | 853 | SaveBackupText(file, "", buffer, UseUnicode); |
799 | SaveBitmapEntry(file, bitmap, UseUnicode); | 854 | SaveBitmapEntry(file, bitmap, UseUnicode); |
800 | sprintf(buffer,"%c%c",13,10); | 855 | sprintf(buffer,"%c%c",13,10); |
801 | SaveBackupText(file, "", buffer, UseUnicode); | 856 | SaveBackupText(file, "", buffer, UseUnicode); |
802 | } | 857 | } |
803 | 858 | ||
804 | static void SaveToDoEntry(FILE *file, GSM_ToDoEntry *ToDo, bool UseUnicode) | 859 | static void SaveToDoEntry(FILE *file, GSM_ToDoEntry *ToDo, bool UseUnicode) |
805 | { | 860 | { |
806 | unsigned char buffer[1000]; | 861 | unsigned char buffer[1000]; |
807 | int j; | 862 | int j; |
808 | 863 | ||
809 | sprintf(buffer,"Location = %i%c%c",ToDo->Location,13,10); | 864 | sprintf(buffer,"Location = %i%c%c",ToDo->Location,13,10); |
810 | SaveBackupText(file, "", buffer, UseUnicode); | 865 | SaveBackupText(file, "", buffer, UseUnicode); |
811 | switch (ToDo->Priority) { | 866 | switch (ToDo->Priority) { |
812 | case GSM_Priority_High: | 867 | case GSM_Priority_High: |
813 | sprintf(buffer,"Priority = High%c%c",13,10); | 868 | sprintf(buffer,"Priority = High%c%c",13,10); |
814 | break; | 869 | break; |
815 | case GSM_Priority_Medium: | 870 | case GSM_Priority_Medium: |
816 | sprintf(buffer,"Priority = Medium%c%c",13,10); | 871 | sprintf(buffer,"Priority = Medium%c%c",13,10); |
817 | break; | 872 | break; |
818 | case GSM_Priority_Low: | 873 | case GSM_Priority_Low: |
819 | sprintf(buffer,"Priority = Low%c%c",13,10); | 874 | sprintf(buffer,"Priority = Low%c%c",13,10); |
820 | break; | 875 | break; |
821 | } | 876 | } |
822 | SaveBackupText(file, "", buffer, UseUnicode); | 877 | SaveBackupText(file, "", buffer, UseUnicode); |
823 | 878 | ||
824 | for (j=0;j<ToDo->EntriesNum;j++) { | 879 | for (j=0;j<ToDo->EntriesNum;j++) { |
825 | switch (ToDo->Entries[j].EntryType) { | 880 | switch (ToDo->Entries[j].EntryType) { |
826 | case TODO_END_DATETIME: | 881 | case TODO_END_DATETIME: |
827 | SaveBackupText(file, "", "DueTime", UseUnicode); | 882 | SaveBackupText(file, "", "DueTime", UseUnicode); |
828 | SaveVCalDateTime(file, &ToDo->Entries[j].Date, UseUnicode); | 883 | SaveVCalDateTime(file, &ToDo->Entries[j].Date, UseUnicode); |
829 | break; | 884 | break; |
830 | case TODO_COMPLETED: | 885 | case TODO_COMPLETED: |
831 | sprintf(buffer,"Completed = %s%c%c",ToDo->Entries[j].Number == 1 ? "yes" : "no" ,13,10); | 886 | sprintf(buffer,"Completed = %s%c%c",ToDo->Entries[j].Number == 1 ? "yes" : "no" ,13,10); |
@@ -1030,131 +1085,152 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode) | |||
1030 | if (UseUnicode) { | 1085 | if (UseUnicode) { |
1031 | sprintf(buffer,"%c%c", 0xFE, 0xFF); | 1086 | sprintf(buffer,"%c%c", 0xFE, 0xFF); |
1032 | SaveBackupText(file, "", buffer, false); | 1087 | SaveBackupText(file, "", buffer, false); |
1033 | } | 1088 | } |
1034 | 1089 | ||
1035 | sprintf(buffer,"# Format of this file was designed for Gammu (see www.mwiacek.com)%c%c%c%c",13,10,13,10); | 1090 | sprintf(buffer,"# Format of this file was designed for Gammu (see www.mwiacek.com)%c%c%c%c",13,10,13,10); |
1036 | SaveBackupText(file, "", buffer, UseUnicode); | 1091 | SaveBackupText(file, "", buffer, UseUnicode); |
1037 | sprintf(buffer,"[Backup]%c%c",13,10); | 1092 | sprintf(buffer,"[Backup]%c%c",13,10); |
1038 | SaveBackupText(file, "", buffer, UseUnicode); | 1093 | SaveBackupText(file, "", buffer, UseUnicode); |
1039 | sprintf(buffer,"IMEI = \"%s\"%c%c",backup->IMEI,13,10); | 1094 | sprintf(buffer,"IMEI = \"%s\"%c%c",backup->IMEI,13,10); |
1040 | SaveBackupText(file, "", buffer, UseUnicode); | 1095 | SaveBackupText(file, "", buffer, UseUnicode); |
1041 | sprintf(buffer,"Phone = \"%s\"%c%c",backup->Model,13,10); | 1096 | sprintf(buffer,"Phone = \"%s\"%c%c",backup->Model,13,10); |
1042 | SaveBackupText(file, "", buffer, UseUnicode); | 1097 | SaveBackupText(file, "", buffer, UseUnicode); |
1043 | if (backup->Creator[0] != 0) { | 1098 | if (backup->Creator[0] != 0) { |
1044 | sprintf(buffer,"Creator = \"%s\"%c%c",backup->Creator,13,10); | 1099 | sprintf(buffer,"Creator = \"%s\"%c%c",backup->Creator,13,10); |
1045 | SaveBackupText(file, "", buffer, UseUnicode); | 1100 | SaveBackupText(file, "", buffer, UseUnicode); |
1046 | } | 1101 | } |
1047 | if (backup->DateTimeAvailable) { | 1102 | if (backup->DateTimeAvailable) { |
1048 | SaveBackupText(file, "", "DateTime", UseUnicode); | 1103 | SaveBackupText(file, "", "DateTime", UseUnicode); |
1049 | SaveVCalDateTime(file, &backup->DateTime, UseUnicode); | 1104 | SaveVCalDateTime(file, &backup->DateTime, UseUnicode); |
1050 | } | 1105 | } |
1051 | sprintf(buffer,"Format = 1.03%c%c",13,10); | 1106 | sprintf(buffer,"Format = 1.03%c%c",13,10); |
1052 | SaveBackupText(file, "", buffer, UseUnicode); | 1107 | SaveBackupText(file, "", buffer, UseUnicode); |
1053 | sprintf(buffer,"%c%c",13,10); | 1108 | sprintf(buffer,"%c%c",13,10); |
1054 | SaveBackupText(file, "", buffer, UseUnicode); | 1109 | SaveBackupText(file, "", buffer, UseUnicode); |
1055 | 1110 | ||
1056 | i=0; | 1111 | i=0; |
1057 | while (backup->PhonePhonebook[i]!=NULL) { | 1112 | while (backup->PhonePhonebook[i]!=NULL) { |
1058 | sprintf(buffer,"[PhonePBK%03i]%c%c",i+1,13,10); | 1113 | sprintf(buffer,"[PhonePBK%03i]%c%c",i+1,13,10); |
1059 | SaveBackupText(file, "", buffer, UseUnicode); | 1114 | SaveBackupText(file, "", buffer, UseUnicode); |
1060 | SavePbkEntry(file, backup->PhonePhonebook[i], UseUnicode); | 1115 | SavePbkEntry(file, backup->PhonePhonebook[i], UseUnicode); |
1061 | i++; | 1116 | i++; |
1062 | } | 1117 | } |
1063 | i=0; | 1118 | i=0; |
1064 | while (backup->SIMPhonebook[i]!=NULL) { | 1119 | while (backup->SIMPhonebook[i]!=NULL) { |
1065 | sprintf(buffer,"[SIMPBK%03i]%c%c",i+1,13,10); | 1120 | sprintf(buffer,"[SIMPBK%03i]%c%c",i+1,13,10); |
1066 | SaveBackupText(file, "", buffer, UseUnicode); | 1121 | SaveBackupText(file, "", buffer, UseUnicode); |
1067 | SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode); | 1122 | SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode); |
1068 | i++; | 1123 | i++; |
1069 | } | 1124 | } |
1070 | i=0; | 1125 | i=0; |
1071 | while (backup->Calendar[i]!=NULL) { | 1126 | while (backup->Calendar[i]!=NULL) { |
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 | } |
1084 | i=0; | 1146 | i=0; |
1085 | while (backup->SMSC[i]!=NULL) { | 1147 | while (backup->SMSC[i]!=NULL) { |
1086 | sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10); | 1148 | sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10); |
1087 | SaveBackupText(file, "", buffer, UseUnicode); | 1149 | SaveBackupText(file, "", buffer, UseUnicode); |
1088 | SaveSMSCEntry(file, backup->SMSC[i], UseUnicode); | 1150 | SaveSMSCEntry(file, backup->SMSC[i], UseUnicode); |
1089 | i++; | 1151 | i++; |
1090 | } | 1152 | } |
1091 | i=0; | 1153 | i=0; |
1092 | while (backup->WAPBookmark[i]!=NULL) { | 1154 | while (backup->WAPBookmark[i]!=NULL) { |
1093 | sprintf(buffer,"[WAPBookmark%03i]%c%c",i+1,13,10); | 1155 | sprintf(buffer,"[WAPBookmark%03i]%c%c",i+1,13,10); |
1094 | SaveBackupText(file, "", buffer, UseUnicode); | 1156 | SaveBackupText(file, "", buffer, UseUnicode); |
1095 | SaveWAPBookmarkEntry(file, backup->WAPBookmark[i], UseUnicode); | 1157 | SaveWAPBookmarkEntry(file, backup->WAPBookmark[i], UseUnicode); |
1096 | i++; | 1158 | i++; |
1097 | } | 1159 | } |
1098 | i=0; | 1160 | i=0; |
1099 | while (backup->WAPSettings[i]!=NULL) { | 1161 | while (backup->WAPSettings[i]!=NULL) { |
1100 | sprintf(buffer,"[WAPSettings%03i]%c%c",i+1,13,10); | 1162 | sprintf(buffer,"[WAPSettings%03i]%c%c",i+1,13,10); |
1101 | SaveBackupText(file, "", buffer, UseUnicode); | 1163 | SaveBackupText(file, "", buffer, UseUnicode); |
1102 | SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode); | 1164 | SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode); |
1103 | i++; | 1165 | i++; |
1104 | } | 1166 | } |
1105 | i=0; | 1167 | i=0; |
1106 | while (backup->MMSSettings[i]!=NULL) { | 1168 | while (backup->MMSSettings[i]!=NULL) { |
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 | } |
1119 | i=0; | 1195 | i=0; |
1120 | while (backup->ToDo[i]!=NULL) { | 1196 | while (backup->ToDo[i]!=NULL) { |
1121 | sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10); | 1197 | sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10); |
1122 | SaveBackupText(file, "", buffer, UseUnicode); | 1198 | SaveBackupText(file, "", buffer, UseUnicode); |
1123 | SaveToDoEntry(file, backup->ToDo[i], UseUnicode); | 1199 | SaveToDoEntry(file, backup->ToDo[i], UseUnicode); |
1124 | i++; | 1200 | i++; |
1125 | } | 1201 | } |
1126 | i=0; | 1202 | i=0; |
1127 | while (backup->Profiles[i]!=NULL) { | 1203 | while (backup->Profiles[i]!=NULL) { |
1128 | sprintf(buffer,"[Profile%03i]%c%c",i+1,13,10); | 1204 | sprintf(buffer,"[Profile%03i]%c%c",i+1,13,10); |
1129 | SaveBackupText(file, "", buffer, UseUnicode); | 1205 | SaveBackupText(file, "", buffer, UseUnicode); |
1130 | SaveProfileEntry(file, backup->Profiles[i], UseUnicode); | 1206 | SaveProfileEntry(file, backup->Profiles[i], UseUnicode); |
1131 | i++; | 1207 | i++; |
1132 | } | 1208 | } |
1133 | i=0; | 1209 | i=0; |
1134 | while (backup->FMStation[i]!=NULL) { | 1210 | while (backup->FMStation[i]!=NULL) { |
1135 | sprintf(buffer,"[FMStation%03i]%c%c",i+1,13,10); | 1211 | sprintf(buffer,"[FMStation%03i]%c%c",i+1,13,10); |
1136 | SaveBackupText(file, "", buffer, UseUnicode); | 1212 | SaveBackupText(file, "", buffer, UseUnicode); |
1137 | SaveFMStationEntry(file, backup->FMStation[i], UseUnicode); | 1213 | SaveFMStationEntry(file, backup->FMStation[i], UseUnicode); |
1138 | i++; | 1214 | i++; |
1139 | } | 1215 | } |
1140 | i=0; | 1216 | i=0; |
1141 | while (backup->GPRSPoint[i]!=NULL) { | 1217 | while (backup->GPRSPoint[i]!=NULL) { |
1142 | sprintf(buffer,"[GPRSPoint%03i]%c%c",i+1,13,10); | 1218 | sprintf(buffer,"[GPRSPoint%03i]%c%c",i+1,13,10); |
1143 | SaveBackupText(file, "", buffer, UseUnicode); | 1219 | SaveBackupText(file, "", buffer, UseUnicode); |
1144 | SaveGPRSPointEntry(file, backup->GPRSPoint[i], UseUnicode); | 1220 | SaveGPRSPointEntry(file, backup->GPRSPoint[i], UseUnicode); |
1145 | i++; | 1221 | i++; |
1146 | } | 1222 | } |
1147 | 1223 | ||
1148 | if (backup->StartupLogo!=NULL) { | 1224 | if (backup->StartupLogo!=NULL) { |
1149 | SaveStartupEntry(file, backup->StartupLogo, UseUnicode); | 1225 | SaveStartupEntry(file, backup->StartupLogo, UseUnicode); |
1150 | } | 1226 | } |
1151 | if (backup->OperatorLogo!=NULL) { | 1227 | if (backup->OperatorLogo!=NULL) { |
1152 | SaveOperatorEntry(file, backup->OperatorLogo, UseUnicode); | 1228 | SaveOperatorEntry(file, backup->OperatorLogo, UseUnicode); |
1153 | } | 1229 | } |
1154 | 1230 | ||
1155 | fclose(file); | 1231 | fclose(file); |
1156 | 1232 | ||
1157 | FindBackupChecksum(FileName, UseUnicode, checksum); | 1233 | FindBackupChecksum(FileName, UseUnicode, checksum); |
1158 | 1234 | ||
1159 | file = fopen(FileName, "ab"); | 1235 | file = fopen(FileName, "ab"); |
1160 | if (file == NULL) return ERR_CANTOPENFILE; | 1236 | if (file == NULL) return ERR_CANTOPENFILE; |
@@ -2611,97 +2687,222 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode) | |||
2611 | EncodeUnicode(buffer,"GPRSPoint",9); | 2687 | EncodeUnicode(buffer,"GPRSPoint",9); |
2612 | if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; | 2688 | if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; |
2613 | } else { | 2689 | } else { |
2614 | if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true; | 2690 | if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true; |
2615 | } | 2691 | } |
2616 | if (found) { | 2692 | if (found) { |
2617 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | 2693 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); |
2618 | if (readvalue==NULL) break; | 2694 | if (readvalue==NULL) break; |
2619 | if (num < GSM_BACKUP_MAX_GPRSPOINT) { | 2695 | if (num < GSM_BACKUP_MAX_GPRSPOINT) { |
2620 | backup->GPRSPoint[num] = malloc(sizeof(GSM_GPRSAccessPoint)); | 2696 | backup->GPRSPoint[num] = malloc(sizeof(GSM_GPRSAccessPoint)); |
2621 | if (backup->GPRSPoint[num] == NULL) return ERR_MOREMEMORY; | 2697 | if (backup->GPRSPoint[num] == NULL) return ERR_MOREMEMORY; |
2622 | backup->GPRSPoint[num + 1] = NULL; | 2698 | backup->GPRSPoint[num + 1] = NULL; |
2623 | } else { | 2699 | } else { |
2624 | dbgprintf("Increase GSM_BACKUP_MAX_GPRSPOINT\n"); | 2700 | dbgprintf("Increase GSM_BACKUP_MAX_GPRSPOINT\n"); |
2625 | return ERR_MOREMEMORY; | 2701 | return ERR_MOREMEMORY; |
2626 | } | 2702 | } |
2627 | backup->GPRSPoint[num]->Location = num + 1; | 2703 | backup->GPRSPoint[num]->Location = num + 1; |
2628 | ReadGPRSPointEntry(file_info, h->SectionName, backup->GPRSPoint[num],UseUnicode); | 2704 | ReadGPRSPointEntry(file_info, h->SectionName, backup->GPRSPoint[num],UseUnicode); |
2629 | num++; | 2705 | num++; |
2630 | } | 2706 | } |
2631 | } | 2707 | } |
2632 | num = 0; | 2708 | num = 0; |
2633 | for (h = file_info; h != NULL; h = h->Next) { | 2709 | for (h = file_info; h != NULL; h = h->Next) { |
2634 | found = false; | 2710 | found = false; |
2635 | if (UseUnicode) { | 2711 | if (UseUnicode) { |
2636 | EncodeUnicode(buffer,"Note",4); | 2712 | EncodeUnicode(buffer,"Note",4); |
2637 | if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; | 2713 | if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; |
2638 | } else { | 2714 | } else { |
2639 | if (mystrncasecmp("Note", h->SectionName, 4)) found = true; | 2715 | if (mystrncasecmp("Note", h->SectionName, 4)) found = true; |
2640 | } | 2716 | } |
2641 | if (found) { | 2717 | if (found) { |
2642 | readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode); | 2718 | readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode); |
2643 | if (readvalue==NULL) break; | 2719 | if (readvalue==NULL) break; |
2644 | if (num < GSM_BACKUP_MAX_NOTE) { | 2720 | if (num < GSM_BACKUP_MAX_NOTE) { |
2645 | backup->Note[num] = malloc(sizeof(GSM_NoteEntry)); | 2721 | backup->Note[num] = malloc(sizeof(GSM_NoteEntry)); |
2646 | if (backup->Note[num] == NULL) return ERR_MOREMEMORY; | 2722 | if (backup->Note[num] == NULL) return ERR_MOREMEMORY; |
2647 | backup->Note[num + 1] = NULL; | 2723 | backup->Note[num + 1] = NULL; |
2648 | } else { | 2724 | } else { |
2649 | dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n"); | 2725 | dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n"); |
2650 | return ERR_MOREMEMORY; | 2726 | return ERR_MOREMEMORY; |
2651 | } | 2727 | } |
2652 | ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode); | 2728 | ReadNoteEntry(file_info, h->SectionName, backup->Note[num],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 | ||
2665 | static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS) | 2866 | static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS) |
2666 | { | 2867 | { |
2667 | unsigned char buffer[10000], *readvalue; | 2868 | unsigned char buffer[10000], *readvalue; |
2668 | 2869 | ||
2669 | GSM_SetDefaultSMSData(SMS); | 2870 | GSM_SetDefaultSMSData(SMS); |
2670 | 2871 | ||
2671 | SMS->PDU = SMS_Submit; | 2872 | SMS->PDU = SMS_Submit; |
2672 | SMS->SMSC.Location = 0; | 2873 | SMS->SMSC.Location = 0; |
2673 | sprintf(buffer,"SMSC"); | 2874 | sprintf(buffer,"SMSC"); |
2674 | ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false); | 2875 | ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false); |
2675 | sprintf(buffer,"ReplySMSC"); | 2876 | sprintf(buffer,"ReplySMSC"); |
2676 | SMS->ReplyViaSameSMSC = false; | 2877 | SMS->ReplyViaSameSMSC = false; |
2677 | readvalue = ReadCFGText(file_info, section, buffer, false); | 2878 | readvalue = ReadCFGText(file_info, section, buffer, false); |
2678 | if (readvalue!=NULL) { | 2879 | if (readvalue!=NULL) { |
2679 | if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true; | 2880 | if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true; |
2680 | } | 2881 | } |
2681 | sprintf(buffer,"Class"); | 2882 | sprintf(buffer,"Class"); |
2682 | SMS->Class = -1; | 2883 | SMS->Class = -1; |
2683 | readvalue = ReadCFGText(file_info, section, buffer, false); | 2884 | readvalue = ReadCFGText(file_info, section, buffer, false); |
2684 | if (readvalue!=NULL) SMS->Class = atoi(readvalue); | 2885 | if (readvalue!=NULL) SMS->Class = atoi(readvalue); |
2685 | sprintf(buffer,"Sent"); | 2886 | sprintf(buffer,"Sent"); |
2686 | readvalue = ReadCFGText(file_info, section, buffer, false); | 2887 | readvalue = ReadCFGText(file_info, section, buffer, false); |
2687 | if (readvalue!=NULL) { | 2888 | if (readvalue!=NULL) { |
2688 | ReadVCALDateTime(readvalue, &SMS->DateTime); | 2889 | ReadVCALDateTime(readvalue, &SMS->DateTime); |
2689 | SMS->PDU = SMS_Deliver; | 2890 | SMS->PDU = SMS_Deliver; |
2690 | } | 2891 | } |
2691 | sprintf(buffer,"RejectDuplicates"); | 2892 | sprintf(buffer,"RejectDuplicates"); |
2692 | SMS->RejectDuplicates = false; | 2893 | SMS->RejectDuplicates = false; |
2693 | readvalue = ReadCFGText(file_info, section, buffer, false); | 2894 | readvalue = ReadCFGText(file_info, section, buffer, false); |
2694 | if (readvalue!=NULL) { | 2895 | if (readvalue!=NULL) { |
2695 | if (mystrncasecmp(readvalue,"True",0)) SMS->RejectDuplicates = true; | 2896 | if (mystrncasecmp(readvalue,"True",0)) SMS->RejectDuplicates = true; |
2696 | } | 2897 | } |
2697 | sprintf(buffer,"ReplaceMessage"); | 2898 | sprintf(buffer,"ReplaceMessage"); |
2698 | SMS->ReplaceMessage = 0; | 2899 | SMS->ReplaceMessage = 0; |
2699 | readvalue = ReadCFGText(file_info, section, buffer, false); | 2900 | readvalue = ReadCFGText(file_info, section, buffer, false); |
2700 | if (readvalue!=NULL) SMS->ReplaceMessage = atoi(readvalue); | 2901 | if (readvalue!=NULL) SMS->ReplaceMessage = atoi(readvalue); |
2701 | sprintf(buffer,"MessageReference"); | 2902 | sprintf(buffer,"MessageReference"); |
2702 | SMS->MessageReference = 0; | 2903 | SMS->MessageReference = 0; |
2703 | readvalue = ReadCFGText(file_info, section, buffer, false); | 2904 | readvalue = ReadCFGText(file_info, section, buffer, false); |
2704 | if (readvalue!=NULL) SMS->MessageReference = atoi(readvalue); | 2905 | if (readvalue!=NULL) SMS->MessageReference = atoi(readvalue); |
2705 | sprintf(buffer,"State"); | 2906 | sprintf(buffer,"State"); |
2706 | SMS->State = SMS_UnRead; | 2907 | SMS->State = SMS_UnRead; |
2707 | readvalue = ReadCFGText(file_info, section, buffer, false); | 2908 | readvalue = ReadCFGText(file_info, section, buffer, false); |
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 | |||
@@ -28,253 +28,271 @@ void GSM_FreeBackup(GSM_Backup *backup) | |||
28 | while (backup->PhonePhonebook[i]!=NULL) { | 28 | while (backup->PhonePhonebook[i]!=NULL) { |
29 | free(backup->PhonePhonebook[i]); | 29 | free(backup->PhonePhonebook[i]); |
30 | backup->PhonePhonebook[i] = NULL; | 30 | backup->PhonePhonebook[i] = NULL; |
31 | i++; | 31 | i++; |
32 | } | 32 | } |
33 | i=0; | 33 | i=0; |
34 | while (backup->SIMPhonebook[i]!=NULL) { | 34 | while (backup->SIMPhonebook[i]!=NULL) { |
35 | free(backup->SIMPhonebook[i]); | 35 | free(backup->SIMPhonebook[i]); |
36 | backup->SIMPhonebook[i] = NULL; | 36 | backup->SIMPhonebook[i] = NULL; |
37 | i++; | 37 | i++; |
38 | } | 38 | } |
39 | i=0; | 39 | i=0; |
40 | while (backup->Calendar[i]!=NULL) { | 40 | while (backup->Calendar[i]!=NULL) { |
41 | free(backup->Calendar[i]); | 41 | free(backup->Calendar[i]); |
42 | backup->Calendar[i] = NULL; | 42 | backup->Calendar[i] = NULL; |
43 | i++; | 43 | i++; |
44 | } | 44 | } |
45 | i=0; | 45 | i=0; |
46 | while (backup->CallerLogos[i]!=NULL) { | 46 | while (backup->CallerLogos[i]!=NULL) { |
47 | free(backup->CallerLogos[i]); | 47 | free(backup->CallerLogos[i]); |
48 | backup->CallerLogos[i] = NULL; | 48 | backup->CallerLogos[i] = NULL; |
49 | i++; | 49 | i++; |
50 | } | 50 | } |
51 | i=0; | 51 | i=0; |
52 | while (backup->SMSC[i]!=NULL) { | 52 | while (backup->SMSC[i]!=NULL) { |
53 | free(backup->SMSC[i]); | 53 | free(backup->SMSC[i]); |
54 | backup->SMSC[i] = NULL; | 54 | backup->SMSC[i] = NULL; |
55 | i++; | 55 | i++; |
56 | } | 56 | } |
57 | i=0; | 57 | i=0; |
58 | while (backup->WAPBookmark[i]!=NULL) { | 58 | while (backup->WAPBookmark[i]!=NULL) { |
59 | free(backup->WAPBookmark[i]); | 59 | free(backup->WAPBookmark[i]); |
60 | backup->WAPBookmark[i] = NULL; | 60 | backup->WAPBookmark[i] = NULL; |
61 | i++; | 61 | i++; |
62 | } | 62 | } |
63 | i=0; | 63 | i=0; |
64 | while (backup->WAPSettings[i]!=NULL) { | 64 | while (backup->WAPSettings[i]!=NULL) { |
65 | free(backup->WAPSettings[i]); | 65 | free(backup->WAPSettings[i]); |
66 | backup->WAPSettings[i] = NULL; | 66 | backup->WAPSettings[i] = NULL; |
67 | i++; | 67 | i++; |
68 | } | 68 | } |
69 | i=0; | 69 | i=0; |
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; |
82 | while (backup->ToDo[i]!=NULL) { | 94 | while (backup->ToDo[i]!=NULL) { |
83 | free(backup->ToDo[i]); | 95 | free(backup->ToDo[i]); |
84 | backup->ToDo[i] = NULL; | 96 | backup->ToDo[i] = NULL; |
85 | i++; | 97 | i++; |
86 | } | 98 | } |
87 | i=0; | 99 | i=0; |
88 | while (backup->Profiles[i]!=NULL) { | 100 | while (backup->Profiles[i]!=NULL) { |
89 | free(backup->Profiles[i]); | 101 | free(backup->Profiles[i]); |
90 | backup->Profiles[i] = NULL; | 102 | backup->Profiles[i] = NULL; |
91 | i++; | 103 | i++; |
92 | } | 104 | } |
93 | i=0; | 105 | i=0; |
94 | while (backup->FMStation[i]!=NULL) { | 106 | while (backup->FMStation[i]!=NULL) { |
95 | free(backup->FMStation[i]); | 107 | free(backup->FMStation[i]); |
96 | backup->FMStation[i] = NULL; | 108 | backup->FMStation[i] = NULL; |
97 | i++; | 109 | i++; |
98 | } | 110 | } |
99 | if (backup->StartupLogo!=NULL) { | 111 | if (backup->StartupLogo!=NULL) { |
100 | free(backup->StartupLogo); | 112 | free(backup->StartupLogo); |
101 | backup->StartupLogo = NULL; | 113 | backup->StartupLogo = NULL; |
102 | } | 114 | } |
103 | if (backup->OperatorLogo!=NULL) { | 115 | if (backup->OperatorLogo!=NULL) { |
104 | free(backup->OperatorLogo); | 116 | free(backup->OperatorLogo); |
105 | backup->OperatorLogo = NULL; | 117 | backup->OperatorLogo = NULL; |
106 | } | 118 | } |
107 | i=0; | 119 | i=0; |
108 | while (backup->GPRSPoint[i]!=NULL) { | 120 | while (backup->GPRSPoint[i]!=NULL) { |
109 | free(backup->GPRSPoint[i]); | 121 | free(backup->GPRSPoint[i]); |
110 | backup->GPRSPoint[i] = NULL; | 122 | backup->GPRSPoint[i] = NULL; |
111 | i++; | 123 | i++; |
112 | } | 124 | } |
113 | i=0; | 125 | i=0; |
114 | while (backup->Note[i]!=NULL) { | 126 | while (backup->Note[i]!=NULL) { |
115 | free(backup->Note[i]); | 127 | free(backup->Note[i]); |
116 | backup->Note[i] = NULL; | 128 | backup->Note[i] = NULL; |
117 | i++; | 129 | i++; |
118 | } | 130 | } |
119 | } | 131 | } |
120 | 132 | ||
121 | GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode) | 133 | GSM_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 | ||
138 | GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup) | 150 | GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup) |
139 | { | 151 | { |
140 | FILE *file; | 152 | FILE *file; |
141 | unsigned charbuffer[300]; | 153 | unsigned charbuffer[300]; |
142 | 154 | ||
143 | file = fopen(FileName, "rb"); | 155 | file = fopen(FileName, "rb"); |
144 | if (file == NULL) return ERR_CANTOPENFILE; | 156 | if (file == NULL) return ERR_CANTOPENFILE; |
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) { |
164 | return LoadBackup(FileName,backup,true); | 176 | return LoadBackup(FileName,backup,true); |
165 | } else { | 177 | } else { |
166 | return LoadBackup(FileName,backup,false); | 178 | return LoadBackup(FileName,backup,false); |
167 | } | 179 | } |
168 | } | 180 | } |
169 | 181 | ||
170 | void GSM_ClearBackup(GSM_Backup *backup) | 182 | void GSM_ClearBackup(GSM_Backup *backup) |
171 | { | 183 | { |
172 | backup->PhonePhonebook[0] = NULL; | 184 | backup->PhonePhonebook[0] = NULL; |
173 | backup->SIMPhonebook[0] = NULL; | 185 | backup->SIMPhonebook[0] = NULL; |
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; |
186 | backup->StartupLogo = NULL; | 200 | backup->StartupLogo = NULL; |
187 | backup->OperatorLogo = NULL; | 201 | backup->OperatorLogo = NULL; |
188 | 202 | ||
189 | backup->Creator [0] = 0; | 203 | backup->Creator [0] = 0; |
190 | backup->IMEI [0] = 0; | 204 | backup->IMEI [0] = 0; |
191 | backup->Model [0] = 0; | 205 | backup->Model [0] = 0; |
192 | backup->DateTimeAvailable = false; | 206 | backup->DateTimeAvailable = false; |
193 | backup->MD5Original[0] = 0; | 207 | backup->MD5Original[0] = 0; |
194 | backup->MD5Calculated[0] = 0; | 208 | backup->MD5Calculated[0] = 0; |
195 | } | 209 | } |
196 | 210 | ||
197 | void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info) | 211 | void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info) |
198 | { | 212 | { |
199 | info->UseUnicode= false; | 213 | info->UseUnicode= false; |
200 | info->IMEI = false; | 214 | info->IMEI = false; |
201 | info->Model = false; | 215 | info->Model = false; |
202 | info->DateTime = false; | 216 | info->DateTime = false; |
203 | info->PhonePhonebook = false; | 217 | info->PhonePhonebook = false; |
204 | info->SIMPhonebook = false; | 218 | info->SIMPhonebook = false; |
205 | info->ToDo = false; | 219 | info->ToDo = false; |
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; |
218 | info->Note = false; | 234 | info->Note = false; |
219 | 235 | ||
220 | if (strstr(FileName,".lmb")) { | 236 | if (strstr(FileName,".lmb")) { |
221 | info->PhonePhonebook = true; | 237 | info->PhonePhonebook = true; |
222 | info->SIMPhonebook = true; | 238 | info->SIMPhonebook = true; |
223 | info->CallerLogos = true; | 239 | info->CallerLogos = true; |
224 | info->StartupLogo = true; | 240 | info->StartupLogo = true; |
225 | } else if (strstr(FileName,".vcs")) { | 241 | } else if (strstr(FileName,".vcs")) { |
226 | info->ToDo = true; | 242 | info->ToDo = true; |
227 | info->Calendar = true; | 243 | info->Calendar = true; |
228 | } else if (strstr(FileName,".vcf")) { | 244 | } else if (strstr(FileName,".vcf")) { |
229 | info->PhonePhonebook= true; | 245 | info->PhonePhonebook= true; |
230 | } else if (strstr(FileName,".ics")) { | 246 | } else if (strstr(FileName,".ics")) { |
231 | info->ToDo = true; | 247 | info->ToDo = true; |
232 | info->Calendar = true; | 248 | info->Calendar = true; |
233 | } else if (strstr(FileName,".ldif")) { | 249 | } else if (strstr(FileName,".ldif")) { |
234 | info->PhonePhonebook= true; | 250 | info->PhonePhonebook= true; |
235 | } else { | 251 | } else { |
236 | info->UseUnicode= true; | 252 | info->UseUnicode= true; |
237 | info->IMEI = true; | 253 | info->IMEI = true; |
238 | info->Model = true; | 254 | info->Model = true; |
239 | info->DateTime = true; | 255 | info->DateTime = true; |
240 | info->PhonePhonebook = true; | 256 | info->PhonePhonebook = true; |
241 | info->SIMPhonebook = true; | 257 | info->SIMPhonebook = true; |
242 | info->ToDo = true; | 258 | info->ToDo = true; |
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; |
255 | info->Note = true; | 273 | info->Note = true; |
256 | } | 274 | } |
257 | } | 275 | } |
258 | 276 | ||
259 | void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup) | 277 | void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup) |
260 | { | 278 | { |
261 | GSM_GetBackupFormatFeatures(FileName, info); | 279 | GSM_GetBackupFormatFeatures(FileName, info); |
262 | 280 | ||
263 | if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook = false; | 281 | if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook = false; |
264 | if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook = false; | 282 | if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook = false; |
265 | if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar = false; | 283 | if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar = false; |
266 | if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo = false; | 284 | if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo = false; |
267 | if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark = false; | 285 | if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark = false; |
268 | if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings = false; | 286 | if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings = false; |
269 | if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings = false; | 287 | if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings = false; |
270 | if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation = false; | 288 | if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation = false; |
271 | if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint = false; | 289 | if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint = false; |
272 | if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles = false; | 290 | if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles = false; |
273 | /* .... */ | 291 | /* .... */ |
274 | } | 292 | } |
275 | 293 | ||
276 | #endif | 294 | #endif |
277 | 295 | ||
278 | /* How should editor hadle tabs in this file? Add editor commands here. | 296 | /* How should editor hadle tabs in this file? Add editor commands here. |
279 | * vim: noexpandtab sw=8 ts=8 sts=8: | 297 | * vim: noexpandtab sw=8 ts=8 sts=8: |
280 | */ | 298 | */ |
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 | |||
@@ -1,48 +1,50 @@ | |||
1 | /* (c) 2003-2004 by Marcin Wiacek */ | 1 | /* (c) 2003-2004 by Marcin Wiacek */ |
2 | 2 | ||
3 | #ifndef __gsm_back_h | 3 | #ifndef __gsm_back_h |
4 | #define __gsm_back_h | 4 | #define __gsm_back_h |
5 | 5 | ||
6 | #include "backgen.h" | 6 | #include "backgen.h" |
7 | 7 | ||
8 | #ifdef GSM_ENABLE_BACKUP | 8 | #ifdef GSM_ENABLE_BACKUP |
9 | 9 | ||
10 | GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode); | 10 | GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode); |
11 | GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup); | 11 | GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup); |
12 | 12 | ||
13 | void GSM_ClearBackup (GSM_Backup *backup); | 13 | void GSM_ClearBackup (GSM_Backup *backup); |
14 | void GSM_FreeBackup (GSM_Backup *backup); | 14 | void GSM_FreeBackup (GSM_Backup *backup); |
15 | 15 | ||
16 | typedef struct { | 16 | typedef struct { |
17 | bool UseUnicode; | 17 | bool UseUnicode; |
18 | 18 | ||
19 | bool IMEI; | 19 | bool IMEI; |
20 | bool Model; | 20 | bool Model; |
21 | bool DateTime; | 21 | bool DateTime; |
22 | bool ToDo; | 22 | bool ToDo; |
23 | bool PhonePhonebook; | 23 | bool PhonePhonebook; |
24 | bool SIMPhonebook; | 24 | bool SIMPhonebook; |
25 | bool Calendar; | 25 | bool Calendar; |
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; |
38 | } GSM_Backup_Info; | 40 | } GSM_Backup_Info; |
39 | 41 | ||
40 | void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info); | 42 | void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info); |
41 | void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup); | 43 | void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup); |
42 | 44 | ||
43 | #endif | 45 | #endif |
44 | #endif | 46 | #endif |
45 | 47 | ||
46 | /* How should editor hadle tabs in this file? Add editor commands here. | 48 | /* How should editor hadle tabs in this file? Add editor commands here. |
47 | * vim: noexpandtab sw=8 ts=8 sts=8: | 49 | * vim: noexpandtab sw=8 ts=8 sts=8: |
48 | */ | 50 | */ |
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 | |||
@@ -360,86 +360,86 @@ typedef struct { | |||
360 | unsigned int Number; | 360 | unsigned int Number; |
361 | } GSM_SubToDoEntry; | 361 | } GSM_SubToDoEntry; |
362 | 362 | ||
363 | /** | 363 | /** |
364 | * To do entry. | 364 | * To do entry. |
365 | */ | 365 | */ |
366 | typedef struct { | 366 | typedef struct { |
367 | /** | 367 | /** |
368 | * Priority of entry. | 368 | * Priority of entry. |
369 | */ | 369 | */ |
370 | GSM_ToDo_Priority Priority; | 370 | GSM_ToDo_Priority Priority; |
371 | /** | 371 | /** |
372 | * Location in memory. | 372 | * Location in memory. |
373 | */ | 373 | */ |
374 | int Location; | 374 | int Location; |
375 | /** | 375 | /** |
376 | * Number of entries. | 376 | * Number of entries. |
377 | */ | 377 | */ |
378 | int EntriesNum; | 378 | int EntriesNum; |
379 | /** | 379 | /** |
380 | * Values of current entry. | 380 | * Values of current entry. |
381 | */ | 381 | */ |
382 | GSM_SubToDoEntryEntries[GSM_TODO_ENTRIES]; | 382 | GSM_SubToDoEntryEntries[GSM_TODO_ENTRIES]; |
383 | } GSM_ToDoEntry; | 383 | } GSM_ToDoEntry; |
384 | 384 | ||
385 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone); | 385 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone); |
386 | 386 | ||
387 | typedef enum { | 387 | typedef enum { |
388 | Nokia_VToDo = 1, | 388 | Nokia_VToDo = 1, |
389 | SonyEricsson_VToDo | 389 | SonyEricsson_VToDo |
390 | } GSM_VToDoVersion; | 390 | } GSM_VToDoVersion; |
391 | 391 | ||
392 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version); | 392 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version); |
393 | 393 | ||
394 | /** | 394 | /** |
395 | * Status of to do entries. | 395 | * Status of to do entries. |
396 | */ | 396 | */ |
397 | typedef struct { | 397 | typedef struct { |
398 | /** | 398 | /** |
399 | * Number of used positions. | 399 | * Number of used positions. |
400 | */ | 400 | */ |
401 | int Used; | 401 | int Used; |
402 | } GSM_ToDoStatus; | 402 | } GSM_ToDoStatus; |
403 | 403 | ||
404 | /* --------------------------- note ---------------------------------------- */ | 404 | /* --------------------------- note ---------------------------------------- */ |
405 | 405 | ||
406 | typedef struct { | 406 | typedef struct { |
407 | int Location; | 407 | int Location; |
408 | char Text[100]; | 408 | char Text[3000*2]; |
409 | } GSM_NoteEntry; | 409 | } GSM_NoteEntry; |
410 | 410 | ||
411 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); | 411 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); |
412 | 412 | ||
413 | /* --------------------------- alarm --------------------------------------- */ | 413 | /* --------------------------- alarm --------------------------------------- */ |
414 | 414 | ||
415 | /** | 415 | /** |
416 | * Alarm values. | 416 | * Alarm values. |
417 | */ | 417 | */ |
418 | typedef struct { | 418 | typedef struct { |
419 | /** | 419 | /** |
420 | * Location where it is stored. | 420 | * Location where it is stored. |
421 | */ | 421 | */ |
422 | int Location; | 422 | int Location; |
423 | /** | 423 | /** |
424 | * Date and time of alarm. | 424 | * Date and time of alarm. |
425 | */ | 425 | */ |
426 | GSM_DateTime DateTime; | 426 | GSM_DateTime DateTime; |
427 | /** | 427 | /** |
428 | * Whether it repeats each day. | 428 | * Whether it repeats each day. |
429 | */ | 429 | */ |
430 | bool Repeating; | 430 | bool Repeating; |
431 | /** | 431 | /** |
432 | * Text that is shown on display. | 432 | * Text that is shown on display. |
433 | */ | 433 | */ |
434 | char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2]; | 434 | char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2]; |
435 | } GSM_Alarm; | 435 | } GSM_Alarm; |
436 | 436 | ||
437 | /* --------------------------- calendar & todo ----------------------------- */ | 437 | /* --------------------------- calendar & todo ----------------------------- */ |
438 | 438 | ||
439 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer); | 439 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer); |
440 | 440 | ||
441 | #endif | 441 | #endif |
442 | 442 | ||
443 | /* How should editor hadle tabs in this file? Add editor commands here. | 443 | /* How should editor hadle tabs in this file? Add editor commands here. |
444 | * vim: noexpandtab sw=8 ts=8 sts=8: | 444 | * vim: noexpandtab sw=8 ts=8 sts=8: |
445 | */ | 445 | */ |
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 | |||
@@ -201,143 +201,221 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W | |||
201 | } | 201 | } |
202 | /* PORT */ | 202 | /* PORT */ |
203 | if (settings->IsSecurity) { | 203 | if (settings->IsSecurity) { |
204 | if (settings->IsContinuous) { | 204 | if (settings->IsContinuous) { |
205 | /* Port = 9203. Continuous */ | 205 | /* Port = 9203. Continuous */ |
206 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x63); | 206 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x63); |
207 | } else { | 207 | } else { |
208 | /* Port = 9202. Temporary */ | 208 | /* Port = 9202. Temporary */ |
209 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x62); | 209 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x62); |
210 | } | 210 | } |
211 | } else { | 211 | } else { |
212 | if (settings->IsContinuous) { | 212 | if (settings->IsContinuous) { |
213 | /* Port = 9201. Continuous */ | 213 | /* Port = 9201. Continuous */ |
214 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x61); | 214 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x61); |
215 | } else { | 215 | } else { |
216 | /* Port = 9200. Temporary */ | 216 | /* Port = 9200. Temporary */ |
217 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x60); | 217 | AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x60); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | Buffer[(*Length)++] = 0x01; //END PARMeter | 220 | Buffer[(*Length)++] = 0x01; //END PARMeter |
221 | 221 | ||
222 | /* URL */ | 222 | /* URL */ |
223 | Buffer[(*Length)++] = 0x86; //CHARACTERISTIC-LIST with attributes | 223 | Buffer[(*Length)++] = 0x86; //CHARACTERISTIC-LIST with attributes |
224 | if (MMS) { | 224 | if (MMS) { |
225 | Buffer[(*Length)++] = 0x7C; //TYPE = MMSURL | 225 | Buffer[(*Length)++] = 0x7C; //TYPE = MMSURL |
226 | } else { | 226 | } else { |
227 | Buffer[(*Length)++] = 0x07; //TYPE = URL | 227 | Buffer[(*Length)++] = 0x07; //TYPE = URL |
228 | } | 228 | } |
229 | Buffer[(*Length)++] = 0x11; //VALUE | 229 | Buffer[(*Length)++] = 0x11; //VALUE |
230 | Buffer[(*Length)++] = 0x03; //Inline string | 230 | Buffer[(*Length)++] = 0x03; //Inline string |
231 | sprintf(buffer,"%s",DecodeUnicodeString(settings->HomePage)); | 231 | sprintf(buffer,"%s",DecodeUnicodeString(settings->HomePage)); |
232 | for (i=0;i<(int)strlen(buffer);i++) { | 232 | for (i=0;i<(int)strlen(buffer);i++) { |
233 | Buffer[(*Length)++] = buffer[i];//Text | 233 | Buffer[(*Length)++] = buffer[i];//Text |
234 | } | 234 | } |
235 | Buffer[(*Length)++] = 0x00; //END Inline string | 235 | Buffer[(*Length)++] = 0x00; //END Inline string |
236 | Buffer[(*Length)++] = 0x01; //END PARMeter | 236 | Buffer[(*Length)++] = 0x01; //END PARMeter |
237 | 237 | ||
238 | /* ISP_NAME (name) */ | 238 | /* ISP_NAME (name) */ |
239 | Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes | 239 | Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes |
240 | Buffer[(*Length)++] = 0x08; //TYPE=NAME | 240 | Buffer[(*Length)++] = 0x08; //TYPE=NAME |
241 | Buffer[(*Length)++] = 0x01; //END PARMeter | 241 | Buffer[(*Length)++] = 0x01; //END PARMeter |
242 | /* Settings name */ | 242 | /* Settings name */ |
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 */ | ||
249 | void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark) | 251 | void 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 | |||
318 | void 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 | ||
298 | void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length) | 376 | void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length) |
299 | { | 377 | { |
300 | int i; | 378 | int i; |
301 | 379 | ||
302 | strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F"); | 380 | strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F"); |
303 | (*Length)=(*Length)+4; | 381 | (*Length)=(*Length)+4; |
304 | 382 | ||
305 | /* Unique MMS ID ? */ | 383 | /* Unique MMS ID ? */ |
306 | strcpy(Buffer+(*Length),"123456789"); | 384 | strcpy(Buffer+(*Length),"123456789"); |
307 | (*Length)=(*Length)+9; | 385 | (*Length)=(*Length)+9; |
308 | Buffer[(*Length)++] = 0x00; | 386 | Buffer[(*Length)++] = 0x00; |
309 | 387 | ||
310 | strcpy(Buffer+(*Length),"\x8D\x90\x89"); | 388 | strcpy(Buffer+(*Length),"\x8D\x90\x89"); |
311 | (*Length)=(*Length)+3; | 389 | (*Length)=(*Length)+3; |
312 | 390 | ||
313 | strcpy(Buffer+(*Length),"\x01\x81\x86\x81\x96"); | 391 | strcpy(Buffer+(*Length),"\x01\x81\x86\x81\x96"); |
314 | (*Length)=(*Length)+5; | 392 | (*Length)=(*Length)+5; |
315 | 393 | ||
316 | if (UnicodeLength(Info->Subject) != 0) { | 394 | if (UnicodeLength(Info->Subject) != 0) { |
317 | sprintf(Buffer+(*Length),"%s",DecodeUnicodeString(Info->Subject)); | 395 | sprintf(Buffer+(*Length),"%s",DecodeUnicodeString(Info->Subject)); |
318 | (*Length)=(*Length)+UnicodeLength(Info->Subject); | 396 | (*Length)=(*Length)+UnicodeLength(Info->Subject); |
319 | Buffer[(*Length)++] = 0x00; | 397 | Buffer[(*Length)++] = 0x00; |
320 | } | 398 | } |
321 | 399 | ||
322 | for (i=0;i<Info->EntriesNum;i++) { | 400 | for (i=0;i<Info->EntriesNum;i++) { |
323 | switch(Info->Entries[i].ID) { | 401 | switch(Info->Entries[i].ID) { |
324 | case MMS_Text: | 402 | case MMS_Text: |
325 | strcpy(Buffer+(*Length),"\x84\xA3\x01\x04\x04\x03\x83\x81\xEA"); | 403 | strcpy(Buffer+(*Length),"\x84\xA3\x01\x04\x04\x03\x83\x81\xEA"); |
326 | (*Length)=(*Length)+9; | 404 | (*Length)=(*Length)+9; |
327 | 405 | ||
328 | sprintf(Buffer+(*Length),"%s",DecodeUnicodeString(Info->Entries[i].Buffer)); | 406 | sprintf(Buffer+(*Length),"%s",DecodeUnicodeString(Info->Entries[i].Buffer)); |
329 | (*Length)=(*Length)+UnicodeLength(Info->Entries[i].Buffer); | 407 | (*Length)=(*Length)+UnicodeLength(Info->Entries[i].Buffer); |
330 | break; | 408 | break; |
331 | default: | 409 | default: |
332 | break; | 410 | break; |
333 | } | 411 | } |
334 | } | 412 | } |
335 | } | 413 | } |
336 | 414 | ||
337 | void GSM_ClearMultiPartMMSInfo(GSM_EncodeMultiPartMMSInfo *Info) | 415 | void GSM_ClearMultiPartMMSInfo(GSM_EncodeMultiPartMMSInfo *Info) |
338 | { | 416 | { |
339 | Info->EntriesNum= 0; | 417 | Info->EntriesNum= 0; |
340 | Info->Subject[0]= 0x00; | 418 | Info->Subject[0]= 0x00; |
341 | Info->Subject[1]= 0x00; | 419 | Info->Subject[1]= 0x00; |
342 | Info->Source[0] = 0x00; | 420 | Info->Source[0] = 0x00; |
343 | Info->Source[1] = 0x00; | 421 | Info->Source[1] = 0x00; |
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 | |||
@@ -43,96 +43,98 @@ typedef struct { | |||
43 | char Code [(10+1)*2]; | 43 | char Code [(10+1)*2]; |
44 | 44 | ||
45 | /* for data or gprs */ | 45 | /* for data or gprs */ |
46 | char IPAddress[(20+1)*2]; | 46 | char IPAddress[(20+1)*2]; |
47 | bool ManualLogin; | 47 | bool ManualLogin; |
48 | char DialUp [(20+1)*2]; | 48 | char DialUp [(20+1)*2]; |
49 | char User [(50+1)*2]; /*is length OK ?*/ | 49 | char User [(50+1)*2]; /*is length OK ?*/ |
50 | char Password[(50+1)*2]; /*is length OK ?*/ | 50 | char Password[(50+1)*2]; /*is length OK ?*/ |
51 | WAPSettings_SpeedSpeed; | 51 | WAPSettings_SpeedSpeed; |
52 | } GSM_WAPSettings; | 52 | } GSM_WAPSettings; |
53 | 53 | ||
54 | typedef struct { | 54 | typedef struct { |
55 | int Location; | 55 | int Location; |
56 | unsigned char Number; | 56 | unsigned char Number; |
57 | GSM_WAPSettings Settings[4]; | 57 | GSM_WAPSettings Settings[4]; |
58 | bool Active; | 58 | bool Active; |
59 | bool ReadOnly; | 59 | bool ReadOnly; |
60 | char Proxy [(100+1)*2]; | 60 | char Proxy [(100+1)*2]; |
61 | int ProxyPort; | 61 | int ProxyPort; |
62 | char Proxy2 [(100+1)*2]; | 62 | char Proxy2 [(100+1)*2]; |
63 | int Proxy2Port; | 63 | int Proxy2Port; |
64 | 64 | ||
65 | WAPSettings_BearerActiveBearer; | 65 | WAPSettings_BearerActiveBearer; |
66 | } GSM_MultiWAPSettings; | 66 | } GSM_MultiWAPSettings; |
67 | 67 | ||
68 | void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_WAPSettings *settings, bool MMS); | 68 | void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_WAPSettings *settings, bool MMS); |
69 | 69 | ||
70 | /* -------------------------------- WAP Bookmark --------------------------- */ | 70 | /* -------------------------------- WAP Bookmark --------------------------- */ |
71 | 71 | ||
72 | typedef struct { | 72 | typedef struct { |
73 | char Address [(255+1)*2]; | 73 | char Address [(255+1)*2]; |
74 | char Title [(50+1)*2]; | 74 | char Title [(50+1)*2]; |
75 | int Location; | 75 | int Location; |
76 | } GSM_WAPBookmark; | 76 | } GSM_WAPBookmark; |
77 | 77 | ||
78 | void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark); | 78 | void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark); |
79 | GSM_Error GSM_EncodeURLFile (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark); | 79 | GSM_Error GSM_EncodeURLFile (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark); |
80 | 80 | ||
81 | /* ------------------------------ MMS Indicator ---------------------------- */ | 81 | /* ------------------------------ MMS Indicator ---------------------------- */ |
82 | 82 | ||
83 | typedef struct { | 83 | typedef struct { |
84 | unsigned char Address[500]; | 84 | unsigned char Address[500]; |
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 | ||
89 | void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator); | 89 | void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator); |
90 | 90 | ||
91 | void 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 | ||
95 | typedef enum { | 97 | typedef enum { |
96 | MMS_Text = 1, | 98 | MMS_Text = 1, |
97 | MMS_Bitmap_JPG | 99 | MMS_Bitmap_JPG |
98 | } EncodeMultiPartMMSID; | 100 | } EncodeMultiPartMMSID; |
99 | 101 | ||
100 | typedef struct { | 102 | typedef struct { |
101 | EncodeMultiPartMMSID ID; | 103 | EncodeMultiPartMMSID ID; |
102 | 104 | ||
103 | GSM_File File; | 105 | GSM_File File; |
104 | unsigned char *Buffer; | 106 | unsigned char *Buffer; |
105 | } EncodeMultiPartMMSEntry; | 107 | } EncodeMultiPartMMSEntry; |
106 | 108 | ||
107 | typedef struct { | 109 | typedef struct { |
108 | /* Input values */ | 110 | /* Input values */ |
109 | EncodeMultiPartMMSEntry Entries[MAX_MULTI_MMS]; | 111 | EncodeMultiPartMMSEntry Entries[MAX_MULTI_MMS]; |
110 | int EntriesNum; | 112 | int EntriesNum; |
111 | 113 | ||
112 | unsigned char Source[200]; | 114 | unsigned char Source[200]; |
113 | unsigned char Destination[200]; | 115 | unsigned char Destination[200]; |
114 | unsigned char Subject[200]; | 116 | unsigned char Subject[200]; |
115 | } GSM_EncodeMultiPartMMSInfo; | 117 | } GSM_EncodeMultiPartMMSInfo; |
116 | 118 | ||
117 | void GSM_EncodeMMSFile (GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length); | 119 | void GSM_EncodeMMSFile (GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length); |
118 | void GSM_ClearMultiPartMMSInfo(GSM_EncodeMultiPartMMSInfo *Info); | 120 | void GSM_ClearMultiPartMMSInfo(GSM_EncodeMultiPartMMSInfo *Info); |
119 | 121 | ||
120 | /* ------------------------------------------------------------------------ */ | 122 | /* ------------------------------------------------------------------------ */ |
121 | 123 | ||
122 | typedef struct { | 124 | typedef struct { |
123 | int Location; | 125 | int Location; |
124 | bool Active; | 126 | bool Active; |
125 | bool SyncPhonebook; | 127 | bool SyncPhonebook; |
126 | bool SyncCalendar; | 128 | bool SyncCalendar; |
127 | char Name[(20+1)*2]; | 129 | char Name[(20+1)*2]; |
128 | char PhonebookDataBase[(50+1)*2]; | 130 | char PhonebookDataBase[(50+1)*2]; |
129 | char CalendarDataBase[(50+1)*2]; | 131 | char CalendarDataBase[(50+1)*2]; |
130 | char User[(30+1)*2]; | 132 | char User[(30+1)*2]; |
131 | char Password[(20+1)*2]; | 133 | char Password[(20+1)*2]; |
132 | char Server[(128+1)*2]; | 134 | char Server[(128+1)*2]; |
133 | GSM_MultiWAPSettingsConnection; | 135 | GSM_MultiWAPSettingsConnection; |
134 | } GSM_SyncMLSettings; | 136 | } GSM_SyncMLSettings; |
135 | 137 | ||
136 | /* ------------------------------------------------------------------------ */ | 138 | /* ------------------------------------------------------------------------ */ |
137 | 139 | ||
138 | typedef struct { | 140 | typedef struct { |
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,52 +1,53 @@ | |||
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 | ||
11 | void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, int *width, int *height) | 12 | void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, int *width, int *height) |
12 | { | 13 | { |
13 | *width = 0; | 14 | *width = 0; |
14 | *height= 0; | 15 | *height= 0; |
15 | switch (Type) { | 16 | switch (Type) { |
16 | case GSM_EMSSmallPicture: *width=8; *height=8; break; | 17 | case GSM_EMSSmallPicture: *width=8; *height=8; break; |
17 | case GSM_EMSMediumPicture: *width=16; *height=16; break; | 18 | case GSM_EMSMediumPicture: *width=16; *height=16; break; |
18 | case GSM_EMSBigPicture : *width=32; *height=32; break; | 19 | case GSM_EMSBigPicture : *width=32; *height=32; break; |
19 | case GSM_NokiaOperatorLogo: | 20 | case GSM_NokiaOperatorLogo: |
20 | case GSM_NokiaCallerLogo: *width=72; *height=14; break; | 21 | case GSM_NokiaCallerLogo: *width=72; *height=14; break; |
21 | case GSM_NokiaPictureImage: *width=72; *height=28; break; | 22 | case GSM_NokiaPictureImage: *width=72; *height=28; break; |
22 | case GSM_Nokia7110OperatorLogo: | 23 | case GSM_Nokia7110OperatorLogo: |
23 | case GSM_Nokia6510OperatorLogo: *width=78; *height=21; break; | 24 | case GSM_Nokia6510OperatorLogo: *width=78; *height=21; break; |
24 | case GSM_NokiaStartupLogo: *width=84; *height=48; break; | 25 | case GSM_NokiaStartupLogo: *width=84; *height=48; break; |
25 | case GSM_Nokia6210StartupLogo: *width=96; *height=60; break; | 26 | case GSM_Nokia6210StartupLogo: *width=96; *height=60; break; |
26 | case GSM_Nokia7110StartupLogo: *width=96; *height=65; break; | 27 | case GSM_Nokia7110StartupLogo: *width=96; *height=65; break; |
27 | case GSM_EMSVariablePicture : break; | 28 | case GSM_EMSVariablePicture : break; |
28 | case GSM_AlcatelBMMIPicture : break; | 29 | case GSM_AlcatelBMMIPicture : break; |
29 | } | 30 | } |
30 | } | 31 | } |
31 | 32 | ||
32 | int PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, int Width, int Height) | 33 | int PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, int Width, int Height) |
33 | { | 34 | { |
34 | int width, height, x; | 35 | int width, height, x; |
35 | 36 | ||
36 | PHONE_GetBitmapWidthHeight(Type, &width, &height); | 37 | PHONE_GetBitmapWidthHeight(Type, &width, &height); |
37 | if (width == 0 && height == 0) { | 38 | if (width == 0 && height == 0) { |
38 | width = Width; | 39 | width = Width; |
39 | height = Height; | 40 | height = Height; |
40 | } | 41 | } |
41 | switch (Type) { | 42 | switch (Type) { |
42 | case GSM_Nokia6510OperatorLogo: | 43 | case GSM_Nokia6510OperatorLogo: |
43 | x = width * height; | 44 | x = width * height; |
44 | return x/8 + (x%8 > 0); | 45 | return x/8 + (x%8 > 0); |
45 | case GSM_Nokia7110OperatorLogo: | 46 | case GSM_Nokia7110OperatorLogo: |
46 | return (width*height + 7)/8; | 47 | return (width*height + 7)/8; |
47 | case GSM_NokiaStartupLogo: | 48 | case GSM_NokiaStartupLogo: |
48 | case GSM_NokiaOperatorLogo: | 49 | case GSM_NokiaOperatorLogo: |
49 | case GSM_NokiaCallerLogo: | 50 | case GSM_NokiaCallerLogo: |
50 | case GSM_NokiaPictureImage: | 51 | case GSM_NokiaPictureImage: |
51 | case GSM_EMSSmallPicture: | 52 | case GSM_EMSSmallPicture: |
52 | case GSM_EMSMediumPicture: | 53 | case GSM_EMSMediumPicture: |
@@ -116,96 +117,97 @@ static void PHONE_SetPointBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int | |||
116 | case GSM_NokiaPictureImage: | 117 | case GSM_NokiaPictureImage: |
117 | buffer[9*y + x/8] |= 1 << (7-(x%8)); | 118 | buffer[9*y + x/8] |= 1 << (7-(x%8)); |
118 | break; | 119 | break; |
119 | case GSM_AlcatelBMMIPicture: | 120 | case GSM_AlcatelBMMIPicture: |
120 | pixel = height / 8; | 121 | pixel = height / 8; |
121 | if ((height % 8) != 0) pixel++; | 122 | if ((height % 8) != 0) pixel++; |
122 | buffer[pixel*x + y/8] |= 1 << (7 - (y%8)); | 123 | buffer[pixel*x + y/8] |= 1 << (7 - (y%8)); |
123 | break; | 124 | break; |
124 | } | 125 | } |
125 | } | 126 | } |
126 | 127 | ||
127 | void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap) | 128 | void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap) |
128 | { | 129 | { |
129 | int width, height, x,y; | 130 | int width, height, x,y; |
130 | 131 | ||
131 | PHONE_GetBitmapWidthHeight(Type, &width, &height); | 132 | PHONE_GetBitmapWidthHeight(Type, &width, &height); |
132 | if (Type != GSM_Nokia6510OperatorLogo && Type != GSM_Nokia7110OperatorLogo && Type != GSM_EMSVariablePicture) { | 133 | if (Type != GSM_Nokia6510OperatorLogo && Type != GSM_Nokia7110OperatorLogo && Type != GSM_EMSVariablePicture) { |
133 | Bitmap->BitmapHeight= height; | 134 | Bitmap->BitmapHeight= height; |
134 | Bitmap->BitmapWidth= width; | 135 | Bitmap->BitmapWidth= width; |
135 | } | 136 | } |
136 | switch (Type) { | 137 | switch (Type) { |
137 | case GSM_NokiaOperatorLogo: | 138 | case GSM_NokiaOperatorLogo: |
138 | case GSM_Nokia7110OperatorLogo: | 139 | case GSM_Nokia7110OperatorLogo: |
139 | case GSM_Nokia6510OperatorLogo : Bitmap->Type=GSM_OperatorLogo;break; | 140 | case GSM_Nokia6510OperatorLogo : Bitmap->Type=GSM_OperatorLogo;break; |
140 | case GSM_NokiaCallerLogo : Bitmap->Type=GSM_CallerGroupLogo;break; | 141 | case GSM_NokiaCallerLogo : Bitmap->Type=GSM_CallerGroupLogo;break; |
141 | case GSM_AlcatelBMMIPicture : | 142 | case GSM_AlcatelBMMIPicture : |
142 | case GSM_NokiaStartupLogo: | 143 | case GSM_NokiaStartupLogo: |
143 | case GSM_Nokia7110StartupLogo: | 144 | case GSM_Nokia7110StartupLogo: |
144 | case GSM_Nokia6210StartupLogo : Bitmap->Type=GSM_StartupLogo; break; | 145 | case GSM_Nokia6210StartupLogo : Bitmap->Type=GSM_StartupLogo; break; |
145 | case GSM_NokiaPictureImage: | 146 | case GSM_NokiaPictureImage: |
146 | case GSM_EMSVariablePicture: | 147 | case GSM_EMSVariablePicture: |
147 | case GSM_EMSSmallPicture: | 148 | case GSM_EMSSmallPicture: |
148 | case GSM_EMSMediumPicture: | 149 | case GSM_EMSMediumPicture: |
149 | case GSM_EMSBigPicture : Bitmap->Type=GSM_PictureImage;break; | 150 | case GSM_EMSBigPicture : Bitmap->Type=GSM_PictureImage;break; |
150 | } | 151 | } |
151 | 152 | ||
152 | Bitmap->Location = 0; | 153 | Bitmap->Location = 0; |
153 | Bitmap->Text[0] = 0; | 154 | Bitmap->Text[0] = 0; |
154 | Bitmap->Text[1] = 0; | 155 | Bitmap->Text[1] = 0; |
155 | Bitmap->BitmapEnabled = false; | 156 | Bitmap->BitmapEnabled = false; |
156 | Bitmap->DefaultName = false; | 157 | Bitmap->DefaultName = false; |
157 | Bitmap->DefaultBitmap = false; | 158 | Bitmap->DefaultBitmap = false; |
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); |
170 | } | 172 | } |
171 | } | 173 | } |
172 | } | 174 | } |
173 | } | 175 | } |
174 | 176 | ||
175 | void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int width, int height) | 177 | void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int width, int height) |
176 | { | 178 | { |
177 | memset(buffer,0,PHONE_GetBitmapSize(Type,width,height)); | 179 | memset(buffer,0,PHONE_GetBitmapSize(Type,width,height)); |
178 | } | 180 | } |
179 | 181 | ||
180 | void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap) | 182 | void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap) |
181 | { | 183 | { |
182 | int width, height, x, y; | 184 | int width, height, x, y; |
183 | GSM_Bitmapdest; | 185 | GSM_Bitmapdest; |
184 | 186 | ||
185 | PHONE_GetBitmapWidthHeight(Type, &width, &height); | 187 | PHONE_GetBitmapWidthHeight(Type, &width, &height); |
186 | if (width == 0 && height == 0) { | 188 | if (width == 0 && height == 0) { |
187 | width = Bitmap->BitmapWidth; | 189 | width = Bitmap->BitmapWidth; |
188 | height = Bitmap->BitmapHeight; | 190 | height = Bitmap->BitmapHeight; |
189 | } | 191 | } |
190 | GSM_ResizeBitmap(&dest, Bitmap, width, height); | 192 | GSM_ResizeBitmap(&dest, Bitmap, width, height); |
191 | PHONE_ClearBitmap(Type, buffer, width, height); | 193 | PHONE_ClearBitmap(Type, buffer, width, height); |
192 | 194 | ||
193 | for (x=0;x<width;x++) { | 195 | for (x=0;x<width;x++) { |
194 | for (y=0;y<height;y++) { | 196 | for (y=0;y<height;y++) { |
195 | if (GSM_IsPointBitmap(&dest,x,y)) PHONE_SetPointBitmap(Type, buffer, x, y, width, height); | 197 | if (GSM_IsPointBitmap(&dest,x,y)) PHONE_SetPointBitmap(Type, buffer, x, y, width, height); |
196 | } | 198 | } |
197 | } | 199 | } |
198 | } | 200 | } |
199 | 201 | ||
200 | void GSM_GetMaxBitmapWidthHeight(GSM_Bitmap_Types Type, unsigned char *width, unsigned char *height) | 202 | void GSM_GetMaxBitmapWidthHeight(GSM_Bitmap_Types Type, unsigned char *width, unsigned char *height) |
201 | { | 203 | { |
202 | switch (Type) { | 204 | switch (Type) { |
203 | case GSM_CallerGroupLogo: *width=72; *height=14; break; | 205 | case GSM_CallerGroupLogo: *width=72; *height=14; break; |
204 | case GSM_OperatorLogo: *width=101;*height=21; break; | 206 | case GSM_OperatorLogo: *width=101;*height=21; break; |
205 | case GSM_StartupLogo: *width=96; *height=65; break; | 207 | case GSM_StartupLogo: *width=96; *height=65; break; |
206 | case GSM_PictureImage: *width=72; *height=28; break; | 208 | case GSM_PictureImage: *width=72; *height=28; break; |
207 | default : break; | 209 | default : break; |
208 | } | 210 | } |
209 | } | 211 | } |
210 | 212 | ||
211 | void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y) | 213 | void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y) |
@@ -581,107 +583,107 @@ static GSM_Error savexpm(FILE *file, GSM_MultiBitmap *bitmap) | |||
581 | if (y==bitmap->Bitmap[0].BitmapHeight-1) { | 583 | if (y==bitmap->Bitmap[0].BitmapHeight-1) { |
582 | fprintf(file,"};\n"); | 584 | fprintf(file,"};\n"); |
583 | } else { | 585 | } else { |
584 | fprintf(file,",\n"); | 586 | fprintf(file,",\n"); |
585 | } | 587 | } |
586 | } | 588 | } |
587 | 589 | ||
588 | return ERR_NONE; | 590 | return ERR_NONE; |
589 | } | 591 | } |
590 | 592 | ||
591 | static GSM_Error savensl(FILE *file, GSM_MultiBitmap *bitmap) | 593 | static GSM_Error savensl(FILE *file, GSM_MultiBitmap *bitmap) |
592 | { | 594 | { |
593 | char buffer[GSM_BITMAP_SIZE]; | 595 | char buffer[GSM_BITMAP_SIZE]; |
594 | unsigned char header[]={ | 596 | unsigned char header[]={ |
595 | 'F','O','R','M', 0x01,0xFE,/* File ID block, size 1*256+0xFE=510*/ | 597 | 'F','O','R','M', 0x01,0xFE,/* File ID block, size 1*256+0xFE=510*/ |
596 | 'N','S','L','D', 0x01,0xF8};/* Startup Logo block, size 1*256+0xF8=504*/ | 598 | 'N','S','L','D', 0x01,0xF8};/* Startup Logo block, size 1*256+0xF8=504*/ |
597 | 599 | ||
598 | fwrite(header,1,sizeof(header),file); | 600 | fwrite(header,1,sizeof(header),file); |
599 | PHONE_EncodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]); | 601 | PHONE_EncodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]); |
600 | fwrite(buffer,1,PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0),file); | 602 | fwrite(buffer,1,PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0),file); |
601 | 603 | ||
602 | return ERR_NONE; | 604 | return ERR_NONE; |
603 | } | 605 | } |
604 | 606 | ||
605 | static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap) | 607 | static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap) |
606 | { | 608 | { |
607 | unsigned char buffer[4]; | 609 | unsigned char buffer[4]; |
608 | 610 | ||
609 | buffer[0] = 0x00; | 611 | buffer[0] = 0x00; |
610 | buffer[1] = 0x00; | 612 | buffer[1] = 0x00; |
611 | buffer[2] = bitmap->Bitmap[0].BitmapWidth; | 613 | buffer[2] = bitmap->Bitmap[0].BitmapWidth; |
612 | buffer[3] = bitmap->Bitmap[0].BitmapHeight; | 614 | buffer[3] = bitmap->Bitmap[0].BitmapHeight; |
613 | fwrite(buffer,1,4,file); | 615 | fwrite(buffer,1,4,file); |
614 | 616 | ||
615 | PrivSaveNLMWBMP(file, &bitmap->Bitmap[0]); | 617 | PrivSaveNLMWBMP(file, &bitmap->Bitmap[0]); |
616 | 618 | ||
617 | return ERR_NONE; | 619 | return ERR_NONE; |
618 | } | 620 | } |
619 | 621 | ||
620 | GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | 622 | GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) |
621 | { | 623 | { |
622 | FILE *file; | 624 | FILE *file; |
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 | ||
646 | return error; | 648 | return error; |
647 | } | 649 | } |
648 | 650 | ||
649 | GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap) | 651 | GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap) |
650 | { | 652 | { |
651 | bool first_white,isfile=false; | 653 | bool first_white,isfile=false; |
652 | unsigned char buff[34]; | 654 | unsigned char buff[34]; |
653 | int w,h,pos,y,x,i,buffpos=0; | 655 | int w,h,pos,y,x,i,buffpos=0; |
654 | #ifdef DEBUG | 656 | #ifdef DEBUG |
655 | int sizeimage=0; | 657 | int sizeimage=0; |
656 | #endif | 658 | #endif |
657 | 659 | ||
658 | if (bitmap->Type == GSM_None) bitmap->Type = GSM_StartupLogo; | 660 | if (bitmap->Type == GSM_None) bitmap->Type = GSM_StartupLogo; |
659 | if (file!=NULL) isfile=true; | 661 | if (file!=NULL) isfile=true; |
660 | if (isfile) { | 662 | if (isfile) { |
661 | fread(buff, 1, 34, file); | 663 | fread(buff, 1, 34, file); |
662 | } else { | 664 | } else { |
663 | memcpy(buff,buffer,34); | 665 | memcpy(buff,buffer,34); |
664 | } | 666 | } |
665 | 667 | ||
666 | /* height and width of image in the file */ | 668 | /* height and width of image in the file */ |
667 | h=buff[22]+256*buff[21]; | 669 | h=buff[22]+256*buff[21]; |
668 | w=buff[18]+256*buff[17]; | 670 | w=buff[18]+256*buff[17]; |
669 | dbgprintf("Image Size in BMP file: %dx%d\n",w,h); | 671 | dbgprintf("Image Size in BMP file: %dx%d\n",w,h); |
670 | 672 | ||
671 | GSM_GetMaxBitmapWidthHeight(bitmap->Type, &bitmap->BitmapWidth, &bitmap->BitmapHeight); | 673 | GSM_GetMaxBitmapWidthHeight(bitmap->Type, &bitmap->BitmapWidth, &bitmap->BitmapHeight); |
672 | if (h<bitmap->BitmapHeight)bitmap->BitmapHeight=h; | 674 | if (h<bitmap->BitmapHeight)bitmap->BitmapHeight=h; |
673 | if (w<bitmap->BitmapWidth)bitmap->BitmapWidth=w; | 675 | if (w<bitmap->BitmapWidth)bitmap->BitmapWidth=w; |
674 | dbgprintf("Height %i %i, width %i %i\n",h,bitmap->BitmapHeight,w,bitmap->BitmapWidth); | 676 | dbgprintf("Height %i %i, width %i %i\n",h,bitmap->BitmapHeight,w,bitmap->BitmapWidth); |
675 | 677 | ||
676 | GSM_ClearBitmap(bitmap); | 678 | GSM_ClearBitmap(bitmap); |
677 | 679 | ||
678 | #ifdef DEBUG | 680 | #ifdef DEBUG |
679 | dbgprintf("Number of colors in BMP file: "); | 681 | dbgprintf("Number of colors in BMP file: "); |
680 | switch (buff[28]) { | 682 | switch (buff[28]) { |
681 | case 1 : dbgprintf("2 (supported)\n"); break; | 683 | case 1 : dbgprintf("2 (supported)\n"); break; |
682 | case 4 : dbgprintf("16 (NOT SUPPORTED)\n"); break; | 684 | case 4 : dbgprintf("16 (NOT SUPPORTED)\n"); break; |
683 | case 8 : dbgprintf("256 (NOT SUPPORTED)\n"); break; | 685 | case 8 : dbgprintf("256 (NOT SUPPORTED)\n"); break; |
684 | case 24 : dbgprintf("True Color (NOT SUPPORTED)\n"); break; | 686 | case 24 : dbgprintf("True Color (NOT SUPPORTED)\n"); break; |
685 | default : dbgprintf("unknown\n"); break; | 687 | default : dbgprintf("unknown\n"); break; |
686 | } | 688 | } |
687 | #endif | 689 | #endif |
@@ -910,94 +912,127 @@ static GSM_Error loadnsl(FILE *file, GSM_MultiBitmap *bitmap) | |||
910 | 912 | ||
911 | while (fread(block,1,6,file)==6) { | 913 | while (fread(block,1,6,file)==6) { |
912 | block_size = block[4]*256 + block[5]; | 914 | block_size = block[4]*256 + block[5]; |
913 | dbgprintf("Block %c%c%c%c, size %i\n",block[0],block[1],block[2],block[3],block_size); | 915 | dbgprintf("Block %c%c%c%c, size %i\n",block[0],block[1],block[2],block[3],block_size); |
914 | if (!strncmp(block, "FORM", 4)) { | 916 | if (!strncmp(block, "FORM", 4)) { |
915 | dbgprintf("File ID\n"); | 917 | dbgprintf("File ID\n"); |
916 | } else { | 918 | } else { |
917 | if (block_size>504) return ERR_UNKNOWN; | 919 | if (block_size>504) return ERR_UNKNOWN; |
918 | if (block_size!=0) { | 920 | if (block_size!=0) { |
919 | fread(buffer,1,block_size,file); | 921 | fread(buffer,1,block_size,file); |
920 | /* if it's string, we end it with 0 */ | 922 | /* if it's string, we end it with 0 */ |
921 | buffer[block_size]=0; | 923 | buffer[block_size]=0; |
922 | #ifdef DEBUG | 924 | #ifdef DEBUG |
923 | if (!strncmp(block, "VERS", 4)) dbgprintf("File saved by: %s\n",buffer); | 925 | if (!strncmp(block, "VERS", 4)) dbgprintf("File saved by: %s\n",buffer); |
924 | if (!strncmp(block, "MODL", 4)) dbgprintf("Logo saved from: %s\n",buffer); | 926 | if (!strncmp(block, "MODL", 4)) dbgprintf("Logo saved from: %s\n",buffer); |
925 | if (!strncmp(block, "COMM", 4)) dbgprintf("Phone was connected to COM port: %s\n",buffer); | 927 | if (!strncmp(block, "COMM", 4)) dbgprintf("Phone was connected to COM port: %s\n",buffer); |
926 | #endif | 928 | #endif |
927 | if (!strncmp(block, "NSLD", 4)) { | 929 | if (!strncmp(block, "NSLD", 4)) { |
928 | bitmap->Bitmap[0].BitmapHeight = 48; | 930 | bitmap->Bitmap[0].BitmapHeight = 48; |
929 | bitmap->Bitmap[0].BitmapWidth = 84; | 931 | bitmap->Bitmap[0].BitmapWidth = 84; |
930 | OldType = bitmap->Bitmap[0].Type; | 932 | OldType = bitmap->Bitmap[0].Type; |
931 | PHONE_DecodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]); | 933 | PHONE_DecodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]); |
932 | if (OldType != GSM_None) bitmap->Bitmap[0].Type = OldType; | 934 | if (OldType != GSM_None) bitmap->Bitmap[0].Type = OldType; |
933 | dbgprintf("Startup logo (size %i)\n",block_size); | 935 | dbgprintf("Startup logo (size %i)\n",block_size); |
934 | } | 936 | } |
935 | } | 937 | } |
936 | } | 938 | } |
937 | } | 939 | } |
938 | bitmap->Number = 1; | 940 | bitmap->Number = 1; |
939 | return(ERR_NONE); | 941 | return(ERR_NONE); |
940 | } | 942 | } |
941 | 943 | ||
942 | static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap) | 944 | static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap) |
943 | { | 945 | { |
944 | unsigned char buffer[10000]; | 946 | unsigned char buffer[10000]; |
945 | 947 | ||
946 | fread(buffer,1,4,file); | 948 | fread(buffer,1,4,file); |
947 | bitmap->Bitmap[0].BitmapWidth = buffer[2]; | 949 | bitmap->Bitmap[0].BitmapWidth = buffer[2]; |
948 | bitmap->Bitmap[0].BitmapHeight = buffer[3]; | 950 | bitmap->Bitmap[0].BitmapHeight = buffer[3]; |
949 | bitmap->Number = 1; | 951 | bitmap->Number = 1; |
950 | 952 | ||
951 | fread(buffer,1,10000,file); | 953 | fread(buffer,1,10000,file); |
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 | ||
960 | static 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 | |||
958 | GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | 987 | GSM_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 */ |
972 | if (memcmp(buffer, "BM",2)==0) { | 1005 | if (memcmp(buffer, "BM",2)==0) { |
973 | return loadbmp(file,bitmap); | 1006 | return loadbmp(file,bitmap); |
974 | } else if (buffer[0] == 0x00 && buffer[1] == 0x00) { | 1007 | } else if (buffer[0] == 0x00 && buffer[1] == 0x00) { |
975 | return loadwbmp(file,bitmap); | 1008 | return loadwbmp(file,bitmap); |
976 | } else if (memcmp(buffer, "NLM",3)==0) { | 1009 | } else if (memcmp(buffer, "NLM",3)==0) { |
977 | return loadnlm(file,bitmap); | 1010 | return loadnlm(file,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 | ||
988 | void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length) | 1023 | void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length) |
989 | { | 1024 | { |
990 | int Width, Height; | 1025 | int Width, Height; |
991 | 1026 | ||
992 | Buffer[(*Length)++] = 0x00; | 1027 | Buffer[(*Length)++] = 0x00; |
993 | PHONE_GetBitmapWidthHeight(Type, &Width, &Height); | 1028 | PHONE_GetBitmapWidthHeight(Type, &Width, &Height); |
994 | Buffer[(*Length)++] = Width; | 1029 | Buffer[(*Length)++] = Width; |
995 | Buffer[(*Length)++] = Height; | 1030 | Buffer[(*Length)++] = Height; |
996 | Buffer[(*Length)++] = 0x01; | 1031 | Buffer[(*Length)++] = 0x01; |
997 | PHONE_EncodeBitmap(Type, Buffer + (*Length), Bitmap); | 1032 | PHONE_EncodeBitmap(Type, Buffer + (*Length), Bitmap); |
998 | (*Length) = (*Length) + PHONE_GetBitmapSize(Type,0,0); | 1033 | (*Length) = (*Length) + PHONE_GetBitmapSize(Type,0,0); |
999 | } | 1034 | } |
1000 | 1035 | ||
1001 | /* How should editor hadle tabs in this file? Add editor commands here. | 1036 | /* How should editor hadle tabs in this file? Add editor commands here. |
1002 | * vim: noexpandtab sw=8 ts=8 sts=8: | 1037 | * vim: noexpandtab sw=8 ts=8 sts=8: |
1003 | */ | 1038 | */ |
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 | |||
@@ -1,165 +1,191 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
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 | ||
8 | typedef enum { | ||
9 | PICTURE_BMP = 1, | ||
10 | PICTURE_GIF, | ||
11 | PICTURE_JPG, | ||
12 | PICTURE_ICN, | ||
13 | PICTURE_PNG | ||
14 | } GSM_BinaryPicture_Types; | ||
15 | |||
16 | typedef 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 | */ |
11 | typedef enum { | 25 | typedef enum { |
12 | GSM_None = 1, | 26 | GSM_None = 1, |
13 | /** | 27 | /** |
14 | * ID of static file in filesystem displayed during startup | 28 | * ID of static file in filesystem displayed during startup |
15 | */ | 29 | */ |
16 | GSM_ColourStartupLogo_ID, | 30 | GSM_ColourStartupLogo_ID, |
17 | /** | 31 | /** |
18 | * Static mono bitmap/ID of animated mono bitmap displayed during startup | 32 | * Static mono bitmap/ID of animated mono bitmap displayed during startup |
19 | */ | 33 | */ |
20 | GSM_StartupLogo, | 34 | GSM_StartupLogo, |
21 | /** | 35 | /** |
22 | * ID of static file in filesystem displayed instead of operator name | 36 | * ID of static file in filesystem displayed instead of operator name |
23 | */ | 37 | */ |
24 | GSM_ColourOperatorLogo_ID, | 38 | GSM_ColourOperatorLogo_ID, |
25 | /** | 39 | /** |
26 | * Mono bitmap displayed instead of operator name | 40 | * Mono bitmap displayed instead of operator name |
27 | */ | 41 | */ |
28 | GSM_OperatorLogo, | 42 | GSM_OperatorLogo, |
29 | /** | 43 | /** |
30 | * ID of static file in filesystem displayed as wallpaper | 44 | * ID of static file in filesystem displayed as wallpaper |
31 | */ | 45 | */ |
32 | GSM_ColourWallPaper_ID, | 46 | GSM_ColourWallPaper_ID, |
33 | /** | 47 | /** |
34 | * Mono bitmap assigned to caller group | 48 | * Mono bitmap assigned to caller group |
35 | */ | 49 | */ |
36 | GSM_CallerGroupLogo, | 50 | GSM_CallerGroupLogo, |
37 | /** | 51 | /** |
38 | * Text displayed during startup, which can't be removed from phone menu | 52 | * Text displayed during startup, which can't be removed from phone menu |
39 | */ | 53 | */ |
40 | GSM_DealerNote_Text, | 54 | GSM_DealerNote_Text, |
41 | /** | 55 | /** |
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 | /** |
55 | * Structure for all possible bitmaps, which are not saved in various filesystems | 73 | * Structure for all possible bitmaps, which are not saved in various filesystems |
56 | */ | 74 | */ |
57 | typedef struct { | 75 | typedef struct { |
58 | /** | 76 | /** |
59 | * For all: bitmap type | 77 | * For all: bitmap type |
60 | */ | 78 | */ |
61 | GSM_Bitmap_Types Type; | 79 | GSM_Bitmap_Types Type; |
62 | /** | 80 | /** |
63 | * For caller group logos: number of group | 81 | * For caller group logos: number of group |
64 | * For startup logos: number of animated bitmap | 82 | * For startup logos: number of animated bitmap |
65 | */ | 83 | */ |
66 | unsigned char Location; | 84 | unsigned char Location; |
67 | /** | 85 | /** |
68 | * For dealer/welcome note text: text | 86 | * For dealer/welcome note text: text |
69 | * For caller group logo: name of group | 87 | * For caller group logo: name of group |
70 | * For picture images: text assigned to it | 88 | * For picture images: text assigned to it |
71 | */ | 89 | */ |
72 | unsigned char Text[2 * (GSM_BITMAP_TEXT_LENGTH + 1)]; | 90 | unsigned char Text[2 * (GSM_BITMAP_TEXT_LENGTH + 1)]; |
73 | /** | 91 | /** |
74 | * For caller group logo: true, when logo is enabled in group | 92 | * For caller group logo: true, when logo is enabled in group |
75 | */ | 93 | */ |
76 | bool BitmapEnabled; | 94 | bool BitmapEnabled; |
77 | /** | 95 | /** |
78 | * For caller group logo: true, when group has default name | 96 | * For caller group logo: true, when group has default name |
79 | */ | 97 | */ |
80 | bool DefaultName; | 98 | bool DefaultName; |
81 | /** | 99 | /** |
82 | * For caller group logo: true, when group has default bitmap | 100 | * For caller group logo: true, when group has default bitmap |
83 | */ | 101 | */ |
84 | bool DefaultBitmap; | 102 | bool DefaultBitmap; |
85 | /** | 103 | /** |
86 | * For caller group logo: true, when group has default ringtone | 104 | * For caller group logo: true, when group has default ringtone |
87 | */ | 105 | */ |
88 | bool DefaultRingtone; | 106 | bool DefaultRingtone; |
89 | /** | 107 | /** |
90 | * For caller group logo: ringtone ID. Phone model specific | 108 | * For caller group logo: ringtone ID. Phone model specific |
91 | */ | 109 | */ |
92 | unsigned char RingtoneID; | 110 | unsigned char RingtoneID; |
93 | bool FileSystemRingtone; | 111 | bool FileSystemRingtone; |
94 | /** | 112 | /** |
95 | * For mono bitmaps: body of bitmap | 113 | * For mono bitmaps: body of bitmap |
96 | */ | 114 | */ |
97 | unsigned char BitmapPoints[GSM_BITMAP_SIZE]; | 115 | unsigned char BitmapPoints[GSM_BITMAP_SIZE]; |
98 | /** | 116 | /** |
99 | * For mono bitmaps: height specified in pixels | 117 | * For mono bitmaps: height specified in pixels |
100 | */ | 118 | */ |
101 | unsigned char BitmapHeight; | 119 | unsigned char BitmapHeight; |
102 | /** | 120 | /** |
103 | * For mono bitmaps: width specified in pixels | 121 | * For mono bitmaps: width specified in pixels |
104 | */ | 122 | */ |
105 | unsigned char BitmapWidth; | 123 | unsigned char BitmapWidth; |
106 | /** | 124 | /** |
107 | * For operator logos: Network operator code | 125 | * For operator logos: Network operator code |
108 | */ | 126 | */ |
109 | char NetworkCode[7]; | 127 | char NetworkCode[7]; |
110 | /** | 128 | /** |
111 | * For picture images: number of sender | 129 | * For picture images: number of sender |
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 |
124 | */ | 150 | */ |
125 | typedef struct { | 151 | typedef struct { |
126 | /** | 152 | /** |
127 | * Number of bitmaps | 153 | * Number of bitmaps |
128 | */ | 154 | */ |
129 | unsigned char Number; | 155 | unsigned char Number; |
130 | /** | 156 | /** |
131 | * All bitmaps | 157 | * All bitmaps |
132 | */ | 158 | */ |
133 | GSM_Bitmap Bitmap[MAX_MULTI_BITMAP]; | 159 | GSM_Bitmap Bitmap[MAX_MULTI_BITMAP]; |
134 | } GSM_MultiBitmap; | 160 | } GSM_MultiBitmap; |
135 | 161 | ||
136 | typedef enum { | 162 | typedef enum { |
137 | GSM_NokiaStartupLogo = 1,/*size 84*48*/ | 163 | GSM_NokiaStartupLogo = 1,/*size 84*48*/ |
138 | GSM_NokiaOperatorLogo, /*size 72*14*/ | 164 | GSM_NokiaOperatorLogo, /*size 72*14*/ |
139 | GSM_Nokia7110OperatorLogo,/*size 78*21*/ | 165 | GSM_Nokia7110OperatorLogo,/*size 78*21*/ |
140 | GSM_Nokia6510OperatorLogo,/*size 78*21*/ | 166 | GSM_Nokia6510OperatorLogo,/*size 78*21*/ |
141 | GSM_NokiaCallerLogo, /*size 72*14*/ | 167 | GSM_NokiaCallerLogo, /*size 72*14*/ |
142 | GSM_NokiaPictureImage, /*size 72*28*/ | 168 | GSM_NokiaPictureImage, /*size 72*28*/ |
143 | GSM_Nokia7110StartupLogo,/*size 96*65*/ | 169 | GSM_Nokia7110StartupLogo,/*size 96*65*/ |
144 | GSM_Nokia6210StartupLogo,/*size 96*60*/ | 170 | GSM_Nokia6210StartupLogo,/*size 96*60*/ |
145 | GSM_AlcatelBMMIPicture, | 171 | GSM_AlcatelBMMIPicture, |
146 | GSM_EMSSmallPicture, /*size 8* 8*/ | 172 | GSM_EMSSmallPicture, /*size 8* 8*/ |
147 | GSM_EMSMediumPicture, /*size 16*16*/ | 173 | GSM_EMSMediumPicture, /*size 16*16*/ |
148 | GSM_EMSBigPicture, /*size 32*32*/ | 174 | GSM_EMSBigPicture, /*size 32*32*/ |
149 | GSM_EMSVariablePicture | 175 | GSM_EMSVariablePicture |
150 | } GSM_Phone_Bitmap_Types; | 176 | } GSM_Phone_Bitmap_Types; |
151 | 177 | ||
152 | bool GSM_IsPointBitmap (GSM_Bitmap *bmp, int x, int y); | 178 | bool GSM_IsPointBitmap (GSM_Bitmap *bmp, int x, int y); |
153 | void GSM_SetPointBitmap (GSM_Bitmap *bmp, int x, int y); | 179 | void GSM_SetPointBitmap (GSM_Bitmap *bmp, int x, int y); |
154 | void GSM_ClearPointBitmap (GSM_Bitmap *bmp, int x, int y); | 180 | void GSM_ClearPointBitmap (GSM_Bitmap *bmp, int x, int y); |
155 | void GSM_ClearBitmap (GSM_Bitmap *bmp); | 181 | void GSM_ClearBitmap (GSM_Bitmap *bmp); |
156 | void GSM_ResizeBitmap (GSM_Bitmap *dest, GSM_Bitmap *src, int width, int height); | 182 | void GSM_ResizeBitmap (GSM_Bitmap *dest, GSM_Bitmap *src, int width, int height); |
157 | void GSM_ReverseBitmap (GSM_Bitmap *Bitmap); | 183 | void GSM_ReverseBitmap (GSM_Bitmap *Bitmap); |
158 | void GSM_GetMaxBitmapWidthHeight(GSM_Bitmap_Types Type, unsigned char *width, unsigned char *height); | 184 | void GSM_GetMaxBitmapWidthHeight(GSM_Bitmap_Types Type, unsigned char *width, unsigned char *height); |
159 | int GSM_GetBitmapSize (GSM_Bitmap *bmp); | 185 | int GSM_GetBitmapSize (GSM_Bitmap *bmp); |
160 | void GSM_PrintBitmap (FILE *file, GSM_Bitmap *bitmap); | 186 | void GSM_PrintBitmap (FILE *file, GSM_Bitmap *bitmap); |
161 | 187 | ||
162 | GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap); | 188 | GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap); |
163 | GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap); | 189 | GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap); |
164 | 190 | ||
165 | GSM_Error BMP2Bitmap (unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap); | 191 | GSM_Error BMP2Bitmap (unsigned char *buffer, FILE *file,GSM_Bitmap *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 | |||
@@ -247,70 +247,75 @@ typedef enum { | |||
247 | #endif | 247 | #endif |
248 | GSM_File_Other | 248 | GSM_File_Other |
249 | } GSM_FileType; | 249 | } GSM_FileType; |
250 | 250 | ||
251 | typedef struct { | 251 | typedef struct { |
252 | int Used; /* how many bytes used */ | 252 | int Used; /* how many bytes used */ |
253 | unsigned char Name[300]; /* Name */ | 253 | unsigned char Name[300]; /* Name */ |
254 | bool Folder; /* true, when folder */ | 254 | bool Folder; /* true, when folder */ |
255 | int Level; | 255 | int Level; |
256 | GSM_FileTypeType; | 256 | GSM_FileTypeType; |
257 | unsigned charID_FullName[400]; | 257 | unsigned charID_FullName[400]; |
258 | unsigned char*Buffer; | 258 | unsigned char*Buffer; |
259 | 259 | ||
260 | GSM_DateTimeModified; | 260 | GSM_DateTimeModified; |
261 | bool ModifiedEmpty; | 261 | bool ModifiedEmpty; |
262 | 262 | ||
263 | /* File attributes */ | 263 | /* File attributes */ |
264 | bool Protected; | 264 | bool Protected; |
265 | bool ReadOnly; | 265 | bool ReadOnly; |
266 | bool Hidden; | 266 | bool Hidden; |
267 | bool System; | 267 | bool System; |
268 | } GSM_File; | 268 | } GSM_File; |
269 | 269 | ||
270 | GSM_Error GSM_ReadFile(char *FileName, GSM_File *File); | 270 | GSM_Error GSM_ReadFile(char *FileName, GSM_File *File); |
271 | 271 | ||
272 | GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size); | 272 | GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size); |
273 | 273 | ||
274 | void GSM_IdentifyFileFormat(GSM_File *File); | 274 | void GSM_IdentifyFileFormat(GSM_File *File); |
275 | 275 | ||
276 | typedef struct { | 276 | typedef struct { |
277 | int Free; | 277 | int Free; |
278 | int Used; | 278 | int Used; |
279 | } GSM_FileSystemStatus; | 279 | } GSM_FileSystemStatus; |
280 | 280 | ||
281 | /* ----------------------------- GPRS access points ----------------------- */ | 281 | /* ----------------------------- GPRS access points ----------------------- */ |
282 | 282 | ||
283 | typedef struct { | 283 | typedef struct { |
284 | int Location; | 284 | int Location; |
285 | unsigned char Name[300]; | 285 | unsigned char Name[300]; |
286 | unsigned char URL[500]; | 286 | unsigned char URL[500]; |
287 | bool Active; | 287 | bool Active; |
288 | } GSM_GPRSAccessPoint; | 288 | } GSM_GPRSAccessPoint; |
289 | 289 | ||
290 | /* ------------------------------------------------------------------------ */ | 290 | /* ------------------------------------------------------------------------ */ |
291 | 291 | ||
292 | typedef enum { | 292 | typedef 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 | ||
298 | typedef struct { | 303 | typedef struct { |
299 | unsigned char DateSeparator; | 304 | unsigned char DateSeparator; |
300 | GSM_DateFormatDateFormat; | 305 | GSM_DateFormatDateFormat; |
301 | bool AMPMTime; | 306 | bool AMPMTime; |
302 | } GSM_Locale; | 307 | } GSM_Locale; |
303 | 308 | ||
304 | /* ------------------------------------------------------------------------ */ | 309 | /* ------------------------------------------------------------------------ */ |
305 | 310 | ||
306 | void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt); | 311 | void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt); |
307 | void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start); | 312 | void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start); |
308 | 313 | ||
309 | void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start); | 314 | void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start); |
310 | bool ReadVCALText(char *Buffer, char *Start, char *Value); | 315 | bool ReadVCALText(char *Buffer, char *Start, char *Value); |
311 | 316 | ||
312 | #endif | 317 | #endif |
313 | 318 | ||
314 | /* How should editor hadle tabs in this file? Add editor commands here. | 319 | /* How should editor hadle tabs in this file? Add editor commands here. |
315 | * vim: noexpandtab sw=8 ts=8 sts=8: | 320 | * vim: noexpandtab sw=8 ts=8 sts=8: |
316 | */ | 321 | */ |
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,57 +1,60 @@ | |||
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" |
16 | #include "../gsmstate.h" | 19 | #include "../gsmstate.h" |
17 | #include "gsmring.h" | 20 | #include "gsmring.h" |
18 | #include "sms/gsmsms.h" | 21 | #include "sms/gsmsms.h" |
19 | 22 | ||
20 | int GSM_RingNoteGetFrequency(GSM_RingNote Note) | 23 | int GSM_RingNoteGetFrequency(GSM_RingNote Note) |
21 | { | 24 | { |
22 | double freq=0; | 25 | double freq=0; |
23 | 26 | ||
24 | /* Values according to the software from http://iki.fi/too/sw/xring/ | 27 | /* Values according to the software from http://iki.fi/too/sw/xring/ |
25 | * generated with: | 28 | * generated with: |
26 | * perl -e 'print int(4400 * (2 **($_/12)) + .5)/10, "\n" for(3..14)' | 29 | * perl -e 'print int(4400 * (2 **($_/12)) + .5)/10, "\n" for(3..14)' |
27 | */ | 30 | */ |
28 | switch (Note.Note) { | 31 | switch (Note.Note) { |
29 | case Note_C : freq = 523.3; break; | 32 | case Note_C : freq = 523.3; break; |
30 | case Note_Cis: freq = 554.4; break; | 33 | case Note_Cis: freq = 554.4; break; |
31 | case Note_D : freq = 587.3; break; | 34 | case Note_D : freq = 587.3; break; |
32 | case Note_Dis: freq = 622.3; break; | 35 | case Note_Dis: freq = 622.3; break; |
33 | case Note_E : freq = 659.3; break; | 36 | case Note_E : freq = 659.3; break; |
34 | case Note_F : freq = 698.5; break; | 37 | case Note_F : freq = 698.5; break; |
35 | case Note_Fis: freq = 740; break; | 38 | case Note_Fis: freq = 740; break; |
36 | case Note_G : freq = 784; break; | 39 | case Note_G : freq = 784; break; |
37 | case Note_Gis: freq = 830.6; break; | 40 | case Note_Gis: freq = 830.6; break; |
38 | case Note_A : freq = 880; break; | 41 | case Note_A : freq = 880; break; |
39 | case Note_Ais: freq = 932.3; break; | 42 | case Note_Ais: freq = 932.3; break; |
40 | case Note_H : freq = 987.8; break; | 43 | case Note_H : freq = 987.8; break; |
41 | case Note_Pause: break; | 44 | case Note_Pause: break; |
42 | } | 45 | } |
43 | switch (Note.Scale) { | 46 | switch (Note.Scale) { |
44 | case Scale_440 : freq = freq / 2; break; | 47 | case Scale_440 : freq = freq / 2; break; |
45 | case Scale_880 : break; | 48 | case Scale_880 : break; |
46 | case Scale_1760: freq = freq * 2; break; | 49 | case Scale_1760: freq = freq * 2; break; |
47 | case Scale_3520: freq = freq * 4; break; | 50 | case Scale_3520: freq = freq * 4; break; |
48 | default : break; | 51 | default : break; |
49 | } | 52 | } |
50 | return (int)freq; | 53 | return (int)freq; |
51 | } | 54 | } |
52 | 55 | ||
53 | int GSM_RingNoteGetFullDuration(GSM_RingNote Note) | 56 | int GSM_RingNoteGetFullDuration(GSM_RingNote Note) |
54 | { | 57 | { |
55 | int duration = 1; | 58 | int duration = 1; |
56 | 59 | ||
57 | switch (Note.Duration) { | 60 | switch (Note.Duration) { |
@@ -111,96 +114,102 @@ GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone) | |||
111 | DATA_Buffer[j] = ((int)(0.5*50000)); | 114 | DATA_Buffer[j] = ((int)(0.5*50000)); |
112 | #endif | 115 | #endif |
113 | phase = phase + phase_step; | 116 | phase = phase + phase_step; |
114 | length++; | 117 | length++; |
115 | } | 118 | } |
116 | fwrite(&DATA_Buffer,sizeof(short),j,file); | 119 | fwrite(&DATA_Buffer,sizeof(short),j,file); |
117 | } | 120 | } |
118 | } | 121 | } |
119 | 122 | ||
120 | wavfilesize = sizeof(WAV_Header) + sizeof(FMT_Header) + sizeof(DATA_Header) + length*2; | 123 | wavfilesize = sizeof(WAV_Header) + sizeof(FMT_Header) + sizeof(DATA_Header) + length*2; |
121 | WAV_Header[4] = ((unsigned char)wavfilesize % 256); | 124 | WAV_Header[4] = ((unsigned char)wavfilesize % 256); |
122 | WAV_Header[5] = ((unsigned char)wavfilesize / 256); | 125 | WAV_Header[5] = ((unsigned char)wavfilesize / 256); |
123 | WAV_Header[6] = ((unsigned char)wavfilesize / (256*256)); | 126 | WAV_Header[6] = ((unsigned char)wavfilesize / (256*256)); |
124 | WAV_Header[7] = ((unsigned char)wavfilesize / (256*256*256)); | 127 | WAV_Header[7] = ((unsigned char)wavfilesize / (256*256*256)); |
125 | wavfilesize = wavfilesize - 54; | 128 | wavfilesize = wavfilesize - 54; |
126 | DATA_Header[4] = ((unsigned char)wavfilesize % 256); | 129 | DATA_Header[4] = ((unsigned char)wavfilesize % 256); |
127 | DATA_Header[5] = ((unsigned char)wavfilesize / 256); | 130 | DATA_Header[5] = ((unsigned char)wavfilesize / 256); |
128 | DATA_Header[6] = ((unsigned char)wavfilesize / (256*256)); | 131 | DATA_Header[6] = ((unsigned char)wavfilesize / (256*256)); |
129 | DATA_Header[7] = ((unsigned char)wavfilesize / (256*256*256)); | 132 | DATA_Header[7] = ((unsigned char)wavfilesize / (256*256*256)); |
130 | 133 | ||
131 | fseek( file, 0, SEEK_SET); | 134 | fseek( file, 0, SEEK_SET); |
132 | fwrite(&WAV_Header, 1, sizeof(WAV_Header),file); | 135 | fwrite(&WAV_Header, 1, sizeof(WAV_Header),file); |
133 | fwrite(&FMT_Header, 1, sizeof(FMT_Header),file); | 136 | fwrite(&FMT_Header, 1, sizeof(FMT_Header),file); |
134 | fwrite(&DATA_Header, 1, sizeof(DATA_Header),file); | 137 | fwrite(&DATA_Header, 1, sizeof(DATA_Header),file); |
135 | 138 | ||
136 | return ERR_NONE; | 139 | return ERR_NONE; |
137 | } | 140 | } |
138 | 141 | ||
139 | static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone) | 142 | static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone) |
140 | { | 143 | { |
141 | char nullchar=0x00; | 144 | char nullchar=0x00; |
142 | 145 | ||
143 | fwrite(&nullchar,1,1,file); | 146 | fwrite(&nullchar,1,1,file); |
144 | fwrite(&nullchar,1,1,file); | 147 | fwrite(&nullchar,1,1,file); |
145 | fprintf(file,"\x0C\x01\x2C"); | 148 | fprintf(file,"\x0C\x01\x2C"); |
146 | fprintf(file,"%s",DecodeUnicodeString(ringtone->Name)); | 149 | fprintf(file,"%s",DecodeUnicodeString(ringtone->Name)); |
147 | fwrite(&nullchar,1,1,file); | 150 | fwrite(&nullchar,1,1,file); |
148 | fwrite(&nullchar,1,1,file); | 151 | fwrite(&nullchar,1,1,file); |
149 | fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); | 152 | fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); |
150 | return ERR_NONE; | 153 | return ERR_NONE; |
151 | } | 154 | } |
152 | 155 | ||
153 | static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone) | 156 | static 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 | ||
162 | static 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 | |||
159 | GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone) | 168 | GSM_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; |
165 | int DefNoteTempo=0; | 174 | int DefNoteTempo=0; |
166 | 175 | ||
167 | bool started = false, firstcomma = true; | 176 | bool started = false, firstcomma = true; |
168 | GSM_RingNote *Note; | 177 | GSM_RingNote *Note; |
169 | 178 | ||
170 | unsigned char buffer[15]; | 179 | unsigned char buffer[15]; |
171 | int i,j,k=0; | 180 | int i,j,k=0; |
172 | 181 | ||
173 | /* Saves ringtone name */ | 182 | /* Saves ringtone name */ |
174 | fprintf(file,"%s:",DecodeUnicodeString(ringtone->Name)); | 183 | fprintf(file,"%s:",DecodeUnicodeString(ringtone->Name)); |
175 | 184 | ||
176 | /* Find the most frequently used duration */ | 185 | /* Find the most frequently used duration */ |
177 | for (i=0;i<6;i++) buffer[i]=0; | 186 | for (i=0;i<6;i++) buffer[i]=0; |
178 | for (i=0;i<ringtone->NoteTone.NrCommands;i++) { | 187 | for (i=0;i<ringtone->NoteTone.NrCommands;i++) { |
179 | if (ringtone->NoteTone.Commands[i].Type == RING_Note) { | 188 | if (ringtone->NoteTone.Commands[i].Type == RING_Note) { |
180 | Note = &ringtone->NoteTone.Commands[i].Note; | 189 | Note = &ringtone->NoteTone.Commands[i].Note; |
181 | /* some durations need 2 bytes in file, some 1 */ | 190 | /* some durations need 2 bytes in file, some 1 */ |
182 | if (Note->Duration >= Duration_Full && Note->Duration <= Duration_1_8) { | 191 | if (Note->Duration >= Duration_Full && Note->Duration <= Duration_1_8) { |
183 | buffer[Note->Duration/32]++; | 192 | buffer[Note->Duration/32]++; |
184 | } | 193 | } |
185 | if (Note->Duration >= Duration_1_16 && Note->Duration <= Duration_1_32) { | 194 | if (Note->Duration >= Duration_1_16 && Note->Duration <= Duration_1_32) { |
186 | buffer[Note->Duration/32]+=2; | 195 | buffer[Note->Duration/32]+=2; |
187 | } | 196 | } |
188 | } | 197 | } |
189 | } | 198 | } |
190 | /* Now find the most frequently used */ | 199 | /* Now find the most frequently used */ |
191 | j=0; | 200 | j=0; |
192 | for (i=0;i<6;i++) { | 201 | for (i=0;i<6;i++) { |
193 | if (buffer[i]>j) { | 202 | if (buffer[i]>j) { |
194 | k=i; | 203 | k=i; |
195 | j=buffer[i]; | 204 | j=buffer[i]; |
196 | } | 205 | } |
197 | } | 206 | } |
198 | /* Finally convert the default duration */ | 207 | /* Finally convert the default duration */ |
199 | DefNoteDuration = k * 32; | 208 | DefNoteDuration = k * 32; |
200 | dbgprintf("DefNoteDuration=%d\n", DefNoteDuration); | 209 | dbgprintf("DefNoteDuration=%d\n", DefNoteDuration); |
201 | switch (DefNoteDuration) { | 210 | switch (DefNoteDuration) { |
202 | case Duration_Full:fprintf(file,"d=1"); break; | 211 | case Duration_Full:fprintf(file,"d=1"); break; |
203 | case Duration_1_2 :fprintf(file,"d=2"); break; | 212 | case Duration_1_2 :fprintf(file,"d=2"); break; |
204 | case Duration_1_4 :fprintf(file,"d=4"); break; | 213 | case Duration_1_4 :fprintf(file,"d=4"); break; |
205 | case Duration_1_8 :fprintf(file,"d=8"); break; | 214 | case Duration_1_8 :fprintf(file,"d=8"); break; |
206 | case Duration_1_16:fprintf(file,"d=16");break; | 215 | case Duration_1_16:fprintf(file,"d=16");break; |
@@ -440,96 +449,99 @@ void savemid(FILE* file, GSM_Ringtone *ringtone) | |||
440 | fwrite(midifile,1,current,file); | 449 | fwrite(midifile,1,current,file); |
441 | } | 450 | } |
442 | 451 | ||
443 | #endif | 452 | #endif |
444 | 453 | ||
445 | void saveott(FILE *file, GSM_Ringtone *ringtone) | 454 | void saveott(FILE *file, GSM_Ringtone *ringtone) |
446 | { | 455 | { |
447 | char Buffer[2000]; | 456 | char Buffer[2000]; |
448 | int i=2000; | 457 | int i=2000; |
449 | 458 | ||
450 | GSM_EncodeNokiaRTTLRingtone(*ringtone, Buffer, &i); | 459 | GSM_EncodeNokiaRTTLRingtone(*ringtone, Buffer, &i); |
451 | 460 | ||
452 | fwrite(Buffer, 1, i, file); | 461 | fwrite(Buffer, 1, i, file); |
453 | } | 462 | } |
454 | 463 | ||
455 | GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone) | 464 | GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone) |
456 | { | 465 | { |
457 | FILE *file; | 466 | FILE *file; |
458 | 467 | ||
459 | file = fopen(FileName, "wb"); | 468 | file = fopen(FileName, "wb"); |
460 | if (file == NULL) return ERR_CANTOPENFILE; | 469 | if (file == NULL) return ERR_CANTOPENFILE; |
461 | 470 | ||
462 | switch (ringtone->Format) { | 471 | switch (ringtone->Format) { |
463 | case RING_NOTETONE: | 472 | case RING_NOTETONE: |
464 | if (strstr(FileName,".ott")) { | 473 | if (strstr(FileName,".ott")) { |
465 | saveott(file,ringtone); | 474 | saveott(file,ringtone); |
466 | #ifndef ENABLE_LGPL | 475 | #ifndef ENABLE_LGPL |
467 | } else if (strstr(FileName,".mid")) { | 476 | } else if (strstr(FileName,".mid")) { |
468 | savemid(file,ringtone); | 477 | savemid(file,ringtone); |
469 | #endif | 478 | #endif |
470 | } else if (strstr(FileName,".rng")) { | 479 | } else if (strstr(FileName,".rng")) { |
471 | saveott(file,ringtone); | 480 | saveott(file,ringtone); |
472 | } else if (strstr(FileName,".imy")) { | 481 | } else if (strstr(FileName,".imy")) { |
473 | saveimelody(file,ringtone); | 482 | saveimelody(file,ringtone); |
474 | } else if (strstr(FileName,".ime")) { | 483 | } else if (strstr(FileName,".ime")) { |
475 | saveimelody(file,ringtone); | 484 | saveimelody(file,ringtone); |
476 | } else if (strstr(FileName,".wav")) { | 485 | } else if (strstr(FileName,".wav")) { |
477 | savewav(file,ringtone); | 486 | savewav(file,ringtone); |
478 | } else { | 487 | } else { |
479 | saverttl(file, ringtone); | 488 | saverttl(file, ringtone); |
480 | } | 489 | } |
481 | break; | 490 | break; |
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 | } |
494 | 506 | ||
495 | static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone) | 507 | static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone) |
496 | { | 508 | { |
497 | GSM_RingNoteScale DefNoteScale= Scale_880; | 509 | GSM_RingNoteScale DefNoteScale= Scale_880; |
498 | GSM_RingNoteDuration DefNoteDuration= Duration_1_4; | 510 | GSM_RingNoteDuration DefNoteDuration= Duration_1_4; |
499 | GSM_RingNoteStyle DefNoteStyle= NaturalStyle; | 511 | GSM_RingNoteStyle DefNoteStyle= NaturalStyle; |
500 | int DefNoteTempo= 63, i=0; | 512 | int DefNoteTempo= 63, i=0; |
501 | 513 | ||
502 | unsigned char buffer[2000],Name[100]; | 514 | unsigned char buffer[2000],Name[100]; |
503 | GSM_RingNote *Note; | 515 | GSM_RingNote *Note; |
504 | 516 | ||
505 | fread(buffer, 2000, 1, file); | 517 | fread(buffer, 2000, 1, file); |
506 | 518 | ||
507 | ringtone->NoteTone.NrCommands = 0; | 519 | ringtone->NoteTone.NrCommands = 0; |
508 | 520 | ||
509 | /* -------------- name ---------------- */ | 521 | /* -------------- name ---------------- */ |
510 | while (buffer[i] != ':') { | 522 | while (buffer[i] != ':') { |
511 | if (buffer[i] == 0x00) return ERR_NONE; | 523 | if (buffer[i] == 0x00) return ERR_NONE; |
512 | i++; | 524 | i++; |
513 | } | 525 | } |
514 | if (i == 0) { | 526 | if (i == 0) { |
515 | /* This is for RTTL ringtones without name. */ | 527 | /* This is for RTTL ringtones without name. */ |
516 | EncodeUnicode(ringtone->Name,"Gammu",5); | 528 | EncodeUnicode(ringtone->Name,"Gammu",5); |
517 | } else { | 529 | } else { |
518 | memcpy(Name,buffer,i); | 530 | memcpy(Name,buffer,i); |
519 | Name[i] = 0x00; | 531 | Name[i] = 0x00; |
520 | EncodeUnicode(ringtone->Name,Name,strlen(Name)); | 532 | EncodeUnicode(ringtone->Name,Name,strlen(Name)); |
521 | } | 533 | } |
522 | i++; | 534 | i++; |
523 | 535 | ||
524 | /* --------- section with default ringtone settings ----------- */ | 536 | /* --------- section with default ringtone settings ----------- */ |
525 | while(1) { | 537 | while(1) { |
526 | switch (buffer[i]) { | 538 | switch (buffer[i]) { |
527 | case ':': | 539 | case ':': |
528 | break; | 540 | break; |
529 | case 0x00: | 541 | case 0x00: |
530 | return ERR_NONE; | 542 | return ERR_NONE; |
531 | case 'd': case 'D': | 543 | case 'd': case 'D': |
532 | switch (atoi(buffer+i+2)) { | 544 | switch (atoi(buffer+i+2)) { |
533 | case 1: DefNoteDuration = Duration_Full; break; | 545 | case 1: DefNoteDuration = Duration_Full; break; |
534 | case 2: DefNoteDuration = Duration_1_2 ; break; | 546 | case 2: DefNoteDuration = Duration_1_2 ; break; |
535 | case 4: DefNoteDuration = Duration_1_4 ; break; | 547 | case 4: DefNoteDuration = Duration_1_4 ; break; |
@@ -724,169 +736,198 @@ static GSM_Error loadcommunicator(FILE *file, GSM_Ringtone *ringtone) | |||
724 | char Buffer[4000]; | 736 | char Buffer[4000]; |
725 | int i,j; | 737 | int i,j; |
726 | 738 | ||
727 | i=fread(Buffer, 1, 4000, file); | 739 | i=fread(Buffer, 1, 4000, file); |
728 | 740 | ||
729 | i=0;j=0; | 741 | i=0;j=0; |
730 | while (true) { | 742 | while (true) { |
731 | if (Buffer[j] ==0x00 && Buffer[j+1]==0x02 && | 743 | if (Buffer[j] ==0x00 && Buffer[j+1]==0x02 && |
732 | Buffer[j+2]==0x4a && Buffer[j+3]==0x3a) break; | 744 | Buffer[j+2]==0x4a && Buffer[j+3]==0x3a) break; |
733 | if (j==i-4) return ERR_UNKNOWN; | 745 | if (j==i-4) return ERR_UNKNOWN; |
734 | j++; | 746 | j++; |
735 | } | 747 | } |
736 | j++; | 748 | j++; |
737 | 749 | ||
738 | return GSM_DecodeNokiaRTTLRingtone(ringtone, Buffer+j, i-j); | 750 | return GSM_DecodeNokiaRTTLRingtone(ringtone, Buffer+j, i-j); |
739 | } | 751 | } |
740 | 752 | ||
741 | static GSM_Error loadbin(FILE *file, GSM_Ringtone *ringtone) | 753 | static GSM_Error loadbin(FILE *file, GSM_Ringtone *ringtone) |
742 | { | 754 | { |
743 | int i; | 755 | int i; |
744 | unsigned charbuffer[2000]; | 756 | unsigned charbuffer[2000]; |
745 | 757 | ||
746 | dbgprintf("loading binary\n"); | 758 | dbgprintf("loading binary\n"); |
747 | ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file); | 759 | ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file); |
748 | i=5; | 760 | i=5; |
749 | while (buffer[i]!=0x00) i++; | 761 | while (buffer[i]!=0x00) i++; |
750 | EncodeUnicode(ringtone->Name,buffer+5,i-5); | 762 | EncodeUnicode(ringtone->Name,buffer+5,i-5); |
751 | while (buffer[i]!=0x02 && buffer[i+1]!=0xFC && buffer[i+2]!=0x09) { | 763 | while (buffer[i]!=0x02 && buffer[i+1]!=0xFC && buffer[i+2]!=0x09) { |
752 | i++; | 764 | i++; |
753 | } | 765 | } |
754 | ringtone->NokiaBinary.Length=ringtone->NokiaBinary.Length-i; | 766 | ringtone->NokiaBinary.Length=ringtone->NokiaBinary.Length-i; |
755 | memcpy(ringtone->NokiaBinary.Frame,buffer+i,ringtone->NokiaBinary.Length); | 767 | memcpy(ringtone->NokiaBinary.Frame,buffer+i,ringtone->NokiaBinary.Length); |
756 | dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name)); | 768 | dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name)); |
757 | return ERR_NONE; | 769 | return ERR_NONE; |
758 | } | 770 | } |
759 | 771 | ||
760 | static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone) | 772 | static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone) |
761 | { | 773 | { |
762 | unsigned char buffer[30000]; | 774 | unsigned char buffer[30000]; |
763 | 775 | ||
764 | dbgprintf("loading midi\n"); | 776 | dbgprintf("loading midi\n"); |
765 | EncodeUnicode(ringtone->Name,"MIDI",4); | 777 | EncodeUnicode(ringtone->Name,"MIDI",4); |
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 | ||
784 | static 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 | |||
772 | static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone) | 804 | static 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 | ||
778 | if (buffer[18]==0x00 && buffer[21]!=0x02) { | 810 | if (buffer[18]==0x00 && buffer[21]!=0x02) { |
779 | /* DCT3, Unicode subformat, 62xx & 7110 */ | 811 | /* DCT3, Unicode subformat, 62xx & 7110 */ |
780 | CopyUnicodeString(ringtone->Name,buffer+18); | 812 | CopyUnicodeString(ringtone->Name,buffer+18); |
781 | ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (21+UnicodeLength(ringtone->Name)*2); | 813 | ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (21+UnicodeLength(ringtone->Name)*2); |
782 | memcpy(ringtone->NokiaBinary.Frame,buffer+21+UnicodeLength(ringtone->Name)*2,ringtone->NokiaBinary.Length); | 814 | memcpy(ringtone->NokiaBinary.Frame,buffer+21+UnicodeLength(ringtone->Name)*2,ringtone->NokiaBinary.Length); |
783 | } else { | 815 | } else { |
784 | /* DCT3, normal subformat, 32xx/33xx/51xx/5210/5510/61xx/8xxx */ | 816 | /* DCT3, normal subformat, 32xx/33xx/51xx/5210/5510/61xx/8xxx */ |
785 | EncodeUnicode(ringtone->Name,buffer+17,buffer[16]); | 817 | EncodeUnicode(ringtone->Name,buffer+17,buffer[16]); |
786 | ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (19+UnicodeLength(ringtone->Name)); | 818 | ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (19+UnicodeLength(ringtone->Name)); |
787 | memcpy(ringtone->NokiaBinary.Frame,buffer+19+UnicodeLength(ringtone->Name),ringtone->NokiaBinary.Length); | 819 | memcpy(ringtone->NokiaBinary.Frame,buffer+19+UnicodeLength(ringtone->Name),ringtone->NokiaBinary.Length); |
788 | } | 820 | } |
789 | dbgprintf("Name \"%s\"\n",DecodeUnicodeString(ringtone->Name)); | 821 | dbgprintf("Name \"%s\"\n",DecodeUnicodeString(ringtone->Name)); |
790 | return ERR_NONE; | 822 | return ERR_NONE; |
791 | } | 823 | } |
792 | 824 | ||
793 | GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone) | 825 | GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone) |
794 | { | 826 | { |
795 | FILE *file; | 827 | FILE *file; |
796 | unsigned charbuffer[300]; | 828 | unsigned charbuffer[300]; |
797 | GSM_Errorerror = ERR_UNKNOWN; | 829 | GSM_Errorerror = ERR_UNKNOWN; |
798 | 830 | ||
799 | dbgprintf("Loading ringtone %s\n",FileName); | 831 | dbgprintf("Loading ringtone %s\n",FileName); |
800 | file = fopen(FileName, "rb"); | 832 | file = fopen(FileName, "rb"); |
801 | if (file == NULL) return ERR_CANTOPENFILE; | 833 | if (file == NULL) return ERR_CANTOPENFILE; |
802 | 834 | ||
803 | /* Read the header of the file. */ | 835 | /* Read the header of the file. */ |
804 | fread(buffer, 1, 4, file); | 836 | fread(buffer, 1, 4, file); |
805 | if (ringtone->Format == 0x00) { | 837 | if (ringtone->Format == 0x00) { |
806 | ringtone->Format = RING_NOTETONE; | 838 | ringtone->Format = RING_NOTETONE; |
807 | if (buffer[0]==0x00 && buffer[1]==0x00 && | 839 | if (buffer[0]==0x00 && buffer[1]==0x00 && |
808 | buffer[2]==0x0C && buffer[3]==0x01) { | 840 | buffer[2]==0x0C && buffer[3]==0x01) { |
809 | ringtone->Format = RING_NOKIABINARY; | 841 | ringtone->Format = RING_NOKIABINARY; |
810 | } | 842 | } |
811 | if (buffer[0]==0x00 && buffer[1]==0x00 && | 843 | if (buffer[0]==0x00 && buffer[1]==0x00 && |
812 | buffer[2]==0x00) { | 844 | buffer[2]==0x00) { |
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); |
825 | } else if (buffer[0]==0xC7 && buffer[1]==0x45) { | 861 | } else if (buffer[0]==0xC7 && buffer[1]==0x45) { |
826 | error=loadcommunicator(file,ringtone); | 862 | error=loadcommunicator(file,ringtone); |
827 | } else { | 863 | } else { |
828 | error=loadrttl(file,ringtone); | 864 | error=loadrttl(file,ringtone); |
829 | } | 865 | } |
830 | ringtone->NoteTone.AllNotesScale=false; | 866 | ringtone->NoteTone.AllNotesScale=false; |
831 | break; | 867 | break; |
832 | case RING_NOKIABINARY: | 868 | case RING_NOKIABINARY: |
833 | if (buffer[0]==0x00 && buffer[1]==0x00 && | 869 | if (buffer[0]==0x00 && buffer[1]==0x00 && |
834 | buffer[2]==0x0C && buffer[3]==0x01) { | 870 | buffer[2]==0x0C && buffer[3]==0x01) { |
835 | error=loadbin(file,ringtone); | 871 | error=loadbin(file,ringtone); |
836 | } | 872 | } |
837 | if (buffer[0]==0x00 && buffer[1]==0x00 && | 873 | if (buffer[0]==0x00 && buffer[1]==0x00 && |
838 | buffer[2]==0x00) { | 874 | buffer[2]==0x00) { |
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 ------------------- */ |
851 | 892 | ||
852 | /* Beats per Minute like written in Smart Messaging */ | 893 | /* Beats per Minute like written in Smart Messaging */ |
853 | static int SM_BeatsPerMinute[] = { | 894 | static int SM_BeatsPerMinute[] = { |
854 | 25, 28, 31, 35, 40, 45, 50, 56, 63,70, | 895 | 25, 28, 31, 35, 40, 45, 50, 56, 63,70, |
855 | 80, 90, 100, 112, 125, 140, 160, 180, 200,225, | 896 | 80, 90, 100, 112, 125, 140, 160, 180, 200,225, |
856 | 250, 285, 320, 355, 400, 450, 500, 565, 635,715, | 897 | 250, 285, 320, 355, 400, 450, 500, 565, 635,715, |
857 | 800,900 | 898 | 800,900 |
858 | }; | 899 | }; |
859 | 900 | ||
860 | int GSM_RTTLGetTempo(int Beats) | 901 | int GSM_RTTLGetTempo(int Beats) |
861 | { | 902 | { |
862 | int i=0; | 903 | int i=0; |
863 | 904 | ||
864 | while (Beats > SM_BeatsPerMinute[i] && SM_BeatsPerMinute[i] != 900) i++; | 905 | while (Beats > SM_BeatsPerMinute[i] && SM_BeatsPerMinute[i] != 900) i++; |
865 | 906 | ||
866 | return i<<3; | 907 | return i<<3; |
867 | } | 908 | } |
868 | 909 | ||
869 | /* This function packs the ringtone from the structure "ringtone" to | 910 | /* This function packs the ringtone from the structure "ringtone" to |
870 | "package", where maxlength means length of package. | 911 | "package", where maxlength means length of package. |
871 | Function returns number of packed notes and change maxlength to | 912 | Function returns number of packed notes and change maxlength to |
872 | number of used chars in "package" */ | 913 | number of used chars in "package" */ |
873 | unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength) | 914 | unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength) |
874 | { | 915 | { |
875 | unsigned char CommandLength = 0x02; | 916 | unsigned char CommandLength = 0x02; |
876 | unsigned char Loop = 0x15;/* Infinite */ | 917 | unsigned char Loop = 0x15;/* Infinite */ |
877 | 918 | ||
878 | unsigned char Buffer[200]; | 919 | unsigned char Buffer[200]; |
879 | int StartBit=0, OldStartBit; | 920 | int StartBit=0, OldStartBit; |
880 | int StartBitHowManyCommands; | 921 | int StartBitHowManyCommands; |
881 | int HowManyCommands = 0;/* How many instructions packed */ | 922 | int HowManyCommands = 0;/* How many instructions packed */ |
882 | int HowManyNotes= 0; | 923 | int HowManyNotes= 0; |
883 | int i,j; | 924 | int i,j; |
884 | bool started; | 925 | bool started; |
885 | GSM_RingNote *Note; | 926 | GSM_RingNote *Note; |
886 | 927 | ||
887 | GSM_RingNoteScale DefScale = 255; | 928 | GSM_RingNoteScale DefScale = 255; |
888 | GSM_RingNoteStyle DefStyle = 255; | 929 | GSM_RingNoteStyle DefStyle = 255; |
889 | int DefTempo = 255; | 930 | int DefTempo = 255; |
890 | 931 | ||
891 | AddBufferByte(package, &StartBit, CommandLength, 8); | 932 | AddBufferByte(package, &StartBit, CommandLength, 8); |
892 | AddBufferByte(package, &StartBit, SM_Command_RingingToneProgramming, 7); | 933 | AddBufferByte(package, &StartBit, SM_Command_RingingToneProgramming, 7); |
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 | |||
@@ -75,111 +75,113 @@ typedef enum { | |||
75 | DoubleDottedNote = 0x02<<6, | 75 | DoubleDottedNote = 0x02<<6, |
76 | Length_2_3 = 0x03<<6 | 76 | Length_2_3 = 0x03<<6 |
77 | } GSM_RingNoteDurationSpec; | 77 | } GSM_RingNoteDurationSpec; |
78 | 78 | ||
79 | typedef enum { | 79 | typedef enum { |
80 | Scale_55 = 1, /* 55 Hz for note A */ | 80 | Scale_55 = 1, /* 55 Hz for note A */ |
81 | Scale_110, /* 110 Hz for note A */ | 81 | Scale_110, /* 110 Hz for note A */ |
82 | Scale_220, | 82 | Scale_220, |
83 | Scale_440, /* first scale for Nokia */ | 83 | Scale_440, /* first scale for Nokia */ |
84 | Scale_880, | 84 | Scale_880, |
85 | Scale_1760, | 85 | Scale_1760, |
86 | Scale_3520, /* last scale for Nokia */ | 86 | Scale_3520, /* last scale for Nokia */ |
87 | Scale_7040, | 87 | Scale_7040, |
88 | Scale_14080 | 88 | Scale_14080 |
89 | } GSM_RingNoteScale; | 89 | } GSM_RingNoteScale; |
90 | 90 | ||
91 | typedef struct { | 91 | typedef struct { |
92 | GSM_RingNoteDuration Duration; | 92 | GSM_RingNoteDuration Duration; |
93 | GSM_RingNoteDurationSpec DurationSpec; | 93 | GSM_RingNoteDurationSpec DurationSpec; |
94 | GSM_RingNoteNote Note; | 94 | GSM_RingNoteNote Note; |
95 | GSM_RingNoteStyle Style; | 95 | GSM_RingNoteStyle Style; |
96 | GSM_RingNoteScale Scale; | 96 | GSM_RingNoteScale Scale; |
97 | int Tempo; | 97 | int Tempo; |
98 | } GSM_RingNote; | 98 | } GSM_RingNote; |
99 | 99 | ||
100 | typedef enum { | 100 | typedef enum { |
101 | RING_Note = 1, | 101 | RING_Note = 1, |
102 | RING_EnableVibra, | 102 | RING_EnableVibra, |
103 | RING_DisableVibra, | 103 | RING_DisableVibra, |
104 | RING_EnableLight, | 104 | RING_EnableLight, |
105 | RING_DisableLight, | 105 | RING_DisableLight, |
106 | RING_EnableLED, | 106 | RING_EnableLED, |
107 | RING_DisableLED, | 107 | RING_DisableLED, |
108 | RING_Repeat | 108 | RING_Repeat |
109 | } GSM_RingCommandType; | 109 | } GSM_RingCommandType; |
110 | 110 | ||
111 | typedef struct { | 111 | typedef struct { |
112 | GSM_RingCommandType Type; | 112 | GSM_RingCommandType Type; |
113 | GSM_RingNote Note; | 113 | GSM_RingNote Note; |
114 | unsigned char Value; | 114 | unsigned char Value; |
115 | } GSM_RingCommand; | 115 | } GSM_RingCommand; |
116 | 116 | ||
117 | typedef struct { | 117 | typedef 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. */ |
124 | typedef struct { | 125 | typedef 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 | ||
129 | typedef struct { | 130 | typedef struct { |
130 | unsigned char *Frame; | 131 | unsigned char *Buffer; |
131 | int Length; | 132 | int Length; |
132 | } GSM_BinaryTone; | 133 | } GSM_BinaryTone; |
133 | 134 | ||
134 | typedef enum { | 135 | typedef 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 | */ |
143 | typedef struct { | 145 | typedef struct { |
144 | /** | 146 | /** |
145 | * Ringtone saved in one of three formats | 147 | * Ringtone saved in one of three formats |
146 | */ | 148 | */ |
147 | GSM_NokiaBinaryRingtone NokiaBinary; | 149 | GSM_NokiaBinaryRingtone NokiaBinary; |
148 | GSM_BinaryTone BinaryTone; | 150 | GSM_BinaryTone BinaryTone; |
149 | GSM_NoteRingtone NoteTone; | 151 | GSM_NoteRingtone NoteTone; |
150 | /** | 152 | /** |
151 | * Ringtone format | 153 | * Ringtone format |
152 | */ | 154 | */ |
153 | GSM_RingtoneFormat Format; | 155 | GSM_RingtoneFormat Format; |
154 | /** | 156 | /** |
155 | * Ringtone name | 157 | * Ringtone name |
156 | */ | 158 | */ |
157 | char Name[20*2]; | 159 | char Name[20*2]; |
158 | /** | 160 | /** |
159 | * Ringtone location | 161 | * Ringtone location |
160 | */ | 162 | */ |
161 | int Location; | 163 | int Location; |
162 | } GSM_Ringtone; | 164 | } GSM_Ringtone; |
163 | 165 | ||
164 | typedef struct { | 166 | typedef struct { |
165 | int Group;//Nokia specific | 167 | int Group;//Nokia specific |
166 | int ID; | 168 | int ID; |
167 | char Name[30*2]; | 169 | char Name[30*2]; |
168 | } GSM_RingtoneInfo; | 170 | } GSM_RingtoneInfo; |
169 | 171 | ||
170 | typedef struct { | 172 | typedef struct { |
171 | int Number; | 173 | int Number; |
172 | GSM_RingtoneInfo Ringtone[100]; | 174 | GSM_RingtoneInfo Ringtone[100]; |
173 | } GSM_AllRingtonesInfo; | 175 | } GSM_AllRingtonesInfo; |
174 | 176 | ||
175 | GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone); | 177 | GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone); |
176 | GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone); | 178 | GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone); |
177 | 179 | ||
178 | void saveott(FILE *file, GSM_Ringtone *ringtone); | 180 | void saveott(FILE *file, GSM_Ringtone *ringtone); |
179 | void savemid(FILE *file, GSM_Ringtone *ringtone); | 181 | void savemid(FILE *file, GSM_Ringtone *ringtone); |
180 | void saverng(FILE *file, GSM_Ringtone *ringtone); | 182 | void saverng(FILE *file, GSM_Ringtone *ringtone); |
181 | void saveimelody(FILE *file, GSM_Ringtone *ringtone); | 183 | void saveimelody(FILE *file, GSM_Ringtone *ringtone); |
182 | GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone); | 184 | GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone); |
183 | GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone); | 185 | GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone); |
184 | 186 | ||
185 | unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength); | 187 | unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength); |
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 | |||
@@ -442,96 +442,101 @@ GSM_Error GSM_EncodeMultiPartSMS(GSM_MultiPartSMSInfo *Info, | |||
442 | return GSM_EncodeEMSMultiPartSMS(Info,SMS,UDH_ConcatenatedMessages); | 442 | return GSM_EncodeEMSMultiPartSMS(Info,SMS,UDH_ConcatenatedMessages); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | return GSM_EncodeEMSMultiPartSMS(Info,SMS,UDH_ConcatenatedMessages16bit); | 445 | return GSM_EncodeEMSMultiPartSMS(Info,SMS,UDH_ConcatenatedMessages16bit); |
446 | } | 446 | } |
447 | return error; | 447 | return error; |
448 | } | 448 | } |
449 | 449 | ||
450 | if (Info->EntriesNum != 1) return ERR_UNKNOWN; | 450 | if (Info->EntriesNum != 1) return ERR_UNKNOWN; |
451 | 451 | ||
452 | switch (Info->Entries[0].ID) { | 452 | switch (Info->Entries[0].ID) { |
453 | case SMS_AlcatelMonoBitmapLong: | 453 | case SMS_AlcatelMonoBitmapLong: |
454 | Buffer[0] = Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth; | 454 | Buffer[0] = Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth; |
455 | Buffer[1] = Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight; | 455 | Buffer[1] = Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight; |
456 | PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+2, &Info->Entries[0].Bitmap->Bitmap[0]); | 456 | PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+2, &Info->Entries[0].Bitmap->Bitmap[0]); |
457 | Length = PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight)+2; | 457 | Length = PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight)+2; |
458 | return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_PICTURE); | 458 | return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_PICTURE); |
459 | case SMS_AlcatelMonoAnimationLong: | 459 | case SMS_AlcatelMonoAnimationLong: |
460 | /* Number of sequence words */ | 460 | /* Number of sequence words */ |
461 | Buffer[0] = (Info->Entries[0].Bitmap->Number+1) % 256; | 461 | Buffer[0] = (Info->Entries[0].Bitmap->Number+1) % 256; |
462 | Buffer[1] = (Info->Entries[0].Bitmap->Number+1) / 256; | 462 | Buffer[1] = (Info->Entries[0].Bitmap->Number+1) / 256; |
463 | /* Picture display time 1 second (1 = 100ms) */ | 463 | /* Picture display time 1 second (1 = 100ms) */ |
464 | Buffer[2] = 10 % 256; | 464 | Buffer[2] = 10 % 256; |
465 | Buffer[3] = 10 / 256 + 0xF0; | 465 | Buffer[3] = 10 / 256 + 0xF0; |
466 | 466 | ||
467 | Length = 4; | 467 | Length = 4; |
468 | j = 0; | 468 | j = 0; |
469 | 469 | ||
470 | /* Offsets to bitmaps */ | 470 | /* Offsets to bitmaps */ |
471 | for (i=0;i<Info->Entries[0].Bitmap->Number;i++) { | 471 | for (i=0;i<Info->Entries[0].Bitmap->Number;i++) { |
472 | Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) % 256; | 472 | Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) % 256; |
473 | Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) / 256; | 473 | Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) / 256; |
474 | j += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight)+2; | 474 | j += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight)+2; |
475 | } | 475 | } |
476 | 476 | ||
477 | /* Bitmaps */ | 477 | /* Bitmaps */ |
478 | for (i=0;i<Info->Entries[0].Bitmap->Number;i++) { | 478 | for (i=0;i<Info->Entries[0].Bitmap->Number;i++) { |
479 | Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth; | 479 | Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth; |
480 | Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight; | 480 | Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight; |
481 | PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]); | 481 | PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]); |
482 | Length += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight); | 482 | Length += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight); |
483 | } | 483 | } |
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; |
496 | Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); | 501 | Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); |
497 | if (Info->Entries[0].ID == SMS_NokiaRingtone) break; | 502 | if (Info->Entries[0].ID == SMS_NokiaRingtone) break; |
498 | if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) { | 503 | if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) { |
499 | UDH = UDH_NokiaRingtoneLong; | 504 | UDH = UDH_NokiaRingtoneLong; |
500 | Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3; | 505 | Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3; |
501 | Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); | 506 | Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); |
502 | } | 507 | } |
503 | break; | 508 | break; |
504 | case SMS_NokiaOperatorLogoLong: | 509 | case SMS_NokiaOperatorLogoLong: |
505 | if (Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth > 72 || Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight > 14) { | 510 | if (Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth > 72 || Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight > 14) { |
506 | UDH= UDH_NokiaOperatorLogoLong; | 511 | UDH= UDH_NokiaOperatorLogoLong; |
507 | Class = 1; | 512 | Class = 1; |
508 | NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode); | 513 | NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode); |
509 | Length = Length + 3; | 514 | Length = Length + 3; |
510 | NOKIA_CopyBitmap(GSM_Nokia7110OperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length); | 515 | NOKIA_CopyBitmap(GSM_Nokia7110OperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length); |
511 | break; | 516 | break; |
512 | } | 517 | } |
513 | case SMS_NokiaOperatorLogo: | 518 | case SMS_NokiaOperatorLogo: |
514 | UDH= UDH_NokiaOperatorLogo; | 519 | UDH= UDH_NokiaOperatorLogo; |
515 | Class = 1; | 520 | Class = 1; |
516 | NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode); | 521 | NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode); |
517 | Length = Length + 3; | 522 | Length = Length + 3; |
518 | NOKIA_CopyBitmap(GSM_NokiaOperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length); | 523 | NOKIA_CopyBitmap(GSM_NokiaOperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length); |
519 | break; | 524 | break; |
520 | case SMS_NokiaCallerLogo: | 525 | case SMS_NokiaCallerLogo: |
521 | UDH= UDH_NokiaCallerLogo; | 526 | UDH= UDH_NokiaCallerLogo; |
522 | Class = 1; | 527 | Class = 1; |
523 | NOKIA_CopyBitmap(GSM_NokiaCallerLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length); | 528 | NOKIA_CopyBitmap(GSM_NokiaCallerLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length); |
524 | break; | 529 | break; |
525 | case SMS_NokiaProfileLong: | 530 | case SMS_NokiaProfileLong: |
526 | case SMS_NokiaPictureImageLong: | 531 | case SMS_NokiaPictureImageLong: |
527 | case SMS_NokiaScreenSaverLong: | 532 | case SMS_NokiaScreenSaverLong: |
528 | Class = 1; | 533 | Class = 1; |
529 | UDH= UDH_NokiaProfileLong; | 534 | UDH= UDH_NokiaProfileLong; |
530 | GSM_EncodeSMS30MultiPartSMS(Info,Buffer,&Length); | 535 | GSM_EncodeSMS30MultiPartSMS(Info,Buffer,&Length); |
531 | break; | 536 | break; |
532 | case SMS_NokiaWAPBookmarkLong: | 537 | case SMS_NokiaWAPBookmarkLong: |
533 | Class= 1; | 538 | Class= 1; |
534 | NOKIA_EncodeWAPBookmarkSMSText(Buffer,&Length,Info->Entries[0].Bookmark); | 539 | NOKIA_EncodeWAPBookmarkSMSText(Buffer,&Length,Info->Entries[0].Bookmark); |
535 | /* 7 = length of UDH_NokiaWAP UDH header */ | 540 | /* 7 = length of UDH_NokiaWAP UDH header */ |
536 | if (Length>(GSM_MAX_8BIT_SMS_LENGTH-7)) { | 541 | if (Length>(GSM_MAX_8BIT_SMS_LENGTH-7)) { |
537 | UDH=UDH_NokiaWAPLong; | 542 | UDH=UDH_NokiaWAPLong; |
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,53 +1,57 @@ | |||
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" |
12 | #include "gsmsms.h" | 16 | #include "gsmsms.h" |
13 | 17 | ||
14 | /* ---------------------- multi SMS --------------------------------------- */ | 18 | /* ---------------------- multi SMS --------------------------------------- */ |
15 | 19 | ||
16 | /* Identifiers for Smart Messaging 3.0 multipart SMS */ | 20 | /* Identifiers for Smart Messaging 3.0 multipart SMS */ |
17 | 21 | ||
18 | #define SM30_ISOTEXT 0 /* ISO 8859-1 text */ | 22 | #define SM30_ISOTEXT 0 /* ISO 8859-1 text */ |
19 | #define SM30_UNICODETEXT 1 | 23 | #define SM30_UNICODETEXT 1 |
20 | #define SM30_OTA 2 | 24 | #define SM30_OTA 2 |
21 | #define SM30_RINGTONE 3 | 25 | #define SM30_RINGTONE 3 |
22 | #define SM30_PROFILENAME 4 | 26 | #define SM30_PROFILENAME 4 |
23 | /* ... */ | 27 | /* ... */ |
24 | #define SM30_SCREENSAVER 6 | 28 | #define SM30_SCREENSAVER 6 |
25 | 29 | ||
26 | /* Identifiers for Alcatel Terminal Data Download */ | 30 | /* Identifiers for Alcatel Terminal Data Download */ |
27 | #define ALCATELTDD_PICTURE 4 | 31 | #define ALCATELTDD_PICTURE 4 |
28 | #define ALCATELTDD_ANIMATION 5 | 32 | #define ALCATELTDD_ANIMATION 5 |
29 | #define ALCATELTDD_SMSTEMPLATE 6 | 33 | #define ALCATELTDD_SMSTEMPLATE 6 |
30 | 34 | ||
31 | void GSM_SMSCounter(int MessageLength, | 35 | void GSM_SMSCounter(int MessageLength, |
32 | unsigned char *MessageBuffer, | 36 | unsigned char *MessageBuffer, |
33 | GSM_UDH UDHType, | 37 | GSM_UDH UDHType, |
34 | GSM_Coding_Type Coding, | 38 | GSM_Coding_Type Coding, |
35 | int *SMSNum, | 39 | int *SMSNum, |
36 | int *CharsLeft); | 40 | int *CharsLeft); |
37 | 41 | ||
38 | #define MAX_MULTI_SMS 10 | 42 | #define MAX_MULTI_SMS 10 |
39 | 43 | ||
40 | /** | 44 | /** |
41 | * Multiple SMS messages, used for Smart Messaging 3.0/EMS. | 45 | * Multiple SMS messages, used for Smart Messaging 3.0/EMS. |
42 | */ | 46 | */ |
43 | typedef struct { | 47 | typedef struct { |
44 | /** | 48 | /** |
45 | * Sender or recipient number. | 49 | * Sender or recipient number. |
46 | */ | 50 | */ |
47 | unsigned char Number; | 51 | unsigned char Number; |
48 | /** | 52 | /** |
49 | * Array of SMSes. | 53 | * Array of SMSes. |
50 | */ | 54 | */ |
51 | GSM_SMSMessage SMS[MAX_MULTI_SMS]; | 55 | GSM_SMSMessage SMS[MAX_MULTI_SMS]; |
52 | } GSM_MultiSMSMessage; | 56 | } GSM_MultiSMSMessage; |
53 | 57 | ||
@@ -127,145 +131,150 @@ typedef enum { | |||
127 | */ | 131 | */ |
128 | SMS_NokiaWAPBookmarkLong, | 132 | SMS_NokiaWAPBookmarkLong, |
129 | /** | 133 | /** |
130 | * Nokia WAP settings in 2 SMS | 134 | * Nokia WAP settings in 2 SMS |
131 | */ | 135 | */ |
132 | SMS_NokiaWAPSettingsLong, | 136 | SMS_NokiaWAPSettingsLong, |
133 | /** | 137 | /** |
134 | * Nokia MMS settings in 2 SMS | 138 | * Nokia MMS settings in 2 SMS |
135 | */ | 139 | */ |
136 | SMS_NokiaMMSSettingsLong, | 140 | SMS_NokiaMMSSettingsLong, |
137 | /** | 141 | /** |
138 | * Nokia VCARD 1.0 - only name and default number | 142 | * Nokia VCARD 1.0 - only name and default number |
139 | */ | 143 | */ |
140 | SMS_NokiaVCARD10Long, | 144 | SMS_NokiaVCARD10Long, |
141 | /** | 145 | /** |
142 | * Nokia VCARD 2.1 - all numbers + text | 146 | * Nokia VCARD 2.1 - all numbers + text |
143 | */ | 147 | */ |
144 | SMS_NokiaVCARD21Long, | 148 | SMS_NokiaVCARD21Long, |
145 | /** | 149 | /** |
146 | * Nokia VCALENDAR 1.0 - can be in few sms | 150 | * Nokia VCALENDAR 1.0 - can be in few sms |
147 | */ | 151 | */ |
148 | SMS_NokiaVCALENDAR10Long, | 152 | SMS_NokiaVCALENDAR10Long, |
149 | SMS_NokiaVTODOLong, | 153 | SMS_NokiaVTODOLong, |
150 | SMS_VCARD10Long, | 154 | SMS_VCARD10Long, |
151 | SMS_VCARD21Long, | 155 | SMS_VCARD21Long, |
152 | SMS_DisableVoice, | 156 | SMS_DisableVoice, |
153 | SMS_DisableFax, | 157 | SMS_DisableFax, |
154 | SMS_DisableEmail, | 158 | SMS_DisableEmail, |
155 | SMS_EnableVoice, | 159 | SMS_EnableVoice, |
156 | SMS_EnableFax, | 160 | SMS_EnableFax, |
157 | SMS_EnableEmail, | 161 | SMS_EnableEmail, |
158 | SMS_VoidSMS, | 162 | SMS_VoidSMS, |
159 | /** | 163 | /** |
160 | * IMelody 1.0 | 164 | * IMelody 1.0 |
161 | */ | 165 | */ |
162 | SMS_EMSSound10, | 166 | SMS_EMSSound10, |
163 | /** | 167 | /** |
164 | * IMelody 1.2 | 168 | * IMelody 1.2 |
165 | */ | 169 | */ |
166 | SMS_EMSSound12, | 170 | SMS_EMSSound12, |
167 | /** | 171 | /** |
168 | * IMelody without header - SonyEricsson extension | 172 | * IMelody without header - SonyEricsson extension |
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 | */ |
182 | SMS_EMSSonyEricssonSoundLong, | 186 | SMS_EMSSonyEricssonSoundLong, |
183 | SMS_EMSPredefinedSound, | 187 | SMS_EMSPredefinedSound, |
184 | SMS_EMSPredefinedAnimation, | 188 | SMS_EMSPredefinedAnimation, |
185 | SMS_EMSAnimation, | 189 | SMS_EMSAnimation, |
186 | /** | 190 | /** |
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 |
199 | */ | 204 | */ |
200 | SMS_AlcatelMonoAnimationLong, | 205 | SMS_AlcatelMonoAnimationLong, |
201 | SMS_AlcatelSMSTemplateName | 206 | SMS_AlcatelSMSTemplateName |
202 | } EncodeMultiPartSMSID; | 207 | } EncodeMultiPartSMSID; |
203 | 208 | ||
204 | typedef struct { | 209 | typedef struct { |
205 | EncodeMultiPartSMSID ID; | 210 | EncodeMultiPartSMSID ID; |
206 | 211 | ||
207 | int Number; | 212 | int Number; |
208 | GSM_Ringtone *Ringtone; | 213 | GSM_Ringtone *Ringtone; |
209 | GSM_MultiBitmap *Bitmap; | 214 | GSM_MultiBitmap *Bitmap; |
210 | GSM_WAPBookmark *Bookmark; | 215 | GSM_WAPBookmark *Bookmark; |
211 | GSM_WAPSettings *Settings; | 216 | GSM_WAPSettings *Settings; |
212 | GSM_MMSIndicator*MMSIndicator; | 217 | GSM_MMSIndicator*MMSIndicator; |
213 | GSM_MemoryEntry *Phonebook; | 218 | GSM_MemoryEntry *Phonebook; |
214 | GSM_CalendarEntry *Calendar; | 219 | GSM_CalendarEntry *Calendar; |
215 | GSM_ToDoEntry *ToDo; | 220 | GSM_ToDoEntry *ToDo; |
216 | bool Protected; | 221 | bool Protected; |
217 | 222 | ||
218 | unsigned char *Buffer; | 223 | unsigned char *Buffer; |
219 | bool Left; | 224 | bool Left; |
220 | bool Right; | 225 | bool Right; |
221 | bool Center; | 226 | bool Center; |
222 | bool Large; | 227 | bool Large; |
223 | bool Small; | 228 | bool Small; |
224 | bool Bold; | 229 | bool Bold; |
225 | bool Italic; | 230 | bool Italic; |
226 | bool Underlined; | 231 | bool Underlined; |
227 | bool Strikethrough; | 232 | bool Strikethrough; |
228 | 233 | ||
229 | /* Return values */ | 234 | /* Return values */ |
230 | int RingtoneNotes; | 235 | int RingtoneNotes; |
231 | } MultiPartSMSEntry; | 236 | } MultiPartSMSEntry; |
232 | 237 | ||
233 | typedef struct { | 238 | typedef struct { |
234 | MultiPartSMSEntryEntries[MAX_MULTI_SMS]; | 239 | MultiPartSMSEntryEntries[MAX_MULTI_SMS]; |
235 | int EntriesNum; | 240 | int EntriesNum; |
236 | bool UnicodeCoding; | 241 | bool UnicodeCoding; |
237 | int Class; | 242 | int Class; |
238 | unsigned char ReplaceMessage; | 243 | unsigned char ReplaceMessage; |
239 | bool Unknown; | 244 | bool Unknown; |
240 | } GSM_MultiPartSMSInfo; | 245 | } GSM_MultiPartSMSInfo; |
241 | 246 | ||
242 | /** | 247 | /** |
243 | * Encodes multi part SMS from "readable" format. | 248 | * Encodes multi part SMS from "readable" format. |
244 | */ | 249 | */ |
245 | GSM_Error GSM_EncodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS); | 250 | GSM_Error GSM_EncodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS); |
246 | 251 | ||
247 | /** | 252 | /** |
248 | * Decodes multi part SMS to "readable" format. | 253 | * Decodes multi part SMS to "readable" format. |
249 | */ | 254 | */ |
250 | bool GSM_DecodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS, bool ems); | 255 | bool GSM_DecodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS, bool ems); |
251 | 256 | ||
252 | /** | 257 | /** |
253 | * Clears @ref GSM_MultiPartSMSInfo to default values. | 258 | * Clears @ref GSM_MultiPartSMSInfo to default values. |
254 | */ | 259 | */ |
255 | void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info); | 260 | void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info); |
256 | 261 | ||
257 | /** | 262 | /** |
258 | * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo. | 263 | * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo. |
259 | */ | 264 | */ |
260 | void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info); | 265 | 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 | */ |
265 | GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems); | 270 | GSM_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,50 +1,53 @@ | |||
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" |
9 | #include "../../misc/coding/coding.h" | 12 | #include "../../misc/coding/coding.h" |
10 | #include "../gsmcal.h" | 13 | #include "../gsmcal.h" |
11 | #include "../gsmpbk.h" | 14 | #include "../gsmpbk.h" |
12 | #include "../gsmlogo.h" | 15 | #include "../gsmlogo.h" |
13 | #include "../gsmring.h" | 16 | #include "../gsmring.h" |
14 | #include "../gsmdata.h" | 17 | #include "../gsmdata.h" |
15 | #include "../gsmnet.h" | 18 | #include "../gsmnet.h" |
16 | #include "gsmsms.h" | 19 | #include "gsmsms.h" |
17 | 20 | ||
18 | /* User data headers */ | 21 | /* User data headers */ |
19 | static GSM_UDHHeader UDHHeaders[] = { | 22 | static GSM_UDHHeader UDHHeaders[] = { |
20 | /* See GSM 03.40 section 9.2.3.24.1 | 23 | /* See GSM 03.40 section 9.2.3.24.1 |
21 | * 1 byte 0x00 | 24 | * 1 byte 0x00 |
22 | * 1 byte 0x03 | 25 | * 1 byte 0x03 |
23 | * 1 byte 0x01: unique ID for message series | 26 | * 1 byte 0x01: unique ID for message series |
24 | * 1 byte 0x00: how many SMS in sequence | 27 | * 1 byte 0x00: how many SMS in sequence |
25 | * 1 byte 0x00: number of current SMS in sequence */ | 28 | * 1 byte 0x00: number of current SMS in sequence */ |
26 | { UDH_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00",2,-1,4,3}, | 29 | { UDH_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00",2,-1,4,3}, |
27 | 30 | ||
28 | /* See GSM 03.40 section 9.2.3.24.2 for voice, fax and email messages */ | 31 | /* See GSM 03.40 section 9.2.3.24.2 for voice, fax and email messages */ |
29 | { UDH_DisableVoice, 0x04, "\x01\x02\x00\x00",-1,-1,-1,-1}, | 32 | { UDH_DisableVoice, 0x04, "\x01\x02\x00\x00",-1,-1,-1,-1}, |
30 | { UDH_DisableFax, 0x04, "\x01\x02\x01\x00",-1,-1,-1,-1}, | 33 | { UDH_DisableFax, 0x04, "\x01\x02\x01\x00",-1,-1,-1,-1}, |
31 | { UDH_DisableEmail, 0x04, "\x01\x02\x02\x00",-1,-1,-1,-1}, | 34 | { UDH_DisableEmail, 0x04, "\x01\x02\x02\x00",-1,-1,-1,-1}, |
32 | { UDH_EnableVoice, 0x04, "\x01\x02\x00\x01",-1,-1,-1,-1}, | 35 | { UDH_EnableVoice, 0x04, "\x01\x02\x00\x01",-1,-1,-1,-1}, |
33 | { UDH_EnableFax, 0x04, "\x01\x02\x01\x01",-1,-1,-1,-1}, | 36 | { UDH_EnableFax, 0x04, "\x01\x02\x01\x01",-1,-1,-1,-1}, |
34 | { UDH_EnableEmail, 0x04, "\x01\x02\x02\x01",-1,-1,-1,-1}, | 37 | { UDH_EnableEmail, 0x04, "\x01\x02\x02\x01",-1,-1,-1,-1}, |
35 | 38 | ||
36 | /* When send such SMS to some phones, they don't display anything, | 39 | /* When send such SMS to some phones, they don't display anything, |
37 | * only beep and enable vibra/light | 40 | * only beep and enable vibra/light |
38 | */ | 41 | */ |
39 | { UDH_VoidSMS, 0x08, "\x01\x02\x02\x01\x01\x02\x02\x00",-1,-1,-1,-1}, | 42 | { UDH_VoidSMS, 0x08, "\x01\x02\x02\x01\x01\x02\x02\x00",-1,-1,-1,-1}, |
40 | 43 | ||
41 | /* Nokia Smart Messaging (short version) UDH | 44 | /* Nokia Smart Messaging (short version) UDH |
42 | * General format : | 45 | * General format : |
43 | * 1 byte 0x05 : IEI application port addressing scheme, 16 bit address | 46 | * 1 byte 0x05 : IEI application port addressing scheme, 16 bit address |
44 | * 1 byte 0x04 : IEI length | 47 | * 1 byte 0x04 : IEI length |
45 | * 2 bytes : destination address : high & low byte | 48 | * 2 bytes : destination address : high & low byte |
46 | * 2 bytes 0x00 0x00 : originator address : high & low byte */ | 49 | * 2 bytes 0x00 0x00 : originator address : high & low byte */ |
47 | { UDH_NokiaRingtone, 0x06, "\x05\x04\x15\x81\x00\x00",-1,-1,-1,-1}, | 50 | { UDH_NokiaRingtone, 0x06, "\x05\x04\x15\x81\x00\x00",-1,-1,-1,-1}, |
48 | { UDH_NokiaOperatorLogo, 0x06, "\x05\x04\x15\x82\x00\x00",-1,-1,-1,-1}, | 51 | { UDH_NokiaOperatorLogo, 0x06, "\x05\x04\x15\x82\x00\x00",-1,-1,-1,-1}, |
49 | { UDH_NokiaCallerLogo, 0x06, "\x05\x04\x15\x83\x00\x00",-1,-1,-1,-1}, | 52 | { UDH_NokiaCallerLogo, 0x06, "\x05\x04\x15\x83\x00\x00",-1,-1,-1,-1}, |
50 | { UDH_NokiaWAP, 0x06, "\x05\x04\xc3\x4f\x00\x00",-1,-1,-1,-1}, | 53 | { UDH_NokiaWAP, 0x06, "\x05\x04\xc3\x4f\x00\x00",-1,-1,-1,-1}, |
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,50 +1,53 @@ | |||
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" |
9 | #include "../gsmcal.h" | 12 | #include "../gsmcal.h" |
10 | #include "../gsmpbk.h" | 13 | #include "../gsmpbk.h" |
11 | #include "../gsmdata.h" | 14 | #include "../gsmdata.h" |
12 | #include "../gsmring.h" | 15 | #include "../gsmring.h" |
13 | 16 | ||
14 | /* --------------------- Some general definitions ------------------------- */ | 17 | /* --------------------- Some general definitions ------------------------- */ |
15 | 18 | ||
16 | #define GSM_MAX_UDH_LENGTH 140 | 19 | #define GSM_MAX_UDH_LENGTH 140 |
17 | #define GSM_MAX_SMS_LENGTH 160 | 20 | #define GSM_MAX_SMS_LENGTH 160 |
18 | #define GSM_MAX_8BIT_SMS_LENGTH 140 | 21 | #define GSM_MAX_8BIT_SMS_LENGTH 140 |
19 | 22 | ||
20 | /* -------------------- Cell Broadcast ------------------------------------ */ | 23 | /* -------------------- Cell Broadcast ------------------------------------ */ |
21 | 24 | ||
22 | /** | 25 | /** |
23 | * Structure for Cell Broadcast messages. | 26 | * Structure for Cell Broadcast messages. |
24 | */ | 27 | */ |
25 | typedef struct { | 28 | typedef struct { |
26 | /** | 29 | /** |
27 | * Message text. | 30 | * Message text. |
28 | */ | 31 | */ |
29 | char Text[300]; | 32 | char Text[300]; |
30 | /** | 33 | /** |
31 | * Channel number. | 34 | * Channel number. |
32 | */ | 35 | */ |
33 | int Channel; | 36 | int Channel; |
34 | } GSM_CBMessage; | 37 | } GSM_CBMessage; |
35 | 38 | ||
36 | /* ------------------------ SMS status ------------------------------------ */ | 39 | /* ------------------------ SMS status ------------------------------------ */ |
37 | 40 | ||
38 | /** | 41 | /** |
39 | * Status of SMS memory. | 42 | * Status of SMS memory. |
40 | */ | 43 | */ |
41 | typedef struct { | 44 | typedef struct { |
42 | /** | 45 | /** |
43 | * Number of unread messages on SIM. | 46 | * Number of unread messages on SIM. |
44 | */ | 47 | */ |
45 | int SIMUnRead; | 48 | int SIMUnRead; |
46 | /** | 49 | /** |
47 | * Number of all saved messages (including unread) on SIM. | 50 | * Number of all saved messages (including unread) on SIM. |
48 | */ | 51 | */ |
49 | int SIMUsed; | 52 | int SIMUsed; |
50 | /** | 53 | /** |