|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "CSFLog.h" |
|
6 |
|
7 #include "CC_Common.h" |
|
8 |
|
9 #include "csf_common.h" |
|
10 #include "CC_SIPCCLineInfo.h" |
|
11 #include "CC_SIPCCLine.h" |
|
12 #include "CC_SIPCCCall.h" |
|
13 |
|
14 extern "C" |
|
15 { |
|
16 #include "cpr_types.h" |
|
17 #include "ccapi_line.h" |
|
18 #include "ccapi_line_info.h" |
|
19 } |
|
20 |
|
21 using namespace std; |
|
22 using namespace CSF; |
|
23 |
|
24 #define MAX_SUPPORTED_NUM_CALLS 100 |
|
25 |
|
26 //FIXME: Header file "ccapi_line.h" has misnamed the retain function as "CCAPI_Device_retainLineInfo" |
|
27 // Checked the source file and it's declared correctly there, so I have to declare it myself here. |
|
28 |
|
29 //Also CCAPI_LineInfo_getCalls() in source file and CCAPI_lineInfo_getCalls() in header (lowercase 'l' in lineInfo) |
|
30 |
|
31 extern "C" void CCAPI_Line_retainLineInfo(cc_lineinfo_ref_t ref); |
|
32 extern "C" void CCAPI_LineInfo_getCalls(cc_lineid_t line, cc_call_handle_t handles[], int *count); |
|
33 extern "C" void CCAPI_LineInfo_getCallsByState(cc_lineid_t line, cc_call_state_t state, cc_call_handle_t handles[], int *count); |
|
34 |
|
35 CSF_IMPLEMENT_WRAP(CC_SIPCCLineInfo, cc_lineinfo_ref_t); |
|
36 |
|
37 CC_SIPCCLineInfo::CC_SIPCCLineInfo (cc_lineinfo_ref_t lineinfo) : lineinfo(lineinfo) |
|
38 { |
|
39 CCAPI_Line_retainLineInfo(lineinfo); |
|
40 } |
|
41 |
|
42 CC_SIPCCLineInfo::~CC_SIPCCLineInfo() |
|
43 { |
|
44 CCAPI_Line_releaseLineInfo(lineinfo); |
|
45 } |
|
46 |
|
47 string CC_SIPCCLineInfo::getName() |
|
48 { |
|
49 return CCAPI_lineInfo_getName(lineinfo); |
|
50 } |
|
51 |
|
52 string CC_SIPCCLineInfo::getNumber() |
|
53 { |
|
54 return CCAPI_lineInfo_getNumber(lineinfo); |
|
55 } |
|
56 |
|
57 cc_uint32_t CC_SIPCCLineInfo::getButton() |
|
58 { |
|
59 return CCAPI_lineInfo_getButton(lineinfo); |
|
60 } |
|
61 |
|
62 cc_line_feature_t CC_SIPCCLineInfo::getLineType() |
|
63 { |
|
64 return CCAPI_lineInfo_getLineType(lineinfo); |
|
65 } |
|
66 |
|
67 bool CC_SIPCCLineInfo::getRegState() |
|
68 { |
|
69 if (CCAPI_lineInfo_getRegState(lineinfo)) |
|
70 { |
|
71 return true; |
|
72 } |
|
73 else |
|
74 { |
|
75 return false; |
|
76 } |
|
77 } |
|
78 |
|
79 bool CC_SIPCCLineInfo::isCFWDActive() |
|
80 { |
|
81 if (CCAPI_lineInfo_isCFWDActive(lineinfo)) |
|
82 { |
|
83 return true; |
|
84 } |
|
85 else |
|
86 { |
|
87 return false; |
|
88 } |
|
89 } |
|
90 |
|
91 string CC_SIPCCLineInfo::getCFWDName() |
|
92 { |
|
93 return CCAPI_lineInfo_getCFWDName(lineinfo); |
|
94 } |
|
95 |
|
96 vector<CC_CallPtr> CC_SIPCCLineInfo::getCalls (CC_LinePtr linePtr) |
|
97 { |
|
98 vector<CC_CallPtr> callsVector; |
|
99 |
|
100 cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {}; |
|
101 int numCalls = csf_countof(handles); |
|
102 |
|
103 CCAPI_LineInfo_getCalls(linePtr->getID(), handles, &numCalls) ; |
|
104 |
|
105 for (int i=0; i<numCalls; i++) |
|
106 { |
|
107 CC_CallPtr callPtr = CC_SIPCCCall::wrap(handles[i]).get(); |
|
108 callsVector.push_back(callPtr); |
|
109 } |
|
110 |
|
111 return callsVector; |
|
112 } |
|
113 |
|
114 vector<CC_CallPtr> CC_SIPCCLineInfo::getCallsByState (CC_LinePtr linePtr, cc_call_state_t state) |
|
115 { |
|
116 vector<CC_CallPtr> callsVector; |
|
117 |
|
118 cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {}; |
|
119 int numCalls = csf_countof(handles); |
|
120 |
|
121 CCAPI_LineInfo_getCallsByState(linePtr->getID(), state, handles, &numCalls) ; |
|
122 |
|
123 for (int i=0; i<numCalls; i++) |
|
124 { |
|
125 CC_CallPtr callPtr = CC_SIPCCCall::wrap(handles[i]).get(); |
|
126 callsVector.push_back(callPtr); |
|
127 } |
|
128 |
|
129 return callsVector; |
|
130 } |
|
131 |
|
132 bool CC_SIPCCLineInfo::getMWIStatus() |
|
133 { |
|
134 return (CCAPI_lineInfo_getMWIStatus(lineinfo) != 0); |
|
135 } |
|
136 |
|
137 cc_uint32_t CC_SIPCCLineInfo::getMWIType() |
|
138 { |
|
139 return CCAPI_lineInfo_getMWIType(lineinfo); |
|
140 } |
|
141 |
|
142 cc_uint32_t CC_SIPCCLineInfo::getMWINewMsgCount() |
|
143 { |
|
144 return CCAPI_lineInfo_getMWINewMsgCount(lineinfo); |
|
145 } |
|
146 |
|
147 cc_uint32_t CC_SIPCCLineInfo::getMWIOldMsgCount() |
|
148 { |
|
149 return CCAPI_lineInfo_getMWIOldMsgCount(lineinfo); |
|
150 } |
|
151 |
|
152 cc_uint32_t CC_SIPCCLineInfo::getMWIPrioNewMsgCount() |
|
153 { |
|
154 return CCAPI_lineInfo_getMWIPrioNewMsgCount(lineinfo); |
|
155 } |
|
156 |
|
157 cc_uint32_t CC_SIPCCLineInfo::getMWIPrioOldMsgCount() |
|
158 { |
|
159 return CCAPI_lineInfo_getMWIPrioOldMsgCount(lineinfo); |
|
160 } |
|
161 |
|
162 bool CC_SIPCCLineInfo::hasCapability(ccapi_call_capability_e capability) |
|
163 { |
|
164 return CCAPI_LineInfo_hasCapability(lineinfo, (cc_int32_t) capability) == TRUE; |
|
165 } |
|
166 |
|
167 bitset<CCAPI_CALL_CAP_MAX> CC_SIPCCLineInfo::getCapabilitySet() |
|
168 { |
|
169 bitset<CCAPI_CALL_CAP_MAX> lineCaps; |
|
170 |
|
171 for (int i=0; i<CCAPI_CALL_CAP_MAX; i++) |
|
172 { |
|
173 if (hasCapability((ccapi_call_capability_e) i)) |
|
174 { |
|
175 lineCaps.set(i, true); |
|
176 } |
|
177 } |
|
178 |
|
179 return lineCaps; |
|
180 } |
|
181 |