Fixed .la dependency tracking for -lpthread
[barry.git] / src / r_hhagent.h
blobfb7b9436fb40bdfb1d398d2172e62c67fb2365a9
1 ///
2 /// \file r_hhagent.h
3 /// Blackberry database record parser class for Handheld Agent records
4 ///
6 /*
7 Copyright (C) 2011, 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__
25 #include "dll.h"
26 #include "record.h"
28 namespace Barry {
30 // forward declarations
31 class IConverter;
34 // NOTE: All classes here must be container-safe! Perhaps add sorting
35 // operators in the future.
38 /// \addtogroup RecordParserClasses
39 /// @{
42 // Handheld Agent record class
44 /// Represents a single record in the Handheld Agent database.
45 ///
46 class BXEXPORT HandheldAgent
48 public:
49 typedef Barry::UnknownsType UnknownsType;
52 // Record fields
55 // contact specific data
56 uint8_t RecType;
57 uint32_t RecordId;
59 std::string MEID;
60 std::string Model;
61 std::string Bands;
62 std::string Pin; // may not be valid for every record
63 std::string Version;
64 std::string PlatformVersion;
65 std::string Manufacturer;
66 std::string Network;
68 UnknownsType Unknowns;
70 public:
71 const unsigned char* ParseField(const unsigned char *begin,
72 const unsigned char *end, const IConverter *ic = 0);
74 public:
75 HandheldAgent();
76 ~HandheldAgent();
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;
100 // database name
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);
109 // utility functions
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);
116 BXEXPORT inline std::ostream& operator<< (std::ostream &os, const HandheldAgent &hha) {
117 hha.Dump(os);
118 return os;
121 /// @}
123 } // namespace Barry
125 #endif