Tree-wide cleanup of trailing whitespace
[barry.git] / src / r_calendar.h
blobfb26d06cede84fefb445f8fd072c52c8d862538a
1 ///
2 /// \file r_calendar.h
3 /// Blackberry database record parser class for calndar records.
4 ///
6 /*
7 Copyright (C) 2005-2009, 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 std::vector<UnknownField> 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 time_t NotificationTime; // 0 means notification is off
63 time_t StartTime;
64 time_t EndTime;
66 ///
67 /// Free Busy Flag
68 ///
69 /// This lists the available settings found in the device.
70 /// This list is based on information from MS Outlook 2007
71 /// (Free ==0 and Busy == 2)
72 /// This is FBTYPE in RFC2445 and is defined as
73 /// FREE, BUSY, BUSY-UNAVAILABLE and BUSY-TENTATIVE
74 ///
75 enum FreeBusyFlagType {
76 Free = 0,
77 Tentative,
78 Busy,
79 OutOfOffice
81 FreeBusyFlagType FreeBusyFlag;
83 ///
84 /// Class Flag
85 ///
86 /// This is also called classification in Evolution and it
87 /// is the equivilant of public or private in outlook
88 /// Private is set to 0x2 in Outlook
89 /// RFC2445 CLASS is PUBLIC, PRIVATE, CONFIDENTIAL
90 ///
91 enum ClassFlagType {
92 Public = 0,
93 Confidential,
94 Private
97 ClassFlagType ClassFlag;
100 unsigned short TimeZoneCode; // the time zone originally used
101 // for the recurrence data...
102 // seems to have little use, but
103 // set to your current time zone
104 // as a good default
105 bool TimeZoneValid; // true if the record contained a
106 // time zone code
108 // unknown
109 UnknownsType Unknowns;
111 public:
112 const unsigned char* ParseField(const unsigned char *begin,
113 const unsigned char *end, const IConverter *ic = 0);
115 public:
116 Calendar();
117 ~Calendar();
119 // Parser / Builder API (see parser.h / builder.h)
120 uint8_t GetRecType() const { return RecType; }
121 uint32_t GetUniqueId() const { return RecordId; }
122 void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
123 void ParseHeader(const Data &data, size_t &offset);
124 void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
125 void BuildHeader(Data &data, size_t &offset) const;
126 void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
128 void Clear();
130 void Dump(std::ostream &os) const;
132 // sorting
133 bool operator<(const Calendar &other) const { return StartTime < other.StartTime; }
135 // database name
136 static const char * GetDBName() { return "Calendar"; }
137 static uint8_t GetDefaultRecType() { return 5; } // or 0?
140 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Calendar &msg) {
141 msg.Dump(os);
142 return os;
145 /// @}
147 } // namespace Barry
149 #endif