#ifndef __USER_LOGIN_VIEW_H__
#define __USER_LOGIN_VIEW_H__

#include "UserItem.h"
#include <gtkmm.h>
#include "ImageButton.h"

class UserLoginView : public Gtk::Box {
public:
    UserLoginView();
    virtual ~UserLoginView();

    void setUserName(const Glib::ustring& name);

    void focusEntry();

    void requestSwitchUser();

    void resetFocus();

    sigc::signal<void> signalSwitchUser();
    
private:
    void initLoginButton();
    void initSwitchUserButton();
    bool onLoginButtonPress(GdkEventButton* event);
    bool onSwitchUserButtonPress(GdkEventButton* event);
    bool onSwitchUserKeyPress(GdkEventKey* event);
    void onEntryActive();
    void onSessionFailed();
    void onMessage(Glib::ustring text, int type);
    void onPrompt(Glib::ustring text, int type);
    void onLoginFailed();
    void realDoLogin();
    void realDoSwitchUser();
    bool delayLogin();

private:
    UserItem m_userItem;

    bool m_isOtherUser;
    int m_loginCount;
    int m_delaySecs;

    Gtk::Box m_inputEntryArea;
    Gtk::Entry m_inputEntry;
    Gtk::Label m_errMsgBox;
    ImageButton m_loginBtn;

    Gtk::Overlay m_switchUserArea;
    Gtk::Label m_switchUserLbl;
    ImageButton m_switchUserButton;

    sigc::signal<void> m_switchUserSig;

    sigc::connection m_sigSessionFailedIter;
    sigc::connection m_sigPromptIter;
    sigc::connection m_sigMsgIter;
    sigc::connection m_sigAuthFailedIter;

    sigc::connection m_sigEntryActiveIter;
    sigc::connection m_sigLoginPressIter;
    sigc::connection m_sigSwitchPressIter;
    sigc::connection m_sigSwitchKeyPressIter;
};

#endif // __USER_LOGIN_VIEW_H__