michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=40: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_telephony_telephonycall_h__ michael@0: #define mozilla_dom_telephony_telephonycall_h__ michael@0: michael@0: #include "mozilla/dom/telephony/TelephonyCommon.h" michael@0: michael@0: #include "mozilla/dom/DOMError.h" michael@0: michael@0: class nsPIDOMWindow; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class TelephonyCall MOZ_FINAL : public DOMEventTargetHelper michael@0: { michael@0: nsRefPtr mTelephony; michael@0: nsRefPtr mGroup; michael@0: michael@0: uint32_t mServiceId; michael@0: nsString mNumber; michael@0: nsString mSecondNumber; michael@0: nsString mState; michael@0: bool mEmergency; michael@0: nsRefPtr mError; michael@0: bool mSwitchable; michael@0: bool mMergeable; michael@0: michael@0: uint32_t mCallIndex; michael@0: uint16_t mCallState; michael@0: bool mLive; michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall, michael@0: DOMEventTargetHelper) michael@0: michael@0: friend class Telephony; michael@0: michael@0: nsPIDOMWindow* michael@0: GetParentObject() const michael@0: { michael@0: return GetOwner(); michael@0: } michael@0: michael@0: // WrapperCache michael@0: virtual JSObject* michael@0: WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: // WebIDL michael@0: void michael@0: GetNumber(nsString& aNumber) const michael@0: { michael@0: aNumber.Assign(mNumber); michael@0: } michael@0: michael@0: void michael@0: GetSecondNumber(nsString& aSecondNumber) const michael@0: { michael@0: aSecondNumber.Assign(mSecondNumber); michael@0: } michael@0: michael@0: void michael@0: GetState(nsString& aState) const michael@0: { michael@0: aState.Assign(mState); michael@0: } michael@0: michael@0: bool michael@0: Emergency() const michael@0: { michael@0: return mEmergency; michael@0: } michael@0: michael@0: bool michael@0: Switchable() const michael@0: { michael@0: return mSwitchable; michael@0: } michael@0: michael@0: bool michael@0: Mergeable() const michael@0: { michael@0: return mMergeable; michael@0: } michael@0: michael@0: already_AddRefed michael@0: GetError() const; michael@0: michael@0: already_AddRefed michael@0: GetGroup() const; michael@0: michael@0: void michael@0: Answer(ErrorResult& aRv); michael@0: michael@0: void michael@0: HangUp(ErrorResult& aRv); michael@0: michael@0: void michael@0: Hold(ErrorResult& aRv); michael@0: michael@0: void michael@0: Resume(ErrorResult& aRv); michael@0: michael@0: IMPL_EVENT_HANDLER(statechange) michael@0: IMPL_EVENT_HANDLER(dialing) michael@0: IMPL_EVENT_HANDLER(alerting) michael@0: IMPL_EVENT_HANDLER(connecting) michael@0: IMPL_EVENT_HANDLER(connected) michael@0: IMPL_EVENT_HANDLER(disconnecting) michael@0: IMPL_EVENT_HANDLER(disconnected) michael@0: IMPL_EVENT_HANDLER(holding) michael@0: IMPL_EVENT_HANDLER(held) michael@0: IMPL_EVENT_HANDLER(resuming) michael@0: IMPL_EVENT_HANDLER(error) michael@0: IMPL_EVENT_HANDLER(groupchange) michael@0: michael@0: static already_AddRefed michael@0: Create(Telephony* aTelephony, uint32_t aServiceId, michael@0: const nsAString& aNumber, uint16_t aCallState, michael@0: uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex, michael@0: bool aEmergency = false, bool aIsConference = false, michael@0: bool aSwitchable = true, bool aMergeable = true); michael@0: michael@0: void michael@0: ChangeState(uint16_t aCallState) michael@0: { michael@0: ChangeStateInternal(aCallState, true); michael@0: } michael@0: michael@0: uint32_t michael@0: ServiceId() const michael@0: { michael@0: return mServiceId; michael@0: } michael@0: michael@0: uint32_t michael@0: CallIndex() const michael@0: { michael@0: return mCallIndex; michael@0: } michael@0: michael@0: void michael@0: UpdateCallIndex(uint32_t aCallIndex) michael@0: { michael@0: NS_ASSERTION(mCallIndex == telephony::kOutgoingPlaceholderCallIndex, michael@0: "Call index should not be set!"); michael@0: mCallIndex = aCallIndex; michael@0: } michael@0: michael@0: uint16_t michael@0: CallState() const michael@0: { michael@0: return mCallState; michael@0: } michael@0: michael@0: void michael@0: UpdateEmergency(bool aEmergency) michael@0: { michael@0: mEmergency = aEmergency; michael@0: } michael@0: michael@0: void michael@0: UpdateSecondNumber(const nsAString& aNumber) michael@0: { michael@0: mSecondNumber = aNumber; michael@0: } michael@0: michael@0: void michael@0: UpdateSwitchable(bool aSwitchable) { michael@0: mSwitchable = aSwitchable; michael@0: } michael@0: michael@0: void michael@0: UpdateMergeable(bool aMergeable) { michael@0: mMergeable = aMergeable; michael@0: } michael@0: michael@0: void michael@0: NotifyError(const nsAString& aError); michael@0: michael@0: void michael@0: ChangeGroup(TelephonyCallGroup* aGroup); michael@0: michael@0: private: michael@0: TelephonyCall(nsPIDOMWindow* aOwner); michael@0: michael@0: ~TelephonyCall(); michael@0: michael@0: void michael@0: ChangeStateInternal(uint16_t aCallState, bool aFireEvents); michael@0: michael@0: nsresult michael@0: DispatchCallEvent(const nsAString& aType, michael@0: TelephonyCall* aCall); michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_telephony_telephonycall_h__