File: fbrecurring.cpp

package info (click to toggle)
kcalcore 4%3A18.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,704 kB
  • sloc: cpp: 22,533; perl: 136; sh: 11; makefile: 5
file content (73 lines) | stat: -rw-r--r-- 2,655 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
  This file is part of the kcalcore library.

  Copyright (c) 2007 Allen Winter <winter@kde.org>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301, USA.
*/

#include "icalformat.h"
#include "event.h"
#include "memorycalendar.h"
#include "freebusy.h"

#include <iostream>

#include <QDate>
#include <QTimeZone>

using namespace KCalCore;
using namespace std;

int main()
{
    ICalFormat f;

    MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc()));

    Event::Ptr event1 = Event::Ptr(new Event);
    event1->setSummary(QStringLiteral("A"));
    event1->setDtStart(QDateTime(QDate(2006, 1, 1), QTime(12, 0, 0)));
    //event1->setDuration( 60 * 60 );
    event1->setDtEnd(QDateTime(QDate(2006, 1, 1), QTime(13, 0, 0)));
    event1->setAllDay(false);
    event1->recurrence()->setDaily(1);
    //event1->recurrence()->setDuration( 2 );
    event1->recurrence()->setEndDateTime(QDateTime(QDate(2006, 1, 3), QTime(13, 0, 0)));
    cout << f.toICalString(event1).toLocal8Bit().data() << endl;
    cal->addEvent(event1);

    Event::Ptr event2 = Event::Ptr(new Event);
    event2->setSummary(QStringLiteral("B"));
    event2->setDtStart(QDateTime(QDate(2006, 1, 1), QTime(13, 0, 0)));
    //event2->setDuration( 60 * 60 );
    event2->setDtEnd(QDateTime(QDate(2006, 1, 1), QTime(14, 0, 0)));
    event2->setAllDay(false);
    event2->recurrence()->setDaily(1);
    //event2->recurrence()->setDuration( 3 );
    event2->recurrence()->setEndDateTime(QDateTime(QDate(2006, 1, 4), QTime(13, 0, 0)));
    cout << f.toICalString(event2).toLocal8Bit().data() << endl;
    cal->addEvent(event2);

    QDateTime start(QDate(2006, 1, 2), QTime(0, 0, 0));
    QDateTime end(QDate(2006, 1, 3), QTime(0, 0, 0));

    FreeBusy::Ptr freebusy = FreeBusy::Ptr(new FreeBusy(cal->rawEvents(start.date(), end.date()), start, end));
    QString result = f.createScheduleMessage(freebusy, iTIPPublish);
    cout << result.toLocal8Bit().data() << endl;

    return 0;
}