-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 20 | ||||
-rw-r--r-- | kabc/addressee.cpp | 1 | ||||
-rw-r--r-- | kabc/kabc.pro | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | libkcal/event.cpp | 46 | ||||
-rw-r--r-- | libkcal/event.h | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 100 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 | ||||
-rw-r--r-- | libkcal/todo.cpp | 58 | ||||
-rw-r--r-- | libkcal/todo.h | 1 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 9 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 49 | ||||
-rw-r--r-- | microkde/microkde.pro | 2 | ||||
-rw-r--r-- | microkde/ofileselector_p.cpp | 7 |
14 files changed, 227 insertions, 76 deletions
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 @@ -82,174 +82,174 @@ void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entr default: break; } } } GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) { int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; char buffer[2000]; GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); if (header) { *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); } *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); if (Version == Nokia_VCalendar) { *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); switch (note->Type) { case GSM_CAL_REMINDER: *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); break; case GSM_CAL_MEMO: *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); break; case GSM_CAL_CALL: *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: *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); break; } if (note->Type == GSM_CAL_CALL) { buffer[0] = 0; buffer[1] = 0; if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); if (Text != -1) { if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); } SaveVCALText(Buffer, Length, buffer, "SUMMARY"); } else { SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); } if (note->Type == GSM_CAL_MEETING && Location != -1) { SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); } if (Time == -1) return ERR_UNKNOWN; SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); if (EndTime != -1) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); } if (Alarm != -1) { if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); } else { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); } } /* 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) { *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); switch (note->Type) { case GSM_CAL_MEETING: *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); break; case GSM_CAL_CALL: *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: *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); break; } if (Time == -1) return ERR_UNKNOWN; SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); if (Alarm != -1) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); } if (Recurrance != -1) { switch(note->Entries[Recurrance].Number/24) { 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; } } if (note->Type == GSM_CAL_CALL) { buffer[0] = 0; buffer[1] = 0; if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); if (Text != -1) { if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); } SaveVCALText(Buffer, Length, buffer, "SUMMARY"); } else { SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); } } else if (Version == SonyEricsson_VCalendar) { *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); switch (note->Type) { case GSM_CAL_MEETING: *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); break; case GSM_CAL_REMINDER: *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); break; case GSM_CAL_TRAVEL: *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); break; case GSM_CAL_VACATION: *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: *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); break; } if (Time == -1) return ERR_UNKNOWN; SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); if (EndTime != -1) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); } if (Alarm != -1) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); } SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); if (Location != -1) { SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); } } *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); return ERR_NONE; } @@ -361,94 +361,100 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda unsigned char Line[2000],Buff[2000]; int Level = 0; Calendar->EntriesNum = 0; ToDo->EntriesNum = 0; while (1) { MyGetLine(Buffer, Pos, Line, strlen(Buffer)); if (strlen(Line) == 0) break; switch (Level) { case 0: if (strstr(Line,"BEGIN:VEVENT")) { Calendar->Type = GSM_CAL_MEMO; Level = 1; } if (strstr(Line,"BEGIN:VTODO")) { ToDo->Priority = GSM_Priority_Medium; Level = 2; } break; case 1: /* Calendar note */ if (strstr(Line,"END:VEVENT")) { if (Calendar->EntriesNum == 0) return ERR_EMPTY; return ERR_NONE; } Calendar->Type = GSM_CAL_MEETING; if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE 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")) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; Calendar->Entries[Calendar->EntriesNum].Number = 1*24; Calendar->EntriesNum++; } if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; Calendar->Entries[Calendar->EntriesNum].Number = 7*24; Calendar->EntriesNum++; } if (strstr(Line,"RRULE:W2")) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; Calendar->Entries[Calendar->EntriesNum].Number = 14*24; Calendar->EntriesNum++; } if (strstr(Line,"RRULE:MD1")) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; Calendar->Entries[Calendar->EntriesNum].Number = 30*24; Calendar->EntriesNum++; } if (strstr(Line,"RRULE:YD1")) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; Calendar->Entries[Calendar->EntriesNum].Number = 365*24; 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); Calendar->EntriesNum++; } if (ReadVCALText(Line, "DESCRIPTION", Buff)) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); Calendar->EntriesNum++; } if (ReadVCALText(Line, "LOCATION", Buff)) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); Calendar->EntriesNum++; } if (ReadVCALText(Line, "DTSTART", Buff)) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); Calendar->EntriesNum++; } if (ReadVCALText(Line, "DTEND", Buff)) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); Calendar->EntriesNum++; } if (ReadVCALText(Line, "DALARM", Buff)) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); Calendar->EntriesNum++; } if (ReadVCALText(Line, "AALARM", Buff)) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2564894..40877ef 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -281,64 +281,65 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; if ( !mData->birthday.isValid() ) if ( ad.mData->birthday.isValid()) mData->birthday = ad.mData->birthday; if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; QStringList t; QStringList tAD; uint iii; // ********** phone numbers PhoneNumber::List phoneAD = ad.phoneNumbers(); PhoneNumber::List::Iterator phoneItAD; for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { bool found = false; PhoneNumber::List::Iterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { if ( ( *phoneItAD ).contains( (*it) ) ) { found = true; (*it).setType( ( *phoneItAD ).type() ); + (*it).setNumber( ( *phoneItAD ).number() ); break; } } if ( isSubSet && ! found ) mData->phoneNumbers.append( *phoneItAD ); } if ( isSubSet ) { // ************* emails; t = mData->emails; tAD = ad.mData->emails; for ( iii = 0; iii < tAD.count(); ++iii) if ( !t.contains(tAD[iii] ) ) mData->emails.append( tAD[iii] ); } // ************* categories; t = mData->categories; tAD = ad.mData->categories; for ( iii = 0; iii < tAD.count(); ++iii) if ( !t.contains(tAD[iii] ) ) mData->categories.append( tAD[iii] ); QStringList::ConstIterator it; for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { QString qualifiedName = (*it).left( (*it).find( ":" )); bool found = false; QStringList::ConstIterator itL; for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { if ( (*itL).startsWith( qualifiedName ) ) { found = true; break; } } diff --git a/kabc/kabc.pro b/kabc/kabc.pro index d690acc..17ebff8 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro @@ -19,65 +19,64 @@ MOC_DIR = moc/unix } win32: { DEFINES += _WIN32_ OBJECTS_DIR = obj/win MOC_DIR = moc/win } INTERFACES = \ HEADERS = \ resource.h \ stdaddressbook.h \ agent.h \ geo.h \ key.h \ field.h \ plugin.h \ address.h \ addresseelist.h \ addresseeview.h \ formatfactory.h \ formatplugin.h \ phonenumber.h \ distributionlist.h \ distributionlistdialog.h \ distributionlisteditor.h \ vcardformatplugin.h \ formats/vcardformatplugin2.h \ picture.h \ secrecy.h \ sound.h \ addressbook.h \ - syncprefwidget.h \ timezone.h \ tmpaddressbook.h \ addressee.h \ addresseedialog.h \ vcardconverter.h \ vcard21parser.h \ vcardformatimpl.h \ plugins/file/resourcefile.h \ plugins/file/resourcefileconfig.h \ plugins/dir/resourcedir.h \ plugins/dir/resourcedirconfig.h \ vcardparser/vcardline.h \ vcardparser/vcard.h \ vcardparser/vcardtool.h \ vcardparser/vcardparser.h \ vcard/include/VCardAdrParam.h \ vcard/include/VCardAdrValue.h \ vcard/include/VCardAgentParam.h \ vcard/include/VCardContentLine.h \ vcard/include/VCardDateParam.h \ vcard/include/VCardDateValue.h \ vcard/include/VCardEmailParam.h \ vcard/include/VCardGeoValue.h \ vcard/include/VCardGroup.h \ vcard/include/VCardImageParam.h \ vcard/include/VCardImageValue.h \ vcard/include/VCardLangValue.h \ vcard/include/VCardNValue.h \ vcard/include/VCardParam.h \ vcard/include/VCardPhoneNumberValue.h \ vcard/include/VCardSourceParam.h \ vcard/include/VCardTelParam.h \ @@ -131,65 +130,64 @@ vcard/include/generated/UTCValue-generated.h \ vcard/include/generated/ClassValue-generated.h \ vcard/include/generated/FloatValue-generated.h \ vcard/include/generated/TextListValue-generated.h # plugins/ldap/resourceldap.h \ # plugins/ldap/resourceldapconfig.h \ #formats/binary/binaryformat.h \ #vcard/include/VCardTextNSParam.h \ SOURCES = \ distributionlist.cpp \ distributionlistdialog.cpp \ distributionlisteditor.cpp \ vcardformatplugin.cpp \ formats/vcardformatplugin2.cpp \ formatfactory.cpp \ resource.cpp \ stdaddressbook.cpp \ plugin.cpp \ agent.cpp \ geo.cpp \ key.cpp \ field.cpp \ addresseeview.cpp \ address.cpp \ phonenumber.cpp \ picture.cpp \ secrecy.cpp \ sound.cpp \ addressbook.cpp \ - syncprefwidget.cpp \ timezone.cpp \ tmpaddressbook.cpp \ addressee.cpp \ addresseelist.cpp \ addresseedialog.cpp \ vcardconverter.cpp \ vcard21parser.cpp \ vcardformatimpl.cpp \ plugins/file/resourcefile.cpp \ plugins/file/resourcefileconfig.cpp \ plugins/dir/resourcedir.cpp \ plugins/dir/resourcedirconfig.cpp \ vcardparser/vcardline.cpp \ vcardparser/vcard.cpp \ vcardparser/vcardtool.cpp \ vcardparser/vcardparser.cpp \ vcard/AdrParam.cpp \ vcard/AdrValue.cpp \ vcard/AgentParam.cpp \ vcard/ContentLine.cpp \ vcard/DateParam.cpp \ vcard/DateValue.cpp \ vcard/EmailParam.cpp \ vcard/Entity.cpp \ vcard/Enum.cpp \ vcard/GeoValue.cpp \ vcard/ImageParam.cpp \ vcard/ImageValue.cpp \ vcard/LangValue.cpp \ vcard/NValue.cpp \ vcard/Param.cpp \ vcard/PhoneNumberValue.cpp \ diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3e0a27d..e4a11f5 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1101,110 +1101,112 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int checkExternSyncEvent(eventLSyncSharp, inL); local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! mSyncManager->mWriteBackExistingOnly ) { inL->removeID(mCurrentSyncDevice ); ++addedEventR; //qDebug("remote added Incidence %s ", inL->summary().latin1()); inL->setLastModified( modifiedCalendar ); inR = inL->clone(); inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); remote->addIncidence( inR ); } } } else { if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { checkExternSyncEvent(eventLSyncSharp, inL); local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! mSyncManager->mWriteBackExistingOnly ) { ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); } } } } } 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 ); QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); while ( inR ) { if ( inR->type() == "Todo" ) { Todo * t = (Todo*)inR; if ( t->hasDueDate() ) dt = t->dtDue(); else dt = cur.addSecs( 62 ); } else if (inR->type() == "Event" ) { bool ok; dt = inR->getNextOccurence( cur, &ok ); if ( !ok ) dt = cur.addSecs( -62 ); } else dt = inR->dtStart(); if ( dt < cur || dt > end ) { remote->deleteIncidence( inR ); ++delFut; } inR = er.next(); } } bar.hide(); mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); eventLSync->setReadOnly( false ); eventLSync->setDtStart( mLastCalendarSync ); eventRSync->setDtStart( mLastCalendarSync ); eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); eventLSync->setReadOnly( true ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->addEvent( eventRSync ); QString mes; 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 ) { KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); } qDebug( mes ); mCalendar->checkAlarmForIncidence( 0, true ); return syncOK; } void CalendarView::setSyncDevice( QString s ) { mCurrentSyncDevice= s; } void CalendarView::setSyncName( QString s ) { mCurrentSyncName= s; } bool CalendarView::syncCalendar(QString filename, int mode) { //qDebug("syncCalendar %s ", filename.latin1()); mGlobalSyncMode = SYNC_MODE_NORMAL; CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); FileStorage* storage = new FileStorage( calendar ); bool syncOK = false; storage->setFileName( filename ); // qDebug("loading ... "); if ( storage->load() ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); diff --git a/libkcal/event.cpp b/libkcal/event.cpp index dfa265b..7256f05 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp @@ -27,64 +27,110 @@ using namespace KCal; Event::Event() : mHasEndDate( false ), mTransparency( Opaque ) { } Event::Event(const Event &e) : Incidence(e) { mDtEnd = e.mDtEnd; mHasEndDate = e.mHasEndDate; mTransparency = e.mTransparency; } Event::~Event() { } Incidence *Event::clone() { return new Event(*this); } bool KCal::operator==( const Event& e1, const Event& e2 ) { return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && e1.dtEnd() == e2.dtEnd() && e1.hasEndDate() == e2.hasEndDate() && e1.transparency() == e2.transparency(); } +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) { if (mReadOnly) return; mDtEnd = getEvenTime( dtEnd ); setHasEndDate(true); setHasDuration(false); updated(); } QDateTime Event::dtEnd() const { if (hasEndDate()) return mDtEnd; if (hasDuration()) return dtStart().addSecs(duration()); kdDebug(5800) << "Warning! Event '" << summary() << "' does have neither end date nor duration." << endl; return dtStart(); } QString Event::dtEndTimeStr() const { return KGlobal::locale()->formatTime(mDtEnd.time()); } QString Event::dtEndDateStr(bool shortfmt) const { return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); } diff --git a/libkcal/event.h b/libkcal/event.h index 2a8bd95..3bc8adc 100644 --- a/libkcal/event.h +++ b/libkcal/event.h @@ -42,47 +42,49 @@ class Event : public Incidence QCString type() const { return "Event"; } Incidence *clone(); QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; /** for setting an event's ending date/time with a QDateTime. */ void setDtEnd(const QDateTime &dtEnd); /** Return the event's ending date/time as a QDateTime. */ virtual QDateTime dtEnd() const; /** returns an event's end time as a string formatted according to the users locale settings */ QString dtEndTimeStr() const; /** returns an event's end date as a string formatted according to the users locale settings */ QString dtEndDateStr(bool shortfmt=true) const; /** returns an event's end date and time as a string formatted according to the users locale settings */ QString dtEndStr(bool shortfmt=true) const; void setHasEndDate(bool); /** Return whether the event has an end date/time. */ bool hasEndDate() const; /** Return true if the event spans multiple days, otherwise return false. */ bool isMultiDay() const; /** set the event's time transparency level. */ void setTransparency(Transparency transparency); /** get the event's time transparency level. */ Transparency transparency() const; void setDuration(int seconds); + bool contains ( Event*); + private: bool accept(Visitor &v) { return v.visit(this); } QDateTime mDtEnd; bool mHasEndDate; Transparency mTransparency; }; bool operator==( const Event&, const Event& ); } #endif diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 281434e..101db57 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -283,352 +283,338 @@ ulong PhoneFormat::getCsum( const QStringList & attList) return cSum; } //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); #include <stdlib.h> #define DEBUGMODE false bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) { QString fileName; #ifdef _WIN32_ fileName = locateLocal("tmp", "phonefile.vcs"); #else fileName = "/tmp/phonefile.vcs"; #endif QString command; if ( ! PhoneAccess::readFromPhone( fileName )) { return false; } VCalFormat vfload; vfload.setLocalTime ( true ); qDebug("loading file ..."); if ( ! vfload.load( calendar, fileName ) ) return false; QPtrList<Event> er = calendar->rawEvents(); Event* ev = er.first(); qDebug("reading events... "); while ( ev ) { 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 ) ); if ( event ) { event = (Event*)event->clone(); copyEvent( event, ev ); calendar->deleteEvent( ev ); calendar->addEvent( event); } 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 ) ); ev = er.next(); } { qDebug("reading todos... "); QPtrList<Todo> tr = calendar->rawTodos(); Todo* ev = tr.first(); while ( ev ) { QStringList cat = ev->categories(); if ( cat.contains( "MeetingDEF" )) { ev->setCategories( QStringList() ); } int id = ev->pilotId(); + uint cSum; + cSum = PhoneFormat::getCsumTodo( ev ); Todo *event; event = existingCal->todo( mProfileName ,QString::number( id ) ); if ( event ) { //qDebug("copy todo %s ", event->summary().latin1()); event = (Todo*)event->clone(); copyTodo( event, ev ); calendar->deleteTodo( ev ); calendar->addTodo( event); } 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 ) ); ev = tr.next(); } } return true; } void PhoneFormat::copyEvent( Event* to, Event* from ) { if ( from->dtStart().isValid() ) to->setDtStart( from->dtStart() ); if ( from->dtEnd().isValid() ) to->setDtEnd( from->dtEnd() ); if ( !from->location().isEmpty() ) to->setLocation( from->location() ); if ( !from->description().isEmpty() ) to->setDescription( from->description() ); if ( !from->summary().isEmpty() ) to->setSummary( from->summary() ); if ( from->alarms().count() ) { to->clearAlarms(); 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(); 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 )) { cat << nCat; } } to->setCategories( cat ); + 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() ) to->setDescription( from->description() ); if ( !from->summary().isEmpty() ) to->setSummary( from->summary() ); if ( from->alarms().count() ) { to->clearAlarms(); 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(); 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 )) { cat << nCat; } } to->setCategories( cat ); if ( from->isCompleted() ) { to->setCompleted( true ); if( from->completed().isValid() ) to->setCompleted( from->completed() ); } else { // set percentcomplete only, if to->isCompleted() if ( to->isCompleted() ) to->setPercentComplete(from->percentComplete()); } if( to->priority() == 2 && from->priority() == 1 ) ; //skip else if (to->priority() == 4 && from->priority() == 5 ) ; else to->setPriority(from->priority()); } #include <qcstring.h> -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 ); } 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; vfsave.setLocalTime ( true ); QString id = calendar->timeZoneId(); calendar->setLocalTime(); if ( ! vfsave.save( calendar, fileName ) ) return false; calendar->setTimeZoneId( id ); return PhoneAccess::writeToPhone( fileName ); } 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<Event> er = calendar->rawEvents(); Event* ev = er.first(); while ( ev ) { if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { calendar->deleteEvent( ev ); } else { } ev = er.next(); } // 2 remove todos which should be deleted QPtrList<Todo> tl = calendar->rawTodos(); Todo* to = tl.first(); while ( to ) { if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { calendar->deleteTodo( to ); } else { if ( to->isCompleted()) { calendar->deleteTodo( to ); } } to = tl.next(); } // 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 ); qApp->processEvents(); CalendarLocal* calendarTemp = new CalendarLocal(); calendarTemp->setTimeZoneId( calendar->timeZoneId()); if ( ! load( calendarTemp,calendar) ){ qDebug("error reloading calendar "); delete calendarTemp; return false; } // 6 compare data //algo 6 compare event er = calendar->rawEvents(); ev = er.first(); message = i18n(" Comparing event # "); QPtrList<Event> er1 = calendarTemp->rawEvents(); Event* ev1; int procCount = 0; while ( ev ) { //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(); } if ( ! ev1 ) { // ev->removeID(mProfileName); qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); } ev = er.next(); } //algo 6 compare todo tl = calendar->rawTodos(); to = tl.first(); procCount = 0; QPtrList<Todo> tl1 = calendarTemp->rawTodos(); Todo* to1 ; message = i18n(" Comparing todo # "); 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(); } if ( ! to1 ) { //to->removeID(mProfileName); qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); } to = tl.next(); } delete calendarTemp; return true; } QString PhoneFormat::toString( Calendar * ) { return QString::null; } bool PhoneFormat::fromString( Calendar *calendar, const QString & text) { return false; } diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 001fd81..d11f68b 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h @@ -25,38 +25,38 @@ #include "scheduler.h" #include "vcalformat.h" #include "calformat.h" namespace KCal { /** This class implements the calendar format used by Phone. */ class Event; class Todo; class PhoneFormat : public QObject { public: /** Create new iCalendar format. */ PhoneFormat(QString profileName, QString device,QString connection, QString model); virtual ~PhoneFormat(); bool load( Calendar * ,Calendar * ); bool save( Calendar * ); bool fromString( Calendar *, const QString & ); QString toString( Calendar * ); static ulong getCsum( const QStringList & ); static ulong getCsumTodo( Todo* to ); static ulong getCsumEvent( Event* ev ); static bool writeToPhone( Calendar * ); private: void copyEvent( Event* to, Event* from ); void copyTodo( Todo* to, Todo* from ); //int initDevice(GSM_StateMachine *s); QString mProfileName; - void afterSave( Incidence* ); + void afterSave( Incidence* ,const QString&,const QString&); }; } #endif diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 0c1e3e4..3d2de61 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -27,65 +27,123 @@ using namespace KCal; Todo::Todo(): Incidence() { // mStatus = TENTATIVE; mHasDueDate = false; setHasStartDate( false ); mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; mPercentComplete = 0; } Todo::Todo(const Todo &t) : Incidence(t) { mDtDue = t.mDtDue; mHasDueDate = t.mHasDueDate; mCompleted = t.mCompleted; mHasCompletedDate = t.mHasCompletedDate; mPercentComplete = t.mPercentComplete; } Todo::~Todo() { } 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 ) { bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); if ( ! ret ) return false; if ( t1.hasDueDate() == t2.hasDueDate() ) { if ( t1.hasDueDate() ) { if ( t1.doesFloat() == t2.doesFloat() ) { if ( t1.doesFloat() ) { if ( t1.dtDue().date() != t2.dtDue().date() ) return false; } else if ( t1.dtDue() != t2.dtDue() ) return false; } else return false;// float != } } else return false; if ( t1.percentComplete() != t2.percentComplete() ) return false; if ( t1.isCompleted() ) { if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { if ( t1.hasCompletedDate() ) { if ( t1.completed() != t2.completed() ) return false; } } else return false; diff --git a/libkcal/todo.h b/libkcal/todo.h index 9aa92f8..0f22c59 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -70,52 +70,53 @@ class Todo : public Incidence /** sets the event's status to the value specified. See the enumeration * above for possible values. */ // void setStatus(int); /** return the event's status. */ // int status() const; /** return the event's status in string format. */ // QString statusStr() const; /** return, if this todo is completed */ bool isCompleted() const; /** set completed state of this todo */ void setCompleted(bool); /** Return how many percent of the task are completed. Returns a value between 0 and 100. */ int percentComplete() const; /** Set how many percent of the task are completed. Valid values are in the range from 0 to 100. */ void setPercentComplete(int); /** return date and time when todo was completed */ QDateTime completed() const; QString completedStr() const; /** set date and time of completion */ void setCompleted(const QDateTime &completed); /** 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); } QDateTime mDtDue; // due date of todo bool mHasDueDate; // if todo has associated due date // int mStatus; // confirmed/delegated/tentative/etc QDateTime mCompleted; bool mHasCompletedDate; int mPercentComplete; }; bool operator==( const Todo&, const Todo& ); } #endif diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index a6ae1bc..df93209 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -33,92 +33,94 @@ #include <kmessagebox.h> #include <kiconloader.h> #include <klocale.h> #include "vcc.h" #include "vobject.h" #include "vcaldrag.h" #include "calendar.h" #include "vcalformat.h" using namespace KCal; VCalFormat::VCalFormat() { mCalendar = 0; useLocalTime = false; } VCalFormat::~VCalFormat() { } void VCalFormat::setLocalTime ( bool b ) { useLocalTime = b; } bool VCalFormat::load(Calendar *calendar, const QString &fileName) { mCalendar = calendar; clearException(); + if ( ! useLocalTime ) useLocalTime = mCalendar->isLocalTime(); VObject *vcal = 0; // this is not necessarily only 1 vcal. Could be many vcals, or include // a vcard... vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); if (!vcal) { setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); return FALSE; } // any other top-level calendar stuff should be added/initialized here // put all vobjects into their proper places populate(vcal); // clean up from vcal API stuff cleanVObjects(vcal); cleanStrTbl(); return true; } bool VCalFormat::save(Calendar *calendar, const QString &fileName) { mCalendar = calendar; + if ( ! useLocalTime ) useLocalTime = mCalendar->isLocalTime(); QString tmpStr; VObject *vcal, *vo; vcal = newVObject(VCCalProp); // addPropValue(vcal,VCLocationProp, "0.0"); addPropValue(vcal,VCProdIdProp, productId()); tmpStr = mCalendar->getTimeZoneStr(); //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); addPropValue(vcal,VCVersionProp, _VCAL_VERSION); // TODO STUFF QPtrList<Todo> todoList = mCalendar->rawTodos(); QPtrListIterator<Todo> qlt(todoList); for (; qlt.current(); ++qlt) { vo = eventToVTodo(qlt.current()); addVObjectProp(vcal, vo); } // EVENT STUFF QPtrList<Event> events = mCalendar->rawEvents(); Event *ev; for(ev=events.first();ev;ev=events.next()) { vo = eventToVEvent(ev); addVObjectProp(vcal, vo); } writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); @@ -1143,98 +1145,102 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) if( index == last ) { // e.g. MD1 #0 tmpDay = anEvent->dtStart().date().day(); anEvent->recurrence()->addMonthlyDay(tmpDay); } else { // e.g. MD1 3 #0 while (index < last) { int index2 = tmpStr.find(' ', index); tmpDay = tmpStr.mid(index, (index2-index)).toShort(); index = index2-1; if (tmpStr.mid(index, 1) == "-") tmpDay = 0 - tmpDay; index += 2; // advance the index; anEvent->recurrence()->addMonthlyDay(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()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); } else { int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); if (rDuration == 0) anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); else anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); } } /*********************** YEARLY-BY-MONTH *******************************/ else if (tmpStr.left(2) == "YM") { + // 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") { + // 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; @@ -1507,69 +1513,70 @@ void VCalFormat::populate(VObject *vcal) VObject *curVO, *curVOProp; Event *anEvent; if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { char *methodType = 0; methodType = fakeCString(vObjectUStringZValue(curVO)); kdDebug() << "This calendar is an iTIP transaction of type '" << methodType << "'" << endl; delete methodType; } // warn the user that we might have trouble reading non-known calendar. if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { char *s = fakeCString(vObjectUStringZValue(curVO)); if (strcmp(productId().local8Bit(), s) != 0) kdDebug() << "This vCalendar file was not created by KOrganizer " "or any other product we support. Loading anyway..." << endl; mLoadedProductId = s; deleteStr(s); } // warn the user we might have trouble reading this unknown version. if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { char *s = fakeCString(vObjectUStringZValue(curVO)); if (strcmp(_VCAL_VERSION, s) != 0) kdDebug() << "This vCalendar file has version " << s << "We only support " << _VCAL_VERSION << endl; deleteStr(s); } // set the time zone if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { + 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(); initPropIterator(&i, vcal); // go through all the vobjects in the vcal while (moreIteration(&i)) { curVO = nextVObject(&i); /************************************************************************/ // now, check to see that the object is an event or todo. if (strcmp(vObjectName(curVO), VCEventProp) == 0) { if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { char *s; s = fakeCString(vObjectUStringZValue(curVOProp)); // check to see if event was deleted by the kpilot conduit if (atoi(s) == Event::SYNCDEL) { deleteStr(s); kdDebug(5800) << "skipping pilot-deleted event" << endl; goto SKIP; } deleteStr(s); } // this code checks to see if we are trying to read in an event // that we already find to be in the calendar. If we find this // to be the case, we skip the event. if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 8298aa6..e24ad9e 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp @@ -1,59 +1,60 @@ /* This file is part of libkdepim. Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qstring.h> #include <qapplication.h> #include <qptrlist.h> #include <qregexp.h> #include <qfile.h> +#include <qlabel.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qdir.h> #include <kmessagebox.h> #include <stdlib.h> #include "phoneaccess.h" void PhoneAccess::writeConfig( QString device, QString connection, QString model ) { #ifdef _WIN32_ QString fileName = qApp->applicationDirPath () +"\\gammurc"; #else QString fileName = QDir::homeDirPath() +"/.gammurc"; #endif //qDebug("save %d ", load ); QString content = "[gammu]\n";; bool write = false; bool addPort = true, addConnection = true, addModel = true; QFile file( fileName ); if ( QFile::exists( fileName) ) { if (!file.open( IO_ReadOnly ) ) { qDebug("Error: cannot open %s ", fileName.latin1() ); return; } QString line; while ( file.readLine( line, 1024 ) > 0 ) { //qDebug("*%s* ", line.latin1() ); if ( line.left(7 ) == "[gammu]" ) { ; } else if ( line.left(4 ) == "port" ) { if ( line == "port = " + device+"\n" ) { @@ -110,64 +111,106 @@ void PhoneAccess::writeConfig( QString device, QString connection, QString model if ( addModel ) { write = true; content += "model = "; content += model; content += "\n"; } if ( write ) { if (!file.open( IO_WriteOnly ) ) { qDebug("Error: cannot write file %s ", fileName.latin1() ); return; } qDebug("Writing file %s ", fileName.latin1() ); QTextStream ts( &file ); ts << content ; file.close(); } } bool PhoneAccess::writeToPhone( QString fileName) { #ifdef DESKTOP_VERSION #ifdef _WIN32_ QString command ="kammu --restore " + fileName ; #else QString command ="./kammu --restore " + fileName ; #endif #else QString command ="kammu --restore " + fileName ; #endif - int ret; - while ( (ret = system ( command.latin1())) != 0 ) { + 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; } bool PhoneAccess::readFromPhone( QString fileName) { #ifdef DESKTOP_VERSION #ifdef _WIN32_ QString command ="kammu --backup " + fileName + " -yes" ; #else QString command ="./kammu --backup " + fileName + " -yes" ; #endif #else QString command ="kammu --backup " + fileName + " -yes" ; #endif int ret; - while ( (ret = system ( command.latin1())) != 0 ) { + 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 @@ -52,65 +52,64 @@ KDGanttMinimizeSplitter.h \ krestrictedline.h \ krun.h \ ksimpleconfig.h \ kstaticdeleter.h \ ksystemtray.h \ ktempfile.h \ ktextedit.h \ kunload.h \ kurl.h \ kdeui/kguiitem.h \ kdeui/kcmodule.h \ kdeui/kbuttonbox.h \ kdeui/klistbox.h \ kdeui/klistview.h \ kdeui/kjanuswidget.h \ kdeui/kseparator.h \ kdeui/knuminput.h \ kdeui/knumvalidator.h \ kdeui/ksqueezedtextlabel.h \ kio/job.h \ kio/kio/kdirwatch.h \ kio/kio/kdirwatch_p.h \ kio/kfile/kurlrequester.h \ kresources/resource.h \ kresources/factory.h \ kresources/managerimpl.h \ kresources/manager.h \ kresources/selectdialog.h \ kresources/configpage.h \ kresources/configwidget.h \ kresources/configdialog.h \ kresources/kcmkresources.h \ - kresources/syncwidget.h \ kdecore/kmdcodec.h \ kdecore/kconfigbase.h \ kdecore/klocale.h \ kdecore/kcatalogue.h \ kdecore/ksharedptr.h \ kdecore/kshell.h \ kdecore/kstandarddirs.h \ kdecore/kstringhandler.h \ kdecore/kshortcut.h \ kutils/kcmultidialog.h \ kdeui/kxmlguiclient.h \ kdeui/kstdaction.h \ kdeui/kmainwindow.h \ kdeui/ktoolbar.h \ kdeui/ktoolbarbutton.h \ kdeui/ktoolbarhandler.h \ kdeui/kaction.h \ kdeui/kactionclasses.h \ kdeui/kactioncollection.h \ kdecore/kprefs.h \ kdecore/klibloader.h \ kidmanager.h # kdecore/klibloader.h \ SOURCES = \ KDGanttMinimizeSplitter.cpp \ kapplication.cpp \ kcalendarsystem.cpp \ kcalendarsystemgregorian.cpp \ @@ -131,46 +130,45 @@ KDGanttMinimizeSplitter.cpp \ ktextedit.cpp \ kprocess.cpp \ krun.cpp \ ksystemtray.cpp \ ktempfile.cpp \ kurl.cpp \ kdecore/kcatalogue.cpp \ kdecore/klocale.cpp \ kdecore/kmdcodec.cpp \ kdecore/kshell.cpp \ kdecore/kstandarddirs.cpp \ kdecore/kstringhandler.cpp \ kdeui/kbuttonbox.cpp \ kdeui/kcmodule.cpp \ kdeui/kguiitem.cpp \ kdeui/kjanuswidget.cpp \ kdeui/klistbox.cpp \ kdeui/klistview.cpp \ kdeui/knuminput.cpp \ kdeui/knumvalidator.cpp \ kdeui/kseparator.cpp \ kdeui/ksqueezedtextlabel.cpp \ kio/kio/kdirwatch.cpp \ kio/kfile/kurlrequester.cpp \ kresources/configpage.cpp \ kresources/configdialog.cpp \ kresources/configwidget.cpp \ kresources/factory.cpp \ kresources/kcmkresources.cpp \ kresources/managerimpl.cpp \ kresources/resource.cpp \ kresources/selectdialog.cpp \ - kresources/syncwidget.cpp \ kutils/kcmultidialog.cpp \ kdeui/kaction.cpp \ kdeui/kactionclasses.cpp \ kdeui/kactioncollection.cpp \ kdeui/kmainwindow.cpp \ kdeui/ktoolbar.cpp \ kdeui/ktoolbarbutton.cpp \ kdeui/ktoolbarhandler.cpp \ kdeui/kstdaction.cpp \ kdeui/kxmlguiclient.cpp \ kdecore/kprefs.cpp \ kdecore/klibloader.cpp \ kidmanager.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 @@ -1,54 +1,56 @@ #include <qcombobox.h> #include <qdir.h> #include <qhbox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qpopupmenu.h> #include <qwidgetstack.h> #include <qregexp.h> #include <qobjectlist.h> /* hacky but we need to get FileSelector::filter */ #define private public #include <qpe/fileselector.h> #undef private #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/resource.h> #include <qpe/storage.h> +#include <kglobal.h> +#include <klocale.h> #include "ofileselector_p.h" //US#include "ofileselector.h" #include "klocale.h" OFileViewInterface::OFileViewInterface( OFileSelector* selector ) : m_selector( selector ) { } OFileViewInterface::~OFileViewInterface() { } QString OFileViewInterface::name()const{ return m_name; } void OFileViewInterface::setName( const QString& name ) { m_name = name; } OFileSelector* OFileViewInterface::selector()const { return m_selector; } DocLnk OFileViewInterface::selectedDocument()const { return DocLnk( selectedName() ); } bool OFileViewInterface::showNew()const { return selector()->showNew(); } bool OFileViewInterface::showClose()const { return selector()->showClose(); } MimeTypes OFileViewInterface::mimeTypes()const { @@ -438,85 +440,86 @@ void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); } } // not locked } void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { MimeType type( info->absFilePath() ); if (!compliesMime( type.id() ) ) return; QPixmap pix = type.pixmap(); QString dir, name; bool locked; if ( pix.isNull() ) { QWMatrix matrix; QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); matrix.scale( .4, .4 ); pix = pixer.xForm( matrix ); } dir = info->dirPath( true ); locked = false; if ( symlink ) name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); else{ name = info->fileName(); if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { locked = true; pix = Resource::loadPixmap("locked"); } } (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 ) { bool locked = false; QString name; QPixmap pix; if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { locked = true; if ( symlink ) pix = Resource::loadPixmap( "symlink" ); else pix = Resource::loadPixmap( "lockedfolder" ); }else pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 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 ); } void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { } void OFileViewFileListView::cdUP() { QDir dir( m_currentDir ); dir.cdUp(); if (!dir.exists() ) m_currentDir = "/"; else m_currentDir = dir.absPath(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::cdHome() { m_currentDir = QDir::homeDirPath(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::cdDoc() { m_currentDir = QPEApplication::documentDir(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::changeDir( const QString& dir ) { m_currentDir = dir; |