2012-01-09 14:28:47 -08: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 04:12:37 -07: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-09 14:28:47 -08:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_telephony_telephonycall_h__
|
|
|
|
#define mozilla_dom_telephony_telephonycall_h__
|
|
|
|
|
|
|
|
#include "TelephonyCommon.h"
|
|
|
|
|
|
|
|
#include "nsIDOMTelephonyCall.h"
|
|
|
|
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
|
|
|
BEGIN_TELEPHONY_NAMESPACE
|
|
|
|
|
2012-02-08 11:22:01 -08:00
|
|
|
class TelephonyCall : public nsDOMEventTargetHelper,
|
2012-01-09 14:28:47 -08:00
|
|
|
public nsIDOMTelephonyCall
|
|
|
|
{
|
|
|
|
nsRefPtr<Telephony> mTelephony;
|
|
|
|
|
|
|
|
nsString mNumber;
|
|
|
|
nsString mState;
|
2012-05-14 21:13:06 -07:00
|
|
|
nsCOMPtr<nsIDOMDOMError> mError;
|
2012-01-09 14:28:47 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mCallIndex;
|
|
|
|
uint16_t mCallState;
|
2012-01-09 14:28:47 -08:00
|
|
|
bool mLive;
|
2012-01-11 18:17:26 -08:00
|
|
|
bool mOutgoing;
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIDOMTELEPHONYCALL
|
2013-04-16 14:16:08 -07:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
|
2012-01-09 14:28:47 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall,
|
2012-02-08 11:22:01 -08:00
|
|
|
nsDOMEventTargetHelper)
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
static already_AddRefed<TelephonyCall>
|
2012-08-22 08:56:38 -07:00
|
|
|
Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState,
|
|
|
|
uint32_t aCallIndex = kOutgoingPlaceholderCallIndex);
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
nsISupports*
|
2013-04-19 15:18:33 -07:00
|
|
|
ToISupports()
|
2012-01-09 14:28:47 -08:00
|
|
|
{
|
2013-04-19 15:18:33 -07:00
|
|
|
return static_cast<EventTarget*>(this);
|
2012-01-09 14:28:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
ChangeState(uint16_t aCallState)
|
2012-01-09 14:28:47 -08:00
|
|
|
{
|
|
|
|
ChangeStateInternal(aCallState, true);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-01-09 14:28:47 -08:00
|
|
|
CallIndex() const
|
|
|
|
{
|
|
|
|
return mCallIndex;
|
|
|
|
}
|
|
|
|
|
2012-01-11 18:17:26 -08:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
UpdateCallIndex(uint32_t aCallIndex)
|
2012-01-11 18:17:26 -08:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mCallIndex == kOutgoingPlaceholderCallIndex,
|
|
|
|
"Call index should not be set!");
|
|
|
|
mCallIndex = aCallIndex;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t
|
2012-01-09 14:28:47 -08:00
|
|
|
CallState() const
|
|
|
|
{
|
|
|
|
return mCallState;
|
|
|
|
}
|
|
|
|
|
2012-01-11 18:17:26 -08:00
|
|
|
bool
|
|
|
|
IsOutgoing() const
|
|
|
|
{
|
|
|
|
return mOutgoing;
|
|
|
|
}
|
|
|
|
|
2012-05-14 21:13:06 -07:00
|
|
|
void
|
|
|
|
NotifyError(const nsAString& aError);
|
|
|
|
|
2012-01-09 14:28:47 -08:00
|
|
|
private:
|
2013-03-06 01:53:23 -08:00
|
|
|
TelephonyCall();
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
~TelephonyCall()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
ChangeStateInternal(uint16_t aCallState, bool aFireEvents);
|
2013-01-27 23:39:50 -08:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
DispatchCallEvent(const nsAString& aType,
|
|
|
|
nsIDOMTelephonyCall* aCall);
|
2012-01-09 14:28:47 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
END_TELEPHONY_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_telephony_telephonycall_h__
|