lib: use typedef instead of hard coded std::vector<FieldHandle<T> >
[barry.git] / src / r_calendar.h
blobc9b2c6291478d4e806ce918fd747fa6f8845a937
1 ///
2 /// \file r_calendar.h
3 /// Blackberry database record parser class for calendar records.
4 ///
6 /*
7 Copyright (C) 2005-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_RECORD_CALENDAR_H__
23 #define __BARRY_RECORD_CALENDAR_H__
25 #include "dll.h"
26 #include "record.h"
27 #include "r_recur_base.h"
28 #include <iosfwd>
29 #include <string>
30 #include <vector>
31 #include <map>
32 #include <stdint.h>
34 namespace Barry {
36 // forward declarations
37 class IConverter;
40 // NOTE: All classes here must be container-safe! Perhaps add sorting
41 // operators in the future.
46 /// \addtogroup RecordParserClasses
47 /// @{
49 class BXEXPORT Calendar : public RecurBase
51 public:
52 typedef Barry::UnknownsType UnknownsType;
54 uint8_t RecType;
55 uint32_t RecordId;
57 // general data
58 bool AllDayEvent;
59 std::string Subject;
60 std::string Notes;
61 std::string Location;
62 Barry::TimeT NotificationTime; // 0 means notification is off
63 Barry::TimeT StartTime;
64 Barry::TimeT EndTime;
65 EmailAddressList Organizer;
66 EmailAddressList AcceptedBy;
67 EmailAddressList Invited; // list of invited people (email a
69 ///
70 /// Free Busy Flag
71 ///
72 /// This lists the available settings found in the device.
73 /// This list is based on information from MS Outlook 2007
74 /// (Free ==0 and Busy == 2)
75 /// This is FBTYPE in RFC2445 and is defined as
76 /// FREE, BUSY, BUSY-UNAVAILABLE and BUSY-TENTATIVE
77 ///
78 enum FreeBusyFlagType {
79 Free = 0,
80 Tentative,
81 Busy,
82 OutOfOffice
84 FreeBusyFlagType FreeBusyFlag;
86 ///
87 /// Class Flag
88 ///
89 /// This is also called classification in Evolution and it
90 /// is the equivilant of public or private in outlook
91 /// Private is set to 0x2 in Outlook
92 /// RFC2445 CLASS is PUBLIC, PRIVATE, CONFIDENTIAL
93 ///
94 enum ClassFlagType {
95 Public = 0,
96 Confidential,
97 Private
100 ClassFlagType ClassFlag;
102 uint64_t CalendarID; // Calendar ID (usefull if devices have several calendars)
104 uint16_t TimeZoneCode; // the time zone originally used
105 // for the recurrence data...
106 // seems to have little use, but
107 // set to your current time zone
108 // as a good default
109 bool TimeZoneValid; // true if the record contained a
110 // time zone code
112 // unknown
113 UnknownsType Unknowns;
115 protected:
116 static FreeBusyFlagType FreeBusyFlagProto2Rec(uint8_t f);
117 static uint8_t FreeBusyFlagRec2Proto(FreeBusyFlagType f);
119 static ClassFlagType ClassFlagProto2Rec(uint8_t f);
120 static uint8_t ClassFlagRec2Proto(ClassFlagType f);
122 virtual void DumpSpecialFields(std::ostream &os) const;
124 public:
125 const unsigned char* ParseField(const unsigned char *begin,
126 const unsigned char *end, const IConverter *ic = 0);
128 public:
129 Calendar();
130 ~Calendar();
132 // Parser / Builder API (see parser.h / builder.h)
133 uint8_t GetRecType() const { return RecType; }
134 uint32_t GetUniqueId() const { return RecordId; }
135 void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
136 void ParseHeader(const Data &data, size_t &offset);
137 void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
138 void BuildHeader(Data &data, size_t &offset) const;
139 void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
141 // operations (common among record classes)
142 void Clear();
143 void Dump(std::ostream &os) const;
144 std::string GetDescription() const;
146 // sorting
147 bool operator<(const Calendar &other) const;
149 // database name
150 static const char * GetDBName() { return "Calendar"; }
151 static uint8_t GetDefaultRecType() { return 5; } // or 0?
153 // Generic Field Handle support
154 static const FieldHandle<Calendar>::ListT& GetFieldHandles();
157 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Calendar &msg) {
158 msg.Dump(os);
159 return os;
163 class BXEXPORT CalendarAll : public Calendar
165 public:
166 std::string MailAccount;
168 protected:
169 virtual void DumpSpecialFields(std::ostream &os) const;
171 public:
172 // Parser / Builder API (see parser.h / builder.h)
173 void ParseHeader(const Data &data, size_t &offset);
175 void Clear();
177 public:
178 // database name
179 static const char * GetDBName() { return "Calendar - All"; }
181 // Generic Field Handle support
182 static const FieldHandle<CalendarAll>::ListT& GetFieldHandles();
185 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CalendarAll &msg) {
186 msg.Dump(os);
187 return os;
191 /// @}
193 } // namespace Barry
195 #endif