author | zautrix <zautrix> | 2004-08-07 17:24:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-07 17:24:40 (UTC) |
commit | 88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22 (patch) (unidiff) | |
tree | 6331418973714243beb674abc87692277b83869d /gammu/emb/common/service/backup | |
parent | ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf (diff) | |
download | kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.zip kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.tar.gz kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.tar.bz2 |
Initial revision
Diffstat (limited to 'gammu/emb/common/service/backup') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/service/backup/backgen.h | 69 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backics.c | 42 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backics.h | 17 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backldif.c | 297 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backldif.h | 17 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backlmb.c | 413 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backlmb.h | 17 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backtext.c | 2908 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backtext.h | 17 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backvcf.c | 75 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backvcf.h | 17 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backvcs.c | 106 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/backvcs.h | 17 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/gsmback.c | 280 | ||||
-rw-r--r-- | gammu/emb/common/service/backup/gsmback.h | 48 |
15 files changed, 4340 insertions, 0 deletions
diff --git a/gammu/emb/common/service/backup/backgen.h b/gammu/emb/common/service/backup/backgen.h new file mode 100644 index 0000000..9d7d973 --- a/dev/null +++ b/gammu/emb/common/service/backup/backgen.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_backgen_h | ||
4 | #define __gsm_backgen_h | ||
5 | |||
6 | #include "../../config.h" | ||
7 | #include "../../misc/misc.h" | ||
8 | #include "../gsmpbk.h" | ||
9 | #include "../gsmcal.h" | ||
10 | #include "../gsmlogo.h" | ||
11 | #include "../gsmring.h" | ||
12 | #include "../gsmdata.h" | ||
13 | #include "../gsmprof.h" | ||
14 | #include "../gsmmisc.h" | ||
15 | #include "../sms/gsmsms.h" | ||
16 | |||
17 | #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501 | ||
18 | #define GSM_BACKUP_MAX_SIMPHONEBOOK 251 | ||
19 | #define GSM_BACKUP_MAX_CALLER 6 | ||
20 | #define GSM_BACKUP_MAX_SMSC 10 | ||
21 | #define GSM_BACKUP_MAX_WAPBOOKMARK40 | ||
22 | #define GSM_BACKUP_MAX_WAPSETTINGS30 | ||
23 | #define GSM_BACKUP_MAX_MMSSETTINGS30 | ||
24 | #define GSM_BACKUP_MAX_RINGTONES30 | ||
25 | #define GSM_BACKUP_MAX_PROFILES 10 | ||
26 | #define GSM_BACKUP_MAX_FMSTATIONS20 | ||
27 | #define GSM_BACKUP_MAX_GPRSPOINT10 | ||
28 | #define GSM_BACKUP_MAX_NOTE 10/* FIXME */ | ||
29 | |||
30 | typedef struct { | ||
31 | char IMEI [MAX_IMEI_LENGTH]; | ||
32 | char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH]; | ||
33 | char Creator [80]; | ||
34 | GSM_DateTime DateTime; | ||
35 | bool DateTimeAvailable; | ||
36 | char MD5Original[100]; | ||
37 | char MD5Calculated[100]; | ||
38 | GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1]; | ||
39 | GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1]; | ||
40 | GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1]; | ||
41 | GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1]; | ||
42 | GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1]; | ||
43 | GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1]; | ||
44 | GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1]; | ||
45 | GSM_MultiWAPSettings *MMSSettings[GSM_BACKUP_MAX_MMSSETTINGS + 1]; | ||
46 | GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1]; | ||
47 | GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1]; | ||
48 | GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1]; | ||
49 | GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1]; | ||
50 | GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1]; | ||
51 | GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1]; | ||
52 | GSM_Bitmap *StartupLogo; | ||
53 | GSM_Bitmap *OperatorLogo; | ||
54 | } GSM_Backup; | ||
55 | |||
56 | #define GSM_BACKUP_MAX_SMS500 | ||
57 | |||
58 | typedef struct { | ||
59 | GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS]; | ||
60 | } GSM_SMS_Backup; | ||
61 | |||
62 | extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); | ||
63 | extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); | ||
64 | |||
65 | #endif | ||
66 | |||
67 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
68 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
69 | */ | ||
diff --git a/gammu/emb/common/service/backup/backics.c b/gammu/emb/common/service/backup/backics.c new file mode 100644 index 0000000..3e6b083 --- a/dev/null +++ b/gammu/emb/common/service/backup/backics.c | |||
@@ -0,0 +1,42 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <ctype.h> | ||
5 | |||
6 | #include "../../phone/nokia/nfunc.h" | ||
7 | #include "../../phone/nokia/dct3/n7110.h" | ||
8 | #include "../../misc/coding/coding.h" | ||
9 | #include "../gsmlogo.h" | ||
10 | #include "../gsmmisc.h" | ||
11 | #include "backics.h" | ||
12 | |||
13 | #ifdef GSM_ENABLE_BACKUP | ||
14 | |||
15 | GSM_Error SaveICS(char *FileName, GSM_Backup *backup) | ||
16 | { | ||
17 | FILE *file; | ||
18 | |||
19 | file = fopen(FileName, "wb"); | ||
20 | if (file == NULL) return ERR_CANTOPENFILE; | ||
21 | |||
22 | fclose(file); | ||
23 | return ERR_NONE; | ||
24 | } | ||
25 | |||
26 | GSM_Error LoadICS(char *FileName, GSM_Backup *backup) | ||
27 | { | ||
28 | GSM_File File; | ||
29 | GSM_Error error; | ||
30 | |||
31 | File.Buffer = NULL; | ||
32 | error = GSM_ReadFile(FileName, &File); | ||
33 | if (error != ERR_NONE) return error; | ||
34 | |||
35 | return ERR_NONE; | ||
36 | } | ||
37 | |||
38 | #endif | ||
39 | |||
40 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
41 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
42 | */ | ||
diff --git a/gammu/emb/common/service/backup/backics.h b/gammu/emb/common/service/backup/backics.h new file mode 100644 index 0000000..80e2b15 --- a/dev/null +++ b/gammu/emb/common/service/backup/backics.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_backics_h | ||
4 | #define __gsm_backics_h | ||
5 | |||
6 | #include "backgen.h" | ||
7 | |||
8 | #ifdef GSM_ENABLE_BACKUP | ||
9 | GSM_Error SaveICS(char *FileName, GSM_Backup *backup); | ||
10 | GSM_Error LoadICS(char *FileName, GSM_Backup *backup); | ||
11 | #endif | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
16 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
17 | */ | ||
diff --git a/gammu/emb/common/service/backup/backldif.c b/gammu/emb/common/service/backup/backldif.c new file mode 100644 index 0000000..ab16160 --- a/dev/null +++ b/gammu/emb/common/service/backup/backldif.c | |||
@@ -0,0 +1,297 @@ | |||
1 | /* (c) 2003-2004 by Marcin Wiacek */ | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <ctype.h> | ||
5 | |||
6 | #include "../../phone/nokia/nfunc.h" | ||
7 | #include "../../phone/nokia/dct3/n7110.h" | ||
8 | #include "../../misc/coding/coding.h" | ||
9 | #include "../gsmlogo.h" | ||
10 | #include "../gsmmisc.h" | ||
11 | #include "backldif.h" | ||
12 | |||
13 | #ifdef GSM_ENABLE_BACKUP | ||
14 | |||
15 | static void SaveLDIFText(FILE *file, unsigned char *Name, unsigned char *Value) | ||
16 | { | ||
17 | unsigned char Buffer[1000],Buffer2[1000]; | ||
18 | |||
19 | if (EncodeUTF8(Buffer, Value)) { | ||
20 | // dbgprintf("%s\n",Buffer); | ||
21 | EncodeBASE64(Buffer, Buffer2, strlen(Buffer)); | ||
22 | fprintf(file,"%s:: %s%c%c",Name,Buffer2,13,10); | ||
23 | } else { | ||
24 | fprintf(file,"%s: %s%c%c",Name,DecodeUnicodeString(Value),13,10); | ||
25 | } | ||
26 | } | ||
27 | |||
28 | GSM_Error SaveLDIF(char *FileName, GSM_Backup *backup) | ||
29 | { | ||
30 | int i, j; | ||
31 | FILE *file; | ||
32 | |||
33 | file = fopen(FileName, "wb"); | ||
34 | if (file == NULL) return ERR_CANTOPENFILE; | ||
35 | |||
36 | i=0; | ||
37 | while (backup->PhonePhonebook[i]!=NULL) { | ||
38 | for (j=0;j<backup->PhonePhonebook[i]->EntriesNum;j++) { | ||
39 | switch (backup->PhonePhonebook[i]->Entries[j].EntryType) { | ||
40 | case PBK_Text_Name: | ||
41 | SaveLDIFText(file, "dn", backup->PhonePhonebook[i]->Entries[j].Text); | ||
42 | break; | ||
43 | default: | ||
44 | break; | ||
45 | } | ||
46 | } | ||
47 | fprintf(file, "objectclass: top%c%c",13,10); | ||
48 | fprintf(file, "objectclass: person%c%c",13,10); | ||
49 | fprintf(file, "objectclass: organizationalPerson%c%c",13,10); | ||
50 | fprintf(file, "objectclass: inetOrgPerson%c%c",13,10); | ||
51 | fprintf(file, "objectclass: mozillaAbPersonObsolete%c%c",13,10); | ||
52 | for (j=0;j<backup->PhonePhonebook[i]->EntriesNum;j++) { | ||
53 | switch (backup->PhonePhonebook[i]->Entries[j].EntryType) { | ||
54 | case PBK_Text_Postal: | ||
55 | SaveLDIFText(file, "HomePostalAddress", backup->PhonePhonebook[i]->Entries[j].Text); | ||
56 | break; | ||
57 | case PBK_Text_URL: | ||
58 | SaveLDIFText(file, "homeurl", backup->PhonePhonebook[i]->Entries[j].Text); | ||
59 | break; | ||
60 | case PBK_Text_Name: | ||
61 | SaveLDIFText(file, "givenName", backup->PhonePhonebook[i]->Entries[j].Text); | ||
62 | SaveLDIFText(file, "cn", backup->PhonePhonebook[i]->Entries[j].Text); | ||
63 | break; | ||
64 | case PBK_Text_Note: | ||
65 | SaveLDIFText(file, "Description", backup->PhonePhonebook[i]->Entries[j].Text); | ||
66 | break; | ||
67 | case PBK_Number_Work: | ||
68 | SaveLDIFText(file, "workPhone", backup->PhonePhonebook[i]->Entries[j].Text);//not exist in Mozilla 1.4 win32 | ||
69 | break; | ||
70 | case PBK_Number_Mobile: | ||
71 | SaveLDIFText(file, "mobile", backup->PhonePhonebook[i]->Entries[j].Text); | ||
72 | break; | ||
73 | case PBK_Number_Pager: | ||
74 | SaveLDIFText(file, "pager", backup->PhonePhonebook[i]->Entries[j].Text); | ||
75 | break; | ||
76 | case PBK_Number_Fax: | ||
77 | SaveLDIFText(file, "fax", backup->PhonePhonebook[i]->Entries[j].Text);//facsimileTelephoneNumber | ||
78 | break; | ||
79 | case PBK_Number_Home: | ||
80 | SaveLDIFText(file, "homePhone", backup->PhonePhonebook[i]->Entries[j].Text); | ||
81 | break; | ||
82 | case PBK_Number_General: | ||
83 | SaveLDIFText(file, "telephoneNumber", backup->PhonePhonebook[i]->Entries[j].Text);//work in Mozilla 1.4 win32 | ||
84 | break; | ||
85 | case PBK_Text_Email: | ||
86 | SaveLDIFText(file, "mail", backup->PhonePhonebook[i]->Entries[j].Text); | ||
87 | break; | ||
88 | case PBK_Text_Email2: | ||
89 | SaveLDIFText(file, "mozillaSecondEmail", backup->PhonePhonebook[i]->Entries[j].Text); | ||
90 | break; | ||
91 | case PBK_Text_Custom1: | ||
92 | SaveLDIFText(file, "custom1", backup->PhonePhonebook[i]->Entries[j].Text); | ||
93 | break; | ||
94 | case PBK_Text_Custom2: | ||
95 | SaveLDIFText(file, "custom2", backup->PhonePhonebook[i]->Entries[j].Text); | ||
96 | break; | ||
97 | case PBK_Text_Custom3: | ||
98 | SaveLDIFText(file, "custom3", backup->PhonePhonebook[i]->Entries[j].Text); | ||
99 | break; | ||
100 | case PBK_Text_Custom4: | ||
101 | SaveLDIFText(file, "custom4", backup->PhonePhonebook[i]->Entries[j].Text); | ||
102 | break; | ||
103 | case PBK_Text_Company: | ||
104 | SaveLDIFText(file, "o", backup->PhonePhonebook[i]->Entries[j].Text); | ||
105 | break; | ||
106 | case PBK_Text_JobTitle: | ||
107 | SaveLDIFText(file, "title", backup->PhonePhonebook[i]->Entries[j].Text); | ||
108 | break; | ||
109 | case PBK_Text_StreetAddress: | ||
110 | SaveLDIFText(file, "homePostalAddress", backup->PhonePhonebook[i]->Entries[j].Text); | ||
111 | break; | ||
112 | case PBK_Text_City: | ||
113 | SaveLDIFText(file, "mozillaHomeLocalityName", backup->PhonePhonebook[i]->Entries[j].Text); | ||
114 | break; | ||
115 | case PBK_Text_State: | ||
116 | SaveLDIFText(file, "mozillaHomeState", backup->PhonePhonebook[i]->Entries[j].Text); | ||
117 | break; | ||
118 | case PBK_Text_Zip: | ||
119 | SaveLDIFText(file, "mozillaHomePostalCode", backup->PhonePhonebook[i]->Entries[j].Text); | ||
120 | break; | ||
121 | case PBK_Text_Country: | ||
122 | SaveLDIFText(file, "mozillaHomeCountryName", backup->PhonePhonebook[i]->Entries[j].Text); | ||
123 | break; | ||
124 | case PBK_Number_Other: | ||
125 | case PBK_Caller_Group: | ||
126 | case PBK_RingtoneID: | ||
127 | case PBK_PictureID: | ||
128 | case PBK_Date: | ||
129 | case PBK_RingtoneFileSystemID: | ||
130 | case PBK_Text_UserID: | ||
131 | case PBK_SMSListID: | ||
132 | case PBK_Category: | ||
133 | case PBK_Private: | ||
134 | case PBK_Text_LastName: | ||
135 | case PBK_Text_FirstName: | ||
136 | dbgprintf("Feature missed\n"); | ||
137 | break; | ||
138 | } | ||
139 | } | ||
140 | fprintf(file, "%c%c",13,10); | ||
141 | i++; | ||
142 | } | ||
143 | fclose(file); | ||
144 | return ERR_NONE; | ||
145 | } | ||
146 | |||
147 | static bool ReadLDIFText(char *Buffer, char *Start, char *Value) | ||
148 | { | ||
149 | unsigned char Buffer2[1000],buff[200]; | ||
150 | int i; | ||
151 | |||
152 | Value[0] = 0x00; | ||
153 | |||
154 | strcpy(buff,Start); | ||
155 | strcat(buff,":: "); | ||
156 | if (!strncmp(Buffer,buff,strlen(buff))) { | ||
157 | i = DecodeBASE64(Buffer+strlen(Start)+3, Buffer2, strlen(Buffer)-(strlen(Start)+3)); | ||
158 | dbgprintf("Text after DecodeBASE64 is \"%s\"\n",Buffer2); | ||
159 | DecodeUTF8(Value, Buffer2, i); | ||
160 | dbgprintf("Text after DecodeUTF8 is \"%s\"\n",DecodeUnicodeString(Value)); | ||
161 | return true; | ||
162 | } | ||
163 | strcpy(buff,Start); | ||
164 | strcat(buff,": "); | ||
165 | if (!strncmp(Buffer,buff,strlen(buff))) { | ||
166 | EncodeUnicode(Value,Buffer+strlen(Start)+2,strlen(Buffer)-(strlen(Start)+2)); | ||
167 | dbgprintf("Text after EncodeUnicode is \"%s\"\n",DecodeUnicodeString(Value)); | ||
168 | return true; | ||
169 | } | ||
170 | return false; | ||
171 | } | ||
172 | |||
173 | static GSM_Error GSM_DecodeLDIFEntry(unsigned char *Buffer, int *Pos, GSM_MemoryEntry *Pbk) | ||
174 | { | ||
175 | unsigned char Line[2000],Buff[2000],Buff2[2000]; | ||
176 | int Level = 0; | ||
177 | |||
178 | Buff[0] = 0; | ||
179 | Pbk->EntriesNum = 0; | ||
180 | |||
181 | while (1) { | ||
182 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); | ||
183 | if (strlen(Line) == 0) break; | ||
184 | switch (Level) { | ||
185 | case 0: | ||
186 | if (ReadLDIFText(Line, "objectclass", Buff)) { | ||
187 | sprintf(Buff2,"%s",DecodeUnicodeString(Buff)); | ||
188 | if (!strcmp("mozillaAbPersonObsolete",Buff2)) { | ||
189 | dbgprintf("level1\n"); | ||
190 | Level = 1; | ||
191 | } | ||
192 | } | ||
193 | break; | ||
194 | case 1: | ||
195 | if (ReadLDIFText(Line, "dn", Buff)) { | ||
196 | dbgprintf("entries num is %i\n",Pbk->EntriesNum); | ||
197 | if (Pbk->EntriesNum == 0) return ERR_EMPTY; | ||
198 | return ERR_NONE; | ||
199 | } | ||
200 | if (ReadLDIFText(Line, "givenName", Buff)) { | ||
201 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
202 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Name; | ||
203 | Pbk->EntriesNum++; | ||
204 | } | ||
205 | if (ReadLDIFText(Line, "telephoneNumber", Buff)) { | ||
206 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
207 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_General; | ||
208 | Pbk->EntriesNum++; | ||
209 | } | ||
210 | if (ReadLDIFText(Line, "mobile", Buff)) { | ||
211 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
212 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Mobile; | ||
213 | Pbk->EntriesNum++; | ||
214 | } | ||
215 | if (ReadLDIFText(Line, "workPhone", Buff)) { | ||
216 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
217 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Work; | ||
218 | Pbk->EntriesNum++; | ||
219 | } | ||
220 | if (ReadLDIFText(Line, "fax", Buff)) { | ||
221 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
222 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Fax; | ||
223 | Pbk->EntriesNum++; | ||
224 | } | ||
225 | if (ReadLDIFText(Line, "homePhone",Buff)) { | ||
226 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
227 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Home; | ||
228 | Pbk->EntriesNum++; | ||
229 | } | ||
230 | if (ReadLDIFText(Line, "Description", Buff)) { | ||
231 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
232 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Note; | ||
233 | Pbk->EntriesNum++; | ||
234 | } | ||
235 | if (ReadLDIFText(Line, "HomePostalAddress", Buff)) { | ||
236 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
237 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Postal; | ||
238 | Pbk->EntriesNum++; | ||
239 | } | ||
240 | if (ReadLDIFText(Line, "mail", Buff)) { | ||
241 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
242 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Email; | ||
243 | Pbk->EntriesNum++; | ||
244 | } | ||
245 | if (ReadLDIFText(Line, "homeurl", Buff)) { | ||
246 | CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); | ||
247 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_URL; | ||
248 | Pbk->EntriesNum++; | ||
249 | } | ||
250 | /* FIXME: add rest */ | ||
251 | break; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | dbgprintf("entries num is %i\n",Pbk->EntriesNum); | ||
256 | if (Pbk->EntriesNum == 0) return ERR_EMPTY; | ||
257 | return ERR_NONE; | ||
258 | } | ||
259 | |||
260 | GSM_Error LoadLDIF(char *FileName, GSM_Backup *backup) | ||
261 | { | ||
262 | GSM_File File; | ||
263 | GSM_Error error; | ||
264 | GSM_MemoryEntryPbk; | ||
265 | int numPbk = 0, Pos; | ||
266 | |||
267 | File.Buffer = NULL; | ||
268 | error = GSM_ReadFile(FileName, &File); | ||
269 | if (error != ERR_NONE) return error; | ||
270 | |||
271 | Pos = 0; | ||
272 | while (1) { | ||
273 | error = GSM_DecodeLDIFEntry(File.Buffer, &Pos, &Pbk); | ||
274 | if (error == ERR_EMPTY) break; | ||
275 | if (error != ERR_NONE) return error; | ||
276 | if (numPbk < GSM_BACKUP_MAX_PHONEPHONEBOOK) { | ||
277 | backup->PhonePhonebook[numPbk] = malloc(sizeof(GSM_MemoryEntry)); | ||
278 | if (backup->PhonePhonebook[numPbk] == NULL) return ERR_MOREMEMORY; | ||
279 | backup->PhonePhonebook[numPbk + 1] = NULL; | ||
280 | } else { | ||
281 | dbgprintf("Increase GSM_BACKUP_MAX_PHONEPHONEBOOK\n"); | ||
282 | return ERR_MOREMEMORY; | ||
283 | } | ||
284 | memcpy(backup->PhonePhonebook[numPbk],&Pbk,sizeof(GSM_MemoryEntry)); | ||
285 | backup->PhonePhonebook[numPbk]->Location = numPbk + 1; | ||
286 | backup->PhonePhonebook[numPbk]->MemoryType = MEM_ME; | ||
287 | numPbk++; | ||
288 | } | ||
289 | |||
290 | return ERR_NONE; | ||
291 | } | ||
292 | |||
293 | #endif | ||
294 | |||
295 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
296 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
297 | */ | ||
diff --git a/gammu/emb/common/service/backup/backldif.h b/gammu/emb/common/service/backup/backldif.h new file mode 100644 index 0000000..212c048 --- a/dev/null +++ b/gammu/emb/common/service/backup/backldif.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_backldif_h | ||
4 | #define __gsm_backldif_h | ||
5 | |||
6 | #include "backgen.h" | ||
7 | |||
8 | #ifdef GSM_ENABLE_BACKUP | ||
9 | GSM_Error SaveLDIF(char *FileName, GSM_Backup *backup); | ||
10 | GSM_Error LoadLDIF(char *FileName, GSM_Backup *backup); | ||
11 | #endif | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
16 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
17 | */ | ||
diff --git a/gammu/emb/common/service/backup/backlmb.c b/gammu/emb/common/service/backup/backlmb.c new file mode 100644 index 0000000..d7f845a --- a/dev/null +++ b/gammu/emb/common/service/backup/backlmb.c | |||
@@ -0,0 +1,413 @@ | |||
1 | /* (c) 2001-2004 by Marcin Wiacek */ | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <ctype.h> | ||
5 | |||
6 | #include "../../phone/nokia/nfunc.h" | ||
7 | #include "../../phone/nokia/dct3/n7110.h" | ||
8 | #include "../../misc/coding/coding.h" | ||
9 | #include "../gsmlogo.h" | ||
10 | #include "../gsmmisc.h" | ||
11 | #include "backlmb.h" | ||
12 | |||
13 | #ifdef GSM_ENABLE_BACKUP | ||
14 | |||
15 | static void SaveLMBStartupEntry(FILE *file, GSM_Bitmap bitmap) | ||
16 | { | ||
17 | int count=13; | ||
18 | GSM_Phone_Bitmap_Types Type; | ||
19 | /* Welcome note and logo header block */ | ||
20 | char req[1000] = { | ||
21 | 'W','E','L',' ', /*block identifier*/ | ||
22 | 00,00, /*block data size*/ | ||
23 | 0x02,00,00,00,00,00, | ||
24 | 0x00}; /*number of blocks (like in 6110 frame)*/ | ||
25 | |||
26 | if (bitmap.Type == GSM_StartupLogo) { | ||
27 | req[count++] = 0x01; | ||
28 | req[count++] = bitmap.BitmapHeight; | ||
29 | req[count++] = bitmap.BitmapWidth; | ||
30 | Type = GSM_NokiaStartupLogo; | ||
31 | switch (bitmap.BitmapHeight) { | ||
32 | case 65: Type = GSM_Nokia7110StartupLogo; break; | ||
33 | case 60: Type = GSM_Nokia6210StartupLogo; break; | ||
34 | } | ||
35 | PHONE_EncodeBitmap(Type, req+count, &bitmap); | ||
36 | count = count + PHONE_GetBitmapSize(Type, 0, 0); | ||
37 | |||
38 | req[12]++; | ||
39 | } | ||
40 | if (bitmap.Type == GSM_WelcomeNote_Text) { | ||
41 | req[count++]=0x02; | ||
42 | req[count++]=UnicodeLength(bitmap.Text); | ||
43 | memcpy(req+count,DecodeUnicodeString(bitmap.Text),UnicodeLength(bitmap.Text)); | ||
44 | count=count+UnicodeLength(bitmap.Text); | ||
45 | |||
46 | req[12]++; | ||
47 | } | ||
48 | |||
49 | req[4]=(count-12)%256; | ||
50 | req[5]=(count-12)/256; | ||
51 | |||
52 | fwrite(req, 1, count, file); | ||
53 | } | ||
54 | |||
55 | static void SaveLMBCallerEntry(FILE *file, GSM_Bitmap bitmap) | ||
56 | { | ||
57 | int count=12, textlen; | ||
58 | char req[500] = { | ||
59 | 'C','G','R',' ', /*block identifier*/ | ||
60 | 00,00, /*block data size*/ | ||
61 | 02,00, | ||
62 | 00, /*group number=0,1,etc.*/ | ||
63 | 00,00,00}; | ||
64 | |||
65 | req[count++] = bitmap.Location - 1; | ||
66 | if (bitmap.DefaultName) { | ||
67 | req[count++] = 0; | ||
68 | } else { | ||
69 | textlen = UnicodeLength(bitmap.Text); | ||
70 | req[count++] = textlen; | ||
71 | memcpy(req+count,DecodeUnicodeString(bitmap.Text),textlen); | ||
72 | count += textlen; | ||
73 | } | ||
74 | if (bitmap.DefaultRingtone) { | ||
75 | req[count++] = 0x16; | ||
76 | } else { | ||
77 | req[count++] = bitmap.RingtoneID; | ||
78 | } | ||
79 | if (bitmap.BitmapEnabled) req[count++] = 0x01; else req[count++] = 0x00; | ||
80 | req[count++] = (PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 4) >> 8; | ||
81 | req[count++] = (PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 4) % 0xff; | ||
82 | if (bitmap.DefaultBitmap) { | ||
83 | bitmap.BitmapWidth = 72; | ||
84 | bitmap.BitmapHeight = 14; | ||
85 | GSM_ClearBitmap(&bitmap); | ||
86 | } | ||
87 | NOKIA_CopyBitmap(GSM_NokiaCallerLogo, &bitmap, req, &count); | ||
88 | req[count++]=0; | ||
89 | |||
90 | req[4]=(count-12)%256; | ||
91 | req[5]=(count-12)/256; | ||
92 | req[8]=bitmap.Location; | ||
93 | |||
94 | fwrite(req, 1, count, file); | ||
95 | } | ||
96 | |||
97 | void SaveLMBPBKEntry(FILE *file, GSM_MemoryEntry *entry) | ||
98 | { | ||
99 | int count = 16, blocks; | ||
100 | char req[500] = { | ||
101 | 'P','B','E','2', /*block identifier*/ | ||
102 | 00,00, /*block data size*/ | ||
103 | 00,00, | ||
104 | 00,00, /*position of phonebook entry*/ | ||
105 | 03, /*memory type. ME=02;SM=03*/ | ||
106 | 00, | ||
107 | 00,00, /*position of phonebook entry*/ | ||
108 | 03, /*memory type. ME=02;SM=03*/ | ||
109 | 00}; | ||
110 | |||
111 | count=count+N71_65_EncodePhonebookFrame(NULL, req+16, *entry, &blocks, true, true); | ||
112 | |||
113 | req[4]=(count-12)%256; | ||
114 | req[5]=(count-12)/256; | ||
115 | req[8]=req[12] = entry->Location & 0xff; | ||
116 | req[9]=req[13] = (entry->Location >> 8); | ||
117 | if (entry->MemoryType==MEM_ME) req[10]=req[14]=2; | ||
118 | |||
119 | fwrite(req, 1, count, file); | ||
120 | } | ||
121 | |||
122 | GSM_Error SaveLMB(char *FileName, GSM_Backup *backup) | ||
123 | { | ||
124 | FILE *file; | ||
125 | int i; | ||
126 | char LMBHeader[] = {'L','M','B',' '}; /*file identifier*/ | ||
127 | char PBKHeader[] = { /*Phonebook header block */ | ||
128 | 'P','B','K',' ', /*block identifier*/ | ||
129 | 0x08,00, /*block data size*/ | ||
130 | 0x02,00, | ||
131 | 03, /*memory type. ME=02;SM=03*/ | ||
132 | 00,00,00, | ||
133 | 00,00, /*size of phonebook*/ | ||
134 | 14, /*max length of each position*/ | ||
135 | 00,00,00,00,00}; | ||
136 | |||
137 | |||
138 | file = fopen(FileName, "wb"); | ||
139 | if (file == NULL) return ERR_CANTOPENFILE; | ||
140 | |||
141 | /* Write the header of the file. */ | ||
142 | fwrite(LMBHeader, 1, sizeof(LMBHeader), file); | ||
143 | |||
144 | if (backup->PhonePhonebook[0]!=NULL) { | ||
145 | PBKHeader[8] = 2; /* memory type=MEM_ME */ | ||
146 | PBKHeader[12] = (unsigned char)(500 % 256); | ||
147 | PBKHeader[13] = 500 / 256; | ||
148 | fwrite(PBKHeader, 1, sizeof(PBKHeader), file); | ||
149 | i=0; | ||
150 | while (backup->PhonePhonebook[i]!=NULL) { | ||
151 | SaveLMBPBKEntry(file, backup->PhonePhonebook[i]); | ||
152 | i++; | ||
153 | } | ||
154 | } | ||
155 | if (backup->SIMPhonebook[0]!=NULL) { | ||
156 | PBKHeader[8] = 3; /* memory type=MEM_SM */ | ||
157 | PBKHeader[12] = (unsigned char)(250 % 256); | ||
158 | PBKHeader[13] = 250 / 256; | ||
159 | PBKHeader[14] = 0x16; /* max size of one entry */ | ||
160 | fwrite(PBKHeader, 1, sizeof(PBKHeader), file); | ||
161 | i=0; | ||
162 | while (backup->SIMPhonebook[i]!=NULL) { | ||
163 | SaveLMBPBKEntry(file, backup->SIMPhonebook[i]); | ||
164 | i++; | ||
165 | } | ||
166 | } | ||
167 | i=0; | ||
168 | while (backup->CallerLogos[i]!=NULL) { | ||
169 | SaveLMBCallerEntry(file, *backup->CallerLogos[i]); | ||
170 | i++; | ||
171 | } | ||
172 | if (backup->StartupLogo!=NULL) { | ||
173 | SaveLMBStartupEntry(file, *backup->StartupLogo); | ||
174 | } | ||
175 | |||
176 | fclose(file); | ||
177 | return ERR_NONE; | ||
178 | } | ||
179 | |||
180 | static GSM_Error LoadLMBCallerEntry(unsigned char *buffer, unsigned char *buffer2, GSM_Backup *backup) | ||
181 | { | ||
182 | GSM_Bitmap bitmap; | ||
183 | int num; | ||
184 | |||
185 | #ifdef DEBUG | ||
186 | dbgprintf("Number %i, name \"", buffer2[0]+1); | ||
187 | for (num=0;num<buffer2[1];num++) dbgprintf("%c", buffer2[num+2]); | ||
188 | dbgprintf("\"\n"); | ||
189 | dbgprintf("Ringtone ID=%i\n", buffer2[num+2]); | ||
190 | if (buffer2[num+3]==1) { | ||
191 | dbgprintf("Logo enabled\n"); | ||
192 | } else { | ||
193 | dbgprintf("Logo disabled\n"); | ||
194 | } | ||
195 | #endif | ||
196 | |||
197 | bitmap.Location = buffer2[0] + 1; | ||
198 | bitmap.Type = GSM_CallerGroupLogo; | ||
199 | bitmap.DefaultRingtone = false; | ||
200 | bitmap.RingtoneID = buffer2[buffer2[1]+2]; | ||
201 | |||
202 | EncodeUnicode(bitmap.Text,buffer2+2,buffer2[1]); | ||
203 | if (bitmap.Text[0] == 0x00 && bitmap.Text[1] == 0x00) { | ||
204 | bitmap.DefaultName = true; | ||
205 | } else { | ||
206 | bitmap.DefaultName = false; | ||
207 | } | ||
208 | |||
209 | bitmap.BitmapEnabled = false; | ||
210 | if (buffer2[buffer2[1]+3]==1) bitmap.BitmapEnabled=true; | ||
211 | |||
212 | bitmap.DefaultBitmap = false; | ||
213 | PHONE_DecodeBitmap(GSM_NokiaCallerLogo, buffer2+(buffer2[1]+10), &bitmap); | ||
214 | |||
215 | #ifdef DEBUG | ||
216 | dbgprintf("Caller logo\n"); | ||
217 | if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) GSM_PrintBitmap(di.df,&bitmap); | ||
218 | #endif | ||
219 | |||
220 | num = 0; | ||
221 | while (backup->CallerLogos[num] != NULL) num++; | ||
222 | if (num < GSM_BACKUP_MAX_CALLER) { | ||
223 | backup->CallerLogos[num] = malloc(sizeof(GSM_Bitmap)); | ||
224 | if (backup->CallerLogos[num] == NULL) return ERR_MOREMEMORY; | ||
225 | backup->CallerLogos[num + 1] = NULL; | ||
226 | } else { | ||
227 | dbgprintf("Increase GSM_BACKUP_MAX_CALLER\n"); | ||
228 | return ERR_MOREMEMORY; | ||
229 | } | ||
230 | *backup->CallerLogos[num] = bitmap; | ||
231 | |||
232 | return ERR_NONE; | ||
233 | } | ||
234 | |||
235 | static GSM_Error LoadLMBStartupEntry(unsigned char *buffer, unsigned char *buffer2, GSM_Backup *backup) | ||
236 | { | ||
237 | int i,j; | ||
238 | #ifdef DEBUG | ||
239 | int z; | ||
240 | #endif | ||
241 | GSM_Phone_Bitmap_Types Type; | ||
242 | |||
243 | j=1; | ||
244 | for (i=0;i<buffer2[0];i++) { | ||
245 | switch (buffer2[j++]) { | ||
246 | case 1: | ||
247 | dbgprintf("Block 1 - startup logo\n"); | ||
248 | backup->StartupLogo = malloc(sizeof(GSM_Bitmap)); | ||
249 | if (backup->StartupLogo == NULL) return ERR_MOREMEMORY; | ||
250 | backup->StartupLogo->Location= 1; | ||
251 | backup->StartupLogo->BitmapHeight= buffer2[j++]; | ||
252 | backup->StartupLogo->BitmapWidth= buffer2[j++]; | ||
253 | Type = GSM_NokiaStartupLogo; | ||
254 | switch (backup->StartupLogo->BitmapHeight) { | ||
255 | case 65: Type = GSM_Nokia7110StartupLogo; break; | ||
256 | case 60: Type = GSM_Nokia6210StartupLogo; break; | ||
257 | } | ||
258 | PHONE_DecodeBitmap(Type, buffer2+j, backup->StartupLogo); | ||
259 | #ifdef DEBUG | ||
260 | if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) GSM_PrintBitmap(di.df,backup->StartupLogo); | ||
261 | #endif | ||
262 | j = j + PHONE_GetBitmapSize(Type,0,0); | ||
263 | break; | ||
264 | case 2: | ||
265 | #ifdef DEBUG | ||
266 | dbgprintf("Block 2 - welcome note \""); | ||
267 | for (z=0;z<buffer2[j];z++) dbgprintf("%c",buffer2[j+z+1]); | ||
268 | dbgprintf("\"\n"); | ||
269 | #endif | ||
270 | if (backup->StartupLogo == NULL) { | ||
271 | backup->StartupLogo = malloc(sizeof(GSM_Bitmap)); | ||
272 | if (backup->StartupLogo == NULL) return ERR_MOREMEMORY; | ||
273 | backup->StartupLogo->Type = GSM_WelcomeNote_Text; | ||
274 | EncodeUnicode(backup->StartupLogo->Text,buffer2+j,buffer2[j]); | ||
275 | } | ||
276 | j = j + buffer2[j]; | ||
277 | break; | ||
278 | default: | ||
279 | dbgprintf("Unknown block %02x\n",buffer2[j]); | ||
280 | break; | ||
281 | } | ||
282 | } | ||
283 | return ERR_NONE; | ||
284 | } | ||
285 | |||
286 | static GSM_Error LoadLMBPbkEntry(unsigned char *buffer, unsigned char *buffer2, GSM_Backup *backup) | ||
287 | { | ||
288 | GSM_MemoryEntry pbk; | ||
289 | int num; | ||
290 | |||
291 | #ifdef DEBUG | ||
292 | dbgprintf("Memory : "); | ||
293 | switch(buffer[10]) { | ||
294 | case 2 : dbgprintf("(internal)\n"); break; | ||
295 | case 3 : dbgprintf("(sim)\n"); break; | ||
296 | default: dbgprintf("(unknown)\n"); break; | ||
297 | } | ||
298 | dbgprintf("Location : %i\n",buffer2[0]+buffer2[1]*256); | ||
299 | #endif | ||
300 | |||
301 | N71_65_DecodePhonebook(NULL, &pbk, NULL,NULL,buffer2+4,(buffer[4]+buffer[5]*256)-4,false); | ||
302 | |||
303 | pbk.MemoryType=MEM_SM; | ||
304 | if (buffer[10]==2) pbk.MemoryType=MEM_ME; | ||
305 | |||
306 | pbk.Location=buffer2[0]+256*buffer2[1]; | ||
307 | |||
308 | num = 0; | ||
309 | if (buffer[10]==2) { | ||
310 | while (backup->PhonePhonebook[num] != NULL) num++; | ||
311 | if (num < GSM_BACKUP_MAX_PHONEPHONEBOOK) { | ||
312 | backup->PhonePhonebook[num] = malloc(sizeof(GSM_MemoryEntry)); | ||
313 | if (backup->PhonePhonebook[num] == NULL) return ERR_MOREMEMORY; | ||
314 | backup->PhonePhonebook[num + 1] = NULL; | ||
315 | } else { | ||
316 | dbgprintf("Increase GSM_BACKUP_MAX_PHONEPHONEBOOK\n"); | ||
317 | return ERR_MOREMEMORY; | ||
318 | } | ||
319 | *backup->PhonePhonebook[num] = pbk; | ||
320 | } else { | ||
321 | while (backup->SIMPhonebook[num] != NULL) num++; | ||
322 | if (num < GSM_BACKUP_MAX_SIMPHONEBOOK) { | ||
323 | backup->SIMPhonebook[num] = malloc(sizeof(GSM_MemoryEntry)); | ||
324 | if (backup->SIMPhonebook[num] == NULL) return ERR_MOREMEMORY; | ||
325 | backup->SIMPhonebook[num + 1] = NULL; | ||
326 | } else { | ||
327 | dbgprintf("Increase GSM_BACKUP_MAX_SIMPHONEBOOK\n"); | ||
328 | return ERR_MOREMEMORY; | ||
329 | } | ||
330 | *backup->SIMPhonebook[num] = pbk; | ||
331 | } | ||
332 | return ERR_NONE; | ||
333 | } | ||
334 | |||
335 | GSM_Error LoadLMB(char *FileName, GSM_Backup *backup) | ||
336 | { | ||
337 | #ifdef DEBUG | ||
338 | int i; | ||
339 | #endif | ||
340 | unsigned char buffer[12], buffer2[1000]; | ||
341 | FILE *file; | ||
342 | GSM_Errorerror; | ||
343 | |||
344 | file = fopen(FileName, "rb"); | ||
345 | if (file == NULL) return(ERR_CANTOPENFILE); | ||
346 | |||
347 | /* Read the header of the file. */ | ||
348 | fread(buffer, 1, 4, file); | ||
349 | |||
350 | /* while we have something to read */ | ||
351 | while (fread(buffer, 1, 12, file)==12) { | ||
352 | #ifdef DEBUG | ||
353 | /* Info about block in the file */ | ||
354 | dbgprintf("Block \""); | ||
355 | for (i=0;i<4;i++) {dbgprintf("%c",buffer[i]);} | ||
356 | dbgprintf("\" ("); | ||
357 | if (memcmp(buffer, "PBK ",4)==0) { dbgprintf("Phonebook"); | ||
358 | } else if (memcmp(buffer, "PBE2",4)==0) { dbgprintf("Phonebook entry"); | ||
359 | } else if (memcmp(buffer, "CGR ",4)==0) { dbgprintf("Caller group"); | ||
360 | } else if (memcmp(buffer, "SPD ",4)==0) { dbgprintf("Speed dial"); | ||
361 | } else if (memcmp(buffer, "OLG ",4)==0) { dbgprintf("Operator logo"); | ||
362 | } else if (memcmp(buffer, "WEL ",4)==0) { dbgprintf("Startup logo and welcome text"); | ||
363 | } else { dbgprintf("unknown - ignored"); | ||
364 | } | ||
365 | dbgprintf(") - length %i\n", buffer[4]+buffer[5]*256); | ||
366 | #endif | ||
367 | /* reading block data */ | ||
368 | fread(buffer2, 1, buffer[4]+buffer[5]*256, file); | ||
369 | |||
370 | #ifdef DEBUG | ||
371 | if (memcmp(buffer, "PBK ",4)==0) { | ||
372 | dbgprintf("Size of phonebook %i, type %i ",(buffer2[0]+buffer2[1]*256),buffer[8]); | ||
373 | switch(buffer[8]) { | ||
374 | case 2 : dbgprintf("(internal)");break; | ||
375 | case 3 : dbgprintf("(sim)") ;break; | ||
376 | default: dbgprintf("(unknown)") ;break; | ||
377 | } | ||
378 | dbgprintf(", length of each position - %i\n",buffer2[2]); | ||
379 | } | ||
380 | #endif | ||
381 | if (memcmp(buffer, "PBE2",4)==0) { | ||
382 | error = LoadLMBPbkEntry(buffer,buffer2,backup); | ||
383 | if (error != ERR_NONE) { | ||
384 | fclose(file); | ||
385 | return error; | ||
386 | } | ||
387 | } | ||
388 | if (memcmp(buffer, "CGR ",4)==0) { | ||
389 | error = LoadLMBCallerEntry(buffer, buffer2, backup); | ||
390 | if (error != ERR_NONE) { | ||
391 | fclose(file); | ||
392 | return error; | ||
393 | } | ||
394 | } | ||
395 | if (memcmp(buffer, "WEL ",4)==0) { | ||
396 | error = LoadLMBStartupEntry(buffer, buffer2, backup); | ||
397 | if (error != ERR_NONE) { | ||
398 | fclose(file); | ||
399 | return error; | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | |||
404 | fclose(file); | ||
405 | |||
406 | return ERR_NONE; | ||
407 | } | ||
408 | |||
409 | #endif | ||
410 | |||
411 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
412 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
413 | */ | ||
diff --git a/gammu/emb/common/service/backup/backlmb.h b/gammu/emb/common/service/backup/backlmb.h new file mode 100644 index 0000000..18bba66 --- a/dev/null +++ b/gammu/emb/common/service/backup/backlmb.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_backlmb_h | ||
4 | #define __gsm_backlmb_h | ||
5 | |||
6 | #include "backgen.h" | ||
7 | |||
8 | #ifdef GSM_ENABLE_BACKUP | ||
9 | GSM_Error SaveLMB(char *FileName, GSM_Backup *backup); | ||
10 | GSM_Error LoadLMB(char *FileName, GSM_Backup *backup); | ||
11 | #endif | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
16 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
17 | */ | ||
diff --git a/gammu/emb/common/service/backup/backtext.c b/gammu/emb/common/service/backup/backtext.c new file mode 100644 index 0000000..fee0f73 --- a/dev/null +++ b/gammu/emb/common/service/backup/backtext.c | |||
@@ -0,0 +1,2908 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek, Walek and Michal Cihar */ | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <ctype.h> | ||
5 | |||
6 | #include "../../phone/nokia/nfunc.h" | ||
7 | #include "../../phone/nokia/dct3/n7110.h" | ||
8 | #include "../../misc/cfg.h" | ||
9 | #include "../../misc/coding/coding.h" | ||
10 | #include "../../misc/coding/md5.h" | ||
11 | #include "../gsmlogo.h" | ||
12 | #include "../gsmmisc.h" | ||
13 | #include "backtext.h" | ||
14 | |||
15 | #ifdef GSM_ENABLE_BACKUP | ||
16 | |||
17 | GSM_Error FindBackupChecksum(char *FileName, bool UseUnicode, char *checksum) | ||
18 | { | ||
19 | INI_Section *file_info, *h; | ||
20 | INI_Entry *e; | ||
21 | char *buffer = NULL,buff[100]; | ||
22 | int len=0; | ||
23 | |||
24 | //int i; | ||
25 | |||
26 | file_info = INI_ReadFile(FileName, UseUnicode); | ||
27 | |||
28 | if (UseUnicode) { | ||
29 | for (h = file_info; h != NULL; h = h->Next) { | ||
30 | EncodeUnicode(buff,"Checksum",8); | ||
31 | if (mywstrncasecmp(buff, h->SectionName, 8)) continue; | ||
32 | |||
33 | buffer = (unsigned char *)realloc(buffer,len+UnicodeLength(h->SectionName)*2+2); | ||
34 | CopyUnicodeString(buffer+len,h->SectionName); | ||
35 | len+=UnicodeLength(h->SectionName)*2; | ||
36 | // dbgprintf("[%s]\n",DecodeUnicodeConsole(h->SectionName)); | ||
37 | |||
38 | for (e = h->SubEntries; e != NULL; e = e->Next) { | ||
39 | buffer = (unsigned char *)realloc(buffer,len+UnicodeLength(e->EntryName)*2+2); | ||
40 | CopyUnicodeString(buffer+len,e->EntryName); | ||
41 | len+=UnicodeLength(e->EntryName)*2; | ||
42 | buffer = (unsigned char *)realloc(buffer,len+UnicodeLength(e->EntryValue)*2+2); | ||
43 | CopyUnicodeString(buffer+len,e->EntryValue); | ||
44 | len+=UnicodeLength(e->EntryValue)*2; | ||
45 | // dbgprintf("\"%s\"",DecodeUnicodeConsole(e->EntryName)); | ||
46 | // dbgprintf("=\"%s\"\n",DecodeUnicodeConsole(e->EntryValue)); | ||
47 | } | ||
48 | } | ||
49 | } else { | ||
50 | for (h = file_info; h != NULL; h = h->Next) { | ||
51 | if (mystrncasecmp("Checksum", h->SectionName, 8)) continue; | ||
52 | |||
53 | buffer = (unsigned char *)realloc(buffer,len+strlen(h->SectionName)+1); | ||
54 | strcpy(buffer+len,h->SectionName); | ||
55 | len+=strlen(h->SectionName); | ||
56 | |||
57 | for (e = h->SubEntries; e != NULL; e = e->Next) { | ||
58 | // dbgprintf("%s=%s\n",e->EntryName,e->EntryValue); | ||
59 | buffer = (unsigned char *)realloc(buffer,len+strlen(e->EntryName)+1); | ||
60 | strcpy(buffer+len,e->EntryName); | ||
61 | len+=strlen(e->EntryName); | ||
62 | buffer = (unsigned char *)realloc(buffer,len+strlen(e->EntryValue)+1); | ||
63 | strcpy(buffer+len,e->EntryValue); | ||
64 | len+=strlen(e->EntryValue); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | //for (i=0;i<len;i++) printf("%02x",buffer[i]); | ||
70 | CalculateMD5(buffer, len, checksum); | ||
71 | free(buffer); | ||
72 | |||
73 | return ERR_NONE; | ||
74 | } | ||
75 | |||
76 | static unsigned char *ReadCFGText(INI_Section *cfg, unsigned char *section, unsigned char *key, bool Unicode) | ||
77 | { | ||
78 | unsigned char Buffer[500],Buffer2[500],*retval; | ||
79 | |||
80 | if (Unicode) { | ||
81 | EncodeUnicode(Buffer2,key,strlen(key)); | ||
82 | retval = INI_GetValue(cfg,section,Buffer2,Unicode); | ||
83 | if (retval != NULL) return DecodeUnicodeString(retval); | ||
84 | return NULL; | ||
85 | } else { | ||
86 | strcpy(Buffer,section); | ||
87 | strcpy(Buffer2,key); | ||
88 | return INI_GetValue(cfg,section,key,Unicode); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | static void SaveLinkedBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode) | ||
93 | { | ||
94 | int w,current; | ||
95 | unsigned char buffer2[1000],buffer3[1000]; | ||
96 | |||
97 | current = strlen(myvalue); w = 0; | ||
98 | while (true) { | ||
99 | if (current > 200) { | ||
100 | memcpy(buffer2,myvalue+(strlen(myvalue)-current),200); | ||
101 | buffer2[200] = 0; | ||
102 | current = current - 200; | ||
103 | } else { | ||
104 | memcpy(buffer2,myvalue+(strlen(myvalue)-current),current); | ||
105 | buffer2[current] = 0; | ||
106 | current = 0; | ||
107 | } | ||
108 | if (UseUnicode) { | ||
109 | sprintf(buffer3,"%s%02i = %s%c%c",myname,w,buffer2,13,10); | ||
110 | EncodeUnicode(buffer2,buffer3,strlen(buffer3)); | ||
111 | fwrite(buffer2,1,strlen(buffer3)*2,file); | ||
112 | } else { | ||
113 | fprintf(file,"%s%02i = %s%c%c",myname,w,buffer2,13,10); | ||
114 | } | ||
115 | if (current == 0) break; | ||
116 | w++; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | static void ReadLinkedBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) | ||
121 | { | ||
122 | unsigned char buffer2[300]; | ||
123 | char *readvalue; | ||
124 | int i; | ||
125 | |||
126 | i=0; | ||
127 | myvalue[0] = 0; | ||
128 | while (true) { | ||
129 | sprintf(buffer2,"%s%02i",myname,i); | ||
130 | readvalue = ReadCFGText(file_info, section, buffer2, UseUnicode); | ||
131 | if (readvalue!=NULL) { | ||
132 | myvalue[strlen(myvalue)+strlen(readvalue)]=0; | ||
133 | memcpy(myvalue+strlen(myvalue),readvalue,strlen(readvalue)); | ||
134 | } else break; | ||
135 | i++; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode) | ||
140 | { | ||
141 | unsigned char buffer[10000], buffer2[10000]; | ||
142 | |||
143 | if (myname[0] == 0x00) { | ||
144 | if (UseUnicode) { | ||
145 | EncodeUnicode(buffer,myvalue,strlen(myvalue)); | ||
146 | fwrite(buffer,1,strlen(myvalue)*2,file); | ||
147 | } else fprintf(file,"%s",myvalue); | ||
148 | } else { | ||
149 | if (UseUnicode) { | ||
150 | sprintf(buffer,"%s = \"",myname); | ||
151 | EncodeUnicode(buffer2,buffer,strlen(buffer)); | ||
152 | fwrite(buffer2,1,strlen(buffer)*2,file); | ||
153 | |||
154 | fwrite(myvalue,1,UnicodeLength(myvalue)*2,file); | ||
155 | |||
156 | sprintf(buffer,"\"%c%c",13,10); | ||
157 | EncodeUnicode(buffer2,buffer,strlen(buffer)); | ||
158 | fwrite(buffer2,1,strlen(buffer)*2,file); | ||
159 | } else { | ||
160 | sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10); | ||
161 | fprintf(file,"%s",buffer); | ||
162 | |||
163 | EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2); | ||
164 | fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10); | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | |||
169 | static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) | ||
170 | { | ||
171 | unsigned char paramname[10000],*readvalue; | ||
172 | |||
173 | if (UseUnicode) { | ||
174 | EncodeUnicode(paramname,myname,strlen(myname)); | ||
175 | readvalue = INI_GetValue(file_info, section, paramname, UseUnicode); | ||
176 | if (readvalue!=NULL) { | ||
177 | CopyUnicodeString(myvalue,readvalue+2); | ||
178 | myvalue[UnicodeLength(readvalue)*2-4]=0; | ||
179 | myvalue[UnicodeLength(readvalue)*2-3]=0; | ||
180 | dbgprintf("%s\n",DecodeUnicodeString(readvalue)); | ||
181 | } else { | ||
182 | myvalue[0]=0; | ||
183 | myvalue[1]=0; | ||
184 | return false; | ||
185 | } | ||
186 | } else { | ||
187 | strcpy(paramname,myname); | ||
188 | strcat(paramname,"Unicode"); | ||
189 | readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); | ||
190 | if (readvalue!=NULL) { | ||
191 | dbgprintf("%s %i\n",readvalue,strlen(readvalue)); | ||
192 | DecodeHexBin (myvalue, readvalue, strlen(readvalue)); | ||
193 | myvalue[strlen(readvalue)/2]=0; | ||
194 | myvalue[strlen(readvalue)/2+1]=0; | ||
195 | dbgprintf("%s\n",DecodeUnicodeString(myvalue)); | ||
196 | } else { | ||
197 | strcpy(paramname,myname); | ||
198 | readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); | ||
199 | if (readvalue!=NULL) { | ||
200 | EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2); | ||
201 | } else { | ||
202 | myvalue[0]=0; | ||
203 | myvalue[1]=0; | ||
204 | return false; | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | return true; | ||
209 | } | ||
210 | |||
211 | static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode) | ||
212 | { | ||
213 | unsigned char buffer[100]; | ||
214 | int Length = 3; | ||
215 | |||
216 | sprintf(buffer, " = "); | ||
217 | SaveVCALDateTime(buffer, &Length, dt, NULL); | ||
218 | SaveBackupText(file, "", buffer, UseUnicode); | ||
219 | } | ||
220 | |||
221 | static void SaveVCalDate(FILE *file, GSM_DateTime *dt, bool UseUnicode) | ||
222 | { | ||
223 | unsigned char buffer[100]; | ||
224 | |||
225 | sprintf(buffer, " = %04d%02d%02d%c%c", dt->Year, dt->Month, dt->Day,13,10); | ||
226 | SaveBackupText(file, "", buffer, UseUnicode); | ||
227 | } | ||
228 | |||
229 | /* ---------------------- backup files ------------------------------------- */ | ||
230 | |||
231 | static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode) | ||
232 | { | ||
233 | booltext; | ||
234 | charbuffer[1000]; | ||
235 | intj, i; | ||
236 | |||
237 | sprintf(buffer,"Location = %03i%c%c",Pbk->Location,13,10); | ||
238 | SaveBackupText(file, "", buffer, UseUnicode); | ||
239 | for (j=0;j<Pbk->EntriesNum;j++) { | ||
240 | text = true; | ||
241 | switch (Pbk->Entries[j].EntryType) { | ||
242 | case PBK_Number_General: | ||
243 | sprintf(buffer,"Entry%02iType = NumberGeneral%c%c",j,13,10); | ||
244 | SaveBackupText(file, "", buffer, UseUnicode); | ||
245 | break; | ||
246 | case PBK_Number_Mobile: | ||
247 | sprintf(buffer,"Entry%02iType = NumberMobile%c%c",j,13,10); | ||
248 | SaveBackupText(file, "", buffer, UseUnicode); | ||
249 | break; | ||
250 | case PBK_Number_Work: | ||
251 | sprintf(buffer,"Entry%02iType = NumberWork%c%c",j,13,10); | ||
252 | SaveBackupText(file, "", buffer, UseUnicode); | ||
253 | break; | ||
254 | case PBK_Number_Fax: | ||
255 | sprintf(buffer,"Entry%02iType = NumberFax%c%c",j,13,10); | ||
256 | SaveBackupText(file, "", buffer, UseUnicode); | ||
257 | break; | ||
258 | case PBK_Number_Home: | ||
259 | sprintf(buffer,"Entry%02iType = NumberHome%c%c",j,13,10); | ||
260 | SaveBackupText(file, "", buffer, UseUnicode); | ||
261 | break; | ||
262 | case PBK_Number_Pager: | ||
263 | sprintf(buffer,"Entry%02iType = NumberPager%c%c",j,13,10); | ||
264 | SaveBackupText(file, "", buffer, UseUnicode); | ||
265 | break; | ||
266 | case PBK_Number_Other: | ||
267 | sprintf(buffer,"Entry%02iType = NumberOther%c%c",j,13,10); | ||
268 | SaveBackupText(file, "", buffer, UseUnicode); | ||
269 | break; | ||
270 | case PBK_Text_Note: | ||
271 | sprintf(buffer,"Entry%02iType = Note%c%c",j,13,10); | ||
272 | SaveBackupText(file, "", buffer, UseUnicode); | ||
273 | break; | ||
274 | case PBK_Text_Postal: | ||
275 | sprintf(buffer,"Entry%02iType = Postal%c%c",j,13,10); | ||
276 | SaveBackupText(file, "", buffer, UseUnicode); | ||
277 | break; | ||
278 | case PBK_Text_Email: | ||
279 | sprintf(buffer,"Entry%02iType = Email%c%c",j,13,10); | ||
280 | SaveBackupText(file, "", buffer, UseUnicode); | ||
281 | break; | ||
282 | case PBK_Text_Email2: | ||
283 | sprintf(buffer,"Entry%02iType = Email2%c%c",j,13,10); | ||
284 | SaveBackupText(file, "", buffer, UseUnicode); | ||
285 | break; | ||
286 | case PBK_Text_URL: | ||
287 | sprintf(buffer,"Entry%02iType = URL%c%c",j,13,10); | ||
288 | SaveBackupText(file, "", buffer, UseUnicode); | ||
289 | break; | ||
290 | case PBK_Text_Name: | ||
291 | sprintf(buffer,"Entry%02iType = Name%c%c",j,13,10); | ||
292 | SaveBackupText(file, "", buffer, UseUnicode); | ||
293 | break; | ||
294 | case PBK_Caller_Group: | ||
295 | sprintf(buffer,"Entry%02iType = CallerGroup%c%c",j,13,10); | ||
296 | SaveBackupText(file, "", buffer, UseUnicode); | ||
297 | sprintf(buffer,"Entry%02iNumber = %i%c%c",j,Pbk->Entries[j].Number,13,10); | ||
298 | SaveBackupText(file, "", buffer, UseUnicode); | ||
299 | text = false; | ||
300 | break; | ||
301 | case PBK_RingtoneID: | ||
302 | sprintf(buffer,"Entry%02iType = RingtoneID%c%c",j,13,10); | ||
303 | SaveBackupText(file, "", buffer, UseUnicode); | ||
304 | sprintf(buffer,"Entry%02iNumber = %i%c%c",j,Pbk->Entries[j].Number,13,10); | ||
305 | SaveBackupText(file, "", buffer, UseUnicode); | ||
306 | text = false; | ||
307 | break; | ||
308 | case PBK_PictureID: | ||
309 | sprintf(buffer,"Entry%02iType = PictureID%c%c",j,13,10); | ||
310 | SaveBackupText(file, "", buffer, UseUnicode); | ||
311 | sprintf(buffer,"Entry%02iNumber = %i%c%c",j,Pbk->Entries[j].Number,13,10); | ||
312 | SaveBackupText(file, "", buffer, UseUnicode); | ||
313 | text = false; | ||
314 | break; | ||
315 | case PBK_Text_UserID: | ||
316 | sprintf(buffer,"Entry%02iType = UserID%c%c",j,13,10); | ||
317 | SaveBackupText(file, "", buffer, UseUnicode); | ||
318 | break; | ||
319 | case PBK_Category: | ||
320 | sprintf(buffer,"Entry%02iType = Category%c%c",j,13,10); | ||
321 | SaveBackupText(file, "", buffer, UseUnicode); | ||
322 | sprintf(buffer,"Entry%02iNumber = %i%c%c",j,Pbk->Entries[j].Number,13,10); | ||
323 | SaveBackupText(file, "", buffer, UseUnicode); | ||
324 | text = false; | ||
325 | break; | ||
326 | case PBK_Private: | ||
327 | sprintf(buffer,"Entry%02iType = Private%c%c",j,13,10); | ||
328 | SaveBackupText(file, "", buffer, UseUnicode); | ||
329 | sprintf(buffer,"Entry%02iNumber = %i%c%c",j,Pbk->Entries[j].Number,13,10); | ||
330 | SaveBackupText(file, "", buffer, UseUnicode); | ||
331 | text = false; | ||
332 | break; | ||
333 | case PBK_Text_LastName: | ||
334 | sprintf(buffer,"Entry%02iType = LastName%c%c",j,13,10); | ||
335 | SaveBackupText(file, "", buffer, UseUnicode); | ||
336 | break; | ||
337 | case PBK_Text_FirstName: | ||
338 | sprintf(buffer,"Entry%02iType = FirstName%c%c",j,13,10); | ||
339 | SaveBackupText(file, "", buffer, UseUnicode); | ||
340 | break; | ||
341 | case PBK_Text_Company: | ||
342 | sprintf(buffer,"Entry%02iType = Company%c%c",j,13,10); | ||
343 | SaveBackupText(file, "", buffer, UseUnicode); | ||
344 | break; | ||
345 | case PBK_Text_JobTitle: | ||
346 | sprintf(buffer,"Entry%02iType = JobTitle%c%c",j,13,10); | ||
347 | SaveBackupText(file, "", buffer, UseUnicode); | ||
348 | break; | ||
349 | case PBK_Text_StreetAddress: | ||
350 | sprintf(buffer,"Entry%02iType = Address%c%c",j,13,10); | ||
351 | SaveBackupText(file, "", buffer, UseUnicode); | ||
352 | break; | ||
353 | case PBK_Text_City: | ||
354 | sprintf(buffer,"Entry%02iType = City%c%c",j,13,10); | ||
355 | SaveBackupText(file, "", buffer, UseUnicode); | ||
356 | break; | ||
357 | case PBK_Text_State: | ||
358 | sprintf(buffer,"Entry%02iType = State%c%c",j,13,10); | ||
359 | SaveBackupText(file, "", buffer, UseUnicode); | ||
360 | break; | ||
361 | case PBK_Text_Zip: | ||
362 | sprintf(buffer,"Entry%02iType = Zip%c%c",j,13,10); | ||
363 | SaveBackupText(file, "", buffer, UseUnicode); | ||
364 | break; | ||
365 | case PBK_Text_Country: | ||
366 | sprintf(buffer,"Entry%02iType = Country%c%c",j,13,10); | ||
367 | SaveBackupText(file, "", buffer, UseUnicode); | ||
368 | break; | ||
369 | case PBK_Text_Custom1: | ||
370 | sprintf(buffer,"Entry%02iType = Custom1%c%c",j,13,10); | ||
371 | SaveBackupText(file, "", buffer, UseUnicode); | ||
372 | break; | ||
373 | case PBK_Text_Custom2: | ||
374 | sprintf(buffer,"Entry%02iType = Custom2%c%c",j,13,10); | ||
375 | SaveBackupText(file, "", buffer, UseUnicode); | ||
376 | break; | ||
377 | case PBK_Text_Custom3: | ||
378 | sprintf(buffer,"Entry%02iType = Custom3%c%c",j,13,10); | ||
379 | SaveBackupText(file, "", buffer, UseUnicode); | ||
380 | break; | ||
381 | case PBK_Text_Custom4: | ||
382 | sprintf(buffer,"Entry%02iType = Custom4%c%c",j,13,10); | ||
383 | SaveBackupText(file, "", buffer, UseUnicode); | ||
384 | break; | ||
385 | case PBK_SMSListID: | ||
386 | case PBK_RingtoneFileSystemID: | ||
387 | case PBK_Date: | ||
388 | break; | ||
389 | } | ||
390 | if (text) { | ||
391 | sprintf(buffer,"Entry%02iText",j); | ||
392 | SaveBackupText(file,buffer,Pbk->Entries[j].Text, UseUnicode); | ||
393 | } | ||
394 | switch (Pbk->Entries[j].EntryType) { | ||
395 | case PBK_Number_General: | ||
396 | case PBK_Number_Mobile: | ||
397 | case PBK_Number_Work: | ||
398 | case PBK_Number_Fax: | ||
399 | case PBK_Number_Home: | ||
400 | case PBK_Number_Other: | ||
401 | case PBK_Number_Pager: | ||
402 | if (Pbk->Entries[j].VoiceTag!=0) { | ||
403 | sprintf(buffer,"Entry%02iVoiceTag = %i%c%c",j,Pbk->Entries[j].VoiceTag,13,10); | ||
404 | SaveBackupText(file, "", buffer, UseUnicode); | ||
405 | } | ||
406 | i = 0; | ||
407 | 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 | SaveBackupText(file, "", buffer, UseUnicode); | ||
410 | i++; | ||
411 | } | ||
412 | break; | ||
413 | default: | ||
414 | break; | ||
415 | } | ||
416 | } | ||
417 | sprintf(buffer,"%c%c",13,10); | ||
418 | SaveBackupText(file, "", buffer, UseUnicode); | ||
419 | } | ||
420 | |||
421 | static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode) | ||
422 | { | ||
423 | int i; | ||
424 | charbuffer[1000]; | ||
425 | |||
426 | sprintf(buffer,"Location = %d%c%c", Note->Location,13,10); | ||
427 | SaveBackupText(file, "", buffer, UseUnicode); | ||
428 | SaveBackupText(file, "", "Type = ", UseUnicode); | ||
429 | switch (Note->Type) { | ||
430 | 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; | ||
432 | 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; | ||
434 | 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; | ||
436 | 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; | ||
438 | 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; | ||
440 | 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; | ||
442 | 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; | ||
444 | 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; | ||
446 | 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; | ||
448 | 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; | ||
450 | 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; | ||
452 | 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; | ||
454 | 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; | ||
456 | 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; | ||
458 | } | ||
459 | SaveBackupText(file, "", buffer, UseUnicode); | ||
460 | for (i=0;i<Note->EntriesNum;i++) { | ||
461 | switch (Note->Entries[i].EntryType) { | ||
462 | case CAL_START_DATETIME: | ||
463 | SaveBackupText(file, "", "StartTime", UseUnicode); | ||
464 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | ||
465 | break; | ||
466 | case CAL_END_DATETIME: | ||
467 | SaveBackupText(file, "", "StopTime", UseUnicode); | ||
468 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | ||
469 | break; | ||
470 | case CAL_ALARM_DATETIME: | ||
471 | SaveBackupText(file, "", "Alarm", UseUnicode); | ||
472 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | ||
473 | sprintf(buffer,"AlarmType = Tone%c%c",13,10); | ||
474 | SaveBackupText(file, "", buffer, UseUnicode); | ||
475 | break; | ||
476 | case CAL_SILENT_ALARM_DATETIME: | ||
477 | SaveBackupText(file, "", "Alarm", UseUnicode); | ||
478 | SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode); | ||
479 | sprintf(buffer,"AlarmType = Silent%c%c",13,10); | ||
480 | SaveBackupText(file, "", buffer, UseUnicode); | ||
481 | break; | ||
482 | case CAL_PRIVATE: | ||
483 | sprintf(buffer, "Private = %d%c%c",Note->Entries[i].Number,13,10); | ||
484 | SaveBackupText(file, "", buffer, UseUnicode); | ||
485 | break; | ||
486 | case CAL_LOCATION: | ||
487 | SaveBackupText(file, "EventLocation", Note->Entries[i].Text, UseUnicode); | ||
488 | break; | ||
489 | case CAL_CONTACTID: | ||
490 | sprintf(buffer, "ContactID = %d%c%c",Note->Entries[i].Number,13,10); | ||
491 | SaveBackupText(file, "", buffer, UseUnicode); | ||
492 | break; | ||
493 | case CAL_RECURRANCE: | ||
494 | sprintf(buffer, "Recurrance = %d%c%c",Note->Entries[i].Number/24,13,10); | ||
495 | SaveBackupText(file, "", buffer, UseUnicode); | ||
496 | break; | ||
497 | case CAL_TEXT: | ||
498 | SaveBackupText(file, "Text", Note->Entries[i].Text, UseUnicode); | ||
499 | break; | ||
500 | case CAL_PHONE: | ||
501 | SaveBackupText(file, "Phone", Note->Entries[i].Text, UseUnicode); | ||
502 | break; | ||
503 | case CAL_REPEAT_STOPDATE: | ||
504 | SaveBackupText(file, "", "RepeatStopDate", UseUnicode); | ||
505 | SaveVCalDate(file, &Note->Entries[i].Date, UseUnicode); | ||
506 | break; | ||
507 | case CAL_REPEAT_STARTDATE: | ||
508 | SaveBackupText(file, "", "RepeatStartDate", UseUnicode); | ||
509 | SaveVCalDate(file, &Note->Entries[i].Date, UseUnicode); | ||
510 | break; | ||
511 | case CAL_REPEAT_DAYOFWEEK: | ||
512 | sprintf(buffer, "RepeatDayOfWeek = %d%c%c",Note->Entries[i].Number,13,10); | ||
513 | SaveBackupText(file, "", buffer, UseUnicode); | ||
514 | break; | ||
515 | case CAL_REPEAT_DAY: | ||
516 | sprintf(buffer, "RepeatDay = %d%c%c",Note->Entries[i].Number,13,10); | ||
517 | SaveBackupText(file, "", buffer, UseUnicode); | ||
518 | break; | ||
519 | case CAL_REPEAT_WEEKOFMONTH: | ||
520 | sprintf(buffer, "RepeatWeekOfMonth = %d%c%c",Note->Entries[i].Number,13,10); | ||
521 | SaveBackupText(file, "", buffer, UseUnicode); | ||
522 | break; | ||
523 | case CAL_REPEAT_MONTH: | ||
524 | sprintf(buffer, "RepeatMonth = %d%c%c",Note->Entries[i].Number,13,10); | ||
525 | SaveBackupText(file, "", buffer, UseUnicode); | ||
526 | break; | ||
527 | case CAL_REPEAT_FREQUENCY: | ||
528 | sprintf(buffer, "RepeatFrequency = %d%c%c",Note->Entries[i].Number,13,10); | ||
529 | SaveBackupText(file, "", buffer, UseUnicode); | ||
530 | break; | ||
531 | } | ||
532 | } | ||
533 | sprintf(buffer, "%c%c",13,10); | ||
534 | SaveBackupText(file, "", buffer, UseUnicode); | ||
535 | } | ||
536 | |||
537 | static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, bool UseUnicode) | ||
538 | { | ||
539 | int i; | ||
540 | char buffer[10000]; | ||
541 | |||
542 | if (settings->Active) { | ||
543 | sprintf(buffer,"Active = Yes%c%c",13,10); | ||
544 | SaveBackupText(file, "", buffer, UseUnicode); | ||
545 | } | ||
546 | switch (settings->ActiveBearer) { | ||
547 | case WAPSETTINGS_BEARER_SMS : sprintf(buffer,"Bearer = SMS%c%c",13,10); break; | ||
548 | case WAPSETTINGS_BEARER_GPRS: sprintf(buffer,"Bearer = GPRS%c%c",13,10); break; | ||
549 | case WAPSETTINGS_BEARER_DATA: sprintf(buffer,"Bearer = Data%c%c",13,10); break; | ||
550 | case WAPSETTINGS_BEARER_USSD: sprintf(buffer,"Bearer = USSD%c%c",13,10); | ||
551 | } | ||
552 | SaveBackupText(file, "", buffer, UseUnicode); | ||
553 | if (settings->ReadOnly) { | ||
554 | sprintf(buffer,"ReadOnly = Yes%c%c",13,10); | ||
555 | SaveBackupText(file, "", buffer, UseUnicode); | ||
556 | } | ||
557 | sprintf(buffer,"Proxy"); | ||
558 | SaveBackupText(file, buffer, settings->Proxy, UseUnicode); | ||
559 | sprintf(buffer,"ProxyPort = %i%c%c",settings->ProxyPort,13,10); | ||
560 | SaveBackupText(file, "", buffer, UseUnicode); | ||
561 | sprintf(buffer,"Proxy2"); | ||
562 | SaveBackupText(file, buffer, settings->Proxy2, UseUnicode); | ||
563 | sprintf(buffer,"Proxy2Port = %i%c%c",settings->Proxy2Port,13,10); | ||
564 | SaveBackupText(file, "", buffer, UseUnicode); | ||
565 | sprintf(buffer,"%c%c",13,10); | ||
566 | SaveBackupText(file, "", buffer, UseUnicode); | ||
567 | for (i=0;i<settings->Number;i++) { | ||
568 | sprintf(buffer,"Title%02i",i); | ||
569 | SaveBackupText(file, buffer, settings->Settings[i].Title, UseUnicode); | ||
570 | sprintf(buffer,"HomePage%02i",i); | ||
571 | SaveBackupText(file, buffer, settings->Settings[i].HomePage, UseUnicode); | ||
572 | if (settings->Settings[i].IsContinuous) { | ||
573 | sprintf(buffer,"Type%02i = Continuous%c%c",i,13,10); | ||
574 | } else { | ||
575 | sprintf(buffer,"Type%02i = Temporary%c%c",i,13,10); | ||
576 | } | ||
577 | SaveBackupText(file, "", buffer, UseUnicode); | ||
578 | if (settings->Settings[i].IsSecurity) { | ||
579 | sprintf(buffer,"Security%02i = On%c%c",i,13,10); | ||
580 | } else { | ||
581 | sprintf(buffer,"Security%02i = Off%c%c",i,13,10); | ||
582 | } | ||
583 | SaveBackupText(file, "", buffer, UseUnicode); | ||
584 | switch (settings->Settings[i].Bearer) { | ||
585 | case WAPSETTINGS_BEARER_SMS: | ||
586 | sprintf(buffer,"Bearer%02i = SMS%c%c",i,13,10); | ||
587 | SaveBackupText(file, "", buffer, UseUnicode); | ||
588 | sprintf(buffer,"Server%02i",i); | ||
589 | SaveBackupText(file, buffer, settings->Settings[i].Server, UseUnicode); | ||
590 | sprintf(buffer,"Service%02i",i); | ||
591 | SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode); | ||
592 | break; | ||
593 | case WAPSETTINGS_BEARER_GPRS: | ||
594 | sprintf(buffer,"Bearer%02i = GPRS%c%c",i,13,10); | ||
595 | SaveBackupText(file, "", buffer, UseUnicode); | ||
596 | sprintf(buffer,"IP%02i",i); | ||
597 | SaveBackupText(file, buffer, settings->Settings[i].IPAddress, UseUnicode); | ||
598 | case WAPSETTINGS_BEARER_DATA: | ||
599 | if (settings->Settings[i].Bearer == WAPSETTINGS_BEARER_DATA) { | ||
600 | sprintf(buffer,"Bearer%02i = Data%c%c",i,13,10); | ||
601 | SaveBackupText(file, "", buffer, UseUnicode); | ||
602 | if (settings->Settings[i].IsISDNCall) { | ||
603 | sprintf(buffer,"CallType%02i = ISDN%c%c",i,13,10); | ||
604 | } else { | ||
605 | sprintf(buffer,"CallType%02i = Analogue%c%c",i,13,10); | ||
606 | } | ||
607 | SaveBackupText(file, "", buffer, UseUnicode); | ||
608 | sprintf(buffer,"IP%02i",i); | ||
609 | SaveBackupText(file, buffer, settings->Settings[i].IPAddress, UseUnicode); | ||
610 | } | ||
611 | sprintf(buffer,"Number%02i",i); | ||
612 | SaveBackupText(file, buffer, settings->Settings[i].DialUp, UseUnicode); | ||
613 | if (settings->Settings[i].ManualLogin) { | ||
614 | sprintf(buffer,"Login%02i = Manual%c%c",i,13,10); | ||
615 | } else { | ||
616 | sprintf(buffer,"Login%02i = Automatic%c%c",i,13,10); | ||
617 | } | ||
618 | SaveBackupText(file, "", buffer, UseUnicode); | ||
619 | if (settings->Settings[i].IsNormalAuthentication) { | ||
620 | sprintf(buffer,"Authentication%02i = Normal%c%c",i,13,10); | ||
621 | } else { | ||
622 | sprintf(buffer,"Authentication%02i = Secure%c%c",i,13,10); | ||
623 | } | ||
624 | SaveBackupText(file, "", buffer, UseUnicode); | ||
625 | switch (settings->Settings[i].Speed) { | ||
626 | case WAPSETTINGS_SPEED_9600 : sprintf(buffer,"CallSpeed%02i = 9600%c%c" ,i,13,10); break; | ||
627 | case WAPSETTINGS_SPEED_14400: sprintf(buffer,"CallSpeed%02i = 14400%c%c",i,13,10); break; | ||
628 | case WAPSETTINGS_SPEED_AUTO : sprintf(buffer,"CallSpeed%02i = auto%c%c" ,i,13,10); break; | ||
629 | } | ||
630 | switch (settings->Settings[i].Speed) { | ||
631 | case WAPSETTINGS_SPEED_9600 : | ||
632 | case WAPSETTINGS_SPEED_14400: | ||
633 | case WAPSETTINGS_SPEED_AUTO : | ||
634 | SaveBackupText(file, "", buffer, UseUnicode); | ||
635 | default: | ||
636 | break; | ||
637 | } | ||
638 | sprintf(buffer,"User%02i",i); | ||
639 | SaveBackupText(file, buffer, settings->Settings[i].User, UseUnicode); | ||
640 | sprintf(buffer,"Password%02i",i); | ||
641 | SaveBackupText(file, buffer, settings->Settings[i].Password, UseUnicode); | ||
642 | break; | ||
643 | case WAPSETTINGS_BEARER_USSD: | ||
644 | sprintf(buffer,"Bearer%02i = USSD%c%c",i,13,10); | ||
645 | SaveBackupText(file, "", buffer, UseUnicode); | ||
646 | sprintf(buffer,"ServiceCode%02i",i); | ||
647 | SaveBackupText(file, buffer, settings->Settings[i].Code, UseUnicode); | ||
648 | if (settings->Settings[i].IsIP) { | ||
649 | sprintf(buffer,"IP%02i",i); | ||
650 | } else { | ||
651 | sprintf(buffer,"Number%02i",i); | ||
652 | } | ||
653 | SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode); | ||
654 | } | ||
655 | sprintf(buffer,"%c%c",13,10); | ||
656 | SaveBackupText(file, "", buffer, UseUnicode); | ||
657 | } | ||
658 | } | ||
659 | |||
660 | static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | ||
661 | { | ||
662 | unsigned char buffer[10000],buffer2[10000]; | ||
663 | int x,y; | ||
664 | |||
665 | sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10); | ||
666 | SaveBackupText(file, "", buffer, UseUnicode); | ||
667 | sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10); | ||
668 | SaveBackupText(file, "", buffer, UseUnicode); | ||
669 | for (y=0;y<bitmap->BitmapHeight;y++) { | ||
670 | for (x=0;x<bitmap->BitmapWidth;x++) { | ||
671 | buffer[x] = ' '; | ||
672 | if (GSM_IsPointBitmap(bitmap,x,y)) buffer[x]='#'; | ||
673 | } | ||
674 | buffer[bitmap->BitmapWidth] = 0; | ||
675 | sprintf(buffer2,"Bitmap%02i = \"%s\"%c%c",y,buffer,13,10); | ||
676 | SaveBackupText(file, "", buffer2, UseUnicode); | ||
677 | } | ||
678 | } | ||
679 | |||
680 | static void SaveCallerEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | ||
681 | { | ||
682 | unsigned char buffer[1000]; | ||
683 | |||
684 | sprintf(buffer,"Location = %03i%c%c",bitmap->Location,13,10); | ||
685 | SaveBackupText(file, "", buffer, UseUnicode); | ||
686 | if (!bitmap->DefaultName) SaveBackupText(file, "Name", bitmap->Text, UseUnicode); | ||
687 | if (!bitmap->DefaultRingtone) { | ||
688 | if (bitmap->FileSystemRingtone) { | ||
689 | sprintf(buffer,"FileRingtone = %02x%c%c",bitmap->RingtoneID,13,10); | ||
690 | } else { | ||
691 | sprintf(buffer,"Ringtone = %02x%c%c",bitmap->RingtoneID,13,10); | ||
692 | } | ||
693 | SaveBackupText(file, "", buffer, UseUnicode); | ||
694 | } | ||
695 | if (bitmap->BitmapEnabled) { | ||
696 | sprintf(buffer,"Enabled = True%c%c",13,10); | ||
697 | } else { | ||
698 | sprintf(buffer,"Enabled = False%c%c",13,10); | ||
699 | } | ||
700 | SaveBackupText(file, "", buffer, UseUnicode); | ||
701 | if (!bitmap->DefaultBitmap) SaveBitmapEntry(file, bitmap, UseUnicode); | ||
702 | sprintf(buffer,"%c%c",13,10); | ||
703 | SaveBackupText(file, "", buffer, UseUnicode); | ||
704 | } | ||
705 | |||
706 | static void SaveWAPBookmarkEntry(FILE *file, GSM_WAPBookmark *bookmark, bool UseUnicode) | ||
707 | { | ||
708 | unsigned char buffer[1000]; | ||
709 | |||
710 | SaveBackupText(file, "URL", bookmark->Address, UseUnicode); | ||
711 | SaveBackupText(file, "Title", bookmark->Title, UseUnicode); | ||
712 | sprintf(buffer,"%c%c",13,10); | ||
713 | SaveBackupText(file, "", buffer, UseUnicode); | ||
714 | } | ||
715 | |||
716 | static void SaveStartupEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | ||
717 | { | ||
718 | unsigned char buffer[1000]; | ||
719 | |||
720 | sprintf(buffer,"[Startup]%c%c",13,10); | ||
721 | SaveBackupText(file, "", buffer, UseUnicode); | ||
722 | if (bitmap->Type == GSM_WelcomeNote_Text) { | ||
723 | SaveBackupText(file, "Text", bitmap->Text, UseUnicode); | ||
724 | } | ||
725 | if (bitmap->Type == GSM_StartupLogo) { | ||
726 | SaveBitmapEntry(file, bitmap, UseUnicode); | ||
727 | } | ||
728 | sprintf(buffer,"%c%c",13,10); | ||
729 | SaveBackupText(file, "", buffer, UseUnicode); | ||
730 | } | ||
731 | |||
732 | static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode) | ||
733 | { | ||
734 | unsigned char buffer[1000]; | ||
735 | |||
736 | sprintf(buffer,"Location = %03i%c%c",SMSC->Location,13,10); | ||
737 | SaveBackupText(file, "", buffer, UseUnicode); | ||
738 | SaveBackupText(file, "Name", SMSC->Name, UseUnicode); | ||
739 | SaveBackupText(file, "Number", SMSC->Number, UseUnicode); | ||
740 | SaveBackupText(file, "DefaultNumber", SMSC->DefaultNumber, UseUnicode); | ||
741 | SaveBackupText(file, "", "Format = ", UseUnicode); | ||
742 | switch (SMSC->Format) { | ||
743 | case SMS_FORMAT_Text: sprintf(buffer,"Text"); break; | ||
744 | case SMS_FORMAT_Fax: sprintf(buffer,"Fax"); break; | ||
745 | case SMS_FORMAT_Email: sprintf(buffer,"Email"); break; | ||
746 | case SMS_FORMAT_Pager: sprintf(buffer,"Pager"); break; | ||
747 | } | ||
748 | SaveBackupText(file, "", buffer, UseUnicode); | ||
749 | sprintf(buffer,"%c%cValidity = ",13,10); | ||
750 | SaveBackupText(file, "", buffer, UseUnicode); | ||
751 | switch (SMSC->Validity.Relative) { | ||
752 | case SMS_VALID_1_Hour : sprintf(buffer, "1hour"); break; | ||
753 | case SMS_VALID_6_Hours : sprintf(buffer, "6hours"); break; | ||
754 | case SMS_VALID_1_Day : sprintf(buffer, "24hours"); break; | ||
755 | case SMS_VALID_3_Days : sprintf(buffer, "72hours"); break; | ||
756 | case SMS_VALID_1_Week : sprintf(buffer, "1week"); break; | ||
757 | case SMS_VALID_Max_Time: | ||
758 | default : sprintf(buffer,"MaximumTime"); break; | ||
759 | } | ||
760 | SaveBackupText(file, "", buffer, UseUnicode); | ||
761 | sprintf(buffer,"%c%c%c%c",13,10,13,10); | ||
762 | SaveBackupText(file, "", buffer, UseUnicode); | ||
763 | } | ||
764 | |||
765 | static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode) | ||
766 | { | ||
767 | unsigned char buffer[45000]; | ||
768 | int i,j; | ||
769 | |||
770 | sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10); | ||
771 | SaveBackupText(file, "", buffer, UseUnicode); | ||
772 | SaveBackupText(file, "Name", ringtone->Name, UseUnicode); | ||
773 | switch (ringtone->Format) { | ||
774 | case RING_NOKIABINARY: | ||
775 | j = 0; i = 0; | ||
776 | EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); | ||
777 | SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode); | ||
778 | break; | ||
779 | case RING_MIDI: | ||
780 | j = 0; i = 0; | ||
781 | EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); | ||
782 | SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode); | ||
783 | break; | ||
784 | case RING_NOTETONE: | ||
785 | break; | ||
786 | } | ||
787 | sprintf(buffer,"%c%c",13,10); | ||
788 | SaveBackupText(file, "", buffer, UseUnicode); | ||
789 | } | ||
790 | |||
791 | static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) | ||
792 | { | ||
793 | unsigned char buffer[1000]; | ||
794 | |||
795 | sprintf(buffer,"[Operator]%c%c",13,10); | ||
796 | SaveBackupText(file, "", buffer, UseUnicode); | ||
797 | sprintf(buffer,"Network = \"%s\"%c%c", bitmap->NetworkCode,13,10); | ||
798 | SaveBackupText(file, "", buffer, UseUnicode); | ||
799 | SaveBitmapEntry(file, bitmap, UseUnicode); | ||
800 | sprintf(buffer,"%c%c",13,10); | ||
801 | SaveBackupText(file, "", buffer, UseUnicode); | ||
802 | } | ||
803 | |||
804 | static void SaveToDoEntry(FILE *file, GSM_ToDoEntry *ToDo, bool UseUnicode) | ||
805 | { | ||
806 | unsigned char buffer[1000]; | ||
807 | int j; | ||
808 | |||
809 | sprintf(buffer,"Location = %i%c%c",ToDo->Location,13,10); | ||
810 | SaveBackupText(file, "", buffer, UseUnicode); | ||
811 | switch (ToDo->Priority) { | ||
812 | case GSM_Priority_High: | ||
813 | sprintf(buffer,"Priority = High%c%c",13,10); | ||
814 | break; | ||
815 | case GSM_Priority_Medium: | ||
816 | sprintf(buffer,"Priority = Medium%c%c",13,10); | ||
817 | break; | ||
818 | case GSM_Priority_Low: | ||
819 | sprintf(buffer,"Priority = Low%c%c",13,10); | ||
820 | break; | ||
821 | } | ||
822 | SaveBackupText(file, "", buffer, UseUnicode); | ||
823 | |||
824 | for (j=0;j<ToDo->EntriesNum;j++) { | ||
825 | switch (ToDo->Entries[j].EntryType) { | ||
826 | case TODO_END_DATETIME: | ||
827 | SaveBackupText(file, "", "DueTime", UseUnicode); | ||
828 | SaveVCalDateTime(file, &ToDo->Entries[j].Date, UseUnicode); | ||
829 | break; | ||
830 | case TODO_COMPLETED: | ||
831 | sprintf(buffer,"Completed = %s%c%c",ToDo->Entries[j].Number == 1 ? "yes" : "no" ,13,10); | ||
832 | SaveBackupText(file, "", buffer, UseUnicode); | ||
833 | break; | ||
834 | case TODO_ALARM_DATETIME: | ||
835 | SaveBackupText(file, "", "Alarm", UseUnicode); | ||
836 | SaveVCalDateTime(file, &ToDo->Entries[j].Date, UseUnicode); | ||
837 | break; | ||
838 | case TODO_SILENT_ALARM_DATETIME: | ||
839 | SaveBackupText(file, "", "SilentAlarm", UseUnicode); | ||
840 | SaveVCalDateTime(file, &ToDo->Entries[j].Date, UseUnicode); | ||
841 | break; | ||
842 | case TODO_TEXT: | ||
843 | SaveBackupText(file, "Text", ToDo->Entries[j].Text, UseUnicode); | ||
844 | break; | ||
845 | case TODO_PRIVATE: | ||
846 | sprintf(buffer,"Private = %i%c%c",ToDo->Entries[j].Number,13,10); | ||
847 | SaveBackupText(file, "", buffer, UseUnicode); | ||
848 | break; | ||
849 | case TODO_CATEGORY: | ||
850 | sprintf(buffer,"Category = %i%c%c",ToDo->Entries[j].Number,13,10); | ||
851 | SaveBackupText(file, "", buffer, UseUnicode); | ||
852 | break; | ||
853 | case TODO_CONTACTID: | ||
854 | sprintf(buffer,"ContactID = %i%c%c",ToDo->Entries[j].Number,13,10); | ||
855 | SaveBackupText(file, "", buffer, UseUnicode); | ||
856 | break; | ||
857 | case TODO_PHONE: | ||
858 | SaveBackupText(file, "Phone", ToDo->Entries[j].Text, UseUnicode); | ||
859 | break; | ||
860 | } | ||
861 | } | ||
862 | sprintf(buffer,"%c%c",13,10); | ||
863 | SaveBackupText(file, "", buffer, UseUnicode); | ||
864 | } | ||
865 | |||
866 | static void SaveProfileEntry(FILE *file, GSM_Profile *Profile, bool UseUnicode) | ||
867 | { | ||
868 | int j,k; | ||
869 | bool special; | ||
870 | unsigned char buffer[1000]; | ||
871 | |||
872 | sprintf(buffer,"Location = %i%c%c",Profile->Location,13,10); | ||
873 | SaveBackupText(file, "", buffer, UseUnicode); | ||
874 | SaveBackupText(file, "Name",Profile->Name, UseUnicode); | ||
875 | |||
876 | if (Profile->DefaultName) { | ||
877 | sprintf(buffer,"DefaultName = true%c%c",13,10); | ||
878 | SaveBackupText(file, "", buffer, UseUnicode); | ||
879 | } | ||
880 | if (Profile->HeadSetProfile) { | ||
881 | sprintf(buffer,"HeadSetProfile = true%c%c",13,10); | ||
882 | SaveBackupText(file, "", buffer, UseUnicode); | ||
883 | } | ||
884 | if (Profile->CarKitProfile) { | ||
885 | sprintf(buffer,"CarKitProfile = true%c%c",13,10); | ||
886 | SaveBackupText(file, "", buffer, UseUnicode); | ||
887 | } | ||
888 | |||
889 | for (j=0;j<Profile->FeaturesNumber;j++) { | ||
890 | sprintf(buffer,"Feature%02i = ",j); | ||
891 | SaveBackupText(file, "", buffer, UseUnicode); | ||
892 | special = false; | ||
893 | switch (Profile->FeatureID[j]) { | ||
894 | case Profile_MessageToneID: | ||
895 | case Profile_RingtoneID: | ||
896 | special = true; | ||
897 | if (Profile->FeatureID[j] == Profile_RingtoneID) { | ||
898 | sprintf(buffer,"RingtoneID%c%c",13,10); | ||
899 | } else { | ||
900 | sprintf(buffer,"MessageToneID%c%c",13,10); | ||
901 | } | ||
902 | SaveBackupText(file, "", buffer, UseUnicode); | ||
903 | sprintf(buffer,"Value%02i = %i%c%c",j,Profile->FeatureValue[j],13,10); | ||
904 | SaveBackupText(file, "", buffer, UseUnicode); | ||
905 | break; | ||
906 | case Profile_CallerGroups: | ||
907 | special = true; | ||
908 | sprintf(buffer,"CallerGroups%c%c",13,10); | ||
909 | SaveBackupText(file, "", buffer, UseUnicode); | ||
910 | sprintf(buffer,"Value%02i = ",j); | ||
911 | SaveBackupText(file, "", buffer, UseUnicode); | ||
912 | for (k=0;k<5;k++) { | ||
913 | if (Profile->CallerGroups[k]) { | ||
914 | sprintf(buffer,"%i",k); | ||
915 | SaveBackupText(file, "", buffer, UseUnicode); | ||
916 | } | ||
917 | } | ||
918 | sprintf(buffer,"%c%c",13,10); | ||
919 | SaveBackupText(file, "", buffer, UseUnicode); | ||
920 | break; | ||
921 | case Profile_ScreenSaverNumber: | ||
922 | special = true; | ||
923 | sprintf(buffer,"ScreenSaverNumber%c%c",13,10); | ||
924 | SaveBackupText(file, "", buffer, UseUnicode); | ||
925 | sprintf(buffer,"Value%02i = %i%c%c",j,Profile->FeatureValue[j],13,10); | ||
926 | SaveBackupText(file, "", buffer, UseUnicode); | ||
927 | break; | ||
928 | case Profile_CallAlert : sprintf(buffer,"IncomingCallAlert%c%c",13,10); break; | ||
929 | case Profile_RingtoneVolume : sprintf(buffer,"RingtoneVolume%c%c",13,10); break; | ||
930 | case Profile_Vibration : sprintf(buffer,"Vibrating%c%c",13,10); break; | ||
931 | case Profile_MessageTone : sprintf(buffer,"MessageTone%c%c",13,10); break; | ||
932 | case Profile_KeypadTone : sprintf(buffer,"KeypadTones%c%c",13,10); break; | ||
933 | case Profile_WarningTone : sprintf(buffer,"WarningTones%c%c",13,10); break; | ||
934 | case Profile_ScreenSaver : sprintf(buffer,"ScreenSaver%c%c",13,10); break; | ||
935 | case Profile_ScreenSaverTime : sprintf(buffer,"ScreenSaverTimeout%c%c",13,10); break; | ||
936 | case Profile_AutoAnswer : sprintf(buffer,"AutomaticAnswer%c%c",13,10); break; | ||
937 | case Profile_Lights : sprintf(buffer,"Lights%c%c",13,10); break; | ||
938 | default : special = true; | ||
939 | } | ||
940 | if (!special) { | ||
941 | SaveBackupText(file, "", buffer, UseUnicode); | ||
942 | sprintf(buffer,"Value%02i = ",j); | ||
943 | SaveBackupText(file, "", buffer, UseUnicode); | ||
944 | switch (Profile->FeatureValue[j]) { | ||
945 | case PROFILE_VOLUME_LEVEL1 : | ||
946 | case PROFILE_KEYPAD_LEVEL1 : sprintf(buffer,"Level1%c%c",13,10); break; | ||
947 | case PROFILE_VOLUME_LEVEL2 : | ||
948 | case PROFILE_KEYPAD_LEVEL2 : sprintf(buffer,"Level2%c%c",13,10); break; | ||
949 | case PROFILE_VOLUME_LEVEL3 : | ||
950 | case PROFILE_KEYPAD_LEVEL3 : sprintf(buffer,"Level3%c%c",13,10); break; | ||
951 | case PROFILE_VOLUME_LEVEL4 : sprintf(buffer,"Level4%c%c",13,10); break; | ||
952 | case PROFILE_VOLUME_LEVEL5 : sprintf(buffer,"Level5%c%c",13,10); break; | ||
953 | case PROFILE_MESSAGE_NOTONE : | ||
954 | case PROFILE_AUTOANSWER_OFF : | ||
955 | case PROFILE_LIGHTS_OFF : | ||
956 | case PROFILE_SAVER_OFF : | ||
957 | case PROFILE_WARNING_OFF : | ||
958 | case PROFILE_CALLALERT_OFF : | ||
959 | case PROFILE_VIBRATION_OFF : | ||
960 | case PROFILE_KEYPAD_OFF : sprintf(buffer,"Off%c%c",13,10); break; | ||
961 | case PROFILE_CALLALERT_RINGING : sprintf(buffer,"Ringing%c%c",13,10); break; | ||
962 | case PROFILE_CALLALERT_RINGONCE : sprintf(buffer,"RingOnce%c%c",13,10); break; | ||
963 | case PROFILE_CALLALERT_ASCENDING : sprintf(buffer,"Ascending%c%c",13,10); break; | ||
964 | case PROFILE_CALLALERT_CALLERGROUPS : sprintf(buffer,"CallerGroups%c%c",13,10);break; | ||
965 | case PROFILE_MESSAGE_STANDARD : sprintf(buffer,"Standard%c%c",13,10); break; | ||
966 | case PROFILE_MESSAGE_SPECIAL : sprintf(buffer,"Special%c%c",13,10); break; | ||
967 | case PROFILE_MESSAGE_BEEPONCE : | ||
968 | case PROFILE_CALLALERT_BEEPONCE : sprintf(buffer,"BeepOnce%c%c",13,10); break; | ||
969 | case PROFILE_MESSAGE_ASCENDING : sprintf(buffer,"Ascending%c%c",13,10); break; | ||
970 | case PROFILE_MESSAGE_PERSONAL : sprintf(buffer,"Personal%c%c",13,10); break; | ||
971 | case PROFILE_AUTOANSWER_ON : | ||
972 | case PROFILE_WARNING_ON : | ||
973 | case PROFILE_SAVER_ON : | ||
974 | case PROFILE_VIBRATION_ON : sprintf(buffer,"On%c%c",13,10); break; | ||
975 | case PROFILE_VIBRATION_FIRST : sprintf(buffer,"VibrateFirst%c%c",13,10);break; | ||
976 | case PROFILE_LIGHTS_AUTO : sprintf(buffer,"Auto%c%c",13,10); break; | ||
977 | case PROFILE_SAVER_TIMEOUT_5SEC : sprintf(buffer,"5Seconds%c%c",13,10); break; | ||
978 | case PROFILE_SAVER_TIMEOUT_20SEC : sprintf(buffer,"20Seconds%c%c",13,10); break; | ||
979 | case PROFILE_SAVER_TIMEOUT_1MIN : sprintf(buffer,"1Minute%c%c",13,10); break; | ||
980 | case PROFILE_SAVER_TIMEOUT_2MIN : sprintf(buffer,"2Minutes%c%c",13,10); break; | ||
981 | case PROFILE_SAVER_TIMEOUT_5MIN : sprintf(buffer,"5Minutes%c%c",13,10); break; | ||
982 | case PROFILE_SAVER_TIMEOUT_10MIN : sprintf(buffer,"10Minutes%c%c",13,10);break; | ||
983 | default : sprintf(buffer,"UNKNOWN%c%c",13,10); | ||
984 | } | ||
985 | SaveBackupText(file, "", buffer, UseUnicode); | ||
986 | } | ||
987 | } | ||
988 | sprintf(buffer,"%c%c",13,10); | ||
989 | SaveBackupText(file, "", buffer, UseUnicode); | ||
990 | } | ||
991 | |||
992 | static void SaveFMStationEntry(FILE *file, GSM_FMStation *FMStation, bool UseUnicode) | ||
993 | { | ||
994 | unsigned char buffer[1000]; | ||
995 | |||
996 | sprintf(buffer,"Location = %i%c%c",FMStation->Location,13,10); | ||
997 | SaveBackupText(file, "", buffer, UseUnicode); | ||
998 | SaveBackupText(file, "StationName", FMStation->StationName, UseUnicode); | ||
999 | sprintf(buffer,"Frequency = %f%c%c",FMStation->Frequency,13,10); | ||
1000 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1001 | sprintf(buffer,"%c%c",13,10); | ||
1002 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1003 | } | ||
1004 | |||
1005 | static void SaveGPRSPointEntry(FILE *file, GSM_GPRSAccessPoint *GPRSPoint, bool UseUnicode) | ||
1006 | { | ||
1007 | unsigned char buffer[1000]; | ||
1008 | |||
1009 | sprintf(buffer,"Location = %i%c%c",GPRSPoint->Location,13,10); | ||
1010 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1011 | SaveBackupText(file, "Name", GPRSPoint->Name, UseUnicode); | ||
1012 | SaveBackupText(file, "URL", GPRSPoint->URL, UseUnicode); | ||
1013 | if (GPRSPoint->Active) { | ||
1014 | sprintf(buffer,"Active = Yes%c%c",13,10); | ||
1015 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1016 | } | ||
1017 | sprintf(buffer,"%c%c",13,10); | ||
1018 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1019 | } | ||
1020 | |||
1021 | GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode) | ||
1022 | { | ||
1023 | int i; | ||
1024 | unsigned char buffer[1000],checksum[200]; | ||
1025 | FILE *file; | ||
1026 | |||
1027 | file = fopen(FileName, "wb"); | ||
1028 | if (file == NULL) return ERR_CANTOPENFILE; | ||
1029 | |||
1030 | if (UseUnicode) { | ||
1031 | sprintf(buffer,"%c%c", 0xFE, 0xFF); | ||
1032 | SaveBackupText(file, "", buffer, false); | ||
1033 | } | ||
1034 | |||
1035 | sprintf(buffer,"# Format of this file was designed for Gammu (see www.mwiacek.com)%c%c%c%c",13,10,13,10); | ||
1036 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1037 | sprintf(buffer,"[Backup]%c%c",13,10); | ||
1038 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1039 | sprintf(buffer,"IMEI = \"%s\"%c%c",backup->IMEI,13,10); | ||
1040 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1041 | sprintf(buffer,"Phone = \"%s\"%c%c",backup->Model,13,10); | ||
1042 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1043 | if (backup->Creator[0] != 0) { | ||
1044 | sprintf(buffer,"Creator = \"%s\"%c%c",backup->Creator,13,10); | ||
1045 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1046 | } | ||
1047 | if (backup->DateTimeAvailable) { | ||
1048 | SaveBackupText(file, "", "DateTime", UseUnicode); | ||
1049 | SaveVCalDateTime(file, &backup->DateTime, UseUnicode); | ||
1050 | } | ||
1051 | sprintf(buffer,"Format = 1.03%c%c",13,10); | ||
1052 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1053 | sprintf(buffer,"%c%c",13,10); | ||
1054 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1055 | |||
1056 | i=0; | ||
1057 | while (backup->PhonePhonebook[i]!=NULL) { | ||
1058 | sprintf(buffer,"[PhonePBK%03i]%c%c",i+1,13,10); | ||
1059 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1060 | SavePbkEntry(file, backup->PhonePhonebook[i], UseUnicode); | ||
1061 | i++; | ||
1062 | } | ||
1063 | i=0; | ||
1064 | while (backup->SIMPhonebook[i]!=NULL) { | ||
1065 | sprintf(buffer,"[SIMPBK%03i]%c%c",i+1,13,10); | ||
1066 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1067 | SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode); | ||
1068 | i++; | ||
1069 | } | ||
1070 | i=0; | ||
1071 | while (backup->Calendar[i]!=NULL) { | ||
1072 | sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10); | ||
1073 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1074 | SaveCalendarEntry(file, backup->Calendar[i], UseUnicode); | ||
1075 | i++; | ||
1076 | } | ||
1077 | i=0; | ||
1078 | while (backup->CallerLogos[i]!=NULL) { | ||
1079 | sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10); | ||
1080 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1081 | SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode); | ||
1082 | i++; | ||
1083 | } | ||
1084 | i=0; | ||
1085 | while (backup->SMSC[i]!=NULL) { | ||
1086 | sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10); | ||
1087 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1088 | SaveSMSCEntry(file, backup->SMSC[i], UseUnicode); | ||
1089 | i++; | ||
1090 | } | ||
1091 | i=0; | ||
1092 | while (backup->WAPBookmark[i]!=NULL) { | ||
1093 | sprintf(buffer,"[WAPBookmark%03i]%c%c",i+1,13,10); | ||
1094 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1095 | SaveWAPBookmarkEntry(file, backup->WAPBookmark[i], UseUnicode); | ||
1096 | i++; | ||
1097 | } | ||
1098 | i=0; | ||
1099 | while (backup->WAPSettings[i]!=NULL) { | ||
1100 | sprintf(buffer,"[WAPSettings%03i]%c%c",i+1,13,10); | ||
1101 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1102 | SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode); | ||
1103 | i++; | ||
1104 | } | ||
1105 | i=0; | ||
1106 | while (backup->MMSSettings[i]!=NULL) { | ||
1107 | sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10); | ||
1108 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1109 | SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode); | ||
1110 | i++; | ||
1111 | } | ||
1112 | i=0; | ||
1113 | while (backup->Ringtone[i]!=NULL) { | ||
1114 | sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10); | ||
1115 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1116 | SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode); | ||
1117 | i++; | ||
1118 | } | ||
1119 | i=0; | ||
1120 | while (backup->ToDo[i]!=NULL) { | ||
1121 | sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10); | ||
1122 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1123 | SaveToDoEntry(file, backup->ToDo[i], UseUnicode); | ||
1124 | i++; | ||
1125 | } | ||
1126 | i=0; | ||
1127 | while (backup->Profiles[i]!=NULL) { | ||
1128 | sprintf(buffer,"[Profile%03i]%c%c",i+1,13,10); | ||
1129 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1130 | SaveProfileEntry(file, backup->Profiles[i], UseUnicode); | ||
1131 | i++; | ||
1132 | } | ||
1133 | i=0; | ||
1134 | while (backup->FMStation[i]!=NULL) { | ||
1135 | sprintf(buffer,"[FMStation%03i]%c%c",i+1,13,10); | ||
1136 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1137 | SaveFMStationEntry(file, backup->FMStation[i], UseUnicode); | ||
1138 | i++; | ||
1139 | } | ||
1140 | i=0; | ||
1141 | while (backup->GPRSPoint[i]!=NULL) { | ||
1142 | sprintf(buffer,"[GPRSPoint%03i]%c%c",i+1,13,10); | ||
1143 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1144 | SaveGPRSPointEntry(file, backup->GPRSPoint[i], UseUnicode); | ||
1145 | i++; | ||
1146 | } | ||
1147 | |||
1148 | if (backup->StartupLogo!=NULL) { | ||
1149 | SaveStartupEntry(file, backup->StartupLogo, UseUnicode); | ||
1150 | } | ||
1151 | if (backup->OperatorLogo!=NULL) { | ||
1152 | SaveOperatorEntry(file, backup->OperatorLogo, UseUnicode); | ||
1153 | } | ||
1154 | |||
1155 | fclose(file); | ||
1156 | |||
1157 | FindBackupChecksum(FileName, UseUnicode, checksum); | ||
1158 | |||
1159 | file = fopen(FileName, "ab"); | ||
1160 | if (file == NULL) return ERR_CANTOPENFILE; | ||
1161 | sprintf(buffer,"[Checksum]%c%c",13,10); | ||
1162 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1163 | sprintf(buffer,"MD5=%s%c%c",checksum,13,10); | ||
1164 | SaveBackupText(file, "", buffer, UseUnicode); | ||
1165 | fclose(file); | ||
1166 | |||
1167 | return ERR_NONE; | ||
1168 | } | ||
1169 | |||
1170 | static void ReadPbkEntry(INI_Section *file_info, char *section, GSM_MemoryEntry *Pbk, bool UseUnicode) | ||
1171 | { | ||
1172 | unsigned char buffer[10000]; | ||
1173 | char *readvalue; | ||
1174 | int num,i; | ||
1175 | INI_Entry *e; | ||
1176 | |||
1177 | Pbk->EntriesNum = 0; | ||
1178 | e = INI_FindLastSectionEntry(file_info, section, UseUnicode); | ||
1179 | |||
1180 | while (e != NULL) { | ||
1181 | num = -1; | ||
1182 | if (UseUnicode) { | ||
1183 | sprintf(buffer,"%s",DecodeUnicodeString(e->EntryName)); | ||
1184 | } else { | ||
1185 | sprintf(buffer,"%s",e->EntryName); | ||
1186 | } | ||
1187 | if (strlen(buffer) == 11) { | ||
1188 | if (mystrncasecmp("Entry", buffer, 5) && | ||
1189 | mystrncasecmp("Type", buffer+7, 4)) { | ||
1190 | num = atoi(buffer+5); | ||
1191 | } | ||
1192 | } | ||
1193 | e = e->Prev; | ||
1194 | if (num != -1) { | ||
1195 | sprintf(buffer,"Entry%02iType",num); | ||
1196 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1197 | if (mystrncasecmp(readvalue,"NumberGeneral",0)) { | ||
1198 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_General; | ||
1199 | } else if (mystrncasecmp(readvalue,"NumberMobile",0)) { | ||
1200 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Mobile; | ||
1201 | } else if (mystrncasecmp(readvalue,"NumberWork",0)) { | ||
1202 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Work; | ||
1203 | } else if (mystrncasecmp(readvalue,"NumberFax",0)) { | ||
1204 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Fax; | ||
1205 | } else if (mystrncasecmp(readvalue,"NumberHome",0)) { | ||
1206 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Home; | ||
1207 | } else if (mystrncasecmp(readvalue,"NumberOther",0)) { | ||
1208 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Other; | ||
1209 | } else if (mystrncasecmp(readvalue,"NumberPager",0)) { | ||
1210 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Pager; | ||
1211 | } else if (mystrncasecmp(readvalue,"Note",0)) { | ||
1212 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Note; | ||
1213 | } else if (mystrncasecmp(readvalue,"Postal",0)) { | ||
1214 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Postal; | ||
1215 | } else if (mystrncasecmp(readvalue,"Email",0)) { | ||
1216 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Email; | ||
1217 | } else if (mystrncasecmp(readvalue,"Email2",0)) { | ||
1218 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Email2; | ||
1219 | } else if (mystrncasecmp(readvalue,"URL",0)) { | ||
1220 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_URL; | ||
1221 | } else if (mystrncasecmp(readvalue,"FirstName",0)) { | ||
1222 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_FirstName; | ||
1223 | } else if (mystrncasecmp(readvalue,"LastName",0)) { | ||
1224 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_LastName; | ||
1225 | } else if (mystrncasecmp(readvalue,"Company",0)) { | ||
1226 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Company; | ||
1227 | } else if (mystrncasecmp(readvalue,"JobTitle",0)) { | ||
1228 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_JobTitle; | ||
1229 | } else if (mystrncasecmp(readvalue,"Address",0)) { | ||
1230 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_StreetAddress; | ||
1231 | } else if (mystrncasecmp(readvalue,"City",0)) { | ||
1232 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_City; | ||
1233 | } else if (mystrncasecmp(readvalue,"State",0)) { | ||
1234 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_State; | ||
1235 | } else if (mystrncasecmp(readvalue,"Zip",0)) { | ||
1236 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Zip; | ||
1237 | } else if (mystrncasecmp(readvalue,"Country",0)) { | ||
1238 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Country; | ||
1239 | } else if (mystrncasecmp(readvalue,"Custom1",0)) { | ||
1240 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Custom1; | ||
1241 | } else if (mystrncasecmp(readvalue,"Custom2",0)) { | ||
1242 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Custom2; | ||
1243 | } else if (mystrncasecmp(readvalue,"Custom3",0)) { | ||
1244 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Custom3; | ||
1245 | } else if (mystrncasecmp(readvalue,"Custom4",0)) { | ||
1246 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Custom4; | ||
1247 | } else if (mystrncasecmp(readvalue,"Name",0)) { | ||
1248 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Name; | ||
1249 | } else if (mystrncasecmp(readvalue,"Category",0)) { | ||
1250 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Category; | ||
1251 | Pbk->Entries[Pbk->EntriesNum].Number = 0; | ||
1252 | sprintf(buffer,"Entry%02iNumber",num); | ||
1253 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1254 | if (readvalue!=NULL) { | ||
1255 | Pbk->Entries[Pbk->EntriesNum].Number = atoi(readvalue); | ||
1256 | } | ||
1257 | Pbk->EntriesNum ++; | ||
1258 | continue; | ||
1259 | } else if (mystrncasecmp(readvalue,"Private",0)) { | ||
1260 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Private; | ||
1261 | Pbk->Entries[Pbk->EntriesNum].Number = 0; | ||
1262 | sprintf(buffer,"Entry%02iNumber",num); | ||
1263 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1264 | if (readvalue!=NULL) { | ||
1265 | Pbk->Entries[Pbk->EntriesNum].Number = atoi(readvalue); | ||
1266 | } | ||
1267 | Pbk->EntriesNum ++; | ||
1268 | continue; | ||
1269 | } else if (mystrncasecmp(readvalue,"CallerGroup",0)) { | ||
1270 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Caller_Group; | ||
1271 | Pbk->Entries[Pbk->EntriesNum].Number = 0; | ||
1272 | sprintf(buffer,"Entry%02iNumber",num); | ||
1273 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1274 | if (readvalue!=NULL) { | ||
1275 | Pbk->Entries[Pbk->EntriesNum].Number = atoi(readvalue); | ||
1276 | } | ||
1277 | Pbk->EntriesNum ++; | ||
1278 | continue; | ||
1279 | } else if (mystrncasecmp(readvalue,"RingtoneID",0)) { | ||
1280 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_RingtoneID; | ||
1281 | Pbk->Entries[Pbk->EntriesNum].Number = 0; | ||
1282 | sprintf(buffer,"Entry%02iNumber",num); | ||
1283 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1284 | if (readvalue!=NULL) { | ||
1285 | Pbk->Entries[Pbk->EntriesNum].Number = atoi(readvalue); | ||
1286 | } | ||
1287 | Pbk->EntriesNum ++; | ||
1288 | continue; | ||
1289 | } else if (mystrncasecmp(readvalue,"PictureID",0)) { | ||
1290 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_PictureID; | ||
1291 | Pbk->Entries[Pbk->EntriesNum].Number = 0; | ||
1292 | sprintf(buffer,"Entry%02iNumber",num); | ||
1293 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1294 | if (readvalue!=NULL) { | ||
1295 | Pbk->Entries[Pbk->EntriesNum].Number = atoi(readvalue); | ||
1296 | } | ||
1297 | Pbk->EntriesNum ++; | ||
1298 | continue; | ||
1299 | } else if (mystrncasecmp(readvalue,"UserID",0)) { | ||
1300 | Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_UserID; | ||
1301 | } | ||
1302 | sprintf(buffer,"Entry%02iText",num); | ||
1303 | ReadBackupText(file_info, section, buffer, Pbk->Entries[Pbk->EntriesNum].Text,UseUnicode); | ||
1304 | dbgprintf("text \"%s\", type %i\n",DecodeUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text),Pbk->Entries[Pbk->EntriesNum].EntryType); | ||
1305 | Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0; | ||
1306 | sprintf(buffer,"Entry%02iVoiceTag",num); | ||
1307 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1308 | if (readvalue!=NULL) { | ||
1309 | Pbk->Entries[Pbk->EntriesNum].VoiceTag = atoi(readvalue); | ||
1310 | } | ||
1311 | i = 0; | ||
1312 | while (1) { | ||
1313 | Pbk->Entries[Pbk->EntriesNum].SMSList[i] = 0; | ||
1314 | sprintf(buffer,"Entry%02iSMSList%02i",num,i); | ||
1315 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1316 | if (readvalue==NULL) break; | ||
1317 | Pbk->Entries[Pbk->EntriesNum].SMSList[i] = atoi(readvalue); | ||
1318 | i++; | ||
1319 | } | ||
1320 | Pbk->EntriesNum ++; | ||
1321 | } | ||
1322 | } | ||
1323 | } | ||
1324 | |||
1325 | static void ReadCalendarEntry(INI_Section *file_info, char *section, GSM_CalendarEntry *note, bool UseUnicode) | ||
1326 | { | ||
1327 | unsigned char buffer[10000]; | ||
1328 | char *readvalue; | ||
1329 | |||
1330 | sprintf(buffer,"Location"); | ||
1331 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1332 | if (readvalue!=NULL) note->Location = atoi(readvalue); | ||
1333 | |||
1334 | sprintf(buffer,"Type"); | ||
1335 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1336 | note->Type = GSM_CAL_REMINDER; | ||
1337 | if (readvalue!=NULL) | ||
1338 | { | ||
1339 | if (mystrncasecmp(readvalue,"Call",0)) { | ||
1340 | note->Type = GSM_CAL_CALL; | ||
1341 | } else if (mystrncasecmp(readvalue,"Meeting",0)) { | ||
1342 | note->Type = GSM_CAL_MEETING; | ||
1343 | } else if (mystrncasecmp(readvalue,"Birthday",0)) { | ||
1344 | note->Type = GSM_CAL_BIRTHDAY; | ||
1345 | } else if (mystrncasecmp(readvalue,"Memo",0)) { | ||
1346 | note->Type = GSM_CAL_MEMO; | ||
1347 | } else if (mystrncasecmp(readvalue,"Travel",0)) { | ||
1348 | note->Type = GSM_CAL_TRAVEL; | ||
1349 | } else if (mystrncasecmp(readvalue,"Vacation",0)) { | ||
1350 | note->Type = GSM_CAL_VACATION; | ||
1351 | } else if (mystrncasecmp(readvalue,"DailyAlarm",0)) { | ||
1352 | note->Type = GSM_CAL_DAILY_ALARM; | ||
1353 | } else if (mystrncasecmp(readvalue,"Alarm",0)) { | ||
1354 | note->Type = GSM_CAL_ALARM; | ||
1355 | } else if (mystrncasecmp(readvalue,"Training/Athletism",0)) { | ||
1356 | note->Type = GSM_CAL_T_ATHL; | ||
1357 | } else if (mystrncasecmp(readvalue,"Training/BallGames",0)) { | ||
1358 | note->Type = GSM_CAL_T_BALL; | ||
1359 | } else if (mystrncasecmp(readvalue,"Training/Cycling",0)) { | ||
1360 | note->Type = GSM_CAL_T_CYCL; | ||
1361 | } else if (mystrncasecmp(readvalue,"Training/Budo",0)) { | ||
1362 | note->Type = GSM_CAL_T_BUDO; | ||
1363 | } else if (mystrncasecmp(readvalue,"Training/Dance",0)) { | ||
1364 | note->Type = GSM_CAL_T_DANC; | ||
1365 | } else if (mystrncasecmp(readvalue,"Training/ExtremeSports",0)) { | ||
1366 | note->Type = GSM_CAL_T_EXTR; | ||
1367 | } else if (mystrncasecmp(readvalue,"Training/Football",0)) { | ||
1368 | note->Type = GSM_CAL_T_FOOT; | ||
1369 | } else if (mystrncasecmp(readvalue,"Training/Golf",0)) { | ||
1370 | note->Type = GSM_CAL_T_GOLF; | ||
1371 | } else if (mystrncasecmp(readvalue,"Training/Gym",0)) { | ||
1372 | note->Type = GSM_CAL_T_GYM; | ||
1373 | } else if (mystrncasecmp(readvalue,"Training/HorseRaces",0)) { | ||
1374 | note->Type = GSM_CAL_T_HORS; | ||
1375 | } else if (mystrncasecmp(readvalue,"Training/Hockey",0)) { | ||
1376 | note->Type = GSM_CAL_T_HOCK; | ||
1377 | } else if (mystrncasecmp(readvalue,"Training/Races",0)) { | ||
1378 | note->Type = GSM_CAL_T_RACE; | ||
1379 | } else if (mystrncasecmp(readvalue,"Training/Rugby",0)) { | ||
1380 | note->Type = GSM_CAL_T_RUGB; | ||
1381 | } else if (mystrncasecmp(readvalue,"Training/Sailing",0)) { | ||
1382 | note->Type = GSM_CAL_T_SAIL; | ||
1383 | } else if (mystrncasecmp(readvalue,"Training/StreetGames",0)) { | ||
1384 | note->Type = GSM_CAL_T_STRE; | ||
1385 | } else if (mystrncasecmp(readvalue,"Training/Swimming",0)) { | ||
1386 | note->Type = GSM_CAL_T_SWIM; | ||
1387 | } else if (mystrncasecmp(readvalue,"Training/Tennis",0)) { | ||
1388 | note->Type = GSM_CAL_T_TENN; | ||
1389 | } else if (mystrncasecmp(readvalue,"Training/Travels",0)) { | ||
1390 | note->Type = GSM_CAL_T_TRAV; | ||
1391 | } else if (mystrncasecmp(readvalue,"Training/WinterGames",0)) { | ||
1392 | note->Type = GSM_CAL_T_WINT; | ||
1393 | } | ||
1394 | } | ||
1395 | note->EntriesNum = 0; | ||
1396 | sprintf(buffer,"Text"); | ||
1397 | if (ReadBackupText(file_info, section, buffer, note->Entries[note->EntriesNum].Text,UseUnicode)) { | ||
1398 | note->Entries[note->EntriesNum].EntryType = CAL_TEXT; | ||
1399 | note->EntriesNum++; | ||
1400 | } | ||
1401 | sprintf(buffer,"Phone"); | ||
1402 | if (ReadBackupText(file_info, section, buffer, note->Entries[note->EntriesNum].Text,UseUnicode)) { | ||
1403 | note->Entries[note->EntriesNum].EntryType = CAL_PHONE; | ||
1404 | note->EntriesNum++; | ||
1405 | } | ||
1406 | sprintf(buffer,"Private"); | ||
1407 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1408 | if (readvalue!=NULL) { | ||
1409 | note->Entries[note->EntriesNum].Number = atoi(readvalue); | ||
1410 | note->Entries[note->EntriesNum].EntryType = CAL_PRIVATE; | ||
1411 | note->EntriesNum++; | ||
1412 | } | ||
1413 | sprintf(buffer,"EventLocation"); | ||
1414 | if (ReadBackupText(file_info, section, buffer, note->Entries[note->EntriesNum].Text,UseUnicode)) { | ||
1415 | note->Entries[note->EntriesNum].EntryType = CAL_LOCATION; | ||
1416 | note->EntriesNum++; | ||
1417 | } | ||
1418 | sprintf(buffer,"ContactID"); | ||
1419 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1420 | if (readvalue!=NULL) { | ||
1421 | note->Entries[note->EntriesNum].Number = atoi(readvalue); | ||
1422 | note->Entries[note->EntriesNum].EntryType = CAL_CONTACTID; | ||
1423 | note->EntriesNum++; | ||
1424 | } | ||
1425 | sprintf(buffer,"Recurrance"); | ||
1426 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1427 | if (readvalue!=NULL) { | ||
1428 | note->Entries[note->EntriesNum].Number = atoi(readvalue) * 24; | ||
1429 | note->Entries[note->EntriesNum].EntryType = CAL_RECURRANCE; | ||
1430 | note->EntriesNum++; | ||
1431 | } | ||
1432 | sprintf(buffer,"StartTime"); | ||
1433 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1434 | if (readvalue!=NULL) { | ||
1435 | ReadVCALDateTime(readvalue, ¬e->Entries[note->EntriesNum].Date); | ||
1436 | note->Entries[note->EntriesNum].EntryType = CAL_START_DATETIME; | ||
1437 | note->EntriesNum++; | ||
1438 | } | ||
1439 | sprintf(buffer,"StopTime"); | ||
1440 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1441 | if (readvalue!=NULL) { | ||
1442 | ReadVCALDateTime(readvalue, ¬e->Entries[note->EntriesNum].Date); | ||
1443 | note->Entries[note->EntriesNum].EntryType = CAL_END_DATETIME; | ||
1444 | note->EntriesNum++; | ||
1445 | } | ||
1446 | sprintf(buffer,"Alarm"); | ||
1447 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1448 | if (readvalue!=NULL) | ||
1449 | { | ||
1450 | ReadVCALDateTime(readvalue, ¬e->Entries[note->EntriesNum].Date); | ||
1451 | note->Entries[note->EntriesNum].EntryType = CAL_ALARM_DATETIME; | ||
1452 | sprintf(buffer,"AlarmType"); | ||
1453 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1454 | if (readvalue!=NULL) | ||
1455 | { | ||
1456 | if (mystrncasecmp(readvalue,"Silent",0)) { | ||
1457 | note->Entries[note->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; | ||
1458 | } | ||
1459 | } | ||
1460 | note->EntriesNum++; | ||
1461 | } | ||
1462 | sprintf(buffer,"RepeatStartDate"); | ||
1463 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1464 | if (readvalue!=NULL) { | ||
1465 | ReadVCALDateTime(readvalue, ¬e->Entries[note->EntriesNum].Date); | ||
1466 | note->Entries[note->EntriesNum].EntryType = CAL_REPEAT_STARTDATE; | ||
1467 | note->EntriesNum++; | ||
1468 | } | ||
1469 | sprintf(buffer,"RepeatStopDate"); | ||
1470 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1471 | if (readvalue!=NULL) { | ||
1472 | ReadVCALDateTime(readvalue, ¬e->Entries[note->EntriesNum].Date); | ||
1473 | note->Entries[note->EntriesNum].EntryType = CAL_REPEAT_STOPDATE; | ||
1474 | note->EntriesNum++; | ||
1475 | } | ||
1476 | sprintf(buffer,"RepeatDayOfWeek"); | ||
1477 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1478 | if (readvalue!=NULL) { | ||
1479 | note->Entries[note->EntriesNum].Number = atoi(readvalue); | ||
1480 | note->Entries[note->EntriesNum].EntryType = CAL_REPEAT_DAYOFWEEK; | ||
1481 | note->EntriesNum++; | ||
1482 | } | ||
1483 | sprintf(buffer,"RepeatDay"); | ||
1484 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1485 | if (readvalue!=NULL) { | ||
1486 | note->Entries[note->EntriesNum].Number = atoi(readvalue); | ||
1487 | note->Entries[note->EntriesNum].EntryType = CAL_REPEAT_DAY; | ||
1488 | note->EntriesNum++; | ||
1489 | } | ||
1490 | sprintf(buffer,"RepeatWeekOfMonth"); | ||
1491 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1492 | if (readvalue!=NULL) { | ||
1493 | note->Entries[note->EntriesNum].Number = atoi(readvalue); | ||
1494 | note->Entries[note->EntriesNum].EntryType = CAL_REPEAT_WEEKOFMONTH; | ||
1495 | note->EntriesNum++; | ||
1496 | } | ||
1497 | sprintf(buffer,"RepeatMonth"); | ||
1498 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1499 | if (readvalue!=NULL) { | ||
1500 | note->Entries[note->EntriesNum].Number = atoi(readvalue); | ||
1501 | note->Entries[note->EntriesNum].EntryType = CAL_REPEAT_MONTH; | ||
1502 | note->EntriesNum++; | ||
1503 | } | ||
1504 | sprintf(buffer,"RepeatFrequency"); | ||
1505 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1506 | if (readvalue!=NULL) { | ||
1507 | note->Entries[note->EntriesNum].Number = atoi(readvalue); | ||
1508 | note->Entries[note->EntriesNum].EntryType = CAL_REPEAT_FREQUENCY; | ||
1509 | note->EntriesNum++; | ||
1510 | } | ||
1511 | } | ||
1512 | |||
1513 | static void ReadToDoEntry(INI_Section *file_info, char *section, GSM_ToDoEntry *ToDo, bool UseUnicode) | ||
1514 | { | ||
1515 | unsigned char buffer[10000]; | ||
1516 | char *readvalue; | ||
1517 | |||
1518 | ToDo->EntriesNum = 0; | ||
1519 | |||
1520 | sprintf(buffer,"Location"); | ||
1521 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1522 | if (readvalue!=NULL) ToDo->Location = atoi(readvalue); | ||
1523 | |||
1524 | ToDo->Priority = GSM_Priority_High; | ||
1525 | sprintf(buffer,"Priority"); | ||
1526 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1527 | if (readvalue!=NULL) { | ||
1528 | if (!strcmp(readvalue,"3") || !strcmp(readvalue,"Low")) { | ||
1529 | ToDo->Priority = GSM_Priority_Low; | ||
1530 | } | ||
1531 | if (!strcmp(readvalue,"2") || !strcmp(readvalue,"Medium")) { | ||
1532 | ToDo->Priority = GSM_Priority_Medium; | ||
1533 | } | ||
1534 | } | ||
1535 | |||
1536 | sprintf(buffer,"Text"); | ||
1537 | if (ReadBackupText(file_info, section, buffer, ToDo->Entries[ToDo->EntriesNum].Text,UseUnicode)) { | ||
1538 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; | ||
1539 | ToDo->EntriesNum++; | ||
1540 | } | ||
1541 | |||
1542 | sprintf(buffer,"Phone"); | ||
1543 | if (ReadBackupText(file_info, section, buffer, ToDo->Entries[ToDo->EntriesNum].Text,UseUnicode)) { | ||
1544 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_PHONE; | ||
1545 | ToDo->EntriesNum++; | ||
1546 | } | ||
1547 | |||
1548 | sprintf(buffer,"Private"); | ||
1549 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1550 | if (readvalue!=NULL) { | ||
1551 | ToDo->Entries[ToDo->EntriesNum].Number = atoi(readvalue); | ||
1552 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_PRIVATE; | ||
1553 | ToDo->EntriesNum++; | ||
1554 | } | ||
1555 | |||
1556 | sprintf(buffer,"Completed"); | ||
1557 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1558 | if (readvalue!=NULL) { | ||
1559 | if (strncmp(readvalue, "yes", 3) == 0) { | ||
1560 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | ||
1561 | } else { | ||
1562 | ToDo->Entries[ToDo->EntriesNum].Number = 0; | ||
1563 | } | ||
1564 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; | ||
1565 | ToDo->EntriesNum++; | ||
1566 | } | ||
1567 | |||
1568 | sprintf(buffer,"Category"); | ||
1569 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1570 | if (readvalue!=NULL) { | ||
1571 | ToDo->Entries[ToDo->EntriesNum].Number = atoi(readvalue); | ||
1572 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_CATEGORY; | ||
1573 | ToDo->EntriesNum++; | ||
1574 | } | ||
1575 | |||
1576 | sprintf(buffer,"ContactID"); | ||
1577 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1578 | if (readvalue!=NULL) { | ||
1579 | ToDo->Entries[ToDo->EntriesNum].Number = atoi(readvalue); | ||
1580 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_CONTACTID; | ||
1581 | ToDo->EntriesNum++; | ||
1582 | } | ||
1583 | |||
1584 | sprintf(buffer,"DueTime"); | ||
1585 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1586 | if (readvalue!=NULL) { | ||
1587 | ReadVCALDateTime(readvalue, &ToDo->Entries[ToDo->EntriesNum].Date); | ||
1588 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; | ||
1589 | ToDo->EntriesNum++; | ||
1590 | } | ||
1591 | |||
1592 | sprintf(buffer,"Alarm"); | ||
1593 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1594 | if (readvalue!=NULL) { | ||
1595 | ReadVCALDateTime(readvalue, &ToDo->Entries[ToDo->EntriesNum].Date); | ||
1596 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | ||
1597 | ToDo->EntriesNum++; | ||
1598 | } | ||
1599 | |||
1600 | sprintf(buffer,"SilentAlarm"); | ||
1601 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1602 | if (readvalue!=NULL) { | ||
1603 | ReadVCALDateTime(readvalue, &ToDo->Entries[ToDo->EntriesNum].Date); | ||
1604 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; | ||
1605 | ToDo->EntriesNum++; | ||
1606 | } | ||
1607 | } | ||
1608 | |||
1609 | static bool ReadBitmapEntry(INI_Section *file_info, char *section, GSM_Bitmap *bitmap, bool UseUnicode) | ||
1610 | { | ||
1611 | char *readvalue; | ||
1612 | unsigned charbuffer[10000]; | ||
1613 | unsigned char Width, Height; | ||
1614 | int x, y; | ||
1615 | |||
1616 | GSM_GetMaxBitmapWidthHeight(bitmap->Type, &Width, &Height); | ||
1617 | sprintf(buffer,"Width"); | ||
1618 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1619 | if (readvalue==NULL) bitmap->BitmapWidth = Width; else bitmap->BitmapWidth = atoi(readvalue); | ||
1620 | sprintf(buffer,"Height"); | ||
1621 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1622 | if (readvalue==NULL) bitmap->BitmapHeight = Height; else bitmap->BitmapHeight = atoi(readvalue); | ||
1623 | GSM_ClearBitmap(bitmap); | ||
1624 | for (y=0;y<bitmap->BitmapHeight;y++) { | ||
1625 | sprintf(buffer,"Bitmap%02i",y); | ||
1626 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1627 | if (readvalue!=NULL) { | ||
1628 | for (x=0;x<bitmap->BitmapWidth;x++) { | ||
1629 | if (readvalue[x+1]=='#') GSM_SetPointBitmap(bitmap,x,y); | ||
1630 | } | ||
1631 | } else return false; | ||
1632 | } | ||
1633 | return true; | ||
1634 | } | ||
1635 | |||
1636 | static void ReadCallerEntry(INI_Section *file_info, char *section, GSM_Bitmap *bitmap, bool UseUnicode) | ||
1637 | { | ||
1638 | unsigned char buffer[10000]; | ||
1639 | char *readvalue; | ||
1640 | |||
1641 | bitmap->Type = GSM_CallerGroupLogo; | ||
1642 | bitmap->DefaultBitmap = !ReadBitmapEntry(file_info, section, bitmap, UseUnicode); | ||
1643 | if (bitmap->DefaultBitmap) { | ||
1644 | bitmap->BitmapWidth = 72; | ||
1645 | bitmap->BitmapHeight = 14; | ||
1646 | GSM_ClearBitmap(bitmap); | ||
1647 | } | ||
1648 | sprintf(buffer,"Name"); | ||
1649 | ReadBackupText(file_info, section, buffer, bitmap->Text,UseUnicode); | ||
1650 | if (bitmap->Text[0] == 0x00 && bitmap->Text[1] == 0x00) { | ||
1651 | bitmap->DefaultName = true; | ||
1652 | } else { | ||
1653 | bitmap->DefaultName = false; | ||
1654 | } | ||
1655 | sprintf(buffer,"Ringtone"); | ||
1656 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1657 | if (readvalue==NULL) { | ||
1658 | sprintf(buffer,"FileRingtone"); | ||
1659 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1660 | if (readvalue==NULL) { | ||
1661 | bitmap->DefaultRingtone = true; | ||
1662 | } else { | ||
1663 | DecodeHexBin (&bitmap->RingtoneID, readvalue, 2); | ||
1664 | bitmap->DefaultRingtone = false; | ||
1665 | bitmap->FileSystemRingtone = true; | ||
1666 | } | ||
1667 | } else { | ||
1668 | DecodeHexBin (&bitmap->RingtoneID, readvalue, 2); | ||
1669 | bitmap->DefaultRingtone = false; | ||
1670 | bitmap->FileSystemRingtone = false; | ||
1671 | } | ||
1672 | sprintf(buffer,"Enabled"); | ||
1673 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1674 | bitmap->BitmapEnabled = true; | ||
1675 | if (readvalue!=NULL) { | ||
1676 | if (mystrncasecmp(readvalue,"False",0)) bitmap->BitmapEnabled = false; | ||
1677 | } | ||
1678 | } | ||
1679 | |||
1680 | static void ReadStartupEntry(INI_Section *file_info, char *section, GSM_Bitmap *bitmap, bool UseUnicode) | ||
1681 | { | ||
1682 | unsigned char buffer[10000]; | ||
1683 | |||
1684 | sprintf(buffer,"Text"); | ||
1685 | ReadBackupText(file_info, section, buffer, bitmap->Text,UseUnicode); | ||
1686 | if (bitmap->Text[0]!=0 || bitmap->Text[1]!=0) { | ||
1687 | bitmap->Type = GSM_WelcomeNote_Text; | ||
1688 | } else { | ||
1689 | bitmap->Type = GSM_StartupLogo; | ||
1690 | bitmap->Location = 1; | ||
1691 | ReadBitmapEntry(file_info, section, bitmap, UseUnicode); | ||
1692 | #ifdef DEBUG | ||
1693 | if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) GSM_PrintBitmap(di.df,bitmap); | ||
1694 | #endif | ||
1695 | } | ||
1696 | } | ||
1697 | |||
1698 | static void ReadWAPBookmarkEntry(INI_Section *file_info, char *section, GSM_WAPBookmark *bookmark, bool UseUnicode) | ||
1699 | { | ||
1700 | unsigned char buffer[10000]; | ||
1701 | |||
1702 | sprintf(buffer,"URL"); | ||
1703 | ReadBackupText(file_info, section, buffer, bookmark->Address,UseUnicode); | ||
1704 | sprintf(buffer,"Title"); | ||
1705 | ReadBackupText(file_info, section, buffer, bookmark->Title,UseUnicode); | ||
1706 | } | ||
1707 | |||
1708 | static void ReadOperatorEntry(INI_Section *file_info, char *section, GSM_Bitmap *bitmap, bool UseUnicode) | ||
1709 | { | ||
1710 | unsigned char buffer[10000]; | ||
1711 | char *readvalue; | ||
1712 | |||
1713 | sprintf(buffer,"Network"); | ||
1714 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1715 | memcpy(bitmap->NetworkCode, readvalue + 1, 6); | ||
1716 | bitmap->NetworkCode[6] = 0; | ||
1717 | bitmap->Type = GSM_OperatorLogo; | ||
1718 | ReadBitmapEntry(file_info, section, bitmap, UseUnicode); | ||
1719 | } | ||
1720 | |||
1721 | static void ReadSMSCEntry(INI_Section *file_info, char *section, GSM_SMSC *SMSC, bool UseUnicode) | ||
1722 | { | ||
1723 | unsigned char buffer[10000]; | ||
1724 | char *readvalue; | ||
1725 | |||
1726 | sprintf(buffer,"Name"); | ||
1727 | ReadBackupText(file_info, section, buffer, SMSC->Name,UseUnicode); | ||
1728 | sprintf(buffer,"Number"); | ||
1729 | ReadBackupText(file_info, section, buffer, SMSC->Number,UseUnicode); | ||
1730 | sprintf(buffer,"DefaultNumber"); | ||
1731 | ReadBackupText(file_info, section, buffer, SMSC->DefaultNumber,UseUnicode); | ||
1732 | sprintf(buffer,"Format"); | ||
1733 | SMSC->Format = SMS_FORMAT_Text; | ||
1734 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1735 | if (readvalue!=NULL) { | ||
1736 | if (mystrncasecmp(readvalue,"Fax",0)) { | ||
1737 | SMSC->Format = SMS_FORMAT_Fax; | ||
1738 | } else if (mystrncasecmp(readvalue,"Email",0)) { | ||
1739 | SMSC->Format = SMS_FORMAT_Email; | ||
1740 | } else if (mystrncasecmp(readvalue,"Pager",0)) { | ||
1741 | SMSC->Format = SMS_FORMAT_Pager; | ||
1742 | } | ||
1743 | } | ||
1744 | sprintf(buffer,"Validity"); | ||
1745 | SMSC->Validity.Relative = SMS_VALID_Max_Time; | ||
1746 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1747 | if (readvalue!=NULL) { | ||
1748 | if (mystrncasecmp(readvalue,"1hour",0)) { | ||
1749 | SMSC->Validity.Relative = SMS_VALID_1_Hour; | ||
1750 | } else if (mystrncasecmp(readvalue,"6hours",0)) { | ||
1751 | SMSC->Validity.Relative = SMS_VALID_6_Hours; | ||
1752 | } else if (mystrncasecmp(readvalue,"24hours",0)) { | ||
1753 | SMSC->Validity.Relative = SMS_VALID_1_Day; | ||
1754 | } else if (mystrncasecmp(readvalue,"72hours",0)) { | ||
1755 | SMSC->Validity.Relative = SMS_VALID_3_Days; | ||
1756 | } else if (mystrncasecmp(readvalue,"1week",0)) { | ||
1757 | SMSC->Validity.Relative = SMS_VALID_1_Week; | ||
1758 | } | ||
1759 | } | ||
1760 | } | ||
1761 | |||
1762 | static void ReadWAPSettingsEntry(INI_Section *file_info, char *section, GSM_MultiWAPSettings *settings, bool UseUnicode) | ||
1763 | { | ||
1764 | unsigned char buffer[10000], *readvalue; | ||
1765 | int num; | ||
1766 | INI_Entry *e; | ||
1767 | |||
1768 | settings->ActiveBearer = WAPSETTINGS_BEARER_DATA; | ||
1769 | sprintf(buffer,"Bearer"); | ||
1770 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1771 | if (readvalue!=NULL) { | ||
1772 | if (mystrncasecmp(readvalue,"SMS",0)) { | ||
1773 | settings->ActiveBearer = WAPSETTINGS_BEARER_SMS; | ||
1774 | } else if (mystrncasecmp(readvalue,"GPRS",0)) { | ||
1775 | settings->ActiveBearer = WAPSETTINGS_BEARER_GPRS; | ||
1776 | } else if (mystrncasecmp(readvalue,"USSD",0)) { | ||
1777 | settings->ActiveBearer = WAPSETTINGS_BEARER_USSD; | ||
1778 | } | ||
1779 | } | ||
1780 | |||
1781 | settings->Active = false; | ||
1782 | sprintf(buffer,"Active"); | ||
1783 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1784 | if (readvalue!=NULL) { | ||
1785 | if (mystrncasecmp(readvalue,"Yes",0)) settings->Active = true; | ||
1786 | } | ||
1787 | |||
1788 | settings->ReadOnly = false; | ||
1789 | sprintf(buffer,"ReadOnly"); | ||
1790 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1791 | if (readvalue!=NULL) { | ||
1792 | if (mystrncasecmp(readvalue,"Yes",0)) settings->ReadOnly = true; | ||
1793 | } | ||
1794 | |||
1795 | sprintf(buffer,"Proxy"); | ||
1796 | ReadBackupText(file_info, section, buffer, settings->Proxy,UseUnicode); | ||
1797 | sprintf(buffer,"ProxyPort"); | ||
1798 | settings->ProxyPort = 8080; | ||
1799 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1800 | if (readvalue!=NULL) settings->ProxyPort = atoi(readvalue); | ||
1801 | sprintf(buffer,"Proxy2"); | ||
1802 | ReadBackupText(file_info, section, buffer, settings->Proxy2,UseUnicode); | ||
1803 | sprintf(buffer,"Proxy2Port"); | ||
1804 | settings->Proxy2Port = 8080; | ||
1805 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1806 | if (readvalue!=NULL) settings->Proxy2Port = atoi(readvalue); | ||
1807 | |||
1808 | settings->Number = 0; | ||
1809 | e = INI_FindLastSectionEntry(file_info, section, UseUnicode); | ||
1810 | while (e != NULL) { | ||
1811 | num = -1; | ||
1812 | if (UseUnicode) { | ||
1813 | sprintf(buffer,"%s",DecodeUnicodeString(e->EntryName)); | ||
1814 | } else { | ||
1815 | sprintf(buffer,"%s",e->EntryName); | ||
1816 | } | ||
1817 | if (strlen(buffer) == 7) { | ||
1818 | if (mystrncasecmp("Title", buffer,5)) num = atoi(buffer+5); | ||
1819 | } | ||
1820 | e = e->Prev; | ||
1821 | if (num != -1) { | ||
1822 | sprintf(buffer,"Title%02i",num); | ||
1823 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].Title,UseUnicode); | ||
1824 | sprintf(buffer,"HomePage%02i",num); | ||
1825 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].HomePage,UseUnicode); | ||
1826 | sprintf(buffer,"Type%02i",num); | ||
1827 | settings->Settings[settings->Number].IsContinuous = true; | ||
1828 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1829 | if (readvalue!=NULL) { | ||
1830 | if (mystrncasecmp(readvalue,"Temporary",0)) settings->Settings[settings->Number].IsContinuous = false; | ||
1831 | } | ||
1832 | sprintf(buffer,"Security%02i",num); | ||
1833 | settings->Settings[settings->Number].IsSecurity = true; | ||
1834 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1835 | if (readvalue!=NULL) | ||
1836 | { | ||
1837 | if (mystrncasecmp(readvalue,"Off",0)) settings->Settings[settings->Number].IsSecurity = false; | ||
1838 | } | ||
1839 | sprintf(buffer,"Bearer%02i",num); | ||
1840 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1841 | if (readvalue!=NULL) | ||
1842 | { | ||
1843 | if (mystrncasecmp(readvalue,"SMS",0)) { | ||
1844 | settings->Settings[settings->Number].Bearer = WAPSETTINGS_BEARER_SMS; | ||
1845 | sprintf(buffer,"Server%02i",num); | ||
1846 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].Server,UseUnicode); | ||
1847 | sprintf(buffer,"Service%02i",num); | ||
1848 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].Service,UseUnicode); | ||
1849 | } else if ((mystrncasecmp(readvalue,"Data",0) || mystrncasecmp(readvalue,"GPRS",0))) { | ||
1850 | settings->Settings[settings->Number].Bearer = WAPSETTINGS_BEARER_DATA; | ||
1851 | if (mystrncasecmp(readvalue,"GPRS",0)) settings->Settings[settings->Number].Bearer = WAPSETTINGS_BEARER_GPRS; | ||
1852 | sprintf(buffer,"Number%02i",num); | ||
1853 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].DialUp,UseUnicode); | ||
1854 | sprintf(buffer,"IP%02i",num); | ||
1855 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].IPAddress,UseUnicode); | ||
1856 | sprintf(buffer,"User%02i",num); | ||
1857 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].User,UseUnicode); | ||
1858 | sprintf(buffer,"Password%02i",num); | ||
1859 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].Password,UseUnicode); | ||
1860 | sprintf(buffer,"Authentication%02i",num); | ||
1861 | settings->Settings[settings->Number].IsNormalAuthentication = true; | ||
1862 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1863 | if (readvalue!=NULL) | ||
1864 | { | ||
1865 | if (mystrncasecmp(readvalue,"Secure",0)) settings->Settings[settings->Number].IsNormalAuthentication = false; | ||
1866 | } | ||
1867 | sprintf(buffer,"CallSpeed%02i",num); | ||
1868 | settings->Settings[settings->Number].Speed = WAPSETTINGS_SPEED_14400; | ||
1869 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1870 | if (readvalue!=NULL) | ||
1871 | { | ||
1872 | if (mystrncasecmp(readvalue,"9600",0)) settings->Settings[settings->Number].Speed = WAPSETTINGS_SPEED_9600; | ||
1873 | if (mystrncasecmp(readvalue,"auto",0)) settings->Settings[settings->Number].Speed = WAPSETTINGS_SPEED_AUTO; | ||
1874 | } | ||
1875 | sprintf(buffer,"Login%02i",num); | ||
1876 | settings->Settings[settings->Number].ManualLogin = false; | ||
1877 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1878 | if (readvalue!=NULL) | ||
1879 | { | ||
1880 | if (mystrncasecmp(readvalue,"Manual",0)) settings->Settings[settings->Number].ManualLogin = true; | ||
1881 | } | ||
1882 | sprintf(buffer,"CallType%02i",num); | ||
1883 | settings->Settings[settings->Number].IsISDNCall = true; | ||
1884 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1885 | if (readvalue!=NULL) | ||
1886 | { | ||
1887 | if (mystrncasecmp(readvalue,"Analogue",0)) settings->Settings[settings->Number].IsISDNCall = false; | ||
1888 | } | ||
1889 | } else if (mystrncasecmp(readvalue,"USSD",0)) { | ||
1890 | settings->Settings[settings->Number].Bearer = WAPSETTINGS_BEARER_USSD; | ||
1891 | sprintf(buffer,"ServiceCode%02i",num); | ||
1892 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].Code,UseUnicode); | ||
1893 | sprintf(buffer,"IP%02i",num); | ||
1894 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1895 | if (readvalue!=NULL) { | ||
1896 | settings->Settings[settings->Number].IsIP = true; | ||
1897 | sprintf(buffer,"IP%02i",num); | ||
1898 | } else { | ||
1899 | settings->Settings[settings->Number].IsIP = false; | ||
1900 | sprintf(buffer,"Number%02i",num); | ||
1901 | } | ||
1902 | ReadBackupText(file_info, section, buffer, settings->Settings[settings->Number].Service,UseUnicode); | ||
1903 | } | ||
1904 | } | ||
1905 | settings->Number++; | ||
1906 | } | ||
1907 | } | ||
1908 | } | ||
1909 | |||
1910 | static void ReadRingtoneEntry(INI_Section *file_info, char *section, GSM_Ringtone *ringtone, bool UseUnicode) | ||
1911 | { | ||
1912 | unsigned char buffer[10000], buffer2[10000], *readvalue; | ||
1913 | |||
1914 | sprintf(buffer,"Name"); | ||
1915 | ReadBackupText(file_info, section, buffer, ringtone->Name,UseUnicode); | ||
1916 | ringtone->Location = 0; | ||
1917 | sprintf(buffer,"Location"); | ||
1918 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1919 | if (readvalue!=NULL) ringtone->Location = atoi(readvalue); | ||
1920 | sprintf(buffer,"NokiaBinary00"); | ||
1921 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1922 | if (readvalue!=NULL) { | ||
1923 | ringtone->Format = RING_NOKIABINARY; | ||
1924 | ReadLinkedBackupText(file_info, section, "NokiaBinary", buffer2, UseUnicode); | ||
1925 | DecodeHexBin (ringtone->NokiaBinary.Frame, buffer2, strlen(buffer2)); | ||
1926 | ringtone->NokiaBinary.Length = strlen(buffer2)/2; | ||
1927 | } | ||
1928 | sprintf(buffer,"Pure Midi00"); | ||
1929 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1930 | if (readvalue!=NULL) { | ||
1931 | ringtone->Format = RING_MIDI; | ||
1932 | ReadLinkedBackupText(file_info, section, "Pure Midi", buffer2, UseUnicode); | ||
1933 | DecodeHexBin (ringtone->NokiaBinary.Frame, buffer2, strlen(buffer2)); | ||
1934 | ringtone->NokiaBinary.Length = strlen(buffer2)/2; | ||
1935 | } | ||
1936 | |||
1937 | } | ||
1938 | |||
1939 | static void ReadProfileEntry(INI_Section *file_info, char *section, GSM_Profile *Profile, bool UseUnicode) | ||
1940 | { | ||
1941 | unsigned char buffer[10000]; | ||
1942 | char *readvalue; | ||
1943 | bool unknown; | ||
1944 | int num,j; | ||
1945 | INI_Entry *e; | ||
1946 | |||
1947 | sprintf(buffer,"Name"); | ||
1948 | ReadBackupText(file_info, section, buffer, Profile->Name,UseUnicode); | ||
1949 | |||
1950 | sprintf(buffer,"Location"); | ||
1951 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1952 | Profile->Location = atoi(readvalue); | ||
1953 | |||
1954 | Profile->DefaultName = false; | ||
1955 | sprintf(buffer,"DefaultName"); | ||
1956 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1957 | if (readvalue!=NULL && mystrncasecmp(buffer,"true",0)) Profile->DefaultName = true; | ||
1958 | |||
1959 | Profile->HeadSetProfile = false; | ||
1960 | sprintf(buffer,"HeadSetProfile"); | ||
1961 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1962 | if (readvalue!=NULL && mystrncasecmp(buffer,"true",0)) Profile->HeadSetProfile = true; | ||
1963 | |||
1964 | Profile->CarKitProfile = false; | ||
1965 | sprintf(buffer,"CarKitProfile"); | ||
1966 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1967 | if (readvalue!=NULL && mystrncasecmp(buffer,"true",0)) Profile->CarKitProfile = true; | ||
1968 | |||
1969 | Profile->FeaturesNumber = 0; | ||
1970 | e = INI_FindLastSectionEntry(file_info, section, UseUnicode); | ||
1971 | while (e != NULL) { | ||
1972 | num = -1; | ||
1973 | if (UseUnicode) { | ||
1974 | sprintf(buffer,"%s",DecodeUnicodeString(e->EntryName)); | ||
1975 | } else { | ||
1976 | sprintf(buffer,"%s",e->EntryName); | ||
1977 | } | ||
1978 | if (strlen(buffer) == 9) { | ||
1979 | if (mystrncasecmp("Feature", buffer, 7)) num = atoi(buffer+7); | ||
1980 | } | ||
1981 | e = e->Prev; | ||
1982 | if (num != -1) { | ||
1983 | sprintf(buffer,"Feature%02i",num); | ||
1984 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1985 | if (readvalue==NULL) break; | ||
1986 | unknown = true; | ||
1987 | if (mystrncasecmp(readvalue,"RingtoneID",0)) { | ||
1988 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_RingtoneID; | ||
1989 | sprintf(buffer,"Value%02i",num); | ||
1990 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1991 | Profile->FeatureValue[Profile->FeaturesNumber]=atoi(readvalue); | ||
1992 | Profile->FeaturesNumber++; | ||
1993 | } else if (mystrncasecmp(readvalue,"MessageToneID",0)) { | ||
1994 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_MessageToneID; | ||
1995 | sprintf(buffer,"Value%02i",num); | ||
1996 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
1997 | Profile->FeatureValue[Profile->FeaturesNumber]=atoi(readvalue); | ||
1998 | Profile->FeaturesNumber++; | ||
1999 | } else if (mystrncasecmp(readvalue,"ScreenSaverNumber",0)) { | ||
2000 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_ScreenSaverNumber; | ||
2001 | sprintf(buffer,"Value%02i",num); | ||
2002 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
2003 | Profile->FeatureValue[Profile->FeaturesNumber]=atoi(readvalue); | ||
2004 | Profile->FeaturesNumber++; | ||
2005 | } else if (mystrncasecmp(readvalue,"CallerGroups",0)) { | ||
2006 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_CallerGroups; | ||
2007 | sprintf(buffer,"Value%02i",num); | ||
2008 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
2009 | for (j=0;j<5;j++) { | ||
2010 | Profile->CallerGroups[j]=false; | ||
2011 | if (strstr(readvalue,"1"+j)!=NULL) Profile->CallerGroups[j]=true; | ||
2012 | } | ||
2013 | Profile->FeaturesNumber++; | ||
2014 | } else if (mystrncasecmp(readvalue,"IncomingCallAlert",0)) { | ||
2015 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_CallAlert; | ||
2016 | unknown = false; | ||
2017 | } else if (mystrncasecmp(readvalue,"RingtoneVolume",0)) { | ||
2018 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_RingtoneVolume; | ||
2019 | unknown = false; | ||
2020 | } else if (mystrncasecmp(readvalue,"Vibrating",0)) { | ||
2021 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_Vibration; | ||
2022 | unknown = false; | ||
2023 | } else if (mystrncasecmp(readvalue,"MessageTone",0)) { | ||
2024 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_MessageTone; | ||
2025 | unknown = false; | ||
2026 | } else if (mystrncasecmp(readvalue,"KeypadTones",0)) { | ||
2027 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_KeypadTone; | ||
2028 | unknown = false; | ||
2029 | } else if (mystrncasecmp(readvalue,"WarningTones",0)) { | ||
2030 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_WarningTone; | ||
2031 | unknown = false; | ||
2032 | } else if (mystrncasecmp(readvalue,"ScreenSaver",0)) { | ||
2033 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_ScreenSaver; | ||
2034 | unknown = false; | ||
2035 | } else if (mystrncasecmp(readvalue,"ScreenSaverTimeout",0)) { | ||
2036 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_ScreenSaverTime; | ||
2037 | unknown = false; | ||
2038 | } else if (mystrncasecmp(readvalue,"AutomaticAnswer",0)) { | ||
2039 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_AutoAnswer; | ||
2040 | unknown = false; | ||
2041 | } else if (mystrncasecmp(readvalue,"Lights",0)) { | ||
2042 | Profile->FeatureID[Profile->FeaturesNumber]=Profile_Lights; | ||
2043 | unknown = false; | ||
2044 | } | ||
2045 | if (!unknown) { | ||
2046 | sprintf(buffer,"Value%02i",num); | ||
2047 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
2048 | if (mystrncasecmp(readvalue,"Level1",0)) { | ||
2049 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VOLUME_LEVEL1; | ||
2050 | if (Profile->FeatureID[Profile->FeaturesNumber]==Profile_KeypadTone) { | ||
2051 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_KEYPAD_LEVEL1; | ||
2052 | } | ||
2053 | } else if (mystrncasecmp(readvalue,"Level2",0)) { | ||
2054 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VOLUME_LEVEL2; | ||
2055 | if (Profile->FeatureID[Profile->FeaturesNumber]==Profile_KeypadTone) { | ||
2056 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_KEYPAD_LEVEL2; | ||
2057 | } | ||
2058 | } else if (mystrncasecmp(readvalue,"Level3",0)) { | ||
2059 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VOLUME_LEVEL3; | ||
2060 | if (Profile->FeatureID[Profile->FeaturesNumber]==Profile_KeypadTone) { | ||
2061 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_KEYPAD_LEVEL3; | ||
2062 | } | ||
2063 | } else if (mystrncasecmp(readvalue,"Level4",0)) { | ||
2064 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VOLUME_LEVEL4; | ||
2065 | } else if (mystrncasecmp(readvalue,"Level5",0)) { | ||
2066 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VOLUME_LEVEL5; | ||
2067 | } else if (mystrncasecmp(readvalue,"Off",0)) { | ||
2068 | switch (Profile->FeatureID[Profile->FeaturesNumber]) { | ||
2069 | case Profile_MessageTone: | ||
2070 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_MESSAGE_NOTONE; | ||
2071 | break; | ||
2072 | case Profile_AutoAnswer: | ||
2073 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_AUTOANSWER_OFF; | ||
2074 | break; | ||
2075 | case Profile_Lights: | ||
2076 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_LIGHTS_OFF; | ||
2077 | break; | ||
2078 | case Profile_ScreenSaver: | ||
2079 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_OFF; | ||
2080 | break; | ||
2081 | case Profile_WarningTone: | ||
2082 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_WARNING_OFF; | ||
2083 | break; | ||
2084 | case Profile_CallAlert: | ||
2085 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_CALLALERT_OFF; | ||
2086 | break; | ||
2087 | case Profile_Vibration: | ||
2088 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VIBRATION_OFF; | ||
2089 | break; | ||
2090 | default: | ||
2091 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_KEYPAD_OFF; | ||
2092 | break; | ||
2093 | } | ||
2094 | } else if (mystrncasecmp(readvalue,"Ringing",0)) { | ||
2095 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_CALLALERT_RINGING; | ||
2096 | } else if (mystrncasecmp(readvalue,"BeepOnce",0)) { | ||
2097 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_CALLALERT_BEEPONCE; | ||
2098 | if (Profile->FeatureID[Profile->FeaturesNumber]==Profile_MessageTone) { | ||
2099 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_MESSAGE_BEEPONCE; | ||
2100 | } | ||
2101 | } else if (mystrncasecmp(readvalue,"RingOnce",0)) { | ||
2102 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_CALLALERT_RINGONCE; | ||
2103 | } else if (mystrncasecmp(readvalue,"Ascending",0)) { | ||
2104 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_CALLALERT_ASCENDING; | ||
2105 | } else if (mystrncasecmp(readvalue,"CallerGroups",0)) { | ||
2106 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_CALLALERT_CALLERGROUPS; | ||
2107 | } else if (mystrncasecmp(readvalue,"Standard",0)) { | ||
2108 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_MESSAGE_STANDARD; | ||
2109 | } else if (mystrncasecmp(readvalue,"Special",0)) { | ||
2110 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_MESSAGE_SPECIAL; | ||
2111 | } else if (mystrncasecmp(readvalue,"Ascending",0)) { | ||
2112 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_MESSAGE_ASCENDING; | ||
2113 | } else if (mystrncasecmp(readvalue,"Personal",0)) { | ||
2114 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_MESSAGE_PERSONAL; | ||
2115 | } else if (mystrncasecmp(readvalue,"VibrateFirst",0)) { | ||
2116 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VIBRATION_FIRST; | ||
2117 | } else if (mystrncasecmp(readvalue,"Auto",0)) { | ||
2118 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_LIGHTS_AUTO; | ||
2119 | } else if (mystrncasecmp(readvalue,"5Seconds",0)) { | ||
2120 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_TIMEOUT_5SEC; | ||
2121 | } else if (mystrncasecmp(readvalue,"20Seconds",0)) { | ||
2122 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_TIMEOUT_20SEC; | ||
2123 | } else if (mystrncasecmp(readvalue,"1Minute",0)) { | ||
2124 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_TIMEOUT_1MIN; | ||
2125 | } else if (mystrncasecmp(readvalue,"2Minutes",0)) { | ||
2126 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_TIMEOUT_2MIN; | ||
2127 | } else if (mystrncasecmp(readvalue,"5Minutes",0)) { | ||
2128 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_TIMEOUT_5MIN; | ||
2129 | } else if (mystrncasecmp(readvalue,"10Minutes",0)) { | ||
2130 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_TIMEOUT_10MIN; | ||
2131 | } else if (mystrncasecmp(readvalue,"On",0)) { | ||
2132 | switch (Profile->FeatureID[Profile->FeaturesNumber]) { | ||
2133 | case Profile_AutoAnswer: | ||
2134 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_AUTOANSWER_ON; | ||
2135 | break; | ||
2136 | case Profile_WarningTone: | ||
2137 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_WARNING_ON; | ||
2138 | break; | ||
2139 | case Profile_ScreenSaver: | ||
2140 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_SAVER_ON; | ||
2141 | break; | ||
2142 | default: | ||
2143 | Profile->FeatureValue[Profile->FeaturesNumber]=PROFILE_VIBRATION_ON; | ||
2144 | break; | ||
2145 | } | ||
2146 | } else unknown = true; | ||
2147 | } | ||
2148 | if (!unknown) Profile->FeaturesNumber++; | ||
2149 | } | ||
2150 | } | ||
2151 | } | ||
2152 | |||
2153 | static void ReadFMStationEntry(INI_Section *file_info, char *section, GSM_FMStation *FMStation, bool UseUnicode) | ||
2154 | { | ||
2155 | unsigned char buffer[10000], *readvalue; | ||
2156 | |||
2157 | FMStation->Location = 0; | ||
2158 | FMStation->Frequency = 0; | ||
2159 | |||
2160 | sprintf(buffer,"Location"); | ||
2161 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
2162 | if (readvalue!=NULL) FMStation->Location = atoi(readvalue); | ||
2163 | |||
2164 | sprintf(buffer,"StationName"); | ||
2165 | ReadBackupText(file_info, section, buffer, FMStation->StationName,UseUnicode); | ||
2166 | |||
2167 | sprintf(buffer,"Frequency"); | ||
2168 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
2169 | if (readvalue!=NULL) StringToDouble(readvalue, &FMStation->Frequency); | ||
2170 | } | ||
2171 | |||
2172 | static void ReadGPRSPointEntry(INI_Section *file_info, char *section, GSM_GPRSAccessPoint *GPRSPoint, bool UseUnicode) | ||
2173 | { | ||
2174 | unsigned char buffer[10000], *readvalue; | ||
2175 | |||
2176 | GPRSPoint->Name[0] = 0; | ||
2177 | GPRSPoint->Name[1] = 0; | ||
2178 | GPRSPoint->URL[0] = 0; | ||
2179 | GPRSPoint->URL[1] = 0; | ||
2180 | GPRSPoint->Location = 0; | ||
2181 | |||
2182 | GPRSPoint->Active = false; | ||
2183 | sprintf(buffer,"Active"); | ||
2184 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
2185 | if (readvalue!=NULL) { | ||
2186 | if (mystrncasecmp(readvalue,"Yes",0)) GPRSPoint->Active = true; | ||
2187 | } | ||
2188 | |||
2189 | sprintf(buffer,"Location"); | ||
2190 | readvalue = ReadCFGText(file_info, section, buffer, UseUnicode); | ||
2191 | if (readvalue!=NULL) GPRSPoint->Location = atoi(readvalue); | ||
2192 | |||
2193 | sprintf(buffer,"Name"); | ||
2194 | ReadBackupText(file_info, section, buffer, GPRSPoint->Name,UseUnicode); | ||
2195 | |||
2196 | sprintf(buffer,"URL"); | ||
2197 | ReadBackupText(file_info, section, buffer, GPRSPoint->URL,UseUnicode); | ||
2198 | } | ||
2199 | |||
2200 | static void ReadNoteEntry(INI_Section *file_info, char *section, GSM_NoteEntry *Note, bool UseUnicode) | ||
2201 | { | ||
2202 | unsigned char buffer[100]; | ||
2203 | |||
2204 | sprintf(buffer,"Text"); | ||
2205 | ReadBackupText(file_info, section, buffer, Note->Text,UseUnicode); | ||
2206 | } | ||
2207 | |||
2208 | GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode) | ||
2209 | { | ||
2210 | INI_Section *file_info, *h; | ||
2211 | char buffer[100], *readvalue; | ||
2212 | int num; | ||
2213 | GSM_MemoryEntry PBK; | ||
2214 | bool found; | ||
2215 | |||
2216 | file_info = INI_ReadFile(FileName, UseUnicode); | ||
2217 | |||
2218 | sprintf(buffer,"Backup"); | ||
2219 | if (UseUnicode) EncodeUnicode(buffer,"Backup",6); | ||
2220 | |||
2221 | readvalue = ReadCFGText(file_info, buffer, "Format", UseUnicode); | ||
2222 | /* Did we read anything? */ | ||
2223 | if (readvalue == NULL) return ERR_FILENOTSUPPORTED; | ||
2224 | /* Is this format version supported ? */ | ||
2225 | if (strcmp(readvalue,"1.01")!=0 && strcmp(readvalue,"1.02")!=0 && | ||
2226 | strcmp(readvalue,"1.03")!=0) return ERR_FILENOTSUPPORTED; | ||
2227 | |||
2228 | readvalue = ReadCFGText(file_info, buffer, "IMEI", UseUnicode); | ||
2229 | if (readvalue!=NULL) strcpy(backup->IMEI,readvalue); | ||
2230 | readvalue = ReadCFGText(file_info, buffer, "Phone", UseUnicode); | ||
2231 | if (readvalue!=NULL) strcpy(backup->Model,readvalue); | ||
2232 | readvalue = ReadCFGText(file_info, buffer, "Creator", UseUnicode); | ||
2233 | if (readvalue!=NULL) strcpy(backup->Creator,readvalue); | ||
2234 | readvalue = ReadCFGText(file_info, buffer, "DateTime", UseUnicode); | ||
2235 | if (readvalue!=NULL) { | ||
2236 | ReadVCALDateTime(readvalue, &backup->DateTime); | ||
2237 | backup->DateTimeAvailable = true; | ||
2238 | } | ||
2239 | |||
2240 | sprintf(buffer,"Checksum"); | ||
2241 | if (UseUnicode) EncodeUnicode(buffer,"Checksum",8); | ||
2242 | readvalue = ReadCFGText(file_info, buffer, "MD5", UseUnicode); | ||
2243 | if (readvalue!=NULL) strcpy(backup->MD5Original,readvalue); | ||
2244 | |||
2245 | num = 0; | ||
2246 | for (h = file_info; h != NULL; h = h->Next) { | ||
2247 | found = false; | ||
2248 | if (UseUnicode) { | ||
2249 | EncodeUnicode(buffer,"Profile",7); | ||
2250 | if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true; | ||
2251 | } else { | ||
2252 | if (mystrncasecmp("Profile", h->SectionName, 7)) found = true; | ||
2253 | } | ||
2254 | if (found) { | ||
2255 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2256 | if (readvalue==NULL) break; | ||
2257 | if (num < GSM_BACKUP_MAX_PROFILES) { | ||
2258 | backup->Profiles[num] = malloc(sizeof(GSM_Profile)); | ||
2259 | if (backup->Profiles[num] == NULL) return ERR_MOREMEMORY; | ||
2260 | backup->Profiles[num + 1] = NULL; | ||
2261 | } else { | ||
2262 | dbgprintf("Increase GSM_BACKUP_MAX_PROFILES\n"); | ||
2263 | return ERR_MOREMEMORY; | ||
2264 | } | ||
2265 | ReadProfileEntry(file_info, h->SectionName, backup->Profiles[num], UseUnicode); | ||
2266 | num++; | ||
2267 | } | ||
2268 | } | ||
2269 | num = 0; | ||
2270 | for (h = file_info; h != NULL; h = h->Next) { | ||
2271 | found = false; | ||
2272 | if (UseUnicode) { | ||
2273 | EncodeUnicode(buffer,"PhonePBK",8); | ||
2274 | if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; | ||
2275 | } else { | ||
2276 | if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true; | ||
2277 | } | ||
2278 | if (found) { | ||
2279 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2280 | if (readvalue==NULL) break; | ||
2281 | if (num < GSM_BACKUP_MAX_PHONEPHONEBOOK) { | ||
2282 | backup->PhonePhonebook[num] = malloc(sizeof(GSM_MemoryEntry)); | ||
2283 | if (backup->PhonePhonebook[num] == NULL) return ERR_MOREMEMORY; | ||
2284 | backup->PhonePhonebook[num + 1] = NULL; | ||
2285 | } else { | ||
2286 | dbgprintf("Increase GSM_BACKUP_MAX_PHONEPHONEBOOK\n"); | ||
2287 | return ERR_MOREMEMORY; | ||
2288 | } | ||
2289 | backup->PhonePhonebook[num]->Location= atoi (readvalue); | ||
2290 | backup->PhonePhonebook[num]->MemoryType= MEM_ME; | ||
2291 | ReadPbkEntry(file_info, h->SectionName, backup->PhonePhonebook[num],UseUnicode); | ||
2292 | dbgprintf("number of entries = %i\n",backup->PhonePhonebook[num]->EntriesNum); | ||
2293 | num++; | ||
2294 | } | ||
2295 | } | ||
2296 | num = 0; | ||
2297 | while (0) { | ||
2298 | if (backup->PhonePhonebook[num] == NULL) break; | ||
2299 | if (backup->PhonePhonebook[num+1] != NULL) { | ||
2300 | if (backup->PhonePhonebook[num+1]->Location < backup->PhonePhonebook[num]->Location) { | ||
2301 | memcpy(&PBK,backup->PhonePhonebook[num+1],sizeof(GSM_MemoryEntry)); | ||
2302 | memcpy(backup->PhonePhonebook[num+1],backup->PhonePhonebook[num],sizeof(GSM_MemoryEntry)); | ||
2303 | memcpy(backup->PhonePhonebook[num],&PBK,sizeof(GSM_MemoryEntry)); | ||
2304 | num = 0; | ||
2305 | continue; | ||
2306 | } | ||
2307 | } | ||
2308 | num++; | ||
2309 | } | ||
2310 | num = 0; | ||
2311 | for (h = file_info; h != NULL; h = h->Next) { | ||
2312 | found = false; | ||
2313 | if (UseUnicode) { | ||
2314 | EncodeUnicode(buffer,"SIMPBK",6); | ||
2315 | if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true; | ||
2316 | } else { | ||
2317 | if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true; | ||
2318 | } | ||
2319 | if (found) { | ||
2320 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2321 | if (readvalue==NULL) break; | ||
2322 | if (num < GSM_BACKUP_MAX_SIMPHONEBOOK) { | ||
2323 | backup->SIMPhonebook[num] = malloc(sizeof(GSM_MemoryEntry)); | ||
2324 | if (backup->SIMPhonebook[num] == NULL) return ERR_MOREMEMORY; | ||
2325 | backup->SIMPhonebook[num + 1] = NULL; | ||
2326 | } else { | ||
2327 | dbgprintf("Increase GSM_BACKUP_MAX_SIMPHONEBOOK\n"); | ||
2328 | return ERR_MOREMEMORY; | ||
2329 | } | ||
2330 | backup->SIMPhonebook[num]->Location= atoi (readvalue); | ||
2331 | backup->SIMPhonebook[num]->MemoryType= MEM_SM; | ||
2332 | ReadPbkEntry(file_info, h->SectionName, backup->SIMPhonebook[num],UseUnicode); | ||
2333 | num++; | ||
2334 | } | ||
2335 | } | ||
2336 | num = 0; | ||
2337 | while (0) { | ||
2338 | if (backup->SIMPhonebook[num] == NULL) break; | ||
2339 | if (backup->SIMPhonebook[num+1] != NULL) { | ||
2340 | if (backup->SIMPhonebook[num+1]->Location < backup->SIMPhonebook[num]->Location) { | ||
2341 | memcpy(&PBK,backup->SIMPhonebook[num+1],sizeof(GSM_MemoryEntry)); | ||
2342 | memcpy(backup->SIMPhonebook[num+1],backup->SIMPhonebook[num],sizeof(GSM_MemoryEntry)); | ||
2343 | memcpy(backup->SIMPhonebook[num],&PBK,sizeof(GSM_MemoryEntry)); | ||
2344 | num = 0; | ||
2345 | continue; | ||
2346 | } | ||
2347 | } | ||
2348 | num++; | ||
2349 | } | ||
2350 | num = 0; | ||
2351 | for (h = file_info; h != NULL; h = h->Next) { | ||
2352 | found = false; | ||
2353 | if (UseUnicode) { | ||
2354 | EncodeUnicode(buffer,"Calendar",8); | ||
2355 | if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; | ||
2356 | } else { | ||
2357 | if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true; | ||
2358 | } | ||
2359 | if (found) { | ||
2360 | readvalue = ReadCFGText(file_info, h->SectionName, "Type", UseUnicode); | ||
2361 | if (readvalue==NULL) break; | ||
2362 | if (num < GSM_MAXCALENDARTODONOTES) { | ||
2363 | backup->Calendar[num] = malloc(sizeof(GSM_CalendarEntry)); | ||
2364 | if (backup->Calendar[num] == NULL) return ERR_MOREMEMORY; | ||
2365 | backup->Calendar[num + 1] = NULL; | ||
2366 | } else { | ||
2367 | dbgprintf("Increase GSM_MAXCALENDARTODONOTES\n"); | ||
2368 | return ERR_MOREMEMORY; | ||
2369 | } | ||
2370 | backup->Calendar[num]->Location = num + 1; | ||
2371 | ReadCalendarEntry(file_info, h->SectionName, backup->Calendar[num],UseUnicode); | ||
2372 | num++; | ||
2373 | } | ||
2374 | } | ||
2375 | num = 0; | ||
2376 | for (h = file_info; h != NULL; h = h->Next) { | ||
2377 | found = false; | ||
2378 | if (UseUnicode) { | ||
2379 | EncodeUnicode(buffer,"Caller",6); | ||
2380 | if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true; | ||
2381 | } else { | ||
2382 | if (mystrncasecmp("Caller", h->SectionName, 6)) found = true; | ||
2383 | } | ||
2384 | if (found) { | ||
2385 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2386 | if (readvalue==NULL) break; | ||
2387 | if (num < GSM_BACKUP_MAX_CALLER) { | ||
2388 | backup->CallerLogos[num] = malloc(sizeof(GSM_Bitmap)); | ||
2389 | if (backup->CallerLogos[num] == NULL) return ERR_MOREMEMORY; | ||
2390 | backup->CallerLogos[num + 1] = NULL; | ||
2391 | } else { | ||
2392 | dbgprintf("Increase GSM_BACKUP_MAX_CALLER\n"); | ||
2393 | return ERR_MOREMEMORY; | ||
2394 | } | ||
2395 | backup->CallerLogos[num]->Location = atoi (readvalue); | ||
2396 | ReadCallerEntry(file_info, h->SectionName, backup->CallerLogos[num],UseUnicode); | ||
2397 | num++; | ||
2398 | } | ||
2399 | } | ||
2400 | num = 0; | ||
2401 | for (h = file_info; h != NULL; h = h->Next) { | ||
2402 | found = false; | ||
2403 | if (UseUnicode) { | ||
2404 | EncodeUnicode(buffer,"SMSC",4); | ||
2405 | if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; | ||
2406 | } else { | ||
2407 | if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true; | ||
2408 | } | ||
2409 | if (found) { | ||
2410 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2411 | if (readvalue==NULL) break; | ||
2412 | if (num < GSM_BACKUP_MAX_SMSC) { | ||
2413 | backup->SMSC[num] = malloc(sizeof(GSM_SMSC)); | ||
2414 | if (backup->SMSC[num] == NULL) return ERR_MOREMEMORY; | ||
2415 | backup->SMSC[num + 1] = NULL; | ||
2416 | } else { | ||
2417 | dbgprintf("Increase GSM_BACKUP_MAX_SMSC\n"); | ||
2418 | return ERR_MOREMEMORY; | ||
2419 | } | ||
2420 | backup->SMSC[num]->Location = atoi (readvalue); | ||
2421 | ReadSMSCEntry(file_info, h->SectionName, backup->SMSC[num],UseUnicode); | ||
2422 | num++; | ||
2423 | } | ||
2424 | } | ||
2425 | num = 0; | ||
2426 | for (h = file_info; h != NULL; h = h->Next) { | ||
2427 | found = false; | ||
2428 | if (UseUnicode) { | ||
2429 | EncodeUnicode(buffer,"WAPBookmark",11); | ||
2430 | if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true; | ||
2431 | if (!found) { | ||
2432 | EncodeUnicode(buffer,"Bookmark",8); | ||
2433 | if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; | ||
2434 | } | ||
2435 | } else { | ||
2436 | if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true; | ||
2437 | if (!found) { | ||
2438 | if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true; | ||
2439 | } | ||
2440 | } | ||
2441 | if (found) { | ||
2442 | readvalue = ReadCFGText(file_info, h->SectionName, "URL", UseUnicode); | ||
2443 | if (readvalue==NULL) break; | ||
2444 | if (num < GSM_BACKUP_MAX_WAPBOOKMARK) { | ||
2445 | backup->WAPBookmark[num] = malloc(sizeof(GSM_WAPBookmark)); | ||
2446 | if (backup->WAPBookmark[num] == NULL) return ERR_MOREMEMORY; | ||
2447 | backup->WAPBookmark[num + 1] = NULL; | ||
2448 | } else { | ||
2449 | dbgprintf("Increase GSM_BACKUP_MAX_WAPBOOKMARK\n"); | ||
2450 | return ERR_MOREMEMORY; | ||
2451 | } | ||
2452 | backup->WAPBookmark[num]->Location = num + 1; | ||
2453 | ReadWAPBookmarkEntry(file_info, h->SectionName, backup->WAPBookmark[num],UseUnicode); | ||
2454 | num++; | ||
2455 | } | ||
2456 | } | ||
2457 | num = 0; | ||
2458 | for (h = file_info; h != NULL; h = h->Next) { | ||
2459 | found = false; | ||
2460 | if (UseUnicode) { | ||
2461 | EncodeUnicode(buffer,"WAPSettings",11); | ||
2462 | if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true; | ||
2463 | if (!found) { | ||
2464 | EncodeUnicode(buffer,"Settings",8); | ||
2465 | if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; | ||
2466 | } | ||
2467 | } else { | ||
2468 | if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true; | ||
2469 | if (!found) { | ||
2470 | if (mystrncasecmp("Settings", h->SectionName, 8)) found = true; | ||
2471 | } | ||
2472 | } | ||
2473 | if (found) { | ||
2474 | readvalue = ReadCFGText(file_info, h->SectionName, "Title00", UseUnicode); | ||
2475 | if (readvalue==NULL) break; | ||
2476 | if (num < GSM_BACKUP_MAX_WAPSETTINGS) { | ||
2477 | backup->WAPSettings[num] = malloc(sizeof(GSM_MultiWAPSettings)); | ||
2478 | if (backup->WAPSettings[num] == NULL) return ERR_MOREMEMORY; | ||
2479 | backup->WAPSettings[num + 1] = NULL; | ||
2480 | } else { | ||
2481 | dbgprintf("Increase GSM_BACKUP_MAX_WAPSETTINGS\n"); | ||
2482 | return ERR_MOREMEMORY; | ||
2483 | } | ||
2484 | backup->WAPSettings[num]->Location = num + 1; | ||
2485 | dbgprintf("reading wap settings\n"); | ||
2486 | ReadWAPSettingsEntry(file_info, h->SectionName, backup->WAPSettings[num],UseUnicode); | ||
2487 | num++; | ||
2488 | } | ||
2489 | } | ||
2490 | num = 0; | ||
2491 | for (h = file_info; h != NULL; h = h->Next) { | ||
2492 | found = false; | ||
2493 | if (UseUnicode) { | ||
2494 | EncodeUnicode(buffer,"MMSSettings",8); | ||
2495 | if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; | ||
2496 | } else { | ||
2497 | if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true; | ||
2498 | } | ||
2499 | if (found) { | ||
2500 | readvalue = ReadCFGText(file_info, h->SectionName, "Title00", UseUnicode); | ||
2501 | if (readvalue==NULL) break; | ||
2502 | if (num < GSM_BACKUP_MAX_MMSSETTINGS) { | ||
2503 | backup->MMSSettings[num] = malloc(sizeof(GSM_MultiWAPSettings)); | ||
2504 | if (backup->MMSSettings[num] == NULL) return ERR_MOREMEMORY; | ||
2505 | backup->MMSSettings[num + 1] = NULL; | ||
2506 | } else { | ||
2507 | dbgprintf("Increase GSM_BACKUP_MAX_MMSSETTINGS\n"); | ||
2508 | return ERR_MOREMEMORY; | ||
2509 | } | ||
2510 | backup->MMSSettings[num]->Location = num + 1; | ||
2511 | dbgprintf("reading mms settings\n"); | ||
2512 | ReadWAPSettingsEntry(file_info, h->SectionName, backup->MMSSettings[num],UseUnicode); | ||
2513 | num++; | ||
2514 | } | ||
2515 | } | ||
2516 | num = 0; | ||
2517 | for (h = file_info; h != NULL; h = h->Next) { | ||
2518 | found = false; | ||
2519 | if (UseUnicode) { | ||
2520 | EncodeUnicode(buffer,"Ringtone",8); | ||
2521 | if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; | ||
2522 | } else { | ||
2523 | if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true; | ||
2524 | } | ||
2525 | if (found) { | ||
2526 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2527 | if (readvalue==NULL) break; | ||
2528 | if (num < GSM_BACKUP_MAX_RINGTONES) { | ||
2529 | backup->Ringtone[num] = malloc(sizeof(GSM_Ringtone)); | ||
2530 | if (backup->Ringtone[num] == NULL) return ERR_MOREMEMORY; | ||
2531 | backup->Ringtone[num + 1] = NULL; | ||
2532 | } else { | ||
2533 | dbgprintf("Increase GSM_BACKUP_MAX_RINGTONES\n"); | ||
2534 | return ERR_MOREMEMORY; | ||
2535 | } | ||
2536 | ReadRingtoneEntry(file_info, h->SectionName, backup->Ringtone[num],UseUnicode); | ||
2537 | num++; | ||
2538 | } | ||
2539 | } | ||
2540 | num = 0; | ||
2541 | for (h = file_info; h != NULL; h = h->Next) { | ||
2542 | found = false; | ||
2543 | if (UseUnicode) { | ||
2544 | EncodeUnicode(buffer,"TODO",4); | ||
2545 | if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; | ||
2546 | } else { | ||
2547 | if (mystrncasecmp("TODO", h->SectionName, 4)) found = true; | ||
2548 | } | ||
2549 | if (found) { | ||
2550 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2551 | if (readvalue==NULL) break; | ||
2552 | if (num < GSM_MAXCALENDARTODONOTES) { | ||
2553 | backup->ToDo[num] = malloc(sizeof(GSM_ToDoEntry)); | ||
2554 | if (backup->ToDo[num] == NULL) return ERR_MOREMEMORY; | ||
2555 | backup->ToDo[num + 1] = NULL; | ||
2556 | } else { | ||
2557 | dbgprintf("Increase GSM_MAXCALENDARTODONOTES\n"); | ||
2558 | return ERR_MOREMEMORY; | ||
2559 | } | ||
2560 | backup->ToDo[num]->Location = num + 1; | ||
2561 | ReadToDoEntry(file_info, h->SectionName, backup->ToDo[num],UseUnicode); | ||
2562 | num++; | ||
2563 | } | ||
2564 | } | ||
2565 | sprintf(buffer,"Startup"); | ||
2566 | readvalue = ReadCFGText(file_info, buffer, "Text", UseUnicode); | ||
2567 | if (readvalue==NULL) { | ||
2568 | readvalue = ReadCFGText(file_info, buffer, "Width", UseUnicode); | ||
2569 | } | ||
2570 | if (readvalue!=NULL) { | ||
2571 | backup->StartupLogo = malloc(sizeof(GSM_Bitmap)); | ||
2572 | if (backup->StartupLogo == NULL) return ERR_MOREMEMORY; | ||
2573 | ReadStartupEntry(file_info, buffer, backup->StartupLogo,UseUnicode); | ||
2574 | } | ||
2575 | sprintf(buffer,"Operator"); | ||
2576 | readvalue = ReadCFGText(file_info, buffer, "Network", UseUnicode); | ||
2577 | if (readvalue!=NULL) { | ||
2578 | backup->OperatorLogo = malloc(sizeof(GSM_Bitmap)); | ||
2579 | if (backup->OperatorLogo == NULL) return ERR_MOREMEMORY; | ||
2580 | ReadOperatorEntry(file_info, buffer, backup->OperatorLogo,UseUnicode); | ||
2581 | } | ||
2582 | num = 0; | ||
2583 | for (h = file_info; h != NULL; h = h->Next) { | ||
2584 | found = false; | ||
2585 | if (UseUnicode) { | ||
2586 | EncodeUnicode(buffer,"FMStation",9); | ||
2587 | if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; | ||
2588 | } else { | ||
2589 | if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true; | ||
2590 | } | ||
2591 | if (found) { | ||
2592 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2593 | if (readvalue==NULL) break; | ||
2594 | if (num < GSM_BACKUP_MAX_FMSTATIONS) { | ||
2595 | backup->FMStation[num] = malloc(sizeof(GSM_FMStation)); | ||
2596 | if (backup->FMStation[num] == NULL) return ERR_MOREMEMORY; | ||
2597 | backup->FMStation[num + 1] = NULL; | ||
2598 | } else { | ||
2599 | dbgprintf("Increase GSM_BACKUP_MAX_FMSTATIONS\n"); | ||
2600 | return ERR_MOREMEMORY; | ||
2601 | } | ||
2602 | backup->FMStation[num]->Location = num + 1; | ||
2603 | ReadFMStationEntry(file_info, h->SectionName, backup->FMStation[num],UseUnicode); | ||
2604 | num++; | ||
2605 | } | ||
2606 | } | ||
2607 | num = 0; | ||
2608 | for (h = file_info; h != NULL; h = h->Next) { | ||
2609 | found = false; | ||
2610 | if (UseUnicode) { | ||
2611 | EncodeUnicode(buffer,"GPRSPoint",9); | ||
2612 | if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; | ||
2613 | } else { | ||
2614 | if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true; | ||
2615 | } | ||
2616 | if (found) { | ||
2617 | readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); | ||
2618 | if (readvalue==NULL) break; | ||
2619 | if (num < GSM_BACKUP_MAX_GPRSPOINT) { | ||
2620 | backup->GPRSPoint[num] = malloc(sizeof(GSM_GPRSAccessPoint)); | ||
2621 | if (backup->GPRSPoint[num] == NULL) return ERR_MOREMEMORY; | ||
2622 | backup->GPRSPoint[num + 1] = NULL; | ||
2623 | } else { | ||
2624 | dbgprintf("Increase GSM_BACKUP_MAX_GPRSPOINT\n"); | ||
2625 | return ERR_MOREMEMORY; | ||
2626 | } | ||
2627 | backup->GPRSPoint[num]->Location = num + 1; | ||
2628 | ReadGPRSPointEntry(file_info, h->SectionName, backup->GPRSPoint[num],UseUnicode); | ||
2629 | num++; | ||
2630 | } | ||
2631 | } | ||
2632 | num = 0; | ||
2633 | for (h = file_info; h != NULL; h = h->Next) { | ||
2634 | found = false; | ||
2635 | if (UseUnicode) { | ||
2636 | EncodeUnicode(buffer,"Note",4); | ||
2637 | if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; | ||
2638 | } else { | ||
2639 | if (mystrncasecmp("Note", h->SectionName, 4)) found = true; | ||
2640 | } | ||
2641 | if (found) { | ||
2642 | readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode); | ||
2643 | if (readvalue==NULL) break; | ||
2644 | if (num < GSM_BACKUP_MAX_NOTE) { | ||
2645 | backup->Note[num] = malloc(sizeof(GSM_NoteEntry)); | ||
2646 | if (backup->Note[num] == NULL) return ERR_MOREMEMORY; | ||
2647 | backup->Note[num + 1] = NULL; | ||
2648 | } else { | ||
2649 | dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n"); | ||
2650 | return ERR_MOREMEMORY; | ||
2651 | } | ||
2652 | ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode); | ||
2653 | num++; | ||
2654 | } | ||
2655 | } | ||
2656 | if (backup->MD5Original[0]!=0) { | ||
2657 | FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated); | ||
2658 | } | ||
2659 | |||
2660 | return ERR_NONE; | ||
2661 | } | ||
2662 | |||
2663 | /* ---------------------- backup files for SMS ----------------------------- */ | ||
2664 | |||
2665 | static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS) | ||
2666 | { | ||
2667 | unsigned char buffer[10000], *readvalue; | ||
2668 | |||
2669 | GSM_SetDefaultSMSData(SMS); | ||
2670 | |||
2671 | SMS->PDU = SMS_Submit; | ||
2672 | SMS->SMSC.Location = 0; | ||
2673 | sprintf(buffer,"SMSC"); | ||
2674 | ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false); | ||
2675 | sprintf(buffer,"ReplySMSC"); | ||
2676 | SMS->ReplyViaSameSMSC = false; | ||
2677 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2678 | if (readvalue!=NULL) { | ||
2679 | if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true; | ||
2680 | } | ||
2681 | sprintf(buffer,"Class"); | ||
2682 | SMS->Class = -1; | ||
2683 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2684 | if (readvalue!=NULL) SMS->Class = atoi(readvalue); | ||
2685 | sprintf(buffer,"Sent"); | ||
2686 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2687 | if (readvalue!=NULL) { | ||
2688 | ReadVCALDateTime(readvalue, &SMS->DateTime); | ||
2689 | SMS->PDU = SMS_Deliver; | ||
2690 | } | ||
2691 | sprintf(buffer,"RejectDuplicates"); | ||
2692 | SMS->RejectDuplicates = false; | ||
2693 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2694 | if (readvalue!=NULL) { | ||
2695 | if (mystrncasecmp(readvalue,"True",0)) SMS->RejectDuplicates = true; | ||
2696 | } | ||
2697 | sprintf(buffer,"ReplaceMessage"); | ||
2698 | SMS->ReplaceMessage = 0; | ||
2699 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2700 | if (readvalue!=NULL) SMS->ReplaceMessage = atoi(readvalue); | ||
2701 | sprintf(buffer,"MessageReference"); | ||
2702 | SMS->MessageReference = 0; | ||
2703 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2704 | if (readvalue!=NULL) SMS->MessageReference = atoi(readvalue); | ||
2705 | sprintf(buffer,"State"); | ||
2706 | SMS->State = SMS_UnRead; | ||
2707 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2708 | if (readvalue!=NULL) { | ||
2709 | if (mystrncasecmp(readvalue,"Read",0)) SMS->State = SMS_Read; | ||
2710 | else if (mystrncasecmp(readvalue,"Sent",0))SMS->State = SMS_Sent; | ||
2711 | else if (mystrncasecmp(readvalue,"UnSent",0))SMS->State = SMS_UnSent; | ||
2712 | } | ||
2713 | sprintf(buffer,"Number"); | ||
2714 | ReadBackupText(file_info, section, buffer, SMS->Number, false); | ||
2715 | sprintf(buffer,"Name"); | ||
2716 | ReadBackupText(file_info, section, buffer, SMS->Name, false); | ||
2717 | sprintf(buffer,"Length"); | ||
2718 | SMS->Length = 0; | ||
2719 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2720 | if (readvalue!=NULL) SMS->Length = atoi(readvalue); | ||
2721 | sprintf(buffer,"Coding"); | ||
2722 | SMS->Coding = SMS_Coding_Default; | ||
2723 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2724 | if (readvalue!=NULL) { | ||
2725 | if (mystrncasecmp(readvalue,"Unicode",0)) { | ||
2726 | SMS->Coding = SMS_Coding_Unicode; | ||
2727 | } else if (mystrncasecmp(readvalue,"8bit",0)) { | ||
2728 | SMS->Coding = SMS_Coding_8bit; | ||
2729 | } | ||
2730 | } | ||
2731 | ReadLinkedBackupText(file_info, section, "Text", buffer, false); | ||
2732 | DecodeHexBin (SMS->Text, buffer, strlen(buffer)); | ||
2733 | SMS->Text[strlen(buffer)/2]= 0; | ||
2734 | SMS->Text[strlen(buffer)/2+1] = 0; | ||
2735 | sprintf(buffer,"Folder"); | ||
2736 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2737 | if (readvalue!=NULL) SMS->Folder = atoi(readvalue); | ||
2738 | SMS->UDH.Type = UDH_NoUDH; | ||
2739 | SMS->UDH.Length = 0; | ||
2740 | SMS->UDH.ID8bit = -1; | ||
2741 | SMS->UDH.ID16bit= -1; | ||
2742 | SMS->UDH.PartNumber= -1; | ||
2743 | SMS->UDH.AllParts= -1; | ||
2744 | sprintf(buffer,"UDH"); | ||
2745 | readvalue = ReadCFGText(file_info, section, buffer, false); | ||
2746 | if (readvalue!=NULL) { | ||
2747 | DecodeHexBin (SMS->UDH.Text, readvalue, strlen(readvalue)); | ||
2748 | SMS->UDH.Length = strlen(readvalue)/2; | ||
2749 | GSM_DecodeUDHHeader(&SMS->UDH); | ||
2750 | } | ||
2751 | } | ||
2752 | |||
2753 | static GSM_Error GSM_ReadSMSBackupTextFile(char *FileName, GSM_SMS_Backup *backup) | ||
2754 | { | ||
2755 | INI_Section*file_info, *h; | ||
2756 | char *readvalue; | ||
2757 | int num; | ||
2758 | |||
2759 | backup->SMS[0] = NULL; | ||
2760 | |||
2761 | file_info = INI_ReadFile(FileName, false); | ||
2762 | |||
2763 | num = 0; | ||
2764 | for (h = file_info; h != NULL; h = h->Next) { | ||
2765 | if (mystrncasecmp("SMSBackup", h->SectionName, 9)) { | ||
2766 | readvalue = ReadCFGText(file_info, h->SectionName, "Number", false); | ||
2767 | if (readvalue==NULL) break; | ||
2768 | if (num < GSM_BACKUP_MAX_SMS) { | ||
2769 | backup->SMS[num] = malloc(sizeof(GSM_SMSMessage)); | ||
2770 | if (backup->SMS[num] == NULL) return ERR_MOREMEMORY; | ||
2771 | backup->SMS[num + 1] = NULL; | ||
2772 | } else { | ||
2773 | dbgprintf("Increase GSM_BACKUP_MAX_SMS\n"); | ||
2774 | return ERR_MOREMEMORY; | ||
2775 | } | ||
2776 | backup->SMS[num]->Location = num + 1; | ||
2777 | ReadSMSBackupEntry(file_info, h->SectionName, backup->SMS[num]); | ||
2778 | num++; | ||
2779 | } | ||
2780 | } | ||
2781 | return ERR_NONE; | ||
2782 | } | ||
2783 | |||
2784 | GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup) | ||
2785 | { | ||
2786 | FILE *file; | ||
2787 | |||
2788 | backup->SMS[0] = NULL; | ||
2789 | |||
2790 | file = fopen(FileName, "rb"); | ||
2791 | if (file == NULL) return(ERR_CANTOPENFILE); | ||
2792 | |||
2793 | fclose(file); | ||
2794 | |||
2795 | return GSM_ReadSMSBackupTextFile(FileName, backup); | ||
2796 | } | ||
2797 | |||
2798 | GSM_Error SaveSMSBackupTextFile(FILE *file, GSM_SMS_Backup *backup) | ||
2799 | { | ||
2800 | int i,w,current; | ||
2801 | unsigned char buffer[10000]; | ||
2802 | GSM_DateTimeDT; | ||
2803 | |||
2804 | fprintf(file,"\n# File created by Gammu (www.mwiacek.com) version %s\n",VERSION); | ||
2805 | GSM_GetCurrentDateTime (&DT); | ||
2806 | fprintf(file,"# Saved %s\n\n",OSDateTime(DT,false)); | ||
2807 | |||
2808 | i=0; | ||
2809 | while (backup->SMS[i]!=NULL) { | ||
2810 | fprintf(file,"[SMSBackup%03i]\n",i); | ||
2811 | switch (backup->SMS[i]->Coding) { | ||
2812 | case SMS_Coding_Unicode: | ||
2813 | case SMS_Coding_Default: | ||
2814 | sprintf(buffer,"%s",DecodeUnicodeString(backup->SMS[i]->Text)); | ||
2815 | fprintf(file,"#"); | ||
2816 | current = 0; | ||
2817 | for (w=0;w<(int)(strlen(buffer));w++) { | ||
2818 | switch (buffer[w]) { | ||
2819 | case 10: | ||
2820 | fprintf(file,"\n#"); | ||
2821 | current = 0; | ||
2822 | break; | ||
2823 | case 13: | ||
2824 | break; | ||
2825 | default: | ||
2826 | if (isprint(buffer[w])) { | ||
2827 | fprintf(file,"%c",buffer[w]); | ||
2828 | current ++; | ||
2829 | } | ||
2830 | if (current == 75) { | ||
2831 | fprintf(file,"\n#"); | ||
2832 | current = 0; | ||
2833 | } | ||
2834 | } | ||
2835 | } | ||
2836 | fprintf(file,"\n"); | ||
2837 | break; | ||
2838 | default: | ||
2839 | break; | ||
2840 | } | ||
2841 | if (backup->SMS[i]->PDU == SMS_Deliver) { | ||
2842 | SaveBackupText(file, "SMSC", backup->SMS[i]->SMSC.Number, false); | ||
2843 | if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"SMSCReply = true\n"); | ||
2844 | fprintf(file,"Sent"); | ||
2845 | SaveVCalDateTime(file,&backup->SMS[i]->DateTime, false); | ||
2846 | } | ||
2847 | fprintf(file,"State = "); | ||
2848 | switch (backup->SMS[i]->State) { | ||
2849 | case SMS_UnRead : fprintf(file,"UnRead\n");break; | ||
2850 | case SMS_Read : fprintf(file,"Read\n");break; | ||
2851 | case SMS_Sent : fprintf(file,"Sent\n");break; | ||
2852 | case SMS_UnSent : fprintf(file,"UnSent\n");break; | ||
2853 | } | ||
2854 | SaveBackupText(file, "Number", backup->SMS[i]->Number, false); | ||
2855 | SaveBackupText(file, "Name", backup->SMS[i]->Name, false); | ||
2856 | if (backup->SMS[i]->UDH.Type != UDH_NoUDH) { | ||
2857 | EncodeHexBin(buffer,backup->SMS[i]->UDH.Text,backup->SMS[i]->UDH.Length); | ||
2858 | fprintf(file,"UDH = %s\n",buffer); | ||
2859 | } | ||
2860 | switch (backup->SMS[i]->Coding) { | ||
2861 | case SMS_Coding_Unicode: | ||
2862 | case SMS_Coding_Default: | ||
2863 | EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length*2); | ||
2864 | break; | ||
2865 | default: | ||
2866 | EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length); | ||
2867 | break; | ||
2868 | } | ||
2869 | SaveLinkedBackupText(file, "Text", buffer, false); | ||
2870 | switch (backup->SMS[i]->Coding) { | ||
2871 | case SMS_Coding_Unicode : fprintf(file,"Coding = Unicode\n"); break; | ||
2872 | case SMS_Coding_Default : fprintf(file,"Coding = Default\n"); break; | ||
2873 | case SMS_Coding_8bit : fprintf(file,"Coding = 8bit\n"); break; | ||
2874 | } | ||
2875 | fprintf(file,"Folder = %i\n",backup->SMS[i]->Folder); | ||
2876 | fprintf(file,"Length = %i\n",backup->SMS[i]->Length); | ||
2877 | fprintf(file,"Class = %i\n",backup->SMS[i]->Class); | ||
2878 | fprintf(file,"ReplySMSC = "); | ||
2879 | if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"True\n"); else fprintf(file,"False\n"); | ||
2880 | fprintf(file,"RejectDuplicates = "); | ||
2881 | if (backup->SMS[i]->RejectDuplicates) fprintf(file,"True\n"); else fprintf(file,"False\n"); | ||
2882 | fprintf(file,"ReplaceMessage = %i\n",backup->SMS[i]->ReplaceMessage); | ||
2883 | fprintf(file,"MessageReference = %i\n",backup->SMS[i]->MessageReference); | ||
2884 | fprintf(file,"\n"); | ||
2885 | i++; | ||
2886 | } | ||
2887 | return ERR_NONE; | ||
2888 | } | ||
2889 | |||
2890 | GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup) | ||
2891 | { | ||
2892 | FILE *file; | ||
2893 | |||
2894 | file = fopen(FileName, "wb"); | ||
2895 | if (file == NULL) return(ERR_CANTOPENFILE); | ||
2896 | |||
2897 | SaveSMSBackupTextFile(file,backup); | ||
2898 | |||
2899 | fclose(file); | ||
2900 | |||
2901 | return ERR_NONE; | ||
2902 | } | ||
2903 | |||
2904 | #endif | ||
2905 | |||
2906 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
2907 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
2908 | */ | ||
diff --git a/gammu/emb/common/service/backup/backtext.h b/gammu/emb/common/service/backup/backtext.h new file mode 100644 index 0000000..a95bd89 --- a/dev/null +++ b/gammu/emb/common/service/backup/backtext.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_backtext_h | ||
4 | #define __gsm_backtext_h | ||
5 | |||
6 | #include "backgen.h" | ||
7 | |||
8 | #ifdef GSM_ENABLE_BACKUP | ||
9 | GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode); | ||
10 | GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode); | ||
11 | #endif | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
16 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
17 | */ | ||
diff --git a/gammu/emb/common/service/backup/backvcf.c b/gammu/emb/common/service/backup/backvcf.c new file mode 100644 index 0000000..761a81b --- a/dev/null +++ b/gammu/emb/common/service/backup/backvcf.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <ctype.h> | ||
5 | |||
6 | #include "../../phone/nokia/nfunc.h" | ||
7 | #include "../../phone/nokia/dct3/n7110.h" | ||
8 | #include "../../misc/coding/coding.h" | ||
9 | #include "../gsmlogo.h" | ||
10 | #include "../gsmmisc.h" | ||
11 | #include "backvcf.h" | ||
12 | |||
13 | #ifdef GSM_ENABLE_BACKUP | ||
14 | |||
15 | GSM_Error SaveVCard(char *FileName, GSM_Backup *backup) | ||
16 | { | ||
17 | int i, Length = 0; | ||
18 | unsigned char Buffer[1000]; | ||
19 | FILE *file; | ||
20 | |||
21 | file = fopen(FileName, "wb"); | ||
22 | if (file == NULL) return ERR_CANTOPENFILE; | ||
23 | |||
24 | i=0; | ||
25 | while (backup->PhonePhonebook[i]!=NULL) { | ||
26 | sprintf(Buffer, "%c%c",13,10); | ||
27 | fwrite(Buffer,1,2,file); | ||
28 | Length = 0; | ||
29 | GSM_EncodeVCARD(Buffer,&Length,backup->PhonePhonebook[i],true,Nokia_VCard21); | ||
30 | fwrite(Buffer,1,Length,file); | ||
31 | i++; | ||
32 | } | ||
33 | |||
34 | fclose(file); | ||
35 | return ERR_NONE; | ||
36 | } | ||
37 | |||
38 | GSM_Error LoadVCard(char *FileName, GSM_Backup *backup) | ||
39 | { | ||
40 | GSM_File File; | ||
41 | GSM_Error error; | ||
42 | GSM_MemoryEntry Pbk; | ||
43 | int numPbk = 0, Pos; | ||
44 | |||
45 | File.Buffer = NULL; | ||
46 | error = GSM_ReadFile(FileName, &File); | ||
47 | if (error != ERR_NONE) return error; | ||
48 | |||
49 | Pos = 0; | ||
50 | while (1) { | ||
51 | error = GSM_DecodeVCARD(File.Buffer, &Pos, &Pbk, Nokia_VCard21); | ||
52 | if (error == ERR_EMPTY) break; | ||
53 | if (error != ERR_NONE) return error; | ||
54 | if (numPbk < GSM_BACKUP_MAX_PHONEPHONEBOOK) { | ||
55 | backup->PhonePhonebook[numPbk] = malloc(sizeof(GSM_MemoryEntry)); | ||
56 | if (backup->PhonePhonebook[numPbk] == NULL) return ERR_MOREMEMORY; | ||
57 | backup->PhonePhonebook[numPbk + 1] = NULL; | ||
58 | } else { | ||
59 | dbgprintf("Increase GSM_BACKUP_MAX_PHONEPHONEBOOK\n"); | ||
60 | return ERR_MOREMEMORY; | ||
61 | } | ||
62 | memcpy(backup->PhonePhonebook[numPbk],&Pbk,sizeof(GSM_MemoryEntry)); | ||
63 | backup->PhonePhonebook[numPbk]->Location = numPbk + 1; | ||
64 | backup->PhonePhonebook[numPbk]->MemoryType = MEM_ME; | ||
65 | numPbk++; | ||
66 | } | ||
67 | |||
68 | return ERR_NONE; | ||
69 | } | ||
70 | |||
71 | #endif | ||
72 | |||
73 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
74 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
75 | */ | ||
diff --git a/gammu/emb/common/service/backup/backvcf.h b/gammu/emb/common/service/backup/backvcf.h new file mode 100644 index 0000000..8cbb6cf --- a/dev/null +++ b/gammu/emb/common/service/backup/backvcf.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_backvcf_h | ||
4 | #define __gsm_backvcf_h | ||
5 | |||
6 | #include "backgen.h" | ||
7 | |||
8 | #ifdef GSM_ENABLE_BACKUP | ||
9 | GSM_Error SaveVCard(char *FileName, GSM_Backup *backup); | ||
10 | GSM_Error LoadVCard(char *FileName, GSM_Backup *backup); | ||
11 | #endif | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
16 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
17 | */ | ||
diff --git a/gammu/emb/common/service/backup/backvcs.c b/gammu/emb/common/service/backup/backvcs.c new file mode 100644 index 0000000..332e718 --- a/dev/null +++ b/gammu/emb/common/service/backup/backvcs.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <ctype.h> | ||
5 | |||
6 | #include "../../phone/nokia/nfunc.h" | ||
7 | #include "../../phone/nokia/dct3/n7110.h" | ||
8 | #include "../../misc/coding/coding.h" | ||
9 | #include "../gsmlogo.h" | ||
10 | #include "../gsmmisc.h" | ||
11 | #include "backvcs.h" | ||
12 | |||
13 | #ifdef GSM_ENABLE_BACKUP | ||
14 | |||
15 | GSM_Error SaveVCalendar(char *FileName, GSM_Backup *backup) | ||
16 | { | ||
17 | int i, Length = 0; | ||
18 | unsigned char Buffer[1000]; | ||
19 | FILE *file; | ||
20 | |||
21 | file = fopen(FileName, "wb"); | ||
22 | if (file == NULL) return ERR_CANTOPENFILE; | ||
23 | |||
24 | Length=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | ||
25 | Length+=sprintf(Buffer+Length, "VERSION:1.0%c%c",13,10); | ||
26 | fwrite(Buffer,1,Length,file); | ||
27 | |||
28 | i=0; | ||
29 | while (backup->Calendar[i]!=NULL) { | ||
30 | sprintf(Buffer, "%c%c",13,10); | ||
31 | fwrite(Buffer,1,2,file); | ||
32 | Length = 0; | ||
33 | GSM_EncodeVCALENDAR(Buffer,&Length,backup->Calendar[i],false,Nokia_VCalendar); | ||
34 | fwrite(Buffer,1,Length,file); | ||
35 | i++; | ||
36 | } | ||
37 | i=0; | ||
38 | while (backup->ToDo[i]!=NULL) { | ||
39 | sprintf(Buffer, "%c%c",13,10); | ||
40 | fwrite(Buffer,1,2,file); | ||
41 | Length = 0; | ||
42 | GSM_EncodeVTODO(Buffer,&Length,backup->ToDo[i],false,Nokia_VToDo); | ||
43 | fwrite(Buffer,1,Length,file); | ||
44 | i++; | ||
45 | } | ||
46 | |||
47 | Length=sprintf(Buffer, "%c%cEND:VCALENDAR%c%c",13,10,13,10); | ||
48 | fwrite(Buffer,1,Length,file); | ||
49 | |||
50 | fclose(file); | ||
51 | return ERR_NONE; | ||
52 | } | ||
53 | |||
54 | GSM_Error LoadVCalendar(char *FileName, GSM_Backup *backup) | ||
55 | { | ||
56 | GSM_File File; | ||
57 | GSM_Error error; | ||
58 | GSM_CalendarEntryCalendar; | ||
59 | GSM_ToDoEntry ToDo; | ||
60 | int numCal = 0, numToDo = 0, Pos; | ||
61 | |||
62 | File.Buffer = NULL; | ||
63 | error = GSM_ReadFile(FileName, &File); | ||
64 | if (error != ERR_NONE) return error; | ||
65 | |||
66 | Pos = 0; | ||
67 | while (1) { | ||
68 | error = GSM_DecodeVCALENDAR_VTODO(File.Buffer, &Pos, &Calendar, &ToDo, Nokia_VCalendar, Nokia_VToDo); | ||
69 | if (error == ERR_EMPTY) break; | ||
70 | if (error != ERR_NONE) return error; | ||
71 | if (Calendar.EntriesNum != 0) { | ||
72 | if (numCal < GSM_MAXCALENDARTODONOTES) { | ||
73 | backup->Calendar[numCal] = malloc(sizeof(GSM_CalendarEntry)); | ||
74 | if (backup->Calendar[numCal] == NULL) return ERR_MOREMEMORY; | ||
75 | backup->Calendar[numCal + 1] = NULL; | ||
76 | } else { | ||
77 | dbgprintf("Increase GSM_MAXCALENDARTODONOTES\n"); | ||
78 | return ERR_MOREMEMORY; | ||
79 | } | ||
80 | memcpy(backup->Calendar[numCal],&Calendar,sizeof(GSM_CalendarEntry)); | ||
81 | backup->Calendar[numCal]->Location = numCal + 1; | ||
82 | numCal++; | ||
83 | } | ||
84 | if (ToDo.EntriesNum != 0) { | ||
85 | if (numToDo < GSM_MAXCALENDARTODONOTES) { | ||
86 | backup->ToDo[numToDo] = malloc(sizeof(GSM_ToDoEntry)); | ||
87 | if (backup->ToDo[numToDo] == NULL) return ERR_MOREMEMORY; | ||
88 | backup->ToDo[numToDo + 1] = NULL; | ||
89 | } else { | ||
90 | dbgprintf("Increase GSM_MAXCALENDARTODONOTES\n"); | ||
91 | return ERR_MOREMEMORY; | ||
92 | } | ||
93 | memcpy(backup->ToDo[numToDo],&ToDo,sizeof(GSM_ToDoEntry)); | ||
94 | backup->ToDo[numToDo]->Location = numToDo + 1; | ||
95 | numToDo++; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | return ERR_NONE; | ||
100 | } | ||
101 | |||
102 | #endif | ||
103 | |||
104 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
105 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
106 | */ | ||
diff --git a/gammu/emb/common/service/backup/backvcs.h b/gammu/emb/common/service/backup/backvcs.h new file mode 100644 index 0000000..f3331b5 --- a/dev/null +++ b/gammu/emb/common/service/backup/backvcs.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* (c) 2003 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_backvcs_h | ||
4 | #define __gsm_backvcs_h | ||
5 | |||
6 | #include "backgen.h" | ||
7 | |||
8 | #ifdef GSM_ENABLE_BACKUP | ||
9 | GSM_Error SaveVCalendar(char *FileName, GSM_Backup *backup); | ||
10 | GSM_Error LoadVCalendar(char *FileName, GSM_Backup *backup); | ||
11 | #endif | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
16 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
17 | */ | ||
diff --git a/gammu/emb/common/service/backup/gsmback.c b/gammu/emb/common/service/backup/gsmback.c new file mode 100644 index 0000000..91ac745 --- a/dev/null +++ b/gammu/emb/common/service/backup/gsmback.c | |||
@@ -0,0 +1,280 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek & Michal Cihar */ | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <ctype.h> | ||
5 | |||
6 | #include "../../phone/nokia/nfunc.h" | ||
7 | #include "../../phone/nokia/dct3/n7110.h" | ||
8 | #include "../../misc/coding/coding.h" | ||
9 | #include "../../misc/cfg.h" | ||
10 | #include "../gsmlogo.h" | ||
11 | #include "../gsmmisc.h" | ||
12 | #include "../gsmcal.h" | ||
13 | #include "gsmback.h" | ||
14 | #include "backtext.h" | ||
15 | #include "backldif.h" | ||
16 | #include "backlmb.h" | ||
17 | #include "backvcs.h" | ||
18 | #include "backvcf.h" | ||
19 | #include "backics.h" | ||
20 | |||
21 | #ifdef GSM_ENABLE_BACKUP | ||
22 | |||
23 | void GSM_FreeBackup(GSM_Backup *backup) | ||
24 | { | ||
25 | int i; | ||
26 | |||
27 | i=0; | ||
28 | while (backup->PhonePhonebook[i]!=NULL) { | ||
29 | free(backup->PhonePhonebook[i]); | ||
30 | backup->PhonePhonebook[i] = NULL; | ||
31 | i++; | ||
32 | } | ||
33 | i=0; | ||
34 | while (backup->SIMPhonebook[i]!=NULL) { | ||
35 | free(backup->SIMPhonebook[i]); | ||
36 | backup->SIMPhonebook[i] = NULL; | ||
37 | i++; | ||
38 | } | ||
39 | i=0; | ||
40 | while (backup->Calendar[i]!=NULL) { | ||
41 | free(backup->Calendar[i]); | ||
42 | backup->Calendar[i] = NULL; | ||
43 | i++; | ||
44 | } | ||
45 | i=0; | ||
46 | while (backup->CallerLogos[i]!=NULL) { | ||
47 | free(backup->CallerLogos[i]); | ||
48 | backup->CallerLogos[i] = NULL; | ||
49 | i++; | ||
50 | } | ||
51 | i=0; | ||
52 | while (backup->SMSC[i]!=NULL) { | ||
53 | free(backup->SMSC[i]); | ||
54 | backup->SMSC[i] = NULL; | ||
55 | i++; | ||
56 | } | ||
57 | i=0; | ||
58 | while (backup->WAPBookmark[i]!=NULL) { | ||
59 | free(backup->WAPBookmark[i]); | ||
60 | backup->WAPBookmark[i] = NULL; | ||
61 | i++; | ||
62 | } | ||
63 | i=0; | ||
64 | while (backup->WAPSettings[i]!=NULL) { | ||
65 | free(backup->WAPSettings[i]); | ||
66 | backup->WAPSettings[i] = NULL; | ||
67 | i++; | ||
68 | } | ||
69 | i=0; | ||
70 | while (backup->MMSSettings[i]!=NULL) { | ||
71 | free(backup->MMSSettings[i]); | ||
72 | backup->MMSSettings[i] = NULL; | ||
73 | i++; | ||
74 | } | ||
75 | i=0; | ||
76 | while (backup->Ringtone[i]!=NULL) { | ||
77 | free(backup->Ringtone[i]); | ||
78 | backup->Ringtone[i] = NULL; | ||
79 | i++; | ||
80 | } | ||
81 | i=0; | ||
82 | while (backup->ToDo[i]!=NULL) { | ||
83 | free(backup->ToDo[i]); | ||
84 | backup->ToDo[i] = NULL; | ||
85 | i++; | ||
86 | } | ||
87 | i=0; | ||
88 | while (backup->Profiles[i]!=NULL) { | ||
89 | free(backup->Profiles[i]); | ||
90 | backup->Profiles[i] = NULL; | ||
91 | i++; | ||
92 | } | ||
93 | i=0; | ||
94 | while (backup->FMStation[i]!=NULL) { | ||
95 | free(backup->FMStation[i]); | ||
96 | backup->FMStation[i] = NULL; | ||
97 | i++; | ||
98 | } | ||
99 | if (backup->StartupLogo!=NULL) { | ||
100 | free(backup->StartupLogo); | ||
101 | backup->StartupLogo = NULL; | ||
102 | } | ||
103 | if (backup->OperatorLogo!=NULL) { | ||
104 | free(backup->OperatorLogo); | ||
105 | backup->OperatorLogo = NULL; | ||
106 | } | ||
107 | i=0; | ||
108 | while (backup->GPRSPoint[i]!=NULL) { | ||
109 | free(backup->GPRSPoint[i]); | ||
110 | backup->GPRSPoint[i] = NULL; | ||
111 | i++; | ||
112 | } | ||
113 | i=0; | ||
114 | while (backup->Note[i]!=NULL) { | ||
115 | free(backup->Note[i]); | ||
116 | backup->Note[i] = NULL; | ||
117 | i++; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode) | ||
122 | { | ||
123 | if (strstr(FileName,".lmb")) { | ||
124 | return SaveLMB(FileName,backup); | ||
125 | } else if (strstr(FileName,".vcs")) { | ||
126 | return SaveVCalendar(FileName,backup); | ||
127 | } else if (strstr(FileName,".vcf")) { | ||
128 | return SaveVCard(FileName,backup); | ||
129 | } else if (strstr(FileName,".ldif")) { | ||
130 | return SaveLDIF(FileName,backup); | ||
131 | } else if (strstr(FileName,".ics")) { | ||
132 | return SaveICS(FileName,backup); | ||
133 | } else { | ||
134 | return SaveBackup(FileName,backup, UseUnicode); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup) | ||
139 | { | ||
140 | FILE *file; | ||
141 | unsigned charbuffer[300]; | ||
142 | |||
143 | file = fopen(FileName, "rb"); | ||
144 | if (file == NULL) return ERR_CANTOPENFILE; | ||
145 | fread(buffer, 1, 9, file); /* Read the header of the file. */ | ||
146 | fclose(file); | ||
147 | |||
148 | GSM_ClearBackup(backup); | ||
149 | |||
150 | /* Attempt to identify filetype */ | ||
151 | if (strstr(FileName,".vcs")) { | ||
152 | return LoadVCalendar(FileName,backup); | ||
153 | } else if (strstr(FileName,".vcf")) { | ||
154 | return LoadVCard(FileName,backup); | ||
155 | } else if (strstr(FileName,".ldif")) { | ||
156 | return LoadLDIF(FileName,backup); | ||
157 | } else if (strstr(FileName,".ics")) { | ||
158 | return LoadICS(FileName,backup); | ||
159 | } else if (memcmp(buffer, "LMB ",4)==0) { | ||
160 | return LoadLMB(FileName,backup); | ||
161 | } else if (buffer[0] == 0xFE && buffer[1] == 0xFF) { | ||
162 | return LoadBackup(FileName,backup,true); | ||
163 | } else if (buffer[0] == 0xFF && buffer[1] == 0xFE) { | ||
164 | return LoadBackup(FileName,backup,true); | ||
165 | } else { | ||
166 | return LoadBackup(FileName,backup,false); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | void GSM_ClearBackup(GSM_Backup *backup) | ||
171 | { | ||
172 | backup->PhonePhonebook[0] = NULL; | ||
173 | backup->SIMPhonebook[0] = NULL; | ||
174 | backup->Calendar[0] = NULL; | ||
175 | backup->CallerLogos[0] = NULL; | ||
176 | backup->SMSC [0] = NULL; | ||
177 | backup->WAPBookmark[0] = NULL; | ||
178 | backup->WAPSettings[0] = NULL; | ||
179 | backup->MMSSettings[0] = NULL; | ||
180 | backup->Ringtone[0] = NULL; | ||
181 | backup->Profiles[0] = NULL; | ||
182 | backup->ToDo [0] = NULL; | ||
183 | backup->GPRSPoint[0] = NULL; | ||
184 | backup->FMStation[0] = NULL; | ||
185 | backup->Note [0] = NULL; | ||
186 | backup->StartupLogo = NULL; | ||
187 | backup->OperatorLogo = NULL; | ||
188 | |||
189 | backup->Creator [0] = 0; | ||
190 | backup->IMEI [0] = 0; | ||
191 | backup->Model [0] = 0; | ||
192 | backup->DateTimeAvailable = false; | ||
193 | backup->MD5Original[0] = 0; | ||
194 | backup->MD5Calculated[0] = 0; | ||
195 | } | ||
196 | |||
197 | void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info) | ||
198 | { | ||
199 | info->UseUnicode= false; | ||
200 | info->IMEI = false; | ||
201 | info->Model = false; | ||
202 | info->DateTime = false; | ||
203 | info->PhonePhonebook = false; | ||
204 | info->SIMPhonebook = false; | ||
205 | info->ToDo = false; | ||
206 | info->Calendar = false; | ||
207 | info->CallerLogos = false; | ||
208 | info->SMSC = false; | ||
209 | info->WAPBookmark = false; | ||
210 | info->WAPSettings = false; | ||
211 | info->MMSSettings = false; | ||
212 | info->Ringtone = false; | ||
213 | info->StartupLogo = false; | ||
214 | info->OperatorLogo = false; | ||
215 | info->Profiles = false; | ||
216 | info->FMStation = false; | ||
217 | info->GPRSPoint = false; | ||
218 | info->Note = false; | ||
219 | |||
220 | if (strstr(FileName,".lmb")) { | ||
221 | info->PhonePhonebook = true; | ||
222 | info->SIMPhonebook = true; | ||
223 | info->CallerLogos = true; | ||
224 | info->StartupLogo = true; | ||
225 | } else if (strstr(FileName,".vcs")) { | ||
226 | info->ToDo = true; | ||
227 | info->Calendar = true; | ||
228 | } else if (strstr(FileName,".vcf")) { | ||
229 | info->PhonePhonebook= true; | ||
230 | } else if (strstr(FileName,".ics")) { | ||
231 | info->ToDo = true; | ||
232 | info->Calendar = true; | ||
233 | } else if (strstr(FileName,".ldif")) { | ||
234 | info->PhonePhonebook= true; | ||
235 | } else { | ||
236 | info->UseUnicode= true; | ||
237 | info->IMEI = true; | ||
238 | info->Model = true; | ||
239 | info->DateTime = true; | ||
240 | info->PhonePhonebook = true; | ||
241 | info->SIMPhonebook = true; | ||
242 | info->ToDo = true; | ||
243 | info->Calendar = true; | ||
244 | info->CallerLogos = true; | ||
245 | info->SMSC = true; | ||
246 | info->WAPBookmark = true; | ||
247 | info->WAPSettings = true; | ||
248 | info->MMSSettings = true; | ||
249 | info->Ringtone = true; | ||
250 | info->StartupLogo = true; | ||
251 | info->OperatorLogo = true; | ||
252 | info->Profiles = true; | ||
253 | info->FMStation = true; | ||
254 | info->GPRSPoint = true; | ||
255 | info->Note = true; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup) | ||
260 | { | ||
261 | GSM_GetBackupFormatFeatures(FileName, info); | ||
262 | |||
263 | if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook = false; | ||
264 | if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook = false; | ||
265 | if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar = false; | ||
266 | if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo = false; | ||
267 | if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark = false; | ||
268 | if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings = false; | ||
269 | if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings = false; | ||
270 | if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation = false; | ||
271 | if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint = false; | ||
272 | if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles = false; | ||
273 | /* .... */ | ||
274 | } | ||
275 | |||
276 | #endif | ||
277 | |||
278 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
279 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
280 | */ | ||
diff --git a/gammu/emb/common/service/backup/gsmback.h b/gammu/emb/common/service/backup/gsmback.h new file mode 100644 index 0000000..1fd99b0 --- a/dev/null +++ b/gammu/emb/common/service/backup/gsmback.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* (c) 2003-2004 by Marcin Wiacek */ | ||
2 | |||
3 | #ifndef __gsm_back_h | ||
4 | #define __gsm_back_h | ||
5 | |||
6 | #include "backgen.h" | ||
7 | |||
8 | #ifdef GSM_ENABLE_BACKUP | ||
9 | |||
10 | GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode); | ||
11 | GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup); | ||
12 | |||
13 | void GSM_ClearBackup (GSM_Backup *backup); | ||
14 | void GSM_FreeBackup (GSM_Backup *backup); | ||
15 | |||
16 | typedef struct { | ||
17 | bool UseUnicode; | ||
18 | |||
19 | bool IMEI; | ||
20 | bool Model; | ||
21 | bool DateTime; | ||
22 | bool ToDo; | ||
23 | bool PhonePhonebook; | ||
24 | bool SIMPhonebook; | ||
25 | bool Calendar; | ||
26 | bool CallerLogos; | ||
27 | bool SMSC; | ||
28 | bool WAPBookmark; | ||
29 | bool Profiles; | ||
30 | bool WAPSettings; | ||
31 | bool MMSSettings; | ||
32 | bool Ringtone; | ||
33 | bool StartupLogo; | ||
34 | bool OperatorLogo; | ||
35 | bool FMStation; | ||
36 | bool GPRSPoint; | ||
37 | bool Note; | ||
38 | } GSM_Backup_Info; | ||
39 | |||
40 | void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info); | ||
41 | void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup); | ||
42 | |||
43 | #endif | ||
44 | #endif | ||
45 | |||
46 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
47 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
48 | */ | ||