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