File indexing completed on 2024-04-14 03:51:24

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef CALENDARURL_H
0009 #define CALENDARURL_H
0010 #include "kcontacts_export.h"
0011 
0012 #include <QMap>
0013 #include <QSharedDataPointer>
0014 #include <QString>
0015 class QUrl;
0016 
0017 class CalendarUrlTest;
0018 
0019 namespace KContacts
0020 {
0021 class ParameterMap;
0022 
0023 /**
0024  * @short Class that holds a Calendar Url (FBURL/CALADRURI/CALURI)
0025  *
0026  * @see RFC 6350 Section 6.9 (https://datatracker.ietf.org/doc/html/rfc6350#section-6.9)
0027  * @since 4.14.6
0028  */
0029 class KCONTACTS_EXPORT CalendarUrl
0030 {
0031     friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const CalendarUrl &);
0032     friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, CalendarUrl &);
0033     friend class VCardTool;
0034     friend class ::CalendarUrlTest;
0035 
0036 public:
0037     enum CalendarType {
0038         Unknown = 0, ///< Unknow calendar type
0039         FBUrl, ///< Specify the calendar containing the FreeBusy time information
0040         CALUri, ///< Specify the calendar associated with the contact
0041         CALADRUri, ///< Specify the calendar which should received the sheduling requests
0042         EndCalendarType,
0043     };
0044 
0045     CalendarUrl();
0046     CalendarUrl(CalendarUrl::CalendarType type);
0047     CalendarUrl(const CalendarUrl &other);
0048 
0049     ~CalendarUrl();
0050 
0051     typedef QList<CalendarUrl> List;
0052 
0053     Q_REQUIRED_RESULT bool isValid() const;
0054 
0055     void setType(CalendarUrl::CalendarType type);
0056     Q_REQUIRED_RESULT CalendarUrl::CalendarType type() const;
0057 
0058     void setUrl(const QUrl &url);
0059     QUrl url() const;
0060 
0061     Q_REQUIRED_RESULT bool operator==(const CalendarUrl &other) const;
0062     Q_REQUIRED_RESULT bool operator!=(const CalendarUrl &other) const;
0063 
0064     CalendarUrl &operator=(const CalendarUrl &other);
0065 
0066     Q_REQUIRED_RESULT QString toString() const;
0067 
0068 private:
0069     // exported for CalendarUrlTest
0070     void setParams(const ParameterMap &params);
0071     Q_REQUIRED_RESULT ParameterMap params() const;
0072 
0073     class Private;
0074     QSharedDataPointer<Private> d;
0075 };
0076 
0077 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const CalendarUrl &object);
0078 
0079 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, CalendarUrl &object);
0080 }
0081 Q_DECLARE_TYPEINFO(KContacts::CalendarUrl, Q_RELOCATABLE_TYPE);
0082 #endif // CALENDARURL_H