Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
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 file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "mozilla/dom/MobileConnection.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "GeneratedEvents.h" |
michael@0 | 8 | #include "mozilla/dom/CFStateChangeEvent.h" |
michael@0 | 9 | #include "mozilla/dom/DataErrorEvent.h" |
michael@0 | 10 | #include "mozilla/dom/MozEmergencyCbModeEvent.h" |
michael@0 | 11 | #include "mozilla/dom/MozOtaStatusEvent.h" |
michael@0 | 12 | #include "mozilla/dom/USSDReceivedEvent.h" |
michael@0 | 13 | #include "mozilla/Preferences.h" |
michael@0 | 14 | #include "nsIDOMClassInfo.h" |
michael@0 | 15 | #include "nsIDOMDOMRequest.h" |
michael@0 | 16 | #include "nsIPermissionManager.h" |
michael@0 | 17 | #include "nsIVariant.h" |
michael@0 | 18 | |
michael@0 | 19 | #include "nsJSUtils.h" |
michael@0 | 20 | #include "nsJSON.h" |
michael@0 | 21 | #include "mozilla/Services.h" |
michael@0 | 22 | |
michael@0 | 23 | #define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1" |
michael@0 | 24 | |
michael@0 | 25 | using namespace mozilla::dom; |
michael@0 | 26 | |
michael@0 | 27 | class MobileConnection::Listener MOZ_FINAL : public nsIMobileConnectionListener |
michael@0 | 28 | { |
michael@0 | 29 | MobileConnection* mMobileConnection; |
michael@0 | 30 | |
michael@0 | 31 | public: |
michael@0 | 32 | NS_DECL_ISUPPORTS |
michael@0 | 33 | NS_FORWARD_SAFE_NSIMOBILECONNECTIONLISTENER(mMobileConnection) |
michael@0 | 34 | |
michael@0 | 35 | Listener(MobileConnection* aMobileConnection) |
michael@0 | 36 | : mMobileConnection(aMobileConnection) |
michael@0 | 37 | { |
michael@0 | 38 | MOZ_ASSERT(mMobileConnection); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | void Disconnect() |
michael@0 | 42 | { |
michael@0 | 43 | MOZ_ASSERT(mMobileConnection); |
michael@0 | 44 | mMobileConnection = nullptr; |
michael@0 | 45 | } |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | NS_IMPL_ISUPPORTS(MobileConnection::Listener, nsIMobileConnectionListener) |
michael@0 | 49 | |
michael@0 | 50 | DOMCI_DATA(MozMobileConnection, MobileConnection) |
michael@0 | 51 | |
michael@0 | 52 | NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection) |
michael@0 | 53 | |
michael@0 | 54 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection, |
michael@0 | 55 | DOMEventTargetHelper) |
michael@0 | 56 | // Don't traverse mListener because it doesn't keep any reference to |
michael@0 | 57 | // MobileConnection but a raw pointer instead. Neither does mProvider because |
michael@0 | 58 | // it's an xpcom service and is only released at shutting down. |
michael@0 | 59 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
michael@0 | 60 | |
michael@0 | 61 | NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection, |
michael@0 | 62 | DOMEventTargetHelper) |
michael@0 | 63 | NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
michael@0 | 64 | |
michael@0 | 65 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileConnection) |
michael@0 | 66 | NS_INTERFACE_MAP_ENTRY(nsIDOMMozMobileConnection) |
michael@0 | 67 | NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMobileConnection) |
michael@0 | 68 | NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) |
michael@0 | 69 | |
michael@0 | 70 | NS_IMPL_ADDREF_INHERITED(MobileConnection, DOMEventTargetHelper) |
michael@0 | 71 | NS_IMPL_RELEASE_INHERITED(MobileConnection, DOMEventTargetHelper) |
michael@0 | 72 | |
michael@0 | 73 | NS_IMPL_EVENT_HANDLER(MobileConnection, voicechange) |
michael@0 | 74 | NS_IMPL_EVENT_HANDLER(MobileConnection, datachange) |
michael@0 | 75 | NS_IMPL_EVENT_HANDLER(MobileConnection, ussdreceived) |
michael@0 | 76 | NS_IMPL_EVENT_HANDLER(MobileConnection, dataerror) |
michael@0 | 77 | NS_IMPL_EVENT_HANDLER(MobileConnection, cfstatechange) |
michael@0 | 78 | NS_IMPL_EVENT_HANDLER(MobileConnection, emergencycbmodechange) |
michael@0 | 79 | NS_IMPL_EVENT_HANDLER(MobileConnection, otastatuschange) |
michael@0 | 80 | NS_IMPL_EVENT_HANDLER(MobileConnection, iccchange) |
michael@0 | 81 | NS_IMPL_EVENT_HANDLER(MobileConnection, radiostatechange) |
michael@0 | 82 | |
michael@0 | 83 | MobileConnection::MobileConnection(uint32_t aClientId) |
michael@0 | 84 | : mClientId(aClientId) |
michael@0 | 85 | { |
michael@0 | 86 | mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID); |
michael@0 | 87 | mWindow = nullptr; |
michael@0 | 88 | |
michael@0 | 89 | // Not being able to acquire the provider isn't fatal since we check |
michael@0 | 90 | // for it explicitly below. |
michael@0 | 91 | if (!mProvider) { |
michael@0 | 92 | NS_WARNING("Could not acquire nsIMobileConnectionProvider!"); |
michael@0 | 93 | return; |
michael@0 | 94 | } |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | void |
michael@0 | 98 | MobileConnection::Init(nsPIDOMWindow* aWindow) |
michael@0 | 99 | { |
michael@0 | 100 | BindToOwner(aWindow); |
michael@0 | 101 | |
michael@0 | 102 | mWindow = do_GetWeakReference(aWindow); |
michael@0 | 103 | mListener = new Listener(this); |
michael@0 | 104 | |
michael@0 | 105 | if (CheckPermission("mobileconnection")) { |
michael@0 | 106 | DebugOnly<nsresult> rv = mProvider->RegisterMobileConnectionMsg(mClientId, mListener); |
michael@0 | 107 | NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), |
michael@0 | 108 | "Failed registering mobile connection messages with provider"); |
michael@0 | 109 | } |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | void |
michael@0 | 113 | MobileConnection::Shutdown() |
michael@0 | 114 | { |
michael@0 | 115 | if (mProvider && mListener) { |
michael@0 | 116 | mListener->Disconnect(); |
michael@0 | 117 | mProvider->UnregisterMobileConnectionMsg(mClientId, mListener); |
michael@0 | 118 | mProvider = nullptr; |
michael@0 | 119 | mListener = nullptr; |
michael@0 | 120 | } |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | // nsIDOMMozMobileConnection |
michael@0 | 124 | |
michael@0 | 125 | NS_IMETHODIMP |
michael@0 | 126 | MobileConnection::GetLastKnownNetwork(nsAString& aNetwork) |
michael@0 | 127 | { |
michael@0 | 128 | aNetwork.SetIsVoid(true); |
michael@0 | 129 | |
michael@0 | 130 | if (!CheckPermission("mobilenetwork")) { |
michael@0 | 131 | return NS_OK; |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | return mProvider->GetLastKnownNetwork(mClientId, aNetwork); |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | NS_IMETHODIMP |
michael@0 | 138 | MobileConnection::GetLastKnownHomeNetwork(nsAString& aNetwork) |
michael@0 | 139 | { |
michael@0 | 140 | aNetwork.SetIsVoid(true); |
michael@0 | 141 | |
michael@0 | 142 | if (!CheckPermission("mobilenetwork")) { |
michael@0 | 143 | return NS_OK; |
michael@0 | 144 | } |
michael@0 | 145 | |
michael@0 | 146 | return mProvider->GetLastKnownHomeNetwork(mClientId, aNetwork); |
michael@0 | 147 | } |
michael@0 | 148 | |
michael@0 | 149 | // All fields below require the "mobileconnection" permission. |
michael@0 | 150 | |
michael@0 | 151 | bool |
michael@0 | 152 | MobileConnection::CheckPermission(const char* aType) |
michael@0 | 153 | { |
michael@0 | 154 | nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow); |
michael@0 | 155 | NS_ENSURE_TRUE(window, false); |
michael@0 | 156 | |
michael@0 | 157 | nsCOMPtr<nsIPermissionManager> permMgr = |
michael@0 | 158 | do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); |
michael@0 | 159 | NS_ENSURE_TRUE(permMgr, false); |
michael@0 | 160 | |
michael@0 | 161 | uint32_t permission = nsIPermissionManager::DENY_ACTION; |
michael@0 | 162 | permMgr->TestPermissionFromWindow(window, aType, &permission); |
michael@0 | 163 | return permission == nsIPermissionManager::ALLOW_ACTION; |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | NS_IMETHODIMP |
michael@0 | 167 | MobileConnection::GetVoice(nsIDOMMozMobileConnectionInfo** aVoice) |
michael@0 | 168 | { |
michael@0 | 169 | *aVoice = nullptr; |
michael@0 | 170 | |
michael@0 | 171 | if (!mProvider || !CheckPermission("mobileconnection")) { |
michael@0 | 172 | return NS_OK; |
michael@0 | 173 | } |
michael@0 | 174 | return mProvider->GetVoiceConnectionInfo(mClientId, aVoice); |
michael@0 | 175 | } |
michael@0 | 176 | |
michael@0 | 177 | NS_IMETHODIMP |
michael@0 | 178 | MobileConnection::GetData(nsIDOMMozMobileConnectionInfo** aData) |
michael@0 | 179 | { |
michael@0 | 180 | *aData = nullptr; |
michael@0 | 181 | |
michael@0 | 182 | if (!mProvider || !CheckPermission("mobileconnection")) { |
michael@0 | 183 | return NS_OK; |
michael@0 | 184 | } |
michael@0 | 185 | return mProvider->GetDataConnectionInfo(mClientId, aData); |
michael@0 | 186 | } |
michael@0 | 187 | |
michael@0 | 188 | NS_IMETHODIMP |
michael@0 | 189 | MobileConnection::GetIccId(nsAString& aIccId) |
michael@0 | 190 | { |
michael@0 | 191 | aIccId.SetIsVoid(true); |
michael@0 | 192 | |
michael@0 | 193 | if (!mProvider || !CheckPermission("mobileconnection")) { |
michael@0 | 194 | return NS_OK; |
michael@0 | 195 | } |
michael@0 | 196 | return mProvider->GetIccId(mClientId, aIccId); |
michael@0 | 197 | } |
michael@0 | 198 | |
michael@0 | 199 | NS_IMETHODIMP |
michael@0 | 200 | MobileConnection::GetNetworkSelectionMode(nsAString& aNetworkSelectionMode) |
michael@0 | 201 | { |
michael@0 | 202 | aNetworkSelectionMode.SetIsVoid(true); |
michael@0 | 203 | |
michael@0 | 204 | if (!mProvider || !CheckPermission("mobileconnection")) { |
michael@0 | 205 | return NS_OK; |
michael@0 | 206 | } |
michael@0 | 207 | return mProvider->GetNetworkSelectionMode(mClientId, aNetworkSelectionMode); |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | NS_IMETHODIMP |
michael@0 | 211 | MobileConnection::GetRadioState(nsAString& aRadioState) |
michael@0 | 212 | { |
michael@0 | 213 | aRadioState.SetIsVoid(true); |
michael@0 | 214 | |
michael@0 | 215 | if (!mProvider || !CheckPermission("mobileconnection")) { |
michael@0 | 216 | return NS_OK; |
michael@0 | 217 | } |
michael@0 | 218 | return mProvider->GetRadioState(mClientId, aRadioState); |
michael@0 | 219 | } |
michael@0 | 220 | |
michael@0 | 221 | NS_IMETHODIMP |
michael@0 | 222 | MobileConnection::GetSupportedNetworkTypes(nsIVariant** aSupportedNetworkTypes) |
michael@0 | 223 | { |
michael@0 | 224 | *aSupportedNetworkTypes = nullptr; |
michael@0 | 225 | |
michael@0 | 226 | if (!mProvider || !CheckPermission("mobileconnection")) { |
michael@0 | 227 | return NS_OK; |
michael@0 | 228 | } |
michael@0 | 229 | |
michael@0 | 230 | return mProvider->GetSupportedNetworkTypes(mClientId, aSupportedNetworkTypes); |
michael@0 | 231 | } |
michael@0 | 232 | |
michael@0 | 233 | NS_IMETHODIMP |
michael@0 | 234 | MobileConnection::GetNetworks(nsIDOMDOMRequest** aRequest) |
michael@0 | 235 | { |
michael@0 | 236 | *aRequest = nullptr; |
michael@0 | 237 | |
michael@0 | 238 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 239 | return NS_OK; |
michael@0 | 240 | } |
michael@0 | 241 | |
michael@0 | 242 | if (!mProvider) { |
michael@0 | 243 | return NS_ERROR_FAILURE; |
michael@0 | 244 | } |
michael@0 | 245 | |
michael@0 | 246 | return mProvider->GetNetworks(mClientId, GetOwner(), aRequest); |
michael@0 | 247 | } |
michael@0 | 248 | |
michael@0 | 249 | NS_IMETHODIMP |
michael@0 | 250 | MobileConnection::SelectNetwork(nsIDOMMozMobileNetworkInfo* aNetwork, nsIDOMDOMRequest** aRequest) |
michael@0 | 251 | { |
michael@0 | 252 | *aRequest = nullptr; |
michael@0 | 253 | |
michael@0 | 254 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 255 | return NS_OK; |
michael@0 | 256 | } |
michael@0 | 257 | |
michael@0 | 258 | if (!mProvider) { |
michael@0 | 259 | return NS_ERROR_FAILURE; |
michael@0 | 260 | } |
michael@0 | 261 | |
michael@0 | 262 | return mProvider->SelectNetwork(mClientId, GetOwner(), aNetwork, aRequest); |
michael@0 | 263 | } |
michael@0 | 264 | |
michael@0 | 265 | NS_IMETHODIMP |
michael@0 | 266 | MobileConnection::SelectNetworkAutomatically(nsIDOMDOMRequest** aRequest) |
michael@0 | 267 | { |
michael@0 | 268 | *aRequest = nullptr; |
michael@0 | 269 | |
michael@0 | 270 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 271 | return NS_OK; |
michael@0 | 272 | } |
michael@0 | 273 | |
michael@0 | 274 | if (!mProvider) { |
michael@0 | 275 | return NS_ERROR_FAILURE; |
michael@0 | 276 | } |
michael@0 | 277 | |
michael@0 | 278 | return mProvider->SelectNetworkAutomatically(mClientId, GetOwner(), aRequest); |
michael@0 | 279 | } |
michael@0 | 280 | |
michael@0 | 281 | NS_IMETHODIMP |
michael@0 | 282 | MobileConnection::SetPreferredNetworkType(const nsAString& aType, |
michael@0 | 283 | nsIDOMDOMRequest** aDomRequest) |
michael@0 | 284 | { |
michael@0 | 285 | *aDomRequest = nullptr; |
michael@0 | 286 | |
michael@0 | 287 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 288 | return NS_OK; |
michael@0 | 289 | } |
michael@0 | 290 | |
michael@0 | 291 | if (!mProvider) { |
michael@0 | 292 | return NS_ERROR_FAILURE; |
michael@0 | 293 | } |
michael@0 | 294 | |
michael@0 | 295 | return mProvider->SetPreferredNetworkType(mClientId, GetOwner(), aType, aDomRequest); |
michael@0 | 296 | } |
michael@0 | 297 | |
michael@0 | 298 | NS_IMETHODIMP |
michael@0 | 299 | MobileConnection::GetPreferredNetworkType(nsIDOMDOMRequest** aDomRequest) |
michael@0 | 300 | { |
michael@0 | 301 | *aDomRequest = nullptr; |
michael@0 | 302 | |
michael@0 | 303 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 304 | return NS_OK; |
michael@0 | 305 | } |
michael@0 | 306 | |
michael@0 | 307 | if (!mProvider) { |
michael@0 | 308 | return NS_ERROR_FAILURE; |
michael@0 | 309 | } |
michael@0 | 310 | |
michael@0 | 311 | return mProvider->GetPreferredNetworkType(mClientId, GetOwner(), aDomRequest); |
michael@0 | 312 | } |
michael@0 | 313 | |
michael@0 | 314 | NS_IMETHODIMP |
michael@0 | 315 | MobileConnection::SetRoamingPreference(const nsAString& aMode, nsIDOMDOMRequest** aDomRequest) |
michael@0 | 316 | { |
michael@0 | 317 | *aDomRequest = nullptr; |
michael@0 | 318 | |
michael@0 | 319 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 320 | return NS_OK; |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | if (!mProvider) { |
michael@0 | 324 | return NS_ERROR_FAILURE; |
michael@0 | 325 | } |
michael@0 | 326 | |
michael@0 | 327 | return mProvider->SetRoamingPreference(mClientId, GetOwner(), aMode, aDomRequest); |
michael@0 | 328 | } |
michael@0 | 329 | |
michael@0 | 330 | NS_IMETHODIMP |
michael@0 | 331 | MobileConnection::GetRoamingPreference(nsIDOMDOMRequest** aDomRequest) |
michael@0 | 332 | { |
michael@0 | 333 | *aDomRequest = nullptr; |
michael@0 | 334 | |
michael@0 | 335 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 336 | return NS_OK; |
michael@0 | 337 | } |
michael@0 | 338 | |
michael@0 | 339 | if (!mProvider) { |
michael@0 | 340 | return NS_ERROR_FAILURE; |
michael@0 | 341 | } |
michael@0 | 342 | |
michael@0 | 343 | return mProvider->GetRoamingPreference(mClientId, GetOwner(), aDomRequest); |
michael@0 | 344 | } |
michael@0 | 345 | |
michael@0 | 346 | NS_IMETHODIMP |
michael@0 | 347 | MobileConnection::SetVoicePrivacyMode(bool aEnabled, nsIDOMDOMRequest** aDomRequest) |
michael@0 | 348 | { |
michael@0 | 349 | *aDomRequest = nullptr; |
michael@0 | 350 | |
michael@0 | 351 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 352 | return NS_OK; |
michael@0 | 353 | } |
michael@0 | 354 | |
michael@0 | 355 | if (!mProvider) { |
michael@0 | 356 | return NS_ERROR_FAILURE; |
michael@0 | 357 | } |
michael@0 | 358 | |
michael@0 | 359 | return mProvider->SetVoicePrivacyMode(mClientId, GetOwner(), aEnabled, aDomRequest); |
michael@0 | 360 | } |
michael@0 | 361 | |
michael@0 | 362 | NS_IMETHODIMP |
michael@0 | 363 | MobileConnection::GetVoicePrivacyMode(nsIDOMDOMRequest** aDomRequest) |
michael@0 | 364 | { |
michael@0 | 365 | *aDomRequest = nullptr; |
michael@0 | 366 | |
michael@0 | 367 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 368 | return NS_OK; |
michael@0 | 369 | } |
michael@0 | 370 | |
michael@0 | 371 | if (!mProvider) { |
michael@0 | 372 | return NS_ERROR_FAILURE; |
michael@0 | 373 | } |
michael@0 | 374 | |
michael@0 | 375 | return mProvider->GetVoicePrivacyMode(mClientId, GetOwner(), aDomRequest); |
michael@0 | 376 | } |
michael@0 | 377 | |
michael@0 | 378 | NS_IMETHODIMP |
michael@0 | 379 | MobileConnection::SendMMI(const nsAString& aMMIString, |
michael@0 | 380 | nsIDOMDOMRequest** aRequest) |
michael@0 | 381 | { |
michael@0 | 382 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 383 | return NS_OK; |
michael@0 | 384 | } |
michael@0 | 385 | |
michael@0 | 386 | if (!mProvider) { |
michael@0 | 387 | return NS_ERROR_FAILURE; |
michael@0 | 388 | } |
michael@0 | 389 | |
michael@0 | 390 | return mProvider->SendMMI(mClientId, GetOwner(), aMMIString, aRequest); |
michael@0 | 391 | } |
michael@0 | 392 | |
michael@0 | 393 | NS_IMETHODIMP |
michael@0 | 394 | MobileConnection::CancelMMI(nsIDOMDOMRequest** aRequest) |
michael@0 | 395 | { |
michael@0 | 396 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 397 | return NS_OK; |
michael@0 | 398 | } |
michael@0 | 399 | |
michael@0 | 400 | if (!mProvider) { |
michael@0 | 401 | return NS_ERROR_FAILURE; |
michael@0 | 402 | } |
michael@0 | 403 | |
michael@0 | 404 | return mProvider->CancelMMI(mClientId, GetOwner(),aRequest); |
michael@0 | 405 | } |
michael@0 | 406 | |
michael@0 | 407 | NS_IMETHODIMP |
michael@0 | 408 | MobileConnection::GetCallForwardingOption(uint16_t aReason, |
michael@0 | 409 | nsIDOMDOMRequest** aRequest) |
michael@0 | 410 | { |
michael@0 | 411 | *aRequest = nullptr; |
michael@0 | 412 | |
michael@0 | 413 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 414 | return NS_OK; |
michael@0 | 415 | } |
michael@0 | 416 | |
michael@0 | 417 | if (!mProvider) { |
michael@0 | 418 | return NS_ERROR_FAILURE; |
michael@0 | 419 | } |
michael@0 | 420 | |
michael@0 | 421 | return mProvider->GetCallForwardingOption(mClientId, GetOwner(), aReason, aRequest); |
michael@0 | 422 | } |
michael@0 | 423 | |
michael@0 | 424 | NS_IMETHODIMP |
michael@0 | 425 | MobileConnection::SetCallForwardingOption(nsIDOMMozMobileCFInfo* aCFInfo, |
michael@0 | 426 | nsIDOMDOMRequest** aRequest) |
michael@0 | 427 | { |
michael@0 | 428 | *aRequest = nullptr; |
michael@0 | 429 | |
michael@0 | 430 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 431 | return NS_OK; |
michael@0 | 432 | } |
michael@0 | 433 | |
michael@0 | 434 | if (!mProvider) { |
michael@0 | 435 | return NS_ERROR_FAILURE; |
michael@0 | 436 | } |
michael@0 | 437 | |
michael@0 | 438 | return mProvider->SetCallForwardingOption(mClientId, GetOwner(), aCFInfo, aRequest); |
michael@0 | 439 | } |
michael@0 | 440 | |
michael@0 | 441 | NS_IMETHODIMP |
michael@0 | 442 | MobileConnection::GetCallBarringOption(JS::Handle<JS::Value> aOption, |
michael@0 | 443 | nsIDOMDOMRequest** aRequest) |
michael@0 | 444 | { |
michael@0 | 445 | *aRequest = nullptr; |
michael@0 | 446 | |
michael@0 | 447 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 448 | return NS_OK; |
michael@0 | 449 | } |
michael@0 | 450 | |
michael@0 | 451 | if (!mProvider) { |
michael@0 | 452 | return NS_ERROR_FAILURE; |
michael@0 | 453 | } |
michael@0 | 454 | |
michael@0 | 455 | return mProvider->GetCallBarringOption(mClientId, GetOwner(), aOption, aRequest); |
michael@0 | 456 | } |
michael@0 | 457 | |
michael@0 | 458 | NS_IMETHODIMP |
michael@0 | 459 | MobileConnection::SetCallBarringOption(JS::Handle<JS::Value> aOption, |
michael@0 | 460 | nsIDOMDOMRequest** aRequest) |
michael@0 | 461 | { |
michael@0 | 462 | *aRequest = nullptr; |
michael@0 | 463 | |
michael@0 | 464 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 465 | return NS_OK; |
michael@0 | 466 | } |
michael@0 | 467 | |
michael@0 | 468 | if (!mProvider) { |
michael@0 | 469 | return NS_ERROR_FAILURE; |
michael@0 | 470 | } |
michael@0 | 471 | |
michael@0 | 472 | return mProvider->SetCallBarringOption(mClientId, GetOwner(), aOption, aRequest); |
michael@0 | 473 | } |
michael@0 | 474 | |
michael@0 | 475 | NS_IMETHODIMP |
michael@0 | 476 | MobileConnection::ChangeCallBarringPassword(JS::Handle<JS::Value> aInfo, |
michael@0 | 477 | nsIDOMDOMRequest** aRequest) |
michael@0 | 478 | { |
michael@0 | 479 | *aRequest = nullptr; |
michael@0 | 480 | |
michael@0 | 481 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 482 | return NS_OK; |
michael@0 | 483 | } |
michael@0 | 484 | |
michael@0 | 485 | if (!mProvider) { |
michael@0 | 486 | return NS_ERROR_FAILURE; |
michael@0 | 487 | } |
michael@0 | 488 | |
michael@0 | 489 | return mProvider->ChangeCallBarringPassword(mClientId, GetOwner(), aInfo, aRequest); |
michael@0 | 490 | } |
michael@0 | 491 | |
michael@0 | 492 | NS_IMETHODIMP |
michael@0 | 493 | MobileConnection::GetCallWaitingOption(nsIDOMDOMRequest** aRequest) |
michael@0 | 494 | { |
michael@0 | 495 | *aRequest = nullptr; |
michael@0 | 496 | |
michael@0 | 497 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 498 | return NS_OK; |
michael@0 | 499 | } |
michael@0 | 500 | |
michael@0 | 501 | if (!mProvider) { |
michael@0 | 502 | return NS_ERROR_FAILURE; |
michael@0 | 503 | } |
michael@0 | 504 | |
michael@0 | 505 | return mProvider->GetCallWaitingOption(mClientId, GetOwner(), aRequest); |
michael@0 | 506 | } |
michael@0 | 507 | |
michael@0 | 508 | NS_IMETHODIMP |
michael@0 | 509 | MobileConnection::SetCallWaitingOption(bool aEnabled, |
michael@0 | 510 | nsIDOMDOMRequest** aRequest) |
michael@0 | 511 | { |
michael@0 | 512 | *aRequest = nullptr; |
michael@0 | 513 | |
michael@0 | 514 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 515 | return NS_OK; |
michael@0 | 516 | } |
michael@0 | 517 | |
michael@0 | 518 | if (!mProvider) { |
michael@0 | 519 | return NS_ERROR_FAILURE; |
michael@0 | 520 | } |
michael@0 | 521 | |
michael@0 | 522 | return mProvider->SetCallWaitingOption(mClientId, GetOwner(), aEnabled, aRequest); |
michael@0 | 523 | } |
michael@0 | 524 | |
michael@0 | 525 | NS_IMETHODIMP |
michael@0 | 526 | MobileConnection::GetCallingLineIdRestriction(nsIDOMDOMRequest** aRequest) |
michael@0 | 527 | { |
michael@0 | 528 | *aRequest = nullptr; |
michael@0 | 529 | |
michael@0 | 530 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 531 | return NS_OK; |
michael@0 | 532 | } |
michael@0 | 533 | |
michael@0 | 534 | if (!mProvider) { |
michael@0 | 535 | return NS_ERROR_FAILURE; |
michael@0 | 536 | } |
michael@0 | 537 | |
michael@0 | 538 | return mProvider->GetCallingLineIdRestriction(mClientId, GetOwner(), aRequest); |
michael@0 | 539 | } |
michael@0 | 540 | |
michael@0 | 541 | NS_IMETHODIMP |
michael@0 | 542 | MobileConnection::SetCallingLineIdRestriction(unsigned short aClirMode, |
michael@0 | 543 | nsIDOMDOMRequest** aRequest) |
michael@0 | 544 | { |
michael@0 | 545 | *aRequest = nullptr; |
michael@0 | 546 | |
michael@0 | 547 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 548 | return NS_OK; |
michael@0 | 549 | } |
michael@0 | 550 | |
michael@0 | 551 | if (!mProvider) { |
michael@0 | 552 | return NS_ERROR_FAILURE; |
michael@0 | 553 | } |
michael@0 | 554 | |
michael@0 | 555 | return mProvider->SetCallingLineIdRestriction(mClientId, GetOwner(), aClirMode, aRequest); |
michael@0 | 556 | } |
michael@0 | 557 | |
michael@0 | 558 | NS_IMETHODIMP |
michael@0 | 559 | MobileConnection::ExitEmergencyCbMode(nsIDOMDOMRequest** aRequest) |
michael@0 | 560 | { |
michael@0 | 561 | *aRequest = nullptr; |
michael@0 | 562 | |
michael@0 | 563 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 564 | return NS_OK; |
michael@0 | 565 | } |
michael@0 | 566 | |
michael@0 | 567 | if (!mProvider) { |
michael@0 | 568 | return NS_ERROR_FAILURE; |
michael@0 | 569 | } |
michael@0 | 570 | |
michael@0 | 571 | return mProvider->ExitEmergencyCbMode(mClientId, GetOwner(), aRequest); |
michael@0 | 572 | } |
michael@0 | 573 | |
michael@0 | 574 | NS_IMETHODIMP |
michael@0 | 575 | MobileConnection::SetRadioEnabled(bool aEnabled, |
michael@0 | 576 | nsIDOMDOMRequest** aRequest) |
michael@0 | 577 | { |
michael@0 | 578 | *aRequest = nullptr; |
michael@0 | 579 | |
michael@0 | 580 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 581 | return NS_OK; |
michael@0 | 582 | } |
michael@0 | 583 | |
michael@0 | 584 | if (!mProvider) { |
michael@0 | 585 | return NS_ERROR_FAILURE; |
michael@0 | 586 | } |
michael@0 | 587 | |
michael@0 | 588 | return mProvider->SetRadioEnabled(mClientId, GetOwner(), aEnabled, aRequest); |
michael@0 | 589 | } |
michael@0 | 590 | |
michael@0 | 591 | // nsIMobileConnectionListener |
michael@0 | 592 | |
michael@0 | 593 | NS_IMETHODIMP |
michael@0 | 594 | MobileConnection::NotifyVoiceChanged() |
michael@0 | 595 | { |
michael@0 | 596 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 597 | return NS_OK; |
michael@0 | 598 | } |
michael@0 | 599 | |
michael@0 | 600 | return DispatchTrustedEvent(NS_LITERAL_STRING("voicechange")); |
michael@0 | 601 | } |
michael@0 | 602 | |
michael@0 | 603 | NS_IMETHODIMP |
michael@0 | 604 | MobileConnection::NotifyDataChanged() |
michael@0 | 605 | { |
michael@0 | 606 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 607 | return NS_OK; |
michael@0 | 608 | } |
michael@0 | 609 | |
michael@0 | 610 | return DispatchTrustedEvent(NS_LITERAL_STRING("datachange")); |
michael@0 | 611 | } |
michael@0 | 612 | |
michael@0 | 613 | NS_IMETHODIMP |
michael@0 | 614 | MobileConnection::NotifyUssdReceived(const nsAString& aMessage, |
michael@0 | 615 | bool aSessionEnded) |
michael@0 | 616 | { |
michael@0 | 617 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 618 | return NS_OK; |
michael@0 | 619 | } |
michael@0 | 620 | |
michael@0 | 621 | USSDReceivedEventInit init; |
michael@0 | 622 | init.mBubbles = false; |
michael@0 | 623 | init.mCancelable = false; |
michael@0 | 624 | init.mMessage = aMessage; |
michael@0 | 625 | init.mSessionEnded = aSessionEnded; |
michael@0 | 626 | |
michael@0 | 627 | nsRefPtr<USSDReceivedEvent> event = |
michael@0 | 628 | USSDReceivedEvent::Constructor(this, NS_LITERAL_STRING("ussdreceived"), init); |
michael@0 | 629 | |
michael@0 | 630 | return DispatchTrustedEvent(event); |
michael@0 | 631 | } |
michael@0 | 632 | |
michael@0 | 633 | NS_IMETHODIMP |
michael@0 | 634 | MobileConnection::NotifyDataError(const nsAString& aMessage) |
michael@0 | 635 | { |
michael@0 | 636 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 637 | return NS_OK; |
michael@0 | 638 | } |
michael@0 | 639 | |
michael@0 | 640 | DataErrorEventInit init; |
michael@0 | 641 | init.mBubbles = false; |
michael@0 | 642 | init.mCancelable = false; |
michael@0 | 643 | init.mMessage = aMessage; |
michael@0 | 644 | |
michael@0 | 645 | nsRefPtr<DataErrorEvent> event = |
michael@0 | 646 | DataErrorEvent::Constructor(this, NS_LITERAL_STRING("dataerror"), init); |
michael@0 | 647 | |
michael@0 | 648 | return DispatchTrustedEvent(event); |
michael@0 | 649 | } |
michael@0 | 650 | |
michael@0 | 651 | NS_IMETHODIMP |
michael@0 | 652 | MobileConnection::NotifyCFStateChange(bool aSuccess, |
michael@0 | 653 | unsigned short aAction, |
michael@0 | 654 | unsigned short aReason, |
michael@0 | 655 | const nsAString& aNumber, |
michael@0 | 656 | unsigned short aSeconds, |
michael@0 | 657 | unsigned short aServiceClass) |
michael@0 | 658 | { |
michael@0 | 659 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 660 | return NS_OK; |
michael@0 | 661 | } |
michael@0 | 662 | |
michael@0 | 663 | CFStateChangeEventInit init; |
michael@0 | 664 | init.mBubbles = false; |
michael@0 | 665 | init.mCancelable = false; |
michael@0 | 666 | init.mSuccess = aSuccess; |
michael@0 | 667 | init.mAction = aAction; |
michael@0 | 668 | init.mReason = aReason; |
michael@0 | 669 | init.mNumber = aNumber; |
michael@0 | 670 | init.mTimeSeconds = aSeconds; |
michael@0 | 671 | init.mServiceClass = aServiceClass; |
michael@0 | 672 | |
michael@0 | 673 | nsRefPtr<CFStateChangeEvent> event = |
michael@0 | 674 | CFStateChangeEvent::Constructor(this, NS_LITERAL_STRING("cfstatechange"), init); |
michael@0 | 675 | |
michael@0 | 676 | return DispatchTrustedEvent(event); |
michael@0 | 677 | } |
michael@0 | 678 | |
michael@0 | 679 | NS_IMETHODIMP |
michael@0 | 680 | MobileConnection::NotifyEmergencyCbModeChanged(bool aActive, |
michael@0 | 681 | uint32_t aTimeoutMs) |
michael@0 | 682 | { |
michael@0 | 683 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 684 | return NS_OK; |
michael@0 | 685 | } |
michael@0 | 686 | |
michael@0 | 687 | MozEmergencyCbModeEventInit init; |
michael@0 | 688 | init.mBubbles = false; |
michael@0 | 689 | init.mCancelable = false; |
michael@0 | 690 | init.mActive = aActive; |
michael@0 | 691 | init.mTimeoutMs = aTimeoutMs; |
michael@0 | 692 | |
michael@0 | 693 | nsRefPtr<MozEmergencyCbModeEvent> event = |
michael@0 | 694 | MozEmergencyCbModeEvent::Constructor(this, NS_LITERAL_STRING("emergencycbmodechange"), init); |
michael@0 | 695 | |
michael@0 | 696 | return DispatchTrustedEvent(event); |
michael@0 | 697 | } |
michael@0 | 698 | |
michael@0 | 699 | NS_IMETHODIMP |
michael@0 | 700 | MobileConnection::NotifyOtaStatusChanged(const nsAString& aStatus) |
michael@0 | 701 | { |
michael@0 | 702 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 703 | return NS_OK; |
michael@0 | 704 | } |
michael@0 | 705 | |
michael@0 | 706 | MozOtaStatusEventInit init; |
michael@0 | 707 | init.mBubbles = false; |
michael@0 | 708 | init.mCancelable = false; |
michael@0 | 709 | init.mStatus = aStatus; |
michael@0 | 710 | |
michael@0 | 711 | nsRefPtr<MozOtaStatusEvent> event = |
michael@0 | 712 | MozOtaStatusEvent::Constructor(this, NS_LITERAL_STRING("otastatuschange"), init); |
michael@0 | 713 | |
michael@0 | 714 | return DispatchTrustedEvent(event); |
michael@0 | 715 | } |
michael@0 | 716 | |
michael@0 | 717 | NS_IMETHODIMP |
michael@0 | 718 | MobileConnection::NotifyIccChanged() |
michael@0 | 719 | { |
michael@0 | 720 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 721 | return NS_OK; |
michael@0 | 722 | } |
michael@0 | 723 | |
michael@0 | 724 | return DispatchTrustedEvent(NS_LITERAL_STRING("iccchange")); |
michael@0 | 725 | } |
michael@0 | 726 | |
michael@0 | 727 | NS_IMETHODIMP |
michael@0 | 728 | MobileConnection::NotifyRadioStateChanged() |
michael@0 | 729 | { |
michael@0 | 730 | if (!CheckPermission("mobileconnection")) { |
michael@0 | 731 | return NS_OK; |
michael@0 | 732 | } |
michael@0 | 733 | |
michael@0 | 734 | return DispatchTrustedEvent(NS_LITERAL_STRING("radiostatechange")); |
michael@0 | 735 | } |