3 /// Blackberry database record parser class for Handheld Agent records
7 Copyright (C) 2011-2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_RECORD_HHAGENT_H__
23 #define __BARRY_RECORD_HHAGENT_H__
30 // forward declarations
34 // NOTE: All classes here must be container-safe! Perhaps add sorting
35 // operators in the future.
38 /// \addtogroup RecordParserClasses
42 // Handheld Agent record class
44 /// Represents a single record in the Handheld Agent database.
46 class BXEXPORT HandheldAgent
49 typedef Barry::UnknownsType UnknownsType
;
55 // contact specific data
62 std::string Pin
; // may not be valid for every record
64 std::string PlatformVersion
;
65 std::string Manufacturer
;
68 UnknownsType Unknowns
;
71 const unsigned char* ParseField(const unsigned char *begin
,
72 const unsigned char *end
, const IConverter
*ic
= 0);
78 uint32_t GetID() const { return RecordId
; }
79 std::string
GetFullName() const;
80 const std::string
& GetEmail(unsigned int index
= 0) const;
82 // Parser / Builder API (see parser.h / builder.h)
83 uint8_t GetRecType() const { return RecType
; }
84 uint32_t GetUniqueId() const { return RecordId
; }
85 void SetIds(uint8_t Type
, uint32_t Id
) { RecType
= Type
; RecordId
= Id
; }
86 void ParseHeader(const Data
&data
, size_t &offset
);
87 void ParseFields(const Data
&data
, size_t &offset
, const IConverter
*ic
= 0);
88 void BuildHeader(Data
&data
, size_t &offset
) const;
89 void BuildFields(Data
&data
, size_t &offset
, const IConverter
*ic
= 0) const;
91 // operations (common among record classes)
92 void Clear(); // erase everything
93 void Dump(std::ostream
&os
) const;
94 std::string
GetDescription() const;
96 // Sorting - use enough data to make the sorting as
97 // consistent as possible
98 bool operator<(const HandheldAgent
&other
) const;
101 static const char * GetDBName() { return "Handheld Agent"; }
102 static uint8_t GetDefaultRecType() { return 0; }
103 static uint32_t GetMEIDRecordId() { return 0x3000000; }
104 static uint32_t GetUnknown1RecordId() { return 0x4000000; }
105 static uint32_t GetUnknown2RecordId() { return 0x5000000; }
106 static uint32_t GetUnknown3RecordId() { return 0x7000000; }
107 static bool IsSpecial(uint32_t record_id
);
110 static bool IsESNHex(const std::string
&esn
);
111 static bool IsESNDec(const std::string
&esn
);
112 static std::string
ESNDec2Hex(const std::string
&esn
);
113 static std::string
ESNHex2Dec(const std::string
&esn
);
115 // Generic Field Handle support
116 static const std::vector
<FieldHandle
<HandheldAgent
> >& GetFieldHandles();
119 BXEXPORT
inline std::ostream
& operator<< (std::ostream
&os
, const HandheldAgent
&hha
) {