xref: /haiku/src/apps/haikudepot/model/CreateUserDetail.cpp (revision 142723d1970b2c76f9c70311edb88b13b7b2019e)
1 /*
2  * Copyright 2019-2024, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5  #include "CreateUserDetail.h"
6 
7  // These are keys that are used to store this object's data into a BMessage
8  // instance.
9 
10 #define KEY_NICKNAME							"nickname"
11 #define KEY_PASSWORD_CLEAR						"passwordClear"
12 #define KEY_IS_PASSWORD_REPEATED				"isPasswordRepeated"
13 #define KEY_EMAIL								"email"
14 #define KEY_CAPTCHA_TOKEN						"captchaToken"
15 #define KEY_CAPTCHA_RESPONSE					"captchaResponse"
16 #define KEY_LANGUAGE_ID							"languageId"
17 #define KEY_AGREED_USER_USAGE_CONDITIONS_CODE	"agreedUserUsageConditionsCode"
18 
19 
20 CreateUserDetail::CreateUserDetail(BMessage* from)
21 {
22 	from->FindString(KEY_NICKNAME, &fNickname);
23 	from->FindString(KEY_PASSWORD_CLEAR, &fPasswordClear);
24 	from->FindBool(KEY_IS_PASSWORD_REPEATED, &fIsPasswordRepeated);
25 	from->FindString(KEY_EMAIL, &fEmail);
26 	from->FindString(KEY_CAPTCHA_TOKEN, &fCaptchaToken);
27 	from->FindString(KEY_CAPTCHA_RESPONSE, &fCaptchaResponse);
28 	from->FindString(KEY_LANGUAGE_ID, &fLanguageId);
29 	from->FindString(KEY_AGREED_USER_USAGE_CONDITIONS_CODE,
30 		&fAgreedUserUsageConditionsCode);
31 }
32 
33 
34 CreateUserDetail::CreateUserDetail()
35 	:
36 	fIsPasswordRepeated(false)
37 {
38 }
39 
40 
41 CreateUserDetail::~CreateUserDetail()
42 {
43 }
44 
45 
46 const BString&
47 CreateUserDetail::Nickname() const
48 {
49 	return fNickname;
50 }
51 
52 
53 const BString&
54 CreateUserDetail::PasswordClear() const
55 {
56 	return fPasswordClear;
57 }
58 
59 
60 bool
61 CreateUserDetail::IsPasswordRepeated() const
62 {
63 	return fIsPasswordRepeated;
64 }
65 
66 
67 const BString&
68 CreateUserDetail::Email() const
69 {
70 	return fEmail;
71 }
72 
73 
74 const BString&
75 CreateUserDetail::CaptchaToken() const
76 {
77 	return fCaptchaToken;
78 }
79 
80 
81 const BString&
82 CreateUserDetail::CaptchaResponse() const
83 {
84 	return fCaptchaResponse;
85 }
86 
87 
88 const BString&
89 CreateUserDetail::LanguageId() const
90 {
91 	return fLanguageId;
92 }
93 
94 
95 const BString&
96 CreateUserDetail::AgreedToUserUsageConditionsCode() const
97 {
98 	return fAgreedUserUsageConditionsCode;
99 }
100 
101 
102 void
103 CreateUserDetail::SetNickname(const BString& value)
104 {
105 	fNickname = value;
106 }
107 
108 
109 void
110 CreateUserDetail::SetPasswordClear(const BString& value)
111 {
112 	fPasswordClear = value;
113 }
114 
115 
116 void
117 CreateUserDetail::SetIsPasswordRepeated(bool value)
118 {
119 	fIsPasswordRepeated = value;
120 }
121 
122 
123 void
124 CreateUserDetail::SetEmail(const BString& value)
125 {
126 	fEmail = value;
127 }
128 
129 
130 void
131 CreateUserDetail::SetCaptchaToken(const BString& value)
132 {
133 	fCaptchaToken = value;
134 }
135 
136 
137 void
138 CreateUserDetail::SetCaptchaResponse(const BString& value)
139 {
140 	fCaptchaResponse = value;
141 }
142 
143 
144 void
145 CreateUserDetail::SetLanguageId(const BString& value)
146 {
147 	fLanguageId = value;
148 }
149 
150 
151 void
152 CreateUserDetail::SetAgreedToUserUsageConditionsCode(const BString& value)
153 {
154 	fAgreedUserUsageConditionsCode = value;
155 }
156 
157 
158 status_t
159 CreateUserDetail::Archive(BMessage* into, bool deep) const
160 {
161 	status_t result = B_OK;
162 	if (result == B_OK)
163 		result = into->AddString(KEY_NICKNAME, fNickname);
164 	if (result == B_OK)
165 		result = into->AddString(KEY_PASSWORD_CLEAR, fPasswordClear);
166 	if (result == B_OK)
167 		result = into->AddBool(KEY_IS_PASSWORD_REPEATED, fIsPasswordRepeated);
168 	if (result == B_OK)
169 		result = into->AddString(KEY_EMAIL, fEmail);
170 	if (result == B_OK)
171 		result = into->AddString(KEY_CAPTCHA_TOKEN, fCaptchaToken);
172 	if (result == B_OK)
173 		result = into->AddString(KEY_CAPTCHA_RESPONSE, fCaptchaResponse);
174 	if (result == B_OK)
175 		result = into->AddString(KEY_LANGUAGE_ID, fLanguageId);
176 	if (result == B_OK) {
177 		result = into->AddString(KEY_AGREED_USER_USAGE_CONDITIONS_CODE,
178 			fAgreedUserUsageConditionsCode);
179 	}
180 	return result;
181 }