debian: added giffgaff chatscripts
[barry.git] / src / r_hhagent.h
blob565739df22ba5c7cea7047dad265b80b67ffd706
1 ///
2 /// \file r_hhagent.h
3 /// Blackberry database record parser class for Handheld Agent records
4 ///
6 /*
7 Copyright (C) 2011-2013, 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 void Validate() const;
84 uint8_t GetRecType() const { return RecType; }
85 uint32_t GetUniqueId() const { return RecordId; }
86 void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
87 void ParseHeader(const Data &data, size_t &offset);
88 void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
89 void BuildHeader(Data &data, size_t &offset) const;
90 void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
92 // operations (common among record classes)
93 void Clear(); // erase everything
94 void Dump(std::ostream &os) const;
95 std::string GetDescription() const;
97 // Sorting - use enough data to make the sorting as
98 // consistent as possible
99 bool operator<(const HandheldAgent &other) const;
101 // database name
102 static const char * GetDBName() { return "Handheld Agent"; }
103 static uint8_t GetDefaultRecType() { return 0; }
104 static uint32_t GetMEIDRecordId() { return 0x3000000; }
105 static uint32_t GetUnknown1RecordId() { return 0x4000000; }
106 static uint32_t GetUnknown2RecordId() { return 0x5000000; }
107 static uint32_t GetUnknown3RecordId() { return 0x7000000; }
108 static bool IsSpecial(uint32_t record_id);
110 // utility functions
111 static bool IsESNHex(const std::string &esn);
112 static bool IsESNDec(const std::string &esn);
113 static std::string ESNDec2Hex(const std::string &esn);
114 static std::string ESNHex2Dec(const std::string &esn);
116 // Generic Field Handle support
117 static const FieldHandle<HandheldAgent>::ListT& GetFieldHandles();
120 BXEXPORT inline std::ostream& operator<< (std::ostream &os, const HandheldAgent &hha) {
121 hha.Dump(os);
122 return os;
125 /// @}
127 } // namespace Barry
129 #endif