author | zautrix <zautrix> | 2004-08-20 04:28:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-20 04:28:28 (UTC) |
commit | 93decd4185adc7197008e8397cf753a5ab674d99 (patch) (side-by-side diff) | |
tree | 0d701d0a687c22cfe2894121f8540d60a5fbe7a9 /libkcal/vcalformat.cpp | |
parent | f7a401f03c18ef96eb40dc5540b31cd10880e845 (diff) | |
download | kdepimpi-93decd4185adc7197008e8397cf753a5ab674d99.zip kdepimpi-93decd4185adc7197008e8397cf753a5ab674d99.tar.gz kdepimpi-93decd4185adc7197008e8397cf753a5ab674d99.tar.bz2 |
Bugfixes for syncing
-rw-r--r-- | libkcal/vcalformat.cpp | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 076cd3f..9307f12 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -302,112 +302,114 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent) // status // backward compatibility, KOrganizer used to interpret only these two values addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : "NEEDS_ACTION"); // completion date if (anEvent->hasCompletedDate()) { tmpStr = qDateTimeToISO(anEvent->completed()); addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); } // priority tmpStr.sprintf("%i",anEvent->priority()); addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); // related event if (anEvent->relatedTo()) { addPropValue(vtodo, VCRelatedToProp, anEvent->relatedTo()->uid().local8Bit()); } // categories tmpStrList = anEvent->categories(); tmpStr = ""; QString catStr; for ( QStringList::Iterator it = tmpStrList.begin(); it != tmpStrList.end(); ++it ) { catStr = *it; if (catStr[0] == ' ') tmpStr += catStr.mid(1); else tmpStr += catStr; // this must be a ';' character as the vCalendar specification requires! // vcc.y has been hacked to translate the ';' to a ',' when the vcal is // read in. tmpStr += ";"; } if (!tmpStr.isEmpty()) { tmpStr.truncate(tmpStr.length()-1); addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); } // alarm stuff kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; QPtrList<Alarm> alarms = anEvent->alarms(); Alarm* alarm; for (alarm = alarms.first(); alarm; alarm = alarms.next()) { if (alarm->enabled()) { - VObject *a = addProp(vtodo, VCDAlarmProp); - tmpStr = qDateTimeToISO(alarm->time()); - addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); - addPropValue(a, VCRepeatCountProp, "1"); - addPropValue(a, VCDisplayStringProp, "beep!"); - if (alarm->type() == Alarm::Audio) { - a = addProp(vtodo, VCAAlarmProp); - addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); - addPropValue(a, VCRepeatCountProp, "1"); - addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); - } - else if (alarm->type() == Alarm::Procedure) { - a = addProp(vtodo, VCPAlarmProp); - addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); - addPropValue(a, VCRepeatCountProp, "1"); - addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); + VObject *a; + tmpStr = qDateTimeToISO(alarm->time()); + if (alarm->type() == Alarm::Audio) { + a = addProp(vtodo, VCAAlarmProp); + addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); + addPropValue(a, VCRepeatCountProp, "1"); + addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); + } + else if (alarm->type() == Alarm::Procedure) { + a = addProp(vtodo, VCPAlarmProp); + addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); + addPropValue(a, VCRepeatCountProp, "1"); + addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); + } else { + a = addProp(vtodo, VCDAlarmProp); + addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); + addPropValue(a, VCRepeatCountProp, "1"); + addPropValue(a, VCDisplayStringProp, "beep!"); } } } if (anEvent->pilotId()) { // pilot sync stuff tmpStr.sprintf("%i",anEvent->pilotId()); addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); tmpStr.sprintf("%i",anEvent->syncStatus()); addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); } return vtodo; } VObject* VCalFormat::eventToVEvent(const Event *anEvent) { VObject *vevent; QString tmpStr; QStringList tmpStrList; vevent = newVObject(VCEventProp); // start and end time tmpStr = qDateTimeToISO(anEvent->dtStart(), !anEvent->doesFloat()); addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); // events that have time associated but take up no time should // not have both DTSTART and DTEND. if (anEvent->dtStart() != anEvent->dtEnd()) { tmpStr = qDateTimeToISO(anEvent->dtEnd(), !anEvent->doesFloat()); addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); } // creation date tmpStr = qDateTimeToISO(anEvent->created()); addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); // unique id addPropValue(vevent, VCUniqueStringProp, anEvent->uid().local8Bit()); // revision tmpStr.sprintf("%i", anEvent->revision()); addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); @@ -580,113 +582,116 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) text = "PRIVATE"; break; case Incidence::SecrecyConfidential: text = "CONFIDENTIAL"; break; } if (text) { addPropValue(vevent, VCClassProp, text); } // categories tmpStrList = anEvent->categories(); tmpStr = ""; QString catStr; for ( QStringList::Iterator it = tmpStrList.begin(); it != tmpStrList.end(); ++it ) { catStr = *it; if (catStr[0] == ' ') tmpStr += catStr.mid(1); else tmpStr += catStr; // this must be a ';' character as the vCalendar specification requires! // vcc.y has been hacked to translate the ';' to a ',' when the vcal is // read in. tmpStr += ";"; } if (!tmpStr.isEmpty()) { tmpStr.truncate(tmpStr.length()-1); addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); } // attachments // TODO: handle binary attachments! QPtrList<Attachment> attachments = anEvent->attachments(); for ( Attachment *at = attachments.first(); at; at = attachments.next() ) addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); // resources tmpStrList = anEvent->resources(); tmpStr = tmpStrList.join(";"); if (!tmpStr.isEmpty()) addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); // alarm stuff QPtrList<Alarm> alarms = anEvent->alarms(); Alarm* alarm; for (alarm = alarms.first(); alarm; alarm = alarms.next()) { - if (alarm->enabled()) { - VObject *a = addProp(vevent, VCDAlarmProp); - tmpStr = qDateTimeToISO(alarm->time()); - addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); - addPropValue(a, VCRepeatCountProp, "1"); - addPropValue(a, VCDisplayStringProp, "beep!"); - if (alarm->type() == Alarm::Audio) { - a = addProp(vevent, VCAAlarmProp); - addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); - addPropValue(a, VCRepeatCountProp, "1"); - addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); - } - if (alarm->type() == Alarm::Procedure) { - a = addProp(vevent, VCPAlarmProp); - addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); - addPropValue(a, VCRepeatCountProp, "1"); - addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); + if (alarm->enabled()) { + VObject *a ; + tmpStr = qDateTimeToISO(alarm->time()); + if (alarm->type() == Alarm::Audio) { + a = addProp(vevent, VCAAlarmProp); + addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); + addPropValue(a, VCRepeatCountProp, "1"); + addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); + } + if (alarm->type() == Alarm::Procedure) { + a = addProp(vevent, VCPAlarmProp); + addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); + addPropValue(a, VCRepeatCountProp, "1"); + addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); + } else { + a = addProp(vevent, VCDAlarmProp); + addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); + addPropValue(a, VCRepeatCountProp, "1"); + addPropValue(a, VCDisplayStringProp, "beep!"); + } } } // priority tmpStr.sprintf("%i",anEvent->priority()); addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); // transparency tmpStr.sprintf("%i",anEvent->transparency()); addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); // related event if (anEvent->relatedTo()) { addPropValue(vevent, VCRelatedToProp, anEvent->relatedTo()->uid().local8Bit()); } if (anEvent->pilotId()) { // pilot sync stuff tmpStr.sprintf("%i",anEvent->pilotId()); addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); tmpStr.sprintf("%i",anEvent->syncStatus()); addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); } return vevent; } Todo *VCalFormat::VTodoToEvent(VObject *vtodo) { VObject *vo; VObjectIterator voi; char *s; Todo *anEvent = new Todo; // creation date if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); deleteStr(s); } // unique id vo = isAPropertyOf(vtodo, VCUniqueStringProp); // while the UID property is preferred, it is not required. We'll use the // default Event UID if none is given. if (vo) { |