1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "TelephonyCallId.h"
9 #include "nsITelephonyService.h"
14 TelephonyCallId::TelephonyCallId(nsPIDOMWindow
* aWindow
,
15 const nsAString
& aNumber
,
16 uint16_t aNumberPresentation
,
17 const nsAString
& aName
,
18 uint16_t aNamePresentation
)
19 : mWindow(aWindow
), mNumber(aNumber
), mNumberPresentation(aNumberPresentation
),
20 mName(aName
), mNamePresentation(aNamePresentation
)
24 TelephonyCallId::~TelephonyCallId()
29 TelephonyCallId::WrapObject(JSContext
* aCx
)
31 return TelephonyCallIdBinding::Wrap(aCx
, this);
35 TelephonyCallId::GetPresentationStr(uint16_t aPresentation
) const
37 switch (aPresentation
) {
38 case nsITelephonyService::CALL_PRESENTATION_ALLOWED
:
39 return CallIdPresentation::Allowed
;
40 case nsITelephonyService::CALL_PRESENTATION_RESTRICTED
:
41 return CallIdPresentation::Restricted
;
42 case nsITelephonyService::CALL_PRESENTATION_UNKNOWN
:
43 return CallIdPresentation::Unknown
;
44 case nsITelephonyService::CALL_PRESENTATION_PAYPHONE
:
45 return CallIdPresentation::Payphone
;
47 MOZ_CRASH("Bad presentation!");
51 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TelephonyCallId
, mWindow
)
53 NS_IMPL_CYCLE_COLLECTING_ADDREF(TelephonyCallId
)
54 NS_IMPL_CYCLE_COLLECTING_RELEASE(TelephonyCallId
)
56 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TelephonyCallId
)
57 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
58 NS_INTERFACE_MAP_ENTRY(nsISupports
)
64 TelephonyCallId::NumberPresentation() const
66 return GetPresentationStr(mNumberPresentation
);
70 TelephonyCallId::NamePresentation() const
72 return GetPresentationStr(mNamePresentation
);
76 } // namespace mozilla