1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
/*
This file is part of libkcal.
Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KCAL_ALARM_H
#define KCAL_ALARM_H
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqvaluelist.h>
#include "customproperties.h"
#include "duration.h"
#include "person.h"
#include "listbase.h"
#include "libkcal_export.h"
#include <kdepimmacros.h>
namespace KCal {
class Incidence;
/**
This class represents an alarm notification.
*/
class LIBKCAL_EXPORT Alarm : public CustomProperties
{
public:
enum Type { Invalid, Display, Procedure, Email, Audio };
typedef ListBase<Alarm> List;
/**
Construct a new alarm with variables initialized to "sane" values.
*/
explicit Alarm( Incidence *parent );
/**
Destruct Alarm object.
*/
~Alarm();
/**
Compare this alarm with another one.
*/
bool operator==( const Alarm & ) const;
bool operator!=( const Alarm &a ) const { return !operator==( a ); }
/**
Set the type of the alarm.
If the specified type is different from the current type of the alarm,
the alarm's type-specific properties are initialised to null.
@param type type of alarm.
*/
void setType( Type type );
/**
Return the type of the alarm.
*/
Type type() const;
/**
Set the alarm to be a display alarm.
@param text text to display when the alarm is triggered.
*/
void setDisplayAlarm( const TQString &text = TQString::null );
/**
Set the text to be displayed when the alarm is triggered.
Ignored if the alarm is not a display alarm.
*/
void setText( const TQString &text );
/**
Return the text string that displays when the alarm is triggered.
*/
TQString text() const;
/**
Set the alarm to be an audio alarm.
@param audioFile optional file to play when the alarm is triggered.
*/
void setAudioAlarm( const TQString &audioFile = TQString::null );
/**
Set the file to play when the audio alarm is triggered.
Ignored if the alarm is not an audio alarm.
*/
void setAudioFile( const TQString &audioFile );
/**
Return the name of the audio file for the alarm.
@return The audio file for the alarm, or TQString::null if not an audio alarm.
*/
TQString audioFile() const;
/**
Set the alarm to be a procedure alarm.
@param programFile program to execute when the alarm is triggered.
@param arguments arguments to supply to programFile.
*/
void setProcedureAlarm( const TQString &programFile,
const TQString &arguments = TQString::null );
/**
Set the program file to execute when the alarm is triggered.
Ignored if the alarm is not a procedure alarm.
*/
void setProgramFile( const TQString &programFile );
/**
Return the name of the program file to execute when the alarm is triggered.
@return the program file name, or TQString::null if not a procedure alarm.
*/
TQString programFile() const;
/**
Set the arguments to the program to execute when the alarm is triggered.
Ignored if the alarm is not a procedure alarm.
*/
void setProgramArguments( const TQString &arguments );
/**
Return the arguments to the program to run when the alarm is triggered.
@return the program arguments, or TQString::null if not a procedure alarm.
*/
TQString programArguments() const;
/**
Set the alarm to be an email alarm.
@param subject subject line of email.
@param text body of email.
@param addressees email addresses of recipient(s).
@param attachments optional names of files to attach to the email.
*/
void setEmailAlarm( const TQString &subject, const TQString &text,
const TQValueList<Person> &addressees,
const TQStringList &attachments = TQStringList() );
/**
Send mail to this address when the alarm is triggered.
Ignored if the alarm is not an email alarm.
*/
void setMailAddress( const Person &mailAlarmAddress );
/**
Send mail to these addresses when the alarm is triggered.
Ignored if the alarm is not an email alarm.
*/
void setMailAddresses( const TQValueList<Person> &mailAlarmAddresses );
/**
Add this address to the list of addresses to send mail to when the alarm is triggered.
Ignored if the alarm is not an email alarm.
*/
void addMailAddress( const Person &mailAlarmAddress );
/**
Return the addresses to send mail to when an alarm goes off.
*/
TQValueList<Person> mailAddresses() const;
/**
Set the subject line of the mail.
Ignored if the alarm is not an email alarm.
*/
void setMailSubject( const TQString &mailAlarmSubject );
/**
Return the subject line of the mail.
*/
TQString mailSubject() const;
/**
Attach this filename to the email.
Ignored if the alarm is not an email alarm.
*/
void setMailAttachment( const TQString &mailAttachFile );
/**
Attach these filenames to the email.
Ignored if the alarm is not an email alarm.
*/
void setMailAttachments( const TQStringList &mailAttachFiles );
/**
Add this filename to the list of files to attach to the email.
Ignored if the alarm is not an email alarm.
*/
void addMailAttachment( const TQString &mailAttachFile );
/**
Return the filenames to attach to the email.
*/
TQStringList mailAttachments() const;
/**
Set the email body text.
Ignored if the alarm is not an email alarm.
*/
void setMailText( const TQString &text );
/**
Return the email body text.
@return the body text, or TQString::null if not an email alarm.
*/
TQString mailText() const;
/**
Set the time to trigger an alarm.
*/
void setTime( const TQDateTime &alarmTime );
/**
Return the date/time when an alarm goes off.
*/
TQDateTime time() const;
/**
Return the date/time when the last repetition of the alarm goes off.
If the alarm does not repeat, this is equivalent to calling time().
*/
TQDateTime endTime() const;
/**
Return true, if the alarm has an explicit date/time.
*/
bool hasTime() const;
/**
Set offset of alarm in time relative to the start of the event.
*/
void setStartOffset( const Duration & );
/**
Return offset of alarm in time relative to the start of the event.
If the alarm's time is not defined in terms of an offset relative
to the start of the event, returns zero.
*/
Duration startOffset() const;
/**
Return whether the alarm is defined in terms of an offset relative
to the start of the event.
*/
bool hasStartOffset() const;
/**
Set offset of alarm in time relative to the end of the event.
*/
void setEndOffset( const Duration & );
/**
Return offset of alarm in time relative to the end of the event.
If the alarm's time is not defined in terms of an offset relative
to the end of the event, returns zero.
*/
Duration endOffset() const;
/**
Return whether the alarm is defined in terms of an offset relative
to the end of the event.
*/
bool hasEndOffset() const;
/**
Set the interval between snoozes for the alarm.
@param alarmSnoozeTime the time in minutes between snoozes.
*/
void setSnoozeTime( int alarmSnoozeTime );
/**
Get how long the alarm snooze interval is.
@return the number of minutes between snoozes.
*/
int snoozeTime() const;
/**
Set how many times an alarm is to repeat itself after its initial
occurrence (w/snoozes).
*/
void setRepeatCount( int alarmRepeatCount );
/**
Get how many times an alarm repeats, after its initial occurrence.
*/
int repeatCount() const;
/**
Get the time of the alarm's initial occurrence or its next repetition,
after a given time.
@param preTime the date and time after which to find the next repetition.
@return the date and time of the next repetition, or an invalid date/time if
the specified time is at or after the alarm's last repetition.
*/
TQDateTime nextRepetition(const TQDateTime& preTime) const;
/**
Get the time of the alarm's latest repetition, or its initial occurrence if
none, before a given time.
@param afterTime the date and time before which to find the latest repetition.
@return the date and time of the latest repetition, or an invalid date/time if
the specified time is at or before the alarm's initial occurrence.
*/
TQDateTime previousRepetition(const TQDateTime& afterTime) const;
/**
Get how long between the alarm's initial occurrence and its final repetition.
@return the number of seconds between the initial occurrence and final repetition.
*/
int duration() const;
/**
Toggles the value of alarm to be either on or off.
Set's the alarm time to be x minutes before dtStart time.
*/
void toggleAlarm();
/**
Set the alarm enabled status.
*/
void setEnabled(bool enable);
/**
Get the alarm enabled status.
*/
bool enabled() const;
/**
Set the alarm's parent incidence.
*/
void setParent( Incidence * );
/**
Get the alarm's parent incidence.
*/
Incidence *parent() const { return mParent; }
protected:
/**
@copydoc
CustomProperties::customPropertyUpdated()
*/
virtual void customPropertyUpdated();
private:
Incidence *mParent; // the incidence which this alarm belongs to
Type mType; // type of alarm
TQString mDescription; // text to display/email body/procedure arguments
TQString mFile; // procedure program to run/optional audio file to play
TQStringList mMailAttachFiles; // filenames to attach to email
TQValueList<Person> mMailAddresses; // who to mail for reminder
TQString mMailSubject; // subject of email
int mAlarmSnoozeTime; // number of minutes after alarm to
// snooze before ringing again
int mAlarmRepeatCount; // number of times for alarm to repeat
// after the initial time
TQDateTime mAlarmTime; // time at which to trigger the alarm
Duration mOffset; // time relative to incidence DTSTART to trigger the alarm
bool mEndOffset; // if true, mOffset relates to DTEND, not DTSTART
bool mHasTime; // use mAlarmTime, not mOffset
bool mAlarmEnabled;
class Private;
Private *d;
};
}
#endif
|