Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
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/. */
5 #include "CSFLog.h"
7 #include "CC_Common.h"
9 #include "csf_common.h"
10 #include "CC_SIPCCLineInfo.h"
11 #include "CC_SIPCCLine.h"
12 #include "CC_SIPCCCall.h"
14 extern "C"
15 {
16 #include "cpr_types.h"
17 #include "ccapi_line.h"
18 #include "ccapi_line_info.h"
19 }
21 using namespace std;
22 using namespace CSF;
24 #define MAX_SUPPORTED_NUM_CALLS 100
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.
29 //Also CCAPI_LineInfo_getCalls() in source file and CCAPI_lineInfo_getCalls() in header (lowercase 'l' in lineInfo)
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);
35 CSF_IMPLEMENT_WRAP(CC_SIPCCLineInfo, cc_lineinfo_ref_t);
37 CC_SIPCCLineInfo::CC_SIPCCLineInfo (cc_lineinfo_ref_t lineinfo) : lineinfo(lineinfo)
38 {
39 CCAPI_Line_retainLineInfo(lineinfo);
40 }
42 CC_SIPCCLineInfo::~CC_SIPCCLineInfo()
43 {
44 CCAPI_Line_releaseLineInfo(lineinfo);
45 }
47 string CC_SIPCCLineInfo::getName()
48 {
49 return CCAPI_lineInfo_getName(lineinfo);
50 }
52 string CC_SIPCCLineInfo::getNumber()
53 {
54 return CCAPI_lineInfo_getNumber(lineinfo);
55 }
57 cc_uint32_t CC_SIPCCLineInfo::getButton()
58 {
59 return CCAPI_lineInfo_getButton(lineinfo);
60 }
62 cc_line_feature_t CC_SIPCCLineInfo::getLineType()
63 {
64 return CCAPI_lineInfo_getLineType(lineinfo);
65 }
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 }
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 }
91 string CC_SIPCCLineInfo::getCFWDName()
92 {
93 return CCAPI_lineInfo_getCFWDName(lineinfo);
94 }
96 vector<CC_CallPtr> CC_SIPCCLineInfo::getCalls (CC_LinePtr linePtr)
97 {
98 vector<CC_CallPtr> callsVector;
100 cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {};
101 int numCalls = csf_countof(handles);
103 CCAPI_LineInfo_getCalls(linePtr->getID(), handles, &numCalls) ;
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 }
111 return callsVector;
112 }
114 vector<CC_CallPtr> CC_SIPCCLineInfo::getCallsByState (CC_LinePtr linePtr, cc_call_state_t state)
115 {
116 vector<CC_CallPtr> callsVector;
118 cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {};
119 int numCalls = csf_countof(handles);
121 CCAPI_LineInfo_getCallsByState(linePtr->getID(), state, handles, &numCalls) ;
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 }
129 return callsVector;
130 }
132 bool CC_SIPCCLineInfo::getMWIStatus()
133 {
134 return (CCAPI_lineInfo_getMWIStatus(lineinfo) != 0);
135 }
137 cc_uint32_t CC_SIPCCLineInfo::getMWIType()
138 {
139 return CCAPI_lineInfo_getMWIType(lineinfo);
140 }
142 cc_uint32_t CC_SIPCCLineInfo::getMWINewMsgCount()
143 {
144 return CCAPI_lineInfo_getMWINewMsgCount(lineinfo);
145 }
147 cc_uint32_t CC_SIPCCLineInfo::getMWIOldMsgCount()
148 {
149 return CCAPI_lineInfo_getMWIOldMsgCount(lineinfo);
150 }
152 cc_uint32_t CC_SIPCCLineInfo::getMWIPrioNewMsgCount()
153 {
154 return CCAPI_lineInfo_getMWIPrioNewMsgCount(lineinfo);
155 }
157 cc_uint32_t CC_SIPCCLineInfo::getMWIPrioOldMsgCount()
158 {
159 return CCAPI_lineInfo_getMWIPrioOldMsgCount(lineinfo);
160 }
162 bool CC_SIPCCLineInfo::hasCapability(ccapi_call_capability_e capability)
163 {
164 return CCAPI_LineInfo_hasCapability(lineinfo, (cc_int32_t) capability) == TRUE;
165 }
167 bitset<CCAPI_CALL_CAP_MAX> CC_SIPCCLineInfo::getCapabilitySet()
168 {
169 bitset<CCAPI_CALL_CAP_MAX> lineCaps;
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 }
179 return lineCaps;
180 }