r_calendar.h

Go to the documentation of this file.
00001 ///
00002 /// \file       r_calendar.h
00003 ///             Blackberry database record parser class for calendar records.
00004 ///
00005 
00006 /*
00007     Copyright (C) 2005-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_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 Barry::UnknownsType             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         uint64_t CalendarID;    // Calendar ID (usefull if devices have several calendars)
00103 
00104         unsigned short TimeZoneCode;    // the time zone originally used
00105                                         // for the recurrence data...
00106                                         // seems to have little use, but
00107                                         // set to your current time zone
00108                                         // as a good default
00109         bool TimeZoneValid;             // true if the record contained a
00110                                         // time zone code
00111 
00112         // unknown
00113         UnknownsType Unknowns;
00114 
00115 protected:
00116         static FreeBusyFlagType FreeBusyFlagProto2Rec(uint8_t f);
00117         static uint8_t FreeBusyFlagRec2Proto(FreeBusyFlagType f);
00118 
00119         static ClassFlagType ClassFlagProto2Rec(uint8_t f);
00120         static uint8_t ClassFlagRec2Proto(ClassFlagType f);
00121 
00122         virtual void DumpSpecialFields(std::ostream &os) const;
00123 
00124 public:
00125         const unsigned char* ParseField(const unsigned char *begin,
00126                 const unsigned char *end, const IConverter *ic = 0);
00127 
00128 public:
00129         Calendar();
00130         ~Calendar();
00131 
00132         // Parser / Builder API (see parser.h / builder.h)
00133         uint8_t GetRecType() const { return RecType; }
00134         uint32_t GetUniqueId() const { return RecordId; }
00135         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00136         void ParseHeader(const Data &data, size_t &offset);
00137         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00138         void BuildHeader(Data &data, size_t &offset) const;
00139         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
00140 
00141         // operations (common among record classes)
00142         void Clear();
00143         void Dump(std::ostream &os) const;
00144         std::string GetDescription() const;
00145 
00146         // sorting
00147         bool operator<(const Calendar &other) const;
00148 
00149         // database name
00150         static const char * GetDBName() { return "Calendar"; }
00151         static uint8_t GetDefaultRecType() { return 5; }        // or 0?
00152 };
00153 
00154 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Calendar &msg) {
00155         msg.Dump(os);
00156         return os;
00157 }
00158 
00159 
00160 class BXEXPORT CalendarAll : public Calendar
00161 {
00162 protected:
00163         virtual void DumpSpecialFields(std::ostream &os) const;
00164 
00165 public:
00166         std::string MailAccount;
00167 
00168 public:
00169         // Parser / Builder API (see parser.h / builder.h)
00170         void ParseHeader(const Data &data, size_t &offset);
00171 
00172         void Clear();
00173 
00174 public:
00175         // database name
00176         static const char * GetDBName() { return "Calendar - All"; }
00177 };
00178 
00179 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CalendarAll &msg) {
00180         msg.Dump(os);
00181         return os;
00182 }
00183 
00184 
00185 /// @}
00186 
00187 } // namespace Barry
00188 
00189 #endif
00190 

Generated on Tue Mar 1 17:50:16 2011 for Barry by  doxygen 1.5.6