File: testfb.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 (67 lines) | stat: -rw-r--r-- 2,826 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
/*
  This file is part of the kcalcore library.

  Copyright (c) 2003 Cornelius Schumacher <schumacher@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 "event.h"
#include "icalformat.h"
#include "freebusy.h"

#include <QDebug>

#include <iostream>

using namespace KCalCore;

int main(int, char **)
{
    const QString fbString
        = QStringLiteral("BEGIN:VCALENDAR\n"
                         "PRODID:-//proko2//freebusy 1.0//EN\n"
                         "METHOD:PUBLISH\n"
                         "VERSION:2.0\n"
                         "BEGIN:VFREEBUSY\n"
                         "ORGANIZER:MAILTO:test3@kdab.net\n"
                         "X-KDE-Foo:bla\n"
                         "DTSTAMP:20071202T152453Z\n"
                         "URL:http://mail.kdab.net/freebusy/test3%40kdab.net.ifb\n"
                         "DTSTART:19700101T000000Z\n"
                         "DTEND:200700101T000000Z\n"
                         "COMMENT:This is a dummy vfreebusy that indicates an empty calendar\n"
                         "FREEBUSY:19700101T000000Z/19700101T000000Z\n"
                         "FREEBUSY;X-UID=bGlia2NhbC0xODk4MjgxNTcuMTAxMA==;X-\n"
                         " SUMMARY=RW1wbG95ZWUgbWVldGluZw==;X-LOCATION=Um9vb\n"
                         " SAyMTM=:20080131T170000Z/20080131T174500Z\n"
                         "END:VFREEBUSY\n"
                         "END:VCALENDAR\n");

    ICalFormat format;
    FreeBusy::Ptr fb = format.parseFreeBusy(fbString);
    qDebug() << fb->fullBusyPeriods().count() << " " << fb->dtStart().toString();
    const FreeBusyPeriod::List l = fb->fullBusyPeriods();
    for (FreeBusyPeriod::List::ConstIterator it = l.begin(); it != l.end(); ++it) {
        qDebug() << (*it).start().toString() << " " << (*it).end().toString() << "+ "
                 << (*it).summary() << ":" << (*it).location();
    }
    typedef QMap<QByteArray, QString> FooMap;
    const FooMap props = fb->customProperties();
    for (FooMap::ConstIterator it = props.begin(); it != props.end(); ++it) {
        qDebug() << it.key() << ": " << it.value();
    }
}