-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 4 | ||||
-rw-r--r-- | gammu/emb/gammu/gammu.c | 6 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 42 |
3 files changed, 36 insertions, 16 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index ddf9790..0ea8e06 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -1,512 +1,512 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | 4 | ||
5 | #include "gsmcal.h" | 5 | #include "gsmcal.h" |
6 | #include "gsmmisc.h" | 6 | #include "gsmmisc.h" |
7 | #include "../misc/coding/coding.h" | 7 | #include "../misc/coding/coding.h" |
8 | 8 | ||
9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) | 9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) |
10 | { | 10 | { |
11 | bool Past = true; | 11 | bool Past = true; |
12 | int i; | 12 | int i; |
13 | GSM_DateTimeDT; | 13 | GSM_DateTimeDT; |
14 | 14 | ||
15 | GSM_GetCurrentDateTime (&DT); | 15 | GSM_GetCurrentDateTime (&DT); |
16 | for (i = 0; i < note->EntriesNum; i++) { | 16 | for (i = 0; i < note->EntriesNum; i++) { |
17 | switch (note->Entries[i].EntryType) { | 17 | switch (note->Entries[i].EntryType) { |
18 | case CAL_RECURRANCE: | 18 | case CAL_RECURRANCE: |
19 | Past = false; | 19 | Past = false; |
20 | break; | 20 | break; |
21 | case CAL_START_DATETIME : | 21 | case CAL_START_DATETIME : |
22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; | 22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; |
23 | if (note->Entries[i].Date.Year == DT.Year && | 23 | if (note->Entries[i].Date.Year == DT.Year && |
24 | note->Entries[i].Date.Month > DT.Month) Past = false; | 24 | note->Entries[i].Date.Month > DT.Month) Past = false; |
25 | if (note->Entries[i].Date.Year == DT.Year && | 25 | if (note->Entries[i].Date.Year == DT.Year && |
26 | note->Entries[i].Date.Month == DT.Month && | 26 | note->Entries[i].Date.Month == DT.Month && |
27 | note->Entries[i].Date.Day > DT.Day) Past = false; | 27 | note->Entries[i].Date.Day > DT.Day) Past = false; |
28 | break; | 28 | break; |
29 | default: | 29 | default: |
30 | break; | 30 | break; |
31 | } | 31 | } |
32 | if (!Past) break; | 32 | if (!Past) break; |
33 | } | 33 | } |
34 | switch (note->Type) { | 34 | switch (note->Type) { |
35 | case GSM_CAL_BIRTHDAY: | 35 | case GSM_CAL_BIRTHDAY: |
36 | Past = false; | 36 | Past = false; |
37 | break; | 37 | break; |
38 | default: | 38 | default: |
39 | break; | 39 | break; |
40 | } | 40 | } |
41 | return Past; | 41 | return Past; |
42 | } | 42 | } |
43 | 43 | ||
44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) | 44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) |
45 | { | 45 | { |
46 | int i; | 46 | int i; |
47 | 47 | ||
48 | *Text = -1; | 48 | *Text = -1; |
49 | *Time = -1; | 49 | *Time = -1; |
50 | *Alarm = -1; | 50 | *Alarm = -1; |
51 | *Phone = -1; | 51 | *Phone = -1; |
52 | *Recurrance= -1; | 52 | *Recurrance= -1; |
53 | *EndTime= -1; | 53 | *EndTime= -1; |
54 | *Location= -1; | 54 | *Location= -1; |
55 | for (i = 0; i < entry->EntriesNum; i++) { | 55 | for (i = 0; i < entry->EntriesNum; i++) { |
56 | switch (entry->Entries[i].EntryType) { | 56 | switch (entry->Entries[i].EntryType) { |
57 | case CAL_START_DATETIME : | 57 | case CAL_START_DATETIME : |
58 | if (*Time == -1) *Time = i; | 58 | if (*Time == -1) *Time = i; |
59 | break; | 59 | break; |
60 | case CAL_END_DATETIME : | 60 | case CAL_END_DATETIME : |
61 | if (*EndTime == -1) *EndTime = i; | 61 | if (*EndTime == -1) *EndTime = i; |
62 | break; | 62 | break; |
63 | case CAL_ALARM_DATETIME : | 63 | case CAL_ALARM_DATETIME : |
64 | case CAL_SILENT_ALARM_DATETIME: | 64 | case CAL_SILENT_ALARM_DATETIME: |
65 | if (*Alarm == -1) *Alarm = i; | 65 | if (*Alarm == -1) *Alarm = i; |
66 | break; | 66 | break; |
67 | case CAL_RECURRANCE: | 67 | case CAL_RECURRANCE: |
68 | if (*Recurrance == -1) *Recurrance = i; | 68 | if (*Recurrance == -1) *Recurrance = i; |
69 | break; | 69 | break; |
70 | case CAL_TEXT: | 70 | case CAL_TEXT: |
71 | if (*Text == -1) *Text = i; | 71 | if (*Text == -1) *Text = i; |
72 | break; | 72 | break; |
73 | case CAL_PHONE: | 73 | case CAL_PHONE: |
74 | if (*Phone == -1) *Phone = i; | 74 | if (*Phone == -1) *Phone = i; |
75 | break; | 75 | break; |
76 | case CAL_LOCATION: | 76 | case CAL_LOCATION: |
77 | if (*Location == -1) *Location = i; | 77 | if (*Location == -1) *Location = i; |
78 | break; | 78 | break; |
79 | default: | 79 | default: |
80 | break; | 80 | break; |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) | 85 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) |
86 | { | 86 | { |
87 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; | 87 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; |
88 | char buffer[2000]; | 88 | char buffer[2000]; |
89 | 89 | ||
90 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); | 90 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); |
91 | 91 | ||
92 | if (header) { | 92 | if (header) { |
93 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 93 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
94 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 94 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
95 | } | 95 | } |
96 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); | 96 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); |
97 | 97 | ||
98 | if (Version == Nokia_VCalendar) { | 98 | if (Version == Nokia_VCalendar) { |
99 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 99 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
100 | switch (note->Type) { | 100 | switch (note->Type) { |
101 | case GSM_CAL_REMINDER: | 101 | case GSM_CAL_REMINDER: |
102 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); | 102 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); |
103 | break; | 103 | break; |
104 | case GSM_CAL_MEMO: | 104 | case GSM_CAL_MEMO: |
105 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 105 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
106 | break; | 106 | break; |
107 | case GSM_CAL_CALL: | 107 | case GSM_CAL_CALL: |
108 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 108 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
109 | break; | 109 | break; |
110 | case GSM_CAL_BIRTHDAY: | 110 | case GSM_CAL_BIRTHDAY: |
111 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); | 111 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); |
112 | break; | 112 | break; |
113 | case GSM_CAL_MEETING: | 113 | case GSM_CAL_MEETING: |
114 | default: | 114 | default: |
115 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); | 115 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | if (note->Type == GSM_CAL_CALL) { | 118 | if (note->Type == GSM_CAL_CALL) { |
119 | buffer[0] = 0; | 119 | buffer[0] = 0; |
120 | buffer[1] = 0; | 120 | buffer[1] = 0; |
121 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 121 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
122 | if (Text != -1) { | 122 | if (Text != -1) { |
123 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 123 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
124 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 124 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
125 | } | 125 | } |
126 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 126 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
127 | } else { | 127 | } else { |
128 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 128 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
129 | } | 129 | } |
130 | if (note->Type == GSM_CAL_MEETING && Location != -1) { | 130 | if (note->Type == GSM_CAL_MEETING && Location != -1) { |
131 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 131 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
132 | } | 132 | } |
133 | 133 | ||
134 | if (Time == -1) return ERR_UNKNOWN; | 134 | if (Time == -1) return ERR_UNKNOWN; |
135 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 135 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
136 | 136 | ||
137 | if (EndTime != -1) { | 137 | if (EndTime != -1) { |
138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
139 | } | 139 | } |
140 | 140 | ||
141 | if (Alarm != -1) { | 141 | if (Alarm != -1) { |
142 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 142 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
143 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 143 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
144 | } else { | 144 | } else { |
145 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 145 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | /* Birthday is known to be recurranced */ | 149 | /* Birthday is known to be recurranced */ |
150 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { | 150 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { |
151 | switch(note->Entries[Recurrance].Number/24) { | 151 | switch(note->Entries[Recurrance].Number/24) { |
152 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; | 152 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; |
153 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; | 153 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; |
154 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; | 154 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; |
155 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; | 155 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | } else if (Version == Siemens_VCalendar) { | 158 | } else if (Version == Siemens_VCalendar) { |
159 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 159 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
160 | switch (note->Type) { | 160 | switch (note->Type) { |
161 | case GSM_CAL_MEETING: | 161 | case GSM_CAL_MEETING: |
162 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 162 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
163 | break; | 163 | break; |
164 | case GSM_CAL_CALL: | 164 | case GSM_CAL_CALL: |
165 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 165 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
166 | break; | 166 | break; |
167 | case GSM_CAL_BIRTHDAY: | 167 | case GSM_CAL_BIRTHDAY: |
168 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); | 168 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); |
169 | break; | 169 | break; |
170 | case GSM_CAL_MEMO: | 170 | case GSM_CAL_MEMO: |
171 | default: | 171 | default: |
172 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 172 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
173 | break; | 173 | break; |
174 | } | 174 | } |
175 | 175 | ||
176 | if (Time == -1) return ERR_UNKNOWN; | 176 | if (Time == -1) return ERR_UNKNOWN; |
177 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 177 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
178 | 178 | ||
179 | if (Alarm != -1) { | 179 | if (Alarm != -1) { |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
181 | } | 181 | } |
182 | 182 | ||
183 | if (Recurrance != -1) { | 183 | if (Recurrance != -1) { |
184 | switch(note->Entries[Recurrance].Number/24) { | 184 | switch(note->Entries[Recurrance].Number/24) { |
185 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; | 185 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; |
186 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; | 186 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; |
187 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; | 187 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; |
188 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; | 188 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | if (note->Type == GSM_CAL_CALL) { | 192 | if (note->Type == GSM_CAL_CALL) { |
193 | buffer[0] = 0; | 193 | buffer[0] = 0; |
194 | buffer[1] = 0; | 194 | buffer[1] = 0; |
195 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 195 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
196 | if (Text != -1) { | 196 | if (Text != -1) { |
197 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 197 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
198 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 198 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
199 | } | 199 | } |
200 | SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); | 200 | SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); |
201 | } else { | 201 | } else { |
202 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); | 202 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); |
203 | } | 203 | } |
204 | } else if (Version == SonyEricsson_VCalendar) { | 204 | } else if (Version == SonyEricsson_VCalendar) { |
205 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 205 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
206 | switch (note->Type) { | 206 | switch (note->Type) { |
207 | case GSM_CAL_MEETING: | 207 | case GSM_CAL_MEETING: |
208 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 208 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
209 | break; | 209 | break; |
210 | case GSM_CAL_REMINDER: | 210 | case GSM_CAL_REMINDER: |
211 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); | 211 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); |
212 | break; | 212 | break; |
213 | case GSM_CAL_TRAVEL: | 213 | case GSM_CAL_TRAVEL: |
214 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); | 214 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); |
215 | break; | 215 | break; |
216 | case GSM_CAL_VACATION: | 216 | case GSM_CAL_VACATION: |
217 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); | 217 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); |
218 | break; | 218 | break; |
219 | case GSM_CAL_BIRTHDAY: | 219 | case GSM_CAL_BIRTHDAY: |
220 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); | 220 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); |
221 | break; | 221 | break; |
222 | case GSM_CAL_MEMO: | 222 | case GSM_CAL_MEMO: |
223 | default: | 223 | default: |
224 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 224 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (Time == -1) return ERR_UNKNOWN; | 228 | if (Time == -1) return ERR_UNKNOWN; |
229 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 229 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
230 | 230 | ||
231 | if (EndTime != -1) { | 231 | if (EndTime != -1) { |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
233 | } | 233 | } |
234 | 234 | ||
235 | if (Alarm != -1) { | 235 | if (Alarm != -1) { |
236 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 236 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
237 | } | 237 | } |
238 | 238 | ||
239 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 239 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
240 | 240 | ||
241 | if (Location != -1) { | 241 | if (Location != -1) { |
242 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 242 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 246 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
247 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); | 247 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); |
248 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 248 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
249 | 249 | ||
250 | return ERR_NONE; | 250 | return ERR_NONE; |
251 | } | 251 | } |
252 | 252 | ||
253 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) | 253 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) |
254 | { | 254 | { |
255 | int i; | 255 | int i; |
256 | 256 | ||
257 | *Text = -1; | 257 | *Text = -1; |
258 | *EndTime= -1; | 258 | *EndTime= -1; |
259 | *Alarm = -1; | 259 | *Alarm = -1; |
260 | *Completed= -1; | 260 | *Completed= -1; |
261 | *Phone = -1; | 261 | *Phone = -1; |
262 | for (i = 0; i < entry->EntriesNum; i++) { | 262 | for (i = 0; i < entry->EntriesNum; i++) { |
263 | switch (entry->Entries[i].EntryType) { | 263 | switch (entry->Entries[i].EntryType) { |
264 | case TODO_END_DATETIME : | 264 | case TODO_END_DATETIME : |
265 | if (*EndTime == -1) *EndTime = i; | 265 | if (*EndTime == -1) *EndTime = i; |
266 | break; | 266 | break; |
267 | case TODO_ALARM_DATETIME : | 267 | case TODO_ALARM_DATETIME : |
268 | case TODO_SILENT_ALARM_DATETIME: | 268 | case TODO_SILENT_ALARM_DATETIME: |
269 | if (*Alarm == -1) *Alarm = i; | 269 | if (*Alarm == -1) *Alarm = i; |
270 | break; | 270 | break; |
271 | case TODO_TEXT: | 271 | case TODO_TEXT: |
272 | if (*Text == -1) *Text = i; | 272 | if (*Text == -1) *Text = i; |
273 | break; | 273 | break; |
274 | case TODO_COMPLETED: | 274 | case TODO_COMPLETED: |
275 | if (*Completed == -1) *Completed = i; | 275 | if (*Completed == -1) *Completed = i; |
276 | break; | 276 | break; |
277 | case TODO_PHONE: | 277 | case TODO_PHONE: |
278 | if (*Phone == -1) *Phone = i; | 278 | if (*Phone == -1) *Phone = i; |
279 | break; | 279 | break; |
280 | default: | 280 | default: |
281 | break; | 281 | break; |
282 | } | 282 | } |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) | 286 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) |
287 | { | 287 | { |
288 | int Text, Alarm, Completed, EndTime, Phone; | 288 | int Text, Alarm, Completed, EndTime, Phone; |
289 | 289 | ||
290 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); | 290 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); |
291 | 291 | ||
292 | if (header) { | 292 | if (header) { |
293 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 293 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
294 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 294 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
295 | } | 295 | } |
296 | 296 | ||
297 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); | 297 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); |
298 | 298 | ||
299 | if (Version == Nokia_VToDo) { | 299 | if (Version == Nokia_VToDo) { |
300 | if (Text == -1) return ERR_UNKNOWN; | 300 | if (Text == -1) return ERR_UNKNOWN; |
301 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 301 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
302 | 302 | ||
303 | if (Completed == -1) { | 303 | if (Completed == -1) { |
304 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 304 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
305 | } else { | 305 | } else { |
306 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 306 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
307 | } | 307 | } |
308 | 308 | ||
309 | switch (note->Priority) { | 309 | switch (note->Priority) { |
310 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; | 310 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
311 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 311 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
312 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 312 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
313 | } | 313 | } |
314 | 314 | ||
315 | if (EndTime != -1) { | 315 | if (EndTime != -1) { |
316 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); | 316 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); |
317 | } | 317 | } |
318 | 318 | ||
319 | if (Alarm != -1) { | 319 | if (Alarm != -1) { |
320 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 320 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
321 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 321 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
322 | } else { | 322 | } else { |
323 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 323 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | } else if (Version == SonyEricsson_VToDo) { | 326 | } else if (Version == SonyEricsson_VToDo) { |
327 | if (Text == -1) return ERR_UNKNOWN; | 327 | if (Text == -1) return ERR_UNKNOWN; |
328 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 328 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
329 | 329 | ||
330 | if (Completed == -1) { | 330 | if (Completed == -1) { |
331 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 331 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
332 | } else { | 332 | } else { |
333 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 333 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
334 | } | 334 | } |
335 | 335 | ||
336 | switch (note->Priority) { | 336 | switch (note->Priority) { |
337 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; | 337 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
338 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 338 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
339 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 339 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
340 | } | 340 | } |
341 | 341 | ||
342 | if (Alarm != -1) { | 342 | if (Alarm != -1) { |
343 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 343 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 347 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
348 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); | 348 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); |
349 | 349 | ||
350 | if (header) { | 350 | if (header) { |
351 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 351 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
352 | } | 352 | } |
353 | return ERR_NONE; | 353 | return ERR_NONE; |
354 | } | 354 | } |
355 | 355 | ||
356 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) | 356 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) |
357 | { | 357 | { |
358 | unsigned char Line[2000],Buff[2000]; | 358 | unsigned char Line[2000],Buff[2000]; |
359 | int Level = 0; | 359 | int Level = 0; |
360 | 360 | ||
361 | Calendar->EntriesNum = 0; | 361 | Calendar->EntriesNum = 0; |
362 | ToDo->EntriesNum = 0; | 362 | ToDo->EntriesNum = 0; |
363 | 363 | ||
364 | while (1) { | 364 | while (1) { |
365 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); | 365 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); |
366 | if (strlen(Line) == 0) break; | 366 | if (strlen(Line) == 0) break; |
367 | switch (Level) { | 367 | switch (Level) { |
368 | case 0: | 368 | case 0: |
369 | if (strstr(Line,"BEGIN:VEVENT")) { | 369 | if (strstr(Line,"BEGIN:VEVENT")) { |
370 | Calendar->Type = GSM_CAL_MEMO; | 370 | Calendar->Type = GSM_CAL_MEMO; |
371 | Level = 1; | 371 | Level = 1; |
372 | } | 372 | } |
373 | if (strstr(Line,"BEGIN:VTODO")) { | 373 | if (strstr(Line,"BEGIN:VTODO")) { |
374 | ToDo->Priority = GSM_Priority_Medium; | 374 | ToDo->Priority = GSM_Priority_Medium; |
375 | Level = 2; | 375 | Level = 2; |
376 | } | 376 | } |
377 | break; | 377 | break; |
378 | case 1: /* Calendar note */ | 378 | case 1: /* Calendar note */ |
379 | if (strstr(Line,"END:VEVENT")) { | 379 | if (strstr(Line,"END:VEVENT")) { |
380 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; | 380 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; |
381 | return ERR_NONE; | 381 | return ERR_NONE; |
382 | } | 382 | } |
383 | Calendar->Type = GSM_CAL_MEETING; | 383 | Calendar->Type = GSM_CAL_MEETING; |
384 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; | 384 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; |
385 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE | 385 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE |
386 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE | 386 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE |
387 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE | 387 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE |
388 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; | 388 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; |
389 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; | 389 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; |
390 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; | 390 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; |
391 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; | 391 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; |
392 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; | 392 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; |
393 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; | 393 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; |
394 | if (strstr(Line,"RRULE:D1")) { | 394 | if (strstr(Line,"RRULE:D1")) { |
395 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 395 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
396 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; | 396 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; |
397 | Calendar->EntriesNum++; | 397 | Calendar->EntriesNum++; |
398 | } | 398 | } |
399 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { | 399 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { |
400 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 400 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
401 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; | 401 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; |
402 | Calendar->EntriesNum++; | 402 | Calendar->EntriesNum++; |
403 | } | 403 | } |
404 | if (strstr(Line,"RRULE:W2")) { | 404 | if (strstr(Line,"RRULE:W2")) { |
405 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 405 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
406 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; | 406 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; |
407 | Calendar->EntriesNum++; | 407 | Calendar->EntriesNum++; |
408 | } | 408 | } |
409 | if (strstr(Line,"RRULE:MD1")) { | 409 | if (strstr(Line,"RRULE:MD1")) { |
410 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 410 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
411 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; | 411 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; |
412 | Calendar->EntriesNum++; | 412 | Calendar->EntriesNum++; |
413 | } | 413 | } |
414 | if (strstr(Line,"RRULE:YD1")) { | 414 | if (strstr(Line,"RRULE:YD1")) { |
415 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 415 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
416 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | 416 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; |
417 | Calendar->EntriesNum++; | 417 | Calendar->EntriesNum++; |
418 | } | 418 | } |
419 | if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { | 419 | if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { |
420 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; | 420 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; |
421 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 421 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
422 | Calendar->EntriesNum++; | 422 | Calendar->EntriesNum++; |
423 | } | 423 | } |
424 | if (ReadVCALText(Line, "LOCATION", Buff)) { | 424 | if (ReadVCALText(Line, "LOCATION", Buff)) { |
425 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; | 425 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; |
426 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 426 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
427 | Calendar->EntriesNum++; | 427 | Calendar->EntriesNum++; |
428 | } | 428 | } |
429 | if (ReadVCALText(Line, "DTSTART", Buff)) { | 429 | if (ReadVCALText(Line, "DTSTART", Buff)) { |
430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; | 430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; |
431 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 431 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
432 | Calendar->EntriesNum++; | 432 | Calendar->EntriesNum++; |
433 | } | 433 | } |
434 | if (ReadVCALText(Line, "DTEND", Buff)) { | 434 | if (ReadVCALText(Line, "DTEND", Buff)) { |
435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; | 435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; |
436 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 436 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
437 | Calendar->EntriesNum++; | 437 | Calendar->EntriesNum++; |
438 | } | 438 | } |
439 | if (ReadVCALText(Line, "DALARM", Buff)) { | 439 | if (ReadVCALText(Line, "DALARM", Buff)) { |
440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; | 440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; |
441 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 441 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
442 | Calendar->EntriesNum++; | 442 | Calendar->EntriesNum++; |
443 | } | 443 | } |
444 | if (ReadVCALText(Line, "AALARM", Buff)) { | 444 | if (ReadVCALText(Line, "AALARM", Buff)) { |
445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; | 445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; |
446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
447 | Calendar->EntriesNum++; | 447 | Calendar->EntriesNum++; |
448 | } | 448 | } |
449 | break; | 449 | break; |
450 | case 2: /* ToDo note */ | 450 | case 2: /* ToDo note */ |
451 | if (strstr(Line,"END:VTODO")) { | 451 | if (strstr(Line,"END:VTODO")) { |
452 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; | 452 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; |
453 | return ERR_NONE; | 453 | return ERR_NONE; |
454 | } | 454 | } |
455 | if (ReadVCALText(Line, "DUE", Buff)) { | 455 | if (ReadVCALText(Line, "DUE", Buff)) { |
456 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; | 456 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; |
457 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 457 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
458 | ToDo->EntriesNum++; | 458 | ToDo->EntriesNum++; |
459 | } | 459 | } |
460 | if (ReadVCALText(Line, "DALARM", Buff)) { | 460 | if (ReadVCALText(Line, "DALARM", Buff)) { |
461 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; | 461 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; |
462 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 462 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
463 | ToDo->EntriesNum++; | 463 | ToDo->EntriesNum++; |
464 | } | 464 | } |
465 | if (ReadVCALText(Line, "AALARM", Buff)) { | 465 | if (ReadVCALText(Line, "AALARM", Buff)) { |
466 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | 466 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; |
467 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 467 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
468 | ToDo->EntriesNum++; | 468 | ToDo->EntriesNum++; |
469 | } | 469 | } |
470 | if (ReadVCALText(Line, "SUMMARY", Buff)) { | 470 | if (ReadVCALText(Line, "SUMMARY", Buff)) { |
471 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; | 471 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; |
472 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); | 472 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); |
473 | ToDo->EntriesNum++; | 473 | ToDo->EntriesNum++; |
474 | } | 474 | } |
475 | if (ReadVCALText(Line, "PRIORITY", Buff)) { | 475 | if (ReadVCALText(Line, "PRIORITY", Buff)) { |
476 | if (ToDoVer == SonyEricsson_VToDo) { | 476 | if (ToDoVer == SonyEricsson_VToDo) { |
477 | ToDo->Priority = GSM_Priority_Low; | 477 | ToDo->Priority = GSM_Priority_Medium; |
478 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 478 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
479 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 479 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
480 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); | 480 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); |
481 | } else if (ToDoVer == Nokia_VToDo) { | 481 | } else if (ToDoVer == Nokia_VToDo) { |
482 | ToDo->Priority = GSM_Priority_Low; | 482 | ToDo->Priority = GSM_Priority_Medium; |
483 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 483 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
484 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 484 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
485 | } | 485 | } |
486 | } | 486 | } |
487 | if (strstr(Line,"PERCENT-COMPLETE:100")) { | 487 | if (strstr(Line,"PERCENT-COMPLETE:100")) { |
488 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; | 488 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; |
489 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | 489 | ToDo->Entries[ToDo->EntriesNum].Number = 1; |
490 | ToDo->EntriesNum++; | 490 | ToDo->EntriesNum++; |
491 | } | 491 | } |
492 | break; | 492 | break; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||
496 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; | 496 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; |
497 | return ERR_NONE; | 497 | return ERR_NONE; |
498 | } | 498 | } |
499 | 499 | ||
500 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 500 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) |
501 | { | 501 | { |
502 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); | 502 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); |
503 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); | 503 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); |
504 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); | 504 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); |
505 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); | 505 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); |
506 | 506 | ||
507 | return ERR_NONE; | 507 | return ERR_NONE; |
508 | } | 508 | } |
509 | 509 | ||
510 | /* How should editor hadle tabs in this file? Add editor commands here. | 510 | /* How should editor hadle tabs in this file? Add editor commands here. |
511 | * vim: noexpandtab sw=8 ts=8 sts=8: | 511 | * vim: noexpandtab sw=8 ts=8 sts=8: |
512 | */ | 512 | */ |
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c index a3b93a8..997485a 100644 --- a/gammu/emb/gammu/gammu.c +++ b/gammu/emb/gammu/gammu.c | |||
@@ -3862,1597 +3862,1602 @@ static void SaveFile(int argc, char *argv[]) | |||
3862 | printmsg("Where is backup filename and location ?\n"); | 3862 | printmsg("Where is backup filename and location ?\n"); |
3863 | exit(-1); | 3863 | exit(-1); |
3864 | } | 3864 | } |
3865 | error=GSM_ReadBackupFile(argv[4],&Backup); | 3865 | error=GSM_ReadBackupFile(argv[4],&Backup); |
3866 | Print_Error(error); | 3866 | Print_Error(error); |
3867 | i = 0; | 3867 | i = 0; |
3868 | while (Backup.ToDo[i]!=NULL) { | 3868 | while (Backup.ToDo[i]!=NULL) { |
3869 | if (i == atoi(argv[5])-1) break; | 3869 | if (i == atoi(argv[5])-1) break; |
3870 | i++; | 3870 | i++; |
3871 | } | 3871 | } |
3872 | if (i != atoi(argv[5])-1) { | 3872 | if (i != atoi(argv[5])-1) { |
3873 | printmsg("ToDo note not found in file\n"); | 3873 | printmsg("ToDo note not found in file\n"); |
3874 | exit(-1); | 3874 | exit(-1); |
3875 | } | 3875 | } |
3876 | j = 0; | 3876 | j = 0; |
3877 | GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo); | 3877 | GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo); |
3878 | } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { | 3878 | } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { |
3879 | if (argc<6) { | 3879 | if (argc<6) { |
3880 | printmsg("Where is backup filename and location and memory type ?\n"); | 3880 | printmsg("Where is backup filename and location and memory type ?\n"); |
3881 | exit(-1); | 3881 | exit(-1); |
3882 | } | 3882 | } |
3883 | error=GSM_ReadBackupFile(argv[4],&Backup); | 3883 | error=GSM_ReadBackupFile(argv[4],&Backup); |
3884 | Print_Error(error); | 3884 | Print_Error(error); |
3885 | i = 0; | 3885 | i = 0; |
3886 | if (mystrncasecmp(argv[5],"SM",0)) { | 3886 | if (mystrncasecmp(argv[5],"SM",0)) { |
3887 | while (Backup.SIMPhonebook[i]!=NULL) { | 3887 | while (Backup.SIMPhonebook[i]!=NULL) { |
3888 | if (i == atoi(argv[6])-1) break; | 3888 | if (i == atoi(argv[6])-1) break; |
3889 | i++; | 3889 | i++; |
3890 | } | 3890 | } |
3891 | if (i != atoi(argv[6])-1) { | 3891 | if (i != atoi(argv[6])-1) { |
3892 | printmsg("Phonebook entry not found in file\n"); | 3892 | printmsg("Phonebook entry not found in file\n"); |
3893 | exit(-1); | 3893 | exit(-1); |
3894 | } | 3894 | } |
3895 | pbk = Backup.SIMPhonebook[i]; | 3895 | pbk = Backup.SIMPhonebook[i]; |
3896 | } else if (mystrncasecmp(argv[5],"ME",0)) { | 3896 | } else if (mystrncasecmp(argv[5],"ME",0)) { |
3897 | while (Backup.PhonePhonebook[i]!=NULL) { | 3897 | while (Backup.PhonePhonebook[i]!=NULL) { |
3898 | if (i == atoi(argv[6])-1) break; | 3898 | if (i == atoi(argv[6])-1) break; |
3899 | i++; | 3899 | i++; |
3900 | } | 3900 | } |
3901 | if (i != atoi(argv[6])-1) { | 3901 | if (i != atoi(argv[6])-1) { |
3902 | printmsg("Phonebook entry not found in file\n"); | 3902 | printmsg("Phonebook entry not found in file\n"); |
3903 | exit(-1); | 3903 | exit(-1); |
3904 | } | 3904 | } |
3905 | pbk = Backup.PhonePhonebook[i]; | 3905 | pbk = Backup.PhonePhonebook[i]; |
3906 | } else { | 3906 | } else { |
3907 | printmsg("Unknown memory type: \"%s\"\n",argv[5]); | 3907 | printmsg("Unknown memory type: \"%s\"\n",argv[5]); |
3908 | exit(-1); | 3908 | exit(-1); |
3909 | } | 3909 | } |
3910 | j = 0; | 3910 | j = 0; |
3911 | if (mystrncasecmp(argv[2],"VCARD10",0)) { | 3911 | if (mystrncasecmp(argv[2],"VCARD10",0)) { |
3912 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10); | 3912 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10); |
3913 | } else { | 3913 | } else { |
3914 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21); | 3914 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21); |
3915 | } | 3915 | } |
3916 | } else { | 3916 | } else { |
3917 | printmsg("What format of file (\"%s\") ?\n",argv[2]); | 3917 | printmsg("What format of file (\"%s\") ?\n",argv[2]); |
3918 | exit(-1); | 3918 | exit(-1); |
3919 | } | 3919 | } |
3920 | 3920 | ||
3921 | file = fopen(argv[3],"wb"); | 3921 | file = fopen(argv[3],"wb"); |
3922 | fwrite(Buffer,1,j,file); | 3922 | fwrite(Buffer,1,j,file); |
3923 | fclose(file); | 3923 | fclose(file); |
3924 | } | 3924 | } |
3925 | 3925 | ||
3926 | static void Backup(int argc, char *argv[]) | 3926 | static void Backup(int argc, char *argv[]) |
3927 | { | 3927 | { |
3928 | int i, used; | 3928 | int i, used; |
3929 | GSM_MemoryStatusMemStatus; | 3929 | GSM_MemoryStatusMemStatus; |
3930 | GSM_ToDoEntry ToDo; | 3930 | GSM_ToDoEntry ToDo; |
3931 | GSM_ToDoStatus ToDoStatus; | 3931 | GSM_ToDoStatus ToDoStatus; |
3932 | GSM_MemoryEntry Pbk; | 3932 | GSM_MemoryEntry Pbk; |
3933 | GSM_CalendarEntryNote; | 3933 | GSM_CalendarEntryNote; |
3934 | GSM_Bitmap Bitmap; | 3934 | GSM_Bitmap Bitmap; |
3935 | GSM_WAPBookmark Bookmark; | 3935 | GSM_WAPBookmark Bookmark; |
3936 | GSM_Profile Profile; | 3936 | GSM_Profile Profile; |
3937 | GSM_MultiWAPSettingsSettings; | 3937 | GSM_MultiWAPSettingsSettings; |
3938 | GSM_Ringtone Ringtone; | 3938 | GSM_Ringtone Ringtone; |
3939 | GSM_SMSC SMSC; | 3939 | GSM_SMSC SMSC; |
3940 | GSM_Backup Backup; | 3940 | GSM_Backup Backup; |
3941 | GSM_Backup_Info Info; | 3941 | GSM_Backup_Info Info; |
3942 | GSM_FMStation FMStation; | 3942 | GSM_FMStation FMStation; |
3943 | GSM_GPRSAccessPointGPRSPoint; | 3943 | GSM_GPRSAccessPointGPRSPoint; |
3944 | bool DoBackup; | 3944 | bool DoBackup; |
3945 | 3945 | ||
3946 | if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true; | 3946 | if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true; |
3947 | 3947 | ||
3948 | GSM_ClearBackup(&Backup); | 3948 | GSM_ClearBackup(&Backup); |
3949 | GSM_GetBackupFormatFeatures(argv[2],&Info); | 3949 | GSM_GetBackupFormatFeatures(argv[2],&Info); |
3950 | 3950 | ||
3951 | sprintf(Backup.Creator,"Gammu %s",VERSION); | 3951 | sprintf(Backup.Creator,"Gammu %s",VERSION); |
3952 | if (strlen(GetOS()) != 0) { | 3952 | if (strlen(GetOS()) != 0) { |
3953 | strcat(Backup.Creator+strlen(Backup.Creator),", "); | 3953 | strcat(Backup.Creator+strlen(Backup.Creator),", "); |
3954 | strcat(Backup.Creator+strlen(Backup.Creator),GetOS()); | 3954 | strcat(Backup.Creator+strlen(Backup.Creator),GetOS()); |
3955 | } | 3955 | } |
3956 | if (strlen(GetCompiler()) != 0) { | 3956 | if (strlen(GetCompiler()) != 0) { |
3957 | strcat(Backup.Creator+strlen(Backup.Creator),", "); | 3957 | strcat(Backup.Creator+strlen(Backup.Creator),", "); |
3958 | strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler()); | 3958 | strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler()); |
3959 | } | 3959 | } |
3960 | 3960 | ||
3961 | signal(SIGINT, interrupt); | 3961 | signal(SIGINT, interrupt); |
3962 | printmsgerr("Press Ctrl+C to break...\n"); | 3962 | printmsgerr("Press Ctrl+C to break...\n"); |
3963 | 3963 | ||
3964 | GSM_Init(true); | 3964 | GSM_Init(true); |
3965 | 3965 | ||
3966 | if (Info.UseUnicode) { | 3966 | if (Info.UseUnicode) { |
3967 | Info.UseUnicode=answer_yes("Use Unicode subformat of backup file"); | 3967 | Info.UseUnicode=answer_yes("Use Unicode subformat of backup file"); |
3968 | } | 3968 | } |
3969 | if (Info.DateTime) { | 3969 | if (Info.DateTime) { |
3970 | GSM_GetCurrentDateTime (&Backup.DateTime); | 3970 | GSM_GetCurrentDateTime (&Backup.DateTime); |
3971 | Backup.DateTimeAvailable=true; | 3971 | Backup.DateTimeAvailable=true; |
3972 | } | 3972 | } |
3973 | if (Info.Model) { | 3973 | if (Info.Model) { |
3974 | error=Phone->GetManufacturer(&s); | 3974 | error=Phone->GetManufacturer(&s); |
3975 | Print_Error(error); | 3975 | Print_Error(error); |
3976 | sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer); | 3976 | sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer); |
3977 | if (s.Phone.Data.ModelInfo->model[0]!=0) { | 3977 | if (s.Phone.Data.ModelInfo->model[0]!=0) { |
3978 | strcat(Backup.Model,s.Phone.Data.ModelInfo->model); | 3978 | strcat(Backup.Model,s.Phone.Data.ModelInfo->model); |
3979 | } else { | 3979 | } else { |
3980 | strcat(Backup.Model,s.Phone.Data.Model); | 3980 | strcat(Backup.Model,s.Phone.Data.Model); |
3981 | } | 3981 | } |
3982 | strcat(Backup.Model," "); | 3982 | strcat(Backup.Model," "); |
3983 | strcat(Backup.Model,s.Phone.Data.Version); | 3983 | strcat(Backup.Model,s.Phone.Data.Version); |
3984 | } | 3984 | } |
3985 | if (Info.IMEI) { | 3985 | if (Info.IMEI) { |
3986 | error=Phone->GetIMEI(&s); | 3986 | error=Phone->GetIMEI(&s); |
3987 | if (error != ERR_NOTSUPPORTED) { | 3987 | if (error != ERR_NOTSUPPORTED) { |
3988 | strcpy(Backup.IMEI, s.Phone.Data.IMEI); | 3988 | strcpy(Backup.IMEI, s.Phone.Data.IMEI); |
3989 | Print_Error(error); | 3989 | Print_Error(error); |
3990 | } else { | 3990 | } else { |
3991 | Backup.IMEI[0] = 0; | 3991 | Backup.IMEI[0] = 0; |
3992 | } | 3992 | } |
3993 | } | 3993 | } |
3994 | printf("\n"); | 3994 | printf("\n"); |
3995 | 3995 | ||
3996 | DoBackup = false; | 3996 | DoBackup = false; |
3997 | if (Info.PhonePhonebook) { | 3997 | if (Info.PhonePhonebook) { |
3998 | printmsg("Checking phone phonebook\n"); | 3998 | printmsg("Checking phone phonebook\n"); |
3999 | MemStatus.MemoryType = MEM_ME; | 3999 | MemStatus.MemoryType = MEM_ME; |
4000 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 4000 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
4001 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { | 4001 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { |
4002 | if (answer_yes(" Backup phone phonebook")) DoBackup = true; | 4002 | if (answer_yes(" Backup phone phonebook")) DoBackup = true; |
4003 | } | 4003 | } |
4004 | } | 4004 | } |
4005 | if (DoBackup) { | 4005 | if (DoBackup) { |
4006 | Pbk.MemoryType = MEM_ME; | 4006 | Pbk.MemoryType = MEM_ME; |
4007 | i = 1; | 4007 | i = 1; |
4008 | used = 0; | 4008 | used = 0; |
4009 | while (used != MemStatus.MemoryUsed) { | 4009 | while (used != MemStatus.MemoryUsed) { |
4010 | Pbk.Location = i; | 4010 | Pbk.Location = i; |
4011 | error=Phone->GetMemory(&s, &Pbk); | 4011 | error=Phone->GetMemory(&s, &Pbk); |
4012 | if (error != ERR_EMPTY) { | 4012 | if (error != ERR_EMPTY) { |
4013 | Print_Error(error); | 4013 | Print_Error(error); |
4014 | if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) { | 4014 | if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) { |
4015 | Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); | 4015 | Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); |
4016 | if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4016 | if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4017 | Backup.PhonePhonebook[used+1] = NULL; | 4017 | Backup.PhonePhonebook[used+1] = NULL; |
4018 | } else { | 4018 | } else { |
4019 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK"); | 4019 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK"); |
4020 | GSM_Terminate(); | 4020 | GSM_Terminate(); |
4021 | exit(-1); | 4021 | exit(-1); |
4022 | } | 4022 | } |
4023 | *Backup.PhonePhonebook[used]=Pbk; | 4023 | *Backup.PhonePhonebook[used]=Pbk; |
4024 | used++; | 4024 | used++; |
4025 | } | 4025 | } |
4026 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); | 4026 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); |
4027 | i++; | 4027 | i++; |
4028 | if (gshutdown) { | 4028 | if (gshutdown) { |
4029 | GSM_Terminate(); | 4029 | GSM_Terminate(); |
4030 | exit(0); | 4030 | exit(0); |
4031 | } | 4031 | } |
4032 | } | 4032 | } |
4033 | printmsgerr("\n"); | 4033 | printmsgerr("\n"); |
4034 | } | 4034 | } |
4035 | DoBackup = false; | 4035 | DoBackup = false; |
4036 | if (Info.SIMPhonebook) { | 4036 | if (Info.SIMPhonebook) { |
4037 | printmsg("Checking SIM phonebook\n"); | 4037 | printmsg("Checking SIM phonebook\n"); |
4038 | MemStatus.MemoryType = MEM_SM; | 4038 | MemStatus.MemoryType = MEM_SM; |
4039 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 4039 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
4040 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { | 4040 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { |
4041 | if (answer_yes(" Backup SIM phonebook")) DoBackup=true; | 4041 | if (answer_yes(" Backup SIM phonebook")) DoBackup=true; |
4042 | } | 4042 | } |
4043 | } | 4043 | } |
4044 | if (DoBackup) { | 4044 | if (DoBackup) { |
4045 | Pbk.MemoryType = MEM_SM; | 4045 | Pbk.MemoryType = MEM_SM; |
4046 | i = 1; | 4046 | i = 1; |
4047 | used = 0; | 4047 | used = 0; |
4048 | while (used != MemStatus.MemoryUsed) { | 4048 | while (used != MemStatus.MemoryUsed) { |
4049 | Pbk.Location = i; | 4049 | Pbk.Location = i; |
4050 | error=Phone->GetMemory(&s, &Pbk); | 4050 | error=Phone->GetMemory(&s, &Pbk); |
4051 | if (error != ERR_EMPTY) { | 4051 | if (error != ERR_EMPTY) { |
4052 | Print_Error(error); | 4052 | Print_Error(error); |
4053 | if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) { | 4053 | if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) { |
4054 | Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); | 4054 | Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); |
4055 | if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4055 | if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4056 | Backup.SIMPhonebook[used + 1] = NULL; | 4056 | Backup.SIMPhonebook[used + 1] = NULL; |
4057 | } else { | 4057 | } else { |
4058 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK"); | 4058 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK"); |
4059 | GSM_Terminate(); | 4059 | GSM_Terminate(); |
4060 | exit(-1); | 4060 | exit(-1); |
4061 | } | 4061 | } |
4062 | *Backup.SIMPhonebook[used]=Pbk; | 4062 | *Backup.SIMPhonebook[used]=Pbk; |
4063 | used++; | 4063 | used++; |
4064 | } | 4064 | } |
4065 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); | 4065 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); |
4066 | i++; | 4066 | i++; |
4067 | if (gshutdown) { | 4067 | if (gshutdown) { |
4068 | GSM_Terminate(); | 4068 | GSM_Terminate(); |
4069 | exit(0); | 4069 | exit(0); |
4070 | } | 4070 | } |
4071 | } | 4071 | } |
4072 | printmsgerr("\n"); | 4072 | printmsgerr("\n"); |
4073 | } | 4073 | } |
4074 | DoBackup = false; | 4074 | DoBackup = false; |
4075 | if (Info.Calendar) { | 4075 | if (Info.Calendar) { |
4076 | printmsg("Checking calendar\n"); | 4076 | printmsg("Checking calendar\n"); |
4077 | error=Phone->GetNextCalendar(&s,&Note,true); | 4077 | error=Phone->GetNextCalendar(&s,&Note,true); |
4078 | if (error==ERR_NONE) { | 4078 | if (error==ERR_NONE) { |
4079 | if (answer_yes(" Backup calendar notes")) DoBackup = true; | 4079 | if (answer_yes(" Backup calendar notes")) DoBackup = true; |
4080 | } | 4080 | } |
4081 | } | 4081 | } |
4082 | if (DoBackup) { | 4082 | if (DoBackup) { |
4083 | used = 0; | 4083 | used = 0; |
4084 | printmsgerr(" Reading : "); | 4084 | printmsgerr(" Reading : "); |
4085 | while (error == ERR_NONE) { | 4085 | while (error == ERR_NONE) { |
4086 | if (used < GSM_MAXCALENDARTODONOTES) { | 4086 | if (used < GSM_MAXCALENDARTODONOTES) { |
4087 | Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); | 4087 | Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); |
4088 | if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4088 | if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4089 | Backup.Calendar[used+1] = NULL; | 4089 | Backup.Calendar[used+1] = NULL; |
4090 | } else { | 4090 | } else { |
4091 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); | 4091 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); |
4092 | GSM_Terminate(); | 4092 | GSM_Terminate(); |
4093 | exit(-1); | 4093 | exit(-1); |
4094 | } | 4094 | } |
4095 | *Backup.Calendar[used]=Note; | 4095 | *Backup.Calendar[used]=Note; |
4096 | used ++; | 4096 | used ++; |
4097 | error=Phone->GetNextCalendar(&s,&Note,false); | 4097 | error=Phone->GetNextCalendar(&s,&Note,false); |
4098 | printmsgerr("*"); | 4098 | printmsgerr("*"); |
4099 | if (gshutdown) { | 4099 | if (gshutdown) { |
4100 | GSM_Terminate(); | 4100 | GSM_Terminate(); |
4101 | exit(0); | 4101 | exit(0); |
4102 | } | 4102 | } |
4103 | } | 4103 | } |
4104 | printmsgerr("\n"); | 4104 | printmsgerr("\n"); |
4105 | } | 4105 | } |
4106 | DoBackup = false; | 4106 | DoBackup = false; |
4107 | if (Info.ToDo) { | 4107 | if (Info.ToDo) { |
4108 | printmsg("Checking ToDo\n"); | 4108 | printmsg("Checking ToDo\n"); |
4109 | error=Phone->GetToDoStatus(&s,&ToDoStatus); | 4109 | error=Phone->GetToDoStatus(&s,&ToDoStatus); |
4110 | if (error == ERR_NONE && ToDoStatus.Used != 0) { | 4110 | if (error == ERR_NONE && ToDoStatus.Used != 0) { |
4111 | if (answer_yes(" Backup ToDo")) DoBackup = true; | 4111 | if (answer_yes(" Backup ToDo")) DoBackup = true; |
4112 | } | 4112 | } |
4113 | } | 4113 | } |
4114 | if (DoBackup) { | 4114 | if (DoBackup) { |
4115 | used = 0; | 4115 | used = 0; |
4116 | error=Phone->GetNextToDo(&s,&ToDo,true); | 4116 | error=Phone->GetNextToDo(&s,&ToDo,true); |
4117 | while (error == ERR_NONE) { | 4117 | while (error == ERR_NONE) { |
4118 | if (used < GSM_MAXCALENDARTODONOTES) { | 4118 | if (used < GSM_MAXCALENDARTODONOTES) { |
4119 | Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry)); | 4119 | Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry)); |
4120 | if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4120 | if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4121 | Backup.ToDo[used+1] = NULL; | 4121 | Backup.ToDo[used+1] = NULL; |
4122 | } else { | 4122 | } else { |
4123 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); | 4123 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); |
4124 | GSM_Terminate(); | 4124 | GSM_Terminate(); |
4125 | exit(-1); | 4125 | exit(-1); |
4126 | } | 4126 | } |
4127 | *Backup.ToDo[used]=ToDo; | 4127 | *Backup.ToDo[used]=ToDo; |
4128 | used ++; | 4128 | used ++; |
4129 | error=Phone->GetNextToDo(&s,&ToDo,false); | 4129 | error=Phone->GetNextToDo(&s,&ToDo,false); |
4130 | printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used); | 4130 | printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used); |
4131 | if (gshutdown) { | 4131 | if (gshutdown) { |
4132 | GSM_Terminate(); | 4132 | GSM_Terminate(); |
4133 | exit(0); | 4133 | exit(0); |
4134 | } | 4134 | } |
4135 | } | 4135 | } |
4136 | printmsgerr("\n"); | 4136 | printmsgerr("\n"); |
4137 | } | 4137 | } |
4138 | DoBackup = false; | 4138 | DoBackup = false; |
4139 | if (Info.CallerLogos) { | 4139 | if (Info.CallerLogos) { |
4140 | printmsg("Checking caller logos\n"); | 4140 | printmsg("Checking caller logos\n"); |
4141 | Bitmap.Type = GSM_CallerGroupLogo; | 4141 | Bitmap.Type = GSM_CallerGroupLogo; |
4142 | Bitmap.Location = 1; | 4142 | Bitmap.Location = 1; |
4143 | error=Phone->GetBitmap(&s,&Bitmap); | 4143 | error=Phone->GetBitmap(&s,&Bitmap); |
4144 | if (error == ERR_NONE) { | 4144 | if (error == ERR_NONE) { |
4145 | if (answer_yes(" Backup caller groups and logos")) DoBackup = true; | 4145 | if (answer_yes(" Backup caller groups and logos")) DoBackup = true; |
4146 | } | 4146 | } |
4147 | } | 4147 | } |
4148 | if (DoBackup) { | 4148 | if (DoBackup) { |
4149 | printmsgerr(" Reading : "); | 4149 | printmsgerr(" Reading : "); |
4150 | error = ERR_NONE; | 4150 | error = ERR_NONE; |
4151 | used = 0; | 4151 | used = 0; |
4152 | while (error == ERR_NONE) { | 4152 | while (error == ERR_NONE) { |
4153 | if (used < GSM_BACKUP_MAX_CALLER) { | 4153 | if (used < GSM_BACKUP_MAX_CALLER) { |
4154 | Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap)); | 4154 | Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap)); |
4155 | if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4155 | if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4156 | Backup.CallerLogos[used+1] = NULL; | 4156 | Backup.CallerLogos[used+1] = NULL; |
4157 | } else { | 4157 | } else { |
4158 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER"); | 4158 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER"); |
4159 | GSM_Terminate(); | 4159 | GSM_Terminate(); |
4160 | exit(-1); | 4160 | exit(-1); |
4161 | } | 4161 | } |
4162 | *Backup.CallerLogos[used] = Bitmap; | 4162 | *Backup.CallerLogos[used] = Bitmap; |
4163 | used ++; | 4163 | used ++; |
4164 | Bitmap.Location = used + 1; | 4164 | Bitmap.Location = used + 1; |
4165 | error=Phone->GetBitmap(&s,&Bitmap); | 4165 | error=Phone->GetBitmap(&s,&Bitmap); |
4166 | printmsgerr("*"); | 4166 | printmsgerr("*"); |
4167 | if (gshutdown) { | 4167 | if (gshutdown) { |
4168 | GSM_Terminate(); | 4168 | GSM_Terminate(); |
4169 | exit(0); | 4169 | exit(0); |
4170 | } | 4170 | } |
4171 | } | 4171 | } |
4172 | printmsgerr("\n"); | 4172 | printmsgerr("\n"); |
4173 | } | 4173 | } |
4174 | DoBackup = false; | 4174 | DoBackup = false; |
4175 | if (Info.SMSC) { | 4175 | if (Info.SMSC) { |
4176 | printmsg("Checking SMS profiles\n"); | 4176 | printmsg("Checking SMS profiles\n"); |
4177 | if (answer_yes(" Backup SMS profiles")) DoBackup = true; | 4177 | if (answer_yes(" Backup SMS profiles")) DoBackup = true; |
4178 | } | 4178 | } |
4179 | if (DoBackup) { | 4179 | if (DoBackup) { |
4180 | used = 0; | 4180 | used = 0; |
4181 | printmsgerr(" Reading: "); | 4181 | printmsgerr(" Reading: "); |
4182 | while (true) { | 4182 | while (true) { |
4183 | SMSC.Location = used + 1; | 4183 | SMSC.Location = used + 1; |
4184 | error = Phone->GetSMSC(&s,&SMSC); | 4184 | error = Phone->GetSMSC(&s,&SMSC); |
4185 | if (error != ERR_NONE) break; | 4185 | if (error != ERR_NONE) break; |
4186 | if (used < GSM_BACKUP_MAX_SMSC) { | 4186 | if (used < GSM_BACKUP_MAX_SMSC) { |
4187 | Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); | 4187 | Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); |
4188 | if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4188 | if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4189 | Backup.SMSC[used + 1] = NULL; | 4189 | Backup.SMSC[used + 1] = NULL; |
4190 | } else { | 4190 | } else { |
4191 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC"); | 4191 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC"); |
4192 | GSM_Terminate(); | 4192 | GSM_Terminate(); |
4193 | exit(-1); | 4193 | exit(-1); |
4194 | } | 4194 | } |
4195 | *Backup.SMSC[used]=SMSC; | 4195 | *Backup.SMSC[used]=SMSC; |
4196 | used++; | 4196 | used++; |
4197 | printmsgerr("*"); | 4197 | printmsgerr("*"); |
4198 | } | 4198 | } |
4199 | printmsgerr("\n"); | 4199 | printmsgerr("\n"); |
4200 | } | 4200 | } |
4201 | DoBackup = false; | 4201 | DoBackup = false; |
4202 | if (Info.StartupLogo) { | 4202 | if (Info.StartupLogo) { |
4203 | printmsg("Checking startup text\n"); | 4203 | printmsg("Checking startup text\n"); |
4204 | Bitmap.Type = GSM_WelcomeNote_Text; | 4204 | Bitmap.Type = GSM_WelcomeNote_Text; |
4205 | error = Phone->GetBitmap(&s,&Bitmap); | 4205 | error = Phone->GetBitmap(&s,&Bitmap); |
4206 | if (error == ERR_NONE) { | 4206 | if (error == ERR_NONE) { |
4207 | if (answer_yes(" Backup startup logo/text")) DoBackup = true; | 4207 | if (answer_yes(" Backup startup logo/text")) DoBackup = true; |
4208 | } | 4208 | } |
4209 | } | 4209 | } |
4210 | if (DoBackup) { | 4210 | if (DoBackup) { |
4211 | Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); | 4211 | Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); |
4212 | if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); | 4212 | if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); |
4213 | *Backup.StartupLogo = Bitmap; | 4213 | *Backup.StartupLogo = Bitmap; |
4214 | if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { | 4214 | if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { |
4215 | Bitmap.Type = GSM_StartupLogo; | 4215 | Bitmap.Type = GSM_StartupLogo; |
4216 | error = Phone->GetBitmap(&s,&Bitmap); | 4216 | error = Phone->GetBitmap(&s,&Bitmap); |
4217 | if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; | 4217 | if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; |
4218 | } | 4218 | } |
4219 | } | 4219 | } |
4220 | DoBackup = false; | 4220 | DoBackup = false; |
4221 | if (Info.OperatorLogo) { | 4221 | if (Info.OperatorLogo) { |
4222 | printmsg("Checking operator logo\n"); | 4222 | printmsg("Checking operator logo\n"); |
4223 | Bitmap.Type = GSM_OperatorLogo; | 4223 | Bitmap.Type = GSM_OperatorLogo; |
4224 | error=Phone->GetBitmap(&s,&Bitmap); | 4224 | error=Phone->GetBitmap(&s,&Bitmap); |
4225 | if (error == ERR_NONE) { | 4225 | if (error == ERR_NONE) { |
4226 | if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { | 4226 | if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { |
4227 | if (answer_yes(" Backup operator logo")) DoBackup = true; | 4227 | if (answer_yes(" Backup operator logo")) DoBackup = true; |
4228 | } | 4228 | } |
4229 | } | 4229 | } |
4230 | } | 4230 | } |
4231 | if (DoBackup) { | 4231 | if (DoBackup) { |
4232 | Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); | 4232 | Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); |
4233 | if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); | 4233 | if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); |
4234 | *Backup.OperatorLogo = Bitmap; | 4234 | *Backup.OperatorLogo = Bitmap; |
4235 | } | 4235 | } |
4236 | DoBackup = false; | 4236 | DoBackup = false; |
4237 | if (Info.MMSSettings) { | 4237 | if (Info.MMSSettings) { |
4238 | printmsg("Checking MMS settings\n"); | 4238 | printmsg("Checking MMS settings\n"); |
4239 | Settings.Location = 1; | 4239 | Settings.Location = 1; |
4240 | error=Phone->GetMMSSettings(&s,&Settings); | 4240 | error=Phone->GetMMSSettings(&s,&Settings); |
4241 | if (error==ERR_NONE) { | 4241 | if (error==ERR_NONE) { |
4242 | if (answer_yes(" Backup MMS settings")) DoBackup = true; | 4242 | if (answer_yes(" Backup MMS settings")) DoBackup = true; |
4243 | } | 4243 | } |
4244 | } | 4244 | } |
4245 | if (DoBackup) { | 4245 | if (DoBackup) { |
4246 | used = 0; | 4246 | used = 0; |
4247 | printmsgerr(" Reading : "); | 4247 | printmsgerr(" Reading : "); |
4248 | while (error == ERR_NONE) { | 4248 | while (error == ERR_NONE) { |
4249 | if (used < GSM_BACKUP_MAX_MMSSETTINGS) { | 4249 | if (used < GSM_BACKUP_MAX_MMSSETTINGS) { |
4250 | Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); | 4250 | Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); |
4251 | if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4251 | if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4252 | Backup.MMSSettings[used+1] = NULL; | 4252 | Backup.MMSSettings[used+1] = NULL; |
4253 | } else { | 4253 | } else { |
4254 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS"); | 4254 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS"); |
4255 | GSM_Terminate(); | 4255 | GSM_Terminate(); |
4256 | exit(-1); | 4256 | exit(-1); |
4257 | } | 4257 | } |
4258 | *Backup.MMSSettings[used]=Settings; | 4258 | *Backup.MMSSettings[used]=Settings; |
4259 | used ++; | 4259 | used ++; |
4260 | Settings.Location = used+1; | 4260 | Settings.Location = used+1; |
4261 | error=Phone->GetMMSSettings(&s,&Settings); | 4261 | error=Phone->GetMMSSettings(&s,&Settings); |
4262 | printmsgerr("*"); | 4262 | printmsgerr("*"); |
4263 | if (gshutdown) { | 4263 | if (gshutdown) { |
4264 | GSM_Terminate(); | 4264 | GSM_Terminate(); |
4265 | exit(0); | 4265 | exit(0); |
4266 | } | 4266 | } |
4267 | } | 4267 | } |
4268 | printmsgerr("\n"); | 4268 | printmsgerr("\n"); |
4269 | } | 4269 | } |
4270 | DoBackup = false; | 4270 | DoBackup = false; |
4271 | if (Info.WAPBookmark) { | 4271 | if (Info.WAPBookmark) { |
4272 | printmsg("Checking WAP bookmarks\n"); | 4272 | printmsg("Checking WAP bookmarks\n"); |
4273 | Bookmark.Location = 1; | 4273 | Bookmark.Location = 1; |
4274 | error=Phone->GetWAPBookmark(&s,&Bookmark); | 4274 | error=Phone->GetWAPBookmark(&s,&Bookmark); |
4275 | if (error==ERR_NONE) { | 4275 | if (error==ERR_NONE) { |
4276 | if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; | 4276 | if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; |
4277 | } | 4277 | } |
4278 | } | 4278 | } |
4279 | if (DoBackup) { | 4279 | if (DoBackup) { |
4280 | used = 0; | 4280 | used = 0; |
4281 | printmsgerr(" Reading : "); | 4281 | printmsgerr(" Reading : "); |
4282 | while (error == ERR_NONE) { | 4282 | while (error == ERR_NONE) { |
4283 | if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { | 4283 | if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { |
4284 | Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); | 4284 | Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); |
4285 | if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4285 | if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4286 | Backup.WAPBookmark[used+1] = NULL; | 4286 | Backup.WAPBookmark[used+1] = NULL; |
4287 | } else { | 4287 | } else { |
4288 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); | 4288 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); |
4289 | GSM_Terminate(); | 4289 | GSM_Terminate(); |
4290 | exit(-1); | 4290 | exit(-1); |
4291 | } | 4291 | } |
4292 | *Backup.WAPBookmark[used]=Bookmark; | 4292 | *Backup.WAPBookmark[used]=Bookmark; |
4293 | used ++; | 4293 | used ++; |
4294 | Bookmark.Location = used+1; | 4294 | Bookmark.Location = used+1; |
4295 | error=Phone->GetWAPBookmark(&s,&Bookmark); | 4295 | error=Phone->GetWAPBookmark(&s,&Bookmark); |
4296 | printmsgerr("*"); | 4296 | printmsgerr("*"); |
4297 | if (gshutdown) { | 4297 | if (gshutdown) { |
4298 | GSM_Terminate(); | 4298 | GSM_Terminate(); |
4299 | exit(0); | 4299 | exit(0); |
4300 | } | 4300 | } |
4301 | } | 4301 | } |
4302 | printmsgerr("\n"); | 4302 | printmsgerr("\n"); |
4303 | } | 4303 | } |
4304 | DoBackup = false; | 4304 | DoBackup = false; |
4305 | if (Info.WAPSettings) { | 4305 | if (Info.WAPSettings) { |
4306 | printmsg("Checking WAP settings\n"); | 4306 | printmsg("Checking WAP settings\n"); |
4307 | Settings.Location = 1; | 4307 | Settings.Location = 1; |
4308 | error=Phone->GetWAPSettings(&s,&Settings); | 4308 | error=Phone->GetWAPSettings(&s,&Settings); |
4309 | if (error==ERR_NONE) { | 4309 | if (error==ERR_NONE) { |
4310 | if (answer_yes(" Backup WAP settings")) DoBackup = true; | 4310 | if (answer_yes(" Backup WAP settings")) DoBackup = true; |
4311 | } | 4311 | } |
4312 | } | 4312 | } |
4313 | if (DoBackup) { | 4313 | if (DoBackup) { |
4314 | used = 0; | 4314 | used = 0; |
4315 | printmsgerr(" Reading : "); | 4315 | printmsgerr(" Reading : "); |
4316 | while (error == ERR_NONE) { | 4316 | while (error == ERR_NONE) { |
4317 | if (used < GSM_BACKUP_MAX_WAPSETTINGS) { | 4317 | if (used < GSM_BACKUP_MAX_WAPSETTINGS) { |
4318 | Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); | 4318 | Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); |
4319 | if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4319 | if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4320 | Backup.WAPSettings[used+1] = NULL; | 4320 | Backup.WAPSettings[used+1] = NULL; |
4321 | } else { | 4321 | } else { |
4322 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); | 4322 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); |
4323 | GSM_Terminate(); | 4323 | GSM_Terminate(); |
4324 | exit(-1); | 4324 | exit(-1); |
4325 | } | 4325 | } |
4326 | *Backup.WAPSettings[used]=Settings; | 4326 | *Backup.WAPSettings[used]=Settings; |
4327 | used ++; | 4327 | used ++; |
4328 | Settings.Location = used+1; | 4328 | Settings.Location = used+1; |
4329 | error=Phone->GetWAPSettings(&s,&Settings); | 4329 | error=Phone->GetWAPSettings(&s,&Settings); |
4330 | printmsgerr("*"); | 4330 | printmsgerr("*"); |
4331 | if (gshutdown) { | 4331 | if (gshutdown) { |
4332 | GSM_Terminate(); | 4332 | GSM_Terminate(); |
4333 | exit(0); | 4333 | exit(0); |
4334 | } | 4334 | } |
4335 | } | 4335 | } |
4336 | printmsgerr("\n"); | 4336 | printmsgerr("\n"); |
4337 | } | 4337 | } |
4338 | DoBackup = false; | 4338 | DoBackup = false; |
4339 | if (Info.Ringtone) { | 4339 | if (Info.Ringtone) { |
4340 | printmsg("Checking user ringtones\n"); | 4340 | printmsg("Checking user ringtones\n"); |
4341 | Ringtone.Location = 1; | 4341 | Ringtone.Location = 1; |
4342 | Ringtone.Format = 0; | 4342 | Ringtone.Format = 0; |
4343 | error=Phone->GetRingtone(&s,&Ringtone,false); | 4343 | error=Phone->GetRingtone(&s,&Ringtone,false); |
4344 | if (error==ERR_EMPTY || error == ERR_NONE) { | 4344 | if (error==ERR_EMPTY || error == ERR_NONE) { |
4345 | if (answer_yes(" Backup user ringtones")) DoBackup = true; | 4345 | if (answer_yes(" Backup user ringtones")) DoBackup = true; |
4346 | } | 4346 | } |
4347 | } | 4347 | } |
4348 | if (DoBackup) { | 4348 | if (DoBackup) { |
4349 | used = 0; | 4349 | used = 0; |
4350 | i= 1; | 4350 | i= 1; |
4351 | printmsgerr(" Reading : "); | 4351 | printmsgerr(" Reading : "); |
4352 | while (error == ERR_NONE || error == ERR_EMPTY) { | 4352 | while (error == ERR_NONE || error == ERR_EMPTY) { |
4353 | if (error == ERR_NONE) { | 4353 | if (error == ERR_NONE) { |
4354 | if (used < GSM_BACKUP_MAX_RINGTONES) { | 4354 | if (used < GSM_BACKUP_MAX_RINGTONES) { |
4355 | Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); | 4355 | Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); |
4356 | if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4356 | if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4357 | Backup.Ringtone[used+1] = NULL; | 4357 | Backup.Ringtone[used+1] = NULL; |
4358 | } else { | 4358 | } else { |
4359 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES"); | 4359 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES"); |
4360 | GSM_Terminate(); | 4360 | GSM_Terminate(); |
4361 | exit(-1); | 4361 | exit(-1); |
4362 | } | 4362 | } |
4363 | *Backup.Ringtone[used]=Ringtone; | 4363 | *Backup.Ringtone[used]=Ringtone; |
4364 | used ++; | 4364 | used ++; |
4365 | } | 4365 | } |
4366 | i++; | 4366 | i++; |
4367 | Ringtone.Location = i; | 4367 | Ringtone.Location = i; |
4368 | Ringtone.Format = 0; | 4368 | Ringtone.Format = 0; |
4369 | error=Phone->GetRingtone(&s,&Ringtone,false); | 4369 | error=Phone->GetRingtone(&s,&Ringtone,false); |
4370 | printmsgerr("*"); | 4370 | printmsgerr("*"); |
4371 | if (gshutdown) { | 4371 | if (gshutdown) { |
4372 | GSM_Terminate(); | 4372 | GSM_Terminate(); |
4373 | exit(0); | 4373 | exit(0); |
4374 | } | 4374 | } |
4375 | } | 4375 | } |
4376 | printmsgerr("\n"); | 4376 | printmsgerr("\n"); |
4377 | } | 4377 | } |
4378 | DoBackup = false; | 4378 | DoBackup = false; |
4379 | if (Info.Profiles) { | 4379 | if (Info.Profiles) { |
4380 | printmsg("Checking phone profiles\n"); | 4380 | printmsg("Checking phone profiles\n"); |
4381 | Profile.Location = 1; | 4381 | Profile.Location = 1; |
4382 | error = Phone->GetProfile(&s,&Profile); | 4382 | error = Phone->GetProfile(&s,&Profile); |
4383 | if (error == ERR_NONE) { | 4383 | if (error == ERR_NONE) { |
4384 | if (answer_yes(" Backup phone profiles")) DoBackup = true; | 4384 | if (answer_yes(" Backup phone profiles")) DoBackup = true; |
4385 | } | 4385 | } |
4386 | } | 4386 | } |
4387 | if (DoBackup) { | 4387 | if (DoBackup) { |
4388 | used = 0; | 4388 | used = 0; |
4389 | printmsgerr(" Reading: "); | 4389 | printmsgerr(" Reading: "); |
4390 | while (true) { | 4390 | while (true) { |
4391 | Profile.Location = used + 1; | 4391 | Profile.Location = used + 1; |
4392 | error = Phone->GetProfile(&s,&Profile); | 4392 | error = Phone->GetProfile(&s,&Profile); |
4393 | if (error != ERR_NONE) break; | 4393 | if (error != ERR_NONE) break; |
4394 | if (used < GSM_BACKUP_MAX_PROFILES) { | 4394 | if (used < GSM_BACKUP_MAX_PROFILES) { |
4395 | Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); | 4395 | Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); |
4396 | if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4396 | if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4397 | Backup.Profiles[used + 1] = NULL; | 4397 | Backup.Profiles[used + 1] = NULL; |
4398 | } else { | 4398 | } else { |
4399 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES"); | 4399 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES"); |
4400 | GSM_Terminate(); | 4400 | GSM_Terminate(); |
4401 | exit(-1); | 4401 | exit(-1); |
4402 | } | 4402 | } |
4403 | *Backup.Profiles[used]=Profile; | 4403 | *Backup.Profiles[used]=Profile; |
4404 | used++; | 4404 | used++; |
4405 | printmsgerr("*"); | 4405 | printmsgerr("*"); |
4406 | } | 4406 | } |
4407 | printmsgerr("\n"); | 4407 | printmsgerr("\n"); |
4408 | } | 4408 | } |
4409 | DoBackup = false; | 4409 | DoBackup = false; |
4410 | if (Info.FMStation) { | 4410 | if (Info.FMStation) { |
4411 | printmsg("Checking FM stations\n"); | 4411 | printmsg("Checking FM stations\n"); |
4412 | FMStation.Location = 1; | 4412 | FMStation.Location = 1; |
4413 | error = Phone->GetFMStation(&s,&FMStation); | 4413 | error = Phone->GetFMStation(&s,&FMStation); |
4414 | if (error == ERR_NONE || error == ERR_EMPTY) { | 4414 | if (error == ERR_NONE || error == ERR_EMPTY) { |
4415 | if (answer_yes(" Backup phone FM stations")) DoBackup=true; | 4415 | if (answer_yes(" Backup phone FM stations")) DoBackup=true; |
4416 | } | 4416 | } |
4417 | } | 4417 | } |
4418 | if (DoBackup) { | 4418 | if (DoBackup) { |
4419 | used= 0; | 4419 | used= 0; |
4420 | i = 1; | 4420 | i = 1; |
4421 | printmsgerr(" Reading: "); | 4421 | printmsgerr(" Reading: "); |
4422 | while (error == ERR_NONE || error == ERR_EMPTY) { | 4422 | while (error == ERR_NONE || error == ERR_EMPTY) { |
4423 | error = Phone->GetFMStation(&s,&FMStation); | 4423 | error = Phone->GetFMStation(&s,&FMStation); |
4424 | if (error == ERR_NONE) { | 4424 | if (error == ERR_NONE) { |
4425 | if (used < GSM_BACKUP_MAX_FMSTATIONS) { | 4425 | if (used < GSM_BACKUP_MAX_FMSTATIONS) { |
4426 | Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); | 4426 | Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); |
4427 | if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4427 | if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4428 | Backup.FMStation[used + 1] = NULL; | 4428 | Backup.FMStation[used + 1] = NULL; |
4429 | } else { | 4429 | } else { |
4430 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); | 4430 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); |
4431 | GSM_Terminate(); | 4431 | GSM_Terminate(); |
4432 | exit(-1); | 4432 | exit(-1); |
4433 | } | 4433 | } |
4434 | *Backup.FMStation[used]=FMStation; | 4434 | *Backup.FMStation[used]=FMStation; |
4435 | used++; | 4435 | used++; |
4436 | } | 4436 | } |
4437 | i++; | 4437 | i++; |
4438 | FMStation.Location = i; | 4438 | FMStation.Location = i; |
4439 | printmsgerr("*"); | 4439 | printmsgerr("*"); |
4440 | } | 4440 | } |
4441 | printmsgerr("\n"); | 4441 | printmsgerr("\n"); |
4442 | } | 4442 | } |
4443 | DoBackup = false; | 4443 | DoBackup = false; |
4444 | if (Info.GPRSPoint) { | 4444 | if (Info.GPRSPoint) { |
4445 | printmsg("Checking GPRS access points\n"); | 4445 | printmsg("Checking GPRS access points\n"); |
4446 | GPRSPoint.Location = 1; | 4446 | GPRSPoint.Location = 1; |
4447 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); | 4447 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); |
4448 | if (error == ERR_NONE || error == ERR_EMPTY) { | 4448 | if (error == ERR_NONE || error == ERR_EMPTY) { |
4449 | if (answer_yes(" Backup GPRS access points")) DoBackup = true; | 4449 | if (answer_yes(" Backup GPRS access points")) DoBackup = true; |
4450 | } | 4450 | } |
4451 | } | 4451 | } |
4452 | if (DoBackup) { | 4452 | if (DoBackup) { |
4453 | used= 0; | 4453 | used= 0; |
4454 | i = 1; | 4454 | i = 1; |
4455 | printmsgerr(" Reading: "); | 4455 | printmsgerr(" Reading: "); |
4456 | while (error == ERR_NONE || error == ERR_EMPTY) { | 4456 | while (error == ERR_NONE || error == ERR_EMPTY) { |
4457 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); | 4457 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); |
4458 | if (error == ERR_NONE) { | 4458 | if (error == ERR_NONE) { |
4459 | if (used < GSM_BACKUP_MAX_GPRSPOINT) { | 4459 | if (used < GSM_BACKUP_MAX_GPRSPOINT) { |
4460 | Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); | 4460 | Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); |
4461 | if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4461 | if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4462 | Backup.GPRSPoint[used + 1] = NULL; | 4462 | Backup.GPRSPoint[used + 1] = NULL; |
4463 | } else { | 4463 | } else { |
4464 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT"); | 4464 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT"); |
4465 | GSM_Terminate(); | 4465 | GSM_Terminate(); |
4466 | exit(-1); | 4466 | exit(-1); |
4467 | } | 4467 | } |
4468 | *Backup.GPRSPoint[used]=GPRSPoint; | 4468 | *Backup.GPRSPoint[used]=GPRSPoint; |
4469 | used++; | 4469 | used++; |
4470 | } | 4470 | } |
4471 | i++; | 4471 | i++; |
4472 | GPRSPoint.Location = i; | 4472 | GPRSPoint.Location = i; |
4473 | printmsgerr("*"); | 4473 | printmsgerr("*"); |
4474 | } | 4474 | } |
4475 | printmsgerr("\n"); | 4475 | printmsgerr("\n"); |
4476 | } | 4476 | } |
4477 | 4477 | ||
4478 | GSM_Terminate(); | 4478 | GSM_Terminate(); |
4479 | 4479 | ||
4480 | GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode); | 4480 | GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode); |
4481 | GSM_FreeBackup(&Backup); | 4481 | GSM_FreeBackup(&Backup); |
4482 | } | 4482 | } |
4483 | 4483 | ||
4484 | static void Restore(int argc, char *argv[]) | 4484 | static void Restore(int argc, char *argv[]) |
4485 | { | 4485 | { |
4486 | GSM_Backup Backup; | 4486 | GSM_Backup Backup; |
4487 | GSM_FMStation FMStation; | 4487 | GSM_FMStation FMStation; |
4488 | GSM_DateTime date_time; | 4488 | GSM_DateTime date_time; |
4489 | GSM_CalendarEntryCalendar; | 4489 | GSM_CalendarEntryCalendar; |
4490 | GSM_Bitmap Bitmap; | 4490 | GSM_Bitmap Bitmap; |
4491 | GSM_Ringtone Ringtone; | 4491 | GSM_Ringtone Ringtone; |
4492 | GSM_MemoryEntry Pbk; | 4492 | GSM_MemoryEntry Pbk; |
4493 | GSM_MemoryStatusMemStatus; | 4493 | GSM_MemoryStatusMemStatus; |
4494 | GSM_ToDoEntry ToDo; | 4494 | GSM_ToDoEntry ToDo; |
4495 | GSM_ToDoStatus ToDoStatus; | 4495 | GSM_ToDoStatus ToDoStatus; |
4496 | GSM_Profile Profile; | 4496 | GSM_Profile Profile; |
4497 | GSM_MultiWAPSettingsSettings; | 4497 | GSM_MultiWAPSettingsSettings; |
4498 | GSM_GPRSAccessPointGPRSPoint; | 4498 | GSM_GPRSAccessPointGPRSPoint; |
4499 | GSM_WAPBookmark Bookmark; | 4499 | GSM_WAPBookmark Bookmark; |
4500 | int i, used, max = 0; | 4500 | int i, used, max = 0; |
4501 | bool Past = true; | 4501 | bool Past = true; |
4502 | bool Found, DoRestore; | 4502 | bool Found, DoRestore; |
4503 | 4503 | ||
4504 | error=GSM_ReadBackupFile(argv[2],&Backup); | 4504 | error=GSM_ReadBackupFile(argv[2],&Backup); |
4505 | Print_Error(error); | 4505 | Print_Error(error); |
4506 | 4506 | ||
4507 | signal(SIGINT, interrupt); | 4507 | signal(SIGINT, interrupt); |
4508 | printmsgerr("Press Ctrl+C to break...\n"); | 4508 | printmsgerr("Press Ctrl+C to break...\n"); |
4509 | 4509 | ||
4510 | if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); | 4510 | if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); |
4511 | if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); | 4511 | if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); |
4512 | if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); | 4512 | if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); |
4513 | 4513 | ||
4514 | if (Backup.MD5Calculated[0]!=0) { | 4514 | if (Backup.MD5Calculated[0]!=0) { |
4515 | dbgprintf("\"%s\"\n",Backup.MD5Original); | 4515 | dbgprintf("\"%s\"\n",Backup.MD5Original); |
4516 | dbgprintf("\"%s\"\n",Backup.MD5Calculated); | 4516 | dbgprintf("\"%s\"\n",Backup.MD5Calculated); |
4517 | if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) { | 4517 | if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) { |
4518 | if (!answer_yes("Checksum in backup file do not match. Continue")) return; | 4518 | if (!answer_yes("Checksum in backup file do not match. Continue")) return; |
4519 | } | 4519 | } |
4520 | } | 4520 | } |
4521 | 4521 | ||
4522 | GSM_Init(true); | 4522 | GSM_Init(true); |
4523 | 4523 | ||
4524 | DoRestore = false; | 4524 | DoRestore = false; |
4525 | if (Backup.PhonePhonebook[0] != NULL) { | 4525 | if (Backup.PhonePhonebook[0] != NULL) { |
4526 | MemStatus.MemoryType = MEM_ME; | 4526 | MemStatus.MemoryType = MEM_ME; |
4527 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 4527 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
4528 | if (error==ERR_NONE) { | 4528 | if (error==ERR_NONE) { |
4529 | max = 0; | 4529 | max = 0; |
4530 | while (Backup.PhonePhonebook[max]!=NULL) max++; | 4530 | while (Backup.PhonePhonebook[max]!=NULL) max++; |
4531 | printmsgerr("%i entries in backup file\n",max); | 4531 | printmsgerr("%i entries in backup file\n",max); |
4532 | if (answer_yes("Restore phone phonebook")) DoRestore = true; | 4532 | if (answer_yes("Restore phone phonebook")) DoRestore = true; |
4533 | } | 4533 | } |
4534 | } | 4534 | } |
4535 | if (DoRestore) { | 4535 | if (DoRestore) { |
4536 | used = 0; | 4536 | used = 0; |
4537 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { | 4537 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { |
4538 | Pbk.MemoryType = MEM_ME; | 4538 | Pbk.MemoryType = MEM_ME; |
4539 | Pbk.Location= i + 1; | 4539 | Pbk.Location= i + 1; |
4540 | Pbk.EntriesNum= 0; | 4540 | Pbk.EntriesNum= 0; |
4541 | if (used<max) { | 4541 | if (used<max) { |
4542 | if (Backup.PhonePhonebook[used]->Location == Pbk.Location) { | 4542 | if (Backup.PhonePhonebook[used]->Location == Pbk.Location) { |
4543 | Pbk = *Backup.PhonePhonebook[used]; | 4543 | Pbk = *Backup.PhonePhonebook[used]; |
4544 | used++; | 4544 | used++; |
4545 | dbgprintf("Location %i\n",Pbk.Location); | 4545 | dbgprintf("Location %i\n",Pbk.Location); |
4546 | if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); | 4546 | if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); |
4547 | } | 4547 | } |
4548 | } | 4548 | } |
4549 | if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); | 4549 | if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); |
4550 | Print_Error(error); | 4550 | Print_Error(error); |
4551 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); | 4551 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); |
4552 | if (gshutdown) { | 4552 | if (gshutdown) { |
4553 | GSM_Terminate(); | 4553 | GSM_Terminate(); |
4554 | exit(0); | 4554 | exit(0); |
4555 | } | 4555 | } |
4556 | } | 4556 | } |
4557 | printmsgerr("\n"); | 4557 | printmsgerr("\n"); |
4558 | } | 4558 | } |
4559 | 4559 | ||
4560 | DoRestore = false; | 4560 | DoRestore = false; |
4561 | if (Backup.SIMPhonebook[0] != NULL) { | 4561 | if (Backup.SIMPhonebook[0] != NULL) { |
4562 | MemStatus.MemoryType = MEM_SM; | 4562 | MemStatus.MemoryType = MEM_SM; |
4563 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 4563 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
4564 | if (error==ERR_NONE) { | 4564 | if (error==ERR_NONE) { |
4565 | max = 0; | 4565 | max = 0; |
4566 | while (Backup.SIMPhonebook[max]!=NULL) max++; | 4566 | while (Backup.SIMPhonebook[max]!=NULL) max++; |
4567 | printmsgerr("%i entries in backup file\n",max); | 4567 | printmsgerr("%i entries in backup file\n",max); |
4568 | if (answer_yes("Restore SIM phonebook")) DoRestore = true; | 4568 | if (answer_yes("Restore SIM phonebook")) DoRestore = true; |
4569 | } | 4569 | } |
4570 | } | 4570 | } |
4571 | if (DoRestore) { | 4571 | if (DoRestore) { |
4572 | used = 0; | 4572 | used = 0; |
4573 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { | 4573 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { |
4574 | Pbk.MemoryType = MEM_SM; | 4574 | Pbk.MemoryType = MEM_SM; |
4575 | Pbk.Location= i + 1; | 4575 | Pbk.Location= i + 1; |
4576 | Pbk.EntriesNum= 0; | 4576 | Pbk.EntriesNum= 0; |
4577 | if (used<max) { | 4577 | if (used<max) { |
4578 | if (Backup.SIMPhonebook[used]->Location == Pbk.Location) { | 4578 | if (Backup.SIMPhonebook[used]->Location == Pbk.Location) { |
4579 | Pbk = *Backup.SIMPhonebook[used]; | 4579 | Pbk = *Backup.SIMPhonebook[used]; |
4580 | used++; | 4580 | used++; |
4581 | dbgprintf("Location %i\n",Pbk.Location); | 4581 | dbgprintf("Location %i\n",Pbk.Location); |
4582 | if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); | 4582 | if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); |
4583 | } | 4583 | } |
4584 | } | 4584 | } |
4585 | if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); | 4585 | if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); |
4586 | Print_Error(error); | 4586 | Print_Error(error); |
4587 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); | 4587 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); |
4588 | if (gshutdown) { | 4588 | if (gshutdown) { |
4589 | GSM_Terminate(); | 4589 | GSM_Terminate(); |
4590 | exit(0); | 4590 | exit(0); |
4591 | } | 4591 | } |
4592 | } | 4592 | } |
4593 | printmsgerr("\n"); | 4593 | printmsgerr("\n"); |
4594 | } | 4594 | } |
4595 | 4595 | ||
4596 | DoRestore = false; | 4596 | DoRestore = false; |
4597 | if (Backup.CallerLogos[0] != NULL) { | 4597 | if (Backup.CallerLogos[0] != NULL) { |
4598 | Bitmap.Type = GSM_CallerGroupLogo; | 4598 | Bitmap.Type = GSM_CallerGroupLogo; |
4599 | Bitmap.Location = 1; | 4599 | Bitmap.Location = 1; |
4600 | error=Phone->GetBitmap(&s,&Bitmap); | 4600 | error=Phone->GetBitmap(&s,&Bitmap); |
4601 | if (error == ERR_NONE) { | 4601 | if (error == ERR_NONE) { |
4602 | if (answer_yes("Restore caller groups and logos")) DoRestore = true; | 4602 | if (answer_yes("Restore caller groups and logos")) DoRestore = true; |
4603 | } | 4603 | } |
4604 | } | 4604 | } |
4605 | if (DoRestore) { | 4605 | if (DoRestore) { |
4606 | max = 0; | 4606 | max = 0; |
4607 | while (Backup.CallerLogos[max]!=NULL) max++; | 4607 | while (Backup.CallerLogos[max]!=NULL) max++; |
4608 | for (i=0;i<max;i++) { | 4608 | for (i=0;i<max;i++) { |
4609 | error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); | 4609 | error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); |
4610 | Print_Error(error); | 4610 | Print_Error(error); |
4611 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4611 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4612 | if (gshutdown) { | 4612 | if (gshutdown) { |
4613 | GSM_Terminate(); | 4613 | GSM_Terminate(); |
4614 | exit(0); | 4614 | exit(0); |
4615 | } | 4615 | } |
4616 | } | 4616 | } |
4617 | printmsgerr("\n"); | 4617 | printmsgerr("\n"); |
4618 | } | 4618 | } |
4619 | 4619 | ||
4620 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { | 4620 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { |
4621 | if (/*answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/ true ) { | 4621 | if (/*answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/ true ) { |
4622 | GSM_GetCurrentDateTime(&date_time); | 4622 | GSM_GetCurrentDateTime(&date_time); |
4623 | 4623 | ||
4624 | error=Phone->SetDateTime(&s, &date_time); | 4624 | error=Phone->SetDateTime(&s, &date_time); |
4625 | Print_Error(error); | 4625 | Print_Error(error); |
4626 | } | 4626 | } |
4627 | } | 4627 | } |
4628 | DoRestore = false; | 4628 | DoRestore = false; |
4629 | if (Backup.Calendar[0] != NULL) { | 4629 | if (Backup.Calendar[0] != NULL) { |
4630 | DoRestore = true; | ||
4630 | /* N6110 doesn't support getting calendar status */ | 4631 | /* N6110 doesn't support getting calendar status */ |
4631 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 4632 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
4632 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { | 4633 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { |
4633 | max = 0; | 4634 | max = 0; |
4634 | while (Backup.Calendar[max] != NULL) max++; | 4635 | while (Backup.Calendar[max] != NULL) max++; |
4635 | printmsgerr("%i entries in backup file\n",max); | 4636 | printmsgerr("%i entries in backup file\n",max); |
4636 | DoRestore = true; | 4637 | DoRestore = true; |
4637 | /* | 4638 | /* |
4638 | if (answer_yes("Restore calendar notes")) { | 4639 | if (answer_yes("Restore calendar notes")) { |
4639 | Past = answer_yes("Restore notes from the past"); | 4640 | Past = answer_yes("Restore notes from the past"); |
4640 | DoRestore = true; | 4641 | DoRestore = true; |
4641 | } | 4642 | } |
4642 | */ | 4643 | */ |
4643 | } | 4644 | } |
4644 | } | 4645 | } |
4645 | if (DoRestore) { | 4646 | if (DoRestore) { |
4646 | printmsgerr("Deleting old notes: "); | 4647 | printmsgerr("Deleting old notes: "); |
4647 | error = Phone->DeleteAllCalendar(&s); | 4648 | error = Phone->DeleteAllCalendar(&s); |
4648 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 4649 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
4649 | while (1) { | 4650 | while (1) { |
4650 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 4651 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
4651 | if (error != ERR_NONE) break; | 4652 | if (error != ERR_NONE) break; |
4652 | error = Phone->DeleteCalendar(&s,&Calendar); | 4653 | error = Phone->DeleteCalendar(&s,&Calendar); |
4653 | Print_Error(error); | 4654 | Print_Error(error); |
4654 | printmsgerr("*"); | 4655 | printmsgerr("*"); |
4655 | } | 4656 | } |
4656 | printmsgerr("\n"); | 4657 | printmsgerr("\n"); |
4657 | } else { | 4658 | } else { |
4658 | printmsgerr("Done\n"); | 4659 | printmsgerr("Done\n"); |
4659 | Print_Error(error); | 4660 | Print_Error(error); |
4660 | } | 4661 | } |
4661 | 4662 | ||
4662 | for (i=0;i<max;i++) { | 4663 | for (i=0;i<max;i++) { |
4663 | if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; | 4664 | if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; |
4664 | 4665 | ||
4665 | Calendar = *Backup.Calendar[i]; | 4666 | Calendar = *Backup.Calendar[i]; |
4666 | error=Phone->AddCalendar(&s,&Calendar); | 4667 | error=Phone->AddCalendar(&s,&Calendar); |
4667 | Print_Error(error); | 4668 | Print_Error(error); |
4668 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4669 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4669 | if (gshutdown) { | 4670 | if (gshutdown) { |
4670 | GSM_Terminate(); | 4671 | GSM_Terminate(); |
4671 | exit(0); | 4672 | exit(0); |
4672 | } | 4673 | } |
4673 | } | 4674 | } |
4674 | printmsgerr("\n"); | 4675 | printmsgerr("\n"); |
4675 | } | 4676 | } |
4676 | 4677 | ||
4677 | DoRestore = false; | 4678 | DoRestore = false; |
4678 | if (Backup.ToDo[0] != NULL) { | 4679 | if (Backup.ToDo[0] != NULL) { |
4679 | error = Phone->GetToDoStatus(&s,&ToDoStatus); | 4680 | error = Phone->GetToDoStatus(&s,&ToDoStatus); |
4680 | if (error == ERR_NONE) { | 4681 | if (error == ERR_NONE) { |
4682 | error == ERR_NOTSUPPORTED; | ||
4683 | DoRestore = true; | ||
4681 | max = 0; | 4684 | max = 0; |
4682 | while (Backup.ToDo[max]!=NULL) max++; | 4685 | while (Backup.ToDo[max]!=NULL) max++; |
4683 | printmsgerr("%i entries in backup file\n",max); | 4686 | printmsgerr("%i entries in backup file\n",max); |
4684 | 4687 | ||
4685 | /*if (answer_yes("Restore ToDo")) */DoRestore = true; | 4688 | /*if (answer_yes("Restore ToDo")) */DoRestore = true; |
4686 | } | 4689 | } |
4687 | } | 4690 | } |
4688 | if (DoRestore) { | 4691 | if (DoRestore) { |
4692 | if ( max > 0 ) { | ||
4689 | ToDo = *Backup.ToDo[0]; | 4693 | ToDo = *Backup.ToDo[0]; |
4690 | error = Phone->SetToDo(&s,&ToDo); | 4694 | error = Phone->SetToDo(&s,&ToDo); |
4695 | } | ||
4691 | } | 4696 | } |
4692 | if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { | 4697 | if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { |
4693 | printmsgerr("Deleting old ToDo: "); | 4698 | printmsgerr("Deleting old ToDo: "); |
4694 | error=Phone->DeleteAllToDo(&s); | 4699 | error=Phone->DeleteAllToDo(&s); |
4695 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 4700 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
4696 | while (1) { | 4701 | while (1) { |
4697 | error = Phone->GetNextToDo(&s,&ToDo,true); | 4702 | error = Phone->GetNextToDo(&s,&ToDo,true); |
4698 | if (error != ERR_NONE) break; | 4703 | if (error != ERR_NONE) break; |
4699 | error = Phone->DeleteToDo(&s,&ToDo); | 4704 | error = Phone->DeleteToDo(&s,&ToDo); |
4700 | Print_Error(error); | 4705 | Print_Error(error); |
4701 | printmsgerr("*"); | 4706 | printmsgerr("*"); |
4702 | } | 4707 | } |
4703 | printmsgerr("\n"); | 4708 | printmsgerr("\n"); |
4704 | } else { | 4709 | } else { |
4705 | printmsgerr("Done\n"); | 4710 | printmsgerr("Done\n"); |
4706 | Print_Error(error); | 4711 | Print_Error(error); |
4707 | } | 4712 | } |
4708 | 4713 | ||
4709 | for (i=0;i<max;i++) { | 4714 | for (i=0;i<max;i++) { |
4710 | ToDo = *Backup.ToDo[i]; | 4715 | ToDo = *Backup.ToDo[i]; |
4711 | ToDo.Location = 0; | 4716 | ToDo.Location = 0; |
4712 | error=Phone->AddToDo(&s,&ToDo); | 4717 | error=Phone->AddToDo(&s,&ToDo); |
4713 | Print_Error(error); | 4718 | Print_Error(error); |
4714 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4719 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4715 | if (gshutdown) { | 4720 | if (gshutdown) { |
4716 | GSM_Terminate(); | 4721 | GSM_Terminate(); |
4717 | exit(0); | 4722 | exit(0); |
4718 | } | 4723 | } |
4719 | } | 4724 | } |
4720 | printmsgerr("\n"); | 4725 | printmsgerr("\n"); |
4721 | } else if (DoRestore) { | 4726 | } else if (DoRestore) { |
4722 | /* At first delete entries, that were deleted */ | 4727 | /* At first delete entries, that were deleted */ |
4723 | used = 0; | 4728 | used = 0; |
4724 | error = Phone->GetNextToDo(&s,&ToDo,true); | 4729 | error = Phone->GetNextToDo(&s,&ToDo,true); |
4725 | while (error == ERR_NONE) { | 4730 | while (error == ERR_NONE) { |
4726 | used++; | 4731 | used++; |
4727 | Found = false; | 4732 | Found = false; |
4728 | for (i=0;i<max;i++) { | 4733 | for (i=0;i<max;i++) { |
4729 | if (Backup.ToDo[i]->Location == ToDo.Location) { | 4734 | if (Backup.ToDo[i]->Location == ToDo.Location) { |
4730 | Found = true; | 4735 | Found = true; |
4731 | break; | 4736 | break; |
4732 | } | 4737 | } |
4733 | } | 4738 | } |
4734 | if (!Found) { | 4739 | if (!Found) { |
4735 | error=Phone->DeleteToDo(&s,&ToDo); | 4740 | error=Phone->DeleteToDo(&s,&ToDo); |
4736 | Print_Error(error); | 4741 | Print_Error(error); |
4737 | } | 4742 | } |
4738 | error = Phone->GetNextToDo(&s,&ToDo,false); | 4743 | error = Phone->GetNextToDo(&s,&ToDo,false); |
4739 | printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); | 4744 | printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); |
4740 | if (gshutdown) { | 4745 | if (gshutdown) { |
4741 | GSM_Terminate(); | 4746 | GSM_Terminate(); |
4742 | exit(0); | 4747 | exit(0); |
4743 | } | 4748 | } |
4744 | } | 4749 | } |
4745 | printmsgerr("\n"); | 4750 | printmsgerr("\n"); |
4746 | 4751 | ||
4747 | /* Now write modified/new entries */ | 4752 | /* Now write modified/new entries */ |
4748 | for (i=0;i<max;i++) { | 4753 | for (i=0;i<max;i++) { |
4749 | ToDo = *Backup.ToDo[i]; | 4754 | ToDo = *Backup.ToDo[i]; |
4750 | error = Phone->SetToDo(&s,&ToDo); | 4755 | error = Phone->SetToDo(&s,&ToDo); |
4751 | Print_Error(error); | 4756 | Print_Error(error); |
4752 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4757 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4753 | if (gshutdown) { | 4758 | if (gshutdown) { |
4754 | GSM_Terminate(); | 4759 | GSM_Terminate(); |
4755 | exit(0); | 4760 | exit(0); |
4756 | } | 4761 | } |
4757 | } | 4762 | } |
4758 | printmsgerr("\n"); | 4763 | printmsgerr("\n"); |
4759 | } | 4764 | } |
4760 | 4765 | ||
4761 | if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { | 4766 | if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { |
4762 | max = 0; | 4767 | max = 0; |
4763 | while (Backup.SMSC[max]!=NULL) max++; | 4768 | while (Backup.SMSC[max]!=NULL) max++; |
4764 | for (i=0;i<max;i++) { | 4769 | for (i=0;i<max;i++) { |
4765 | error=Phone->SetSMSC(&s,Backup.SMSC[i]); | 4770 | error=Phone->SetSMSC(&s,Backup.SMSC[i]); |
4766 | Print_Error(error); | 4771 | Print_Error(error); |
4767 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4772 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4768 | if (gshutdown) { | 4773 | if (gshutdown) { |
4769 | GSM_Terminate(); | 4774 | GSM_Terminate(); |
4770 | exit(0); | 4775 | exit(0); |
4771 | } | 4776 | } |
4772 | } | 4777 | } |
4773 | printmsgerr("\n"); | 4778 | printmsgerr("\n"); |
4774 | } | 4779 | } |
4775 | if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { | 4780 | if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { |
4776 | error=Phone->SetBitmap(&s,Backup.StartupLogo); | 4781 | error=Phone->SetBitmap(&s,Backup.StartupLogo); |
4777 | Print_Error(error); | 4782 | Print_Error(error); |
4778 | } | 4783 | } |
4779 | if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { | 4784 | if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { |
4780 | error=Phone->SetBitmap(&s,Backup.OperatorLogo); | 4785 | error=Phone->SetBitmap(&s,Backup.OperatorLogo); |
4781 | Print_Error(error); | 4786 | Print_Error(error); |
4782 | } | 4787 | } |
4783 | DoRestore = false; | 4788 | DoRestore = false; |
4784 | if (Backup.WAPBookmark[0] != NULL) { | 4789 | if (Backup.WAPBookmark[0] != NULL) { |
4785 | Bookmark.Location = 1; | 4790 | Bookmark.Location = 1; |
4786 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 4791 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
4787 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { | 4792 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { |
4788 | if (answer_yes("Restore WAP bookmarks")) DoRestore = true; | 4793 | if (answer_yes("Restore WAP bookmarks")) DoRestore = true; |
4789 | } | 4794 | } |
4790 | } | 4795 | } |
4791 | if (DoRestore) { | 4796 | if (DoRestore) { |
4792 | printmsgerr("Deleting old bookmarks: "); | 4797 | printmsgerr("Deleting old bookmarks: "); |
4793 | /* One thing to explain: DCT4 phones seems to have bug here. | 4798 | /* One thing to explain: DCT4 phones seems to have bug here. |
4794 | * When delete for example first bookmark, phone change | 4799 | * When delete for example first bookmark, phone change |
4795 | * numeration for getting frame, not for deleting. So, we try to | 4800 | * numeration for getting frame, not for deleting. So, we try to |
4796 | * get 1'st bookmark. Inside frame is "correct" location. We use | 4801 | * get 1'st bookmark. Inside frame is "correct" location. We use |
4797 | * it later | 4802 | * it later |
4798 | */ | 4803 | */ |
4799 | while (error==ERR_NONE) { | 4804 | while (error==ERR_NONE) { |
4800 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); | 4805 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); |
4801 | Bookmark.Location = 1; | 4806 | Bookmark.Location = 1; |
4802 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 4807 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
4803 | printmsgerr("*"); | 4808 | printmsgerr("*"); |
4804 | } | 4809 | } |
4805 | printmsgerr("\n"); | 4810 | printmsgerr("\n"); |
4806 | max = 0; | 4811 | max = 0; |
4807 | while (Backup.WAPBookmark[max]!=NULL) max++; | 4812 | while (Backup.WAPBookmark[max]!=NULL) max++; |
4808 | for (i=0;i<max;i++) { | 4813 | for (i=0;i<max;i++) { |
4809 | Bookmark = *Backup.WAPBookmark[i]; | 4814 | Bookmark = *Backup.WAPBookmark[i]; |
4810 | Bookmark.Location = 0; | 4815 | Bookmark.Location = 0; |
4811 | error=Phone->SetWAPBookmark(&s,&Bookmark); | 4816 | error=Phone->SetWAPBookmark(&s,&Bookmark); |
4812 | Print_Error(error); | 4817 | Print_Error(error); |
4813 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4818 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4814 | if (gshutdown) { | 4819 | if (gshutdown) { |
4815 | GSM_Terminate(); | 4820 | GSM_Terminate(); |
4816 | exit(0); | 4821 | exit(0); |
4817 | } | 4822 | } |
4818 | } | 4823 | } |
4819 | printmsgerr("\n"); | 4824 | printmsgerr("\n"); |
4820 | } | 4825 | } |
4821 | DoRestore = false; | 4826 | DoRestore = false; |
4822 | if (Backup.WAPSettings[0] != NULL) { | 4827 | if (Backup.WAPSettings[0] != NULL) { |
4823 | Settings.Location = 1; | 4828 | Settings.Location = 1; |
4824 | error = Phone->GetWAPSettings(&s,&Settings); | 4829 | error = Phone->GetWAPSettings(&s,&Settings); |
4825 | if (error == ERR_NONE) { | 4830 | if (error == ERR_NONE) { |
4826 | if (answer_yes("Restore WAP settings")) DoRestore = true; | 4831 | if (answer_yes("Restore WAP settings")) DoRestore = true; |
4827 | } | 4832 | } |
4828 | } | 4833 | } |
4829 | if (DoRestore) { | 4834 | if (DoRestore) { |
4830 | max = 0; | 4835 | max = 0; |
4831 | while (Backup.WAPSettings[max]!=NULL) max++; | 4836 | while (Backup.WAPSettings[max]!=NULL) max++; |
4832 | for (i=0;i<max;i++) { | 4837 | for (i=0;i<max;i++) { |
4833 | error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); | 4838 | error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); |
4834 | Print_Error(error); | 4839 | Print_Error(error); |
4835 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4840 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4836 | if (gshutdown) { | 4841 | if (gshutdown) { |
4837 | GSM_Terminate(); | 4842 | GSM_Terminate(); |
4838 | exit(0); | 4843 | exit(0); |
4839 | } | 4844 | } |
4840 | } | 4845 | } |
4841 | printmsgerr("\n"); | 4846 | printmsgerr("\n"); |
4842 | } | 4847 | } |
4843 | DoRestore = false; | 4848 | DoRestore = false; |
4844 | if (Backup.MMSSettings[0] != NULL) { | 4849 | if (Backup.MMSSettings[0] != NULL) { |
4845 | Settings.Location = 1; | 4850 | Settings.Location = 1; |
4846 | error = Phone->GetMMSSettings(&s,&Settings); | 4851 | error = Phone->GetMMSSettings(&s,&Settings); |
4847 | if (error == ERR_NONE) { | 4852 | if (error == ERR_NONE) { |
4848 | if (answer_yes("Restore MMS settings")) DoRestore = true; | 4853 | if (answer_yes("Restore MMS settings")) DoRestore = true; |
4849 | } | 4854 | } |
4850 | } | 4855 | } |
4851 | if (DoRestore) { | 4856 | if (DoRestore) { |
4852 | max = 0; | 4857 | max = 0; |
4853 | while (Backup.MMSSettings[max]!=NULL) max++; | 4858 | while (Backup.MMSSettings[max]!=NULL) max++; |
4854 | for (i=0;i<max;i++) { | 4859 | for (i=0;i<max;i++) { |
4855 | error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); | 4860 | error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); |
4856 | Print_Error(error); | 4861 | Print_Error(error); |
4857 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4862 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4858 | if (gshutdown) { | 4863 | if (gshutdown) { |
4859 | GSM_Terminate(); | 4864 | GSM_Terminate(); |
4860 | exit(0); | 4865 | exit(0); |
4861 | } | 4866 | } |
4862 | } | 4867 | } |
4863 | printmsgerr("\n"); | 4868 | printmsgerr("\n"); |
4864 | } | 4869 | } |
4865 | DoRestore = false; | 4870 | DoRestore = false; |
4866 | if (Backup.Ringtone[0] != NULL) { | 4871 | if (Backup.Ringtone[0] != NULL) { |
4867 | Ringtone.Location = 1; | 4872 | Ringtone.Location = 1; |
4868 | Ringtone.Format = 0; | 4873 | Ringtone.Format = 0; |
4869 | error = Phone->GetRingtone(&s,&Ringtone,false); | 4874 | error = Phone->GetRingtone(&s,&Ringtone,false); |
4870 | if (error == ERR_NONE || error ==ERR_EMPTY) { | 4875 | if (error == ERR_NONE || error ==ERR_EMPTY) { |
4871 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { | 4876 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { |
4872 | if (answer_yes("Delete all user ringtones")) DoRestore = true; | 4877 | if (answer_yes("Delete all user ringtones")) DoRestore = true; |
4873 | } | 4878 | } |
4874 | } | 4879 | } |
4875 | } | 4880 | } |
4876 | if (DoRestore) { | 4881 | if (DoRestore) { |
4877 | printmsgerr("Deleting: "); | 4882 | printmsgerr("Deleting: "); |
4878 | error=Phone->DeleteUserRingtones(&s); | 4883 | error=Phone->DeleteUserRingtones(&s); |
4879 | Print_Error(error); | 4884 | Print_Error(error); |
4880 | printmsgerr("Done\n"); | 4885 | printmsgerr("Done\n"); |
4881 | DoRestore = false; | 4886 | DoRestore = false; |
4882 | if (answer_yes("Restore user ringtones")) DoRestore = true; | 4887 | if (answer_yes("Restore user ringtones")) DoRestore = true; |
4883 | } | 4888 | } |
4884 | if (DoRestore) { | 4889 | if (DoRestore) { |
4885 | max = 0; | 4890 | max = 0; |
4886 | while (Backup.Ringtone[max]!=NULL) max++; | 4891 | while (Backup.Ringtone[max]!=NULL) max++; |
4887 | for (i=0;i<max;i++) { | 4892 | for (i=0;i<max;i++) { |
4888 | error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format); | 4893 | error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format); |
4889 | Print_Error(error); | 4894 | Print_Error(error); |
4890 | error=Phone->SetRingtone(&s,&Ringtone,&i); | 4895 | error=Phone->SetRingtone(&s,&Ringtone,&i); |
4891 | Print_Error(error); | 4896 | Print_Error(error); |
4892 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4897 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4893 | if (gshutdown) { | 4898 | if (gshutdown) { |
4894 | GSM_Terminate(); | 4899 | GSM_Terminate(); |
4895 | exit(0); | 4900 | exit(0); |
4896 | } | 4901 | } |
4897 | } | 4902 | } |
4898 | printmsgerr("\n"); | 4903 | printmsgerr("\n"); |
4899 | } | 4904 | } |
4900 | DoRestore = false; | 4905 | DoRestore = false; |
4901 | if (Backup.Profiles[0] != NULL) { | 4906 | if (Backup.Profiles[0] != NULL) { |
4902 | Profile.Location = 1; | 4907 | Profile.Location = 1; |
4903 | error = Phone->GetProfile(&s,&Profile); | 4908 | error = Phone->GetProfile(&s,&Profile); |
4904 | if (error == ERR_NONE) { | 4909 | if (error == ERR_NONE) { |
4905 | if (answer_yes("Restore profiles")) DoRestore = true; | 4910 | if (answer_yes("Restore profiles")) DoRestore = true; |
4906 | } | 4911 | } |
4907 | } | 4912 | } |
4908 | if (DoRestore) { | 4913 | if (DoRestore) { |
4909 | Profile.Location= 0; | 4914 | Profile.Location= 0; |
4910 | max = 0; | 4915 | max = 0; |
4911 | while (Backup.Profiles[max]!=NULL) max++; | 4916 | while (Backup.Profiles[max]!=NULL) max++; |
4912 | for (i=0;i<max;i++) { | 4917 | for (i=0;i<max;i++) { |
4913 | Profile= *Backup.Profiles[i]; | 4918 | Profile= *Backup.Profiles[i]; |
4914 | error=Phone->SetProfile(&s,&Profile); | 4919 | error=Phone->SetProfile(&s,&Profile); |
4915 | Print_Error(error); | 4920 | Print_Error(error); |
4916 | if (gshutdown) { | 4921 | if (gshutdown) { |
4917 | GSM_Terminate(); | 4922 | GSM_Terminate(); |
4918 | exit(0); | 4923 | exit(0); |
4919 | } | 4924 | } |
4920 | } | 4925 | } |
4921 | printmsgerr("\n"); | 4926 | printmsgerr("\n"); |
4922 | } | 4927 | } |
4923 | DoRestore = false; | 4928 | DoRestore = false; |
4924 | if (Backup.FMStation[0] != NULL) { | 4929 | if (Backup.FMStation[0] != NULL) { |
4925 | FMStation.Location = 1; | 4930 | FMStation.Location = 1; |
4926 | error = Phone->GetFMStation(&s,&FMStation); | 4931 | error = Phone->GetFMStation(&s,&FMStation); |
4927 | if (error == ERR_NONE || error == ERR_EMPTY) { | 4932 | if (error == ERR_NONE || error == ERR_EMPTY) { |
4928 | if (answer_yes("Restore FM stations")) DoRestore = true; | 4933 | if (answer_yes("Restore FM stations")) DoRestore = true; |
4929 | } | 4934 | } |
4930 | } | 4935 | } |
4931 | if (DoRestore) { | 4936 | if (DoRestore) { |
4932 | printmsgerr("Deleting old FM stations: "); | 4937 | printmsgerr("Deleting old FM stations: "); |
4933 | error=Phone->ClearFMStations(&s); | 4938 | error=Phone->ClearFMStations(&s); |
4934 | Print_Error(error); | 4939 | Print_Error(error); |
4935 | printmsgerr("Done\n"); | 4940 | printmsgerr("Done\n"); |
4936 | max = 0; | 4941 | max = 0; |
4937 | while (Backup.FMStation[max]!=NULL) max++; | 4942 | while (Backup.FMStation[max]!=NULL) max++; |
4938 | for (i=0;i<max;i++) { | 4943 | for (i=0;i<max;i++) { |
4939 | FMStation = *Backup.FMStation[i]; | 4944 | FMStation = *Backup.FMStation[i]; |
4940 | error=Phone->SetFMStation(&s,&FMStation); | 4945 | error=Phone->SetFMStation(&s,&FMStation); |
4941 | Print_Error(error); | 4946 | Print_Error(error); |
4942 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4947 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4943 | if (gshutdown) { | 4948 | if (gshutdown) { |
4944 | GSM_Terminate(); | 4949 | GSM_Terminate(); |
4945 | exit(0); | 4950 | exit(0); |
4946 | } | 4951 | } |
4947 | } | 4952 | } |
4948 | printmsgerr("\n"); | 4953 | printmsgerr("\n"); |
4949 | } | 4954 | } |
4950 | DoRestore = false; | 4955 | DoRestore = false; |
4951 | if (Backup.GPRSPoint[0] != NULL) { | 4956 | if (Backup.GPRSPoint[0] != NULL) { |
4952 | GPRSPoint.Location = 1; | 4957 | GPRSPoint.Location = 1; |
4953 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); | 4958 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); |
4954 | if (error == ERR_NONE || error == ERR_EMPTY) { | 4959 | if (error == ERR_NONE || error == ERR_EMPTY) { |
4955 | if (answer_yes("Restore GPRS Points")) DoRestore = true; | 4960 | if (answer_yes("Restore GPRS Points")) DoRestore = true; |
4956 | } | 4961 | } |
4957 | } | 4962 | } |
4958 | if (DoRestore) { | 4963 | if (DoRestore) { |
4959 | max = 0; | 4964 | max = 0; |
4960 | while (Backup.GPRSPoint[max]!=NULL) max++; | 4965 | while (Backup.GPRSPoint[max]!=NULL) max++; |
4961 | for (i=0;i<max;i++) { | 4966 | for (i=0;i<max;i++) { |
4962 | error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]); | 4967 | error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]); |
4963 | Print_Error(error); | 4968 | Print_Error(error); |
4964 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4969 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4965 | if (gshutdown) { | 4970 | if (gshutdown) { |
4966 | GSM_Terminate(); | 4971 | GSM_Terminate(); |
4967 | exit(0); | 4972 | exit(0); |
4968 | } | 4973 | } |
4969 | } | 4974 | } |
4970 | printmsgerr("\n"); | 4975 | printmsgerr("\n"); |
4971 | } | 4976 | } |
4972 | 4977 | ||
4973 | GSM_Terminate(); | 4978 | GSM_Terminate(); |
4974 | } | 4979 | } |
4975 | 4980 | ||
4976 | static void AddNew(int argc, char *argv[]) | 4981 | static void AddNew(int argc, char *argv[]) |
4977 | { | 4982 | { |
4978 | GSM_Backup Backup; | 4983 | GSM_Backup Backup; |
4979 | GSM_DateTime date_time; | 4984 | GSM_DateTime date_time; |
4980 | GSM_MemoryEntry Pbk; | 4985 | GSM_MemoryEntry Pbk; |
4981 | GSM_MemoryStatusMemStatus; | 4986 | GSM_MemoryStatusMemStatus; |
4982 | GSM_ToDoEntry ToDo; | 4987 | GSM_ToDoEntry ToDo; |
4983 | GSM_ToDoStatus ToDoStatus; | 4988 | GSM_ToDoStatus ToDoStatus; |
4984 | GSM_CalendarEntryCalendar; | 4989 | GSM_CalendarEntryCalendar; |
4985 | GSM_WAPBookmark Bookmark; | 4990 | GSM_WAPBookmark Bookmark; |
4986 | int i, max, j; | 4991 | int i, max, j; |
4987 | 4992 | ||
4988 | error=GSM_ReadBackupFile(argv[2],&Backup); | 4993 | error=GSM_ReadBackupFile(argv[2],&Backup); |
4989 | Print_Error(error); | 4994 | Print_Error(error); |
4990 | 4995 | ||
4991 | signal(SIGINT, interrupt); | 4996 | signal(SIGINT, interrupt); |
4992 | printmsgerr("Press Ctrl+C to break...\n"); | 4997 | printmsgerr("Press Ctrl+C to break...\n"); |
4993 | 4998 | ||
4994 | if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); | 4999 | if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); |
4995 | if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); | 5000 | if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); |
4996 | if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); | 5001 | if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); |
4997 | 5002 | ||
4998 | GSM_Init(true); | 5003 | GSM_Init(true); |
4999 | 5004 | ||
5000 | if (Backup.PhonePhonebook[0] != NULL) { | 5005 | if (Backup.PhonePhonebook[0] != NULL) { |
5001 | MemStatus.MemoryType = MEM_ME; | 5006 | MemStatus.MemoryType = MEM_ME; |
5002 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5007 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5003 | if (error==ERR_NONE) { | 5008 | if (error==ERR_NONE) { |
5004 | max = 0; | 5009 | max = 0; |
5005 | while (Backup.PhonePhonebook[max]!=NULL) max++; | 5010 | while (Backup.PhonePhonebook[max]!=NULL) max++; |
5006 | printmsgerr("%i entries in backup file\n",max); | 5011 | printmsgerr("%i entries in backup file\n",max); |
5007 | if (MemStatus.MemoryFree < max) { | 5012 | if (MemStatus.MemoryFree < max) { |
5008 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); | 5013 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); |
5009 | } else if (answer_yes("Add phone phonebook entries")) { | 5014 | } else if (answer_yes("Add phone phonebook entries")) { |
5010 | for (i=0;i<max;i++) { | 5015 | for (i=0;i<max;i++) { |
5011 | Pbk = *Backup.PhonePhonebook[i]; | 5016 | Pbk = *Backup.PhonePhonebook[i]; |
5012 | Pbk.MemoryType = MEM_ME; | 5017 | Pbk.MemoryType = MEM_ME; |
5013 | error=Phone->AddMemory(&s, &Pbk); | 5018 | error=Phone->AddMemory(&s, &Pbk); |
5014 | Print_Error(error); | 5019 | Print_Error(error); |
5015 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5020 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5016 | if (gshutdown) { | 5021 | if (gshutdown) { |
5017 | GSM_Terminate(); | 5022 | GSM_Terminate(); |
5018 | exit(0); | 5023 | exit(0); |
5019 | } | 5024 | } |
5020 | } | 5025 | } |
5021 | printmsgerr("\n"); | 5026 | printmsgerr("\n"); |
5022 | } | 5027 | } |
5023 | } | 5028 | } |
5024 | } | 5029 | } |
5025 | if (Backup.SIMPhonebook[0] != NULL) { | 5030 | if (Backup.SIMPhonebook[0] != NULL) { |
5026 | MemStatus.MemoryType = MEM_SM; | 5031 | MemStatus.MemoryType = MEM_SM; |
5027 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5032 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5028 | if (error==ERR_NONE) { | 5033 | if (error==ERR_NONE) { |
5029 | max = 0; | 5034 | max = 0; |
5030 | while (Backup.SIMPhonebook[max]!=NULL) max++; | 5035 | while (Backup.SIMPhonebook[max]!=NULL) max++; |
5031 | printmsgerr("%i entries in backup file\n",max); | 5036 | printmsgerr("%i entries in backup file\n",max); |
5032 | if (MemStatus.MemoryFree < max) { | 5037 | if (MemStatus.MemoryFree < max) { |
5033 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); | 5038 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); |
5034 | } else if (answer_yes("Add SIM phonebook entries")) { | 5039 | } else if (answer_yes("Add SIM phonebook entries")) { |
5035 | j = 1; | 5040 | j = 1; |
5036 | for (i=0;i<max;i++) { | 5041 | for (i=0;i<max;i++) { |
5037 | Pbk = *Backup.SIMPhonebook[i]; | 5042 | Pbk = *Backup.SIMPhonebook[i]; |
5038 | Pbk.MemoryType = MEM_SM; | 5043 | Pbk.MemoryType = MEM_SM; |
5039 | error=Phone->AddMemory(&s, &Pbk); | 5044 | error=Phone->AddMemory(&s, &Pbk); |
5040 | Print_Error(error); | 5045 | Print_Error(error); |
5041 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5046 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5042 | if (gshutdown) { | 5047 | if (gshutdown) { |
5043 | GSM_Terminate(); | 5048 | GSM_Terminate(); |
5044 | exit(0); | 5049 | exit(0); |
5045 | } | 5050 | } |
5046 | } | 5051 | } |
5047 | printmsgerr("\n"); | 5052 | printmsgerr("\n"); |
5048 | } | 5053 | } |
5049 | } | 5054 | } |
5050 | } | 5055 | } |
5051 | 5056 | ||
5052 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { | 5057 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { |
5053 | if (answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")) { | 5058 | if (answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")) { |
5054 | GSM_GetCurrentDateTime(&date_time); | 5059 | GSM_GetCurrentDateTime(&date_time); |
5055 | 5060 | ||
5056 | error=Phone->SetDateTime(&s, &date_time); | 5061 | error=Phone->SetDateTime(&s, &date_time); |
5057 | Print_Error(error); | 5062 | Print_Error(error); |
5058 | } | 5063 | } |
5059 | } | 5064 | } |
5060 | if (Backup.Calendar[0] != NULL) { | 5065 | if (Backup.Calendar[0] != NULL) { |
5061 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 5066 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
5062 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { | 5067 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { |
5063 | if (answer_yes("Add calendar notes")) { | 5068 | if (answer_yes("Add calendar notes")) { |
5064 | max = 0; | 5069 | max = 0; |
5065 | while (Backup.Calendar[max]!=NULL) max++; | 5070 | while (Backup.Calendar[max]!=NULL) max++; |
5066 | for (i=0;i<max;i++) { | 5071 | for (i=0;i<max;i++) { |
5067 | Calendar = *Backup.Calendar[i]; | 5072 | Calendar = *Backup.Calendar[i]; |
5068 | error=Phone->AddCalendar(&s,&Calendar); | 5073 | error=Phone->AddCalendar(&s,&Calendar); |
5069 | Print_Error(error); | 5074 | Print_Error(error); |
5070 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5075 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5071 | if (gshutdown) { | 5076 | if (gshutdown) { |
5072 | GSM_Terminate(); | 5077 | GSM_Terminate(); |
5073 | exit(0); | 5078 | exit(0); |
5074 | } | 5079 | } |
5075 | } | 5080 | } |
5076 | printmsgerr("\n"); | 5081 | printmsgerr("\n"); |
5077 | } | 5082 | } |
5078 | } | 5083 | } |
5079 | } | 5084 | } |
5080 | if (Backup.ToDo[0] != NULL) { | 5085 | if (Backup.ToDo[0] != NULL) { |
5081 | ToDo.Location = 1; | 5086 | ToDo.Location = 1; |
5082 | error=Phone->GetToDoStatus(&s,&ToDoStatus); | 5087 | error=Phone->GetToDoStatus(&s,&ToDoStatus); |
5083 | if (error == ERR_NONE) { | 5088 | if (error == ERR_NONE) { |
5084 | if (answer_yes("Add ToDo")) { | 5089 | if (answer_yes("Add ToDo")) { |
5085 | max = 0; | 5090 | max = 0; |
5086 | while (Backup.ToDo[max]!=NULL) max++; | 5091 | while (Backup.ToDo[max]!=NULL) max++; |
5087 | for (i=0;i<max;i++) { | 5092 | for (i=0;i<max;i++) { |
5088 | ToDo = *Backup.ToDo[i]; | 5093 | ToDo = *Backup.ToDo[i]; |
5089 | error = Phone->AddToDo(&s,&ToDo); | 5094 | error = Phone->AddToDo(&s,&ToDo); |
5090 | Print_Error(error); | 5095 | Print_Error(error); |
5091 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5096 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5092 | if (gshutdown) { | 5097 | if (gshutdown) { |
5093 | GSM_Terminate(); | 5098 | GSM_Terminate(); |
5094 | exit(0); | 5099 | exit(0); |
5095 | } | 5100 | } |
5096 | } | 5101 | } |
5097 | printmsgerr("\n"); | 5102 | printmsgerr("\n"); |
5098 | } | 5103 | } |
5099 | } | 5104 | } |
5100 | } | 5105 | } |
5101 | if (Backup.WAPBookmark[0] != NULL) { | 5106 | if (Backup.WAPBookmark[0] != NULL) { |
5102 | Bookmark.Location = 1; | 5107 | Bookmark.Location = 1; |
5103 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 5108 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
5104 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { | 5109 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { |
5105 | if (answer_yes("Add WAP bookmarks")) { | 5110 | if (answer_yes("Add WAP bookmarks")) { |
5106 | max = 0; | 5111 | max = 0; |
5107 | while (Backup.WAPBookmark[max]!=NULL) max++; | 5112 | while (Backup.WAPBookmark[max]!=NULL) max++; |
5108 | for (i=0;i<max;i++) { | 5113 | for (i=0;i<max;i++) { |
5109 | Bookmark = *Backup.WAPBookmark[i]; | 5114 | Bookmark = *Backup.WAPBookmark[i]; |
5110 | Bookmark.Location = 0; | 5115 | Bookmark.Location = 0; |
5111 | error=Phone->SetWAPBookmark(&s,&Bookmark); | 5116 | error=Phone->SetWAPBookmark(&s,&Bookmark); |
5112 | Print_Error(error); | 5117 | Print_Error(error); |
5113 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5118 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5114 | if (gshutdown) { | 5119 | if (gshutdown) { |
5115 | GSM_Terminate(); | 5120 | GSM_Terminate(); |
5116 | exit(0); | 5121 | exit(0); |
5117 | } | 5122 | } |
5118 | } | 5123 | } |
5119 | printmsgerr("\n"); | 5124 | printmsgerr("\n"); |
5120 | } | 5125 | } |
5121 | } | 5126 | } |
5122 | } | 5127 | } |
5123 | 5128 | ||
5124 | GSM_Terminate(); | 5129 | GSM_Terminate(); |
5125 | } | 5130 | } |
5126 | #endif | 5131 | #endif |
5127 | 5132 | ||
5128 | static void ClearAll(int argc, char *argv[]) | 5133 | static void ClearAll(int argc, char *argv[]) |
5129 | { | 5134 | { |
5130 | GSM_MemoryStatusMemStatus; | 5135 | GSM_MemoryStatusMemStatus; |
5131 | GSM_ToDoStatus ToDoStatus; | 5136 | GSM_ToDoStatus ToDoStatus; |
5132 | GSM_CalendarEntryCalendar; | 5137 | GSM_CalendarEntryCalendar; |
5133 | GSM_ToDoEntry ToDo; | 5138 | GSM_ToDoEntry ToDo; |
5134 | GSM_WAPBookmark Bookmark; | 5139 | GSM_WAPBookmark Bookmark; |
5135 | GSM_FMStation Station; | 5140 | GSM_FMStation Station; |
5136 | GSM_MemoryEntry Pbk; | 5141 | GSM_MemoryEntry Pbk; |
5137 | bool DoClear; | 5142 | bool DoClear; |
5138 | 5143 | ||
5139 | GSM_Init(true); | 5144 | GSM_Init(true); |
5140 | 5145 | ||
5141 | DoClear = false; | 5146 | DoClear = false; |
5142 | MemStatus.MemoryType = MEM_ME; | 5147 | MemStatus.MemoryType = MEM_ME; |
5143 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5148 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5144 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { | 5149 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { |
5145 | if (answer_yes("Delete phone phonebook")) DoClear = true; | 5150 | if (answer_yes("Delete phone phonebook")) DoClear = true; |
5146 | } | 5151 | } |
5147 | if (DoClear) { | 5152 | if (DoClear) { |
5148 | error = Phone->DeleteAllMemory(&s,MEM_ME); | 5153 | error = Phone->DeleteAllMemory(&s,MEM_ME); |
5149 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5154 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5150 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { | 5155 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { |
5151 | Pbk.MemoryType = MEM_ME; | 5156 | Pbk.MemoryType = MEM_ME; |
5152 | Pbk.Location= i + 1; | 5157 | Pbk.Location= i + 1; |
5153 | Pbk.EntriesNum= 0; | 5158 | Pbk.EntriesNum= 0; |
5154 | error=Phone->DeleteMemory(&s, &Pbk); | 5159 | error=Phone->DeleteMemory(&s, &Pbk); |
5155 | Print_Error(error); | 5160 | Print_Error(error); |
5156 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); | 5161 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); |
5157 | if (gshutdown) { | 5162 | if (gshutdown) { |
5158 | GSM_Terminate(); | 5163 | GSM_Terminate(); |
5159 | exit(0); | 5164 | exit(0); |
5160 | } | 5165 | } |
5161 | } | 5166 | } |
5162 | printmsgerr("\n"); | 5167 | printmsgerr("\n"); |
5163 | } else { | 5168 | } else { |
5164 | printmsgerr("Done\n"); | 5169 | printmsgerr("Done\n"); |
5165 | Print_Error(error); | 5170 | Print_Error(error); |
5166 | } | 5171 | } |
5167 | } | 5172 | } |
5168 | 5173 | ||
5169 | DoClear = false; | 5174 | DoClear = false; |
5170 | MemStatus.MemoryType = MEM_SM; | 5175 | MemStatus.MemoryType = MEM_SM; |
5171 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5176 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5172 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { | 5177 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { |
5173 | if (answer_yes("Delete SIM phonebook")) DoClear = true; | 5178 | if (answer_yes("Delete SIM phonebook")) DoClear = true; |
5174 | } | 5179 | } |
5175 | if (DoClear) { | 5180 | if (DoClear) { |
5176 | error = Phone->DeleteAllMemory(&s,MEM_SM); | 5181 | error = Phone->DeleteAllMemory(&s,MEM_SM); |
5177 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5182 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5178 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { | 5183 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { |
5179 | Pbk.MemoryType = MEM_SM; | 5184 | Pbk.MemoryType = MEM_SM; |
5180 | Pbk.Location= i + 1; | 5185 | Pbk.Location= i + 1; |
5181 | Pbk.EntriesNum= 0; | 5186 | Pbk.EntriesNum= 0; |
5182 | error=Phone->DeleteMemory(&s, &Pbk); | 5187 | error=Phone->DeleteMemory(&s, &Pbk); |
5183 | Print_Error(error); | 5188 | Print_Error(error); |
5184 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); | 5189 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); |
5185 | if (gshutdown) { | 5190 | if (gshutdown) { |
5186 | GSM_Terminate(); | 5191 | GSM_Terminate(); |
5187 | exit(0); | 5192 | exit(0); |
5188 | } | 5193 | } |
5189 | } | 5194 | } |
5190 | printmsgerr("\n"); | 5195 | printmsgerr("\n"); |
5191 | } else { | 5196 | } else { |
5192 | printmsgerr("Done\n"); | 5197 | printmsgerr("Done\n"); |
5193 | Print_Error(error); | 5198 | Print_Error(error); |
5194 | } | 5199 | } |
5195 | } | 5200 | } |
5196 | 5201 | ||
5197 | DoClear = false; | 5202 | DoClear = false; |
5198 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 5203 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
5199 | if (error == ERR_NONE) { | 5204 | if (error == ERR_NONE) { |
5200 | if (answer_yes("Delete calendar notes")) DoClear = true; | 5205 | if (answer_yes("Delete calendar notes")) DoClear = true; |
5201 | } | 5206 | } |
5202 | if (DoClear) { | 5207 | if (DoClear) { |
5203 | printmsgerr("Deleting: "); | 5208 | printmsgerr("Deleting: "); |
5204 | error=Phone->DeleteAllCalendar(&s); | 5209 | error=Phone->DeleteAllCalendar(&s); |
5205 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5210 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5206 | while (1) { | 5211 | while (1) { |
5207 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 5212 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
5208 | if (error != ERR_NONE) break; | 5213 | if (error != ERR_NONE) break; |
5209 | error = Phone->DeleteCalendar(&s,&Calendar); | 5214 | error = Phone->DeleteCalendar(&s,&Calendar); |
5210 | Print_Error(error); | 5215 | Print_Error(error); |
5211 | printmsgerr("*"); | 5216 | printmsgerr("*"); |
5212 | } | 5217 | } |
5213 | printmsgerr("\n"); | 5218 | printmsgerr("\n"); |
5214 | } else { | 5219 | } else { |
5215 | printmsgerr("Done\n"); | 5220 | printmsgerr("Done\n"); |
5216 | Print_Error(error); | 5221 | Print_Error(error); |
5217 | } | 5222 | } |
5218 | } | 5223 | } |
5219 | 5224 | ||
5220 | DoClear = false; | 5225 | DoClear = false; |
5221 | error = Phone->GetToDoStatus(&s,&ToDoStatus); | 5226 | error = Phone->GetToDoStatus(&s,&ToDoStatus); |
5222 | if (error == ERR_NONE && ToDoStatus.Used != 0) { | 5227 | if (error == ERR_NONE && ToDoStatus.Used != 0) { |
5223 | if (answer_yes("Delete ToDo")) DoClear = true; | 5228 | if (answer_yes("Delete ToDo")) DoClear = true; |
5224 | } | 5229 | } |
5225 | if (DoClear) { | 5230 | if (DoClear) { |
5226 | printmsgerr("Deleting: "); | 5231 | printmsgerr("Deleting: "); |
5227 | error=Phone->DeleteAllToDo(&s); | 5232 | error=Phone->DeleteAllToDo(&s); |
5228 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5233 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5229 | while (1) { | 5234 | while (1) { |
5230 | error = Phone->GetNextToDo(&s,&ToDo,true); | 5235 | error = Phone->GetNextToDo(&s,&ToDo,true); |
5231 | if (error != ERR_NONE) break; | 5236 | if (error != ERR_NONE) break; |
5232 | error = Phone->DeleteToDo(&s,&ToDo); | 5237 | error = Phone->DeleteToDo(&s,&ToDo); |
5233 | Print_Error(error); | 5238 | Print_Error(error); |
5234 | printmsgerr("*"); | 5239 | printmsgerr("*"); |
5235 | } | 5240 | } |
5236 | printmsgerr("\n"); | 5241 | printmsgerr("\n"); |
5237 | } else { | 5242 | } else { |
5238 | printmsgerr("Done\n"); | 5243 | printmsgerr("Done\n"); |
5239 | Print_Error(error); | 5244 | Print_Error(error); |
5240 | } | 5245 | } |
5241 | } | 5246 | } |
5242 | 5247 | ||
5243 | Bookmark.Location = 1; | 5248 | Bookmark.Location = 1; |
5244 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 5249 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
5245 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { | 5250 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { |
5246 | if (answer_yes("Delete WAP bookmarks")) { | 5251 | if (answer_yes("Delete WAP bookmarks")) { |
5247 | printmsgerr("Deleting: "); | 5252 | printmsgerr("Deleting: "); |
5248 | /* One thing to explain: DCT4 phones seems to have bug here. | 5253 | /* One thing to explain: DCT4 phones seems to have bug here. |
5249 | * When delete for example first bookmark, phone change | 5254 | * When delete for example first bookmark, phone change |
5250 | * numeration for getting frame, not for deleting. So, we try to | 5255 | * numeration for getting frame, not for deleting. So, we try to |
5251 | * get 1'st bookmark. Inside frame is "correct" location. We use | 5256 | * get 1'st bookmark. Inside frame is "correct" location. We use |
5252 | * it later | 5257 | * it later |
5253 | */ | 5258 | */ |
5254 | while (error==ERR_NONE) { | 5259 | while (error==ERR_NONE) { |
5255 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); | 5260 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); |
5256 | Bookmark.Location = 1; | 5261 | Bookmark.Location = 1; |
5257 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 5262 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
5258 | printmsgerr("*"); | 5263 | printmsgerr("*"); |
5259 | } | 5264 | } |
5260 | printmsgerr("\n"); | 5265 | printmsgerr("\n"); |
5261 | } | 5266 | } |
5262 | } | 5267 | } |
5263 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { | 5268 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { |
5264 | if (answer_yes("Delete all user ringtones")) { | 5269 | if (answer_yes("Delete all user ringtones")) { |
5265 | printmsgerr("Deleting: "); | 5270 | printmsgerr("Deleting: "); |
5266 | error=Phone->DeleteUserRingtones(&s); | 5271 | error=Phone->DeleteUserRingtones(&s); |
5267 | Print_Error(error); | 5272 | Print_Error(error); |
5268 | printmsgerr("Done\n"); | 5273 | printmsgerr("Done\n"); |
5269 | } | 5274 | } |
5270 | } | 5275 | } |
5271 | Station.Location=i; | 5276 | Station.Location=i; |
5272 | error=Phone->GetFMStation(&s,&Station); | 5277 | error=Phone->GetFMStation(&s,&Station); |
5273 | if (error == ERR_NONE || error == ERR_EMPTY) { | 5278 | if (error == ERR_NONE || error == ERR_EMPTY) { |
5274 | if (answer_yes("Delete all FM station")) { | 5279 | if (answer_yes("Delete all FM station")) { |
5275 | error=Phone->ClearFMStations(&s); | 5280 | error=Phone->ClearFMStations(&s); |
5276 | Print_Error(error); | 5281 | Print_Error(error); |
5277 | } | 5282 | } |
5278 | } | 5283 | } |
5279 | 5284 | ||
5280 | GSM_Terminate(); | 5285 | GSM_Terminate(); |
5281 | } | 5286 | } |
5282 | 5287 | ||
5283 | static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) | 5288 | static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) |
5284 | { | 5289 | { |
5285 | if (settings->Settings[j].IsContinuous) { | 5290 | if (settings->Settings[j].IsContinuous) { |
5286 | printmsg("Connection type : Continuous\n"); | 5291 | printmsg("Connection type : Continuous\n"); |
5287 | } else { | 5292 | } else { |
5288 | printmsg("Connection type : Temporary\n"); | 5293 | printmsg("Connection type : Temporary\n"); |
5289 | } | 5294 | } |
5290 | if (settings->Settings[j].IsSecurity) { | 5295 | if (settings->Settings[j].IsSecurity) { |
5291 | printmsg("Connection security : On\n"); | 5296 | printmsg("Connection security : On\n"); |
5292 | } else { | 5297 | } else { |
5293 | printmsg("Connection security : Off\n"); | 5298 | printmsg("Connection security : Off\n"); |
5294 | } | 5299 | } |
5295 | printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); | 5300 | printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); |
5296 | printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); | 5301 | printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); |
5297 | switch (settings->Settings[j].Bearer) { | 5302 | switch (settings->Settings[j].Bearer) { |
5298 | case WAPSETTINGS_BEARER_SMS: | 5303 | case WAPSETTINGS_BEARER_SMS: |
5299 | printmsg("Bearer : SMS"); | 5304 | printmsg("Bearer : SMS"); |
5300 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); | 5305 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); |
5301 | printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); | 5306 | printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); |
5302 | printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); | 5307 | printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); |
5303 | break; | 5308 | break; |
5304 | case WAPSETTINGS_BEARER_DATA: | 5309 | case WAPSETTINGS_BEARER_DATA: |
5305 | printmsg("Bearer : Data (CSD)"); | 5310 | printmsg("Bearer : Data (CSD)"); |
5306 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); | 5311 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); |
5307 | printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); | 5312 | printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); |
5308 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); | 5313 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); |
5309 | if (settings->Settings[j].ManualLogin) { | 5314 | if (settings->Settings[j].ManualLogin) { |
5310 | printmsg("Login Type : Manual\n"); | 5315 | printmsg("Login Type : Manual\n"); |
5311 | } else { | 5316 | } else { |
5312 | printmsg("Login Type : Automatic\n"); | 5317 | printmsg("Login Type : Automatic\n"); |
5313 | } | 5318 | } |
5314 | if (settings->Settings[j].IsNormalAuthentication) { | 5319 | if (settings->Settings[j].IsNormalAuthentication) { |
5315 | printmsg("Authentication type : Normal\n"); | 5320 | printmsg("Authentication type : Normal\n"); |
5316 | } else { | 5321 | } else { |
5317 | printmsg("Authentication type : Secure\n"); | 5322 | printmsg("Authentication type : Secure\n"); |
5318 | } | 5323 | } |
5319 | if (settings->Settings[j].IsISDNCall) { | 5324 | if (settings->Settings[j].IsISDNCall) { |
5320 | printmsg("Data call type : ISDN\n"); | 5325 | printmsg("Data call type : ISDN\n"); |
5321 | } else { | 5326 | } else { |
5322 | printmsg("Data call type : Analogue\n"); | 5327 | printmsg("Data call type : Analogue\n"); |
5323 | } | 5328 | } |
5324 | switch (settings->Settings[j].Speed) { | 5329 | switch (settings->Settings[j].Speed) { |
5325 | case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; | 5330 | case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; |
5326 | case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; | 5331 | case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; |
5327 | case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; | 5332 | case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; |
5328 | } | 5333 | } |
5329 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); | 5334 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); |
5330 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); | 5335 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); |
5331 | break; | 5336 | break; |
5332 | case WAPSETTINGS_BEARER_USSD: | 5337 | case WAPSETTINGS_BEARER_USSD: |
5333 | printmsg("Bearer : USSD"); | 5338 | printmsg("Bearer : USSD"); |
5334 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); | 5339 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); |
5335 | printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); | 5340 | printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); |
5336 | if (settings->Settings[j].IsIP) { | 5341 | if (settings->Settings[j].IsIP) { |
5337 | printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); | 5342 | printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); |
5338 | } else { | 5343 | } else { |
5339 | printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); | 5344 | printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); |
5340 | } | 5345 | } |
5341 | break; | 5346 | break; |
5342 | case WAPSETTINGS_BEARER_GPRS: | 5347 | case WAPSETTINGS_BEARER_GPRS: |
5343 | printmsg("Bearer : GPRS"); | 5348 | printmsg("Bearer : GPRS"); |
5344 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); | 5349 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); |
5345 | if (settings->Settings[j].ManualLogin) { | 5350 | if (settings->Settings[j].ManualLogin) { |
5346 | printmsg("\nLogin Type : Manual\n"); | 5351 | printmsg("\nLogin Type : Manual\n"); |
5347 | } else { | 5352 | } else { |
5348 | printmsg("\nLogin Type : Automatic\n"); | 5353 | printmsg("\nLogin Type : Automatic\n"); |
5349 | } | 5354 | } |
5350 | if (settings->Settings[j].IsNormalAuthentication) { | 5355 | if (settings->Settings[j].IsNormalAuthentication) { |
5351 | printmsg("Authentication type : Normal\n"); | 5356 | printmsg("Authentication type : Normal\n"); |
5352 | } else { | 5357 | } else { |
5353 | printmsg("Authentication type : Secure\n"); | 5358 | printmsg("Authentication type : Secure\n"); |
5354 | } | 5359 | } |
5355 | printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); | 5360 | printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); |
5356 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); | 5361 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); |
5357 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); | 5362 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); |
5358 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); | 5363 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); |
5359 | } | 5364 | } |
5360 | } | 5365 | } |
5361 | 5366 | ||
5362 | static void GetSyncMLSettings(int argc, char *argv[]) | 5367 | static void GetSyncMLSettings(int argc, char *argv[]) |
5363 | { | 5368 | { |
5364 | GSM_SyncMLSettingssettings; | 5369 | GSM_SyncMLSettingssettings; |
5365 | int start,stop,j; | 5370 | int start,stop,j; |
5366 | 5371 | ||
5367 | GetStartStop(&start, &stop, 2, argc, argv); | 5372 | GetStartStop(&start, &stop, 2, argc, argv); |
5368 | 5373 | ||
5369 | GSM_Init(true); | 5374 | GSM_Init(true); |
5370 | 5375 | ||
5371 | for (i=start;i<=stop;i++) { | 5376 | for (i=start;i<=stop;i++) { |
5372 | settings.Location=i; | 5377 | settings.Location=i; |
5373 | error=Phone->GetSyncMLSettings(&s,&settings); | 5378 | error=Phone->GetSyncMLSettings(&s,&settings); |
5374 | Print_Error(error); | 5379 | Print_Error(error); |
5375 | printmsg("%i. ",i); | 5380 | printmsg("%i. ",i); |
5376 | if (settings.Name[0]==0 && settings.Name[1]==0) { | 5381 | if (settings.Name[0]==0 && settings.Name[1]==0) { |
5377 | printmsg("Set %i",i); | 5382 | printmsg("Set %i",i); |
5378 | } else { | 5383 | } else { |
5379 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); | 5384 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); |
5380 | } | 5385 | } |
5381 | if (settings.Active) printmsg(" (active)"); | 5386 | if (settings.Active) printmsg(" (active)"); |
5382 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); | 5387 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); |
5383 | printmsg("\n"); | 5388 | printmsg("\n"); |
5384 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); | 5389 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); |
5385 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); | 5390 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); |
5386 | printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); | 5391 | printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); |
5387 | printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); | 5392 | printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); |
5388 | printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); | 5393 | printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); |
5389 | printmsg("Sync. phonebook : "); | 5394 | printmsg("Sync. phonebook : "); |
5390 | if (settings.SyncPhonebook) printmsg("yes\n"); | 5395 | if (settings.SyncPhonebook) printmsg("yes\n"); |
5391 | if (!settings.SyncPhonebook) printmsg("no\n"); | 5396 | if (!settings.SyncPhonebook) printmsg("no\n"); |
5392 | printmsg("Sync. calendar : "); | 5397 | printmsg("Sync. calendar : "); |
5393 | if (settings.SyncCalendar) printmsg("yes\n"); | 5398 | if (settings.SyncCalendar) printmsg("yes\n"); |
5394 | if (!settings.SyncCalendar) printmsg("no\n"); | 5399 | if (!settings.SyncCalendar) printmsg("no\n"); |
5395 | printmsg("\n"); | 5400 | printmsg("\n"); |
5396 | for (j=0;j<settings.Connection.Number;j++) { | 5401 | for (j=0;j<settings.Connection.Number;j++) { |
5397 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { | 5402 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { |
5398 | printmsg("Connection set name : Set %i\n",i); | 5403 | printmsg("Connection set name : Set %i\n",i); |
5399 | } else { | 5404 | } else { |
5400 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); | 5405 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); |
5401 | } | 5406 | } |
5402 | DisplayConnectionSettings(&settings.Connection,j); | 5407 | DisplayConnectionSettings(&settings.Connection,j); |
5403 | printf("\n"); | 5408 | printf("\n"); |
5404 | } | 5409 | } |
5405 | } | 5410 | } |
5406 | GSM_Terminate(); | 5411 | GSM_Terminate(); |
5407 | } | 5412 | } |
5408 | 5413 | ||
5409 | static void GetChatSettings(int argc, char *argv[]) | 5414 | static void GetChatSettings(int argc, char *argv[]) |
5410 | { | 5415 | { |
5411 | GSM_ChatSettingssettings; | 5416 | GSM_ChatSettingssettings; |
5412 | int start,stop,j; | 5417 | int start,stop,j; |
5413 | 5418 | ||
5414 | GetStartStop(&start, &stop, 2, argc, argv); | 5419 | GetStartStop(&start, &stop, 2, argc, argv); |
5415 | 5420 | ||
5416 | GSM_Init(true); | 5421 | GSM_Init(true); |
5417 | 5422 | ||
5418 | for (i=start;i<=stop;i++) { | 5423 | for (i=start;i<=stop;i++) { |
5419 | settings.Location=i; | 5424 | settings.Location=i; |
5420 | error=Phone->GetChatSettings(&s,&settings); | 5425 | error=Phone->GetChatSettings(&s,&settings); |
5421 | Print_Error(error); | 5426 | Print_Error(error); |
5422 | printmsg("%i. ",i); | 5427 | printmsg("%i. ",i); |
5423 | if (settings.Name[0]==0 && settings.Name[1]==0) { | 5428 | if (settings.Name[0]==0 && settings.Name[1]==0) { |
5424 | printmsg("Set %i",i); | 5429 | printmsg("Set %i",i); |
5425 | } else { | 5430 | } else { |
5426 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); | 5431 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); |
5427 | } | 5432 | } |
5428 | if (settings.Active) printmsg(" (active)"); | 5433 | if (settings.Active) printmsg(" (active)"); |
5429 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); | 5434 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); |
5430 | printmsg("\n"); | 5435 | printmsg("\n"); |
5431 | printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); | 5436 | printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); |
5432 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); | 5437 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); |
5433 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); | 5438 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); |
5434 | printmsg("\n"); | 5439 | printmsg("\n"); |
5435 | for (j=0;j<settings.Connection.Number;j++) { | 5440 | for (j=0;j<settings.Connection.Number;j++) { |
5436 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { | 5441 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { |
5437 | printmsg("Connection set name : Set %i\n",i); | 5442 | printmsg("Connection set name : Set %i\n",i); |
5438 | } else { | 5443 | } else { |
5439 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); | 5444 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); |
5440 | } | 5445 | } |
5441 | DisplayConnectionSettings(&settings.Connection,j); | 5446 | DisplayConnectionSettings(&settings.Connection,j); |
5442 | printf("\n"); | 5447 | printf("\n"); |
5443 | } | 5448 | } |
5444 | } | 5449 | } |
5445 | GSM_Terminate(); | 5450 | GSM_Terminate(); |
5446 | } | 5451 | } |
5447 | 5452 | ||
5448 | static void GetWAPMMSSettings(int argc, char *argv[]) | 5453 | static void GetWAPMMSSettings(int argc, char *argv[]) |
5449 | { | 5454 | { |
5450 | GSM_MultiWAPSettingssettings; | 5455 | GSM_MultiWAPSettingssettings; |
5451 | int start,stop,j; | 5456 | int start,stop,j; |
5452 | 5457 | ||
5453 | GetStartStop(&start, &stop, 2, argc, argv); | 5458 | GetStartStop(&start, &stop, 2, argc, argv); |
5454 | 5459 | ||
5455 | GSM_Init(true); | 5460 | GSM_Init(true); |
5456 | 5461 | ||
5457 | for (i=start;i<=stop;i++) { | 5462 | for (i=start;i<=stop;i++) { |
5458 | settings.Location=i; | 5463 | settings.Location=i; |
@@ -7609,820 +7614,819 @@ void SearchPhoneThread(OneDeviceInfo *Info) | |||
7609 | Info->s.Phone.Data.Model); | 7614 | Info->s.Phone.Data.Model); |
7610 | } else { | 7615 | } else { |
7611 | if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); | 7616 | if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); |
7612 | } | 7617 | } |
7613 | } else { | 7618 | } else { |
7614 | if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); | 7619 | if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); |
7615 | } | 7620 | } |
7616 | } else { | 7621 | } else { |
7617 | if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); | 7622 | if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); |
7618 | } | 7623 | } |
7619 | if (error != ERR_DEVICEOPENERROR) { | 7624 | if (error != ERR_DEVICEOPENERROR) { |
7620 | GSM_TerminateConnection(&Info->s); | 7625 | GSM_TerminateConnection(&Info->s); |
7621 | dbgprintf("Closing done\n"); | 7626 | dbgprintf("Closing done\n"); |
7622 | } | 7627 | } |
7623 | if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break; | 7628 | if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break; |
7624 | j++; | 7629 | j++; |
7625 | } | 7630 | } |
7626 | num--; | 7631 | num--; |
7627 | #endif | 7632 | #endif |
7628 | } | 7633 | } |
7629 | 7634 | ||
7630 | //#undef HAVE_PTHREAD | 7635 | //#undef HAVE_PTHREAD |
7631 | //#if 0 | 7636 | //#if 0 |
7632 | #if defined(WIN32) || defined(HAVE_PTHREAD) | 7637 | #if defined(WIN32) || defined(HAVE_PTHREAD) |
7633 | #ifdef HAVE_PTHREAD | 7638 | #ifdef HAVE_PTHREAD |
7634 | pthread_t Thread[100]; | 7639 | pthread_t Thread[100]; |
7635 | #endif | 7640 | #endif |
7636 | 7641 | ||
7637 | void MakeSearchThread(int i) | 7642 | void MakeSearchThread(int i) |
7638 | { | 7643 | { |
7639 | num++; | 7644 | num++; |
7640 | #ifdef HAVE_PTHREAD | 7645 | #ifdef HAVE_PTHREAD |
7641 | if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) { | 7646 | if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) { |
7642 | dbgprintf("Error creating thread\n"); | 7647 | dbgprintf("Error creating thread\n"); |
7643 | } | 7648 | } |
7644 | #else | 7649 | #else |
7645 | if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, | 7650 | if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, |
7646 | (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i], | 7651 | (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i], |
7647 | 0,NULL)==NULL) { | 7652 | 0,NULL)==NULL) { |
7648 | dbgprintf("Error creating thread\n"); | 7653 | dbgprintf("Error creating thread\n"); |
7649 | } | 7654 | } |
7650 | #endif | 7655 | #endif |
7651 | } | 7656 | } |
7652 | 7657 | ||
7653 | static void SearchPhone(int argc, char *argv[]) | 7658 | static void SearchPhone(int argc, char *argv[]) |
7654 | { | 7659 | { |
7655 | int i,dev = 0, dev2 = 0; | 7660 | int i,dev = 0, dev2 = 0; |
7656 | 7661 | ||
7657 | SearchOutput = false; | 7662 | SearchOutput = false; |
7658 | if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true; | 7663 | if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true; |
7659 | 7664 | ||
7660 | num = 0; | 7665 | num = 0; |
7661 | #ifdef WIN32 | 7666 | #ifdef WIN32 |
7662 | # ifdef GSM_ENABLE_IRDADEVICE | 7667 | # ifdef GSM_ENABLE_IRDADEVICE |
7663 | sprintf(SearchDevices[dev].Device,""); | 7668 | sprintf(SearchDevices[dev].Device,""); |
7664 | sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); | 7669 | sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); |
7665 | SearchDevices[dev].Connections[1].Connection[0] = 0; | 7670 | SearchDevices[dev].Connections[1].Connection[0] = 0; |
7666 | dev++; | 7671 | dev++; |
7667 | # endif | 7672 | # endif |
7668 | # ifdef GSM_ENABLE_SERIALDEVICE | 7673 | # ifdef GSM_ENABLE_SERIALDEVICE |
7669 | dev2 = dev; | 7674 | dev2 = dev; |
7670 | for(i=0;i<10;i++) { | 7675 | for(i=0;i<10;i++) { |
7671 | sprintf(SearchDevices[dev2].Device,"com%i:",i+1); | 7676 | sprintf(SearchDevices[dev2].Device,"com%i:",i+1); |
7672 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); | 7677 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); |
7673 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); | 7678 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); |
7674 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); | 7679 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); |
7675 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); | 7680 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); |
7676 | SearchDevices[dev2].Connections[4].Connection[0] = 0; | 7681 | SearchDevices[dev2].Connections[4].Connection[0] = 0; |
7677 | dev2++; | 7682 | dev2++; |
7678 | } | 7683 | } |
7679 | # endif | 7684 | # endif |
7680 | #endif | 7685 | #endif |
7681 | #ifdef __linux__ | 7686 | #ifdef __linux__ |
7682 | # ifdef GSM_ENABLE_IRDADEVICE | 7687 | # ifdef GSM_ENABLE_IRDADEVICE |
7683 | for(i=0;i<6;i++) { | 7688 | for(i=0;i<6;i++) { |
7684 | sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i); | 7689 | sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i); |
7685 | sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); | 7690 | sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); |
7686 | sprintf(SearchDevices[dev].Connections[1].Connection,"at19200"); | 7691 | sprintf(SearchDevices[dev].Connections[1].Connection,"at19200"); |
7687 | SearchDevices[dev].Connections[2].Connection[0] = 0; | 7692 | SearchDevices[dev].Connections[2].Connection[0] = 0; |
7688 | dev++; | 7693 | dev++; |
7689 | } | 7694 | } |
7690 | # endif | 7695 | # endif |
7691 | # ifdef GSM_ENABLE_SERIALDEVICE | 7696 | # ifdef GSM_ENABLE_SERIALDEVICE |
7692 | dev2 = dev; | 7697 | dev2 = dev; |
7693 | for(i=0;i<10;i++) { | 7698 | for(i=0;i<10;i++) { |
7694 | sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i); | 7699 | sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i); |
7695 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); | 7700 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); |
7696 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); | 7701 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); |
7697 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); | 7702 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); |
7698 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); | 7703 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); |
7699 | SearchDevices[dev2].Connections[4].Connection[0] = 0; | 7704 | SearchDevices[dev2].Connections[4].Connection[0] = 0; |
7700 | dev2++; | 7705 | dev2++; |
7701 | } | 7706 | } |
7702 | for(i=0;i<8;i++) { | 7707 | for(i=0;i<8;i++) { |
7703 | sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i); | 7708 | sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i); |
7704 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); | 7709 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); |
7705 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); | 7710 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); |
7706 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); | 7711 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); |
7707 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); | 7712 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); |
7708 | SearchDevices[dev2].Connections[4].Connection[0] = 0; | 7713 | SearchDevices[dev2].Connections[4].Connection[0] = 0; |
7709 | dev2++; | 7714 | dev2++; |
7710 | } | 7715 | } |
7711 | for(i=0;i<4;i++) { | 7716 | for(i=0;i<4;i++) { |
7712 | sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i); | 7717 | sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i); |
7713 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); | 7718 | sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); |
7714 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); | 7719 | sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); |
7715 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); | 7720 | sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); |
7716 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); | 7721 | sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); |
7717 | SearchDevices[dev2].Connections[4].Connection[0] = 0; | 7722 | SearchDevices[dev2].Connections[4].Connection[0] = 0; |
7718 | dev2++; | 7723 | dev2++; |
7719 | } | 7724 | } |
7720 | # endif | 7725 | # endif |
7721 | #endif | 7726 | #endif |
7722 | for(i=0;i<dev;i++) MakeSearchThread(i); | 7727 | for(i=0;i<dev;i++) MakeSearchThread(i); |
7723 | while (num != 0) my_sleep(5); | 7728 | while (num != 0) my_sleep(5); |
7724 | for(i=dev;i<dev2;i++) MakeSearchThread(i); | 7729 | for(i=dev;i<dev2;i++) MakeSearchThread(i); |
7725 | while (num != 0) my_sleep(5); | 7730 | while (num != 0) my_sleep(5); |
7726 | } | 7731 | } |
7727 | #endif /*Support for threads */ | 7732 | #endif /*Support for threads */ |
7728 | // #if 0 | 7733 | // #if 0 |
7729 | static void NokiaGetADC(int argc, char *argv[]) | 7734 | static void NokiaGetADC(int argc, char *argv[]) |
7730 | { | 7735 | { |
7731 | GSM_Init(true); | 7736 | GSM_Init(true); |
7732 | 7737 | ||
7733 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 7738 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
7734 | DCT3GetADC(argc,argv); | 7739 | DCT3GetADC(argc,argv); |
7735 | #endif | 7740 | #endif |
7736 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 7741 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
7737 | DCT4GetADC(argc, argv); | 7742 | DCT4GetADC(argc, argv); |
7738 | #endif | 7743 | #endif |
7739 | 7744 | ||
7740 | GSM_Terminate(); | 7745 | GSM_Terminate(); |
7741 | } | 7746 | } |
7742 | 7747 | ||
7743 | static void NokiaDisplayTest(int argc, char *argv[]) | 7748 | static void NokiaDisplayTest(int argc, char *argv[]) |
7744 | { | 7749 | { |
7745 | GSM_Init(true); | 7750 | GSM_Init(true); |
7746 | 7751 | ||
7747 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 7752 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
7748 | DCT3DisplayTest(argc,argv); | 7753 | DCT3DisplayTest(argc,argv); |
7749 | #endif | 7754 | #endif |
7750 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 7755 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
7751 | DCT4DisplayTest(argc, argv); | 7756 | DCT4DisplayTest(argc, argv); |
7752 | #endif | 7757 | #endif |
7753 | 7758 | ||
7754 | GSM_Terminate(); | 7759 | GSM_Terminate(); |
7755 | } | 7760 | } |
7756 | 7761 | ||
7757 | static void NokiaGetT9(int argc, char *argv[]) | 7762 | static void NokiaGetT9(int argc, char *argv[]) |
7758 | { | 7763 | { |
7759 | GSM_Init(true); | 7764 | GSM_Init(true); |
7760 | 7765 | ||
7761 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 7766 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
7762 | DCT3GetT9(argc,argv); | 7767 | DCT3GetT9(argc,argv); |
7763 | #endif | 7768 | #endif |
7764 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 7769 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
7765 | DCT4GetT9(argc, argv); | 7770 | DCT4GetT9(argc, argv); |
7766 | #endif | 7771 | #endif |
7767 | 7772 | ||
7768 | GSM_Terminate(); | 7773 | GSM_Terminate(); |
7769 | } | 7774 | } |
7770 | 7775 | ||
7771 | static void NokiaVibraTest(int argc, char *argv[]) | 7776 | static void NokiaVibraTest(int argc, char *argv[]) |
7772 | { | 7777 | { |
7773 | GSM_Init(true); | 7778 | GSM_Init(true); |
7774 | 7779 | ||
7775 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 7780 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
7776 | DCT3VibraTest(argc,argv); | 7781 | DCT3VibraTest(argc,argv); |
7777 | #endif | 7782 | #endif |
7778 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 7783 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
7779 | DCT4VibraTest(argc, argv); | 7784 | DCT4VibraTest(argc, argv); |
7780 | #endif | 7785 | #endif |
7781 | 7786 | ||
7782 | GSM_Terminate(); | 7787 | GSM_Terminate(); |
7783 | } | 7788 | } |
7784 | 7789 | ||
7785 | static GSM_Parameters Parameters[] = { | 7790 | static GSM_Parameters Parameters[] = { |
7786 | {"--identify", 0, 0, Identify, {H_Info,0}, ""}, | 7791 | {"--identify", 0, 0, Identify, {H_Info,0}, ""}, |
7787 | {"--version", 0, 0, Version, {H_Other,0}, ""}, | 7792 | {"--version", 0, 0, Version, {H_Other,0}, ""}, |
7788 | {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""}, | 7793 | {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""}, |
7789 | {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"}, | 7794 | {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"}, |
7790 | {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""}, | 7795 | {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""}, |
7791 | {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""}, | 7796 | {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""}, |
7792 | {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"}, | 7797 | {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"}, |
7793 | {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"}, | 7798 | {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"}, |
7794 | {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"}, | 7799 | {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"}, |
7795 | {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""}, | 7800 | {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""}, |
7796 | {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."}, | 7801 | {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."}, |
7797 | {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."}, | 7802 | {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."}, |
7798 | {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"}, | 7803 | {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"}, |
7799 | {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"}, | 7804 | {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"}, |
7800 | {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"}, | 7805 | {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"}, |
7801 | {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, | 7806 | {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, |
7802 | {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, | 7807 | {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, |
7803 | {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, | 7808 | {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, |
7804 | {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, | 7809 | {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, |
7805 | {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, | 7810 | {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, |
7806 | {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, | 7811 | {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, |
7807 | {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, | 7812 | {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, |
7808 | {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"}, | 7813 | {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"}, |
7809 | {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"}, | 7814 | {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"}, |
7810 | {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"}, | 7815 | {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"}, |
7811 | {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"}, | 7816 | {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"}, |
7812 | {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"}, | 7817 | {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"}, |
7813 | {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"}, | 7818 | {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"}, |
7814 | {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"}, | 7819 | {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"}, |
7815 | {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"}, | 7820 | {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"}, |
7816 | {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"}, | 7821 | {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"}, |
7817 | {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"}, | 7822 | {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"}, |
7818 | {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"}, | 7823 | {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"}, |
7819 | {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""}, | 7824 | {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""}, |
7820 | {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""}, | 7825 | {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""}, |
7821 | {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""}, | 7826 | {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""}, |
7822 | 7827 | ||
7823 | #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]" | 7828 | #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]" |
7824 | #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]" | 7829 | #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]" |
7825 | #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]" | 7830 | #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]" |
7826 | #define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]" | 7831 | #define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]" |
7827 | #define SMS_SMSTEMPLATE_OPTIONS"[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]" | 7832 | #define SMS_SMSTEMPLATE_OPTIONS"[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]" |
7828 | #define SMS_ANIMATION_OPTIONS"" | 7833 | #define SMS_ANIMATION_OPTIONS"" |
7829 | #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]" | 7834 | #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]" |
7830 | #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]" | 7835 | #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]" |
7831 | #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]" | 7836 | #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]" |
7832 | #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]" | 7837 | #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]" |
7833 | 7838 | ||
7834 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, | 7839 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, |
7835 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7840 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7836 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, | 7841 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, |
7837 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7842 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7838 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, | 7843 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, |
7839 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, | 7844 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, |
7840 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7845 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7841 | #ifdef GSM_ENABLE_BACKUP | 7846 | #ifdef GSM_ENABLE_BACKUP |
7842 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7847 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7843 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7848 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7844 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7849 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7845 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7850 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7846 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7851 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7847 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, | 7852 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, |
7848 | #endif | 7853 | #endif |
7849 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS}, | 7854 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS}, |
7850 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, | 7855 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, |
7851 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, | 7856 | {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, |
7852 | 7857 | ||
7853 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, | 7858 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, |
7854 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7859 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7855 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, | 7860 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, |
7856 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7861 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7857 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, | 7862 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, |
7858 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, | 7863 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, |
7859 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7864 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7860 | #ifdef GSM_ENABLE_BACKUP | 7865 | #ifdef GSM_ENABLE_BACKUP |
7861 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7866 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7862 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7867 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7863 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7868 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7864 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7869 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7865 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7870 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7866 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, | 7871 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, |
7867 | #endif | 7872 | #endif |
7868 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS}, | 7873 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS}, |
7869 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, | 7874 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, |
7870 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, | 7875 | {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, |
7871 | 7876 | ||
7872 | {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"}, | 7877 | {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"}, |
7873 | 7878 | ||
7874 | {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"}, | 7879 | {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"}, |
7875 | #ifdef HAVE_MYSQL_MYSQL_H | 7880 | #ifdef HAVE_MYSQL_MYSQL_H |
7876 | {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"}, | 7881 | {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"}, |
7877 | #endif | 7882 | #endif |
7878 | {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"}, | 7883 | {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"}, |
7879 | {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"}, | 7884 | {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"}, |
7880 | {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, | 7885 | {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, |
7881 | {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, | 7886 | {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, |
7882 | {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""}, | 7887 | {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""}, |
7883 | {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"}, | 7888 | {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"}, |
7884 | {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"}, | 7889 | {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"}, |
7885 | {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"}, | 7890 | {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"}, |
7886 | {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"}, | 7891 | {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"}, |
7887 | {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"}, | 7892 | {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"}, |
7888 | {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"}, | 7893 | {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"}, |
7889 | {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"}, | 7894 | {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"}, |
7890 | {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"}, | 7895 | {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"}, |
7891 | {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"}, | 7896 | {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"}, |
7892 | {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"}, | 7897 | {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"}, |
7893 | {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"}, | 7898 | {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"}, |
7894 | {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"}, | 7899 | {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"}, |
7895 | {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"}, | 7900 | {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"}, |
7896 | {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"}, | 7901 | {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"}, |
7897 | {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"}, | 7902 | {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"}, |
7898 | {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""}, | 7903 | {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""}, |
7899 | {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"}, | 7904 | {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"}, |
7900 | {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""}, | 7905 | {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""}, |
7901 | {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""}, | 7906 | {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""}, |
7902 | {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"}, | 7907 | {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"}, |
7903 | {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"}, | 7908 | {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"}, |
7904 | {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"}, | 7909 | {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"}, |
7905 | {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"}, | 7910 | {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"}, |
7906 | {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"}, | 7911 | {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"}, |
7907 | {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""}, | 7912 | {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""}, |
7908 | {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"}, | 7913 | {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"}, |
7909 | {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"}, | 7914 | {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"}, |
7910 | {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"}, | 7915 | {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"}, |
7911 | {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"}, | 7916 | {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"}, |
7912 | {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"}, | 7917 | {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"}, |
7913 | {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""}, | 7918 | {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""}, |
7914 | {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"}, | 7919 | {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"}, |
7915 | {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"}, | 7920 | {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"}, |
7916 | {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"}, | 7921 | {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"}, |
7917 | {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"}, | 7922 | {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"}, |
7918 | {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"}, | 7923 | {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"}, |
7919 | {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"}, | 7924 | {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"}, |
7920 | {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"}, | 7925 | {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"}, |
7921 | {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"}, | 7926 | {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"}, |
7922 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"}, | 7927 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"}, |
7923 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"}, | 7928 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"}, |
7924 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"}, | 7929 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"}, |
7925 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"}, | 7930 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"}, |
7926 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"}, | 7931 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"}, |
7927 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"}, | 7932 | {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"}, |
7928 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"}, | 7933 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"}, |
7929 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"}, | 7934 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"}, |
7930 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"}, | 7935 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"}, |
7931 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"}, | 7936 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"}, |
7932 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"}, | 7937 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"}, |
7933 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"}, | 7938 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"}, |
7934 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"}, | 7939 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"}, |
7935 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"}, | 7940 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"}, |
7936 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"}, | 7941 | {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"}, |
7937 | {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"}, | 7942 | {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"}, |
7938 | {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"}, | 7943 | {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"}, |
7939 | #if defined(WIN32) || defined(HAVE_PTHREAD) | 7944 | #if defined(WIN32) || defined(HAVE_PTHREAD) |
7940 | {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"}, | 7945 | {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"}, |
7941 | #endif | 7946 | #endif |
7942 | #ifdef GSM_ENABLE_BACKUP | 7947 | #ifdef GSM_ENABLE_BACKUP |
7943 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"}, | 7948 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"}, |
7944 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"}, | 7949 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"}, |
7945 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"}, | 7950 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"}, |
7946 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"}, | 7951 | {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"}, |
7947 | {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"}, | 7952 | {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"}, |
7948 | {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"}, | 7953 | {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"}, |
7949 | {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, | 7954 | {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, |
7950 | {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, | 7955 | {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, |
7951 | {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"}, | 7956 | {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"}, |
7952 | {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"}, | 7957 | {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"}, |
7953 | #endif | 7958 | #endif |
7954 | {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""}, | 7959 | {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""}, |
7955 | {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""}, | 7960 | {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""}, |
7956 | #ifdef GSM_ENABLE_AT | 7961 | #ifdef GSM_ENABLE_AT |
7957 | {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""}, | 7962 | {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""}, |
7958 | {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"}, | 7963 | {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"}, |
7959 | {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"}, | 7964 | {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"}, |
7960 | #endif | 7965 | #endif |
7961 | #ifdef GSM_ENABLE_NOKIA6110 | 7966 | #ifdef GSM_ENABLE_NOKIA6110 |
7962 | {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""}, | 7967 | {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""}, |
7963 | {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"}, | 7968 | {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"}, |
7964 | {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""}, | 7969 | {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""}, |
7965 | #endif | 7970 | #endif |
7966 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 7971 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
7967 | {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"}, | 7972 | {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"}, |
7968 | {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""}, | 7973 | {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""}, |
7969 | {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"}, | 7974 | {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"}, |
7970 | #endif | 7975 | #endif |
7971 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 7976 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
7972 | {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"}, | 7977 | {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"}, |
7973 | {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"}, | 7978 | {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"}, |
7974 | {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"}, | 7979 | {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"}, |
7975 | {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""}, | 7980 | {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""}, |
7976 | {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""}, | 7981 | {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""}, |
7977 | {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""}, | 7982 | {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""}, |
7978 | #endif | 7983 | #endif |
7979 | #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) | 7984 | #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) |
7980 | {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""}, | 7985 | {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""}, |
7981 | {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""}, | 7986 | {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""}, |
7982 | {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"}, | 7987 | {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"}, |
7983 | {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""}, | 7988 | {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""}, |
7984 | {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""}, | 7989 | {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""}, |
7985 | {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""}, | 7990 | {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""}, |
7986 | {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""}, | 7991 | {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""}, |
7987 | #endif | 7992 | #endif |
7988 | #ifdef DEBUG | 7993 | #ifdef DEBUG |
7989 | {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"}, | 7994 | {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"}, |
7990 | {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"}, | 7995 | {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"}, |
7991 | {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"}, | 7996 | {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"}, |
7992 | #endif | 7997 | #endif |
7993 | {"", 0, 0, NULL } | 7998 | {"", 0, 0, NULL } |
7994 | }; | 7999 | }; |
7995 | 8000 | ||
7996 | static HelpCategoryDescriptions HelpDescriptions[] = { | 8001 | static HelpCategoryDescriptions HelpDescriptions[] = { |
7997 | {H_Call, "call", "Calls",}, | 8002 | {H_Call, "call", "Calls",}, |
7998 | {H_SMS, "sms", "SMS and EMS"}, | 8003 | {H_SMS, "sms", "SMS and EMS"}, |
7999 | {H_Memory, "memory","Memory (phonebooks and calls)"}, | 8004 | {H_Memory, "memory","Memory (phonebooks and calls)"}, |
8000 | {H_Filesystem, "filesystem","Filesystem"}, | 8005 | {H_Filesystem, "filesystem","Filesystem"}, |
8001 | {H_Logo, "logo", "Logo and pictures"}, | 8006 | {H_Logo, "logo", "Logo and pictures"}, |
8002 | {H_Ringtone, "ringtone","Ringtones"}, | 8007 | {H_Ringtone, "ringtone","Ringtones"}, |
8003 | {H_Calendar, "calendar","Calendar notes"}, | 8008 | {H_Calendar, "calendar","Calendar notes"}, |
8004 | {H_ToDo, "todo", "To do lists"}, | 8009 | {H_ToDo, "todo", "To do lists"}, |
8005 | {H_Note, "note", "Notes"}, | 8010 | {H_Note, "note", "Notes"}, |
8006 | {H_DateTime, "datetime","Date, time and alarms"}, | 8011 | {H_DateTime, "datetime","Date, time and alarms"}, |
8007 | {H_Category, "category","Categories"}, | 8012 | {H_Category, "category","Categories"}, |
8008 | #ifdef GSM_ENABLE_BACKUP | 8013 | #ifdef GSM_ENABLE_BACKUP |
8009 | {H_Backup, "backup","Backing up and restoring"}, | 8014 | {H_Backup, "backup","Backing up and restoring"}, |
8010 | #endif | 8015 | #endif |
8011 | #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) | 8016 | #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) |
8012 | {H_Nokia, "nokia","Nokia specific"}, | 8017 | {H_Nokia, "nokia","Nokia specific"}, |
8013 | #endif | 8018 | #endif |
8014 | #ifdef GSM_ENABLE_AT | 8019 | #ifdef GSM_ENABLE_AT |
8015 | {H_Siemens, "siemens","Siemens specific"}, | 8020 | {H_Siemens, "siemens","Siemens specific"}, |
8016 | #endif | 8021 | #endif |
8017 | {H_Network, "network","Network"}, | 8022 | {H_Network, "network","Network"}, |
8018 | {H_WAP, "wap", "WAP settings and bookmarks"}, | 8023 | {H_WAP, "wap", "WAP settings and bookmarks"}, |
8019 | {H_MMS, "mms", "MMS and MMS settings"}, | 8024 | {H_MMS, "mms", "MMS and MMS settings"}, |
8020 | {H_Tests, "tests","Phone tests"}, | 8025 | {H_Tests, "tests","Phone tests"}, |
8021 | {H_FM, "fm", "FM radio"}, | 8026 | {H_FM, "fm", "FM radio"}, |
8022 | {H_Info, "info", "Phone information"}, | 8027 | {H_Info, "info", "Phone information"}, |
8023 | {H_Settings, "settings","Phone settings"}, | 8028 | {H_Settings, "settings","Phone settings"}, |
8024 | #ifdef DEBUG | 8029 | #ifdef DEBUG |
8025 | {H_Decode, "decode","Dumps decoding"}, | 8030 | {H_Decode, "decode","Dumps decoding"}, |
8026 | #endif | 8031 | #endif |
8027 | {H_Other, "other","Functions that don't fit elsewhere"}, | 8032 | {H_Other, "other","Functions that don't fit elsewhere"}, |
8028 | {0, NULL, NULL} | 8033 | {0, NULL, NULL} |
8029 | }; | 8034 | }; |
8030 | 8035 | ||
8031 | 8036 | ||
8032 | void HelpHeader(void) | 8037 | void HelpHeader(void) |
8033 | { | 8038 | { |
8034 | printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); | 8039 | printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); |
8035 | } | 8040 | } |
8036 | 8041 | ||
8037 | static void HelpGeneral(void) | 8042 | static void HelpGeneral(void) |
8038 | { | 8043 | { |
8039 | inti=0; | 8044 | inti=0; |
8040 | 8045 | ||
8041 | HelpHeader(); | 8046 | HelpHeader(); |
8042 | 8047 | ||
8043 | printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n"); | 8048 | printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n"); |
8044 | printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n"); | 8049 | printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n"); |
8045 | printmsg("Second parameter optionally controls debug level, next specify actions.\n\n"); | 8050 | printmsg("Second parameter optionally controls debug level, next specify actions.\n\n"); |
8046 | 8051 | ||
8047 | /* We might want to put here some most used commands */ | 8052 | /* We might want to put here some most used commands */ |
8048 | printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n"); | 8053 | printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n"); |
8049 | 8054 | ||
8050 | while (HelpDescriptions[i].category != 0) { | 8055 | while (HelpDescriptions[i].category != 0) { |
8051 | printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description); | 8056 | printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description); |
8052 | i++; | 8057 | i++; |
8053 | } | 8058 | } |
8054 | printf("\n"); | 8059 | printf("\n"); |
8055 | } | 8060 | } |
8056 | 8061 | ||
8057 | static void HelpSplit(int cols, int len, unsigned char *buff) | 8062 | static void HelpSplit(int cols, int len, unsigned char *buff) |
8058 | { | 8063 | { |
8059 | int l, len2, pos, split; | 8064 | int l, len2, pos, split; |
8060 | bool in_opt,first=true; | 8065 | bool in_opt,first=true; |
8061 | char *remain, spaces[50], buffer[500]; | 8066 | char *remain, spaces[50], buffer[500]; |
8062 | 8067 | ||
8063 | if (cols == 0) { | 8068 | if (cols == 0) { |
8064 | printf(" %s\n", buff); | 8069 | printf(" %s\n", buff); |
8065 | } else { | 8070 | } else { |
8066 | printf(" "); | 8071 | printf(" "); |
8067 | spaces[0] = 0; | 8072 | spaces[0] = 0; |
8068 | len2 = strlen(buff); | 8073 | len2 = strlen(buff); |
8069 | if (len + len2 < cols) { | 8074 | if (len + len2 < cols) { |
8070 | printf("%s\n", buff); | 8075 | printf("%s\n", buff); |
8071 | } else { | 8076 | } else { |
8072 | for(l = 0; l < len; l++) strcat(spaces, " "); | 8077 | for(l = 0; l < len; l++) strcat(spaces, " "); |
8073 | 8078 | ||
8074 | remain = buff; | 8079 | remain = buff; |
8075 | 8080 | ||
8076 | while (strlen(remain) > 0) { | 8081 | while (strlen(remain) > 0) { |
8077 | split= 0; | 8082 | split= 0; |
8078 | pos= 0; | 8083 | pos= 0; |
8079 | in_opt= false; | 8084 | in_opt= false; |
8080 | if (!first) printf(spaces); | 8085 | if (!first) printf(spaces); |
8081 | while (pos < cols - len && remain[pos] != 0) { | 8086 | while (pos < cols - len && remain[pos] != 0) { |
8082 | if (in_opt && remain[pos] == ']') { | 8087 | if (in_opt && remain[pos] == ']') { |
8083 | in_opt = false; | 8088 | in_opt = false; |
8084 | split = pos; | 8089 | split = pos; |
8085 | } else if (remain[pos] == '[') { | 8090 | } else if (remain[pos] == '[') { |
8086 | in_opt = true; | 8091 | in_opt = true; |
8087 | } else if (!in_opt && remain[pos] == ' ') { | 8092 | } else if (!in_opt && remain[pos] == ' ') { |
8088 | split = pos - 1; | 8093 | split = pos - 1; |
8089 | } | 8094 | } |
8090 | pos++; | 8095 | pos++; |
8091 | } | 8096 | } |
8092 | /* Can not be split */ | 8097 | /* Can not be split */ |
8093 | if (split == 0) { | 8098 | if (split == 0) { |
8094 | printf("%s\n", remain); | 8099 | printf("%s\n", remain); |
8095 | remain += strlen(remain); | 8100 | remain += strlen(remain); |
8096 | } else { | 8101 | } else { |
8097 | first = false; | 8102 | first = false; |
8098 | split++; | 8103 | split++; |
8099 | strncpy(buffer, remain, split); | 8104 | strncpy(buffer, remain, split); |
8100 | buffer[split] = 0; | 8105 | buffer[split] = 0; |
8101 | printf("%s\n", buffer); | 8106 | printf("%s\n", buffer); |
8102 | remain += split; | 8107 | remain += split; |
8103 | if (remain[0] == ' ') remain++; | 8108 | if (remain[0] == ' ') remain++; |
8104 | } | 8109 | } |
8105 | } | 8110 | } |
8106 | } | 8111 | } |
8107 | } | 8112 | } |
8108 | } | 8113 | } |
8109 | 8114 | ||
8110 | static void Help(int argc, char *argv[]) | 8115 | static void Help(int argc, char *argv[]) |
8111 | { | 8116 | { |
8112 | int i = 0, j = 0, k, cols; | 8117 | int i = 0, j = 0, k, cols; |
8113 | bool disp; | 8118 | bool disp; |
8114 | #ifdef TIOCGWINSZ | 8119 | #ifdef TIOCGWINSZ |
8115 | struct winsize w; | 8120 | struct winsize w; |
8116 | #endif | 8121 | #endif |
8117 | #if defined(WIN32) || defined(DJGPP) | 8122 | #if defined(WIN32) || defined(DJGPP) |
8118 | #else | 8123 | #else |
8119 | char *columns; | 8124 | char *columns; |
8120 | #endif | 8125 | #endif |
8121 | 8126 | ||
8122 | /* Just --help */ | 8127 | /* Just --help */ |
8123 | if (argc == 2) { | 8128 | if (argc == 2) { |
8124 | HelpGeneral(); | 8129 | HelpGeneral(); |
8125 | return; | 8130 | return; |
8126 | } | 8131 | } |
8127 | 8132 | ||
8128 | if (!strcmp(argv[2],"all")) { | 8133 | if (!strcmp(argv[2],"all")) { |
8129 | HelpHeader(); | 8134 | HelpHeader(); |
8130 | } else { | 8135 | } else { |
8131 | while (HelpDescriptions[i].category != 0) { | 8136 | while (HelpDescriptions[i].category != 0) { |
8132 | if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break; | 8137 | if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break; |
8133 | i++; | 8138 | i++; |
8134 | } | 8139 | } |
8135 | if (HelpDescriptions[i].category == 0) { | 8140 | if (HelpDescriptions[i].category == 0) { |
8136 | HelpGeneral(); | 8141 | HelpGeneral(); |
8137 | printmsg("Unknown help topic specified!\n"); | 8142 | printmsg("Unknown help topic specified!\n"); |
8138 | return; | 8143 | return; |
8139 | } | 8144 | } |
8140 | HelpHeader(); | 8145 | HelpHeader(); |
8141 | printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description); | 8146 | printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description); |
8142 | } | 8147 | } |
8143 | 8148 | ||
8144 | #if defined(WIN32) || defined(DJGPP) | 8149 | #if defined(WIN32) || defined(DJGPP) |
8145 | cols = 80; | 8150 | cols = 80; |
8146 | #else | 8151 | #else |
8147 | cols = 0; | 8152 | cols = 0; |
8148 | /* If stdout is a tty, we will wrap to columns it has */ | 8153 | /* If stdout is a tty, we will wrap to columns it has */ |
8149 | if (isatty(1)) { | 8154 | if (isatty(1)) { |
8150 | #ifdef TIOCGWINSZ | 8155 | #ifdef TIOCGWINSZ |
8151 | if (ioctl(2, TIOCGWINSZ, &w) == 0) { | 8156 | if (ioctl(2, TIOCGWINSZ, &w) == 0) { |
8152 | if (w.ws_col > 0) cols = w.ws_col; | 8157 | if (w.ws_col > 0) cols = w.ws_col; |
8153 | } | 8158 | } |
8154 | #endif | 8159 | #endif |
8155 | if (cols == 0) { | 8160 | if (cols == 0) { |
8156 | columns = getenv("COLUMNS"); | 8161 | columns = getenv("COLUMNS"); |
8157 | if (columns != NULL) { | 8162 | if (columns != NULL) { |
8158 | cols = atoi(columns); | 8163 | cols = atoi(columns); |
8159 | if (cols <= 0) cols = 0; | 8164 | if (cols <= 0) cols = 0; |
8160 | } | 8165 | } |
8161 | } | 8166 | } |
8162 | 8167 | ||
8163 | if (cols == 0) { | 8168 | if (cols == 0) { |
8164 | /* Fallback */ | 8169 | /* Fallback */ |
8165 | cols = 80; | 8170 | cols = 80; |
8166 | } | 8171 | } |
8167 | } | 8172 | } |
8168 | #endif | 8173 | #endif |
8169 | 8174 | ||
8170 | while (Parameters[j].Function != NULL) { | 8175 | while (Parameters[j].Function != NULL) { |
8171 | k = 0; | 8176 | k = 0; |
8172 | disp = false; | 8177 | disp = false; |
8173 | if (!strcmp(argv[2],"all")) { | 8178 | if (!strcmp(argv[2],"all")) { |
8174 | if (j==0) disp = true; | 8179 | if (j==0) disp = true; |
8175 | if (j!=0) { | 8180 | if (j!=0) { |
8176 | if (strcmp(Parameters[j].help,Parameters[j-1].help)) { | 8181 | if (strcmp(Parameters[j].help,Parameters[j-1].help)) { |
8177 | disp = true; | 8182 | disp = true; |
8178 | } else { | 8183 | } else { |
8179 | if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) { | 8184 | if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) { |
8180 | disp = true; | 8185 | disp = true; |
8181 | } | 8186 | } |
8182 | } | 8187 | } |
8183 | } | 8188 | } |
8184 | } else { | 8189 | } else { |
8185 | while (Parameters[j].help_cat[k] != 0) { | 8190 | while (Parameters[j].help_cat[k] != 0) { |
8186 | if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) { | 8191 | if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) { |
8187 | disp = true; | 8192 | disp = true; |
8188 | break; | 8193 | break; |
8189 | } | 8194 | } |
8190 | k++; | 8195 | k++; |
8191 | } | 8196 | } |
8192 | } | 8197 | } |
8193 | if (disp) { | 8198 | if (disp) { |
8194 | printf("%s", Parameters[j].parameter); | 8199 | printf("%s", Parameters[j].parameter); |
8195 | if (Parameters[j].help[0] == 0) { | 8200 | if (Parameters[j].help[0] == 0) { |
8196 | printf("\n"); | 8201 | printf("\n"); |
8197 | } else { | 8202 | } else { |
8198 | HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help); | 8203 | HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help); |
8199 | } | 8204 | } |
8200 | } | 8205 | } |
8201 | j++; | 8206 | j++; |
8202 | } | 8207 | } |
8203 | } | 8208 | } |
8204 | #if 0 | 8209 | #if 0 |
8205 | #endif // 0 | 8210 | #endif // 0 |
8206 | int main(int argc, char *argv[]) | 8211 | int main(int argc, char *argv[]) |
8207 | { | 8212 | { |
8208 | 8213 | ||
8209 | //fprintf(stderr,"HIIIIIIIIIIIII \n"); | 8214 | //fprintf(stderr,"HIIIIIIIIIIIII \n"); |
8210 | //#if 0 | 8215 | //#if 0 |
8211 | static int z ,start,i; | 8216 | static int z ,start,i; |
8212 | static intonly_config ; | 8217 | static intonly_config ; |
8213 | #if !defined(WIN32) && defined(LOCALE_PATH) | 8218 | #if !defined(WIN32) && defined(LOCALE_PATH) |
8214 | static char*locale, locale_file[201]; | 8219 | static char*locale, locale_file[201]; |
8215 | #endif | 8220 | #endif |
8216 | static char*cp; | 8221 | static char*cp; |
8217 | static boolcount_failed; | 8222 | static boolcount_failed; |
8218 | z = 0; | 8223 | z = 0; |
8219 | start=0;only_config = -1;count_failed = false; | 8224 | start=0;only_config = -1;count_failed = false; |
8220 | s.opened = false; | 8225 | s.opened = false; |
8221 | s.msg = NULL; | 8226 | s.msg = NULL; |
8222 | s.ConfigNum = 0; | 8227 | s.ConfigNum = 0; |
8223 | 8228 | ||
8224 | setlocale(LC_ALL, ""); | 8229 | setlocale(LC_ALL, ""); |
8225 | #ifdef DEBUG | 8230 | #ifdef DEBUG |
8226 | di.dl = DL_TEXTALL; | 8231 | di.dl = DL_TEXTALL; |
8227 | di.df = stdout; | 8232 | di.df = stdout; |
8228 | #endif | 8233 | #endif |
8229 | //#if 0 | 8234 | //#if 0 |
8230 | /* Any parameters? */ | 8235 | /* Any parameters? */ |
8231 | if (argc == 1) { | 8236 | if (argc == 1) { |
8232 | HelpGeneral(); | 8237 | HelpGeneral(); |
8233 | printmsg("Too few parameters!\n"); | 8238 | printmsg("Too few parameters!\n"); |
8234 | exit(1); | 8239 | exit(1); |
8235 | } | 8240 | } |
8236 | 8241 | ||
8237 | /* Help? */ | 8242 | /* Help? */ |
8238 | if (strncmp(argv[1 + start], "--help", 6) == 0) { | 8243 | if (strncmp(argv[1 + start], "--help", 6) == 0) { |
8239 | Help(argc - start, argv + start); | 8244 | Help(argc - start, argv + start); |
8240 | exit(1); | 8245 | exit(1); |
8241 | } | 8246 | } |
8242 | 8247 | ||
8243 | /* Is first parameter numeric? If so treat it as config that should be loaded. */ | 8248 | /* Is first parameter numeric? If so treat it as config that should be loaded. */ |
8244 | //if (isdigit(argv[1][0])) { | 8249 | //if (isdigit(argv[1][0])) { |
8245 | //only_config = atoi(argv[1]); | 8250 | //only_config = atoi(argv[1]); |
8246 | //if (only_config >= 0) start++; else only_config = -1; | 8251 | //if (only_config >= 0) start++; else only_config = -1; |
8247 | //} | 8252 | //} |
8248 | only_config = 0;; | 8253 | only_config = 0;; |
8249 | #if 0 | 8254 | #if 0 |
8250 | GSM_ReadConfig(NULL, &s.Config[0], 0); | 8255 | GSM_ReadConfig(NULL, &s.Config[0], 0); |
8251 | s.ConfigNum = 1; | 8256 | s.ConfigNum = 1; |
8252 | GSM_Config *con = &s.Config[0]; | 8257 | GSM_Config *con = &s.Config[0]; |
8253 | 8258 | ||
8254 | char* tempC; | 8259 | char* tempC; |
8255 | tempC = argv[argc-1]+2; | 8260 | tempC = argv[argc-1]+2; |
8256 | if ( *tempC != 0 ) { | 8261 | if ( *tempC != 0 ) { |
8257 | fprintf(stderr,"Using model %s \n",tempC); | 8262 | fprintf(stderr,"Using model %s \n",tempC); |
8258 | strcpy(con->Model,tempC ); | 8263 | strcpy(con->Model,tempC ); |
8259 | } | 8264 | } |
8260 | tempC = argv[argc-2]+2; | 8265 | tempC = argv[argc-2]+2; |
8261 | if ( *tempC != 0 ) { | 8266 | if ( *tempC != 0 ) { |
8262 | fprintf(stderr,"Using device %s \n",tempC); | 8267 | fprintf(stderr,"Using device %s \n",tempC); |
8263 | con->Device = strdup(tempC); | 8268 | con->Device = strdup(tempC); |
8264 | con->DefaultDevice = false; | 8269 | con->DefaultDevice = false; |
8265 | } | 8270 | } |
8266 | tempC = argv[argc-3]+2; | 8271 | tempC = argv[argc-3]+2; |
8267 | if ( *tempC != 0 ) { | 8272 | if ( *tempC != 0 ) { |
8268 | fprintf(stderr,"Using connection %s \n",tempC); | 8273 | fprintf(stderr,"Using connection %s \n",tempC); |
8269 | con->Connection = strdup(tempC); | 8274 | con->Connection = strdup(tempC); |
8270 | con->DefaultConnection = false; | 8275 | con->DefaultConnection = false; |
8271 | } | 8276 | } |
8272 | argc = argc-3; | 8277 | argc = argc-3; |
8273 | //#if 0 | 8278 | //#if 0 |
8274 | if ( ! mConnection.isEmpty() ) { | 8279 | if ( ! mConnection.isEmpty() ) { |
8275 | cfg->Connection = strdup(mConnection.latin1()); | 8280 | cfg->Connection = strdup(mConnection.latin1()); |
8276 | cfg->DefaultConnection = false; | 8281 | cfg->DefaultConnection = false; |
8277 | qDebug("Connection set %s ", cfg->Connection ); | 8282 | qDebug("Connection set %s ", cfg->Connection ); |
8278 | 8283 | ||
8279 | } | 8284 | } |
8280 | if ( ! mDevice.isEmpty() ) { | 8285 | if ( ! mDevice.isEmpty() ) { |
8281 | cfg->Device = strdup(mDevice.latin1()); | 8286 | cfg->Device = strdup(mDevice.latin1()); |
8282 | cfg->DefaultDevice = false; | 8287 | cfg->DefaultDevice = false; |
8283 | qDebug("Device set %s ", cfg->Device); | 8288 | qDebug("Device set %s ", cfg->Device); |
8284 | 8289 | ||
8285 | } | 8290 | } |
8286 | if ( ! mModel.isEmpty() ) { | 8291 | if ( ! mModel.isEmpty() ) { |
8287 | strcpy(cfg->Model,mModel.latin1() ); | 8292 | strcpy(cfg->Model,mModel.latin1() ); |
8288 | cfg->DefaultModel = false; | 8293 | cfg->DefaultModel = false; |
8289 | qDebug("Model set %s ",cfg->Model ); | 8294 | qDebug("Model set %s ",cfg->Model ); |
8290 | } | 8295 | } |
8291 | 8296 | ||
8292 | #endif | 8297 | #endif |
8293 | 8298 | ||
8294 | 8299 | ||
8295 | cfg=GSM_FindGammuRC(); | 8300 | cfg=GSM_FindGammuRC(); |
8296 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | 8301 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { |
8297 | if (cfg!=NULL) { | 8302 | if (cfg!=NULL) { |
8298 | cp = INI_GetValue(cfg, "gammu", "gammucoding", false); | 8303 | cp = INI_GetValue(cfg, "gammu", "gammucoding", false); |
8299 | if (cp) di.coding = cp; | 8304 | if (cp) di.coding = cp; |
8300 | 8305 | ||
8301 | s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); | 8306 | s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); |
8302 | if (s.Config[i].Localize) { | 8307 | if (s.Config[i].Localize) { |
8303 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | 8308 | s.msg=INI_ReadFile(s.Config[i].Localize, true); |
8304 | } else { | 8309 | } else { |
8305 | #if !defined(WIN32) && defined(LOCALE_PATH) | 8310 | #if !defined(WIN32) && defined(LOCALE_PATH) |
8306 | locale = setlocale(LC_MESSAGES, NULL); | 8311 | locale = setlocale(LC_MESSAGES, NULL); |
8307 | if (locale != NULL) { | 8312 | if (locale != NULL) { |
8308 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", | 8313 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", |
8309 | LOCALE_PATH, | 8314 | LOCALE_PATH, |
8310 | tolower(locale[0]), | 8315 | tolower(locale[0]), |
8311 | tolower(locale[1])); | 8316 | tolower(locale[1])); |
8312 | s.msg = INI_ReadFile(locale_file, true); | 8317 | s.msg = INI_ReadFile(locale_file, true); |
8313 | } | 8318 | } |
8314 | #endif | 8319 | #endif |
8315 | } | 8320 | } |
8316 | } | 8321 | } |
8317 | 8322 | ||
8318 | /* Wanted user specific configuration? */ | 8323 | /* Wanted user specific configuration? */ |
8319 | 8324 | ||
8320 | if (only_config != -1) { | 8325 | if (only_config != -1) { |
8321 | /* Here we get only in first for loop */ | 8326 | /* Here we get only in first for loop */ |
8322 | if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; | 8327 | if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; |
8323 | } else { | 8328 | } else { |
8324 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; | 8329 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; |
8325 | } | 8330 | } |
8326 | s.ConfigNum++; | 8331 | s.ConfigNum++; |
8327 | 8332 | ||
8328 | /* We want to use only one file descriptor for global and state machine debug output */ | 8333 | /* We want to use only one file descriptor for global and state machine debug output */ |
8329 | s.Config[i].UseGlobalDebugFile = true; | 8334 | s.Config[i].UseGlobalDebugFile = true; |
8330 | 8335 | ||
8331 | /* It makes no sense to open several debug logs... */ | 8336 | /* It makes no sense to open several debug logs... */ |
8332 | if (i != 0) { | 8337 | if (i != 0) { |
8333 | strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); | 8338 | strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); |
8334 | free(s.Config[i].DebugFile); | 8339 | free(s.Config[i].DebugFile); |
8335 | s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); | 8340 | s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); |
8336 | } else { | 8341 | } else { |
8337 | /* Just for first config */ | 8342 | /* Just for first config */ |
8338 | /* When user gave debug level on command line */ | 8343 | /* When user gave debug level on command line */ |
8339 | if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { | 8344 | if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { |
8340 | /* Debug level from command line will be used with phone too */ | 8345 | /* Debug level from command line will be used with phone too */ |
8341 | strcpy(s.Config[i].DebugLevel,argv[1 + start]); | 8346 | strcpy(s.Config[i].DebugLevel,argv[1 + start]); |
8342 | start++; | 8347 | start++; |
8343 | } else { | 8348 | } else { |
8344 | /* Try to set debug level from config file */ | 8349 | /* Try to set debug level from config file */ |
8345 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); | 8350 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); |
8346 | } | 8351 | } |
8347 | /* If user gave debug file in gammurc, we will use it */ | 8352 | /* If user gave debug file in gammurc, we will use it */ |
8348 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); | 8353 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); |
8349 | Print_Error(error); | 8354 | Print_Error(error); |
8350 | } | 8355 | } |
8351 | 8356 | ||
8352 | /* We wanted to read just user specified configuration. */ | 8357 | /* We wanted to read just user specified configuration. */ |
8353 | if (only_config != -1) {break;} | 8358 | if (only_config != -1) {break;} |
8354 | } | 8359 | } |
8355 | #if 0 | 8360 | #if 0 |
8356 | GSM_Config *con = &s.Config[0]; | 8361 | GSM_Config *con = &s.Config[0]; |
8357 | 8362 | ||
8358 | char* tempC; | 8363 | char* tempC; |
8359 | tempC = argv[argc-1]+2; | 8364 | tempC = argv[argc-1]+2; |
8360 | if ( *tempC != 0 ) { | 8365 | if ( *tempC != 0 ) { |
8361 | fprintf(stderr,"Using model %s \n",tempC); | 8366 | fprintf(stderr,"Using model %s \n",tempC); |
8362 | strcpy(con->Model,tempC ); | 8367 | strcpy(con->Model,tempC ); |
8363 | } | 8368 | } |
8364 | tempC = argv[argc-2]+2; | 8369 | tempC = argv[argc-2]+2; |
8365 | if ( *tempC != 0 ) { | 8370 | if ( *tempC != 0 ) { |
8366 | fprintf(stderr,"Using device %s \n",tempC); | 8371 | fprintf(stderr,"Using device %s \n",tempC); |
8367 | con->Device = strdup(tempC); | 8372 | con->Device = strdup(tempC); |
8368 | con->DefaultDevice = false; | 8373 | con->DefaultDevice = false; |
8369 | } | 8374 | } |
8370 | tempC = argv[argc-3]+2; | 8375 | tempC = argv[argc-3]+2; |
8371 | if ( *tempC != 0 ) { | 8376 | if ( *tempC != 0 ) { |
8372 | fprintf(stderr,"Using connection %s \n",tempC); | 8377 | fprintf(stderr,"Using connection %s \n",tempC); |
8373 | con->Connection = strdup(tempC); | 8378 | con->Connection = strdup(tempC); |
8374 | con->DefaultConnection = false; | 8379 | con->DefaultConnection = false; |
8375 | } | 8380 | } |
8376 | #endif | 8381 | #endif |
8377 | argc = argc-3; | ||
8378 | 8382 | ||
8379 | 8383 | ||
8380 | /* Do we have enough parameters? */ | 8384 | /* Do we have enough parameters? */ |
8381 | if (argc == 1 + start) { | 8385 | if (argc == 1 + start) { |
8382 | HelpGeneral(); | 8386 | HelpGeneral(); |
8383 | printmsg("Too few parameters!\n"); | 8387 | printmsg("Too few parameters!\n"); |
8384 | exit(-2); | 8388 | exit(-2); |
8385 | } | 8389 | } |
8386 | 8390 | ||
8387 | /* Check used version vs. compiled */ | 8391 | /* Check used version vs. compiled */ |
8388 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { | 8392 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { |
8389 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", | 8393 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", |
8390 | GetGammuVersion(),VERSION); | 8394 | GetGammuVersion(),VERSION); |
8391 | exit(-1); | 8395 | exit(-1); |
8392 | } | 8396 | } |
8393 | 8397 | ||
8394 | /* Check parameters */ | 8398 | /* Check parameters */ |
8395 | while (Parameters[z].Function != NULL) { | 8399 | while (Parameters[z].Function != NULL) { |
8396 | if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { | 8400 | if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { |
8397 | if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { | 8401 | if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { |
8398 | fprintf(stderr,"Executing \n"); | 8402 | fprintf(stderr,"Executing \n"); |
8399 | Parameters[z].Function(argc - start, argv + start); | 8403 | Parameters[z].Function(argc - start, argv + start); |
8400 | break; | 8404 | break; |
8401 | } else { | 8405 | } else { |
8402 | count_failed = true; | 8406 | count_failed = true; |
8403 | } | 8407 | } |
8404 | } | 8408 | } |
8405 | z++; | 8409 | z++; |
8406 | } | 8410 | } |
8407 | 8411 | ||
8408 | /* Tell user when we did nothing */ | 8412 | /* Tell user when we did nothing */ |
8409 | if (Parameters[z].Function == NULL) { | 8413 | if (Parameters[z].Function == NULL) { |
8410 | HelpGeneral(); | 8414 | HelpGeneral(); |
8411 | if (count_failed) { | 8415 | if (count_failed) { |
8412 | printmsg("Bad parameter count!\n"); | 8416 | printmsg("Bad parameter count!\n"); |
8413 | } else { | 8417 | } else { |
8414 | printmsg("Bad option!\n"); | 8418 | printmsg("Bad option!\n"); |
8415 | } | 8419 | } |
8416 | } | 8420 | } |
8417 | 8421 | ||
8418 | /* Close debug output if opened */ | 8422 | /* Close debug output if opened */ |
8419 | if (di.df!=stdout) fclose(di.df); | 8423 | if (di.df!=stdout) fclose(di.df); |
8420 | //#endif // 0 | 8424 | //#endif // 0 |
8421 | fprintf(stderr,"kammu: Success. End. \n"); | 8425 | fprintf(stderr,"kammu: Success. End. \n"); |
8422 | exit(0); | 8426 | exit(0); |
8423 | } | 8427 | } |
8424 | 8428 | ||
8425 | /* How should editor hadle tabs in this file? Add editor commands here. | 8429 | /* How should editor hadle tabs in this file? Add editor commands here. |
8426 | * vim: noexpandtab sw=8 ts=8 sts=8: | 8430 | * vim: noexpandtab sw=8 ts=8 sts=8: |
8427 | */ | 8431 | */ |
8428 | 8432 | ||
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 6df639f..ef69bce 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,620 +1,636 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qxml.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | 39 | ||
40 | #include "calendar.h" | 40 | #include "calendar.h" |
41 | #include "alarm.h" | 41 | #include "alarm.h" |
42 | #include "recurrence.h" | 42 | #include "recurrence.h" |
43 | #include "calendarlocal.h" | 43 | #include "calendarlocal.h" |
44 | 44 | ||
45 | #include "phoneformat.h" | 45 | #include "phoneformat.h" |
46 | #include "syncdefines.h" | 46 | #include "syncdefines.h" |
47 | 47 | ||
48 | using namespace KCal; | 48 | using namespace KCal; |
49 | class PhoneParser : public QObject | 49 | class PhoneParser : public QObject |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | PhoneParser( ) { | 52 | PhoneParser( ) { |
53 | ; | 53 | ; |
54 | } | 54 | } |
55 | 55 | ||
56 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) | 56 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
57 | { | 57 | { |
58 | QString datestr; | 58 | QString datestr; |
59 | QString timestr; | 59 | QString timestr; |
60 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 60 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
61 | QDateTime dt; | 61 | QDateTime dt; |
62 | if (useTZ) | 62 | if (useTZ) |
63 | dt = dti.addSecs ( -(offset*60)); | 63 | dt = dti.addSecs ( -(offset*60)); |
64 | else | 64 | else |
65 | dt = dti; | 65 | dt = dti; |
66 | if(dt.date().isValid()){ | 66 | if(dt.date().isValid()){ |
67 | const QDate& date = dt.date(); | 67 | const QDate& date = dt.date(); |
68 | datestr.sprintf("%04d%02d%02d", | 68 | datestr.sprintf("%04d%02d%02d", |
69 | date.year(), date.month(), date.day()); | 69 | date.year(), date.month(), date.day()); |
70 | } | 70 | } |
71 | if(dt.time().isValid()){ | 71 | if(dt.time().isValid()){ |
72 | const QTime& time = dt.time(); | 72 | const QTime& time = dt.time(); |
73 | timestr.sprintf("T%02d%02d%02d", | 73 | timestr.sprintf("T%02d%02d%02d", |
74 | time.hour(), time.minute(), time.second()); | 74 | time.hour(), time.minute(), time.second()); |
75 | } | 75 | } |
76 | return datestr + timestr; | 76 | return datestr + timestr; |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 84 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
85 | { | 85 | { |
86 | mProfileName = profileName; | 86 | mProfileName = profileName; |
87 | mDevice = device; | 87 | mDevice = device; |
88 | mConnection = connection; | 88 | mConnection = connection; |
89 | mModel = model; | 89 | mModel = model; |
90 | } | 90 | } |
91 | 91 | ||
92 | PhoneFormat::~PhoneFormat() | 92 | PhoneFormat::~PhoneFormat() |
93 | { | 93 | { |
94 | } | 94 | } |
95 | #if 0 | 95 | #if 0 |
96 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 96 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
97 | { | 97 | { |
98 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 98 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
99 | s->ConfigNum = 1; | 99 | s->ConfigNum = 1; |
100 | GSM_Config *cfg = &s->Config[0]; | 100 | GSM_Config *cfg = &s->Config[0]; |
101 | if ( ! mConnection.isEmpty() ) { | 101 | if ( ! mConnection.isEmpty() ) { |
102 | cfg->Connection = strdup(mConnection.latin1()); | 102 | cfg->Connection = strdup(mConnection.latin1()); |
103 | cfg->DefaultConnection = false; | 103 | cfg->DefaultConnection = false; |
104 | qDebug("Connection set %s ", cfg->Connection ); | 104 | qDebug("Connection set %s ", cfg->Connection ); |
105 | 105 | ||
106 | } | 106 | } |
107 | if ( ! mDevice.isEmpty() ) { | 107 | if ( ! mDevice.isEmpty() ) { |
108 | cfg->Device = strdup(mDevice.latin1()); | 108 | cfg->Device = strdup(mDevice.latin1()); |
109 | cfg->DefaultDevice = false; | 109 | cfg->DefaultDevice = false; |
110 | qDebug("Device set %s ", cfg->Device); | 110 | qDebug("Device set %s ", cfg->Device); |
111 | 111 | ||
112 | } | 112 | } |
113 | if ( ! mModel.isEmpty() ) { | 113 | if ( ! mModel.isEmpty() ) { |
114 | strcpy(cfg->Model,mModel.latin1() ); | 114 | strcpy(cfg->Model,mModel.latin1() ); |
115 | cfg->DefaultModel = false; | 115 | cfg->DefaultModel = false; |
116 | qDebug("Model set %s ",cfg->Model ); | 116 | qDebug("Model set %s ",cfg->Model ); |
117 | } | 117 | } |
118 | int error=GSM_InitConnection(s,3); | 118 | int error=GSM_InitConnection(s,3); |
119 | return error; | 119 | return error; |
120 | } | 120 | } |
121 | #endif | 121 | #endif |
122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) |
123 | { | 123 | { |
124 | QStringList attList; | 124 | QStringList attList; |
125 | if ( todo->hasDueDate() ) | 125 | if ( todo->hasDueDate() ) |
126 | attList << PhoneParser::dtToString ( todo->dtDue() ); | 126 | attList << PhoneParser::dtToString ( todo->dtDue() ); |
127 | attList << todo->summary(); | 127 | attList << todo->summary(); |
128 | QString completedString = "no"; | 128 | QString completedString = "no"; |
129 | if ( todo->isCompleted() ) | 129 | if ( todo->isCompleted() ) |
130 | completedString = "yes"; | 130 | completedString = "yes"; |
131 | attList << completedString; | 131 | attList << completedString; |
132 | attList << QString::number( todo->priority() ); | 132 | int prio = todo->priority(); |
133 | if( prio == 2 ) prio = 1; | ||
134 | if (prio == 4 ) prio = 5 ; | ||
135 | attList << QString::number( prio ); | ||
133 | QString alarmString = "na"; | 136 | QString alarmString = "na"; |
134 | Alarm *alarm; | 137 | Alarm *alarm; |
135 | if ( todo->alarms().count() > 0 ) { | 138 | if ( todo->alarms().count() > 0 ) { |
136 | alarm = todo->alarms().first(); | 139 | alarm = todo->alarms().first(); |
137 | if ( alarm->enabled() ) { | 140 | if ( alarm->enabled() ) { |
138 | alarmString = QString::number(alarm->startOffset().asSeconds() ); | 141 | alarmString = QString::number(alarm->startOffset().asSeconds() ); |
139 | } | 142 | } |
140 | } | 143 | } |
141 | attList << alarmString; | 144 | attList << alarmString; |
142 | attList << todo->categoriesStr(); | 145 | attList << todo->categoriesStr(); |
143 | attList << todo->secrecyStr(); | 146 | attList << todo->secrecyStr(); |
144 | return PhoneFormat::getCsum(attList ); | 147 | return PhoneFormat::getCsum(attList ); |
145 | 148 | ||
146 | } | 149 | } |
147 | ulong PhoneFormat::getCsumEvent( Event* event ) | 150 | ulong PhoneFormat::getCsumEvent( Event* event ) |
148 | { | 151 | { |
149 | QStringList attList; | 152 | QStringList attList; |
150 | attList << PhoneParser::dtToString ( event->dtStart() ); | 153 | attList << PhoneParser::dtToString ( event->dtStart() ); |
151 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 154 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
152 | attList << event->summary(); | 155 | attList << event->summary(); |
153 | attList << event->location(); | 156 | attList << event->location(); |
154 | QString alarmString = "na"; | 157 | QString alarmString = "na"; |
155 | Alarm *alarm; | 158 | Alarm *alarm; |
156 | if ( event->alarms().count() > 0 ) { | 159 | if ( event->alarms().count() > 0 ) { |
157 | alarm = event->alarms().first(); | 160 | alarm = event->alarms().first(); |
158 | if ( alarm->enabled() ) { | 161 | if ( alarm->enabled() ) { |
159 | alarmString = QString::number( alarm->startOffset().asSeconds() ); | 162 | alarmString = QString::number( alarm->startOffset().asSeconds() ); |
160 | } | 163 | } |
161 | } | 164 | } |
162 | attList << alarmString; | 165 | attList << alarmString; |
163 | Recurrence* rec = event->recurrence(); | 166 | Recurrence* rec = event->recurrence(); |
164 | QStringList list; | 167 | QStringList list; |
165 | bool writeEndDate = false; | 168 | bool writeEndDate = false; |
166 | switch ( rec->doesRecur() ) | 169 | switch ( rec->doesRecur() ) |
167 | { | 170 | { |
168 | case Recurrence::rDaily: // 0 | 171 | case Recurrence::rDaily: // 0 |
169 | list.append( "0" ); | 172 | list.append( "0" ); |
170 | list.append( QString::number( rec->frequency() ));//12 | 173 | list.append( QString::number( rec->frequency() ));//12 |
171 | list.append( "0" ); | 174 | list.append( "0" ); |
172 | list.append( "0" ); | 175 | list.append( "0" ); |
173 | writeEndDate = true; | 176 | writeEndDate = true; |
174 | break; | 177 | break; |
175 | case Recurrence::rWeekly:// 1 | 178 | case Recurrence::rWeekly:// 1 |
176 | list.append( "1" ); | 179 | list.append( "1" ); |
177 | list.append( QString::number( rec->frequency()) );//12 | 180 | list.append( QString::number( rec->frequency()) );//12 |
178 | list.append( "0" ); | 181 | list.append( "0" ); |
179 | { | 182 | { |
180 | int days = 0; | 183 | int days = 0; |
181 | QBitArray weekDays = rec->days(); | 184 | QBitArray weekDays = rec->days(); |
182 | int i; | 185 | int i; |
183 | for( i = 1; i <= 7; ++i ) { | 186 | for( i = 1; i <= 7; ++i ) { |
184 | if ( weekDays[i-1] ) { | 187 | if ( weekDays[i-1] ) { |
185 | days += 1 << (i-1); | 188 | days += 1 << (i-1); |
186 | } | 189 | } |
187 | } | 190 | } |
188 | list.append( QString::number( days ) ); | 191 | list.append( QString::number( days ) ); |
189 | } | 192 | } |
190 | //pending weekdays | 193 | //pending weekdays |
191 | writeEndDate = true; | 194 | writeEndDate = true; |
192 | 195 | ||
193 | break; | 196 | break; |
194 | case Recurrence::rMonthlyPos:// 2 | 197 | case Recurrence::rMonthlyPos:// 2 |
195 | list.append( "2" ); | 198 | list.append( "2" ); |
196 | list.append( QString::number( rec->frequency()) );//12 | 199 | list.append( QString::number( rec->frequency()) );//12 |
197 | 200 | ||
198 | writeEndDate = true; | 201 | writeEndDate = true; |
199 | { | 202 | { |
200 | int count = 1; | 203 | int count = 1; |
201 | QPtrList<Recurrence::rMonthPos> rmp; | 204 | QPtrList<Recurrence::rMonthPos> rmp; |
202 | rmp = rec->monthPositions(); | 205 | rmp = rec->monthPositions(); |
203 | if ( rmp.first()->negative ) | 206 | if ( rmp.first()->negative ) |
204 | count = 5 - rmp.first()->rPos - 1; | 207 | count = 5 - rmp.first()->rPos - 1; |
205 | else | 208 | else |
206 | count = rmp.first()->rPos - 1; | 209 | count = rmp.first()->rPos - 1; |
207 | list.append( QString::number( count ) ); | 210 | list.append( QString::number( count ) ); |
208 | 211 | ||
209 | } | 212 | } |
210 | 213 | ||
211 | list.append( "0" ); | 214 | list.append( "0" ); |
212 | break; | 215 | break; |
213 | case Recurrence::rMonthlyDay:// 3 | 216 | case Recurrence::rMonthlyDay:// 3 |
214 | list.append( "3" ); | 217 | list.append( "3" ); |
215 | list.append( QString::number( rec->frequency()) );//12 | 218 | list.append( QString::number( rec->frequency()) );//12 |
216 | list.append( "0" ); | 219 | list.append( "0" ); |
217 | list.append( "0" ); | 220 | list.append( "0" ); |
218 | writeEndDate = true; | 221 | writeEndDate = true; |
219 | break; | 222 | break; |
220 | case Recurrence::rYearlyMonth://4 | 223 | case Recurrence::rYearlyMonth://4 |
221 | list.append( "4" ); | 224 | list.append( "4" ); |
222 | list.append( QString::number( rec->frequency()) );//12 | 225 | list.append( QString::number( rec->frequency()) );//12 |
223 | list.append( "0" ); | 226 | list.append( "0" ); |
224 | list.append( "0" ); | 227 | list.append( "0" ); |
225 | writeEndDate = true; | 228 | writeEndDate = true; |
226 | break; | 229 | break; |
227 | 230 | ||
228 | default: | 231 | default: |
229 | list.append( "255" ); | 232 | list.append( "255" ); |
230 | list.append( QString() ); | 233 | list.append( QString() ); |
231 | list.append( "0" ); | 234 | list.append( "0" ); |
232 | list.append( QString() ); | 235 | list.append( QString() ); |
233 | list.append( "0" ); | 236 | list.append( "0" ); |
234 | list.append( "20991231T000000" ); | 237 | list.append( "20991231T000000" ); |
235 | break; | 238 | break; |
236 | } | 239 | } |
237 | if ( writeEndDate ) { | 240 | if ( writeEndDate ) { |
238 | 241 | ||
239 | if ( rec->endDate().isValid() ) { // 15 + 16 | 242 | if ( rec->endDate().isValid() ) { // 15 + 16 |
240 | list.append( "1" ); | 243 | list.append( "1" ); |
241 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 244 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
242 | } else { | 245 | } else { |
243 | list.append( "0" ); | 246 | list.append( "0" ); |
244 | list.append( "20991231T000000" ); | 247 | list.append( "20991231T000000" ); |
245 | } | 248 | } |
246 | 249 | ||
247 | } | 250 | } |
248 | attList << list.join(""); | 251 | attList << list.join(""); |
249 | attList << event->categoriesStr(); | 252 | attList << event->categoriesStr(); |
250 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
251 | 254 | ||
252 | attList << event->secrecyStr(); | 255 | attList << event->secrecyStr(); |
253 | return PhoneFormat::getCsum(attList ); | 256 | return PhoneFormat::getCsum(attList ); |
254 | } | 257 | } |
255 | ulong PhoneFormat::getCsum( const QStringList & attList) | 258 | ulong PhoneFormat::getCsum( const QStringList & attList) |
256 | { | 259 | { |
257 | int max = attList.count() -1; | 260 | int max = attList.count(); |
258 | ulong cSum = 0; | 261 | ulong cSum = 0; |
259 | int j,k,i; | 262 | int j,k,i; |
260 | int add; | 263 | int add; |
261 | for ( i = 1; i < max ; ++i ) { | 264 | for ( i = 0; i < max ; ++i ) { |
262 | QString s = attList[i]; | 265 | QString s = attList[i]; |
263 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
264 | j = s.length(); | 267 | j = s.length(); |
265 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
266 | int mul = k +1; | 269 | int mul = k +1; |
267 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
268 | if ( k < 16 ) | 271 | if ( k < 16 ) |
269 | mul = mul * mul; | 272 | mul = mul * mul; |
270 | add = add * mul *i*i*i; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | ||
271 | cSum += add; | 275 | cSum += add; |
272 | } | 276 | } |
273 | } | 277 | } |
278 | if ( i == 0 ) | ||
279 | qDebug("csum: i == 0 %d ", cSum); | ||
280 | |||
274 | } | 281 | } |
275 | //QString dump = attList.join(","); | 282 | QString dump = attList.join(","); |
276 | //qDebug("csum: %s", dump.latin1()); | 283 | qDebug("csum: %d %s", cSum,dump.latin1()); |
277 | 284 | ||
278 | return cSum; | 285 | return cSum; |
279 | 286 | ||
280 | } | 287 | } |
281 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 288 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
282 | #include <stdlib.h> | 289 | #include <stdlib.h> |
283 | #define DEBUGMODE false | 290 | #define DEBUGMODE false |
284 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 291 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
285 | { | 292 | { |
286 | 293 | ||
287 | QString fileName; | 294 | QString fileName; |
288 | #ifdef _WIN32_ | 295 | #ifdef _WIN32_ |
289 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 296 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
290 | #else | 297 | #else |
291 | fileName = "/tmp/kdepimtemp.vcs"; | 298 | fileName = "/tmp/kdepimtemp.vcs"; |
292 | #endif | 299 | #endif |
293 | QString command ="./kammu --backup " + fileName + " -yes -C" + | 300 | QString command ="./kammu --backup " + fileName + " -yes" ; |
294 | mConnection +" -D" + mDevice +" -M" + mModel; | ||
295 | int ret = system ( command.latin1() ); | 301 | int ret = system ( command.latin1() ); |
296 | if ( ret != 0 ) { | 302 | if ( ret != 0 ) { |
297 | qDebug("Error::command returned %d", ret); | 303 | qDebug("Error::command returned %d", ret); |
298 | return false; | 304 | return false; |
299 | } | 305 | } |
300 | qDebug("Command returned %d", ret); | 306 | qDebug("Command returned %d", ret); |
301 | VCalFormat vfload; | 307 | VCalFormat vfload; |
302 | vfload.setLocalTime ( true ); | 308 | vfload.setLocalTime ( true ); |
303 | qDebug("loading file ..."); | 309 | qDebug("loading file ..."); |
304 | 310 | ||
305 | if ( ! vfload.load( calendar, fileName ) ) | 311 | if ( ! vfload.load( calendar, fileName ) ) |
306 | return false; | 312 | return false; |
307 | QPtrList<Event> er = calendar->rawEvents(); | 313 | QPtrList<Event> er = calendar->rawEvents(); |
308 | Event* ev = er.first(); | 314 | Event* ev = er.first(); |
309 | qDebug("reading events... "); | 315 | qDebug("reading events... "); |
310 | while ( ev ) { | 316 | while ( ev ) { |
311 | QStringList cat = ev->categories(); | 317 | QStringList cat = ev->categories(); |
312 | if ( cat.contains( "MeetingDEF" )) { | 318 | if ( cat.contains( "MeetingDEF" )) { |
313 | ev->setCategories( QStringList() ); | 319 | ev->setCategories( QStringList() ); |
314 | } | 320 | } |
315 | int id = ev->pilotId(); | 321 | int id = ev->pilotId(); |
316 | Event *event; | 322 | Event *event; |
317 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 323 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
318 | if ( event ) { | 324 | if ( event ) { |
319 | event = (Event*)event->clone(); | 325 | event = (Event*)event->clone(); |
320 | copyEvent( event, ev ); | 326 | copyEvent( event, ev ); |
321 | calendar->deleteEvent( ev ); | 327 | calendar->deleteEvent( ev ); |
322 | calendar->addEvent( event); | 328 | calendar->addEvent( event); |
323 | } | 329 | } |
324 | else | 330 | else |
325 | event = ev; | 331 | event = ev; |
326 | uint cSum; | 332 | uint cSum; |
327 | cSum = PhoneFormat::getCsumEvent( event ); | 333 | cSum = PhoneFormat::getCsumEvent( event ); |
328 | event->setCsum( mProfileName, QString::number( cSum )); | 334 | event->setCsum( mProfileName, QString::number( cSum )); |
329 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 335 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
330 | event->setID( mProfileName,QString::number( id ) ); | 336 | event->setID( mProfileName,QString::number( id ) ); |
331 | ev = er.next(); | 337 | ev = er.next(); |
332 | } | 338 | } |
333 | { | 339 | { |
334 | qDebug("reading todos... "); | 340 | qDebug("reading todos... "); |
335 | QPtrList<Todo> tr = calendar->rawTodos(); | 341 | QPtrList<Todo> tr = calendar->rawTodos(); |
336 | Todo* ev = tr.first(); | 342 | Todo* ev = tr.first(); |
337 | while ( ev ) { | 343 | while ( ev ) { |
338 | 344 | ||
339 | QStringList cat = ev->categories(); | 345 | QStringList cat = ev->categories(); |
340 | if ( cat.contains( "MeetingDEF" )) { | 346 | if ( cat.contains( "MeetingDEF" )) { |
341 | ev->setCategories( QStringList() ); | 347 | ev->setCategories( QStringList() ); |
342 | } | 348 | } |
343 | int id = ev->pilotId(); | 349 | int id = ev->pilotId(); |
344 | Todo *event; | 350 | Todo *event; |
345 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 351 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
346 | if ( event ) { | 352 | if ( event ) { |
353 | qDebug("copy todo %s ", event->summary().latin1()); | ||
354 | |||
347 | event = (Todo*)event->clone(); | 355 | event = (Todo*)event->clone(); |
348 | copyTodo( event, ev ); | 356 | copyTodo( event, ev ); |
349 | calendar->deleteTodo( ev ); | 357 | calendar->deleteTodo( ev ); |
350 | calendar->addTodo( event); | 358 | calendar->addTodo( event); |
351 | } | 359 | } |
352 | else | 360 | else |
353 | event = ev; | 361 | event = ev; |
354 | uint cSum; | 362 | uint cSum; |
355 | cSum = PhoneFormat::getCsumTodo( event ); | 363 | cSum = PhoneFormat::getCsumTodo( event ); |
356 | event->setCsum( mProfileName, QString::number( cSum )); | 364 | event->setCsum( mProfileName, QString::number( cSum )); |
357 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 365 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
358 | event->setID( mProfileName,QString::number( id ) ); | 366 | event->setID( mProfileName,QString::number( id ) ); |
359 | ev = tr.next(); | 367 | ev = tr.next(); |
360 | } | 368 | } |
361 | } | 369 | } |
362 | return true; | 370 | return true; |
363 | } | 371 | } |
364 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 372 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
365 | { | 373 | { |
366 | if ( from->dtStart().isValid() ) | 374 | if ( from->dtStart().isValid() ) |
367 | to->setDtStart( from->dtStart() ); | 375 | to->setDtStart( from->dtStart() ); |
368 | if ( from->dtEnd().isValid() ) | 376 | if ( from->dtEnd().isValid() ) |
369 | to->setDtEnd( from->dtEnd() ); | 377 | to->setDtEnd( from->dtEnd() ); |
370 | if ( !from->location().isEmpty() ) | 378 | if ( !from->location().isEmpty() ) |
371 | to->setLocation( from->location() ); | 379 | to->setLocation( from->location() ); |
372 | if ( !from->description().isEmpty() ) | 380 | if ( !from->description().isEmpty() ) |
373 | to->setDescription( from->description() ); | 381 | to->setDescription( from->description() ); |
374 | if ( !from->summary().isEmpty() ) | 382 | if ( !from->summary().isEmpty() ) |
375 | to->setSummary( from->summary() ); | 383 | to->setSummary( from->summary() ); |
376 | 384 | ||
377 | QPtrListIterator<Alarm> it( from->alarms() ); | 385 | QPtrListIterator<Alarm> it( from->alarms() ); |
378 | to->clearAlarms(); | 386 | if ( it.current() ) |
387 | to->clearAlarms(); | ||
379 | const Alarm *a; | 388 | const Alarm *a; |
380 | while( (a = it.current()) ) { | 389 | while( (a = it.current()) ) { |
381 | Alarm *b = new Alarm( *a ); | 390 | Alarm *b = new Alarm( *a ); |
382 | b->setParent( to ); | 391 | b->setParent( to ); |
383 | to->addAlarm( b ); | 392 | to->addAlarm( b ); |
384 | ++it; | 393 | ++it; |
385 | } | 394 | } |
386 | QStringList cat = to->categories(); | 395 | QStringList cat = to->categories(); |
387 | QStringList catFrom = from->categories(); | 396 | QStringList catFrom = from->categories(); |
388 | QString nCat; | 397 | QString nCat; |
389 | int iii; | 398 | int iii; |
390 | for ( iii = 0; iii < catFrom.count();++iii ) { | 399 | for ( iii = 0; iii < catFrom.count();++iii ) { |
391 | nCat = catFrom[iii]; | 400 | nCat = catFrom[iii]; |
392 | if ( !nCat.isEmpty() ) | 401 | if ( !nCat.isEmpty() ) |
393 | if ( !cat.contains( nCat )) { | 402 | if ( !cat.contains( nCat )) { |
394 | cat << nCat; | 403 | cat << nCat; |
395 | } | 404 | } |
396 | } | 405 | } |
397 | to->setCategories( cat ); | 406 | to->setCategories( cat ); |
398 | Recurrence * r = new Recurrence( *from->recurrence(),to); | 407 | Recurrence * r = new Recurrence( *from->recurrence(),to); |
399 | to->setRecurrence( r ) ; | 408 | to->setRecurrence( r ) ; |
400 | 409 | ||
401 | 410 | ||
402 | } | 411 | } |
403 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) | 412 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) |
404 | { | 413 | { |
405 | if ( from->dtStart().isValid() ) | 414 | if ( from->dtStart().isValid() ) |
406 | to->setDtStart( from->dtStart() ); | 415 | to->setDtStart( from->dtStart() ); |
407 | if ( from->dtDue().isValid() ) | 416 | if ( from->dtDue().isValid() ) |
408 | to->setDtDue( from->dtDue() ); | 417 | to->setDtDue( from->dtDue() ); |
409 | if ( !from->location().isEmpty() ) | 418 | if ( !from->location().isEmpty() ) |
410 | to->setLocation( from->location() ); | 419 | to->setLocation( from->location() ); |
411 | if ( !from->description().isEmpty() ) | 420 | if ( !from->description().isEmpty() ) |
412 | to->setDescription( from->description() ); | 421 | to->setDescription( from->description() ); |
413 | if ( !from->summary().isEmpty() ) | 422 | if ( !from->summary().isEmpty() ) |
414 | to->setSummary( from->summary() ); | 423 | to->setSummary( from->summary() ); |
415 | 424 | ||
416 | QPtrListIterator<Alarm> it( from->alarms() ); | 425 | QPtrListIterator<Alarm> it( from->alarms() ); |
417 | to->clearAlarms(); | 426 | if ( it.current() ) |
427 | to->clearAlarms(); | ||
418 | const Alarm *a; | 428 | const Alarm *a; |
419 | while( (a = it.current()) ) { | 429 | while( (a = it.current()) ) { |
420 | Alarm *b = new Alarm( *a ); | 430 | Alarm *b = new Alarm( *a ); |
421 | b->setParent( to ); | 431 | b->setParent( to ); |
422 | to->addAlarm( b ); | 432 | to->addAlarm( b ); |
423 | ++it; | 433 | ++it; |
424 | } | 434 | } |
425 | QStringList cat = to->categories(); | 435 | QStringList cat = to->categories(); |
426 | QStringList catFrom = from->categories(); | 436 | QStringList catFrom = from->categories(); |
427 | QString nCat; | 437 | QString nCat; |
428 | int iii; | 438 | int iii; |
429 | for ( iii = 0; iii < catFrom.count();++iii ) { | 439 | for ( iii = 0; iii < catFrom.count();++iii ) { |
430 | nCat = catFrom[iii]; | 440 | nCat = catFrom[iii]; |
431 | if ( !nCat.isEmpty() ) | 441 | if ( !nCat.isEmpty() ) |
432 | if ( !cat.contains( nCat )) { | 442 | if ( !cat.contains( nCat )) { |
433 | cat << nCat; | 443 | cat << nCat; |
434 | } | 444 | } |
435 | } | 445 | } |
436 | to->setCategories( cat ); | 446 | to->setCategories( cat ); |
437 | if ( from->isCompleted() ) { | 447 | if ( from->isCompleted() ) { |
438 | to->setCompleted( true ); | 448 | to->setCompleted( true ); |
439 | if( from->completed().isValid() ) | 449 | if( from->completed().isValid() ) |
440 | to->setCompleted( from->completed() ); | 450 | to->setCompleted( from->completed() ); |
441 | } else { | 451 | } else { |
442 | // set percentcomplete only, if to->isCompleted() | 452 | // set percentcomplete only, if to->isCompleted() |
443 | if ( to->isCompleted() ) | 453 | if ( to->isCompleted() ) |
444 | to->setPercentComplete(from->percentComplete()); | 454 | to->setPercentComplete(from->percentComplete()); |
445 | } | 455 | } |
446 | to->setPriority(from->priority()); | 456 | if( to->priority() == 2 && from->priority() == 1 ) |
457 | ; //skip | ||
458 | else if (to->priority() == 4 && from->priority() == 5 ) | ||
459 | ; | ||
460 | else | ||
461 | to->setPriority(from->priority()); | ||
447 | 462 | ||
448 | } | 463 | } |
449 | #include <qcstring.h> | 464 | #include <qcstring.h> |
450 | 465 | ||
451 | void PhoneFormat::afterSave( Incidence* inc) | 466 | void PhoneFormat::afterSave( Incidence* inc) |
452 | { | 467 | { |
453 | uint csum; | 468 | uint csum; |
454 | inc->removeID( mProfileName ); | 469 | inc->removeID( mProfileName ); |
470 | #if 0 | ||
455 | if ( inc->type() == "Event") | 471 | if ( inc->type() == "Event") |
456 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 472 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
457 | else | 473 | else |
458 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 474 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
459 | inc->setCsum( mProfileName, QString::number( csum )); | 475 | inc->setCsum( mProfileName, QString::number( csum )); |
476 | #endif | ||
460 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 477 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
461 | 478 | ||
462 | } | 479 | } |
463 | bool PhoneFormat::save( Calendar *calendar) | 480 | bool PhoneFormat::save( Calendar *calendar) |
464 | { | 481 | { |
465 | QLabel status ( i18n(" Opening device ..."), 0 ); | 482 | QLabel status ( i18n(" Opening device ..."), 0 ); |
466 | int w = status.sizeHint().width()+20 ; | 483 | int w = status.sizeHint().width()+20 ; |
467 | if ( w < 200 ) w = 230; | 484 | if ( w < 200 ) w = 230; |
468 | int h = status.sizeHint().height()+20 ; | 485 | int h = status.sizeHint().height()+20 ; |
469 | int dw = QApplication::desktop()->width(); | 486 | int dw = QApplication::desktop()->width(); |
470 | int dh = QApplication::desktop()->height(); | 487 | int dh = QApplication::desktop()->height(); |
471 | status.setCaption(i18n("Writing to phone...") ); | 488 | status.setCaption(i18n("Writing to phone...") ); |
472 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 489 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
473 | status.show(); | 490 | status.show(); |
474 | status.raise(); | 491 | status.raise(); |
475 | qApp->processEvents(); | 492 | qApp->processEvents(); |
476 | QString message; | 493 | QString message; |
477 | #ifdef _WIN32_ | 494 | #ifdef _WIN32_ |
478 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 495 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
479 | #else | 496 | #else |
480 | QString fileName = "/tmp/kdepimtemp.vcs"; | 497 | QString fileName = "/tmp/kdepimtemp.vcs"; |
481 | #endif | 498 | #endif |
482 | 499 | ||
483 | // 1 remove events which should be deleted | 500 | // 1 remove events which should be deleted |
484 | QPtrList<Event> er = calendar->rawEvents(); | 501 | QPtrList<Event> er = calendar->rawEvents(); |
485 | Event* ev = er.first(); | 502 | Event* ev = er.first(); |
486 | while ( ev ) { | 503 | while ( ev ) { |
487 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 504 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
488 | calendar->deleteEvent( ev ); | 505 | calendar->deleteEvent( ev ); |
489 | } else { | 506 | } else { |
490 | 507 | ||
491 | } | 508 | } |
492 | ev = er.next(); | 509 | ev = er.next(); |
493 | } | 510 | } |
494 | // 2 remove todos which should be deleted | 511 | // 2 remove todos which should be deleted |
495 | QPtrList<Todo> tl = calendar->rawTodos(); | 512 | QPtrList<Todo> tl = calendar->rawTodos(); |
496 | Todo* to = tl.first(); | 513 | Todo* to = tl.first(); |
497 | while ( to ) { | 514 | while ( to ) { |
498 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 515 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
499 | calendar->deleteTodo( to ); | 516 | calendar->deleteTodo( to ); |
500 | } | 517 | } |
501 | to = tl.next(); | 518 | to = tl.next(); |
502 | } | 519 | } |
503 | // 3 save file | 520 | // 3 save file |
504 | VCalFormat vfsave; | 521 | VCalFormat vfsave; |
505 | vfsave.setLocalTime ( true ); | 522 | vfsave.setLocalTime ( true ); |
506 | if ( ! vfsave.save( calendar, fileName ) ) | 523 | if ( ! vfsave.save( calendar, fileName ) ) |
507 | return false; | 524 | return false; |
508 | // 4 call kammu | 525 | // 4 call kammu |
509 | QString command ="./kammu --restore " + fileName + " -C" + | 526 | QString command ="./kammu --restore " + fileName ; |
510 | mConnection +" -D" + mDevice +" -M" + mModel; | ||
511 | int ret; | 527 | int ret; |
512 | while ( (ret = system ( command.latin1())) != 0 ) { | 528 | while ( (ret = system ( command.latin1())) != 0 ) { |
513 | qDebug("Error S::command returned %d. asking users", ret); | 529 | qDebug("Error S::command returned %d. asking users", ret); |
514 | int retval = KMessageBox::warningContinueCancel(0, | 530 | int retval = KMessageBox::warningContinueCancel(0, |
515 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); | 531 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); |
516 | if ( retval != KMessageBox::Continue ) | 532 | if ( retval != KMessageBox::Continue ) |
517 | return false; | 533 | return false; |
518 | } | 534 | } |
519 | if ( ret != 0 ) { | 535 | if ( ret != 0 ) { |
520 | qDebug("Error S::command returned %d", ret); | 536 | qDebug("Error S::command returned %d", ret); |
521 | return false; | 537 | return false; |
522 | } | 538 | } |
523 | // 5 reread data | 539 | // 5 reread data |
524 | message = i18n(" Rereading all data ... "); | 540 | message = i18n(" Rereading all data ... "); |
525 | status.setText ( message ); | 541 | status.setText ( message ); |
526 | qApp->processEvents(); | 542 | qApp->processEvents(); |
527 | CalendarLocal* calendarTemp = new CalendarLocal(); | 543 | CalendarLocal* calendarTemp = new CalendarLocal(); |
528 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 544 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
529 | if ( ! load( calendarTemp,calendar) ){ | 545 | if ( ! load( calendarTemp,calendar) ){ |
530 | qDebug("error reloading calendar "); | 546 | qDebug("error reloading calendar "); |
531 | delete calendarTemp; | 547 | delete calendarTemp; |
532 | return false; | 548 | return false; |
533 | } | 549 | } |
534 | // 6 compare data | 550 | // 6 compare data |
535 | 551 | ||
536 | //algo 6 compare event | 552 | //algo 6 compare event |
537 | er = calendar->rawEvents(); | 553 | er = calendar->rawEvents(); |
538 | ev = er.first(); | 554 | ev = er.first(); |
539 | message = i18n(" Comparing event # "); | 555 | message = i18n(" Comparing event # "); |
540 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 556 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
541 | Event* ev1; | 557 | Event* ev1; |
542 | int procCount = 0; | 558 | int procCount = 0; |
543 | while ( ev ) { | 559 | while ( ev ) { |
544 | //qDebug("event new ID %s",ev->summary().latin1()); | 560 | //qDebug("event new ID %s",ev->summary().latin1()); |
545 | status.setText ( message + QString::number ( ++procCount ) ); | 561 | status.setText ( message + QString::number ( ++procCount ) ); |
546 | qApp->processEvents(); | 562 | qApp->processEvents(); |
547 | uint csum; | 563 | uint csum; |
548 | csum = PhoneFormat::getCsumEvent( ev ); | 564 | csum = PhoneFormat::getCsumEvent( ev ); |
549 | QString cSum = QString::number( csum ); | 565 | QString cSum = QString::number( csum ); |
550 | ev->setCsum( mProfileName, cSum ); | 566 | ev->setCsum( mProfileName, cSum ); |
551 | //qDebug("Event cSum %s ", cSum.latin1()); | 567 | //qDebug("Event cSum %s ", cSum.latin1()); |
552 | ev1 = er1.first(); | 568 | ev1 = er1.first(); |
553 | while ( ev1 ) { | 569 | while ( ev1 ) { |
554 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 570 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
555 | er1.remove( ev1 ); | 571 | er1.remove( ev1 ); |
556 | afterSave( ev ); | 572 | afterSave( ev ); |
557 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | 573 | ev->setID(mProfileName, ev1->getID(mProfileName) ); |
558 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | 574 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); |
559 | 575 | ||
560 | break; | 576 | break; |
561 | } | 577 | } |
562 | ev1 = er1.next(); | 578 | ev1 = er1.next(); |
563 | } | 579 | } |
564 | if ( ! ev1 ) { | 580 | if ( ! ev1 ) { |
565 | ev->removeID(mProfileName); | 581 | ev->removeID(mProfileName); |
566 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 582 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
567 | } | 583 | } |
568 | 584 | ||
569 | 585 | ||
570 | ev = er.next(); | 586 | ev = er.next(); |
571 | } | 587 | } |
572 | //algo 6 compare todo | 588 | //algo 6 compare todo |
573 | tl = calendar->rawTodos(); | 589 | tl = calendar->rawTodos(); |
574 | to = tl.first(); | 590 | to = tl.first(); |
575 | procCount = 0; | 591 | procCount = 0; |
576 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 592 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
577 | Todo* to1 ; | 593 | Todo* to1 ; |
578 | message = i18n(" Comparing todo # "); | 594 | message = i18n(" Comparing todo # "); |
579 | while ( to ) { | 595 | while ( to ) { |
580 | qDebug("todo2 %d ", procCount); | 596 | qDebug("todo2 %d ", procCount); |
581 | status.setText ( message + QString::number ( ++procCount ) ); | 597 | status.setText ( message + QString::number ( ++procCount ) ); |
582 | qApp->processEvents(); | 598 | qApp->processEvents(); |
583 | uint csum; | 599 | uint csum; |
584 | csum = PhoneFormat::getCsumTodo( to ); | 600 | csum = PhoneFormat::getCsumTodo( to ); |
585 | QString cSum = QString::number( csum ); | 601 | QString cSum = QString::number( csum ); |
586 | to->setCsum( mProfileName, cSum ); | 602 | to->setCsum( mProfileName, cSum ); |
587 | qDebug("Todo cSum %s ", cSum.latin1()); | 603 | qDebug("Todo cSum %s ", cSum.latin1()); |
588 | Todo* to1 = tl1.first(); | 604 | Todo* to1 = tl1.first(); |
589 | while ( to1 ) { | 605 | while ( to1 ) { |
590 | if ( to1->getCsum( mProfileName ) == cSum ) { | 606 | if ( to1->getCsum( mProfileName ) == cSum ) { |
591 | tl1.remove( to1 ); | 607 | tl1.remove( to1 ); |
592 | afterSave( to ); | 608 | afterSave( to ); |
593 | to->setID(mProfileName, to1->getID(mProfileName) ); | 609 | to->setID(mProfileName, to1->getID(mProfileName) ); |
594 | break; | 610 | break; |
595 | } | 611 | } |
596 | to1 = tl1.next(); | 612 | to1 = tl1.next(); |
597 | } | 613 | } |
598 | if ( ! to1 ) { | 614 | if ( ! to1 ) { |
599 | to->removeID(mProfileName); | 615 | to->removeID(mProfileName); |
600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 616 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
601 | } | 617 | } |
602 | 618 | ||
603 | to = tl.next(); | 619 | to = tl.next(); |
604 | } | 620 | } |
605 | delete calendarTemp; | 621 | delete calendarTemp; |
606 | return true; | 622 | return true; |
607 | 623 | ||
608 | 624 | ||
609 | 625 | ||
610 | } | 626 | } |
611 | 627 | ||
612 | 628 | ||
613 | QString PhoneFormat::toString( Calendar * ) | 629 | QString PhoneFormat::toString( Calendar * ) |
614 | { | 630 | { |
615 | return QString::null; | 631 | return QString::null; |
616 | } | 632 | } |
617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 633 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
618 | { | 634 | { |
619 | return false; | 635 | return false; |
620 | } | 636 | } |