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-2009, 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 <iosfwd>
00028 #include <string>
00029 #include <vector>
00030 #include <map>
00031 #include <stdint.h>
00032 
00033 namespace Barry {
00034 
00035 // forward declarations
00036 class IConverter;
00037 
00038 //
00039 // NOTE:  All classes here must be container-safe!  Perhaps add sorting
00040 //        operators in the future.
00041 //
00042 
00043 
00044 
00045 /// \addtogroup RecordParserClasses
00046 /// @{
00047 
00048 class BXEXPORT Calendar
00049 {
00050 public:
00051         typedef std::vector<UnknownField>               UnknownsType;
00052 
00053         uint8_t RecType;
00054         uint32_t RecordId;
00055 
00056         // general data
00057         bool AllDayEvent;
00058         std::string Subject;
00059         std::string Notes;
00060         std::string Location;
00061         time_t NotificationTime;        // 0 means notification is off
00062         time_t StartTime;
00063         time_t EndTime;
00064 
00065         ///
00066         /// Free Busy Flag
00067         ///
00068         /// This lists the available settings found in the device.
00069         /// This list is based on information from MS Outlook 2007
00070         /// (Free ==0 and Busy == 2)
00071         /// This is FBTYPE in RFC2445 and is defined as
00072         /// FREE, BUSY, BUSY-UNAVAILABLE and BUSY-TENTATIVE
00073         ///
00074         enum FreeBusyFlagType {
00075                 Free = 0,
00076                 Tentative,
00077                 Busy,
00078                 OutOfOffice
00079         };
00080         FreeBusyFlagType FreeBusyFlag;
00081 
00082         ///
00083         /// Class Flag
00084         ///
00085         /// This is also called classification in Evolution and it
00086         ///  is the equivilant of public or private in outlook
00087         ///  Private is set to 0x2 in Outlook
00088         ///  RFC2445 CLASS is PUBLIC, PRIVATE, CONFIDENTIAL
00089         ///
00090         enum ClassFlagType {
00091                 Public = 0,
00092                 Confidential,
00093                 Private
00094         };
00095 
00096         ClassFlagType ClassFlag;
00097 
00098         ///
00099         /// Recurring data
00100         ///
00101         /// Note: interval can be used on all of these recurring types to
00102         ///       make it happen "every other time" or more, etc.
00103         ///
00104         enum RecurringCodeType {
00105                 Day = 1,                //< eg. every day
00106                                         //< set: nothing
00107                 MonthByDate = 3,        //< eg. every month on the 12th
00108                                         //< set: DayOfMonth
00109                 MonthByDay = 4,         //< eg. every month on 3rd Wed
00110                                         //< set: DayOfWeek and WeekOfMonth
00111                 YearByDate = 5,         //< eg. every year on March 5
00112                                         //< set: DayOfMonth and MonthOfYear
00113                 YearByDay = 6,          //< eg. every year on 3rd Wed of Jan
00114                                         //< set: DayOfWeek, WeekOfMonth, and
00115                                         //<      MonthOfYear
00116                 Week = 12               //< eg. every week on Mon and Fri
00117                                         //< set: WeekDays
00118         };
00119     
00120         
00121         
00122         bool Recurring;
00123         RecurringCodeType RecurringType;
00124         unsigned short Interval;        // must be >= 1
00125         time_t RecurringEndTime;        // only pertains if Recurring is true
00126                                         // sets the date and time when
00127                                         // recurrence of this appointment
00128                                         // should no longer occur
00129                                         // If a perpetual appointment, this
00130                                         // is 0xFFFFFFFF in the low level data
00131                                         // Instead, set the following flag.
00132         bool Perpetual;                 // if true, this will always recur
00133         unsigned short TimeZoneCode;    // the time zone originally used
00134                                         // for the recurrence data...
00135                                         // seems to have little use, but
00136                                         // set to your current time zone
00137                                         // as a good default
00138         bool TimeZoneValid;             // true if the record contained a
00139                                         // time zone code
00140 
00141         unsigned short                  // recurring details, depending on type
00142                 DayOfWeek,              // 0-6
00143                 WeekOfMonth,            // 1-5
00144                 DayOfMonth,             // 1-31
00145                 MonthOfYear;            // 1-12
00146         unsigned char WeekDays;         // bitmask, bit 0 = sunday
00147 
00148 // FIXME - put these somewhere usable by both C and C++
00149                 #define CAL_WD_SUN      0x01
00150                 #define CAL_WD_MON      0x02
00151                 #define CAL_WD_TUE      0x04
00152                 #define CAL_WD_WED      0x08
00153                 #define CAL_WD_THU      0x10
00154                 #define CAL_WD_FRI      0x20
00155                 #define CAL_WD_SAT      0x40
00156 
00157         // unknown
00158         UnknownsType Unknowns;
00159 
00160 public:
00161         const unsigned char* ParseField(const unsigned char *begin,
00162                 const unsigned char *end, const IConverter *ic = 0);
00163         void ParseRecurrenceData(const void *data);
00164         void BuildRecurrenceData(void *data) const;
00165 
00166 public:
00167         Calendar();
00168         ~Calendar();
00169 
00170         // Parser / Builder API (see parser.h / builder.h)
00171         uint8_t GetRecType() const { return RecType; }
00172         uint32_t GetUniqueId() const { return RecordId; }
00173         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00174         void ParseHeader(const Data &data, size_t &offset);
00175         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00176         void BuildHeader(Data &data, size_t &offset) const;
00177         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
00178 
00179         void Clear();
00180 
00181         void Dump(std::ostream &os) const;
00182 
00183         // sorting
00184         bool operator<(const Calendar &other) const { return StartTime < other.StartTime; }
00185 
00186         // database name
00187         static const char * GetDBName() { return "Calendar"; }
00188         static uint8_t GetDefaultRecType() { return 5; }        // or 0?
00189 };
00190 
00191 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Calendar &msg) {
00192         msg.Dump(os);
00193         return os;
00194 }
00195 
00196 /// @}
00197 
00198 } // namespace Barry
00199 
00200 #endif
00201 

Generated on Mon Jan 12 10:51:13 2009 for Barry by  doxygen 1.5.7.1