From 4f276d80bd977401d656851515474cc00c661e5b Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 15 Oct 2004 14:26:07 +0000 Subject: many phone and sync fixes --- diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0375fee..7310755 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c @@ -111,7 +111,7 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); break; case GSM_CAL_BIRTHDAY: - *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); + *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); break; case GSM_CAL_MEETING: default: @@ -150,12 +150,12 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note } /* Birthday is known to be recurranced */ - if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { + if (Recurrance != -1 ) { switch(note->Entries[Recurrance].Number/24) { case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; - case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; + case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1 #0%c%c",13,10); break; } } } else if (Version == Siemens_VCalendar) { @@ -168,7 +168,7 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); break; case GSM_CAL_BIRTHDAY: - *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); + *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); break; case GSM_CAL_MEMO: default: @@ -188,7 +188,7 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10); break; case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10); break; case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10); break; - case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10); break; + case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1%c%c",13,10); break; } } @@ -220,7 +220,7 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); break; case GSM_CAL_BIRTHDAY: - *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); + *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); break; case GSM_CAL_MEMO: default: @@ -390,8 +390,8 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; - if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; + if (strstr(Line,"CATEGORIES:Birthday")) Calendar->Type = GSM_CAL_BIRTHDAY; if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; if (strstr(Line,"RRULE:D1")) { @@ -420,6 +420,12 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda Calendar->EntriesNum++; } // LR + if (strstr(Line,"RRULE:YM1")) { + Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; + Calendar->Entries[Calendar->EntriesNum].Number = 365*24; + Calendar->EntriesNum++; + } + // LR if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2564894..40877ef 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -310,6 +310,7 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) if ( ( *phoneItAD ).contains( (*it) ) ) { found = true; (*it).setType( ( *phoneItAD ).type() ); + (*it).setNumber( ( *phoneItAD ).number() ); break; } } diff --git a/kabc/kabc.pro b/kabc/kabc.pro index d690acc..17ebff8 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro @@ -48,7 +48,6 @@ formats/vcardformatplugin2.h \ secrecy.h \ sound.h \ addressbook.h \ - syncprefwidget.h \ timezone.h \ tmpaddressbook.h \ addressee.h \ @@ -160,7 +159,6 @@ formatfactory.cpp \ secrecy.cpp \ sound.cpp \ addressbook.cpp \ - syncprefwidget.cpp \ timezone.cpp \ tmpaddressbook.cpp \ addressee.cpp \ diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3e0a27d..e4a11f5 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1130,8 +1130,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int inL = el.next(); } int delFut = 0; + int remRem = 0; if ( mSyncManager->mWriteBackInFuture ) { er = remote->rawIncidences(); + remRem = er.count(); inR = er.first(); QDateTime dt; QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); @@ -1175,7 +1177,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); QString delmess; if ( delFut ) { - delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); + delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); mes += delmess; } if ( mSyncManager->mShowSyncSummary ) { diff --git a/libkcal/event.cpp b/libkcal/event.cpp index dfa265b..7256f05 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp @@ -56,6 +56,52 @@ bool KCal::operator==( const Event& e1, const Event& e2 ) } +bool Event::contains ( Event* from ) +{ + + if ( !from->summary().isEmpty() ) + if ( !summary().startsWith( from->summary() )) + return false; + if ( from->dtStart().isValid() ) + if (dtStart() != from->dtStart() ) + return false; + if ( from->dtEnd().isValid() ) + if ( dtEnd() != from->dtEnd() ) + return false; + if ( !from->location().isEmpty() ) + if ( !location().startsWith( from->location() ) ) + return false; + if ( !from->description().isEmpty() ) + if ( !description().startsWith( from->description() )) + return false; + if ( from->alarms().count() ) { + Alarm *a = from->alarms().first(); + if ( a->enabled() ){ + if ( !alarms().count() ) + return false; + Alarm *b = alarms().first(); + if( ! b->enabled() ) + return false; + if ( ! (a->offset() == b->offset() )) + return false; + } + } + QStringList cat = categories(); + QStringList catFrom = from->categories(); + QString nCat; + int iii; + for ( iii = 0; iii < catFrom.count();++iii ) { + nCat = catFrom[iii]; + if ( !nCat.isEmpty() ) + if ( !cat.contains( nCat )) { + return false; + } + } + if ( from->doesRecur() ) + if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) + return false; + return true; +} void Event::setDtEnd(const QDateTime &dtEnd) { diff --git a/libkcal/event.h b/libkcal/event.h index 2a8bd95..3bc8adc 100644 --- a/libkcal/event.h +++ b/libkcal/event.h @@ -71,6 +71,8 @@ class Event : public Incidence void setDuration(int seconds); + bool contains ( Event*); + private: bool accept(Visitor &v) { return v.visit(this); } diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 281434e..101db57 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -312,7 +312,16 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) QStringList cat = ev->categories(); if ( cat.contains( "MeetingDEF" )) { ev->setCategories( QStringList() ); + } else + if ( cat.contains( "Birthday" )) { + ev->setFloats( true ); + QDate da = ev->dtStart().date(); + ev->setDtStart( QDateTime( da) ); + ev->setDtEnd( QDateTime( da.addDays(1)) ); + } + uint cSum; + cSum = PhoneFormat::getCsumEvent( ev ); int id = ev->pilotId(); Event *event; event = existingCal->event( mProfileName ,QString::number( id ) ); @@ -324,8 +333,6 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) } else event = ev; - uint cSum; - cSum = PhoneFormat::getCsumEvent( event ); event->setCsum( mProfileName, QString::number( cSum )); event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); event->setID( mProfileName,QString::number( id ) ); @@ -342,6 +349,8 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) ev->setCategories( QStringList() ); } int id = ev->pilotId(); + uint cSum; + cSum = PhoneFormat::getCsumTodo( ev ); Todo *event; event = existingCal->todo( mProfileName ,QString::number( id ) ); if ( event ) { @@ -354,8 +363,6 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) } else event = ev; - uint cSum; - cSum = PhoneFormat::getCsumTodo( event ); event->setCsum( mProfileName, QString::number( cSum )); event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); event->setID( mProfileName,QString::number( id ) ); @@ -382,11 +389,7 @@ void PhoneFormat::copyEvent( Event* to, Event* from ) Alarm *a = from->alarms().first(); Alarm *b = to->newAlarm( ); b->setEnabled( a->enabled() ); - if ( a->hasStartOffset() ) { - b->setStartOffset( a->startOffset() ); - } - if ( a->hasTime() ) - b->setTime( a->time() ); + b->setStartOffset(Duration( a->offset() ) ); } QStringList cat = to->categories(); @@ -401,17 +404,23 @@ void PhoneFormat::copyEvent( Event* to, Event* from ) } } to->setCategories( cat ); - Recurrence * r = new Recurrence( *from->recurrence(),to); - to->setRecurrence( r ) ; + if ( from->doesRecur() ) { + Recurrence * r = new Recurrence( *from->recurrence(),to); + to->setRecurrence( r ) ; + } } void PhoneFormat::copyTodo( Todo* to, Todo* from ) { - if ( from->dtStart().isValid() ) + if ( from->hasStartDate() ) { + to->setHasStartDate( true ); to->setDtStart( from->dtStart() ); - if ( from->dtDue().isValid() ) + } + if ( from->hasDueDate() ){ + to->setHasDueDate( true ); to->setDtDue( from->dtDue() ); + } if ( !from->location().isEmpty() ) to->setLocation( from->location() ); if ( !from->description().isEmpty() ) @@ -424,10 +433,7 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) Alarm *a = from->alarms().first(); Alarm *b = to->newAlarm( ); b->setEnabled( a->enabled() ); - if ( a->hasStartOffset() ) - b->setStartOffset( a->startOffset() ); - if ( a->hasTime() ) - b->setTime( a->time() ); + b->setStartOffset(Duration( a->offset() ) ); } QStringList cat = to->categories(); @@ -461,16 +467,10 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) } #include -void PhoneFormat::afterSave( Incidence* inc) +void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) { - uint csum; - inc->removeID( mProfileName ); - if ( inc->type() == "Event") - csum = PhoneFormat::getCsumEvent( (Event*) inc ); - else - csum = PhoneFormat::getCsumTodo( (Todo*) inc ); - inc->setCsum( mProfileName, QString::number( csum )); - + inc->setID( mProfileName, id ); + inc->setCsum( mProfileName, csum); inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); } @@ -478,9 +478,9 @@ void PhoneFormat::afterSave( Incidence* inc) bool PhoneFormat::writeToPhone( Calendar * calendar) { #ifdef _WIN32_ - QString fileName = locateLocal("tmp", "tempfile.vcs"); + QString fileName = locateLocal("tmp", "phonefile.vcs"); #else - QString fileName = "/tmp/kdepimtemp.vcs"; + QString fileName = "/tmp/phonefile.vcs"; #endif VCalFormat vfsave; @@ -494,18 +494,7 @@ bool PhoneFormat::writeToPhone( Calendar * calendar) } bool PhoneFormat::save( Calendar *calendar) { - QLabel status ( i18n(" Opening device ..."), 0 ); - int w = status.sizeHint().width()+20 ; - if ( w < 200 ) w = 230; - int h = status.sizeHint().height()+20 ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - status.setCaption(i18n("Writing to phone...") ); - status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - status.show(); - status.raise(); - qApp->processEvents(); - QString message; + // 1 remove events which should be deleted QPtrList er = calendar->rawEvents(); @@ -534,7 +523,18 @@ bool PhoneFormat::save( Calendar *calendar) // 3 save file if ( !writeToPhone( calendar ) ) return false; - + QLabel status ( i18n(" Opening device ..."), 0 ); + int w = status.sizeHint().width()+20 ; + if ( w < 200 ) w = 230; + int h = status.sizeHint().height()+20 ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + status.setCaption(i18n("Writing to phone...") ); + status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + QString message; + status.show(); + status.raise(); + qApp->processEvents(); // 5 reread data message = i18n(" Rereading all data ... "); status.setText ( message ); @@ -559,19 +559,11 @@ bool PhoneFormat::save( Calendar *calendar) //qDebug("event new ID %s",ev->summary().latin1()); status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); - uint csum; - csum = PhoneFormat::getCsumEvent( ev ); - QString cSum = QString::number( csum ); - //ev->setCsum( mProfileName, cSum ); - //qDebug("Event cSum %s ", cSum.latin1()); ev1 = er1.first(); while ( ev1 ) { - if ( ev1->getCsum( mProfileName ) == cSum ) { + if ( ev->contains( ev1 ) ) { + afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); er1.remove( ev1 ); - afterSave( ev ); - ev->setID(mProfileName, ev1->getID(mProfileName) ); - //qDebug("Event found on phone for %s ", ev->summary().latin1()); - break; } ev1 = er1.next(); @@ -594,17 +586,11 @@ bool PhoneFormat::save( Calendar *calendar) while ( to ) { status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); - uint csum; - csum = PhoneFormat::getCsumTodo( to ); - QString cSum = QString::number( csum ); - //to->setCsum( mProfileName, cSum ); - //qDebug("Todo cSum %s ", cSum.latin1()); Todo* to1 = tl1.first(); while ( to1 ) { - if ( to1->getCsum( mProfileName ) == cSum ) { + if ( to->contains( to1 ) ) { + afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); tl1.remove( to1 ); - afterSave( to ); - to->setID(mProfileName, to1->getID(mProfileName) ); break; } to1 = tl1.next(); diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 001fd81..d11f68b 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h @@ -54,7 +54,7 @@ class PhoneFormat : public QObject { void copyTodo( Todo* to, Todo* from ); //int initDevice(GSM_StateMachine *s); QString mProfileName; - void afterSave( Incidence* ); + void afterSave( Incidence* ,const QString&,const QString&); }; } diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 0c1e3e4..3d2de61 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -56,7 +56,65 @@ Incidence *Todo::clone() return new Todo(*this); } +bool Todo::contains ( Todo* from ) +{ + if ( !from->summary().isEmpty() ) + if ( !summary().startsWith( from->summary() )) + return false; + if ( from->hasStartDate() ) { + if ( !hasStartDate() ) + return false; + if ( from->dtStart() != dtStart()) + return false; + } + if ( from->hasDueDate() ){ + if ( !hasDueDate() ) + return false; + if ( from->dtDue() != dtDue()) + return false; + } + if ( !from->location().isEmpty() ) + if ( !location().startsWith( from->location() ) ) + return false; + if ( !from->description().isEmpty() ) + if ( !description().startsWith( from->description() )) + return false; + if ( from->alarms().count() ) { + Alarm *a = from->alarms().first(); + if ( a->enabled() ){ + if ( !alarms().count() ) + return false; + Alarm *b = alarms().first(); + if( ! b->enabled() ) + return false; + if ( ! (a->offset() == b->offset() )) + return false; + } + } + + QStringList cat = categories(); + QStringList catFrom = from->categories(); + QString nCat; + int iii; + for ( iii = 0; iii < catFrom.count();++iii ) { + nCat = catFrom[iii]; + if ( !nCat.isEmpty() ) + if ( !cat.contains( nCat )) { + return false; + } + } + if ( from->isCompleted() ) { + if ( !isCompleted() ) + return false; + } + if( priority() != from->priority() ) + return false; + + + return true; + +} bool KCal::operator==( const Todo& t1, const Todo& t2 ) { diff --git a/libkcal/todo.h b/libkcal/todo.h index 9aa92f8..0f22c59 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -99,6 +99,7 @@ class Todo : public Incidence /** Return true, if todo has a date associated with completion */ bool hasCompletedDate() const; + bool contains ( Todo*); private: bool accept(Visitor &v) { return v.visit(this); } diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index a6ae1bc..df93209 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -62,7 +62,8 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName) { mCalendar = calendar; clearException(); - useLocalTime = mCalendar->isLocalTime(); + if ( ! useLocalTime ) + useLocalTime = mCalendar->isLocalTime(); VObject *vcal = 0; // this is not necessarily only 1 vcal. Could be many vcals, or include @@ -90,7 +91,8 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName) bool VCalFormat::save(Calendar *calendar, const QString &fileName) { mCalendar = calendar; - useLocalTime = mCalendar->isLocalTime(); + if ( ! useLocalTime ) + useLocalTime = mCalendar->isLocalTime(); QString tmpStr; VObject *vcal, *vo; @@ -1172,72 +1174,76 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) /*********************** YEARLY-BY-MONTH *******************************/ else if (tmpStr.left(2) == "YM") { - int index = tmpStr.find(' '); - int last = tmpStr.findRev(' ') + 1; - int rFreq = tmpStr.mid(2, (index-1)).toInt(); - index += 1; - short tmpMonth; - if( index == last ) { - // e.g. YM1 #0 - tmpMonth = anEvent->dtStart().date().month(); - anEvent->recurrence()->addYearlyNum(tmpMonth); - } - else { - // e.g. YM1 3 #0 - while (index < last) { - int index2 = tmpStr.find(' ', index); - tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); - index = index2+1; - anEvent->recurrence()->addYearlyNum(tmpMonth); - } // while != # - } - index = last; if (tmpStr.mid(index,1) == "#") index++; - if (tmpStr.find('T', index) != -1) { - QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); - } else { - int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); - if (rDuration == 0) - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); - else - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); - } + // we have to set this such that recurrence accepts addYearlyNum(tmpDay); + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); + int index = tmpStr.find(' '); + int last = tmpStr.findRev(' ') + 1; + int rFreq = tmpStr.mid(2, (index-1)).toInt(); + index += 1; + short tmpMonth; + if( index == last ) { + // e.g. YM1 #0 + tmpMonth = anEvent->dtStart().date().month(); + anEvent->recurrence()->addYearlyNum(tmpMonth); + } + else { + // e.g. YM1 3 #0 + while (index < last) { + int index2 = tmpStr.find(' ', index); + tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); + index = index2+1; + anEvent->recurrence()->addYearlyNum(tmpMonth); + } // while != # + } + index = last; if (tmpStr.mid(index,1) == "#") index++; + if (tmpStr.find('T', index) != -1) { + QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); + } else { + int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); + if (rDuration == 0) + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); + else + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); + } } /*********************** YEARLY-BY-DAY *********************************/ else if (tmpStr.left(2) == "YD") { - int index = tmpStr.find(' '); - int last = tmpStr.findRev(' ') + 1; - int rFreq = tmpStr.mid(2, (index-1)).toInt(); - index += 1; - short tmpDay; - if( index == last ) { - // e.g. YD1 #0 - tmpDay = anEvent->dtStart().date().dayOfYear(); - anEvent->recurrence()->addYearlyNum(tmpDay); - } - else { - // e.g. YD1 123 #0 - while (index < last) { - int index2 = tmpStr.find(' ', index); - tmpDay = tmpStr.mid(index, (index2-index)).toShort(); - index = index2+1; - anEvent->recurrence()->addYearlyNum(tmpDay); - } // while != # - } - index = last; if (tmpStr.mid(index,1) == "#") index++; - if (tmpStr.find('T', index) != -1) { - QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); - } else { - int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); - if (rDuration == 0) - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); - else - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); - } + // we have to set this such that recurrence accepts addYearlyNum(tmpDay); + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); + int index = tmpStr.find(' '); + int last = tmpStr.findRev(' ') + 1; + int rFreq = tmpStr.mid(2, (index-1)).toInt(); + index += 1; + short tmpDay; + if( index == last ) { + // e.g. YD1 #0 + tmpDay = anEvent->dtStart().date().dayOfYear(); + anEvent->recurrence()->addYearlyNum(tmpDay); + } + else { + // e.g. YD1 123 #0 + while (index < last) { + int index2 = tmpStr.find(' ', index); + tmpDay = tmpStr.mid(index, (index2-index)).toShort(); + index = index2+1; + anEvent->recurrence()->addYearlyNum(tmpDay); + } // while != # + } + index = last; if (tmpStr.mid(index,1) == "#") index++; + if (tmpStr.find('T', index) != -1) { + QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); + } else { + int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); + if (rDuration == 0) + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); + else + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); + } } else { - kdDebug(5800) << "we don't understand this type of recurrence!" << endl; + kdDebug(5800) << "we don't understand this type of recurrence!" << endl; } // if } // repeats @@ -1536,12 +1542,13 @@ void VCalFormat::populate(VObject *vcal) // set the time zone if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { - char *s = fakeCString(vObjectUStringZValue(curVO)); - mCalendar->setTimeZone(s); - deleteStr(s); + if ( vObjectUStringZValue(curVO) != 0 ) { + char *s = fakeCString(vObjectUStringZValue(curVO)); + mCalendar->setTimeZone(s); + deleteStr(s); + } } - // Store all events with a relatedTo property in a list for post-processing mEventsRelate.clear(); mTodosRelate.clear(); diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 8298aa6..e24ad9e 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -139,13 +140,33 @@ bool PhoneAccess::writeToPhone( QString fileName) #else QString command ="kammu --restore " + fileName ; #endif - int ret; - while ( (ret = system ( command.latin1())) != 0 ) { - qDebug("Error S::command returned %d.", ret); - int retval = KMessageBox::warningContinueCancel(0, - i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); - if ( retval != KMessageBox::Continue ) - return false; + int ret = 1; + while ( ret != 0 ) { + QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); + int w = 235; + int h = status->sizeHint().height()+20 ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + if ( dw > 310 ) + w = 310; + status->setCaption(i18n("Writing to phone...") ); + status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + status->show(); + status->raise(); + status->update(); + qApp->processEvents(); + status->update(); + qApp->processEvents(); + ret = system ( command.latin1()); + delete status; + qApp->processEvents(); + if ( ret ) { + qDebug("Error S::command returned %d.", ret); + int retval = KMessageBox::warningContinueCancel(0, + i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); + if ( retval != KMessageBox::Continue ) + return false; + } } return true; } @@ -162,12 +183,34 @@ bool PhoneAccess::readFromPhone( QString fileName) QString command ="kammu --backup " + fileName + " -yes" ; #endif int ret; - while ( (ret = system ( command.latin1())) != 0 ) { - qDebug("Error reading from phone:Command returned %d", ret); - int retval = KMessageBox::warningContinueCancel(0, - i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); - if ( retval != KMessageBox::Continue ) - return false; + while ( ret != 0 ) { + QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); + int w = 235; + int h = status->sizeHint().height()+20 ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + if ( dw > 310 ) + w = 310; + status->setCaption(i18n("Reading from phone...") ); + status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + status->show(); + status->raise(); + status->update(); + qApp->processEvents(); + status->update(); + qApp->processEvents(); + ret = system ( command.latin1() ); + delete status; + qApp->processEvents(); + if ( ret ) { + qDebug("Error reading from phone:Command returned %d", ret); + int retval = KMessageBox::warningContinueCancel(0, + i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); + if ( retval != KMessageBox::Continue ) + return false; + + } } + qApp->processEvents(); return true; } diff --git a/microkde/microkde.pro b/microkde/microkde.pro index 71d662b..21da158 100644 --- a/microkde/microkde.pro +++ b/microkde/microkde.pro @@ -81,7 +81,6 @@ KDGanttMinimizeSplitter.h \ kresources/configwidget.h \ kresources/configdialog.h \ kresources/kcmkresources.h \ - kresources/syncwidget.h \ kdecore/kmdcodec.h \ kdecore/kconfigbase.h \ kdecore/klocale.h \ @@ -160,7 +159,6 @@ KDGanttMinimizeSplitter.cpp \ kresources/managerimpl.cpp \ kresources/resource.cpp \ kresources/selectdialog.cpp \ - kresources/syncwidget.cpp \ kutils/kcmultidialog.cpp \ kdeui/kaction.cpp \ kdeui/kactionclasses.cpp \ diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index cf6074d..fd5f965 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "ofileselector_p.h" //US#include "ofileselector.h" @@ -467,7 +469,8 @@ void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { } } (void)new OFileSelectorItem( m_view, pix, name, - info->lastModified().toString(), QString::number( info->size() ), + KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), + QString::number( info->size() ), dir, locked ); } void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { @@ -487,7 +490,7 @@ void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { info->fileName(); (void)new OFileSelectorItem( m_view, pix, name, - info->lastModified().toString(), + KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), QString::number( info->size() ), info->dirPath( true ), locked, true ); -- cgit v0.9.0.2