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_telephony_h__
|
|
|
|
#define mozilla_dom_telephony_telephony_h__
|
|
|
|
|
|
|
|
#include "TelephonyCommon.h"
|
|
|
|
|
|
|
|
#include "nsIDOMTelephony.h"
|
|
|
|
#include "nsIDOMTelephonyCall.h"
|
2012-01-19 12:53:32 -08:00
|
|
|
#include "nsIRadioInterfaceLayer.h"
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
class nsIScriptContext;
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
|
|
|
BEGIN_TELEPHONY_NAMESPACE
|
|
|
|
|
2012-02-08 11:22:01 -08:00
|
|
|
class Telephony : public nsDOMEventTargetHelper,
|
2012-01-09 14:28:47 -08:00
|
|
|
public nsIDOMTelephony
|
|
|
|
{
|
2012-04-24 08:44:42 -07:00
|
|
|
nsCOMPtr<nsIRILContentHelper> mRIL;
|
2012-01-19 12:53:32 -08:00
|
|
|
nsCOMPtr<nsIRILTelephonyCallback> mRILTelephonyCallback;
|
2012-01-09 14:28:47 -08:00
|
|
|
|
2012-01-28 12:03:35 -08:00
|
|
|
NS_DECL_EVENT_HANDLER(incoming)
|
2012-02-24 05:14:37 -08:00
|
|
|
NS_DECL_EVENT_HANDLER(callschanged)
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
TelephonyCall* mActiveCall;
|
|
|
|
nsTArray<nsRefPtr<TelephonyCall> > mCalls;
|
|
|
|
|
2012-02-23 07:09:11 -08:00
|
|
|
// Cached calls array object. Cleared whenever mCalls changes and then rebuilt
|
|
|
|
// once a page looks for the liveCalls attribute.
|
|
|
|
JSObject* mCallsArray;
|
|
|
|
|
|
|
|
bool mRooted;
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIDOMTELEPHONY
|
2012-01-19 12:53:32 -08:00
|
|
|
NS_DECL_NSIRILTELEPHONYCALLBACK
|
2012-02-08 11:22:01 -08:00
|
|
|
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
|
2012-02-23 07:09:11 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
|
|
|
Telephony,
|
|
|
|
nsDOMEventTargetHelper)
|
2012-01-09 14:28:47 -08:00
|
|
|
|
|
|
|
static already_AddRefed<Telephony>
|
2012-04-24 08:44:42 -07:00
|
|
|
Create(nsPIDOMWindow* aOwner, nsIRILContentHelper* aRIL);
|
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<Telephony*>(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports*
|
|
|
|
ToISupports() const
|
|
|
|
{
|
|
|
|
return ToIDOMEventTarget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AddCall(TelephonyCall* aCall)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mCalls.Contains(aCall), "Already know about this one!");
|
|
|
|
mCalls.AppendElement(aCall);
|
2012-02-23 07:09:11 -08:00
|
|
|
mCallsArray = nsnull;
|
2012-02-24 05:14:37 -08:00
|
|
|
NotifyCallsChanged(aCall);
|
2012-01-09 14:28:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RemoveCall(TelephonyCall* aCall)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mCalls.Contains(aCall), "Didn't know about this one!");
|
|
|
|
mCalls.RemoveElement(aCall);
|
2012-02-23 07:09:11 -08:00
|
|
|
mCallsArray = nsnull;
|
2012-02-24 05:14:37 -08:00
|
|
|
NotifyCallsChanged(aCall);
|
2012-01-09 14:28:47 -08:00
|
|
|
}
|
|
|
|
|
2012-04-24 08:44:42 -07:00
|
|
|
nsIRILContentHelper*
|
2012-01-19 12:53:32 -08:00
|
|
|
RIL() const
|
2012-01-09 14:28:47 -08:00
|
|
|
{
|
2012-01-19 12:53:32 -08:00
|
|
|
return mRIL;
|
2012-01-09 14:28:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-24 05:14:37 -08:00
|
|
|
Telephony();
|
2012-01-09 14:28:47 -08:00
|
|
|
~Telephony();
|
|
|
|
|
2012-02-24 05:14:37 -08:00
|
|
|
already_AddRefed<TelephonyCall>
|
|
|
|
CreateNewDialingCall(const nsAString& aNumber);
|
|
|
|
|
2012-01-09 14:28:47 -08:00
|
|
|
void
|
2012-02-24 05:14:37 -08:00
|
|
|
NoteDialedCallFromOtherInstance(const nsAString& aNumber);
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NotifyCallsChanged(TelephonyCall* aCall);
|
2012-01-09 14:28:47 -08:00
|
|
|
|
2012-01-19 12:53:32 -08:00
|
|
|
class RILTelephonyCallback : public nsIRILTelephonyCallback
|
2012-01-09 14:28:47 -08:00
|
|
|
{
|
|
|
|
Telephony* mTelephony;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-01-19 12:53:32 -08:00
|
|
|
NS_FORWARD_NSIRILTELEPHONYCALLBACK(mTelephony->)
|
2012-01-09 14:28:47 -08:00
|
|
|
|
2012-01-19 12:53:32 -08:00
|
|
|
RILTelephonyCallback(Telephony* aTelephony)
|
2012-01-09 14:28:47 -08:00
|
|
|
: mTelephony(aTelephony)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mTelephony, "Null pointer!");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
END_TELEPHONY_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_telephony_telephony_h__
|