File indexing completed on 2024-04-21 03:52:43

0001 /*
0002   This file is part of the kcalcore library.
0003 
0004   SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <schumacher@kde.org>
0005 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 /**
0009   @file
0010   This file is part of the API for handling calendar data and
0011   defines the Attendee class.
0012 
0013   @author Cornelius Schumacher \<schumacher@kde.org\>
0014 */
0015 
0016 #ifndef KCALCORE_ATTENDEE_H
0017 #define KCALCORE_ATTENDEE_H
0018 
0019 #include <QMetaType>
0020 #include <QSharedDataPointer>
0021 
0022 #include "customproperties.h"
0023 #include "kcalendarcore_export.h"
0024 
0025 namespace KCalendarCore
0026 {
0027 /**
0028   @brief
0029   Represents information related to an attendee of an Calendar Incidence,
0030   typically a meeting or task (to-do).
0031 
0032   Attendees are people with a name and (optional) email address who are
0033   invited to participate in some way in a meeting or task.  This class
0034   also tracks that status of the invitation: accepted; tentatively accepted;
0035   declined; delegated to another person; in-progress; completed.
0036 
0037   Attendees may optionally be asked to @acronym RSVP ("Respond Please") to
0038   the invitation.
0039 
0040   Note that each attendee be can optionally associated with a @acronym UID
0041   (unique identifier) derived from a Calendar Incidence, Email Message,
0042   or any other thing you want.
0043 */
0044 class KCALENDARCORE_EXPORT Attendee
0045 {
0046     Q_GADGET
0047     Q_PROPERTY(bool isNull READ isNull)
0048     Q_PROPERTY(QString name READ name WRITE setName)
0049     Q_PROPERTY(QString fullName READ fullName)
0050     Q_PROPERTY(QString email READ email WRITE setEmail)
0051     Q_PROPERTY(Role role READ role WRITE setRole)
0052     Q_PROPERTY(QString uid READ uid WRITE setUid)
0053     Q_PROPERTY(PartStat status READ status WRITE setStatus)
0054     Q_PROPERTY(CuType cuType READ cuType WRITE setCuType)
0055     Q_PROPERTY(bool rsvp READ RSVP WRITE setRSVP)
0056     Q_PROPERTY(QString delegate READ delegate WRITE setDelegate)
0057     Q_PROPERTY(QString delegator READ delegator WRITE setDelegator)
0058 
0059 public:
0060     /**
0061       The different types of participant status.
0062       The meaning is specific to the incidence type in context.
0063     */
0064     enum PartStat {
0065         NeedsAction, /**< Event, to-do or journal needs action (default) */
0066         Accepted, /**< Event, to-do or journal accepted */
0067         Declined, /**< Event, to-do or journal declined */
0068         Tentative, /**< Event or to-do tentatively accepted */
0069         Delegated, /**< Event or to-do delegated */
0070         Completed, /**< To-do completed */
0071         InProcess, /**< To-do in process of being completed */
0072         None,
0073     };
0074     Q_ENUM(PartStat)
0075 
0076     /**
0077       The different types of participation roles.
0078     */
0079     enum Role {
0080         ReqParticipant, /**< Participation is required (default) */
0081         OptParticipant, /**< Participation is optional */
0082         NonParticipant, /**< Non-Participant; copied for information purposes */
0083         Chair, /**< Chairperson */
0084     };
0085     Q_ENUM(Role)
0086 
0087     /**
0088      * The different types of a participant.
0089      *
0090      * @since 4.14
0091      */
0092     enum CuType {
0093         Individual, /**< An individual (default) */
0094         Group, /**< A group of individuals */
0095         Resource, /**< A physical resource */
0096         Room, /**< A room resource */
0097         Unknown, /**< Otherwise not known */
0098         /**
0099          * Parameters that have to set via the QString variant of @setCuType() and @cuType()
0100          * x-name         ; Experimental cuType
0101          * iana-token     ; Other IANA-registered
0102          */
0103     };
0104     Q_ENUM(CuType)
0105 
0106     /**
0107       List of attendees.
0108     */
0109     typedef QList<Attendee> List;
0110 
0111     /** Create a null Attendee. */
0112     Attendee();
0113 
0114     /**
0115       Constructs an attendee consisting of a person name (@p name) and
0116       email address (@p email); invitation status and #Role;
0117       an optional @acronym RSVP flag and @acronym UID.
0118 
0119       @param name is person name of the attendee.
0120       @param email is person email address of the attendee.
0121       @param rsvp if true, the attendee is requested to reply to invitations.
0122       @param status is the #PartStat status of the attendee.
0123       @param role is the #Role of the attendee.
0124       @param uid is the @acronym UID of the attendee.
0125     */
0126     Attendee(const QString &name, const QString &email, bool rsvp = false, PartStat status = None, Role role = ReqParticipant, const QString &uid = QString());
0127 
0128     /**
0129       Constructs an attendee by copying another attendee.
0130 
0131       @param attendee is the attendee to be copied.
0132     */
0133     Attendee(const Attendee &attendee);
0134 
0135     /**
0136       Destroys the attendee.
0137     */
0138     ~Attendee();
0139 
0140     /**
0141      * Returns @c true if this is a default-constructed Attendee instance.
0142      */
0143     bool isNull() const;
0144 
0145     /**
0146       Returns the name of the attendee.
0147     */
0148     Q_REQUIRED_RESULT QString name() const;
0149     /**
0150       Sets the name of the attendee to @p name.
0151     */
0152     void setName(const QString &name);
0153 
0154     /**
0155       Returns the full name and email address of this attendee
0156       @return A QString containing the person's full name in the form
0157         "FirstName LastName \<mail@domain\>".
0158     */
0159     Q_REQUIRED_RESULT QString fullName() const;
0160 
0161     /**
0162       Returns the email address for this attendee.
0163     */
0164     Q_REQUIRED_RESULT QString email() const;
0165     /**
0166       Sets the email address for this attendee to @p email.
0167     */
0168     void setEmail(const QString &email);
0169 
0170     /**
0171       Sets the Role of the attendee to @p role.
0172 
0173       @param role is the Role to use for the attendee.
0174 
0175       @see role()
0176     */
0177     void setRole(Role role);
0178 
0179     /**
0180       Returns the Role of the attendee.
0181 
0182       @see setRole()
0183     */
0184     Q_REQUIRED_RESULT Role role() const;
0185 
0186     /**
0187       Sets the @acronym UID of the attendee to @p uid.
0188 
0189       @param uid is the @acronym UID to use for the attendee.
0190 
0191       @see uid()
0192     */
0193     void setUid(const QString &uid);
0194 
0195     /**
0196       Returns the @acronym UID of the attendee.
0197 
0198       @see setUid()
0199     */
0200     Q_REQUIRED_RESULT QString uid() const;
0201 
0202     /**
0203       Sets the #PartStat of the attendee to @p status.
0204 
0205       @param status is the #PartStat to use for the attendee.
0206 
0207       @see status()
0208     */
0209     void setStatus(PartStat status);
0210 
0211     /**
0212       Returns the #PartStat of the attendee.
0213 
0214       @see setStatus()
0215     */
0216     Q_REQUIRED_RESULT PartStat status() const;
0217 
0218     /**
0219       Sets the #CuType of the attendee to @p cuType.
0220 
0221       @param cuType is the #CuType to use for the attendee.
0222 
0223       @see cuType()
0224 
0225       @since 4.14
0226     */
0227     void setCuType(CuType cuType);
0228 
0229     /**
0230       Sets the #CuType of the attendee to @p cuType.
0231 
0232       @param cuType is the #CuType to use for the attendee.
0233 
0234       @see cuType()
0235 
0236       @since 4.14
0237     */
0238     void setCuType(const QString &cuType);
0239 
0240     /**
0241       Returns the #CuType of the attendee.
0242 
0243       @see setCuType()
0244 
0245       @since 4.14
0246     */
0247     Q_REQUIRED_RESULT CuType cuType() const;
0248 
0249     /**
0250       Returns the #CuType of the attendee.
0251 
0252       @see setCuType()
0253 
0254       @since 4.14
0255     */
0256     Q_REQUIRED_RESULT QString cuTypeStr() const;
0257 
0258     /**
0259       Sets the @acronym RSVP flag of the attendee to @p rsvp.
0260 
0261       @param rsvp if set (true), the attendee is requested to reply to
0262       invitations.
0263 
0264       @see RSVP()
0265     */
0266     void setRSVP(bool rsvp);
0267 
0268     /**
0269       Returns the attendee @acronym RSVP flag.
0270 
0271       @see setRSVP()
0272     */
0273     Q_REQUIRED_RESULT bool RSVP() const;
0274 
0275     /**
0276       Compares this with @p attendee for equality.
0277 
0278       @param attendee the attendee to compare.
0279     */
0280     bool operator==(const Attendee &attendee) const;
0281 
0282     /**
0283       Compares this with @p attendee for inequality.
0284 
0285       @param attendee the attendee to compare.
0286     */
0287     bool operator!=(const Attendee &attendee) const;
0288 
0289     /**
0290       Sets the delegate.
0291       @param delegate is a string containing a MAILTO URI of those delegated
0292       to attend the meeting.
0293       @see delegate(), setDelegator().
0294     */
0295     void setDelegate(const QString &delegate);
0296 
0297     /**
0298       Returns the delegate.
0299       @see setDelegate().
0300     */
0301     Q_REQUIRED_RESULT QString delegate() const;
0302 
0303     /**
0304       Sets the delegator.
0305       @param delegator is a string containing a MAILTO URI of those who
0306       have delegated their meeting attendance.
0307       @see delegator(), setDelegate().
0308     */
0309     void setDelegator(const QString &delegator);
0310 
0311     /**
0312       Returns the delegator.
0313       @see setDelegator().
0314     */
0315     Q_REQUIRED_RESULT QString delegator() const;
0316 
0317     /**
0318       Adds a custom property. If the property already exists it will be overwritten.
0319       @param xname is the name of the property.
0320       @param xvalue is its value.
0321     */
0322     void setCustomProperty(const QByteArray &xname, const QString &xvalue);
0323 
0324     /**
0325       Returns a reference to the CustomProperties object
0326     */
0327     Q_REQUIRED_RESULT CustomProperties &customProperties();
0328 
0329     /**
0330       Returns a const reference to the CustomProperties object
0331     */
0332     const CustomProperties &customProperties() const;
0333 
0334     /**
0335       Sets this attendee equal to @p attendee.
0336 
0337       @param attendee is the attendee to copy.
0338     */
0339     Attendee &operator=(const Attendee &attendee);
0340 
0341 private:
0342     //@cond PRIVATE
0343     class Private;
0344     QSharedDataPointer<Private> d;
0345     //@endcond
0346 
0347     friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &s, const KCalendarCore::Attendee &attendee);
0348     friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &s, KCalendarCore::Attendee &attendee);
0349 };
0350 
0351 /**
0352   Serializes an Attendee object into a data stream.
0353   @param stream is a QDataStream.
0354   @param attendee is a pointer to a Attendee object to be serialized.
0355 */
0356 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const KCalendarCore::Attendee &attendee);
0357 
0358 /**
0359   Initializes an Attendee object from a data stream.
0360   @param stream is a QDataStream.
0361   @param attendee is a pointer to a Attendee object to be initialized.
0362 */
0363 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &stream, KCalendarCore::Attendee &attendee);
0364 }
0365 
0366 //@cond PRIVATE
0367 Q_DECLARE_TYPEINFO(KCalendarCore::Attendee, Q_RELOCATABLE_TYPE);
0368 Q_DECLARE_METATYPE(KCalendarCore::Attendee)
0369 //@endcond
0370 
0371 #endif