r_sms.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __BARRY_RECORD_SMS_H__
00024 #define __BARRY_RECORD_SMS_H__
00025
00026 #include "dll.h"
00027 #include "record.h"
00028 #include <vector>
00029 #include <string>
00030 #include <stdint.h>
00031
00032 namespace Barry {
00033
00034
00035 class IConverter;
00036
00037 class BXEXPORT Sms
00038 {
00039 public:
00040 typedef std::vector<UnknownField> UnknownsType;
00041
00042 uint8_t RecType;
00043 uint32_t RecordId;
00044
00045 enum MessageType
00046 {
00047 Unknown = 0,
00048 Received,
00049 Sent,
00050 Draft
00051 };
00052 MessageType MessageStatus;
00053
00054 enum DeliveryType
00055 {
00056 NoReport = 0,
00057 Failed,
00058 Succedded
00059 };
00060 DeliveryType DeliveryStatus;
00061
00062 bool IsNew;
00063 bool NewConversation;
00064 bool Saved;
00065 bool Deleted;
00066 bool Opened;
00067
00068 uint64_t Timestamp;
00069 uint64_t ServiceCenterTimestamp;
00070
00071 enum DataCodingSchemeType
00072 {
00073 SevenBit = 0,
00074 EightBit,
00075 UCS2
00076 };
00077 DataCodingSchemeType DataCodingScheme;
00078
00079 uint32_t ErrorId;
00080
00081 std::vector<std::string> Addresses;
00082 std::string Body;
00083
00084 UnknownsType Unknowns;
00085
00086 public:
00087 Sms();
00088 ~Sms();
00089
00090 time_t GetTime() const;
00091 time_t GetServiceCenterTime() const;
00092 void SetTime(const time_t timestamp, unsigned int milliseconds = 0);
00093 void SetServiceCenterTime(const time_t timestamp, unsigned int milliseconds = 0);
00094
00095 const unsigned char* ParseField(const unsigned char *begin, const unsigned char *end, const IConverter *ic = 0);
00096 uint8_t GetRecType() const { return RecType; }
00097 uint32_t GetUniqueId() const { return RecordId; }
00098 void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00099 void ParseHeader(const Data &data, size_t &offset);
00100 void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00101 void BuildHeader(Data &data, size_t &offset) const;
00102
00103 void Clear();
00104
00105 void Dump(std::ostream &os) const;
00106
00107
00108 bool operator<(const Sms &other) const {
00109 return Timestamp < other.Timestamp;
00110 }
00111
00112
00113 static const char * GetDBName() { return "SMS Messages"; }
00114 static uint8_t GetDefaultRecType() { return 5; }
00115 };
00116
00117 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Sms &msg) {
00118 msg.Dump(os);
00119 return os;
00120 }
00121
00122 }
00123
00124 #endif
00125