3 /// Conversion routines for vevents (VCALENDAR, etc)
7 Copyright (C) 2006-2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_SYNC_VEVENT_H__
23 #define __BARRY_SYNC_VEVENT_H__
28 #include "r_calendar.h"
33 namespace Barry
{ namespace Sync
{
38 /// Class for converting between RFC 2445 iCalendar data format,
39 /// and the Barry::Calendar class.
41 class BXEXPORT vCalendar
: public vBase
43 typedef std::map
<std::string
, std::string
> ArgMapType
;
46 vTimeConverter
&m_vtc
;
48 // data to pass to external requests
49 char *m_gCalData
; // dynamic memory returned by vformat()... can
50 // be used directly by the plugin, without
51 // overmuch allocation and freeing (see Extract())
52 std::string m_vCalData
; // copy of m_gCalData, for C++ use
53 Barry::Calendar m_BarryCal
;
55 static const char *WeekDays
[7];
57 void CheckUnsupportedArg(const ArgMapType
&args
,
58 const std::string
&name
);
59 std::vector
<std::string
> SplitBYDAY(const std::string
&ByDay
);
60 uint16_t GetMonthWeekNumFromBYDAY(const std::string
& ByDay
);
61 uint16_t GetWeekDayIndexFromBYDAY(const std::string
& ByDay
);
62 uint16_t GetDayOfMonthFromBYMONTHDAY(const ArgMapType
&args
,
63 int month_override
= -1);
67 void RecurToBarryCal(vAttr
& rrule
, time_t starttime
);
69 static uint16_t GetWeekDayIndex(const char *dayname
);
70 bool HasMultipleVEvents() const;
73 explicit vCalendar(vTimeConverter
&vtc
);
76 const std::string
& ToVCal(const Barry::Calendar
&cal
);
77 const Barry::Calendar
& ToBarry(const char *vcal
, uint32_t RecordId
);
79 const std::string
& GetVCal() const { return m_vCalData
; }
80 const Barry::Calendar
& GetBarryCal() const { return m_BarryCal
; }
86 // This is the v-name of the innermost BEGIN/END block
87 static const char* GetVName() { return "VEVENT"; }
90 }} // namespace Barry::Sync