Changeset View
Changeset View
Standalone View
Standalone View
src/freebusy.cpp
Show All 33 Lines | |||||
34 | #include "visitor.h" | 34 | #include "visitor.h" | ||
35 | #include "utils.h" | 35 | #include "utils.h" | ||
36 | 36 | | |||
37 | #include "icalformat.h" | 37 | #include "icalformat.h" | ||
38 | 38 | | |||
39 | #include "kcalcore_debug.h" | 39 | #include "kcalcore_debug.h" | ||
40 | #include <QTime> | 40 | #include <QTime> | ||
41 | 41 | | |||
42 | using namespace KCalCore; | 42 | using namespace KCalendarCore; | ||
43 | 43 | | |||
44 | //@cond PRIVATE | 44 | //@cond PRIVATE | ||
45 | class Q_DECL_HIDDEN KCalCore::FreeBusy::Private | 45 | class Q_DECL_HIDDEN KCalendarCore::FreeBusy::Private | ||
46 | { | 46 | { | ||
47 | private: | 47 | private: | ||
48 | FreeBusy *q; | 48 | FreeBusy *q; | ||
49 | public: | 49 | public: | ||
50 | Private(FreeBusy *qq) : q(qq) | 50 | Private(FreeBusy *qq) : q(qq) | ||
51 | {} | 51 | {} | ||
52 | 52 | | |||
53 | Private(const KCalCore::FreeBusy::Private &other, FreeBusy *qq) : q(qq) | 53 | Private(const KCalendarCore::FreeBusy::Private &other, FreeBusy *qq) : q(qq) | ||
54 | { | 54 | { | ||
55 | init(other); | 55 | init(other); | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | Private(const FreeBusyPeriod::List &busyPeriods, FreeBusy *qq) | 58 | Private(const FreeBusyPeriod::List &busyPeriods, FreeBusy *qq) | ||
59 | : q(qq), mBusyPeriods(busyPeriods) | 59 | : q(qq), mBusyPeriods(busyPeriods) | ||
60 | {} | 60 | {} | ||
61 | 61 | | |||
62 | void init(const KCalCore::FreeBusy::Private &other); | 62 | void init(const KCalendarCore::FreeBusy::Private &other); | ||
63 | void init(const Event::List &events, const QDateTime &start, const QDateTime &end); | 63 | void init(const Event::List &events, const QDateTime &start, const QDateTime &end); | ||
64 | 64 | | |||
65 | QDateTime mDtEnd; // end datetime | 65 | QDateTime mDtEnd; // end datetime | ||
66 | FreeBusyPeriod::List mBusyPeriods; // list of periods | 66 | FreeBusyPeriod::List mBusyPeriods; // list of periods | ||
67 | 67 | | |||
68 | // This is used for creating a freebusy object for the current user | 68 | // This is used for creating a freebusy object for the current user | ||
69 | bool addLocalPeriod(FreeBusy *fb, const QDateTime &start, const QDateTime &end); | 69 | bool addLocalPeriod(FreeBusy *fb, const QDateTime &start, const QDateTime &end); | ||
70 | }; | 70 | }; | ||
71 | 71 | | |||
72 | void KCalCore::FreeBusy::Private::init(const KCalCore::FreeBusy::Private &other) | 72 | void KCalendarCore::FreeBusy::Private::init(const KCalendarCore::FreeBusy::Private &other) | ||
73 | { | 73 | { | ||
74 | mDtEnd = other.mDtEnd; | 74 | mDtEnd = other.mDtEnd; | ||
75 | mBusyPeriods = other.mBusyPeriods; | 75 | mBusyPeriods = other.mBusyPeriods; | ||
76 | } | 76 | } | ||
77 | //@endcond | 77 | //@endcond | ||
78 | 78 | | |||
79 | FreeBusy::FreeBusy() | 79 | FreeBusy::FreeBusy() | ||
80 | : d(new KCalCore::FreeBusy::Private(this)) | 80 | : d(new KCalendarCore::FreeBusy::Private(this)) | ||
81 | { | 81 | { | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | FreeBusy::FreeBusy(const FreeBusy &other) | 84 | FreeBusy::FreeBusy(const FreeBusy &other) | ||
85 | : IncidenceBase(other), | 85 | : IncidenceBase(other), | ||
86 | d(new KCalCore::FreeBusy::Private(*other.d, this)) | 86 | d(new KCalendarCore::FreeBusy::Private(*other.d, this)) | ||
87 | { | 87 | { | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | FreeBusy::FreeBusy(const QDateTime &start, const QDateTime &end) | 90 | FreeBusy::FreeBusy(const QDateTime &start, const QDateTime &end) | ||
91 | : d(new KCalCore::FreeBusy::Private(this)) | 91 | : d(new KCalendarCore::FreeBusy::Private(this)) | ||
92 | { | 92 | { | ||
93 | setDtStart(start); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | 93 | setDtStart(start); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | ||
94 | setDtEnd(end); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | 94 | setDtEnd(end); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | ||
95 | } | 95 | } | ||
96 | 96 | | |||
97 | FreeBusy::FreeBusy(const Event::List &events, const QDateTime &start, const QDateTime &end) | 97 | FreeBusy::FreeBusy(const Event::List &events, const QDateTime &start, const QDateTime &end) | ||
98 | : d(new KCalCore::FreeBusy::Private(this)) | 98 | : d(new KCalendarCore::FreeBusy::Private(this)) | ||
99 | { | 99 | { | ||
100 | setDtStart(start); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | 100 | setDtStart(start); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | ||
101 | setDtEnd(end); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | 101 | setDtEnd(end); //NOLINT false clang-analyzer-optin.cplusplus.VirtualCall | ||
102 | 102 | | |||
103 | d->init(events, start, end); | 103 | d->init(events, start, end); | ||
104 | } | 104 | } | ||
105 | 105 | | |||
106 | //@cond PRIVATE | 106 | //@cond PRIVATE | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 120 | for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) { | |||
187 | addLocalPeriod(q, event->dtStart(), event->dtEnd()); | 187 | addLocalPeriod(q, event->dtStart(), event->dtEnd()); | ||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | q->sortList(); | 190 | q->sortList(); | ||
191 | } | 191 | } | ||
192 | //@endcond | 192 | //@endcond | ||
193 | 193 | | |||
194 | FreeBusy::FreeBusy(const Period::List &busyPeriods) | 194 | FreeBusy::FreeBusy(const Period::List &busyPeriods) | ||
195 | : d(new KCalCore::FreeBusy::Private(this)) | 195 | : d(new KCalendarCore::FreeBusy::Private(this)) | ||
196 | { | 196 | { | ||
197 | addPeriods(busyPeriods); | 197 | addPeriods(busyPeriods); | ||
198 | } | 198 | } | ||
199 | 199 | | |||
200 | FreeBusy::FreeBusy(const FreeBusyPeriod::List &busyPeriods) | 200 | FreeBusy::FreeBusy(const FreeBusyPeriod::List &busyPeriods) | ||
201 | : d(new KCalCore::FreeBusy::Private(busyPeriods, this)) | 201 | : d(new KCalendarCore::FreeBusy::Private(busyPeriods, this)) | ||
202 | { | 202 | { | ||
203 | } | 203 | } | ||
204 | 204 | | |||
205 | FreeBusy::~FreeBusy() | 205 | FreeBusy::~FreeBusy() | ||
206 | { | 206 | { | ||
207 | delete d; | 207 | delete d; | ||
208 | } | 208 | } | ||
209 | 209 | | |||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | |||||
398 | } | 398 | } | ||
399 | //@endcond | 399 | //@endcond | ||
400 | 400 | | |||
401 | QLatin1String FreeBusy::mimeType() const | 401 | QLatin1String FreeBusy::mimeType() const | ||
402 | { | 402 | { | ||
403 | return FreeBusy::freeBusyMimeType(); | 403 | return FreeBusy::freeBusyMimeType(); | ||
404 | } | 404 | } | ||
405 | 405 | | |||
406 | QLatin1String KCalCore::FreeBusy::freeBusyMimeType() | 406 | QLatin1String KCalendarCore::FreeBusy::freeBusyMimeType() | ||
407 | { | 407 | { | ||
408 | return QLatin1String("application/x-vnd.akonadi.calendar.freebusy"); | 408 | return QLatin1String("application/x-vnd.akonadi.calendar.freebusy"); | ||
409 | } | 409 | } | ||
410 | 410 | | |||
411 | QDataStream &KCalCore::operator<<(QDataStream &stream, const KCalCore::FreeBusy::Ptr &freebusy) | 411 | QDataStream &KCalendarCore::operator<<(QDataStream &stream, const KCalendarCore::FreeBusy::Ptr &freebusy) | ||
412 | { | 412 | { | ||
413 | KCalCore::ICalFormat format; | 413 | KCalendarCore::ICalFormat format; | ||
414 | QString data = format.createScheduleMessage(freebusy, iTIPPublish); | 414 | QString data = format.createScheduleMessage(freebusy, iTIPPublish); | ||
415 | return stream << data; | 415 | return stream << data; | ||
416 | } | 416 | } | ||
417 | 417 | | |||
418 | QDataStream &KCalCore::operator>>(QDataStream &stream, KCalCore::FreeBusy::Ptr &freebusy) | 418 | QDataStream &KCalendarCore::operator>>(QDataStream &stream, KCalendarCore::FreeBusy::Ptr &freebusy) | ||
419 | { | 419 | { | ||
420 | QString freeBusyVCal; | 420 | QString freeBusyVCal; | ||
421 | stream >> freeBusyVCal; | 421 | stream >> freeBusyVCal; | ||
422 | 422 | | |||
423 | KCalCore::ICalFormat format; | 423 | KCalendarCore::ICalFormat format; | ||
424 | freebusy = format.parseFreeBusy(freeBusyVCal); | 424 | freebusy = format.parseFreeBusy(freeBusyVCal); | ||
425 | 425 | | |||
426 | if (!freebusy) { | 426 | if (!freebusy) { | ||
427 | qCDebug(KCALCORE_LOG) << "Error parsing free/busy"; | 427 | qCDebug(KCALCORE_LOG) << "Error parsing free/busy"; | ||
428 | qCDebug(KCALCORE_LOG) << freeBusyVCal; | 428 | qCDebug(KCALCORE_LOG) << freeBusyVCal; | ||
429 | } | 429 | } | ||
430 | 430 | | |||
431 | return stream; | 431 | return stream; | ||
432 | } | 432 | } | ||
433 | 433 | |