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"
|
|
|
|
|
|
|
|
#include "nsIDOMTelephonyCall.h"
|
|
|
|
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
|
|
|
BEGIN_TELEPHONY_NAMESPACE
|
|
|
|
|
2012-02-08 23:22:01 +04:00
|
|
|
class TelephonyCall : public nsDOMEventTargetHelper,
|
2012-01-10 02:28:47 +04:00
|
|
|
public nsIDOMTelephonyCall
|
|
|
|
{
|
|
|
|
nsRefPtr<Telephony> mTelephony;
|
|
|
|
|
|
|
|
nsString mNumber;
|
|
|
|
nsString mState;
|
2012-05-15 08:13:06 +04:00
|
|
|
nsCOMPtr<nsIDOMDOMError> 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
|
|
|
|
NS_DECL_NSIDOMTELEPHONYCALL
|
2012-02-08 23:22:01 +04:00
|
|
|
NS_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
|
|
|
|
|
|
|
static already_AddRefed<TelephonyCall>
|
2012-08-22 19:56:38 +04:00
|
|
|
Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState,
|
|
|
|
uint32_t aCallIndex = kOutgoingPlaceholderCallIndex);
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
nsIDOMEventTarget*
|
|
|
|
ToIDOMEventTarget() const
|
|
|
|
{
|
2012-02-08 23:22:01 +04:00
|
|
|
return static_cast<nsDOMEventTargetHelper*>(
|
2012-01-10 02:28:47 +04:00
|
|
|
const_cast<TelephonyCall*>(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports*
|
|
|
|
ToISupports() const
|
|
|
|
{
|
|
|
|
return ToIDOMEventTarget();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
~TelephonyCall()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
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,
|
|
|
|
nsIDOMTelephonyCall* aCall);
|
2012-01-10 02:28:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_TELEPHONY_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_telephony_telephonycall_h__
|