media/webrtc/signaling/src/softphonewrapper/CC_SIPCCLineInfo.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCLineInfo.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,181 @@
     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 "csf_common.h"
    1.13 +#include "CC_SIPCCLineInfo.h"
    1.14 +#include "CC_SIPCCLine.h"
    1.15 +#include "CC_SIPCCCall.h"
    1.16 +
    1.17 +extern "C"
    1.18 +{
    1.19 +#include "cpr_types.h"
    1.20 +#include "ccapi_line.h"
    1.21 +#include "ccapi_line_info.h"
    1.22 +}
    1.23 +
    1.24 +using namespace std;
    1.25 +using namespace CSF;
    1.26 +
    1.27 +#define MAX_SUPPORTED_NUM_CALLS 100
    1.28 +
    1.29 +//FIXME: Header file "ccapi_line.h" has misnamed the retain function as "CCAPI_Device_retainLineInfo"
    1.30 +//       Checked the source file and it's declared correctly there, so I have to declare it myself here.
    1.31 +
    1.32 +//Also CCAPI_LineInfo_getCalls() in source file and CCAPI_lineInfo_getCalls() in header (lowercase 'l' in lineInfo)
    1.33 +
    1.34 +extern "C" void CCAPI_Line_retainLineInfo(cc_lineinfo_ref_t ref);
    1.35 +extern "C" void CCAPI_LineInfo_getCalls(cc_lineid_t line, cc_call_handle_t handles[], int *count);
    1.36 +extern "C" void CCAPI_LineInfo_getCallsByState(cc_lineid_t line, cc_call_state_t state, cc_call_handle_t handles[], int *count);
    1.37 +
    1.38 +CSF_IMPLEMENT_WRAP(CC_SIPCCLineInfo, cc_lineinfo_ref_t);
    1.39 +
    1.40 +CC_SIPCCLineInfo::CC_SIPCCLineInfo (cc_lineinfo_ref_t lineinfo) : lineinfo(lineinfo)
    1.41 +{
    1.42 +    CCAPI_Line_retainLineInfo(lineinfo);
    1.43 +}
    1.44 +
    1.45 +CC_SIPCCLineInfo::~CC_SIPCCLineInfo()
    1.46 +{
    1.47 +    CCAPI_Line_releaseLineInfo(lineinfo);
    1.48 +}
    1.49 +
    1.50 +string CC_SIPCCLineInfo::getName()
    1.51 +{
    1.52 +    return CCAPI_lineInfo_getName(lineinfo);
    1.53 +}
    1.54 +
    1.55 +string CC_SIPCCLineInfo::getNumber()
    1.56 +{
    1.57 +    return CCAPI_lineInfo_getNumber(lineinfo);
    1.58 +}
    1.59 +
    1.60 +cc_uint32_t CC_SIPCCLineInfo::getButton()
    1.61 +{
    1.62 +    return CCAPI_lineInfo_getButton(lineinfo);
    1.63 +}
    1.64 +
    1.65 +cc_line_feature_t CC_SIPCCLineInfo::getLineType()
    1.66 +{
    1.67 +    return CCAPI_lineInfo_getLineType(lineinfo);
    1.68 +}
    1.69 +
    1.70 +bool CC_SIPCCLineInfo::getRegState()
    1.71 +{
    1.72 +    if (CCAPI_lineInfo_getRegState(lineinfo))
    1.73 +    {
    1.74 +    	return true;
    1.75 +    }
    1.76 +    else
    1.77 +    {
    1.78 +    	return false;
    1.79 +    }
    1.80 +}
    1.81 +
    1.82 +bool CC_SIPCCLineInfo::isCFWDActive()
    1.83 +{
    1.84 +    if (CCAPI_lineInfo_isCFWDActive(lineinfo))
    1.85 +    {
    1.86 +    	return true;
    1.87 +    }
    1.88 +    else
    1.89 +    {
    1.90 +    	return false;
    1.91 +    }
    1.92 +}
    1.93 +
    1.94 +string CC_SIPCCLineInfo::getCFWDName()
    1.95 +{
    1.96 +    return CCAPI_lineInfo_getCFWDName(lineinfo);
    1.97 +}
    1.98 +
    1.99 +vector<CC_CallPtr> CC_SIPCCLineInfo::getCalls (CC_LinePtr linePtr)
   1.100 +{
   1.101 +    vector<CC_CallPtr> callsVector;
   1.102 +
   1.103 +    cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {};
   1.104 +    int numCalls = csf_countof(handles);
   1.105 +
   1.106 +    CCAPI_LineInfo_getCalls(linePtr->getID(), handles, &numCalls) ;
   1.107 +
   1.108 +    for (int i=0; i<numCalls; i++)
   1.109 +    {
   1.110 +        CC_CallPtr callPtr = CC_SIPCCCall::wrap(handles[i]).get();
   1.111 +        callsVector.push_back(callPtr);
   1.112 +    }
   1.113 +
   1.114 +    return callsVector;
   1.115 +}
   1.116 +
   1.117 +vector<CC_CallPtr> CC_SIPCCLineInfo::getCallsByState (CC_LinePtr linePtr, cc_call_state_t state)
   1.118 +{
   1.119 +    vector<CC_CallPtr> callsVector;
   1.120 +
   1.121 +    cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {};
   1.122 +    int numCalls = csf_countof(handles);
   1.123 +
   1.124 +    CCAPI_LineInfo_getCallsByState(linePtr->getID(), state, handles, &numCalls) ;
   1.125 +
   1.126 +    for (int i=0; i<numCalls; i++)
   1.127 +    {
   1.128 +        CC_CallPtr callPtr = CC_SIPCCCall::wrap(handles[i]).get();
   1.129 +        callsVector.push_back(callPtr);
   1.130 +    }
   1.131 +
   1.132 +    return callsVector;
   1.133 +}
   1.134 +
   1.135 +bool CC_SIPCCLineInfo::getMWIStatus()
   1.136 +{
   1.137 +    return (CCAPI_lineInfo_getMWIStatus(lineinfo) != 0);
   1.138 +}
   1.139 +
   1.140 +cc_uint32_t CC_SIPCCLineInfo::getMWIType()
   1.141 +{
   1.142 +    return CCAPI_lineInfo_getMWIType(lineinfo);
   1.143 +}
   1.144 +
   1.145 +cc_uint32_t CC_SIPCCLineInfo::getMWINewMsgCount()
   1.146 +{
   1.147 +    return CCAPI_lineInfo_getMWINewMsgCount(lineinfo);
   1.148 +}
   1.149 +
   1.150 +cc_uint32_t CC_SIPCCLineInfo::getMWIOldMsgCount()
   1.151 +{
   1.152 +    return CCAPI_lineInfo_getMWIOldMsgCount(lineinfo);
   1.153 +}
   1.154 +
   1.155 +cc_uint32_t CC_SIPCCLineInfo::getMWIPrioNewMsgCount()
   1.156 +{
   1.157 +    return CCAPI_lineInfo_getMWIPrioNewMsgCount(lineinfo);
   1.158 +}
   1.159 +
   1.160 +cc_uint32_t CC_SIPCCLineInfo::getMWIPrioOldMsgCount()
   1.161 +{
   1.162 +    return CCAPI_lineInfo_getMWIPrioOldMsgCount(lineinfo);
   1.163 +}
   1.164 +
   1.165 +bool CC_SIPCCLineInfo::hasCapability(ccapi_call_capability_e capability)
   1.166 +{
   1.167 +    return CCAPI_LineInfo_hasCapability(lineinfo, (cc_int32_t) capability) == TRUE;
   1.168 +}
   1.169 +
   1.170 +bitset<CCAPI_CALL_CAP_MAX> CC_SIPCCLineInfo::getCapabilitySet()
   1.171 +{
   1.172 +    bitset<CCAPI_CALL_CAP_MAX> lineCaps;
   1.173 +
   1.174 +    for (int i=0; i<CCAPI_CALL_CAP_MAX; i++)
   1.175 +    {
   1.176 +        if (hasCapability((ccapi_call_capability_e) i))
   1.177 +        {
   1.178 +            lineCaps.set(i, true);
   1.179 +        }
   1.180 +    }
   1.181 +
   1.182 +    return lineCaps;
   1.183 +}
   1.184 +

mercurial