summaryrefslogtreecommitdiffstats
path: root/libkcal/icalformatimpl.h
blob: 215adfe9b37fbd2a90ce240c898f546417b47eff (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
    This file is part of libkcal.

    Copyright (c) 2001-2003 Cornelius Schumacher <[email protected]>
    Copyright (C) 2003-2004 Reinhold Kainhofer <[email protected]>

    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.
*/
#ifndef KCAL_ICALFORMATIMPL_H
#define KCAL_ICALFORMATIMPL_H

#include <tqstring.h>
#include <tqdict.h>

#include "scheduler.h"
#include "freebusy.h"


extern "C" {
  #include <libical/ical.h>
}

namespace KCal {

class Compat;

/**
  @internal

  This class provides the libical dependent functions for ICalFormat.
*/
class ICalFormatImpl
{
  public:
    /** Create new iCal format for calendar object */
    ICalFormatImpl( ICalFormat *tqparent );
    virtual ~ICalFormatImpl();

    bool populate( Calendar *, icalcomponent *fs);

    icalcomponent *writeIncidence(IncidenceBase *incidence, Scheduler::Method method = Scheduler::Request );
    icalcomponent *writeTodo(Todo *todo);
    icalcomponent *writeEvent(Event *event);
    icalcomponent *writeFreeBusy(FreeBusy *freebusy,
                                 Scheduler::Method method = Scheduler::Publish );
    icalcomponent *writeJournal(Journal *journal);
    void writeIncidence(icalcomponent *tqparent,Incidence *incidence);
    icalproperty *writeAttendee(Attendee *attendee);
    icalproperty *writeOrganizer( const Person &organizer );
    icalproperty *writeAttachment(Attachment *attach);
    icalproperty *writeRecurrenceRule(Recurrence *);
    icalrecurrencetype writeRecurrenceRule( RecurrenceRule *recur );
    icalcomponent *writeAlarm(Alarm *alarm);

    TQString extractErrorProperty(icalcomponent *);
    Todo *readTodo(icalcomponent *vtodo);
    Event *readEvent(icalcomponent *vevent, icalcomponent *vtimezone);
    FreeBusy *readFreeBusy(icalcomponent *vfreebusy);
    Journal *readJournal(icalcomponent *vjournal);
    Attendee *readAttendee(icalproperty *attendee);
    Person readOrganizer( icalproperty *organizer );
    Attachment *readAttachment(icalproperty *attach);
    void readIncidence(icalcomponent *tqparent, icaltimezone *timezone, Incidence *incidence);
    void readRecurrenceRule(icalproperty *rrule,Incidence *event );
    void readExceptionRule( icalproperty *rrule, Incidence *incidence );
    void readRecurrence( const struct icalrecurrencetype &r, RecurrenceRule* recur );
    void readAlarm(icalcomponent *alarm,Incidence *incidence);
    /** Return the PRODID string loaded from calendar file */
    const TQString &loadedProductId()  { return mLoadedProductId; }

    static icaltimetype writeICalDate(const TQDate &);
    static TQDate readICalDate(icaltimetype);
    icaltimetype writeICalDateTime(const TQDateTime &);
    TQDateTime readICalDateTime( icalproperty*, icaltimetype&, icaltimezone* tz = 0 );
    static icaldurationtype writeICalDuration(int seconds);
    static int readICalDuration(icaldurationtype);
    static icaldatetimeperiodtype writeICalDatePeriod( const TQDate &date );
    icaldatetimeperiodtype writeICalDateTimePeriod( const TQDateTime &date );

    icalcomponent *createCalendarComponent(Calendar * = 0);
    icalcomponent *createScheduleComponent(IncidenceBase *,Scheduler::Method);

  protected:
    void dumpIcalRecurrence(icalrecurrencetype);
  private:
    void writeIncidenceBase(icalcomponent *tqparent,IncidenceBase *);
    void readIncidenceBase(icalcomponent *tqparent, IncidenceBase *);
    void writeCustomProperties(icalcomponent *tqparent,CustomProperties *);
    void readCustomProperties(icalcomponent *tqparent,CustomProperties *);
    void readTimezone(icalcomponent *vtimezone);

    ICalFormat *mParent;
    Calendar *mCalendar;

    TQString mLoadedProductId;         // PRODID string loaded from calendar file

    Event::List mEventsRelate;           // events with relations
    Todo::List mTodosRelate;             // todos with relations

    static const int mSecondsPerWeek;
    static const int mSecondsPerDay;
    static const int mSecondsPerHour;
    static const int mSecondsPerMinute;

    Compat *mCompat;

    class ToComponentVisitor;
    class Private;
    Private *d;
};

}

#endif