From ad825350a6967b6e0273c0a5916693853b70d242 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sun, 08 Aug 2004 09:30:54 +0000 Subject: more phone sync: read todo added --- (limited to 'libkcal/phoneformat.cpp') diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index fd6b6af..c97b43d 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -62,413 +62,516 @@ using namespace KCal; class PhoneParser : public QObject { - public: +public: PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { - oldCategories = 0; + ; } - - bool startElement( Calendar *existingCalendar, GSM_CalendarEntry* Note, QString qName ) + bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) { - QStringList attList; - /* -// pending csum - int i = 1; - bool skip = true; - int max = attList.count() -2; - while ( i < max ) { - if ( !attList[i].isEmpty() ) { - skip = false; + + int id = ToDo->Location; + Todo *todo; + todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); + if (todo ) + todo = (Todo *)todo->clone(); + else + todo = new Todo; + todo->setID( mProfileName,QString::number( id ) ); + todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); + int priority; + switch (ToDo->Priority) { + case GSM_Priority_Low : priority = 1; break; + case GSM_Priority_Medium : priority = 3; break; + case GSM_Priority_High : priority = 5; break; + default :priority = 3 ; break; + } + todo->setPriority( priority ); + GSM_Phone_Functions *Phone; + Phone=s->Phone.Functions; + int j; + GSM_DateTime* dtp; + bool alarm = false; + QDateTime alarmDt; + GSM_Category Category; + int error; + QString completedString = "no"; + for (j=0;jEntriesNum;j++) { + switch (ToDo->Entries[j].EntryType) { + case TODO_END_DATETIME: + dtp = &ToDo->Entries[j].Date ; + todo->setDtDue (fromGSM ( dtp )); + break; + case TODO_COMPLETED: + if ( ToDo->Entries[j].Number == 1 ) { + todo->setCompleted( true ); + completedString = "yes"; + } + else { + todo->setCompleted( false ); + } + break; + case TODO_ALARM_DATETIME: + dtp = &ToDo->Entries[j].Date ; + alarm = true; + alarmDt = fromGSM ( dtp ); + break; + case TODO_SILENT_ALARM_DATETIME: + dtp = &ToDo->Entries[j].Date ; + alarm = true; + alarmDt = fromGSM ( dtp ); + break; + case TODO_TEXT: + todo->setSummary( QString ( (const char*) ToDo->Entries[j].Text )); + break; + case TODO_PRIVATE: + if ( ToDo->Entries[j].Number == 1 ) + todo->setSecrecy( Incidence::SecrecyPrivate ); + else + todo->setSecrecy( Incidence::SecrecyPublic ); + break; + case TODO_CATEGORY: + Category.Location = ToDo->Entries[j].Number; + Category.Type = Category_ToDo; + error=Phone->GetCategory(s, &Category); + if (error == ERR_NONE) { + QStringList cat = todo->categories(); + QString nCat = QString ( (const char*)Category.Name ); + if ( !nCat.isEmpty() ) + if ( !cat.contains( nCat )) { + cat << nCat; + todo->setCategories( cat ); + } + } + break; + case TODO_CONTACTID: +#if 0 + // not supported + entry.Location = ToDo->Entries[j].Number; + entry.MemoryType = MEM_ME; + error=Phone->GetMemory(s, &entry); + if (error == ERR_NONE) { + name = GSM_PhonebookGetEntryName(&entry); + if (name != NULL) { + printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); + } else { + printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); + } + } else { + printmsg("Contact : %d\n",ToDo->Entries[j].Number); + } +#endif break; - } - ++i ; + case TODO_PHONE: +#if 0 + // not supported + printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); +#endif + break; + } } - if ( skip ) - return false; - ulong cSum = PhoneFormat::getCsum(attList ); - */ - if ( qName == "Event" ) { - int id = Note->Location; - Event *event; - event = existingCalendar->event( mProfileName ,QString::number( id ) ); - if ( event ) - event = (Event*)event->clone(); - else - event = new Event; - event->setID( mProfileName, attList[0] ); - // pending event->setCsum( "Sharp_DTM", QString::number( cSum )); - event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); - - - int i = 0; - bool repeating = false; - int repeat_dayofweek = -1; - int repeat_day = -1; - int repeat_weekofmonth = -1; - int repeat_month = -1; - int repeat_frequency = -1; - GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; - GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; - GSM_DateTime* dtp; - bool alarm = false; - QDateTime alarmDt; - repeat_startdate.Day = 0; - repeat_stopdate.Day = 0; - for (i=0;iEntriesNum;i++) { + QString alarmString = ""; + // strange 0 semms to mean: alarm enabled + if ( alarm ) { + Alarm *alarm; + if ( todo->alarms().count() > 0 ) + alarm = todo->alarms().first(); + else { + alarm = new Alarm( todo ); + todo->addAlarm( alarm ); + } + alarm->setType( Alarm::Audio ); + alarm->setEnabled( true ); + int alarmOffset = alarmDt.secsTo( todo->dtStart() ); + alarm->setStartOffset( alarmOffset ); + alarmString = QString::number( alarmOffset ); + } + // csum ***************************************** + QStringList attList; + uint cSum; + if ( todo->hasDueDate() ) + attList << dtToString ( todo->dtDue() ); + attList << QString::number( id ); + attList << todo->summary(); + attList << completedString; + attList << alarmString; + attList << todo->categoriesStr(); + attList << todo->secrecyStr(); + cSum = PhoneFormat::getCsum(attList ); + todo->setCsum( mProfileName, QString::number( cSum )); + mCalendar->addTodo( todo); - qDebug(" for "); - switch (Note->Entries[i].EntryType) { - case CAL_START_DATETIME: - dtp = &Note->Entries[i].Date ; - if ( dtp->Hour > 24 ) { - event->setFloats( true ); - event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); - } else { - event->setDtStart (fromGSM ( dtp )); + return true; + } + bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry* Note) + { + + int id = Note->Location; + Event *event; + event = existingCalendar->event( mProfileName ,QString::number( id ) ); + if ( event ) + event = (Event*)event->clone(); + else + event = new Event; + event->setID( mProfileName,QString::number( id ) ); + event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); + + + int i = 0; + bool repeating = false; + int repeat_dayofweek = -1; + int repeat_day = -1; + int repeat_weekofmonth = -1; + int repeat_month = -1; + int repeat_frequency = -1; + int rec_type = -1; + GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; + GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; + GSM_DateTime* dtp; + bool alarm = false; + QDateTime alarmDt; + repeat_startdate.Day = 0; + repeat_stopdate.Day = 0; + for (i=0;iEntriesNum;i++) { + + qDebug(" for "); + switch (Note->Entries[i].EntryType) { + case CAL_START_DATETIME: + dtp = &Note->Entries[i].Date ; + if ( dtp->Hour > 24 ) { + event->setFloats( true ); + event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); + } else { + event->setDtStart (fromGSM ( dtp )); - } - break; - case CAL_END_DATETIME: - dtp = &Note->Entries[i].Date ; - if ( dtp->Hour > 24 ) { - event->setFloats( true ); - event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); - } else { - event->setDtEnd (fromGSM ( dtp )); - } - break; - case CAL_ALARM_DATETIME: - dtp = &Note->Entries[i].Date ; - alarm = true; - alarmDt = fromGSM ( dtp ); - break; - case CAL_SILENT_ALARM_DATETIME: - dtp = &Note->Entries[i].Date ; - alarm = true; - alarmDt = fromGSM ( dtp ); - break; - case CAL_RECURRANCE: - //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); - break; - case CAL_TEXT: - event->setSummary( QString ( (const char*) Note->Entries[i].Text )); - break; - case CAL_LOCATION: - event->setLocation(QString ((const char*) Note->Entries[i].Text )); - break; - case CAL_PHONE: - //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); - break; - case CAL_PRIVATE: - //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); - break; - case CAL_CONTACTID: + } + break; + case CAL_END_DATETIME: + dtp = &Note->Entries[i].Date ; + if ( dtp->Hour > 24 ) { + event->setFloats( true ); + event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); + } else { + event->setDtEnd (fromGSM ( dtp )); + } + break; + case CAL_ALARM_DATETIME: + dtp = &Note->Entries[i].Date ; + alarm = true; + alarmDt = fromGSM ( dtp ); + break; + case CAL_SILENT_ALARM_DATETIME: + dtp = &Note->Entries[i].Date ; + alarm = true; + alarmDt = fromGSM ( dtp ); + break; + case CAL_RECURRANCE: + rec_type = Note->Entries[i].Number; + //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); + break; + case CAL_TEXT: + event->setSummary( QString ( (const char*) Note->Entries[i].Text )); + break; + case CAL_LOCATION: + event->setLocation(QString ((const char*) Note->Entries[i].Text )); + break; + case CAL_PHONE: + //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); + break; + case CAL_PRIVATE: + if ( Note->Entries[i].Number == 1 ) + event->setSecrecy( Incidence::SecrecyPrivate ); + else + event->setSecrecy( Incidence::SecrecyPublic ); + + break; + case CAL_CONTACTID: #if 0 - entry.Location = Note->Entries[i].Number; - entry.MemoryType = MEM_ME; - error=Phone->GetMemory(&s, &entry); - if (error == ERR_NONE) { - name = GSM_PhonebookGetEntryName(&entry); - if (name != NULL) { - //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); - } else { - //printmsg("Contact ID : %d\n",Note->Entries[i].Number); - } + entry.Location = Note->Entries[i].Number; + entry.MemoryType = MEM_ME; + error=Phone->GetMemory(&s, &entry); + if (error == ERR_NONE) { + name = GSM_PhonebookGetEntryName(&entry); + if (name != NULL) { + //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); } else { //printmsg("Contact ID : %d\n",Note->Entries[i].Number); } -#endif - break; - case CAL_REPEAT_DAYOFWEEK: - repeat_dayofweek = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_DAY: - repeat_day = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_WEEKOFMONTH: - repeat_weekofmonth = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_MONTH: - repeat_month = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_FREQUENCY: - repeat_frequency = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_STARTDATE: - repeat_startdate = Note->Entries[i].Date; - repeating = true; - break; - case CAL_REPEAT_STOPDATE: - repeat_stopdate = Note->Entries[i].Date; - repeating = true; - break; + } else { + //printmsg("Contact ID : %d\n",Note->Entries[i].Number); } +#endif + break; + case CAL_REPEAT_DAYOFWEEK: + repeat_dayofweek = Note->Entries[i].Number; + repeating = true; + break; + case CAL_REPEAT_DAY: + repeat_day = Note->Entries[i].Number; + repeating = true; + break; + case CAL_REPEAT_WEEKOFMONTH: + repeat_weekofmonth = Note->Entries[i].Number; + repeating = true; + break; + case CAL_REPEAT_MONTH: + repeat_month = Note->Entries[i].Number; + repeating = true; + break; + case CAL_REPEAT_FREQUENCY: + repeat_frequency = Note->Entries[i].Number; + repeating = true; + break; + case CAL_REPEAT_STARTDATE: + repeat_startdate = Note->Entries[i].Date; + repeating = true; + break; + case CAL_REPEAT_STOPDATE: + repeat_stopdate = Note->Entries[i].Date; + repeating = true; + break; } + } #if 0 - event->setDescription( attList[4] ); - bool repeating = false; - int repeat_dayofweek = -1; - int repeat_day = -1; - int repeat_weekofmonth = -1; - int repeat_month = -1; - int repeat_frequency = -1; - GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; - GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; + event->setDescription( attList[4] ); + bool repeating = false; + int repeat_dayofweek = -1; + int repeat_day = -1; + int repeat_weekofmonth = -1; + int repeat_month = -1; + int repeat_frequency = -1; + GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; + GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; #endif - QString rtype = attList[11]; - if ( repeating ) { - int rtype = 0; - // qDebug("recurs "); - QDate startDate, endDate; - if ( repeat_startdate.Day > 0 ) - startDate = datefromGSM ( &repeat_startdate ); - else - startDate = event->dtStart().date(); - int freq = repeat_frequency; - bool hasEndDate = false; - if ( repeat_stopdate.Day > 0 ) { - endDate = datefromGSM ( &repeat_stopdate ); - hasEndDate = true; - } + QString recurString = "no"; + if ( repeating ) { + recurString = "y"; + if ( repeat_dayofweek >= 0 ) + recurString += "dow" + QString::number (repeat_dayofweek); + if ( repeat_day >= 0 ) + recurString += "d" + QString::number (repeat_day); + if ( repeat_weekofmonth >= 0 ) + recurString += "w" + QString::number (repeat_weekofmonth); + if ( repeat_month >= 0 ) + recurString += "m" + QString::number ( repeat_month ); + if ( repeat_frequency >= 0 ) + recurString += "f" + QString::number (repeat_frequency ); + + int rtype = 0; + // qDebug("recurs "); + QDate startDate, endDate; + if ( repeat_startdate.Day > 0 ) + startDate = datefromGSM ( &repeat_startdate ); + else + startDate = event->dtStart().date(); + int freq = repeat_frequency; + bool hasEndDate = false; + if ( repeat_stopdate.Day > 0 ) { + endDate = datefromGSM ( &repeat_stopdate ); + hasEndDate = true; + } - uint weekDaysNum = repeat_dayofweek ; + uint weekDaysNum = repeat_dayofweek ; - QBitArray weekDays( 7 ); - int i; - int bb = 1; - for( i = 1; i <= 7; ++i ) { - weekDays.setBit( i - 1, ( bb & weekDaysNum )); - bb = 2 << (i-1); - //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); - } - // qDebug("next "); - int pos = 0; - Recurrence *r = event->recurrence(); - /* - 0 daily; - 1 weekly;x - 2 monthpos;x - 3 monthlyday; - 4 rYearlyMont - */ - int dayOfWeek = startDate.dayOfWeek(); - if ( repeat_weekofmonth >= 0 ) { - rtype = 2; - pos = repeat_weekofmonth; - if ( repeat_dayofweek >= 0 ) - dayOfWeek = repeat_dayofweek; - } else if ( repeat_dayofweek >= 0 ) { - rtype = 1; - } if ( repeat_dayofweek >= 0 ) { - rtype = 1; - } - - if ( rtype == 0 ) { - if ( hasEndDate ) r->setDaily( freq, endDate ); - else r->setDaily( freq, -1 ); - } else if ( rtype == 1 ) { - if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); - else r->setWeekly( freq, weekDays, -1 ); - } else if ( rtype == 3 ) { - if ( hasEndDate ) - r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); - else - r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); - r->addMonthlyDay( startDate.day() ); - } else if ( rtype == 2 ) { - if ( hasEndDate ) - r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); - else - r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); - QBitArray days( 7 ); - days.fill( false ); - days.setBit( dayOfWeek - 1 ); - r->addMonthlyPos( pos, days ); - } else if ( rtype == 4 ) { - if ( hasEndDate ) - r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); - else - r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); - r->addYearlyNum( startDate.month() ); - } - } else { - event->recurrence()->unsetRecurs(); + QBitArray weekDays( 7 ); + int i; + int bb = 1; + for( i = 1; i <= 7; ++i ) { + weekDays.setBit( i - 1, ( bb & weekDaysNum )); + bb = 2 << (i-1); + //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); } - - QString categoryList = attList[1] ; - event->setCategories( lookupCategories( categoryList ) ); - - // strange 0 semms to mean: alarm enabled - if ( alarm ) { - Alarm *alarm; - if ( event->alarms().count() > 0 ) - alarm = event->alarms().first(); - else { - alarm = new Alarm( event ); - event->addAlarm( alarm ); - } - alarm->setType( Alarm::Audio ); - alarm->setEnabled( true ); - int alarmOffset = alarmDt.secsTo( event->dtStart() ); - alarm->setStartOffset( alarmOffset ); + // qDebug("next "); + int pos = 0; + Recurrence *r = event->recurrence(); + /* + 0 daily; + 1 weekly;x + 2 monthpos;x + 3 monthlyday; + 4 rYearlyMont + bool repeating = false; + int repeat_dayofweek = -1; + int repeat_day = -1; + int repeat_weekofmonth = -1; + int repeat_month = -1; + int repeat_frequency = -1; + */ + int dayOfWeek = startDate.dayOfWeek(); + if ( repeat_weekofmonth >= 0 ) { + rtype = 2; + pos = repeat_weekofmonth; + if ( repeat_dayofweek >= 0 ) + dayOfWeek = repeat_dayofweek; + } else if ( repeat_dayofweek >= 0 ) { + rtype = 1; + } if ( repeat_dayofweek >= 0 ) { + rtype = 1; } - mCalendar->addEvent( event); - } else if ( qName == "Todo" ) { -#if 0 - Todo *todo; - todo = existingCalendar->todo( attList[0] ); - if (todo ) - todo = (Todo*)todo->clone(); - else - todo = new Todo; - -//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 -// 0 1 2 3 4 5 6 7 8 -//1,,,,,1,4,Loch zumachen,"" -//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " -//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes - - //todo->setZaurusId( attList[0] ); - //todo->setZaurusUid( cSum ); - //todo->setZaurusStat( -2 ); - - todo->setSummary( attList[7] ); - todo->setDescription( attList[8]); - - int priority = attList[6].toInt(); - if ( priority == 0 ) priority = 3; - todo->setPriority( priority ); - - QString categoryList = attList[1]; - todo->setCategories( lookupCategories( categoryList ) ); - - - - QString hasDateStr = attList[3]; // due - if ( !hasDateStr.isEmpty() ) { - if ( hasDateStr.right(6) == "000000" ) { - todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); - todo->setFloats( true ); - } - else { - todo->setDtDue( fromString( hasDateStr ) ); - todo->setFloats( false ); - } - - todo->setHasDueDate( true ); - } - hasDateStr = attList[2];//start - if ( !hasDateStr.isEmpty() ) { - - todo->setDtStart( fromString( hasDateStr ) ); - todo->setHasStartDate( true); - } else - todo->setHasStartDate( false ); - hasDateStr = attList[4];//completed - if ( !hasDateStr.isEmpty() ) { - todo->setCompleted(fromString( hasDateStr ) ); + if ( rtype == 0 ) { + if ( hasEndDate ) r->setDaily( freq, endDate ); + else r->setDaily( freq, -1 ); + } else if ( rtype == 1 ) { + if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); + else r->setWeekly( freq, weekDays, -1 ); + } else if ( rtype == 3 ) { + if ( hasEndDate ) + r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); + else + r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); + r->addMonthlyDay( startDate.day() ); + } else if ( rtype == 2 ) { + if ( hasEndDate ) + r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); + else + r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); + QBitArray days( 7 ); + days.fill( false ); + days.setBit( dayOfWeek - 1 ); + r->addMonthlyPos( pos, days ); + } else if ( rtype == 4 ) { + if ( hasEndDate ) + r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); + else + r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); + r->addYearlyNum( startDate.month() ); } - QString completedStr = attList[5]; - if ( completedStr == "0" ) - todo->setCompleted( true ); - else - todo->setCompleted( false ); - mCalendar->addTodo( todo ); -#endif + } else { + event->recurrence()->unsetRecurs(); + } - } else if ( qName == "Category" ) { - /* - QString id = attributes.value( "id" ); - QString name = attributes.value( "name" ); - setCategory( id, name ); - */ + QStringList categoryList; + categoryList << getCategory( Note ); + event->setCategories( categoryList ); + QString alarmString = ""; + // strange 0 semms to mean: alarm enabled + if ( alarm ) { + Alarm *alarm; + if ( event->alarms().count() > 0 ) + alarm = event->alarms().first(); + else { + alarm = new Alarm( event ); + event->addAlarm( alarm ); + } + alarm->setType( Alarm::Audio ); + alarm->setEnabled( true ); + int alarmOffset = alarmDt.secsTo( event->dtStart() ); + alarm->setStartOffset( alarmOffset ); + alarmString = QString::number( alarmOffset ); } - //qDebug("end "); + // csum ***************************************** + QStringList attList; + uint cSum; + attList << dtToString ( event->dtStart() ); + attList << dtToString ( event->dtEnd() ); + attList << QString::number( id ); + attList << event->summary(); + attList << event->location(); + attList << alarmString; + attList << recurString; + attList << event->categoriesStr(); + attList << event->secrecyStr(); + cSum = PhoneFormat::getCsum(attList ); + event->setCsum( mProfileName, QString::number( cSum )); + mCalendar->addEvent( event); + return true; } - - void setCategoriesList ( QStringList * c ) - { - oldCategories = c; - } - + QDateTime fromGSM ( GSM_DateTime* dtp, bool useTz = true ) { - QDateTime dt; - int y,m,t,h,min,sec; - y = dtp->Year; - m = dtp->Month; - t = dtp->Day; - h = dtp->Hour; - min = dtp->Minute; - sec = dtp->Second; - dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); - // dtp->Timezone: offset in hours - int offset = KGlobal::locale()->localTimeOffset( dt ); - if ( useTz ) - dt = dt.addSecs ( offset*60); - return dt; + QDateTime dt; + int y,m,t,h,min,sec; + y = dtp->Year; + m = dtp->Month; + t = dtp->Day; + h = dtp->Hour; + min = dtp->Minute; + sec = dtp->Second; + dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); + // dtp->Timezone: offset in hours + int offset = KGlobal::locale()->localTimeOffset( dt ); + if ( useTz ) + dt = dt.addSecs ( offset*60); + return dt; - } - QDate datefromGSM ( GSM_DateTime* dtp ) { - return QDate ( dtp->Year, dtp->Month, dtp->Day ); - } - protected: - QDateTime toDateTime( const QString &value ) - { - QDateTime dt; - dt.setTime_t( value.toUInt() ); - - return dt; } - QStringList lookupCategories( const QString &categoryList ) + QString dtToString( const QDateTime& dti, bool useTZ = false ) { - QStringList categoryIds = QStringList::split( ";", categoryList ); - QStringList categories; - QStringList::ConstIterator it; - for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { - QString cate = category( *it ); - if ( oldCategories ) { - if ( ! oldCategories->contains( cate ) ) - oldCategories->append( cate ); - } - categories.append(cate ); - } - return categories; + QString datestr; + QString timestr; + int offset = KGlobal::locale()->localTimeOffset( dti ); + QDateTime dt; + if (useTZ) + dt = dti.addSecs ( -(offset*60)); + else + dt = dti; + if(dt.date().isValid()){ + const QDate& date = dt.date(); + datestr.sprintf("%04d%02d%02d", + date.year(), date.month(), date.day()); + } + if(dt.time().isValid()){ + const QTime& time = dt.time(); + timestr.sprintf("T%02d%02d%02d", + time.hour(), time.minute(), time.second()); + } + return datestr + timestr; } - - private: - QString mProfileName ; - Calendar *mCalendar; - QStringList * oldCategories; - static QString category( const QString &id ) - { - QMap::ConstIterator it = mCategoriesMap.find( id ); - if ( it == mCategoriesMap.end() ) return id; - else return *it; + QDate datefromGSM ( GSM_DateTime* dtp ) { + return QDate ( dtp->Year, dtp->Month, dtp->Day ); } - - static void setCategory( const QString &id, const QString &name ) + QString getCategory( GSM_CalendarEntry* Note) { - mCategoriesMap.insert( id, name ); + QString CATEGORY; + switch (Note->Type) { + case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; + case GSM_CAL_CALL : CATEGORY = QString("Call"); break; + case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; + case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; + case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; + case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; + case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; + case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; + case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; + case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; + case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; + case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; + case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; + case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; + case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; + case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; + case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; + case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; + case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; + case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; + case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; + case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; + case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; + case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; + case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; + case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; + case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; + case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; + default : CATEGORY = QString(""); + } + + return CATEGORY; } - static QMap mCategoriesMap; +protected: +private: + Calendar *mCalendar; + QString mProfileName ; }; -QMap PhoneParser::mCategoriesMap; PhoneFormat::PhoneFormat() { - mCategories = 0; + ; } PhoneFormat::~PhoneFormat() @@ -508,26 +611,26 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profi s.opened = false; s.msg = NULL; s.ConfigNum = 0; -static char *cp; + static char *cp; static INI_Section *cfg = NULL; cfg=GSM_FindGammuRC(); int i; for (i = 0; i <= MAX_CONFIG_NUM; i++) { if (cfg!=NULL) { cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); - if (cp) di.coding = cp; + if (cp) di.coding = cp; - s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); - if (s.Config[i].Localize) { + s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); + if (s.Config[i].Localize) { s.msg=INI_ReadFile(s.Config[i].Localize, true); } else { #if !defined(WIN32) && defined(LOCALE_PATH) locale = setlocale(LC_MESSAGES, NULL); if (locale != NULL) { snprintf(locale_file, 200, "%s/gammu_%c%c.txt", - LOCALE_PATH, - tolower(locale[0]), - tolower(locale[1])); + LOCALE_PATH, + tolower(locale[0]), + tolower(locale[1])); s.msg = INI_ReadFile(locale_file, true); } #endif @@ -536,25 +639,20 @@ static char *cp; /* Wanted user specific configuration? */ - if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; + if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; s.ConfigNum++; - /* We want to use only one file descriptor for global and state machine debug output */ - s.Config[i].UseGlobalDebugFile = true; + /* We want to use only one file descriptor for global and state machine debug output */ + s.Config[i].UseGlobalDebugFile = true; /* We wanted to read just user specified configuration. */ - {break;} + {break;} } - - - int error=GSM_InitConnection(&s,3); - - qDebug(" init %d %d", error, ERR_NONE); if ( error != ERR_NONE ) return false; @@ -565,134 +663,35 @@ static char *cp; Phone=s.Phone.Functions; bool gshutdown = false; PhoneParser handler( calendar, profileName ); - //handler.setCategoriesList( mCategories ); int ccc = 0; while (!gshutdown && ccc++ < 10 ) { - qDebug("count %d ", ccc); + qDebug("readEvent %d ", ccc); error=Phone->GetNextCalendar(&s,¬e,refresh); if (error == ERR_EMPTY) break; - handler.startElement( existingCal, ¬e, "Event" ); + handler.readEvent( existingCal, ¬e ); } + + bool start = true; + GSM_ToDoEntry ToDo; + int ccc = 0; + while (!gshutdown) { + error = Phone->GetNextToDo(&s, &ToDo, start); + if (error == ERR_EMPTY) break; + start = false; + qDebug("readTodo %d ", ++ccc); + handler.readTodo( existingCal, &ToDo, &s); + + } + error=GSM_TerminateConnection(&s); -#if 0 - - bool debug = DEBUGMODE; - //debug = true; - QString text; - QString codec = "utf8"; - QLabel status ( i18n("Reading events ..."), 0 ); - - int w = status.sizeHint().width()+20 ; - if ( w < 200 ) w = 200; - int h = status.sizeHint().height()+20 ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - status.setCaption(i18n("Reading DTM Data") ); - status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - status.show(); - status.raise(); - qApp->processEvents(); - QString fileName; - if ( ! debug ) { - fileName = "/tmp/kopitempout"; - QString command ="db2file datebook -r -c "+ codec + " > " + fileName; - system ( command.latin1() ); - } else { - fileName = "/tmp/events.txt"; - - } - QFile file( fileName ); - if (!file.open( IO_ReadOnly ) ) { - return false; - - } - QTextStream ts( &file ); - ts.setCodec( QTextCodec::codecForName("utf8") ); - text = ts.read(); - file.close(); - status.setText( i18n("Processing events ...") ); - status.raise(); - qApp->processEvents(); - fromString2Cal( calendar, existngCal, text, "Event" ); - status.setText( i18n("Reading todos ...") ); - qApp->processEvents(); - if ( ! debug ) { - fileName = "/tmp/kopitempout"; - QString command = "db2file todo -r -c " + codec+ " > " + fileName; - system ( command.latin1() ); - } else { - fileName = "/tmp/todo.txt"; - } - file.setName( fileName ); - if (!file.open( IO_ReadOnly ) ) { - return false; - - } - ts.setDevice( &file ); - text = ts.read(); - file.close(); - status.setText( i18n("Processing todos ...") ); - status.raise(); - qApp->processEvents(); - fromString2Cal( calendar, existngCal, text, "Todo" ); -#endif return true; } -int PhoneFormat::getNumFromRecord( QString answer, Incidence* inc ) -{ - int retval = -1; - QStringList templist; - QString tempString; - int start = 0; - int len = answer.length(); - int end = answer.find ("\n",start)+1; - bool ok = true; - start = end; - int ccc = 0; - while ( start > 0 ) { - templist.clear(); - ok = true; - int loopCount = 0; - while ( ok ) { - ++loopCount; - if ( loopCount > 25 ) { - qDebug("KO: Error in while loop"); - ok = false; - start = 0; - break; - } - if ( ok ) - tempString = getPart( answer, ok, start ); - if ( start >= len || start == 0 ) { - start = 0; - ok = false; - } - if ( tempString.right(1) =="\n" ) - tempString = tempString.left( tempString.length()-1); - - templist.append( tempString ); - } - ++ccc; - if ( ccc == 2 && loopCount < 25 ) { - start = 0; - bool ok; - int newnum = templist[0].toInt( &ok ); - if ( ok && newnum > 0) { - retval = newnum; - //inc->setZaurusId( newnum ); - //inc->setZaurusUid( getCsum( templist ) ); - //inc->setZaurusStat( -4 ); - } - } - } - //qDebug("getNumFromRecord returning : %d ", retval); - return retval; -} + bool PhoneFormat::save( Calendar *calendar) { - +#if 0 QLabel status ( i18n("Processing/adding events ..."), 0 ); int w = status.sizeHint().width()+20 ; if ( w < 200 ) w = 200; @@ -724,7 +723,7 @@ bool PhoneFormat::save( Calendar *calendar) //qDebug("i %d ", ++i); if ( true /*ev->zaurusStat() != -2*/ ) { status.setText ( message + QString::number ( ++procCount ) ); - qApp->processEvents(); + qApp->processEvents(); QString eString = getEventString( ev ); if (/* ev->zaurusStat() == -3 */ true) { // delete // deleting empty strings does not work. @@ -734,7 +733,7 @@ bool PhoneFormat::save( Calendar *calendar) deleteString += eString + "\n"; deleteEnt = true; changeEnt = true; - } + } else if ( /*ev->zaurusId() == -1*/true ) { // add new command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; system ( command.utf8() ); @@ -809,8 +808,8 @@ bool PhoneFormat::save( Calendar *calendar) procCount = 0; while ( to ) { if ( true /*to->zaurusStat() != -2 */) { - status.setText ( message + QString::number ( ++procCount ) ); - qApp->processEvents(); + status.setText ( message + QString::number ( ++procCount ) ); + qApp->processEvents(); QString eString = getTodoString( to ); if ( /*to->zaurusStat() == -3*/true ) { // delete // deleting empty strings does not work. @@ -820,7 +819,7 @@ bool PhoneFormat::save( Calendar *calendar) deleteString += eString + "\n"; deleteEnt = true; changeEnt = true; - } + } else if ( true /*to->zaurusId() == -1*/ ) { // add new command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; system ( command.utf8() ); @@ -883,10 +882,10 @@ bool PhoneFormat::save( Calendar *calendar) system ( command.latin1() ); // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); } - - return true; +#endif + return true; } -QString PhoneFormat::dtToString( const QDateTime& dti, bool useTZ ) +QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) { QString datestr; QString timestr; @@ -899,12 +898,12 @@ QString PhoneFormat::dtToString( const QDateTime& dti, bool useTZ ) if(dt.date().isValid()){ const QDate& date = dt.date(); datestr.sprintf("%04d%02d%02d", - date.year(), date.month(), date.day()); + date.year(), date.month(), date.day()); } if(dt.time().isValid()){ const QTime& time = dt.time(); timestr.sprintf("T%02d%02d%02d", - time.hour(), time.minute(), time.second()); + time.hour(), time.minute(), time.second()); } return datestr + timestr; } @@ -1058,20 +1057,20 @@ QString PhoneFormat::getEventString( Event* event ) list.append( "1" ); - for(QStringList::Iterator it=list.begin(); - it!=list.end(); ++it){ - QString& s = (*it); - s.replace(QRegExp("\""), "\"\""); - if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ - s.prepend('\"'); - s.append('\"'); - } else if(s.isEmpty() && !s.isNull()){ - s = "\"\""; - } - } - return list.join(","); + for(QStringList::Iterator it=list.begin(); + it!=list.end(); ++it){ + QString& s = (*it); + s.replace(QRegExp("\""), "\"\""); + if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ + s.prepend('\"'); + s.append('\"'); + } else if(s.isEmpty() && !s.isNull()){ + s = "\"\""; + } + } + return list.join(","); #endif - return QString(); + return QString(); } QString PhoneFormat::getTodoString( Todo* todo ) @@ -1089,7 +1088,7 @@ QString PhoneFormat::getTodoString( Todo* todo ) if ( todo->hasDueDate() ) { QTime tim; if ( todo->doesFloat()) { - list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; + list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; } else { list.append( dtToString(todo->dtDue() ) ); } @@ -1125,393 +1124,15 @@ QString PhoneFormat::getTodoString( Todo* todo ) } return list.join(","); #endif - return QString(); + return QString(); } -QString PhoneFormat::getPart( const QString & text, bool &ok, int &start ) -{ - //qDebug("start %d ", start); - - QString retval =""; - if ( text.at(start) == '"' ) { - if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { - start = start +2; - if ( text.mid( start,1) == "," ) { - start += 1; - } - retval = ""; - if ( text.mid( start,1) == "\n" ) { - start += 1; - ok = false; - } - return retval; - } - int hk = start+1; - hk = text.find ('"',hk); - while ( text.at(hk+1) == '"' ) - hk = text.find ('"',hk+2); - retval = text.mid( start+1, hk-start-1); - start = hk+1; - retval.replace( QRegExp("\"\""), "\""); - if ( text.mid( start,1) == "," ) { - start += 1; - } - if ( text.mid( start,1) == "\n" ) { - start += 1; - ok = false; - } - //qDebug("retval***%s*** ",retval.latin1() ); - return retval; - } else { - int nl = text.find ("\n",start); - int kom = text.find (',',start); - if ( kom < nl ) { - // qDebug("kom < nl %d ", kom); - retval = text.mid(start, kom-start); - start = kom+1; - return retval; - } else { - if ( nl == kom ) { - // qDebug(" nl == kom "); - start = 0; - ok = false; - return "0"; - } - // qDebug(" nl < kom ", nl); - retval = text.mid( start, nl-start); - ok = false; - start = nl+1; - return retval; - } - } -} -bool PhoneFormat::fromString( Calendar *calendar, const QString & text) + +QString PhoneFormat::toString( Calendar * ) { - return false; + return QString::null; } -bool PhoneFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine* s, const QString & type) +bool PhoneFormat::fromString( Calendar *calendar, const QString & text) { -#if 0 - GSM_Phone_Functions *Phone; - - GSM_CalendarEntry note; - GSM_CalendarEntry* Note; - bool refresh = true; - - Phone=s->Phone.Functions; - bool gshutdown = false; - PhoneParser handler( calendar ); - //handler.setCategoriesList( mCategories ); - QStringList templist; - QString tempString; - int start = 0; - int error; - int ccc = 0; - while (!gshutdown && ccc++ < 10 ) { - QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY; - templist.clear(); - qDebug("count %d ", ccc); - error=Phone->GetNextCalendar(s,¬e,refresh); - if (error == ERR_EMPTY) break; - - Note = ¬e; -//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY -// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 - -//ARSD silentalarm = 0 -// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly -// 12 RFRQ -// 13 RPOS pos = 4. monday in month -// 14 RDYS days: 1 mon/ 2 tue .. 64 sun -// 15 REND 0 = no end/ 1 = end -// 16 REDT rec end dt -//ALSD -//ALED -//MDAY - - CARDID = QString::number( Note->Location ); // 0 - - - int i_age = 0,i; - GSM_DateTime Alarm,DateTime; - GSM_DateTime* dtp; - GSM_MemoryEntry entry; - unsigned char *name; - - bool repeating = false; - int repeat_dayofweek = -1; - int repeat_day = -1; - int repeat_weekofmonth = -1; - int repeat_month = -1; - int repeat_frequency = -1; - GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; - GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; - - Alarm.Year = 0; - - repeating = false; - repeat_dayofweek = -1; - repeat_day = -1; - repeat_weekofmonth = -1; - repeat_month = -1; - repeat_frequency = -1; - repeat_startdate.Day = 0; - repeat_stopdate.Day = 0; - - - switch (Note->Type) { - case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; - case GSM_CAL_CALL : CATEGORY = QString("Call"); break; - case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; - case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; - case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; - case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; - case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; - case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; - case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; - case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; - case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; - case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; - case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; - case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; - case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; - case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; - case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; - case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; - case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; - case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; - case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; - case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; - case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; - case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; - case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; - case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; - case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; - case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; - default : CATEGORY = QString(""); - } -//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY -// 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19? - - MEM1 = ""; - -#if 0 - - if ( attList[7] == "1" ) { - event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); - event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); - event->setFloats( true ); - } else { - event->setFloats( false ); - event->setDtStart( fromString( attList[5] ) ); - event->setDtEnd( fromString( attList[6] )); - } - - - -typedef struct { - /** - * The difference between local time and GMT in hours - */ - int Timezone; - - unsigned int Second; - unsigned int Minute; - unsigned int Hour; - - unsigned int Day; - /** - * January = 1, February = 2, etc. - */ - unsigned int Month; - /** - * Complete year number. Not 03, but 2003 - */ - unsigned int Year; -} GSM_DateTime; - - if(dt.date().isValid()){ - const QDate& date = dt.date(); - datestr.sprintf("%04d%02d%02d", - date.year(), date.month(), date.day()); - } - if(dt.time().isValid()){ - const QTime& time = dt.time(); - timestr.sprintf("T%02d%02d%02d", - time.hour(), time.minute(), time.second()); - } - return datestr + timestr; - - - - -#endif - - - ADAY = "0"; - ARON = "1"; // 1 == disabled - ARMN = "0"; //alarm offset in minutes - - for (i=0;iEntriesNum;i++) { - - qDebug(" for "); - switch (Note->Entries[i].EntryType) { - case CAL_START_DATETIME: - dtp = &Note->Entries[i].Date ; - - qDebug("hour: %d ", dtp->Hour); - if ( dtp->Hour == -1 ) { - ADAY = "1"; - ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); - TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); - } else { - TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); - - } - ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); - // memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); - break; - case CAL_END_DATETIME: - dtp = &Note->Entries[i].Date ; - qDebug("hour2: %d ", dtp->Hour); - if ( dtp->Hour == -1 ) { - ADAY = "1"; - ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); - TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); - } else { - TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); - - } - //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); - //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); - break; - case CAL_ALARM_DATETIME: - ARON = "0"; - dtp = &Note->Entries[i].Date ; - ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); - //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); - memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); - break; - case CAL_SILENT_ALARM_DATETIME: - ARON = "0"; - dtp = &Note->Entries[i].Date ; - ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); - //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); - //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); - break; - case CAL_RECURRANCE: - //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); - break; - case CAL_TEXT: - DSRP = QString ( (const char*) Note->Entries[i].Text ); - break; - case CAL_LOCATION: - PLCE = QString ((const char*) Note->Entries[i].Text ); - break; - case CAL_PHONE: - //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); - break; - case CAL_PRIVATE: - //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); - break; - case CAL_CONTACTID: -#if 0 - entry.Location = Note->Entries[i].Number; - entry.MemoryType = MEM_ME; - error=Phone->GetMemory(&s, &entry); - if (error == ERR_NONE) { - name = GSM_PhonebookGetEntryName(&entry); - if (name != NULL) { - //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); - } else { - //printmsg("Contact ID : %d\n",Note->Entries[i].Number); - } - } else { - //printmsg("Contact ID : %d\n",Note->Entries[i].Number); - } -#endif - break; - case CAL_REPEAT_DAYOFWEEK: - repeat_dayofweek = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_DAY: - repeat_day = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_WEEKOFMONTH: - repeat_weekofmonth = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_MONTH: - repeat_month = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_FREQUENCY: - repeat_frequency = Note->Entries[i].Number; - repeating = true; - break; - case CAL_REPEAT_STARTDATE: - repeat_startdate = Note->Entries[i].Date; - repeating = true; - break; - case CAL_REPEAT_STOPDATE: - repeat_stopdate = Note->Entries[i].Date; - repeating = true; - break; - } - } - - - - if ( ARON == "0" ) { - QDateTime start,alarm; - start = handler.fromString( TIM1 ); - alarm = handler.fromString( ARMN ); - int min = alarm.secsTo ( start )/60; - ARMN = QString::number ( min ); - } - - templist.clear(); - templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY; - handler.startElement( existingCalendar, templist, type ); - } - - -#endif -#if 0 - // qDebug("test %s ", text.latin1()); - QStringList templist; - QString tempString; - int start = 0; - int len = text.length(); - int end = text.find ("\n",start)+1; - bool ok = true; - start = end; - PhoneParser handler( calendar ); - handler.setCategoriesList( mCategories ); - while ( start > 0 ) { - templist.clear(); - ok = true; - while ( ok ) { - tempString = getPart( text, ok, start ); - if ( start >= len || start == 0 ) { - start = 0; - ok = false; - } - if ( tempString.right(1) =="\n" ) - tempString = tempString.left( tempString.length()-1); - //if ( ok ) - templist.append( tempString ); - //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); - } - handler.startElement( existingCalendar, templist, type ); - } -#endif return false; } - -QString PhoneFormat::toString( Calendar * ) -{ - return QString::null; -} -- cgit v0.9.0.2