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 :
45 : // DOM event class to handle progress notifications
46 0 : nsSmartCardEvent::nsSmartCardEvent(const nsAString &aTokenName)
47 0 : : mInner(nsnull), mPrivate(nsnull), mTokenName(aTokenName)
48 : {
49 0 : }
50 :
51 0 : nsSmartCardEvent::~nsSmartCardEvent()
52 0 : {}
53 :
54 : //NS_DECL_DOM_CLASSINFO(SmartCardEvent)
55 :
56 : // QueryInterface implementation for nsXMLHttpRequest
57 0 : NS_INTERFACE_MAP_BEGIN(nsSmartCardEvent)
58 0 : NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMSmartCardEvent)
59 0 : NS_INTERFACE_MAP_ENTRY(nsIDOMSmartCardEvent)
60 0 : NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
61 0 : NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
62 0 : NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
63 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SmartCardEvent)
64 0 : NS_INTERFACE_MAP_END
65 :
66 0 : NS_IMPL_ADDREF(nsSmartCardEvent)
67 0 : NS_IMPL_RELEASE(nsSmartCardEvent)
68 :
69 : //
70 : // Init must be called before we do anything with the event.
71 : //
72 0 : NS_IMETHODIMP nsSmartCardEvent::Init(nsIDOMEvent * aInner)
73 : {
74 : nsresult rv;
75 :
76 0 : NS_ASSERTION(aInner, "SmartCardEvent initialized with a null Event");
77 0 : mInner = aInner;
78 0 : mPrivate = do_QueryInterface(mInner, &rv);
79 0 : if (NS_FAILED(rv)) {
80 0 : return rv;
81 : }
82 0 : mNSEvent = do_QueryInterface(mInner, &rv);
83 0 : if (NS_FAILED(rv)) {
84 0 : return rv;
85 : }
86 0 : return mPrivate->SetTrusted(true);
87 : }
88 :
89 : // nsSmartCard Specific methods
90 0 : NS_IMETHODIMP nsSmartCardEvent::GetTokenName(nsAString &aTokenName)
91 : {
92 0 : aTokenName = mTokenName;
93 0 : return NS_OK;
94 : }
95 :
96 : // nsIPrivateDOMEvent maps
97 0 : NS_IMETHODIMP nsSmartCardEvent::DuplicatePrivateData(void)
98 : {
99 0 : NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
100 0 : return mPrivate->DuplicatePrivateData();
101 : }
102 :
103 0 : NS_IMETHODIMP nsSmartCardEvent::SetTarget(nsIDOMEventTarget *aTarget)
104 : {
105 0 : NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
106 0 : return mPrivate->SetTarget(aTarget);
107 : }
108 :
109 0 : NS_IMETHODIMP_(bool ) nsSmartCardEvent::IsDispatchStopped()
110 : {
111 0 : NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
112 0 : return mPrivate->IsDispatchStopped();
113 : }
114 :
115 0 : NS_IMETHODIMP_(nsEvent*) nsSmartCardEvent::GetInternalNSEvent()
116 : {
117 0 : NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
118 0 : return mPrivate->GetInternalNSEvent();
119 : }
120 :
121 0 : NS_IMETHODIMP nsSmartCardEvent::SetTrusted(bool aResult)
122 : {
123 0 : NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
124 0 : return mPrivate->SetTrusted(aResult);
125 : }
126 :
127 : void
128 0 : nsSmartCardEvent::Serialize(IPC::Message* aMsg,
129 : bool aSerializeInterfaceType)
130 : {
131 0 : NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
132 0 : mPrivate->Serialize(aMsg, aSerializeInterfaceType);
133 0 : }
134 :
135 : bool
136 0 : nsSmartCardEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
137 : {
138 0 : NS_ASSERTION(mPrivate, "SmartCardEvent called without Init");
139 0 : return mPrivate->Deserialize(aMsg, aIter);
140 : }
141 :
142 : // IDOMNSEvent maps
143 0 : NS_IMETHODIMP nsSmartCardEvent::GetOriginalTarget(nsIDOMEventTarget * *aOriginalTarget)
144 : {
145 0 : NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
146 0 : return mNSEvent->GetOriginalTarget(aOriginalTarget);
147 : }
148 :
149 0 : NS_IMETHODIMP nsSmartCardEvent::GetExplicitOriginalTarget(nsIDOMEventTarget * *aTarget)
150 : {
151 0 : NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
152 0 : return mNSEvent->GetExplicitOriginalTarget(aTarget);
153 : }
154 :
155 0 : NS_IMETHODIMP nsSmartCardEvent::PreventBubble(void)
156 : {
157 0 : NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
158 0 : return mNSEvent->PreventBubble();
159 : }
160 :
161 0 : NS_IMETHODIMP nsSmartCardEvent::PreventCapture(void)
162 : {
163 0 : NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
164 0 : return mNSEvent->PreventCapture();
165 : }
166 :
167 0 : NS_IMETHODIMP nsSmartCardEvent::GetIsTrusted(bool *aIsTrusted)
168 : {
169 0 : NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
170 0 : return mNSEvent->GetIsTrusted(aIsTrusted);
171 : }
172 :
173 : NS_IMETHODIMP
174 0 : nsSmartCardEvent::GetPreventDefault(bool* aReturn)
175 : {
176 0 : NS_ASSERTION(mNSEvent, "SmartCardEvent called without Init");
177 0 : return mNSEvent->GetPreventDefault(aReturn);
178 : }
179 :
180 : // IDOMEvent maps
181 0 : NS_IMETHODIMP nsSmartCardEvent::GetType(nsAString & aType)
182 : {
183 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
184 0 : return mInner->GetType(aType);
185 : }
186 :
187 0 : NS_IMETHODIMP nsSmartCardEvent::GetTarget(nsIDOMEventTarget * *aTarget)
188 : {
189 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
190 0 : return mInner->GetTarget(aTarget);
191 : }
192 :
193 0 : NS_IMETHODIMP nsSmartCardEvent::GetCurrentTarget(nsIDOMEventTarget * *aCurrentTarget)
194 : {
195 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
196 0 : return mInner->GetCurrentTarget(aCurrentTarget);
197 : }
198 :
199 0 : NS_IMETHODIMP nsSmartCardEvent::GetEventPhase(PRUint16 *aEventPhase)
200 : {
201 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
202 0 : return mInner->GetEventPhase(aEventPhase);
203 : }
204 :
205 0 : NS_IMETHODIMP nsSmartCardEvent::GetBubbles(bool *aBubbles)
206 : {
207 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
208 0 : return mInner->GetBubbles(aBubbles);
209 : }
210 :
211 0 : NS_IMETHODIMP nsSmartCardEvent::GetCancelable(bool *aCancelable)
212 : {
213 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
214 0 : return mInner->GetCancelable(aCancelable);
215 : }
216 :
217 0 : NS_IMETHODIMP nsSmartCardEvent::GetTimeStamp(DOMTimeStamp *aTimeStamp)
218 : {
219 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
220 0 : return mInner->GetTimeStamp(aTimeStamp);
221 : }
222 :
223 0 : NS_IMETHODIMP nsSmartCardEvent::StopPropagation()
224 : {
225 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
226 0 : return mInner->StopPropagation();
227 : }
228 :
229 0 : NS_IMETHODIMP nsSmartCardEvent::StopImmediatePropagation()
230 : {
231 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
232 0 : return mInner->StopImmediatePropagation();
233 : }
234 :
235 0 : NS_IMETHODIMP nsSmartCardEvent::PreventDefault()
236 : {
237 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
238 0 : return mInner->PreventDefault();
239 : }
240 :
241 0 : NS_IMETHODIMP nsSmartCardEvent::GetDefaultPrevented(bool* aReturn)
242 : {
243 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
244 0 : return mInner->GetDefaultPrevented(aReturn);
245 : }
246 :
247 0 : NS_IMETHODIMP nsSmartCardEvent::InitEvent(const nsAString & eventTypeArg, bool canBubbleArg, bool cancelableArg)
248 : {
249 0 : NS_ASSERTION(mInner, "SmartCardEvent called without Init");
250 0 : return mInner->InitEvent(eventTypeArg, canBubbleArg, cancelableArg);
251 : }
252 :
|