icalformatimpl.h
00001 /* 00002 This file is part of libkcal. 00003 00004 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 #ifndef KCAL_ICALFORMATIMPL_H 00023 #define KCAL_ICALFORMATIMPL_H 00024 00025 #include <tqstring.h> 00026 #include <tqdict.h> 00027 00028 #include "scheduler.h" 00029 #include "freebusy.h" 00030 00031 00032 extern "C" { 00033 #include <libical/ical.h> 00034 } 00035 00036 namespace KCal { 00037 00038 class Compat; 00039 00045 class ICalFormatImpl 00046 { 00047 public: 00049 ICalFormatImpl( ICalFormat *parent ); 00050 virtual ~ICalFormatImpl(); 00051 00052 bool populate( Calendar *, icalcomponent *fs); 00053 00054 icalcomponent *writeIncidence(IncidenceBase *incidence, Scheduler::Method method = Scheduler::Request ); 00055 icalcomponent *writeTodo(Todo *todo); 00056 icalcomponent *writeEvent(Event *event); 00057 icalcomponent *writeFreeBusy(FreeBusy *freebusy, 00058 Scheduler::Method method = Scheduler::Publish ); 00059 icalcomponent *writeJournal(Journal *journal); 00060 void writeIncidence(icalcomponent *parent,Incidence *incidence); 00061 icalproperty *writeAttendee(Attendee *attendee); 00062 icalproperty *writeOrganizer( const Person &organizer ); 00063 icalproperty *writeAttachment(Attachment *attach); 00064 icalproperty *writeRecurrenceRule(Recurrence *); 00065 icalrecurrencetype writeRecurrenceRule( RecurrenceRule *recur ); 00066 icalcomponent *writeAlarm(Alarm *alarm); 00067 00068 TQString extractErrorProperty(icalcomponent *); 00069 Todo *readTodo(icalcomponent *vtodo); 00070 Event *readEvent(icalcomponent *vevent, icalcomponent *vtimezone); 00071 FreeBusy *readFreeBusy(icalcomponent *vfreebusy); 00072 Journal *readJournal(icalcomponent *vjournal); 00073 Attendee *readAttendee(icalproperty *attendee); 00074 Person readOrganizer( icalproperty *organizer ); 00075 Attachment *readAttachment(icalproperty *attach); 00076 void readIncidence(icalcomponent *parent, icaltimezone *timezone, Incidence *incidence); 00077 void readRecurrenceRule(icalproperty *rrule,Incidence *event ); 00078 void readExceptionRule( icalproperty *rrule, Incidence *incidence ); 00079 void readRecurrence( const struct icalrecurrencetype &r, RecurrenceRule* recur ); 00080 void readAlarm(icalcomponent *alarm,Incidence *incidence); 00082 const TQString &loadedProductId() { return mLoadedProductId; } 00083 00084 static icaltimetype writeICalDate(const TQDate &); 00085 static TQDate readICalDate(icaltimetype); 00086 icaltimetype writeICalDateTime(const TQDateTime &); 00087 TQDateTime readICalDateTime( icalproperty*, icaltimetype&, icaltimezone* tz = 0 ); 00088 static icaldurationtype writeICalDuration(int seconds); 00089 static int readICalDuration(icaldurationtype); 00090 static icaldatetimeperiodtype writeICalDatePeriod( const TQDate &date ); 00091 icaldatetimeperiodtype writeICalDateTimePeriod( const TQDateTime &date ); 00092 00093 icalcomponent *createCalendarComponent(Calendar * = 0); 00094 icalcomponent *createScheduleComponent(IncidenceBase *,Scheduler::Method); 00095 00096 protected: 00097 void dumpIcalRecurrence(icalrecurrencetype); 00098 private: 00099 void writeIncidenceBase(icalcomponent *parent,IncidenceBase *); 00100 void readIncidenceBase(icalcomponent *parent, IncidenceBase *); 00101 void writeCustomProperties(icalcomponent *parent,CustomProperties *); 00102 void readCustomProperties(icalcomponent *parent,CustomProperties *); 00103 void readTimezone(icalcomponent *vtimezone); 00104 00105 ICalFormat *mParent; 00106 Calendar *mCalendar; 00107 00108 TQString mLoadedProductId; // PRODID string loaded from calendar file 00109 00110 Event::List mEventsRelate; // events with relations 00111 Todo::List mTodosRelate; // todos with relations 00112 00113 static const int mSecondsPerWeek; 00114 static const int mSecondsPerDay; 00115 static const int mSecondsPerHour; 00116 static const int mSecondsPerMinute; 00117 00118 Compat *mCompat; 00119 00120 class ToComponentVisitor; 00121 class Private; 00122 Private *d; 00123 }; 00124 00125 } 00126 00127 #endif