Line data Source code
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/. */
6 :
7 : #include "PaymentActionResponse.h"
8 : #include "nsIRunnable.h"
9 :
10 : namespace mozilla {
11 : namespace dom {
12 :
13 : /* PaymentActionResponse */
14 :
15 0 : NS_IMPL_ISUPPORTS(PaymentActionResponse,
16 : nsIPaymentActionResponse)
17 :
18 0 : PaymentActionResponse::PaymentActionResponse()
19 0 : : mRequestId(EmptyString())
20 0 : , mType(nsIPaymentActionResponse::NO_TYPE)
21 : {
22 0 : }
23 :
24 : NS_IMETHODIMP
25 0 : PaymentActionResponse::GetRequestId(nsAString& aRequestId)
26 : {
27 0 : aRequestId = mRequestId;
28 0 : return NS_OK;
29 : }
30 :
31 : NS_IMETHODIMP
32 0 : PaymentActionResponse::GetType(uint32_t* aType)
33 : {
34 0 : NS_ENSURE_ARG_POINTER(aType);
35 0 : *aType = mType;
36 0 : return NS_OK;
37 : }
38 :
39 : /* PaymentCanMakeActionResponse */
40 :
41 0 : NS_IMPL_ISUPPORTS_INHERITED(PaymentCanMakeActionResponse,
42 : PaymentActionResponse,
43 : nsIPaymentCanMakeActionResponse)
44 :
45 0 : PaymentCanMakeActionResponse::PaymentCanMakeActionResponse()
46 : {
47 0 : mType = nsIPaymentActionResponse::CANMAKE_ACTION;
48 0 : }
49 :
50 : NS_IMETHODIMP
51 0 : PaymentCanMakeActionResponse::GetResult(bool* aResult)
52 : {
53 0 : NS_ENSURE_ARG_POINTER(aResult);
54 0 : *aResult = mResult;
55 0 : return NS_OK;
56 : }
57 :
58 : NS_IMETHODIMP
59 0 : PaymentCanMakeActionResponse::Init(const nsAString& aRequestId, const bool aResult)
60 : {
61 0 : mRequestId = aRequestId;
62 0 : mResult = aResult;
63 0 : return NS_OK;
64 : }
65 :
66 : /* PaymentShowActionResponse */
67 :
68 0 : NS_IMPL_ISUPPORTS_INHERITED(PaymentShowActionResponse,
69 : PaymentActionResponse,
70 : nsIPaymentShowActionResponse)
71 :
72 0 : PaymentShowActionResponse::PaymentShowActionResponse()
73 : {
74 0 : mType = nsIPaymentActionResponse::SHOW_ACTION;
75 0 : }
76 :
77 : NS_IMETHODIMP
78 0 : PaymentShowActionResponse::GetAcceptStatus(uint32_t* aAcceptStatus)
79 : {
80 0 : NS_ENSURE_ARG_POINTER(aAcceptStatus);
81 0 : *aAcceptStatus = mAcceptStatus;
82 0 : return NS_OK;
83 : }
84 :
85 : NS_IMETHODIMP
86 0 : PaymentShowActionResponse::GetMethodName(nsAString& aMethodName)
87 : {
88 0 : aMethodName = mMethodName;
89 0 : return NS_OK;
90 : }
91 :
92 : NS_IMETHODIMP
93 0 : PaymentShowActionResponse::GetData(nsAString& aData)
94 : {
95 0 : aData = mData;
96 0 : return NS_OK;
97 : }
98 :
99 : NS_IMETHODIMP
100 0 : PaymentShowActionResponse::GetPayerName(nsAString& aPayerName)
101 : {
102 0 : aPayerName = mPayerName;
103 0 : return NS_OK;
104 : }
105 :
106 : NS_IMETHODIMP
107 0 : PaymentShowActionResponse::GetPayerEmail(nsAString& aPayerEmail)
108 : {
109 0 : aPayerEmail = mPayerEmail;
110 0 : return NS_OK;
111 : }
112 :
113 : NS_IMETHODIMP
114 0 : PaymentShowActionResponse::GetPayerPhone(nsAString& aPayerPhone)
115 : {
116 0 : aPayerPhone = mPayerPhone;
117 0 : return NS_OK;
118 : }
119 :
120 : NS_IMETHODIMP
121 0 : PaymentShowActionResponse::Init(const nsAString& aRequestId,
122 : const uint32_t aAcceptStatus,
123 : const nsAString& aMethodName,
124 : const nsAString& aData,
125 : const nsAString& aPayerName,
126 : const nsAString& aPayerEmail,
127 : const nsAString& aPayerPhone)
128 : {
129 0 : mRequestId = aRequestId;
130 0 : mAcceptStatus = aAcceptStatus;
131 0 : mMethodName = aMethodName;
132 0 : mData = aData;
133 0 : mPayerName = aPayerName;
134 0 : mPayerEmail = aPayerEmail;
135 0 : mPayerPhone = aPayerPhone;
136 0 : return NS_OK;
137 : }
138 :
139 : NS_IMETHODIMP
140 0 : PaymentShowActionResponse::IsAccepted(bool* aIsAccepted)
141 : {
142 0 : NS_ENSURE_ARG_POINTER(aIsAccepted);
143 0 : *aIsAccepted = (mAcceptStatus == nsIPaymentActionResponse::PAYMENT_ACCEPTED);
144 0 : return NS_OK;
145 : }
146 :
147 : /* PaymentAbortActionResponse */
148 :
149 0 : NS_IMPL_ISUPPORTS_INHERITED(PaymentAbortActionResponse,
150 : PaymentActionResponse,
151 : nsIPaymentAbortActionResponse)
152 :
153 0 : PaymentAbortActionResponse::PaymentAbortActionResponse()
154 : {
155 0 : mType = nsIPaymentActionResponse::ABORT_ACTION;
156 0 : }
157 :
158 : NS_IMETHODIMP
159 0 : PaymentAbortActionResponse::GetAbortStatus(uint32_t* aAbortStatus)
160 : {
161 0 : NS_ENSURE_ARG_POINTER(aAbortStatus);
162 0 : *aAbortStatus = mAbortStatus;
163 0 : return NS_OK;
164 : }
165 :
166 : NS_IMETHODIMP
167 0 : PaymentAbortActionResponse::Init(const nsAString& aRequestId,
168 : const uint32_t aAbortStatus)
169 : {
170 0 : mRequestId = aRequestId;
171 0 : mAbortStatus = aAbortStatus;
172 0 : return NS_OK;
173 : }
174 :
175 : NS_IMETHODIMP
176 0 : PaymentAbortActionResponse::IsSucceeded(bool* aIsSucceeded)
177 : {
178 0 : NS_ENSURE_ARG_POINTER(aIsSucceeded);
179 0 : *aIsSucceeded = (mAbortStatus == nsIPaymentActionResponse::ABORT_SUCCEEDED);
180 0 : return NS_OK;
181 : }
182 :
183 : /* PaymentCompleteActionResponse */
184 :
185 0 : NS_IMPL_ISUPPORTS_INHERITED(PaymentCompleteActionResponse,
186 : PaymentActionResponse,
187 : nsIPaymentCompleteActionResponse)
188 :
189 0 : PaymentCompleteActionResponse::PaymentCompleteActionResponse()
190 : {
191 0 : mType = nsIPaymentActionResponse::COMPLETE_ACTION;
192 0 : }
193 :
194 : nsresult
195 0 : PaymentCompleteActionResponse::Init(const nsAString& aRequestId,
196 : const uint32_t aCompleteStatus)
197 : {
198 0 : mRequestId = aRequestId;
199 0 : mCompleteStatus = aCompleteStatus;
200 0 : return NS_OK;
201 : }
202 :
203 : nsresult
204 0 : PaymentCompleteActionResponse::GetCompleteStatus(uint32_t* aCompleteStatus)
205 : {
206 0 : NS_ENSURE_ARG_POINTER(aCompleteStatus);
207 0 : *aCompleteStatus = mCompleteStatus;
208 0 : return NS_OK;
209 : }
210 :
211 : nsresult
212 0 : PaymentCompleteActionResponse::IsCompleted(bool* aIsCompleted)
213 : {
214 0 : NS_ENSURE_ARG_POINTER(aIsCompleted);
215 0 : *aIsCompleted = (mCompleteStatus == nsIPaymentActionResponse::COMPLETE_SUCCEEDED);
216 0 : return NS_OK;
217 : }
218 :
219 : } // end of namespace dom
220 : } // end of namespace mozilla
|