3 /// Record parsing class for call logs
7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2005-2012, 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__
34 // forward declarations
37 class BXEXPORT CallLog
40 typedef Barry::UnknownsType UnknownsType
;
45 uint32_t Duration
; //< duration of call in seconds
46 uint64_t Timestamp
; //< timestamp of call in milliseconds
47 //< use GetTime() to convert to
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
59 Missing
//< We have missing a call. The
60 //< emitter has stopped the
63 DirectionFlagType DirectionFlag
;
68 Busy
, //< We have sent the emitter on our
70 NetError
, //< Network communication error
71 Unknown
//< Not supported by Barry CallLog parser
73 StatusFlagType StatusFlag
;
75 enum PhoneTypeFlagType
81 TypeUnknown
// To be completed (Office2, Home2, Pager ???)
83 PhoneTypeFlagType PhoneTypeFlag
;
85 enum PhoneInfoFlagType
88 InfoKnown
, //< PhoneNumber should be set
89 InfoUnknown
, //< PhoneNumber isn't set
90 InfoPrivate
//< PhoneNumber is private
92 PhoneInfoFlagType PhoneInfoFlag
;
94 UnknownsType Unknowns
;
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
);
109 // Parser / Builder API (see parser.h / builder.h)
110 void Validate() const;
111 const unsigned char* ParseField(const unsigned char *begin
,
112 const unsigned char *end
, const IConverter
*ic
= 0);
113 uint8_t GetRecType() const { return RecType
; }
114 uint32_t GetUniqueId() const { return RecordId
; }
115 void SetIds(uint8_t Type
, uint32_t Id
) { RecType
= Type
; RecordId
= Id
; }
116 void ParseHeader(const Data
&data
, size_t &offset
);
117 void ParseFields(const Data
&data
, size_t &offset
, const IConverter
*ic
= 0);
118 void BuildHeader(Data
&data
, size_t &offset
) const;
119 void BuildFields(Data
&data
, size_t &offset
, const IConverter
*ic
= 0) const;
121 // operations (common among record classes)
123 void Dump(std::ostream
&os
) const;
124 std::string
GetDescription() const;
127 bool operator<(const CallLog
&other
) const { return Timestamp
< other
.Timestamp
; }
130 static const char * GetDBName() { return "Phone Call Logs"; }
131 static uint8_t GetDefaultRecType() { return 0; }
133 // Generic Field Handle support
134 static const FieldHandle
<CallLog
>::ListT
& GetFieldHandles();
137 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const CallLog
&msg
) {