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__
|
|
|
|
|
2013-05-18 17:52:06 +00:00
|
|
|
#include "mozilla/dom/DOMError.h"
|
2015-01-04 22:33:00 +00:00
|
|
|
#include "mozilla/dom/Promise.h"
|
2015-03-26 08:39:39 +00:00
|
|
|
#include "mozilla/dom/TelephonyCallBinding.h"
|
2015-01-04 22:33:00 +00:00
|
|
|
#include "mozilla/dom/TelephonyCallId.h"
|
|
|
|
#include "mozilla/dom/telephony/TelephonyCommon.h"
|
2014-04-10 06:25:42 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
2013-09-12 03:47:14 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-01-09 22:28:47 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class TelephonyCall final : public DOMEventTargetHelper
|
2012-01-09 22:28:47 +00:00
|
|
|
{
|
|
|
|
nsRefPtr<Telephony> mTelephony;
|
2013-07-06 10:24:55 +00:00
|
|
|
nsRefPtr<TelephonyCallGroup> mGroup;
|
2012-01-09 22:28:47 +00:00
|
|
|
|
2014-04-10 06:25:42 +00:00
|
|
|
nsRefPtr<TelephonyCallId> mId;
|
|
|
|
nsRefPtr<TelephonyCallId> mSecondId;
|
|
|
|
|
2013-10-31 12:05:51 +00:00
|
|
|
uint32_t mServiceId;
|
2012-01-09 22:28:47 +00:00
|
|
|
nsString mState;
|
2013-05-14 06:08:07 +00:00
|
|
|
bool mEmergency;
|
2013-09-12 03:47:14 +00:00
|
|
|
nsRefPtr<DOMError> mError;
|
2015-03-26 08:39:39 +00:00
|
|
|
Nullable<TelephonyCallDisconnectedReason> mDisconnectedReason;
|
|
|
|
|
2014-02-21 09:52:13 +00:00
|
|
|
bool mSwitchable;
|
|
|
|
bool mMergeable;
|
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;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-04-01 06:13:50 +00:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
|
2012-01-09 22:28:47 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall,
|
2014-04-01 06:13:50 +00:00
|
|
|
DOMEventTargetHelper)
|
2013-07-06 10:24:55 +00:00
|
|
|
friend class Telephony;
|
|
|
|
|
2013-07-15 08:27:19 +00:00
|
|
|
nsPIDOMWindow*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
// WrapperCache
|
|
|
|
virtual JSObject*
|
2015-03-21 16:28:04 +00:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-07-15 08:27:19 +00:00
|
|
|
|
|
|
|
// WebIDL
|
2014-04-10 06:25:42 +00:00
|
|
|
already_AddRefed<TelephonyCallId>
|
|
|
|
Id() const;
|
2013-07-15 08:27:19 +00:00
|
|
|
|
2014-04-10 06:25:42 +00:00
|
|
|
already_AddRefed<TelephonyCallId>
|
|
|
|
GetSecondId() const;
|
2013-07-30 09:08:53 +00:00
|
|
|
|
2013-07-15 08:27:19 +00:00
|
|
|
void
|
|
|
|
GetState(nsString& aState) const
|
|
|
|
{
|
|
|
|
aState.Assign(mState);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Emergency() const
|
|
|
|
{
|
|
|
|
return mEmergency;
|
|
|
|
}
|
|
|
|
|
2014-02-21 09:52:13 +00:00
|
|
|
bool
|
|
|
|
Switchable() const
|
|
|
|
{
|
|
|
|
return mSwitchable;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Mergeable() const
|
|
|
|
{
|
|
|
|
return mMergeable;
|
|
|
|
}
|
|
|
|
|
2013-07-15 08:27:19 +00:00
|
|
|
already_AddRefed<DOMError>
|
|
|
|
GetError() const;
|
|
|
|
|
2015-03-26 08:39:39 +00:00
|
|
|
Nullable<TelephonyCallDisconnectedReason>
|
|
|
|
GetDisconnectedReason() const
|
|
|
|
{
|
|
|
|
return mDisconnectedReason;
|
|
|
|
}
|
|
|
|
|
2013-07-06 10:24:55 +00:00
|
|
|
already_AddRefed<TelephonyCallGroup>
|
|
|
|
GetGroup() const;
|
|
|
|
|
2015-01-04 22:33:00 +00:00
|
|
|
already_AddRefed<Promise>
|
2013-07-15 08:27:19 +00:00
|
|
|
Answer(ErrorResult& aRv);
|
|
|
|
|
2015-01-04 22:33:00 +00:00
|
|
|
already_AddRefed<Promise>
|
2013-07-15 08:27:19 +00:00
|
|
|
HangUp(ErrorResult& aRv);
|
|
|
|
|
2015-01-04 22:33:00 +00:00
|
|
|
already_AddRefed<Promise>
|
2013-07-15 08:27:19 +00:00
|
|
|
Hold(ErrorResult& aRv);
|
|
|
|
|
2015-01-04 22:33:00 +00:00
|
|
|
already_AddRefed<Promise>
|
2013-07-15 08:27:19 +00:00
|
|
|
Resume(ErrorResult& aRv);
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(statechange)
|
|
|
|
IMPL_EVENT_HANDLER(dialing)
|
|
|
|
IMPL_EVENT_HANDLER(alerting)
|
|
|
|
IMPL_EVENT_HANDLER(connected)
|
|
|
|
IMPL_EVENT_HANDLER(disconnected)
|
|
|
|
IMPL_EVENT_HANDLER(held)
|
|
|
|
IMPL_EVENT_HANDLER(error)
|
2013-07-06 10:24:55 +00:00
|
|
|
IMPL_EVENT_HANDLER(groupchange)
|
2013-07-15 08:27:19 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
static already_AddRefed<TelephonyCall>
|
2014-06-24 10:52:00 +00:00
|
|
|
Create(Telephony* aTelephony, TelephonyCallId* aId,
|
|
|
|
uint32_t aServiceId, uint32_t aCallIndex, uint16_t aCallState,
|
|
|
|
bool aEmergency = false, bool aConference = false,
|
2014-02-21 09:52:13 +00:00
|
|
|
bool aSwitchable = true, bool aMergeable = true);
|
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);
|
|
|
|
}
|
|
|
|
|
2013-10-31 12:05:51 +00:00
|
|
|
uint32_t
|
|
|
|
ServiceId() const
|
|
|
|
{
|
|
|
|
return mServiceId;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t
|
2012-01-09 22:28:47 +00:00
|
|
|
CallIndex() const
|
|
|
|
{
|
|
|
|
return mCallIndex;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t
|
2012-01-09 22:28:47 +00:00
|
|
|
CallState() const
|
|
|
|
{
|
|
|
|
return mCallState;
|
|
|
|
}
|
|
|
|
|
2013-05-14 06:08:07 +00:00
|
|
|
void
|
|
|
|
UpdateEmergency(bool aEmergency)
|
|
|
|
{
|
|
|
|
mEmergency = aEmergency;
|
|
|
|
}
|
|
|
|
|
2014-02-21 09:52:13 +00:00
|
|
|
void
|
|
|
|
UpdateSwitchable(bool aSwitchable) {
|
|
|
|
mSwitchable = aSwitchable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateMergeable(bool aMergeable) {
|
|
|
|
mMergeable = aMergeable;
|
|
|
|
}
|
|
|
|
|
2014-04-10 06:25:42 +00:00
|
|
|
void
|
|
|
|
UpdateSecondId(TelephonyCallId* aId) {
|
|
|
|
mSecondId = aId;
|
|
|
|
}
|
|
|
|
|
2012-05-15 04:13:06 +00:00
|
|
|
void
|
|
|
|
NotifyError(const nsAString& aError);
|
|
|
|
|
2015-03-26 08:39:39 +00:00
|
|
|
void
|
|
|
|
UpdateDisconnectedReason(const nsAString& aDisconnectedReason);
|
|
|
|
|
2013-07-06 10:24:55 +00:00
|
|
|
void
|
|
|
|
ChangeGroup(TelephonyCallGroup* aGroup);
|
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
private:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit TelephonyCall(nsPIDOMWindow* aOwner);
|
2012-01-09 22:28:47 +00:00
|
|
|
|
2013-07-15 08:27:19 +00:00
|
|
|
~TelephonyCall();
|
2012-01-09 22:28:47 +00:00
|
|
|
|
|
|
|
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,
|
2013-07-15 08:27:19 +00:00
|
|
|
TelephonyCall* aCall);
|
2015-01-28 04:01:00 +00:00
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
CreatePromise(ErrorResult& aRv);
|
2012-01-09 22:28:47 +00:00
|
|
|
};
|
|
|
|
|
2013-09-12 03:47:14 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-01-09 22:28:47 +00:00
|
|
|
|
|
|
|
#endif // mozilla_dom_telephony_telephonycall_h__
|