r_pin_message.h

Go to the documentation of this file.
00001 ///
00002 /// \file       r_pin_message.h
00003 ///             Blackberry database record parser class for pin message records.
00004 ///
00005 
00006 /*
00007     Copyright (C) 2005-2008, Net Direct Inc. (http://www.netdirect.ca/)
00008     Copyright (C) 2007, Brian Edginton (edge@edginton.net)
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 
00019     See the GNU General Public License in the COPYING file at the
00020     root directory of this project for more details.
00021 */
00022 
00023 #ifndef __BARRY_RECORD_PIN_MESSAGE_H__
00024 #define __BARRY_RECORD_PIN_MESSAGE_H__
00025 
00026 #include "dll.h"
00027 #include "record.h"
00028 #include <iosfwd>
00029 #include <string>
00030 #include <vector>
00031 #include <map>
00032 #include <stdint.h>
00033 
00034 namespace Barry {
00035 
00036 //
00037 // NOTE:  All classes here must be container-safe!  Perhaps add sorting
00038 //        operators in the future.
00039 //
00040 
00041 /// \addtogroup RecordParserClasses
00042 /// @{
00043 
00044 class BXEXPORT PINMessage
00045 {
00046 public:
00047         uint8_t RecType;
00048         uint32_t RecordId;
00049 
00050         EmailAddress From;
00051         EmailAddress To;
00052         EmailAddress Cc;
00053         EmailAddress Bcc;
00054         std::string Subject;
00055         std::string Body;
00056         uint32_t MessageRecordId;       // this happens to be the same as
00057                                         // RecordId in my (CDF) testing,
00058                                         // but interestingly, it is stored
00059                                         // as a field *inside* the record,
00060                                         // and not as part of the header...
00061                                         // in effect, this record ID occurs
00062                                         // twice in the protocol
00063         uint32_t MessageReplyTo;
00064         time_t MessageDateSent;
00065         time_t MessageDateReceived;
00066         
00067         // Message Flags
00068         bool    MessageTruncated;
00069         bool    MessageRead;
00070         bool    MessageReply;
00071         bool    MessageSaved;
00072         bool    MessageSavedDeleted;
00073         
00074         enum MessagePriorityType {
00075                 LowPriority = 0,
00076                 NormalPriority,
00077                 HighPriority,
00078                 UnknownPriority
00079         };
00080         MessagePriorityType MessagePriority;
00081         
00082         enum MessageSensitivityType {
00083                 NormalSensitivity = 0,
00084                 Personal,
00085                 Private,
00086                 Confidential,
00087                 UnknownSensitivity
00088         };
00089         MessageSensitivityType MessageSensitivity;
00090         
00091         std::vector<UnknownField> Unknowns;
00092 
00093 public:
00094         const unsigned char* ParseField(const unsigned char *begin,
00095                 const unsigned char *end);
00096 
00097 public:
00098         PINMessage();
00099         ~PINMessage();
00100 
00101         // Parser / Builder API (see parser.h / builder.h)
00102         uint8_t GetRecType() const { return RecType; }
00103         uint32_t GetUniqueId() const { return RecordId; }
00104         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00105         void ParseHeader(const Data &data, size_t &offset);
00106         void ParseFields(const Data &data, size_t &offset);
00107         void BuildHeader(Data &data, size_t &offset) const;
00108         void BuildFields(Data &data, size_t &offset) const;
00109 
00110         void Clear();
00111 
00112         void Dump(std::ostream &os) const;
00113 
00114         // sorting
00115         bool operator<(const PINMessage &other) const { return Subject < other.Subject; }
00116 
00117         // database name
00118         static const char * GetDBName() { return "PIN Messages"; }
00119         static uint8_t GetDefaultRecType() { return 0; }
00120 };
00121 
00122 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const PINMessage &msg) {
00123         msg.Dump(os);
00124         return os;
00125 }
00126 
00127 /// @}
00128 
00129 } // namespace Barry
00130 
00131 #endif // __BARRY_RECORD_PIN_MESSAGE_H__
00132 
00133 

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