dom/telephony/TelephonyCall.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     2 /* vim: set ts=2 et sw=2 tw=40: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_telephony_telephonycall_h__
     8 #define mozilla_dom_telephony_telephonycall_h__
    10 #include "mozilla/dom/telephony/TelephonyCommon.h"
    12 #include "mozilla/dom/DOMError.h"
    14 class nsPIDOMWindow;
    16 namespace mozilla {
    17 namespace dom {
    19 class TelephonyCall MOZ_FINAL : public DOMEventTargetHelper
    20 {
    21   nsRefPtr<Telephony> mTelephony;
    22   nsRefPtr<TelephonyCallGroup> mGroup;
    24   uint32_t mServiceId;
    25   nsString mNumber;
    26   nsString mSecondNumber;
    27   nsString mState;
    28   bool mEmergency;
    29   nsRefPtr<DOMError> mError;
    30   bool mSwitchable;
    31   bool mMergeable;
    33   uint32_t mCallIndex;
    34   uint16_t mCallState;
    35   bool mLive;
    37 public:
    38   NS_DECL_ISUPPORTS_INHERITED
    39   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
    40   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall,
    41                                            DOMEventTargetHelper)
    43   friend class Telephony;
    45   nsPIDOMWindow*
    46   GetParentObject() const
    47   {
    48     return GetOwner();
    49   }
    51   // WrapperCache
    52   virtual JSObject*
    53   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    55   // WebIDL
    56   void
    57   GetNumber(nsString& aNumber) const
    58   {
    59     aNumber.Assign(mNumber);
    60   }
    62   void
    63   GetSecondNumber(nsString& aSecondNumber) const
    64   {
    65     aSecondNumber.Assign(mSecondNumber);
    66   }
    68   void
    69   GetState(nsString& aState) const
    70   {
    71     aState.Assign(mState);
    72   }
    74   bool
    75   Emergency() const
    76   {
    77     return mEmergency;
    78   }
    80   bool
    81   Switchable() const
    82   {
    83     return mSwitchable;
    84   }
    86   bool
    87   Mergeable() const
    88   {
    89     return mMergeable;
    90   }
    92   already_AddRefed<DOMError>
    93   GetError() const;
    95   already_AddRefed<TelephonyCallGroup>
    96   GetGroup() const;
    98   void
    99   Answer(ErrorResult& aRv);
   101   void
   102   HangUp(ErrorResult& aRv);
   104   void
   105   Hold(ErrorResult& aRv);
   107   void
   108   Resume(ErrorResult& aRv);
   110   IMPL_EVENT_HANDLER(statechange)
   111   IMPL_EVENT_HANDLER(dialing)
   112   IMPL_EVENT_HANDLER(alerting)
   113   IMPL_EVENT_HANDLER(connecting)
   114   IMPL_EVENT_HANDLER(connected)
   115   IMPL_EVENT_HANDLER(disconnecting)
   116   IMPL_EVENT_HANDLER(disconnected)
   117   IMPL_EVENT_HANDLER(holding)
   118   IMPL_EVENT_HANDLER(held)
   119   IMPL_EVENT_HANDLER(resuming)
   120   IMPL_EVENT_HANDLER(error)
   121   IMPL_EVENT_HANDLER(groupchange)
   123   static already_AddRefed<TelephonyCall>
   124   Create(Telephony* aTelephony, uint32_t aServiceId,
   125          const nsAString& aNumber, uint16_t aCallState,
   126          uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex,
   127          bool aEmergency = false, bool aIsConference = false,
   128          bool aSwitchable = true, bool aMergeable = true);
   130   void
   131   ChangeState(uint16_t aCallState)
   132   {
   133     ChangeStateInternal(aCallState, true);
   134   }
   136   uint32_t
   137   ServiceId() const
   138   {
   139     return mServiceId;
   140   }
   142   uint32_t
   143   CallIndex() const
   144   {
   145     return mCallIndex;
   146   }
   148   void
   149   UpdateCallIndex(uint32_t aCallIndex)
   150   {
   151     NS_ASSERTION(mCallIndex == telephony::kOutgoingPlaceholderCallIndex,
   152                  "Call index should not be set!");
   153     mCallIndex = aCallIndex;
   154   }
   156   uint16_t
   157   CallState() const
   158   {
   159     return mCallState;
   160   }
   162   void
   163   UpdateEmergency(bool aEmergency)
   164   {
   165     mEmergency = aEmergency;
   166   }
   168   void
   169   UpdateSecondNumber(const nsAString& aNumber)
   170   {
   171     mSecondNumber = aNumber;
   172   }
   174   void
   175   UpdateSwitchable(bool aSwitchable) {
   176     mSwitchable = aSwitchable;
   177   }
   179   void
   180   UpdateMergeable(bool aMergeable) {
   181     mMergeable = aMergeable;
   182   }
   184   void
   185   NotifyError(const nsAString& aError);
   187   void
   188   ChangeGroup(TelephonyCallGroup* aGroup);
   190 private:
   191   TelephonyCall(nsPIDOMWindow* aOwner);
   193   ~TelephonyCall();
   195   void
   196   ChangeStateInternal(uint16_t aCallState, bool aFireEvents);
   198   nsresult
   199   DispatchCallEvent(const nsAString& aType,
   200                     TelephonyCall* aCall);
   201 };
   203 } // namespace dom
   204 } // namespace mozilla
   206 #endif // mozilla_dom_telephony_telephonycall_h__

mercurial