exchangecalendar.h
00001 /* 00002 This file is part of libkpimexchange. 00003 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 00004 00005 This library is free software; you can redistribute it and/or modify it 00006 under the terms of the GNU Library General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or (at your 00008 option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, but WITHOUT 00011 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to the 00017 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00018 02111-1307, USA. 00019 */ 00020 #ifndef KPIM_EXCHANGECALENDAR_H 00021 #define KPIM_EXCHANGECALENDAR_H 00022 00023 #include <qmap.h> 00024 #include <libkcal/calendar.h> 00025 #include <libkcal/calendarlocal.h> 00026 00027 class DateSet; 00028 00029 namespace KPIM { 00030 class ExchangeAccount; 00031 class ExchangeClient; 00032 } 00033 00034 namespace KCal { 00035 class Event; 00036 } 00037 00038 namespace KCal { 00039 00040 class CalFormat; 00041 00045 class ExchangeCalendar : public Calendar, public IncidenceBase::Observer 00046 { 00047 public: 00049 ExchangeCalendar( KPIM::ExchangeAccount* account ); 00051 ExchangeCalendar( KPIM::ExchangeAccount* account, const QString &timeZoneId ); 00052 virtual ~ExchangeCalendar(); 00053 00061 bool load( const QString &fileName ); 00068 bool save( const QString &fileName, CalFormat *format = 0 ); 00069 00071 void close(); 00072 00074 void addEvent(Event *anEvent); 00076 void deleteEvent(Event *); 00077 00081 Event *event(const QString &UniqueStr); 00085 // QPtrList<Event> events(); 00090 QPtrList<Event> rawEvents(); 00091 00092 /* 00093 Returns a QString with the text of the holiday (if any) that falls 00094 on the specified date. 00095 */ 00096 QString getHolidayForDate(const QDate &qd); 00097 00101 void addTodo( Todo *todo ); 00105 void deleteTodo( Todo * ); 00110 Todo *todo( const QString &uid ); 00114 QPtrList<Todo> rawTodos() const; 00118 QPtrList<Todo> todos( const QDate &date ); 00124 QPtrList<Todo> todos() { return Calendar::todos(); } 00125 00127 virtual void addJournal(Journal *); 00129 virtual Journal *journal(const QDate &); 00131 virtual Journal *journal(const QString &UID); 00133 QPtrList<Journal> journals(); 00134 00136 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 00137 00139 Alarm::List alarmsTo( const QDateTime &to ); 00140 00141 protected: 00146 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 00150 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 00155 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 00156 bool inclusive = false ); 00157 00161 void update(IncidenceBase *incidence); 00162 00164 void incidenceUpdated( IncidenceBase *i ) { mCache->update( i ); update( i ); } 00165 00167 void insertEvent(const Event *anEvent); 00168 00170 // void appendAlarms( Alarm::List &alarms, Incidence *incidence, 00171 // const QDateTime &from, const QDateTime &to ); 00172 00174 // void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 00175 // const QDateTime &from, const QDateTime &to ); 00176 00177 private: 00178 void init( KPIM::ExchangeAccount* account ); 00179 00180 KPIM::ExchangeAccount* mAccount; 00181 KPIM::ExchangeClient* mClient; 00182 CalendarLocal* mCache; 00183 DateSet* mDates; 00184 QMap<Event, QDateTime>* mEventDates; 00185 QMap<QDate, QDateTime>* mCacheDates; 00186 int mCachedSeconds; 00187 }; 00188 00189 } 00190 00191 #endif