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 "CC_SIPCCDevice.h"
10 #include "CC_SIPCCDeviceInfo.h"
11 #include "CC_SIPCCFeatureInfo.h"
12 #include "CC_SIPCCCall.h"
14 extern "C"
15 {
16 #include "cpr_types.h"
17 #include "config_api.h"
18 #include "ccapi_device.h"
19 #include "ccapi_device_info.h"
20 #include "ccapi_device_listener.h"
21 }
23 using namespace std;
24 using namespace CSF;
26 CSF_IMPLEMENT_WRAP(CC_SIPCCDevice, cc_device_handle_t);
28 CC_DevicePtr CC_SIPCCDevice::createDevice ()
29 {
30 cc_device_handle_t deviceHandle = CCAPI_Device_getDeviceID();
32 CC_SIPCCDevicePtr pSIPCCDevice = CC_SIPCCDevice::wrap(deviceHandle);
34 return pSIPCCDevice.get();
35 }
37 CC_SIPCCDevice::CC_SIPCCDevice (cc_device_handle_t aDeviceHandle)
38 : deviceHandle(aDeviceHandle)
39 {
40 enableVideo(true);
41 enableCamera(true);
42 }
44 CC_DeviceInfoPtr CC_SIPCCDevice::getDeviceInfo ()
45 {
46 cc_deviceinfo_ref_t deviceInfoRef = CCAPI_Device_getDeviceInfo(deviceHandle);
47 CC_DeviceInfoPtr deviceInfoPtr =
48 CC_SIPCCDeviceInfo::wrap(deviceInfoRef).get();
50 //A call to CCAPI_Device_getDeviceInfo() needs a matching call to CCAPI_Device_releaseDeviceInfo()
51 //However, the CC_SIPCCDeviceInfo() ctor/dtor does a retain/release internally, so I need to explicitly release
52 //here to match up with the call to CCAPI_Device_getDeviceInfo().
54 CCAPI_Device_releaseDeviceInfo(deviceInfoRef);
56 //CCAPI_Device_getDeviceInfo() --> requires release be called.
57 //CC_SIPCCDeviceInfo::CC_SIPCCDeviceInfo() -> Call retain (wrapped in smart_ptr)
58 //CCAPI_Device_releaseDeviceInfo() --> this maps to the call to CCAPI_Device_getDeviceInfo()
59 //CC_SIPCCDeviceInfo::~CC_SIPCCDeviceInfo() --> CCAPI_Device_releaseDeviceInfo() (when smart pointer destroyed)
61 return deviceInfoPtr;
62 }
64 std::string CC_SIPCCDevice::toString()
65 {
66 std::string result;
67 char tmpString[11];
68 csf_sprintf(tmpString, sizeof(tmpString), "%X", deviceHandle);
69 result = tmpString;
70 return result;
71 }
73 CC_CallPtr CC_SIPCCDevice::createCall ()
74 {
75 cc_call_handle_t callHandle = CCAPI_Device_CreateCall(deviceHandle);
77 return CC_SIPCCCall::wrap(callHandle).get();
78 }
80 void CC_SIPCCDevice::enableVideo(bool enable)
81 {
82 CCAPI_Device_enableVideo(deviceHandle, enable);
83 }
85 void CC_SIPCCDevice::enableCamera(bool enable)
86 {
87 CCAPI_Device_enableCamera(deviceHandle, enable);
88 }
90 void CC_SIPCCDevice::setDigestNamePasswd (char *name, char *pw)
91 {
92 CCAPI_Device_setDigestNamePasswd(deviceHandle, name, pw);
93 }