Bumping gaia.json for 4 gaia revision(s) a=gaia-bump
[gecko.git] / dom / telephony / TelephonyCallId.cpp
blobced3905d9409714164790d90c434cd3db93119cf
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)
24 TelephonyCallId::~TelephonyCallId()
28 JSObject*
29 TelephonyCallId::WrapObject(JSContext* aCx)
31 return TelephonyCallIdBinding::Wrap(aCx, this);
34 CallIdPresentation
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;
46 default:
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)
59 NS_INTERFACE_MAP_END
61 // WebIDL
63 CallIdPresentation
64 TelephonyCallId::NumberPresentation() const
66 return GetPresentationStr(mNumberPresentation);
69 CallIdPresentation
70 TelephonyCallId::NamePresentation() const
72 return GetPresentationStr(mNamePresentation);
75 } // namespace dom
76 } // namespace mozilla