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 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | include protocol PBlob; |
michael@0 | 8 | include protocol PBluetoothRequest; |
michael@0 | 9 | include protocol PContent; |
michael@0 | 10 | |
michael@0 | 11 | include BluetoothTypes; |
michael@0 | 12 | |
michael@0 | 13 | include "mozilla/dom/bluetooth/ipc/BluetoothMessageUtils.h"; |
michael@0 | 14 | |
michael@0 | 15 | using mozilla::dom::bluetooth::BluetoothObjectType from "mozilla/dom/bluetooth/BluetoothCommon.h"; |
michael@0 | 16 | |
michael@0 | 17 | namespace mozilla { |
michael@0 | 18 | namespace dom { |
michael@0 | 19 | namespace bluetooth { |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * Bluetooth request types. |
michael@0 | 23 | */ |
michael@0 | 24 | |
michael@0 | 25 | struct DefaultAdapterPathRequest |
michael@0 | 26 | { }; |
michael@0 | 27 | |
michael@0 | 28 | struct SetPropertyRequest |
michael@0 | 29 | { |
michael@0 | 30 | BluetoothObjectType type; |
michael@0 | 31 | BluetoothNamedValue value; |
michael@0 | 32 | }; |
michael@0 | 33 | |
michael@0 | 34 | struct GetPropertyRequest |
michael@0 | 35 | { |
michael@0 | 36 | BluetoothObjectType type; |
michael@0 | 37 | nsString path; |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | struct StartDiscoveryRequest |
michael@0 | 41 | { |
michael@0 | 42 | }; |
michael@0 | 43 | |
michael@0 | 44 | struct StopDiscoveryRequest |
michael@0 | 45 | { |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | struct PairRequest |
michael@0 | 49 | { |
michael@0 | 50 | nsString address; |
michael@0 | 51 | uint32_t timeoutMS; |
michael@0 | 52 | }; |
michael@0 | 53 | |
michael@0 | 54 | struct UnpairRequest |
michael@0 | 55 | { |
michael@0 | 56 | nsString address; |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | struct SetPinCodeRequest |
michael@0 | 60 | { |
michael@0 | 61 | nsString path; |
michael@0 | 62 | nsString pincode; |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | struct SetPasskeyRequest |
michael@0 | 66 | { |
michael@0 | 67 | nsString path; |
michael@0 | 68 | uint32_t passkey; |
michael@0 | 69 | }; |
michael@0 | 70 | |
michael@0 | 71 | struct ConfirmPairingConfirmationRequest |
michael@0 | 72 | { |
michael@0 | 73 | nsString path; |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | struct DenyPairingConfirmationRequest |
michael@0 | 77 | { |
michael@0 | 78 | nsString path; |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | struct PairedDevicePropertiesRequest |
michael@0 | 82 | { |
michael@0 | 83 | nsString[] addresses; |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | struct ConnectedDevicePropertiesRequest |
michael@0 | 87 | { |
michael@0 | 88 | uint16_t serviceUuid; |
michael@0 | 89 | }; |
michael@0 | 90 | |
michael@0 | 91 | struct ConnectRequest |
michael@0 | 92 | { |
michael@0 | 93 | nsString address; |
michael@0 | 94 | uint32_t cod; |
michael@0 | 95 | uint16_t serviceUuid; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | struct DisconnectRequest |
michael@0 | 99 | { |
michael@0 | 100 | nsString address; |
michael@0 | 101 | uint16_t serviceUuid; |
michael@0 | 102 | }; |
michael@0 | 103 | |
michael@0 | 104 | struct SendFileRequest |
michael@0 | 105 | { |
michael@0 | 106 | nsString devicePath; |
michael@0 | 107 | PBlob blob; |
michael@0 | 108 | }; |
michael@0 | 109 | |
michael@0 | 110 | struct StopSendingFileRequest |
michael@0 | 111 | { |
michael@0 | 112 | nsString devicePath; |
michael@0 | 113 | }; |
michael@0 | 114 | |
michael@0 | 115 | struct ConfirmReceivingFileRequest |
michael@0 | 116 | { |
michael@0 | 117 | nsString devicePath; |
michael@0 | 118 | }; |
michael@0 | 119 | |
michael@0 | 120 | struct DenyReceivingFileRequest |
michael@0 | 121 | { |
michael@0 | 122 | nsString devicePath; |
michael@0 | 123 | }; |
michael@0 | 124 | |
michael@0 | 125 | struct ConnectScoRequest |
michael@0 | 126 | { |
michael@0 | 127 | }; |
michael@0 | 128 | |
michael@0 | 129 | struct DisconnectScoRequest |
michael@0 | 130 | { |
michael@0 | 131 | }; |
michael@0 | 132 | |
michael@0 | 133 | struct IsScoConnectedRequest |
michael@0 | 134 | { |
michael@0 | 135 | }; |
michael@0 | 136 | |
michael@0 | 137 | struct AnswerWaitingCallRequest |
michael@0 | 138 | { |
michael@0 | 139 | }; |
michael@0 | 140 | |
michael@0 | 141 | struct IgnoreWaitingCallRequest |
michael@0 | 142 | { |
michael@0 | 143 | }; |
michael@0 | 144 | |
michael@0 | 145 | struct ToggleCallsRequest |
michael@0 | 146 | { |
michael@0 | 147 | }; |
michael@0 | 148 | |
michael@0 | 149 | struct SendMetaDataRequest |
michael@0 | 150 | { |
michael@0 | 151 | nsString title; |
michael@0 | 152 | nsString artist; |
michael@0 | 153 | nsString album; |
michael@0 | 154 | int64_t mediaNumber; |
michael@0 | 155 | int64_t totalMediaCount; |
michael@0 | 156 | int64_t duration; |
michael@0 | 157 | }; |
michael@0 | 158 | |
michael@0 | 159 | struct SendPlayStatusRequest |
michael@0 | 160 | { |
michael@0 | 161 | int64_t duration; |
michael@0 | 162 | int64_t position; |
michael@0 | 163 | nsString playStatus; |
michael@0 | 164 | }; |
michael@0 | 165 | |
michael@0 | 166 | union Request |
michael@0 | 167 | { |
michael@0 | 168 | DefaultAdapterPathRequest; |
michael@0 | 169 | SetPropertyRequest; |
michael@0 | 170 | GetPropertyRequest; |
michael@0 | 171 | StartDiscoveryRequest; |
michael@0 | 172 | StopDiscoveryRequest; |
michael@0 | 173 | PairRequest; |
michael@0 | 174 | UnpairRequest; |
michael@0 | 175 | SetPinCodeRequest; |
michael@0 | 176 | SetPasskeyRequest; |
michael@0 | 177 | ConfirmPairingConfirmationRequest; |
michael@0 | 178 | DenyPairingConfirmationRequest; |
michael@0 | 179 | ConnectedDevicePropertiesRequest; |
michael@0 | 180 | PairedDevicePropertiesRequest; |
michael@0 | 181 | ConnectRequest; |
michael@0 | 182 | DisconnectRequest; |
michael@0 | 183 | SendFileRequest; |
michael@0 | 184 | StopSendingFileRequest; |
michael@0 | 185 | ConfirmReceivingFileRequest; |
michael@0 | 186 | DenyReceivingFileRequest; |
michael@0 | 187 | ConnectScoRequest; |
michael@0 | 188 | DisconnectScoRequest; |
michael@0 | 189 | IsScoConnectedRequest; |
michael@0 | 190 | AnswerWaitingCallRequest; |
michael@0 | 191 | IgnoreWaitingCallRequest; |
michael@0 | 192 | ToggleCallsRequest; |
michael@0 | 193 | SendMetaDataRequest; |
michael@0 | 194 | SendPlayStatusRequest; |
michael@0 | 195 | }; |
michael@0 | 196 | |
michael@0 | 197 | protocol PBluetooth |
michael@0 | 198 | { |
michael@0 | 199 | manager PContent; |
michael@0 | 200 | manages PBluetoothRequest; |
michael@0 | 201 | |
michael@0 | 202 | /** |
michael@0 | 203 | * The potential exists for a racy shutdown so the following sequence of |
michael@0 | 204 | * messages is used to shutdown safely: |
michael@0 | 205 | * |
michael@0 | 206 | * 1. [BeginShutdown] (Parent -> Child [Optional]) |
michael@0 | 207 | * 2. StopNotifying (Child -> Parent) |
michael@0 | 208 | * 3. NotificationsStopped (Parent -> Child) |
michael@0 | 209 | * 4. __delete__() (Child -> Parent) |
michael@0 | 210 | */ |
michael@0 | 211 | |
michael@0 | 212 | child: |
michael@0 | 213 | /** |
michael@0 | 214 | * Sent when a settings change has enabled or disabled the bluetooth firmware. |
michael@0 | 215 | */ |
michael@0 | 216 | Enabled(bool enabled); |
michael@0 | 217 | |
michael@0 | 218 | /** |
michael@0 | 219 | * Sent when a bluetooth signal is broadcasted to child processes. |
michael@0 | 220 | */ |
michael@0 | 221 | Notify(BluetoothSignal signal); |
michael@0 | 222 | |
michael@0 | 223 | /** |
michael@0 | 224 | * Sent when the parent process is about to be shut down. See shutdown note |
michael@0 | 225 | * above. |
michael@0 | 226 | */ |
michael@0 | 227 | BeginShutdown(); |
michael@0 | 228 | |
michael@0 | 229 | /** |
michael@0 | 230 | * Sent to inform the child process that it will no longer receive any |
michael@0 | 231 | * messages from the parent. See shutdown note above. |
michael@0 | 232 | */ |
michael@0 | 233 | NotificationsStopped(); |
michael@0 | 234 | |
michael@0 | 235 | parent: |
michael@0 | 236 | /** |
michael@0 | 237 | * Sent when the child no longer needs to use bluetooth. See shutdown note |
michael@0 | 238 | * above. |
michael@0 | 239 | */ |
michael@0 | 240 | __delete__(); |
michael@0 | 241 | |
michael@0 | 242 | /** |
michael@0 | 243 | * Sent when the child needs to receive signals related to the given node. |
michael@0 | 244 | */ |
michael@0 | 245 | RegisterSignalHandler(nsString node); |
michael@0 | 246 | |
michael@0 | 247 | /** |
michael@0 | 248 | * Sent when the child no longer needs to receive signals related to the given |
michael@0 | 249 | * node. |
michael@0 | 250 | */ |
michael@0 | 251 | UnregisterSignalHandler(nsString node); |
michael@0 | 252 | |
michael@0 | 253 | /** |
michael@0 | 254 | * Sent when the child no longer needs to receive any messages from the |
michael@0 | 255 | * parent. See shutdown note above. |
michael@0 | 256 | */ |
michael@0 | 257 | StopNotifying(); |
michael@0 | 258 | |
michael@0 | 259 | /** |
michael@0 | 260 | * Sent when the child makes an asynchronous request to the parent. |
michael@0 | 261 | */ |
michael@0 | 262 | PBluetoothRequest(Request request); |
michael@0 | 263 | |
michael@0 | 264 | /** |
michael@0 | 265 | * FIXME: Bug 547703. |
michael@0 | 266 | * |
michael@0 | 267 | * This is the state machine we want: |
michael@0 | 268 | * |
michael@0 | 269 | * start state NOTIFYING: |
michael@0 | 270 | * send Enabled goto NOTIFYING; |
michael@0 | 271 | * send Notify goto NOTIFYING; |
michael@0 | 272 | * recv RegisterSignalHandler goto NOTIFYING; |
michael@0 | 273 | * recv UnregisterSignalHandler goto NOTIFYING; |
michael@0 | 274 | * send BeginShutdown goto PARENT_DONE; |
michael@0 | 275 | * recv StopNotifying goto CHILD_DONE; |
michael@0 | 276 | * |
michael@0 | 277 | * state PARENT_DONE: |
michael@0 | 278 | * recv RegisterSignalHandler goto PARENT_DONE; |
michael@0 | 279 | * recv UnregisterSignalHandler goto PARENT_DONE; |
michael@0 | 280 | * recv StopNotifying goto CHILD_DONE; |
michael@0 | 281 | * |
michael@0 | 282 | * state CHILD_DONE: |
michael@0 | 283 | * send Enabled goto CHILD_DONE; |
michael@0 | 284 | * send Notify goto CHILD_DONE; |
michael@0 | 285 | * send BeginShutdown goto CHILD_DONE; |
michael@0 | 286 | * send NotificationsStopped goto DONE; |
michael@0 | 287 | * |
michael@0 | 288 | * state DONE: |
michael@0 | 289 | * recv __delete__; |
michael@0 | 290 | */ |
michael@0 | 291 | }; |
michael@0 | 292 | |
michael@0 | 293 | } // namespace bluetooth |
michael@0 | 294 | } // namespace dom |
michael@0 | 295 | } // namespace mozilla |