r_calendar.h

Go to the documentation of this file.
00001 ///
00002 /// \file       r_calendar.h
00003 ///             Blackberry database record parser class for calndar records.
00004 ///
00005 
00006 /*
00007     Copyright (C) 2005-2010, 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_RECORD_CALENDAR_H__
00023 #define __BARRY_RECORD_CALENDAR_H__
00024 
00025 #include "dll.h"
00026 #include "record.h"
00027 #include "r_recur_base.h"
00028 #include <iosfwd>
00029 #include <string>
00030 #include <vector>
00031 #include <map>
00032 #include <stdint.h>
00033 
00034 namespace Barry {
00035 
00036 // forward declarations
00037 class IConverter;
00038 
00039 //
00040 // NOTE:  All classes here must be container-safe!  Perhaps add sorting
00041 //        operators in the future.
00042 //
00043 
00044 
00045 
00046 /// \addtogroup RecordParserClasses
00047 /// @{
00048 
00049 class BXEXPORT Calendar : public RecurBase
00050 {
00051 public:
00052         typedef std::vector<UnknownField>               UnknownsType;
00053 
00054         uint8_t RecType;
00055         uint32_t RecordId;
00056 
00057         // general data
00058         bool AllDayEvent;
00059         std::string Subject;
00060         std::string Notes;
00061         std::string Location;
00062         time_t NotificationTime;        // 0 means notification is off
00063         time_t StartTime;
00064         time_t EndTime;
00065         EmailAddressList Organizer;
00066         EmailAddressList AcceptedBy;
00067         EmailAddressList Invited;               // list of invited people (email a
00068 
00069         ///
00070         /// Free Busy Flag
00071         ///
00072         /// This lists the available settings found in the device.
00073         /// This list is based on information from MS Outlook 2007
00074         /// (Free ==0 and Busy == 2)
00075         /// This is FBTYPE in RFC2445 and is defined as
00076         /// FREE, BUSY, BUSY-UNAVAILABLE and BUSY-TENTATIVE
00077         ///
00078         enum FreeBusyFlagType {
00079                 Free = 0,
00080                 Tentative,
00081                 Busy,
00082                 OutOfOffice
00083         };
00084         FreeBusyFlagType FreeBusyFlag;
00085 
00086         ///
00087         /// Class Flag
00088         ///
00089         /// This is also called classification in Evolution and it
00090         ///  is the equivilant of public or private in outlook
00091         ///  Private is set to 0x2 in Outlook
00092         ///  RFC2445 CLASS is PUBLIC, PRIVATE, CONFIDENTIAL
00093         ///
00094         enum ClassFlagType {
00095                 Public = 0,
00096                 Confidential,
00097                 Private
00098         };
00099 
00100         ClassFlagType ClassFlag;
00101 
00102 
00103         unsigned short TimeZoneCode;    // the time zone originally used
00104                                         // for the recurrence data...
00105                                         // seems to have little use, but
00106                                         // set to your current time zone
00107                                         // as a good default
00108         bool TimeZoneValid;             // true if the record contained a
00109                                         // time zone code
00110 
00111         // unknown
00112         UnknownsType Unknowns;
00113 
00114 protected:
00115         static FreeBusyFlagType FreeBusyFlagProto2Rec(uint8_t f);
00116         static uint8_t FreeBusyFlagRec2Proto(FreeBusyFlagType f);
00117 
00118         static ClassFlagType ClassFlagProto2Rec(uint8_t f);
00119         static uint8_t ClassFlagRec2Proto(ClassFlagType f);
00120 
00121 public:
00122         const unsigned char* ParseField(const unsigned char *begin,
00123                 const unsigned char *end, const IConverter *ic = 0);
00124 
00125 public:
00126         Calendar();
00127         ~Calendar();
00128 
00129         // Parser / Builder API (see parser.h / builder.h)
00130         uint8_t GetRecType() const { return RecType; }
00131         uint32_t GetUniqueId() const { return RecordId; }
00132         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00133         void ParseHeader(const Data &data, size_t &offset);
00134         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00135         void BuildHeader(Data &data, size_t &offset) const;
00136         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
00137 
00138         void Clear();
00139 
00140         void Dump(std::ostream &os) const;
00141 
00142         // sorting
00143         bool operator<(const Calendar &other) const { return StartTime < other.StartTime; }
00144 
00145         // database name
00146         static const char * GetDBName() { return "Calendar"; }
00147         static uint8_t GetDefaultRecType() { return 5; }        // or 0?
00148 };
00149 
00150 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Calendar &msg) {
00151         msg.Dump(os);
00152         return os;
00153 }
00154 
00155 /// @}
00156 
00157 } // namespace Barry
00158 
00159 #endif
00160 

Generated on 29 Mar 2010 for Barry by  doxygen 1.6.1