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
)
25 TelephonyCallId::~TelephonyCallId()
30 TelephonyCallId::WrapObject(JSContext
* aCx
)
32 return TelephonyCallIdBinding::Wrap(aCx
, this);
36 TelephonyCallId::GetPresentationStr(uint16_t aPresentation
) const
38 switch (aPresentation
) {
39 case nsITelephonyService::CALL_PRESENTATION_ALLOWED
:
40 return CallIdPresentation::Allowed
;
41 case nsITelephonyService::CALL_PRESENTATION_RESTRICTED
:
42 return CallIdPresentation::Restricted
;
43 case nsITelephonyService::CALL_PRESENTATION_UNKNOWN
:
44 return CallIdPresentation::Unknown
;
45 case nsITelephonyService::CALL_PRESENTATION_PAYPHONE
:
46 return CallIdPresentation::Payphone
;
48 MOZ_CRASH("Bad presentation!");
52 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TelephonyCallId
, mWindow
)
54 NS_IMPL_CYCLE_COLLECTING_ADDREF(TelephonyCallId
)
55 NS_IMPL_CYCLE_COLLECTING_RELEASE(TelephonyCallId
)
57 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TelephonyCallId
)
58 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
59 NS_INTERFACE_MAP_ENTRY(nsISupports
)
65 TelephonyCallId::NumberPresentation() const
67 return GetPresentationStr(mNumberPresentation
);
71 TelephonyCallId::NamePresentation() const
73 return GetPresentationStr(mNamePresentation
);
77 } // namespace mozilla