2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-07-19 07:27:19 +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/. */
|
|
|
|
|
2013-02-05 13:02:15 +04:00
|
|
|
#ifndef mozilla_dom_voicemail_voicemail_h__
|
|
|
|
#define mozilla_dom_voicemail_voicemail_h__
|
2012-07-19 07:27:19 +04:00
|
|
|
|
2013-09-03 18:38:53 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2013-09-03 18:38:53 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2014-09-26 09:00:23 +04:00
|
|
|
#include "nsIVoicemailService.h"
|
2012-07-19 07:27:19 +04:00
|
|
|
|
2013-09-03 18:38:53 +04:00
|
|
|
class JSObject;
|
|
|
|
struct JSContext;
|
|
|
|
|
2013-02-05 13:02:15 +04:00
|
|
|
class nsPIDOMWindow;
|
2012-07-19 07:27:19 +04:00
|
|
|
|
2013-02-05 13:02:15 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-07-19 07:27:19 +04:00
|
|
|
|
2014-09-26 09:00:24 +04:00
|
|
|
class VoicemailStatus;
|
2014-07-18 00:47:41 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Voicemail final : public DOMEventTargetHelper,
|
2015-03-27 21:52:19 +03:00
|
|
|
private nsIVoicemailListener
|
2012-07-19 07:27:19 +04:00
|
|
|
{
|
2013-03-06 13:53:19 +04:00
|
|
|
/**
|
2014-08-20 05:01:49 +04:00
|
|
|
* Class Voicemail doesn't actually expose nsIVoicemailListener. Instead, it
|
2013-03-06 13:53:19 +04:00
|
|
|
* owns an nsIVoicemailListener derived instance mListener and passes it to
|
2014-09-26 09:00:23 +04:00
|
|
|
* nsIVoicemailService. The onreceived events are first delivered to
|
2013-03-06 13:53:19 +04:00
|
|
|
* mListener and then forwarded to its owner, Voicemail. See also bug 775997
|
|
|
|
* comment #51.
|
|
|
|
*/
|
|
|
|
class Listener;
|
|
|
|
|
2012-07-19 07:27:19 +04:00
|
|
|
public:
|
2014-08-20 05:01:49 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-03-06 13:53:19 +04:00
|
|
|
NS_DECL_NSIVOICEMAILLISTENER
|
2012-07-19 07:27:19 +04:00
|
|
|
|
2014-09-26 09:00:24 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Voicemail,
|
|
|
|
DOMEventTargetHelper)
|
2012-07-19 07:27:19 +04:00
|
|
|
|
2014-09-26 09:00:24 +04:00
|
|
|
static already_AddRefed<Voicemail>
|
|
|
|
Create(nsPIDOMWindow* aOwner,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
void
|
|
|
|
Shutdown();
|
2013-09-03 18:38:53 +04:00
|
|
|
|
|
|
|
nsPIDOMWindow*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-09-03 18:38:53 +04:00
|
|
|
|
2014-09-26 09:00:24 +04:00
|
|
|
already_AddRefed<VoicemailStatus>
|
2014-09-26 09:00:23 +04:00
|
|
|
GetStatus(const Optional<uint32_t>& aServiceId,
|
2014-09-26 09:00:24 +04:00
|
|
|
ErrorResult& aRv);
|
2013-09-03 18:38:53 +04:00
|
|
|
|
|
|
|
void
|
2014-09-26 09:00:23 +04:00
|
|
|
GetNumber(const Optional<uint32_t>& aServiceId,
|
|
|
|
nsString& aNumber,
|
2013-10-29 05:58:12 +04:00
|
|
|
ErrorResult& aRv) const;
|
2013-09-03 18:38:53 +04:00
|
|
|
|
|
|
|
void
|
2014-09-26 09:00:23 +04:00
|
|
|
GetDisplayName(const Optional<uint32_t>& aServiceId,
|
|
|
|
nsString& aDisplayName,
|
2013-10-29 05:58:12 +04:00
|
|
|
ErrorResult& aRv) const;
|
2013-09-03 18:38:53 +04:00
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(statuschanged)
|
|
|
|
|
2014-09-26 09:00:24 +04:00
|
|
|
private:
|
|
|
|
Voicemail(nsPIDOMWindow* aWindow,
|
|
|
|
nsIVoicemailService* aService);
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
// final suppresses -Werror,-Wdelete-non-virtual-dtor
|
2014-09-26 09:00:24 +04:00
|
|
|
~Voicemail();
|
|
|
|
|
2012-07-19 07:27:19 +04:00
|
|
|
private:
|
2014-09-26 09:00:23 +04:00
|
|
|
nsCOMPtr<nsIVoicemailService> mService;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Listener> mListener;
|
2013-10-29 05:58:12 +04:00
|
|
|
|
2014-09-26 09:00:24 +04:00
|
|
|
// |mStatuses| keeps all instantiated VoicemailStatus objects as well as the
|
|
|
|
// empty slots for not interested ones. The length of |mStatuses| is decided
|
|
|
|
// in the constructor and is never changed ever since.
|
2015-10-18 08:24:48 +03:00
|
|
|
nsAutoTArray<RefPtr<VoicemailStatus>, 1> mStatuses;
|
2014-09-26 09:00:24 +04:00
|
|
|
|
|
|
|
// Return a nsIVoicemailProvider instance based on the requests from external
|
|
|
|
// components. Return nullptr if aOptionalServiceId contains an invalid
|
|
|
|
// service id or the default one is just not available.
|
|
|
|
already_AddRefed<nsIVoicemailProvider>
|
|
|
|
GetItemByServiceId(const Optional<uint32_t>& aOptionalServiceId,
|
|
|
|
uint32_t& aActualServiceId) const;
|
|
|
|
|
|
|
|
// Request for a valid VoicemailStatus object based on given service id and
|
|
|
|
// provider. It's the callee's responsibility to ensure the validity of the
|
|
|
|
// two parameters.
|
|
|
|
already_AddRefed<VoicemailStatus>
|
|
|
|
GetOrCreateStatus(uint32_t aServiceId,
|
|
|
|
nsIVoicemailProvider* aProvider);
|
2012-07-19 07:27:19 +04:00
|
|
|
};
|
|
|
|
|
2013-02-05 13:02:15 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_voicemail_voicemail_h__
|