dom/telephony/Telephony.h

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.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_telephony_telephony_h__
michael@0 8 #define mozilla_dom_telephony_telephony_h__
michael@0 9
michael@0 10 #include "mozilla/dom/BindingDeclarations.h"
michael@0 11 #include "mozilla/dom/Promise.h"
michael@0 12 #include "mozilla/dom/telephony/TelephonyCommon.h"
michael@0 13
michael@0 14 #include "nsITelephonyProvider.h"
michael@0 15
michael@0 16 // Need to include TelephonyCall.h because we have inline methods that
michael@0 17 // assume they see the definition of TelephonyCall.
michael@0 18 #include "TelephonyCall.h"
michael@0 19
michael@0 20 class nsPIDOMWindow;
michael@0 21
michael@0 22 namespace mozilla {
michael@0 23 namespace dom {
michael@0 24
michael@0 25 class OwningTelephonyCallOrTelephonyCallGroup;
michael@0 26
michael@0 27 class Telephony MOZ_FINAL : public DOMEventTargetHelper
michael@0 28 {
michael@0 29 /**
michael@0 30 * Class Telephony doesn't actually inherit nsITelephonyListener.
michael@0 31 * Instead, it owns an nsITelephonyListener derived instance mListener
michael@0 32 * and passes it to nsITelephonyProvider. The onreceived events are first
michael@0 33 * delivered to mListener and then forwarded to its owner, Telephony. See
michael@0 34 * also bug 775997 comment #51.
michael@0 35 */
michael@0 36 class Listener;
michael@0 37
michael@0 38 class Callback;
michael@0 39 friend class Callback;
michael@0 40
michael@0 41 class EnumerationAck;
michael@0 42 friend class EnumerationAck;
michael@0 43
michael@0 44 nsCOMPtr<nsITelephonyProvider> mProvider;
michael@0 45 nsRefPtr<Listener> mListener;
michael@0 46
michael@0 47 TelephonyCall* mActiveCall;
michael@0 48 nsTArray<nsRefPtr<TelephonyCall> > mCalls;
michael@0 49 nsRefPtr<CallsList> mCallsList;
michael@0 50
michael@0 51 nsRefPtr<TelephonyCallGroup> mGroup;
michael@0 52
michael@0 53 bool mEnumerated;
michael@0 54
michael@0 55 public:
michael@0 56 NS_DECL_ISUPPORTS_INHERITED
michael@0 57 NS_DECL_NSITELEPHONYLISTENER
michael@0 58 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
michael@0 59 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Telephony,
michael@0 60 DOMEventTargetHelper)
michael@0 61
michael@0 62 nsPIDOMWindow*
michael@0 63 GetParentObject() const
michael@0 64 {
michael@0 65 return GetOwner();
michael@0 66 }
michael@0 67
michael@0 68 // WrapperCache
michael@0 69 virtual JSObject*
michael@0 70 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 71
michael@0 72 // WebIDL
michael@0 73 already_AddRefed<Promise>
michael@0 74 Dial(const nsAString& aNumber, const Optional<uint32_t>& aServiceId);
michael@0 75
michael@0 76 already_AddRefed<Promise>
michael@0 77 DialEmergency(const nsAString& aNumber, const Optional<uint32_t>& aServiceId);
michael@0 78
michael@0 79 void
michael@0 80 StartTone(const nsAString& aDTMFChar, const Optional<uint32_t>& aServiceId,
michael@0 81 ErrorResult& aRv);
michael@0 82
michael@0 83 void
michael@0 84 StopTone(const Optional<uint32_t>& aServiceId, ErrorResult& aRv);
michael@0 85
michael@0 86 bool
michael@0 87 GetMuted(ErrorResult& aRv) const;
michael@0 88
michael@0 89 void
michael@0 90 SetMuted(bool aMuted, ErrorResult& aRv);
michael@0 91
michael@0 92 bool
michael@0 93 GetSpeakerEnabled(ErrorResult& aRv) const;
michael@0 94
michael@0 95 void
michael@0 96 SetSpeakerEnabled(bool aEnabled, ErrorResult& aRv);
michael@0 97
michael@0 98 void
michael@0 99 GetActive(Nullable<OwningTelephonyCallOrTelephonyCallGroup>& aValue);
michael@0 100
michael@0 101 already_AddRefed<CallsList>
michael@0 102 Calls() const;
michael@0 103
michael@0 104 already_AddRefed<TelephonyCallGroup>
michael@0 105 ConferenceGroup() const;
michael@0 106
michael@0 107 IMPL_EVENT_HANDLER(incoming)
michael@0 108 IMPL_EVENT_HANDLER(callschanged)
michael@0 109 IMPL_EVENT_HANDLER(remoteheld)
michael@0 110 IMPL_EVENT_HANDLER(remoteresumed)
michael@0 111
michael@0 112 static already_AddRefed<Telephony>
michael@0 113 Create(nsPIDOMWindow* aOwner, ErrorResult& aRv);
michael@0 114
michael@0 115 void
michael@0 116 AddCall(TelephonyCall* aCall)
michael@0 117 {
michael@0 118 NS_ASSERTION(!mCalls.Contains(aCall), "Already know about this one!");
michael@0 119 mCalls.AppendElement(aCall);
michael@0 120 UpdateActiveCall(aCall, IsActiveState(aCall->CallState()));
michael@0 121 NotifyCallsChanged(aCall);
michael@0 122 }
michael@0 123
michael@0 124 void
michael@0 125 RemoveCall(TelephonyCall* aCall)
michael@0 126 {
michael@0 127 NS_ASSERTION(mCalls.Contains(aCall), "Didn't know about this one!");
michael@0 128 mCalls.RemoveElement(aCall);
michael@0 129 UpdateActiveCall(aCall, false);
michael@0 130 NotifyCallsChanged(aCall);
michael@0 131 }
michael@0 132
michael@0 133 nsITelephonyProvider*
michael@0 134 Provider() const
michael@0 135 {
michael@0 136 return mProvider;
michael@0 137 }
michael@0 138
michael@0 139 const nsTArray<nsRefPtr<TelephonyCall> >&
michael@0 140 CallsArray() const
michael@0 141 {
michael@0 142 return mCalls;
michael@0 143 }
michael@0 144
michael@0 145 virtual void EventListenerAdded(nsIAtom* aType) MOZ_OVERRIDE;
michael@0 146
michael@0 147 private:
michael@0 148 Telephony(nsPIDOMWindow* aOwner);
michael@0 149 ~Telephony();
michael@0 150
michael@0 151 void
michael@0 152 Shutdown();
michael@0 153
michael@0 154 static bool
michael@0 155 IsValidNumber(const nsAString& aNumber);
michael@0 156
michael@0 157 static uint32_t
michael@0 158 GetNumServices();
michael@0 159
michael@0 160 static bool
michael@0 161 IsValidServiceId(uint32_t aServiceId);
michael@0 162
michael@0 163 static bool
michael@0 164 IsActiveState(uint16_t aCallState);
michael@0 165
michael@0 166 uint32_t
michael@0 167 ProvidedOrDefaultServiceId(const Optional<uint32_t>& aServiceId);
michael@0 168
michael@0 169 bool
michael@0 170 HasDialingCall();
michael@0 171
michael@0 172 bool
michael@0 173 MatchActiveCall(TelephonyCall* aCall);
michael@0 174
michael@0 175 already_AddRefed<Promise>
michael@0 176 DialInternal(uint32_t aServiceId, const nsAString& aNumber, bool isEmergency);
michael@0 177
michael@0 178 already_AddRefed<TelephonyCall>
michael@0 179 CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber);
michael@0 180
michael@0 181 nsresult
michael@0 182 NotifyCallsChanged(TelephonyCall* aCall);
michael@0 183
michael@0 184 nsresult
michael@0 185 DispatchCallEvent(const nsAString& aType, TelephonyCall* aCall);
michael@0 186
michael@0 187 void
michael@0 188 EnqueueEnumerationAck();
michael@0 189
michael@0 190 void
michael@0 191 UpdateActiveCall(TelephonyCall* aCall, bool aIsActive);
michael@0 192
michael@0 193 already_AddRefed<TelephonyCall>
michael@0 194 GetCall(uint32_t aServiceId, uint32_t aCallIndex);
michael@0 195
michael@0 196 already_AddRefed<TelephonyCall>
michael@0 197 GetOutgoingCall();
michael@0 198
michael@0 199 already_AddRefed<TelephonyCall>
michael@0 200 GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex);
michael@0 201 };
michael@0 202
michael@0 203 } // namespace dom
michael@0 204 } // namespace mozilla
michael@0 205
michael@0 206 #endif // mozilla_dom_telephony_telephony_h__

mercurial