KTnef

ktnefwriter.h
Go to the documentation of this file.
1/*
2 ktnefwriter.cpp
3
4 SPDX-FileCopyrightText: 2002 Bo Thorsen <bo@sonofthor.dk>
5
6 This file is part of KTNEF, the KDE TNEF support library/program.
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10/**
11 * @file
12 * This file is part of the API for handling TNEF data and
13 * defines the KTNEFWriter class.
14 *
15 * @author Bo Thorsen
16 */
17
18#pragma once
19#include <QStringList>
20
21#include "ktnef_export.h"
22#include <memory>
23#include <qglobal.h>
24
25class QString;
26class QVariant;
27class QIODevice;
28class QDataStream;
29class QDateTime;
30
31namespace KTnef
32{
33class KTNEFWriterPrivateData;
34/**
35 * @brief
36 * Manages the writing of @acronym TNEF attachments.
37 */
38class KTNEF_EXPORT KTNEFWriter
39{
40public:
41 /**
42 * The different types of messages.
43 */
45 Appointment, /**< Appointment */
46 MeetingCancelled, /**< The meeting is cancelled */
47 MeetingRequest, /**< Meeting request */
48 MeetingNo, /**< Negative response to a meeting request */
49 MeetingYes, /**< Affirmative response to a meeting request */
50 MeetingTent /**< Tentative affirmative to a meeting request */
51 };
52
53 /**
54 * The different types of message statuses.
55 */
56 enum Method {
57 PublishNew, /**< Publish new */
58 Obsolete, /**< Replace the message */
59 RequestNew, /**< Request a new message */
60 RequestUpdate, /**< Request an update */
61 Unknown /**< Unknown */
62 };
63
64 /**
65 * The different types of meeting roles.
66 */
67 enum Role {
68 ReqParticipant, /**< Required participant */
69 OptParticipant, /**< Optional participant */
70 NonParticipant, /**< Non-participant */
71 Chair /**< Meeting chairperson */
72 };
73
74 /**
75 * The different types of participant statuses.
76 */
77 enum PartStat {
78 NeedsAction, /**< No information about the task/invitation received */
79 Accepted, /**< Accepted the task/invitation */
80 Declined, /**< Declined the task/invitation */
81 Tentative, /**< Tentatively accepted the task/invitation */
82 Delegated, /**< Delegated the task to another */
83 Completed, /**< Completed the task */
84 InProcess /**< Work on the task is in-progress */
85 };
86
87 /**
88 * The different priorities.
89 */
90 enum Priority {
91 High = 2, /**< High priority task */
92 Normal = 3, /**< Normal priority task */
93 Low = 1 /**< Low priority task */
94 };
95
96 /**
97 * The different alarm actions.
98 */
100 Display /**< Display the alarm */
101 };
102
103 /**
104 * Constructs a @acronym TNEF writer object.
105 */
106 KTNEFWriter();
107
108 /**
109 * Destroys the @acronym TNEF writer object.
110 */
112
113 /**
114 * Adds a @acronym TNEF property.
115 *
116 * @param tag is the @acronym TNEF tag
117 * @param type is the property type
118 * @param value is the property value
119 */
120 void addProperty(int tag, int type, const QVariant &value);
121
122 /**
123 * Writes a @acronym TNEF property to the #QDataStream specified by @p stream.
124 *
125 * A @acronym TNEF property has a 1 byte type (LVL_MESSAGE or LVL_ATTACHMENT),
126 * a 4 byte type/tag, a 4 byte length, the data and finally the checksum.
127 *
128 * The checksum is a 16 byte int with all bytes in the data added.
129 *
130 * @param stream is the #QDataStream to write
131 * @param bytes is a pointer to an int type that will contain
132 * the number of bytes written to the @p stream
133 * @param tag is the @acronym TNEF tag
134 *
135 * @return false if an invalid @acronym TNEF tag was specified by @p tag or
136 * if there are no properties to write; else true.
137 */
138 [[nodiscard]] bool writeProperty(QDataStream &stream, int &bytes, int tag) const;
139
140 /**
141 * Writes the attachment to the #QIODevice specified by @p file.
142 *
143 * @param file is the #QIODevice to write.
144 * @return true if the write was successful; otherwise false.
145 */
146 [[nodiscard]] bool writeFile(QIODevice &file) const;
147
148 /**
149 * Writes the attachment to the #QDataStream specified by @p stream.
150 *
151 * @param stream is the #QDataStream to write.
152 * @return true if the write was successful; otherwise false.
153 */
154 [[nodiscard]] bool writeFile(QDataStream &stream) const;
155
156 /**
157 * Sets the sender's @p name and @p email address.
158 *
159 * @param name is the sender's name.
160 * @param email is the sender's email address.
161 */
162 void setSender(const QString &name, const QString &email);
163
164 /**
165 * Sets the #MessageType to @p methodType.
166 *
167 * @param methodType is the #MessageType.
168 */
169 void setMessageType(MessageType methodType);
170
171 /**
172 * Sets the #Method to @p method.
173 *
174 * @param method is the #Method.
175 */
176 void setMethod(Method method);
177
178 /**
179 * Clears the attendees list.
180 */
181 void clearAttendees();
182
183 /**
184 * Adds a meeting participant (attendee).
185 *
186 * @param name is the name of the attendee
187 * @param role is the #Role of the attendee
188 * @param partstat is the status #PartStat of the attendee
189 * @param rsvp is true if the attendee will attend the meeting; else false
190 * @param email is the email address of the attendee
191 */
192 void addAttendee(const QString &name, Role role, PartStat partstat, bool rsvp, const QString &email);
193
194 /**
195 * Sets the name of the organizer to @p organizer.
196 * The organizer is any string identifier; it could be the name
197 * of a person, or the application that sent the invitation, for example.
198 *
199 * @param organizer is the organizer identifier.
200 */
201 void setOrganizer(const QString &organizer);
202
203 /**
204 * Sets the Starting Date and Time to @p dtStart.
205 *
206 * @param dtStart is the starting date/time.
207 */
208 void setDtStart(const QDateTime &dtStart);
209
210 /**
211 * Sets the Ending Date and Time to @p dtEnd.
212 *
213 * @param dtEnd is the ending date/time.
214 */
215 void setDtEnd(const QDateTime &dtEnd);
216
217 /**
218 * Sets the Location to @p location.
219 *
220 * @param location is the location.
221 */
222 void setLocation(const QString &location);
223
224 /**
225 * Sets the @acronym UID to @p uid.
226 *
227 * @param uid is the @acronym UID.
228 */
229 void setUID(const QString &uid);
230
231 /**
232 * Sets the timestamp to @p dtStamp.
233 *
234 * @param dtStamp is the timestamp.
235 */
236 void setDtStamp(const QDateTime &dtStamp);
237
238 /**
239 * Sets the category list to @p categories.
240 *
241 * @param categories is the list categories.
242 */
243 void setCategories(const QStringList &categories);
244
245 /**
246 * Sets the description to @p description.
247 *
248 * @param description is the description.
249 */
250 void setDescription(const QString &description);
251
252 /**
253 * Sets the summary to @p summary.
254 *
255 * @param summary is the summary.
256 */
257 void setSummary(const QString &summary);
258
259 /**
260 * Sets the priority to @p priority.
261 *
262 * @param priority is the #Priority.
263 */
264 void setPriority(Priority priority);
265
266 /**
267 * Sets the alarm.
268 *
269 * @param description is the alarm description
270 * @param action is the alaram #AlarmAction
271 * @param wakeBefore is the alarm Date/Time
272 */
273 void setAlarm(const QString &description, AlarmAction action, const QDateTime &wakeBefore);
274
275private:
276 //@cond PRIVATE
277 std::unique_ptr<KTNEFWriterPrivateData> const d;
278 //@endcond
279
280 Q_DISABLE_COPY(KTNEFWriter)
281};
282
283}
Manages the writing of TNEF attachments.
Definition ktnefwriter.h:39
AlarmAction
The different alarm actions.
Definition ktnefwriter.h:99
Role
The different types of meeting roles.
Definition ktnefwriter.h:67
@ OptParticipant
Optional participant.
Definition ktnefwriter.h:69
@ ReqParticipant
Required participant.
Definition ktnefwriter.h:68
@ NonParticipant
Non-participant.
Definition ktnefwriter.h:70
MessageType
The different types of messages.
Definition ktnefwriter.h:44
@ MeetingNo
Negative response to a meeting request.
Definition ktnefwriter.h:48
@ MeetingRequest
Meeting request.
Definition ktnefwriter.h:47
@ Appointment
Appointment.
Definition ktnefwriter.h:45
@ MeetingYes
Affirmative response to a meeting request.
Definition ktnefwriter.h:49
@ MeetingCancelled
The meeting is cancelled.
Definition ktnefwriter.h:46
Priority
The different priorities.
Definition ktnefwriter.h:90
~KTNEFWriter()
Destroys the TNEF writer object.
Method
The different types of message statuses.
Definition ktnefwriter.h:56
@ RequestNew
Request a new message.
Definition ktnefwriter.h:59
@ RequestUpdate
Request an update.
Definition ktnefwriter.h:60
@ PublishNew
Publish new.
Definition ktnefwriter.h:57
@ Obsolete
Replace the message.
Definition ktnefwriter.h:58
PartStat
The different types of participant statuses.
Definition ktnefwriter.h:77
@ Declined
Declined the task/invitation.
Definition ktnefwriter.h:80
@ Completed
Completed the task.
Definition ktnefwriter.h:83
@ Accepted
Accepted the task/invitation.
Definition ktnefwriter.h:79
@ Tentative
Tentatively accepted the task/invitation.
Definition ktnefwriter.h:81
@ NeedsAction
No information about the task/invitation received.
Definition ktnefwriter.h:78
@ Delegated
Delegated the task to another.
Definition ktnefwriter.h:82
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.