author | zautrix <zautrix> | 2004-08-08 09:30:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-08 09:30:54 (UTC) |
commit | ad825350a6967b6e0273c0a5916693853b70d242 (patch) (unidiff) | |
tree | 7164d97e4ddc77c6e9304c5f48dbbb26940dad47 | |
parent | a9c3191a42084b6631dededef1709fa67eb2c048 (diff) | |
download | kdepimpi-ad825350a6967b6e0273c0a5916693853b70d242.zip kdepimpi-ad825350a6967b6e0273c0a5916693853b70d242.tar.gz kdepimpi-ad825350a6967b6e0273c0a5916693853b70d242.tar.bz2 |
more phone sync: read todo added
-rw-r--r-- | libkcal/phoneformat.cpp | 897 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 8 |
2 files changed, 260 insertions, 645 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index fd6b6af..c97b43d 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -64,29 +64,147 @@ class PhoneParser : public QObject | |||
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { | 66 | PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { |
67 | oldCategories = 0; | 67 | ; |
68 | } | 68 | } |
69 | 69 | bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) | |
70 | bool startElement( Calendar *existingCalendar, GSM_CalendarEntry*Note, QString qName ) | ||
71 | { | 70 | { |
72 | QStringList attList; | 71 | |
73 | /* | 72 | int id = ToDo->Location; |
74 | // pending csum | 73 | Todo *todo; |
75 | int i = 1; | 74 | todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); |
76 | bool skip = true; | 75 | if (todo ) |
77 | int max = attList.count() -2; | 76 | todo = (Todo *)todo->clone(); |
78 | while ( i < max ) { | 77 | else |
79 | if ( !attList[i].isEmpty() ) { | 78 | todo = new Todo; |
80 | skip = false; | 79 | todo->setID( mProfileName,QString::number( id ) ); |
80 | todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | ||
81 | int priority; | ||
82 | switch (ToDo->Priority) { | ||
83 | case GSM_Priority_Low : priority = 1; break; | ||
84 | case GSM_Priority_Medium : priority = 3; break; | ||
85 | case GSM_Priority_High : priority = 5; break; | ||
86 | default :priority = 3 ;break; | ||
87 | } | ||
88 | todo->setPriority( priority ); | ||
89 | GSM_Phone_Functions*Phone; | ||
90 | Phone=s->Phone.Functions; | ||
91 | int j; | ||
92 | GSM_DateTime* dtp; | ||
93 | bool alarm = false; | ||
94 | QDateTime alarmDt; | ||
95 | GSM_Category Category; | ||
96 | int error; | ||
97 | QString completedString = "no"; | ||
98 | for (j=0;j<ToDo->EntriesNum;j++) { | ||
99 | switch (ToDo->Entries[j].EntryType) { | ||
100 | case TODO_END_DATETIME: | ||
101 | dtp = &ToDo->Entries[j].Date ; | ||
102 | todo->setDtDue (fromGSM ( dtp )); | ||
81 | break; | 103 | break; |
104 | case TODO_COMPLETED: | ||
105 | if ( ToDo->Entries[j].Number == 1 ) { | ||
106 | todo->setCompleted( true ); | ||
107 | completedString = "yes"; | ||
82 | } | 108 | } |
83 | ++i ; | 109 | else { |
110 | todo->setCompleted( false ); | ||
84 | } | 111 | } |
85 | if ( skip ) | 112 | break; |
86 | return false; | 113 | case TODO_ALARM_DATETIME: |
87 | ulong cSum = PhoneFormat::getCsum(attList ); | 114 | dtp = &ToDo->Entries[j].Date ; |
88 | */ | 115 | alarm = true; |
89 | if ( qName == "Event" ) { | 116 | alarmDt = fromGSM ( dtp ); |
117 | break; | ||
118 | case TODO_SILENT_ALARM_DATETIME: | ||
119 | dtp = &ToDo->Entries[j].Date ; | ||
120 | alarm = true; | ||
121 | alarmDt = fromGSM ( dtp ); | ||
122 | break; | ||
123 | case TODO_TEXT: | ||
124 | todo->setSummary( QString ( (const char*) ToDo->Entries[j].Text )); | ||
125 | break; | ||
126 | case TODO_PRIVATE: | ||
127 | if ( ToDo->Entries[j].Number == 1 ) | ||
128 | todo->setSecrecy( Incidence::SecrecyPrivate ); | ||
129 | else | ||
130 | todo->setSecrecy( Incidence::SecrecyPublic ); | ||
131 | break; | ||
132 | case TODO_CATEGORY: | ||
133 | Category.Location = ToDo->Entries[j].Number; | ||
134 | Category.Type = Category_ToDo; | ||
135 | error=Phone->GetCategory(s, &Category); | ||
136 | if (error == ERR_NONE) { | ||
137 | QStringList cat = todo->categories(); | ||
138 | QString nCat = QString ( (const char*)Category.Name ); | ||
139 | if ( !nCat.isEmpty() ) | ||
140 | if ( !cat.contains( nCat )) { | ||
141 | cat << nCat; | ||
142 | todo->setCategories( cat ); | ||
143 | } | ||
144 | } | ||
145 | break; | ||
146 | case TODO_CONTACTID: | ||
147 | #if 0 | ||
148 | // not supported | ||
149 | entry.Location = ToDo->Entries[j].Number; | ||
150 | entry.MemoryType = MEM_ME; | ||
151 | error=Phone->GetMemory(s, &entry); | ||
152 | if (error == ERR_NONE) { | ||
153 | name = GSM_PhonebookGetEntryName(&entry); | ||
154 | if (name != NULL) { | ||
155 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); | ||
156 | } else { | ||
157 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); | ||
158 | } | ||
159 | } else { | ||
160 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); | ||
161 | } | ||
162 | #endif | ||
163 | break; | ||
164 | case TODO_PHONE: | ||
165 | #if 0 | ||
166 | // not supported | ||
167 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | ||
168 | #endif | ||
169 | break; | ||
170 | } | ||
171 | } | ||
172 | QString alarmString = ""; | ||
173 | // strange 0 semms to mean: alarm enabled | ||
174 | if ( alarm ) { | ||
175 | Alarm *alarm; | ||
176 | if ( todo->alarms().count() > 0 ) | ||
177 | alarm = todo->alarms().first(); | ||
178 | else { | ||
179 | alarm = new Alarm( todo ); | ||
180 | todo->addAlarm( alarm ); | ||
181 | } | ||
182 | alarm->setType( Alarm::Audio ); | ||
183 | alarm->setEnabled( true ); | ||
184 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); | ||
185 | alarm->setStartOffset( alarmOffset ); | ||
186 | alarmString = QString::number( alarmOffset ); | ||
187 | } | ||
188 | // csum ***************************************** | ||
189 | QStringList attList; | ||
190 | uint cSum; | ||
191 | if ( todo->hasDueDate() ) | ||
192 | attList << dtToString ( todo->dtDue() ); | ||
193 | attList << QString::number( id ); | ||
194 | attList << todo->summary(); | ||
195 | attList << completedString; | ||
196 | attList << alarmString; | ||
197 | attList << todo->categoriesStr(); | ||
198 | attList << todo->secrecyStr(); | ||
199 | cSum = PhoneFormat::getCsum(attList ); | ||
200 | todo->setCsum( mProfileName, QString::number( cSum )); | ||
201 | mCalendar->addTodo( todo); | ||
202 | |||
203 | return true; | ||
204 | } | ||
205 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) | ||
206 | { | ||
207 | |||
90 | int id = Note->Location; | 208 | int id = Note->Location; |
91 | Event *event; | 209 | Event *event; |
92 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); | 210 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); |
@@ -94,8 +212,7 @@ class PhoneParser : public QObject | |||
94 | event = (Event*)event->clone(); | 212 | event = (Event*)event->clone(); |
95 | else | 213 | else |
96 | event = new Event; | 214 | event = new Event; |
97 | event->setID( mProfileName, attList[0] ); | 215 | event->setID( mProfileName,QString::number( id ) ); |
98 | // pending event->setCsum( "Sharp_DTM", QString::number( cSum )); | ||
99 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 216 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
100 | 217 | ||
101 | 218 | ||
@@ -106,6 +223,7 @@ class PhoneParser : public QObject | |||
106 | int repeat_weekofmonth = -1; | 223 | int repeat_weekofmonth = -1; |
107 | int repeat_month = -1; | 224 | int repeat_month = -1; |
108 | int repeat_frequency = -1; | 225 | int repeat_frequency = -1; |
226 | int rec_type = -1; | ||
109 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 227 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
110 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 228 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
111 | GSM_DateTime* dtp; | 229 | GSM_DateTime* dtp; |
@@ -147,6 +265,7 @@ class PhoneParser : public QObject | |||
147 | alarmDt = fromGSM ( dtp ); | 265 | alarmDt = fromGSM ( dtp ); |
148 | break; | 266 | break; |
149 | case CAL_RECURRANCE: | 267 | case CAL_RECURRANCE: |
268 | rec_type = Note->Entries[i].Number; | ||
150 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); | 269 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); |
151 | break; | 270 | break; |
152 | case CAL_TEXT: | 271 | case CAL_TEXT: |
@@ -159,7 +278,11 @@ class PhoneParser : public QObject | |||
159 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 278 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
160 | break; | 279 | break; |
161 | case CAL_PRIVATE: | 280 | case CAL_PRIVATE: |
162 | //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); | 281 | if ( Note->Entries[i].Number == 1 ) |
282 | event->setSecrecy( Incidence::SecrecyPrivate ); | ||
283 | else | ||
284 | event->setSecrecy( Incidence::SecrecyPublic ); | ||
285 | |||
163 | break; | 286 | break; |
164 | case CAL_CONTACTID: | 287 | case CAL_CONTACTID: |
165 | #if 0 | 288 | #if 0 |
@@ -221,8 +344,20 @@ class PhoneParser : public QObject | |||
221 | 344 | ||
222 | #endif | 345 | #endif |
223 | 346 | ||
224 | QString rtype = attList[11]; | 347 | QString recurString = "no"; |
225 | if ( repeating ) { | 348 | if ( repeating ) { |
349 | recurString = "y"; | ||
350 | if ( repeat_dayofweek >= 0 ) | ||
351 | recurString += "dow" + QString::number (repeat_dayofweek); | ||
352 | if ( repeat_day >= 0 ) | ||
353 | recurString += "d" + QString::number (repeat_day); | ||
354 | if ( repeat_weekofmonth >= 0 ) | ||
355 | recurString += "w" + QString::number (repeat_weekofmonth); | ||
356 | if ( repeat_month >= 0 ) | ||
357 | recurString += "m" + QString::number ( repeat_month ); | ||
358 | if ( repeat_frequency >= 0 ) | ||
359 | recurString += "f" + QString::number (repeat_frequency ); | ||
360 | |||
226 | int rtype = 0; | 361 | int rtype = 0; |
227 | // qDebug("recurs "); | 362 | // qDebug("recurs "); |
228 | QDate startDate, endDate; | 363 | QDate startDate, endDate; |
@@ -256,6 +391,12 @@ class PhoneParser : public QObject | |||
256 | 2 monthpos;x | 391 | 2 monthpos;x |
257 | 3 monthlyday; | 392 | 3 monthlyday; |
258 | 4 rYearlyMont | 393 | 4 rYearlyMont |
394 | bool repeating = false; | ||
395 | int repeat_dayofweek = -1; | ||
396 | int repeat_day = -1; | ||
397 | int repeat_weekofmonth = -1; | ||
398 | int repeat_month = -1; | ||
399 | int repeat_frequency = -1; | ||
259 | */ | 400 | */ |
260 | int dayOfWeek = startDate.dayOfWeek(); | 401 | int dayOfWeek = startDate.dayOfWeek(); |
261 | if ( repeat_weekofmonth >= 0 ) { | 402 | if ( repeat_weekofmonth >= 0 ) { |
@@ -301,9 +442,10 @@ class PhoneParser : public QObject | |||
301 | event->recurrence()->unsetRecurs(); | 442 | event->recurrence()->unsetRecurs(); |
302 | } | 443 | } |
303 | 444 | ||
304 | QString categoryList = attList[1] ; | 445 | QStringList categoryList; |
305 | event->setCategories( lookupCategories( categoryList ) ); | 446 | categoryList << getCategory( Note ); |
306 | 447 | event->setCategories( categoryList ); | |
448 | QString alarmString = ""; | ||
307 | // strange 0 semms to mean: alarm enabled | 449 | // strange 0 semms to mean: alarm enabled |
308 | if ( alarm ) { | 450 | if ( alarm ) { |
309 | Alarm *alarm; | 451 | Alarm *alarm; |
@@ -317,89 +459,28 @@ class PhoneParser : public QObject | |||
317 | alarm->setEnabled( true ); | 459 | alarm->setEnabled( true ); |
318 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); | 460 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); |
319 | alarm->setStartOffset( alarmOffset ); | 461 | alarm->setStartOffset( alarmOffset ); |
462 | alarmString = QString::number( alarmOffset ); | ||
320 | } | 463 | } |
464 | // csum ***************************************** | ||
465 | QStringList attList; | ||
466 | uint cSum; | ||
467 | attList << dtToString ( event->dtStart() ); | ||
468 | attList << dtToString ( event->dtEnd() ); | ||
469 | attList << QString::number( id ); | ||
470 | attList << event->summary(); | ||
471 | attList << event->location(); | ||
472 | attList << alarmString; | ||
473 | attList << recurString; | ||
474 | attList << event->categoriesStr(); | ||
475 | attList << event->secrecyStr(); | ||
476 | cSum = PhoneFormat::getCsum(attList ); | ||
477 | event->setCsum( mProfileName, QString::number( cSum )); | ||
321 | mCalendar->addEvent( event); | 478 | mCalendar->addEvent( event); |
322 | } else if ( qName == "Todo" ) { | ||
323 | #if 0 | ||
324 | Todo *todo; | ||
325 | |||
326 | todo = existingCalendar->todo( attList[0] ); | ||
327 | if (todo ) | ||
328 | todo = (Todo*)todo->clone(); | ||
329 | else | ||
330 | todo = new Todo; | ||
331 | |||
332 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | ||
333 | // 0 1 2 3 4 5 6 7 8 | ||
334 | //1,,,,,1,4,Loch zumachen,"" | ||
335 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | ||
336 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | ||
337 | 479 | ||
338 | //todo->setZaurusId( attList[0] ); | ||
339 | //todo->setZaurusUid( cSum ); | ||
340 | //todo->setZaurusStat( -2 ); | ||
341 | |||
342 | todo->setSummary( attList[7] ); | ||
343 | todo->setDescription( attList[8]); | ||
344 | |||
345 | int priority = attList[6].toInt(); | ||
346 | if ( priority == 0 ) priority = 3; | ||
347 | todo->setPriority( priority ); | ||
348 | |||
349 | QString categoryList = attList[1]; | ||
350 | todo->setCategories( lookupCategories( categoryList ) ); | ||
351 | |||
352 | |||
353 | |||
354 | QString hasDateStr = attList[3]; // due | ||
355 | if ( !hasDateStr.isEmpty() ) { | ||
356 | if ( hasDateStr.right(6) == "000000" ) { | ||
357 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | ||
358 | todo->setFloats( true ); | ||
359 | } | ||
360 | else { | ||
361 | todo->setDtDue( fromString( hasDateStr ) ); | ||
362 | todo->setFloats( false ); | ||
363 | } | ||
364 | |||
365 | todo->setHasDueDate( true ); | ||
366 | } | ||
367 | hasDateStr = attList[2];//start | ||
368 | if ( !hasDateStr.isEmpty() ) { | ||
369 | |||
370 | todo->setDtStart( fromString( hasDateStr ) ); | ||
371 | todo->setHasStartDate( true); | ||
372 | } else | ||
373 | todo->setHasStartDate( false ); | ||
374 | hasDateStr = attList[4];//completed | ||
375 | if ( !hasDateStr.isEmpty() ) { | ||
376 | todo->setCompleted(fromString( hasDateStr ) ); | ||
377 | } | ||
378 | QString completedStr = attList[5]; | ||
379 | if ( completedStr == "0" ) | ||
380 | todo->setCompleted( true ); | ||
381 | else | ||
382 | todo->setCompleted( false ); | ||
383 | mCalendar->addTodo( todo ); | ||
384 | #endif | ||
385 | |||
386 | } else if ( qName == "Category" ) { | ||
387 | /* | ||
388 | QString id = attributes.value( "id" ); | ||
389 | QString name = attributes.value( "name" ); | ||
390 | setCategory( id, name ); | ||
391 | */ | ||
392 | } | ||
393 | //qDebug("end "); | ||
394 | return true; | 480 | return true; |
395 | } | 481 | } |
396 | 482 | ||
397 | 483 | ||
398 | void setCategoriesList ( QStringList * c ) | ||
399 | { | ||
400 | oldCategories = c; | ||
401 | } | ||
402 | |||
403 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { | 484 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { |
404 | QDateTime dt; | 485 | QDateTime dt; |
405 | int y,m,t,h,min,sec; | 486 | int y,m,t,h,min,sec; |
@@ -417,58 +498,80 @@ class PhoneParser : public QObject | |||
417 | return dt; | 498 | return dt; |
418 | 499 | ||
419 | } | 500 | } |
420 | QDate datefromGSM ( GSM_DateTime*dtp ) { | 501 | |
421 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); | 502 | QString dtToString( const QDateTime& dti, bool useTZ = false ) |
422 | } | ||
423 | protected: | ||
424 | QDateTime toDateTime( const QString &value ) | ||
425 | { | 503 | { |
504 | QString datestr; | ||
505 | QString timestr; | ||
506 | int offset = KGlobal::locale()->localTimeOffset( dti ); | ||
426 | QDateTime dt; | 507 | QDateTime dt; |
427 | dt.setTime_t( value.toUInt() ); | 508 | if (useTZ) |
428 | 509 | dt = dti.addSecs ( -(offset*60)); | |
429 | return dt; | 510 | else |
511 | dt = dti; | ||
512 | if(dt.date().isValid()){ | ||
513 | const QDate& date = dt.date(); | ||
514 | datestr.sprintf("%04d%02d%02d", | ||
515 | date.year(), date.month(), date.day()); | ||
430 | } | 516 | } |
431 | 517 | if(dt.time().isValid()){ | |
432 | QStringList lookupCategories( const QString &categoryList ) | 518 | const QTime& time = dt.time(); |
433 | { | 519 | timestr.sprintf("T%02d%02d%02d", |
434 | QStringList categoryIds = QStringList::split( ";", categoryList ); | 520 | time.hour(), time.minute(), time.second()); |
435 | QStringList categories; | ||
436 | QStringList::ConstIterator it; | ||
437 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { | ||
438 | QString cate = category( *it ); | ||
439 | if ( oldCategories ) { | ||
440 | if ( ! oldCategories->contains( cate ) ) | ||
441 | oldCategories->append( cate ); | ||
442 | } | 521 | } |
443 | categories.append(cate ); | 522 | return datestr + timestr; |
444 | } | 523 | } |
445 | return categories; | 524 | QDate datefromGSM ( GSM_DateTime*dtp ) { |
525 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); | ||
446 | } | 526 | } |
447 | 527 | QString getCategory( GSM_CalendarEntry*Note) | |
448 | private: | ||
449 | QString mProfileName ; | ||
450 | Calendar *mCalendar; | ||
451 | QStringList * oldCategories; | ||
452 | static QString category( const QString &id ) | ||
453 | { | 528 | { |
454 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); | 529 | QString CATEGORY; |
455 | if ( it == mCategoriesMap.end() ) return id; | 530 | switch (Note->Type) { |
456 | else return *it; | 531 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; |
532 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; | ||
533 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; | ||
534 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; | ||
535 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; | ||
536 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; | ||
537 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; | ||
538 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; | ||
539 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; | ||
540 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; | ||
541 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; | ||
542 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; | ||
543 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; | ||
544 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; | ||
545 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; | ||
546 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; | ||
547 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; | ||
548 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; | ||
549 | 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_RACE : CATEGORY = QString("Training/Races"); break; | ||
552 | 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_STRE : CATEGORY = QString("Training/Street Games"); break; | ||
555 | 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_TRAV : CATEGORY = QString("Training/Travels"); break; | ||
558 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; | ||
559 | default : CATEGORY = QString(""); | ||
457 | } | 560 | } |
458 | 561 | ||
459 | static void setCategory( const QString &id, const QString &name ) | 562 | return CATEGORY; |
460 | { | ||
461 | mCategoriesMap.insert( id, name ); | ||
462 | } | 563 | } |
463 | 564 | ||
464 | static QMap<QString,QString> mCategoriesMap; | 565 | protected: |
566 | private: | ||
567 | Calendar *mCalendar; | ||
568 | QString mProfileName ; | ||
465 | }; | 569 | }; |
466 | 570 | ||
467 | QMap<QString,QString> PhoneParser::mCategoriesMap; | ||
468 | 571 | ||
469 | PhoneFormat::PhoneFormat() | 572 | PhoneFormat::PhoneFormat() |
470 | { | 573 | { |
471 | mCategories = 0; | 574 | ; |
472 | } | 575 | } |
473 | 576 | ||
474 | PhoneFormat::~PhoneFormat() | 577 | PhoneFormat::~PhoneFormat() |
@@ -549,12 +652,7 @@ static char *cp; | |||
549 | {break;} | 652 | {break;} |
550 | } | 653 | } |
551 | 654 | ||
552 | |||
553 | |||
554 | |||
555 | int error=GSM_InitConnection(&s,3); | 655 | int error=GSM_InitConnection(&s,3); |
556 | |||
557 | |||
558 | qDebug(" init %d %d", error, ERR_NONE); | 656 | qDebug(" init %d %d", error, ERR_NONE); |
559 | if ( error != ERR_NONE ) | 657 | if ( error != ERR_NONE ) |
560 | return false; | 658 | return false; |
@@ -565,134 +663,35 @@ static char *cp; | |||
565 | Phone=s.Phone.Functions; | 663 | Phone=s.Phone.Functions; |
566 | bool gshutdown = false; | 664 | bool gshutdown = false; |
567 | PhoneParser handler( calendar, profileName ); | 665 | PhoneParser handler( calendar, profileName ); |
568 | //handler.setCategoriesList( mCategories ); | ||
569 | int ccc = 0; | 666 | int ccc = 0; |
570 | while (!gshutdown && ccc++ < 10 ) { | 667 | while (!gshutdown && ccc++ < 10 ) { |
571 | 668 | ||
572 | qDebug("count %d ", ccc); | 669 | qDebug("readEvent %d ", ccc); |
573 | error=Phone->GetNextCalendar(&s,¬e,refresh); | 670 | error=Phone->GetNextCalendar(&s,¬e,refresh); |
574 | if (error == ERR_EMPTY) break; | 671 | if (error == ERR_EMPTY) break; |
575 | handler.startElement( existingCal, ¬e, "Event" ); | 672 | handler.readEvent( existingCal, ¬e ); |
576 | } | 673 | } |
577 | error=GSM_TerminateConnection(&s); | ||
578 | #if 0 | ||
579 | 674 | ||
580 | bool debug = DEBUGMODE; | 675 | bool start = true; |
581 | //debug = true; | 676 | GSM_ToDoEntry ToDo; |
582 | QString text; | 677 | int ccc = 0; |
583 | QString codec = "utf8"; | 678 | while (!gshutdown) { |
584 | QLabel status ( i18n("Reading events ..."), 0 ); | 679 | error = Phone->GetNextToDo(&s, &ToDo, start); |
585 | 680 | if (error == ERR_EMPTY) break; | |
586 | int w = status.sizeHint().width()+20 ; | 681 | start = false; |
587 | if ( w < 200 ) w = 200; | 682 | qDebug("readTodo %d ", ++ccc); |
588 | int h = status.sizeHint().height()+20 ; | 683 | handler.readTodo( existingCal, &ToDo, &s); |
589 | int dw = QApplication::desktop()->width(); | ||
590 | int dh = QApplication::desktop()->height(); | ||
591 | status.setCaption(i18n("Reading DTM Data") ); | ||
592 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
593 | status.show(); | ||
594 | status.raise(); | ||
595 | qApp->processEvents(); | ||
596 | QString fileName; | ||
597 | if ( ! debug ) { | ||
598 | fileName = "/tmp/kopitempout"; | ||
599 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | ||
600 | system ( command.latin1() ); | ||
601 | } else { | ||
602 | fileName = "/tmp/events.txt"; | ||
603 | |||
604 | } | ||
605 | QFile file( fileName ); | ||
606 | if (!file.open( IO_ReadOnly ) ) { | ||
607 | return false; | ||
608 | 684 | ||
609 | } | 685 | } |
610 | QTextStream ts( &file ); | ||
611 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
612 | text = ts.read(); | ||
613 | file.close(); | ||
614 | status.setText( i18n("Processing events ...") ); | ||
615 | status.raise(); | ||
616 | qApp->processEvents(); | ||
617 | fromString2Cal( calendar, existngCal, text, "Event" ); | ||
618 | status.setText( i18n("Reading todos ...") ); | ||
619 | qApp->processEvents(); | ||
620 | if ( ! debug ) { | ||
621 | fileName = "/tmp/kopitempout"; | ||
622 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | ||
623 | system ( command.latin1() ); | ||
624 | } else { | ||
625 | fileName = "/tmp/todo.txt"; | ||
626 | } | ||
627 | file.setName( fileName ); | ||
628 | if (!file.open( IO_ReadOnly ) ) { | ||
629 | return false; | ||
630 | 686 | ||
631 | } | 687 | error=GSM_TerminateConnection(&s); |
632 | ts.setDevice( &file ); | ||
633 | text = ts.read(); | ||
634 | file.close(); | ||
635 | 688 | ||
636 | status.setText( i18n("Processing todos ...") ); | ||
637 | status.raise(); | ||
638 | qApp->processEvents(); | ||
639 | fromString2Cal( calendar, existngCal, text, "Todo" ); | ||
640 | #endif | ||
641 | return true; | 689 | return true; |
642 | } | 690 | } |
643 | int PhoneFormat::getNumFromRecord( QString answer, Incidence* inc ) | ||
644 | { | ||
645 | int retval = -1; | ||
646 | QStringList templist; | ||
647 | QString tempString; | ||
648 | int start = 0; | ||
649 | int len = answer.length(); | ||
650 | int end = answer.find ("\n",start)+1; | ||
651 | bool ok = true; | ||
652 | start = end; | ||
653 | int ccc = 0; | ||
654 | while ( start > 0 ) { | ||
655 | templist.clear(); | ||
656 | ok = true; | ||
657 | int loopCount = 0; | ||
658 | while ( ok ) { | ||
659 | ++loopCount; | ||
660 | if ( loopCount > 25 ) { | ||
661 | qDebug("KO: Error in while loop"); | ||
662 | ok = false; | ||
663 | start = 0; | ||
664 | break; | ||
665 | } | ||
666 | if ( ok ) | ||
667 | tempString = getPart( answer, ok, start ); | ||
668 | if ( start >= len || start == 0 ) { | ||
669 | start = 0; | ||
670 | ok = false; | ||
671 | } | ||
672 | if ( tempString.right(1) =="\n" ) | ||
673 | tempString = tempString.left( tempString.length()-1); | ||
674 | 691 | ||
675 | templist.append( tempString ); | ||
676 | } | ||
677 | ++ccc; | ||
678 | if ( ccc == 2 && loopCount < 25 ) { | ||
679 | start = 0; | ||
680 | bool ok; | ||
681 | int newnum = templist[0].toInt( &ok ); | ||
682 | if ( ok && newnum > 0) { | ||
683 | retval = newnum; | ||
684 | //inc->setZaurusId( newnum ); | ||
685 | //inc->setZaurusUid( getCsum( templist ) ); | ||
686 | //inc->setZaurusStat( -4 ); | ||
687 | } | ||
688 | } | ||
689 | } | ||
690 | //qDebug("getNumFromRecord returning : %d ", retval); | ||
691 | return retval; | ||
692 | } | ||
693 | bool PhoneFormat::save( Calendar *calendar) | 692 | bool PhoneFormat::save( Calendar *calendar) |
694 | { | 693 | { |
695 | 694 | #if 0 | |
696 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 695 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
697 | int w = status.sizeHint().width()+20 ; | 696 | int w = status.sizeHint().width()+20 ; |
698 | if ( w < 200 ) w = 200; | 697 | if ( w < 200 ) w = 200; |
@@ -883,10 +882,10 @@ bool PhoneFormat::save( Calendar *calendar) | |||
883 | system ( command.latin1() ); | 882 | system ( command.latin1() ); |
884 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 883 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
885 | } | 884 | } |
886 | 885 | #endif | |
887 | return true; | 886 | return true; |
888 | } | 887 | } |
889 | QString PhoneFormat::dtToString( const QDateTime& dti, bool useTZ ) | 888 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) |
890 | { | 889 | { |
891 | QString datestr; | 890 | QString datestr; |
892 | QString timestr; | 891 | QString timestr; |
@@ -1127,391 +1126,13 @@ QString PhoneFormat::getTodoString( Todo* todo ) | |||
1127 | #endif | 1126 | #endif |
1128 | return QString(); | 1127 | return QString(); |
1129 | } | 1128 | } |
1130 | QString PhoneFormat::getPart( const QString & text, bool &ok, int &start ) | ||
1131 | { | ||
1132 | //qDebug("start %d ", start); | ||
1133 | |||
1134 | QString retval =""; | ||
1135 | if ( text.at(start) == '"' ) { | ||
1136 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { | ||
1137 | start = start +2; | ||
1138 | if ( text.mid( start,1) == "," ) { | ||
1139 | start += 1; | ||
1140 | } | ||
1141 | retval = ""; | ||
1142 | if ( text.mid( start,1) == "\n" ) { | ||
1143 | start += 1; | ||
1144 | ok = false; | ||
1145 | } | ||
1146 | return retval; | ||
1147 | } | ||
1148 | int hk = start+1; | ||
1149 | hk = text.find ('"',hk); | ||
1150 | while ( text.at(hk+1) == '"' ) | ||
1151 | hk = text.find ('"',hk+2); | ||
1152 | retval = text.mid( start+1, hk-start-1); | ||
1153 | start = hk+1; | ||
1154 | retval.replace( QRegExp("\"\""), "\""); | ||
1155 | if ( text.mid( start,1) == "," ) { | ||
1156 | start += 1; | ||
1157 | } | ||
1158 | if ( text.mid( start,1) == "\n" ) { | ||
1159 | start += 1; | ||
1160 | ok = false; | ||
1161 | } | ||
1162 | //qDebug("retval***%s*** ",retval.latin1() ); | ||
1163 | return retval; | ||
1164 | |||
1165 | } else { | ||
1166 | int nl = text.find ("\n",start); | ||
1167 | int kom = text.find (',',start); | ||
1168 | if ( kom < nl ) { | ||
1169 | // qDebug("kom < nl %d ", kom); | ||
1170 | retval = text.mid(start, kom-start); | ||
1171 | start = kom+1; | ||
1172 | return retval; | ||
1173 | } else { | ||
1174 | if ( nl == kom ) { | ||
1175 | // qDebug(" nl == kom "); | ||
1176 | start = 0; | ||
1177 | ok = false; | ||
1178 | return "0"; | ||
1179 | } | ||
1180 | // qDebug(" nl < kom ", nl); | ||
1181 | retval = text.mid( start, nl-start); | ||
1182 | ok = false; | ||
1183 | start = nl+1; | ||
1184 | return retval; | ||
1185 | } | ||
1186 | } | ||
1187 | } | ||
1188 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | ||
1189 | { | ||
1190 | return false; | ||
1191 | } | ||
1192 | bool PhoneFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type) | ||
1193 | { | ||
1194 | #if 0 | ||
1195 | GSM_Phone_Functions*Phone; | ||
1196 | |||
1197 | GSM_CalendarEntrynote; | ||
1198 | GSM_CalendarEntry*Note; | ||
1199 | bool refresh= true; | ||
1200 | |||
1201 | Phone=s->Phone.Functions; | ||
1202 | bool gshutdown = false; | ||
1203 | PhoneParser handler( calendar ); | ||
1204 | //handler.setCategoriesList( mCategories ); | ||
1205 | QStringList templist; | ||
1206 | QString tempString; | ||
1207 | int start = 0; | ||
1208 | int error; | ||
1209 | int ccc = 0; | ||
1210 | while (!gshutdown && ccc++ < 10 ) { | ||
1211 | QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY; | ||
1212 | templist.clear(); | ||
1213 | qDebug("count %d ", ccc); | ||
1214 | error=Phone->GetNextCalendar(s,¬e,refresh); | ||
1215 | if (error == ERR_EMPTY) break; | ||
1216 | |||
1217 | Note = ¬e; | ||
1218 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | ||
1219 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ||
1220 | |||
1221 | //ARSD silentalarm = 0 | ||
1222 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | ||
1223 | // 12 RFRQ | ||
1224 | // 13 RPOS pos = 4. monday in month | ||
1225 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | ||
1226 | // 15 REND 0 = no end/ 1 = end | ||
1227 | // 16 REDT rec end dt | ||
1228 | //ALSD | ||
1229 | //ALED | ||
1230 | //MDAY | ||
1231 | |||
1232 | CARDID = QString::number( Note->Location ); // 0 | ||
1233 | |||
1234 | |||
1235 | int i_age = 0,i; | ||
1236 | GSM_DateTime Alarm,DateTime; | ||
1237 | GSM_DateTime* dtp; | ||
1238 | GSM_MemoryEntry entry; | ||
1239 | unsigned char *name; | ||
1240 | |||
1241 | bool repeating = false; | ||
1242 | int repeat_dayofweek = -1; | ||
1243 | int repeat_day = -1; | ||
1244 | int repeat_weekofmonth = -1; | ||
1245 | int repeat_month = -1; | ||
1246 | int repeat_frequency = -1; | ||
1247 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | ||
1248 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | ||
1249 | |||
1250 | Alarm.Year = 0; | ||
1251 | |||
1252 | repeating = false; | ||
1253 | repeat_dayofweek = -1; | ||
1254 | repeat_day = -1; | ||
1255 | repeat_weekofmonth = -1; | ||
1256 | repeat_month = -1; | ||
1257 | repeat_frequency = -1; | ||
1258 | repeat_startdate.Day= 0; | ||
1259 | repeat_stopdate.Day = 0; | ||
1260 | |||
1261 | |||
1262 | switch (Note->Type) { | ||
1263 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; | ||
1264 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; | ||
1265 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; | ||
1266 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; | ||
1267 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; | ||
1268 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; | ||
1269 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; | ||
1270 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; | ||
1271 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; | ||
1272 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; | ||
1273 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; | ||
1274 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; | ||
1275 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; | ||
1276 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; | ||
1277 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; | ||
1278 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; | ||
1279 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; | ||
1280 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; | ||
1281 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; | ||
1282 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; | ||
1283 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; | ||
1284 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; | ||
1285 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; | ||
1286 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; | ||
1287 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; | ||
1288 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; | ||
1289 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; | ||
1290 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; | ||
1291 | default : CATEGORY = QString(""); | ||
1292 | } | ||
1293 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | ||
1294 | // 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19? | ||
1295 | |||
1296 | MEM1 = ""; | ||
1297 | |||
1298 | #if 0 | ||
1299 | |||
1300 | if ( attList[7] == "1" ) { | ||
1301 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); | ||
1302 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); | ||
1303 | event->setFloats( true ); | ||
1304 | } else { | ||
1305 | event->setFloats( false ); | ||
1306 | event->setDtStart( fromString( attList[5] ) ); | ||
1307 | event->setDtEnd( fromString( attList[6] )); | ||
1308 | } | ||
1309 | |||
1310 | |||
1311 | |||
1312 | typedef struct { | ||
1313 | /** | ||
1314 | * The difference between local time and GMT in hours | ||
1315 | */ | ||
1316 | int Timezone; | ||
1317 | |||
1318 | unsigned int Second; | ||
1319 | unsigned int Minute; | ||
1320 | unsigned int Hour; | ||
1321 | |||
1322 | unsigned int Day; | ||
1323 | /** | ||
1324 | * January = 1, February = 2, etc. | ||
1325 | */ | ||
1326 | unsigned int Month; | ||
1327 | /** | ||
1328 | * Complete year number. Not 03, but 2003 | ||
1329 | */ | ||
1330 | unsigned int Year; | ||
1331 | } GSM_DateTime; | ||
1332 | |||
1333 | if(dt.date().isValid()){ | ||
1334 | const QDate& date = dt.date(); | ||
1335 | datestr.sprintf("%04d%02d%02d", | ||
1336 | date.year(), date.month(), date.day()); | ||
1337 | } | ||
1338 | if(dt.time().isValid()){ | ||
1339 | const QTime& time = dt.time(); | ||
1340 | timestr.sprintf("T%02d%02d%02d", | ||
1341 | time.hour(), time.minute(), time.second()); | ||
1342 | } | ||
1343 | return datestr + timestr; | ||
1344 | |||
1345 | |||
1346 | |||
1347 | |||
1348 | #endif | ||
1349 | |||
1350 | |||
1351 | ADAY = "0"; | ||
1352 | ARON = "1"; // 1 == disabled | ||
1353 | ARMN = "0"; //alarm offset in minutes | ||
1354 | |||
1355 | for (i=0;i<Note->EntriesNum;i++) { | ||
1356 | |||
1357 | qDebug(" for "); | ||
1358 | switch (Note->Entries[i].EntryType) { | ||
1359 | case CAL_START_DATETIME: | ||
1360 | dtp = &Note->Entries[i].Date ; | ||
1361 | |||
1362 | qDebug("hour: %d ", dtp->Hour); | ||
1363 | if ( dtp->Hour == -1 ) { | ||
1364 | ADAY = "1"; | ||
1365 | ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); | ||
1366 | TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); | ||
1367 | } else { | ||
1368 | TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1369 | |||
1370 | } | ||
1371 | ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1372 | //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1373 | break; | ||
1374 | case CAL_END_DATETIME: | ||
1375 | dtp = &Note->Entries[i].Date ; | ||
1376 | qDebug("hour2: %d ", dtp->Hour); | ||
1377 | if ( dtp->Hour == -1 ) { | ||
1378 | ADAY = "1"; | ||
1379 | ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); | ||
1380 | TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); | ||
1381 | } else { | ||
1382 | TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1383 | |||
1384 | } | ||
1385 | //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1386 | //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1387 | break; | ||
1388 | case CAL_ALARM_DATETIME: | ||
1389 | ARON = "0"; | ||
1390 | dtp = &Note->Entries[i].Date ; | ||
1391 | ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1392 | //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1393 | memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1394 | break; | ||
1395 | case CAL_SILENT_ALARM_DATETIME: | ||
1396 | ARON = "0"; | ||
1397 | dtp = &Note->Entries[i].Date ; | ||
1398 | ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1399 | //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1400 | //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1401 | break; | ||
1402 | case CAL_RECURRANCE: | ||
1403 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); | ||
1404 | break; | ||
1405 | case CAL_TEXT: | ||
1406 | DSRP = QString ( (const char*) Note->Entries[i].Text ); | ||
1407 | break; | ||
1408 | case CAL_LOCATION: | ||
1409 | PLCE = QString ((const char*) Note->Entries[i].Text ); | ||
1410 | break; | ||
1411 | case CAL_PHONE: | ||
1412 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | ||
1413 | break; | ||
1414 | case CAL_PRIVATE: | ||
1415 | //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); | ||
1416 | break; | ||
1417 | case CAL_CONTACTID: | ||
1418 | #if 0 | ||
1419 | entry.Location = Note->Entries[i].Number; | ||
1420 | entry.MemoryType = MEM_ME; | ||
1421 | error=Phone->GetMemory(&s, &entry); | ||
1422 | if (error == ERR_NONE) { | ||
1423 | name = GSM_PhonebookGetEntryName(&entry); | ||
1424 | if (name != NULL) { | ||
1425 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); | ||
1426 | } else { | ||
1427 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | ||
1428 | } | ||
1429 | } else { | ||
1430 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | ||
1431 | } | ||
1432 | #endif | ||
1433 | break; | ||
1434 | case CAL_REPEAT_DAYOFWEEK: | ||
1435 | repeat_dayofweek = Note->Entries[i].Number; | ||
1436 | repeating = true; | ||
1437 | break; | ||
1438 | case CAL_REPEAT_DAY: | ||
1439 | repeat_day = Note->Entries[i].Number; | ||
1440 | repeating = true; | ||
1441 | break; | ||
1442 | case CAL_REPEAT_WEEKOFMONTH: | ||
1443 | repeat_weekofmonth = Note->Entries[i].Number; | ||
1444 | repeating = true; | ||
1445 | break; | ||
1446 | case CAL_REPEAT_MONTH: | ||
1447 | repeat_month = Note->Entries[i].Number; | ||
1448 | repeating = true; | ||
1449 | break; | ||
1450 | case CAL_REPEAT_FREQUENCY: | ||
1451 | repeat_frequency = Note->Entries[i].Number; | ||
1452 | repeating = true; | ||
1453 | break; | ||
1454 | case CAL_REPEAT_STARTDATE: | ||
1455 | repeat_startdate = Note->Entries[i].Date; | ||
1456 | repeating = true; | ||
1457 | break; | ||
1458 | case CAL_REPEAT_STOPDATE: | ||
1459 | repeat_stopdate = Note->Entries[i].Date; | ||
1460 | repeating = true; | ||
1461 | break; | ||
1462 | } | ||
1463 | } | ||
1464 | 1129 | ||
1465 | 1130 | ||
1466 | |||
1467 | if ( ARON == "0" ) { | ||
1468 | QDateTime start,alarm; | ||
1469 | start = handler.fromString( TIM1 ); | ||
1470 | alarm = handler.fromString( ARMN ); | ||
1471 | int min = alarm.secsTo ( start )/60; | ||
1472 | ARMN = QString::number ( min ); | ||
1473 | } | ||
1474 | |||
1475 | templist.clear(); | ||
1476 | templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY; | ||
1477 | handler.startElement( existingCalendar, templist, type ); | ||
1478 | } | ||
1479 | |||
1480 | |||
1481 | #endif | ||
1482 | #if 0 | ||
1483 | // qDebug("test %s ", text.latin1()); | ||
1484 | QStringList templist; | ||
1485 | QString tempString; | ||
1486 | int start = 0; | ||
1487 | int len = text.length(); | ||
1488 | int end = text.find ("\n",start)+1; | ||
1489 | bool ok = true; | ||
1490 | start = end; | ||
1491 | PhoneParser handler( calendar ); | ||
1492 | handler.setCategoriesList( mCategories ); | ||
1493 | while ( start > 0 ) { | ||
1494 | templist.clear(); | ||
1495 | ok = true; | ||
1496 | while ( ok ) { | ||
1497 | tempString = getPart( text, ok, start ); | ||
1498 | if ( start >= len || start == 0 ) { | ||
1499 | start = 0; | ||
1500 | ok = false; | ||
1501 | } | ||
1502 | if ( tempString.right(1) =="\n" ) | ||
1503 | tempString = tempString.left( tempString.length()-1); | ||
1504 | //if ( ok ) | ||
1505 | templist.append( tempString ); | ||
1506 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); | ||
1507 | } | ||
1508 | handler.startElement( existingCalendar, templist, type ); | ||
1509 | } | ||
1510 | #endif | ||
1511 | return false; | ||
1512 | } | ||
1513 | |||
1514 | QString PhoneFormat::toString( Calendar * ) | 1131 | QString PhoneFormat::toString( Calendar * ) |
1515 | { | 1132 | { |
1516 | return QString::null; | 1133 | return QString::null; |
1517 | } | 1134 | } |
1135 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | ||
1136 | { | ||
1137 | return false; | ||
1138 | } | ||
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 4da38c8..8d4e200 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -44,8 +44,6 @@ class PhoneFormat : public QObject { | |||
44 | 44 | ||
45 | bool load( Calendar * ,Calendar *, QString profileName, QString device,QString connection, QString model ); | 45 | bool load( Calendar * ,Calendar *, QString profileName, QString device,QString connection, QString model ); |
46 | bool save( Calendar * ); | 46 | bool save( Calendar * ); |
47 | void setCategoriesList ( QStringList * cat ){ mCategories = cat; } | ||
48 | bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & ); | ||
49 | bool fromString( Calendar *, const QString & ); | 47 | bool fromString( Calendar *, const QString & ); |
50 | QString toString( Calendar * ); | 48 | QString toString( Calendar * ); |
51 | static ulong getCsum( const QStringList & ); | 49 | static ulong getCsum( const QStringList & ); |
@@ -53,11 +51,7 @@ class PhoneFormat : public QObject { | |||
53 | private: | 51 | private: |
54 | QString getEventString( Event* ); | 52 | QString getEventString( Event* ); |
55 | QString getTodoString( Todo* ); | 53 | QString getTodoString( Todo* ); |
56 | QString dtToString( const QDateTime& dt, bool useTZ = true ); | 54 | QString dtToGSM( const QDateTime& dt, bool useTZ = true ); |
57 | |||
58 | QStringList *mCategories; | ||
59 | int getNumFromRecord( QString answer,Incidence* inc ) ; | ||
60 | QString getPart( const QString & text, bool &ok, int &start ); | ||
61 | QString mProfileName; | 55 | QString mProfileName; |
62 | }; | 56 | }; |
63 | 57 | ||