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++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "mozilla/dom/telephony/TelephonyChild.h" |
michael@0 | 7 | |
michael@0 | 8 | USING_TELEPHONY_NAMESPACE |
michael@0 | 9 | |
michael@0 | 10 | /******************************************************************************* |
michael@0 | 11 | * TelephonyChild |
michael@0 | 12 | ******************************************************************************/ |
michael@0 | 13 | |
michael@0 | 14 | TelephonyChild::TelephonyChild(nsITelephonyListener* aListener) |
michael@0 | 15 | : mListener(aListener) |
michael@0 | 16 | { |
michael@0 | 17 | MOZ_ASSERT(aListener); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | void |
michael@0 | 21 | TelephonyChild::ActorDestroy(ActorDestroyReason aWhy) |
michael@0 | 22 | { |
michael@0 | 23 | mListener = nullptr; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | PTelephonyRequestChild* |
michael@0 | 27 | TelephonyChild::AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest) |
michael@0 | 28 | { |
michael@0 | 29 | MOZ_CRASH("Caller is supposed to manually construct a request!"); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | bool |
michael@0 | 33 | TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) |
michael@0 | 34 | { |
michael@0 | 35 | delete aActor; |
michael@0 | 36 | return true; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | bool |
michael@0 | 40 | TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId, |
michael@0 | 41 | const int32_t& aCallIndex, |
michael@0 | 42 | const nsString& aError) |
michael@0 | 43 | { |
michael@0 | 44 | MOZ_ASSERT(mListener); |
michael@0 | 45 | |
michael@0 | 46 | mListener->NotifyError(aClientId, aCallIndex, aError); |
michael@0 | 47 | return true; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | bool |
michael@0 | 51 | TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId, |
michael@0 | 52 | const IPCCallStateData& aData) |
michael@0 | 53 | { |
michael@0 | 54 | MOZ_ASSERT(mListener); |
michael@0 | 55 | |
michael@0 | 56 | mListener->CallStateChanged(aClientId, |
michael@0 | 57 | aData.callIndex(), |
michael@0 | 58 | aData.callState(), |
michael@0 | 59 | aData.number(), |
michael@0 | 60 | aData.isActive(), |
michael@0 | 61 | aData.isOutGoing(), |
michael@0 | 62 | aData.isEmergency(), |
michael@0 | 63 | aData.isConference(), |
michael@0 | 64 | aData.isSwitchable(), |
michael@0 | 65 | aData.isMergeable()); |
michael@0 | 66 | return true; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | bool |
michael@0 | 70 | TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, |
michael@0 | 71 | const nsString& aNumber) |
michael@0 | 72 | { |
michael@0 | 73 | MOZ_ASSERT(mListener); |
michael@0 | 74 | |
michael@0 | 75 | mListener->NotifyCdmaCallWaiting(aClientId, aNumber); |
michael@0 | 76 | return true; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | bool |
michael@0 | 80 | TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) |
michael@0 | 81 | { |
michael@0 | 82 | MOZ_ASSERT(mListener); |
michael@0 | 83 | |
michael@0 | 84 | mListener->ConferenceCallStateChanged(aCallState); |
michael@0 | 85 | return true; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | bool |
michael@0 | 89 | TelephonyChild::RecvNotifyConferenceError(const nsString& aName, |
michael@0 | 90 | const nsString& aMessage) |
michael@0 | 91 | { |
michael@0 | 92 | MOZ_ASSERT(mListener); |
michael@0 | 93 | |
michael@0 | 94 | mListener->NotifyConferenceError(aName, aMessage); |
michael@0 | 95 | return true; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | bool |
michael@0 | 99 | TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId, |
michael@0 | 100 | const int32_t& aCallIndex, |
michael@0 | 101 | const uint16_t& aNotification) |
michael@0 | 102 | { |
michael@0 | 103 | MOZ_ASSERT(mListener); |
michael@0 | 104 | |
michael@0 | 105 | mListener->SupplementaryServiceNotification(aClientId, aCallIndex, |
michael@0 | 106 | aNotification); |
michael@0 | 107 | return true; |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | /******************************************************************************* |
michael@0 | 111 | * TelephonyRequestChild |
michael@0 | 112 | ******************************************************************************/ |
michael@0 | 113 | |
michael@0 | 114 | TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener, |
michael@0 | 115 | nsITelephonyCallback* aCallback) |
michael@0 | 116 | : mListener(aListener), mCallback(aCallback) |
michael@0 | 117 | { |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | void |
michael@0 | 121 | TelephonyRequestChild::ActorDestroy(ActorDestroyReason aWhy) |
michael@0 | 122 | { |
michael@0 | 123 | mListener = nullptr; |
michael@0 | 124 | mCallback = nullptr; |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | bool |
michael@0 | 128 | TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse) |
michael@0 | 129 | { |
michael@0 | 130 | switch (aResponse.type()) { |
michael@0 | 131 | case IPCTelephonyResponse::TEnumerateCallsResponse: |
michael@0 | 132 | mListener->EnumerateCallStateComplete(); |
michael@0 | 133 | break; |
michael@0 | 134 | case IPCTelephonyResponse::TDialResponse: |
michael@0 | 135 | // Do nothing. |
michael@0 | 136 | break; |
michael@0 | 137 | default: |
michael@0 | 138 | MOZ_CRASH("Unknown type!"); |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | return true; |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | bool |
michael@0 | 145 | TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId, |
michael@0 | 146 | const IPCCallStateData& aData) |
michael@0 | 147 | { |
michael@0 | 148 | MOZ_ASSERT(mListener); |
michael@0 | 149 | |
michael@0 | 150 | mListener->EnumerateCallState(aClientId, |
michael@0 | 151 | aData.callIndex(), |
michael@0 | 152 | aData.callState(), |
michael@0 | 153 | aData.number(), |
michael@0 | 154 | aData.isActive(), |
michael@0 | 155 | aData.isOutGoing(), |
michael@0 | 156 | aData.isEmergency(), |
michael@0 | 157 | aData.isConference(), |
michael@0 | 158 | aData.isSwitchable(), |
michael@0 | 159 | aData.isMergeable()); |
michael@0 | 160 | return true; |
michael@0 | 161 | } |
michael@0 | 162 | |
michael@0 | 163 | bool |
michael@0 | 164 | TelephonyRequestChild::RecvNotifyDialError(const nsString& aError) |
michael@0 | 165 | { |
michael@0 | 166 | MOZ_ASSERT(mCallback); |
michael@0 | 167 | |
michael@0 | 168 | mCallback->NotifyDialError(aError); |
michael@0 | 169 | return true; |
michael@0 | 170 | } |
michael@0 | 171 | |
michael@0 | 172 | bool |
michael@0 | 173 | TelephonyRequestChild::RecvNotifyDialSuccess() |
michael@0 | 174 | { |
michael@0 | 175 | MOZ_ASSERT(mCallback); |
michael@0 | 176 | |
michael@0 | 177 | mCallback->NotifyDialSuccess(); |
michael@0 | 178 | return true; |
michael@0 | 179 | } |