kalarmd Library API Documentation

adcalendarbase.h

00001 /*
00002     Calendar access for KDE Alarm Daemon and KDE Alarm Daemon GUI.
00003 
00004     This file is part of the KDE alarm daemon.
00005     Copyright (c) 2001 David Jarvie <software@astrojar.org.uk>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program 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
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #ifndef ADCALENDARBASE_H
00027 #define ADCALENDARBASE_H
00028 
00029 #include <libkcal/calendarlocal.h>
00030 
00031 #include "compat.h"
00032 
00033 using namespace KCal;
00034 
00035 // Base class for Alarm Daemon calendar access
00036 class ADCalendarBase : public CalendarLocal
00037 {
00038   public:
00039     enum Type { KORGANIZER = 0, KALARM = 1 };
00040     ADCalendarBase(const QString& url, const QCString& appname, Type);
00041     ~ADCalendarBase()  { }
00042 
00043     const QString&   urlString() const   { return mUrlString; }
00044     const QCString&  appName() const     { return mAppName; }
00045     int              rcIndex() const     { return mRcIndex; }
00046     const QDateTime& lastCheck() const   { return mLastCheck; }
00047     bool             loaded() const      { return mLoaded; }
00048     Type             actionType() const  { return mActionType; }
00049 
00050     virtual void setEnabled( bool ) = 0;
00051     virtual bool enabled() const = 0;
00052 
00053     virtual void setAvailable( bool ) = 0;
00054     virtual bool available() const = 0;
00055 
00056     // client has registered since calendar was
00057     // constructed, but has not since added the
00058     // calendar. Monitoring is disabled.
00059     void setUnregistered( bool u ) { mUnregistered = u; }
00060     bool unregistered() const { return mUnregistered; }
00061 
00062     virtual bool loadFile() = 0;
00063 
00064     void         setRcIndex(int i)                  { mRcIndex = i; }
00065     void         setLastCheck(const QDateTime& dt)  { mLastCheck = dt; }
00066 
00067     virtual void setEventHandled(const Event*, const QValueList<QDateTime> &) = 0;
00068     virtual bool eventHandled(const Event*, const QValueList<QDateTime> &) = 0;
00069 
00070     void dump() const;
00071 
00072   protected:
00073     bool            loadFile_(const QCString& appName);
00074 
00075   private:
00076     ADCalendarBase(const ADCalendarBase&);             // prohibit copying
00077     ADCalendarBase& operator=(const ADCalendarBase&);  // prohibit copying
00078 
00079   protected:
00080     struct EventItem
00081     {
00082       EventItem() : eventSequence(0) { }
00083       EventItem(const QString& url, int seqno, const QValueList<QDateTime>& alarmtimes)
00084         : calendarURL(url), eventSequence(seqno), alarmTimes(alarmtimes) {}
00085 
00086       QString   calendarURL;
00087       int       eventSequence;
00088       QValueList<QDateTime> alarmTimes;
00089     };
00090 
00091     typedef QMap<QString, EventItem>  EventsMap;   // event ID, calendar URL/event sequence num
00092     static EventsMap  eventsHandled_; // IDs of displayed KALARM type events
00093 
00094   private:
00095     QString           mUrlString;     // calendar file URL
00096     QCString          mAppName;       // name of application owning this calendar
00097     Type              mActionType;    // action to take on event
00098     QDateTime         mLastCheck;     // time at which calendar was last checked for alarms
00099     int               mRcIndex;       // index within 'clients' RC file for this calendar's entry
00100     bool              mLoaded;        // true if calendar file is currently loaded
00101     bool              mUnregistered;  // client has registered, but has not since added the calendar
00102 };
00103 
00104 typedef QPtrList<ADCalendarBase> CalendarList;
00105 
00106 class ADCalendarBaseFactory
00107 {
00108   public:
00109     virtual ADCalendarBase *create(const QString& url, const QCString& appname, ADCalendarBase::Type) = 0;
00110 };
00111 
00112 
00113 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:55 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001