/security/manager/ssl/src/nsSmartCardEvent.cpp

http://github.com/zpao/v8monkey · C++ · 258 lines · 176 code · 35 blank · 47 comment · 2 complexity · f4fee89f3cf24d9a1269cb5897f15ce9 MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is the Red Hat Inc.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Red Hat, Inc.
  19. * Portions created by the Initial Developer are Copyright (C) 2005
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * Robert Relyea <rrelyea@redhat.com>
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. #include "nsSmartCardEvent.h"
  39. #include "nsIDOMSmartCardEvent.h"
  40. #include "nsIDOMClassInfo.h"
  41. #include "nsIDOMNSEvent.h"
  42. #include "nsIDOMEvent.h"
  43. #include "nsXPCOM.h"
  44. // DOM event class to handle progress notifications
  45. nsSmartCardEvent::nsSmartCardEvent(const nsAString &aTokenName)
  46. : mInner(nsnull), mPrivate(nsnull), mTokenName(aTokenName)
  47. {
  48. }
  49. nsSmartCardEvent::~nsSmartCardEvent()
  50. {}
  51. //NS_DECL_DOM_CLASSINFO(SmartCardEvent)
  52. // QueryInterface implementation for nsXMLHttpRequest
  53. NS_INTERFACE_MAP_BEGIN(nsSmartCardEvent)
  54. NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMSmartCardEvent)
  55. NS_INTERFACE_MAP_ENTRY(nsIDOMSmartCardEvent)
  56. NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
  57. NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
  58. NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
  59. NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SmartCardEvent)
  60. NS_INTERFACE_MAP_END
  61. NS_IMPL_ADDREF(nsSmartCardEvent)
  62. NS_IMPL_RELEASE(nsSmartCardEvent)
  63. //
  64. // Init must be called before we do anything with the event.
  65. //
  66. NS_IMETHODIMP nsSmartCardEvent::Init(nsIDOMEvent * aInner)
  67. {
  68. nsresult rv;
  69. NS_ASSERTION(aInner, "SmartCardEvent initialized with a null Event");
  70. mInner = aInner;
  71. mPrivate = do_QueryInterface(mInner, &rv);
  72. if (NS_FAILED(rv)) {
  73. return rv;
  74. }
  75. mNSEvent = do_QueryInterface(mInner, &rv);
  76. if (NS_FAILED(rv)) {
  77. return rv;
  78. }
  79. return mPrivate->SetTrusted(true);
  80. }
  81. // nsSmartCard Specific methods
  82. NS_IMETHODIMP nsSmartCardEvent::GetTokenName(nsAString &aTokenName)
  83. {
  84. aTokenName = mTokenName;
  85. return NS_OK;
  86. }
  87. // nsIPrivateDOMEvent maps
  88. NS_IMETHODIMP nsSmartCardEvent::DuplicatePrivateData(void)
  89. {
  90. NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
  91. return mPrivate->DuplicatePrivateData();
  92. }
  93. NS_IMETHODIMP nsSmartCardEvent::SetTarget(nsIDOMEventTarget *aTarget)
  94. {
  95. NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
  96. return mPrivate->SetTarget(aTarget);
  97. }
  98. NS_IMETHODIMP_(bool ) nsSmartCardEvent::IsDispatchStopped()
  99. {
  100. NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
  101. return mPrivate->IsDispatchStopped();
  102. }
  103. NS_IMETHODIMP_(nsEvent*) nsSmartCardEvent::GetInternalNSEvent()
  104. {
  105. NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
  106. return mPrivate->GetInternalNSEvent();
  107. }
  108. NS_IMETHODIMP nsSmartCardEvent::SetTrusted(bool aResult)
  109. {
  110. NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
  111. return mPrivate->SetTrusted(aResult);
  112. }
  113. void
  114. nsSmartCardEvent::Serialize(IPC::Message* aMsg,
  115. bool aSerializeInterfaceType)
  116. {
  117. NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
  118. mPrivate->Serialize(aMsg, aSerializeInterfaceType);
  119. }
  120. bool
  121. nsSmartCardEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
  122. {
  123. NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
  124. return mPrivate->Deserialize(aMsg, aIter);
  125. }
  126. // IDOMNSEvent maps
  127. NS_IMETHODIMP nsSmartCardEvent::GetOriginalTarget(nsIDOMEventTarget * *aOriginalTarget)
  128. {
  129. NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
  130. return mNSEvent->GetOriginalTarget(aOriginalTarget);
  131. }
  132. NS_IMETHODIMP nsSmartCardEvent::GetExplicitOriginalTarget(nsIDOMEventTarget * *aTarget)
  133. {
  134. NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
  135. return mNSEvent->GetExplicitOriginalTarget(aTarget);
  136. }
  137. NS_IMETHODIMP nsSmartCardEvent::GetTmpRealOriginalTarget(nsIDOMEventTarget * *aTarget)
  138. {
  139. NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
  140. return mNSEvent->GetTmpRealOriginalTarget(aTarget);
  141. }
  142. NS_IMETHODIMP nsSmartCardEvent::PreventBubble(void)
  143. {
  144. NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
  145. return mNSEvent->PreventBubble();
  146. }
  147. NS_IMETHODIMP nsSmartCardEvent::PreventCapture(void)
  148. {
  149. NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
  150. return mNSEvent->PreventCapture();
  151. }
  152. NS_IMETHODIMP nsSmartCardEvent::GetIsTrusted(bool *aIsTrusted)
  153. {
  154. NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
  155. return mNSEvent->GetIsTrusted(aIsTrusted);
  156. }
  157. NS_IMETHODIMP
  158. nsSmartCardEvent::GetPreventDefault(bool* aReturn)
  159. {
  160. NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
  161. return mNSEvent->GetPreventDefault(aReturn);
  162. }
  163. // IDOMEvent maps
  164. NS_IMETHODIMP nsSmartCardEvent::GetType(nsAString & aType)
  165. {
  166. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  167. return mInner->GetType(aType);
  168. }
  169. NS_IMETHODIMP nsSmartCardEvent::GetTarget(nsIDOMEventTarget * *aTarget)
  170. {
  171. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  172. return mInner->GetTarget(aTarget);
  173. }
  174. NS_IMETHODIMP nsSmartCardEvent::GetCurrentTarget(nsIDOMEventTarget * *aCurrentTarget)
  175. {
  176. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  177. return mInner->GetCurrentTarget(aCurrentTarget);
  178. }
  179. NS_IMETHODIMP nsSmartCardEvent::GetEventPhase(PRUint16 *aEventPhase)
  180. {
  181. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  182. return mInner->GetEventPhase(aEventPhase);
  183. }
  184. NS_IMETHODIMP nsSmartCardEvent::GetBubbles(bool *aBubbles)
  185. {
  186. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  187. return mInner->GetBubbles(aBubbles);
  188. }
  189. NS_IMETHODIMP nsSmartCardEvent::GetCancelable(bool *aCancelable)
  190. {
  191. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  192. return mInner->GetCancelable(aCancelable);
  193. }
  194. NS_IMETHODIMP nsSmartCardEvent::GetTimeStamp(DOMTimeStamp *aTimeStamp)
  195. {
  196. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  197. return mInner->GetTimeStamp(aTimeStamp);
  198. }
  199. NS_IMETHODIMP nsSmartCardEvent::StopPropagation()
  200. {
  201. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  202. return mInner->StopPropagation();
  203. }
  204. NS_IMETHODIMP nsSmartCardEvent::StopImmediatePropagation()
  205. {
  206. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  207. return mInner->StopImmediatePropagation();
  208. }
  209. NS_IMETHODIMP nsSmartCardEvent::PreventDefault()
  210. {
  211. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  212. return mInner->PreventDefault();
  213. }
  214. NS_IMETHODIMP nsSmartCardEvent::GetDefaultPrevented(bool* aReturn)
  215. {
  216. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  217. return mInner->GetDefaultPrevented(aReturn);
  218. }
  219. NS_IMETHODIMP nsSmartCardEvent::InitEvent(const nsAString & eventTypeArg, bool canBubbleArg, bool cancelableArg)
  220. {
  221. NS_ASSERTION(mInner, "SmartCardEvent called without Init");
  222. return mInner->InitEvent(eventTypeArg, canBubbleArg, cancelableArg);
  223. }