7 #include "../../phone/nokia/nfunc.h" 8 #include "../../phone/nokia/dct3/n7110.h" 9 #include "../../misc/coding/coding.h" 10 #include "../gsmlogo.h" 11 #include "../gsmmisc.h" 12 #include "../gsmcal.h" 22 #include "../../../helper/string.h" 24 #ifdef GSM_ENABLE_BACKUP 26 void GSM_FreeBackup(GSM_Backup *backup)
31 while (backup->PhonePhonebook[i]!=NULL) {
33 free(backup->PhonePhonebook[i]);
34 backup->PhonePhonebook[i] = NULL;
38 while (backup->SIMPhonebook[i]!=NULL) {
39 free(backup->SIMPhonebook[i]);
40 backup->SIMPhonebook[i] = NULL;
44 while (backup->Calendar[i]!=NULL) {
45 free(backup->Calendar[i]);
46 backup->Calendar[i] = NULL;
50 while (backup->CallerLogos[i]!=NULL) {
51 free(backup->CallerLogos[i]);
52 backup->CallerLogos[i] = NULL;
56 while (backup->SMSC[i]!=NULL) {
57 free(backup->SMSC[i]);
58 backup->SMSC[i] = NULL;
62 while (backup->WAPBookmark[i]!=NULL) {
63 free(backup->WAPBookmark[i]);
64 backup->WAPBookmark[i] = NULL;
68 while (backup->WAPSettings[i]!=NULL) {
69 free(backup->WAPSettings[i]);
70 backup->WAPSettings[i] = NULL;
74 while (backup->MMSSettings[i]!=NULL) {
75 free(backup->MMSSettings[i]);
76 backup->MMSSettings[i] = NULL;
80 while (backup->SyncMLSettings[i]!=NULL) {
81 free(backup->SyncMLSettings[i]);
82 backup->SyncMLSettings[i] = NULL;
86 while (backup->ChatSettings[i]!=NULL) {
87 free(backup->ChatSettings[i]);
88 backup->ChatSettings[i] = NULL;
92 while (backup->Ringtone[i]!=NULL) {
93 free(backup->Ringtone[i]);
94 backup->Ringtone[i] = NULL;
98 while (backup->ToDo[i]!=NULL) {
99 free(backup->ToDo[i]);
100 backup->ToDo[i] = NULL;
104 while (backup->Profiles[i]!=NULL) {
105 free(backup->Profiles[i]);
106 backup->Profiles[i] = NULL;
110 while (backup->FMStation[i]!=NULL) {
111 free(backup->FMStation[i]);
112 backup->FMStation[i] = NULL;
115 if (backup->StartupLogo!=NULL) {
116 free(backup->StartupLogo);
117 backup->StartupLogo = NULL;
119 if (backup->OperatorLogo!=NULL) {
120 free(backup->OperatorLogo);
121 backup->OperatorLogo = NULL;
124 while (backup->GPRSPoint[i]!=NULL) {
125 free(backup->GPRSPoint[i]);
126 backup->GPRSPoint[i] = NULL;
130 while (backup->Note[i]!=NULL) {
131 free(backup->Note[i]);
132 backup->Note[i] = NULL;
137 GSM_BackupFormat GSM_GuessBackupFormat(
const char *FileName,
const gboolean UseUnicode) {
138 GSM_BackupFormat Format = -1;
140 if (strcasestr(FileName,
".lmb")) {
141 Format = GSM_Backup_LMB;
142 }
else if (strcasestr(FileName,
".vcs")) {
143 Format = GSM_Backup_VCalendar;
144 }
else if (strcasestr(FileName,
".vnt")) {
145 Format = GSM_Backup_VNote;
146 }
else if (strcasestr(FileName,
".vcf")) {
147 Format = GSM_Backup_VCard;
148 }
else if (strcasestr(FileName,
".ldif")) {
149 Format = GSM_Backup_LDIF;
150 }
else if (strcasestr(FileName,
".ics")) {
151 Format = GSM_Backup_ICS;
154 Format = GSM_Backup_GammuUCS2;
156 Format = GSM_Backup_Gammu;
162 GSM_Error GSM_SaveBackupFile(
char *FileName, GSM_Backup *backup, GSM_BackupFormat Format)
164 if (Format == GSM_Backup_Auto || Format == GSM_Backup_AutoUnicode) {
165 Format = GSM_GuessBackupFormat(FileName, Format == GSM_Backup_AutoUnicode);
170 return SaveLMB(FileName,backup);
171 case GSM_Backup_VCalendar:
172 return SaveVCalendar(FileName,backup);
173 case GSM_Backup_VCard:
174 return SaveVCard(FileName,backup);
175 case GSM_Backup_LDIF:
176 return SaveLDIF(FileName,backup);
178 return SaveICS(FileName,backup);
179 case GSM_Backup_Gammu:
180 return SaveBackup(FileName,backup,
FALSE);
181 case GSM_Backup_GammuUCS2:
182 return SaveBackup(FileName,backup,
TRUE);
183 case GSM_Backup_VNote:
184 return SaveVNT(FileName,backup);
190 GSM_Error GSM_ReadBackupFile(
const char *FileName, GSM_Backup *backup, GSM_BackupFormat Format)
192 GSM_ClearBackup(backup);
194 if (Format == GSM_Backup_Auto || Format == GSM_Backup_AutoUnicode) {
195 Format = GSM_GuessBackupFormat(FileName, Format == GSM_Backup_AutoUnicode);
200 return LoadLMB(FileName,backup);
201 case GSM_Backup_VCalendar:
202 return LoadVCalendar(FileName,backup);
203 case GSM_Backup_VCard:
204 return LoadVCard(FileName,backup);
205 case GSM_Backup_VNote:
206 return LoadVNT(FileName,backup);
207 case GSM_Backup_LDIF:
208 return LoadLDIF(FileName,backup);
210 return LoadICS(FileName,backup);
211 case GSM_Backup_Gammu:
212 return LoadBackup(FileName,backup);
213 case GSM_Backup_GammuUCS2:
214 return LoadBackup(FileName,backup);
220 void GSM_ClearBackup(GSM_Backup *backup)
222 backup->PhonePhonebook [0] = NULL;
223 backup->SIMPhonebook [0] = NULL;
224 backup->Calendar [0] = NULL;
225 backup->CallerLogos [0] = NULL;
226 backup->SMSC [0] = NULL;
227 backup->WAPBookmark [0] = NULL;
228 backup->WAPSettings [0] = NULL;
229 backup->MMSSettings [0] = NULL;
230 backup->SyncMLSettings [0] = NULL;
231 backup->ChatSettings [0] = NULL;
232 backup->Ringtone [0] = NULL;
233 backup->Profiles [0] = NULL;
234 backup->ToDo [0] = NULL;
235 backup->GPRSPoint [0] = NULL;
236 backup->FMStation [0] = NULL;
237 backup->Note [0] = NULL;
238 backup->StartupLogo = NULL;
239 backup->OperatorLogo = NULL;
241 backup->Creator [0] = 0;
242 backup->IMEI [0] = 0;
243 backup->Model [0] = 0;
244 backup->DateTimeAvailable =
FALSE;
245 backup->MD5Original [0] = 0;
246 backup->MD5Calculated [0] = 0;
249 void GSM_GetBackupFormatFeatures(GSM_BackupFormat Format, GSM_Backup_Info *info)
251 info->UseUnicode =
FALSE;
254 info->DateTime =
FALSE;
255 info->PhonePhonebook =
FALSE;
256 info->SIMPhonebook =
FALSE;
258 info->Calendar =
FALSE;
259 info->CallerLogos =
FALSE;
261 info->WAPBookmark =
FALSE;
262 info->WAPSettings =
FALSE;
263 info->MMSSettings =
FALSE;
264 info->SyncMLSettings =
FALSE;
265 info->ChatSettings =
FALSE;
266 info->Ringtone =
FALSE;
267 info->StartupLogo =
FALSE;
268 info->OperatorLogo =
FALSE;
269 info->Profiles =
FALSE;
270 info->FMStation =
FALSE;
271 info->GPRSPoint =
FALSE;
276 info->PhonePhonebook =
TRUE;
277 info->SIMPhonebook =
TRUE;
278 info->CallerLogos =
TRUE;
279 info->StartupLogo =
TRUE;
281 case GSM_Backup_VCalendar:
283 info->Calendar =
TRUE;
285 case GSM_Backup_VCard:
286 info->PhonePhonebook =
TRUE;
287 info->SIMPhonebook =
TRUE;
289 case GSM_Backup_VNote:
292 case GSM_Backup_LDIF:
293 info->PhonePhonebook =
TRUE;
297 info->Calendar =
TRUE;
299 case GSM_Backup_Gammu:
300 case GSM_Backup_GammuUCS2:
301 info->UseUnicode =
TRUE;
304 info->DateTime =
TRUE;
305 info->PhonePhonebook =
TRUE;
306 info->SIMPhonebook =
TRUE;
308 info->Calendar =
TRUE;
309 info->CallerLogos =
TRUE;
311 info->WAPBookmark =
TRUE;
312 info->WAPSettings =
TRUE;
313 info->MMSSettings =
TRUE;
314 info->SyncMLSettings =
TRUE;
315 info->ChatSettings =
TRUE;
316 info->Ringtone =
TRUE;
317 info->StartupLogo =
TRUE;
318 info->OperatorLogo =
TRUE;
319 info->Profiles =
TRUE;
320 info->FMStation =
TRUE;
321 info->GPRSPoint =
TRUE;
329 void GSM_GetBackupFileFeatures(GSM_BackupFormat Format, GSM_Backup_Info *info, GSM_Backup *backup)
331 GSM_GetBackupFormatFeatures(Format, info);
333 if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook =
FALSE;
334 if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook =
FALSE;
335 if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar =
FALSE;
336 if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo =
FALSE;
337 if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark =
FALSE;
338 if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings =
FALSE;
339 if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings =
FALSE;
340 if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation =
FALSE;
341 if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint =
FALSE;
342 if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles =
FALSE;
void GSM_FreeMemoryEntry(GSM_MemoryEntry *Entry)