1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCDeviceInfo.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,134 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "CSFLog.h" 1.9 + 1.10 +#include "CC_Common.h" 1.11 + 1.12 +#include "CC_SIPCCDeviceInfo.h" 1.13 +#include "CC_SIPCCFeatureInfo.h" 1.14 +#include "CC_SIPCCCallServerInfo.h" 1.15 +#include "CC_SIPCCCall.h" 1.16 +#include "CC_SIPCCLine.h" 1.17 + 1.18 +#include "csf_common.h" 1.19 + 1.20 +extern "C" 1.21 +{ 1.22 +#include "cpr_types.h" 1.23 +#include "ccapi_device.h" 1.24 +#include "ccapi_device_info.h" 1.25 +} 1.26 + 1.27 +using namespace std; 1.28 +using namespace CSF; 1.29 + 1.30 +#define MAX_SUPPORTED_NUM_CALLS 100 1.31 +#define MAX_SUPPORTED_NUM_LINES 100 1.32 +#define MAX_SUPPORTED_NUM_FEATURES 100 1.33 +#define MAX_SUPPORTED_NUM_CALL_SERVERS 100 1.34 + 1.35 + 1.36 +CSF_IMPLEMENT_WRAP(CC_SIPCCDeviceInfo, cc_deviceinfo_ref_t); 1.37 + 1.38 +CC_SIPCCDeviceInfo::CC_SIPCCDeviceInfo (cc_deviceinfo_ref_t deviceinfo) 1.39 +: deviceinfo_ref(deviceinfo) 1.40 +{ 1.41 + CCAPI_Device_retainDeviceInfo(deviceinfo_ref); 1.42 +} 1.43 + 1.44 +CC_SIPCCDeviceInfo::~CC_SIPCCDeviceInfo() 1.45 +{ 1.46 + CCAPI_Device_releaseDeviceInfo(deviceinfo_ref); 1.47 +} 1.48 + 1.49 +string CC_SIPCCDeviceInfo::getDeviceName() 1.50 +{ 1.51 + return CCAPI_DeviceInfo_getDeviceName(deviceinfo_ref); 1.52 +} 1.53 + 1.54 +vector<CC_CallPtr> CC_SIPCCDeviceInfo::getCalls () 1.55 +{ 1.56 + vector<CC_CallPtr> callsVector; 1.57 + 1.58 + cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {}; 1.59 + cc_uint16_t numHandles = csf_countof(handles); 1.60 + 1.61 + CCAPI_DeviceInfo_getCalls(deviceinfo_ref, handles, &numHandles) ; 1.62 + 1.63 + for (int i=0; i<numHandles; i++) 1.64 + { 1.65 + CC_CallPtr callPtr = CC_SIPCCCall::wrap(handles[i]).get(); 1.66 + callsVector.push_back(callPtr); 1.67 + } 1.68 + 1.69 + return callsVector; 1.70 +} 1.71 + 1.72 +vector<CC_LinePtr> CC_SIPCCDeviceInfo::getLines () 1.73 +{ 1.74 + vector<CC_LinePtr> linesVector; 1.75 + 1.76 + cc_lineid_t lines[MAX_SUPPORTED_NUM_LINES] = {}; 1.77 + cc_uint16_t numLines = csf_countof(lines); 1.78 + 1.79 + CCAPI_DeviceInfo_getLines(deviceinfo_ref, lines, &numLines) ; 1.80 + 1.81 + for (int i=0; i<numLines; i++) 1.82 + { 1.83 + CC_LinePtr linePtr = CC_SIPCCLine::wrap(lines[i]).get(); 1.84 + linesVector.push_back(linePtr); 1.85 + } 1.86 + 1.87 + return linesVector; 1.88 +} 1.89 + 1.90 +vector<CC_FeatureInfoPtr> CC_SIPCCDeviceInfo::getFeatures () 1.91 +{ 1.92 + vector<CC_FeatureInfoPtr> featuresVector; 1.93 + 1.94 + cc_featureinfo_ref_t features[MAX_SUPPORTED_NUM_FEATURES] = {}; 1.95 + cc_uint16_t numFeatureInfos = csf_countof(features); 1.96 + 1.97 + CCAPI_DeviceInfo_getFeatures(deviceinfo_ref, features, &numFeatureInfos); 1.98 + 1.99 + for (int i=0; i<numFeatureInfos; i++) 1.100 + { 1.101 + CC_FeatureInfoPtr featurePtr = 1.102 + CC_SIPCCFeatureInfo::wrap(features[i]).get(); 1.103 + featuresVector.push_back(featurePtr); 1.104 + } 1.105 + 1.106 + return featuresVector; 1.107 +} 1.108 + 1.109 +vector<CC_CallServerInfoPtr> CC_SIPCCDeviceInfo::getCallServers () 1.110 +{ 1.111 + vector<CC_CallServerInfoPtr> callServersVector; 1.112 + 1.113 + cc_callserver_ref_t callServers[MAX_SUPPORTED_NUM_CALL_SERVERS] = {}; 1.114 + cc_uint16_t numCallServerInfos = csf_countof(callServers); 1.115 + 1.116 + CCAPI_DeviceInfo_getCallServers(deviceinfo_ref, callServers, &numCallServerInfos); 1.117 + 1.118 + for (int i=0; i<numCallServerInfos; i++) 1.119 + { 1.120 + CC_CallServerInfoPtr callServerPtr = 1.121 + CC_SIPCCCallServerInfo::wrap(callServers[i]).get(); 1.122 + callServersVector.push_back(callServerPtr); 1.123 + } 1.124 + 1.125 + return callServersVector; 1.126 +} 1.127 + 1.128 +cc_service_state_t CC_SIPCCDeviceInfo::getServiceState() 1.129 +{ 1.130 + return CCAPI_DeviceInfo_getServiceState(deviceinfo_ref); 1.131 +} 1.132 + 1.133 + 1.134 +cc_service_cause_t CC_SIPCCDeviceInfo::getServiceCause() 1.135 +{ 1.136 + return CCAPI_DeviceInfo_getServiceCause(deviceinfo_ref); 1.137 +}