2012-01-10 02:28:47 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=40: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_telephony_telephonycall_h__
|
|
|
|
#define mozilla_dom_telephony_telephonycall_h__
|
|
|
|
|
|
|
|
#include "TelephonyCommon.h"
|
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
#include "mozilla/dom/DOMError.h"
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
|
|
|
BEGIN_TELEPHONY_NAMESPACE
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
class TelephonyCall MOZ_FINAL : public nsDOMEventTargetHelper
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
|
|
|
nsRefPtr<Telephony> mTelephony;
|
|
|
|
|
|
|
|
nsString mNumber;
|
2013-07-30 13:08:53 +04:00
|
|
|
nsString mSecondNumber;
|
2012-01-10 02:28:47 +04:00
|
|
|
nsString mState;
|
2013-05-14 10:08:07 +04:00
|
|
|
bool mEmergency;
|
2013-05-18 21:52:06 +04:00
|
|
|
nsRefPtr<mozilla::dom::DOMError> mError;
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mCallIndex;
|
|
|
|
uint16_t mCallState;
|
2012-01-10 02:28:47 +04:00
|
|
|
bool mLive;
|
2012-01-12 06:17:26 +04:00
|
|
|
bool mOutgoing;
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-04-17 01:16:08 +04:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
|
2012-01-10 02:28:47 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall,
|
2012-02-08 23:22:01 +04:00
|
|
|
nsDOMEventTargetHelper)
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
nsPIDOMWindow*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
// WrapperCache
|
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
// WebIDL
|
|
|
|
void
|
|
|
|
GetNumber(nsString& aNumber) const
|
|
|
|
{
|
|
|
|
aNumber.Assign(mNumber);
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:08:53 +04:00
|
|
|
void
|
|
|
|
GetSecondNumber(nsString& aSecondNumber) const
|
|
|
|
{
|
|
|
|
aSecondNumber.Assign(mSecondNumber);
|
|
|
|
}
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
void
|
|
|
|
GetState(nsString& aState) const
|
|
|
|
{
|
|
|
|
aState.Assign(mState);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Emergency() const
|
|
|
|
{
|
|
|
|
return mEmergency;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMError>
|
|
|
|
GetError() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
Answer(ErrorResult& aRv);
|
|
|
|
|
|
|
|
void
|
|
|
|
HangUp(ErrorResult& aRv);
|
|
|
|
|
|
|
|
void
|
|
|
|
Hold(ErrorResult& aRv);
|
|
|
|
|
|
|
|
void
|
|
|
|
Resume(ErrorResult& aRv);
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(statechange)
|
|
|
|
IMPL_EVENT_HANDLER(dialing)
|
|
|
|
IMPL_EVENT_HANDLER(alerting)
|
|
|
|
IMPL_EVENT_HANDLER(connecting)
|
|
|
|
IMPL_EVENT_HANDLER(connected)
|
|
|
|
IMPL_EVENT_HANDLER(disconnecting)
|
|
|
|
IMPL_EVENT_HANDLER(disconnected)
|
|
|
|
IMPL_EVENT_HANDLER(holding)
|
|
|
|
IMPL_EVENT_HANDLER(held)
|
|
|
|
IMPL_EVENT_HANDLER(resuming)
|
|
|
|
IMPL_EVENT_HANDLER(error)
|
|
|
|
|
2012-01-10 02:28:47 +04:00
|
|
|
static already_AddRefed<TelephonyCall>
|
2012-08-22 19:56:38 +04:00
|
|
|
Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState,
|
2013-05-14 10:08:07 +04:00
|
|
|
uint32_t aCallIndex = kOutgoingPlaceholderCallIndex,
|
|
|
|
bool aEmergency = false);
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
ChangeState(uint16_t aCallState)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
|
|
|
ChangeStateInternal(aCallState, true);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-01-10 02:28:47 +04:00
|
|
|
CallIndex() const
|
|
|
|
{
|
|
|
|
return mCallIndex;
|
|
|
|
}
|
|
|
|
|
2012-01-12 06:17:26 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
UpdateCallIndex(uint32_t aCallIndex)
|
2012-01-12 06:17:26 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mCallIndex == kOutgoingPlaceholderCallIndex,
|
|
|
|
"Call index should not be set!");
|
|
|
|
mCallIndex = aCallIndex;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t
|
2012-01-10 02:28:47 +04:00
|
|
|
CallState() const
|
|
|
|
{
|
|
|
|
return mCallState;
|
|
|
|
}
|
|
|
|
|
2013-05-14 10:08:07 +04:00
|
|
|
void
|
|
|
|
UpdateEmergency(bool aEmergency)
|
|
|
|
{
|
|
|
|
mEmergency = aEmergency;
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:08:53 +04:00
|
|
|
void
|
|
|
|
UpdateSecondNumber(const nsAString& aNumber)
|
|
|
|
{
|
|
|
|
mSecondNumber = aNumber;
|
|
|
|
}
|
|
|
|
|
2012-01-12 06:17:26 +04:00
|
|
|
bool
|
|
|
|
IsOutgoing() const
|
|
|
|
{
|
|
|
|
return mOutgoing;
|
|
|
|
}
|
|
|
|
|
2012-05-15 08:13:06 +04:00
|
|
|
void
|
|
|
|
NotifyError(const nsAString& aError);
|
|
|
|
|
2012-01-10 02:28:47 +04:00
|
|
|
private:
|
2013-03-06 13:53:23 +04:00
|
|
|
TelephonyCall();
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
~TelephonyCall();
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
ChangeStateInternal(uint16_t aCallState, bool aFireEvents);
|
2013-01-28 11:39:50 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
DispatchCallEvent(const nsAString& aType,
|
2013-07-15 12:27:19 +04:00
|
|
|
TelephonyCall* aCall);
|
2012-01-10 02:28:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_TELEPHONY_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_telephony_telephonycall_h__
|