|
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 "CC_SIPCCDeviceInfo.h" |
|
10 #include "CC_SIPCCFeatureInfo.h" |
|
11 #include "CC_SIPCCCallServerInfo.h" |
|
12 #include "CC_SIPCCCall.h" |
|
13 #include "CC_SIPCCLine.h" |
|
14 |
|
15 #include "csf_common.h" |
|
16 |
|
17 extern "C" |
|
18 { |
|
19 #include "cpr_types.h" |
|
20 #include "ccapi_device.h" |
|
21 #include "ccapi_device_info.h" |
|
22 } |
|
23 |
|
24 using namespace std; |
|
25 using namespace CSF; |
|
26 |
|
27 #define MAX_SUPPORTED_NUM_CALLS 100 |
|
28 #define MAX_SUPPORTED_NUM_LINES 100 |
|
29 #define MAX_SUPPORTED_NUM_FEATURES 100 |
|
30 #define MAX_SUPPORTED_NUM_CALL_SERVERS 100 |
|
31 |
|
32 |
|
33 CSF_IMPLEMENT_WRAP(CC_SIPCCDeviceInfo, cc_deviceinfo_ref_t); |
|
34 |
|
35 CC_SIPCCDeviceInfo::CC_SIPCCDeviceInfo (cc_deviceinfo_ref_t deviceinfo) |
|
36 : deviceinfo_ref(deviceinfo) |
|
37 { |
|
38 CCAPI_Device_retainDeviceInfo(deviceinfo_ref); |
|
39 } |
|
40 |
|
41 CC_SIPCCDeviceInfo::~CC_SIPCCDeviceInfo() |
|
42 { |
|
43 CCAPI_Device_releaseDeviceInfo(deviceinfo_ref); |
|
44 } |
|
45 |
|
46 string CC_SIPCCDeviceInfo::getDeviceName() |
|
47 { |
|
48 return CCAPI_DeviceInfo_getDeviceName(deviceinfo_ref); |
|
49 } |
|
50 |
|
51 vector<CC_CallPtr> CC_SIPCCDeviceInfo::getCalls () |
|
52 { |
|
53 vector<CC_CallPtr> callsVector; |
|
54 |
|
55 cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {}; |
|
56 cc_uint16_t numHandles = csf_countof(handles); |
|
57 |
|
58 CCAPI_DeviceInfo_getCalls(deviceinfo_ref, handles, &numHandles) ; |
|
59 |
|
60 for (int i=0; i<numHandles; i++) |
|
61 { |
|
62 CC_CallPtr callPtr = CC_SIPCCCall::wrap(handles[i]).get(); |
|
63 callsVector.push_back(callPtr); |
|
64 } |
|
65 |
|
66 return callsVector; |
|
67 } |
|
68 |
|
69 vector<CC_LinePtr> CC_SIPCCDeviceInfo::getLines () |
|
70 { |
|
71 vector<CC_LinePtr> linesVector; |
|
72 |
|
73 cc_lineid_t lines[MAX_SUPPORTED_NUM_LINES] = {}; |
|
74 cc_uint16_t numLines = csf_countof(lines); |
|
75 |
|
76 CCAPI_DeviceInfo_getLines(deviceinfo_ref, lines, &numLines) ; |
|
77 |
|
78 for (int i=0; i<numLines; i++) |
|
79 { |
|
80 CC_LinePtr linePtr = CC_SIPCCLine::wrap(lines[i]).get(); |
|
81 linesVector.push_back(linePtr); |
|
82 } |
|
83 |
|
84 return linesVector; |
|
85 } |
|
86 |
|
87 vector<CC_FeatureInfoPtr> CC_SIPCCDeviceInfo::getFeatures () |
|
88 { |
|
89 vector<CC_FeatureInfoPtr> featuresVector; |
|
90 |
|
91 cc_featureinfo_ref_t features[MAX_SUPPORTED_NUM_FEATURES] = {}; |
|
92 cc_uint16_t numFeatureInfos = csf_countof(features); |
|
93 |
|
94 CCAPI_DeviceInfo_getFeatures(deviceinfo_ref, features, &numFeatureInfos); |
|
95 |
|
96 for (int i=0; i<numFeatureInfos; i++) |
|
97 { |
|
98 CC_FeatureInfoPtr featurePtr = |
|
99 CC_SIPCCFeatureInfo::wrap(features[i]).get(); |
|
100 featuresVector.push_back(featurePtr); |
|
101 } |
|
102 |
|
103 return featuresVector; |
|
104 } |
|
105 |
|
106 vector<CC_CallServerInfoPtr> CC_SIPCCDeviceInfo::getCallServers () |
|
107 { |
|
108 vector<CC_CallServerInfoPtr> callServersVector; |
|
109 |
|
110 cc_callserver_ref_t callServers[MAX_SUPPORTED_NUM_CALL_SERVERS] = {}; |
|
111 cc_uint16_t numCallServerInfos = csf_countof(callServers); |
|
112 |
|
113 CCAPI_DeviceInfo_getCallServers(deviceinfo_ref, callServers, &numCallServerInfos); |
|
114 |
|
115 for (int i=0; i<numCallServerInfos; i++) |
|
116 { |
|
117 CC_CallServerInfoPtr callServerPtr = |
|
118 CC_SIPCCCallServerInfo::wrap(callServers[i]).get(); |
|
119 callServersVector.push_back(callServerPtr); |
|
120 } |
|
121 |
|
122 return callServersVector; |
|
123 } |
|
124 |
|
125 cc_service_state_t CC_SIPCCDeviceInfo::getServiceState() |
|
126 { |
|
127 return CCAPI_DeviceInfo_getServiceState(deviceinfo_ref); |
|
128 } |
|
129 |
|
130 |
|
131 cc_service_cause_t CC_SIPCCDeviceInfo::getServiceCause() |
|
132 { |
|
133 return CCAPI_DeviceInfo_getServiceCause(deviceinfo_ref); |
|
134 } |