dom/telephony/TelephonyCall.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/telephony/TelephonyCall.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,206 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=40: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_telephony_telephonycall_h__
    1.11 +#define mozilla_dom_telephony_telephonycall_h__
    1.12 +
    1.13 +#include "mozilla/dom/telephony/TelephonyCommon.h"
    1.14 +
    1.15 +#include "mozilla/dom/DOMError.h"
    1.16 +
    1.17 +class nsPIDOMWindow;
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace dom {
    1.21 +
    1.22 +class TelephonyCall MOZ_FINAL : public DOMEventTargetHelper
    1.23 +{
    1.24 +  nsRefPtr<Telephony> mTelephony;
    1.25 +  nsRefPtr<TelephonyCallGroup> mGroup;
    1.26 +
    1.27 +  uint32_t mServiceId;
    1.28 +  nsString mNumber;
    1.29 +  nsString mSecondNumber;
    1.30 +  nsString mState;
    1.31 +  bool mEmergency;
    1.32 +  nsRefPtr<DOMError> mError;
    1.33 +  bool mSwitchable;
    1.34 +  bool mMergeable;
    1.35 +
    1.36 +  uint32_t mCallIndex;
    1.37 +  uint16_t mCallState;
    1.38 +  bool mLive;
    1.39 +
    1.40 +public:
    1.41 +  NS_DECL_ISUPPORTS_INHERITED
    1.42 +  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
    1.43 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall,
    1.44 +                                           DOMEventTargetHelper)
    1.45 +
    1.46 +  friend class Telephony;
    1.47 +
    1.48 +  nsPIDOMWindow*
    1.49 +  GetParentObject() const
    1.50 +  {
    1.51 +    return GetOwner();
    1.52 +  }
    1.53 +
    1.54 +  // WrapperCache
    1.55 +  virtual JSObject*
    1.56 +  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.57 +
    1.58 +  // WebIDL
    1.59 +  void
    1.60 +  GetNumber(nsString& aNumber) const
    1.61 +  {
    1.62 +    aNumber.Assign(mNumber);
    1.63 +  }
    1.64 +
    1.65 +  void
    1.66 +  GetSecondNumber(nsString& aSecondNumber) const
    1.67 +  {
    1.68 +    aSecondNumber.Assign(mSecondNumber);
    1.69 +  }
    1.70 +
    1.71 +  void
    1.72 +  GetState(nsString& aState) const
    1.73 +  {
    1.74 +    aState.Assign(mState);
    1.75 +  }
    1.76 +
    1.77 +  bool
    1.78 +  Emergency() const
    1.79 +  {
    1.80 +    return mEmergency;
    1.81 +  }
    1.82 +
    1.83 +  bool
    1.84 +  Switchable() const
    1.85 +  {
    1.86 +    return mSwitchable;
    1.87 +  }
    1.88 +
    1.89 +  bool
    1.90 +  Mergeable() const
    1.91 +  {
    1.92 +    return mMergeable;
    1.93 +  }
    1.94 +
    1.95 +  already_AddRefed<DOMError>
    1.96 +  GetError() const;
    1.97 +
    1.98 +  already_AddRefed<TelephonyCallGroup>
    1.99 +  GetGroup() const;
   1.100 +
   1.101 +  void
   1.102 +  Answer(ErrorResult& aRv);
   1.103 +
   1.104 +  void
   1.105 +  HangUp(ErrorResult& aRv);
   1.106 +
   1.107 +  void
   1.108 +  Hold(ErrorResult& aRv);
   1.109 +
   1.110 +  void
   1.111 +  Resume(ErrorResult& aRv);
   1.112 +
   1.113 +  IMPL_EVENT_HANDLER(statechange)
   1.114 +  IMPL_EVENT_HANDLER(dialing)
   1.115 +  IMPL_EVENT_HANDLER(alerting)
   1.116 +  IMPL_EVENT_HANDLER(connecting)
   1.117 +  IMPL_EVENT_HANDLER(connected)
   1.118 +  IMPL_EVENT_HANDLER(disconnecting)
   1.119 +  IMPL_EVENT_HANDLER(disconnected)
   1.120 +  IMPL_EVENT_HANDLER(holding)
   1.121 +  IMPL_EVENT_HANDLER(held)
   1.122 +  IMPL_EVENT_HANDLER(resuming)
   1.123 +  IMPL_EVENT_HANDLER(error)
   1.124 +  IMPL_EVENT_HANDLER(groupchange)
   1.125 +
   1.126 +  static already_AddRefed<TelephonyCall>
   1.127 +  Create(Telephony* aTelephony, uint32_t aServiceId,
   1.128 +         const nsAString& aNumber, uint16_t aCallState,
   1.129 +         uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex,
   1.130 +         bool aEmergency = false, bool aIsConference = false,
   1.131 +         bool aSwitchable = true, bool aMergeable = true);
   1.132 +
   1.133 +  void
   1.134 +  ChangeState(uint16_t aCallState)
   1.135 +  {
   1.136 +    ChangeStateInternal(aCallState, true);
   1.137 +  }
   1.138 +
   1.139 +  uint32_t
   1.140 +  ServiceId() const
   1.141 +  {
   1.142 +    return mServiceId;
   1.143 +  }
   1.144 +
   1.145 +  uint32_t
   1.146 +  CallIndex() const
   1.147 +  {
   1.148 +    return mCallIndex;
   1.149 +  }
   1.150 +
   1.151 +  void
   1.152 +  UpdateCallIndex(uint32_t aCallIndex)
   1.153 +  {
   1.154 +    NS_ASSERTION(mCallIndex == telephony::kOutgoingPlaceholderCallIndex,
   1.155 +                 "Call index should not be set!");
   1.156 +    mCallIndex = aCallIndex;
   1.157 +  }
   1.158 +
   1.159 +  uint16_t
   1.160 +  CallState() const
   1.161 +  {
   1.162 +    return mCallState;
   1.163 +  }
   1.164 +
   1.165 +  void
   1.166 +  UpdateEmergency(bool aEmergency)
   1.167 +  {
   1.168 +    mEmergency = aEmergency;
   1.169 +  }
   1.170 +
   1.171 +  void
   1.172 +  UpdateSecondNumber(const nsAString& aNumber)
   1.173 +  {
   1.174 +    mSecondNumber = aNumber;
   1.175 +  }
   1.176 +
   1.177 +  void
   1.178 +  UpdateSwitchable(bool aSwitchable) {
   1.179 +    mSwitchable = aSwitchable;
   1.180 +  }
   1.181 +
   1.182 +  void
   1.183 +  UpdateMergeable(bool aMergeable) {
   1.184 +    mMergeable = aMergeable;
   1.185 +  }
   1.186 +
   1.187 +  void
   1.188 +  NotifyError(const nsAString& aError);
   1.189 +
   1.190 +  void
   1.191 +  ChangeGroup(TelephonyCallGroup* aGroup);
   1.192 +
   1.193 +private:
   1.194 +  TelephonyCall(nsPIDOMWindow* aOwner);
   1.195 +
   1.196 +  ~TelephonyCall();
   1.197 +
   1.198 +  void
   1.199 +  ChangeStateInternal(uint16_t aCallState, bool aFireEvents);
   1.200 +
   1.201 +  nsresult
   1.202 +  DispatchCallEvent(const nsAString& aType,
   1.203 +                    TelephonyCall* aCall);
   1.204 +};
   1.205 +
   1.206 +} // namespace dom
   1.207 +} // namespace mozilla
   1.208 +
   1.209 +#endif // mozilla_dom_telephony_telephonycall_h__

mercurial