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.
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 "CC_SIPCCDeviceInfo.h" |
michael@0 | 10 | #include "CC_SIPCCFeatureInfo.h" |
michael@0 | 11 | #include "CC_SIPCCCallServerInfo.h" |
michael@0 | 12 | #include "CC_SIPCCCall.h" |
michael@0 | 13 | #include "CC_SIPCCLine.h" |
michael@0 | 14 | |
michael@0 | 15 | #include "csf_common.h" |
michael@0 | 16 | |
michael@0 | 17 | extern "C" |
michael@0 | 18 | { |
michael@0 | 19 | #include "cpr_types.h" |
michael@0 | 20 | #include "ccapi_device.h" |
michael@0 | 21 | #include "ccapi_device_info.h" |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | using namespace std; |
michael@0 | 25 | using namespace CSF; |
michael@0 | 26 | |
michael@0 | 27 | #define MAX_SUPPORTED_NUM_CALLS 100 |
michael@0 | 28 | #define MAX_SUPPORTED_NUM_LINES 100 |
michael@0 | 29 | #define MAX_SUPPORTED_NUM_FEATURES 100 |
michael@0 | 30 | #define MAX_SUPPORTED_NUM_CALL_SERVERS 100 |
michael@0 | 31 | |
michael@0 | 32 | |
michael@0 | 33 | CSF_IMPLEMENT_WRAP(CC_SIPCCDeviceInfo, cc_deviceinfo_ref_t); |
michael@0 | 34 | |
michael@0 | 35 | CC_SIPCCDeviceInfo::CC_SIPCCDeviceInfo (cc_deviceinfo_ref_t deviceinfo) |
michael@0 | 36 | : deviceinfo_ref(deviceinfo) |
michael@0 | 37 | { |
michael@0 | 38 | CCAPI_Device_retainDeviceInfo(deviceinfo_ref); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | CC_SIPCCDeviceInfo::~CC_SIPCCDeviceInfo() |
michael@0 | 42 | { |
michael@0 | 43 | CCAPI_Device_releaseDeviceInfo(deviceinfo_ref); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | string CC_SIPCCDeviceInfo::getDeviceName() |
michael@0 | 47 | { |
michael@0 | 48 | return CCAPI_DeviceInfo_getDeviceName(deviceinfo_ref); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | vector<CC_CallPtr> CC_SIPCCDeviceInfo::getCalls () |
michael@0 | 52 | { |
michael@0 | 53 | vector<CC_CallPtr> callsVector; |
michael@0 | 54 | |
michael@0 | 55 | cc_call_handle_t handles[MAX_SUPPORTED_NUM_CALLS] = {}; |
michael@0 | 56 | cc_uint16_t numHandles = csf_countof(handles); |
michael@0 | 57 | |
michael@0 | 58 | CCAPI_DeviceInfo_getCalls(deviceinfo_ref, handles, &numHandles) ; |
michael@0 | 59 | |
michael@0 | 60 | for (int i=0; i<numHandles; i++) |
michael@0 | 61 | { |
michael@0 | 62 | CC_CallPtr callPtr = CC_SIPCCCall::wrap(handles[i]).get(); |
michael@0 | 63 | callsVector.push_back(callPtr); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | return callsVector; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | vector<CC_LinePtr> CC_SIPCCDeviceInfo::getLines () |
michael@0 | 70 | { |
michael@0 | 71 | vector<CC_LinePtr> linesVector; |
michael@0 | 72 | |
michael@0 | 73 | cc_lineid_t lines[MAX_SUPPORTED_NUM_LINES] = {}; |
michael@0 | 74 | cc_uint16_t numLines = csf_countof(lines); |
michael@0 | 75 | |
michael@0 | 76 | CCAPI_DeviceInfo_getLines(deviceinfo_ref, lines, &numLines) ; |
michael@0 | 77 | |
michael@0 | 78 | for (int i=0; i<numLines; i++) |
michael@0 | 79 | { |
michael@0 | 80 | CC_LinePtr linePtr = CC_SIPCCLine::wrap(lines[i]).get(); |
michael@0 | 81 | linesVector.push_back(linePtr); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | return linesVector; |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | vector<CC_FeatureInfoPtr> CC_SIPCCDeviceInfo::getFeatures () |
michael@0 | 88 | { |
michael@0 | 89 | vector<CC_FeatureInfoPtr> featuresVector; |
michael@0 | 90 | |
michael@0 | 91 | cc_featureinfo_ref_t features[MAX_SUPPORTED_NUM_FEATURES] = {}; |
michael@0 | 92 | cc_uint16_t numFeatureInfos = csf_countof(features); |
michael@0 | 93 | |
michael@0 | 94 | CCAPI_DeviceInfo_getFeatures(deviceinfo_ref, features, &numFeatureInfos); |
michael@0 | 95 | |
michael@0 | 96 | for (int i=0; i<numFeatureInfos; i++) |
michael@0 | 97 | { |
michael@0 | 98 | CC_FeatureInfoPtr featurePtr = |
michael@0 | 99 | CC_SIPCCFeatureInfo::wrap(features[i]).get(); |
michael@0 | 100 | featuresVector.push_back(featurePtr); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | return featuresVector; |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | vector<CC_CallServerInfoPtr> CC_SIPCCDeviceInfo::getCallServers () |
michael@0 | 107 | { |
michael@0 | 108 | vector<CC_CallServerInfoPtr> callServersVector; |
michael@0 | 109 | |
michael@0 | 110 | cc_callserver_ref_t callServers[MAX_SUPPORTED_NUM_CALL_SERVERS] = {}; |
michael@0 | 111 | cc_uint16_t numCallServerInfos = csf_countof(callServers); |
michael@0 | 112 | |
michael@0 | 113 | CCAPI_DeviceInfo_getCallServers(deviceinfo_ref, callServers, &numCallServerInfos); |
michael@0 | 114 | |
michael@0 | 115 | for (int i=0; i<numCallServerInfos; i++) |
michael@0 | 116 | { |
michael@0 | 117 | CC_CallServerInfoPtr callServerPtr = |
michael@0 | 118 | CC_SIPCCCallServerInfo::wrap(callServers[i]).get(); |
michael@0 | 119 | callServersVector.push_back(callServerPtr); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | return callServersVector; |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | cc_service_state_t CC_SIPCCDeviceInfo::getServiceState() |
michael@0 | 126 | { |
michael@0 | 127 | return CCAPI_DeviceInfo_getServiceState(deviceinfo_ref); |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | |
michael@0 | 131 | cc_service_cause_t CC_SIPCCDeviceInfo::getServiceCause() |
michael@0 | 132 | { |
michael@0 | 133 | return CCAPI_DeviceInfo_getServiceCause(deviceinfo_ref); |
michael@0 | 134 | } |