author | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
commit | 50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff) | |
tree | 0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/service/backup | |
parent | cf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff) | |
download | kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2 |
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/service/backup') (more/less context) (ignore whitespace changes)
-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 |
4 files changed, 248 insertions, 23 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 | |||
@@ -130,95 +130,96 @@ static void ReadLinkedBackupText(INI_Section *file_info, char *section, char *my | |||
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 | ||
@@ -397,66 +398,77 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode) | |||
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: |
@@ -636,48 +648,90 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo | |||
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 | ||
@@ -743,65 +797,66 @@ static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode) | |||
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; |
@@ -1054,83 +1109,104 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode) | |||
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); |
@@ -2635,49 +2711,174 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode) | |||
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); |
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 | |||
@@ -52,221 +52,239 @@ void GSM_FreeBackup(GSM_Backup *backup) | |||
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; |
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 | |||
@@ -8,41 +8,43 @@ | |||
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 | */ |