Moved platform specific detail into tools/platform.h
[barry.git] / src / r_calllog.h
blob48acf41f02ad0fbd83a9ddacaf7cf25ed92aa8a0
1 ///
2 /// \file r_calllog.h
3 /// Record parsing class for call logs
4 ///
6 /*
7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #ifndef __BARRY_RECORD_CALLLOG_H__
24 #define __BARRY_RECORD_CALLLOG_H__
26 #include "dll.h"
27 #include "record.h"
28 #include <vector>
29 #include <string>
30 #include <stdint.h>
32 namespace Barry {
34 // forward declarations
35 class IConverter;
37 class BXEXPORT CallLog
39 public:
40 typedef std::vector<UnknownField> UnknownsType;
42 uint8_t RecType;
43 uint32_t RecordId;
45 uint32_t Duration; //< duration of call in seconds
46 uint64_t Timestamp; //< timestamp of call in milliseconds
47 //< use GetTime() to convert to
48 //< a time_t
49 std::string ContactName;
50 std::string PhoneNumber;
52 enum DirectionFlagType
54 Receiver = 0, //< We have received a call
55 Emitter, //< We have composed a call
56 Failed, //< We have missing a call and the
57 //< emitter is arrived on our
58 //< answering machine
59 Missing //< We have missing a call. The
60 //< emitter has stopped the
61 //< communication.
63 DirectionFlagType DirectionFlag;
65 enum StatusFlagType
67 OK = 0, //
68 Busy, //< We have sent the emitter on our
69 //< answering machine
70 NetError, //< Network communication error
71 Unknown //< Not supported by Barry CallLog parser
73 StatusFlagType StatusFlag;
75 enum PhoneTypeFlagType
77 TypeUndefined = 0,
78 TypeOffice,
79 TypeHome,
80 TypeMobile,
81 TypeUnknown // To be completed (Office2, Home2, Pager ???)
83 PhoneTypeFlagType PhoneTypeFlag;
85 enum PhoneInfoFlagType
87 InfoUndefined = 0,
88 InfoKnown, //< PhoneNumber should be set
89 InfoUnknown, //< PhoneNumber isn't set
90 InfoPrivate //< PhoneNumber is private
92 PhoneInfoFlagType PhoneInfoFlag;
94 UnknownsType Unknowns;
96 protected:
97 time_t GetTime() const;
99 static DirectionFlagType DirectionProto2Rec(uint8_t s);
100 static uint8_t DirectionRec2Proto(DirectionFlagType s);
102 static PhoneTypeFlagType PhoneTypeProto2Rec(uint8_t s);
103 static uint8_t PhoneTypeRec2Proto(PhoneTypeFlagType s);
105 public:
106 CallLog();
107 ~CallLog();
109 // Parser / Builder API (see parser.h / builder.h)
110 const unsigned char* ParseField(const unsigned char *begin,
111 const unsigned char *end, const IConverter *ic = 0);
112 uint8_t GetRecType() const { return RecType; }
113 uint32_t GetUniqueId() const { return RecordId; }
114 void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
115 void ParseHeader(const Data &data, size_t &offset);
116 void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
118 void Clear();
120 void Dump(std::ostream &os) const;
122 // Sorting
123 bool operator<(const CallLog &other) const { return Timestamp < other.Timestamp; }
125 // database name
126 static const char * GetDBName() { return "Phone Call Logs"; }
127 static uint8_t GetDefaultRecType() { return 0; }
130 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CallLog &msg) {
131 msg.Dump(os);
132 return os;
135 } // namespace Barry
137 #endif