summaryrefslogtreecommitdiff
diff options
authorAndrea Azzarone <azzaronea@gmail.com>2016-06-23 16:51:42 +0200
committerAndrea Azzarone <azzaronea@gmail.com>2016-06-23 16:51:42 +0200
commitb4f995af7b2fc6dfcd3f27d865a67dbe3ff8228b (patch)
tree20d61a2fc8fd66503fd7cfb4f53d7c09fe5f8331
parent254df95731bab6ea64b7884c8dbe38f3cd37d43b (diff)
Fix style.
(bzr r4130.1.4)
-rw-r--r--lockscreen/UserPromptView.cpp55
-rw-r--r--lockscreen/UserPromptView.h5
2 files changed, 26 insertions, 34 deletions
diff --git a/lockscreen/UserPromptView.cpp b/lockscreen/UserPromptView.cpp
index c3811085a..3abb6c25a 100644
--- a/lockscreen/UserPromptView.cpp
+++ b/lockscreen/UserPromptView.cpp
@@ -142,8 +142,7 @@ UserPromptView::UserPromptView(session::Manager::Ptr const& session_manager)
UpdateSize();
ResetLayout();
- user_authenticator_.AuthenticateStart(session_manager_->UserName(),
- sigc::mem_fun(this, &UserPromptView::AuthenticationCb));
+ StartAuthentication();
}
void UserPromptView::UpdateSize()
@@ -277,37 +276,20 @@ void UserPromptView::AuthenticationCb(bool is_authenticated)
if (is_authenticated)
{
if (prompted_ && !unacknowledged_messages_)
- {
- session_manager_->unlock_requested.emit();
- }
+ DoUnlock();
else
- {
- prompted_ = true;
-
- unacknowledged_messages_ = false;
ShowAuthenticated(true);
- }
}
else
{
if (prompted_)
{
AddMessage(_("Invalid password, please try again"), nux::color::Red);
-
- prompted_ = false;
- unacknowledged_messages_ = false;
-
- user_authenticator_.AuthenticateStart(session_manager_->UserName(),
- sigc::mem_fun(this, &UserPromptView::AuthenticationCb));
+ StartAuthentication();
}
else
{
- if (!unacknowledged_messages_)
- AddMessage(_("Failed to authenticate"), nux::color::Red);
-
- prompted_ = true;
- unacknowledged_messages_ = false;
-
+ AddMessage(_("Failed to authenticate"), nux::color::Red);
ShowAuthenticated(false);
}
}
@@ -471,21 +453,30 @@ void UserPromptView::AddButton(std::string const& text, std::function<void()> co
void UserPromptView::ShowAuthenticated(bool successful)
{
+ prompted_ = true;
+ unacknowledged_messages_ = false;
+
if (successful)
- AddButton(_("Unlock"), [this]() {
- session_manager_->unlock_requested.emit();
- });
+ AddButton(_("Unlock"), sigc::mem_fun(this, &UserPromptView::DoUnlock));
else
- AddButton(_("Retry"), [this]() {
- prompted_ = false;
- unacknowledged_messages_ = false;
-
- user_authenticator_.AuthenticateStart(session_manager_->UserName(),
- sigc::mem_fun(this, &UserPromptView::AuthenticationCb));
- });
+ AddButton(_("Retry"), sigc::mem_fun(this, &UserPromptView::StartAuthentication));
GetLayout()->AddLayout(button_layout_);
}
+void UserPromptView::StartAuthentication()
+{
+ prompted_ = false;
+ unacknowledged_messages_ = false;
+
+ user_authenticator_.AuthenticateStart(session_manager_->UserName(),
+ sigc::mem_fun(this, &UserPromptView::AuthenticationCb));
+}
+
+void UserPromptView::DoUnlock()
+{
+ session_manager_->unlock_requested.emit();
+}
+
}
}
diff --git a/lockscreen/UserPromptView.h b/lockscreen/UserPromptView.h
index 562440e8a..e0d4f9be1 100644
--- a/lockscreen/UserPromptView.h
+++ b/lockscreen/UserPromptView.h
@@ -60,6 +60,7 @@ public:
protected:
void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) override;
void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) override;
+ bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character) override;
private:
void ResetLayout();
@@ -67,8 +68,8 @@ private:
void EnsureBGLayer();
void ShowAuthenticated(bool successful);
-
- bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);
+ void StartAuthentication();
+ void DoUnlock();
session::Manager::Ptr session_manager_;
UserAuthenticatorPam user_authenticator_;