dom/telephony/ipc/TelephonyChild.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial