repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / haikudepot / ui / UserLoginWindow.h
blob6d529e717e523431dabe5a4d51885dffa6fd4b23
1 /*
2 * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #ifndef USER_LOGIN_WINDOW_H
6 #define USER_LOGIN_WINDOW_H
8 #include <Locker.h>
9 #include <Messenger.h>
10 #include <Window.h>
12 #include "PackageInfo.h"
15 class BButton;
16 class BMenuField;
17 class BTabView;
18 class BTextControl;
19 class BitmapView;
20 class Model;
23 class UserLoginWindow : public BWindow {
24 public:
25 UserLoginWindow(BWindow* parent, BRect frame,
26 Model& model);
27 virtual ~UserLoginWindow();
29 virtual void MessageReceived(BMessage* message);
31 void SetOnSuccessMessage(
32 const BMessenger& messenger,
33 const BMessage& message);
35 private:
36 enum Mode {
37 NONE = 0,
38 LOGIN,
39 CREATE_ACCOUNT
42 void _SetMode(Mode mode);
43 bool _ValidateCreateAccountFields(
44 bool alertProblems = false);
45 void _Login();
46 void _CreateAccount();
47 void _RequestCaptcha();
48 void _LoginSuccessful(const BString& message);
50 void _SetWorkerThread(thread_id thread);
52 static int32 _AuthenticateThreadEntry(void* data);
53 void _AuthenticateThread();
55 static int32 _RequestCaptchaThreadEntry(void* data);
56 void _RequestCaptchaThread();
58 static int32 _CreateAccountThreadEntry(void* data);
59 void _CreateAccountThread();
61 void _CollectValidationFailures(
62 const BMessage& result,
63 BString& error) const;
65 private:
66 BMessenger fOnSuccessTarget;
67 BMessage fOnSuccessMessage;
69 BTabView* fTabView;
71 BTextControl* fUsernameField;
72 BTextControl* fPasswordField;
74 BTextControl* fNewUsernameField;
75 BTextControl* fNewPasswordField;
76 BTextControl* fRepeatPasswordField;
77 BTextControl* fEmailField;
78 BMenuField* fLanguageCodeField;
79 BitmapView* fCaptchaView;
80 BTextControl* fCaptchaResultField;
82 BButton* fSendButton;
83 BButton* fCancelButton;
85 BString fCaptchaToken;
86 BitmapRef fCaptchaImage;
87 BString fPreferredLanguage;
89 Model& fModel;
91 Mode fMode;
93 BLocker fLock;
94 thread_id fWorkerThread;
98 #endif // USER_LOGIN_WINDOW_H