libkcal

alarm.h

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
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 
00023 #ifndef KCAL_ALARM_H
00024 #define KCAL_ALARM_H
00025 
00026 #include <tqstring.h>
00027 #include <tqstringlist.h>
00028 #include <tqvaluelist.h>
00029 
00030 #include "customproperties.h"
00031 #include "duration.h"
00032 #include "person.h"
00033 #include "listbase.h"
00034 #include "libkcal_export.h"
00035 
00036 #include <tdepimmacros.h>
00037 
00038 namespace KCal {
00039 
00040 class Incidence;
00041 
00045 class LIBKCAL_EXPORT Alarm : public CustomProperties
00046 {
00047   public:
00048     enum Type { Invalid, Display, Procedure, Email, Audio };
00049 
00050     typedef ListBase<Alarm> List;
00051 
00055     explicit Alarm( Incidence *parent );
00059     virtual ~Alarm();
00060 
00065     Alarm *clone();
00066 
00071     Alarm &operator=( const Alarm & );
00072 
00076     bool operator==( const Alarm & ) const;
00077     bool operator!=( const Alarm &a ) const { return !operator==( a ); }
00078 
00086     void setType( Type type );
00087 
00091     Type type() const;
00092 
00098     void setDisplayAlarm( const TQString &text = TQString() );
00099 
00104     void setText( const TQString &text );
00105 
00109     TQString text() const;
00110 
00116     void setAudioAlarm( const TQString &audioFile = TQString() );
00121     void setAudioFile( const TQString &audioFile );
00127     TQString audioFile() const;
00128 
00135     void setProcedureAlarm( const TQString &programFile,
00136                             const TQString &arguments = TQString() );
00141     void setProgramFile( const TQString &programFile );
00147     TQString programFile() const;
00152     void setProgramArguments( const TQString &arguments );
00158     TQString programArguments() const;
00159 
00168     void setEmailAlarm( const TQString &subject, const TQString &text,
00169                         const TQValueList<Person> &addressees,
00170                         const TQStringList &attachments = TQStringList() );
00171 
00176     void setMailAddress( const Person &mailAlarmAddress );
00181     void setMailAddresses( const TQValueList<Person> &mailAlarmAddresses );
00186     void addMailAddress( const Person &mailAlarmAddress );
00190     TQValueList<Person> mailAddresses() const;
00191 
00196     void setMailSubject( const TQString &mailAlarmSubject );
00200     TQString mailSubject() const;
00201 
00206     void setMailAttachment( const TQString &mailAttachFile );
00211     void setMailAttachments( const TQStringList &mailAttachFiles );
00216     void addMailAttachment( const TQString &mailAttachFile );
00220     TQStringList mailAttachments() const;
00221 
00226     void setMailText( const TQString &text );
00232     TQString mailText() const;
00233 
00237     void setTime( const TQDateTime &alarmTime );
00241     TQDateTime time() const;
00246     TQDateTime endTime() const;
00250     bool hasTime() const;
00251 
00255     void setStartOffset( const Duration & );
00261     Duration startOffset() const;
00266     bool hasStartOffset() const;
00267 
00271     void setEndOffset( const Duration & );
00277     Duration endOffset() const;
00282     bool hasEndOffset() const;
00283 
00289     void setSnoozeTime( const Duration &alarmSnoozeTime );
00290 
00296     Duration snoozeTime() const;
00297 
00302     void setRepeatCount( int alarmRepeatCount );
00306     int repeatCount() const;
00314     TQDateTime nextRepetition(const TQDateTime& preTime) const;
00322     TQDateTime previousRepetition(const TQDateTime& afterTime) const;
00327     Duration duration() const;
00328 
00333     void toggleAlarm();
00334 
00338     void setEnabled(bool enable);
00342     bool enabled() const;
00343 
00347     void setParent( Incidence * );
00351     Incidence *parent() const  { return mParent; }
00352 
00353   protected:
00358     virtual void customPropertyUpdated();
00359 
00360   private:
00361     Incidence *mParent;          // the incidence which this alarm belongs to
00362     Type mType;                  // type of alarm
00363     TQString mDescription;        // text to display/email body/procedure arguments
00364     TQString mFile;               // procedure program to run/optional audio file to play
00365     TQStringList mMailAttachFiles;      // filenames to attach to email
00366     TQValueList<Person> mMailAddresses; // who to mail for reminder
00367     TQString mMailSubject;        // subject of email
00368 
00369     Duration mAlarmSnoozeTime;   // how long after alarm to snooze before
00370                                  // triggering again
00371     int mAlarmRepeatCount;       // number of times for alarm to repeat
00372                                  // after the initial time
00373 
00374     TQDateTime mAlarmTime;        // time at which to trigger the alarm
00375     Duration mOffset;            // time relative to incidence DTSTART to trigger the alarm
00376     bool mEndOffset;             // if true, mOffset relates to DTEND, not DTSTART
00377     bool mHasTime;               // use mAlarmTime, not mOffset
00378     bool mAlarmEnabled;
00379 
00380     class Private;
00381     Private *d;
00382 };
00383 
00384 }
00385 
00386 #endif