# vevent.h

    00001 //
    00002 // \file        vevent.h
    00003 //              Conversion routines for vevents (VCALENDAR, etc)
    00004 //
    00005
    00006 /*
    00007     Copyright (C) 2006-2011, Net Direct Inc. (http://www.netdirect.ca/)
    00008
    00009     This program is free software; you can redistribute it and/or modify
    00010     it under the terms of the GNU General Public License as published by
    00011     the Free Software Foundation; either version 2 of the License, or
    00012     (at your option) any later version.
    00013
    00014     This program is distributed in the hope that it will be useful,
    00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00017
    00018     See the GNU General Public License in the COPYING file at the
    00019     root directory of this project for more details.
    00020 */
    00021
    00022 #ifndef __BARRY_SYNC_VEVENT_H__
    00023 #define __BARRY_SYNC_VEVENT_H__
    00024
    00025 #include "dll.h"
    00026 #include "vbase.h"
    00027 #include "vformat.h"
    00028 #include "r_calendar.h"
    00029 #include <stdint.h>
    00030 #include <string>
    00031
    00032 namespace Barry { namespace Sync {
    00033
    00034 //
    00035 // vCalendar
    00036 //
    00037 /// Class for converting between RFC 2445 iCalendar data format,
    00038 /// and the Barry::Calendar class.
    00039 ///
    00040 class BXEXPORT vCalendar : public vBase
    00041 {
    00042         // external reference
    00043         vTimeConverter &m_vtc;
    00044
    00045         // data to pass to external requests
    00046         char *m_gCalData;       // dynamic memory returned by vformat()... can
    00047                                 // be used directly by the plugin, without
    00048                                 // overmuch allocation and freeing (see Extract())
    00049         std::string m_vCalData; // copy of m_gCalData, for C++ use
    00050         Barry::Calendar m_BarryCal;
    00051
    00052         static const char *WeekDays[7];
    00053
    00054         unsigned short GetMonthWeekNumFromBYDAY(const std::string& ByDay);
    00055         unsigned short GetWeekDayIndexFromBYDAY(const std::string& ByDay);
    00056
    00057 protected:
    00058         void RecurToVCal();
    00059         void RecurToBarryCal(vAttr& rrule, time_t starttime);
    00060
    00061         static unsigned short GetWeekDayIndex(const char *dayname);
    00062         bool HasMultipleVEvents() const;
    00063
    00064 public:
    00065         explicit vCalendar(vTimeConverter &vtc);
    00066         ~vCalendar();
    00067
    00068         const std::string&      ToVCal(const Barry::Calendar &cal);
    00069         const Barry::Calendar&  ToBarry(const char *vcal, uint32_t RecordId);
    00070
    00071         const std::string&      GetVCal() const { return m_vCalData; }
    00072         const Barry::Calendar&  GetBarryCal() const { return m_BarryCal; }
    00073
    00074         char* ExtractVCal();
    00075
    00076         void Clear();
    00077
    00078         // This is the v-name of the innermost BEGIN/END block
    00079         static const char* GetVName() { return "VEVENT"; }
    00080 };
    00081
    00082 }} // namespace Barry::Sync
    00083
    00084 #endif
    00085