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

Generated on Wed Sep 24 21:27:32 2008 for Barry by  doxygen 1.5.1