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