00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BARRY_RECORD_MESSAGE_H__
00023 #define __BARRY_RECORD_MESSAGE_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
00037
00038
00039
00040
00041
00042
00043 class BXEXPORT Message
00044 {
00045 public:
00046 uint8_t RecType;
00047 uint32_t RecordId;
00048
00049 EmailAddress From;
00050 EmailAddress To;
00051 EmailAddress Cc;
00052 EmailAddress Bcc;
00053 EmailAddress Sender;
00054 EmailAddress ReplyTo;
00055 std::string Subject;
00056 std::string Body;
00057 std::string Attachment;
00058 uint32_t MessageRecordId;
00059 uint32_t MessageReplyTo;
00060 time_t MessageDateSent;
00061 time_t MessageDateReceived;
00062
00063
00064 bool MessageTruncated;
00065 bool MessageRead;
00066 bool MessageReply;
00067 bool MessageSaved;
00068 bool MessageSavedDeleted;
00069
00070 enum MessagePriorityType {
00071 LowPriority = 0,
00072 NormalPriority,
00073 HighPriority,
00074 UnknownPriority
00075 };
00076 MessagePriorityType MessagePriority;
00077
00078 enum MessageSensitivityType {
00079 NormalSensitivity = 0,
00080 Personal,
00081 Private,
00082 Confidential,
00083 UnknownSensitivity
00084 };
00085 MessageSensitivityType MessageSensitivity;
00086
00087 std::vector<UnknownField> Unknowns;
00088
00089 protected:
00090 std::string SimpleEmailAddress() const;
00091
00092 public:
00093 const unsigned char* ParseField(const unsigned char *begin,
00094 const unsigned char *end);
00095
00096 public:
00097 Message();
00098 ~Message();
00099
00100
00101 uint8_t GetRecType() const;
00102 uint32_t GetUniqueId() const;
00103 void SetIds(uint8_t Type, uint32_t Id){ RecType = Type; RecordId = Id; }
00104 void ParseHeader(const Data &data, size_t &offset);
00105 void ParseFields(const Data &data, size_t &offset);
00106 void BuildHeader(Data &data, size_t &offset) const;
00107 void BuildFields(Data &data, size_t &offset) const;
00108
00109 void Clear();
00110
00111 void Dump(std::ostream &os) const;
00112
00113
00114 bool operator<(const Message &other) const { return Subject < other.Subject; }
00115
00116
00117 static const char * GetDBName() { return "Messages"; }
00118 static uint8_t GetDefaultRecType() { return 0; }
00119 };
00120
00121 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Message &msg) {
00122 msg.Dump(os);
00123 return os;
00124 }
00125
00126
00127
00128 }
00129
00130 #endif
00131