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