dom/telephony/ipc/TelephonyChild.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/telephony/ipc/TelephonyChild.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,179 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "mozilla/dom/telephony/TelephonyChild.h"
    1.10 +
    1.11 +USING_TELEPHONY_NAMESPACE
    1.12 +
    1.13 +/*******************************************************************************
    1.14 + * TelephonyChild
    1.15 + ******************************************************************************/
    1.16 +
    1.17 +TelephonyChild::TelephonyChild(nsITelephonyListener* aListener)
    1.18 +  : mListener(aListener)
    1.19 +{
    1.20 +  MOZ_ASSERT(aListener);
    1.21 +}
    1.22 +
    1.23 +void
    1.24 +TelephonyChild::ActorDestroy(ActorDestroyReason aWhy)
    1.25 +{
    1.26 +  mListener = nullptr;
    1.27 +}
    1.28 +
    1.29 +PTelephonyRequestChild*
    1.30 +TelephonyChild::AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest)
    1.31 +{
    1.32 +  MOZ_CRASH("Caller is supposed to manually construct a request!");
    1.33 +}
    1.34 +
    1.35 +bool
    1.36 +TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor)
    1.37 +{
    1.38 +  delete aActor;
    1.39 +  return true;
    1.40 +}
    1.41 +
    1.42 +bool
    1.43 +TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId,
    1.44 +                                    const int32_t& aCallIndex,
    1.45 +                                    const nsString& aError)
    1.46 +{
    1.47 +  MOZ_ASSERT(mListener);
    1.48 +
    1.49 +  mListener->NotifyError(aClientId, aCallIndex, aError);
    1.50 +  return true;
    1.51 +}
    1.52 +
    1.53 +bool
    1.54 +TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId,
    1.55 +                                           const IPCCallStateData& aData)
    1.56 +{
    1.57 +  MOZ_ASSERT(mListener);
    1.58 +
    1.59 +  mListener->CallStateChanged(aClientId,
    1.60 +                              aData.callIndex(),
    1.61 +                              aData.callState(),
    1.62 +                              aData.number(),
    1.63 +                              aData.isActive(),
    1.64 +                              aData.isOutGoing(),
    1.65 +                              aData.isEmergency(),
    1.66 +                              aData.isConference(),
    1.67 +                              aData.isSwitchable(),
    1.68 +                              aData.isMergeable());
    1.69 +  return true;
    1.70 +}
    1.71 +
    1.72 +bool
    1.73 +TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId,
    1.74 +                                          const nsString& aNumber)
    1.75 +{
    1.76 +  MOZ_ASSERT(mListener);
    1.77 +
    1.78 +  mListener->NotifyCdmaCallWaiting(aClientId, aNumber);
    1.79 +  return true;
    1.80 +}
    1.81 +
    1.82 +bool
    1.83 +TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState)
    1.84 +{
    1.85 +  MOZ_ASSERT(mListener);
    1.86 +
    1.87 +  mListener->ConferenceCallStateChanged(aCallState);
    1.88 +  return true;
    1.89 +}
    1.90 +
    1.91 +bool
    1.92 +TelephonyChild::RecvNotifyConferenceError(const nsString& aName,
    1.93 +                                          const nsString& aMessage)
    1.94 +{
    1.95 +  MOZ_ASSERT(mListener);
    1.96 +
    1.97 +  mListener->NotifyConferenceError(aName, aMessage);
    1.98 +  return true;
    1.99 +}
   1.100 +
   1.101 +bool
   1.102 +TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId,
   1.103 +                                               const int32_t& aCallIndex,
   1.104 +                                               const uint16_t& aNotification)
   1.105 +{
   1.106 +  MOZ_ASSERT(mListener);
   1.107 +
   1.108 +  mListener->SupplementaryServiceNotification(aClientId, aCallIndex,
   1.109 +                                              aNotification);
   1.110 +  return true;
   1.111 +}
   1.112 +
   1.113 +/*******************************************************************************
   1.114 + * TelephonyRequestChild
   1.115 + ******************************************************************************/
   1.116 +
   1.117 +TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener,
   1.118 +                                             nsITelephonyCallback* aCallback)
   1.119 +  : mListener(aListener), mCallback(aCallback)
   1.120 +{
   1.121 +}
   1.122 +
   1.123 +void
   1.124 +TelephonyRequestChild::ActorDestroy(ActorDestroyReason aWhy)
   1.125 +{
   1.126 +  mListener = nullptr;
   1.127 +  mCallback = nullptr;
   1.128 +}
   1.129 +
   1.130 +bool
   1.131 +TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse)
   1.132 +{
   1.133 +  switch (aResponse.type()) {
   1.134 +    case IPCTelephonyResponse::TEnumerateCallsResponse:
   1.135 +      mListener->EnumerateCallStateComplete();
   1.136 +      break;
   1.137 +    case IPCTelephonyResponse::TDialResponse:
   1.138 +      // Do nothing.
   1.139 +      break;
   1.140 +    default:
   1.141 +      MOZ_CRASH("Unknown type!");
   1.142 +  }
   1.143 +
   1.144 +  return true;
   1.145 +}
   1.146 +
   1.147 +bool
   1.148 +TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId,
   1.149 +                                                    const IPCCallStateData& aData)
   1.150 +{
   1.151 +  MOZ_ASSERT(mListener);
   1.152 +
   1.153 +  mListener->EnumerateCallState(aClientId,
   1.154 +                                aData.callIndex(),
   1.155 +                                aData.callState(),
   1.156 +                                aData.number(),
   1.157 +                                aData.isActive(),
   1.158 +                                aData.isOutGoing(),
   1.159 +                                aData.isEmergency(),
   1.160 +                                aData.isConference(),
   1.161 +                                aData.isSwitchable(),
   1.162 +                                aData.isMergeable());
   1.163 +  return true;
   1.164 +}
   1.165 +
   1.166 +bool
   1.167 +TelephonyRequestChild::RecvNotifyDialError(const nsString& aError)
   1.168 +{
   1.169 +  MOZ_ASSERT(mCallback);
   1.170 +
   1.171 +  mCallback->NotifyDialError(aError);
   1.172 +  return true;
   1.173 +}
   1.174 +
   1.175 +bool
   1.176 +TelephonyRequestChild::RecvNotifyDialSuccess()
   1.177 +{
   1.178 +  MOZ_ASSERT(mCallback);
   1.179 +
   1.180 +  mCallback->NotifyDialSuccess();
   1.181 +  return true;
   1.182 +}

mercurial