Diffstat (limited to 'gammu/emb/common/service/backup/backtext.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/service/backup/backtext.c | 229 |
1 files changed, 215 insertions, 14 deletions
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); |