michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 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_telephonycallgroup_h__ michael@0: #define mozilla_dom_telephony_telephonycallgroup_h__ michael@0: michael@0: #include "mozilla/dom/telephony/TelephonyCommon.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class TelephonyCallGroup MOZ_FINAL : public DOMEventTargetHelper michael@0: { michael@0: nsRefPtr mTelephony; michael@0: michael@0: nsTArray > mCalls; michael@0: michael@0: nsRefPtr mCallsList; michael@0: michael@0: nsString mState; michael@0: michael@0: uint16_t mCallState; michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCallGroup, michael@0: DOMEventTargetHelper) 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 interface michael@0: already_AddRefed michael@0: Calls() const; michael@0: michael@0: void michael@0: Add(TelephonyCall& aCall, ErrorResult& aRv); michael@0: michael@0: void michael@0: Add(TelephonyCall& aCall, TelephonyCall& aSecondCall, ErrorResult& aRv); michael@0: michael@0: void michael@0: Remove(TelephonyCall& aCall, 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: void michael@0: GetState(nsString& aState) const michael@0: { michael@0: aState = mState; michael@0: } michael@0: michael@0: IMPL_EVENT_HANDLER(statechange) michael@0: IMPL_EVENT_HANDLER(connected) michael@0: IMPL_EVENT_HANDLER(holding) michael@0: IMPL_EVENT_HANDLER(held) michael@0: IMPL_EVENT_HANDLER(resuming) michael@0: IMPL_EVENT_HANDLER(callschanged) michael@0: IMPL_EVENT_HANDLER(error) michael@0: michael@0: static already_AddRefed michael@0: Create(Telephony* aTelephony); michael@0: michael@0: void michael@0: AddCall(TelephonyCall* aCall); michael@0: michael@0: void michael@0: RemoveCall(TelephonyCall* aCall); michael@0: michael@0: already_AddRefed michael@0: GetCall(uint32_t aServiceId, uint32_t aCallIndex); michael@0: michael@0: const nsTArray >& michael@0: CallsArray() const michael@0: { michael@0: return mCalls; michael@0: } michael@0: michael@0: void michael@0: ChangeState(uint16_t aCallState); michael@0: michael@0: uint16_t michael@0: CallState() const michael@0: { michael@0: return mCallState; michael@0: } michael@0: michael@0: nsresult michael@0: NotifyError(const nsAString& aName, const nsAString& aMessage); michael@0: michael@0: private: michael@0: TelephonyCallGroup(nsPIDOMWindow* aOwner); michael@0: ~TelephonyCallGroup(); michael@0: michael@0: nsresult michael@0: NotifyCallsChanged(TelephonyCall* aCall); michael@0: michael@0: nsresult michael@0: DispatchCallEvent(const nsAString& aType, michael@0: TelephonyCall* aCall); michael@0: michael@0: bool CanConference(const TelephonyCall& aCall, TelephonyCall* aSecondCall); michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_telephony_telephonycallgroup_h__