-rw-r--r-- | libkcal/phoneformat.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index c97b43d..238b0ef 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -66,259 +66,260 @@ public: | |||
66 | PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { | 66 | PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { |
67 | ; | 67 | ; |
68 | } | 68 | } |
69 | bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) | 69 | bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) |
70 | { | 70 | { |
71 | 71 | ||
72 | int id = ToDo->Location; | 72 | int id = ToDo->Location; |
73 | Todo *todo; | 73 | Todo *todo; |
74 | todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); | 74 | todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); |
75 | if (todo ) | 75 | if (todo ) |
76 | todo = (Todo *)todo->clone(); | 76 | todo = (Todo *)todo->clone(); |
77 | else | 77 | else |
78 | todo = new Todo; | 78 | todo = new Todo; |
79 | todo->setID( mProfileName,QString::number( id ) ); | 79 | todo->setID( mProfileName,QString::number( id ) ); |
80 | todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 80 | todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
81 | int priority; | 81 | int priority; |
82 | switch (ToDo->Priority) { | 82 | switch (ToDo->Priority) { |
83 | case GSM_Priority_Low : priority = 1; break; | 83 | case GSM_Priority_Low : priority = 1; break; |
84 | case GSM_Priority_Medium : priority = 3; break; | 84 | case GSM_Priority_Medium : priority = 3; break; |
85 | case GSM_Priority_High : priority = 5; break; | 85 | case GSM_Priority_High : priority = 5; break; |
86 | default :priority = 3 ;break; | 86 | default :priority = 3 ;break; |
87 | } | 87 | } |
88 | todo->setPriority( priority ); | 88 | todo->setPriority( priority ); |
89 | GSM_Phone_Functions*Phone; | 89 | GSM_Phone_Functions*Phone; |
90 | Phone=s->Phone.Functions; | 90 | Phone=s->Phone.Functions; |
91 | int j; | 91 | int j; |
92 | GSM_DateTime* dtp; | 92 | GSM_DateTime* dtp; |
93 | bool alarm = false; | 93 | bool alarm = false; |
94 | QDateTime alarmDt; | 94 | QDateTime alarmDt; |
95 | GSM_Category Category; | 95 | GSM_Category Category; |
96 | int error; | 96 | int error; |
97 | QString completedString = "no"; | 97 | QString completedString = "no"; |
98 | for (j=0;j<ToDo->EntriesNum;j++) { | 98 | for (j=0;j<ToDo->EntriesNum;j++) { |
99 | switch (ToDo->Entries[j].EntryType) { | 99 | switch (ToDo->Entries[j].EntryType) { |
100 | case TODO_END_DATETIME: | 100 | case TODO_END_DATETIME: |
101 | dtp = &ToDo->Entries[j].Date ; | 101 | dtp = &ToDo->Entries[j].Date ; |
102 | todo->setDtDue (fromGSM ( dtp )); | 102 | todo->setDtDue (fromGSM ( dtp )); |
103 | break; | 103 | break; |
104 | case TODO_COMPLETED: | 104 | case TODO_COMPLETED: |
105 | if ( ToDo->Entries[j].Number == 1 ) { | 105 | if ( ToDo->Entries[j].Number == 1 ) { |
106 | todo->setCompleted( true ); | 106 | todo->setCompleted( true ); |
107 | completedString = "yes"; | 107 | completedString = "yes"; |
108 | } | 108 | } |
109 | else { | 109 | else { |
110 | todo->setCompleted( false ); | 110 | todo->setCompleted( false ); |
111 | } | 111 | } |
112 | break; | 112 | break; |
113 | case TODO_ALARM_DATETIME: | 113 | case TODO_ALARM_DATETIME: |
114 | dtp = &ToDo->Entries[j].Date ; | 114 | dtp = &ToDo->Entries[j].Date ; |
115 | alarm = true; | 115 | alarm = true; |
116 | alarmDt = fromGSM ( dtp ); | 116 | alarmDt = fromGSM ( dtp ); |
117 | break; | 117 | break; |
118 | case TODO_SILENT_ALARM_DATETIME: | 118 | case TODO_SILENT_ALARM_DATETIME: |
119 | dtp = &ToDo->Entries[j].Date ; | 119 | dtp = &ToDo->Entries[j].Date ; |
120 | alarm = true; | 120 | alarm = true; |
121 | alarmDt = fromGSM ( dtp ); | 121 | alarmDt = fromGSM ( dtp ); |
122 | break; | 122 | break; |
123 | case TODO_TEXT: | 123 | case TODO_TEXT: |
124 | todo->setSummary( QString ( (const char*) ToDo->Entries[j].Text )); | 124 | todo->setSummary( QString ( (const char*) ToDo->Entries[j].Text )); |
125 | break; | 125 | break; |
126 | case TODO_PRIVATE: | 126 | case TODO_PRIVATE: |
127 | if ( ToDo->Entries[j].Number == 1 ) | 127 | if ( ToDo->Entries[j].Number == 1 ) |
128 | todo->setSecrecy( Incidence::SecrecyPrivate ); | 128 | todo->setSecrecy( Incidence::SecrecyPrivate ); |
129 | else | 129 | else |
130 | todo->setSecrecy( Incidence::SecrecyPublic ); | 130 | todo->setSecrecy( Incidence::SecrecyPublic ); |
131 | break; | 131 | break; |
132 | case TODO_CATEGORY: | 132 | case TODO_CATEGORY: |
133 | Category.Location = ToDo->Entries[j].Number; | 133 | Category.Location = ToDo->Entries[j].Number; |
134 | Category.Type = Category_ToDo; | 134 | Category.Type = Category_ToDo; |
135 | error=Phone->GetCategory(s, &Category); | 135 | error=Phone->GetCategory(s, &Category); |
136 | if (error == ERR_NONE) { | 136 | if (error == ERR_NONE) { |
137 | QStringList cat = todo->categories(); | 137 | QStringList cat = todo->categories(); |
138 | QString nCat = QString ( (const char*)Category.Name ); | 138 | QString nCat = QString ( (const char*)Category.Name ); |
139 | if ( !nCat.isEmpty() ) | 139 | if ( !nCat.isEmpty() ) |
140 | if ( !cat.contains( nCat )) { | 140 | if ( !cat.contains( nCat )) { |
141 | cat << nCat; | 141 | cat << nCat; |
142 | todo->setCategories( cat ); | 142 | todo->setCategories( cat ); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | break; | 145 | break; |
146 | case TODO_CONTACTID: | 146 | case TODO_CONTACTID: |
147 | #if 0 | 147 | #if 0 |
148 | // not supported | 148 | // not supported |
149 | entry.Location = ToDo->Entries[j].Number; | 149 | entry.Location = ToDo->Entries[j].Number; |
150 | entry.MemoryType = MEM_ME; | 150 | entry.MemoryType = MEM_ME; |
151 | error=Phone->GetMemory(s, &entry); | 151 | error=Phone->GetMemory(s, &entry); |
152 | if (error == ERR_NONE) { | 152 | if (error == ERR_NONE) { |
153 | name = GSM_PhonebookGetEntryName(&entry); | 153 | name = GSM_PhonebookGetEntryName(&entry); |
154 | if (name != NULL) { | 154 | if (name != NULL) { |
155 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); | 155 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); |
156 | } else { | 156 | } else { |
157 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); | 157 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); |
158 | } | 158 | } |
159 | } else { | 159 | } else { |
160 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); | 160 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); |
161 | } | 161 | } |
162 | #endif | 162 | #endif |
163 | break; | 163 | break; |
164 | case TODO_PHONE: | 164 | case TODO_PHONE: |
165 | #if 0 | 165 | #if 0 |
166 | // not supported | 166 | // not supported |
167 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | 167 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); |
168 | #endif | 168 | #endif |
169 | break; | 169 | break; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | QString alarmString = ""; | 172 | QString alarmString = ""; |
173 | // strange 0 semms to mean: alarm enabled | 173 | // strange 0 semms to mean: alarm enabled |
174 | if ( alarm ) { | 174 | if ( alarm ) { |
175 | Alarm *alarm; | 175 | Alarm *alarm; |
176 | if ( todo->alarms().count() > 0 ) | 176 | if ( todo->alarms().count() > 0 ) |
177 | alarm = todo->alarms().first(); | 177 | alarm = todo->alarms().first(); |
178 | else { | 178 | else { |
179 | alarm = new Alarm( todo ); | 179 | alarm = new Alarm( todo ); |
180 | todo->addAlarm( alarm ); | 180 | todo->addAlarm( alarm ); |
181 | } | 181 | } |
182 | alarm->setType( Alarm::Audio ); | 182 | alarm->setType( Alarm::Audio ); |
183 | alarm->setEnabled( true ); | 183 | alarm->setEnabled( true ); |
184 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); | 184 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); |
185 | alarm->setStartOffset( alarmOffset ); | 185 | alarm->setStartOffset( alarmOffset ); |
186 | alarmString = QString::number( alarmOffset ); | 186 | alarmString = QString::number( alarmOffset ); |
187 | } | 187 | } |
188 | // csum ***************************************** | 188 | // csum ***************************************** |
189 | QStringList attList; | 189 | QStringList attList; |
190 | uint cSum; | 190 | uint cSum; |
191 | if ( todo->hasDueDate() ) | 191 | if ( todo->hasDueDate() ) |
192 | attList << dtToString ( todo->dtDue() ); | 192 | attList << dtToString ( todo->dtDue() ); |
193 | attList << QString::number( id ); | 193 | attList << QString::number( id ); |
194 | attList << todo->summary(); | 194 | attList << todo->summary(); |
195 | attList << completedString; | 195 | attList << completedString; |
196 | attList << alarmString; | 196 | attList << QString::number( todo->priority() ); |
197 | attList << alarmString; | ||
197 | attList << todo->categoriesStr(); | 198 | attList << todo->categoriesStr(); |
198 | attList << todo->secrecyStr(); | 199 | attList << todo->secrecyStr(); |
199 | cSum = PhoneFormat::getCsum(attList ); | 200 | cSum = PhoneFormat::getCsum(attList ); |
200 | todo->setCsum( mProfileName, QString::number( cSum )); | 201 | todo->setCsum( mProfileName, QString::number( cSum )); |
201 | mCalendar->addTodo( todo); | 202 | mCalendar->addTodo( todo); |
202 | 203 | ||
203 | return true; | 204 | return true; |
204 | } | 205 | } |
205 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) | 206 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) |
206 | { | 207 | { |
207 | 208 | ||
208 | int id = Note->Location; | 209 | int id = Note->Location; |
209 | Event *event; | 210 | Event *event; |
210 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); | 211 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); |
211 | if ( event ) | 212 | if ( event ) |
212 | event = (Event*)event->clone(); | 213 | event = (Event*)event->clone(); |
213 | else | 214 | else |
214 | event = new Event; | 215 | event = new Event; |
215 | event->setID( mProfileName,QString::number( id ) ); | 216 | event->setID( mProfileName,QString::number( id ) ); |
216 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 217 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
217 | 218 | ||
218 | 219 | ||
219 | int i = 0; | 220 | int i = 0; |
220 | bool repeating = false; | 221 | bool repeating = false; |
221 | int repeat_dayofweek = -1; | 222 | int repeat_dayofweek = -1; |
222 | int repeat_day = -1; | 223 | int repeat_day = -1; |
223 | int repeat_weekofmonth = -1; | 224 | int repeat_weekofmonth = -1; |
224 | int repeat_month = -1; | 225 | int repeat_month = -1; |
225 | int repeat_frequency = -1; | 226 | int repeat_frequency = -1; |
226 | int rec_type = -1; | 227 | int rec_type = -1; |
227 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 228 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
228 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 229 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
229 | GSM_DateTime* dtp; | 230 | GSM_DateTime* dtp; |
230 | bool alarm = false; | 231 | bool alarm = false; |
231 | QDateTime alarmDt; | 232 | QDateTime alarmDt; |
232 | repeat_startdate.Day= 0; | 233 | repeat_startdate.Day= 0; |
233 | repeat_stopdate.Day = 0; | 234 | repeat_stopdate.Day = 0; |
234 | for (i=0;i<Note->EntriesNum;i++) { | 235 | for (i=0;i<Note->EntriesNum;i++) { |
235 | 236 | ||
236 | qDebug(" for "); | 237 | qDebug(" for "); |
237 | switch (Note->Entries[i].EntryType) { | 238 | switch (Note->Entries[i].EntryType) { |
238 | case CAL_START_DATETIME: | 239 | case CAL_START_DATETIME: |
239 | dtp = &Note->Entries[i].Date ; | 240 | dtp = &Note->Entries[i].Date ; |
240 | if ( dtp->Hour > 24 ) { | 241 | if ( dtp->Hour > 24 ) { |
241 | event->setFloats( true ); | 242 | event->setFloats( true ); |
242 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 243 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
243 | } else { | 244 | } else { |
244 | event->setDtStart (fromGSM ( dtp )); | 245 | event->setDtStart (fromGSM ( dtp )); |
245 | 246 | ||
246 | } | 247 | } |
247 | break; | 248 | break; |
248 | case CAL_END_DATETIME: | 249 | case CAL_END_DATETIME: |
249 | dtp = &Note->Entries[i].Date ; | 250 | dtp = &Note->Entries[i].Date ; |
250 | if ( dtp->Hour > 24 ) { | 251 | if ( dtp->Hour > 24 ) { |
251 | event->setFloats( true ); | 252 | event->setFloats( true ); |
252 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 253 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
253 | } else { | 254 | } else { |
254 | event->setDtEnd (fromGSM ( dtp )); | 255 | event->setDtEnd (fromGSM ( dtp )); |
255 | } | 256 | } |
256 | break; | 257 | break; |
257 | case CAL_ALARM_DATETIME: | 258 | case CAL_ALARM_DATETIME: |
258 | dtp = &Note->Entries[i].Date ; | 259 | dtp = &Note->Entries[i].Date ; |
259 | alarm = true; | 260 | alarm = true; |
260 | alarmDt = fromGSM ( dtp ); | 261 | alarmDt = fromGSM ( dtp ); |
261 | break; | 262 | break; |
262 | case CAL_SILENT_ALARM_DATETIME: | 263 | case CAL_SILENT_ALARM_DATETIME: |
263 | dtp = &Note->Entries[i].Date ; | 264 | dtp = &Note->Entries[i].Date ; |
264 | alarm = true; | 265 | alarm = true; |
265 | alarmDt = fromGSM ( dtp ); | 266 | alarmDt = fromGSM ( dtp ); |
266 | break; | 267 | break; |
267 | case CAL_RECURRANCE: | 268 | case CAL_RECURRANCE: |
268 | rec_type = Note->Entries[i].Number; | 269 | rec_type = Note->Entries[i].Number; |
269 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); | 270 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); |
270 | break; | 271 | break; |
271 | case CAL_TEXT: | 272 | case CAL_TEXT: |
272 | event->setSummary( QString ( (const char*) Note->Entries[i].Text )); | 273 | event->setSummary( QString ( (const char*) Note->Entries[i].Text )); |
273 | break; | 274 | break; |
274 | case CAL_LOCATION: | 275 | case CAL_LOCATION: |
275 | event->setLocation(QString ((const char*) Note->Entries[i].Text )); | 276 | event->setLocation(QString ((const char*) Note->Entries[i].Text )); |
276 | break; | 277 | break; |
277 | case CAL_PHONE: | 278 | case CAL_PHONE: |
278 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 279 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
279 | break; | 280 | break; |
280 | case CAL_PRIVATE: | 281 | case CAL_PRIVATE: |
281 | if ( Note->Entries[i].Number == 1 ) | 282 | if ( Note->Entries[i].Number == 1 ) |
282 | event->setSecrecy( Incidence::SecrecyPrivate ); | 283 | event->setSecrecy( Incidence::SecrecyPrivate ); |
283 | else | 284 | else |
284 | event->setSecrecy( Incidence::SecrecyPublic ); | 285 | event->setSecrecy( Incidence::SecrecyPublic ); |
285 | 286 | ||
286 | break; | 287 | break; |
287 | case CAL_CONTACTID: | 288 | case CAL_CONTACTID: |
288 | #if 0 | 289 | #if 0 |
289 | entry.Location = Note->Entries[i].Number; | 290 | entry.Location = Note->Entries[i].Number; |
290 | entry.MemoryType = MEM_ME; | 291 | entry.MemoryType = MEM_ME; |
291 | error=Phone->GetMemory(&s, &entry); | 292 | error=Phone->GetMemory(&s, &entry); |
292 | if (error == ERR_NONE) { | 293 | if (error == ERR_NONE) { |
293 | name = GSM_PhonebookGetEntryName(&entry); | 294 | name = GSM_PhonebookGetEntryName(&entry); |
294 | if (name != NULL) { | 295 | if (name != NULL) { |
295 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); | 296 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); |
296 | } else { | 297 | } else { |
297 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 298 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
298 | } | 299 | } |
299 | } else { | 300 | } else { |
300 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 301 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
301 | } | 302 | } |
302 | #endif | 303 | #endif |
303 | break; | 304 | break; |
304 | case CAL_REPEAT_DAYOFWEEK: | 305 | case CAL_REPEAT_DAYOFWEEK: |
305 | repeat_dayofweek = Note->Entries[i].Number; | 306 | repeat_dayofweek = Note->Entries[i].Number; |
306 | repeating = true; | 307 | repeating = true; |
307 | break; | 308 | break; |
308 | case CAL_REPEAT_DAY: | 309 | case CAL_REPEAT_DAY: |
309 | repeat_day = Note->Entries[i].Number; | 310 | repeat_day = Note->Entries[i].Number; |
310 | repeating = true; | 311 | repeating = true; |
311 | break; | 312 | break; |
312 | case CAL_REPEAT_WEEKOFMONTH: | 313 | case CAL_REPEAT_WEEKOFMONTH: |
313 | repeat_weekofmonth = Note->Entries[i].Number; | 314 | repeat_weekofmonth = Note->Entries[i].Number; |
314 | repeating = true; | 315 | repeating = true; |
315 | break; | 316 | break; |
316 | case CAL_REPEAT_MONTH: | 317 | case CAL_REPEAT_MONTH: |
317 | repeat_month = Note->Entries[i].Number; | 318 | repeat_month = Note->Entries[i].Number; |
318 | repeating = true; | 319 | repeating = true; |
319 | break; | 320 | break; |
320 | case CAL_REPEAT_FREQUENCY: | 321 | case CAL_REPEAT_FREQUENCY: |
321 | repeat_frequency = Note->Entries[i].Number; | 322 | repeat_frequency = Note->Entries[i].Number; |
322 | repeating = true; | 323 | repeating = true; |
323 | break; | 324 | break; |
324 | case CAL_REPEAT_STARTDATE: | 325 | case CAL_REPEAT_STARTDATE: |
@@ -549,257 +550,257 @@ public: | |||
549 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; | 550 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; |
550 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; | 551 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; |
551 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; | 552 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; |
552 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; | 553 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; |
553 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; | 554 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; |
554 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; | 555 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; |
555 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; | 556 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; |
556 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; | 557 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; |
557 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; | 558 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; |
558 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; | 559 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; |
559 | default : CATEGORY = QString(""); | 560 | default : CATEGORY = QString(""); |
560 | } | 561 | } |
561 | 562 | ||
562 | return CATEGORY; | 563 | return CATEGORY; |
563 | } | 564 | } |
564 | 565 | ||
565 | protected: | 566 | protected: |
566 | private: | 567 | private: |
567 | Calendar *mCalendar; | 568 | Calendar *mCalendar; |
568 | QString mProfileName ; | 569 | QString mProfileName ; |
569 | }; | 570 | }; |
570 | 571 | ||
571 | 572 | ||
572 | PhoneFormat::PhoneFormat() | 573 | PhoneFormat::PhoneFormat() |
573 | { | 574 | { |
574 | ; | 575 | ; |
575 | } | 576 | } |
576 | 577 | ||
577 | PhoneFormat::~PhoneFormat() | 578 | PhoneFormat::~PhoneFormat() |
578 | { | 579 | { |
579 | } | 580 | } |
580 | ulong PhoneFormat::getCsum( const QStringList & attList) | 581 | ulong PhoneFormat::getCsum( const QStringList & attList) |
581 | { | 582 | { |
582 | int max = attList.count() -1; | 583 | int max = attList.count() -1; |
583 | ulong cSum = 0; | 584 | ulong cSum = 0; |
584 | int j,k,i; | 585 | int j,k,i; |
585 | int add; | 586 | int add; |
586 | for ( i = 1; i < max ; ++i ) { | 587 | for ( i = 1; i < max ; ++i ) { |
587 | QString s = attList[i]; | 588 | QString s = attList[i]; |
588 | if ( ! s.isEmpty() ){ | 589 | if ( ! s.isEmpty() ){ |
589 | j = s.length(); | 590 | j = s.length(); |
590 | for ( k = 0; k < j; ++k ) { | 591 | for ( k = 0; k < j; ++k ) { |
591 | int mul = k +1; | 592 | int mul = k +1; |
592 | add = s[k].unicode (); | 593 | add = s[k].unicode (); |
593 | if ( k < 16 ) | 594 | if ( k < 16 ) |
594 | mul = mul * mul; | 595 | mul = mul * mul; |
595 | add = add * mul *i*i*i; | 596 | add = add * mul *i*i*i; |
596 | cSum += add; | 597 | cSum += add; |
597 | } | 598 | } |
598 | } | 599 | } |
599 | } | 600 | } |
600 | return cSum; | 601 | return cSum; |
601 | 602 | ||
602 | } | 603 | } |
603 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 604 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
604 | #include <stdlib.h> | 605 | #include <stdlib.h> |
605 | #define DEBUGMODE false | 606 | #define DEBUGMODE false |
606 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profileName, QString device,QString connection, QString model ) | 607 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profileName, QString device,QString connection, QString model ) |
607 | { | 608 | { |
608 | mProfileName = profileName; | 609 | mProfileName = profileName; |
609 | GSM_StateMachines; | 610 | GSM_StateMachines; |
610 | qDebug(" load "); | 611 | qDebug(" load "); |
611 | s.opened = false; | 612 | s.opened = false; |
612 | s.msg = NULL; | 613 | s.msg = NULL; |
613 | s.ConfigNum = 0; | 614 | s.ConfigNum = 0; |
614 | static char*cp; | 615 | static char*cp; |
615 | static INI_Section *cfg = NULL; | 616 | static INI_Section *cfg = NULL; |
616 | cfg=GSM_FindGammuRC(); | 617 | cfg=GSM_FindGammuRC(); |
617 | int i; | 618 | int i; |
618 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | 619 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { |
619 | if (cfg!=NULL) { | 620 | if (cfg!=NULL) { |
620 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); | 621 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); |
621 | if (cp) di.coding = cp; | 622 | if (cp) di.coding = cp; |
622 | 623 | ||
623 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); | 624 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); |
624 | if (s.Config[i].Localize) { | 625 | if (s.Config[i].Localize) { |
625 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | 626 | s.msg=INI_ReadFile(s.Config[i].Localize, true); |
626 | } else { | 627 | } else { |
627 | #if !defined(WIN32) && defined(LOCALE_PATH) | 628 | #if !defined(WIN32) && defined(LOCALE_PATH) |
628 | locale = setlocale(LC_MESSAGES, NULL); | 629 | locale = setlocale(LC_MESSAGES, NULL); |
629 | if (locale != NULL) { | 630 | if (locale != NULL) { |
630 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", | 631 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", |
631 | LOCALE_PATH, | 632 | LOCALE_PATH, |
632 | tolower(locale[0]), | 633 | tolower(locale[0]), |
633 | tolower(locale[1])); | 634 | tolower(locale[1])); |
634 | s.msg = INI_ReadFile(locale_file, true); | 635 | s.msg = INI_ReadFile(locale_file, true); |
635 | } | 636 | } |
636 | #endif | 637 | #endif |
637 | } | 638 | } |
638 | } | 639 | } |
639 | 640 | ||
640 | /* Wanted user specific configuration? */ | 641 | /* Wanted user specific configuration? */ |
641 | 642 | ||
642 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; | 643 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; |
643 | 644 | ||
644 | s.ConfigNum++; | 645 | s.ConfigNum++; |
645 | 646 | ||
646 | /* We want to use only one file descriptor for global and state machine debug output */ | 647 | /* We want to use only one file descriptor for global and state machine debug output */ |
647 | s.Config[i].UseGlobalDebugFile = true; | 648 | s.Config[i].UseGlobalDebugFile = true; |
648 | 649 | ||
649 | 650 | ||
650 | 651 | ||
651 | /* We wanted to read just user specified configuration. */ | 652 | /* We wanted to read just user specified configuration. */ |
652 | {break;} | 653 | {break;} |
653 | } | 654 | } |
654 | 655 | ||
655 | int error=GSM_InitConnection(&s,3); | 656 | int error=GSM_InitConnection(&s,3); |
656 | qDebug(" init %d %d", error, ERR_NONE); | 657 | qDebug(" init %d %d", error, ERR_NONE); |
657 | if ( error != ERR_NONE ) | 658 | if ( error != ERR_NONE ) |
658 | return false; | 659 | return false; |
659 | // fromString2Cal( calendar, existngCal, &s, "Event" ); | 660 | // fromString2Cal( calendar, existngCal, &s, "Event" ); |
660 | GSM_Phone_Functions*Phone; | 661 | GSM_Phone_Functions*Phone; |
661 | GSM_CalendarEntrynote; | 662 | GSM_CalendarEntrynote; |
662 | bool refresh= true; | 663 | bool refresh= true; |
663 | Phone=s.Phone.Functions; | 664 | Phone=s.Phone.Functions; |
664 | bool gshutdown = false; | 665 | bool gshutdown = false; |
665 | PhoneParser handler( calendar, profileName ); | 666 | PhoneParser handler( calendar, profileName ); |
666 | int ccc = 0; | 667 | int ccc = 0; |
667 | while (!gshutdown && ccc++ < 10 ) { | 668 | while (!gshutdown && ccc++ < 10 ) { |
668 | 669 | ||
669 | qDebug("readEvent %d ", ccc); | 670 | qDebug("readEvent %d ", ccc); |
670 | error=Phone->GetNextCalendar(&s,¬e,refresh); | 671 | error=Phone->GetNextCalendar(&s,¬e,refresh); |
671 | if (error == ERR_EMPTY) break; | 672 | if (error == ERR_EMPTY) break; |
672 | handler.readEvent( existingCal, ¬e ); | 673 | handler.readEvent( existingCal, ¬e ); |
673 | } | 674 | } |
674 | 675 | ||
675 | bool start = true; | 676 | bool start = true; |
676 | GSM_ToDoEntry ToDo; | 677 | GSM_ToDoEntry ToDo; |
677 | int ccc = 0; | 678 | ccc = 0; |
678 | while (!gshutdown) { | 679 | while (!gshutdown) { |
679 | error = Phone->GetNextToDo(&s, &ToDo, start); | 680 | error = Phone->GetNextToDo(&s, &ToDo, start); |
680 | if (error == ERR_EMPTY) break; | 681 | if (error == ERR_EMPTY) break; |
681 | start = false; | 682 | start = false; |
682 | qDebug("readTodo %d ", ++ccc); | 683 | qDebug("readTodo %d ", ++ccc); |
683 | handler.readTodo( existingCal, &ToDo, &s); | 684 | handler.readTodo( existingCal, &ToDo, &s); |
684 | 685 | ||
685 | } | 686 | } |
686 | 687 | ||
687 | error=GSM_TerminateConnection(&s); | 688 | error=GSM_TerminateConnection(&s); |
688 | 689 | ||
689 | return true; | 690 | return true; |
690 | } | 691 | } |
691 | 692 | ||
692 | bool PhoneFormat::save( Calendar *calendar) | 693 | bool PhoneFormat::save( Calendar *calendar) |
693 | { | 694 | { |
694 | #if 0 | 695 | #if 0 |
695 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 696 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
696 | int w = status.sizeHint().width()+20 ; | 697 | int w = status.sizeHint().width()+20 ; |
697 | if ( w < 200 ) w = 200; | 698 | if ( w < 200 ) w = 200; |
698 | int h = status.sizeHint().height()+20 ; | 699 | int h = status.sizeHint().height()+20 ; |
699 | int dw = QApplication::desktop()->width(); | 700 | int dw = QApplication::desktop()->width(); |
700 | int dh = QApplication::desktop()->height(); | 701 | int dh = QApplication::desktop()->height(); |
701 | status.setCaption(i18n("Writing DTM Data") ); | 702 | status.setCaption(i18n("Writing DTM Data") ); |
702 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 703 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
703 | status.show(); | 704 | status.show(); |
704 | status.raise(); | 705 | status.raise(); |
705 | qApp->processEvents(); | 706 | qApp->processEvents(); |
706 | bool debug = DEBUGMODE; | 707 | bool debug = DEBUGMODE; |
707 | QString codec = "utf8"; | 708 | QString codec = "utf8"; |
708 | QString answer; | 709 | QString answer; |
709 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 710 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
710 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 711 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
711 | QString command; | 712 | QString command; |
712 | QPtrList<Event> er = calendar->rawEvents(); | 713 | QPtrList<Event> er = calendar->rawEvents(); |
713 | Event* ev = er.first(); | 714 | Event* ev = er.first(); |
714 | QString fileName = "/tmp/kopitempout"; | 715 | QString fileName = "/tmp/kopitempout"; |
715 | int i = 0; | 716 | int i = 0; |
716 | QString changeString = ePrefix; | 717 | QString changeString = ePrefix; |
717 | QString deleteString = ePrefix; | 718 | QString deleteString = ePrefix; |
718 | bool deleteEnt = false; | 719 | bool deleteEnt = false; |
719 | bool changeEnt = false; | 720 | bool changeEnt = false; |
720 | QString message = i18n("Processing event # "); | 721 | QString message = i18n("Processing event # "); |
721 | int procCount = 0; | 722 | int procCount = 0; |
722 | while ( ev ) { | 723 | while ( ev ) { |
723 | //qDebug("i %d ", ++i); | 724 | //qDebug("i %d ", ++i); |
724 | if ( true /*ev->zaurusStat() != -2*/ ) { | 725 | if ( true /*ev->zaurusStat() != -2*/ ) { |
725 | status.setText ( message + QString::number ( ++procCount ) ); | 726 | status.setText ( message + QString::number ( ++procCount ) ); |
726 | qApp->processEvents(); | 727 | qApp->processEvents(); |
727 | QString eString = getEventString( ev ); | 728 | QString eString = getEventString( ev ); |
728 | if (/* ev->zaurusStat() == -3 */ true) { // delete | 729 | if (/* ev->zaurusStat() == -3 */ true) { // delete |
729 | // deleting empty strings does not work. | 730 | // deleting empty strings does not work. |
730 | // we write first and x and then delete the record with the x | 731 | // we write first and x and then delete the record with the x |
731 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 732 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
732 | changeString += eString + "\n"; | 733 | changeString += eString + "\n"; |
733 | deleteString += eString + "\n"; | 734 | deleteString += eString + "\n"; |
734 | deleteEnt = true; | 735 | deleteEnt = true; |
735 | changeEnt = true; | 736 | changeEnt = true; |
736 | } | 737 | } |
737 | else if ( /*ev->zaurusId() == -1*/true ) { // add new | 738 | else if ( /*ev->zaurusId() == -1*/true ) { // add new |
738 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 739 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
739 | system ( command.utf8() ); | 740 | system ( command.utf8() ); |
740 | QFile file( fileName ); | 741 | QFile file( fileName ); |
741 | if (!file.open( IO_ReadOnly ) ) { | 742 | if (!file.open( IO_ReadOnly ) ) { |
742 | return false; | 743 | return false; |
743 | 744 | ||
744 | } | 745 | } |
745 | QTextStream ts( &file ); | 746 | QTextStream ts( &file ); |
746 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 747 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
747 | answer = ts.read(); | 748 | answer = ts.read(); |
748 | file.close(); | 749 | file.close(); |
749 | //qDebug("answer \n%s ", answer.latin1()); | 750 | //qDebug("answer \n%s ", answer.latin1()); |
750 | getNumFromRecord( answer, ev ) ; | 751 | getNumFromRecord( answer, ev ) ; |
751 | 752 | ||
752 | } | 753 | } |
753 | else { // change existing | 754 | else { // change existing |
754 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | 755 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); |
755 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 756 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
756 | changeString += eString + "\n"; | 757 | changeString += eString + "\n"; |
757 | changeEnt = true; | 758 | changeEnt = true; |
758 | 759 | ||
759 | } | 760 | } |
760 | } | 761 | } |
761 | ev = er.next(); | 762 | ev = er.next(); |
762 | } | 763 | } |
763 | status.setText ( i18n("Changing events ...") ); | 764 | status.setText ( i18n("Changing events ...") ); |
764 | qApp->processEvents(); | 765 | qApp->processEvents(); |
765 | //qDebug("changing... "); | 766 | //qDebug("changing... "); |
766 | if ( changeEnt ) { | 767 | if ( changeEnt ) { |
767 | QFile file( fileName ); | 768 | QFile file( fileName ); |
768 | if (!file.open( IO_WriteOnly ) ) { | 769 | if (!file.open( IO_WriteOnly ) ) { |
769 | return false; | 770 | return false; |
770 | 771 | ||
771 | } | 772 | } |
772 | QTextStream ts( &file ); | 773 | QTextStream ts( &file ); |
773 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 774 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
774 | ts << changeString ; | 775 | ts << changeString ; |
775 | file.close(); | 776 | file.close(); |
776 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; | 777 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; |
777 | system ( command.latin1() ); | 778 | system ( command.latin1() ); |
778 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 779 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
779 | 780 | ||
780 | } | 781 | } |
781 | status.setText ( i18n("Deleting events ...") ); | 782 | status.setText ( i18n("Deleting events ...") ); |
782 | qApp->processEvents(); | 783 | qApp->processEvents(); |
783 | //qDebug("deleting... "); | 784 | //qDebug("deleting... "); |
784 | if ( deleteEnt ) { | 785 | if ( deleteEnt ) { |
785 | QFile file( fileName ); | 786 | QFile file( fileName ); |
786 | if (!file.open( IO_WriteOnly ) ) { | 787 | if (!file.open( IO_WriteOnly ) ) { |
787 | return false; | 788 | return false; |
788 | 789 | ||
789 | } | 790 | } |
790 | QTextStream ts( &file ); | 791 | QTextStream ts( &file ); |
791 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 792 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
792 | ts << deleteString; | 793 | ts << deleteString; |
793 | file.close(); | 794 | file.close(); |
794 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; | 795 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; |
795 | system ( command.latin1() ); | 796 | system ( command.latin1() ); |
796 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 797 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
797 | } | 798 | } |
798 | 799 | ||
799 | 800 | ||
800 | changeString = tPrefix; | 801 | changeString = tPrefix; |
801 | deleteString = tPrefix; | 802 | deleteString = tPrefix; |
802 | status.setText ( i18n("Processing todos ...") ); | 803 | status.setText ( i18n("Processing todos ...") ); |
803 | qApp->processEvents(); | 804 | qApp->processEvents(); |
804 | QPtrList<Todo> tl = calendar->rawTodos(); | 805 | QPtrList<Todo> tl = calendar->rawTodos(); |
805 | Todo* to = tl.first(); | 806 | Todo* to = tl.first(); |