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/gsmback.c | |
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/gsmback.c') (more/less context) (show whitespace changes)
-rw-r--r-- | gammu/emb/common/service/backup/gsmback.c | 36 |
1 files changed, 27 insertions, 9 deletions
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; |