r_saved_message.h

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

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