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"
|
2012-01-19 12:53:32 -08:00
|
|
|
#include "nsIRadioInterfaceLayer.h"
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2012-01-28 12:03:35 -08:00
|
|
|
NS_DECL_EVENT_HANDLER(statechange)
|
|
|
|
NS_DECL_EVENT_HANDLER(dialing)
|
2012-03-15 20:13:42 -07:00
|
|
|
NS_DECL_EVENT_HANDLER(alerting)
|
2012-01-28 12:03:35 -08:00
|
|
|
NS_DECL_EVENT_HANDLER(busy)
|
|
|
|
NS_DECL_EVENT_HANDLER(connecting)
|
|
|
|
NS_DECL_EVENT_HANDLER(connected)
|
|
|
|
NS_DECL_EVENT_HANDLER(disconnecting)
|
|
|
|
NS_DECL_EVENT_HANDLER(disconnected)
|
2012-04-05 01:12:42 -07:00
|
|
|
NS_DECL_EVENT_HANDLER(holding)
|
|
|
|
NS_DECL_EVENT_HANDLER(held)
|
|
|
|
NS_DECL_EVENT_HANDLER(resuming)
|
2012-05-14 21:13:06 -07:00
|
|
|
NS_DECL_EVENT_HANDLER(error)
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
PRUint32 mCallIndex;
|
|
|
|
PRUint16 mCallState;
|
|
|
|
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
|
2012-02-08 11:22:01 -08:00
|
|
|
NS_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>
|
|
|
|
Create(Telephony* aTelephony, const nsAString& aNumber, PRUint16 aCallState,
|
2012-01-11 18:17:26 -08:00
|
|
|
PRUint32 aCallIndex = kOutgoingPlaceholderCallIndex);
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
nsIDOMEventTarget*
|
|
|
|
ToIDOMEventTarget() const
|
|
|
|
{
|
2012-02-08 11:22:01 -08:00
|
|
|
return static_cast<nsDOMEventTargetHelper*>(
|
2012-01-09 14:28:47 -08:00
|
|
|
const_cast<TelephonyCall*>(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports*
|
|
|
|
ToISupports() const
|
|
|
|
{
|
|
|
|
return ToIDOMEventTarget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ChangeState(PRUint16 aCallState)
|
|
|
|
{
|
|
|
|
ChangeStateInternal(aCallState, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
CallIndex() const
|
|
|
|
{
|
|
|
|
return mCallIndex;
|
|
|
|
}
|
|
|
|
|
2012-01-11 18:17:26 -08:00
|
|
|
void
|
|
|
|
UpdateCallIndex(PRUint32 aCallIndex)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mCallIndex == kOutgoingPlaceholderCallIndex,
|
|
|
|
"Call index should not be set!");
|
|
|
|
mCallIndex = aCallIndex;
|
|
|
|
}
|
|
|
|
|
2012-01-09 14:28:47 -08:00
|
|
|
PRUint16
|
|
|
|
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:
|
|
|
|
TelephonyCall()
|
2012-01-11 18:17:26 -08:00
|
|
|
: mCallIndex(kOutgoingPlaceholderCallIndex),
|
2012-01-19 12:53:32 -08:00
|
|
|
mCallState(nsIRadioInterfaceLayer::CALL_STATE_UNKNOWN), mLive(false), mOutgoing(false)
|
2012-01-09 14:28:47 -08:00
|
|
|
{ }
|
|
|
|
|
|
|
|
~TelephonyCall()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void
|
|
|
|
ChangeStateInternal(PRUint16 aCallState, bool aFireEvents);
|
|
|
|
};
|
|
|
|
|
|
|
|
END_TELEPHONY_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_telephony_telephonycall_h__
|