summaryrefslogtreecommitdiffabout
path: root/libkcal/icalformat.cpp
authorzautrix <zautrix>2005-06-08 10:34:22 (UTC)
committer zautrix <zautrix>2005-06-08 10:34:22 (UTC)
commit793d117812b4da36c9c11d90cccba347cbc6e208 (patch) (side-by-side diff)
tree5bc77e2b7a32a541c2a3b3c3d6d50f873216deef /libkcal/icalformat.cpp
parent39d84e2fc3099bd5d7596e8be5dc6783826cec01 (diff)
downloadkdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.zip
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.gz
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.bz2
changed incidence type to a faster access method
Diffstat (limited to 'libkcal/icalformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/icalformat.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index 3a2aac6..d9fe40b 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -259,202 +259,202 @@ QString ICalFormat::toString( Recurrence *recurrence )
icalproperty_free( property );
return QString::fromLocal8Bit( text );
}
/*
bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule )
{
bool success = true;
icalerror_clear_errno();
struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule );
if ( icalerrno != ICAL_NO_ERROR ) {
kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl;
success = false;
}
if ( success ) {
mImpl->readRecurrence( recur, recurrence );
}
return success;
}
*/
QString ICalFormat::createScheduleMessage(IncidenceBase *incidence,
Scheduler::Method method)
{
icalcomponent *message = mImpl->createScheduleComponent(incidence,method);
QString messageText = icalcomponent_as_ical_string(message);
return messageText;
}
ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal,
const QString &messageText )
{
setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
clearException();
if (messageText.isEmpty()) return 0;
icalcomponent *message;
message = icalparser_parse_string(messageText.local8Bit());
if (!message) return 0;
icalproperty *m = icalcomponent_get_first_property(message,
ICAL_METHOD_PROPERTY);
if (!m) return 0;
icalcomponent *c;
IncidenceBase *incidence = 0;
c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT);
if (c) {
incidence = mImpl->readEvent(c);
}
if (!incidence) {
c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT);
if (c) {
incidence = mImpl->readTodo(c);
}
}
if (!incidence) {
c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT);
if (c) {
incidence = mImpl->readFreeBusy(c);
}
}
if (!incidence) {
kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl;
return 0;
}
kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl;
icalproperty_method icalmethod = icalproperty_get_method(m);
Scheduler::Method method;
switch (icalmethod) {
case ICAL_METHOD_PUBLISH:
method = Scheduler::Publish;
break;
case ICAL_METHOD_REQUEST:
method = Scheduler::Request;
break;
case ICAL_METHOD_REFRESH:
method = Scheduler::Refresh;
break;
case ICAL_METHOD_CANCEL:
method = Scheduler::Cancel;
break;
case ICAL_METHOD_ADD:
method = Scheduler::Add;
break;
case ICAL_METHOD_REPLY:
method = Scheduler::Reply;
break;
case ICAL_METHOD_COUNTER:
method = Scheduler::Counter;
break;
case ICAL_METHOD_DECLINECOUNTER:
method = Scheduler::Declinecounter;
break;
default:
method = Scheduler::NoMethod;
kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl;
break;
}
if (!icalrestriction_check(message)) {
setException(new ErrorFormat(ErrorFormat::Restriction,
Scheduler::translatedMethodName(method) + ": " +
mImpl->extractErrorProperty(c)));
return 0;
}
icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal);
Incidence *existingIncidence = cal->event(incidence->uid());
if (existingIncidence) {
// TODO: check, if cast is required, or if it can be done by virtual funcs.
- if (existingIncidence->type() == "Todo") {
+ if (existingIncidence->typeID() == todoID ) {
Todo *todo = static_cast<Todo *>(existingIncidence);
icalcomponent_add_component(calendarComponent,
mImpl->writeTodo(todo));
}
- if (existingIncidence->type() == "Event") {
+ if (existingIncidence->typeID() == eventID ) {
Event *event = static_cast<Event *>(existingIncidence);
icalcomponent_add_component(calendarComponent,
mImpl->writeEvent(event));
}
} else {
calendarComponent = 0;
}
qDebug("icalclassify commented out ");
ScheduleMessage::Status status;
#if 0
icalclass result = icalclassify(message,calendarComponent,(char *)"");
switch (result) {
case ICAL_PUBLISH_NEW_CLASS:
status = ScheduleMessage::PublishNew;
break;
case ICAL_OBSOLETE_CLASS:
status = ScheduleMessage::Obsolete;
break;
case ICAL_REQUEST_NEW_CLASS:
status = ScheduleMessage::RequestNew;
break;
case ICAL_REQUEST_UPDATE_CLASS:
status = ScheduleMessage::RequestUpdate;
break;
case ICAL_UNKNOWN_CLASS:
default:
status = ScheduleMessage::Unknown;
break;
}
#endif
status = ScheduleMessage::RequestUpdate;
return new ScheduleMessage(incidence,method,status);
}
void ICalFormat::setTimeZone( const QString &id, bool utc )
{
mTimeZoneId = id;
mUtc = utc;
tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId);
//qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin);
}
QString ICalFormat::timeZoneId() const
{
return mTimeZoneId;
}
bool ICalFormat::utc() const
{
return mUtc;
}
int ICalFormat::timeOffset()
{
return tzOffsetMin;
}
const char *ICalFormat::tzString()
{
const char* ret = (const char* ) mTzString;
return ret;
}