File indexing completed on 2024-11-24 04:44:10

0001 /*
0002  * SPDX-FileCopyrightText: 2012 Christian Mollekopf <mollekopf@kolabsys.com>
0003  *
0004  * SPDX-License-Identifier: LGPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 #include <kolabevent.h>
0009 
0010 #include "icalendar/icalendar.h"
0011 #include "kolab_export.h"
0012 
0013 namespace Kolab
0014 {
0015 namespace Calendaring
0016 {
0017 class KOLAB_EXPORT Event : public Kolab::Event
0018 {
0019 public:
0020     Event();
0021     Event(const Kolab::Event &);
0022     ~Event();
0023 
0024     bool read(const std::string &);
0025     /**
0026      * Convert to kolab xml format.
0027      */
0028     std::string write() const;
0029 
0030     bool fromMime(const std::string &);
0031 
0032     /**
0033      * Convert to kolab mime format.
0034      */
0035     std::string toMime() const;
0036 
0037     enum ITipMethod {
0038         iTIPPublish, /**< Event, to-do, journal or freebusy posting */
0039         iTIPRequest, /**< Event, to-do or freebusy scheduling request */
0040         iTIPReply, /**< Event, to-do or freebusy reply to request */
0041         iTIPAdd, /**< Event, to-do or journal additional property request */
0042         iTIPCancel, /**< Event, to-do or journal cancellation notice */
0043         iTIPRefresh, /**< Event or to-do description update request */
0044         iTIPCounter, /**< Event or to-do submit counter proposal */
0045         iTIPDeclineCounter, /**< Event or to-do decline a counter proposal */
0046         iTIPNoMethod /**< No method */
0047     };
0048 
0049     bool fromICal(const std::string &);
0050     std::string toICal() const;
0051 
0052     bool fromIMip(const std::string &);
0053     std::string toIMip(ITipMethod method) const;
0054 
0055     /**
0056      * Returns the scheduling method from the last fromIMip call
0057      */
0058     ITipMethod getSchedulingMethod() const;
0059 
0060     /**
0061      * Updates the delegators and delegatees of the event.
0062      *
0063      * Creates a new attendee for each missing delegatee (delegators are expected to be existing), and then updates each delegatee with the delegator
0064      * (delegatedFrom). Delegators delegatedTo is updated accordingly. Existing attendees are tried to be found by uid/email/name (in this order).
0065      *
0066      */
0067     void delegate(const std::vector<Kolab::Attendee> &delegators, const std::vector<Kolab::Attendee> &delegatees);
0068 
0069     /**
0070      * Get attendee by uid/email/name (in this order)
0071      */
0072     Kolab::Attendee getAttendee(const std::string &);
0073 
0074     /**
0075      * Returns the next occurrence for a recurring event.
0076      *
0077      * If the start date of the event is passed in, the second occurrence is returned (so it can be used in a for loop to loop through all occurrences).
0078      *
0079      * If there is no next occurrence or the event is not recurring at all an invalid cDateTime is returned.
0080      */
0081     Kolab::cDateTime getNextOccurence(const Kolab::cDateTime &);
0082 
0083     /**
0084      * Returns the corresponding end date-time for a specific occurrence.
0085      * @param start is the start date of the occurrence.
0086      */
0087     Kolab::cDateTime getOccurenceEndDate(const Kolab::cDateTime &start);
0088 
0089     /**
0090      * Returns the last occurrence, or and invalid cDateTime if the event is not recurring or recurring idenfinitely.
0091      */
0092     Kolab::cDateTime getLastOccurrence() const;
0093 
0094 private:
0095     Kolab::Attendee *getAttendee(const ContactReference &);
0096     Kolab::ITipHandler mITipHandler;
0097 };
0098 }
0099 }