summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmcal.c4
-rw-r--r--gammu/emb/gammu/gammu.c6
-rw-r--r--libkcal/phoneformat.cpp42
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
9bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) 9bool 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
44void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) 44void 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
85GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) 85GSM_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, &note->Entries[Time].Date, "DTSTART"); 135 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
136 136
137 if (EndTime != -1) { 137 if (EndTime != -1) {
138 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 138 SaveVCALDateTime(Buffer, Length, &note->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, &note->Entries[Alarm].Date, "DALARM"); 143 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
144 } else { 144 } else {
145 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 145 SaveVCALDateTime(Buffer, Length, &note->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, &note->Entries[Time].Date, "DTSTART"); 177 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
178 178
179 if (Alarm != -1) { 179 if (Alarm != -1) {
180 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 180 SaveVCALDateTime(Buffer, Length, &note->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, &note->Entries[Time].Date, "DTSTART"); 229 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
230 230
231 if (EndTime != -1) { 231 if (EndTime != -1) {
232 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 232 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
233 } 233 }
234 234
235 if (Alarm != -1) { 235 if (Alarm != -1) {
236 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 236 SaveVCALDateTime(Buffer, Length, &note->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
253void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) 253void 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
286GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) 286GSM_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, &note->Entries[EndTime].Date, "DUE"); 316 SaveVCALDateTime(Buffer, Length, &note->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, &note->Entries[Alarm].Date, "DALARM"); 321 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
322 } else { 322 } else {
323 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 323 SaveVCALDateTime(Buffer, Length, &note->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, &note->Entries[Alarm].Date, "AALARM"); 343 SaveVCALDateTime(Buffer, Length, &note->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
356GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) 356GSM_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
500GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) 500GSM_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
@@ -1,8428 +1,8432 @@
1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ 1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
2/* FM stuff by Walek */ 2/* FM stuff by Walek */
3 3
4#include <string.h> 4#include <string.h>
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#include <stdarg.h> 7#include <stdarg.h>
8#include <locale.h> 8#include <locale.h>
9#include <signal.h> 9#include <signal.h>
10#include <ctype.h> 10#include <ctype.h>
11#include <wchar.h> 11#include <wchar.h>
12#undef HAVE_MYSQL_MYSQL_H 12#undef HAVE_MYSQL_MYSQL_H
13#ifdef WIN32 13#ifdef WIN32
14# include <windows.h> 14# include <windows.h>
15# include <process.h> 15# include <process.h>
16# ifdef _MSC_VER 16# ifdef _MSC_VER
17# include <sys/utime.h> 17# include <sys/utime.h>
18# else 18# else
19# include <utime.h> 19# include <utime.h>
20# endif 20# endif
21#else 21#else
22# include <utime.h> 22# include <utime.h>
23#endif 23#endif
24 24
25#include "../common/gammu.h" 25#include "../common/gammu.h"
26#include "gammu.h" 26#include "gammu.h"
27#include "smsd/smsdcore.h" 27#include "smsd/smsdcore.h"
28#ifdef DEBUG 28#ifdef DEBUG
29# include "sniff.h" 29# include "sniff.h"
30#endif 30#endif
31#ifdef GSM_ENABLE_NOKIA_DCT3 31#ifdef GSM_ENABLE_NOKIA_DCT3
32# include "depend/nokia/dct3.h" 32# include "depend/nokia/dct3.h"
33# include "depend/nokia/dct3trac/wmx.h" 33# include "depend/nokia/dct3trac/wmx.h"
34#endif 34#endif
35#ifdef GSM_ENABLE_NOKIA_DCT4 35#ifdef GSM_ENABLE_NOKIA_DCT4
36# include "depend/nokia/dct4.h" 36# include "depend/nokia/dct4.h"
37#endif 37#endif
38#ifdef GSM_ENABLE_ATGEN 38#ifdef GSM_ENABLE_ATGEN
39# include "depend/siemens/dsiemens.h" 39# include "depend/siemens/dsiemens.h"
40#endif 40#endif
41 41
42#ifdef HAVE_PTHREAD 42#ifdef HAVE_PTHREAD
43# include <pthread.h> 43# include <pthread.h>
44#endif 44#endif
45 45
46#ifdef HAVE_SYS_IOCTL_H 46#ifdef HAVE_SYS_IOCTL_H
47# include <sys/ioctl.h> 47# include <sys/ioctl.h>
48#endif 48#endif
49 49
50 50
51 //static GSM_StateMachine s; 51 //static GSM_StateMachine s;
52 //static GSM_Phone_Functions *Phone; 52 //static GSM_Phone_Functions *Phone;
53 static INI_Section *cfg = NULL; 53 static INI_Section *cfg = NULL;
54 54
55 //static GSM_Error error = ERR_NONE; 55 //static GSM_Error error = ERR_NONE;
56 static int i; 56 static int i;
57 57
58 //static bool gshutdown = false; 58 //static bool gshutdown = false;
59typedef struct { 59typedef struct {
60 unsigned char Connection[50]; 60 unsigned char Connection[50];
61} OneConnectionInfo; 61} OneConnectionInfo;
62 62
63typedef struct { 63typedef struct {
64 unsigned char Device[50]; 64 unsigned char Device[50];
65 OneConnectionInfo Connections[6]; 65 OneConnectionInfo Connections[6];
66 //GSM_StateMachines; 66 //GSM_StateMachines;
67} OneDeviceInfo; 67} OneDeviceInfo;
68 68
69 static int num; 69 static int num;
70 static OneDeviceInfo SearchDevices[100]; 70 static OneDeviceInfo SearchDevices[100];
71 static bool SearchOutput; 71 static bool SearchOutput;
72void interrupt(int sign) 72void interrupt(int sign)
73{ 73{
74 signal(sign, SIG_IGN); 74 signal(sign, SIG_IGN);
75 gshutdown = true; 75 gshutdown = true;
76} 76}
77 77
78#ifdef __GNUC__ 78#ifdef __GNUC__
79__attribute__((format(printf, 1, 2))) 79__attribute__((format(printf, 1, 2)))
80#endif 80#endif
81int printmsg(char *format, ...) 81int printmsg(char *format, ...)
82{ 82{
83 va_list argp; 83 va_list argp;
84 int result; 84 int result;
85 85
86 va_start(argp, format); 86 va_start(argp, format);
87 result = vfprintf(stdout,GetMsg(s.msg,format),argp); 87 result = vfprintf(stdout,GetMsg(s.msg,format),argp);
88 va_end(argp); 88 va_end(argp);
89 return result; 89 return result;
90} 90}
91 91
92#ifdef __GNUC__ 92#ifdef __GNUC__
93__attribute__((format(printf, 1, 2))) 93__attribute__((format(printf, 1, 2)))
94#endif 94#endif
95int printmsgerr(char *format, ...) 95int printmsgerr(char *format, ...)
96{ 96{
97 va_list argp; 97 va_list argp;
98 int result; 98 int result;
99 99
100 va_start(argp, format); 100 va_start(argp, format);
101 result = vfprintf(stderr,GetMsg(s.msg,format), argp); 101 result = vfprintf(stderr,GetMsg(s.msg,format), argp);
102 va_end(argp); 102 va_end(argp);
103 return result; 103 return result;
104} 104}
105 105
106static void PrintSecurityStatus() 106static void PrintSecurityStatus()
107{ 107{
108 GSM_SecurityCodeType Status; 108 GSM_SecurityCodeType Status;
109 109
110 error=Phone->GetSecurityStatus(&s,&Status); 110 error=Phone->GetSecurityStatus(&s,&Status);
111 Print_Error(error); 111 Print_Error(error);
112 switch(Status) { 112 switch(Status) {
113 case SEC_SecurityCode: 113 case SEC_SecurityCode:
114 printmsg("Waiting for Security Code.\n"); 114 printmsg("Waiting for Security Code.\n");
115 break; 115 break;
116 case SEC_Pin: 116 case SEC_Pin:
117 printmsg("Waiting for PIN.\n"); 117 printmsg("Waiting for PIN.\n");
118 break; 118 break;
119 case SEC_Pin2: 119 case SEC_Pin2:
120 printmsg("Waiting for PIN2.\n"); 120 printmsg("Waiting for PIN2.\n");
121 break; 121 break;
122 case SEC_Puk: 122 case SEC_Puk:
123 printmsg("Waiting for PUK.\n"); 123 printmsg("Waiting for PUK.\n");
124 break; 124 break;
125 case SEC_Puk2: 125 case SEC_Puk2:
126 printmsg("Waiting for PUK2.\n"); 126 printmsg("Waiting for PUK2.\n");
127 break; 127 break;
128 case SEC_None: 128 case SEC_None:
129 printmsg("Nothing to enter.\n"); 129 printmsg("Nothing to enter.\n");
130 break; 130 break;
131 default: 131 default:
132 printmsg("Unknown\n"); 132 printmsg("Unknown\n");
133 } 133 }
134} 134}
135 135
136void Print_Error(GSM_Error error) 136void Print_Error(GSM_Error error)
137{ 137{
138 if (error != ERR_NONE) { 138 if (error != ERR_NONE) {
139 printf("%s\n",print_error(error,s.di.df,s.msg)); 139 printf("%s\n",print_error(error,s.di.df,s.msg));
140 if (error == ERR_SECURITYERROR) { 140 if (error == ERR_SECURITYERROR) {
141 printmsg("Security status: "); 141 printmsg("Security status: ");
142 PrintSecurityStatus(); 142 PrintSecurityStatus();
143 } 143 }
144 if (s.opened) GSM_TerminateConnection(&s); 144 if (s.opened) GSM_TerminateConnection(&s);
145 exit (-1); 145 exit (-1);
146 } 146 }
147} 147}
148 148
149void GSM_Init(bool checkerror) 149void GSM_Init(bool checkerror)
150{ 150{
151 error=GSM_InitConnection(&s,3); 151 error=GSM_InitConnection(&s,3);
152 if (checkerror) Print_Error(error); 152 if (checkerror) Print_Error(error);
153 153
154 Phone=s.Phone.Functions; 154 Phone=s.Phone.Functions;
155} 155}
156 156
157void GSM_Terminate(void) 157void GSM_Terminate(void)
158{ 158{
159 error=GSM_TerminateConnection(&s); 159 error=GSM_TerminateConnection(&s);
160 Print_Error(error); 160 Print_Error(error);
161} 161}
162 162
163static void GetStartStop(int *start, int *stop, int num, int argc, char *argv[]) 163static void GetStartStop(int *start, int *stop, int num, int argc, char *argv[])
164{ 164{
165 *start=atoi(argv[num]); 165 *start=atoi(argv[num]);
166 if (*start==0) { 166 if (*start==0) {
167 printmsg("ERROR: enumerate locations from 1\n"); 167 printmsg("ERROR: enumerate locations from 1\n");
168 exit (-1); 168 exit (-1);
169 } 169 }
170 170
171 if (stop!=NULL) { 171 if (stop!=NULL) {
172 *stop=*start; 172 *stop=*start;
173 if (argc>=num+2) *stop=atoi(argv[num+1]); 173 if (argc>=num+2) *stop=atoi(argv[num+1]);
174 if (*stop==0) { 174 if (*stop==0) {
175 printmsg("ERROR: enumerate locations from 1\n"); 175 printmsg("ERROR: enumerate locations from 1\n");
176 exit (-1); 176 exit (-1);
177 } 177 }
178 } 178 }
179} 179}
180 180
181bool always_answer_yes = false; 181bool always_answer_yes = false;
182bool always_answer_no = false; 182bool always_answer_no = false;
183 183
184static bool answer_yes(char *text) 184static bool answer_yes(char *text)
185{ 185{
186 int len; 186 int len;
187 char ans[99]; 187 char ans[99];
188 188
189 while (1) { 189 while (1) {
190 printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text); 190 printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text);
191 if (always_answer_yes) { 191 if (always_answer_yes) {
192 printmsgerr("YES (always)\n"); 192 printmsgerr("YES (always)\n");
193 return true; 193 return true;
194 } 194 }
195 if (always_answer_no) { 195 if (always_answer_no) {
196 printmsgerr("NO (always)\n"); 196 printmsgerr("NO (always)\n");
197 return false; 197 return false;
198 } 198 }
199 len=GetLine(stdin, ans, 99); 199 len=GetLine(stdin, ans, 99);
200 if (len==-1) exit(-1); 200 if (len==-1) exit(-1);
201 if (!strcmp(ans, "NONE")) { 201 if (!strcmp(ans, "NONE")) {
202 always_answer_no = true; 202 always_answer_no = true;
203 return false; 203 return false;
204 } 204 }
205 if (!strcmp(ans, "ONLY")) { 205 if (!strcmp(ans, "ONLY")) {
206 always_answer_no = true; 206 always_answer_no = true;
207 return true; 207 return true;
208 } 208 }
209 if (!strcmp(ans, "ALL")) { 209 if (!strcmp(ans, "ALL")) {
210 always_answer_yes = true; 210 always_answer_yes = true;
211 return true; 211 return true;
212 } 212 }
213 if (mystrncasecmp(ans, "yes",0)) return true; 213 if (mystrncasecmp(ans, "yes",0)) return true;
214 if (mystrncasecmp(ans, "no" ,0)) return false; 214 if (mystrncasecmp(ans, "no" ,0)) return false;
215 } 215 }
216} 216}
217 217
218#ifdef GSM_ENABLE_BEEP 218#ifdef GSM_ENABLE_BEEP
219void GSM_PhoneBeep(void) 219void GSM_PhoneBeep(void)
220{ 220{
221 error = PHONE_Beep(&s); 221 error = PHONE_Beep(&s);
222 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error); 222 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error);
223} 223}
224#endif 224#endif
225 225
226static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone) 226static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
227{ 227{
228 int i; 228 int i;
229 bool first=true; 229 bool first=true;
230 GSM_Error error; 230 GSM_Error error;
231 231
232 signal(SIGINT, interrupt); 232 signal(SIGINT, interrupt);
233 printmsg("Press Ctrl+C to break...\n"); 233 printmsg("Press Ctrl+C to break...\n");
234 234
235 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 235 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
236 if (gshutdown) break; 236 if (gshutdown) break;
237 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue; 237 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue;
238 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first); 238 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first);
239 if (error!=ERR_NONE) return error; 239 if (error!=ERR_NONE) return error;
240 first = false; 240 first = false;
241 } 241 }
242 242
243 /* Disables buzzer */ 243 /* Disables buzzer */
244 return s.Phone.Functions->PlayTone(&s,255*255,0,false); 244 return s.Phone.Functions->PlayTone(&s,255*255,0,false);
245} 245}
246static void PlayRingtone(int argc, char *argv[]) 246static void PlayRingtone(int argc, char *argv[])
247{ 247{
248 GSM_Ringtone ringtone,ringtone2; 248 GSM_Ringtone ringtone,ringtone2;
249 249
250 ringtone.Format= 0; 250 ringtone.Format= 0;
251 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 251 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
252 Print_Error(error); 252 Print_Error(error);
253 253
254 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE); 254 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE);
255 Print_Error(error); 255 Print_Error(error);
256 256
257 GSM_Init(true); 257 GSM_Init(true);
258 258
259 error=GSM_PlayRingtone(ringtone2); 259 error=GSM_PlayRingtone(ringtone2);
260 Print_Error(error); 260 Print_Error(error);
261 261
262 GSM_Terminate(); 262 GSM_Terminate();
263} 263}
264 264
265static void Identify(int argc, char *argv[]) 265static void Identify(int argc, char *argv[])
266{ 266{
267 unsigned char buffer[100]; 267 unsigned char buffer[100];
268 268
269 GSM_Init(true); 269 GSM_Init(true);
270 270
271 error=Phone->GetManufacturer(&s); 271 error=Phone->GetManufacturer(&s);
272 Print_Error(error); 272 Print_Error(error);
273 printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer); 273 printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer);
274 error=Phone->GetModel(&s); 274 error=Phone->GetModel(&s);
275 Print_Error(error); 275 Print_Error(error);
276 printmsg("Model : %s (%s)\n", 276 printmsg("Model : %s (%s)\n",
277 s.Phone.Data.ModelInfo->model, 277 s.Phone.Data.ModelInfo->model,
278 s.Phone.Data.Model); 278 s.Phone.Data.Model);
279 279
280 error=Phone->GetFirmware(&s); 280 error=Phone->GetFirmware(&s);
281 Print_Error(error); 281 Print_Error(error);
282 printmsg("Firmware : %s",s.Phone.Data.Version); 282 printmsg("Firmware : %s",s.Phone.Data.Version);
283 error=Phone->GetPPM(&s, buffer); 283 error=Phone->GetPPM(&s, buffer);
284 if (error != ERR_NOTSUPPORTED) { 284 if (error != ERR_NOTSUPPORTED) {
285 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 285 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
286 if (error == ERR_NONE) printmsg(" %s",buffer); 286 if (error == ERR_NONE) printmsg(" %s",buffer);
287 } 287 }
288 if (s.Phone.Data.VerDate[0]!=0) printmsg(" (%s)",s.Phone.Data.VerDate); 288 if (s.Phone.Data.VerDate[0]!=0) printmsg(" (%s)",s.Phone.Data.VerDate);
289 printf("\n"); 289 printf("\n");
290 290
291 error=Phone->GetHardware(&s, buffer); 291 error=Phone->GetHardware(&s, buffer);
292 if (error != ERR_NOTSUPPORTED) { 292 if (error != ERR_NOTSUPPORTED) {
293 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 293 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
294 if (error == ERR_NONE) printmsg("Hardware : %s\n",buffer); 294 if (error == ERR_NONE) printmsg("Hardware : %s\n",buffer);
295 } 295 }
296 296
297 error=Phone->GetIMEI(&s); 297 error=Phone->GetIMEI(&s);
298 if (error != ERR_NOTSUPPORTED) { 298 if (error != ERR_NOTSUPPORTED) {
299 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 299 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
300 if (error == ERR_NONE) printmsg("IMEI : %s\n",s.Phone.Data.IMEI); 300 if (error == ERR_NONE) printmsg("IMEI : %s\n",s.Phone.Data.IMEI);
301 301
302 error=Phone->GetOriginalIMEI(&s, buffer); 302 error=Phone->GetOriginalIMEI(&s, buffer);
303 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) { 303 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
304 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 304 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
305 if (error == ERR_NONE) printmsg("Original IMEI : %s\n",buffer); 305 if (error == ERR_NONE) printmsg("Original IMEI : %s\n",buffer);
306 } 306 }
307 } 307 }
308 308
309 error=Phone->GetManufactureMonth(&s, buffer); 309 error=Phone->GetManufactureMonth(&s, buffer);
310 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) { 310 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
311 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 311 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
312 if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer); 312 if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer);
313 } 313 }
314 314
315 error=Phone->GetProductCode(&s, buffer); 315 error=Phone->GetProductCode(&s, buffer);
316 if (error != ERR_NOTSUPPORTED) { 316 if (error != ERR_NOTSUPPORTED) {
317 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 317 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
318 if (error == ERR_NONE) printmsg("Product code : %s\n",buffer); 318 if (error == ERR_NONE) printmsg("Product code : %s\n",buffer);
319 } 319 }
320 320
321 error=Phone->GetSIMIMSI(&s, buffer); 321 error=Phone->GetSIMIMSI(&s, buffer);
322 switch (error) { 322 switch (error) {
323 case ERR_SECURITYERROR: 323 case ERR_SECURITYERROR:
324 case ERR_NOTSUPPORTED: 324 case ERR_NOTSUPPORTED:
325 case ERR_NOTIMPLEMENTED: 325 case ERR_NOTIMPLEMENTED:
326 break; 326 break;
327 case ERR_NONE: 327 case ERR_NONE:
328 printmsg("SIM IMSI : %s\n",buffer); 328 printmsg("SIM IMSI : %s\n",buffer);
329 break; 329 break;
330 default: 330 default:
331 Print_Error(error); 331 Print_Error(error);
332 } 332 }
333 333
334#ifdef GSM_ENABLE_NOKIA_DCT3 334#ifdef GSM_ENABLE_NOKIA_DCT3
335 DCT3Info(argc, argv); 335 DCT3Info(argc, argv);
336#endif 336#endif
337#ifdef GSM_ENABLE_NOKIA_DCT4 337#ifdef GSM_ENABLE_NOKIA_DCT4
338 DCT4Info(argc, argv); 338 DCT4Info(argc, argv);
339#endif 339#endif
340 340
341 GSM_Terminate(); 341 GSM_Terminate();
342} 342}
343 343
344//#if 0 344//#if 0
345static void GetDateTime(int argc, char *argv[]) 345static void GetDateTime(int argc, char *argv[])
346{ 346{
347 GSM_DateTime date_time; 347 GSM_DateTime date_time;
348 GSM_Localelocale; 348 GSM_Localelocale;
349 349
350 GSM_Init(true); 350 GSM_Init(true);
351 351
352 error=Phone->GetDateTime(&s, &date_time); 352 error=Phone->GetDateTime(&s, &date_time);
353 switch (error) { 353 switch (error) {
354 case ERR_EMPTY: 354 case ERR_EMPTY:
355 printmsg("Date and time not set in phone\n"); 355 printmsg("Date and time not set in phone\n");
356 break; 356 break;
357 case ERR_NONE: 357 case ERR_NONE:
358 printmsg("Phone time is %s\n",OSDateTime(date_time,false)); 358 printmsg("Phone time is %s\n",OSDateTime(date_time,false));
359 break; 359 break;
360 default: 360 default:
361 Print_Error(error); 361 Print_Error(error);
362 } 362 }
363 363
364 error=Phone->GetLocale(&s, &locale); 364 error=Phone->GetLocale(&s, &locale);
365 switch (error) { 365 switch (error) {
366 case ERR_NOTSUPPORTED: 366 case ERR_NOTSUPPORTED:
367 case ERR_NOTIMPLEMENTED: 367 case ERR_NOTIMPLEMENTED:
368 break; 368 break;
369 default: 369 default:
370 Print_Error(error); 370 Print_Error(error);
371 printmsg("Time format is "); 371 printmsg("Time format is ");
372 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n"); 372 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n");
373 printmsg("Date format is "); 373 printmsg("Date format is ");
374 switch (locale.DateFormat) { 374 switch (locale.DateFormat) {
375 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break; 375 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break;
376 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break; 376 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break;
377 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD"); 377 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
378 } 378 }
379 printmsg(", date separator is %c\n",locale.DateSeparator); 379 printmsg(", date separator is %c\n",locale.DateSeparator);
380 } 380 }
381 381
382 GSM_Terminate(); 382 GSM_Terminate();
383} 383}
384 384
385static void SetDateTime(int argc, char *argv[]) 385static void SetDateTime(int argc, char *argv[])
386{ 386{
387 GSM_DateTime date_time; 387 GSM_DateTime date_time;
388 388
389 GSM_GetCurrentDateTime(&date_time); 389 GSM_GetCurrentDateTime(&date_time);
390 390
391 GSM_Init(true); 391 GSM_Init(true);
392 392
393 error=Phone->SetDateTime(&s, &date_time); 393 error=Phone->SetDateTime(&s, &date_time);
394 Print_Error(error); 394 Print_Error(error);
395 395
396 GSM_Terminate(); 396 GSM_Terminate();
397} 397}
398 398
399static void GetAlarm(int argc, char *argv[]) 399static void GetAlarm(int argc, char *argv[])
400{ 400{
401 GSM_Alarm alarm; 401 GSM_Alarm alarm;
402 402
403 GSM_Init(true); 403 GSM_Init(true);
404 404
405 alarm.Location = 1; 405 alarm.Location = 1;
406 error=Phone->GetAlarm(&s, &alarm); 406 error=Phone->GetAlarm(&s, &alarm);
407 switch (error) { 407 switch (error) {
408 case ERR_EMPTY: 408 case ERR_EMPTY:
409 printmsg("Alarm not set in phone\n"); 409 printmsg("Alarm not set in phone\n");
410 break; 410 break;
411 case ERR_NONE: 411 case ERR_NONE:
412 if (alarm.Repeating) { 412 if (alarm.Repeating) {
413 printmsg("Date: %s\n","Every day"); 413 printmsg("Date: %s\n","Every day");
414 } else { 414 } else {
415 printmsg("Date: %s\n",OSDate(alarm.DateTime)); 415 printmsg("Date: %s\n",OSDate(alarm.DateTime));
416 } 416 }
417 printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute); 417 printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute);
418 if (alarm.Text[0] != 0 || alarm.Text[1] != 0) { 418 if (alarm.Text[0] != 0 || alarm.Text[1] != 0) {
419 printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text)); 419 printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text));
420 } 420 }
421 break; 421 break;
422 default: 422 default:
423 Print_Error(error); 423 Print_Error(error);
424 } 424 }
425 425
426 GSM_Terminate(); 426 GSM_Terminate();
427} 427}
428 428
429static void SetAlarm(int argc, char *argv[]) 429static void SetAlarm(int argc, char *argv[])
430{ 430{
431 GSM_Alarm alarm; 431 GSM_Alarm alarm;
432 432
433 alarm.DateTime.Hour = atoi(argv[2]); 433 alarm.DateTime.Hour = atoi(argv[2]);
434 alarm.DateTime.Minute = atoi(argv[3]); 434 alarm.DateTime.Minute = atoi(argv[3]);
435 alarm.DateTime.Second = 0; 435 alarm.DateTime.Second = 0;
436 alarm.Location = 1; 436 alarm.Location = 1;
437 alarm.Repeating = true; 437 alarm.Repeating = true;
438 alarm.Text[0] = 0; 438 alarm.Text[0] = 0;
439 alarm.Text[1] = 0; 439 alarm.Text[1] = 0;
440 440
441 GSM_Init(true); 441 GSM_Init(true);
442 442
443 error=Phone->SetAlarm(&s, &alarm); 443 error=Phone->SetAlarm(&s, &alarm);
444 Print_Error(error); 444 Print_Error(error);
445 445
446 GSM_Terminate(); 446 GSM_Terminate();
447} 447}
448 448
449 GSM_Bitmap caller[5]; 449 GSM_Bitmap caller[5];
450 GSM_AllRingtonesInfo Info; 450 GSM_AllRingtonesInfo Info;
451 bool callerinit[5] = {false, false, false, false, false}; 451 bool callerinit[5] = {false, false, false, false, false};
452 bool ringinit = false; 452 bool ringinit = false;
453 453
454static void PrintMemoryEntry(GSM_MemoryEntry *entry) 454static void PrintMemoryEntry(GSM_MemoryEntry *entry)
455{ 455{
456 GSM_Category Category; 456 GSM_Category Category;
457 bool unknown; 457 bool unknown;
458 int z; 458 int z;
459 459
460 for (i=0;i<entry->EntriesNum;i++) { 460 for (i=0;i<entry->EntriesNum;i++) {
461 unknown = false; 461 unknown = false;
462 switch (entry->Entries[i].EntryType) { 462 switch (entry->Entries[i].EntryType) {
463 case PBK_Date: 463 case PBK_Date:
464 printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false)); 464 printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false));
465 continue; 465 continue;
466 case PBK_Category: 466 case PBK_Category:
467 Category.Location = entry->Entries[i].Number; 467 Category.Location = entry->Entries[i].Number;
468 Category.Type = Category_Phonebook; 468 Category.Type = Category_Phonebook;
469 error=Phone->GetCategory(&s, &Category); 469 error=Phone->GetCategory(&s, &Category);
470 if (error == ERR_NONE) { 470 if (error == ERR_NONE) {
471 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number); 471 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number);
472 } else { 472 } else {
473 printmsg("Category : %i\n", entry->Entries[i].Number); 473 printmsg("Category : %i\n", entry->Entries[i].Number);
474 } 474 }
475 continue; 475 continue;
476 case PBK_Private: 476 case PBK_Private:
477 printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No"); 477 printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No");
478 continue; 478 continue;
479 case PBK_Number_General : printmsg("General number "); break; 479 case PBK_Number_General : printmsg("General number "); break;
480 case PBK_Number_Mobile : printmsg("Mobile number "); break; 480 case PBK_Number_Mobile : printmsg("Mobile number "); break;
481 case PBK_Number_Work : printmsg("Work number "); break; 481 case PBK_Number_Work : printmsg("Work number "); break;
482 case PBK_Number_Fax : printmsg("Fax number "); break; 482 case PBK_Number_Fax : printmsg("Fax number "); break;
483 case PBK_Number_Home : printmsg("Home number "); break; 483 case PBK_Number_Home : printmsg("Home number "); break;
484 case PBK_Number_Pager : printmsg("Pager number "); break; 484 case PBK_Number_Pager : printmsg("Pager number "); break;
485 case PBK_Number_Other : printmsg("Other number "); break; 485 case PBK_Number_Other : printmsg("Other number "); break;
486 case PBK_Text_Note : printmsg("Text "); break; 486 case PBK_Text_Note : printmsg("Text "); break;
487 case PBK_Text_Postal : printmsg("Snail address "); break; 487 case PBK_Text_Postal : printmsg("Snail address "); break;
488 case PBK_Text_Email : printmsg("Email address 1 "); break; 488 case PBK_Text_Email : printmsg("Email address 1 "); break;
489 case PBK_Text_Email2 : printmsg("Email address 2 "); break; 489 case PBK_Text_Email2 : printmsg("Email address 2 "); break;
490 case PBK_Text_URL : printmsg("URL address "); break; 490 case PBK_Text_URL : printmsg("URL address "); break;
491 case PBK_Text_Name : printmsg("Name "); break; 491 case PBK_Text_Name : printmsg("Name "); break;
492 case PBK_Text_LastName : printmsg("Last name "); break; 492 case PBK_Text_LastName : printmsg("Last name "); break;
493 case PBK_Text_FirstName : printmsg("First name "); break; 493 case PBK_Text_FirstName : printmsg("First name "); break;
494 case PBK_Text_Company : printmsg("Company "); break; 494 case PBK_Text_Company : printmsg("Company "); break;
495 case PBK_Text_JobTitle : printmsg("Job title "); break; 495 case PBK_Text_JobTitle : printmsg("Job title "); break;
496 case PBK_Text_StreetAddress : printmsg("Street address "); break; 496 case PBK_Text_StreetAddress : printmsg("Street address "); break;
497 case PBK_Text_City : printmsg("City "); break; 497 case PBK_Text_City : printmsg("City "); break;
498 case PBK_Text_State : printmsg("State "); break; 498 case PBK_Text_State : printmsg("State "); break;
499 case PBK_Text_Zip : printmsg("Zip code "); break; 499 case PBK_Text_Zip : printmsg("Zip code "); break;
500 case PBK_Text_Country : printmsg("Country "); break; 500 case PBK_Text_Country : printmsg("Country "); break;
501 case PBK_Text_Custom1 : printmsg("Custom text 1 "); break; 501 case PBK_Text_Custom1 : printmsg("Custom text 1 "); break;
502 case PBK_Text_Custom2 : printmsg("Custom text 2 "); break; 502 case PBK_Text_Custom2 : printmsg("Custom text 2 "); break;
503 case PBK_Text_Custom3 : printmsg("Custom text 3 "); break; 503 case PBK_Text_Custom3 : printmsg("Custom text 3 "); break;
504 case PBK_Text_Custom4 : printmsg("Custom text 4 "); break; 504 case PBK_Text_Custom4 : printmsg("Custom text 4 "); break;
505 case PBK_Caller_Group : 505 case PBK_Caller_Group :
506 unknown = true; 506 unknown = true;
507 if (!callerinit[entry->Entries[i].Number]) { 507 if (!callerinit[entry->Entries[i].Number]) {
508 caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo; 508 caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo;
509 caller[entry->Entries[i].Number].Location = entry->Entries[i].Number; 509 caller[entry->Entries[i].Number].Location = entry->Entries[i].Number;
510 error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]); 510 error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]);
511 Print_Error(error); 511 Print_Error(error);
512 if (caller[entry->Entries[i].Number].DefaultName) { 512 if (caller[entry->Entries[i].Number].DefaultName) {
513 NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]); 513 NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]);
514 } 514 }
515 callerinit[entry->Entries[i].Number]=true; 515 callerinit[entry->Entries[i].Number]=true;
516 } 516 }
517 printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text)); 517 printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text));
518 break; 518 break;
519 case PBK_RingtoneID : 519 case PBK_RingtoneID :
520 unknown = true; 520 unknown = true;
521 if (!ringinit) { 521 if (!ringinit) {
522 error=Phone->GetRingtonesInfo(&s,&Info); 522 error=Phone->GetRingtonesInfo(&s,&Info);
523 if (error != ERR_NOTSUPPORTED) Print_Error(error); 523 if (error != ERR_NOTSUPPORTED) Print_Error(error);
524 if (error == ERR_NONE) ringinit = true; 524 if (error == ERR_NONE) ringinit = true;
525 } 525 }
526 if (ringinit) { 526 if (ringinit) {
527 for (z=0;z<Info.Number;z++) { 527 for (z=0;z<Info.Number;z++) {
528 if (Info.Ringtone[z].ID == entry->Entries[i].Number) { 528 if (Info.Ringtone[z].ID == entry->Entries[i].Number) {
529 printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name)); 529 printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name));
530 break; 530 break;
531 } 531 }
532 } 532 }
533 } else { 533 } else {
534 printmsg("Ringtone ID : %i\n",entry->Entries[i].Number); 534 printmsg("Ringtone ID : %i\n",entry->Entries[i].Number);
535 } 535 }
536 break; 536 break;
537 case PBK_PictureID : 537 case PBK_PictureID :
538 unknown = true; 538 unknown = true;
539 printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number); 539 printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number);
540 break; 540 break;
541 default : 541 default :
542 printmsg("UNKNOWN\n"); 542 printmsg("UNKNOWN\n");
543 unknown = true; 543 unknown = true;
544 break; 544 break;
545 } 545 }
546 if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text)); 546 if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text));
547 } 547 }
548 printf("\n"); 548 printf("\n");
549} 549}
550 550
551static void GetAllMemory(int argc, char *argv[]) 551static void GetAllMemory(int argc, char *argv[])
552{ 552{
553 GSM_MemoryEntry Entry; 553 GSM_MemoryEntry Entry;
554 bool start = true; 554 bool start = true;
555 555
556 signal(SIGINT, interrupt); 556 signal(SIGINT, interrupt);
557 printmsgerr("Press Ctrl+C to break...\n"); 557 printmsgerr("Press Ctrl+C to break...\n");
558 558
559 Entry.MemoryType = 0; 559 Entry.MemoryType = 0;
560 560
561 if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC; 561 if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC;
562 if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON; 562 if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON;
563 if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC; 563 if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC;
564 if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC; 564 if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC;
565 if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME; 565 if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME;
566 if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM; 566 if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM;
567 if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM; 567 if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM;
568 if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD; 568 if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD;
569 if (Entry.MemoryType==0) { 569 if (Entry.MemoryType==0) {
570 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]); 570 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
571 exit (-1); 571 exit (-1);
572 } 572 }
573 573
574 GSM_Init(true); 574 GSM_Init(true);
575 575
576 while (!gshutdown) { 576 while (!gshutdown) {
577 error = Phone->GetNextMemory(&s, &Entry, start); 577 error = Phone->GetNextMemory(&s, &Entry, start);
578 if (error == ERR_EMPTY) break; 578 if (error == ERR_EMPTY) break;
579 Print_Error(error); 579 Print_Error(error);
580 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location); 580 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location);
581 PrintMemoryEntry(&Entry); 581 PrintMemoryEntry(&Entry);
582 start = false; 582 start = false;
583 } 583 }
584 584
585 GSM_Terminate(); 585 GSM_Terminate();
586} 586}
587 587
588static void GetMemory(int argc, char *argv[]) 588static void GetMemory(int argc, char *argv[])
589{ 589{
590 int j, start, stop; 590 int j, start, stop;
591 GSM_MemoryEntry entry; 591 GSM_MemoryEntry entry;
592 592
593 entry.MemoryType=0; 593 entry.MemoryType=0;
594 594
595 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC; 595 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC;
596 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON; 596 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON;
597 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC; 597 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC;
598 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC; 598 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC;
599 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME; 599 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME;
600 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM; 600 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM;
601 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM; 601 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM;
602 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD; 602 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD;
603 if (entry.MemoryType==0) { 603 if (entry.MemoryType==0) {
604 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]); 604 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
605 exit (-1); 605 exit (-1);
606 } 606 }
607 607
608 GetStartStop(&start, &stop, 3, argc, argv); 608 GetStartStop(&start, &stop, 3, argc, argv);
609 609
610 GSM_Init(true); 610 GSM_Init(true);
611 611
612 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) { 612 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) {
613 if (s.Phone.Data.VerNum<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n"); 613 if (s.Phone.Data.VerNum<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n");
614 } 614 }
615 615
616 for (j=start;j<=stop;j++) { 616 for (j=start;j<=stop;j++) {
617 printmsg("Memory %s, Location %i\n",argv[2],j); 617 printmsg("Memory %s, Location %i\n",argv[2],j);
618 618
619 entry.Location=j; 619 entry.Location=j;
620 620
621 error=Phone->GetMemory(&s, &entry); 621 error=Phone->GetMemory(&s, &entry);
622 if (error != ERR_EMPTY) Print_Error(error); 622 if (error != ERR_EMPTY) Print_Error(error);
623 623
624 if (error == ERR_EMPTY) { 624 if (error == ERR_EMPTY) {
625 printmsg("Entry is empty\n"); 625 printmsg("Entry is empty\n");
626 printf("\n"); 626 printf("\n");
627 } else { 627 } else {
628 PrintMemoryEntry(&entry); 628 PrintMemoryEntry(&entry);
629 } 629 }
630 } 630 }
631 631
632 GSM_Terminate(); 632 GSM_Terminate();
633} 633}
634 634
635#define MemoryLocationToString(x) ( \ 635#define MemoryLocationToString(x) ( \
636 x == MEM_ON ? "ON" : \ 636 x == MEM_ON ? "ON" : \
637 x == MEM_RC ? "RC" : \ 637 x == MEM_RC ? "RC" : \
638 x == MEM_MC ? "MC" : \ 638 x == MEM_MC ? "MC" : \
639 x == MEM_ME ? "ME" : \ 639 x == MEM_ME ? "ME" : \
640 x == MEM_SM ? "SM" : \ 640 x == MEM_SM ? "SM" : \
641 x == MEM_VM ? "VM" : \ 641 x == MEM_VM ? "VM" : \
642 x == MEM_FD ? "FD" : "XX") 642 x == MEM_FD ? "FD" : "XX")
643 643
644static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text) 644static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
645{ 645{
646 int i; 646 int i;
647 647
648 for (i=0;i<Entry->EntriesNum;i++) { 648 for (i=0;i<Entry->EntriesNum;i++) {
649 switch (Entry->Entries[i].EntryType) { 649 switch (Entry->Entries[i].EntryType) {
650 case PBK_Number_General : 650 case PBK_Number_General :
651 case PBK_Number_Mobile : 651 case PBK_Number_Mobile :
652 case PBK_Number_Work : 652 case PBK_Number_Work :
653 case PBK_Number_Fax : 653 case PBK_Number_Fax :
654 case PBK_Number_Home : 654 case PBK_Number_Home :
655 case PBK_Number_Pager : 655 case PBK_Number_Pager :
656 case PBK_Number_Other : 656 case PBK_Number_Other :
657 case PBK_Text_Note : 657 case PBK_Text_Note :
658 case PBK_Text_Postal : 658 case PBK_Text_Postal :
659 case PBK_Text_Email : 659 case PBK_Text_Email :
660 case PBK_Text_Email2 : 660 case PBK_Text_Email2 :
661 case PBK_Text_URL : 661 case PBK_Text_URL :
662 case PBK_Text_Name : 662 case PBK_Text_Name :
663 case PBK_Text_LastName : 663 case PBK_Text_LastName :
664 case PBK_Text_FirstName : 664 case PBK_Text_FirstName :
665 case PBK_Text_Company : 665 case PBK_Text_Company :
666 case PBK_Text_JobTitle : 666 case PBK_Text_JobTitle :
667 case PBK_Text_StreetAddress : 667 case PBK_Text_StreetAddress :
668 case PBK_Text_City : 668 case PBK_Text_City :
669 case PBK_Text_State : 669 case PBK_Text_State :
670 case PBK_Text_Zip : 670 case PBK_Text_Zip :
671 case PBK_Text_Country : 671 case PBK_Text_Country :
672 case PBK_Text_Custom1 : 672 case PBK_Text_Custom1 :
673 case PBK_Text_Custom2 : 673 case PBK_Text_Custom2 :
674 case PBK_Text_Custom3 : 674 case PBK_Text_Custom3 :
675 case PBK_Text_Custom4 : 675 case PBK_Text_Custom4 :
676 case PBK_Caller_Group : 676 case PBK_Caller_Group :
677 if (mystrstr(Entry->Entries[i].Text, Text) != NULL) { 677 if (mystrstr(Entry->Entries[i].Text, Text) != NULL) {
678 fprintf(stderr,"\n"); 678 fprintf(stderr,"\n");
679 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location); 679 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location);
680 PrintMemoryEntry(Entry); 680 PrintMemoryEntry(Entry);
681 return; 681 return;
682 } 682 }
683 break; 683 break;
684 default: 684 default:
685 break; 685 break;
686 } 686 }
687 } 687 }
688 } 688 }
689 689
690static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text) 690static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text)
691{ 691{
692 GSM_MemoryEntry Entry; 692 GSM_MemoryEntry Entry;
693 GSM_MemoryStatusStatus; 693 GSM_MemoryStatusStatus;
694 int i = 0, l = 1; 694 int i = 0, l = 1;
695 bool start = true; 695 bool start = true;
696 696
697 Status.MemoryType = MemoryType; 697 Status.MemoryType = MemoryType;
698 Entry.MemoryType = MemoryType; 698 Entry.MemoryType = MemoryType;
699 699
700 if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) { 700 if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) {
701 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1)); 701 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
702 if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) { 702 if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) {
703 while (i < Status.MemoryUsed) { 703 while (i < Status.MemoryUsed) {
704 if (gshutdown) return; 704 if (gshutdown) return;
705 i++; 705 i++;
706 fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1)); 706 fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1));
707 error = Phone->GetNextMemory(&s, &Entry, start); 707 error = Phone->GetNextMemory(&s, &Entry, start);
708 if (error == ERR_EMPTY) break; 708 if (error == ERR_EMPTY) break;
709 Print_Error(error); 709 Print_Error(error);
710 SearchOneEntry(&Entry, Text); 710 SearchOneEntry(&Entry, Text);
711 start = false; 711 start = false;
712 } 712 }
713 } else { 713 } else {
714 while (i < Status.MemoryUsed) { 714 while (i < Status.MemoryUsed) {
715 Entry.Location = l; 715 Entry.Location = l;
716 error = Phone->GetMemory(&s, &Entry); 716 error = Phone->GetMemory(&s, &Entry);
717 if (error != ERR_EMPTY) { 717 if (error != ERR_EMPTY) {
718 Print_Error(error); 718 Print_Error(error);
719 i++; 719 i++;
720 SearchOneEntry(&Entry, Text); 720 SearchOneEntry(&Entry, Text);
721 } 721 }
722 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1)); 722 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
723 l++; 723 l++;
724 } 724 }
725 } 725 }
726 fprintf(stderr,"\n"); 726 fprintf(stderr,"\n");
727 } 727 }
728} 728}
729 729
730static void SearchMemory(int argc, char *argv[]) 730static void SearchMemory(int argc, char *argv[])
731{ 731{
732 unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2]; 732 unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2];
733 int Length; 733 int Length;
734 734
735 signal(SIGINT, interrupt); 735 signal(SIGINT, interrupt);
736 printmsgerr("Press Ctrl+C to break...\n"); 736 printmsgerr("Press Ctrl+C to break...\n");
737 737
738 Length = strlen(argv[2]); 738 Length = strlen(argv[2]);
739 if (Length > GSM_PHONEBOOK_TEXT_LENGTH) { 739 if (Length > GSM_PHONEBOOK_TEXT_LENGTH) {
740 printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH); 740 printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH);
741 Length = GSM_PHONEBOOK_TEXT_LENGTH; 741 Length = GSM_PHONEBOOK_TEXT_LENGTH;
742 } 742 }
743 EncodeUnicode(Text, argv[2], Length); 743 EncodeUnicode(Text, argv[2], Length);
744 744
745 GSM_Init(true); 745 GSM_Init(true);
746 746
747 if (!gshutdown) SearchOneMemory(MEM_ME, "Phone phonebook", Text); 747 if (!gshutdown) SearchOneMemory(MEM_ME, "Phone phonebook", Text);
748 if (!gshutdown) SearchOneMemory(MEM_SM, "SIM phonebook", Text); 748 if (!gshutdown) SearchOneMemory(MEM_SM, "SIM phonebook", Text);
749 if (!gshutdown) SearchOneMemory(MEM_ON, "Own numbers", Text); 749 if (!gshutdown) SearchOneMemory(MEM_ON, "Own numbers", Text);
750 if (!gshutdown) SearchOneMemory(MEM_DC, "Dialled numbers", Text); 750 if (!gshutdown) SearchOneMemory(MEM_DC, "Dialled numbers", Text);
751 if (!gshutdown) SearchOneMemory(MEM_RC, "Received numbers", Text); 751 if (!gshutdown) SearchOneMemory(MEM_RC, "Received numbers", Text);
752 if (!gshutdown) SearchOneMemory(MEM_MC, "Missed numbers", Text); 752 if (!gshutdown) SearchOneMemory(MEM_MC, "Missed numbers", Text);
753 if (!gshutdown) SearchOneMemory(MEM_FD, "Fix dialling", Text); 753 if (!gshutdown) SearchOneMemory(MEM_FD, "Fix dialling", Text);
754 if (!gshutdown) SearchOneMemory(MEM_VM, "Voice mailbox", Text); 754 if (!gshutdown) SearchOneMemory(MEM_VM, "Voice mailbox", Text);
755 755
756 GSM_Terminate(); 756 GSM_Terminate();
757} 757}
758 758
759static void ListMemoryCategoryEntries(int Category) 759static void ListMemoryCategoryEntries(int Category)
760{ 760{
761 GSM_MemoryEntry Entry; 761 GSM_MemoryEntry Entry;
762 bool start = true; 762 bool start = true;
763 int j; 763 int j;
764 764
765 /* Category can be only for ME stored entries */ 765 /* Category can be only for ME stored entries */
766 Entry.MemoryType = MEM_ME; 766 Entry.MemoryType = MEM_ME;
767 767
768 while (!gshutdown) { 768 while (!gshutdown) {
769 error = Phone->GetNextMemory(&s, &Entry, start); 769 error = Phone->GetNextMemory(&s, &Entry, start);
770 if (error == ERR_EMPTY) break; 770 if (error == ERR_EMPTY) break;
771 Print_Error(error); 771 Print_Error(error);
772 for (j=0;j<Entry.EntriesNum;j++) { 772 for (j=0;j<Entry.EntriesNum;j++) {
773 if (Entry.Entries[j].EntryType == PBK_Category && Entry.Entries[j].Number == Category) { 773 if (Entry.Entries[j].EntryType == PBK_Category && Entry.Entries[j].Number == Category) {
774 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry.MemoryType),Entry.Location); 774 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry.MemoryType),Entry.Location);
775 PrintMemoryEntry(&Entry); 775 PrintMemoryEntry(&Entry);
776 } 776 }
777 } 777 }
778 start = false; 778 start = false;
779 } 779 }
780} 780}
781 781
782static void ListMemoryCategory(int argc, char *argv[]) 782static void ListMemoryCategory(int argc, char *argv[])
783{ 783{
784 GSM_Category Category; 784 GSM_Category Category;
785 GSM_CategoryStatusStatus; 785 GSM_CategoryStatusStatus;
786 int j, count; 786 int j, count;
787 787
788 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; 788 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
789 int Length; 789 int Length;
790 bool Number = true;; 790 bool Number = true;;
791 791
792 GSM_Init(true); 792 GSM_Init(true);
793 793
794 signal(SIGINT, interrupt); 794 signal(SIGINT, interrupt);
795 printmsgerr("Press Ctrl+C to break...\n"); 795 printmsgerr("Press Ctrl+C to break...\n");
796 796
797 Length = strlen(argv[2]); 797 Length = strlen(argv[2]);
798 for (j = 0; j < Length; j++) { 798 for (j = 0; j < Length; j++) {
799 if (!isdigit(argv[2][j])) { 799 if (!isdigit(argv[2][j])) {
800 Number = false; 800 Number = false;
801 break; 801 break;
802 } 802 }
803 } 803 }
804 804
805 if (Number) { 805 if (Number) {
806 j = atoi(argv[2]); 806 j = atoi(argv[2]);
807 if (j > 0) { 807 if (j > 0) {
808 ListMemoryCategoryEntries(j); 808 ListMemoryCategoryEntries(j);
809 } 809 }
810 } else { 810 } else {
811 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { 811 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
812 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); 812 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
813 Length = GSM_MAX_CATEGORY_NAME_LENGTH; 813 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
814 } 814 }
815 EncodeUnicode(Text, argv[2], Length); 815 EncodeUnicode(Text, argv[2], Length);
816 816
817 Category.Type = Category_Phonebook; 817 Category.Type = Category_Phonebook;
818 Status.Type = Category_Phonebook; 818 Status.Type = Category_Phonebook;
819 819
820 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 820 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
821 for (count=0,j=1;count<Status.Used;j++) { 821 for (count=0,j=1;count<Status.Used;j++) {
822 Category.Location=j; 822 Category.Location=j;
823 error=Phone->GetCategory(&s, &Category); 823 error=Phone->GetCategory(&s, &Category);
824 824
825 if (error != ERR_EMPTY) { 825 if (error != ERR_EMPTY) {
826 count++; 826 count++;
827 if (mystrstr(Category.Name, Text) != NULL) { 827 if (mystrstr(Category.Name, Text) != NULL) {
828 ListMemoryCategoryEntries(j); 828 ListMemoryCategoryEntries(j);
829 } 829 }
830 } 830 }
831 } 831 }
832 } 832 }
833 } 833 }
834 GSM_Terminate(); 834 GSM_Terminate();
835} 835}
836 836
837static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh) 837static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh)
838{ 838{
839 switch (sms.PDU) { 839 switch (sms.PDU) {
840 case SMS_Status_Report: 840 case SMS_Status_Report:
841 printmsg("SMS status report\n"); 841 printmsg("SMS status report\n");
842 printmsg("Status : "); 842 printmsg("Status : ");
843 switch (sms.State) { 843 switch (sms.State) {
844 case SMS_Sent : printmsg("Sent");break; 844 case SMS_Sent : printmsg("Sent");break;
845 case SMS_Read : printmsg("Read");break; 845 case SMS_Read : printmsg("Read");break;
846 case SMS_UnRead : printmsg("UnRead");break; 846 case SMS_UnRead : printmsg("UnRead");break;
847 case SMS_UnSent : printmsg("UnSent");break; 847 case SMS_UnSent : printmsg("UnSent");break;
848 } 848 }
849 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number)); 849 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
850 printmsg("Reference number: 0x%02X\n",sms.MessageReference); 850 printmsg("Reference number: 0x%02X\n",sms.MessageReference);
851 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true)); 851 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true));
852 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number)); 852 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number));
853 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true)); 853 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true));
854 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text)); 854 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text));
855 printmsg("Details : "); 855 printmsg("Details : ");
856 if (sms.DeliveryStatus & 0x40) { 856 if (sms.DeliveryStatus & 0x40) {
857 if (sms.DeliveryStatus & 0x20) { 857 if (sms.DeliveryStatus & 0x20) {
858 printmsg("Temporary error, "); 858 printmsg("Temporary error, ");
859 } else { 859 } else {
860 printmsg("Permanent error, "); 860 printmsg("Permanent error, ");
861 } 861 }
862 } else if (sms.DeliveryStatus & 0x20) { 862 } else if (sms.DeliveryStatus & 0x20) {
863 printmsg("Temporary error, "); 863 printmsg("Temporary error, ");
864 } 864 }
865 switch (sms.DeliveryStatus) { 865 switch (sms.DeliveryStatus) {
866 case 0x00: printmsg("SM received by the SME"); break; 866 case 0x00: printmsg("SM received by the SME"); break;
867 case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break; 867 case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break;
868 case 0x02: printmsg("SM replaced by the SC"); break; 868 case 0x02: printmsg("SM replaced by the SC"); break;
869 case 0x20: printmsg("Congestion"); break; 869 case 0x20: printmsg("Congestion"); break;
870 case 0x21: printmsg("SME busy"); break; 870 case 0x21: printmsg("SME busy"); break;
871 case 0x22: printmsg("No response from SME"); break; 871 case 0x22: printmsg("No response from SME"); break;
872 case 0x23: printmsg("Service rejected"); break; 872 case 0x23: printmsg("Service rejected"); break;
873 case 0x24: printmsg("Quality of service not aviable"); break; 873 case 0x24: printmsg("Quality of service not aviable"); break;
874 case 0x25: printmsg("Error in SME"); break; 874 case 0x25: printmsg("Error in SME"); break;
875 case 0x40: printmsg("Remote procedure error"); break; 875 case 0x40: printmsg("Remote procedure error"); break;
876 case 0x41: printmsg("Incompatibile destination"); break; 876 case 0x41: printmsg("Incompatibile destination"); break;
877 case 0x42: printmsg("Connection rejected by SME"); break; 877 case 0x42: printmsg("Connection rejected by SME"); break;
878 case 0x43: printmsg("Not obtainable"); break; 878 case 0x43: printmsg("Not obtainable"); break;
879 case 0x44: printmsg("Quality of service not available"); break; 879 case 0x44: printmsg("Quality of service not available"); break;
880 case 0x45: printmsg("No internetworking available"); break; 880 case 0x45: printmsg("No internetworking available"); break;
881 case 0x46: printmsg("SM Validity Period Expired"); break; 881 case 0x46: printmsg("SM Validity Period Expired"); break;
882 case 0x47: printmsg("SM deleted by originating SME"); break; 882 case 0x47: printmsg("SM deleted by originating SME"); break;
883 case 0x48: printmsg("SM Deleted by SC Administration"); break; 883 case 0x48: printmsg("SM Deleted by SC Administration"); break;
884 case 0x49: printmsg("SM does not exist"); break; 884 case 0x49: printmsg("SM does not exist"); break;
885 case 0x60: printmsg("Congestion"); break; 885 case 0x60: printmsg("Congestion"); break;
886 case 0x61: printmsg("SME busy"); break; 886 case 0x61: printmsg("SME busy"); break;
887 case 0x62: printmsg("No response from SME"); break; 887 case 0x62: printmsg("No response from SME"); break;
888 case 0x63: printmsg("Service rejected"); break; 888 case 0x63: printmsg("Service rejected"); break;
889 case 0x64: printmsg("Quality of service not available"); break; 889 case 0x64: printmsg("Quality of service not available"); break;
890 case 0x65: printmsg("Error in SME"); break; 890 case 0x65: printmsg("Error in SME"); break;
891 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break; 891 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break;
892 } 892 }
893 printf("\n"); 893 printf("\n");
894 break; 894 break;
895 case SMS_Deliver: 895 case SMS_Deliver:
896 printmsg("SMS message\n"); 896 printmsg("SMS message\n");
897 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number)); 897 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number));
898 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)"); 898 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)");
899 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true)); 899 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true));
900 /* No break. The only difference for SMS_Deliver and SMS_Submit is, 900 /* No break. The only difference for SMS_Deliver and SMS_Submit is,
901 * that SMS_Deliver contains additional data. We wrote them and then go 901 * that SMS_Deliver contains additional data. We wrote them and then go
902 * for data shared with SMS_Submit 902 * for data shared with SMS_Submit
903 */ 903 */
904 case SMS_Submit: 904 case SMS_Submit:
905 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage); 905 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage);
906 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */ 906 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */
907 if (sms.PDU==SMS_Submit) { 907 if (sms.PDU==SMS_Submit) {
908 printmsg("SMS message\n"); 908 printmsg("SMS message\n");
909 printmsg("Reference number : 0x%02X\n",sms.MessageReference); 909 printmsg("Reference number : 0x%02X\n",sms.MessageReference);
910 } 910 }
911 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) { 911 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) {
912 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name)); 912 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name));
913 } 913 }
914 if (sms.Class != -1) { 914 if (sms.Class != -1) {
915 printmsg("Class : %i\n",sms.Class); 915 printmsg("Class : %i\n",sms.Class);
916 } 916 }
917 printmsg("Coding : "); 917 printmsg("Coding : ");
918 switch (sms.Coding) { 918 switch (sms.Coding) {
919 case SMS_Coding_Unicode : printmsg("Unicode\n"); break; 919 case SMS_Coding_Unicode : printmsg("Unicode\n"); break;
920 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break; 920 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break;
921 case SMS_Coding_8bit : printmsg("8 bit\n"); break; 921 case SMS_Coding_8bit : printmsg("8 bit\n"); break;
922 } 922 }
923 printmsg("Status : "); 923 printmsg("Status : ");
924 switch (sms.State) { 924 switch (sms.State) {
925 case SMS_Sent : printmsg("Sent");break; 925 case SMS_Sent : printmsg("Sent");break;
926 case SMS_Read : printmsg("Read");break; 926 case SMS_Read : printmsg("Read");break;
927 case SMS_UnRead : printmsg("UnRead");break; 927 case SMS_UnRead : printmsg("UnRead");break;
928 case SMS_UnSent : printmsg("UnSent");break; 928 case SMS_UnSent : printmsg("UnSent");break;
929 } 929 }
930 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number)); 930 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
931 if (sms.UDH.Type != UDH_NoUDH) { 931 if (sms.UDH.Type != UDH_NoUDH) {
932 printmsg("User Data Header : "); 932 printmsg("User Data Header : ");
933 switch (sms.UDH.Type) { 933 switch (sms.UDH.Type) {
934 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break; 934 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break;
935 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break; 935 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break;
936 case UDH_DisableVoice : printmsg("Disables voice indicator"); break; 936 case UDH_DisableVoice : printmsg("Disables voice indicator"); break;
937 case UDH_EnableVoice : printmsg("Enables voice indicator"); break; 937 case UDH_EnableVoice : printmsg("Enables voice indicator"); break;
938 case UDH_DisableFax : printmsg("Disables fax indicator"); break; 938 case UDH_DisableFax : printmsg("Disables fax indicator"); break;
939 case UDH_EnableFax : printmsg("Enables fax indicator"); break; 939 case UDH_EnableFax : printmsg("Enables fax indicator"); break;
940 case UDH_DisableEmail : printmsg("Disables email indicator"); break; 940 case UDH_DisableEmail : printmsg("Disables email indicator"); break;
941 case UDH_EnableEmail : printmsg("Enables email indicator"); break; 941 case UDH_EnableEmail : printmsg("Enables email indicator"); break;
942 case UDH_VoidSMS : printmsg("Void SMS"); break; 942 case UDH_VoidSMS : printmsg("Void SMS"); break;
943 case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break; 943 case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break;
944 case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break; 944 case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break;
945 case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break; 945 case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break;
946 case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break; 946 case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break;
947 case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break; 947 case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break;
948 case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break; 948 case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break;
949 case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break; 949 case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break;
950 case UDH_NokiaProfileLong : printmsg("Nokia profile"); break; 950 case UDH_NokiaProfileLong : printmsg("Nokia profile"); break;
951 case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break; 951 case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break;
952 case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break; 952 case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break;
953 case UDH_UserUDH : printmsg("User UDH"); break; 953 case UDH_UserUDH : printmsg("User UDH"); break;
954 case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break; 954 case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break;
955 case UDH_NoUDH: break; 955 case UDH_NoUDH: break;
956 } 956 }
957 if (sms.UDH.Type != UDH_NoUDH) { 957 if (sms.UDH.Type != UDH_NoUDH) {
958 if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit); 958 if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit);
959 if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit); 959 if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit);
960 if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) { 960 if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) {
961 if (displayudh) { 961 if (displayudh) {
962 printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts); 962 printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts);
963 } else { 963 } else {
964 printmsg(", %i parts",sms.UDH.AllParts); 964 printmsg(", %i parts",sms.UDH.AllParts);
965 } 965 }
966 } 966 }
967 } 967 }
968 printf("\n"); 968 printf("\n");
969 } 969 }
970 if (displaytext) { 970 if (displaytext) {
971 printf("\n"); 971 printf("\n");
972 if (sms.Coding!=SMS_Coding_8bit) { 972 if (sms.Coding!=SMS_Coding_8bit) {
973 printmsg("%s\n",DecodeUnicodeConsole(sms.Text)); 973 printmsg("%s\n",DecodeUnicodeConsole(sms.Text));
974 } else { 974 } else {
975 printmsg("8 bit SMS, cannot be displayed here\n"); 975 printmsg("8 bit SMS, cannot be displayed here\n");
976 } 976 }
977 } 977 }
978 break; 978 break;
979 } 979 }
980} 980}
981//#if 0 981//#if 0
982static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems) 982static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems)
983{ 983{
984 GSM_MultiPartSMSInfoSMSInfo; 984 GSM_MultiPartSMSInfoSMSInfo;
985 bool RetVal,udhinfo=true; 985 bool RetVal,udhinfo=true;
986 int j; 986 int j;
987 987
988 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */ 988 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */
989 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems); 989 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems);
990 990
991 if (eachsms) { 991 if (eachsms) {
992 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false; 992 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false;
993 if (RetVal && !udhinfo) { 993 if (RetVal && !udhinfo) {
994 displaysinglesmsinfo(sms.SMS[0],false,false); 994 displaysinglesmsinfo(sms.SMS[0],false,false);
995 printf("\n"); 995 printf("\n");
996 } else { 996 } else {
997 for (j=0;j<sms.Number;j++) { 997 for (j=0;j<sms.Number;j++) {
998 displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo); 998 displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo);
999 printf("\n"); 999 printf("\n");
1000 } 1000 }
1001 } 1001 }
1002 } else { 1002 } else {
1003 for (j=0;j<sms.Number;j++) { 1003 for (j=0;j<sms.Number;j++) {
1004 displaysinglesmsinfo(sms.SMS[j],!RetVal,true); 1004 displaysinglesmsinfo(sms.SMS[j],!RetVal,true);
1005 printf("\n"); 1005 printf("\n");
1006 } 1006 }
1007 } 1007 }
1008 if (!RetVal) { 1008 if (!RetVal) {
1009 GSM_FreeMultiPartSMSInfo(&SMSInfo); 1009 GSM_FreeMultiPartSMSInfo(&SMSInfo);
1010 return; 1010 return;
1011 } 1011 }
1012 1012
1013 if (SMSInfo.Unknown) printmsg("Some details were ignored (unknown or not implemented in decoding functions)\n\n"); 1013 if (SMSInfo.Unknown) printmsg("Some details were ignored (unknown or not implemented in decoding functions)\n\n");
1014 1014
1015 for (i=0;i<SMSInfo.EntriesNum;i++) { 1015 for (i=0;i<SMSInfo.EntriesNum;i++) {
1016 switch (SMSInfo.Entries[i].ID) { 1016 switch (SMSInfo.Entries[i].ID) {
1017 case SMS_NokiaRingtone: 1017 case SMS_NokiaRingtone:
1018 printmsg("Ringtone \"%s\"\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Ringtone->Name)); 1018 printmsg("Ringtone \"%s\"\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Ringtone->Name));
1019 saverttl(stdout,SMSInfo.Entries[i].Ringtone); 1019 saverttl(stdout,SMSInfo.Entries[i].Ringtone);
1020 printf("\n"); 1020 printf("\n");
1021 if (s.Phone.Functions->PlayTone!=NOTSUPPORTED && 1021 if (s.Phone.Functions->PlayTone!=NOTSUPPORTED &&
1022 s.Phone.Functions->PlayTone!=NOTIMPLEMENTED) { 1022 s.Phone.Functions->PlayTone!=NOTIMPLEMENTED) {
1023 if (answer_yes("Do you want to play it")) GSM_PlayRingtone(*SMSInfo.Entries[i].Ringtone); 1023 if (answer_yes("Do you want to play it")) GSM_PlayRingtone(*SMSInfo.Entries[i].Ringtone);
1024 } 1024 }
1025 break; 1025 break;
1026 case SMS_NokiaCallerLogo: 1026 case SMS_NokiaCallerLogo:
1027 printmsg("Caller logo\n\n"); 1027 printmsg("Caller logo\n\n");
1028 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1028 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1029 break; 1029 break;
1030 case SMS_NokiaOperatorLogo: 1030 case SMS_NokiaOperatorLogo:
1031 printmsg("Operator logo for %s network (%s, %s)\n\n", 1031 printmsg("Operator logo for %s network (%s, %s)\n\n",
1032 SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode, 1032 SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode,
1033 DecodeUnicodeConsole(GSM_GetNetworkName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)), 1033 DecodeUnicodeConsole(GSM_GetNetworkName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)),
1034 DecodeUnicodeConsole(GSM_GetCountryName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode))); 1034 DecodeUnicodeConsole(GSM_GetCountryName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)));
1035 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1035 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1036 break; 1036 break;
1037 case SMS_NokiaScreenSaverLong: 1037 case SMS_NokiaScreenSaverLong:
1038 printmsg("Screen saver\n"); 1038 printmsg("Screen saver\n");
1039 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1039 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1040 break; 1040 break;
1041 case SMS_NokiaPictureImageLong: 1041 case SMS_NokiaPictureImageLong:
1042 printmsg("Picture Image\n"); 1042 printmsg("Picture Image\n");
1043 if (UnicodeLength(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text)!=0) printmsg("Text: \"%s\"\n\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text)); 1043 if (UnicodeLength(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text)!=0) printmsg("Text: \"%s\"\n\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text));
1044 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1044 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1045 break; 1045 break;
1046 case SMS_NokiaProfileLong: 1046 case SMS_NokiaProfileLong:
1047 printmsg("Profile\n"); 1047 printmsg("Profile\n");
1048 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1048 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1049 break; 1049 break;
1050 case SMS_ConcatenatedTextLong: 1050 case SMS_ConcatenatedTextLong:
1051 case SMS_ConcatenatedAutoTextLong: 1051 case SMS_ConcatenatedAutoTextLong:
1052 case SMS_ConcatenatedTextLong16bit: 1052 case SMS_ConcatenatedTextLong16bit:
1053 case SMS_ConcatenatedAutoTextLong16bit: 1053 case SMS_ConcatenatedAutoTextLong16bit:
1054 printmsg("%s\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Buffer)); 1054 printmsg("%s\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Buffer));
1055 break; 1055 break;
1056 case SMS_EMSFixedBitmap: 1056 case SMS_EMSFixedBitmap:
1057 case SMS_EMSVariableBitmap: 1057 case SMS_EMSVariableBitmap:
1058 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1058 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1059 break; 1059 break;
1060 case SMS_EMSAnimation: 1060 case SMS_EMSAnimation:
1061 /* Can't show animation, we show first frame */ 1061 /* Can't show animation, we show first frame */
1062 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]); 1062 GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
1063 break; 1063 break;
1064 case SMS_EMSPredefinedSound: 1064 case SMS_EMSPredefinedSound:
1065 printmsg("\nEMS sound ID: %i\n",SMSInfo.Entries[i].Number); 1065 printmsg("\nEMS sound ID: %i\n",SMSInfo.Entries[i].Number);
1066 break; 1066 break;
1067 case SMS_EMSPredefinedAnimation: 1067 case SMS_EMSPredefinedAnimation:
1068 printmsg("\nEMS animation ID: %i\n",SMSInfo.Entries[i].Number); 1068 printmsg("\nEMS animation ID: %i\n",SMSInfo.Entries[i].Number);
1069 break; 1069 break;
1070 default: 1070 default:
1071 printf("Error\n"); 1071 printf("Error\n");
1072 break; 1072 break;
1073 } 1073 }
1074 } 1074 }
1075 printf("\n"); 1075 printf("\n");
1076 GSM_FreeMultiPartSMSInfo(&SMSInfo); 1076 GSM_FreeMultiPartSMSInfo(&SMSInfo);
1077} 1077}
1078 1078
1079static void NetworkInfo(int argc, char *argv[]) 1079static void NetworkInfo(int argc, char *argv[])
1080{ 1080{
1081 GSM_NetworkInfo NetInfo; 1081 GSM_NetworkInfo NetInfo;
1082 1082
1083 GSM_Init(true); 1083 GSM_Init(true);
1084 1084
1085 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) { 1085 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
1086 printmsg("Network state : "); 1086 printmsg("Network state : ");
1087 switch (NetInfo.State) { 1087 switch (NetInfo.State) {
1088 case GSM_HomeNetwork : printmsg("home network\n"); break; 1088 case GSM_HomeNetwork : printmsg("home network\n"); break;
1089 case GSM_RoamingNetwork : printmsg("roaming network\n"); break; 1089 case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
1090 case GSM_RequestingNetwork : printmsg("requesting network\n"); break; 1090 case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
1091 case GSM_NoNetwork : printmsg("not logged into network\n");break; 1091 case GSM_NoNetwork : printmsg("not logged into network\n");break;
1092 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break; 1092 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break;
1093 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break; 1093 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
1094 default : printmsg("unknown\n"); 1094 default : printmsg("unknown\n");
1095 } 1095 }
1096 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) { 1096 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
1097 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode))); 1097 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
1098 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode))); 1098 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
1099 printmsg(", LAC %s, CellID %s\n", NetInfo.LAC,NetInfo.CID); 1099 printmsg(", LAC %s, CellID %s\n", NetInfo.LAC,NetInfo.CID);
1100 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) { 1100 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
1101 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName)); 1101 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
1102 } 1102 }
1103 } 1103 }
1104 } 1104 }
1105 GSM_Terminate(); 1105 GSM_Terminate();
1106} 1106}
1107 1107
1108static void IncomingSMS(char *Device, GSM_SMSMessage sms) 1108static void IncomingSMS(char *Device, GSM_SMSMessage sms)
1109{ 1109{
1110 GSM_MultiSMSMessage SMS; 1110 GSM_MultiSMSMessage SMS;
1111 1111
1112 printmsg("SMS message received\n"); 1112 printmsg("SMS message received\n");
1113 SMS.Number = 1; 1113 SMS.Number = 1;
1114 memcpy(&SMS.SMS[0],&sms,sizeof(GSM_SMSMessage)); 1114 memcpy(&SMS.SMS[0],&sms,sizeof(GSM_SMSMessage));
1115 displaymultismsinfo(SMS,false,false); 1115 displaymultismsinfo(SMS,false,false);
1116} 1116}
1117 1117
1118static void IncomingCB(char *Device, GSM_CBMessage CB) 1118static void IncomingCB(char *Device, GSM_CBMessage CB)
1119{ 1119{
1120 printmsg("CB message received\n"); 1120 printmsg("CB message received\n");
1121 printmsg("Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeConsole(CB.Text)); 1121 printmsg("Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeConsole(CB.Text));
1122} 1122}
1123 1123
1124static void IncomingCall(char *Device, GSM_Call call) 1124static void IncomingCall(char *Device, GSM_Call call)
1125{ 1125{
1126 printmsg("Call info : "); 1126 printmsg("Call info : ");
1127 if (call.CallIDAvailable) printmsg("ID %i, ",call.CallID); 1127 if (call.CallIDAvailable) printmsg("ID %i, ",call.CallID);
1128 switch(call.Status) { 1128 switch(call.Status) {
1129 case GSM_CALL_IncomingCall : printmsg("incoming call from \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break; 1129 case GSM_CALL_IncomingCall : printmsg("incoming call from \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break;
1130 case GSM_CALL_OutgoingCall : printmsg("outgoing call to \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break; 1130 case GSM_CALL_OutgoingCall : printmsg("outgoing call to \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break;
1131 case GSM_CALL_CallStart : printmsg("call started\n"); break; 1131 case GSM_CALL_CallStart : printmsg("call started\n"); break;
1132 case GSM_CALL_CallEnd : printmsg("end of call (unknown side)\n"); break; 1132 case GSM_CALL_CallEnd : printmsg("end of call (unknown side)\n"); break;
1133 case GSM_CALL_CallLocalEnd : printmsg("call end from our side\n"); break; 1133 case GSM_CALL_CallLocalEnd : printmsg("call end from our side\n"); break;
1134 case GSM_CALL_CallRemoteEnd : printmsg("call end from remote side (code %i)\n",call.StatusCode); break; 1134 case GSM_CALL_CallRemoteEnd : printmsg("call end from remote side (code %i)\n",call.StatusCode); break;
1135 case GSM_CALL_CallEstablished : printmsg("call established. Waiting for answer\n"); break; 1135 case GSM_CALL_CallEstablished : printmsg("call established. Waiting for answer\n"); break;
1136 case GSM_CALL_CallHeld : printmsg("call held\n"); break; 1136 case GSM_CALL_CallHeld : printmsg("call held\n"); break;
1137 case GSM_CALL_CallResumed : printmsg("call resumed\n"); break; 1137 case GSM_CALL_CallResumed : printmsg("call resumed\n"); break;
1138 case GSM_CALL_CallSwitched : printmsg("call switched\n"); break; 1138 case GSM_CALL_CallSwitched : printmsg("call switched\n"); break;
1139 } 1139 }
1140} 1140}
1141 1141
1142static void IncomingUSSD(char *Device, char *Buffer) 1142static void IncomingUSSD(char *Device, char *Buffer)
1143{ 1143{
1144 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer)); 1144 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
1145} 1145}
1146 1146
1147 #define CHECKMEMORYSTATUS(x, m, a1, b1) { \ 1147 #define CHECKMEMORYSTATUS(x, m, a1, b1) { \
1148 x.MemoryType=m; \ 1148 x.MemoryType=m; \
1149 if (Phone->GetMemoryStatus(&s, &x) == ERR_NONE) \ 1149 if (Phone->GetMemoryStatus(&s, &x) == ERR_NONE) \
1150 printmsg("%s %03d, %s %03d\n", a1, x.MemoryUsed, b1, x.MemoryFree);\ 1150 printmsg("%s %03d, %s %03d\n", a1, x.MemoryUsed, b1, x.MemoryFree);\
1151} 1151}
1152 1152
1153static void Monitor(int argc, char *argv[]) 1153static void Monitor(int argc, char *argv[])
1154{ 1154{
1155 GSM_MemoryStatusMemStatus; 1155 GSM_MemoryStatusMemStatus;
1156 GSM_SMSMemoryStatusSMSStatus; 1156 GSM_SMSMemoryStatusSMSStatus;
1157 GSM_ToDoStatus ToDoStatus; 1157 GSM_ToDoStatus ToDoStatus;
1158 GSM_CalendarStatusCalendarStatus; 1158 GSM_CalendarStatusCalendarStatus;
1159 GSM_NetworkInfo NetInfo; 1159 GSM_NetworkInfo NetInfo;
1160 GSM_BatteryCharge BatteryCharge; 1160 GSM_BatteryCharge BatteryCharge;
1161 GSM_SignalQuality SignalQuality; 1161 GSM_SignalQuality SignalQuality;
1162 int count = -1; 1162 int count = -1;
1163 1163
1164 if (argc >= 3) { 1164 if (argc >= 3) {
1165 count = atoi(argv[2]); 1165 count = atoi(argv[2]);
1166 if (count <= 0) count = -1; 1166 if (count <= 0) count = -1;
1167 } 1167 }
1168 1168
1169 signal(SIGINT, interrupt); 1169 signal(SIGINT, interrupt);
1170 printmsgerr("Press Ctrl+C to break...\n"); 1170 printmsgerr("Press Ctrl+C to break...\n");
1171 printmsg("Entering monitor mode...\n\n"); 1171 printmsg("Entering monitor mode...\n\n");
1172 1172
1173 GSM_Init(true); 1173 GSM_Init(true);
1174 1174
1175 s.User.IncomingSMS = IncomingSMS; 1175 s.User.IncomingSMS = IncomingSMS;
1176 s.User.IncomingCB = IncomingCB; 1176 s.User.IncomingCB = IncomingCB;
1177 s.User.IncomingCall = IncomingCall; 1177 s.User.IncomingCall = IncomingCall;
1178 s.User.IncomingUSSD = IncomingUSSD; 1178 s.User.IncomingUSSD = IncomingUSSD;
1179 1179
1180 error=Phone->SetIncomingSMS (&s,true); 1180 error=Phone->SetIncomingSMS (&s,true);
1181 printmsg("Enabling info about incoming SMS : %s\n",print_error(error,NULL,s.msg)); 1181 printmsg("Enabling info about incoming SMS : %s\n",print_error(error,NULL,s.msg));
1182 error=Phone->SetIncomingCB (&s,true); 1182 error=Phone->SetIncomingCB (&s,true);
1183 printmsg("Enabling info about incoming CB : %s\n",print_error(error,NULL,s.msg)); 1183 printmsg("Enabling info about incoming CB : %s\n",print_error(error,NULL,s.msg));
1184 error=Phone->SetIncomingCall (&s,true); 1184 error=Phone->SetIncomingCall (&s,true);
1185 printmsg("Enabling info about calls : %s\n",print_error(error,NULL,s.msg)); 1185 printmsg("Enabling info about calls : %s\n",print_error(error,NULL,s.msg));
1186 error=Phone->SetIncomingUSSD (&s,true); 1186 error=Phone->SetIncomingUSSD (&s,true);
1187 printmsg("Enabling info about USSD : %s\n\n",print_error(error,NULL,s.msg)); 1187 printmsg("Enabling info about USSD : %s\n\n",print_error(error,NULL,s.msg));
1188 1188
1189 while (!gshutdown && count != 0) { 1189 while (!gshutdown && count != 0) {
1190 if (count > 0) count--; 1190 if (count > 0) count--;
1191 CHECKMEMORYSTATUS(MemStatus,MEM_SM,"SIM phonebook : Used","Free"); 1191 CHECKMEMORYSTATUS(MemStatus,MEM_SM,"SIM phonebook : Used","Free");
1192 if (gshutdown) break; 1192 if (gshutdown) break;
1193 CHECKMEMORYSTATUS(MemStatus,MEM_DC,"Dialled numbers : Used","Free"); 1193 CHECKMEMORYSTATUS(MemStatus,MEM_DC,"Dialled numbers : Used","Free");
1194 if (gshutdown) break; 1194 if (gshutdown) break;
1195 CHECKMEMORYSTATUS(MemStatus,MEM_RC,"Received numbers : Used","Free"); 1195 CHECKMEMORYSTATUS(MemStatus,MEM_RC,"Received numbers : Used","Free");
1196 if (gshutdown) break; 1196 if (gshutdown) break;
1197 CHECKMEMORYSTATUS(MemStatus,MEM_MC,"Missed numbers : Used","Free"); 1197 CHECKMEMORYSTATUS(MemStatus,MEM_MC,"Missed numbers : Used","Free");
1198 if (gshutdown) break; 1198 if (gshutdown) break;
1199 CHECKMEMORYSTATUS(MemStatus,MEM_ON,"Own numbers : Used","Free"); 1199 CHECKMEMORYSTATUS(MemStatus,MEM_ON,"Own numbers : Used","Free");
1200 if (gshutdown) break; 1200 if (gshutdown) break;
1201 CHECKMEMORYSTATUS(MemStatus,MEM_ME,"Phone phonebook : Used","Free"); 1201 CHECKMEMORYSTATUS(MemStatus,MEM_ME,"Phone phonebook : Used","Free");
1202 if (gshutdown) break; 1202 if (gshutdown) break;
1203 if (Phone->GetToDoStatus(&s, &ToDoStatus) == ERR_NONE) { 1203 if (Phone->GetToDoStatus(&s, &ToDoStatus) == ERR_NONE) {
1204 printmsg("ToDos : Used %d\n", ToDoStatus.Used); 1204 printmsg("ToDos : Used %d\n", ToDoStatus.Used);
1205 } 1205 }
1206 if (gshutdown) break; 1206 if (gshutdown) break;
1207 if (Phone->GetCalendarStatus(&s, &CalendarStatus) == ERR_NONE) { 1207 if (Phone->GetCalendarStatus(&s, &CalendarStatus) == ERR_NONE) {
1208 printmsg("Calendar : Used %d\n", CalendarStatus.Used); 1208 printmsg("Calendar : Used %d\n", CalendarStatus.Used);
1209 } 1209 }
1210 if (gshutdown) break; 1210 if (gshutdown) break;
1211 if (Phone->GetBatteryCharge(&s,&BatteryCharge)==ERR_NONE) { 1211 if (Phone->GetBatteryCharge(&s,&BatteryCharge)==ERR_NONE) {
1212 if (BatteryCharge.BatteryPercent != -1) printmsg("Battery level : %i percent\n", BatteryCharge.BatteryPercent); 1212 if (BatteryCharge.BatteryPercent != -1) printmsg("Battery level : %i percent\n", BatteryCharge.BatteryPercent);
1213 if (BatteryCharge.ChargeState != 0) { 1213 if (BatteryCharge.ChargeState != 0) {
1214 printmsg("Charge state : "); 1214 printmsg("Charge state : ");
1215 switch (BatteryCharge.ChargeState) { 1215 switch (BatteryCharge.ChargeState) {
1216 case GSM_BatteryPowered: 1216 case GSM_BatteryPowered:
1217 printmsg("powered from battery"); 1217 printmsg("powered from battery");
1218 break; 1218 break;
1219 case GSM_BatteryConnected: 1219 case GSM_BatteryConnected:
1220 printmsg("battery connected, but not powered from battery"); 1220 printmsg("battery connected, but not powered from battery");
1221 break; 1221 break;
1222 case GSM_BatteryNotConnected: 1222 case GSM_BatteryNotConnected:
1223 printmsg("battery not connected"); 1223 printmsg("battery not connected");
1224 break; 1224 break;
1225 case GSM_PowerFault: 1225 case GSM_PowerFault:
1226 printmsg("detected power failure"); 1226 printmsg("detected power failure");
1227 break; 1227 break;
1228 default: 1228 default:
1229 printmsg("unknown"); 1229 printmsg("unknown");
1230 break; 1230 break;
1231 } 1231 }
1232 printf("\n"); 1232 printf("\n");
1233 } 1233 }
1234 } 1234 }
1235 if (gshutdown) break; 1235 if (gshutdown) break;
1236 if (Phone->GetSignalQuality(&s,&SignalQuality)==ERR_NONE) { 1236 if (Phone->GetSignalQuality(&s,&SignalQuality)==ERR_NONE) {
1237 if (SignalQuality.SignalStrength != -1) printmsg("Signal strength : %i dBm\n", SignalQuality.SignalStrength); 1237 if (SignalQuality.SignalStrength != -1) printmsg("Signal strength : %i dBm\n", SignalQuality.SignalStrength);
1238 if (SignalQuality.SignalPercent != -1) printmsg("Network level : %i percent\n", SignalQuality.SignalPercent); 1238 if (SignalQuality.SignalPercent != -1) printmsg("Network level : %i percent\n", SignalQuality.SignalPercent);
1239 if (SignalQuality.BitErrorRate != -1) printmsg("Bit error rate : %i percent\n", SignalQuality.BitErrorRate); 1239 if (SignalQuality.BitErrorRate != -1) printmsg("Bit error rate : %i percent\n", SignalQuality.BitErrorRate);
1240 } 1240 }
1241 if (gshutdown) break; 1241 if (gshutdown) break;
1242 if (Phone->GetSMSStatus(&s,&SMSStatus)==ERR_NONE) { 1242 if (Phone->GetSMSStatus(&s,&SMSStatus)==ERR_NONE) {
1243 if (SMSStatus.SIMSize > 0) { 1243 if (SMSStatus.SIMSize > 0) {
1244 printmsg("SIM SMS status : %i used, %i unread, %i locations\n", 1244 printmsg("SIM SMS status : %i used, %i unread, %i locations\n",
1245 SMSStatus.SIMUsed, 1245 SMSStatus.SIMUsed,
1246 SMSStatus.SIMUnRead, 1246 SMSStatus.SIMUnRead,
1247 SMSStatus.SIMSize); 1247 SMSStatus.SIMSize);
1248 } 1248 }
1249 1249
1250 if (SMSStatus.PhoneSize > 0) { 1250 if (SMSStatus.PhoneSize > 0) {
1251 printmsg("Phone SMS status : %i used, %i unread, %i locations", 1251 printmsg("Phone SMS status : %i used, %i unread, %i locations",
1252 SMSStatus.PhoneUsed, 1252 SMSStatus.PhoneUsed,
1253 SMSStatus.PhoneUnRead, 1253 SMSStatus.PhoneUnRead,
1254 SMSStatus.PhoneSize); 1254 SMSStatus.PhoneSize);
1255 if (SMSStatus.TemplatesUsed!=0) printmsg(", %i templates", SMSStatus.TemplatesUsed); 1255 if (SMSStatus.TemplatesUsed!=0) printmsg(", %i templates", SMSStatus.TemplatesUsed);
1256 printf("\n"); 1256 printf("\n");
1257 } 1257 }
1258 } 1258 }
1259 if (gshutdown) break; 1259 if (gshutdown) break;
1260 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) { 1260 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
1261 printmsg("Network state : "); 1261 printmsg("Network state : ");
1262 switch (NetInfo.State) { 1262 switch (NetInfo.State) {
1263 case GSM_HomeNetwork : printmsg("home network\n"); break; 1263 case GSM_HomeNetwork : printmsg("home network\n"); break;
1264 case GSM_RoamingNetwork : printmsg("roaming network\n"); break; 1264 case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
1265 case GSM_RequestingNetwork : printmsg("requesting network\n"); break; 1265 case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
1266 case GSM_NoNetwork : printmsg("not logged into network\n"); break; 1266 case GSM_NoNetwork : printmsg("not logged into network\n"); break;
1267 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break; 1267 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break;
1268 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break; 1268 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
1269 default : printmsg("unknown\n"); 1269 default : printmsg("unknown\n");
1270 } 1270 }
1271 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) { 1271 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
1272 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode))); 1272 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
1273 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode))); 1273 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
1274 printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID); 1274 printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID);
1275 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) { 1275 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
1276 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName)); 1276 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
1277 } 1277 }
1278 } 1278 }
1279 } 1279 }
1280 printf("\n"); 1280 printf("\n");
1281 } 1281 }
1282 1282
1283 printmsg("Leaving monitor mode...\n"); 1283 printmsg("Leaving monitor mode...\n");
1284 1284
1285 GSM_Terminate(); 1285 GSM_Terminate();
1286} 1286}
1287 1287
1288static void GetUSSD(int argc, char *argv[]) 1288static void GetUSSD(int argc, char *argv[])
1289{ 1289{
1290 GSM_Init(true); 1290 GSM_Init(true);
1291 1291
1292 signal(SIGINT, interrupt); 1292 signal(SIGINT, interrupt);
1293 printmsgerr("Press Ctrl+C to break...\n"); 1293 printmsgerr("Press Ctrl+C to break...\n");
1294 1294
1295 s.User.IncomingUSSD = IncomingUSSD; 1295 s.User.IncomingUSSD = IncomingUSSD;
1296 1296
1297 error=Phone->SetIncomingUSSD(&s,true); 1297 error=Phone->SetIncomingUSSD(&s,true);
1298 Print_Error(error); 1298 Print_Error(error);
1299 1299
1300 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence); 1300 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence);
1301 Print_Error(error); 1301 Print_Error(error);
1302 1302
1303 while (!gshutdown) GSM_ReadDevice(&s,true); 1303 while (!gshutdown) GSM_ReadDevice(&s,true);
1304 1304
1305 GSM_Terminate(); 1305 GSM_Terminate();
1306} 1306}
1307 1307
1308static void GetSMSC(int argc, char *argv[]) 1308static void GetSMSC(int argc, char *argv[])
1309{ 1309{
1310 GSM_SMSC smsc; 1310 GSM_SMSC smsc;
1311 int start, stop; 1311 int start, stop;
1312 1312
1313 GetStartStop(&start, &stop, 2, argc, argv); 1313 GetStartStop(&start, &stop, 2, argc, argv);
1314 1314
1315 GSM_Init(true); 1315 GSM_Init(true);
1316 1316
1317 for (i=start;i<=stop;i++) { 1317 for (i=start;i<=stop;i++) {
1318 smsc.Location=i; 1318 smsc.Location=i;
1319 1319
1320 error=Phone->GetSMSC(&s, &smsc); 1320 error=Phone->GetSMSC(&s, &smsc);
1321 Print_Error(error); 1321 Print_Error(error);
1322 1322
1323 if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) { 1323 if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) {
1324 printmsg("%i. Set %i\n",smsc.Location, smsc.Location); 1324 printmsg("%i. Set %i\n",smsc.Location, smsc.Location);
1325 } else { 1325 } else {
1326 printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name)); 1326 printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name));
1327 } 1327 }
1328 printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number)); 1328 printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number));
1329 printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber)); 1329 printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber));
1330 1330
1331 printmsg("Format : "); 1331 printmsg("Format : ");
1332 switch (smsc.Format) { 1332 switch (smsc.Format) {
1333 case SMS_FORMAT_Text : printmsg("Text");break; 1333 case SMS_FORMAT_Text : printmsg("Text");break;
1334 case SMS_FORMAT_Fax : printmsg("Fax");break; 1334 case SMS_FORMAT_Fax : printmsg("Fax");break;
1335 case SMS_FORMAT_Email : printmsg("Email");break; 1335 case SMS_FORMAT_Email : printmsg("Email");break;
1336 case SMS_FORMAT_Pager : printmsg("Pager");break; 1336 case SMS_FORMAT_Pager : printmsg("Pager");break;
1337 } 1337 }
1338 printf("\n"); 1338 printf("\n");
1339 1339
1340 printmsg("Validity : "); 1340 printmsg("Validity : ");
1341 switch (smsc.Validity.Relative) { 1341 switch (smsc.Validity.Relative) {
1342 case SMS_VALID_1_Hour : printmsg("1 hour"); break; 1342 case SMS_VALID_1_Hour : printmsg("1 hour"); break;
1343 case SMS_VALID_6_Hours : printmsg("6 hours"); break; 1343 case SMS_VALID_6_Hours : printmsg("6 hours"); break;
1344 case SMS_VALID_1_Day : printmsg("24 hours"); break; 1344 case SMS_VALID_1_Day : printmsg("24 hours"); break;
1345 case SMS_VALID_3_Days : printmsg("72 hours"); break; 1345 case SMS_VALID_3_Days : printmsg("72 hours"); break;
1346 case SMS_VALID_1_Week : printmsg("1 week"); break; 1346 case SMS_VALID_1_Week : printmsg("1 week"); break;
1347 case SMS_VALID_Max_Time: printmsg("Maximum time"); break; 1347 case SMS_VALID_Max_Time: printmsg("Maximum time"); break;
1348 default : printmsg("Unknown"); 1348 default : printmsg("Unknown");
1349 } 1349 }
1350 printf("\n"); 1350 printf("\n");
1351 } 1351 }
1352 1352
1353 GSM_Terminate(); 1353 GSM_Terminate();
1354} 1354}
1355 1355
1356static void GetSMS(int argc, char *argv[]) 1356static void GetSMS(int argc, char *argv[])
1357{ 1357{
1358 GSM_MultiSMSMessagesms; 1358 GSM_MultiSMSMessagesms;
1359 GSM_SMSFolders folders; 1359 GSM_SMSFolders folders;
1360 int start, stop; 1360 int start, stop;
1361 int j; 1361 int j;
1362 1362
1363 GetStartStop(&start, &stop, 3, argc, argv); 1363 GetStartStop(&start, &stop, 3, argc, argv);
1364 1364
1365 GSM_Init(true); 1365 GSM_Init(true);
1366 1366
1367 error=Phone->GetSMSFolders(&s, &folders); 1367 error=Phone->GetSMSFolders(&s, &folders);
1368 Print_Error(error); 1368 Print_Error(error);
1369 1369
1370 for (j = start; j <= stop; j++) { 1370 for (j = start; j <= stop; j++) {
1371 sms.SMS[0].Folder= atoi(argv[2]); 1371 sms.SMS[0].Folder= atoi(argv[2]);
1372 sms.SMS[0].Location= j; 1372 sms.SMS[0].Location= j;
1373 error=Phone->GetSMS(&s, &sms); 1373 error=Phone->GetSMS(&s, &sms);
1374 switch (error) { 1374 switch (error) {
1375 case ERR_EMPTY: 1375 case ERR_EMPTY:
1376 printmsg("Location %i\n",sms.SMS[0].Location); 1376 printmsg("Location %i\n",sms.SMS[0].Location);
1377 printmsg("Empty\n"); 1377 printmsg("Empty\n");
1378 break; 1378 break;
1379 default: 1379 default:
1380 Print_Error(error); 1380 Print_Error(error);
1381 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name)); 1381 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
1382 switch(sms.SMS[0].Memory) { 1382 switch(sms.SMS[0].Memory) {
1383 case MEM_SM: printmsg(", SIM memory"); break; 1383 case MEM_SM: printmsg(", SIM memory"); break;
1384 case MEM_ME: printmsg(", phone memory"); break; 1384 case MEM_ME: printmsg(", phone memory"); break;
1385 case MEM_MT: printmsg(", phone or SIM memory"); break; 1385 case MEM_MT: printmsg(", phone or SIM memory"); break;
1386 default : break; 1386 default : break;
1387 } 1387 }
1388 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder"); 1388 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
1389 printf("\n"); 1389 printf("\n");
1390 displaymultismsinfo(sms,false,false); 1390 displaymultismsinfo(sms,false,false);
1391 } 1391 }
1392 } 1392 }
1393 1393
1394 GSM_Terminate(); 1394 GSM_Terminate();
1395} 1395}
1396 1396
1397static void DeleteSMS(int argc, char *argv[]) 1397static void DeleteSMS(int argc, char *argv[])
1398{ 1398{
1399 GSM_SMSMessagesms; 1399 GSM_SMSMessagesms;
1400 int start, stop; 1400 int start, stop;
1401 1401
1402 sms.Folder=atoi(argv[2]); 1402 sms.Folder=atoi(argv[2]);
1403 1403
1404 GetStartStop(&start, &stop, 3, argc, argv); 1404 GetStartStop(&start, &stop, 3, argc, argv);
1405 1405
1406 GSM_Init(true); 1406 GSM_Init(true);
1407 1407
1408 for (i=start;i<=stop;i++) { 1408 for (i=start;i<=stop;i++) {
1409 sms.Folder= 0; 1409 sms.Folder= 0;
1410 sms.Location= i; 1410 sms.Location= i;
1411 error=Phone->DeleteSMS(&s, &sms); 1411 error=Phone->DeleteSMS(&s, &sms);
1412 Print_Error(error); 1412 Print_Error(error);
1413 } 1413 }
1414#ifdef GSM_ENABLE_BEEP 1414#ifdef GSM_ENABLE_BEEP
1415 GSM_PhoneBeep(); 1415 GSM_PhoneBeep();
1416#endif 1416#endif
1417 GSM_Terminate(); 1417 GSM_Terminate();
1418} 1418}
1419 1419
1420static void GetAllSMS(int argc, char *argv[]) 1420static void GetAllSMS(int argc, char *argv[])
1421{ 1421{
1422 GSM_MultiSMSMessage sms; 1422 GSM_MultiSMSMessage sms;
1423 GSM_SMSFolders folders; 1423 GSM_SMSFolders folders;
1424 bool start = true; 1424 bool start = true;
1425 1425
1426 GSM_Init(true); 1426 GSM_Init(true);
1427 1427
1428 error=Phone->GetSMSFolders(&s, &folders); 1428 error=Phone->GetSMSFolders(&s, &folders);
1429 Print_Error(error); 1429 Print_Error(error);
1430 1430
1431 fprintf(stderr,"Reading: "); 1431 fprintf(stderr,"Reading: ");
1432 while (error == ERR_NONE) { 1432 while (error == ERR_NONE) {
1433 sms.SMS[0].Folder=0x00; 1433 sms.SMS[0].Folder=0x00;
1434 error=Phone->GetNextSMS(&s, &sms, start); 1434 error=Phone->GetNextSMS(&s, &sms, start);
1435 switch (error) { 1435 switch (error) {
1436 case ERR_EMPTY: 1436 case ERR_EMPTY:
1437 break; 1437 break;
1438 default: 1438 default:
1439 Print_Error(error); 1439 Print_Error(error);
1440 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name)); 1440 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
1441 switch(sms.SMS[0].Memory) { 1441 switch(sms.SMS[0].Memory) {
1442 case MEM_SM: printmsg(", SIM memory"); break; 1442 case MEM_SM: printmsg(", SIM memory"); break;
1443 case MEM_ME: printmsg(", phone memory"); break; 1443 case MEM_ME: printmsg(", phone memory"); break;
1444 case MEM_MT: printmsg(", phone or SIM memory"); break; 1444 case MEM_MT: printmsg(", phone or SIM memory"); break;
1445 default : break; 1445 default : break;
1446 } 1446 }
1447 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder"); 1447 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
1448 printf("\n"); 1448 printf("\n");
1449 displaymultismsinfo(sms,false,false); 1449 displaymultismsinfo(sms,false,false);
1450 } 1450 }
1451 fprintf(stderr,"*"); 1451 fprintf(stderr,"*");
1452 start=false; 1452 start=false;
1453 } 1453 }
1454 fprintf(stderr,"\n"); 1454 fprintf(stderr,"\n");
1455 1455
1456#ifdef GSM_ENABLE_BEEP 1456#ifdef GSM_ENABLE_BEEP
1457 GSM_PhoneBeep(); 1457 GSM_PhoneBeep();
1458#endif 1458#endif
1459 GSM_Terminate(); 1459 GSM_Terminate();
1460} 1460}
1461 1461
1462static void GetEachSMS(int argc, char *argv[]) 1462static void GetEachSMS(int argc, char *argv[])
1463{ 1463{
1464 GSM_MultiSMSMessage*GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms; 1464 GSM_MultiSMSMessage*GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms;
1465 int GetSMSNumber = 0,i,j; 1465 int GetSMSNumber = 0,i,j;
1466 GSM_SMSFolders folders; 1466 GSM_SMSFolders folders;
1467 bool start = true, ems = true; 1467 bool start = true, ems = true;
1468 1468
1469 GetSMS[0] = NULL; 1469 GetSMS[0] = NULL;
1470 1470
1471 GSM_Init(true); 1471 GSM_Init(true);
1472 1472
1473 error=Phone->GetSMSFolders(&s, &folders); 1473 error=Phone->GetSMSFolders(&s, &folders);
1474 Print_Error(error); 1474 Print_Error(error);
1475 1475
1476 fprintf(stderr,"Reading: "); 1476 fprintf(stderr,"Reading: ");
1477 while (error == ERR_NONE) { 1477 while (error == ERR_NONE) {
1478 sms.SMS[0].Folder=0x00; 1478 sms.SMS[0].Folder=0x00;
1479 error=Phone->GetNextSMS(&s, &sms, start); 1479 error=Phone->GetNextSMS(&s, &sms, start);
1480 switch (error) { 1480 switch (error) {
1481 case ERR_EMPTY: 1481 case ERR_EMPTY:
1482 break; 1482 break;
1483 default: 1483 default:
1484 Print_Error(error); 1484 Print_Error(error);
1485 GetSMS[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage)); 1485 GetSMS[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage));
1486 if (GetSMS[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY); 1486 if (GetSMS[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY);
1487 GetSMS[GetSMSNumber+1] = NULL; 1487 GetSMS[GetSMSNumber+1] = NULL;
1488 memcpy(GetSMS[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage)); 1488 memcpy(GetSMS[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage));
1489 GetSMSNumber++; 1489 GetSMSNumber++;
1490 if (GetSMSNumber==PHONE_MAXSMSINFOLDER) { 1490 if (GetSMSNumber==PHONE_MAXSMSINFOLDER) {
1491 fprintf(stderr,"SMS counter overflow\n"); 1491 fprintf(stderr,"SMS counter overflow\n");
1492 return; 1492 return;
1493 } 1493 }
1494 } 1494 }
1495 fprintf(stderr,"*"); 1495 fprintf(stderr,"*");
1496 start=false; 1496 start=false;
1497 } 1497 }
1498 fprintf(stderr,"\n"); 1498 fprintf(stderr,"\n");
1499 1499
1500#ifdef GSM_ENABLE_BEEP 1500#ifdef GSM_ENABLE_BEEP
1501 GSM_PhoneBeep(); 1501 GSM_PhoneBeep();
1502#endif 1502#endif
1503 1503
1504 error = GSM_LinkSMS(GetSMS, SortedSMS, ems); 1504 error = GSM_LinkSMS(GetSMS, SortedSMS, ems);
1505 Print_Error(error); 1505 Print_Error(error);
1506 1506
1507 i=0; 1507 i=0;
1508 while(GetSMS[i] != NULL) { 1508 while(GetSMS[i] != NULL) {
1509 free(GetSMS[i]); 1509 free(GetSMS[i]);
1510 GetSMS[i] = NULL; 1510 GetSMS[i] = NULL;
1511 i++; 1511 i++;
1512 } 1512 }
1513 1513
1514 i=0; 1514 i=0;
1515 while(SortedSMS[i] != NULL) { 1515 while(SortedSMS[i] != NULL) {
1516 for (j=0;j<SortedSMS[i]->Number;j++) { 1516 for (j=0;j<SortedSMS[i]->Number;j++) {
1517 if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) { 1517 if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) {
1518 printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name)); 1518 printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name));
1519 switch(SortedSMS[i]->SMS[j].Memory) { 1519 switch(SortedSMS[i]->SMS[j].Memory) {
1520 case MEM_SM: printmsg(", SIM memory"); break; 1520 case MEM_SM: printmsg(", SIM memory"); break;
1521 case MEM_ME: printmsg(", phone memory"); break; 1521 case MEM_ME: printmsg(", phone memory"); break;
1522 case MEM_MT: printmsg(", phone or SIM memory"); break; 1522 case MEM_MT: printmsg(", phone or SIM memory"); break;
1523 default : break; 1523 default : break;
1524 } 1524 }
1525 if (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder"); 1525 if (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder");
1526 printf("\n"); 1526 printf("\n");
1527 } 1527 }
1528 } 1528 }
1529 displaymultismsinfo(*SortedSMS[i],true,ems); 1529 displaymultismsinfo(*SortedSMS[i],true,ems);
1530 1530
1531 free(SortedSMS[i]); 1531 free(SortedSMS[i]);
1532 SortedSMS[i] = NULL; 1532 SortedSMS[i] = NULL;
1533 i++; 1533 i++;
1534 } 1534 }
1535 1535
1536 GSM_Terminate(); 1536 GSM_Terminate();
1537} 1537}
1538 1538
1539static void GetSMSFolders(int argc, char *argv[]) 1539static void GetSMSFolders(int argc, char *argv[])
1540{ 1540{
1541 GSM_SMSFolders folders; 1541 GSM_SMSFolders folders;
1542 1542
1543 GSM_Init(true); 1543 GSM_Init(true);
1544 1544
1545 error=Phone->GetSMSFolders(&s,&folders); 1545 error=Phone->GetSMSFolders(&s,&folders);
1546 Print_Error(error); 1546 Print_Error(error);
1547 1547
1548 for (i=0;i<folders.Number;i++) { 1548 for (i=0;i<folders.Number;i++) {
1549 printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name)); 1549 printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name));
1550 switch(folders.Folder[i].Memory) { 1550 switch(folders.Folder[i].Memory) {
1551 case MEM_SM: printmsg(", SIM memory"); break; 1551 case MEM_SM: printmsg(", SIM memory"); break;
1552 case MEM_ME: printmsg(", phone memory"); break; 1552 case MEM_ME: printmsg(", phone memory"); break;
1553 case MEM_MT: printmsg(", phone or SIM memory"); break; 1553 case MEM_MT: printmsg(", phone or SIM memory"); break;
1554 default : break; 1554 default : break;
1555 } 1555 }
1556 if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder"); 1556 if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder");
1557 printf("\n"); 1557 printf("\n");
1558 } 1558 }
1559 1559
1560 GSM_Terminate(); 1560 GSM_Terminate();
1561} 1561}
1562 1562
1563static void GetRingtone(int argc, char *argv[]) 1563static void GetRingtone(int argc, char *argv[])
1564{ 1564{
1565 GSM_Ringtone ringtone; 1565 GSM_Ringtone ringtone;
1566 bool PhoneRingtone = false; 1566 bool PhoneRingtone = false;
1567 1567
1568 if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true; 1568 if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true;
1569 1569
1570 GetStartStop(&ringtone.Location, NULL, 2, argc, argv); 1570 GetStartStop(&ringtone.Location, NULL, 2, argc, argv);
1571 1571
1572 GSM_Init(true); 1572 GSM_Init(true);
1573 1573
1574 ringtone.Format=0; 1574 ringtone.Format=0;
1575 1575
1576 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone); 1576 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone);
1577 Print_Error(error); 1577 Print_Error(error);
1578 1578
1579 switch (ringtone.Format) { 1579 switch (ringtone.Format) {
1580 case RING_NOTETONE : printmsg("Smart Messaging");break; 1580 case RING_NOTETONE : printmsg("Smart Messaging");break;
1581 case RING_NOKIABINARY : printmsg("Nokia binary");break; 1581 case RING_NOKIABINARY : printmsg("Nokia binary");break;
1582 case RING_MIDI : printmsg("Midi format");break; 1582 case RING_MIDI : printmsg("Midi format");break;
1583 } 1583 }
1584 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name)); 1584 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name));
1585 1585
1586 if (argc==4) { 1586 if (argc==4) {
1587 error=GSM_SaveRingtoneFile(argv[3], &ringtone); 1587 error=GSM_SaveRingtoneFile(argv[3], &ringtone);
1588 Print_Error(error); 1588 Print_Error(error);
1589 } 1589 }
1590 1590
1591 GSM_Terminate(); 1591 GSM_Terminate();
1592} 1592}
1593 1593
1594static void GetRingtonesList(int argc, char *argv[]) 1594static void GetRingtonesList(int argc, char *argv[])
1595{ 1595{
1596 GSM_AllRingtonesInfo Info; 1596 GSM_AllRingtonesInfo Info;
1597 int i; 1597 int i;
1598 1598
1599 GSM_Init(true); 1599 GSM_Init(true);
1600 1600
1601 error=Phone->GetRingtonesInfo(&s,&Info); 1601 error=Phone->GetRingtonesInfo(&s,&Info);
1602 Print_Error(error); 1602 Print_Error(error);
1603 1603
1604 GSM_Terminate(); 1604 GSM_Terminate();
1605 1605
1606 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); 1606 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name));
1607} 1607}
1608 1608
1609static void DialVoice(int argc, char *argv[]) 1609static void DialVoice(int argc, char *argv[])
1610{ 1610{
1611 GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence; 1611 GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence;
1612 1612
1613 if (argc > 3) { 1613 if (argc > 3) {
1614 if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber; 1614 if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber;
1615 } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber; 1615 } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber;
1616 } else { 1616 } else {
1617 printmsg("Unknown parameter (\"%s\")\n",argv[3]); 1617 printmsg("Unknown parameter (\"%s\")\n",argv[3]);
1618 exit(-1); 1618 exit(-1);
1619 } 1619 }
1620 } 1620 }
1621 1621
1622 GSM_Init(true); 1622 GSM_Init(true);
1623 1623
1624 error=Phone->DialVoice(&s, argv[2], ShowNumber); 1624 error=Phone->DialVoice(&s, argv[2], ShowNumber);
1625 Print_Error(error); 1625 Print_Error(error);
1626 1626
1627 GSM_Terminate(); 1627 GSM_Terminate();
1628} 1628}
1629 1629
1630static void CancelCall(int argc, char *argv[]) 1630static void CancelCall(int argc, char *argv[])
1631{ 1631{
1632 GSM_Init(true); 1632 GSM_Init(true);
1633 1633
1634 if (argc>2) { 1634 if (argc>2) {
1635 error=Phone->CancelCall(&s,atoi(argv[2]),false); 1635 error=Phone->CancelCall(&s,atoi(argv[2]),false);
1636 } else { 1636 } else {
1637 error=Phone->CancelCall(&s,0,true); 1637 error=Phone->CancelCall(&s,0,true);
1638 } 1638 }
1639 Print_Error(error); 1639 Print_Error(error);
1640 1640
1641 GSM_Terminate(); 1641 GSM_Terminate();
1642} 1642}
1643 1643
1644static void AnswerCall(int argc, char *argv[]) 1644static void AnswerCall(int argc, char *argv[])
1645{ 1645{
1646 GSM_Init(true); 1646 GSM_Init(true);
1647 1647
1648 if (argc>2) { 1648 if (argc>2) {
1649 error=Phone->AnswerCall(&s,atoi(argv[2]),false); 1649 error=Phone->AnswerCall(&s,atoi(argv[2]),false);
1650 } else { 1650 } else {
1651 error=Phone->AnswerCall(&s,0,true); 1651 error=Phone->AnswerCall(&s,0,true);
1652 } 1652 }
1653 Print_Error(error); 1653 Print_Error(error);
1654 1654
1655 GSM_Terminate(); 1655 GSM_Terminate();
1656} 1656}
1657 1657
1658static void UnholdCall(int argc, char *argv[]) 1658static void UnholdCall(int argc, char *argv[])
1659{ 1659{
1660 GSM_Init(true); 1660 GSM_Init(true);
1661 1661
1662 error=Phone->UnholdCall(&s,atoi(argv[2])); 1662 error=Phone->UnholdCall(&s,atoi(argv[2]));
1663 Print_Error(error); 1663 Print_Error(error);
1664 1664
1665 GSM_Terminate(); 1665 GSM_Terminate();
1666} 1666}
1667 1667
1668static void HoldCall(int argc, char *argv[]) 1668static void HoldCall(int argc, char *argv[])
1669{ 1669{
1670 GSM_Init(true); 1670 GSM_Init(true);
1671 1671
1672 error=Phone->HoldCall(&s,atoi(argv[2])); 1672 error=Phone->HoldCall(&s,atoi(argv[2]));
1673 Print_Error(error); 1673 Print_Error(error);
1674 1674
1675 GSM_Terminate(); 1675 GSM_Terminate();
1676} 1676}
1677 1677
1678static void ConferenceCall(int argc, char *argv[]) 1678static void ConferenceCall(int argc, char *argv[])
1679{ 1679{
1680 GSM_Init(true); 1680 GSM_Init(true);
1681 1681
1682 error=Phone->ConferenceCall(&s,atoi(argv[2])); 1682 error=Phone->ConferenceCall(&s,atoi(argv[2]));
1683 Print_Error(error); 1683 Print_Error(error);
1684 1684
1685 GSM_Terminate(); 1685 GSM_Terminate();
1686} 1686}
1687 1687
1688static void SplitCall(int argc, char *argv[]) 1688static void SplitCall(int argc, char *argv[])
1689{ 1689{
1690 GSM_Init(true); 1690 GSM_Init(true);
1691 1691
1692 error=Phone->SplitCall(&s,atoi(argv[2])); 1692 error=Phone->SplitCall(&s,atoi(argv[2]));
1693 Print_Error(error); 1693 Print_Error(error);
1694 1694
1695 GSM_Terminate(); 1695 GSM_Terminate();
1696} 1696}
1697 1697
1698static void SwitchCall(int argc, char *argv[]) 1698static void SwitchCall(int argc, char *argv[])
1699{ 1699{
1700 GSM_Init(true); 1700 GSM_Init(true);
1701 1701
1702 if (argc > 2) { 1702 if (argc > 2) {
1703 error=Phone->SwitchCall(&s,atoi(argv[2]),false); 1703 error=Phone->SwitchCall(&s,atoi(argv[2]),false);
1704 } else { 1704 } else {
1705 error=Phone->SwitchCall(&s,0,true); 1705 error=Phone->SwitchCall(&s,0,true);
1706 } 1706 }
1707 Print_Error(error); 1707 Print_Error(error);
1708 1708
1709 GSM_Terminate(); 1709 GSM_Terminate();
1710} 1710}
1711 1711
1712static void TransferCall(int argc, char *argv[]) 1712static void TransferCall(int argc, char *argv[])
1713{ 1713{
1714 GSM_Init(true); 1714 GSM_Init(true);
1715 1715
1716 if (argc > 2) { 1716 if (argc > 2) {
1717 error=Phone->TransferCall(&s,atoi(argv[2]),false); 1717 error=Phone->TransferCall(&s,atoi(argv[2]),false);
1718 } else { 1718 } else {
1719 error=Phone->TransferCall(&s,0,true); 1719 error=Phone->TransferCall(&s,0,true);
1720 } 1720 }
1721 Print_Error(error); 1721 Print_Error(error);
1722 1722
1723 GSM_Terminate(); 1723 GSM_Terminate();
1724} 1724}
1725 1725
1726static void AddSMSFolder(int argc, char *argv[]) 1726static void AddSMSFolder(int argc, char *argv[])
1727{ 1727{
1728 unsigned char buffer[200]; 1728 unsigned char buffer[200];
1729 1729
1730 GSM_Init(true); 1730 GSM_Init(true);
1731 1731
1732 EncodeUnicode(buffer,argv[2],strlen(argv[2])); 1732 EncodeUnicode(buffer,argv[2],strlen(argv[2]));
1733 error=Phone->AddSMSFolder(&s,buffer); 1733 error=Phone->AddSMSFolder(&s,buffer);
1734 Print_Error(error); 1734 Print_Error(error);
1735 1735
1736 GSM_Terminate(); 1736 GSM_Terminate();
1737} 1737}
1738 1738
1739static void Reset(int argc, char *argv[]) 1739static void Reset(int argc, char *argv[])
1740{ 1740{
1741 bool hard; 1741 bool hard;
1742 1742
1743 if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false; 1743 if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false;
1744 } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true; 1744 } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true;
1745 } else { 1745 } else {
1746 printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]); 1746 printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]);
1747 exit(-1); 1747 exit(-1);
1748 } 1748 }
1749 1749
1750 GSM_Init(true); 1750 GSM_Init(true);
1751 1751
1752 error=Phone->Reset(&s, hard); 1752 error=Phone->Reset(&s, hard);
1753 Print_Error(error); 1753 Print_Error(error);
1754 1754
1755 GSM_Terminate(); 1755 GSM_Terminate();
1756} 1756}
1757 1757
1758static void PrintCalendar(GSM_CalendarEntry *Note) 1758static void PrintCalendar(GSM_CalendarEntry *Note)
1759{ 1759{
1760 int i_age = 0,i; 1760 int i_age = 0,i;
1761 GSM_DateTime Alarm,DateTime; 1761 GSM_DateTime Alarm,DateTime;
1762 GSM_MemoryEntry entry; 1762 GSM_MemoryEntry entry;
1763 unsigned char *name; 1763 unsigned char *name;
1764 1764
1765 bool repeating = false; 1765 bool repeating = false;
1766 int repeat_dayofweek = -1; 1766 int repeat_dayofweek = -1;
1767 int repeat_day = -1; 1767 int repeat_day = -1;
1768 int repeat_weekofmonth = -1; 1768 int repeat_weekofmonth = -1;
1769 int repeat_month = -1; 1769 int repeat_month = -1;
1770 int repeat_frequency = -1; 1770 int repeat_frequency = -1;
1771 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 1771 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
1772 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 1772 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
1773 1773
1774 printmsg("Location : %d\n", Note->Location); 1774 printmsg("Location : %d\n", Note->Location);
1775 printmsg("Note type : "); 1775 printmsg("Note type : ");
1776 switch (Note->Type) { 1776 switch (Note->Type) {
1777 case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break; 1777 case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break;
1778 case GSM_CAL_CALL : printmsg("Call\n"); break; 1778 case GSM_CAL_CALL : printmsg("Call\n"); break;
1779 case GSM_CAL_MEETING : printmsg("Meeting\n"); break; 1779 case GSM_CAL_MEETING : printmsg("Meeting\n"); break;
1780 case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break; 1780 case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break;
1781 case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break; 1781 case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break;
1782 case GSM_CAL_TRAVEL : printmsg("Travel\n"); break; 1782 case GSM_CAL_TRAVEL : printmsg("Travel\n"); break;
1783 case GSM_CAL_VACATION : printmsg("Vacation\n"); break; 1783 case GSM_CAL_VACATION : printmsg("Vacation\n"); break;
1784 case GSM_CAL_ALARM : printmsg("Alarm\n"); break; 1784 case GSM_CAL_ALARM : printmsg("Alarm\n"); break;
1785 case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break; 1785 case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break;
1786 case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break; 1786 case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break;
1787 case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break; 1787 case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break;
1788 case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break; 1788 case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break;
1789 case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break; 1789 case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break;
1790 case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break; 1790 case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break;
1791 case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break; 1791 case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break;
1792 case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break; 1792 case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break;
1793 case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break; 1793 case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break;
1794 case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break; 1794 case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break;
1795 case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break; 1795 case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break;
1796 case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break; 1796 case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break;
1797 case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break; 1797 case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break;
1798 case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break; 1798 case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break;
1799 case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break; 1799 case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break;
1800 case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break; 1800 case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break;
1801 case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break; 1801 case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break;
1802 case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break; 1802 case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break;
1803 case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break; 1803 case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break;
1804 case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break; 1804 case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break;
1805 default : printmsg("UNKNOWN\n"); 1805 default : printmsg("UNKNOWN\n");
1806 } 1806 }
1807 Alarm.Year = 0; 1807 Alarm.Year = 0;
1808 1808
1809 repeating = false; 1809 repeating = false;
1810 repeat_dayofweek = -1; 1810 repeat_dayofweek = -1;
1811 repeat_day = -1; 1811 repeat_day = -1;
1812 repeat_weekofmonth = -1; 1812 repeat_weekofmonth = -1;
1813 repeat_month = -1; 1813 repeat_month = -1;
1814 repeat_frequency = -1; 1814 repeat_frequency = -1;
1815 repeat_startdate.Day= 0; 1815 repeat_startdate.Day= 0;
1816 repeat_stopdate.Day = 0; 1816 repeat_stopdate.Day = 0;
1817 1817
1818 for (i=0;i<Note->EntriesNum;i++) { 1818 for (i=0;i<Note->EntriesNum;i++) {
1819 switch (Note->Entries[i].EntryType) { 1819 switch (Note->Entries[i].EntryType) {
1820 case CAL_START_DATETIME: 1820 case CAL_START_DATETIME:
1821 printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1821 printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
1822 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1822 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1823 break; 1823 break;
1824 case CAL_END_DATETIME: 1824 case CAL_END_DATETIME:
1825 printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1825 printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
1826 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1826 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1827 break; 1827 break;
1828 case CAL_ALARM_DATETIME: 1828 case CAL_ALARM_DATETIME:
1829 printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1829 printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1830 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1830 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1831 break; 1831 break;
1832 case CAL_SILENT_ALARM_DATETIME: 1832 case CAL_SILENT_ALARM_DATETIME:
1833 printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1833 printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1834 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1834 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1835 break; 1835 break;
1836 case CAL_RECURRANCE: 1836 case CAL_RECURRANCE:
1837 printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24, 1837 printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,
1838 ((Note->Entries[i].Number/24)>1) ? "s":"" ); 1838 ((Note->Entries[i].Number/24)>1) ? "s":"" );
1839 break; 1839 break;
1840 case CAL_TEXT: 1840 case CAL_TEXT:
1841 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1841 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1842 break; 1842 break;
1843 case CAL_LOCATION: 1843 case CAL_LOCATION:
1844 printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1844 printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1845 break; 1845 break;
1846 case CAL_PHONE: 1846 case CAL_PHONE:
1847 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1847 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1848 break; 1848 break;
1849 case CAL_PRIVATE: 1849 case CAL_PRIVATE:
1850 printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); 1850 printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
1851 break; 1851 break;
1852 case CAL_CONTACTID: 1852 case CAL_CONTACTID:
1853 entry.Location = Note->Entries[i].Number; 1853 entry.Location = Note->Entries[i].Number;
1854 entry.MemoryType = MEM_ME; 1854 entry.MemoryType = MEM_ME;
1855 error=Phone->GetMemory(&s, &entry); 1855 error=Phone->GetMemory(&s, &entry);
1856 if (error == ERR_NONE) { 1856 if (error == ERR_NONE) {
1857 name = GSM_PhonebookGetEntryName(&entry); 1857 name = GSM_PhonebookGetEntryName(&entry);
1858 if (name != NULL) { 1858 if (name != NULL) {
1859 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 1859 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
1860 } else { 1860 } else {
1861 printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1861 printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1862 } 1862 }
1863 } else { 1863 } else {
1864 printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1864 printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1865 } 1865 }
1866 break; 1866 break;
1867 case CAL_REPEAT_DAYOFWEEK: 1867 case CAL_REPEAT_DAYOFWEEK:
1868 repeat_dayofweek = Note->Entries[i].Number; 1868 repeat_dayofweek = Note->Entries[i].Number;
1869 repeating = true; 1869 repeating = true;
1870 break; 1870 break;
1871 case CAL_REPEAT_DAY: 1871 case CAL_REPEAT_DAY:
1872 repeat_day = Note->Entries[i].Number; 1872 repeat_day = Note->Entries[i].Number;
1873 repeating = true; 1873 repeating = true;
1874 break; 1874 break;
1875 case CAL_REPEAT_WEEKOFMONTH: 1875 case CAL_REPEAT_WEEKOFMONTH:
1876 repeat_weekofmonth = Note->Entries[i].Number; 1876 repeat_weekofmonth = Note->Entries[i].Number;
1877 repeating = true; 1877 repeating = true;
1878 break; 1878 break;
1879 case CAL_REPEAT_MONTH: 1879 case CAL_REPEAT_MONTH:
1880 repeat_month = Note->Entries[i].Number; 1880 repeat_month = Note->Entries[i].Number;
1881 repeating = true; 1881 repeating = true;
1882 break; 1882 break;
1883 case CAL_REPEAT_FREQUENCY: 1883 case CAL_REPEAT_FREQUENCY:
1884 repeat_frequency = Note->Entries[i].Number; 1884 repeat_frequency = Note->Entries[i].Number;
1885 repeating = true; 1885 repeating = true;
1886 break; 1886 break;
1887 case CAL_REPEAT_STARTDATE: 1887 case CAL_REPEAT_STARTDATE:
1888 repeat_startdate = Note->Entries[i].Date; 1888 repeat_startdate = Note->Entries[i].Date;
1889 repeating = true; 1889 repeating = true;
1890 break; 1890 break;
1891 case CAL_REPEAT_STOPDATE: 1891 case CAL_REPEAT_STOPDATE:
1892 repeat_stopdate = Note->Entries[i].Date; 1892 repeat_stopdate = Note->Entries[i].Date;
1893 repeating = true; 1893 repeating = true;
1894 break; 1894 break;
1895 } 1895 }
1896 } 1896 }
1897 if (repeating) { 1897 if (repeating) {
1898 printmsg("Repeating : "); 1898 printmsg("Repeating : ");
1899 if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) { 1899 if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) {
1900 printmsg("Forever"); 1900 printmsg("Forever");
1901 } else if (repeat_startdate.Day == 0) { 1901 } else if (repeat_startdate.Day == 0) {
1902 printmsg("Till %s", OSDate(repeat_stopdate)); 1902 printmsg("Till %s", OSDate(repeat_stopdate));
1903 } else if (repeat_stopdate.Day == 0) { 1903 } else if (repeat_stopdate.Day == 0) {
1904 printmsg("Since %s", OSDate(repeat_startdate)); 1904 printmsg("Since %s", OSDate(repeat_startdate));
1905 } else { 1905 } else {
1906 printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate)); 1906 printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate));
1907 } 1907 }
1908 if (repeat_frequency != -1) { 1908 if (repeat_frequency != -1) {
1909 if (repeat_frequency == 1) { 1909 if (repeat_frequency == 1) {
1910 printmsg (" on each "); 1910 printmsg (" on each ");
1911 } else { 1911 } else {
1912 printmsg(" on each %d. ", repeat_frequency); 1912 printmsg(" on each %d. ", repeat_frequency);
1913 } 1913 }
1914 if (repeat_dayofweek > 0) { 1914 if (repeat_dayofweek > 0) {
1915 switch (repeat_dayofweek) { 1915 switch (repeat_dayofweek) {
1916 case 1 : printmsg("Monday"); break; 1916 case 1 : printmsg("Monday"); break;
1917 case 2 : printmsg("Tuesday"); break; 1917 case 2 : printmsg("Tuesday"); break;
1918 case 3 : printmsg("Wednesday"); break; 1918 case 3 : printmsg("Wednesday"); break;
1919 case 4 : printmsg("Thursday"); break; 1919 case 4 : printmsg("Thursday"); break;
1920 case 5 : printmsg("Friday"); break; 1920 case 5 : printmsg("Friday"); break;
1921 case 6 : printmsg("Saturday"); break; 1921 case 6 : printmsg("Saturday"); break;
1922 case 7 : printmsg("Sunday"); break; 1922 case 7 : printmsg("Sunday"); break;
1923 default: printmsg("Bad day!"); break; 1923 default: printmsg("Bad day!"); break;
1924 } 1924 }
1925 if (repeat_weekofmonth > 0) { 1925 if (repeat_weekofmonth > 0) {
1926 printmsg(" in %d. week of ", repeat_weekofmonth); 1926 printmsg(" in %d. week of ", repeat_weekofmonth);
1927 } else { 1927 } else {
1928 printmsg(" in "); 1928 printmsg(" in ");
1929 } 1929 }
1930 if (repeat_month > 0) { 1930 if (repeat_month > 0) {
1931 switch(repeat_month) { 1931 switch(repeat_month) {
1932 case 1 : printmsg("January"); break; 1932 case 1 : printmsg("January"); break;
1933 case 2 : printmsg("February"); break; 1933 case 2 : printmsg("February"); break;
1934 case 3 : printmsg("March"); break; 1934 case 3 : printmsg("March"); break;
1935 case 4 : printmsg("April"); break; 1935 case 4 : printmsg("April"); break;
1936 case 5 : printmsg("May"); break; 1936 case 5 : printmsg("May"); break;
1937 case 6 : printmsg("June"); break; 1937 case 6 : printmsg("June"); break;
1938 case 7 : printmsg("July"); break; 1938 case 7 : printmsg("July"); break;
1939 case 8 : printmsg("August"); break; 1939 case 8 : printmsg("August"); break;
1940 case 9 : printmsg("September"); break; 1940 case 9 : printmsg("September"); break;
1941 case 10: printmsg("October"); break; 1941 case 10: printmsg("October"); break;
1942 case 11: printmsg("November"); break; 1942 case 11: printmsg("November"); break;
1943 case 12: printmsg("December"); break; 1943 case 12: printmsg("December"); break;
1944 default: printmsg("Bad month!"); break; 1944 default: printmsg("Bad month!"); break;
1945 } 1945 }
1946 } else { 1946 } else {
1947 printmsg("each month"); 1947 printmsg("each month");
1948 } 1948 }
1949 } else if (repeat_day > 0) { 1949 } else if (repeat_day > 0) {
1950 printmsg("%d. day of ", repeat_day); 1950 printmsg("%d. day of ", repeat_day);
1951 if (repeat_month > 0) { 1951 if (repeat_month > 0) {
1952 switch(repeat_month) { 1952 switch(repeat_month) {
1953 case 1 : printmsg("January"); break; 1953 case 1 : printmsg("January"); break;
1954 case 2 : printmsg("February"); break; 1954 case 2 : printmsg("February"); break;
1955 case 3 : printmsg("March");break; 1955 case 3 : printmsg("March");break;
1956 case 4 : printmsg("April"); break; 1956 case 4 : printmsg("April"); break;
1957 case 5 : printmsg("May"); break; 1957 case 5 : printmsg("May"); break;
1958 case 6 : printmsg("June"); break; 1958 case 6 : printmsg("June"); break;
1959 case 7 : printmsg("July"); break; 1959 case 7 : printmsg("July"); break;
1960 case 8 : printmsg("August"); break; 1960 case 8 : printmsg("August"); break;
1961 case 9 : printmsg("September"); break; 1961 case 9 : printmsg("September"); break;
1962 case 10: printmsg("October"); break; 1962 case 10: printmsg("October"); break;
1963 case 11: printmsg("November"); break; 1963 case 11: printmsg("November"); break;
1964 case 12: printmsg("December"); break; 1964 case 12: printmsg("December"); break;
1965 default: printmsg("Bad month!");break; 1965 default: printmsg("Bad month!");break;
1966 } 1966 }
1967 } else { 1967 } else {
1968 printmsg("each month"); 1968 printmsg("each month");
1969 } 1969 }
1970 } else { 1970 } else {
1971 printmsg("day"); 1971 printmsg("day");
1972 } 1972 }
1973 } 1973 }
1974 printf("\n"); 1974 printf("\n");
1975 } 1975 }
1976 if (Note->Type == GSM_CAL_BIRTHDAY) { 1976 if (Note->Type == GSM_CAL_BIRTHDAY) {
1977 if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm); 1977 if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm);
1978 if (DateTime.Year != 0) { 1978 if (DateTime.Year != 0) {
1979 i_age = Alarm.Year - DateTime.Year; 1979 i_age = Alarm.Year - DateTime.Year;
1980 if (DateTime.Month < Alarm.Month) i_age++; 1980 if (DateTime.Month < Alarm.Month) i_age++;
1981 if (DateTime.Month == Alarm.Month && 1981 if (DateTime.Month == Alarm.Month &&
1982 DateTime.Day < Alarm.Day) { 1982 DateTime.Day < Alarm.Day) {
1983 i_age++; 1983 i_age++;
1984 } 1984 }
1985 printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years"); 1985 printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years");
1986 } 1986 }
1987 } 1987 }
1988 printf("\n"); 1988 printf("\n");
1989} 1989}
1990 1990
1991static void GetCalendar(int argc, char *argv[]) 1991static void GetCalendar(int argc, char *argv[])
1992{ 1992{
1993 GSM_CalendarEntryNote; 1993 GSM_CalendarEntryNote;
1994 int start,stop; 1994 int start,stop;
1995 1995
1996 GetStartStop(&start, &stop, 2, argc, argv); 1996 GetStartStop(&start, &stop, 2, argc, argv);
1997 1997
1998 GSM_Init(true); 1998 GSM_Init(true);
1999 1999
2000 for (i=start;i<=stop;i++) { 2000 for (i=start;i<=stop;i++) {
2001 Note.Location=i; 2001 Note.Location=i;
2002 error = Phone->GetCalendar(&s, &Note); 2002 error = Phone->GetCalendar(&s, &Note);
2003 if (error == ERR_EMPTY) continue; 2003 if (error == ERR_EMPTY) continue;
2004 Print_Error(error); 2004 Print_Error(error);
2005 PrintCalendar(&Note); 2005 PrintCalendar(&Note);
2006 } 2006 }
2007 2007
2008 GSM_Terminate(); 2008 GSM_Terminate();
2009} 2009}
2010 2010
2011static void DeleteCalendar(int argc, char *argv[]) 2011static void DeleteCalendar(int argc, char *argv[])
2012{ 2012{
2013 GSM_CalendarEntryNote; 2013 GSM_CalendarEntryNote;
2014 int start,stop; 2014 int start,stop;
2015 2015
2016 GetStartStop(&start, &stop, 2, argc, argv); 2016 GetStartStop(&start, &stop, 2, argc, argv);
2017 2017
2018 GSM_Init(true); 2018 GSM_Init(true);
2019 2019
2020 for (i=start;i<=stop;i++) { 2020 for (i=start;i<=stop;i++) {
2021 Note.Location=i; 2021 Note.Location=i;
2022 error = Phone->DeleteCalendar(&s, &Note); 2022 error = Phone->DeleteCalendar(&s, &Note);
2023 if (error == ERR_EMPTY) continue; 2023 if (error == ERR_EMPTY) continue;
2024 Print_Error(error); 2024 Print_Error(error);
2025 PrintCalendar(&Note); 2025 PrintCalendar(&Note);
2026 } 2026 }
2027 2027
2028 GSM_Terminate(); 2028 GSM_Terminate();
2029} 2029}
2030 2030
2031 2031
2032static void GetAllCalendar(int argc, char *argv[]) 2032static void GetAllCalendar(int argc, char *argv[])
2033{ 2033{
2034 GSM_CalendarEntryNote; 2034 GSM_CalendarEntryNote;
2035 bool refresh= true; 2035 bool refresh= true;
2036 2036
2037 signal(SIGINT, interrupt); 2037 signal(SIGINT, interrupt);
2038 printmsgerr("Press Ctrl+C to break...\n"); 2038 printmsgerr("Press Ctrl+C to break...\n");
2039 2039
2040 GSM_Init(true); 2040 GSM_Init(true);
2041 2041
2042 while (!gshutdown) { 2042 while (!gshutdown) {
2043 error=Phone->GetNextCalendar(&s,&Note,refresh); 2043 error=Phone->GetNextCalendar(&s,&Note,refresh);
2044 if (error == ERR_EMPTY) break; 2044 if (error == ERR_EMPTY) break;
2045 PrintCalendar(&Note); 2045 PrintCalendar(&Note);
2046 Print_Error(error); 2046 Print_Error(error);
2047 refresh=false; 2047 refresh=false;
2048 } 2048 }
2049 2049
2050 GSM_Terminate(); 2050 GSM_Terminate();
2051} 2051}
2052 2052
2053static void GetCalendarSettings(int argc, char *argv[]) 2053static void GetCalendarSettings(int argc, char *argv[])
2054{ 2054{
2055 GSM_CalendarSettings settings; 2055 GSM_CalendarSettings settings;
2056 2056
2057 GSM_Init(true); 2057 GSM_Init(true);
2058 2058
2059 error=Phone->GetCalendarSettings(&s,&settings); 2059 error=Phone->GetCalendarSettings(&s,&settings);
2060 Print_Error(error); 2060 Print_Error(error);
2061 2061
2062 if (settings.AutoDelete == 0) { 2062 if (settings.AutoDelete == 0) {
2063 printmsg("Auto deleting disabled"); 2063 printmsg("Auto deleting disabled");
2064 } else { 2064 } else {
2065 printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete); 2065 printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete);
2066 } 2066 }
2067 printmsg("\nWeek start on "); 2067 printmsg("\nWeek start on ");
2068 switch(settings.StartDay) { 2068 switch(settings.StartDay) {
2069 case 1: printmsg("Monday"); break; 2069 case 1: printmsg("Monday"); break;
2070 case 6: printmsg("Saturday"); break; 2070 case 6: printmsg("Saturday"); break;
2071 case 7: printmsg("Sunday"); break; 2071 case 7: printmsg("Sunday"); break;
2072 } 2072 }
2073 printf("\n"); 2073 printf("\n");
2074 2074
2075 GSM_Terminate(); 2075 GSM_Terminate();
2076} 2076}
2077 2077
2078static void GetWAPBookmark(int argc, char *argv[]) 2078static void GetWAPBookmark(int argc, char *argv[])
2079{ 2079{
2080 GSM_WAPBookmark bookmark; 2080 GSM_WAPBookmark bookmark;
2081 int start,stop; 2081 int start,stop;
2082 2082
2083 GetStartStop(&start, &stop, 2, argc, argv); 2083 GetStartStop(&start, &stop, 2, argc, argv);
2084 2084
2085 GSM_Init(true); 2085 GSM_Init(true);
2086 2086
2087 for (i=start;i<=stop;i++) { 2087 for (i=start;i<=stop;i++) {
2088 bookmark.Location=i; 2088 bookmark.Location=i;
2089 error=Phone->GetWAPBookmark(&s,&bookmark); 2089 error=Phone->GetWAPBookmark(&s,&bookmark);
2090 Print_Error(error); 2090 Print_Error(error);
2091 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title)); 2091 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title));
2092 printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address)); 2092 printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address));
2093 } 2093 }
2094 2094
2095 GSM_Terminate(); 2095 GSM_Terminate();
2096} 2096}
2097 2097
2098static void DeleteWAPBookmark(int argc, char *argv[]) 2098static void DeleteWAPBookmark(int argc, char *argv[])
2099{ 2099{
2100 GSM_WAPBookmarkbookmark; 2100 GSM_WAPBookmarkbookmark;
2101 int start, stop; 2101 int start, stop;
2102 2102
2103 GetStartStop(&start, &stop, 2, argc, argv); 2103 GetStartStop(&start, &stop, 2, argc, argv);
2104 2104
2105 GSM_Init(true); 2105 GSM_Init(true);
2106 2106
2107 for (i=start;i<=stop;i++) { 2107 for (i=start;i<=stop;i++) {
2108 bookmark.Location=i; 2108 bookmark.Location=i;
2109 error=Phone->DeleteWAPBookmark(&s, &bookmark); 2109 error=Phone->DeleteWAPBookmark(&s, &bookmark);
2110 Print_Error(error); 2110 Print_Error(error);
2111 } 2111 }
2112 2112
2113 GSM_Terminate(); 2113 GSM_Terminate();
2114} 2114}
2115 2115
2116static void GetGPRSPoint(int argc, char *argv[]) 2116static void GetGPRSPoint(int argc, char *argv[])
2117{ 2117{
2118 GSM_GPRSAccessPointpoint; 2118 GSM_GPRSAccessPointpoint;
2119 int start,stop; 2119 int start,stop;
2120 2120
2121 GetStartStop(&start, &stop, 2, argc, argv); 2121 GetStartStop(&start, &stop, 2, argc, argv);
2122 2122
2123 GSM_Init(true); 2123 GSM_Init(true);
2124 2124
2125 for (i=start;i<=stop;i++) { 2125 for (i=start;i<=stop;i++) {
2126 point.Location=i; 2126 point.Location=i;
2127 error=Phone->GetGPRSAccessPoint(&s,&point); 2127 error=Phone->GetGPRSAccessPoint(&s,&point);
2128 if (error != ERR_EMPTY) { 2128 if (error != ERR_EMPTY) {
2129 Print_Error(error); 2129 Print_Error(error);
2130 printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name)); 2130 printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name));
2131 } else { 2131 } else {
2132 printmsg("%i. Access point %i",point.Location,point.Location); 2132 printmsg("%i. Access point %i",point.Location,point.Location);
2133 } 2133 }
2134 if (point.Active) printmsg(" (active)"); 2134 if (point.Active) printmsg(" (active)");
2135 if (error != ERR_EMPTY) { 2135 if (error != ERR_EMPTY) {
2136 printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL)); 2136 printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL));
2137 } else { 2137 } else {
2138 printmsg("\n\n"); 2138 printmsg("\n\n");
2139 } 2139 }
2140 } 2140 }
2141 2141
2142 GSM_Terminate(); 2142 GSM_Terminate();
2143} 2143}
2144 2144
2145static void GetBitmap(int argc, char *argv[]) 2145static void GetBitmap(int argc, char *argv[])
2146{ 2146{
2147 GSM_File File; 2147 GSM_File File;
2148 GSM_MultiBitmap MultiBitmap; 2148 GSM_MultiBitmap MultiBitmap;
2149 int location=0; 2149 int location=0;
2150 GSM_AllRingtonesInfo Info; 2150 GSM_AllRingtonesInfo Info;
2151 2151
2152 if (mystrncasecmp(argv[2],"STARTUP",0)) { 2152 if (mystrncasecmp(argv[2],"STARTUP",0)) {
2153 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; 2153 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
2154 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2154 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2155 MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo; 2155 MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo;
2156 GetStartStop(&location, NULL, 3, argc, argv); 2156 GetStartStop(&location, NULL, 3, argc, argv);
2157 if (location>5) { 2157 if (location>5) {
2158 printmsg("Maximal location for caller logo can be 5\n"); 2158 printmsg("Maximal location for caller logo can be 5\n");
2159 exit (-1); 2159 exit (-1);
2160 } 2160 }
2161 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2161 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2162 MultiBitmap.Bitmap[0].Type=GSM_PictureImage; 2162 MultiBitmap.Bitmap[0].Type=GSM_PictureImage;
2163 GetStartStop(&location, NULL, 3, argc, argv); 2163 GetStartStop(&location, NULL, 3, argc, argv);
2164 } else if (mystrncasecmp(argv[2],"TEXT",0)) { 2164 } else if (mystrncasecmp(argv[2],"TEXT",0)) {
2165 MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text; 2165 MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text;
2166 } else if (mystrncasecmp(argv[2],"DEALER",0)) { 2166 } else if (mystrncasecmp(argv[2],"DEALER",0)) {
2167 MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text; 2167 MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text;
2168 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2168 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2169 MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo; 2169 MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo;
2170 } else { 2170 } else {
2171 printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]); 2171 printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]);
2172 exit(-1); 2172 exit(-1);
2173 } 2173 }
2174 MultiBitmap.Bitmap[0].Location=location; 2174 MultiBitmap.Bitmap[0].Location=location;
2175 2175
2176 GSM_Init(true); 2176 GSM_Init(true);
2177 2177
2178 error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]); 2178 error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]);
2179 Print_Error(error); 2179 Print_Error(error);
2180 2180
2181 MultiBitmap.Number = 1; 2181 MultiBitmap.Number = 1;
2182 2182
2183 error=ERR_NONE; 2183 error=ERR_NONE;
2184 switch (MultiBitmap.Bitmap[0].Type) { 2184 switch (MultiBitmap.Bitmap[0].Type) {
2185 case GSM_CallerGroupLogo: 2185 case GSM_CallerGroupLogo:
2186 if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2186 if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2187 printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2187 printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2188 if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)"); 2188 if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)");
2189 printf("\n"); 2189 printf("\n");
2190 if (MultiBitmap.Bitmap[0].DefaultRingtone) { 2190 if (MultiBitmap.Bitmap[0].DefaultRingtone) {
2191 printmsg("Ringtone : default\n"); 2191 printmsg("Ringtone : default\n");
2192 } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) { 2192 } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) {
2193 sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID); 2193 sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID);
2194 2194
2195 File.Buffer = NULL; 2195 File.Buffer = NULL;
2196 File.Used = 0; 2196 File.Used = 0;
2197 2197
2198 error = ERR_NONE; 2198 error = ERR_NONE;
2199 // while (error == ERR_NONE) { 2199 // while (error == ERR_NONE) {
2200 error = Phone->GetFilePart(&s,&File); 2200 error = Phone->GetFilePart(&s,&File);
2201 // } 2201 // }
2202 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 2202 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
2203 error = ERR_NONE; 2203 error = ERR_NONE;
2204 2204
2205 printmsg("Ringtone : \"%s\" (file with ID %i)\n", 2205 printmsg("Ringtone : \"%s\" (file with ID %i)\n",
2206 DecodeUnicodeString(File.Name), 2206 DecodeUnicodeString(File.Name),
2207 MultiBitmap.Bitmap[0].RingtoneID); 2207 MultiBitmap.Bitmap[0].RingtoneID);
2208 } else { 2208 } else {
2209 error = Phone->GetRingtonesInfo(&s,&Info); 2209 error = Phone->GetRingtonesInfo(&s,&Info);
2210 if (error != ERR_NONE) Info.Number = 0; 2210 if (error != ERR_NONE) Info.Number = 0;
2211 error = ERR_NONE; 2211 error = ERR_NONE;
2212 2212
2213 printmsg("Ringtone : "); 2213 printmsg("Ringtone : ");
2214 if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) { 2214 if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) {
2215 printmsg("\"%s\" (ID %i)\n", 2215 printmsg("\"%s\" (ID %i)\n",
2216 DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)), 2216 DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)),
2217 MultiBitmap.Bitmap[0].RingtoneID); 2217 MultiBitmap.Bitmap[0].RingtoneID);
2218 } else { 2218 } else {
2219 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID); 2219 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID);
2220 } 2220 }
2221 } 2221 }
2222 if (MultiBitmap.Bitmap[0].BitmapEnabled) { 2222 if (MultiBitmap.Bitmap[0].BitmapEnabled) {
2223 printmsg("Bitmap : enabled\n"); 2223 printmsg("Bitmap : enabled\n");
2224 } else { 2224 } else {
2225 printmsg("Bitmap : disabled\n"); 2225 printmsg("Bitmap : disabled\n");
2226 } 2226 }
2227 if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); 2227 if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
2228 break; 2228 break;
2229 case GSM_StartupLogo: 2229 case GSM_StartupLogo:
2230 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2230 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2231 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); 2231 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
2232 break; 2232 break;
2233 case GSM_OperatorLogo: 2233 case GSM_OperatorLogo:
2234 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) { 2234 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) {
2235 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2235 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2236 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); 2236 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
2237 } else { 2237 } else {
2238 printmsg("No operator logo in phone\n"); 2238 printmsg("No operator logo in phone\n");
2239 } 2239 }
2240 break; 2240 break;
2241 case GSM_PictureImage: 2241 case GSM_PictureImage:
2242 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2242 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2243 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2243 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2244 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender)); 2244 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender));
2245 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); 2245 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
2246 break; 2246 break;
2247 case GSM_WelcomeNote_Text: 2247 case GSM_WelcomeNote_Text:
2248 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2248 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2249 break; 2249 break;
2250 case GSM_DealerNote_Text: 2250 case GSM_DealerNote_Text:
2251 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2251 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2252 break; 2252 break;
2253 default: 2253 default:
2254 break; 2254 break;
2255 } 2255 }
2256 Print_Error(error); 2256 Print_Error(error);
2257 2257
2258 GSM_Terminate(); 2258 GSM_Terminate();
2259} 2259}
2260 2260
2261static void SetBitmap(int argc, char *argv[]) 2261static void SetBitmap(int argc, char *argv[])
2262{ 2262{
2263 GSM_Bitmap Bitmap, NewBitmap; 2263 GSM_Bitmap Bitmap, NewBitmap;
2264 GSM_MultiBitmap MultiBitmap; 2264 GSM_MultiBitmap MultiBitmap;
2265 GSM_NetworkInfo NetInfo; 2265 GSM_NetworkInfo NetInfo;
2266 bool init = true; 2266 bool init = true;
2267 2267
2268 if (mystrncasecmp(argv[2],"STARTUP",0)) { 2268 if (mystrncasecmp(argv[2],"STARTUP",0)) {
2269 if (argc<4) { 2269 if (argc<4) {
2270 printmsg("More arguments required\n"); 2270 printmsg("More arguments required\n");
2271 exit(-1); 2271 exit(-1);
2272 } 2272 }
2273 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; 2273 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
2274 MultiBitmap.Bitmap[0].Location=1; 2274 MultiBitmap.Bitmap[0].Location=1;
2275 if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2; 2275 if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2;
2276 if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3; 2276 if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3;
2277 if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4; 2277 if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4;
2278 if (MultiBitmap.Bitmap[0].Location == 1) { 2278 if (MultiBitmap.Bitmap[0].Location == 1) {
2279 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2279 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2280 Print_Error(error); 2280 Print_Error(error);
2281 } 2281 }
2282 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2282 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2283 } else if (mystrncasecmp(argv[2],"TEXT",0)) { 2283 } else if (mystrncasecmp(argv[2],"TEXT",0)) {
2284 if (argc<4) { 2284 if (argc<4) {
2285 printmsg("More arguments required\n"); 2285 printmsg("More arguments required\n");
2286 exit(-1); 2286 exit(-1);
2287 } 2287 }
2288 Bitmap.Type=GSM_WelcomeNote_Text; 2288 Bitmap.Type=GSM_WelcomeNote_Text;
2289 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); 2289 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
2290 } else if (mystrncasecmp(argv[2],"DEALER",0)) { 2290 } else if (mystrncasecmp(argv[2],"DEALER",0)) {
2291 if (argc<4) { 2291 if (argc<4) {
2292 printmsg("More arguments required\n"); 2292 printmsg("More arguments required\n");
2293 exit(-1); 2293 exit(-1);
2294 } 2294 }
2295 Bitmap.Type=GSM_DealerNote_Text; 2295 Bitmap.Type=GSM_DealerNote_Text;
2296 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); 2296 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
2297 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2297 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2298 if (argc<4) { 2298 if (argc<4) {
2299 printmsg("More arguments required\n"); 2299 printmsg("More arguments required\n");
2300 exit(-1); 2300 exit(-1);
2301 } 2301 }
2302 GetStartStop(&i, NULL, 3, argc, argv); 2302 GetStartStop(&i, NULL, 3, argc, argv);
2303 if (i>5 && i!=255) { 2303 if (i>5 && i!=255) {
2304 printmsg("Maximal location for caller logo can be 5\n"); 2304 printmsg("Maximal location for caller logo can be 5\n");
2305 exit (-1); 2305 exit (-1);
2306 } 2306 }
2307 MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo; 2307 MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo;
2308 MultiBitmap.Bitmap[0].Location= i; 2308 MultiBitmap.Bitmap[0].Location= i;
2309 if (argc>4) { 2309 if (argc>4) {
2310 error=GSM_ReadBitmapFile(argv[4],&MultiBitmap); 2310 error=GSM_ReadBitmapFile(argv[4],&MultiBitmap);
2311 Print_Error(error); 2311 Print_Error(error);
2312 } 2312 }
2313 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2313 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2314 if (i!=255) { 2314 if (i!=255) {
2315 GSM_Init(true); 2315 GSM_Init(true);
2316 init = false; 2316 init = false;
2317 NewBitmap.Type = GSM_CallerGroupLogo; 2317 NewBitmap.Type = GSM_CallerGroupLogo;
2318 NewBitmap.Location = i; 2318 NewBitmap.Location = i;
2319 error=Phone->GetBitmap(&s,&NewBitmap); 2319 error=Phone->GetBitmap(&s,&NewBitmap);
2320 Print_Error(error); 2320 Print_Error(error);
2321 Bitmap.RingtoneID = NewBitmap.RingtoneID; 2321 Bitmap.RingtoneID = NewBitmap.RingtoneID;
2322 Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone; 2322 Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone;
2323 Bitmap.FileSystemRingtone = false; 2323 Bitmap.FileSystemRingtone = false;
2324 CopyUnicodeString(Bitmap.Text, NewBitmap.Text); 2324 CopyUnicodeString(Bitmap.Text, NewBitmap.Text);
2325 Bitmap.DefaultName = NewBitmap.DefaultName; 2325 Bitmap.DefaultName = NewBitmap.DefaultName;
2326 } 2326 }
2327 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2327 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2328 if (argc<5) { 2328 if (argc<5) {
2329 printmsg("More arguments required\n"); 2329 printmsg("More arguments required\n");
2330 exit(-1); 2330 exit(-1);
2331 } 2331 }
2332 MultiBitmap.Bitmap[0].Type = GSM_PictureImage; 2332 MultiBitmap.Bitmap[0].Type = GSM_PictureImage;
2333 MultiBitmap.Bitmap[0].Location = atoi(argv[4]); 2333 MultiBitmap.Bitmap[0].Location = atoi(argv[4]);
2334 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2334 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2335 Print_Error(error); 2335 Print_Error(error);
2336 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2336 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2337 Bitmap.Text[0]=0; 2337 Bitmap.Text[0]=0;
2338 Bitmap.Text[1]=0; 2338 Bitmap.Text[1]=0;
2339 if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5])); 2339 if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5]));
2340 Bitmap.Sender[0]=0; 2340 Bitmap.Sender[0]=0;
2341 Bitmap.Sender[1]=0; 2341 Bitmap.Sender[1]=0;
2342 } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) { 2342 } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) {
2343 Bitmap.Type = GSM_ColourOperatorLogo_ID; 2343 Bitmap.Type = GSM_ColourOperatorLogo_ID;
2344 strcpy(Bitmap.NetworkCode,"000 00"); 2344 strcpy(Bitmap.NetworkCode,"000 00");
2345 if (argc > 3) { 2345 if (argc > 3) {
2346 Bitmap.ID = atoi(argv[3]); 2346 Bitmap.ID = atoi(argv[3]);
2347 if (argc>4) { 2347 if (argc>4) {
2348 strncpy(Bitmap.NetworkCode,argv[4],6); 2348 strncpy(Bitmap.NetworkCode,argv[4],6);
2349 } else { 2349 } else {
2350 GSM_Init(true); 2350 GSM_Init(true);
2351 init = false; 2351 init = false;
2352 error=Phone->GetNetworkInfo(&s,&NetInfo); 2352 error=Phone->GetNetworkInfo(&s,&NetInfo);
2353 Print_Error(error); 2353 Print_Error(error);
2354 strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode); 2354 strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode);
2355 } 2355 }
2356 } 2356 }
2357 } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) { 2357 } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) {
2358 Bitmap.Type = GSM_ColourStartupLogo_ID; 2358 Bitmap.Type = GSM_ColourStartupLogo_ID;
2359 Bitmap.Location = 0; 2359 Bitmap.Location = 0;
2360 if (argc > 3) { 2360 if (argc > 3) {
2361 Bitmap.Location = 1; 2361 Bitmap.Location = 1;
2362 Bitmap.ID = atoi(argv[3]); 2362 Bitmap.ID = atoi(argv[3]);
2363 } 2363 }
2364 } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) { 2364 } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) {
2365 Bitmap.Type = GSM_ColourWallPaper_ID; 2365 Bitmap.Type = GSM_ColourWallPaper_ID;
2366 Bitmap.ID = 0; 2366 Bitmap.ID = 0;
2367 if (argc > 3) Bitmap.ID = atoi(argv[3]); 2367 if (argc > 3) Bitmap.ID = atoi(argv[3]);
2368 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2368 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2369 MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo; 2369 MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo;
2370 MultiBitmap.Bitmap[0].Location = 1; 2370 MultiBitmap.Bitmap[0].Location = 1;
2371 strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00"); 2371 strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00");
2372 if (argc>3) { 2372 if (argc>3) {
2373 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2373 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2374 Print_Error(error); 2374 Print_Error(error);
2375 if (argc>4) { 2375 if (argc>4) {
2376 strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6); 2376 strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6);
2377 } else { 2377 } else {
2378 GSM_Init(true); 2378 GSM_Init(true);
2379 init = false; 2379 init = false;
2380 error=Phone->GetNetworkInfo(&s,&NetInfo); 2380 error=Phone->GetNetworkInfo(&s,&NetInfo);
2381 Print_Error(error); 2381 Print_Error(error);
2382 strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode); 2382 strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode);
2383 } 2383 }
2384 } 2384 }
2385 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2385 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2386 } else { 2386 } else {
2387 printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]); 2387 printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]);
2388 exit(-1); 2388 exit(-1);
2389 } 2389 }
2390 2390
2391 if (init) GSM_Init(true); 2391 if (init) GSM_Init(true);
2392 2392
2393 error=Phone->SetBitmap(&s,&Bitmap); 2393 error=Phone->SetBitmap(&s,&Bitmap);
2394 Print_Error(error); 2394 Print_Error(error);
2395 2395
2396#ifdef GSM_ENABLE_BEEP 2396#ifdef GSM_ENABLE_BEEP
2397 GSM_PhoneBeep(); 2397 GSM_PhoneBeep();
2398#endif 2398#endif
2399 2399
2400 GSM_Terminate(); 2400 GSM_Terminate();
2401} 2401}
2402 2402
2403static void SetRingtone(int argc, char *argv[]) 2403static void SetRingtone(int argc, char *argv[])
2404{ 2404{
2405 GSM_Ringtone ringtone; 2405 GSM_Ringtone ringtone;
2406 int i,nextlong=0; 2406 int i,nextlong=0;
2407 2407
2408 ringtone.Format= 0; 2408 ringtone.Format= 0;
2409 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 2409 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
2410 Print_Error(error); 2410 Print_Error(error);
2411 ringtone.Location = 255; 2411 ringtone.Location = 255;
2412 for (i=3;i<argc;i++) { 2412 for (i=3;i<argc;i++) {
2413 switch (nextlong) { 2413 switch (nextlong) {
2414 case 0: 2414 case 0:
2415 if (mystrncasecmp(argv[i],"-scale",0)) { 2415 if (mystrncasecmp(argv[i],"-scale",0)) {
2416 ringtone.NoteTone.AllNotesScale = true; 2416 ringtone.NoteTone.AllNotesScale = true;
2417 break; 2417 break;
2418 } 2418 }
2419 if (mystrncasecmp(argv[i],"-location",0)) { 2419 if (mystrncasecmp(argv[i],"-location",0)) {
2420 nextlong = 1; 2420 nextlong = 1;
2421 break; 2421 break;
2422 } 2422 }
2423 if (mystrncasecmp(argv[i],"-name",0)) { 2423 if (mystrncasecmp(argv[i],"-name",0)) {
2424 nextlong = 2; 2424 nextlong = 2;
2425 break; 2425 break;
2426 } 2426 }
2427 printmsg("Unknown parameter \"%s\"",argv[i]); 2427 printmsg("Unknown parameter \"%s\"",argv[i]);
2428 exit(-1); 2428 exit(-1);
2429 case 1: 2429 case 1:
2430 ringtone.Location=atoi(argv[i]); 2430 ringtone.Location=atoi(argv[i]);
2431 nextlong = 0; 2431 nextlong = 0;
2432 break; 2432 break;
2433 case 2: 2433 case 2:
2434 EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i])); 2434 EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i]));
2435 nextlong = 0; 2435 nextlong = 0;
2436 break; 2436 break;
2437 } 2437 }
2438 } 2438 }
2439 if (nextlong!=0) { 2439 if (nextlong!=0) {
2440 printmsg("Parameter missed...\n"); 2440 printmsg("Parameter missed...\n");
2441 exit(-1); 2441 exit(-1);
2442 } 2442 }
2443 if (ringtone.Location==0) { 2443 if (ringtone.Location==0) {
2444 printmsg("ERROR: enumerate locations from 1\n"); 2444 printmsg("ERROR: enumerate locations from 1\n");
2445 exit (-1); 2445 exit (-1);
2446 } 2446 }
2447 2447
2448 GSM_Init(true); 2448 GSM_Init(true);
2449 error=Phone->SetRingtone(&s, &ringtone, &i); 2449 error=Phone->SetRingtone(&s, &ringtone, &i);
2450 Print_Error(error); 2450 Print_Error(error);
2451#ifdef GSM_ENABLE_BEEP 2451#ifdef GSM_ENABLE_BEEP
2452 GSM_PhoneBeep(); 2452 GSM_PhoneBeep();
2453#endif 2453#endif
2454 GSM_Terminate(); 2454 GSM_Terminate();
2455} 2455}
2456 2456
2457static void DisplaySMSFrame(GSM_SMSMessage *SMS) 2457static void DisplaySMSFrame(GSM_SMSMessage *SMS)
2458{ 2458{
2459 GSM_Error error; 2459 GSM_Error error;
2460 int i, length, current = 0; 2460 int i, length, current = 0;
2461 unsigned char req[1000], buffer[1000], hexreq[1000]; 2461 unsigned char req[1000], buffer[1000], hexreq[1000];
2462#ifdef OSCAR 2462#ifdef OSCAR
2463 unsigned char hexmsg[1000], hexudh[1000]; 2463 unsigned char hexmsg[1000], hexudh[1000];
2464#endif 2464#endif
2465 error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true); 2465 error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true);
2466 if (error != ERR_NONE) { 2466 if (error != ERR_NONE) {
2467 printmsg("Error\n"); 2467 printmsg("Error\n");
2468 exit(-1); 2468 exit(-1);
2469 } 2469 }
2470 length = length - PHONE_SMSSubmit.Text; 2470 length = length - PHONE_SMSSubmit.Text;
2471#ifdef OSCAR 2471#ifdef OSCAR
2472 for(i=SMS->UDH.Length;i<length;i++) { 2472 for(i=SMS->UDH.Length;i<length;i++) {
2473 req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i]; 2473 req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i];
2474 } 2474 }
2475 EncodeHexBin(hexmsg, req, length-SMS->UDH.Length); 2475 EncodeHexBin(hexmsg, req, length-SMS->UDH.Length);
2476 2476
2477 for(i=0;i<SMS->UDH.Length;i++) { 2477 for(i=0;i<SMS->UDH.Length;i++) {
2478 req[i]=buffer[PHONE_SMSSubmit.Text+i]; 2478 req[i]=buffer[PHONE_SMSSubmit.Text+i];
2479 } 2479 }
2480 EncodeHexBin(hexudh, req, SMS->UDH.Length); 2480 EncodeHexBin(hexudh, req, SMS->UDH.Length);
2481 2481
2482 printf("msg:%s nb:%i udh:%s\n", 2482 printf("msg:%s nb:%i udh:%s\n",
2483 hexmsg, 2483 hexmsg,
2484 (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8, 2484 (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8,
2485 hexudh); 2485 hexudh);
2486#else 2486#else
2487 for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) { 2487 for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) {
2488 req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i]; 2488 req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i];
2489 } 2489 }
2490 req[current++]=buffer[PHONE_SMSSubmit.firstbyte]; 2490 req[current++]=buffer[PHONE_SMSSubmit.firstbyte];
2491 req[current++]=buffer[PHONE_SMSSubmit.TPMR]; 2491 req[current++]=buffer[PHONE_SMSSubmit.TPMR];
2492 for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) { 2492 for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) {
2493 req[current++]=buffer[PHONE_SMSSubmit.Number+i]; 2493 req[current++]=buffer[PHONE_SMSSubmit.Number+i];
2494 } 2494 }
2495 req[current++]=buffer[PHONE_SMSSubmit.TPPID]; 2495 req[current++]=buffer[PHONE_SMSSubmit.TPPID];
2496 req[current++]=buffer[PHONE_SMSSubmit.TPDCS]; 2496 req[current++]=buffer[PHONE_SMSSubmit.TPDCS];
2497 req[current++]=buffer[PHONE_SMSSubmit.TPVP]; 2497 req[current++]=buffer[PHONE_SMSSubmit.TPVP];
2498 req[current++]=buffer[PHONE_SMSSubmit.TPUDL]; 2498 req[current++]=buffer[PHONE_SMSSubmit.TPUDL];
2499 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i]; 2499 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i];
2500 EncodeHexBin(hexreq, req, current); 2500 EncodeHexBin(hexreq, req, current);
2501 printmsg("%s\n\n",hexreq); 2501 printmsg("%s\n\n",hexreq);
2502#endif 2502#endif
2503} 2503}
2504 2504
2505#define SEND_SAVE_SMS_BUFFER_SIZE 10000 2505#define SEND_SAVE_SMS_BUFFER_SIZE 10000
2506 2506
2507static GSM_Error SMSStatus; 2507static GSM_Error SMSStatus;
2508//#if 0 2508//#if 0
2509static void SendSMSStatus (char *Device, int status, int MessageReference) 2509static void SendSMSStatus (char *Device, int status, int MessageReference)
2510{ 2510{
2511 dbgprintf("Sent SMS on device: \"%s\"\n",Device); 2511 dbgprintf("Sent SMS on device: \"%s\"\n",Device);
2512 if (status==0) { 2512 if (status==0) {
2513 printmsg("..OK"); 2513 printmsg("..OK");
2514 SMSStatus = ERR_NONE; 2514 SMSStatus = ERR_NONE;
2515 } else { 2515 } else {
2516 printmsg("..error %i",status); 2516 printmsg("..error %i",status);
2517 SMSStatus = ERR_UNKNOWN; 2517 SMSStatus = ERR_UNKNOWN;
2518 } 2518 }
2519 printmsg(", message reference=%02x\n",MessageReference); 2519 printmsg(", message reference=%02x\n",MessageReference);
2520} 2520}
2521 2521
2522static void SendSaveDisplaySMS(int argc, char *argv[]) 2522static void SendSaveDisplaySMS(int argc, char *argv[])
2523{ 2523{
2524#ifdef GSM_ENABLE_BACKUP 2524#ifdef GSM_ENABLE_BACKUP
2525 GSM_Backup Backup; 2525 GSM_Backup Backup;
2526#endif 2526#endif
2527 int i,j,z,FramesNum = 0; 2527 int i,j,z,FramesNum = 0;
2528 int Protected = 0; 2528 int Protected = 0;
2529 GSM_SMSFolders folders; 2529 GSM_SMSFolders folders;
2530 GSM_MultiSMSMessage sms; 2530 GSM_MultiSMSMessage sms;
2531 GSM_Ringtone ringtone[MAX_MULTI_SMS]; 2531 GSM_Ringtone ringtone[MAX_MULTI_SMS];
2532 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2; 2532 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2;
2533 GSM_MultiPartSMSInfoSMSInfo; 2533 GSM_MultiPartSMSInfoSMSInfo;
2534 GSM_NetworkInfo NetInfo; 2534 GSM_NetworkInfo NetInfo;
2535 GSM_MMSIndicator MMSInfo; 2535 GSM_MMSIndicator MMSInfo;
2536 FILE *ReplaceFile,*f; 2536 FILE *ReplaceFile,*f;
2537 char ReplaceBuffer2[200],ReplaceBuffer[200]; 2537 char ReplaceBuffer2[200],ReplaceBuffer[200];
2538 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1]; 2538 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1];
2539 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE]; 2539 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE];
2540 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2540 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2];
2541 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2541 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2];
2542 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2542 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2];
2543 int startarg = 0; 2543 int startarg = 0;
2544 int chars_read = 0; 2544 int chars_read = 0;
2545 int nextlong = 0; 2545 int nextlong = 0;
2546 bool ReplyViaSameSMSC = false; 2546 bool ReplyViaSameSMSC = false;
2547 int SMSCSet = 1; 2547 int SMSCSet = 1;
2548 int MaxSMS = -1; 2548 int MaxSMS = -1;
2549 bool EMS16Bit = false; 2549 bool EMS16Bit = false;
2550 bool SendSaved = false; 2550 bool SendSaved = false;
2551 2551
2552 /* Parameters required only during saving */ 2552 /* Parameters required only during saving */
2553 int Folder = 1; /*Inbox by default */ 2553 int Folder = 1; /*Inbox by default */
2554 GSM_SMS_State State = SMS_Sent; 2554 GSM_SMS_State State = SMS_Sent;
2555 2555
2556 /* Required only during sending */ 2556 /* Required only during sending */
2557 GSM_SMSValidity Validity; 2557 GSM_SMSValidity Validity;
2558 GSM_SMSC PhoneSMSC; 2558 GSM_SMSC PhoneSMSC;
2559 bool DeliveryReport = false; 2559 bool DeliveryReport = false;
2560 2560
2561 ReplaceBuffer[0] = 0; 2561 ReplaceBuffer[0] = 0;
2562 ReplaceBuffer[1] = 0; 2562 ReplaceBuffer[1] = 0;
2563 GSM_ClearMultiPartSMSInfo(&SMSInfo); 2563 GSM_ClearMultiPartSMSInfo(&SMSInfo);
2564 SMSInfo.ReplaceMessage = 0; 2564 SMSInfo.ReplaceMessage = 0;
2565 SMSInfo.EntriesNum = 1; 2565 SMSInfo.EntriesNum = 1;
2566 2566
2567 if (mystrncasecmp(argv[1],"--savesms",0)) { 2567 if (mystrncasecmp(argv[1],"--savesms",0)) {
2568 EncodeUnicode(Sender,"Gammu",5); 2568 EncodeUnicode(Sender,"Gammu",5);
2569 Name[0] = 0; 2569 Name[0] = 0;
2570 Name[1] = 0; 2570 Name[1] = 0;
2571 startarg = 0; 2571 startarg = 0;
2572 } else { 2572 } else {
2573 EncodeUnicode(Sender,argv[3],strlen(argv[3])); 2573 EncodeUnicode(Sender,argv[3],strlen(argv[3]));
2574 startarg = 1; 2574 startarg = 1;
2575 Validity.Format = 0; 2575 Validity.Format = 0;
2576 } 2576 }
2577 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) startarg=startarg+2; 2577 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) startarg=startarg+2;
2578 2578
2579 if (mystrncasecmp(argv[2],"TEXT",0)) { 2579 if (mystrncasecmp(argv[2],"TEXT",0)) {
2580 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin); 2580 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin);
2581 if (chars_read == 0) printmsg("Warning: 0 chars read !\n"); 2581 if (chars_read == 0) printmsg("Warning: 0 chars read !\n");
2582 InputBuffer[chars_read] = 0x00; 2582 InputBuffer[chars_read] = 0x00;
2583 InputBuffer[chars_read+1] = 0x00; 2583 InputBuffer[chars_read+1] = 0x00;
2584 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer)); 2584 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer));
2585 SMSInfo.Entries[0].Buffer = Buffer[0]; 2585 SMSInfo.Entries[0].Buffer = Buffer[0];
2586 SMSInfo.Entries[0].ID = SMS_Text; 2586 SMSInfo.Entries[0].ID = SMS_Text;
2587 SMSInfo.UnicodeCoding = false; 2587 SMSInfo.UnicodeCoding = false;
2588 startarg += 3; 2588 startarg += 3;
2589 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { 2589 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
2590 SMSInfo.UnicodeCoding = false; 2590 SMSInfo.UnicodeCoding = false;
2591 SMSInfo.EntriesNum = 1; 2591 SMSInfo.EntriesNum = 1;
2592 Buffer[0][0] = 0x00; 2592 Buffer[0][0] = 0x00;
2593 Buffer[0][1] = 0x00; 2593 Buffer[0][1] = 0x00;
2594 SMSInfo.Entries[0].Buffer = Buffer[0]; 2594 SMSInfo.Entries[0].Buffer = Buffer[0];
2595 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName; 2595 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName;
2596 startarg += 3; 2596 startarg += 3;
2597 } else if (mystrncasecmp(argv[2],"EMS",0)) { 2597 } else if (mystrncasecmp(argv[2],"EMS",0)) {
2598 SMSInfo.UnicodeCoding = false; 2598 SMSInfo.UnicodeCoding = false;
2599 SMSInfo.EntriesNum = 0; 2599 SMSInfo.EntriesNum = 0;
2600 startarg += 3; 2600 startarg += 3;
2601 } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) { 2601 } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) {
2602 if (argc<6+startarg) { 2602 if (argc<6+startarg) {
2603 printmsg("Where is ringtone filename ?\n"); 2603 printmsg("Where is ringtone filename ?\n");
2604 exit(-1); 2604 exit(-1);
2605 } 2605 }
2606 SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong; 2606 SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong;
2607 SMSInfo.Entries[0].MMSIndicator = &MMSInfo; 2607 SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
2608 if (mystrncasecmp(argv[1],"--savesms",0)) { 2608 if (mystrncasecmp(argv[1],"--savesms",0)) {
2609 EncodeUnicode(Sender,"MMS Info",8); 2609 EncodeUnicode(Sender,"MMS Info",8);
2610 } 2610 }
2611 strcpy(MMSInfo.Address,argv[3+startarg]); 2611 strcpy(MMSInfo.Address,argv[3+startarg]);
2612 strcpy(MMSInfo.Title,argv[4+startarg]); 2612 strcpy(MMSInfo.Title,argv[4+startarg]);
2613 strcpy(MMSInfo.Sender,argv[5+startarg]); 2613 strcpy(MMSInfo.Sender,argv[5+startarg]);
2614 startarg += 6; 2614 startarg += 6;
2615 } else if (mystrncasecmp(argv[2],"RINGTONE",0)) { 2615 } else if (mystrncasecmp(argv[2],"RINGTONE",0)) {
2616 if (argc<4+startarg) { 2616 if (argc<4+startarg) {
2617 printmsg("Where is ringtone filename ?\n"); 2617 printmsg("Where is ringtone filename ?\n");
2618 exit(-1); 2618 exit(-1);
2619 } 2619 }
2620 ringtone[0].Format=RING_NOTETONE; 2620 ringtone[0].Format=RING_NOTETONE;
2621 error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]); 2621 error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]);
2622 Print_Error(error); 2622 Print_Error(error);
2623 SMSInfo.Entries[0].ID = SMS_NokiaRingtone; 2623 SMSInfo.Entries[0].ID = SMS_NokiaRingtone;
2624 SMSInfo.Entries[0].Ringtone = &ringtone[0]; 2624 SMSInfo.Entries[0].Ringtone = &ringtone[0];
2625 if (mystrncasecmp(argv[1],"--savesms",0)) { 2625 if (mystrncasecmp(argv[1],"--savesms",0)) {
2626 CopyUnicodeString(Sender, ringtone[0].Name); 2626 CopyUnicodeString(Sender, ringtone[0].Name);
2627 EncodeUnicode(Name,"Ringtone ",9); 2627 EncodeUnicode(Name,"Ringtone ",9);
2628 CopyUnicodeString(Name+9*2, ringtone[0].Name); 2628 CopyUnicodeString(Name+9*2, ringtone[0].Name);
2629 } 2629 }
2630 startarg += 4; 2630 startarg += 4;
2631 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2631 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2632 if (argc<4+startarg) { 2632 if (argc<4+startarg) {
2633 printmsg("Where is logo filename ?\n"); 2633 printmsg("Where is logo filename ?\n");
2634 exit(-1); 2634 exit(-1);
2635 } 2635 }
2636 bitmap[0].Bitmap[0].Type=GSM_OperatorLogo; 2636 bitmap[0].Bitmap[0].Type=GSM_OperatorLogo;
2637 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); 2637 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
2638 Print_Error(error); 2638 Print_Error(error);
2639 strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00"); 2639 strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00");
2640 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo; 2640 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo;
2641 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2641 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2642 if (mystrncasecmp(argv[1],"--savesms",0)) { 2642 if (mystrncasecmp(argv[1],"--savesms",0)) {
2643 EncodeUnicode(Sender, "OpLogo",6); 2643 EncodeUnicode(Sender, "OpLogo",6);
2644 EncodeUnicode(Name,"OpLogo ",7); 2644 EncodeUnicode(Name,"OpLogo ",7);
2645 } 2645 }
2646 startarg += 4; 2646 startarg += 4;
2647 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2647 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2648 if (argc<4+startarg) { 2648 if (argc<4+startarg) {
2649 printmsg("Where is logo filename ?\n"); 2649 printmsg("Where is logo filename ?\n");
2650 exit(-1); 2650 exit(-1);
2651 } 2651 }
2652 bitmap[0].Bitmap[0].Type=GSM_CallerGroupLogo; 2652 bitmap[0].Bitmap[0].Type=GSM_CallerGroupLogo;
2653 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); 2653 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
2654 Print_Error(error); 2654 Print_Error(error);
2655 SMSInfo.Entries[0].ID = SMS_NokiaCallerLogo; 2655 SMSInfo.Entries[0].ID = SMS_NokiaCallerLogo;
2656 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2656 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2657 if (mystrncasecmp(argv[1],"--savesms",0)) { 2657 if (mystrncasecmp(argv[1],"--savesms",0)) {
2658 EncodeUnicode(Sender, "Caller",6); 2658 EncodeUnicode(Sender, "Caller",6);
2659 } 2659 }
2660 startarg += 4; 2660 startarg += 4;
2661 } else if (mystrncasecmp(argv[2],"ANIMATION",0)) { 2661 } else if (mystrncasecmp(argv[2],"ANIMATION",0)) {
2662 SMSInfo.UnicodeCoding = false; 2662 SMSInfo.UnicodeCoding = false;
2663 SMSInfo.EntriesNum = 1; 2663 SMSInfo.EntriesNum = 1;
2664 if (argc<4+startarg) { 2664 if (argc<4+startarg) {
2665 printmsg("Where is number of frames ?\n"); 2665 printmsg("Where is number of frames ?\n");
2666 exit(-1); 2666 exit(-1);
2667 } 2667 }
2668 bitmap[0].Number = 0; 2668 bitmap[0].Number = 0;
2669 i = 1; 2669 i = 1;
2670 while (1) { 2670 while (1) {
2671 bitmap2.Bitmap[0].Type=GSM_StartupLogo; 2671 bitmap2.Bitmap[0].Type=GSM_StartupLogo;
2672 error=GSM_ReadBitmapFile(argv[3+startarg+i],&bitmap2); 2672 error=GSM_ReadBitmapFile(argv[3+startarg+i],&bitmap2);
2673 Print_Error(error); 2673 Print_Error(error);
2674 for (j=0;j<bitmap2.Number;j++) { 2674 for (j=0;j<bitmap2.Number;j++) {
2675 if (bitmap[0].Number == atoi(argv[3+startarg])) break; 2675 if (bitmap[0].Number == atoi(argv[3+startarg])) break;
2676 memcpy(&bitmap[0].Bitmap[bitmap[0].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); 2676 memcpy(&bitmap[0].Bitmap[bitmap[0].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap));
2677 bitmap[0].Number++; 2677 bitmap[0].Number++;
2678 } 2678 }
2679 if (bitmap[0].Number == atoi(argv[3+startarg])) break; 2679 if (bitmap[0].Number == atoi(argv[3+startarg])) break;
2680 i++; 2680 i++;
2681 } 2681 }
2682 SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong; 2682 SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong;
2683 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2683 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2684 bitmap[0].Bitmap[0].Text[0]= 0; 2684 bitmap[0].Bitmap[0].Text[0]= 0;
2685 bitmap[0].Bitmap[0].Text[1]= 0; 2685 bitmap[0].Bitmap[0].Text[1]= 0;
2686 startarg += 4 + atoi(argv[3+startarg]); 2686 startarg += 4 + atoi(argv[3+startarg]);
2687 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2687 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2688 if (argc<4+startarg) { 2688 if (argc<4+startarg) {
2689 printmsg("Where is logo filename ?\n"); 2689 printmsg("Where is logo filename ?\n");
2690 exit(-1); 2690 exit(-1);
2691 } 2691 }
2692 bitmap[0].Bitmap[0].Type=GSM_PictureImage; 2692 bitmap[0].Bitmap[0].Type=GSM_PictureImage;
2693 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); 2693 error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
2694 printmsg("File \"%s\"\n",argv[3+startarg]); 2694 printmsg("File \"%s\"\n",argv[3+startarg]);
2695 Print_Error(error); 2695 Print_Error(error);
2696 SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong; 2696 SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong;
2697 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 2697 SMSInfo.Entries[0].Bitmap = &bitmap[0];
2698 SMSInfo.UnicodeCoding = false; 2698 SMSInfo.UnicodeCoding = false;
2699 bitmap[0].Bitmap[0].Text[0]= 0; 2699 bitmap[0].Bitmap[0].Text[0]= 0;
2700 bitmap[0].Bitmap[0].Text[1]= 0; 2700 bitmap[0].Bitmap[0].Text[1]= 0;
2701 if (mystrncasecmp(argv[1],"--savesms",0)) { 2701 if (mystrncasecmp(argv[1],"--savesms",0)) {
2702 EncodeUnicode(Sender, "Picture",7); 2702 EncodeUnicode(Sender, "Picture",7);
2703 EncodeUnicode(Name,"Picture Image",13); 2703 EncodeUnicode(Name,"Picture Image",13);
2704 } 2704 }
2705 startarg += 4; 2705 startarg += 4;
2706#ifdef GSM_ENABLE_BACKUP 2706#ifdef GSM_ENABLE_BACKUP
2707 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { 2707 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
2708 if (argc<5+startarg) { 2708 if (argc<5+startarg) {
2709 printmsg("Where is backup filename and location ?\n"); 2709 printmsg("Where is backup filename and location ?\n");
2710 exit(-1); 2710 exit(-1);
2711 } 2711 }
2712 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2712 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2713 Print_Error(error); 2713 Print_Error(error);
2714 i = 0; 2714 i = 0;
2715 while (Backup.WAPBookmark[i]!=NULL) { 2715 while (Backup.WAPBookmark[i]!=NULL) {
2716 if (i == atoi(argv[4+startarg])-1) break; 2716 if (i == atoi(argv[4+startarg])-1) break;
2717 i++; 2717 i++;
2718 } 2718 }
2719 if (i != atoi(argv[4+startarg])-1) { 2719 if (i != atoi(argv[4+startarg])-1) {
2720 printmsg("Bookmark not found in file\n"); 2720 printmsg("Bookmark not found in file\n");
2721 exit(-1); 2721 exit(-1);
2722 } 2722 }
2723 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong; 2723 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
2724 SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i]; 2724 SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i];
2725 if (mystrncasecmp(argv[1],"--savesms",0)) { 2725 if (mystrncasecmp(argv[1],"--savesms",0)) {
2726 EncodeUnicode(Sender, "Bookmark",8); 2726 EncodeUnicode(Sender, "Bookmark",8);
2727 EncodeUnicode(Name,"WAP Bookmark",12); 2727 EncodeUnicode(Name,"WAP Bookmark",12);
2728 } 2728 }
2729 startarg += 5; 2729 startarg += 5;
2730 } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) { 2730 } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) {
2731 if (argc<6+startarg) { 2731 if (argc<6+startarg) {
2732 printmsg("Where is backup filename and location ?\n"); 2732 printmsg("Where is backup filename and location ?\n");
2733 exit(-1); 2733 exit(-1);
2734 } 2734 }
2735 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2735 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2736 Print_Error(error); 2736 Print_Error(error);
2737 i = 0; 2737 i = 0;
2738 while (Backup.WAPSettings[i]!=NULL) { 2738 while (Backup.WAPSettings[i]!=NULL) {
2739 if (i == atoi(argv[4+startarg])-1) break; 2739 if (i == atoi(argv[4+startarg])-1) break;
2740 i++; 2740 i++;
2741 } 2741 }
2742 if (i != atoi(argv[4+startarg])-1) { 2742 if (i != atoi(argv[4+startarg])-1) {
2743 printmsg("WAP settings not found in file\n"); 2743 printmsg("WAP settings not found in file\n");
2744 exit(-1); 2744 exit(-1);
2745 } 2745 }
2746 SMSInfo.Entries[0].Settings = NULL; 2746 SMSInfo.Entries[0].Settings = NULL;
2747 for (j=0;j<Backup.WAPSettings[i]->Number;j++) { 2747 for (j=0;j<Backup.WAPSettings[i]->Number;j++) {
2748 switch (Backup.WAPSettings[i]->Settings[j].Bearer) { 2748 switch (Backup.WAPSettings[i]->Settings[j].Bearer) {
2749 case WAPSETTINGS_BEARER_GPRS: 2749 case WAPSETTINGS_BEARER_GPRS:
2750 if (mystrncasecmp(argv[5+startarg],"GPRS",0)) { 2750 if (mystrncasecmp(argv[5+startarg],"GPRS",0)) {
2751 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; 2751 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
2752 break; 2752 break;
2753 } 2753 }
2754 case WAPSETTINGS_BEARER_DATA: 2754 case WAPSETTINGS_BEARER_DATA:
2755 if (mystrncasecmp(argv[5+startarg],"DATA",0)) { 2755 if (mystrncasecmp(argv[5+startarg],"DATA",0)) {
2756 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; 2756 SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
2757 break; 2757 break;
2758 } 2758 }
2759 default: 2759 default:
2760 break; 2760 break;
2761 } 2761 }
2762 } 2762 }
2763 if (SMSInfo.Entries[0].Settings == NULL) { 2763 if (SMSInfo.Entries[0].Settings == NULL) {
2764 printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n"); 2764 printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n");
2765 exit(-1); 2765 exit(-1);
2766 } 2766 }
2767 SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong; 2767 SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong;
2768 if (mystrncasecmp(argv[1],"--savesms",0)) { 2768 if (mystrncasecmp(argv[1],"--savesms",0)) {
2769 EncodeUnicode(Sender, "Settings",8); 2769 EncodeUnicode(Sender, "Settings",8);
2770 EncodeUnicode(Name,"WAP Settings",12); 2770 EncodeUnicode(Name,"WAP Settings",12);
2771 } 2771 }
2772 startarg += 6; 2772 startarg += 6;
2773 } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) { 2773 } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) {
2774 if (argc<5+startarg) { 2774 if (argc<5+startarg) {
2775 printmsg("Where is backup filename and location ?\n"); 2775 printmsg("Where is backup filename and location ?\n");
2776 exit(-1); 2776 exit(-1);
2777 } 2777 }
2778 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2778 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2779 Print_Error(error); 2779 Print_Error(error);
2780 i = 0; 2780 i = 0;
2781 while (Backup.MMSSettings[i]!=NULL) { 2781 while (Backup.MMSSettings[i]!=NULL) {
2782 if (i == atoi(argv[4+startarg])-1) break; 2782 if (i == atoi(argv[4+startarg])-1) break;
2783 i++; 2783 i++;
2784 } 2784 }
2785 if (i != atoi(argv[4+startarg])-1) { 2785 if (i != atoi(argv[4+startarg])-1) {
2786 printmsg("MMS settings not found in file\n"); 2786 printmsg("MMS settings not found in file\n");
2787 exit(-1); 2787 exit(-1);
2788 } 2788 }
2789 SMSInfo.Entries[0].Settings = NULL; 2789 SMSInfo.Entries[0].Settings = NULL;
2790 for (j=0;j<Backup.MMSSettings[i]->Number;j++) { 2790 for (j=0;j<Backup.MMSSettings[i]->Number;j++) {
2791 switch (Backup.MMSSettings[i]->Settings[j].Bearer) { 2791 switch (Backup.MMSSettings[i]->Settings[j].Bearer) {
2792 case WAPSETTINGS_BEARER_GPRS: 2792 case WAPSETTINGS_BEARER_GPRS:
2793 SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j]; 2793 SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j];
2794 break; 2794 break;
2795 default: 2795 default:
2796 break; 2796 break;
2797 } 2797 }
2798 } 2798 }
2799 if (SMSInfo.Entries[0].Settings == NULL) { 2799 if (SMSInfo.Entries[0].Settings == NULL) {
2800 printmsg("Sorry. No GPRS bearer found in MMS settings\n"); 2800 printmsg("Sorry. No GPRS bearer found in MMS settings\n");
2801 exit(-1); 2801 exit(-1);
2802 } 2802 }
2803 SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong; 2803 SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong;
2804 if (mystrncasecmp(argv[1],"--savesms",0)) { 2804 if (mystrncasecmp(argv[1],"--savesms",0)) {
2805 EncodeUnicode(Sender, "Settings",8); 2805 EncodeUnicode(Sender, "Settings",8);
2806 EncodeUnicode(Name,"MMS Settings",12); 2806 EncodeUnicode(Name,"MMS Settings",12);
2807 } 2807 }
2808 startarg += 5; 2808 startarg += 5;
2809 } else if (mystrncasecmp(argv[2],"CALENDAR",0)) { 2809 } else if (mystrncasecmp(argv[2],"CALENDAR",0)) {
2810 if (argc<5+startarg) { 2810 if (argc<5+startarg) {
2811 printmsg("Where is backup filename and location ?\n"); 2811 printmsg("Where is backup filename and location ?\n");
2812 exit(-1); 2812 exit(-1);
2813 } 2813 }
2814 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2814 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2815 Print_Error(error); 2815 Print_Error(error);
2816 i = 0; 2816 i = 0;
2817 while (Backup.Calendar[i]!=NULL) { 2817 while (Backup.Calendar[i]!=NULL) {
2818 if (i == atoi(argv[4+startarg])-1) break; 2818 if (i == atoi(argv[4+startarg])-1) break;
2819 i++; 2819 i++;
2820 } 2820 }
2821 if (i != atoi(argv[4+startarg])-1) { 2821 if (i != atoi(argv[4+startarg])-1) {
2822 printmsg("Calendar note not found in file\n"); 2822 printmsg("Calendar note not found in file\n");
2823 exit(-1); 2823 exit(-1);
2824 } 2824 }
2825 SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long; 2825 SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long;
2826 SMSInfo.Entries[0].Calendar = Backup.Calendar[i]; 2826 SMSInfo.Entries[0].Calendar = Backup.Calendar[i];
2827 if (mystrncasecmp(argv[1],"--savesms",0)) { 2827 if (mystrncasecmp(argv[1],"--savesms",0)) {
2828 EncodeUnicode(Sender, "Calendar",8); 2828 EncodeUnicode(Sender, "Calendar",8);
2829 } 2829 }
2830 startarg += 5; 2830 startarg += 5;
2831 } else if (mystrncasecmp(argv[2],"TODO",0)) { 2831 } else if (mystrncasecmp(argv[2],"TODO",0)) {
2832 if (argc<5+startarg) { 2832 if (argc<5+startarg) {
2833 printmsg("Where is backup filename and location ?\n"); 2833 printmsg("Where is backup filename and location ?\n");
2834 exit(-1); 2834 exit(-1);
2835 } 2835 }
2836 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2836 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2837 Print_Error(error); 2837 Print_Error(error);
2838 i = 0; 2838 i = 0;
2839 while (Backup.ToDo[i]!=NULL) { 2839 while (Backup.ToDo[i]!=NULL) {
2840 if (i == atoi(argv[4+startarg])-1) break; 2840 if (i == atoi(argv[4+startarg])-1) break;
2841 i++; 2841 i++;
2842 } 2842 }
2843 if (i != atoi(argv[4+startarg])-1) { 2843 if (i != atoi(argv[4+startarg])-1) {
2844 printmsg("ToDo note not found in file\n"); 2844 printmsg("ToDo note not found in file\n");
2845 exit(-1); 2845 exit(-1);
2846 } 2846 }
2847 SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong; 2847 SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong;
2848 SMSInfo.Entries[0].ToDo = Backup.ToDo[i]; 2848 SMSInfo.Entries[0].ToDo = Backup.ToDo[i];
2849 if (mystrncasecmp(argv[1],"--savesms",0)) { 2849 if (mystrncasecmp(argv[1],"--savesms",0)) {
2850 EncodeUnicode(Sender, "ToDo",8); 2850 EncodeUnicode(Sender, "ToDo",8);
2851 } 2851 }
2852 startarg += 5; 2852 startarg += 5;
2853 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { 2853 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
2854 if (argc<6+startarg) { 2854 if (argc<6+startarg) {
2855 printmsg("Where is backup filename and location and memory type ?\n"); 2855 printmsg("Where is backup filename and location and memory type ?\n");
2856 exit(-1); 2856 exit(-1);
2857 } 2857 }
2858 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2858 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2859 Print_Error(error); 2859 Print_Error(error);
2860 i = 0; 2860 i = 0;
2861 if (mystrncasecmp(argv[4+startarg],"SM",0)) { 2861 if (mystrncasecmp(argv[4+startarg],"SM",0)) {
2862 while (Backup.SIMPhonebook[i]!=NULL) { 2862 while (Backup.SIMPhonebook[i]!=NULL) {
2863 if (i == atoi(argv[5+startarg])-1) break; 2863 if (i == atoi(argv[5+startarg])-1) break;
2864 i++; 2864 i++;
2865 } 2865 }
2866 if (i != atoi(argv[5+startarg])-1) { 2866 if (i != atoi(argv[5+startarg])-1) {
2867 printmsg("Phonebook entry not found in file\n"); 2867 printmsg("Phonebook entry not found in file\n");
2868 exit(-1); 2868 exit(-1);
2869 } 2869 }
2870 SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i]; 2870 SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i];
2871 } else if (mystrncasecmp(argv[4+startarg],"ME",0)) { 2871 } else if (mystrncasecmp(argv[4+startarg],"ME",0)) {
2872 while (Backup.PhonePhonebook[i]!=NULL) { 2872 while (Backup.PhonePhonebook[i]!=NULL) {
2873 if (i == atoi(argv[5+startarg])-1) break; 2873 if (i == atoi(argv[5+startarg])-1) break;
2874 i++; 2874 i++;
2875 } 2875 }
2876 if (i != atoi(argv[5+startarg])-1) { 2876 if (i != atoi(argv[5+startarg])-1) {
2877 printmsg("Phonebook entry not found in file\n"); 2877 printmsg("Phonebook entry not found in file\n");
2878 exit(-1); 2878 exit(-1);
2879 } 2879 }
2880 SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i]; 2880 SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i];
2881 } else { 2881 } else {
2882 printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]); 2882 printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]);
2883 exit(-1); 2883 exit(-1);
2884 } 2884 }
2885 if (mystrncasecmp(argv[2],"VCARD10",0)) { 2885 if (mystrncasecmp(argv[2],"VCARD10",0)) {
2886 SMSInfo.Entries[0].ID = SMS_VCARD10Long; 2886 SMSInfo.Entries[0].ID = SMS_VCARD10Long;
2887 } else { 2887 } else {
2888 SMSInfo.Entries[0].ID = SMS_VCARD21Long; 2888 SMSInfo.Entries[0].ID = SMS_VCARD21Long;
2889 } 2889 }
2890 if (mystrncasecmp(argv[1],"--savesms",0)) { 2890 if (mystrncasecmp(argv[1],"--savesms",0)) {
2891 EncodeUnicode(Sender, "VCARD",5); 2891 EncodeUnicode(Sender, "VCARD",5);
2892 EncodeUnicode(Name, "Phonebook entry",15); 2892 EncodeUnicode(Name, "Phonebook entry",15);
2893 } 2893 }
2894 startarg += 6; 2894 startarg += 6;
2895#endif 2895#endif
2896 } else if (mystrncasecmp(argv[2],"PROFILE",0)) { 2896 } else if (mystrncasecmp(argv[2],"PROFILE",0)) {
2897 SMSInfo.Entries[0].ID = SMS_NokiaProfileLong; 2897 SMSInfo.Entries[0].ID = SMS_NokiaProfileLong;
2898 if (mystrncasecmp(argv[1],"--savesms",0)) { 2898 if (mystrncasecmp(argv[1],"--savesms",0)) {
2899 EncodeUnicode(Sender, "Profile",7); 2899 EncodeUnicode(Sender, "Profile",7);
2900 } 2900 }
2901 startarg += 3; 2901 startarg += 3;
2902 } else { 2902 } else {
2903 printmsg("What format of sms (\"%s\") ?\n",argv[2]); 2903 printmsg("What format of sms (\"%s\") ?\n",argv[2]);
2904 exit(-1); 2904 exit(-1);
2905 } 2905 }
2906 2906
2907 for (i=startarg;i<argc;i++) { 2907 for (i=startarg;i<argc;i++) {
2908 switch (nextlong) { 2908 switch (nextlong) {
2909 case 0: 2909 case 0:
2910 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { 2910 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) {
2911 if (mystrncasecmp(argv[i],"-folder",0)) { 2911 if (mystrncasecmp(argv[i],"-folder",0)) {
2912 nextlong=1; 2912 nextlong=1;
2913 continue; 2913 continue;
2914 } 2914 }
2915 } 2915 }
2916 if (mystrncasecmp(argv[1],"--savesms",0)) { 2916 if (mystrncasecmp(argv[1],"--savesms",0)) {
2917 if (mystrncasecmp(argv[i],"-unread",0)) { 2917 if (mystrncasecmp(argv[i],"-unread",0)) {
2918 State = SMS_UnRead; 2918 State = SMS_UnRead;
2919 continue; 2919 continue;
2920 } 2920 }
2921 if (mystrncasecmp(argv[i],"-read",0)) { 2921 if (mystrncasecmp(argv[i],"-read",0)) {
2922 State = SMS_Read; 2922 State = SMS_Read;
2923 continue; 2923 continue;
2924 } 2924 }
2925 if (mystrncasecmp(argv[i],"-unsent",0)) { 2925 if (mystrncasecmp(argv[i],"-unsent",0)) {
2926 State = SMS_UnSent; 2926 State = SMS_UnSent;
2927 continue; 2927 continue;
2928 } 2928 }
2929 if (mystrncasecmp(argv[i],"-sent",0)) { 2929 if (mystrncasecmp(argv[i],"-sent",0)) {
2930 State = SMS_Sent; 2930 State = SMS_Sent;
2931 continue; 2931 continue;
2932 } 2932 }
2933 if (mystrncasecmp(argv[i],"-sender",0)) { 2933 if (mystrncasecmp(argv[i],"-sender",0)) {
2934 nextlong=2; 2934 nextlong=2;
2935 continue; 2935 continue;
2936 } 2936 }
2937 } else { 2937 } else {
2938 if (mystrncasecmp(argv[i],"-save",0)) { 2938 if (mystrncasecmp(argv[i],"-save",0)) {
2939 SendSaved=true; 2939 SendSaved=true;
2940 continue; 2940 continue;
2941 } 2941 }
2942 if (mystrncasecmp(argv[i],"-report",0)) { 2942 if (mystrncasecmp(argv[i],"-report",0)) {
2943 DeliveryReport=true; 2943 DeliveryReport=true;
2944 continue; 2944 continue;
2945 } 2945 }
2946 if (mystrncasecmp(argv[i],"-validity",0)) { 2946 if (mystrncasecmp(argv[i],"-validity",0)) {
2947 nextlong=10; 2947 nextlong=10;
2948 continue; 2948 continue;
2949 } 2949 }
2950 } 2950 }
2951 if (mystrncasecmp(argv[i],"-smscset",0)) { 2951 if (mystrncasecmp(argv[i],"-smscset",0)) {
2952 nextlong=3; 2952 nextlong=3;
2953 continue; 2953 continue;
2954 } 2954 }
2955 if (mystrncasecmp(argv[i],"-smscnumber",0)) { 2955 if (mystrncasecmp(argv[i],"-smscnumber",0)) {
2956 nextlong=4; 2956 nextlong=4;
2957 continue; 2957 continue;
2958 } 2958 }
2959 if (mystrncasecmp(argv[i],"-protected",0)) { 2959 if (mystrncasecmp(argv[i],"-protected",0)) {
2960 nextlong=19; 2960 nextlong=19;
2961 continue; 2961 continue;
2962 } 2962 }
2963 if (mystrncasecmp(argv[i],"-reply",0)) { 2963 if (mystrncasecmp(argv[i],"-reply",0)) {
2964 ReplyViaSameSMSC=true; 2964 ReplyViaSameSMSC=true;
2965 continue; 2965 continue;
2966 } 2966 }
2967 if (mystrncasecmp(argv[i],"-maxsms",0)) { 2967 if (mystrncasecmp(argv[i],"-maxsms",0)) {
2968 nextlong=21; 2968 nextlong=21;
2969 continue; 2969 continue;
2970 } 2970 }
2971 if (mystrncasecmp(argv[2],"RINGTONE",0)) { 2971 if (mystrncasecmp(argv[2],"RINGTONE",0)) {
2972 if (mystrncasecmp(argv[i],"-long",0)) { 2972 if (mystrncasecmp(argv[i],"-long",0)) {
2973 SMSInfo.Entries[0].ID = SMS_NokiaRingtoneLong; 2973 SMSInfo.Entries[0].ID = SMS_NokiaRingtoneLong;
2974 break; 2974 break;
2975 } 2975 }
2976 if (mystrncasecmp(argv[i],"-scale",0)) { 2976 if (mystrncasecmp(argv[i],"-scale",0)) {
2977 ringtone[0].NoteTone.AllNotesScale=true; 2977 ringtone[0].NoteTone.AllNotesScale=true;
2978 break; 2978 break;
2979 } 2979 }
2980 } 2980 }
2981 if (mystrncasecmp(argv[2],"TEXT",0)) { 2981 if (mystrncasecmp(argv[2],"TEXT",0)) {
2982 if (mystrncasecmp(argv[i],"-inputunicode",0)) { 2982 if (mystrncasecmp(argv[i],"-inputunicode",0)) {
2983 ReadUnicodeFile(Buffer[0],InputBuffer); 2983 ReadUnicodeFile(Buffer[0],InputBuffer);
2984 break; 2984 break;
2985 } 2985 }
2986 if (mystrncasecmp(argv[i],"-16bit",0)) { 2986 if (mystrncasecmp(argv[i],"-16bit",0)) {
2987 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong16bit; 2987 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong16bit;
2988 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedAutoTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong16bit; 2988 if (SMSInfo.Entries[0].ID == SMS_ConcatenatedAutoTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong16bit;
2989 break; 2989 break;
2990 } 2990 }
2991 if (mystrncasecmp(argv[i],"-flash",0)) { 2991 if (mystrncasecmp(argv[i],"-flash",0)) {
2992 SMSInfo.Class = 0; 2992 SMSInfo.Class = 0;
2993 break; 2993 break;
2994 } 2994 }
2995 if (mystrncasecmp(argv[i],"-len",0)) { 2995 if (mystrncasecmp(argv[i],"-len",0)) {
2996 nextlong = 5; 2996 nextlong = 5;
2997 break; 2997 break;
2998 } 2998 }
2999 if (mystrncasecmp(argv[i],"-autolen",0)) { 2999 if (mystrncasecmp(argv[i],"-autolen",0)) {
3000 nextlong = 5; 3000 nextlong = 5;
3001 break; 3001 break;
3002 } 3002 }
3003 if (mystrncasecmp(argv[i],"-unicode",0)) { 3003 if (mystrncasecmp(argv[i],"-unicode",0)) {
3004 SMSInfo.UnicodeCoding = true; 3004 SMSInfo.UnicodeCoding = true;
3005 break; 3005 break;
3006 } 3006 }
3007 if (mystrncasecmp(argv[i],"-enablevoice",0)) { 3007 if (mystrncasecmp(argv[i],"-enablevoice",0)) {
3008 SMSInfo.Entries[0].ID = SMS_EnableVoice; 3008 SMSInfo.Entries[0].ID = SMS_EnableVoice;
3009 break; 3009 break;
3010 } 3010 }
3011 if (mystrncasecmp(argv[i],"-disablevoice",0)) { 3011 if (mystrncasecmp(argv[i],"-disablevoice",0)) {
3012 SMSInfo.Entries[0].ID = SMS_DisableVoice; 3012 SMSInfo.Entries[0].ID = SMS_DisableVoice;
3013 break; 3013 break;
3014 } 3014 }
3015 if (mystrncasecmp(argv[i],"-enablefax",0)) { 3015 if (mystrncasecmp(argv[i],"-enablefax",0)) {
3016 SMSInfo.Entries[0].ID = SMS_EnableFax; 3016 SMSInfo.Entries[0].ID = SMS_EnableFax;
3017 break; 3017 break;
3018 } 3018 }
3019 if (mystrncasecmp(argv[i],"-disablefax",0)) { 3019 if (mystrncasecmp(argv[i],"-disablefax",0)) {
3020 SMSInfo.Entries[0].ID = SMS_DisableFax; 3020 SMSInfo.Entries[0].ID = SMS_DisableFax;
3021 break; 3021 break;
3022 } 3022 }
3023 if (mystrncasecmp(argv[i],"-enableemail",0)) { 3023 if (mystrncasecmp(argv[i],"-enableemail",0)) {
3024 SMSInfo.Entries[0].ID = SMS_EnableEmail; 3024 SMSInfo.Entries[0].ID = SMS_EnableEmail;
3025 break; 3025 break;
3026 } 3026 }
3027 if (mystrncasecmp(argv[i],"-disableemail",0)) { 3027 if (mystrncasecmp(argv[i],"-disableemail",0)) {
3028 SMSInfo.Entries[0].ID = SMS_DisableEmail; 3028 SMSInfo.Entries[0].ID = SMS_DisableEmail;
3029 break; 3029 break;
3030 } 3030 }
3031 if (mystrncasecmp(argv[i],"-voidsms",0)) { 3031 if (mystrncasecmp(argv[i],"-voidsms",0)) {
3032 SMSInfo.Entries[0].ID = SMS_VoidSMS; 3032 SMSInfo.Entries[0].ID = SMS_VoidSMS;
3033 break; 3033 break;
3034 } 3034 }
3035 if (mystrncasecmp(argv[i],"-replacemessages",0) && 3035 if (mystrncasecmp(argv[i],"-replacemessages",0) &&
3036 SMSInfo.Entries[0].ID != SMS_ConcatenatedTextLong) { 3036 SMSInfo.Entries[0].ID != SMS_ConcatenatedTextLong) {
3037 nextlong = 8; 3037 nextlong = 8;
3038 break; 3038 break;
3039 } 3039 }
3040 if (mystrncasecmp(argv[i],"-replacefile",0)) { 3040 if (mystrncasecmp(argv[i],"-replacefile",0)) {
3041 nextlong = 9; 3041 nextlong = 9;
3042 continue; 3042 continue;
3043 } 3043 }
3044 } 3044 }
3045 if (mystrncasecmp(argv[2],"PICTURE",0)) { 3045 if (mystrncasecmp(argv[2],"PICTURE",0)) {
3046 if (mystrncasecmp(argv[i],"-text",0)) { 3046 if (mystrncasecmp(argv[i],"-text",0)) {
3047 nextlong = 6; 3047 nextlong = 6;
3048 break; 3048 break;
3049 } 3049 }
3050 if (mystrncasecmp(argv[i],"-unicode",0)) { 3050 if (mystrncasecmp(argv[i],"-unicode",0)) {
3051 SMSInfo.UnicodeCoding = true; 3051 SMSInfo.UnicodeCoding = true;
3052 break; 3052 break;
3053 } 3053 }
3054 if (mystrncasecmp(argv[i],"-alcatelbmmi",0)) { 3054 if (mystrncasecmp(argv[i],"-alcatelbmmi",0)) {
3055 bitmap[0].Bitmap[0].Type=GSM_StartupLogo; 3055 bitmap[0].Bitmap[0].Type=GSM_StartupLogo;
3056 error=GSM_ReadBitmapFile(argv[startarg-1],&bitmap[0]); 3056 error=GSM_ReadBitmapFile(argv[startarg-1],&bitmap[0]);
3057 Print_Error(error); 3057 Print_Error(error);
3058 SMSInfo.UnicodeCoding = true; 3058 SMSInfo.UnicodeCoding = true;
3059 SMSInfo.Entries[0].ID = SMS_AlcatelMonoBitmapLong; 3059 SMSInfo.Entries[0].ID = SMS_AlcatelMonoBitmapLong;
3060 break; 3060 break;
3061 } 3061 }
3062 break; 3062 break;
3063 } 3063 }
3064 if (mystrncasecmp(argv[2],"VCARD10",0)) { 3064 if (mystrncasecmp(argv[2],"VCARD10",0)) {
3065 if (mystrncasecmp(argv[i],"-nokia",0)) { 3065 if (mystrncasecmp(argv[i],"-nokia",0)) {
3066 SMSInfo.Entries[0].ID = SMS_NokiaVCARD10Long; 3066 SMSInfo.Entries[0].ID = SMS_NokiaVCARD10Long;
3067 break; 3067 break;
3068 } 3068 }
3069 break; 3069 break;
3070 } 3070 }
3071 if (mystrncasecmp(argv[2],"VCARD21",0)) { 3071 if (mystrncasecmp(argv[2],"VCARD21",0)) {
3072 if (mystrncasecmp(argv[i],"-nokia",0)) { 3072 if (mystrncasecmp(argv[i],"-nokia",0)) {
3073 SMSInfo.Entries[0].ID = SMS_NokiaVCARD21Long; 3073 SMSInfo.Entries[0].ID = SMS_NokiaVCARD21Long;
3074 break; 3074 break;
3075 } 3075 }
3076 break; 3076 break;
3077 } 3077 }
3078 if (mystrncasecmp(argv[2],"PROFILE",0)) { 3078 if (mystrncasecmp(argv[2],"PROFILE",0)) {
3079 if (mystrncasecmp(argv[i],"-name",0)) { 3079 if (mystrncasecmp(argv[i],"-name",0)) {
3080 nextlong = 22; 3080 nextlong = 22;
3081 break; 3081 break;
3082 } 3082 }
3083 if (mystrncasecmp(argv[i],"-ringtone",0)) { 3083 if (mystrncasecmp(argv[i],"-ringtone",0)) {
3084 nextlong = 23; 3084 nextlong = 23;
3085 break; 3085 break;
3086 } 3086 }
3087 if (mystrncasecmp(argv[i],"-bitmap",0)) { 3087 if (mystrncasecmp(argv[i],"-bitmap",0)) {
3088 nextlong = 24; 3088 nextlong = 24;
3089 break; 3089 break;
3090 } 3090 }
3091 } 3091 }
3092 if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { 3092 if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
3093 if (mystrncasecmp(argv[i],"-unicode",0)) { 3093 if (mystrncasecmp(argv[i],"-unicode",0)) {
3094 SMSInfo.UnicodeCoding = true; 3094 SMSInfo.UnicodeCoding = true;
3095 break; 3095 break;
3096 } 3096 }
3097 if (mystrncasecmp(argv[i],"-text",0)) { 3097 if (mystrncasecmp(argv[i],"-text",0)) {
3098 nextlong = 11; 3098 nextlong = 11;
3099 break; 3099 break;
3100 } 3100 }
3101 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { 3101 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) {
3102 nextlong = 18; 3102 nextlong = 18;
3103 break; 3103 break;
3104 } 3104 }
3105 if (mystrncasecmp(argv[i],"-defsound",0)) { 3105 if (mystrncasecmp(argv[i],"-defsound",0)) {
3106 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; 3106 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound;
3107 nextlong = 12; 3107 nextlong = 12;
3108 break; 3108 break;
3109 } 3109 }
3110 if (mystrncasecmp(argv[i],"-defanimation",0)) { 3110 if (mystrncasecmp(argv[i],"-defanimation",0)) {
3111 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; 3111 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation;
3112 nextlong = 12; 3112 nextlong = 12;
3113 break; 3113 break;
3114 } 3114 }
3115 if (mystrncasecmp(argv[i],"-tone10",0)) { 3115 if (mystrncasecmp(argv[i],"-tone10",0)) {
3116 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; 3116 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10;
3117 if (Protected != 0) { 3117 if (Protected != 0) {
3118 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3118 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3119 Protected --; 3119 Protected --;
3120 } 3120 }
3121 nextlong = 14; 3121 nextlong = 14;
3122 break; 3122 break;
3123 } 3123 }
3124 if (mystrncasecmp(argv[i],"-tone10long",0)) { 3124 if (mystrncasecmp(argv[i],"-tone10long",0)) {
3125 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; 3125 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long;
3126 if (Protected != 0) { 3126 if (Protected != 0) {
3127 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3127 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3128 Protected --; 3128 Protected --;
3129 } 3129 }
3130 nextlong = 14; 3130 nextlong = 14;
3131 break; 3131 break;
3132 } 3132 }
3133 if (mystrncasecmp(argv[i],"-tone12",0)) { 3133 if (mystrncasecmp(argv[i],"-tone12",0)) {
3134 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; 3134 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12;
3135 if (Protected != 0) { 3135 if (Protected != 0) {
3136 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3136 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3137 Protected --; 3137 Protected --;
3138 } 3138 }
3139 nextlong = 14; 3139 nextlong = 14;
3140 break; 3140 break;
3141 } 3141 }
3142 if (mystrncasecmp(argv[i],"-tone12long",0)) { 3142 if (mystrncasecmp(argv[i],"-tone12long",0)) {
3143 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; 3143 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long;
3144 if (Protected != 0) { 3144 if (Protected != 0) {
3145 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3145 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3146 Protected --; 3146 Protected --;
3147 } 3147 }
3148 nextlong = 14; 3148 nextlong = 14;
3149 break; 3149 break;
3150 } 3150 }
3151 if (mystrncasecmp(argv[i],"-toneSE",0)) { 3151 if (mystrncasecmp(argv[i],"-toneSE",0)) {
3152 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; 3152 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound;
3153 if (Protected != 0) { 3153 if (Protected != 0) {
3154 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3154 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3155 Protected --; 3155 Protected --;
3156 } 3156 }
3157 nextlong = 14; 3157 nextlong = 14;
3158 break; 3158 break;
3159 } 3159 }
3160 if (mystrncasecmp(argv[i],"-toneSElong",0)) { 3160 if (mystrncasecmp(argv[i],"-toneSElong",0)) {
3161 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; 3161 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong;
3162 if (Protected != 0) { 3162 if (Protected != 0) {
3163 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3163 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3164 Protected --; 3164 Protected --;
3165 } 3165 }
3166 nextlong = 14; 3166 nextlong = 14;
3167 break; 3167 break;
3168 } 3168 }
3169 if (mystrncasecmp(argv[i],"-variablebitmap",0)) { 3169 if (mystrncasecmp(argv[i],"-variablebitmap",0)) {
3170 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; 3170 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap;
3171 if (Protected != 0) { 3171 if (Protected != 0) {
3172 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3172 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3173 Protected --; 3173 Protected --;
3174 } 3174 }
3175 nextlong = 15; 3175 nextlong = 15;
3176 break; 3176 break;
3177 } 3177 }
3178 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { 3178 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) {
3179 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; 3179 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong;
3180 if (Protected != 0) { 3180 if (Protected != 0) {
3181 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3181 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3182 Protected --; 3182 Protected --;
3183 } 3183 }
3184 nextlong = 15; 3184 nextlong = 15;
3185 break; 3185 break;
3186 } 3186 }
3187 if (mystrncasecmp(argv[i],"-animation",0)) { 3187 if (mystrncasecmp(argv[i],"-animation",0)) {
3188 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; 3188 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation;
3189 if (Protected != 0) { 3189 if (Protected != 0) {
3190 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3190 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3191 Protected --; 3191 Protected --;
3192 } 3192 }
3193 bitmap[SMSInfo.EntriesNum].Number = 0; 3193 bitmap[SMSInfo.EntriesNum].Number = 0;
3194 nextlong = 16; 3194 nextlong = 16;
3195 break; 3195 break;
3196 } 3196 }
3197 } 3197 }
3198 if (mystrncasecmp(argv[2],"EMS",0)) { 3198 if (mystrncasecmp(argv[2],"EMS",0)) {
3199 if (mystrncasecmp(argv[i],"-unicode",0)) { 3199 if (mystrncasecmp(argv[i],"-unicode",0)) {
3200 SMSInfo.UnicodeCoding = true; 3200 SMSInfo.UnicodeCoding = true;
3201 break; 3201 break;
3202 } 3202 }
3203 if (mystrncasecmp(argv[i],"-16bit",0)) { 3203 if (mystrncasecmp(argv[i],"-16bit",0)) {
3204 EMS16Bit = true; 3204 EMS16Bit = true;
3205 break; 3205 break;
3206 } 3206 }
3207 if (mystrncasecmp(argv[i],"-format",0)) { 3207 if (mystrncasecmp(argv[i],"-format",0)) {
3208 nextlong = 20; 3208 nextlong = 20;
3209 break; 3209 break;
3210 } 3210 }
3211 if (mystrncasecmp(argv[i],"-text",0)) { 3211 if (mystrncasecmp(argv[i],"-text",0)) {
3212 nextlong = 11; 3212 nextlong = 11;
3213 break; 3213 break;
3214 } 3214 }
3215 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { 3215 if (mystrncasecmp(argv[i],"-unicodefiletext",0)) {
3216 nextlong = 18; 3216 nextlong = 18;
3217 break; 3217 break;
3218 } 3218 }
3219 if (mystrncasecmp(argv[i],"-defsound",0)) { 3219 if (mystrncasecmp(argv[i],"-defsound",0)) {
3220 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; 3220 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound;
3221 nextlong = 12; 3221 nextlong = 12;
3222 break; 3222 break;
3223 } 3223 }
3224 if (mystrncasecmp(argv[i],"-defanimation",0)) { 3224 if (mystrncasecmp(argv[i],"-defanimation",0)) {
3225 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; 3225 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation;
3226 nextlong = 12; 3226 nextlong = 12;
3227 break; 3227 break;
3228 } 3228 }
3229 if (mystrncasecmp(argv[i],"-tone10",0)) { 3229 if (mystrncasecmp(argv[i],"-tone10",0)) {
3230 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; 3230 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10;
3231 if (Protected != 0) { 3231 if (Protected != 0) {
3232 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3232 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3233 Protected --; 3233 Protected --;
3234 } 3234 }
3235 nextlong = 14; 3235 nextlong = 14;
3236 break; 3236 break;
3237 } 3237 }
3238 if (mystrncasecmp(argv[i],"-tone10long",0)) { 3238 if (mystrncasecmp(argv[i],"-tone10long",0)) {
3239 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; 3239 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long;
3240 if (Protected != 0) { 3240 if (Protected != 0) {
3241 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3241 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3242 Protected --; 3242 Protected --;
3243 } 3243 }
3244 nextlong = 14; 3244 nextlong = 14;
3245 break; 3245 break;
3246 } 3246 }
3247 if (mystrncasecmp(argv[i],"-tone12",0)) { 3247 if (mystrncasecmp(argv[i],"-tone12",0)) {
3248 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; 3248 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12;
3249 if (Protected != 0) { 3249 if (Protected != 0) {
3250 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3250 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3251 Protected --; 3251 Protected --;
3252 } 3252 }
3253 nextlong = 14; 3253 nextlong = 14;
3254 break; 3254 break;
3255 } 3255 }
3256 if (mystrncasecmp(argv[i],"-tone12long",0)) { 3256 if (mystrncasecmp(argv[i],"-tone12long",0)) {
3257 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; 3257 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long;
3258 if (Protected != 0) { 3258 if (Protected != 0) {
3259 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3259 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3260 Protected --; 3260 Protected --;
3261 } 3261 }
3262 nextlong = 14; 3262 nextlong = 14;
3263 break; 3263 break;
3264 } 3264 }
3265 if (mystrncasecmp(argv[i],"-toneSE",0)) { 3265 if (mystrncasecmp(argv[i],"-toneSE",0)) {
3266 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; 3266 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound;
3267 if (Protected != 0) { 3267 if (Protected != 0) {
3268 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3268 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3269 Protected --; 3269 Protected --;
3270 } 3270 }
3271 nextlong = 14; 3271 nextlong = 14;
3272 break; 3272 break;
3273 } 3273 }
3274 if (mystrncasecmp(argv[i],"-toneSElong",0)) { 3274 if (mystrncasecmp(argv[i],"-toneSElong",0)) {
3275 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; 3275 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong;
3276 if (Protected != 0) { 3276 if (Protected != 0) {
3277 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3277 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3278 Protected --; 3278 Protected --;
3279 } 3279 }
3280 nextlong = 14; 3280 nextlong = 14;
3281 break; 3281 break;
3282 } 3282 }
3283 if (mystrncasecmp(argv[i],"-fixedbitmap",0)) { 3283 if (mystrncasecmp(argv[i],"-fixedbitmap",0)) {
3284 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSFixedBitmap; 3284 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSFixedBitmap;
3285 if (Protected != 0) { 3285 if (Protected != 0) {
3286 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3286 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3287 Protected --; 3287 Protected --;
3288 } 3288 }
3289 nextlong = 15; 3289 nextlong = 15;
3290 break; 3290 break;
3291 } 3291 }
3292 if (mystrncasecmp(argv[i],"-variablebitmap",0)) { 3292 if (mystrncasecmp(argv[i],"-variablebitmap",0)) {
3293 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; 3293 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap;
3294 if (Protected != 0) { 3294 if (Protected != 0) {
3295 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3295 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3296 Protected --; 3296 Protected --;
3297 } 3297 }
3298 nextlong = 15; 3298 nextlong = 15;
3299 break; 3299 break;
3300 } 3300 }
3301 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { 3301 if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) {
3302 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; 3302 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong;
3303 if (Protected != 0) { 3303 if (Protected != 0) {
3304 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3304 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3305 Protected --; 3305 Protected --;
3306 } 3306 }
3307 nextlong = 15; 3307 nextlong = 15;
3308 break; 3308 break;
3309 } 3309 }
3310 if (mystrncasecmp(argv[i],"-animation",0)) { 3310 if (mystrncasecmp(argv[i],"-animation",0)) {
3311 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; 3311 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation;
3312 if (Protected != 0) { 3312 if (Protected != 0) {
3313 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; 3313 SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
3314 Protected --; 3314 Protected --;
3315 } 3315 }
3316 bitmap[SMSInfo.EntriesNum].Number = 0; 3316 bitmap[SMSInfo.EntriesNum].Number = 0;
3317 nextlong = 16; 3317 nextlong = 16;
3318 break; 3318 break;
3319 } 3319 }
3320 } 3320 }
3321 if (mystrncasecmp(argv[2],"OPERATOR",0)) { 3321 if (mystrncasecmp(argv[2],"OPERATOR",0)) {
3322 if (mystrncasecmp(argv[i],"-netcode",0)) { 3322 if (mystrncasecmp(argv[i],"-netcode",0)) {
3323 nextlong = 7; 3323 nextlong = 7;
3324 break; 3324 break;
3325 } 3325 }
3326 if (mystrncasecmp(argv[i],"-biglogo",0)) { 3326 if (mystrncasecmp(argv[i],"-biglogo",0)) {
3327 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogoLong; 3327 SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogoLong;
3328 break; 3328 break;
3329 } 3329 }
3330 break; 3330 break;
3331 } 3331 }
3332 printmsg("Unknown parameter (\"%s\")\n",argv[i]); 3332 printmsg("Unknown parameter (\"%s\")\n",argv[i]);
3333 exit(-1); 3333 exit(-1);
3334 break; 3334 break;
3335 case 1: /* SMS folder - only during saving SMS */ 3335 case 1: /* SMS folder - only during saving SMS */
3336 Folder = atoi(argv[i]); 3336 Folder = atoi(argv[i]);
3337 nextlong = 0; 3337 nextlong = 0;
3338 break; 3338 break;
3339 case 2: /* Sender number - only during saving SMS */ 3339 case 2: /* Sender number - only during saving SMS */
3340 EncodeUnicode(Sender,argv[i],strlen(argv[i])); 3340 EncodeUnicode(Sender,argv[i],strlen(argv[i]));
3341 nextlong = 0; 3341 nextlong = 0;
3342 break; 3342 break;
3343 case 3: /* SMSC set number */ 3343 case 3: /* SMSC set number */
3344 SMSCSet = atoi(argv[i]); 3344 SMSCSet = atoi(argv[i]);
3345 nextlong = 0; 3345 nextlong = 0;
3346 break; 3346 break;
3347 case 4: /* Number of SMSC */ 3347 case 4: /* Number of SMSC */
3348 EncodeUnicode(SMSC,argv[i],strlen(argv[i])); 3348 EncodeUnicode(SMSC,argv[i],strlen(argv[i]));
3349 SMSCSet = 0; 3349 SMSCSet = 0;
3350 nextlong= 0; 3350 nextlong= 0;
3351 break; 3351 break;
3352 case 5: /* Length of text SMS */ 3352 case 5: /* Length of text SMS */
3353 if (atoi(argv[i])<chars_read) 3353 if (atoi(argv[i])<chars_read)
3354 { 3354 {
3355 Buffer[0][atoi(argv[i])*2]= 0x00; 3355 Buffer[0][atoi(argv[i])*2]= 0x00;
3356 Buffer[0][atoi(argv[i])*2+1]= 0x00; 3356 Buffer[0][atoi(argv[i])*2+1]= 0x00;
3357 } 3357 }
3358 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; 3358 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
3359 if (mystrncasecmp(argv[i-1],"-autolen",0)) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong; 3359 if (mystrncasecmp(argv[i-1],"-autolen",0)) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong;
3360 nextlong = 0; 3360 nextlong = 0;
3361 break; 3361 break;
3362 case 6:/* Picture Images - text */ 3362 case 6:/* Picture Images - text */
3363 EncodeUnicode(bitmap[0].Bitmap[0].Text,argv[i],strlen(argv[i])); 3363 EncodeUnicode(bitmap[0].Bitmap[0].Text,argv[i],strlen(argv[i]));
3364 nextlong = 0; 3364 nextlong = 0;
3365 break; 3365 break;
3366 case 7:/* Operator Logo - network code */ 3366 case 7:/* Operator Logo - network code */
3367 strncpy(bitmap[0].Bitmap[0].NetworkCode,argv[i],7); 3367 strncpy(bitmap[0].Bitmap[0].NetworkCode,argv[i],7);
3368 if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)),"unknown")) { 3368 if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)),"unknown")) {
3369 printmsg("Unknown GSM network code (\"%s\")\n",argv[i]); 3369 printmsg("Unknown GSM network code (\"%s\")\n",argv[i]);
3370 exit(-1); 3370 exit(-1);
3371 } 3371 }
3372 if (mystrncasecmp(argv[1],"--savesms",0)) { 3372 if (mystrncasecmp(argv[1],"--savesms",0)) {
3373 EncodeUnicode(Sender, "OpLogo",6); 3373 EncodeUnicode(Sender, "OpLogo",6);
3374 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); 3374 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3);
3375 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); 3375 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2);
3376 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { 3376 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) {
3377 EncodeUnicode(Name,"OpLogo ",7); 3377 EncodeUnicode(Name,"OpLogo ",7);
3378 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); 3378 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode));
3379 } else { 3379 } else {
3380 CopyUnicodeString(Name,Sender); 3380 CopyUnicodeString(Name,Sender);
3381 } 3381 }
3382 } 3382 }
3383 nextlong = 0; 3383 nextlong = 0;
3384 break; 3384 break;
3385 case 8:/* Reject duplicates ID */ 3385 case 8:/* Reject duplicates ID */
3386 SMSInfo.ReplaceMessage = atoi(argv[i]); 3386 SMSInfo.ReplaceMessage = atoi(argv[i]);
3387 if (SMSInfo.ReplaceMessage < 1 || SMSInfo.ReplaceMessage > 7) { 3387 if (SMSInfo.ReplaceMessage < 1 || SMSInfo.ReplaceMessage > 7) {
3388 printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv[i]); 3388 printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv[i]);
3389 exit(-1); 3389 exit(-1);
3390 } 3390 }
3391 nextlong = 0; 3391 nextlong = 0;
3392 break; 3392 break;
3393 case 9:/* Replace file for text SMS */ 3393 case 9:/* Replace file for text SMS */
3394 ReplaceFile = fopen(argv[i], "rb"); 3394 ReplaceFile = fopen(argv[i], "rb");
3395 if (ReplaceFile == NULL) Print_Error(ERR_CANTOPENFILE); 3395 if (ReplaceFile == NULL) Print_Error(ERR_CANTOPENFILE);
3396 memset(ReplaceBuffer,0,sizeof(ReplaceBuffer)); 3396 memset(ReplaceBuffer,0,sizeof(ReplaceBuffer));
3397 fread(ReplaceBuffer,1,sizeof(ReplaceBuffer),ReplaceFile); 3397 fread(ReplaceBuffer,1,sizeof(ReplaceBuffer),ReplaceFile);
3398 fclose(ReplaceFile); 3398 fclose(ReplaceFile);
3399 ReadUnicodeFile(ReplaceBuffer2,ReplaceBuffer); 3399 ReadUnicodeFile(ReplaceBuffer2,ReplaceBuffer);
3400 for(j=0;j<(int)(UnicodeLength(Buffer[0]));j++) { 3400 for(j=0;j<(int)(UnicodeLength(Buffer[0]));j++) {
3401 for (z=0;z<(int)(UnicodeLength(ReplaceBuffer2)/2);z++) { 3401 for (z=0;z<(int)(UnicodeLength(ReplaceBuffer2)/2);z++) {
3402 if (ReplaceBuffer2[z*4] == Buffer[0][j] && 3402 if (ReplaceBuffer2[z*4] == Buffer[0][j] &&
3403 ReplaceBuffer2[z*4+1] == Buffer[0][j+1]) { 3403 ReplaceBuffer2[z*4+1] == Buffer[0][j+1]) {
3404 Buffer[0][j] = ReplaceBuffer2[z*4+2]; 3404 Buffer[0][j] = ReplaceBuffer2[z*4+2];
3405 Buffer[0][j+1] = ReplaceBuffer2[z*4+3]; 3405 Buffer[0][j+1] = ReplaceBuffer2[z*4+3];
3406 break; 3406 break;
3407 } 3407 }
3408 } 3408 }
3409 } 3409 }
3410 nextlong = 0; 3410 nextlong = 0;
3411 break; 3411 break;
3412 case 10: 3412 case 10:
3413 Validity.Format = SMS_Validity_RelativeFormat; 3413 Validity.Format = SMS_Validity_RelativeFormat;
3414 if (mystrncasecmp(argv[i],"HOUR",0)) Validity.Relative = SMS_VALID_1_Hour; 3414 if (mystrncasecmp(argv[i],"HOUR",0)) Validity.Relative = SMS_VALID_1_Hour;
3415 else if (mystrncasecmp(argv[i],"6HOURS",0))Validity.Relative = SMS_VALID_6_Hours; 3415 else if (mystrncasecmp(argv[i],"6HOURS",0))Validity.Relative = SMS_VALID_6_Hours;
3416 else if (mystrncasecmp(argv[i],"DAY",0)) Validity.Relative = SMS_VALID_1_Day; 3416 else if (mystrncasecmp(argv[i],"DAY",0)) Validity.Relative = SMS_VALID_1_Day;
3417 else if (mystrncasecmp(argv[i],"3DAYS",0)) Validity.Relative = SMS_VALID_3_Days; 3417 else if (mystrncasecmp(argv[i],"3DAYS",0)) Validity.Relative = SMS_VALID_3_Days;
3418 else if (mystrncasecmp(argv[i],"WEEK",0)) Validity.Relative = SMS_VALID_1_Week; 3418 else if (mystrncasecmp(argv[i],"WEEK",0)) Validity.Relative = SMS_VALID_1_Week;
3419 else if (mystrncasecmp(argv[i],"MAX",0)) Validity.Relative = SMS_VALID_Max_Time; 3419 else if (mystrncasecmp(argv[i],"MAX",0)) Validity.Relative = SMS_VALID_Max_Time;
3420 else { 3420 else {
3421 printmsg("Unknown validity string (\"%s\")\n",argv[i]); 3421 printmsg("Unknown validity string (\"%s\")\n",argv[i]);
3422 exit(-1); 3422 exit(-1);
3423 } 3423 }
3424 nextlong = 0; 3424 nextlong = 0;
3425 break; 3425 break;
3426 case 11:/* EMS text from parameter */ 3426 case 11:/* EMS text from parameter */
3427 EncodeUnicode(Buffer[SMSInfo.EntriesNum],argv[i],strlen(argv[i])); 3427 EncodeUnicode(Buffer[SMSInfo.EntriesNum],argv[i],strlen(argv[i]));
3428 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); 3428 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum]));
3429 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; 3429 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong;
3430 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; 3430 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum];
3431 SMSInfo.EntriesNum++; 3431 SMSInfo.EntriesNum++;
3432 nextlong = 0; 3432 nextlong = 0;
3433 break; 3433 break;
3434 case 12:/* EMS predefined sound/animation number */ 3434 case 12:/* EMS predefined sound/animation number */
3435 SMSInfo.Entries[SMSInfo.EntriesNum].Number = atoi(argv[i]); 3435 SMSInfo.Entries[SMSInfo.EntriesNum].Number = atoi(argv[i]);
3436 SMSInfo.EntriesNum++; 3436 SMSInfo.EntriesNum++;
3437 nextlong = 0; 3437 nextlong = 0;
3438 break; 3438 break;
3439 case 14: /* EMS ringtone - IMelody */ 3439 case 14: /* EMS ringtone - IMelody */
3440 ringtone[SMSInfo.EntriesNum].Format=RING_NOTETONE; 3440 ringtone[SMSInfo.EntriesNum].Format=RING_NOTETONE;
3441 error=GSM_ReadRingtoneFile(argv[i],&ringtone[SMSInfo.EntriesNum]); 3441 error=GSM_ReadRingtoneFile(argv[i],&ringtone[SMSInfo.EntriesNum]);
3442 Print_Error(error); 3442 Print_Error(error);
3443 SMSInfo.Entries[SMSInfo.EntriesNum].Ringtone = &ringtone[SMSInfo.EntriesNum]; 3443 SMSInfo.Entries[SMSInfo.EntriesNum].Ringtone = &ringtone[SMSInfo.EntriesNum];
3444 SMSInfo.EntriesNum++; 3444 SMSInfo.EntriesNum++;
3445 nextlong = 0; 3445 nextlong = 0;
3446 break; 3446 break;
3447 case 15:/* EMS bitmap file */ 3447 case 15:/* EMS bitmap file */
3448 bitmap[SMSInfo.EntriesNum].Bitmap[0].Type=GSM_StartupLogo; 3448 bitmap[SMSInfo.EntriesNum].Bitmap[0].Type=GSM_StartupLogo;
3449 error=GSM_ReadBitmapFile(argv[i],&bitmap[SMSInfo.EntriesNum]); 3449 error=GSM_ReadBitmapFile(argv[i],&bitmap[SMSInfo.EntriesNum]);
3450 Print_Error(error); 3450 Print_Error(error);
3451 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; 3451 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum];
3452 SMSInfo.EntriesNum++; 3452 SMSInfo.EntriesNum++;
3453 nextlong = 0; 3453 nextlong = 0;
3454 break; 3454 break;
3455 case 16:/* Number of frames for EMS animation */ 3455 case 16:/* Number of frames for EMS animation */
3456 FramesNum = atoi(argv[i]); 3456 FramesNum = atoi(argv[i]);
3457 if (FramesNum < 1 || FramesNum > 4) { 3457 if (FramesNum < 1 || FramesNum > 4) {
3458 printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv[i]); 3458 printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv[i]);
3459 exit(-1); 3459 exit(-1);
3460 } 3460 }
3461 bitmap[SMSInfo.EntriesNum].Number = 0; 3461 bitmap[SMSInfo.EntriesNum].Number = 0;
3462 nextlong = 17; 3462 nextlong = 17;
3463 break; 3463 break;
3464 case 17:/*File for EMS animation */ 3464 case 17:/*File for EMS animation */
3465 bitmap2.Bitmap[0].Type=GSM_StartupLogo; 3465 bitmap2.Bitmap[0].Type=GSM_StartupLogo;
3466 error=GSM_ReadBitmapFile(argv[i],&bitmap2); 3466 error=GSM_ReadBitmapFile(argv[i],&bitmap2);
3467 for (j=0;j<bitmap2.Number;j++) { 3467 for (j=0;j<bitmap2.Number;j++) {
3468 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) break; 3468 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) break;
3469 memcpy(&bitmap[SMSInfo.EntriesNum].Bitmap[bitmap[SMSInfo.EntriesNum].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); 3469 memcpy(&bitmap[SMSInfo.EntriesNum].Bitmap[bitmap[SMSInfo.EntriesNum].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap));
3470 bitmap[SMSInfo.EntriesNum].Number++; 3470 bitmap[SMSInfo.EntriesNum].Number++;
3471 } 3471 }
3472 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) { 3472 if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) {
3473 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; 3473 SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum];
3474 SMSInfo.EntriesNum++; 3474 SMSInfo.EntriesNum++;
3475 nextlong = 0; 3475 nextlong = 0;
3476 } 3476 }
3477 break; 3477 break;
3478 case 18:/* EMS text from Unicode file */ 3478 case 18:/* EMS text from Unicode file */
3479 f = fopen(argv[i],"rb"); 3479 f = fopen(argv[i],"rb");
3480 if (f == NULL) { 3480 if (f == NULL) {
3481 printmsg("Can't open file \"%s\"\n",argv[i]); 3481 printmsg("Can't open file \"%s\"\n",argv[i]);
3482 exit(-1); 3482 exit(-1);
3483 } 3483 }
3484 z=fread(InputBuffer,1,2000,f); 3484 z=fread(InputBuffer,1,2000,f);
3485 InputBuffer[z] = 0; 3485 InputBuffer[z] = 0;
3486 InputBuffer[z+1] = 0; 3486 InputBuffer[z+1] = 0;
3487 fclose(f); 3487 fclose(f);
3488 ReadUnicodeFile(Buffer[SMSInfo.EntriesNum],InputBuffer); 3488 ReadUnicodeFile(Buffer[SMSInfo.EntriesNum],InputBuffer);
3489 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); 3489 dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum]));
3490 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; 3490 SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong;
3491 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; 3491 SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum];
3492 SMSInfo.EntriesNum++; 3492 SMSInfo.EntriesNum++;
3493 nextlong = 0; 3493 nextlong = 0;
3494 break; 3494 break;
3495 case 19:/* Number of protected items */ 3495 case 19:/* Number of protected items */
3496 Protected = atoi(argv[i]); 3496 Protected = atoi(argv[i]);
3497 nextlong = 0; 3497 nextlong = 0;
3498 break; 3498 break;
3499 case 20:/* Formatting text for EMS */ 3499 case 20:/* Formatting text for EMS */
3500 if (SMSInfo.Entries[SMSInfo.EntriesNum-1].ID == SMS_ConcatenatedTextLong) { 3500 if (SMSInfo.Entries[SMSInfo.EntriesNum-1].ID == SMS_ConcatenatedTextLong) {
3501 for(j=0;j<(int)strlen(argv[i]);j++) { 3501 for(j=0;j<(int)strlen(argv[i]);j++) {
3502 switch(argv[i][j]) { 3502 switch(argv[i][j]) {
3503 case 'l': case 'L': 3503 case 'l': case 'L':
3504 SMSInfo.Entries[SMSInfo.EntriesNum-1].Left = true; 3504 SMSInfo.Entries[SMSInfo.EntriesNum-1].Left = true;
3505 break; 3505 break;
3506 case 'c': case 'C': 3506 case 'c': case 'C':
3507 SMSInfo.Entries[SMSInfo.EntriesNum-1].Center = true; 3507 SMSInfo.Entries[SMSInfo.EntriesNum-1].Center = true;
3508 break; 3508 break;
3509 case 'r': case 'R': 3509 case 'r': case 'R':
3510 SMSInfo.Entries[SMSInfo.EntriesNum-1].Right = true; 3510 SMSInfo.Entries[SMSInfo.EntriesNum-1].Right = true;
3511 break; 3511 break;
3512 case 'a': case 'A': 3512 case 'a': case 'A':
3513 SMSInfo.Entries[SMSInfo.EntriesNum-1].Large = true; 3513 SMSInfo.Entries[SMSInfo.EntriesNum-1].Large = true;
3514 break; 3514 break;
3515 case 's': case 'S': 3515 case 's': case 'S':
3516 SMSInfo.Entries[SMSInfo.EntriesNum-1].Small = true; 3516 SMSInfo.Entries[SMSInfo.EntriesNum-1].Small = true;
3517 break; 3517 break;
3518 case 'b': case 'B': 3518 case 'b': case 'B':
3519 SMSInfo.Entries[SMSInfo.EntriesNum-1].Bold = true; 3519 SMSInfo.Entries[SMSInfo.EntriesNum-1].Bold = true;
3520 break; 3520 break;
3521 case 'i': case 'I': 3521 case 'i': case 'I':
3522 SMSInfo.Entries[SMSInfo.EntriesNum-1].Italic = true; 3522 SMSInfo.Entries[SMSInfo.EntriesNum-1].Italic = true;
3523 break; 3523 break;
3524 case 'u': case 'U': 3524 case 'u': case 'U':
3525 SMSInfo.Entries[SMSInfo.EntriesNum-1].Underlined = true; 3525 SMSInfo.Entries[SMSInfo.EntriesNum-1].Underlined = true;
3526 break; 3526 break;
3527 case 't': case 'T': 3527 case 't': case 'T':
3528 SMSInfo.Entries[SMSInfo.EntriesNum-1].Strikethrough = true; 3528 SMSInfo.Entries[SMSInfo.EntriesNum-1].Strikethrough = true;
3529 break; 3529 break;
3530 default: 3530 default:
3531 printmsg("Unknown parameter \"%c\"\n",argv[i][j]); 3531 printmsg("Unknown parameter \"%c\"\n",argv[i][j]);
3532 exit(-1); 3532 exit(-1);
3533 } 3533 }
3534 } 3534 }
3535 } else { 3535 } else {
3536 printmsg("Last parameter wasn't text\n"); 3536 printmsg("Last parameter wasn't text\n");
3537 exit(-1); 3537 exit(-1);
3538 } 3538 }
3539 nextlong = 0; 3539 nextlong = 0;
3540 break; 3540 break;
3541 case 21:/*MaxSMS*/ 3541 case 21:/*MaxSMS*/
3542 MaxSMS = atoi(argv[i]); 3542 MaxSMS = atoi(argv[i]);
3543 nextlong = 0; 3543 nextlong = 0;
3544 break; 3544 break;
3545 case 22:/* profile name */ 3545 case 22:/* profile name */
3546 EncodeUnicode(Buffer[0],argv[i],strlen(argv[i])); 3546 EncodeUnicode(Buffer[0],argv[i],strlen(argv[i]));
3547 SMSInfo.Entries[0].Buffer = Buffer[0]; 3547 SMSInfo.Entries[0].Buffer = Buffer[0];
3548 nextlong = 0; 3548 nextlong = 0;
3549 break; 3549 break;
3550 case 23:/* profile ringtone */ 3550 case 23:/* profile ringtone */
3551 ringtone[0].Format = RING_NOTETONE; 3551 ringtone[0].Format = RING_NOTETONE;
3552 error=GSM_ReadRingtoneFile(argv[i],&ringtone[0]); 3552 error=GSM_ReadRingtoneFile(argv[i],&ringtone[0]);
3553 Print_Error(error); 3553 Print_Error(error);
3554 SMSInfo.Entries[0].Ringtone = &ringtone[0]; 3554 SMSInfo.Entries[0].Ringtone = &ringtone[0];
3555 nextlong = 0; 3555 nextlong = 0;
3556 break; 3556 break;
3557 case 24:/* profile bitmap */ 3557 case 24:/* profile bitmap */
3558 bitmap[0].Bitmap[0].Type = GSM_PictureImage; 3558 bitmap[0].Bitmap[0].Type = GSM_PictureImage;
3559 error=GSM_ReadBitmapFile(argv[i],&bitmap[0]); 3559 error=GSM_ReadBitmapFile(argv[i],&bitmap[0]);
3560 Print_Error(error); 3560 Print_Error(error);
3561 bitmap[0].Bitmap[0].Text[0] = 0; 3561 bitmap[0].Bitmap[0].Text[0] = 0;
3562 bitmap[0].Bitmap[0].Text[1] = 0; 3562 bitmap[0].Bitmap[0].Text[1] = 0;
3563 SMSInfo.Entries[0].Bitmap = &bitmap[0]; 3563 SMSInfo.Entries[0].Bitmap = &bitmap[0];
3564 nextlong = 0; 3564 nextlong = 0;
3565 break; 3565 break;
3566 } 3566 }
3567 } 3567 }
3568 if (nextlong!=0) { 3568 if (nextlong!=0) {
3569 printmsg("Parameter missed...\n"); 3569 printmsg("Parameter missed...\n");
3570 exit(-1); 3570 exit(-1);
3571 } 3571 }
3572 3572
3573 if (mystrncasecmp(argv[2],"EMS",0) && EMS16Bit) { 3573 if (mystrncasecmp(argv[2],"EMS",0) && EMS16Bit) {
3574 for (i=0;i<SMSInfo.EntriesNum;i++) { 3574 for (i=0;i<SMSInfo.EntriesNum;i++) {
3575 switch (SMSInfo.Entries[i].ID) { 3575 switch (SMSInfo.Entries[i].ID) {
3576 case SMS_ConcatenatedTextLong: 3576 case SMS_ConcatenatedTextLong:
3577 SMSInfo.Entries[i].ID = SMS_ConcatenatedTextLong16bit; 3577 SMSInfo.Entries[i].ID = SMS_ConcatenatedTextLong16bit;
3578 default: 3578 default:
3579 break; 3579 break;
3580 3580
3581 } 3581 }
3582 } 3582 }
3583 3583
3584 } 3584 }
3585 if (mystrncasecmp(argv[2],"TEXT",0)) { 3585 if (mystrncasecmp(argv[2],"TEXT",0)) {
3586 chars_read = UnicodeLength(Buffer[0]); 3586 chars_read = UnicodeLength(Buffer[0]);
3587 if (chars_read != 0) { 3587 if (chars_read != 0) {
3588 /* Trim \n at the end of string */ 3588 /* Trim \n at the end of string */
3589 if (Buffer[0][chars_read*2-1] == '\n' && Buffer[0][chars_read*2-2] == 0) 3589 if (Buffer[0][chars_read*2-1] == '\n' && Buffer[0][chars_read*2-2] == 0)
3590 { 3590 {
3591 Buffer[0][chars_read*2-1] = 0; 3591 Buffer[0][chars_read*2-1] = 0;
3592 } 3592 }
3593 } 3593 }
3594 } 3594 }
3595 3595
3596 if (mystrncasecmp(argv[1],"--displaysms",0) || mystrncasecmp(argv[1],"--sendsmsdsms",0)) { 3596 if (mystrncasecmp(argv[1],"--displaysms",0) || mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
3597 if (mystrncasecmp(argv[2],"OPERATOR",0)) { 3597 if (mystrncasecmp(argv[2],"OPERATOR",0)) {
3598 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { 3598 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) {
3599 printmsg("No network code\n"); 3599 printmsg("No network code\n");
3600 exit(-1); 3600 exit(-1);
3601 } 3601 }
3602 } 3602 }
3603 } else { 3603 } else {
3604 GSM_Init(true); 3604 GSM_Init(true);
3605 3605
3606 if (mystrncasecmp(argv[2],"OPERATOR",0)) { 3606 if (mystrncasecmp(argv[2],"OPERATOR",0)) {
3607 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { 3607 if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) {
3608 error=Phone->GetNetworkInfo(&s,&NetInfo); 3608 error=Phone->GetNetworkInfo(&s,&NetInfo);
3609 Print_Error(error); 3609 Print_Error(error);
3610 strcpy(bitmap[0].Bitmap[0].NetworkCode,NetInfo.NetworkCode); 3610 strcpy(bitmap[0].Bitmap[0].NetworkCode,NetInfo.NetworkCode);
3611 if (mystrncasecmp(argv[1],"--savesms",0)) { 3611 if (mystrncasecmp(argv[1],"--savesms",0)) {
3612 EncodeUnicode(Sender, "OpLogo",6); 3612 EncodeUnicode(Sender, "OpLogo",6);
3613 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); 3613 EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3);
3614 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); 3614 EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2);
3615 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { 3615 if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) {
3616 EncodeUnicode(Name,"OpLogo ",7); 3616 EncodeUnicode(Name,"OpLogo ",7);
3617 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); 3617 CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode));
3618 } else { 3618 } else {
3619 CopyUnicodeString(Name,Sender); 3619 CopyUnicodeString(Name,Sender);
3620 } 3620 }
3621 } 3621 }
3622 } 3622 }
3623 } 3623 }
3624 } 3624 }
3625 3625
3626 error=GSM_EncodeMultiPartSMS(&SMSInfo,&sms); 3626 error=GSM_EncodeMultiPartSMS(&SMSInfo,&sms);
3627 Print_Error(error); 3627 Print_Error(error);
3628 3628
3629 for (i=0;i<SMSInfo.EntriesNum;i++) { 3629 for (i=0;i<SMSInfo.EntriesNum;i++) {
3630 switch (SMSInfo.Entries[i].ID) { 3630 switch (SMSInfo.Entries[i].ID) {
3631 case SMS_NokiaRingtone: 3631 case SMS_NokiaRingtone:
3632 case SMS_NokiaRingtoneLong: 3632 case SMS_NokiaRingtoneLong:
3633 case SMS_NokiaProfileLong: 3633 case SMS_NokiaProfileLong:
3634 case SMS_EMSSound10: 3634 case SMS_EMSSound10:
3635 case SMS_EMSSound12: 3635 case SMS_EMSSound12:
3636 case SMS_EMSSonyEricssonSound: 3636 case SMS_EMSSonyEricssonSound:
3637 case SMS_EMSSound10Long: 3637 case SMS_EMSSound10Long:
3638 case SMS_EMSSound12Long: 3638 case SMS_EMSSound12Long:
3639 case SMS_EMSSonyEricssonSoundLong: 3639 case SMS_EMSSonyEricssonSoundLong:
3640 if (SMSInfo.Entries[i].RingtoneNotes!=SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands) { 3640 if (SMSInfo.Entries[i].RingtoneNotes!=SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands) {
3641 printmsg("Warning: ringtone too long. %i percent part cut\n", 3641 printmsg("Warning: ringtone too long. %i percent part cut\n",
3642 (SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands-SMSInfo.Entries[i].RingtoneNotes)*100/SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands); 3642 (SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands-SMSInfo.Entries[i].RingtoneNotes)*100/SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands);
3643 } 3643 }
3644 default: 3644 default:
3645 break; 3645 break;
3646 3646
3647 } 3647 }
3648 } 3648 }
3649 if (MaxSMS != -1 && sms.Number > MaxSMS) { 3649 if (MaxSMS != -1 && sms.Number > MaxSMS) {
3650 printmsg("There is %i SMS packed and %i limit. Exiting\n",sms.Number,MaxSMS); 3650 printmsg("There is %i SMS packed and %i limit. Exiting\n",sms.Number,MaxSMS);
3651 if (!mystrncasecmp(argv[1],"--displaysms",0) && !mystrncasecmp(argv[1],"--sendsmsdsms",0)) GSM_Terminate(); 3651 if (!mystrncasecmp(argv[1],"--displaysms",0) && !mystrncasecmp(argv[1],"--sendsmsdsms",0)) GSM_Terminate();
3652 exit(-1); 3652 exit(-1);
3653 } 3653 }
3654 3654
3655 if (mystrncasecmp(argv[1],"--displaysms",0)) { 3655 if (mystrncasecmp(argv[1],"--displaysms",0)) {
3656 if (SMSCSet != 0) { 3656 if (SMSCSet != 0) {
3657 printmsg("Use -smscnumber option to give SMSC number\n"); 3657 printmsg("Use -smscnumber option to give SMSC number\n");
3658 exit(-1); 3658 exit(-1);
3659 } 3659 }
3660 3660
3661 for (i=0;i<sms.Number;i++) { 3661 for (i=0;i<sms.Number;i++) {
3662 sms.SMS[i].Location = 0; 3662 sms.SMS[i].Location = 0;
3663 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; 3663 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
3664 sms.SMS[i].SMSC.Location = 0; 3664 sms.SMS[i].SMSC.Location = 0;
3665 sms.SMS[i].PDU = SMS_Submit; 3665 sms.SMS[i].PDU = SMS_Submit;
3666 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; 3666 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report;
3667 CopyUnicodeString(sms.SMS[i].Number, Sender); 3667 CopyUnicodeString(sms.SMS[i].Number, Sender);
3668 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3668 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3669 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); 3669 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
3670 DisplaySMSFrame(&sms.SMS[i]); 3670 DisplaySMSFrame(&sms.SMS[i]);
3671 } 3671 }
3672 3672
3673 printmsg("\nNumber of SMS: %i\n",sms.Number); 3673 printmsg("\nNumber of SMS: %i\n",sms.Number);
3674 exit(sms.Number); 3674 exit(sms.Number);
3675 } 3675 }
3676 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { 3676 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
3677 if (SMSCSet != 0) { 3677 if (SMSCSet != 0) {
3678 printmsg("Use -smscnumber option to give SMSC number\n"); 3678 printmsg("Use -smscnumber option to give SMSC number\n");
3679 exit(-1); 3679 exit(-1);
3680 } 3680 }
3681 3681
3682 for (i=0;i<sms.Number;i++) { 3682 for (i=0;i<sms.Number;i++) {
3683 sms.SMS[i].Location = 0; 3683 sms.SMS[i].Location = 0;
3684 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; 3684 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
3685 sms.SMS[i].SMSC.Location = 0; 3685 sms.SMS[i].SMSC.Location = 0;
3686 sms.SMS[i].PDU = SMS_Submit; 3686 sms.SMS[i].PDU = SMS_Submit;
3687 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; 3687 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report;
3688 CopyUnicodeString(sms.SMS[i].Number, Sender); 3688 CopyUnicodeString(sms.SMS[i].Number, Sender);
3689 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3689 CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3690 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); 3690 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
3691 } 3691 }
3692 SMSDaemonSendSMS(argv[4],argv[5],&sms); 3692 SMSDaemonSendSMS(argv[4],argv[5],&sms);
3693 exit(0); 3693 exit(0);
3694 } 3694 }
3695 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { 3695 if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) {
3696 error=Phone->GetSMSFolders(&s, &folders); 3696 error=Phone->GetSMSFolders(&s, &folders);
3697 Print_Error(error); 3697 Print_Error(error);
3698 3698
3699 if (SendSaved){ 3699 if (SendSaved){
3700 if (Validity.Format != 0 && SMSCSet != 0) { 3700 if (Validity.Format != 0 && SMSCSet != 0) {
3701 PhoneSMSC.Location = SMSCSet; 3701 PhoneSMSC.Location = SMSCSet;
3702 error=Phone->GetSMSC(&s,&PhoneSMSC); 3702 error=Phone->GetSMSC(&s,&PhoneSMSC);
3703 Print_Error(error); 3703 Print_Error(error);
3704 CopyUnicodeString(SMSC,PhoneSMSC.Number); 3704 CopyUnicodeString(SMSC,PhoneSMSC.Number);
3705 SMSCSet = 0; 3705 SMSCSet = 0;
3706 } 3706 }
3707 3707
3708 s.User.SendSMSStatus = SendSMSStatus; 3708 s.User.SendSMSStatus = SendSMSStatus;
3709 3709
3710 signal(SIGINT, interrupt); 3710 signal(SIGINT, interrupt);
3711 printmsgerr("If you want break, press Ctrl+C...\n"); 3711 printmsgerr("If you want break, press Ctrl+C...\n");
3712 } 3712 }
3713 3713
3714 for (i=0;i<sms.Number;i++) { 3714 for (i=0;i<sms.Number;i++) {
3715 printmsg("Saving SMS %i/%i\n",i+1,sms.Number); 3715 printmsg("Saving SMS %i/%i\n",i+1,sms.Number);
3716 // sms.SMS[i].Location = 0; 3716 // sms.SMS[i].Location = 0;
3717 sms.SMS[i].Folder = Folder; 3717 sms.SMS[i].Folder = Folder;
3718 sms.SMS[i].State = State; 3718 sms.SMS[i].State = State;
3719 sms.SMS[i].ReplyViaSameSMSC= ReplyViaSameSMSC; 3719 sms.SMS[i].ReplyViaSameSMSC= ReplyViaSameSMSC;
3720 sms.SMS[i].SMSC.Location= SMSCSet; 3720 sms.SMS[i].SMSC.Location= SMSCSet;
3721 3721
3722 if (SendSaved){ 3722 if (SendSaved){
3723 sms.SMS[i].PDU= SMS_Submit; 3723 sms.SMS[i].PDU= SMS_Submit;
3724 if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report; 3724 if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report;
3725 if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity; 3725 if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity;
3726 } else { 3726 } else {
3727 sms.SMS[i].PDU= SMS_Deliver; 3727 sms.SMS[i].PDU= SMS_Deliver;
3728 } 3728 }
3729 3729
3730 CopyUnicodeString(sms.SMS[i].Number, Sender); 3730 CopyUnicodeString(sms.SMS[i].Number, Sender);
3731 CopyUnicodeString(sms.SMS[i].Name, Name); 3731 CopyUnicodeString(sms.SMS[i].Name, Name);
3732 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3732 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3733 error=Phone->AddSMS(&s, &sms.SMS[i]); 3733 error=Phone->AddSMS(&s, &sms.SMS[i]);
3734 Print_Error(error); 3734 Print_Error(error);
3735 printmsg("Saved in folder \"%s\", location %i\n", 3735 printmsg("Saved in folder \"%s\", location %i\n",
3736 DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); 3736 DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location);
3737 3737
3738 if (SendSaved) { 3738 if (SendSaved) {
3739 printmsg("Sending sms from folder \"%s\", location %i\n", 3739 printmsg("Sending sms from folder \"%s\", location %i\n",
3740 DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); 3740 DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location);
3741 SMSStatus = ERR_TIMEOUT; 3741 SMSStatus = ERR_TIMEOUT;
3742 error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location); 3742 error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location);
3743 Print_Error(error); 3743 Print_Error(error);
3744 printmsg("....waiting for network answer"); 3744 printmsg("....waiting for network answer");
3745 while (!gshutdown) { 3745 while (!gshutdown) {
3746 GSM_ReadDevice(&s,true); 3746 GSM_ReadDevice(&s,true);
3747 if (SMSStatus == ERR_UNKNOWN) { 3747 if (SMSStatus == ERR_UNKNOWN) {
3748 GSM_Terminate(); 3748 GSM_Terminate();
3749 exit(-1); 3749 exit(-1);
3750 } 3750 }
3751 if (SMSStatus == ERR_NONE) break; 3751 if (SMSStatus == ERR_NONE) break;
3752 } 3752 }
3753 } 3753 }
3754 } 3754 }
3755 } else { 3755 } else {
3756 if (Validity.Format != 0 && SMSCSet != 0) { 3756 if (Validity.Format != 0 && SMSCSet != 0) {
3757 PhoneSMSC.Location = SMSCSet; 3757 PhoneSMSC.Location = SMSCSet;
3758 error=Phone->GetSMSC(&s,&PhoneSMSC); 3758 error=Phone->GetSMSC(&s,&PhoneSMSC);
3759 Print_Error(error); 3759 Print_Error(error);
3760 CopyUnicodeString(SMSC,PhoneSMSC.Number); 3760 CopyUnicodeString(SMSC,PhoneSMSC.Number);
3761 SMSCSet = 0; 3761 SMSCSet = 0;
3762 } 3762 }
3763 3763
3764 signal(SIGINT, interrupt); 3764 signal(SIGINT, interrupt);
3765 printmsgerr("If you want break, press Ctrl+C...\n"); 3765 printmsgerr("If you want break, press Ctrl+C...\n");
3766 3766
3767 s.User.SendSMSStatus = SendSMSStatus; 3767 s.User.SendSMSStatus = SendSMSStatus;
3768 3768
3769 for (i=0;i<sms.Number;i++) { 3769 for (i=0;i<sms.Number;i++) {
3770 printmsg("Sending SMS %i/%i",i+1,sms.Number); 3770 printmsg("Sending SMS %i/%i",i+1,sms.Number);
3771 sms.SMS[i].Location = 0; 3771 sms.SMS[i].Location = 0;
3772 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; 3772 sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
3773 sms.SMS[i].SMSC.Location = SMSCSet; 3773 sms.SMS[i].SMSC.Location = SMSCSet;
3774 sms.SMS[i].PDU = SMS_Submit; 3774 sms.SMS[i].PDU = SMS_Submit;
3775 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; 3775 if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report;
3776 CopyUnicodeString(sms.SMS[i].Number, Sender); 3776 CopyUnicodeString(sms.SMS[i].Number, Sender);
3777 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); 3777 if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
3778 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); 3778 if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
3779 SMSStatus = ERR_TIMEOUT; 3779 SMSStatus = ERR_TIMEOUT;
3780 error=Phone->SendSMS(&s, &sms.SMS[i]); 3780 error=Phone->SendSMS(&s, &sms.SMS[i]);
3781 Print_Error(error); 3781 Print_Error(error);
3782 printmsg("....waiting for network answer"); 3782 printmsg("....waiting for network answer");
3783 while (!gshutdown) { 3783 while (!gshutdown) {
3784 GSM_ReadDevice(&s,true); 3784 GSM_ReadDevice(&s,true);
3785 if (SMSStatus == ERR_UNKNOWN) { 3785 if (SMSStatus == ERR_UNKNOWN) {
3786 GSM_Terminate(); 3786 GSM_Terminate();
3787 exit(-1); 3787 exit(-1);
3788 } 3788 }
3789 if (SMSStatus == ERR_NONE) break; 3789 if (SMSStatus == ERR_NONE) break;
3790 } 3790 }
3791 } 3791 }
3792 } 3792 }
3793 3793
3794 GSM_Terminate(); 3794 GSM_Terminate();
3795} 3795}
3796 3796
3797#ifdef GSM_ENABLE_BACKUP 3797#ifdef GSM_ENABLE_BACKUP
3798static void SaveFile(int argc, char *argv[]) 3798static void SaveFile(int argc, char *argv[])
3799{ 3799{
3800 GSM_Backup Backup; 3800 GSM_Backup Backup;
3801 int i,j; 3801 int i,j;
3802 FILE *file; 3802 FILE *file;
3803 unsigned char Buffer[10000]; 3803 unsigned char Buffer[10000];
3804 GSM_MemoryEntry *pbk; 3804 GSM_MemoryEntry *pbk;
3805 3805
3806 if (mystrncasecmp(argv[2],"CALENDAR",0)) { 3806 if (mystrncasecmp(argv[2],"CALENDAR",0)) {
3807 if (argc<5) { 3807 if (argc<5) {
3808 printmsg("Where is backup filename and location ?\n"); 3808 printmsg("Where is backup filename and location ?\n");
3809 exit(-1); 3809 exit(-1);
3810 } 3810 }
3811 error=GSM_ReadBackupFile(argv[4],&Backup); 3811 error=GSM_ReadBackupFile(argv[4],&Backup);
3812 Print_Error(error); 3812 Print_Error(error);
3813 i = 0; 3813 i = 0;
3814 while (Backup.Calendar[i]!=NULL) { 3814 while (Backup.Calendar[i]!=NULL) {
3815 if (i == atoi(argv[5])-1) break; 3815 if (i == atoi(argv[5])-1) break;
3816 i++; 3816 i++;
3817 } 3817 }
3818 if (i != atoi(argv[5])-1) { 3818 if (i != atoi(argv[5])-1) {
3819 printmsg("Calendar note not found in file\n"); 3819 printmsg("Calendar note not found in file\n");
3820 exit(-1); 3820 exit(-1);
3821 } 3821 }
3822 j = 0; 3822 j = 0;
3823 GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar); 3823 GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar);
3824 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { 3824 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
3825 if (argc<5) { 3825 if (argc<5) {
3826 printmsg("Where is backup filename and location ?\n"); 3826 printmsg("Where is backup filename and location ?\n");
3827 exit(-1); 3827 exit(-1);
3828 } 3828 }
3829 error=GSM_ReadBackupFile(argv[4],&Backup); 3829 error=GSM_ReadBackupFile(argv[4],&Backup);
3830 Print_Error(error); 3830 Print_Error(error);
3831 i = 0; 3831 i = 0;
3832 while (Backup.WAPBookmark[i]!=NULL) { 3832 while (Backup.WAPBookmark[i]!=NULL) {
3833 if (i == atoi(argv[5])-1) break; 3833 if (i == atoi(argv[5])-1) break;
3834 i++; 3834 i++;
3835 } 3835 }
3836 if (i != atoi(argv[5])-1) { 3836 if (i != atoi(argv[5])-1) {
3837 printmsg("WAP bookmark not found in file\n"); 3837 printmsg("WAP bookmark not found in file\n");
3838 exit(-1); 3838 exit(-1);
3839 } 3839 }
3840 j = 0; 3840 j = 0;
3841 GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]); 3841 GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]);
3842 } else if (mystrncasecmp(argv[2],"NOTE",0)) { 3842 } else if (mystrncasecmp(argv[2],"NOTE",0)) {
3843 if (argc<5) { 3843 if (argc<5) {
3844 printmsg("Where is backup filename and location ?\n"); 3844 printmsg("Where is backup filename and location ?\n");
3845 exit(-1); 3845 exit(-1);
3846 } 3846 }
3847 error=GSM_ReadBackupFile(argv[4],&Backup); 3847 error=GSM_ReadBackupFile(argv[4],&Backup);
3848 Print_Error(error); 3848 Print_Error(error);
3849 i = 0; 3849 i = 0;
3850 while (Backup.Note[i]!=NULL) { 3850 while (Backup.Note[i]!=NULL) {
3851 if (i == atoi(argv[5])-1) break; 3851 if (i == atoi(argv[5])-1) break;
3852 i++; 3852 i++;
3853 } 3853 }
3854 if (i != atoi(argv[5])-1) { 3854 if (i != atoi(argv[5])-1) {
3855 printmsg("Note not found in file\n"); 3855 printmsg("Note not found in file\n");
3856 exit(-1); 3856 exit(-1);
3857 } 3857 }
3858 j = 0; 3858 j = 0;
3859 GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]); 3859 GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]);
3860 } else if (mystrncasecmp(argv[2],"TODO",0)) { 3860 } else if (mystrncasecmp(argv[2],"TODO",0)) {
3861 if (argc<5) { 3861 if (argc<5) {
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
3926static void Backup(int argc, char *argv[]) 3926static 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
4484static void Restore(int argc, char *argv[]) 4484static 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
4976static void AddNew(int argc, char *argv[]) 4981static 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
5128static void ClearAll(int argc, char *argv[]) 5133static 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
5283static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) 5288static 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
5362static void GetSyncMLSettings(int argc, char *argv[]) 5367static 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
5409static void GetChatSettings(int argc, char *argv[]) 5414static 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
5448static void GetWAPMMSSettings(int argc, char *argv[]) 5453static 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;
5459 if (mystrncasecmp(argv[1],"--getwapsettings",0)) { 5464 if (mystrncasecmp(argv[1],"--getwapsettings",0)) {
5460 error=Phone->GetWAPSettings(&s,&settings); 5465 error=Phone->GetWAPSettings(&s,&settings);
5461 } else { 5466 } else {
5462 error=Phone->GetMMSSettings(&s,&settings); 5467 error=Phone->GetMMSSettings(&s,&settings);
5463 } 5468 }
5464 Print_Error(error); 5469 Print_Error(error);
5465 for (j=0;j<settings.Number;j++) { 5470 for (j=0;j<settings.Number;j++) {
5466 printmsg("%i. ",i); 5471 printmsg("%i. ",i);
5467 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { 5472 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) {
5468 printmsg("Set %i",i); 5473 printmsg("Set %i",i);
5469 } else { 5474 } else {
5470 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); 5475 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title));
5471 } 5476 }
5472 if (settings.Active) printmsg(" (active)"); 5477 if (settings.Active) printmsg(" (active)");
5473 if (settings.ReadOnly) printmsg("\nRead only : yes"); 5478 if (settings.ReadOnly) printmsg("\nRead only : yes");
5474 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); 5479 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage));
5475 DisplayConnectionSettings(&settings,j); 5480 DisplayConnectionSettings(&settings,j);
5476 printf("\n"); 5481 printf("\n");
5477 } 5482 }
5478 } 5483 }
5479 GSM_Terminate(); 5484 GSM_Terminate();
5480} 5485}
5481 5486
5482#ifdef GSM_ENABLE_BACKUP 5487#ifdef GSM_ENABLE_BACKUP
5483static void BackupSMS(int argc, char *argv[]) 5488static void BackupSMS(int argc, char *argv[])
5484{ 5489{
5485 GSM_SMS_Backup Backup; 5490 GSM_SMS_Backup Backup;
5486 GSM_MultiSMSMessage sms; 5491 GSM_MultiSMSMessage sms;
5487 GSM_SMSFolders folders; 5492 GSM_SMSFolders folders;
5488 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; 5493 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS];
5489 bool start = true; 5494 bool start = true;
5490 bool DeleteAfter; 5495 bool DeleteAfter;
5491 int j, smsnum; 5496 int j, smsnum;
5492 char buffer[200]; 5497 char buffer[200];
5493 5498
5494 /* We ignore return code, because (when file doesn't exist) we 5499 /* We ignore return code, because (when file doesn't exist) we
5495 * will create new later 5500 * will create new later
5496 */ 5501 */
5497 GSM_ReadSMSBackupFile(argv[2], &Backup); 5502 GSM_ReadSMSBackupFile(argv[2], &Backup);
5498 smsnum = 0; 5503 smsnum = 0;
5499 while (Backup.SMS[smsnum]!=NULL) smsnum++; 5504 while (Backup.SMS[smsnum]!=NULL) smsnum++;
5500 5505
5501 GSM_Init(true); 5506 GSM_Init(true);
5502 5507
5503 error=Phone->GetSMSFolders(&s, &folders); 5508 error=Phone->GetSMSFolders(&s, &folders);
5504 Print_Error(error); 5509 Print_Error(error);
5505 5510
5506 DeleteAfter=answer_yes("Delete each sms after backup"); 5511 DeleteAfter=answer_yes("Delete each sms after backup");
5507 5512
5508 for (j=0;j<folders.Number;j++) { 5513 for (j=0;j<folders.Number;j++) {
5509 BackupFromFolder[j] = false; 5514 BackupFromFolder[j] = false;
5510 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); 5515 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name));
5511 if (answer_yes(buffer)) BackupFromFolder[j] = true; 5516 if (answer_yes(buffer)) BackupFromFolder[j] = true;
5512 } 5517 }
5513 5518
5514 while (error == ERR_NONE) { 5519 while (error == ERR_NONE) {
5515 sms.SMS[0].Folder=0x00; 5520 sms.SMS[0].Folder=0x00;
5516 error=Phone->GetNextSMS(&s, &sms, start); 5521 error=Phone->GetNextSMS(&s, &sms, start);
5517 switch (error) { 5522 switch (error) {
5518 case ERR_EMPTY: 5523 case ERR_EMPTY:
5519 break; 5524 break;
5520 default: 5525 default:
5521 Print_Error(error); 5526 Print_Error(error);
5522 for (j=0;j<sms.Number;j++) { 5527 for (j=0;j<sms.Number;j++) {
5523 if (BackupFromFolder[sms.SMS[j].Folder-1]) { 5528 if (BackupFromFolder[sms.SMS[j].Folder-1]) {
5524 switch (sms.SMS[j].PDU) { 5529 switch (sms.SMS[j].PDU) {
5525 case SMS_Status_Report: 5530 case SMS_Status_Report:
5526 break; 5531 break;
5527 case SMS_Submit: 5532 case SMS_Submit:
5528 case SMS_Deliver: 5533 case SMS_Deliver:
5529 if (sms.SMS[j].Length == 0) break; 5534 if (sms.SMS[j].Length == 0) break;
5530 if (smsnum < GSM_BACKUP_MAX_SMS) { 5535 if (smsnum < GSM_BACKUP_MAX_SMS) {
5531 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); 5536 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage));
5532 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); 5537 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY);
5533 Backup.SMS[smsnum+1] = NULL; 5538 Backup.SMS[smsnum+1] = NULL;
5534 } else { 5539 } else {
5535 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); 5540 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS");
5536 GSM_Terminate(); 5541 GSM_Terminate();
5537 exit(-1); 5542 exit(-1);
5538 } 5543 }
5539 *Backup.SMS[smsnum] = sms.SMS[j]; 5544 *Backup.SMS[smsnum] = sms.SMS[j];
5540 smsnum++; 5545 smsnum++;
5541 break; 5546 break;
5542 } 5547 }
5543 } 5548 }
5544 } 5549 }
5545 } 5550 }
5546 start=false; 5551 start=false;
5547 } 5552 }
5548 5553
5549 error = GSM_SaveSMSBackupFile(argv[2],&Backup); 5554 error = GSM_SaveSMSBackupFile(argv[2],&Backup);
5550 Print_Error(error); 5555 Print_Error(error);
5551 5556
5552 if (DeleteAfter) { 5557 if (DeleteAfter) {
5553 for (j=0;j<smsnum;j++) { 5558 for (j=0;j<smsnum;j++) {
5554 Backup.SMS[j]->Folder = 0; 5559 Backup.SMS[j]->Folder = 0;
5555 error=Phone->DeleteSMS(&s, Backup.SMS[j]); 5560 error=Phone->DeleteSMS(&s, Backup.SMS[j]);
5556 Print_Error(error); 5561 Print_Error(error);
5557 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); 5562 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum);
5558 } 5563 }
5559 } 5564 }
5560 5565
5561 GSM_Terminate(); 5566 GSM_Terminate();
5562} 5567}
5563 5568
5564static void AddSMS(int argc, char *argv[]) 5569static void AddSMS(int argc, char *argv[])
5565{ 5570{
5566 GSM_MultiSMSMessage SMS; 5571 GSM_MultiSMSMessage SMS;
5567 GSM_SMS_Backup Backup; 5572 GSM_SMS_Backup Backup;
5568 int smsnum = 0; 5573 int smsnum = 0;
5569 int folder; 5574 int folder;
5570 5575
5571 folder = atoi(argv[2]); 5576 folder = atoi(argv[2]);
5572 5577
5573 error = GSM_ReadSMSBackupFile(argv[3], &Backup); 5578 error = GSM_ReadSMSBackupFile(argv[3], &Backup);
5574 Print_Error(error); 5579 Print_Error(error);
5575 5580
5576 GSM_Init(true); 5581 GSM_Init(true);
5577 5582
5578 while (Backup.SMS[smsnum] != NULL) { 5583 while (Backup.SMS[smsnum] != NULL) {
5579 Backup.SMS[smsnum]->Folder = folder; 5584 Backup.SMS[smsnum]->Folder = folder;
5580 Backup.SMS[smsnum]->SMSC.Location = 1; 5585 Backup.SMS[smsnum]->SMSC.Location = 1;
5581 SMS.Number = 1; 5586 SMS.Number = 1;
5582 SMS.SMS[0] = *Backup.SMS[smsnum]; 5587 SMS.SMS[0] = *Backup.SMS[smsnum];
5583 displaymultismsinfo(SMS,false,false); 5588 displaymultismsinfo(SMS,false,false);
5584 if (answer_yes("Restore sms")) { 5589 if (answer_yes("Restore sms")) {
5585 error=Phone->AddSMS(&s, Backup.SMS[smsnum]); 5590 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5586 Print_Error(error); 5591 Print_Error(error);
5587 } 5592 }
5588 smsnum++; 5593 smsnum++;
5589 } 5594 }
5590 5595
5591 GSM_Terminate(); 5596 GSM_Terminate();
5592} 5597}
5593 5598
5594static void RestoreSMS(int argc, char *argv[]) 5599static void RestoreSMS(int argc, char *argv[])
5595{ 5600{
5596 GSM_MultiSMSMessage SMS; 5601 GSM_MultiSMSMessage SMS;
5597 GSM_SMS_Backup Backup; 5602 GSM_SMS_Backup Backup;
5598 GSM_SMSFolders folders; 5603 GSM_SMSFolders folders;
5599 int smsnum = 0; 5604 int smsnum = 0;
5600 char buffer[200]; 5605 char buffer[200];
5601 5606
5602 error=GSM_ReadSMSBackupFile(argv[2], &Backup); 5607 error=GSM_ReadSMSBackupFile(argv[2], &Backup);
5603 Print_Error(error); 5608 Print_Error(error);
5604 5609
5605 GSM_Init(true); 5610 GSM_Init(true);
5606 5611
5607 error=Phone->GetSMSFolders(&s, &folders); 5612 error=Phone->GetSMSFolders(&s, &folders);
5608 Print_Error(error); 5613 Print_Error(error);
5609 5614
5610 while (Backup.SMS[smsnum] != NULL) { 5615 while (Backup.SMS[smsnum] != NULL) {
5611 SMS.Number = 1; 5616 SMS.Number = 1;
5612 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); 5617 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
5613 displaymultismsinfo(SMS,false,false); 5618 displaymultismsinfo(SMS,false,false);
5614 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); 5619 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
5615 if (answer_yes(buffer)) { 5620 if (answer_yes(buffer)) {
5616 Backup.SMS[smsnum]->Location = 0; 5621 Backup.SMS[smsnum]->Location = 0;
5617 error=Phone->SetSMS(&s, Backup.SMS[smsnum]); 5622 error=Phone->SetSMS(&s, Backup.SMS[smsnum]);
5618 Print_Error(error); 5623 Print_Error(error);
5619 } 5624 }
5620 smsnum++; 5625 smsnum++;
5621 } 5626 }
5622 5627
5623 GSM_Terminate(); 5628 GSM_Terminate();
5624} 5629}
5625#endif 5630#endif
5626 5631
5627static void CopyBitmap(int argc, char *argv[]) 5632static void CopyBitmap(int argc, char *argv[])
5628{ 5633{
5629 GSM_MultiBitmap Bitmap; 5634 GSM_MultiBitmap Bitmap;
5630 int i; 5635 int i;
5631 5636
5632 Bitmap.Bitmap[0].Type = GSM_None; 5637 Bitmap.Bitmap[0].Type = GSM_None;
5633 5638
5634 error=GSM_ReadBitmapFile(argv[2],&Bitmap); 5639 error=GSM_ReadBitmapFile(argv[2],&Bitmap);
5635 Print_Error(error); 5640 Print_Error(error);
5636 5641
5637 if (argc==3) { 5642 if (argc==3) {
5638 for (i=0;i<Bitmap.Number;i++) { 5643 for (i=0;i<Bitmap.Number;i++) {
5639 switch (Bitmap.Bitmap[i].Type) { 5644 switch (Bitmap.Bitmap[i].Type) {
5640 case GSM_StartupLogo : printmsg("Startup logo"); break; 5645 case GSM_StartupLogo : printmsg("Startup logo"); break;
5641 case GSM_OperatorLogo: printmsg("Operator logo"); break; 5646 case GSM_OperatorLogo: printmsg("Operator logo"); break;
5642 case GSM_PictureImage: printmsg("Picture Image"); break; 5647 case GSM_PictureImage: printmsg("Picture Image"); break;
5643 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break; 5648 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break;
5644 default : break; 5649 default : break;
5645 } 5650 }
5646 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight); 5651 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight);
5647 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]); 5652 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]);
5648 } 5653 }
5649 } else { 5654 } else {
5650 if (argc == 5) { 5655 if (argc == 5) {
5651 for (i=0;i<Bitmap.Number;i++) { 5656 for (i=0;i<Bitmap.Number;i++) {
5652 if (mystrncasecmp(argv[4],"PICTURE",0)) { 5657 if (mystrncasecmp(argv[4],"PICTURE",0)) {
5653 Bitmap.Bitmap[i].Type = GSM_PictureImage; 5658 Bitmap.Bitmap[i].Type = GSM_PictureImage;
5654 } else if (mystrncasecmp(argv[4],"STARTUP",0)) { 5659 } else if (mystrncasecmp(argv[4],"STARTUP",0)) {
5655 Bitmap.Bitmap[i].Type = GSM_StartupLogo; 5660 Bitmap.Bitmap[i].Type = GSM_StartupLogo;
5656 } else if (mystrncasecmp(argv[4],"CALLER",0)) { 5661 } else if (mystrncasecmp(argv[4],"CALLER",0)) {
5657 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; 5662 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo;
5658 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { 5663 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) {
5659 Bitmap.Bitmap[i].Type = GSM_OperatorLogo; 5664 Bitmap.Bitmap[i].Type = GSM_OperatorLogo;
5660 } else { 5665 } else {
5661 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); 5666 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]);
5662 exit(-1); 5667 exit(-1);
5663 } 5668 }
5664 } 5669 }
5665 } 5670 }
5666 error=GSM_SaveBitmapFile(argv[3],&Bitmap); 5671 error=GSM_SaveBitmapFile(argv[3],&Bitmap);
5667 Print_Error(error); 5672 Print_Error(error);
5668 } 5673 }
5669} 5674}
5670 5675
5671static void NokiaComposer(int argc, char *argv[]) 5676static void NokiaComposer(int argc, char *argv[])
5672{ 5677{
5673 GSM_Ringtone ringtone; 5678 GSM_Ringtone ringtone;
5674 bool started; 5679 bool started;
5675 int i,j; 5680 int i,j;
5676 GSM_RingNote *Note; 5681 GSM_RingNote *Note;
5677 GSM_RingNoteDuration Duration; 5682 GSM_RingNoteDuration Duration;
5678 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ 5683 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */
5679 unsigned int DefNoteScale = Scale_880; 5684 unsigned int DefNoteScale = Scale_880;
5680 5685
5681 ringtone.Format= 0; 5686 ringtone.Format= 0;
5682 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5687 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5683 5688
5684 if (ringtone.Format != RING_NOTETONE) { 5689 if (ringtone.Format != RING_NOTETONE) {
5685 printmsg("It can be RTTL ringtone only used with this option\n"); 5690 printmsg("It can be RTTL ringtone only used with this option\n");
5686 exit(-1); 5691 exit(-1);
5687 } 5692 }
5688 5693
5689 started = false; 5694 started = false;
5690 j= 0; 5695 j= 0;
5691 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5696 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5692 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5697 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5693 Note = &ringtone.NoteTone.Commands[i].Note; 5698 Note = &ringtone.NoteTone.Commands[i].Note;
5694 if (!started) { 5699 if (!started) {
5695 if (Note->Note != Note_Pause) { 5700 if (Note->Note != Note_Pause) {
5696 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); 5701 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo));
5697 started = true; 5702 started = true;
5698 } 5703 }
5699 } 5704 }
5700 if (started) j++; 5705 if (started) j++;
5701 } 5706 }
5702 } 5707 }
5703 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); 5708 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j);
5704 5709
5705 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); 5710 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: ");
5706 started = false; 5711 started = false;
5707 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5712 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5708 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5713 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5709 Note = &ringtone.NoteTone.Commands[i].Note; 5714 Note = &ringtone.NoteTone.Commands[i].Note;
5710 if (!started) { 5715 if (!started) {
5711 if (Note->Note != Note_Pause) started = true; 5716 if (Note->Note != Note_Pause) started = true;
5712 } 5717 }
5713 if (started) { 5718 if (started) {
5714 switch (Note->Duration) { 5719 switch (Note->Duration) {
5715 case Duration_Full: printmsg("1"); break; 5720 case Duration_Full: printmsg("1"); break;
5716 case Duration_1_2 : printmsg("2"); break; 5721 case Duration_1_2 : printmsg("2"); break;
5717 case Duration_1_4 : printmsg("4"); break; 5722 case Duration_1_4 : printmsg("4"); break;
5718 case Duration_1_8 : printmsg("8"); break; 5723 case Duration_1_8 : printmsg("8"); break;
5719 case Duration_1_16: printmsg("16");break; 5724 case Duration_1_16: printmsg("16");break;
5720 case Duration_1_32: printmsg("32");break; 5725 case Duration_1_32: printmsg("32");break;
5721 } 5726 }
5722 if (Note->DurationSpec == DottedNote) printmsg("."); 5727 if (Note->DurationSpec == DottedNote) printmsg(".");
5723 switch (Note->Note) { 5728 switch (Note->Note) {
5724 case Note_C : printmsg("c");break; 5729 case Note_C : printmsg("c");break;
5725 case Note_Cis : printmsg("#c");break; 5730 case Note_Cis : printmsg("#c");break;
5726 case Note_D :printmsg("d");break; 5731 case Note_D :printmsg("d");break;
5727 case Note_Dis : printmsg("#d");break; 5732 case Note_Dis : printmsg("#d");break;
5728 case Note_E : printmsg("e");break; 5733 case Note_E : printmsg("e");break;
5729 case Note_F : printmsg("f");break; 5734 case Note_F : printmsg("f");break;
5730 case Note_Fis : printmsg("#f");break; 5735 case Note_Fis : printmsg("#f");break;
5731 case Note_G : printmsg("g");break; 5736 case Note_G : printmsg("g");break;
5732 case Note_Gis : printmsg("#g");break; 5737 case Note_Gis : printmsg("#g");break;
5733 case Note_A : printmsg("a");break; 5738 case Note_A : printmsg("a");break;
5734 case Note_Ais : printmsg("#a");break; 5739 case Note_Ais : printmsg("#a");break;
5735 case Note_H : printmsg("h");break; 5740 case Note_H : printmsg("h");break;
5736 case Note_Pause : printmsg("-");break; 5741 case Note_Pause : printmsg("-");break;
5737 } 5742 }
5738 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4); 5743 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4);
5739 printmsg(" "); 5744 printmsg(" ");
5740 } 5745 }
5741 } 5746 }
5742 } 5747 }
5743 5748
5744 printmsg("\n\nTo enter it please press: "); 5749 printmsg("\n\nTo enter it please press: ");
5745 started = false; 5750 started = false;
5746 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5751 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5747 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5752 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5748 Note = &ringtone.NoteTone.Commands[i].Note; 5753 Note = &ringtone.NoteTone.Commands[i].Note;
5749 if (!started) { 5754 if (!started) {
5750 if (Note->Note != Note_Pause) started = true; 5755 if (Note->Note != Note_Pause) started = true;
5751 } 5756 }
5752 if (started) { 5757 if (started) {
5753 switch (Note->Note) { 5758 switch (Note->Note) {
5754 case Note_C : case Note_Cis:printmsg("1");break; 5759 case Note_C : case Note_Cis:printmsg("1");break;
5755 case Note_D : case Note_Dis:printmsg("2");break; 5760 case Note_D : case Note_Dis:printmsg("2");break;
5756 case Note_E : printmsg("3");break; 5761 case Note_E : printmsg("3");break;
5757 case Note_F : case Note_Fis:printmsg("4");break; 5762 case Note_F : case Note_Fis:printmsg("4");break;
5758 case Note_G : case Note_Gis:printmsg("5");break; 5763 case Note_G : case Note_Gis:printmsg("5");break;
5759 case Note_A : case Note_Ais:printmsg("6");break; 5764 case Note_A : case Note_Ais:printmsg("6");break;
5760 case Note_H : printmsg("7");break; 5765 case Note_H : printmsg("7");break;
5761 default : printmsg("0");break; 5766 default : printmsg("0");break;
5762 } 5767 }
5763 if (Note->DurationSpec == DottedNote) printmsg("(longer)"); 5768 if (Note->DurationSpec == DottedNote) printmsg("(longer)");
5764 switch (Note->Note) { 5769 switch (Note->Note) {
5765 case Note_Cis: case Note_Dis: 5770 case Note_Cis: case Note_Dis:
5766 case Note_Fis: case Note_Gis: 5771 case Note_Fis: case Note_Gis:
5767 case Note_Ais: 5772 case Note_Ais:
5768 printmsg("#"); 5773 printmsg("#");
5769 break; 5774 break;
5770 default : 5775 default :
5771 break; 5776 break;
5772 } 5777 }
5773 if (Note->Note != Note_Pause) { 5778 if (Note->Note != Note_Pause) {
5774 if ((unsigned int)Note->Scale != DefNoteScale) { 5779 if ((unsigned int)Note->Scale != DefNoteScale) {
5775 while (DefNoteScale != (unsigned int)Note->Scale) { 5780 while (DefNoteScale != (unsigned int)Note->Scale) {
5776 printmsg("*"); 5781 printmsg("*");
5777 DefNoteScale++; 5782 DefNoteScale++;
5778 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880; 5783 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880;
5779 } 5784 }
5780 } 5785 }
5781 } 5786 }
5782 Duration = 0; 5787 Duration = 0;
5783 switch (Note->Duration) { 5788 switch (Note->Duration) {
5784 case Duration_Full : Duration = 128;break; 5789 case Duration_Full : Duration = 128;break;
5785 case Duration_1_2 : Duration = 64;break; 5790 case Duration_1_2 : Duration = 64;break;
5786 case Duration_1_4 : Duration = 32;break; 5791 case Duration_1_4 : Duration = 32;break;
5787 case Duration_1_8 : Duration = 16;break; 5792 case Duration_1_8 : Duration = 16;break;
5788 case Duration_1_16 : Duration = 8;break; 5793 case Duration_1_16 : Duration = 8;break;
5789 case Duration_1_32 : Duration = 4;break; 5794 case Duration_1_32 : Duration = 4;break;
5790 default : dbgprintf("error\n");break; 5795 default : dbgprintf("error\n");break;
5791 } 5796 }
5792 if (Duration > DefNoteDuration) { 5797 if (Duration > DefNoteDuration) {
5793 while (DefNoteDuration != Duration) { 5798 while (DefNoteDuration != Duration) {
5794 printmsg("9"); 5799 printmsg("9");
5795 DefNoteDuration = DefNoteDuration * 2; 5800 DefNoteDuration = DefNoteDuration * 2;
5796 } 5801 }
5797 } 5802 }
5798 if (Duration < DefNoteDuration) { 5803 if (Duration < DefNoteDuration) {
5799 while (DefNoteDuration != Duration) { 5804 while (DefNoteDuration != Duration) {
5800 printmsg("8"); 5805 printmsg("8");
5801 DefNoteDuration = DefNoteDuration / 2; 5806 DefNoteDuration = DefNoteDuration / 2;
5802 } 5807 }
5803 } 5808 }
5804 printmsg(" "); 5809 printmsg(" ");
5805 } 5810 }
5806 } 5811 }
5807 } 5812 }
5808 5813
5809 printf("\n"); 5814 printf("\n");
5810} 5815}
5811//#if 0 5816//#if 0
5812static void CopyRingtone(int argc, char *argv[]) 5817static void CopyRingtone(int argc, char *argv[])
5813{ 5818{
5814 GSM_Ringtone ringtone, ringtone2; 5819 GSM_Ringtone ringtone, ringtone2;
5815 GSM_RingtoneFormatFormat; 5820 GSM_RingtoneFormatFormat;
5816 5821
5817 ringtone.Format= 0; 5822 ringtone.Format= 0;
5818 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5823 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5819 Print_Error(error); 5824 Print_Error(error);
5820 5825
5821 Format = ringtone.Format; 5826 Format = ringtone.Format;
5822 if (argc == 5) { 5827 if (argc == 5) {
5823 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; 5828 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE;
5824 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY; 5829 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY;
5825 } else { 5830 } else {
5826 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]); 5831 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]);
5827 exit(-1); 5832 exit(-1);
5828 } 5833 }
5829 } 5834 }
5830 5835
5831 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format); 5836 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format);
5832 Print_Error(error); 5837 Print_Error(error);
5833 5838
5834 error=GSM_SaveRingtoneFile(argv[3],&ringtone2); 5839 error=GSM_SaveRingtoneFile(argv[3],&ringtone2);
5835 Print_Error(error); 5840 Print_Error(error);
5836} 5841}
5837 5842
5838static void PressKeySequence(int argc, char *argv[]) 5843static void PressKeySequence(int argc, char *argv[])
5839{ 5844{
5840 int i,Length; 5845 int i,Length;
5841 GSM_KeyCodeKeyCode[500]; 5846 GSM_KeyCodeKeyCode[500];
5842 5847
5843 error = MakeKeySequence(argv[2], KeyCode, &Length); 5848 error = MakeKeySequence(argv[2], KeyCode, &Length);
5844 if (error == ERR_NOTSUPPORTED) { 5849 if (error == ERR_NOTSUPPORTED) {
5845 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]); 5850 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]);
5846 exit(-1); 5851 exit(-1);
5847 } 5852 }
5848 5853
5849 GSM_Init(true); 5854 GSM_Init(true);
5850 5855
5851 for (i=0;i<Length;i++) { 5856 for (i=0;i<Length;i++) {
5852 error=Phone->PressKey(&s, KeyCode[i], true); 5857 error=Phone->PressKey(&s, KeyCode[i], true);
5853 Print_Error(error); 5858 Print_Error(error);
5854 error=Phone->PressKey(&s, KeyCode[i], false); 5859 error=Phone->PressKey(&s, KeyCode[i], false);
5855 Print_Error(error); 5860 Print_Error(error);
5856 } 5861 }
5857 5862
5858 GSM_Terminate(); 5863 GSM_Terminate();
5859} 5864}
5860 5865
5861static void GetAllCategories(int argc, char *argv[]) 5866static void GetAllCategories(int argc, char *argv[])
5862{ 5867{
5863 GSM_Category Category; 5868 GSM_Category Category;
5864 GSM_CategoryStatusStatus; 5869 GSM_CategoryStatusStatus;
5865 int j, count; 5870 int j, count;
5866 5871
5867 if (mystrncasecmp(argv[2],"TODO",0)) { 5872 if (mystrncasecmp(argv[2],"TODO",0)) {
5868 Category.Type = Category_ToDo; 5873 Category.Type = Category_ToDo;
5869 Status.Type = Category_ToDo; 5874 Status.Type = Category_ToDo;
5870 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 5875 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
5871 Category.Type = Category_Phonebook; 5876 Category.Type = Category_Phonebook;
5872 Status.Type = Category_Phonebook; 5877 Status.Type = Category_Phonebook;
5873 } else { 5878 } else {
5874 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 5879 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
5875 exit(-1); 5880 exit(-1);
5876 } 5881 }
5877 5882
5878 GSM_Init(true); 5883 GSM_Init(true);
5879 5884
5880 error=Phone->GetCategoryStatus(&s, &Status); 5885 error=Phone->GetCategoryStatus(&s, &Status);
5881 Print_Error(error); 5886 Print_Error(error);
5882 5887
5883 for (count=0,j=1;count<Status.Used;j++) 5888 for (count=0,j=1;count<Status.Used;j++)
5884 { 5889 {
5885 Category.Location=j; 5890 Category.Location=j;
5886 error=Phone->GetCategory(&s, &Category); 5891 error=Phone->GetCategory(&s, &Category);
5887 5892
5888 if (error != ERR_EMPTY) { 5893 if (error != ERR_EMPTY) {
5889 printmsg("Location: %i\n",j); 5894 printmsg("Location: %i\n",j);
5890 5895
5891 Print_Error(error); 5896 Print_Error(error);
5892 5897
5893 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 5898 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
5894 count++; 5899 count++;
5895 } 5900 }
5896 } 5901 }
5897 5902
5898 GSM_Terminate(); 5903 GSM_Terminate();
5899} 5904}
5900 5905
5901static void GetCategory(int argc, char *argv[]) 5906static void GetCategory(int argc, char *argv[])
5902{ 5907{
5903 GSM_CategoryCategory; 5908 GSM_CategoryCategory;
5904 int start,stop,j; 5909 int start,stop,j;
5905 5910
5906 if (mystrncasecmp(argv[2],"TODO",0)) { 5911 if (mystrncasecmp(argv[2],"TODO",0)) {
5907 Category.Type = Category_ToDo; 5912 Category.Type = Category_ToDo;
5908 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 5913 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
5909 Category.Type = Category_Phonebook; 5914 Category.Type = Category_Phonebook;
5910 } else { 5915 } else {
5911 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 5916 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
5912 exit(-1); 5917 exit(-1);
5913 } 5918 }
5914 5919
5915 GetStartStop(&start, &stop, 2, argc - 1, argv + 1); 5920 GetStartStop(&start, &stop, 2, argc - 1, argv + 1);
5916 5921
5917 GSM_Init(true); 5922 GSM_Init(true);
5918 5923
5919 for (j=start;j<=stop;j++) 5924 for (j=start;j<=stop;j++)
5920 { 5925 {
5921 printmsg("Location: %i\n",j); 5926 printmsg("Location: %i\n",j);
5922 5927
5923 Category.Location=j; 5928 Category.Location=j;
5924 5929
5925 error=Phone->GetCategory(&s, &Category); 5930 error=Phone->GetCategory(&s, &Category);
5926 if (error != ERR_EMPTY) Print_Error(error); 5931 if (error != ERR_EMPTY) Print_Error(error);
5927 5932
5928 if (error == ERR_EMPTY) { 5933 if (error == ERR_EMPTY) {
5929 printmsg("Entry is empty\n\n"); 5934 printmsg("Entry is empty\n\n");
5930 } else { 5935 } else {
5931 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 5936 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
5932 } 5937 }
5933 } 5938 }
5934 5939
5935 GSM_Terminate(); 5940 GSM_Terminate();
5936} 5941}
5937 5942
5938static void DeleteToDo(int argc, char *argv[]) 5943static void DeleteToDo(int argc, char *argv[])
5939{ 5944{
5940 GSM_ToDoEntryToDo; 5945 GSM_ToDoEntryToDo;
5941 int i; 5946 int i;
5942 int start,stop; 5947 int start,stop;
5943 5948
5944 GetStartStop(&start, &stop, 2, argc, argv); 5949 GetStartStop(&start, &stop, 2, argc, argv);
5945 5950
5946 GSM_Init(true); 5951 GSM_Init(true);
5947 5952
5948 for (i=start;i<=stop;i++) { 5953 for (i=start;i<=stop;i++) {
5949 ToDo.Location=i; 5954 ToDo.Location=i;
5950 printmsg("Location : %i\n",i); 5955 printmsg("Location : %i\n",i);
5951 error=Phone->DeleteToDo(&s,&ToDo); 5956 error=Phone->DeleteToDo(&s,&ToDo);
5952 if (error != ERR_EMPTY) Print_Error(error); 5957 if (error != ERR_EMPTY) Print_Error(error);
5953 5958
5954 if (error == ERR_EMPTY) { 5959 if (error == ERR_EMPTY) {
5955 printmsg("Entry was empty\n"); 5960 printmsg("Entry was empty\n");
5956 } else { 5961 } else {
5957 printmsg("Entry was deleted\n"); 5962 printmsg("Entry was deleted\n");
5958 } 5963 }
5959 printf("\n"); 5964 printf("\n");
5960 } 5965 }
5961 5966
5962 GSM_Terminate(); 5967 GSM_Terminate();
5963} 5968}
5964 5969
5965static void PrintToDo(GSM_ToDoEntry *ToDo) 5970static void PrintToDo(GSM_ToDoEntry *ToDo)
5966{ 5971{
5967 int j; 5972 int j;
5968 GSM_MemoryEntry entry; 5973 GSM_MemoryEntry entry;
5969 unsigned char *name; 5974 unsigned char *name;
5970 GSM_Category Category; 5975 GSM_Category Category;
5971 5976
5972 printmsg("Location : %i\n",ToDo->Location); 5977 printmsg("Location : %i\n",ToDo->Location);
5973 printmsg("Priority : "); 5978 printmsg("Priority : ");
5974 switch (ToDo->Priority) { 5979 switch (ToDo->Priority) {
5975 case GSM_Priority_Low : printmsg("Low\n"); break; 5980 case GSM_Priority_Low : printmsg("Low\n"); break;
5976 case GSM_Priority_Medium : printmsg("Medium\n"); break; 5981 case GSM_Priority_Medium : printmsg("Medium\n"); break;
5977 case GSM_Priority_High : printmsg("High\n"); break; 5982 case GSM_Priority_High : printmsg("High\n"); break;
5978 default : printmsg("Unknown\n");break; 5983 default : printmsg("Unknown\n");break;
5979 } 5984 }
5980 for (j=0;j<ToDo->EntriesNum;j++) { 5985 for (j=0;j<ToDo->EntriesNum;j++) {
5981 switch (ToDo->Entries[j].EntryType) { 5986 switch (ToDo->Entries[j].EntryType) {
5982 case TODO_END_DATETIME: 5987 case TODO_END_DATETIME:
5983 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 5988 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
5984 break; 5989 break;
5985 case TODO_COMPLETED: 5990 case TODO_COMPLETED:
5986 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 5991 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
5987 break; 5992 break;
5988 case TODO_ALARM_DATETIME: 5993 case TODO_ALARM_DATETIME:
5989 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 5994 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
5990 break; 5995 break;
5991 case TODO_SILENT_ALARM_DATETIME: 5996 case TODO_SILENT_ALARM_DATETIME:
5992 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 5997 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
5993 break; 5998 break;
5994 case TODO_TEXT: 5999 case TODO_TEXT:
5995 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 6000 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
5996 break; 6001 break;
5997 case TODO_PRIVATE: 6002 case TODO_PRIVATE:
5998 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 6003 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
5999 break; 6004 break;
6000 case TODO_CATEGORY: 6005 case TODO_CATEGORY:
6001 Category.Location = ToDo->Entries[j].Number; 6006 Category.Location = ToDo->Entries[j].Number;
6002 Category.Type = Category_ToDo; 6007 Category.Type = Category_ToDo;
6003 error=Phone->GetCategory(&s, &Category); 6008 error=Phone->GetCategory(&s, &Category);
6004 if (error == ERR_NONE) { 6009 if (error == ERR_NONE) {
6005 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number); 6010 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number);
6006 } else { 6011 } else {
6007 printmsg("Category : %i\n", ToDo->Entries[j].Number); 6012 printmsg("Category : %i\n", ToDo->Entries[j].Number);
6008 } 6013 }
6009 break; 6014 break;
6010 case TODO_CONTACTID: 6015 case TODO_CONTACTID:
6011 entry.Location = ToDo->Entries[j].Number; 6016 entry.Location = ToDo->Entries[j].Number;
6012 entry.MemoryType = MEM_ME; 6017 entry.MemoryType = MEM_ME;
6013 error=Phone->GetMemory(&s, &entry); 6018 error=Phone->GetMemory(&s, &entry);
6014 if (error == ERR_NONE) { 6019 if (error == ERR_NONE) {
6015 name = GSM_PhonebookGetEntryName(&entry); 6020 name = GSM_PhonebookGetEntryName(&entry);
6016 if (name != NULL) { 6021 if (name != NULL) {
6017 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 6022 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
6018 } else { 6023 } else {
6019 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 6024 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
6020 } 6025 }
6021 } else { 6026 } else {
6022 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 6027 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
6023 } 6028 }
6024 break; 6029 break;
6025 case TODO_PHONE: 6030 case TODO_PHONE:
6026 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 6031 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
6027 break; 6032 break;
6028 } 6033 }
6029 } 6034 }
6030 printf("\n"); 6035 printf("\n");
6031} 6036}
6032 6037
6033static void ListToDoCategoryEntries(int Category) 6038static void ListToDoCategoryEntries(int Category)
6034{ 6039{
6035 GSM_ToDoEntry Entry; 6040 GSM_ToDoEntry Entry;
6036 bool start = true; 6041 bool start = true;
6037 int j; 6042 int j;
6038 6043
6039 while (!gshutdown) { 6044 while (!gshutdown) {
6040 error = Phone->GetNextToDo(&s, &Entry, start); 6045 error = Phone->GetNextToDo(&s, &Entry, start);
6041 if (error == ERR_EMPTY) break; 6046 if (error == ERR_EMPTY) break;
6042 Print_Error(error); 6047 Print_Error(error);
6043 for (j=0;j<Entry.EntriesNum;j++) { 6048 for (j=0;j<Entry.EntriesNum;j++) {
6044 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category) 6049 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category)
6045 PrintToDo(&Entry); 6050 PrintToDo(&Entry);
6046 } 6051 }
6047 start = false; 6052 start = false;
6048 } 6053 }
6049} 6054}
6050 6055
6051static void ListToDoCategory(int argc, char *argv[]) 6056static void ListToDoCategory(int argc, char *argv[])
6052{ 6057{
6053 GSM_Category Category; 6058 GSM_Category Category;
6054 GSM_CategoryStatusStatus; 6059 GSM_CategoryStatusStatus;
6055 int j, count; 6060 int j, count;
6056 6061
6057 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; 6062 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
6058 int Length; 6063 int Length;
6059 bool Number = true;; 6064 bool Number = true;;
6060 6065
6061 GSM_Init(true); 6066 GSM_Init(true);
6062 6067
6063 signal(SIGINT, interrupt); 6068 signal(SIGINT, interrupt);
6064 printmsgerr("Press Ctrl+C to break...\n"); 6069 printmsgerr("Press Ctrl+C to break...\n");
6065 6070
6066 Length = strlen(argv[2]); 6071 Length = strlen(argv[2]);
6067 for (j = 0; j < Length; j++) { 6072 for (j = 0; j < Length; j++) {
6068 if (!isdigit(argv[2][j])) { 6073 if (!isdigit(argv[2][j])) {
6069 Number = false; 6074 Number = false;
6070 break; 6075 break;
6071 } 6076 }
6072 } 6077 }
6073 6078
6074 if (Number) { 6079 if (Number) {
6075 j = atoi(argv[2]); 6080 j = atoi(argv[2]);
6076 if (j > 0) { 6081 if (j > 0) {
6077 ListToDoCategoryEntries(j); 6082 ListToDoCategoryEntries(j);
6078 } 6083 }
6079 } else { 6084 } else {
6080 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { 6085 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
6081 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); 6086 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
6082 Length = GSM_MAX_CATEGORY_NAME_LENGTH; 6087 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
6083 } 6088 }
6084 EncodeUnicode(Text, argv[2], Length); 6089 EncodeUnicode(Text, argv[2], Length);
6085 6090
6086 Category.Type = Category_ToDo; 6091 Category.Type = Category_ToDo;
6087 Status.Type = Category_ToDo; 6092 Status.Type = Category_ToDo;
6088 6093
6089 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 6094 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
6090 for (count=0,j=1;count<Status.Used;j++) { 6095 for (count=0,j=1;count<Status.Used;j++) {
6091 Category.Location=j; 6096 Category.Location=j;
6092 error=Phone->GetCategory(&s, &Category); 6097 error=Phone->GetCategory(&s, &Category);
6093 6098
6094 if (error != ERR_EMPTY) { 6099 if (error != ERR_EMPTY) {
6095 count++; 6100 count++;
6096 if (mystrstr(Category.Name, Text) != NULL) { 6101 if (mystrstr(Category.Name, Text) != NULL) {
6097 ListToDoCategoryEntries(j); 6102 ListToDoCategoryEntries(j);
6098 } 6103 }
6099 } 6104 }
6100 } 6105 }
6101 } 6106 }
6102 } 6107 }
6103 GSM_Terminate(); 6108 GSM_Terminate();
6104} 6109}
6105 6110
6106 6111
6107static void GetToDo(int argc, char *argv[]) 6112static void GetToDo(int argc, char *argv[])
6108{ 6113{
6109 GSM_ToDoEntryToDo; 6114 GSM_ToDoEntryToDo;
6110 int i; 6115 int i;
6111 int start,stop; 6116 int start,stop;
6112 6117
6113 GetStartStop(&start, &stop, 2, argc, argv); 6118 GetStartStop(&start, &stop, 2, argc, argv);
6114 6119
6115 GSM_Init(true); 6120 GSM_Init(true);
6116 6121
6117 for (i=start;i<=stop;i++) { 6122 for (i=start;i<=stop;i++) {
6118 ToDo.Location=i; 6123 ToDo.Location=i;
6119 error = Phone->GetToDo(&s,&ToDo); 6124 error = Phone->GetToDo(&s,&ToDo);
6120 if (error == ERR_EMPTY) continue; 6125 if (error == ERR_EMPTY) continue;
6121 Print_Error(error); 6126 Print_Error(error);
6122 PrintToDo(&ToDo); 6127 PrintToDo(&ToDo);
6123 } 6128 }
6124 6129
6125 GSM_Terminate(); 6130 GSM_Terminate();
6126} 6131}
6127 6132
6128static void GetAllToDo(int argc, char *argv[]) 6133static void GetAllToDo(int argc, char *argv[])
6129{ 6134{
6130 GSM_ToDoEntry ToDo; 6135 GSM_ToDoEntry ToDo;
6131 bool start = true; 6136 bool start = true;
6132 6137
6133 signal(SIGINT, interrupt); 6138 signal(SIGINT, interrupt);
6134 printmsgerr("Press Ctrl+C to break...\n"); 6139 printmsgerr("Press Ctrl+C to break...\n");
6135 6140
6136 GSM_Init(true); 6141 GSM_Init(true);
6137 6142
6138 while (!gshutdown) { 6143 while (!gshutdown) {
6139 error = Phone->GetNextToDo(&s, &ToDo, start); 6144 error = Phone->GetNextToDo(&s, &ToDo, start);
6140 if (error == ERR_EMPTY) break; 6145 if (error == ERR_EMPTY) break;
6141 Print_Error(error); 6146 Print_Error(error);
6142 PrintToDo(&ToDo); 6147 PrintToDo(&ToDo);
6143 start = false; 6148 start = false;
6144 } 6149 }
6145 6150
6146 GSM_Terminate(); 6151 GSM_Terminate();
6147} 6152}
6148 6153
6149static void GetNote(int argc, char *argv[]) 6154static void GetNote(int argc, char *argv[])
6150{ 6155{
6151 GSM_NoteEntry Note; 6156 GSM_NoteEntry Note;
6152 int start,stop; 6157 int start,stop;
6153 bool refresh=true; 6158 bool refresh=true;
6154 6159
6155 GetStartStop(&start, &stop, 2, argc, argv); 6160 GetStartStop(&start, &stop, 2, argc, argv);
6156 6161
6157 GSM_Init(true); 6162 GSM_Init(true);
6158 6163
6159 for (i=start;i<=stop;i++) { 6164 for (i=start;i<=stop;i++) {
6160 Note.Location=i; 6165 Note.Location=i;
6161 printmsg("Location : %i\n",i); 6166 printmsg("Location : %i\n",i);
6162 error=Phone->GetNote(&s,&Note,refresh); 6167 error=Phone->GetNote(&s,&Note,refresh);
6163 if (error != ERR_EMPTY) Print_Error(error); 6168 if (error != ERR_EMPTY) Print_Error(error);
6164 6169
6165 if (error == ERR_EMPTY) { 6170 if (error == ERR_EMPTY) {
6166 printmsg("Entry is empty\n\n"); 6171 printmsg("Entry is empty\n\n");
6167 } else { 6172 } else {
6168 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text)); 6173 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
6169 printf("\n"); 6174 printf("\n");
6170 refresh=false; 6175 refresh=false;
6171 } 6176 }
6172 } 6177 }
6173 6178
6174 GSM_Terminate(); 6179 GSM_Terminate();
6175} 6180}
6176 6181
6177static void GetSecurityStatus(int argc, char *argv[]) 6182static void GetSecurityStatus(int argc, char *argv[])
6178{ 6183{
6179 GSM_Init(true); 6184 GSM_Init(true);
6180 6185
6181 PrintSecurityStatus(); 6186 PrintSecurityStatus();
6182 6187
6183 GSM_Terminate(); 6188 GSM_Terminate();
6184} 6189}
6185 6190
6186static void EnterSecurityCode(int argc, char *argv[]) 6191static void EnterSecurityCode(int argc, char *argv[])
6187{ 6192{
6188 GSM_SecurityCode Code; 6193 GSM_SecurityCode Code;
6189 6194
6190 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin; 6195 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin;
6191 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk; 6196 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk;
6192 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2; 6197 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2;
6193 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2; 6198 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2;
6194 } else { 6199 } else {
6195 printmsg("What security code (\"%s\") ?\n",argv[2]); 6200 printmsg("What security code (\"%s\") ?\n",argv[2]);
6196 exit(-1); 6201 exit(-1);
6197 } 6202 }
6198 6203
6199 strcpy(Code.Code,argv[3]); 6204 strcpy(Code.Code,argv[3]);
6200 6205
6201 GSM_Init(true); 6206 GSM_Init(true);
6202 6207
6203 error=Phone->EnterSecurityCode(&s,Code); 6208 error=Phone->EnterSecurityCode(&s,Code);
6204 Print_Error(error); 6209 Print_Error(error);
6205 6210
6206 GSM_Terminate(); 6211 GSM_Terminate();
6207} 6212}
6208 6213
6209static void GetProfile(int argc, char *argv[]) 6214static void GetProfile(int argc, char *argv[])
6210{ 6215{
6211 GSM_Profile Profile; 6216 GSM_Profile Profile;
6212 int start,stop,j,k; 6217 int start,stop,j,k;
6213 GSM_Bitmap caller[5]; 6218 GSM_Bitmap caller[5];
6214 bool callerinit[5],special; 6219 bool callerinit[5],special;
6215 GSM_AllRingtonesInfo Info; 6220 GSM_AllRingtonesInfo Info;
6216 6221
6217 GetStartStop(&start, &stop, 2, argc, argv); 6222 GetStartStop(&start, &stop, 2, argc, argv);
6218 6223
6219 for (i=0;i<5;i++) callerinit[i] = false; 6224 for (i=0;i<5;i++) callerinit[i] = false;
6220 6225
6221 GSM_Init(true); 6226 GSM_Init(true);
6222 6227
6223 error=Phone->GetRingtonesInfo(&s,&Info); 6228 error=Phone->GetRingtonesInfo(&s,&Info);
6224 if (error != ERR_NONE) Info.Number = 0; 6229 if (error != ERR_NONE) Info.Number = 0;
6225 6230
6226 for (i=start;i<=stop;i++) { 6231 for (i=start;i<=stop;i++) {
6227 Profile.Location=i; 6232 Profile.Location=i;
6228 error=Phone->GetProfile(&s,&Profile); 6233 error=Phone->GetProfile(&s,&Profile);
6229 Print_Error(error); 6234 Print_Error(error);
6230 6235
6231 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); 6236 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name));
6232 if (Profile.Active) printmsg(" (active)"); 6237 if (Profile.Active) printmsg(" (active)");
6233 if (Profile.DefaultName) printmsg(" (default name)"); 6238 if (Profile.DefaultName) printmsg(" (default name)");
6234 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); 6239 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)");
6235 if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); 6240 if (Profile.CarKitProfile) printmsg(" (CarKit profile)");
6236 printf("\n"); 6241 printf("\n");
6237 for (j=0;j<Profile.FeaturesNumber;j++) { 6242 for (j=0;j<Profile.FeaturesNumber;j++) {
6238 special = false; 6243 special = false;
6239 switch (Profile.FeatureID[j]) { 6244 switch (Profile.FeatureID[j]) {
6240 case Profile_MessageToneID: 6245 case Profile_MessageToneID:
6241 case Profile_RingtoneID: 6246 case Profile_RingtoneID:
6242 special = true; 6247 special = true;
6243 if (Profile.FeatureID[j] == Profile_RingtoneID) { 6248 if (Profile.FeatureID[j] == Profile_RingtoneID) {
6244 printmsg("Ringtone ID : "); 6249 printmsg("Ringtone ID : ");
6245 } else { 6250 } else {
6246 printmsg("Message alert tone ID : "); 6251 printmsg("Message alert tone ID : ");
6247 } 6252 }
6248 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { 6253 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) {
6249 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); 6254 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j])));
6250 } else { 6255 } else {
6251 printmsg("%i\n",Profile.FeatureValue[j]); 6256 printmsg("%i\n",Profile.FeatureValue[j]);
6252 } 6257 }
6253 break; 6258 break;
6254 case Profile_CallerGroups: 6259 case Profile_CallerGroups:
6255 special = true; 6260 special = true;
6256 printmsg("Call alert for :"); 6261 printmsg("Call alert for :");
6257 for (k=0;k<5;k++) { 6262 for (k=0;k<5;k++) {
6258 if (Profile.CallerGroups[k]) { 6263 if (Profile.CallerGroups[k]) {
6259 if (!callerinit[k]) { 6264 if (!callerinit[k]) {
6260 caller[k].Type = GSM_CallerGroupLogo; 6265 caller[k].Type = GSM_CallerGroupLogo;
6261 caller[k].Location = k + 1; 6266 caller[k].Location = k + 1;
6262 error=Phone->GetBitmap(&s,&caller[k]); 6267 error=Phone->GetBitmap(&s,&caller[k]);
6263 if (error == ERR_SECURITYERROR) { 6268 if (error == ERR_SECURITYERROR) {
6264 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); 6269 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]);
6265 } else { 6270 } else {
6266 Print_Error(error); 6271 Print_Error(error);
6267 } 6272 }
6268 callerinit[k]= true; 6273 callerinit[k]= true;
6269 } 6274 }
6270 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); 6275 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text));
6271 } 6276 }
6272 } 6277 }
6273 printf("\n"); 6278 printf("\n");
6274 break; 6279 break;
6275 case Profile_ScreenSaverNumber: 6280 case Profile_ScreenSaverNumber:
6276 special = true; 6281 special = true;
6277 printmsg("Screen saver number : "); 6282 printmsg("Screen saver number : ");
6278 printmsg("%i\n",Profile.FeatureValue[j]); 6283 printmsg("%i\n",Profile.FeatureValue[j]);
6279 break; 6284 break;
6280 case Profile_CallAlert : printmsg("Incoming call alert : "); break; 6285 case Profile_CallAlert : printmsg("Incoming call alert : "); break;
6281 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; 6286 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break;
6282 case Profile_Vibration : printmsg("Vibrating alert : "); break; 6287 case Profile_Vibration : printmsg("Vibrating alert : "); break;
6283 case Profile_MessageTone: printmsg("Message alert tone : "); break; 6288 case Profile_MessageTone: printmsg("Message alert tone : "); break;
6284 case Profile_KeypadTone : printmsg("Keypad tones : "); break; 6289 case Profile_KeypadTone : printmsg("Keypad tones : "); break;
6285 case Profile_WarningTone: printmsg("Warning (games) tones : "); break; 6290 case Profile_WarningTone: printmsg("Warning (games) tones : "); break;
6286 case Profile_ScreenSaver: printmsg("Screen saver : "); break; 6291 case Profile_ScreenSaver: printmsg("Screen saver : "); break;
6287 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break; 6292 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break;
6288 case Profile_AutoAnswer : printmsg("Automatic answer : "); break; 6293 case Profile_AutoAnswer : printmsg("Automatic answer : "); break;
6289 case Profile_Lights : printmsg("Lights : "); break; 6294 case Profile_Lights : printmsg("Lights : "); break;
6290 default: 6295 default:
6291 printmsg("Unknown\n"); 6296 printmsg("Unknown\n");
6292 special = true; 6297 special = true;
6293 } 6298 }
6294 if (!special) { 6299 if (!special) {
6295 switch (Profile.FeatureValue[j]) { 6300 switch (Profile.FeatureValue[j]) {
6296 case PROFILE_VOLUME_LEVEL1 : 6301 case PROFILE_VOLUME_LEVEL1 :
6297 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; 6302 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break;
6298 case PROFILE_VOLUME_LEVEL2 : 6303 case PROFILE_VOLUME_LEVEL2 :
6299 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; 6304 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break;
6300 case PROFILE_VOLUME_LEVEL3 : 6305 case PROFILE_VOLUME_LEVEL3 :
6301 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; 6306 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break;
6302 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; 6307 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break;
6303 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; 6308 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break;
6304 case PROFILE_MESSAGE_NOTONE : 6309 case PROFILE_MESSAGE_NOTONE :
6305 case PROFILE_AUTOANSWER_OFF : 6310 case PROFILE_AUTOANSWER_OFF :
6306 case PROFILE_LIGHTS_OFF : 6311 case PROFILE_LIGHTS_OFF :
6307 case PROFILE_SAVER_OFF : 6312 case PROFILE_SAVER_OFF :
6308 case PROFILE_WARNING_OFF : 6313 case PROFILE_WARNING_OFF :
6309 case PROFILE_CALLALERT_OFF : 6314 case PROFILE_CALLALERT_OFF :
6310 case PROFILE_VIBRATION_OFF : 6315 case PROFILE_VIBRATION_OFF :
6311 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; 6316 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break;
6312 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; 6317 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break;
6313 case PROFILE_CALLALERT_BEEPONCE : 6318 case PROFILE_CALLALERT_BEEPONCE :
6314 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; 6319 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break;
6315 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break; 6320 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break;
6316 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; 6321 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break;
6317 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break; 6322 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break;
6318 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; 6323 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break;
6319 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; 6324 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break;
6320 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; 6325 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break;
6321 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; 6326 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break;
6322 case PROFILE_AUTOANSWER_ON : 6327 case PROFILE_AUTOANSWER_ON :
6323 case PROFILE_WARNING_ON : 6328 case PROFILE_WARNING_ON :
6324 case PROFILE_SAVER_ON : 6329 case PROFILE_SAVER_ON :
6325 case PROFILE_VIBRATION_ON : printmsg("On\n"); break; 6330 case PROFILE_VIBRATION_ON : printmsg("On\n"); break;
6326 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break; 6331 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break;
6327 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; 6332 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break;
6328 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; 6333 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break;
6329 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; 6334 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break;
6330 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; 6335 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break;
6331 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break; 6336 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break;
6332 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break; 6337 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break;
6333 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break; 6338 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break;
6334 default : printmsg("UNKNOWN\n"); 6339 default : printmsg("UNKNOWN\n");
6335 } 6340 }
6336 } 6341 }
6337 } 6342 }
6338 printf("\n"); 6343 printf("\n");
6339 } 6344 }
6340 6345
6341 GSM_Terminate(); 6346 GSM_Terminate();
6342} 6347}
6343 6348
6344static void GetSpeedDial(int argc, char *argv[]) 6349static void GetSpeedDial(int argc, char *argv[])
6345{ 6350{
6346 GSM_SpeedDial SpeedDial; 6351 GSM_SpeedDial SpeedDial;
6347 GSM_MemoryEntry Phonebook; 6352 GSM_MemoryEntry Phonebook;
6348 int start,stop,Name,Number,Group; 6353 int start,stop,Name,Number,Group;
6349 6354
6350 GetStartStop(&start, &stop, 2, argc, argv); 6355 GetStartStop(&start, &stop, 2, argc, argv);
6351 6356
6352 GSM_Init(true); 6357 GSM_Init(true);
6353 6358
6354 for (i=start;i<=stop;i++) { 6359 for (i=start;i<=stop;i++) {
6355 SpeedDial.Location=i; 6360 SpeedDial.Location=i;
6356 error=Phone->GetSpeedDial(&s,&SpeedDial); 6361 error=Phone->GetSpeedDial(&s,&SpeedDial);
6357 printmsg("%i.",i); 6362 printmsg("%i.",i);
6358 switch (error) { 6363 switch (error) {
6359 case ERR_EMPTY: 6364 case ERR_EMPTY:
6360 printmsg(" speed dial not assigned\n"); 6365 printmsg(" speed dial not assigned\n");
6361 break; 6366 break;
6362 default: 6367 default:
6363 Print_Error(error); 6368 Print_Error(error);
6364 6369
6365 Phonebook.Location= SpeedDial.MemoryLocation; 6370 Phonebook.Location= SpeedDial.MemoryLocation;
6366 Phonebook.MemoryType = SpeedDial.MemoryType; 6371 Phonebook.MemoryType = SpeedDial.MemoryType;
6367 error=Phone->GetMemory(&s,&Phonebook); 6372 error=Phone->GetMemory(&s,&Phonebook);
6368 6373
6369 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); 6374 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group);
6370 6375
6371 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); 6376 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text));
6372 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); 6377 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text));
6373 } 6378 }
6374 printf("\n"); 6379 printf("\n");
6375 } 6380 }
6376 6381
6377 GSM_Terminate(); 6382 GSM_Terminate();
6378} 6383}
6379 6384
6380static void ResetPhoneSettings(int argc, char *argv[]) 6385static void ResetPhoneSettings(int argc, char *argv[])
6381{ 6386{
6382 GSM_ResetSettingsType Type; 6387 GSM_ResetSettingsType Type;
6383 6388
6384 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; 6389 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS;
6385 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; 6390 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE;
6386 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; 6391 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS;
6387 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; 6392 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE;
6388 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; 6393 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY;
6389 } else { 6394 } else {
6390 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); 6395 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]);
6391 exit(-1); 6396 exit(-1);
6392 } 6397 }
6393 6398
6394 GSM_Init(true); 6399 GSM_Init(true);
6395 6400
6396 error=Phone->ResetPhoneSettings(&s,Type); 6401 error=Phone->ResetPhoneSettings(&s,Type);
6397 Print_Error(error); 6402 Print_Error(error);
6398 6403
6399 GSM_Terminate(); 6404 GSM_Terminate();
6400} 6405}
6401 6406
6402#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 6407#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
6403static void NokiaSecurityCode(int argc, char *argv[]) 6408static void NokiaSecurityCode(int argc, char *argv[])
6404{ 6409{
6405 GSM_Init(true); 6410 GSM_Init(true);
6406 6411
6407#ifdef GSM_ENABLE_NOKIA_DCT3 6412#ifdef GSM_ENABLE_NOKIA_DCT3
6408 DCT3GetSecurityCode(argc,argv); 6413 DCT3GetSecurityCode(argc,argv);
6409#endif 6414#endif
6410#ifdef GSM_ENABLE_NOKIA_DCT4 6415#ifdef GSM_ENABLE_NOKIA_DCT4
6411 //DCT4ResetSecurityCode(argc, argv); 6416 //DCT4ResetSecurityCode(argc, argv);
6412 DCT4GetSecurityCode(argc,argv); 6417 DCT4GetSecurityCode(argc,argv);
6413#endif 6418#endif
6414 6419
6415 GSM_Terminate(); 6420 GSM_Terminate();
6416} 6421}
6417 6422
6418static void NokiaSetPhoneMenus(int argc, char *argv[]) 6423static void NokiaSetPhoneMenus(int argc, char *argv[])
6419{ 6424{
6420 GSM_Init(true); 6425 GSM_Init(true);
6421 6426
6422#ifdef GSM_ENABLE_NOKIA_DCT3 6427#ifdef GSM_ENABLE_NOKIA_DCT3
6423 DCT3SetPhoneMenus (argc, argv); 6428 DCT3SetPhoneMenus (argc, argv);
6424#endif 6429#endif
6425#ifdef GSM_ENABLE_NOKIA_DCT4 6430#ifdef GSM_ENABLE_NOKIA_DCT4
6426 DCT4SetPhoneMenus (argc, argv); 6431 DCT4SetPhoneMenus (argc, argv);
6427#endif 6432#endif
6428 6433
6429 GSM_Terminate(); 6434 GSM_Terminate();
6430} 6435}
6431 6436
6432static void NokiaSelfTests(int argc, char *argv[]) 6437static void NokiaSelfTests(int argc, char *argv[])
6433{ 6438{
6434 GSM_Init(true); 6439 GSM_Init(true);
6435 6440
6436#ifdef GSM_ENABLE_NOKIA_DCT3 6441#ifdef GSM_ENABLE_NOKIA_DCT3
6437 DCT3SelfTests(argc, argv); 6442 DCT3SelfTests(argc, argv);
6438#endif 6443#endif
6439#ifdef GSM_ENABLE_NOKIA_DCT4 6444#ifdef GSM_ENABLE_NOKIA_DCT4
6440 DCT4SelfTests(argc, argv); 6445 DCT4SelfTests(argc, argv);
6441#endif 6446#endif
6442 6447
6443 GSM_Terminate(); 6448 GSM_Terminate();
6444} 6449}
6445#endif 6450#endif
6446 6451
6447static void DeleteAllSMS(int argc, char *argv[]) 6452static void DeleteAllSMS(int argc, char *argv[])
6448{ 6453{
6449 GSM_MultiSMSMessage sms; 6454 GSM_MultiSMSMessage sms;
6450 GSM_SMSFolders folders; 6455 GSM_SMSFolders folders;
6451 int foldernum; 6456 int foldernum;
6452 bool start = true; 6457 bool start = true;
6453 6458
6454 GSM_Init(true); 6459 GSM_Init(true);
6455 6460
6456 error=Phone->GetSMSFolders(&s, &folders); 6461 error=Phone->GetSMSFolders(&s, &folders);
6457 Print_Error(error); 6462 Print_Error(error);
6458 6463
6459 GetStartStop(&foldernum, NULL, 2, argc, argv); 6464 GetStartStop(&foldernum, NULL, 2, argc, argv);
6460 if (foldernum > folders.Number) { 6465 if (foldernum > folders.Number) {
6461 printmsg("Too high folder number (max. %i)\n",folders.Number); 6466 printmsg("Too high folder number (max. %i)\n",folders.Number);
6462 GSM_Terminate(); 6467 GSM_Terminate();
6463 exit(-1); 6468 exit(-1);
6464 } 6469 }
6465 6470
6466 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name)); 6471 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name));
6467 6472
6468 while (error == ERR_NONE) { 6473 while (error == ERR_NONE) {
6469 sms.SMS[0].Folder=0x00; 6474 sms.SMS[0].Folder=0x00;
6470 error=Phone->GetNextSMS(&s, &sms, start); 6475 error=Phone->GetNextSMS(&s, &sms, start);
6471 switch (error) { 6476 switch (error) {
6472 case ERR_EMPTY: 6477 case ERR_EMPTY:
6473 break; 6478 break;
6474 default: 6479 default:
6475 Print_Error(error); 6480 Print_Error(error);
6476 if (sms.SMS[0].Folder == foldernum) { 6481 if (sms.SMS[0].Folder == foldernum) {
6477 sms.SMS[0].Folder=0x00; 6482 sms.SMS[0].Folder=0x00;
6478 error=Phone->DeleteSMS(&s, &sms.SMS[0]); 6483 error=Phone->DeleteSMS(&s, &sms.SMS[0]);
6479 Print_Error(error); 6484 Print_Error(error);
6480 printmsg("*"); 6485 printmsg("*");
6481 } 6486 }
6482 } 6487 }
6483 start=false; 6488 start=false;
6484 } 6489 }
6485 6490
6486 printf("\n"); 6491 printf("\n");
6487 6492
6488 GSM_Terminate(); 6493 GSM_Terminate();
6489} 6494}
6490 6495
6491static void SendDTMF(int argc, char *argv[]) 6496static void SendDTMF(int argc, char *argv[])
6492{ 6497{
6493 GSM_Init(true); 6498 GSM_Init(true);
6494 6499
6495 error=Phone->SendDTMF(&s,argv[2]); 6500 error=Phone->SendDTMF(&s,argv[2]);
6496 Print_Error(error); 6501 Print_Error(error);
6497 6502
6498 GSM_Terminate(); 6503 GSM_Terminate();
6499} 6504}
6500 6505
6501static void GetDisplayStatus(int argc, char *argv[]) 6506static void GetDisplayStatus(int argc, char *argv[])
6502{ 6507{
6503 GSM_DisplayFeatures Features; 6508 GSM_DisplayFeatures Features;
6504 int i; 6509 int i;
6505 6510
6506 GSM_Init(true); 6511 GSM_Init(true);
6507 6512
6508 error=Phone->GetDisplayStatus(&s,&Features); 6513 error=Phone->GetDisplayStatus(&s,&Features);
6509 Print_Error(error); 6514 Print_Error(error);
6510 6515
6511 printmsg("Current display features :\n"); 6516 printmsg("Current display features :\n");
6512 6517
6513 for (i=0;i<Features.Number;i++) { 6518 for (i=0;i<Features.Number;i++) {
6514 switch(Features.Feature[i]) { 6519 switch(Features.Feature[i]) {
6515 case GSM_CallActive : printmsg("Call active\n");break; 6520 case GSM_CallActive : printmsg("Call active\n");break;
6516 case GSM_UnreadSMS : printmsg("Unread SMS\n");break; 6521 case GSM_UnreadSMS : printmsg("Unread SMS\n");break;
6517 case GSM_VoiceCall : printmsg("Voice call\n");break; 6522 case GSM_VoiceCall : printmsg("Voice call\n");break;
6518 case GSM_FaxCall : printmsg("Fax call\n");break; 6523 case GSM_FaxCall : printmsg("Fax call\n");break;
6519 case GSM_DataCall : printmsg("Data call\n");break; 6524 case GSM_DataCall : printmsg("Data call\n");break;
6520 case GSM_KeypadLocked : printmsg("Keypad locked\n");break; 6525 case GSM_KeypadLocked : printmsg("Keypad locked\n");break;
6521 case GSM_SMSMemoryFull: printmsg("SMS memory full\n"); 6526 case GSM_SMSMemoryFull: printmsg("SMS memory full\n");
6522 } 6527 }
6523 } 6528 }
6524 6529
6525 GSM_Terminate(); 6530 GSM_Terminate();
6526} 6531}
6527 6532
6528static void SetAutoNetworkLogin(int argc, char *argv[]) 6533static void SetAutoNetworkLogin(int argc, char *argv[])
6529{ 6534{
6530 GSM_Init(true); 6535 GSM_Init(true);
6531 6536
6532 error=Phone->SetAutoNetworkLogin(&s); 6537 error=Phone->SetAutoNetworkLogin(&s);
6533 Print_Error(error); 6538 Print_Error(error);
6534 6539
6535 GSM_Terminate(); 6540 GSM_Terminate();
6536} 6541}
6537 6542
6538#ifdef DEBUG 6543#ifdef DEBUG
6539static void MakeConvertTable(int argc, char *argv[]) 6544static void MakeConvertTable(int argc, char *argv[])
6540{ 6545{
6541 unsigned char InputBuffer[10000], Buffer[10000]; 6546 unsigned char InputBuffer[10000], Buffer[10000];
6542 FILE *file; 6547 FILE *file;
6543 int size,i,j=0; 6548 int size,i,j=0;
6544 6549
6545 file = fopen(argv[2], "rb"); 6550 file = fopen(argv[2], "rb");
6546 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 6551 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
6547 size=fread(InputBuffer, 1, 10000-1, file); 6552 size=fread(InputBuffer, 1, 10000-1, file);
6548 fclose(file); 6553 fclose(file);
6549 InputBuffer[size] = 0; 6554 InputBuffer[size] = 0;
6550 InputBuffer[size+1] = 0; 6555 InputBuffer[size+1] = 0;
6551 6556
6552 ReadUnicodeFile(Buffer,InputBuffer); 6557 ReadUnicodeFile(Buffer,InputBuffer);
6553 6558
6554 for(i=0;i<((int)UnicodeLength(Buffer));i++) { 6559 for(i=0;i<((int)UnicodeLength(Buffer));i++) {
6555 j++; 6560 j++;
6556 if (j==100) { 6561 if (j==100) {
6557 printf("\"\\\n\""); 6562 printf("\"\\\n\"");
6558 j=0; 6563 j=0;
6559 } 6564 }
6560 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); 6565 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]);
6561 } 6566 }
6562 printf("\\x00\\x00"); 6567 printf("\\x00\\x00");
6563} 6568}
6564#endif 6569#endif
6565 6570
6566static void ListNetworks(int argc, char *argv[]) 6571static void ListNetworks(int argc, char *argv[])
6567{ 6572{
6568 extern unsigned char *GSM_Networks[]; 6573 extern unsigned char *GSM_Networks[];
6569 int i=0; 6574 int i=0;
6570 6575
6571 printmsg("Network Name\n\n"); 6576 printmsg("Network Name\n\n");
6572 while (GSM_Networks[i*2]!=NULL) { 6577 while (GSM_Networks[i*2]!=NULL) {
6573 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); 6578 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6574 i++; 6579 i++;
6575 } 6580 }
6576} 6581}
6577 6582
6578static void Version(int argc, char *argv[]) 6583static void Version(int argc, char *argv[])
6579{ 6584{
6580 // unsigned char buff[10]; 6585 // unsigned char buff[10];
6581 // int len; 6586 // int len;
6582 6587
6583 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); 6588 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
6584 6589
6585#ifdef DEBUG 6590#ifdef DEBUG
6586 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); 6591 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage));
6587 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); 6592 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC));
6588 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); 6593 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State));
6589 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); 6594 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader));
6590 printf("bool - %i\n",sizeof(bool)); 6595 printf("bool - %i\n",sizeof(bool));
6591 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); 6596 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime));
6592 printf("int - %i\n",sizeof(int)); 6597 printf("int - %i\n",sizeof(int));
6593 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); 6598 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo));
6594#endif 6599#endif
6595 6600
6596 //len=DecodeBASE64("AXw", buff, 3); 6601 //len=DecodeBASE64("AXw", buff, 3);
6597 //DumpMessage(stdout, buff, len); 6602 //DumpMessage(stdout, buff, len);
6598} 6603}
6599 6604
6600static void GetFMStation(int argc, char *argv[]) 6605static void GetFMStation(int argc, char *argv[])
6601{ 6606{
6602 GSM_FMStation Station; 6607 GSM_FMStation Station;
6603 int start,stop; 6608 int start,stop;
6604 6609
6605 GetStartStop(&start, &stop, 2, argc, argv); 6610 GetStartStop(&start, &stop, 2, argc, argv);
6606 6611
6607 GSM_Init(true); 6612 GSM_Init(true);
6608 6613
6609 for (i=start;i<=stop;i++) { 6614 for (i=start;i<=stop;i++) {
6610 Station.Location=i; 6615 Station.Location=i;
6611 error=Phone->GetFMStation(&s,&Station); 6616 error=Phone->GetFMStation(&s,&Station);
6612 switch (error) { 6617 switch (error) {
6613 case ERR_EMPTY: 6618 case ERR_EMPTY:
6614 printmsg("Entry number %i is empty\n",i); 6619 printmsg("Entry number %i is empty\n",i);
6615 break; 6620 break;
6616 case ERR_NONE: 6621 case ERR_NONE:
6617 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n", 6622 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n",
6618 i,DecodeUnicodeConsole(Station.StationName), 6623 i,DecodeUnicodeConsole(Station.StationName),
6619 Station.Frequency); 6624 Station.Frequency);
6620 break; 6625 break;
6621 default: 6626 default:
6622 Print_Error(error); 6627 Print_Error(error);
6623 } 6628 }
6624 } 6629 }
6625 GSM_Terminate(); 6630 GSM_Terminate();
6626} 6631}
6627 6632
6628static void GetFileSystemStatus(int argc, char *argv[]) 6633static void GetFileSystemStatus(int argc, char *argv[])
6629{ 6634{
6630 GSM_FileSystemStatusStatus; 6635 GSM_FileSystemStatusStatus;
6631 6636
6632 GSM_Init(true); 6637 GSM_Init(true);
6633 6638
6634 error = Phone->GetFileSystemStatus(&s,&Status); 6639 error = Phone->GetFileSystemStatus(&s,&Status);
6635 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6640 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6636 Print_Error(error); 6641 Print_Error(error);
6637 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6642 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6638 } 6643 }
6639 6644
6640 GSM_Terminate(); 6645 GSM_Terminate();
6641} 6646}
6642 6647
6643static void GetFileSystem(int argc, char *argv[]) 6648static void GetFileSystem(int argc, char *argv[])
6644{ 6649{
6645 bool Start = true; 6650 bool Start = true;
6646 GSM_File Files; 6651 GSM_File Files;
6647 int j; 6652 int j;
6648 GSM_FileSystemStatusStatus; 6653 GSM_FileSystemStatusStatus;
6649 char FolderName[256]; 6654 char FolderName[256];
6650 6655
6651 GSM_Init(true); 6656 GSM_Init(true);
6652 6657
6653 while (1) { 6658 while (1) {
6654 error = Phone->GetNextFileFolder(&s,&Files,Start); 6659 error = Phone->GetNextFileFolder(&s,&Files,Start);
6655 if (error == ERR_EMPTY) break; 6660 if (error == ERR_EMPTY) break;
6656 Print_Error(error); 6661 Print_Error(error);
6657 6662
6658 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) { 6663 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) {
6659 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) { 6664 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) {
6660 printf("%5s.",Files.ID_FullName); 6665 printf("%5s.",Files.ID_FullName);
6661 } 6666 }
6662 if (Files.Protected) { 6667 if (Files.Protected) {
6663 printf("P"); 6668 printf("P");
6664 } else { 6669 } else {
6665 printf(" "); 6670 printf(" ");
6666 } 6671 }
6667 if (Files.ReadOnly) { 6672 if (Files.ReadOnly) {
6668 printf("R"); 6673 printf("R");
6669 } else { 6674 } else {
6670 printf(" "); 6675 printf(" ");
6671 } 6676 }
6672 if (Files.Hidden) { 6677 if (Files.Hidden) {
6673 printf("H"); 6678 printf("H");
6674 } else { 6679 } else {
6675 printf(" "); 6680 printf(" ");
6676 } 6681 }
6677 if (Files.System) { 6682 if (Files.System) {
6678 printf("S"); 6683 printf("S");
6679 } else { 6684 } else {
6680 printf(" "); 6685 printf(" ");
6681 } 6686 }
6682 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) { 6687 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) {
6683 if (!Files.Folder) { 6688 if (!Files.Folder) {
6684 if (mystrncasecmp(argv[2],"-flatall",0)) { 6689 if (mystrncasecmp(argv[2],"-flatall",0)) {
6685 if (!Files.ModifiedEmpty) { 6690 if (!Files.ModifiedEmpty) {
6686 printf(" %30s",OSDateTime(Files.Modified,false)); 6691 printf(" %30s",OSDateTime(Files.Modified,false));
6687 } else printf(" %30c",0x20); 6692 } else printf(" %30c",0x20);
6688 printf(" %9i",Files.Used); 6693 printf(" %9i",Files.Used);
6689 printf(" "); 6694 printf(" ");
6690 } else printf("|-- "); 6695 } else printf("|-- ");
6691 } else printf("Folder "); 6696 } else printf("Folder ");
6692 } else { 6697 } else {
6693 if (Files.Level != 1) { 6698 if (Files.Level != 1) {
6694 for (j=0;j<Files.Level-2;j++) printf(" | "); 6699 for (j=0;j<Files.Level-2;j++) printf(" | ");
6695 printf(" |-- "); 6700 printf(" |-- ");
6696 } 6701 }
6697 if (Files.Folder) printf("Folder "); 6702 if (Files.Folder) printf("Folder ");
6698 } 6703 }
6699 printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); 6704 printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
6700 printf("\n"); 6705 printf("\n");
6701 6706
6702 Start = false; 6707 Start = false;
6703 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { 6708 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
6704 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS] 6709 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS]
6705 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */ 6710 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */
6706 if (!Files.Folder) { 6711 if (!Files.Folder) {
6707 printf("%s;File;",Files.ID_FullName); 6712 printf("%s;File;",Files.ID_FullName);
6708 printf("\"%s\";",FolderName); 6713 printf("\"%s\";",FolderName);
6709 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6714 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6710 if (!Files.ModifiedEmpty) { 6715 if (!Files.ModifiedEmpty) {
6711 printf("\"%s\";",OSDateTime(Files.Modified,false)); 6716 printf("\"%s\";",OSDateTime(Files.Modified,false));
6712 } else printf("\"%c\";",0x20); 6717 } else printf("\"%c\";",0x20);
6713 printf("%i;",Files.Used); 6718 printf("%i;",Files.Used);
6714 } else { 6719 } else {
6715 printf("%s;Folder;",Files.ID_FullName); 6720 printf("%s;Folder;",Files.ID_FullName);
6716 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6721 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6717 strcpy(FolderName,DecodeUnicodeConsole(Files.Name)); 6722 strcpy(FolderName,DecodeUnicodeConsole(Files.Name));
6718 } 6723 }
6719 6724
6720 if (Files.Protected) printf("P"); 6725 if (Files.Protected) printf("P");
6721 if (Files.ReadOnly) printf("R"); 6726 if (Files.ReadOnly) printf("R");
6722 if (Files.Hidden) printf("H"); 6727 if (Files.Hidden) printf("H");
6723 if (Files.System) printf("S"); 6728 if (Files.System) printf("S");
6724 6729
6725 printf("\n"); 6730 printf("\n");
6726 6731
6727 Start = false; 6732 Start = false;
6728 } 6733 }
6729 } 6734 }
6730 6735
6731 error = Phone->GetFileSystemStatus(&s,&Status); 6736 error = Phone->GetFileSystemStatus(&s,&Status);
6732 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6737 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6733 Print_Error(error); 6738 Print_Error(error);
6734 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6739 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6735 } 6740 }
6736 6741
6737 GSM_Terminate(); 6742 GSM_Terminate();
6738} 6743}
6739 6744
6740static void GetOneFile(GSM_File *File, bool newtime, int i) 6745static void GetOneFile(GSM_File *File, bool newtime, int i)
6741{ 6746{
6742 FILE *file; 6747 FILE *file;
6743 bool start; 6748 bool start;
6744 unsigned char buffer[5000]; 6749 unsigned char buffer[5000];
6745 struct utimbuf filedate; 6750 struct utimbuf filedate;
6746 6751
6747 if (File->Buffer != NULL) { 6752 if (File->Buffer != NULL) {
6748 free(File->Buffer); 6753 free(File->Buffer);
6749 File->Buffer = NULL; 6754 File->Buffer = NULL;
6750 } 6755 }
6751 File->Used = 0; 6756 File->Used = 0;
6752 start = true; 6757 start = true;
6753 6758
6754 error = ERR_NONE; 6759 error = ERR_NONE;
6755 while (error == ERR_NONE) { 6760 while (error == ERR_NONE) {
6756 error = Phone->GetFilePart(&s,File); 6761 error = Phone->GetFilePart(&s,File);
6757 if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) { 6762 if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) {
6758 if (start) { 6763 if (start) {
6759 printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name)); 6764 printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name));
6760 start = false; 6765 start = false;
6761 } 6766 }
6762 if (File->Folder) { 6767 if (File->Folder) {
6763 free(File->Buffer); 6768 free(File->Buffer);
6764 GSM_Terminate(); 6769 GSM_Terminate();
6765 printmsg("it's folder. Please give only file names\n"); 6770 printmsg("it's folder. Please give only file names\n");
6766 exit(-1); 6771 exit(-1);
6767 } 6772 }
6768 printmsg("*"); 6773 printmsg("*");
6769 if (error == ERR_EMPTY) break; 6774 if (error == ERR_EMPTY) break;
6770 if (error == ERR_WRONGCRC) { 6775 if (error == ERR_WRONGCRC) {
6771 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 6776 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6772 break; 6777 break;
6773 } 6778 }
6774 } 6779 }
6775 Print_Error(error); 6780 Print_Error(error);
6776 } 6781 }
6777 printf("\n"); 6782 printf("\n");
6778 if (File->Used != 0) { 6783 if (File->Used != 0) {
6779 sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name)); 6784 sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name));
6780 file = fopen(buffer,"wb"); 6785 file = fopen(buffer,"wb");
6781 if (file == NULL) { 6786 if (file == NULL) {
6782 sprintf(buffer,"file%s",File->ID_FullName); 6787 sprintf(buffer,"file%s",File->ID_FullName);
6783 file = fopen(buffer,"wb"); 6788 file = fopen(buffer,"wb");
6784 } 6789 }
6785 if (file == NULL) { 6790 if (file == NULL) {
6786 sprintf(buffer,"file%i",i); 6791 sprintf(buffer,"file%i",i);
6787 file = fopen(buffer,"wb"); 6792 file = fopen(buffer,"wb");
6788 } 6793 }
6789 printmsg(" Saving to %s\n",buffer); 6794 printmsg(" Saving to %s\n",buffer);
6790 if (!file) Print_Error(ERR_CANTOPENFILE); 6795 if (!file) Print_Error(ERR_CANTOPENFILE);
6791 fwrite(File->Buffer,1,File->Used,file); 6796 fwrite(File->Buffer,1,File->Used,file);
6792 fclose(file); 6797 fclose(file);
6793 if (!newtime && !File->ModifiedEmpty) { 6798 if (!newtime && !File->ModifiedEmpty) {
6794 /* access time */ 6799 /* access time */
6795 filedate.actime = Fill_Time_T(File->Modified, 8); 6800 filedate.actime = Fill_Time_T(File->Modified, 8);
6796 /* modification time */ 6801 /* modification time */
6797 filedate.modtime = Fill_Time_T(File->Modified, 8); 6802 filedate.modtime = Fill_Time_T(File->Modified, 8);
6798 dbgprintf("Setting date of %s\n",buffer); 6803 dbgprintf("Setting date of %s\n",buffer);
6799 utime(buffer,&filedate); 6804 utime(buffer,&filedate);
6800 } 6805 }
6801 } 6806 }
6802} 6807}
6803 6808
6804static void GetFiles(int argc, char *argv[]) 6809static void GetFiles(int argc, char *argv[])
6805{ 6810{
6806 GSM_File File; 6811 GSM_File File;
6807 int i; 6812 int i;
6808 bool newtime = false; 6813 bool newtime = false;
6809 6814
6810 File.Buffer = NULL; 6815 File.Buffer = NULL;
6811 6816
6812 GSM_Init(true); 6817 GSM_Init(true);
6813 6818
6814 for (i=2;i<argc;i++) { 6819 for (i=2;i<argc;i++) {
6815 if (mystrncasecmp(argv[i],"-newtime",0)) { 6820 if (mystrncasecmp(argv[i],"-newtime",0)) {
6816 newtime = true; 6821 newtime = true;
6817 continue; 6822 continue;
6818 } 6823 }
6819 6824
6820 strcpy(File.ID_FullName,argv[i]); 6825 strcpy(File.ID_FullName,argv[i]);
6821 GetOneFile(&File, newtime, i); 6826 GetOneFile(&File, newtime, i);
6822 } 6827 }
6823 6828
6824 free(File.Buffer); 6829 free(File.Buffer);
6825 GSM_Terminate(); 6830 GSM_Terminate();
6826} 6831}
6827 6832
6828static void GetFileFolder(int argc, char *argv[]) 6833static void GetFileFolder(int argc, char *argv[])
6829{ 6834{
6830 bool Start = true; 6835 bool Start = true;
6831 GSM_File File; 6836 GSM_File File;
6832 int level=0,allnum=0,num=0,filelevel=0; 6837 int level=0,allnum=0,num=0,filelevel=0;
6833 bool newtime = false, found; 6838 bool newtime = false, found;
6834 6839
6835 File.Buffer = NULL; 6840 File.Buffer = NULL;
6836 6841
6837 GSM_Init(true); 6842 GSM_Init(true);
6838 6843
6839 for (i=2;i<argc;i++) { 6844 for (i=2;i<argc;i++) {
6840 if (mystrncasecmp(argv[i],"-newtime",0)) { 6845 if (mystrncasecmp(argv[i],"-newtime",0)) {
6841 newtime = true; 6846 newtime = true;
6842 continue; 6847 continue;
6843 } 6848 }
6844 allnum++; 6849 allnum++;
6845 } 6850 }
6846 6851
6847 while (allnum != num) { 6852 while (allnum != num) {
6848 error = Phone->GetNextFileFolder(&s,&File,Start); 6853 error = Phone->GetNextFileFolder(&s,&File,Start);
6849 if (error == ERR_EMPTY) break; 6854 if (error == ERR_EMPTY) break;
6850 Print_Error(error); 6855 Print_Error(error);
6851 6856
6852 if (level == 0) { 6857 if (level == 0) {
6853 /* We search for file or folder */ 6858 /* We search for file or folder */
6854 found = false; 6859 found = false;
6855 for (i=2;i<argc;i++) { 6860 for (i=2;i<argc;i++) {
6856 if (mystrncasecmp(argv[i],"-newtime",0)) { 6861 if (mystrncasecmp(argv[i],"-newtime",0)) {
6857 continue; 6862 continue;
6858 } 6863 }
6859 if (!strcmp(File.ID_FullName,argv[i])) { 6864 if (!strcmp(File.ID_FullName,argv[i])) {
6860 found = true; 6865 found = true;
6861 if (File.Folder) { 6866 if (File.Folder) {
6862 level = 1; 6867 level = 1;
6863 filelevel = File.Level + 1; 6868 filelevel = File.Level + 1;
6864 Start = false; 6869 Start = false;
6865 } else { 6870 } else {
6866 level = 2; 6871 level = 2;
6867 } 6872 }
6868 break; 6873 break;
6869 } 6874 }
6870 } 6875 }
6871 if (found && File.Folder) continue; 6876 if (found && File.Folder) continue;
6872 } 6877 }
6873 if (level == 1) { 6878 if (level == 1) {
6874 /* We have folder */ 6879 /* We have folder */
6875 dbgprintf("%i %i\n",File.Level,filelevel); 6880 dbgprintf("%i %i\n",File.Level,filelevel);
6876 if (File.Level != filelevel) { 6881 if (File.Level != filelevel) {
6877 level = 0; 6882 level = 0;
6878 num++; 6883 num++;
6879 } 6884 }
6880 } 6885 }
6881 6886
6882 if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num); 6887 if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num);
6883 6888
6884 if (level == 2) { 6889 if (level == 2) {
6885 level = 0; 6890 level = 0;
6886 num++; 6891 num++;
6887 } 6892 }
6888 6893
6889 Start = false; 6894 Start = false;
6890 } 6895 }
6891 6896
6892 free(File.Buffer); 6897 free(File.Buffer);
6893 GSM_Terminate(); 6898 GSM_Terminate();
6894} 6899}
6895 6900
6896static void AddFile(int argc, char *argv[]) 6901static void AddFile(int argc, char *argv[])
6897{ 6902{
6898 GSM_File File; 6903 GSM_File File;
6899 int Pos = 0,i,nextlong; 6904 int Pos = 0,i,nextlong;
6900 6905
6901 File.Buffer = NULL; 6906 File.Buffer = NULL;
6902 strcpy(File.ID_FullName,argv[2]); 6907 strcpy(File.ID_FullName,argv[2]);
6903 error = GSM_ReadFile(argv[3], &File); 6908 error = GSM_ReadFile(argv[3], &File);
6904 Print_Error(error); 6909 Print_Error(error);
6905 EncodeUnicode(File.Name,argv[3],strlen(argv[3])); 6910 EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
6906 GSM_IdentifyFileFormat(&File); 6911 GSM_IdentifyFileFormat(&File);
6907 6912
6908 File.Protected = false; 6913 File.Protected = false;
6909 File.ReadOnly= false; 6914 File.ReadOnly= false;
6910 File.Hidden= false; 6915 File.Hidden= false;
6911 File.System= false; 6916 File.System= false;
6912 6917
6913 if (argc > 4) { 6918 if (argc > 4) {
6914 nextlong = 0; 6919 nextlong = 0;
6915 for (i=4;i<argc;i++) { 6920 for (i=4;i<argc;i++) {
6916 switch(nextlong) { 6921 switch(nextlong) {
6917 case 0: 6922 case 0:
6918 if (mystrncasecmp(argv[i],"-type",0)) { 6923 if (mystrncasecmp(argv[i],"-type",0)) {
6919 nextlong = 1; 6924 nextlong = 1;
6920 continue; 6925 continue;
6921 } 6926 }
6922 if (mystrncasecmp(argv[i],"-protected",0)) { 6927 if (mystrncasecmp(argv[i],"-protected",0)) {
6923 File.Protected = true; 6928 File.Protected = true;
6924 continue; 6929 continue;
6925 } 6930 }
6926 if (mystrncasecmp(argv[i],"-readonly",0)) { 6931 if (mystrncasecmp(argv[i],"-readonly",0)) {
6927 File.ReadOnly = true; 6932 File.ReadOnly = true;
6928 continue; 6933 continue;
6929 } 6934 }
6930 if (mystrncasecmp(argv[i],"-hidden",0)) { 6935 if (mystrncasecmp(argv[i],"-hidden",0)) {
6931 File.Hidden = true; 6936 File.Hidden = true;
6932 continue; 6937 continue;
6933 } 6938 }
6934 if (mystrncasecmp(argv[i],"-system",0)) { 6939 if (mystrncasecmp(argv[i],"-system",0)) {
6935 File.System = true; 6940 File.System = true;
6936 continue; 6941 continue;
6937 } 6942 }
6938 if (mystrncasecmp(argv[i],"-newtime",0)) { 6943 if (mystrncasecmp(argv[i],"-newtime",0)) {
6939 File.ModifiedEmpty = true; 6944 File.ModifiedEmpty = true;
6940 continue; 6945 continue;
6941 } 6946 }
6942 printmsg("Parameter \"%s\" unknown\n",argv[i]); 6947 printmsg("Parameter \"%s\" unknown\n",argv[i]);
6943 exit(-1); 6948 exit(-1);
6944 case 1: 6949 case 1:
6945 if (mystrncasecmp(argv[i],"JAR",0)) { 6950 if (mystrncasecmp(argv[i],"JAR",0)) {
6946 File.Type = GSM_File_Java_JAR; 6951 File.Type = GSM_File_Java_JAR;
6947 } else if (mystrncasecmp(argv[i],"JPG",0)) { 6952 } else if (mystrncasecmp(argv[i],"JPG",0)) {
6948 File.Type = GSM_File_Image_JPG; 6953 File.Type = GSM_File_Image_JPG;
6949 } else if (mystrncasecmp(argv[i],"BMP",0)) { 6954 } else if (mystrncasecmp(argv[i],"BMP",0)) {
6950 File.Type = GSM_File_Image_BMP; 6955 File.Type = GSM_File_Image_BMP;
6951 } else if (mystrncasecmp(argv[i],"WBMP",0)) { 6956 } else if (mystrncasecmp(argv[i],"WBMP",0)) {
6952 File.Type = GSM_File_Image_WBMP; 6957 File.Type = GSM_File_Image_WBMP;
6953 } else if (mystrncasecmp(argv[i],"GIF",0)) { 6958 } else if (mystrncasecmp(argv[i],"GIF",0)) {
6954 File.Type = GSM_File_Image_GIF; 6959 File.Type = GSM_File_Image_GIF;
6955 } else if (mystrncasecmp(argv[i],"PNG",0)) { 6960 } else if (mystrncasecmp(argv[i],"PNG",0)) {
6956 File.Type = GSM_File_Image_PNG; 6961 File.Type = GSM_File_Image_PNG;
6957 } else if (mystrncasecmp(argv[i],"MIDI",0)) { 6962 } else if (mystrncasecmp(argv[i],"MIDI",0)) {
6958 File.Type = GSM_File_Sound_MIDI; 6963 File.Type = GSM_File_Sound_MIDI;
6959 } else if (mystrncasecmp(argv[i],"AMR",0)) { 6964 } else if (mystrncasecmp(argv[i],"AMR",0)) {
6960 File.Type = GSM_File_Sound_AMR; 6965 File.Type = GSM_File_Sound_AMR;
6961 } else if (mystrncasecmp(argv[i],"NRT",0)) { 6966 } else if (mystrncasecmp(argv[i],"NRT",0)) {
6962 File.Type = GSM_File_Sound_NRT; 6967 File.Type = GSM_File_Sound_NRT;
6963 } else if (mystrncasecmp(argv[i],"3GP",0)) { 6968 } else if (mystrncasecmp(argv[i],"3GP",0)) {
6964 File.Type = GSM_File_Video_3GP; 6969 File.Type = GSM_File_Video_3GP;
6965 } else { 6970 } else {
6966 printmsg("What file type (\"%s\") ?\n",argv[i]); 6971 printmsg("What file type (\"%s\") ?\n",argv[i]);
6967 exit(-1); 6972 exit(-1);
6968 } 6973 }
6969 nextlong = 0; 6974 nextlong = 0;
6970 break; 6975 break;
6971 } 6976 }
6972 } 6977 }
6973 if (nextlong!=0) { 6978 if (nextlong!=0) {
6974 printmsg("Parameter missed...\n"); 6979 printmsg("Parameter missed...\n");
6975 exit(-1); 6980 exit(-1);
6976 } 6981 }
6977 } 6982 }
6978 6983
6979 GSM_Init(true); 6984 GSM_Init(true);
6980 6985
6981 error = ERR_NONE; 6986 error = ERR_NONE;
6982 while (error == ERR_NONE) { 6987 while (error == ERR_NONE) {
6983 error = Phone->AddFilePart(&s,&File,&Pos); 6988 error = Phone->AddFilePart(&s,&File,&Pos);
6984 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 6989 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
6985 printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used); 6990 printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used);
6986 } 6991 }
6987 printmsgerr("\n"); 6992 printmsgerr("\n");
6988 if (error == ERR_WRONGCRC) { 6993 if (error == ERR_WRONGCRC) {
6989 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 6994 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
6990 } 6995 }
6991 6996
6992 free(File.Buffer); 6997 free(File.Buffer);
6993 GSM_Terminate(); 6998 GSM_Terminate();
6994} 6999}
6995 7000
6996static void AddFolder(int argc, char *argv[]) 7001static void AddFolder(int argc, char *argv[])
6997{ 7002{
6998 GSM_File File; 7003 GSM_File File;
6999 7004
7000 strcpy(File.ID_FullName,argv[2]); 7005 strcpy(File.ID_FullName,argv[2]);
7001 EncodeUnicode(File.Name,argv[3],strlen(argv[3])); 7006 EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
7002 File.ReadOnly = false; 7007 File.ReadOnly = false;
7003 7008
7004 GSM_Init(true); 7009 GSM_Init(true);
7005 7010
7006 error = Phone->AddFolder(&s,&File); 7011 error = Phone->AddFolder(&s,&File);
7007 Print_Error(error); 7012 Print_Error(error);
7008 7013
7009 GSM_Terminate(); 7014 GSM_Terminate();
7010} 7015}
7011 7016
7012struct NokiaFolderInfo { 7017struct NokiaFolderInfo {
7013 char*model; 7018 char*model;
7014 char *parameter; 7019 char *parameter;
7015 char*folder; 7020 char*folder;
7016 char *level; 7021 char *level;
7017}; 7022};
7018 7023
7019static struct NokiaFolderInfo Folder[] = { 7024static struct NokiaFolderInfo Folder[] = {
7020 /* Language indepedent in DCT4 */ 7025 /* Language indepedent in DCT4 */
7021 {"", "MMSUnreadInbox", "INBOX","3"}, 7026 {"", "MMSUnreadInbox", "INBOX","3"},
7022 {"", "MMSReadInbox", "INBOX","3"}, 7027 {"", "MMSReadInbox", "INBOX","3"},
7023 {"", "MMSOutbox", "OUTBOX","3"}, 7028 {"", "MMSOutbox", "OUTBOX","3"},
7024 {"", "MMSSent", "SENT", "3"}, 7029 {"", "MMSSent", "SENT", "3"},
7025 {"", "MMSDrafts", "DRAFTS","3"}, 7030 {"", "MMSDrafts", "DRAFTS","3"},
7026 {"", "Application", "applications","3"}, 7031 {"", "Application", "applications","3"},
7027 {"", "Game", "games","3"}, 7032 {"", "Game", "games","3"},
7028 /* Language depedent in DCT4 */ 7033 /* Language depedent in DCT4 */
7029 {"", "Gallery", "Pictures","2"}, /* 3510 */ 7034 {"", "Gallery", "Pictures","2"}, /* 3510 */
7030 {"", "Gallery", "Graphics","3"}, /* 3510i */ 7035 {"", "Gallery", "Graphics","3"}, /* 3510i */
7031 {"", "Gallery", "Images","3"}, /* 6610 */ 7036 {"", "Gallery", "Images","3"}, /* 6610 */
7032 {"3510", "Gallery", "", "8"}, 7037 {"3510", "Gallery", "", "8"},
7033 {"3510i","Gallery", "", "3"}, 7038 {"3510i","Gallery", "", "3"},
7034 {"5100", "Gallery", "", "3"}, 7039 {"5100", "Gallery", "", "3"},
7035 {"6220", "Gallery", "", "5"}, 7040 {"6220", "Gallery", "", "5"},
7036 {"", "Tones", "Tones","3"}, 7041 {"", "Tones", "Tones","3"},
7037 {"3510i","Tones", "", "4"}, 7042 {"3510i","Tones", "", "4"},
7038 {"5100", "Tones", "", "4"}, 7043 {"5100", "Tones", "", "4"},
7039 {"6220", "Tones", "", "6"}, 7044 {"6220", "Tones", "", "6"},
7040 /* Language indepedent in OBEX */ 7045 /* Language indepedent in OBEX */
7041 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"}, 7046 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"},
7042 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"}, 7047 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"},
7043 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"}, 7048 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"},
7044 {"obex", "MMSSent", "", "predefMessages\\predefSENT" }, 7049 {"obex", "MMSSent", "", "predefMessages\\predefSENT" },
7045 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"}, 7050 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"},
7046 // {"obex", "Application, "", "predefjava\\predefapplications"}, 7051 // {"obex", "Application, "", "predefjava\\predefapplications"},
7047 // {"obex", "Game", "", "predefjava\\predefgames"}, 7052 // {"obex", "Game", "", "predefjava\\predefgames"},
7048 {"obex", "Gallery", "", "predefgallery\\predefgraphics"}, 7053 {"obex", "Gallery", "", "predefgallery\\predefgraphics"},
7049 {"obex", "Tones", "", "predefgallery\\predeftones"}, 7054 {"obex", "Tones", "", "predefgallery\\predeftones"},
7050 7055
7051 /* End of list */ 7056 /* End of list */
7052 {"", "", "", ""} 7057 {"", "", "", ""}
7053}; 7058};
7054 7059
7055static void NokiaAddFile(int argc, char *argv[]) 7060static void NokiaAddFile(int argc, char *argv[])
7056{ 7061{
7057 GSM_File File, Files; 7062 GSM_File File, Files;
7058 FILE *file; 7063 FILE *file;
7059 GSM_DateTime DT,DT2; 7064 GSM_DateTime DT,DT2;
7060 time_t t_time1,t_time2; 7065 time_t t_time1,t_time2;
7061 unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400]; 7066 unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400];
7062 bool Start = true, Found = false, wasclr; 7067 bool Start = true, Found = false, wasclr;
7063 bool ModEmpty = false; 7068 bool ModEmpty = false;
7064 int i = 0, Pos, Size, Size2, nextlong; 7069 int i = 0, Pos, Size, Size2, nextlong;
7065 7070
7066 while (Folder[i].level[0] != 0) { 7071 while (Folder[i].level[0] != 0) {
7067 if (mystrncasecmp(argv[2],Folder[i].parameter,0)) { 7072 if (mystrncasecmp(argv[2],Folder[i].parameter,0)) {
7068 Found = true; 7073 Found = true;
7069 break; 7074 break;
7070 } 7075 }
7071 i++; 7076 i++;
7072 } 7077 }
7073 if (!Found) { 7078 if (!Found) {
7074 printmsg("What folder type (\"%s\") ?\n",argv[2]); 7079 printmsg("What folder type (\"%s\") ?\n",argv[2]);
7075 exit(-1); 7080 exit(-1);
7076 } 7081 }
7077 7082
7078 GSM_Init(true); 7083 GSM_Init(true);
7079 7084
7080 if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) { 7085 if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) {
7081 Found = false; 7086 Found = false;
7082 i = 0; 7087 i = 0;
7083 while (Folder[i].level[0] != 0) { 7088 while (Folder[i].level[0] != 0) {
7084 if (!strcmp("obex",Folder[i].model) && 7089 if (!strcmp("obex",Folder[i].model) &&
7085 mystrncasecmp(argv[2],Folder[i].parameter,0)) { 7090 mystrncasecmp(argv[2],Folder[i].parameter,0)) {
7086 strcpy(Files.ID_FullName,Folder[i].level); 7091 strcpy(Files.ID_FullName,Folder[i].level);
7087 Found = true; 7092 Found = true;
7088 break; 7093 break;
7089 } 7094 }
7090 i++; 7095 i++;
7091 } 7096 }
7092 } else { 7097 } else {
7093 printmsgerr("Searching for phone folder: "); 7098 printmsgerr("Searching for phone folder: ");
7094 while (1) { 7099 while (1) {
7095 error = Phone->GetNextFileFolder(&s,&Files,Start); 7100 error = Phone->GetNextFileFolder(&s,&Files,Start);
7096 if (error == ERR_EMPTY) break; 7101 if (error == ERR_EMPTY) break;
7097 Print_Error(error); 7102 Print_Error(error);
7098 7103
7099 if (Files.Folder) { 7104 if (Files.Folder) {
7100 dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level); 7105 dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level);
7101 Found = false; 7106 Found = false;
7102 i = 0; 7107 i = 0;
7103 while (Folder[i].level[0] != 0) { 7108 while (Folder[i].level[0] != 0) {
7104 EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder)); 7109 EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder));
7105 dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level); 7110 dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level);
7106 if (mystrncasecmp(argv[2],Folder[i].parameter,0) && 7111 if (mystrncasecmp(argv[2],Folder[i].parameter,0) &&
7107 mywstrncasecmp(Files.Name,buffer,0) && 7112 mywstrncasecmp(Files.Name,buffer,0) &&
7108 Files.Level == atoi(Folder[i].level)) { 7113 Files.Level == atoi(Folder[i].level)) {
7109 Found = true; 7114 Found = true;
7110 break; 7115 break;
7111 } 7116 }
7112 if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) && 7117 if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) &&
7113 mystrncasecmp(argv[2],Folder[i].parameter,0) && 7118 mystrncasecmp(argv[2],Folder[i].parameter,0) &&
7114 !strcmp(Files.ID_FullName,Folder[i].level)) { 7119 !strcmp(Files.ID_FullName,Folder[i].level)) {
7115 Found = true; 7120 Found = true;
7116 break; 7121 break;
7117 } 7122 }
7118 i++; 7123 i++;
7119 } 7124 }
7120 if (Found) break; 7125 if (Found) break;
7121 } 7126 }
7122 printmsgerr("*"); 7127 printmsgerr("*");
7123 7128
7124 Start = false; 7129 Start = false;
7125 } 7130 }
7126 printmsgerr("\n"); 7131 printmsgerr("\n");
7127 } 7132 }
7128 if (!Found) { 7133 if (!Found) {
7129 printmsg("Folder not found. Probably function not supported !\n"); 7134 printmsg("Folder not found. Probably function not supported !\n");
7130 GSM_Terminate(); 7135 GSM_Terminate();
7131 exit(-1); 7136 exit(-1);
7132 } 7137 }
7133 File.Buffer = NULL; 7138 File.Buffer = NULL;
7134 File.Protected = false; 7139 File.Protected = false;
7135 File.ReadOnly = false; 7140 File.ReadOnly = false;
7136 File.Hidden= false; 7141 File.Hidden= false;
7137 File.System= false; 7142 File.System= false;
7138 7143
7139 if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) { 7144 if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) {
7140 sprintf(buffer,"%s.jad",argv[3]); 7145 sprintf(buffer,"%s.jad",argv[3]);
7141 file = fopen(buffer,"rb"); 7146 file = fopen(buffer,"rb");
7142 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7147 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7143 fclose(file); 7148 fclose(file);
7144 sprintf(buffer,"%s.jar",argv[3]); 7149 sprintf(buffer,"%s.jar",argv[3]);
7145 file = fopen(buffer,"rb"); 7150 file = fopen(buffer,"rb");
7146 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7151 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7147 fclose(file); 7152 fclose(file);
7148 7153
7149 /* reading jar file */ 7154 /* reading jar file */
7150 sprintf(buffer,"%s.jar",argv[3]); 7155 sprintf(buffer,"%s.jar",argv[3]);
7151 error = GSM_ReadFile(buffer, &File); 7156 error = GSM_ReadFile(buffer, &File);
7152 Print_Error(error); 7157 Print_Error(error);
7153 Size2 = File.Used; 7158 Size2 = File.Used;
7154 7159
7155 /* reading jad file */ 7160 /* reading jad file */
7156 sprintf(buffer,"%s.jad",argv[3]); 7161 sprintf(buffer,"%s.jad",argv[3]);
7157 error = GSM_ReadFile(buffer, &File); 7162 error = GSM_ReadFile(buffer, &File);
7158 Print_Error(error); 7163 Print_Error(error);
7159 7164
7160 /* Getting values from JAD file */ 7165 /* Getting values from JAD file */
7161 error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size); 7166 error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size);
7162 if (error == ERR_FILENOTSUPPORTED) { 7167 if (error == ERR_FILENOTSUPPORTED) {
7163 if (Vendor[0] == 0x00) { 7168 if (Vendor[0] == 0x00) {
7164 printmsgerr("No vendor info in JAD file\n"); 7169 printmsgerr("No vendor info in JAD file\n");
7165 GSM_Terminate(); 7170 GSM_Terminate();
7166 return; 7171 return;
7167 } 7172 }
7168 if (Name[0] == 0x00) { 7173 if (Name[0] == 0x00) {
7169 printmsgerr("No name info in JAD file\n"); 7174 printmsgerr("No name info in JAD file\n");
7170 GSM_Terminate(); 7175 GSM_Terminate();
7171 return; 7176 return;
7172 } 7177 }
7173 if (JAR[0] == 0x00) { 7178 if (JAR[0] == 0x00) {
7174 printmsgerr("No JAR URL info in JAD file\n"); 7179 printmsgerr("No JAR URL info in JAD file\n");
7175 GSM_Terminate(); 7180 GSM_Terminate();
7176 return; 7181 return;
7177 } 7182 }
7178 if (Size == -1) { 7183 if (Size == -1) {
7179 printmsgerr("No JAR size info in JAD file\n"); 7184 printmsgerr("No JAR size info in JAD file\n");
7180 GSM_Terminate(); 7185 GSM_Terminate();
7181 return; 7186 return;
7182 } 7187 }
7183 } 7188 }
7184 if (Size != Size2) { 7189 if (Size != Size2) {
7185 printmsgerr("Declared JAR file size is different than real\n"); 7190 printmsgerr("Declared JAR file size is different than real\n");
7186 GSM_Terminate(); 7191 GSM_Terminate();
7187 return; 7192 return;
7188 } 7193 }
7189 printmsgerr("Adding \"%s\"",Name); 7194 printmsgerr("Adding \"%s\"",Name);
7190 if (Version[0] != 0x00) printmsgerr(" version %s",Version); 7195 if (Version[0] != 0x00) printmsgerr(" version %s",Version);
7191 printmsgerr(" created by %s\n",Vendor); 7196 printmsgerr(" created by %s\n",Vendor);
7192 7197
7193 /* Bostjan Muller 3200 RH-30 3.08 */ 7198 /* Bostjan Muller 3200 RH-30 3.08 */
7194 if (strstr(JAR,"http://") != NULL) { 7199 if (strstr(JAR,"http://") != NULL) {
7195 i = strlen(JAR)-1; 7200 i = strlen(JAR)-1;
7196 while (JAR[i] != '/') i--; 7201 while (JAR[i] != '/') i--;
7197 strcpy(buffer,JAR+i+1); 7202 strcpy(buffer,JAR+i+1);
7198 strcpy(JAR,buffer); 7203 strcpy(JAR,buffer);
7199 dbgprintf("New file name is \"%s\"\n",JAR); 7204 dbgprintf("New file name is \"%s\"\n",JAR);
7200 } 7205 }
7201 7206
7202 /* Changing all #13 or #10 to #13#10 in JAD */ 7207 /* Changing all #13 or #10 to #13#10 in JAD */
7203 Pos = 0; 7208 Pos = 0;
7204 wasclr = false; 7209 wasclr = false;
7205 for (i=0;i<File.Used;i++) { 7210 for (i=0;i<File.Used;i++) {
7206 switch (File.Buffer[i]) { 7211 switch (File.Buffer[i]) {
7207 case 0x0D: 7212 case 0x0D:
7208 case 0x0A: 7213 case 0x0A:
7209 if (!wasclr) { 7214 if (!wasclr) {
7210 buffer[Pos++] = 0x0D; 7215 buffer[Pos++] = 0x0D;
7211 buffer[Pos++] = 0x0A; 7216 buffer[Pos++] = 0x0A;
7212 wasclr = true; 7217 wasclr = true;
7213 } else wasclr = false; 7218 } else wasclr = false;
7214 break; 7219 break;
7215 default: 7220 default:
7216 buffer[Pos++] = File.Buffer[i]; 7221 buffer[Pos++] = File.Buffer[i];
7217 wasclr = false; 7222 wasclr = false;
7218 } 7223 }
7219 } 7224 }
7220 File.Buffer = realloc(File.Buffer, Pos); 7225 File.Buffer = realloc(File.Buffer, Pos);
7221 File.Used = Pos; 7226 File.Used = Pos;
7222 memcpy(File.Buffer,buffer,Pos); 7227 memcpy(File.Buffer,buffer,Pos);
7223 7228
7224 /* adding folder */ 7229 /* adding folder */
7225 strcpy(buffer,Vendor); 7230 strcpy(buffer,Vendor);
7226 strcat(buffer,Name); 7231 strcat(buffer,Name);
7227 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7232 EncodeUnicode(File.Name,buffer,strlen(buffer));
7228 strcpy(File.ID_FullName,Files.ID_FullName); 7233 strcpy(File.ID_FullName,Files.ID_FullName);
7229 error = Phone->AddFolder(&s,&File); 7234 error = Phone->AddFolder(&s,&File);
7230 Print_Error(error); 7235 Print_Error(error);
7231 strcpy(FileID,File.ID_FullName); 7236 strcpy(FileID,File.ID_FullName);
7232 7237
7233 /* adding jad file */ 7238 /* adding jad file */
7234 strcpy(buffer,JAR); 7239 strcpy(buffer,JAR);
7235 buffer[strlen(buffer) - 1] = 'd'; 7240 buffer[strlen(buffer) - 1] = 'd';
7236 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7241 EncodeUnicode(File.Name,buffer,strlen(buffer));
7237 File.Type = GSM_File_Other; 7242 File.Type = GSM_File_Other;
7238 File.ModifiedEmpty = true; 7243 File.ModifiedEmpty = true;
7239 error = ERR_NONE; 7244 error = ERR_NONE;
7240 Pos = 0; 7245 Pos = 0;
7241 while (error == ERR_NONE) { 7246 while (error == ERR_NONE) {
7242 error = Phone->AddFilePart(&s,&File,&Pos); 7247 error = Phone->AddFilePart(&s,&File,&Pos);
7243 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7248 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7244 printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used); 7249 printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used);
7245 } 7250 }
7246 printmsgerr("\n"); 7251 printmsgerr("\n");
7247 if (error == ERR_WRONGCRC) { 7252 if (error == ERR_WRONGCRC) {
7248 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7253 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7249 } 7254 }
7250 7255
7251 if (argc > 4) { 7256 if (argc > 4) {
7252 if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true; 7257 if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true;
7253 } 7258 }
7254 7259
7255 /* reading jar file */ 7260 /* reading jar file */
7256 sprintf(buffer,"%s.jar",argv[3]); 7261 sprintf(buffer,"%s.jar",argv[3]);
7257 error = GSM_ReadFile(buffer, &File); 7262 error = GSM_ReadFile(buffer, &File);
7258 Print_Error(error); 7263 Print_Error(error);
7259 7264
7260 /* adding jar file */ 7265 /* adding jar file */
7261 strcpy(File.ID_FullName,FileID); 7266 strcpy(File.ID_FullName,FileID);
7262 strcpy(buffer,JAR); 7267 strcpy(buffer,JAR);
7263 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7268 EncodeUnicode(File.Name,buffer,strlen(buffer));
7264 File.Type = GSM_File_Java_JAR; 7269 File.Type = GSM_File_Java_JAR;
7265 File.ModifiedEmpty = true; 7270 File.ModifiedEmpty = true;
7266 error = ERR_NONE; 7271 error = ERR_NONE;
7267 Pos = 0; 7272 Pos = 0;
7268 while (error == ERR_NONE) { 7273 while (error == ERR_NONE) {
7269 error = Phone->AddFilePart(&s,&File,&Pos); 7274 error = Phone->AddFilePart(&s,&File,&Pos);
7270 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7275 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7271 printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used); 7276 printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used);
7272 } 7277 }
7273 printmsgerr("\n"); 7278 printmsgerr("\n");
7274 if (error == ERR_WRONGCRC) { 7279 if (error == ERR_WRONGCRC) {
7275 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7280 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7276 } 7281 }
7277 7282
7278 free(File.Buffer); 7283 free(File.Buffer);
7279 GSM_Terminate(); 7284 GSM_Terminate();
7280 return; 7285 return;
7281 } 7286 }
7282 7287
7283 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { 7288 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
7284 strcpy(buffer,argv[3]); 7289 strcpy(buffer,argv[3]);
7285 if (argc > 4) { 7290 if (argc > 4) {
7286 nextlong = 0; 7291 nextlong = 0;
7287 for (i=4;i<argc;i++) { 7292 for (i=4;i<argc;i++) {
7288 switch(nextlong) { 7293 switch(nextlong) {
7289 case 0: 7294 case 0:
7290 if (mystrncasecmp(argv[i],"-name",0)) { 7295 if (mystrncasecmp(argv[i],"-name",0)) {
7291 nextlong = 1; 7296 nextlong = 1;
7292 continue; 7297 continue;
7293 } 7298 }
7294 if (mystrncasecmp(argv[i],"-protected",0)) { 7299 if (mystrncasecmp(argv[i],"-protected",0)) {
7295 File.Protected = true; 7300 File.Protected = true;
7296 continue; 7301 continue;
7297 } 7302 }
7298 if (mystrncasecmp(argv[i],"-readonly",0)) { 7303 if (mystrncasecmp(argv[i],"-readonly",0)) {
7299 File.ReadOnly = true; 7304 File.ReadOnly = true;
7300 continue; 7305 continue;
7301 } 7306 }
7302 if (mystrncasecmp(argv[i],"-hidden",0)) { 7307 if (mystrncasecmp(argv[i],"-hidden",0)) {
7303 File.Hidden = true; 7308 File.Hidden = true;
7304 continue; 7309 continue;
7305 } 7310 }
7306 if (mystrncasecmp(argv[i],"-system",0)) { 7311 if (mystrncasecmp(argv[i],"-system",0)) {
7307 File.System = true; 7312 File.System = true;
7308 continue; 7313 continue;
7309 } 7314 }
7310 if (mystrncasecmp(argv[i],"-newtime",0)) { 7315 if (mystrncasecmp(argv[i],"-newtime",0)) {
7311 ModEmpty = true; 7316 ModEmpty = true;
7312 continue; 7317 continue;
7313 } 7318 }
7314 printmsg("Parameter \"%s\" unknown\n",argv[i]); 7319 printmsg("Parameter \"%s\" unknown\n",argv[i]);
7315 exit(-1); 7320 exit(-1);
7316 case 1: 7321 case 1:
7317 strcpy(buffer,argv[i]); 7322 strcpy(buffer,argv[i]);
7318 nextlong = 0; 7323 nextlong = 0;
7319 break; 7324 break;
7320 } 7325 }
7321 } 7326 }
7322 if (nextlong!=0) { 7327 if (nextlong!=0) {
7323 printmsg("Parameter missed...\n"); 7328 printmsg("Parameter missed...\n");
7324 exit(-1); 7329 exit(-1);
7325 } 7330 }
7326 } 7331 }
7327 } else { /* MMS things */ 7332 } else { /* MMS things */
7328 DT2.Year = 2001; 7333 DT2.Year = 2001;
7329 DT2.Month = 12; 7334 DT2.Month = 12;
7330 DT2.Day = 31; 7335 DT2.Day = 31;
7331 DT2.Hour = 14; 7336 DT2.Hour = 14;
7332 DT2.Minute = 00; 7337 DT2.Minute = 00;
7333 DT2.Second = 00; 7338 DT2.Second = 00;
7334 t_time2 = Fill_Time_T(DT2,8); 7339 t_time2 = Fill_Time_T(DT2,8);
7335 7340
7336 GSM_GetCurrentDateTime(&DT); 7341 GSM_GetCurrentDateTime(&DT);
7337 t_time1 = Fill_Time_T(DT,8); 7342 t_time1 = Fill_Time_T(DT,8);
7338 7343
7339 sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40)); 7344 sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40));
7340#ifdef DEVELOP 7345#ifdef DEVELOP
7341 sprintf(buffer,"2A947BD 2A947DB "); 7346 sprintf(buffer,"2A947BD 2A947DB ");
7342#endif 7347#endif
7343 /* 40 = inbox "multimedia message received" message */ 7348 /* 40 = inbox "multimedia message received" message */
7344 /* 30 = outbox sending failed */ 7349 /* 30 = outbox sending failed */
7345 if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 "); 7350 if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 ");
7346 else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 "); 7351 else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 ");
7347 else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 "); 7352 else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 ");
7348 else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 "); 7353 else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 ");
7349 else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 "); 7354 else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 ");
7350 if (argc > 4) { 7355 if (argc > 4) {
7351 if (!mystrncasecmp(argv[2],"MMSOutbox",0) && 7356 if (!mystrncasecmp(argv[2],"MMSOutbox",0) &&
7352 !mystrncasecmp(argv[2],"MMSSent",0)) { 7357 !mystrncasecmp(argv[2],"MMSSent",0)) {
7353 sprintf(Name,"%s",argv[4]); 7358 sprintf(Name,"%s",argv[4]);
7354 strcat(buffer,Name); 7359 strcat(buffer,Name);
7355 } 7360 }
7356 if (argc > 5) { 7361 if (argc > 5) {
7357 sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]); 7362 sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]);
7358 strcat(buffer,Name); 7363 strcat(buffer,Name);
7359 } 7364 }
7360 } 7365 }
7361 ModEmpty = true; 7366 ModEmpty = true;
7362 } 7367 }
7363 7368
7364 error = GSM_ReadFile(argv[3], &File); 7369 error = GSM_ReadFile(argv[3], &File);
7365 Print_Error(error); 7370 Print_Error(error);
7366 if (ModEmpty) File.ModifiedEmpty = true; 7371 if (ModEmpty) File.ModifiedEmpty = true;
7367 7372
7368 strcpy(File.ID_FullName,Files.ID_FullName); 7373 strcpy(File.ID_FullName,Files.ID_FullName);
7369 EncodeUnicode(File.Name,buffer,strlen(buffer)); 7374 EncodeUnicode(File.Name,buffer,strlen(buffer));
7370 GSM_IdentifyFileFormat(&File); 7375 GSM_IdentifyFileFormat(&File);
7371#ifdef DEVELOP 7376#ifdef DEVELOP
7372 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { 7377 if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
7373 } else { /* MMS things */ 7378 } else { /* MMS things */
7374 File.Type = GSM_File_MMS; 7379 File.Type = GSM_File_MMS;
7375 } 7380 }
7376#endif 7381#endif
7377 7382
7378 dbgprintf("Adding file to filesystem now\n"); 7383 dbgprintf("Adding file to filesystem now\n");
7379 error = ERR_NONE; 7384 error = ERR_NONE;
7380 Pos= 0; 7385 Pos= 0;
7381 while (error == ERR_NONE) { 7386 while (error == ERR_NONE) {
7382 error = Phone->AddFilePart(&s,&File,&Pos); 7387 error = Phone->AddFilePart(&s,&File,&Pos);
7383 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 7388 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
7384 if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used); 7389 if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used);
7385 } 7390 }
7386 printmsgerr("\n"); 7391 printmsgerr("\n");
7387 if (error == ERR_WRONGCRC) { 7392 if (error == ERR_WRONGCRC) {
7388 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); 7393 printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
7389 } 7394 }
7390 7395
7391 free(File.Buffer); 7396 free(File.Buffer);
7392 GSM_Terminate(); 7397 GSM_Terminate();
7393} 7398}
7394 7399
7395static void DeleteFiles(int argc, char *argv[]) 7400static void DeleteFiles(int argc, char *argv[])
7396{ 7401{
7397 int i; 7402 int i;
7398 7403
7399 GSM_Init(true); 7404 GSM_Init(true);
7400 7405
7401 for (i=2;i<argc;i++) { 7406 for (i=2;i<argc;i++) {
7402 error = Phone->DeleteFile(&s,argv[i]); 7407 error = Phone->DeleteFile(&s,argv[i]);
7403 Print_Error(error); 7408 Print_Error(error);
7404 } 7409 }
7405 7410
7406 GSM_Terminate(); 7411 GSM_Terminate();
7407} 7412}
7408 7413
7409static void SaveMMSFile(int argc, char *argv[]) 7414static void SaveMMSFile(int argc, char *argv[])
7410{ 7415{
7411 FILE *file; 7416 FILE *file;
7412 unsigned char Buffer[50000],Buffer2[20][2010]; 7417 unsigned char Buffer[50000],Buffer2[20][2010];
7413 int i,nextlong = 0,len = 0; 7418 int i,nextlong = 0,len = 0;
7414 GSM_EncodeMultiPartMMSInfo Info; 7419 GSM_EncodeMultiPartMMSInfo Info;
7415 7420
7416 GSM_ClearMultiPartMMSInfo(&Info); 7421 GSM_ClearMultiPartMMSInfo(&Info);
7417 7422
7418 for (i=3;i<argc;i++) { 7423 for (i=3;i<argc;i++) {
7419 switch (nextlong) { 7424 switch (nextlong) {
7420 case 0: 7425 case 0:
7421 if (mystrncasecmp(argv[i],"-subject",0)) { 7426 if (mystrncasecmp(argv[i],"-subject",0)) {
7422 nextlong=1; 7427 nextlong=1;
7423 continue; 7428 continue;
7424 } 7429 }
7425 if (mystrncasecmp(argv[i],"-text",0)) { 7430 if (mystrncasecmp(argv[i],"-text",0)) {
7426 nextlong=2; 7431 nextlong=2;
7427 continue; 7432 continue;
7428 } 7433 }
7429 if (mystrncasecmp(argv[i],"-from",0)) { 7434 if (mystrncasecmp(argv[i],"-from",0)) {
7430 nextlong=3; 7435 nextlong=3;
7431 continue; 7436 continue;
7432 } 7437 }
7433 if (mystrncasecmp(argv[i],"-to",0)) { 7438 if (mystrncasecmp(argv[i],"-to",0)) {
7434 nextlong=4; 7439 nextlong=4;
7435 continue; 7440 continue;
7436 } 7441 }
7437 printmsg("Unknown parameter (\"%s\")\n",argv[i]); 7442 printmsg("Unknown parameter (\"%s\")\n",argv[i]);
7438 exit(-1); 7443 exit(-1);
7439 break; 7444 break;
7440 case 1: /* Subject */ 7445 case 1: /* Subject */
7441 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i])); 7446 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i]));
7442 nextlong = 0; 7447 nextlong = 0;
7443 break; 7448 break;
7444 case 2: /* Text */ 7449 case 2: /* Text */
7445 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i])); 7450 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i]));
7446 Info.Entries[Info.EntriesNum].ID = MMS_Text; 7451 Info.Entries[Info.EntriesNum].ID = MMS_Text;
7447 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum]; 7452 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum];
7448 Info.EntriesNum++; 7453 Info.EntriesNum++;
7449 nextlong = 0; 7454 nextlong = 0;
7450 break; 7455 break;
7451 case 3: /* From */ 7456 case 3: /* From */
7452 EncodeUnicode(Info.Source,argv[i],strlen(argv[i])); 7457 EncodeUnicode(Info.Source,argv[i],strlen(argv[i]));
7453 nextlong = 0; 7458 nextlong = 0;
7454 break; 7459 break;
7455 case 4: /* To */ 7460 case 4: /* To */
7456 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i])); 7461 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i]));
7457 nextlong = 0; 7462 nextlong = 0;
7458 break; 7463 break;
7459 } 7464 }
7460 } 7465 }
7461 if (nextlong!=0) { 7466 if (nextlong!=0) {
7462 printmsg("Parameter missed...\n"); 7467 printmsg("Parameter missed...\n");
7463 exit(-1); 7468 exit(-1);
7464 } 7469 }
7465 7470
7466 GSM_EncodeMMSFile(&Info,Buffer,&len); 7471 GSM_EncodeMMSFile(&Info,Buffer,&len);
7467 7472
7468 file = fopen(argv[2],"wb"); 7473 file = fopen(argv[2],"wb");
7469 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7474 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7470 fwrite(Buffer,1,len,file); 7475 fwrite(Buffer,1,len,file);
7471 fclose(file); 7476 fclose(file);
7472} 7477}
7473 7478
7474static void CallDivert(int argc, char *argv[]) 7479static void CallDivert(int argc, char *argv[])
7475{ 7480{
7476 GSM_MultiCallDivert cd; 7481 GSM_MultiCallDivert cd;
7477 7482
7478 if (mystrncasecmp("get",argv[2],0)) {} 7483 if (mystrncasecmp("get",argv[2],0)) {}
7479 else if (mystrncasecmp("set",argv[2],0)) {} 7484 else if (mystrncasecmp("set",argv[2],0)) {}
7480 else { 7485 else {
7481 printmsg("Unknown divert action (\"%s\")\n",argv[2]); 7486 printmsg("Unknown divert action (\"%s\")\n",argv[2]);
7482 exit(-1); 7487 exit(-1);
7483 } 7488 }
7484 7489
7485 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;} 7490 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;}
7486 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;} 7491 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;}
7487 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;} 7492 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;}
7488 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;} 7493 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;}
7489 else { 7494 else {
7490 printmsg("Unknown divert type (\"%s\")\n",argv[3]); 7495 printmsg("Unknown divert type (\"%s\")\n",argv[3]);
7491 exit(-1); 7496 exit(-1);
7492 } 7497 }
7493 7498
7494 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;} 7499 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;}
7495 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;} 7500 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;}
7496 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;} 7501 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;}
7497 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;} 7502 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;}
7498 else { 7503 else {
7499 printmsg("Unknown call type (\"%s\")\n",argv[4]); 7504 printmsg("Unknown call type (\"%s\")\n",argv[4]);
7500 exit(-1); 7505 exit(-1);
7501 } 7506 }
7502 7507
7503 GSM_Init(true); 7508 GSM_Init(true);
7504 7509
7505 if (mystrncasecmp("get", argv[2],0)) { 7510 if (mystrncasecmp("get", argv[2],0)) {
7506 error = Phone->GetCallDivert(&s,&cd); 7511 error = Phone->GetCallDivert(&s,&cd);
7507 Print_Error(error); 7512 Print_Error(error);
7508 printmsg("Query:\n Divert type: "); 7513 printmsg("Query:\n Divert type: ");
7509 } else { 7514 } else {
7510 cd.Request.Number[0] = 0; 7515 cd.Request.Number[0] = 0;
7511 cd.Request.Number[1] = 0; 7516 cd.Request.Number[1] = 0;
7512 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5])); 7517 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5]));
7513 7518
7514 cd.Request.Timeout = 0; 7519 cd.Request.Timeout = 0;
7515 if (argc > 6) cd.Request.Timeout = atoi(argv[6]); 7520 if (argc > 6) cd.Request.Timeout = atoi(argv[6]);
7516 7521
7517 error = Phone->SetCallDivert(&s,&cd); 7522 error = Phone->SetCallDivert(&s,&cd);
7518 Print_Error(error); 7523 Print_Error(error);
7519 printmsg("Changed:\n Divert type: "); 7524 printmsg("Changed:\n Divert type: ");
7520 } 7525 }
7521 7526
7522 switch (cd.Request.DivertType) { 7527 switch (cd.Request.DivertType) {
7523 case GSM_DIVERT_Busy : printmsg("when busy"); break; 7528 case GSM_DIVERT_Busy : printmsg("when busy"); break;
7524 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break; 7529 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break;
7525 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break; 7530 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break;
7526 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break; 7531 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break;
7527 default : printmsg("unknown %i",cd.Request.DivertType); break; 7532 default : printmsg("unknown %i",cd.Request.DivertType); break;
7528 } 7533 }
7529 printmsg("\n Calls type : "); 7534 printmsg("\n Calls type : ");
7530 switch (cd.Request.CallType) { 7535 switch (cd.Request.CallType) {
7531 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7536 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7532 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7537 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7533 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7538 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7534 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break; 7539 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break;
7535 default : printmsg("unknown %i",cd.Request.CallType); break; 7540 default : printmsg("unknown %i",cd.Request.CallType); break;
7536 } 7541 }
7537 printmsg("\nResponse:"); 7542 printmsg("\nResponse:");
7538 7543
7539 for (i=0;i<cd.Response.EntriesNum;i++) { 7544 for (i=0;i<cd.Response.EntriesNum;i++) {
7540 printmsg("\n Calls type : "); 7545 printmsg("\n Calls type : ");
7541 switch (cd.Response.Entries[i].CallType) { 7546 switch (cd.Response.Entries[i].CallType) {
7542 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7547 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7543 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7548 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7544 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7549 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7545 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; 7550 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break;
7546 } 7551 }
7547 printf("\n"); 7552 printf("\n");
7548 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); 7553 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout);
7549 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); 7554 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number));
7550 } 7555 }
7551 printf("\n"); 7556 printf("\n");
7552 7557
7553 GSM_Terminate(); 7558 GSM_Terminate();
7554} 7559}
7555 7560
7556 7561
7557//#if 0 7562//#if 0
7558static void CancelAllDiverts(int argc, char *argv[]) 7563static void CancelAllDiverts(int argc, char *argv[])
7559{ 7564{
7560 GSM_Init(true); 7565 GSM_Init(true);
7561 7566
7562 error = Phone->CancelAllDiverts(&s); 7567 error = Phone->CancelAllDiverts(&s);
7563 Print_Error(error); 7568 Print_Error(error);
7564 7569
7565 GSM_Terminate(); 7570 GSM_Terminate();
7566} 7571}
7567 7572
7568 7573
7569 7574
7570void SearchPhoneThread(OneDeviceInfo *Info) 7575void SearchPhoneThread(OneDeviceInfo *Info)
7571{ 7576{
7572 int j; 7577 int j;
7573 GSM_Error error; 7578 GSM_Error error;
7574 fprintf(stderr,"*********************************** \n"); 7579 fprintf(stderr,"*********************************** \n");
7575 fprintf(stderr,"*********************************** \n"); 7580 fprintf(stderr,"*********************************** \n");
7576 fprintf(stderr,"*********************************** \n"); 7581 fprintf(stderr,"*********************************** \n");
7577 fprintf(stderr,"*********************************** \n"); 7582 fprintf(stderr,"*********************************** \n");
7578 fprintf(stderr,"*********************************** \n"); 7583 fprintf(stderr,"*********************************** \n");
7579#if 0 7584#if 0
7580 j = 0; 7585 j = 0;
7581 while(strlen(Info->Connections[j].Connection) != 0) { 7586 while(strlen(Info->Connections[j].Connection) != 0) {
7582 memcpy(&Info->s.di,&s.di,sizeof(Debug_Info)); 7587 memcpy(&Info->s.di,&s.di,sizeof(Debug_Info));
7583 Info->s.msg = s.msg; 7588 Info->s.msg = s.msg;
7584 Info->s.ConfigNum = 1; 7589 Info->s.ConfigNum = 1;
7585 Info->s.opened = false; 7590 Info->s.opened = false;
7586 Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile; 7591 Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
7587 Info->s.Config[0].Localize = s.Config[0].Localize; 7592 Info->s.Config[0].Localize = s.Config[0].Localize;
7588 Info->s.Config[0].Device = Info->Device; 7593 Info->s.Config[0].Device = Info->Device;
7589 Info->s.Config[0].Connection = Info->Connections[j].Connection; 7594 Info->s.Config[0].Connection = Info->Connections[j].Connection;
7590 Info->s.Config[0].SyncTime = "no"; 7595 Info->s.Config[0].SyncTime = "no";
7591 Info->s.Config[0].DebugFile = s.Config[0].DebugFile; 7596 Info->s.Config[0].DebugFile = s.Config[0].DebugFile;
7592 Info->s.Config[0].Model[0] = 0; 7597 Info->s.Config[0].Model[0] = 0;
7593 strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel); 7598 strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel);
7594 Info->s.Config[0].LockDevice = "no"; 7599 Info->s.Config[0].LockDevice = "no";
7595 Info->s.Config[0].StartInfo = "no"; 7600 Info->s.Config[0].StartInfo = "no";
7596 7601
7597 error = GSM_InitConnection(&Info->s,1); 7602 error = GSM_InitConnection(&Info->s,1);
7598 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7603 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7599 if (error == ERR_NONE) { 7604 if (error == ERR_NONE) {
7600 error=Info->s.Phone.Functions->GetManufacturer(&Info->s); 7605 error=Info->s.Phone.Functions->GetManufacturer(&Info->s);
7601 if (error == ERR_NONE) { 7606 if (error == ERR_NONE) {
7602 error=Info->s.Phone.Functions->GetModel(&Info->s); 7607 error=Info->s.Phone.Functions->GetModel(&Info->s);
7603 if (error == ERR_NONE) { 7608 if (error == ERR_NONE) {
7604 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7609 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7605 printmsg(" Manufacturer : %s\n", 7610 printmsg(" Manufacturer : %s\n",
7606 Info->s.Phone.Data.Manufacturer); 7611 Info->s.Phone.Data.Manufacturer);
7607 printmsg(" Model : %s (%s)\n", 7612 printmsg(" Model : %s (%s)\n",
7608 Info->s.Phone.Data.ModelInfo->model, 7613 Info->s.Phone.Data.ModelInfo->model,
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
7637void MakeSearchThread(int i) 7642void 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
7653static void SearchPhone(int argc, char *argv[]) 7658static 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
7729static void NokiaGetADC(int argc, char *argv[]) 7734static 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
7743static void NokiaDisplayTest(int argc, char *argv[]) 7748static 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
7757static void NokiaGetT9(int argc, char *argv[]) 7762static 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
7771static void NokiaVibraTest(int argc, char *argv[]) 7776static 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
7785static GSM_Parameters Parameters[] = { 7790static 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
7996static HelpCategoryDescriptions HelpDescriptions[] = { 8001static 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
8032void HelpHeader(void) 8037void 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
8037static void HelpGeneral(void) 8042static 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
8057static void HelpSplit(int cols, int len, unsigned char *buff) 8062static 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
8110static void Help(int argc, char *argv[]) 8115static 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
8206int main(int argc, char *argv[]) 8211int 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
48using namespace KCal; 48using namespace KCal;
49class PhoneParser : public QObject 49class PhoneParser : public QObject
50{ 50{
51public: 51public:
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
84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 84PhoneFormat::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
92PhoneFormat::~PhoneFormat() 92PhoneFormat::~PhoneFormat()
93{ 93{
94} 94}
95#if 0 95#if 0
96int PhoneFormat::initDevice(GSM_StateMachine *s) 96int 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
122ulong PhoneFormat::getCsumTodo( Todo* todo ) 122ulong 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}
147ulong PhoneFormat::getCsumEvent( Event* event ) 150ulong 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}
255ulong PhoneFormat::getCsum( const QStringList & attList) 258ulong 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
284bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 291bool 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}
364void PhoneFormat::copyEvent( Event* to, Event* from ) 372void 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}
403void PhoneFormat::copyTodo( Todo* to, Todo* from ) 412void 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
451void PhoneFormat::afterSave( Incidence* inc) 466void 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}
463bool PhoneFormat::save( Calendar *calendar) 480bool 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
613QString PhoneFormat::toString( Calendar * ) 629QString PhoneFormat::toString( Calendar * )
614{ 630{
615 return QString::null; 631 return QString::null;
616} 632}
617bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 633bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
618{ 634{
619 return false; 635 return false;
620} 636}