Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / telephony / TelephonyCallId.cpp
blob1c75f77c28782d889946488d7835370f806348af
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"
11 namespace mozilla {
12 namespace dom {
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)
22 SetIsDOMBinding();
25 TelephonyCallId::~TelephonyCallId()
29 JSObject*
30 TelephonyCallId::WrapObject(JSContext* aCx)
32 return TelephonyCallIdBinding::Wrap(aCx, this);
35 CallIdPresentation
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;
47 default:
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)
60 NS_INTERFACE_MAP_END
62 // WebIDL
64 CallIdPresentation
65 TelephonyCallId::NumberPresentation() const
67 return GetPresentationStr(mNumberPresentation);
70 CallIdPresentation
71 TelephonyCallId::NamePresentation() const
73 return GetPresentationStr(mNamePresentation);
76 } // namespace dom
77 } // namespace mozilla